Hi, I am working on a setup where I have 2 Dialect: A stable, API-like dialect, let’s call it ToyStable dialect, and a more experimental, fast-changing dialect, let’s call it ToyInternal dialect.
I want to reuse some of the enums / attributes / types defined in ToyStable from ToyInternal.
I tried writing this in ToyInternalOps.td:
include "path/to/ToyStableBase.td"
Is this something supported in MLIR ? I might not have looked well enough, but I couldn’t find any example of one dialect td file including another dialect td file. (With the exception of the Builtin Dialect).
I came across one issue I couldn’t solve. The linker complains about multiple definition
duplicate symbol 'mlir::toy_stable::symbolizeMyToyEnum(unsigned int)' in:
src/Dialect/ToyStable/IR/libMLIRToyStable.a
src/Dialect/ToyInternal/IR/libMLIRToyInternal.a
This is because of this rule:
set(LLVM_TARGET_DEFINITIONS ToyInternalOps.td)
mlir_tablegen(Enums.h.inc -gen-enum-decls)
mlir_tablegen(Enums.cpp.inc -gen-enum-defs)
ToyInternalOps.td contains the ToyStable enums, and generate their definition. I was hoping to have an option equivalent to -attrdefs-dialect=xxx
, but for enums. But it seems such option doesn’t exist. Is it missing ?
Another solution would be to create ToyStableEnums.td, ToyStableAttrs.td, ToyStableTypes.td, and update LLVM_TARGET_DEFINITIONS for every mlir_tablegen rule, but if feels like too much division. And I haven’t seen any upstream dialect having this many TD files.
Do you have any other ideas / suggestions. Perhaps my overall design could be improved.
Thanks.