[Mlir-commits] [mlir] Add a polynomial dialect shell, attributes, and types (PR #72081)

Oleksandr Alex Zinenko llvmlistbot at llvm.org
Sun Apr 7 23:59:55 PDT 2024


================
@@ -0,0 +1,19 @@
+set(LLVM_TARGET_DEFINITIONS PolynomialOps.td)
+mlir_tablegen(PolynomialDialect.cpp.inc -gen-dialect-defs -dialect=polynomial)
+mlir_tablegen(PolynomialDialect.h.inc -gen-dialect-decls -dialect=polynomial)
+add_public_tablegen_target(MLIRPolynomialDialectIncGen)
+
+mlir_tablegen(PolynomialAttributes.cpp.inc -gen-attrdef-defs -attrdefs-dialect=polynomial)
+mlir_tablegen(PolynomialAttributes.h.inc -gen-attrdef-decls -attrdefs-dialect=polynomial)
+mlir_tablegen(PolynomialOps.cpp.inc -gen-op-defs)
+mlir_tablegen(PolynomialOps.h.inc -gen-op-decls)
+mlir_tablegen(PolynomialTypes.cpp.inc -gen-typedef-defs -typedefs-dialect=polynomial)
+mlir_tablegen(PolynomialTypes.h.inc -gen-typedef-decls -typedefs-dialect=polynomial)
+add_public_tablegen_target(MLIRPolynomialAttributesIncGen)
+add_public_tablegen_target(MLIRPolynomialOpsIncGen)
+add_public_tablegen_target(MLIRPolynomialTypesIncGen)
----------------
ftynse wrote:

This looks incorrect. IIUC, tablegen commands are stateful. Specifically, one first has to set `LLVM_TARGET_DEFINITIONS` to point to the source .td, then list generation rules in individual `mlir_tablegen` commands, and finally `add_public_tablegen_target` to name that. Here, all commands will be run against `PolynomialOps.td`, and all included in the `MLIRPolynomialAttributesIncGen`.

This _accidentally_ works because `PolynomialOps.td` transitively includes other `.td` files, but we shouldn't rely on this.

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


More information about the Mlir-commits mailing list