Lines Matching refs:ast

36   CodeGen(MLIRContext *mlirContext, const ast::Context &context,  in CodeGen()
44 OwningOpRef<ModuleOp> generate(const ast::Module &module);
52 Type genType(ast::Type type);
55 void gen(const ast::Node *node);
61 void genImpl(const ast::CompoundStmt *stmt);
62 void genImpl(const ast::EraseStmt *stmt);
63 void genImpl(const ast::LetStmt *stmt);
64 void genImpl(const ast::ReplaceStmt *stmt);
65 void genImpl(const ast::RewriteStmt *stmt);
66 void genImpl(const ast::ReturnStmt *stmt);
72 void genImpl(const ast::UserConstraintDecl *decl);
73 void genImpl(const ast::UserRewriteDecl *decl);
74 void genImpl(const ast::PatternDecl *decl);
78 SmallVector<Value> genVar(const ast::VariableDecl *varDecl);
83 Value genNonInitializerVar(const ast::VariableDecl *varDecl, Location loc);
87 void applyVarConstraints(const ast::VariableDecl *varDecl, ValueRange values);
93 Value genSingleExpr(const ast::Expr *expr);
94 SmallVector<Value> genExpr(const ast::Expr *expr);
95 Value genExprImpl(const ast::AttributeExpr *expr);
96 SmallVector<Value> genExprImpl(const ast::CallExpr *expr);
97 SmallVector<Value> genExprImpl(const ast::DeclRefExpr *expr);
98 Value genExprImpl(const ast::MemberAccessExpr *expr);
99 Value genExprImpl(const ast::OperationExpr *expr);
100 SmallVector<Value> genExprImpl(const ast::TupleExpr *expr);
101 Value genExprImpl(const ast::TypeExpr *expr);
103 SmallVector<Value> genConstraintCall(const ast::UserConstraintDecl *decl,
105 SmallVector<Value> genRewriteCall(const ast::UserRewriteDecl *decl,
120 llvm::ScopedHashTable<const ast::VariableDecl *, SmallVector<Value>>;
131 OwningOpRef<ModuleOp> CodeGen::generate(const ast::Module &module) { in generate()
137 for (const ast::Decl *decl : module.getChildren()) in generate()
158 Type CodeGen::genType(ast::Type type) { in genType()
159 return TypeSwitch<ast::Type, Type>(type) in genType()
160 .Case([&](ast::AttributeType astType) -> Type { in genType()
163 .Case([&](ast::OperationType astType) -> Type { in genType()
166 .Case([&](ast::TypeType astType) -> Type { in genType()
169 .Case([&](ast::ValueType astType) -> Type { in genType()
172 .Case([&](ast::RangeType astType) -> Type { in genType()
177 void CodeGen::gen(const ast::Node *node) { in gen()
178 TypeSwitch<const ast::Node *>(node) in gen()
179 .Case<const ast::CompoundStmt, const ast::EraseStmt, const ast::LetStmt, in gen()
180 const ast::ReplaceStmt, const ast::RewriteStmt, in gen()
181 const ast::ReturnStmt, const ast::UserConstraintDecl, in gen()
182 const ast::UserRewriteDecl, const ast::PatternDecl>( in gen()
184 .Case([&](const ast::Expr *expr) { genExpr(expr); }); in gen()
191 void CodeGen::genImpl(const ast::CompoundStmt *stmt) { in genImpl()
193 for (const ast::Stmt *childStmt : stmt->getChildren()) in genImpl()
210 void CodeGen::genImpl(const ast::EraseStmt *stmt) { in genImpl()
221 void CodeGen::genImpl(const ast::LetStmt *stmt) { genVar(stmt->getVarDecl()); } in genImpl()
223 void CodeGen::genImpl(const ast::ReplaceStmt *stmt) { in genImpl()
233 for (ast::Expr *replExpr : stmt->getReplExprs()) in genImpl()
246 void CodeGen::genImpl(const ast::RewriteStmt *stmt) { in genImpl()
256 void CodeGen::genImpl(const ast::ReturnStmt *stmt) { in genImpl()
265 void CodeGen::genImpl(const ast::UserConstraintDecl *decl) { in genImpl()
271 void CodeGen::genImpl(const ast::UserRewriteDecl *decl) { in genImpl()
277 void CodeGen::genImpl(const ast::PatternDecl *decl) { in genImpl()
278 const ast::Name *name = decl->getName(); in genImpl()
291 SmallVector<Value> CodeGen::genVar(const ast::VariableDecl *varDecl) { in genVar()
299 if (const ast::Expr *initExpr = varDecl->getInitExpr()) in genVar()
311 Value CodeGen::genNonInitializerVar(const ast::VariableDecl *varDecl, in genNonInitializerVar()
315 for (const ast::ConstraintRef &constraint : varDecl->getConstraints()) { in genNonInitializerVar()
317 TypeSwitch<const ast::Node *, Value>(constraint.constraint) in genNonInitializerVar()
318 .Case<ast::AttrConstraintDecl, ast::ValueConstraintDecl, in genNonInitializerVar()
319 ast::ValueRangeConstraintDecl>( in genNonInitializerVar()
333 ast::Type type = varDecl->getType(); in genNonInitializerVar()
335 if (type.isa<ast::ValueType>()) in genNonInitializerVar()
337 if (type.isa<ast::TypeType>()) in genNonInitializerVar()
339 if (type.isa<ast::AttributeType>()) in genNonInitializerVar()
341 if (ast::OperationType opType = type.dyn_cast<ast::OperationType>()) { in genNonInitializerVar()
352 if (ast::RangeType rangeTy = type.dyn_cast<ast::RangeType>()) { in genNonInitializerVar()
353 ast::Type eleTy = rangeTy.getElementType(); in genNonInitializerVar()
354 if (eleTy.isa<ast::ValueType>()) in genNonInitializerVar()
357 if (eleTy.isa<ast::TypeType>()) in genNonInitializerVar()
364 void CodeGen::applyVarConstraints(const ast::VariableDecl *varDecl, in applyVarConstraints()
368 for (const ast::ConstraintRef &ref : varDecl->getConstraints()) in applyVarConstraints()
369 if (const auto *userCst = dyn_cast<ast::UserConstraintDecl>(ref.constraint)) in applyVarConstraints()
377 Value CodeGen::genSingleExpr(const ast::Expr *expr) { in genSingleExpr()
378 return TypeSwitch<const ast::Expr *, Value>(expr) in genSingleExpr()
379 .Case<const ast::AttributeExpr, const ast::MemberAccessExpr, in genSingleExpr()
380 const ast::OperationExpr, const ast::TypeExpr>( in genSingleExpr()
382 .Case<const ast::CallExpr, const ast::DeclRefExpr, const ast::TupleExpr>( in genSingleExpr()
390 SmallVector<Value> CodeGen::genExpr(const ast::Expr *expr) { in genExpr()
391 return TypeSwitch<const ast::Expr *, SmallVector<Value>>(expr) in genExpr()
392 .Case<const ast::CallExpr, const ast::DeclRefExpr, const ast::TupleExpr>( in genExpr()
394 .Default([&](const ast::Expr *expr) -> SmallVector<Value> { in genExpr()
399 Value CodeGen::genExprImpl(const ast::AttributeExpr *expr) { in genExprImpl()
405 SmallVector<Value> CodeGen::genExprImpl(const ast::CallExpr *expr) { in genExprImpl()
408 for (const ast::Expr *arg : expr->getArguments()) in genExprImpl()
412 auto *callableExpr = dyn_cast<ast::DeclRefExpr>(expr->getCallableExpr()); in genExprImpl()
416 const ast::Decl *callable = callableExpr->getDecl(); in genExprImpl()
417 if (const auto *decl = dyn_cast<ast::UserConstraintDecl>(callable)) in genExprImpl()
419 if (const auto *decl = dyn_cast<ast::UserRewriteDecl>(callable)) in genExprImpl()
424 SmallVector<Value> CodeGen::genExprImpl(const ast::DeclRefExpr *expr) { in genExprImpl()
425 if (const auto *varDecl = dyn_cast<ast::VariableDecl>(expr->getDecl())) in genExprImpl()
430 Value CodeGen::genExprImpl(const ast::MemberAccessExpr *expr) { in genExprImpl()
434 ast::Type parentType = expr->getParentExpr()->getType(); in genExprImpl()
437 if (ast::OperationType opType = parentType.dyn_cast<ast::OperationType>()) { in genExprImpl()
438 if (isa<ast::AllResultsMemberAccessExpr>(expr)) { in genExprImpl()
477 if (auto tupleType = parentType.dyn_cast<ast::TupleType>()) { in genExprImpl()
494 Value CodeGen::genExprImpl(const ast::OperationExpr *expr) { in genExprImpl()
500 for (const ast::Expr *operand : expr->getOperands()) in genExprImpl()
506 for (const ast::NamedAttributeDecl *attr : expr->getAttributes()) { in genExprImpl()
513 for (const ast::Expr *result : expr->getResultTypes()) in genExprImpl()
520 SmallVector<Value> CodeGen::genExprImpl(const ast::TupleExpr *expr) { in genExprImpl()
522 for (const ast::Expr *element : expr->getElements()) in genExprImpl()
527 Value CodeGen::genExprImpl(const ast::TypeExpr *expr) { in genExprImpl()
536 CodeGen::genConstraintCall(const ast::UserConstraintDecl *decl, Location loc, in genConstraintCall()
553 SmallVector<Value> CodeGen::genRewriteCall(const ast::UserRewriteDecl *decl, in genRewriteCall()
563 const ast::CompoundStmt *cstBody = decl->getBody(); in genConstraintOrRewriteCall()
567 ast::Type declResultType = decl->getResultType(); in genConstraintOrRewriteCall()
569 if (ast::TupleType tupleType = declResultType.dyn_cast<ast::TupleType>()) { in genConstraintOrRewriteCall()
570 for (ast::Type type : tupleType.getElementTypes()) in genConstraintOrRewriteCall()
595 auto *returnStmt = dyn_cast<ast::ReturnStmt>(cstBody->getChildren().back()); in genConstraintOrRewriteCall()
608 MLIRContext *mlirContext, const ast::Context &context, in codegenPDLLToMLIR()
609 const llvm::SourceMgr &sourceMgr, const ast::Module &module) { in codegenPDLLToMLIR()