[Mlir-commits] [mlir] [mlir][IR] Add `getPropertyFromAttr` and `setPropertyFromAttr` methods. (PR #150060)

Fabian Mora llvmlistbot at llvm.org
Thu Jul 24 05:47:46 PDT 2025


fabianmcg wrote:

> So: properties don't have a mnemnonic and registration for their parsing logic, but in general they can be parsed/printed if you know the class you want to parse/print I think.
> Look at the `let parser` and `let printer` in the property class in ODS.

Yes, they can be parsed in the context of an op, but there's still no method to do it outside an op.

To use a similar example, yes, we can parse attrtype parameters with a `FieldParser`, but there's no generic parameter parsing logic because it doesn't make sense, they are meant to be parsed inside attrs or types, not as a standalone units.

> What is the meaning of an Attribute?
> That is for example what difference to you make between EnumProp and EnumAttr?

Attrs are a mechanism to specify constant information, the specific semantics are defined by the attr itself [1], and they have a well defined syntax inside the IR.

Now, wrt the second question. An `EnumAttr` has semantics and syntax outside an operation. I'd argue that a `EnumProp` currently only gains meaning inside an operation [2]. Further, I'd argue that a valuable comparison is that a `Prop` is like a attr/type parameter for operations, so an impl detail to information of a prop. We can change this, but AFAICT this is the status quo.

[1] https://mlir.llvm.org/docs/LangRef/#attributes
[2] https://mlir.llvm.org/docs/LangRef/#properties


https://github.com/llvm/llvm-project/pull/150060


More information about the Mlir-commits mailing list