[Mlir-commits] [mlir] [mlir-python] Emit only dialect `EnumAttr` registrations. (PR #117918)

Jacques Pienaar llvmlistbot at llvm.org
Thu Dec 5 23:35:59 PST 2024


jpienaar wrote:

> As far as I know there's no way to limit which TD files are considered during generation because they behave just like headers right? So the "preprocessor" injects the headers and only then do we get the TU (or whatever). 

Close, TD files aren't textually included as one would with preprocessor. The origin is retained by SourceMgr.

What I was thinking/suggestion above was something like https://github.com/jpienaar/llvm-project/pull/new/pyenum , so filtering on origin file and making it act on it (that change is larger than it should be as GPU dialect has an enum section ... and then has most of their enums in a different file and that just felt wrong). This is how attributes and types are handled. Unfortunately neither enum generator does that. I think it is a nice organization mechanism that makes things more regular, makes what is acted on explicit/unambigous (especially as many of the enums don't have a dialect associated trivially).

One could still do the dialect prefixing with this in the registry (although the example you showed, shows an attribute from LinalgTransformEnums.td as in builtin dialect so not sure about the heuristic :)). And I was thinking if one could do something more automatic by associating ops with the nearest Dialect definition in include path. But that heuristic could be too magical.

WDYT about making it explicit via file acted on as the other? (could also just be focused on Python side).

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


More information about the Mlir-commits mailing list