From 485cc55edfb875628e19bb6d9de4706af2865d3e Mon Sep 17 00:00:00 2001 From: Stella Laurenzo Date: Mon, 28 Jun 2021 22:54:11 +0000 Subject: [PATCH] [mlir] Generare .cpp.inc files for dialects. * Previously, we were only generating .h.inc files. We foresee the need to also generate implementations and this is a step towards that. * Discussed in https://llvm.discourse.group/t/generating-cpp-inc-files-for-dialects/3732/2 * Deviates from the discussion above by generating a default constructor in the .cpp.inc file (and adding a tablegen bit that disables this in case if this is user provided). * Generating the destructor started as a way to flush out the missing includes (produces a link error), but it is a strict improvement on its own that is worth doing (i.e. by emitting key methods in the .cpp file, we root vtables in one translation unit, which is a non-controversial improvement). Differential Revision: https://reviews.llvm.org/D105070 --- mlir/cmake/modules/AddMLIR.cmake | 1 + .../lib/Standalone/StandaloneDialect.cpp | 2 + mlir/examples/toy/Ch2/include/toy/CMakeLists.txt | 1 + mlir/examples/toy/Ch2/mlir/Dialect.cpp | 2 + mlir/examples/toy/Ch3/include/toy/CMakeLists.txt | 1 + mlir/examples/toy/Ch3/mlir/Dialect.cpp | 2 + mlir/examples/toy/Ch4/include/toy/CMakeLists.txt | 1 + mlir/examples/toy/Ch4/mlir/Dialect.cpp | 2 + mlir/examples/toy/Ch5/include/toy/CMakeLists.txt | 1 + mlir/examples/toy/Ch5/mlir/Dialect.cpp | 2 + mlir/examples/toy/Ch6/include/toy/CMakeLists.txt | 1 + mlir/examples/toy/Ch6/mlir/Dialect.cpp | 2 + mlir/examples/toy/Ch7/include/toy/CMakeLists.txt | 1 + mlir/examples/toy/Ch7/mlir/Dialect.cpp | 2 + mlir/include/mlir/Dialect/LLVMIR/CMakeLists.txt | 1 + mlir/include/mlir/Dialect/OpenACC/CMakeLists.txt | 1 + mlir/include/mlir/Dialect/OpenMP/CMakeLists.txt | 1 + .../mlir/Dialect/StandardOps/IR/CMakeLists.txt | 1 + mlir/include/mlir/IR/CMakeLists.txt | 1 + mlir/include/mlir/IR/OpBase.td | 4 + mlir/include/mlir/TableGen/Dialect.h | 6 +- mlir/lib/Dialect/AMX/IR/AMXDialect.cpp | 2 + mlir/lib/Dialect/Affine/IR/AffineOps.cpp | 2 + mlir/lib/Dialect/ArmNeon/IR/ArmNeonDialect.cpp | 2 + mlir/lib/Dialect/ArmSVE/IR/ArmSVEDialect.cpp | 2 + mlir/lib/Dialect/Async/IR/Async.cpp | 2 + mlir/lib/Dialect/Complex/IR/ComplexDialect.cpp | 2 + mlir/lib/Dialect/DLTI/DLTI.cpp | 2 + mlir/lib/Dialect/EmitC/IR/EmitC.cpp | 2 + mlir/lib/Dialect/GPU/IR/GPUDialect.cpp | 2 + mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp | 2 + mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp | 2 + mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp | 2 + mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp | 2 + mlir/lib/Dialect/Math/IR/MathDialect.cpp | 2 + mlir/lib/Dialect/MemRef/IR/MemRefDialect.cpp | 2 + mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp | 2 + mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp | 1 + mlir/lib/Dialect/PDL/IR/PDL.cpp | 2 + mlir/lib/Dialect/PDLInterp/IR/PDLInterp.cpp | 2 + mlir/lib/Dialect/Quant/IR/QuantOps.cpp | 2 + mlir/lib/Dialect/SCF/SCF.cpp | 2 + mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp | 2 + mlir/lib/Dialect/Shape/IR/Shape.cpp | 2 + .../SparseTensor/IR/SparseTensorDialect.cpp | 2 + mlir/lib/Dialect/StandardOps/IR/Ops.cpp | 2 + mlir/lib/Dialect/Tensor/IR/TensorDialect.cpp | 2 + mlir/lib/Dialect/Tosa/IR/TosaOps.cpp | 2 + mlir/lib/Dialect/Vector/VectorOps.cpp | 1 + mlir/lib/Dialect/X86Vector/IR/X86VectorDialect.cpp | 2 + mlir/lib/IR/BuiltinDialect.cpp | 2 + mlir/lib/TableGen/Dialect.cpp | 4 + mlir/test/lib/Dialect/Test/CMakeLists.txt | 1 + mlir/test/lib/Dialect/Test/TestDialect.cpp | 2 + mlir/test/lib/Dialect/Test/TestOps.td | 3 +- mlir/tools/mlir-tblgen/DialectGen.cpp | 96 +++++++++--- utils/bazel/llvm-project-overlay/mlir/BUILD.bazel | 174 +++++++++++++++++++++ .../llvm-project-overlay/mlir/test/BUILD.bazel | 7 + 58 files changed, 355 insertions(+), 26 deletions(-) diff --git a/mlir/cmake/modules/AddMLIR.cmake b/mlir/cmake/modules/AddMLIR.cmake index 81bb528..109ac46 100644 --- a/mlir/cmake/modules/AddMLIR.cmake +++ b/mlir/cmake/modules/AddMLIR.cmake @@ -15,6 +15,7 @@ function(add_mlir_dialect dialect dialect_namespace) mlir_tablegen(${dialect}Types.h.inc -gen-typedef-decls) mlir_tablegen(${dialect}Types.cpp.inc -gen-typedef-defs) mlir_tablegen(${dialect}Dialect.h.inc -gen-dialect-decls -dialect=${dialect_namespace}) + mlir_tablegen(${dialect}Dialect.cpp.inc -gen-dialect-defs -dialect=${dialect_namespace}) add_public_tablegen_target(MLIR${dialect}IncGen) add_dependencies(mlir-headers MLIR${dialect}IncGen) endfunction() diff --git a/mlir/examples/standalone/lib/Standalone/StandaloneDialect.cpp b/mlir/examples/standalone/lib/Standalone/StandaloneDialect.cpp index acdf88a..cdd9337 100644 --- a/mlir/examples/standalone/lib/Standalone/StandaloneDialect.cpp +++ b/mlir/examples/standalone/lib/Standalone/StandaloneDialect.cpp @@ -12,6 +12,8 @@ using namespace mlir; using namespace mlir::standalone; +#include "Standalone/StandaloneOpsDialect.cpp.inc" + //===----------------------------------------------------------------------===// // Standalone dialect. //===----------------------------------------------------------------------===// diff --git a/mlir/examples/toy/Ch2/include/toy/CMakeLists.txt b/mlir/examples/toy/Ch2/include/toy/CMakeLists.txt index 26a0eb1..301baaf 100644 --- a/mlir/examples/toy/Ch2/include/toy/CMakeLists.txt +++ b/mlir/examples/toy/Ch2/include/toy/CMakeLists.txt @@ -2,4 +2,5 @@ set(LLVM_TARGET_DEFINITIONS Ops.td) mlir_tablegen(Ops.h.inc -gen-op-decls) mlir_tablegen(Ops.cpp.inc -gen-op-defs) mlir_tablegen(Dialect.h.inc -gen-dialect-decls) +mlir_tablegen(Dialect.cpp.inc -gen-dialect-defs) add_public_tablegen_target(ToyCh2OpsIncGen) diff --git a/mlir/examples/toy/Ch2/mlir/Dialect.cpp b/mlir/examples/toy/Ch2/mlir/Dialect.cpp index 9327aaf..5213d33 100644 --- a/mlir/examples/toy/Ch2/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch2/mlir/Dialect.cpp @@ -20,6 +20,8 @@ using namespace mlir; using namespace mlir::toy; +#include "toy/Dialect.cpp.inc" + //===----------------------------------------------------------------------===// // ToyDialect //===----------------------------------------------------------------------===// diff --git a/mlir/examples/toy/Ch3/include/toy/CMakeLists.txt b/mlir/examples/toy/Ch3/include/toy/CMakeLists.txt index 15bb98c..a233f5d 100644 --- a/mlir/examples/toy/Ch3/include/toy/CMakeLists.txt +++ b/mlir/examples/toy/Ch3/include/toy/CMakeLists.txt @@ -2,4 +2,5 @@ set(LLVM_TARGET_DEFINITIONS Ops.td) mlir_tablegen(Ops.h.inc -gen-op-decls) mlir_tablegen(Ops.cpp.inc -gen-op-defs) mlir_tablegen(Dialect.h.inc -gen-dialect-decls) +mlir_tablegen(Dialect.cpp.inc -gen-dialect-defs) add_public_tablegen_target(ToyCh3OpsIncGen) diff --git a/mlir/examples/toy/Ch3/mlir/Dialect.cpp b/mlir/examples/toy/Ch3/mlir/Dialect.cpp index 9327aaf..5213d33 100644 --- a/mlir/examples/toy/Ch3/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch3/mlir/Dialect.cpp @@ -20,6 +20,8 @@ using namespace mlir; using namespace mlir::toy; +#include "toy/Dialect.cpp.inc" + //===----------------------------------------------------------------------===// // ToyDialect //===----------------------------------------------------------------------===// diff --git a/mlir/examples/toy/Ch4/include/toy/CMakeLists.txt b/mlir/examples/toy/Ch4/include/toy/CMakeLists.txt index f2de562..acf7e31 100644 --- a/mlir/examples/toy/Ch4/include/toy/CMakeLists.txt +++ b/mlir/examples/toy/Ch4/include/toy/CMakeLists.txt @@ -3,6 +3,7 @@ set(LLVM_TARGET_DEFINITIONS Ops.td) mlir_tablegen(Ops.h.inc -gen-op-decls) mlir_tablegen(Ops.cpp.inc -gen-op-defs) mlir_tablegen(Dialect.h.inc -gen-dialect-decls) +mlir_tablegen(Dialect.cpp.inc -gen-dialect-defs) add_public_tablegen_target(ToyCh4OpsIncGen) # Most dialects should use add_mlir_interfaces(). diff --git a/mlir/examples/toy/Ch4/mlir/Dialect.cpp b/mlir/examples/toy/Ch4/mlir/Dialect.cpp index dd82e04..ff1d4cd 100644 --- a/mlir/examples/toy/Ch4/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch4/mlir/Dialect.cpp @@ -21,6 +21,8 @@ using namespace mlir; using namespace mlir::toy; +#include "toy/Dialect.cpp.inc" + //===----------------------------------------------------------------------===// // ToyInlinerInterface //===----------------------------------------------------------------------===// diff --git a/mlir/examples/toy/Ch5/include/toy/CMakeLists.txt b/mlir/examples/toy/Ch5/include/toy/CMakeLists.txt index 10313c9..7d51dd9 100644 --- a/mlir/examples/toy/Ch5/include/toy/CMakeLists.txt +++ b/mlir/examples/toy/Ch5/include/toy/CMakeLists.txt @@ -3,6 +3,7 @@ set(LLVM_TARGET_DEFINITIONS Ops.td) mlir_tablegen(Ops.h.inc -gen-op-decls) mlir_tablegen(Ops.cpp.inc -gen-op-defs) mlir_tablegen(Dialect.h.inc -gen-dialect-decls) +mlir_tablegen(Dialect.cpp.inc -gen-dialect-defs) add_public_tablegen_target(ToyCh5OpsIncGen) # Most dialects should use add_mlir_interfaces(). diff --git a/mlir/examples/toy/Ch5/mlir/Dialect.cpp b/mlir/examples/toy/Ch5/mlir/Dialect.cpp index 18d5985..89e7529 100644 --- a/mlir/examples/toy/Ch5/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch5/mlir/Dialect.cpp @@ -21,6 +21,8 @@ using namespace mlir; using namespace mlir::toy; +#include "toy/Dialect.cpp.inc" + //===----------------------------------------------------------------------===// // ToyInlinerInterface //===----------------------------------------------------------------------===// diff --git a/mlir/examples/toy/Ch6/include/toy/CMakeLists.txt b/mlir/examples/toy/Ch6/include/toy/CMakeLists.txt index 4c54020..03e8a2a 100644 --- a/mlir/examples/toy/Ch6/include/toy/CMakeLists.txt +++ b/mlir/examples/toy/Ch6/include/toy/CMakeLists.txt @@ -3,6 +3,7 @@ set(LLVM_TARGET_DEFINITIONS Ops.td) mlir_tablegen(Ops.h.inc -gen-op-decls) mlir_tablegen(Ops.cpp.inc -gen-op-defs) mlir_tablegen(Dialect.h.inc -gen-dialect-decls) +mlir_tablegen(Dialect.cpp.inc -gen-dialect-defs) add_public_tablegen_target(ToyCh6OpsIncGen) # Most dialects should use add_mlir_interfaces(). diff --git a/mlir/examples/toy/Ch6/mlir/Dialect.cpp b/mlir/examples/toy/Ch6/mlir/Dialect.cpp index 18d5985..89e7529 100644 --- a/mlir/examples/toy/Ch6/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch6/mlir/Dialect.cpp @@ -21,6 +21,8 @@ using namespace mlir; using namespace mlir::toy; +#include "toy/Dialect.cpp.inc" + //===----------------------------------------------------------------------===// // ToyInlinerInterface //===----------------------------------------------------------------------===// diff --git a/mlir/examples/toy/Ch7/include/toy/CMakeLists.txt b/mlir/examples/toy/Ch7/include/toy/CMakeLists.txt index 3ff7633..7712e42 100644 --- a/mlir/examples/toy/Ch7/include/toy/CMakeLists.txt +++ b/mlir/examples/toy/Ch7/include/toy/CMakeLists.txt @@ -3,6 +3,7 @@ set(LLVM_TARGET_DEFINITIONS Ops.td) mlir_tablegen(Ops.h.inc -gen-op-decls) mlir_tablegen(Ops.cpp.inc -gen-op-defs) mlir_tablegen(Dialect.h.inc -gen-dialect-decls) +mlir_tablegen(Dialect.cpp.inc -gen-dialect-defs) add_public_tablegen_target(ToyCh7OpsIncGen) # Most dialects should use add_mlir_interfaces(). diff --git a/mlir/examples/toy/Ch7/mlir/Dialect.cpp b/mlir/examples/toy/Ch7/mlir/Dialect.cpp index 28f5435..30d473f 100644 --- a/mlir/examples/toy/Ch7/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch7/mlir/Dialect.cpp @@ -22,6 +22,8 @@ using namespace mlir; using namespace mlir::toy; +#include "toy/Dialect.cpp.inc" + //===----------------------------------------------------------------------===// // ToyInlinerInterface //===----------------------------------------------------------------------===// diff --git a/mlir/include/mlir/Dialect/LLVMIR/CMakeLists.txt b/mlir/include/mlir/Dialect/LLVMIR/CMakeLists.txt index ff3c8e2..91754f1 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/CMakeLists.txt +++ b/mlir/include/mlir/Dialect/LLVMIR/CMakeLists.txt @@ -9,6 +9,7 @@ set(LLVM_TARGET_DEFINITIONS LLVMOps.td) mlir_tablegen(LLVMOps.h.inc -gen-op-decls) mlir_tablegen(LLVMOps.cpp.inc -gen-op-defs) mlir_tablegen(LLVMOpsDialect.h.inc -gen-dialect-decls) +mlir_tablegen(LLVMOpsDialect.cpp.inc -gen-dialect-defs) mlir_tablegen(LLVMOpsEnums.h.inc -gen-enum-decls) mlir_tablegen(LLVMOpsEnums.cpp.inc -gen-enum-defs) add_public_tablegen_target(MLIRLLVMOpsIncGen) diff --git a/mlir/include/mlir/Dialect/OpenACC/CMakeLists.txt b/mlir/include/mlir/Dialect/OpenACC/CMakeLists.txt index 5258515..241f939 100644 --- a/mlir/include/mlir/Dialect/OpenACC/CMakeLists.txt +++ b/mlir/include/mlir/Dialect/OpenACC/CMakeLists.txt @@ -4,6 +4,7 @@ add_public_tablegen_target(acc_common_td) set(LLVM_TARGET_DEFINITIONS OpenACCOps.td) mlir_tablegen(OpenACCOpsDialect.h.inc -gen-dialect-decls -dialect=acc) +mlir_tablegen(OpenACCOpsDialect.cpp.inc -gen-dialect-defs -dialect=acc) mlir_tablegen(OpenACCOps.h.inc -gen-op-decls) mlir_tablegen(OpenACCOps.cpp.inc -gen-op-defs) mlir_tablegen(OpenACCOpsEnums.h.inc -gen-enum-decls) diff --git a/mlir/include/mlir/Dialect/OpenMP/CMakeLists.txt b/mlir/include/mlir/Dialect/OpenMP/CMakeLists.txt index bbcebc0..9061499 100644 --- a/mlir/include/mlir/Dialect/OpenMP/CMakeLists.txt +++ b/mlir/include/mlir/Dialect/OpenMP/CMakeLists.txt @@ -4,6 +4,7 @@ add_public_tablegen_target(omp_common_td) set(LLVM_TARGET_DEFINITIONS OpenMPOps.td) mlir_tablegen(OpenMPOpsDialect.h.inc -gen-dialect-decls -dialect=omp) +mlir_tablegen(OpenMPOpsDialect.cpp.inc -gen-dialect-defs -dialect=omp) mlir_tablegen(OpenMPOps.h.inc -gen-op-decls) mlir_tablegen(OpenMPOps.cpp.inc -gen-op-defs) mlir_tablegen(OpenMPOpsEnums.h.inc -gen-enum-decls) diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/CMakeLists.txt b/mlir/include/mlir/Dialect/StandardOps/IR/CMakeLists.txt index 7bc39e9..c1756e9 100644 --- a/mlir/include/mlir/Dialect/StandardOps/IR/CMakeLists.txt +++ b/mlir/include/mlir/Dialect/StandardOps/IR/CMakeLists.txt @@ -2,6 +2,7 @@ set(LLVM_TARGET_DEFINITIONS Ops.td) mlir_tablegen(Ops.h.inc -gen-op-decls) mlir_tablegen(Ops.cpp.inc -gen-op-defs) mlir_tablegen(OpsDialect.h.inc -gen-dialect-decls) +mlir_tablegen(OpsDialect.cpp.inc -gen-dialect-defs) mlir_tablegen(OpsEnums.h.inc -gen-enum-decls) mlir_tablegen(OpsEnums.cpp.inc -gen-enum-defs) add_public_tablegen_target(MLIRStandardOpsIncGen) diff --git a/mlir/include/mlir/IR/CMakeLists.txt b/mlir/include/mlir/IR/CMakeLists.txt index 1a6b9c9..2757f3d 100644 --- a/mlir/include/mlir/IR/CMakeLists.txt +++ b/mlir/include/mlir/IR/CMakeLists.txt @@ -9,6 +9,7 @@ add_public_tablegen_target(MLIRBuiltinAttributesIncGen) set(LLVM_TARGET_DEFINITIONS BuiltinDialect.td) mlir_tablegen(BuiltinDialect.h.inc -gen-dialect-decls) +mlir_tablegen(BuiltinDialect.cpp.inc -gen-dialect-defs) add_public_tablegen_target(MLIRBuiltinDialectIncGen) set(LLVM_TARGET_DEFINITIONS BuiltinLocationAttributes.td) diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td index 2b17731..5989019 100644 --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -267,6 +267,10 @@ class Dialect { // If this dialect overrides the hook for materializing constants. bit hasConstantMaterializer = 0; + /// If the dialect definition provides a non-default destructor. + /// If false, a default destructor implementation will be generated. + bit hasNonDefaultDestructor = 0; + // If this dialect overrides the hook for verifying operation attributes. bit hasOperationAttrVerify = 0; diff --git a/mlir/include/mlir/TableGen/Dialect.h b/mlir/include/mlir/TableGen/Dialect.h index 609bf4e..4c5af8e 100644 --- a/mlir/include/mlir/TableGen/Dialect.h +++ b/mlir/include/mlir/TableGen/Dialect.h @@ -54,9 +54,13 @@ public: /// Returns true if this dialect has a canonicalizer. bool hasCanonicalizer() const; - // Returns true if this dialect has a constant materializer. + /// Returns true if this dialect has a constant materializer. bool hasConstantMaterializer() const; + /// Returns true if the destructor definition is provided explicitly or + /// false if a default should be generated. + bool hasNonDefaultDestructor() const; + /// Returns true if this dialect has an operation attribute verifier. bool hasOperationAttrVerify() const; diff --git a/mlir/lib/Dialect/AMX/IR/AMXDialect.cpp b/mlir/lib/Dialect/AMX/IR/AMXDialect.cpp index ab98820..c5cf1f41 100644 --- a/mlir/lib/Dialect/AMX/IR/AMXDialect.cpp +++ b/mlir/lib/Dialect/AMX/IR/AMXDialect.cpp @@ -18,6 +18,8 @@ using namespace mlir; +#include "mlir/Dialect/AMX/AMXDialect.cpp.inc" + void amx::AMXDialect::initialize() { addOperations< #define GET_OP_LIST diff --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp index 1106636..5d4db0f 100644 --- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp +++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp @@ -26,6 +26,8 @@ using namespace mlir; #define DEBUG_TYPE "affine-analysis" +#include "mlir/Dialect/Affine/IR/AffineOpsDialect.cpp.inc" + /// A utility function to check if a value is defined at the top level of /// `region` or is an argument of `region`. A value of index type defined at the /// top level of a `AffineScope` region is always a valid symbol for all diff --git a/mlir/lib/Dialect/ArmNeon/IR/ArmNeonDialect.cpp b/mlir/lib/Dialect/ArmNeon/IR/ArmNeonDialect.cpp index b8b8ebd3..b4f85ad 100644 --- a/mlir/lib/Dialect/ArmNeon/IR/ArmNeonDialect.cpp +++ b/mlir/lib/Dialect/ArmNeon/IR/ArmNeonDialect.cpp @@ -18,6 +18,8 @@ using namespace mlir; +#include "mlir/Dialect/ArmNeon/ArmNeonDialect.cpp.inc" + void arm_neon::ArmNeonDialect::initialize() { addOperations< #define GET_OP_LIST diff --git a/mlir/lib/Dialect/ArmSVE/IR/ArmSVEDialect.cpp b/mlir/lib/Dialect/ArmSVE/IR/ArmSVEDialect.cpp index 5e5ce6e..6a89c4e 100644 --- a/mlir/lib/Dialect/ArmSVE/IR/ArmSVEDialect.cpp +++ b/mlir/lib/Dialect/ArmSVE/IR/ArmSVEDialect.cpp @@ -22,6 +22,8 @@ using namespace mlir; using namespace arm_sve; +#include "mlir/Dialect/ArmSVE/ArmSVEDialect.cpp.inc" + static Type getI1SameShape(Type type); static void buildScalableCmpIOp(OpBuilder &build, OperationState &result, CmpIPredicate predicate, Value lhs, Value rhs); diff --git a/mlir/lib/Dialect/Async/IR/Async.cpp b/mlir/lib/Dialect/Async/IR/Async.cpp index bd627edb..3e325e2 100644 --- a/mlir/lib/Dialect/Async/IR/Async.cpp +++ b/mlir/lib/Dialect/Async/IR/Async.cpp @@ -14,6 +14,8 @@ using namespace mlir; using namespace mlir::async; +#include "mlir/Dialect/Async/IR/AsyncOpsDialect.cpp.inc" + void AsyncDialect::initialize() { addOperations< #define GET_OP_LIST diff --git a/mlir/lib/Dialect/Complex/IR/ComplexDialect.cpp b/mlir/lib/Dialect/Complex/IR/ComplexDialect.cpp index 4433036..0a61cea 100644 --- a/mlir/lib/Dialect/Complex/IR/ComplexDialect.cpp +++ b/mlir/lib/Dialect/Complex/IR/ComplexDialect.cpp @@ -8,6 +8,8 @@ #include "mlir/Dialect/Complex/IR/Complex.h" +#include "mlir/Dialect/Complex/IR/ComplexOpsDialect.cpp.inc" + void mlir::complex::ComplexDialect::initialize() { addOperations< #define GET_OP_LIST diff --git a/mlir/lib/Dialect/DLTI/DLTI.cpp b/mlir/lib/Dialect/DLTI/DLTI.cpp index 2567be6..2061512 100644 --- a/mlir/lib/Dialect/DLTI/DLTI.cpp +++ b/mlir/lib/Dialect/DLTI/DLTI.cpp @@ -16,6 +16,8 @@ using namespace mlir; +#include "mlir/Dialect/DLTI/DLTIDialect.cpp.inc" + //===----------------------------------------------------------------------===// // DataLayoutEntryAttr //===----------------------------------------------------------------------===// diff --git a/mlir/lib/Dialect/EmitC/IR/EmitC.cpp b/mlir/lib/Dialect/EmitC/IR/EmitC.cpp index 364c247..c0fa749 100644 --- a/mlir/lib/Dialect/EmitC/IR/EmitC.cpp +++ b/mlir/lib/Dialect/EmitC/IR/EmitC.cpp @@ -14,6 +14,8 @@ using namespace mlir; using namespace mlir::emitc; +#include "mlir/Dialect/EmitC/IR/EmitCDialect.cpp.inc" + //===----------------------------------------------------------------------===// // EmitCDialect //===----------------------------------------------------------------------===// diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp index f0845c4..12730d78 100644 --- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp +++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp @@ -29,6 +29,8 @@ using namespace mlir; using namespace mlir::gpu; +#include "mlir/Dialect/GPU/GPUOpsDialect.cpp.inc" + //===----------------------------------------------------------------------===// // MMAMatrixType //===----------------------------------------------------------------------===// diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp index 8b9a8fa..856c41c 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -36,6 +36,8 @@ using namespace mlir; using namespace mlir::LLVM; +#include "mlir/Dialect/LLVMIR/LLVMOpsDialect.cpp.inc" + static constexpr const char kVolatileAttrName[] = "volatile_"; static constexpr const char kNonTemporalAttrName[] = "nontemporal"; diff --git a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp index c16e1c2..da5c07a 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp @@ -30,6 +30,8 @@ using namespace mlir; using namespace NVVM; +#include "mlir/Dialect/LLVMIR/NVVMOpsDialect.cpp.inc" + //===----------------------------------------------------------------------===// // Printing/parsing for NVVM ops //===----------------------------------------------------------------------===// diff --git a/mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp index f54fcdb..fcce890 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp @@ -30,6 +30,8 @@ using namespace mlir; using namespace ROCDL; +#include "mlir/Dialect/LLVMIR/ROCDLOpsDialect.cpp.inc" + //===----------------------------------------------------------------------===// // Parsing for ROCDL ops //===----------------------------------------------------------------------===// diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp index f4524f1..904f6db 100644 --- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp +++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp @@ -36,6 +36,8 @@ using namespace mlir; using namespace mlir::linalg; +#include "mlir/Dialect/Linalg/IR/LinalgOpsDialect.cpp.inc" + /// Forward declarations. /// Generic entry point to create the block for the region of a LinalgOp. diff --git a/mlir/lib/Dialect/Math/IR/MathDialect.cpp b/mlir/lib/Dialect/Math/IR/MathDialect.cpp index 98ab368..eb21400 100644 --- a/mlir/lib/Dialect/Math/IR/MathDialect.cpp +++ b/mlir/lib/Dialect/Math/IR/MathDialect.cpp @@ -12,6 +12,8 @@ using namespace mlir; using namespace mlir::math; +#include "mlir/Dialect/Math/IR/MathOpsDialect.cpp.inc" + namespace { /// This class defines the interface for handling inlining with math /// operations. diff --git a/mlir/lib/Dialect/MemRef/IR/MemRefDialect.cpp b/mlir/lib/Dialect/MemRef/IR/MemRefDialect.cpp index ed82a4b..b6d5754 100644 --- a/mlir/lib/Dialect/MemRef/IR/MemRefDialect.cpp +++ b/mlir/lib/Dialect/MemRef/IR/MemRefDialect.cpp @@ -12,6 +12,8 @@ using namespace mlir; using namespace mlir::memref; +#include "mlir/Dialect/MemRef/IR/MemRefOpsDialect.cpp.inc" + //===----------------------------------------------------------------------===// // MemRefDialect Dialect Interfaces //===----------------------------------------------------------------------===// diff --git a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp index f823041..92f8aaa 100644 --- a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp +++ b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp @@ -17,6 +17,8 @@ using namespace mlir; using namespace acc; +#include "mlir/Dialect/OpenACC/OpenACCOpsDialect.cpp.inc" + //===----------------------------------------------------------------------===// // OpenACC operations //===----------------------------------------------------------------------===// diff --git a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp index 9160ab9..30a138e 100644 --- a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp +++ b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp @@ -22,6 +22,7 @@ #include "llvm/ADT/StringSwitch.h" #include +#include "mlir/Dialect/OpenMP/OpenMPOpsDialect.cpp.inc" #include "mlir/Dialect/OpenMP/OpenMPOpsEnums.cpp.inc" using namespace mlir; diff --git a/mlir/lib/Dialect/PDL/IR/PDL.cpp b/mlir/lib/Dialect/PDL/IR/PDL.cpp index 8164c89..3cb5b1b 100644 --- a/mlir/lib/Dialect/PDL/IR/PDL.cpp +++ b/mlir/lib/Dialect/PDL/IR/PDL.cpp @@ -16,6 +16,8 @@ using namespace mlir; using namespace mlir::pdl; +#include "mlir/Dialect/PDL/IR/PDLOpsDialect.cpp.inc" + //===----------------------------------------------------------------------===// // PDLDialect //===----------------------------------------------------------------------===// diff --git a/mlir/lib/Dialect/PDLInterp/IR/PDLInterp.cpp b/mlir/lib/Dialect/PDLInterp/IR/PDLInterp.cpp index a93f3c4..d149ef5 100644 --- a/mlir/lib/Dialect/PDLInterp/IR/PDLInterp.cpp +++ b/mlir/lib/Dialect/PDLInterp/IR/PDLInterp.cpp @@ -14,6 +14,8 @@ using namespace mlir; using namespace mlir::pdl_interp; +#include "mlir/Dialect/PDLInterp/IR/PDLInterpOpsDialect.cpp.inc" + //===----------------------------------------------------------------------===// // PDLInterp Dialect //===----------------------------------------------------------------------===// diff --git a/mlir/lib/Dialect/Quant/IR/QuantOps.cpp b/mlir/lib/Dialect/Quant/IR/QuantOps.cpp index fa64e4d..fd0bead 100644 --- a/mlir/lib/Dialect/Quant/IR/QuantOps.cpp +++ b/mlir/lib/Dialect/Quant/IR/QuantOps.cpp @@ -23,6 +23,8 @@ using namespace mlir; using namespace mlir::quant; using namespace mlir::quant::detail; +#include "mlir/Dialect/Quant/QuantOpsDialect.cpp.inc" + void QuantizationDialect::initialize() { addTypes(); diff --git a/mlir/lib/Dialect/SCF/SCF.cpp b/mlir/lib/Dialect/SCF/SCF.cpp index 99d2386..75f8430 100644 --- a/mlir/lib/Dialect/SCF/SCF.cpp +++ b/mlir/lib/Dialect/SCF/SCF.cpp @@ -18,6 +18,8 @@ using namespace mlir; using namespace mlir::scf; +#include "mlir/Dialect/SCF/SCFOpsDialect.cpp.inc" + //===----------------------------------------------------------------------===// // SCFDialect Dialect Interfaces //===----------------------------------------------------------------------===// diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp index 7da2d5a..6537710 100644 --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp @@ -33,6 +33,8 @@ using namespace mlir; using namespace mlir::spirv; +#include "mlir/Dialect/SPIRV/IR/SPIRVOpsDialect.cpp.inc" + //===----------------------------------------------------------------------===// // InlinerInterface //===----------------------------------------------------------------------===// diff --git a/mlir/lib/Dialect/Shape/IR/Shape.cpp b/mlir/lib/Dialect/Shape/IR/Shape.cpp index 158a6d5..f75bfc5 100644 --- a/mlir/lib/Dialect/Shape/IR/Shape.cpp +++ b/mlir/lib/Dialect/Shape/IR/Shape.cpp @@ -24,6 +24,8 @@ using namespace mlir; using namespace mlir::shape; +#include "mlir/Dialect/Shape/IR/ShapeOpsDialect.cpp.inc" + namespace { #include "ShapeCanonicalization.inc" } diff --git a/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp b/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp index 7bde51d..e07dfdc 100644 --- a/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp +++ b/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp @@ -16,6 +16,8 @@ using namespace mlir; using namespace mlir::sparse_tensor; +#include "mlir/Dialect/SparseTensor/IR/SparseTensorOpsDialect.cpp.inc" + //===----------------------------------------------------------------------===// // TensorDialect Attribute Methods. //===----------------------------------------------------------------------===// diff --git a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp index f6abfc4..49c285b 100644 --- a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp +++ b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp @@ -28,6 +28,8 @@ #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/raw_ostream.h" +#include "mlir/Dialect/StandardOps/IR/OpsDialect.cpp.inc" + // Pull in all enum type definitions and utility function declarations. #include "mlir/Dialect/StandardOps/IR/OpsEnums.cpp.inc" diff --git a/mlir/lib/Dialect/Tensor/IR/TensorDialect.cpp b/mlir/lib/Dialect/Tensor/IR/TensorDialect.cpp index 46a348b..860e0b8 100644 --- a/mlir/lib/Dialect/Tensor/IR/TensorDialect.cpp +++ b/mlir/lib/Dialect/Tensor/IR/TensorDialect.cpp @@ -12,6 +12,8 @@ using namespace mlir; using namespace mlir::tensor; +#include "mlir/Dialect/Tensor/IR/TensorOpsDialect.cpp.inc" + //===----------------------------------------------------------------------===// // TensorDialect Dialect Interfaces //===----------------------------------------------------------------------===// diff --git a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp index 83a89f3..39b864f 100644 --- a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp +++ b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp @@ -23,6 +23,8 @@ using namespace mlir; using namespace mlir::tosa; +#include "mlir/Dialect/Tosa/IR/TosaOpsDialect.cpp.inc" + //===----------------------------------------------------------------------===// // Tosa dialect structs and interface includes. //===----------------------------------------------------------------------===// diff --git a/mlir/lib/Dialect/Vector/VectorOps.cpp b/mlir/lib/Dialect/Vector/VectorOps.cpp index 92a6720..c354132 100644 --- a/mlir/lib/Dialect/Vector/VectorOps.cpp +++ b/mlir/lib/Dialect/Vector/VectorOps.cpp @@ -32,6 +32,7 @@ #include "llvm/ADT/bit.h" #include +#include "mlir/Dialect/Vector/VectorOpsDialect.cpp.inc" // Pull in all enum type and utility function definitions. #include "mlir/Dialect/Vector/VectorOpsEnums.cpp.inc" diff --git a/mlir/lib/Dialect/X86Vector/IR/X86VectorDialect.cpp b/mlir/lib/Dialect/X86Vector/IR/X86VectorDialect.cpp index 5c80fa3..a9de16d 100644 --- a/mlir/lib/Dialect/X86Vector/IR/X86VectorDialect.cpp +++ b/mlir/lib/Dialect/X86Vector/IR/X86VectorDialect.cpp @@ -18,6 +18,8 @@ using namespace mlir; +#include "mlir/Dialect/X86Vector/X86VectorDialect.cpp.inc" + void x86vector::X86VectorDialect::initialize() { addOperations< #define GET_OP_LIST diff --git a/mlir/lib/IR/BuiltinDialect.cpp b/mlir/lib/IR/BuiltinDialect.cpp index 728443e..25e853f 100644 --- a/mlir/lib/IR/BuiltinDialect.cpp +++ b/mlir/lib/IR/BuiltinDialect.cpp @@ -27,6 +27,8 @@ using namespace mlir; // Builtin Dialect //===----------------------------------------------------------------------===// +#include "mlir/IR/BuiltinDialect.cpp.inc" + namespace { struct BuiltinOpAsmDialectInterface : public OpAsmDialectInterface { using OpAsmDialectInterface::OpAsmDialectInterface; diff --git a/mlir/lib/TableGen/Dialect.cpp b/mlir/lib/TableGen/Dialect.cpp index 0cdd9d6..59e7593 100644 --- a/mlir/lib/TableGen/Dialect.cpp +++ b/mlir/lib/TableGen/Dialect.cpp @@ -69,6 +69,10 @@ bool Dialect::hasConstantMaterializer() const { return def->getValueAsBit("hasConstantMaterializer"); } +bool Dialect::hasNonDefaultDestructor() const { + return def->getValueAsBit("hasNonDefaultDestructor"); +} + bool Dialect::hasOperationAttrVerify() const { return def->getValueAsBit("hasOperationAttrVerify"); } diff --git a/mlir/test/lib/Dialect/Test/CMakeLists.txt b/mlir/test/lib/Dialect/Test/CMakeLists.txt index a591ab5..5f37b09 100644 --- a/mlir/test/lib/Dialect/Test/CMakeLists.txt +++ b/mlir/test/lib/Dialect/Test/CMakeLists.txt @@ -28,6 +28,7 @@ set(LLVM_TARGET_DEFINITIONS TestOps.td) mlir_tablegen(TestOps.h.inc -gen-op-decls) mlir_tablegen(TestOps.cpp.inc -gen-op-defs) mlir_tablegen(TestOpsDialect.h.inc -gen-dialect-decls -dialect=test) +mlir_tablegen(TestOpsDialect.cpp.inc -gen-dialect-defs -dialect=test) mlir_tablegen(TestOpEnums.h.inc -gen-enum-decls) mlir_tablegen(TestOpEnums.cpp.inc -gen-enum-defs) mlir_tablegen(TestOpStructs.h.inc -gen-struct-attr-decls) diff --git a/mlir/test/lib/Dialect/Test/TestDialect.cpp b/mlir/test/lib/Dialect/Test/TestDialect.cpp index ca6f180..991d8fa 100644 --- a/mlir/test/lib/Dialect/Test/TestDialect.cpp +++ b/mlir/test/lib/Dialect/Test/TestDialect.cpp @@ -26,6 +26,8 @@ using namespace mlir; using namespace mlir::test; +#include "TestOpsDialect.cpp.inc" + void mlir::test::registerTestDialect(DialectRegistry ®istry) { registry.insert(); } diff --git a/mlir/test/lib/Dialect/Test/TestOps.td b/mlir/test/lib/Dialect/Test/TestOps.td index 0f1775f7..c59b9fa 100644 --- a/mlir/test/lib/Dialect/Test/TestOps.td +++ b/mlir/test/lib/Dialect/Test/TestOps.td @@ -31,6 +31,7 @@ def Test_Dialect : Dialect { let hasRegionArgAttrVerify = 1; let hasRegionResultAttrVerify = 1; let hasOperationInterfaceFallback = 1; + let hasNonDefaultDestructor = 1; let dependentDialects = ["::mlir::DLTIDialect"]; let extraClassDeclaration = [{ @@ -47,8 +48,6 @@ def Test_Dialect : Dialect { getParseOperationHook(StringRef opName) const override; LogicalResult printOperation(Operation *op, OpAsmPrinter &printer) const override; - - ~TestDialect(); private: // Storage for a custom fallback interface. void *fallbackEffectOpInterfaces; diff --git a/mlir/tools/mlir-tblgen/DialectGen.cpp b/mlir/tools/mlir-tblgen/DialectGen.cpp index dbbc32b..2ebabc5 100644 --- a/mlir/tools/mlir-tblgen/DialectGen.cpp +++ b/mlir/tools/mlir-tblgen/DialectGen.cpp @@ -17,6 +17,7 @@ #include "mlir/TableGen/OpClass.h" #include "mlir/TableGen/Operator.h" #include "mlir/TableGen/Trait.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/Sequence.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/CommandLine.h" @@ -54,6 +55,29 @@ filterForDialect(ArrayRef records, Dialect &dialect) { DialectFilterIterator(records.end(), records.end(), filterFn)}; } +static Optional +findSelectedDialect(ArrayRef dialectDefs) { + // Select the dialect to gen for. + if (dialectDefs.size() == 1 && selectedDialect.getNumOccurrences() == 0) { + return Dialect(dialectDefs.front()); + } + + if (selectedDialect.getNumOccurrences() == 0) { + llvm::errs() << "when more than 1 dialect is present, one must be selected " + "via '-dialect'\n"; + return llvm::None; + } + + auto dialectIt = llvm::find_if(dialectDefs, [](const llvm::Record *def) { + return Dialect(def).getName() == selectedDialect; + }); + if (dialectIt == dialectDefs.end()) { + llvm::errs() << "selected dialect with '-dialect' does not exist\n"; + return llvm::None; + } + return Dialect(*dialectIt); +} + //===----------------------------------------------------------------------===// // GEN: Dialect declarations //===----------------------------------------------------------------------===// @@ -72,9 +96,11 @@ class {0} : public ::mlir::Dialect { {2} initialize(); } + void initialize(); friend class ::mlir::MLIRContext; public: + ~{0}() override; static constexpr ::llvm::StringLiteral getDialectNamespace() { return ::llvm::StringLiteral("{1}"); } @@ -210,34 +236,52 @@ static bool emitDialectDecls(const llvm::RecordKeeper &recordKeeper, raw_ostream &os) { emitSourceFileHeader("Dialect Declarations", os); - auto defs = recordKeeper.getAllDerivedDefinitions("Dialect"); - if (defs.empty()) + auto dialectDefs = recordKeeper.getAllDerivedDefinitions("Dialect"); + if (dialectDefs.empty()) return false; - // Select the dialect to gen for. - const llvm::Record *dialectDef = nullptr; - if (defs.size() == 1 && selectedDialect.getNumOccurrences() == 0) { - dialectDef = defs.front(); - } else if (selectedDialect.getNumOccurrences() == 0) { - llvm::errs() << "when more than 1 dialect is present, one must be selected " - "via '-dialect'"; + Optional dialect = findSelectedDialect(dialectDefs); + if (!dialect) return true; - } else { - auto dialectIt = llvm::find_if(defs, [](const llvm::Record *def) { - return Dialect(def).getName() == selectedDialect; - }); - if (dialectIt == defs.end()) { - llvm::errs() << "selected dialect with '-dialect' does not exist"; - return true; - } - dialectDef = *dialectIt; - } - auto attrDefs = recordKeeper.getAllDerivedDefinitions("DialectAttr"); auto typeDefs = recordKeeper.getAllDerivedDefinitions("DialectType"); - Dialect dialect(dialectDef); - emitDialectDecl(dialect, filterForDialect(attrDefs, dialect), - filterForDialect(typeDefs, dialect), os); + emitDialectDecl(*dialect, filterForDialect(attrDefs, *dialect), + filterForDialect(typeDefs, *dialect), os); + return false; +} + +//===----------------------------------------------------------------------===// +// GEN: Dialect definitions +//===----------------------------------------------------------------------===// + +/// The code block to generate a default desturctor definition. +/// +/// {0}: The name of the dialect class. +static const char *const dialectDestructorStr = R"( +{0}::~{0}() = default; + +)"; + +static void emitDialectDef(Dialect &dialect, raw_ostream &os) { + // Emit all nested namespaces. + NamespaceEmitter nsEmitter(os, dialect); + + if (!dialect.hasNonDefaultDestructor()) + os << llvm::formatv(dialectDestructorStr, dialect.getCppClassName()); +} + +static bool emitDialectDefs(const llvm::RecordKeeper &recordKeeper, + raw_ostream &os) { + emitSourceFileHeader("Dialect Definitions", os); + + auto dialectDefs = recordKeeper.getAllDerivedDefinitions("Dialect"); + if (dialectDefs.empty()) + return false; + + Optional dialect = findSelectedDialect(dialectDefs); + if (!dialect) + return true; + emitDialectDef(*dialect, os); return false; } @@ -250,3 +294,9 @@ static mlir::GenRegistration [](const llvm::RecordKeeper &records, raw_ostream &os) { return emitDialectDecls(records, os); }); + +static mlir::GenRegistration + genDialectDefs("gen-dialect-defs", "Generate dialect definitions", + [](const llvm::RecordKeeper &records, raw_ostream &os) { + return emitDialectDefs(records, os); + }); diff --git a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel index a9211f1..e111906 100644 --- a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel @@ -129,6 +129,10 @@ gentbl_cc_library( ["-gen-dialect-decls"], "include/mlir/IR/BuiltinDialect.h.inc", ), + ( + ["-gen-dialect-defs"], + "include/mlir/IR/BuiltinDialect.cpp.inc", + ), ], tblgen = ":mlir-tblgen", td_file = "include/mlir/IR/BuiltinDialect.td", @@ -778,6 +782,10 @@ gentbl_cc_library( ["-gen-dialect-decls"], "include/mlir/Dialect/Affine/IR/AffineOpsDialect.h.inc", ), + ( + ["-gen-dialect-defs"], + "include/mlir/Dialect/Affine/IR/AffineOpsDialect.cpp.inc", + ), ], tblgen = ":mlir-tblgen", td_file = "include/mlir/Dialect/Affine/IR/AffineOps.td", @@ -848,6 +856,10 @@ gentbl_cc_library( "include/mlir/Dialect/EmitC/IR/EmitCDialect.h.inc", ), ( + ["-gen-dialect-defs"], + "include/mlir/Dialect/EmitC/IR/EmitCDialect.cpp.inc", + ), + ( ["-gen-op-decls"], "include/mlir/Dialect/EmitC/IR/EmitC.h.inc", ), @@ -905,6 +917,10 @@ gentbl_cc_library( "include/mlir/Dialect/Async/IR/AsyncOpsDialect.h.inc", ), ( + ["-gen-dialect-defs"], + "include/mlir/Dialect/Async/IR/AsyncOpsDialect.cpp.inc", + ), + ( ["-gen-typedef-decls"], "include/mlir/Dialect/Async/IR/AsyncOpsTypes.h.inc", ), @@ -976,6 +992,13 @@ gentbl_cc_library( "include/mlir/Dialect/ArmNeon/ArmNeonDialect.h.inc", ), ( + [ + "-gen-dialect-defs", + "-dialect=arm_neon", + ], + "include/mlir/Dialect/ArmNeon/ArmNeonDialect.cpp.inc", + ), + ( ["-gen-op-decls"], "include/mlir/Dialect/ArmNeon/ArmNeon.h.inc", ), @@ -1093,6 +1116,13 @@ gentbl_cc_library( ], "include/mlir/Dialect/ArmSVE/ArmSVEDialect.h.inc", ), + ( + [ + "-gen-dialect-defs", + "-dialect=arm_sve", + ], + "include/mlir/Dialect/ArmSVE/ArmSVEDialect.cpp.inc", + ), ], tblgen = ":mlir-tblgen", td_file = "include/mlir/Dialect/ArmSVE/ArmSVE.td", @@ -1174,6 +1204,13 @@ gentbl_cc_library( "include/mlir/Dialect/AMX/AMXDialect.h.inc", ), ( + [ + "-gen-dialect-defs", + "-dialect=amx", + ], + "include/mlir/Dialect/AMX/AMXDialect.cpp.inc", + ), + ( ["-gen-op-decls"], "include/mlir/Dialect/AMX/AMX.h.inc", ), @@ -1262,6 +1299,13 @@ gentbl_cc_library( "include/mlir/Dialect/X86Vector/X86VectorDialect.h.inc", ), ( + [ + "-gen-dialect-defs", + "-dialect=x86vector", + ], + "include/mlir/Dialect/X86Vector/X86VectorDialect.cpp.inc", + ), + ( ["-gen-op-decls"], "include/mlir/Dialect/X86Vector/X86Vector.h.inc", ), @@ -1355,6 +1399,10 @@ gentbl_cc_library( ["-gen-dialect-decls"], "include/mlir/Dialect/SCF/SCFOpsDialect.h.inc", ), + ( + ["-gen-dialect-defs"], + "include/mlir/Dialect/SCF/SCFOpsDialect.cpp.inc", + ), ], tblgen = ":mlir-tblgen", td_file = "include/mlir/Dialect/SCF/SCFOps.td", @@ -1447,6 +1495,13 @@ gentbl_cc_library( "include/mlir/Dialect/SparseTensor/IR/SparseTensorOpsDialect.h.inc", ), ( + [ + "-gen-dialect-defs", + "-dialect=sparse_tensor", + ], + "include/mlir/Dialect/SparseTensor/IR/SparseTensorOpsDialect.cpp.inc", + ), + ( ["-gen-op-decls"], "include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.h.inc", ), @@ -1587,6 +1642,10 @@ gentbl_cc_library( "include/mlir/Dialect/StandardOps/IR/OpsDialect.h.inc", ), ( + ["-gen-dialect-defs"], + "include/mlir/Dialect/StandardOps/IR/OpsDialect.cpp.inc", + ), + ( ["-gen-enum-decls"], "include/mlir/Dialect/StandardOps/IR/OpsEnums.h.inc", ), @@ -2060,6 +2119,10 @@ gentbl_cc_library( ["-gen-dialect-decls"], "include/mlir/Dialect/Shape/IR/ShapeOpsDialect.h.inc", ), + ( + ["-gen-dialect-defs"], + "include/mlir/Dialect/Shape/IR/ShapeOpsDialect.cpp.inc", + ), ], tblgen = ":mlir-tblgen", td_file = "include/mlir/Dialect/Shape/IR/ShapeOps.td", @@ -2517,6 +2580,13 @@ gentbl_cc_library( "include/mlir/Dialect/GPU/GPUOpsDialect.h.inc", ), ( + [ + "-gen-dialect-defs", + "-dialect=gpu", + ], + "include/mlir/Dialect/GPU/GPUOpsDialect.cpp.inc", + ), + ( ["-gen-op-interface-decls"], "include/mlir/Dialect/GPU/GPUOpInterfaces.h.inc", ), @@ -2954,6 +3024,10 @@ gentbl_cc_library( "include/mlir/Dialect/LLVMIR/LLVMOpsDialect.h.inc", ), ( + ["-gen-dialect-defs"], + "include/mlir/Dialect/LLVMIR/LLVMOpsDialect.cpp.inc", + ), + ( ["-gen-enum-decls"], "include/mlir/Dialect/LLVMIR/LLVMOpsEnums.h.inc", ), @@ -3037,6 +3111,13 @@ gentbl_cc_library( ], "include/mlir/Dialect/LLVMIR/NVVMOpsDialect.h.inc", ), + ( + [ + "-gen-dialect-defs", + "-dialect=nvvm", + ], + "include/mlir/Dialect/LLVMIR/NVVMOpsDialect.cpp.inc", + ), ], tblgen = ":mlir-tblgen", td_file = "include/mlir/Dialect/LLVMIR/NVVMOps.td", @@ -3105,6 +3186,13 @@ gentbl_cc_library( ], "include/mlir/Dialect/LLVMIR/ROCDLOpsDialect.h.inc", ), + ( + [ + "-gen-dialect-defs", + "-dialect=rocdl", + ], + "include/mlir/Dialect/LLVMIR/ROCDLOpsDialect.cpp.inc", + ), ], tblgen = ":mlir-tblgen", td_file = "include/mlir/Dialect/LLVMIR/ROCDLOps.td", @@ -3175,6 +3263,10 @@ gentbl_cc_library( ["-gen-dialect-decls"], "include/mlir/Dialect/PDL/IR/PDLOpsDialect.h.inc", ), + ( + ["-gen-dialect-defs"], + "include/mlir/Dialect/PDL/IR/PDLOpsDialect.cpp.inc", + ), ], tblgen = ":mlir-tblgen", td_file = "include/mlir/Dialect/PDL/IR/PDLOps.td", @@ -3250,6 +3342,13 @@ gentbl_cc_library( ], "include/mlir/Dialect/PDLInterp/IR/PDLInterpOpsDialect.h.inc", ), + ( + [ + "-gen-dialect-defs", + "-dialect=pdl_interp", + ], + "include/mlir/Dialect/PDLInterp/IR/PDLInterpOpsDialect.cpp.inc", + ), ], tblgen = ":mlir-tblgen", td_file = "include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td", @@ -3285,6 +3384,10 @@ gentbl_cc_library( "include/mlir/Dialect/SPIRV/IR/SPIRVOpsDialect.h.inc", ), ( + ["-gen-dialect-defs"], + "include/mlir/Dialect/SPIRV/IR/SPIRVOpsDialect.cpp.inc", + ), + ( ["-gen-op-doc"], "g3doc/Dialects/SPIRV/SPIRVOps.md", ), @@ -3646,6 +3749,13 @@ gentbl_cc_library( "include/mlir/Dialect/Tensor/IR/TensorOpsDialect.h.inc", ), ( + [ + "-gen-dialect-defs", + "-dialect=tensor", + ], + "include/mlir/Dialect/Tensor/IR/TensorOpsDialect.cpp.inc", + ), + ( ["-gen-op-decls"], "include/mlir/Dialect/Tensor/IR/TensorOps.h.inc", ), @@ -5153,6 +5263,13 @@ gentbl_cc_library( "include/mlir/Dialect/OpenACC/OpenACCOpsDialect.h.inc", ), ( + [ + "-gen-dialect-defs", + "-dialect=acc", + ], + "include/mlir/Dialect/OpenACC/OpenACCOpsDialect.cpp.inc", + ), + ( ["-gen-op-decls"], "include/mlir/Dialect/OpenACC/OpenACCOps.h.inc", ), @@ -5260,6 +5377,13 @@ gentbl_cc_library( "include/mlir/Dialect/OpenMP/OpenMPOpsDialect.h.inc", ), ( + [ + "-gen-dialect-defs", + "-dialect=omp", + ], + "include/mlir/Dialect/OpenMP/OpenMPOpsDialect.cpp.inc", + ), + ( ["-gen-op-doc"], "g3doc/Dialects/OpenMP/OpenMPOps.md", ), @@ -5391,6 +5515,10 @@ gentbl_cc_library( "include/mlir/Dialect/Quant/QuantOpsDialect.h.inc", ), ( + ["-gen-dialect-defs"], + "include/mlir/Dialect/Quant/QuantOpsDialect.cpp.inc", + ), + ( ["-gen-op-doc"], "g3doc/Dialects/QuantOps/QuantOps.md", ), @@ -5488,6 +5616,13 @@ gentbl_cc_library( ], "include/mlir/Dialect/Linalg/IR/LinalgOpsDialect.h.inc", ), + ( + [ + "-gen-dialect-defs", + "-dialect=linalg", + ], + "include/mlir/Dialect/Linalg/IR/LinalgOpsDialect.cpp.inc", + ), ], tblgen = ":mlir-tblgen", td_file = "include/mlir/Dialect/Linalg/IR/LinalgOps.td", @@ -5827,6 +5962,13 @@ gentbl_cc_library( "include/mlir/Dialect/Vector/VectorOpsDialect.h.inc", ), ( + [ + "-gen-dialect-defs", + "-dialect=vector", + ], + "include/mlir/Dialect/Vector/VectorOpsDialect.cpp.inc", + ), + ( ["-gen-enum-decls"], "include/mlir/Dialect/Vector/VectorOpsEnums.h.inc", ), @@ -5974,6 +6116,10 @@ gentbl_cc_library( "include/mlir/Dialect/Tosa/IR/TosaOpsDialect.h.inc", ), ( + ["-gen-dialect-defs"], + "include/mlir/Dialect/Tosa/IR/TosaOpsDialect.cpp.inc", + ), + ( ["-gen-op-doc"], "g3doc/Dialects/Tosa/TosaOps.md", ), @@ -6147,6 +6293,13 @@ gentbl_cc_library( ], "include/mlir/Dialect/Complex/IR/ComplexOpsDialect.h.inc", ), + ( + [ + "-gen-dialect-defs", + "-dialect=complex", + ], + "include/mlir/Dialect/Complex/IR/ComplexOpsDialect.cpp.inc", + ), ], tblgen = ":mlir-tblgen", td_file = "include/mlir/Dialect/Complex/IR/ComplexBase.td", @@ -6295,6 +6448,13 @@ gentbl_cc_library( ], "include/mlir/Dialect/Math/IR/MathOpsDialect.h.inc", ), + ( + [ + "-gen-dialect-defs", + "-dialect=math", + ], + "include/mlir/Dialect/Math/IR/MathOpsDialect.cpp.inc", + ), ], tblgen = ":mlir-tblgen", td_file = "include/mlir/Dialect/Math/IR/MathBase.td", @@ -6418,6 +6578,13 @@ gentbl_cc_library( ], "include/mlir/Dialect/MemRef/IR/MemRefOpsDialect.h.inc", ), + ( + [ + "-gen-dialect-defs", + "-dialect=memref", + ], + "include/mlir/Dialect/MemRef/IR/MemRefOpsDialect.cpp.inc", + ), ], tblgen = ":mlir-tblgen", td_file = "include/mlir/Dialect/MemRef/IR/MemRefBase.td", @@ -6535,6 +6702,13 @@ gentbl_cc_library( ], "include/mlir/Dialect/DLTI/DLTIDialect.h.inc", ), + ( + [ + "-gen-dialect-defs", + "-dialect=dlti", + ], + "include/mlir/Dialect/DLTI/DLTIDialect.cpp.inc", + ), ], tblgen = ":mlir-tblgen", td_file = "include/mlir/Dialect/DLTI/DLTIBase.td", diff --git a/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel index 4d20116..b8f590a 100644 --- a/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel @@ -72,6 +72,13 @@ gentbl_cc_library( "lib/Dialect/Test/TestOpsDialect.h.inc", ), ( + [ + "-gen-dialect-defs", + "-dialect=test", + ], + "lib/Dialect/Test/TestOpsDialect.cpp.inc", + ), + ( ["-gen-enum-decls"], "lib/Dialect/Test/TestOpEnums.h.inc", ), -- 2.7.4