[Mlir-commits] [mlir] [mlir][EmitC] Remove `func.constant` from emitter (PR #82342)
Marius Brehler
llvmlistbot at llvm.org
Tue Feb 20 03:14:34 PST 2024
https://github.com/marbre created https://github.com/llvm/llvm-project/pull/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.
>From ccf3d175298601d4043f3f851f29b5e74e147540 Mon Sep 17 00:00:00 2001
From: Marius Brehler <marius.brehler at iml.fraunhofer.de>
Date: Tue, 20 Feb 2024 11:07:09 +0000
Subject: [PATCH] [mlir][EmitC] Remove `func.constant` from emitter
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.
---
mlir/docs/Dialects/emitc.md | 1 -
mlir/lib/Target/Cpp/TranslateToCpp.cpp | 10 +---------
2 files changed, 1 insertion(+), 10 deletions(-)
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