diff --git a/mlir/docs/Dialects/emitc.md b/mlir/docs/Dialects/emitc.md --- a/mlir/docs/Dialects/emitc.md +++ b/mlir/docs/Dialects/emitc.md @@ -29,6 +29,7 @@ * 'func' Dialect * `func.call` * `func.constant` + * `func.func` * `func.return` * 'scf' Dialect * `scf.for` diff --git a/mlir/lib/Target/Cpp/TranslateToCpp.cpp b/mlir/lib/Target/Cpp/TranslateToCpp.cpp --- a/mlir/lib/Target/Cpp/TranslateToCpp.cpp +++ b/mlir/lib/Target/Cpp/TranslateToCpp.cpp @@ -574,7 +574,8 @@ return success(); } -static LogicalResult printOperation(CppEmitter &emitter, FuncOp functionOp) { +static LogicalResult printOperation(CppEmitter &emitter, + func::FuncOp functionOp) { // We need to declare variables at top if the function has multiple blocks. if (!emitter.shouldDeclareVariablesAtTop() && functionOp.getBlocks().size() > 1) { @@ -911,8 +912,7 @@ LogicalResult status = llvm::TypeSwitch<Operation *, LogicalResult>(&op) // Builtin ops. - .Case<FuncOp, ModuleOp>( - [&](auto op) { return printOperation(*this, op); }) + .Case<ModuleOp>([&](auto op) { return printOperation(*this, op); }) // CF ops. .Case<cf::BranchOp, cf::CondBranchOp>( [&](auto op) { return printOperation(*this, op); }) @@ -921,7 +921,7 @@ emitc::IncludeOp, emitc::VariableOp>( [&](auto op) { return printOperation(*this, op); }) // Func ops. - .Case<func::CallOp, func::ConstantOp, func::ReturnOp>( + .Case<func::CallOp, func::ConstantOp, func::FuncOp, func::ReturnOp>( [&](auto op) { return printOperation(*this, op); }) // SCF ops. .Case<scf::ForOp, scf::IfOp, scf::YieldOp>(