[Mlir-commits] [mlir] [mlir] Refactor opaque properties to make them type-safe (PR #185157)

Krzysztof Drewniak llvmlistbot at llvm.org
Fri Mar 20 11:53:36 PDT 2026


krzysz00 wrote:

@kuhar This is the part that gets finicky and where I'm trying to order this relative to future work people have convinced me to do.

Namely, the idea of there being some auxiliary struct, called something like `PropertyDesc`, where all the parsers/printers/... (and maybe something like interface attachments) live, which'd form an Operation/Attribute-style hierarchy. These'd be the sort of thing you could register in the MLIR context, and I'm hoping that C++ templates behave well enough to allow 

```
template<typename WrappedProp>
struct OptionalPropDesc<WrappedProp> : ConcretePropertyDesc<...> {
  using InterfaceType = std::optional<WrappedProp::InterfaceType>;
  ...
  void print(const InterfaceType&, OpAsmPrinter&) { ... }
};
```
and the like to behave. I've sketched a bunch of this out in https://github.com/llvm/llvm-project/issues/183798 

But then the question becomes whether `PropertyRef` carries around a reference to the registered descriptor or no - and if not, whether there's some third thing that does ... maybe bring back `OpaqueProperty` as a name for that.

---

But also I think we can't move to LLVM-style casts without making the type the rather silly `PropertyRef<T>` because types like `int64_t` aren't part of the LLVM RTTI system.

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


More information about the Mlir-commits mailing list