[Mlir-commits] [mlir] dfb70c3 - [mlir][EmitC] Remove `func.constant` from emitter (#82342)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Feb 20 05:16:38 PST 2024
Author: Marius Brehler
Date: 2024-02-20T14:16:34+01:00
New Revision: dfb70c3a7c65cd5143c942ad8a18f4177c16d74e
URL: https://github.com/llvm/llvm-project/commit/dfb70c3a7c65cd5143c942ad8a18f4177c16d74e
DIFF: https://github.com/llvm/llvm-project/commit/dfb70c3a7c65cd5143c942ad8a18f4177c16d74e.diff
LOG: [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.
Added:
Modified:
mlir/docs/Dialects/emitc.md
mlir/lib/Target/Cpp/TranslateToCpp.cpp
Removed:
################################################################################
diff --git a/mlir/docs/Dialects/emitc.md b/mlir/docs/Dialects/emitc.md
index 809a04660336b0..b227a8c4599a8f 100644
--- a/mlir/docs/Dialects/emitc.md
+++ b/mlir/docs/Dialects/emitc.md
@@ -28,7 +28,6 @@ translating the following operations:
* `cf.cond_br`
* 'func' Dialect
* `func.call`
- * `func.constant`
* `func.func`
* `func.return`
* 'arith' Dialect
diff --git a/mlir/lib/Target/Cpp/TranslateToCpp.cpp b/mlir/lib/Target/Cpp/TranslateToCpp.cpp
index e27fddc2c61017..2ba3dec0a9a57f 100644
--- a/mlir/lib/Target/Cpp/TranslateToCpp.cpp
+++ b/mlir/lib/Target/Cpp/TranslateToCpp.cpp
@@ -331,14 +331,6 @@ static LogicalResult printOperation(CppEmitter &emitter,
return printConstantOp(emitter, operation, value);
}
-static LogicalResult printOperation(CppEmitter &emitter,
- func::ConstantOp constantOp) {
- Operation *operation = constantOp.getOperation();
- Attribute value = constantOp.getValueAttr();
-
- return printConstantOp(emitter, operation, value);
-}
-
static LogicalResult printOperation(CppEmitter &emitter,
emitc::AssignOp assignOp) {
auto variableOp = cast<emitc::VariableOp>(assignOp.getVar().getDefiningOp());
@@ -1296,7 +1288,7 @@ LogicalResult CppEmitter::emitOperation(Operation &op, bool trailingSemicolon) {
emitc::SubOp, emitc::VariableOp, emitc::VerbatimOp>(
[&](auto op) { return printOperation(*this, op); })
// Func ops.
- .Case<func::CallOp, func::ConstantOp, func::FuncOp, func::ReturnOp>(
+ .Case<func::CallOp, func::FuncOp, func::ReturnOp>(
[&](auto op) { return printOperation(*this, op); })
// Arithmetic ops.
.Case<arith::ConstantOp>(
More information about the Mlir-commits
mailing list