Skip to content

Commit dfb70c3

Browse files
authored
[mlir][EmitC] Remove func.constant from emitter (#82342)
As part of the renaming the Standard dialect to Func dialect, *support* for the `func.constant` operation was added to the emitter. However, the emitter cannot emit function types. Hence the emission for a snippet like ``` %0 = func.constant @myFN : (f32) -> f32 func.func private @myFN(%arg0: f32) -> f32 { return %arg0 : f32 } ``` failes with `func.mlir:1:6: error: cannot emit type '(f32) -> f32'`. This removes `func.constant` from the emitter.
1 parent ddba6b2 commit dfb70c3

File tree

2 files changed

+1
-10
lines changed

2 files changed

+1
-10
lines changed

mlir/docs/Dialects/emitc.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ translating the following operations:
2828
* `cf.cond_br`
2929
* 'func' Dialect
3030
* `func.call`
31-
* `func.constant`
3231
* `func.func`
3332
* `func.return`
3433
* 'arith' Dialect

mlir/lib/Target/Cpp/TranslateToCpp.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -331,14 +331,6 @@ static LogicalResult printOperation(CppEmitter &emitter,
331331
return printConstantOp(emitter, operation, value);
332332
}
333333

334-
static LogicalResult printOperation(CppEmitter &emitter,
335-
func::ConstantOp constantOp) {
336-
Operation *operation = constantOp.getOperation();
337-
Attribute value = constantOp.getValueAttr();
338-
339-
return printConstantOp(emitter, operation, value);
340-
}
341-
342334
static LogicalResult printOperation(CppEmitter &emitter,
343335
emitc::AssignOp assignOp) {
344336
auto variableOp = cast<emitc::VariableOp>(assignOp.getVar().getDefiningOp());
@@ -1296,7 +1288,7 @@ LogicalResult CppEmitter::emitOperation(Operation &op, bool trailingSemicolon) {
12961288
emitc::SubOp, emitc::VariableOp, emitc::VerbatimOp>(
12971289
[&](auto op) { return printOperation(*this, op); })
12981290
// Func ops.
1299-
.Case<func::CallOp, func::ConstantOp, func::FuncOp, func::ReturnOp>(
1291+
.Case<func::CallOp, func::FuncOp, func::ReturnOp>(
13001292
[&](auto op) { return printOperation(*this, op); })
13011293
// Arithmetic ops.
13021294
.Case<arith::ConstantOp>(

0 commit comments

Comments
 (0)