[Mlir-commits] [mlir] d1bb301 - [mlir] fix `add_tablegen()` macro to allow installing mlir-pdll
Ashay Rane
llvmlistbot at llvm.org
Sun Aug 7 15:49:19 PDT 2022
Author: Ashay Rane
Date: 2022-08-07T15:48:38-07:00
New Revision: d1bb3016ddc8331a96048eda37ab13bf412c7749
URL: https://github.com/llvm/llvm-project/commit/d1bb3016ddc8331a96048eda37ab13bf412c7749
DIFF: https://github.com/llvm/llvm-project/commit/d1bb3016ddc8331a96048eda37ab13bf412c7749.diff
LOG: [mlir] fix `add_tablegen()` macro to allow installing mlir-pdll
Prior to this patch, the `add_tablegen()` macro in
llvm/cmake/modules/TableGen.cmake added the install rule only if
`project` matched `LLVM` or `MLIR`. This patch adds an optional
`DESTINATION` argument, which, if non-empty, decides whether (and where)
to install the tablegen tool, thus eliminating the need for
project-specific overrides. This patch also updates all other
invocations of the `add_tablegen()` macro.
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D131282
Added:
Modified:
clang/utils/TableGen/CMakeLists.txt
llvm/cmake/modules/TableGen.cmake
llvm/utils/TableGen/CMakeLists.txt
mlir/tools/mlir-pdll/CMakeLists.txt
mlir/tools/mlir-tblgen/CMakeLists.txt
Removed:
################################################################################
diff --git a/clang/utils/TableGen/CMakeLists.txt b/clang/utils/TableGen/CMakeLists.txt
index 04aa72cde03e3..d2cb29dd23a30 100644
--- a/clang/utils/TableGen/CMakeLists.txt
+++ b/clang/utils/TableGen/CMakeLists.txt
@@ -1,6 +1,6 @@
set(LLVM_LINK_COMPONENTS Support)
-add_tablegen(clang-tblgen CLANG
+add_tablegen(clang-tblgen CLANG DESTINATION "${CLANG_TOOLS_INSTALL_DIR}"
ASTTableGen.cpp
ClangASTNodesEmitter.cpp
ClangASTPropertiesEmitter.cpp
diff --git a/llvm/cmake/modules/TableGen.cmake b/llvm/cmake/modules/TableGen.cmake
index 4711456776c86..172621d377485 100644
--- a/llvm/cmake/modules/TableGen.cmake
+++ b/llvm/cmake/modules/TableGen.cmake
@@ -140,6 +140,8 @@ function(add_public_tablegen_target target)
endfunction()
macro(add_tablegen target project)
+ cmake_parse_arguments(ADD_TABLEGEN "" "DESTINATION" "" ${ARGN})
+
set(${target}_OLD_LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS})
set(LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS} TableGen)
@@ -149,7 +151,8 @@ macro(add_tablegen target project)
set(LLVM_ENABLE_OBJLIB ON)
endif()
- add_llvm_executable(${target} DISABLE_LLVM_LINK_LLVM_DYLIB ${ARGN})
+ add_llvm_executable(${target} DISABLE_LLVM_LINK_LLVM_DYLIB
+ ${ADD_TABLEGEN_UNPARSED_ARGUMENTS})
set(LLVM_LINK_COMPONENTS ${${target}_OLD_LLVM_LINK_COMPONENTS})
set(${project}_TABLEGEN "${target}" CACHE
@@ -186,7 +189,7 @@ macro(add_tablegen target project)
endif()
endif()
- if ((${project} STREQUAL LLVM OR ${project} STREQUAL MLIR) AND NOT LLVM_INSTALL_TOOLCHAIN_ONLY AND LLVM_BUILD_UTILS)
+ if (ADD_TABLEGEN_DESTINATION AND NOT LLVM_INSTALL_TOOLCHAIN_ONLY AND LLVM_BUILD_UTILS)
set(export_to_llvmexports)
if(${target} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
NOT LLVM_DISTRIBUTION_COMPONENTS)
@@ -196,7 +199,7 @@ macro(add_tablegen target project)
install(TARGETS ${target}
${export_to_llvmexports}
COMPONENT ${target}
- RUNTIME DESTINATION "${${project}_TOOLS_INSTALL_DIR}")
+ RUNTIME DESTINATION "${ADD_TABLEGEN_DESTINATION}")
if(NOT LLVM_ENABLE_IDE)
add_llvm_install_targets("install-${target}"
DEPENDS ${target}
diff --git a/llvm/utils/TableGen/CMakeLists.txt b/llvm/utils/TableGen/CMakeLists.txt
index 725c99b8e08ef..bf4d51b8dca44 100644
--- a/llvm/utils/TableGen/CMakeLists.txt
+++ b/llvm/utils/TableGen/CMakeLists.txt
@@ -2,7 +2,7 @@ add_subdirectory(GlobalISel)
set(LLVM_LINK_COMPONENTS Support)
-add_tablegen(llvm-tblgen LLVM
+add_tablegen(llvm-tblgen LLVM DESTINATION "${LLVM_TOOLS_INSTALL_DIR}"
AsmMatcherEmitter.cpp
AsmWriterEmitter.cpp
AsmWriterInst.cpp
diff --git a/mlir/tools/mlir-pdll/CMakeLists.txt b/mlir/tools/mlir-pdll/CMakeLists.txt
index b195d62dfd076..6acee39e875cd 100644
--- a/mlir/tools/mlir-pdll/CMakeLists.txt
+++ b/mlir/tools/mlir-pdll/CMakeLists.txt
@@ -12,7 +12,7 @@ set(LIBS
MLIRPDLLParser
)
-add_tablegen(mlir-pdll MLIR_PDLL
+add_tablegen(mlir-pdll MLIR_PDLL DESTINATION "${MLIR_TOOLS_INSTALL_DIR}"
mlir-pdll.cpp
DEPENDS
diff --git a/mlir/tools/mlir-tblgen/CMakeLists.txt b/mlir/tools/mlir-tblgen/CMakeLists.txt
index e3e3ed91515dd..85f9207f723b1 100644
--- a/mlir/tools/mlir-tblgen/CMakeLists.txt
+++ b/mlir/tools/mlir-tblgen/CMakeLists.txt
@@ -4,7 +4,7 @@ set(LLVM_LINK_COMPONENTS
TableGen
)
-add_tablegen(mlir-tblgen MLIR
+add_tablegen(mlir-tblgen MLIR DESTINATION "${MLIR_TOOLS_INSTALL_DIR}"
AttrOrTypeDefGen.cpp
AttrOrTypeFormatGen.cpp
CodeGenHelpers.cpp
More information about the Mlir-commits
mailing list