[Mlir-commits] [mlir] [mlir][ODS] Add namespace filtering to `-gen-enum-*` (PR #89627)
Markus Böck
llvmlistbot at llvm.org
Tue Apr 23 02:14:19 PDT 2024
zero9178 wrote:
> > This is problematic if a dialect depends on another dialect and therefore transitively #includes another dialects enums: The declarations and definitions of the enum will be generated in both dialects and therefore lead to likely a compiler error and a guaranteed linker error.
>
> It's not clear to me that this is actually a problem, isn't it is just a matter of organization of the .td files:
>
> * `Dialect.td` : defines the dialect.
> * `Enums.td`: include the dialect, defines the enums.
> * `Ops.td`: uses the dialect and the enums.
I see this partially as more of a workaround in some scenarios and insuffiecent in some scenarios. We have TableGen classes that take an `EnumAttrInfo` as parameter for the purpose of type safety that require us to `include Enums.td` in the corresponding attribute, type and/or op definition files [0]. As soon as we then include the `Enums.td` in these it is also transitively included in all other dialects using that dialects attributes, types or ops.
Personally, if I define an enum for the purpose of being used in just on op/attr/type I'd also rather have it defined right next to the given entity.
[0] See `EnumParameter` or `EnumAttr`
https://github.com/llvm/llvm-project/pull/89627
More information about the Mlir-commits
mailing list