[Mlir-commits] [mlir] [mlir][IR] Add `getPropertyAsAttr` and `setPropertyFromAttr` methods. (PR #150060)
Krzysztof Drewniak
llvmlistbot at llvm.org
Tue Jul 29 08:59:39 PDT 2025
krzysz00 wrote:
> IMO, the semantics and meaning of an attr are owned by the attr, while for a prop they are owned (let's say jointly) by the op.
I'm going to disagree with that one. Attributes and non-attribute properties are both means of storing data of same type T. The semantics of the attribute/property are determined by what data type is being stored there - ops have nothing to do with it.
The main distinction is that non-attribute properties lean on the C++ type system directly for how they're stored, while attributes have this whole mechanism where they gen uniqued into the context. The other useful point is that there is an attribute hierarchy (everything is a subclass of `Attribute`), while non-attribute/native properties don't have such a common superclass.
The lack of that superclass is *why* all properties have to be convertible to an Attribute - if you need to work with all the fields in an arbitrary Properties struct, all you can really do is to convert said struct to a collection of name/attribute pairs.
Side note re parsing: one could (maybe should) gather up the `let parser` (and perhaps `let printer`s) from all the non-attribute properties in scope and unique them the way we unique property or attribute constraints.
https://github.com/llvm/llvm-project/pull/150060
More information about the Mlir-commits
mailing list