[Mlir-commits] [mlir] [mlir] Add struct parsing and printing utilities (PR #133939)
Jorn Tuyls
llvmlistbot at llvm.org
Thu Apr 3 10:41:31 PDT 2025
jtuyls wrote:
> Instead of adding more c++ code, did you consider just expanding what the struct directive in tablegen can support? Why not extend that to support using a custom directive for the individual fields? This is generally what we have done when the declarative form is lacking something, try and extend that first.
Yes, I briefly thought about that and tried something like `struct(field1, custom<Field2>(field2))`, but I ran into the current assumption that these directives have top-level context and it felt like a larger change to reconsider that as this potentially opens up a bunch of nested variations of directives that need to be supported or properly excluded:
```
custom<Field1>(field1, custom<Field2>(field2))
struct(field1, struct(field2, field3), field4) -> probably doesn't make sense, or maybe it does as a nested dictionary or so?
custom<Field1>(field1, struct(field2, field3)) -> probably doesn't make sense?
...
```
The assumption that this is a larger change might be misguided though as I am not too familiar with tablegen (yet).
Additionally, I didn't see these two approaches as mutually exclusive as some fully custom printer/parser that can't be represented with the above directives might want to reuse these utilities as well for a part of it.
Anyway, if the declarative form is the way to go or if you want both implementations, I am happy to implement the nested directives as well.
https://github.com/llvm/llvm-project/pull/133939
More information about the Mlir-commits
mailing list