https://github.com/jpienaar updated
https://github.com/llvm/llvm-project/pull/69927
>From eea36708d838411d70eb99265c3a2f3aabb91460 Mon Sep 17 00:00:00 2001
From: Jacques Pienaar
Date: Sun, 22 Oct 2023 09:33:40 -0700
Subject: [PATCH] [mlir] Add config for PDL
Make it so that PDL can be optionally disabled. PDL is different than
other dialects as its included in rewrite framework. This results in
these being included even where it isn't used and not removed during
compilation. Add option to disable for workloads where it isn't needed
or used. This ends up being rather invasive due to how PDL is included.
Ideally we'd have less ifdefs, not particularly happy with those, but
given how integrated it is, couldn't see simple alternative.
PDL is enabled by default (and not optional bazel).
This only works with tests disabled. With tests enabled this still
compiles but tests fail as there is no lit config to disable tests that
depend on PDL yet.
---
mlir/CMakeLists.txt | 12 ++--
mlir/cmake/modules/AddMLIR.cmake | 3 +
mlir/examples/CMakeLists.txt | 4 +-
mlir/examples/minimal-opt/README.md | 7 ++-
mlir/include/mlir/Config/mlir-config.h.cmake | 3 +
mlir/include/mlir/Conversion/Passes.td| 2 +
mlir/include/mlir/Dialect/CMakeLists.txt | 6 +-
.../mlir/Dialect/Transform/CMakeLists.txt | 4 +-
mlir/include/mlir/IR/PatternMatch.h | 17 +
mlir/include/mlir/InitAllDialects.h | 9 ++-
mlir/include/mlir/InitAllExtensions.h | 11 +++-
.../mlir/Rewrite/FrozenRewritePatternSet.h| 6 ++
mlir/include/mlir/Rewrite/PatternApplicator.h | 5 ++
.../mlir/Transforms/DialectConversion.h | 2 +
mlir/lib/CAPI/Dialect/CMakeLists.txt | 18 +++---
mlir/lib/Conversion/CMakeLists.txt| 4 +-
mlir/lib/Dialect/Bufferization/CMakeLists.txt | 4 +-
.../Bufferization/TransformOps/CMakeLists.txt | 1 -
mlir/lib/Dialect/CMakeLists.txt | 6 +-
mlir/lib/Dialect/Transform/CMakeLists.txt | 4 +-
mlir/lib/IR/PatternMatch.cpp | 2 +
mlir/lib/Rewrite/CMakeLists.txt | 24 +--
mlir/lib/Rewrite/FrozenRewritePatternSet.cpp | 13 +++-
mlir/lib/Rewrite/PatternApplicator.cpp| 26 +++-
mlir/lib/Tools/CMakeLists.txt | 6 +-
.../Transforms/Utils/DialectConversion.cpp| 2 +
mlir/python/CMakeLists.txt| 62 ++-
mlir/test/CAPI/CMakeLists.txt | 16 ++---
mlir/test/CMakeLists.txt | 20 --
mlir/test/lib/Dialect/CMakeLists.txt | 5 +-
mlir/test/lib/Rewrite/CMakeLists.txt | 3 +-
mlir/test/lib/Tools/CMakeLists.txt| 4 +-
mlir/test/lib/Transforms/CMakeLists.txt | 28 ++---
mlir/tools/CMakeLists.txt | 4 +-
mlir/tools/mlir-lsp-server/CMakeLists.txt | 10 ++-
.../tools/mlir-lsp-server/mlir-lsp-server.cpp | 4 ++
mlir/tools/mlir-opt/CMakeLists.txt| 10 ++-
mlir/tools/mlir-opt/mlir-opt.cpp | 16 +++--
mlir/unittests/Conversion/CMakeLists.txt | 4 +-
mlir/unittests/Dialect/CMakeLists.txt | 4 +-
.../llvm-project-overlay/mlir/BUILD.bazel | 1 +
41 files changed, 283 insertions(+), 109 deletions(-)
diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index ac120aad0d1eda7..d0db9e341765b3d 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -132,6 +132,8 @@ set(MLIR_ENABLE_NVPTXCOMPILER 0 CACHE BOOL
"Statically link the nvptxlibrary instead of calling ptxas as a subprocess
\
for compiling PTX to cubin")
+set(MLIR_ENABLE_PDL 1 CACHE BOOL "Enable PDL")
+
option(MLIR_INCLUDE_TESTS
"Generate build targets for the MLIR unit tests."
${LLVM_INCLUDE_TESTS})
@@ -179,12 +181,14 @@ include_directories( ${MLIR_INCLUDE_DIR})
# from another directory like tools
add_subdirectory(tools/mlir-tblgen)
add_subdirectory(tools/mlir-linalg-ods-gen)
-add_subdirectory(tools/mlir-pdll)
-
set(MLIR_TABLEGEN_EXE "${MLIR_TABLEGEN_EXE}" CACHE INTERNAL "")
set(MLIR_TABLEGEN_TARGET "${MLIR_TABLEGEN_TARGET}" CACHE INTERNAL "")
-set(MLIR_PDLL_TABLEGEN_EXE "${MLIR_PDLL_TABLEGEN_EXE}" CACHE INTERNAL "")
-set(MLIR_PDLL_TABLEGEN_TARGET "${MLIR_PDLL_TABLEGEN_TARGET}" CACHE INTERNAL "")
+
+if(MLIR_ENABLE_PDL)
+ add_subdirectory(tools/mlir-pdll)
+ set(MLIR_PDLL_TABLEGEN_EXE "${MLIR_PDLL_TABLEGEN_EXE}" CACHE INTERNAL "")
+ set(MLIR_PDLL_TABLEGEN_TARGET "${MLIR_PDLL_TABLEGEN_TARGET}" CACHE INTERNAL
"")
+endif()
add_subdirectory(include/mlir)
add_subdirectory(lib)
diff --git a/mlir/cmake/modules/AddMLIR.cmake b/mlir/cmake/modules/AddMLIR.cmake
index 544abe43688820e..f20a2bc75d5433b 100644
--- a/mlir/cmake/modules/AddMLIR.cmake
+++ b/mlir/cmake/modules/AddMLIR.cmake
@@ -6,6 +6,9 @@ include(LLVMDistributionSupport)
file(REMOVE ${CMAKE_BINARY_DIR}/tablegen_compile_commands.yml)
function(mlir_tablegen ofn)
+ if