This revision adds support to the declarative parser for formatting enum attributes in the symbolized form. It uses this new functionality to port several of the SPIRV parsers over to the declarative form.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Nice! Thanks River for adding support for this!
mlir/tools/mlir-tblgen/OpFormatGen.cpp | ||
---|---|---|
301 | Do we want to specify none type here? It should parse as a string attr for start and we later reply on that for symbolize the string. |
mlir/tools/mlir-tblgen/OpFormatGen.cpp | ||
---|---|---|
301 | Without specifying a type, the parser of StringAttr will check for an optional colon type which isn't a desirable. Passing NoneType makes sure that we only parse the string value. |
This is great! Would it be possible to parse keywords into enum attrs as well?
Actually, what's the general feeling about using keywords vs strings for enum values? I think I prefer keywords a little more, it's less noisy and its distinguished from an actual string in the textual representation. Also, it seems like LLVM IR has 'keywords' (they aren't wrapped in quotes) for many enums.
I think we could, but we would need additional checks given that only a subset of enums can actually be represented with a keyword. BitEnums would be completely out, but that is to be expected. For the others we would need to check dynamically if the case value can be parsed in as a keyword. I say dynamically instead of statically because it would be really awful if you added a new enum case that wasn't conforming and then had to update all of your existing tests.
Do we want to specify none type here? It should parse as a string attr for start and we later reply on that for symbolize the string.