[Mlir-commits] [mlir] [mlir][EmitC]Allow Fields to have initial values (PR #151437)
Jacques Pienaar
llvmlistbot at llvm.org
Thu Jul 31 00:46:45 PDT 2025
================
@@ -1659,13 +1659,23 @@ def EmitC_FieldOp : EmitC_Op<"field", [Symbol]> {
emitc.field @fieldName0 : !emitc.array<1xf32> {emitc.opaque = "another_feature"}
// Example with no attribute:
emitc.field @fieldName0 : !emitc.array<1xf32>
+ // Example with an initial value:
+ emitc.field @fieldName0 : !emitc.array<1xf32> = dense<0.0>
+ // Example with an initial value and attributes:
+ emitc.field @fieldName0 : !emitc.array<1xf32> = dense<0.0> {
+ emitc.opaque = "input_tensor"}
```
}];
let arguments = (ins SymbolNameAttr:$sym_name, TypeAttr:$type,
+ OptionalAttr<EmitC_OpaqueOrTypedAttr>:$initial_value,
OptionalAttr<AnyAttr>:$attrs);
----------------
jpienaar wrote:
Having an explicit attrs attribute is different from attr-dict which is something all ops have. They are called discardable attributes (attr-dict), but they aren't discarded randomly, it mostly means "not semantically meaningful to the op". Here I think you are actually using it for a short lived ID between two passes you control (or maybe not even more?), so probably good to remove as it doesn't carry any semantics.
https://github.com/llvm/llvm-project/pull/151437
More information about the Mlir-commits
mailing list