For AttrDef declarations, place specified code in extraClassDefinition into the generated *.cpp.inc file.
Details
Diff Detail
Event Timeline
Please add a test in attrdefs.td and add documentation to docs/AttributesAndTypes.md.
| mlir/include/mlir/IR/AttrTypeBase.td | ||
|---|---|---|
| 220 | Use class instead of attribute, this tablegen class is for both attributes and types. | |
Thanks for the review! Could you commit it for me? I do not have commit access.
| mlir/include/mlir/TableGen/AttrOrTypeDef.h | ||
|---|---|---|
| 114 | Weird. Might've come from the clang-format on my system. Reverted it. | |
| mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp | ||
|---|---|---|
| 238 | I had initially done that but ran into some lifetime issue with the underlying string for the definition which resulted in printing of a lot of garbage in the generated .inc file. So that's why I moved it into the class definition. I'll look into this again, maybe I missed something then | |
| mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp | ||
|---|---|---|
| 238 | The field is a StringRef so you can change that in ExtraClassDeclaration. | |
| mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp | ||
|---|---|---|
| 238 | done, thank you! | |
Two minor comments. Otherwise LG. Thanks for making this!
| mlir/include/mlir/TableGen/Class.h | ||
|---|---|---|
| 557 ↗ | (On Diff #445398) | extraClassDeclaration doesn't need to be std::string since it has no format requirements and can reference the TableGen string safely |
| mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp | ||
| 240 | The string isn't needed afterwards and can be moved into the object | |
Addressed additional comments. Thanks for the review! Could you please commit it for me?
?