[Mlir-commits] [mlir] c07fb9e - [MLIR] Refactor library handling for conversions.

Stephen Neuendorffer llvmlistbot at llvm.org
Fri Feb 28 11:39:39 PST 2020


Author: Stephen Neuendorffer
Date: 2020-02-28T11:35:17-08:00
New Revision: c07fb9e016b3b1190a66e02a6aa212dbe8c1a3e3

URL: https://github.com/llvm/llvm-project/commit/c07fb9e016b3b1190a66e02a6aa212dbe8c1a3e3
DIFF: https://github.com/llvm/llvm-project/commit/c07fb9e016b3b1190a66e02a6aa212dbe8c1a3e3.diff

LOG: [MLIR] Refactor library handling for conversions.

Collect a list of conversion libraries in cmake, so we don't have to
list these explicitly in most binaries.

Differential Revision: https://reviews.llvm.org/D75222

Added: 
    

Modified: 
    mlir/cmake/modules/AddMLIR.cmake
    mlir/examples/toy/Ch6/CMakeLists.txt
    mlir/examples/toy/Ch7/CMakeLists.txt
    mlir/lib/Conversion/AffineToStandard/CMakeLists.txt
    mlir/lib/Conversion/GPUToCUDA/CMakeLists.txt
    mlir/lib/Conversion/GPUToNVVM/CMakeLists.txt
    mlir/lib/Conversion/GPUToROCDL/CMakeLists.txt
    mlir/lib/Conversion/GPUToSPIRV/CMakeLists.txt
    mlir/lib/Conversion/GPUToVulkan/CMakeLists.txt
    mlir/lib/Conversion/LinalgToLLVM/CMakeLists.txt
    mlir/lib/Conversion/LinalgToSPIRV/CMakeLists.txt
    mlir/lib/Conversion/LoopToStandard/CMakeLists.txt
    mlir/lib/Conversion/LoopsToGPU/CMakeLists.txt
    mlir/lib/Conversion/StandardToLLVM/CMakeLists.txt
    mlir/lib/Conversion/StandardToSPIRV/CMakeLists.txt
    mlir/lib/Conversion/VectorToLLVM/CMakeLists.txt
    mlir/lib/Conversion/VectorToLoops/CMakeLists.txt
    mlir/tools/mlir-cuda-runner/CMakeLists.txt
    mlir/tools/mlir-opt/CMakeLists.txt
    mlir/tools/mlir-vulkan-runner/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/mlir/cmake/modules/AddMLIR.cmake b/mlir/cmake/modules/AddMLIR.cmake
index 125a18d9c8d0..d8944532c6ff 100644
--- a/mlir/cmake/modules/AddMLIR.cmake
+++ b/mlir/cmake/modules/AddMLIR.cmake
@@ -54,3 +54,9 @@ function(add_mlir_dialect_library name)
   set_property(GLOBAL APPEND PROPERTY MLIR_DIALECT_LIBS ${name})
   add_llvm_library(${ARGV})
 endfunction(add_mlir_dialect_library)
+
+# Declare the library associated with a conversion.
+function(add_mlir_conversion_library name)
+  set_property(GLOBAL APPEND PROPERTY MLIR_CONVERSION_LIBS ${name})
+  add_llvm_library(${ARGV})
+endfunction(add_mlir_conversion_library)

diff  --git a/mlir/examples/toy/Ch6/CMakeLists.txt b/mlir/examples/toy/Ch6/CMakeLists.txt
index 054033399614..e46200d3f9ad 100644
--- a/mlir/examples/toy/Ch6/CMakeLists.txt
+++ b/mlir/examples/toy/Ch6/CMakeLists.txt
@@ -28,18 +28,17 @@ include_directories(include/)
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
 get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
+get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS)
 target_link_libraries(toyc-ch6
   PRIVATE
     ${dialect_libs}
-    MLIRAffineToStandard
+    ${conversion_libs}
     MLIRAnalysis
     MLIRExecutionEngine
     MLIRIR
     MLIRLLVMIR
-    MLIRLoopToStandard
     MLIRParser
     MLIRPass
-    MLIRStandardToLLVM
     MLIRTargetLLVMIR
     MLIRTransforms
     )

diff  --git a/mlir/examples/toy/Ch7/CMakeLists.txt b/mlir/examples/toy/Ch7/CMakeLists.txt
index 8f5e5f00ef92..7f67cc9519ec 100644
--- a/mlir/examples/toy/Ch7/CMakeLists.txt
+++ b/mlir/examples/toy/Ch7/CMakeLists.txt
@@ -28,17 +28,16 @@ include_directories(include/)
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
 get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
+get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS)
 target_link_libraries(toyc-ch7
   PRIVATE
     ${dialect_libs}
-    MLIRAffineToStandard
+    ${conversion_libs}
     MLIRAnalysis
     MLIRExecutionEngine
     MLIRIR
-    MLIRLoopToStandard
     MLIRParser
     MLIRPass
-    MLIRStandardToLLVM
     MLIRTargetLLVMIR
     MLIRTransforms
     )

diff  --git a/mlir/lib/Conversion/AffineToStandard/CMakeLists.txt b/mlir/lib/Conversion/AffineToStandard/CMakeLists.txt
index 7a665a6d3a69..9d639e034b66 100644
--- a/mlir/lib/Conversion/AffineToStandard/CMakeLists.txt
+++ b/mlir/lib/Conversion/AffineToStandard/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_llvm_library(MLIRAffineToStandard
+add_mlir_conversion_library(MLIRAffineToStandard
   AffineToStandard.cpp
 
   ADDITIONAL_HEADER_DIRS

diff  --git a/mlir/lib/Conversion/GPUToCUDA/CMakeLists.txt b/mlir/lib/Conversion/GPUToCUDA/CMakeLists.txt
index 484bc9dbd89c..65c976ce9a38 100644
--- a/mlir/lib/Conversion/GPUToCUDA/CMakeLists.txt
+++ b/mlir/lib/Conversion/GPUToCUDA/CMakeLists.txt
@@ -10,7 +10,7 @@ if (MLIR_CUDA_CONVERSIONS_ENABLED)
  list(APPEND SOURCES "ConvertKernelFuncToCubin.cpp")
 endif()
 
-add_llvm_library(MLIRGPUtoCUDATransforms ${SOURCES})
+add_mlir_conversion_library(MLIRGPUtoCUDATransforms ${SOURCES})
 target_link_libraries(MLIRGPUtoCUDATransforms
   MLIRGPU
   MLIRLLVMIR

diff  --git a/mlir/lib/Conversion/GPUToNVVM/CMakeLists.txt b/mlir/lib/Conversion/GPUToNVVM/CMakeLists.txt
index d0706b5537af..339b2b79a439 100644
--- a/mlir/lib/Conversion/GPUToNVVM/CMakeLists.txt
+++ b/mlir/lib/Conversion/GPUToNVVM/CMakeLists.txt
@@ -2,7 +2,7 @@ set(LLVM_TARGET_DEFINITIONS GPUToNVVM.td)
 mlir_tablegen(GPUToNVVM.cpp.inc -gen-rewriters)
 add_public_tablegen_target(MLIRGPUToNVVMIncGen)
 
-add_llvm_library(MLIRGPUtoNVVMTransforms
+add_mlir_conversion_library(MLIRGPUtoNVVMTransforms
   LowerGpuOpsToNVVMOps.cpp
   )
 

diff  --git a/mlir/lib/Conversion/GPUToROCDL/CMakeLists.txt b/mlir/lib/Conversion/GPUToROCDL/CMakeLists.txt
index a32d9e8f7088..778689859a84 100644
--- a/mlir/lib/Conversion/GPUToROCDL/CMakeLists.txt
+++ b/mlir/lib/Conversion/GPUToROCDL/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_llvm_library(MLIRGPUtoROCDLTransforms
+add_mlir_conversion_library(MLIRGPUtoROCDLTransforms
   LowerGpuOpsToROCDLOps.cpp
   )
 target_link_libraries(MLIRGPUtoROCDLTransforms

diff  --git a/mlir/lib/Conversion/GPUToSPIRV/CMakeLists.txt b/mlir/lib/Conversion/GPUToSPIRV/CMakeLists.txt
index adeb4e099ab9..e59c48e4a614 100644
--- a/mlir/lib/Conversion/GPUToSPIRV/CMakeLists.txt
+++ b/mlir/lib/Conversion/GPUToSPIRV/CMakeLists.txt
@@ -2,7 +2,7 @@ set(LLVM_TARGET_DEFINITIONS GPUToSPIRV.td)
 mlir_tablegen(GPUToSPIRV.cpp.inc -gen-rewriters)
 add_public_tablegen_target(MLIRGPUToSPIRVIncGen)
 
-add_llvm_library(MLIRGPUtoSPIRVTransforms
+add_mlir_conversion_library(MLIRGPUtoSPIRVTransforms
   ConvertGPUToSPIRV.cpp
   ConvertGPUToSPIRVPass.cpp
   )

diff  --git a/mlir/lib/Conversion/GPUToVulkan/CMakeLists.txt b/mlir/lib/Conversion/GPUToVulkan/CMakeLists.txt
index 491a1caa544c..69c1c4e8b06d 100644
--- a/mlir/lib/Conversion/GPUToVulkan/CMakeLists.txt
+++ b/mlir/lib/Conversion/GPUToVulkan/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_llvm_library(MLIRGPUtoVulkanTransforms
+add_mlir_conversion_library(MLIRGPUtoVulkanTransforms
   ConvertLaunchFuncToVulkanCalls.cpp
   )
 

diff  --git a/mlir/lib/Conversion/LinalgToLLVM/CMakeLists.txt b/mlir/lib/Conversion/LinalgToLLVM/CMakeLists.txt
index b8c8d9a8b382..c63411796465 100644
--- a/mlir/lib/Conversion/LinalgToLLVM/CMakeLists.txt
+++ b/mlir/lib/Conversion/LinalgToLLVM/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_llvm_library(MLIRLinalgToLLVM
+add_mlir_conversion_library(MLIRLinalgToLLVM
   LinalgToLLVM.cpp
 
   ADDITIONAL_HEADER_DIRS

diff  --git a/mlir/lib/Conversion/LinalgToSPIRV/CMakeLists.txt b/mlir/lib/Conversion/LinalgToSPIRV/CMakeLists.txt
index a9bf51a2269b..5f00034abae9 100644
--- a/mlir/lib/Conversion/LinalgToSPIRV/CMakeLists.txt
+++ b/mlir/lib/Conversion/LinalgToSPIRV/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_llvm_library(MLIRLinalgToSPIRVTransforms
+add_mlir_conversion_library(MLIRLinalgToSPIRVTransforms
   LinalgToSPIRV.cpp
   LinalgToSPIRVPass.cpp
 

diff  --git a/mlir/lib/Conversion/LoopToStandard/CMakeLists.txt b/mlir/lib/Conversion/LoopToStandard/CMakeLists.txt
index 8f05dbd0b633..4297346a10bf 100644
--- a/mlir/lib/Conversion/LoopToStandard/CMakeLists.txt
+++ b/mlir/lib/Conversion/LoopToStandard/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_llvm_library(MLIRLoopToStandard
+add_mlir_conversion_library(MLIRLoopToStandard
   ConvertLoopToStandard.cpp
 
   ADDITIONAL_HEADER_DIRS

diff  --git a/mlir/lib/Conversion/LoopsToGPU/CMakeLists.txt b/mlir/lib/Conversion/LoopsToGPU/CMakeLists.txt
index e1bf962fdd15..c2f3c2a7f852 100644
--- a/mlir/lib/Conversion/LoopsToGPU/CMakeLists.txt
+++ b/mlir/lib/Conversion/LoopsToGPU/CMakeLists.txt
@@ -11,7 +11,7 @@ set(LIBS
   LLVMSupport
 )
 
-add_llvm_library(MLIRLoopsToGPU
+add_mlir_conversion_library(MLIRLoopsToGPU
   LoopsToGPU.cpp
   LoopsToGPUPass.cpp
 

diff  --git a/mlir/lib/Conversion/StandardToLLVM/CMakeLists.txt b/mlir/lib/Conversion/StandardToLLVM/CMakeLists.txt
index 3ce7b9fc6555..3e8f72bb60c5 100644
--- a/mlir/lib/Conversion/StandardToLLVM/CMakeLists.txt
+++ b/mlir/lib/Conversion/StandardToLLVM/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_llvm_library(MLIRStandardToLLVM
+add_mlir_conversion_library(MLIRStandardToLLVM
   ConvertStandardToLLVM.cpp
 
   ADDITIONAL_HEADER_DIRS

diff  --git a/mlir/lib/Conversion/StandardToSPIRV/CMakeLists.txt b/mlir/lib/Conversion/StandardToSPIRV/CMakeLists.txt
index fcced23a95e8..f02f68db7bb1 100644
--- a/mlir/lib/Conversion/StandardToSPIRV/CMakeLists.txt
+++ b/mlir/lib/Conversion/StandardToSPIRV/CMakeLists.txt
@@ -2,7 +2,7 @@ set(LLVM_TARGET_DEFINITIONS StandardToSPIRV.td)
 mlir_tablegen(StandardToSPIRV.cpp.inc -gen-rewriters)
 add_public_tablegen_target(MLIRStandardToSPIRVIncGen)
 
-add_llvm_library(MLIRStandardToSPIRVTransforms
+add_mlir_conversion_library(MLIRStandardToSPIRVTransforms
   ConvertStandardToSPIRV.cpp
   ConvertStandardToSPIRVPass.cpp
   LegalizeStandardForSPIRV.cpp

diff  --git a/mlir/lib/Conversion/VectorToLLVM/CMakeLists.txt b/mlir/lib/Conversion/VectorToLLVM/CMakeLists.txt
index 352353c33be5..5a89f399516c 100644
--- a/mlir/lib/Conversion/VectorToLLVM/CMakeLists.txt
+++ b/mlir/lib/Conversion/VectorToLLVM/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_llvm_library(MLIRVectorToLLVM
+add_mlir_conversion_library(MLIRVectorToLLVM
   ConvertVectorToLLVM.cpp
 
   ADDITIONAL_HEADER_DIRS

diff  --git a/mlir/lib/Conversion/VectorToLoops/CMakeLists.txt b/mlir/lib/Conversion/VectorToLoops/CMakeLists.txt
index 187a84de91e1..0dccea93b234 100644
--- a/mlir/lib/Conversion/VectorToLoops/CMakeLists.txt
+++ b/mlir/lib/Conversion/VectorToLoops/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_llvm_library(MLIRVectorToLoops
+add_mlir_conversion_library(MLIRVectorToLoops
   ConvertVectorToLoops.cpp
 
   ADDITIONAL_HEADER_DIRS

diff  --git a/mlir/tools/mlir-cuda-runner/CMakeLists.txt b/mlir/tools/mlir-cuda-runner/CMakeLists.txt
index e9fb74025861..3c6dcbaec7ba 100644
--- a/mlir/tools/mlir-cuda-runner/CMakeLists.txt
+++ b/mlir/tools/mlir-cuda-runner/CMakeLists.txt
@@ -36,20 +36,18 @@ if(MLIR_CUDA_RUNNER_ENABLED)
   )
 
   get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
+  get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS)
   set(LIBS
     ${dialect_libs}
+    ${conversion_libs}
     LLVMCore
     LLVMSupport
     MLIRJitRunner
     MLIRAnalysis
     MLIREDSC
     MLIRExecutionEngine
-    MLIRGPUtoCUDATransforms
-    MLIRGPUtoNVVMTransforms
     MLIRIR
-    MLIRLoopToStandard
     MLIRParser
-    MLIRStandardToLLVM
     MLIRSupport
     MLIRTargetLLVMIR
     MLIRTransforms

diff  --git a/mlir/tools/mlir-opt/CMakeLists.txt b/mlir/tools/mlir-opt/CMakeLists.txt
index d7b96d029530..b415bf97b63d 100644
--- a/mlir/tools/mlir-opt/CMakeLists.txt
+++ b/mlir/tools/mlir-opt/CMakeLists.txt
@@ -19,23 +19,15 @@ target_link_libraries(MLIRMlirOptMain
 )
 
 get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
+get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS)
 set(LIBS
   ${dialect_libs}
+  ${conversion_libs}
   MLIRLoopOpsTransforms
   MLIRLoopAnalysis
   MLIRAnalysis
-  MLIRAffineToStandard
   MLIRDialect
-  MLIRLoopsToGPU
-  MLIRLinalgToLLVM
-
-  MLIRLoopToStandard
   MLIREDSC
-  MLIRGPUtoCUDATransforms
-  MLIRGPUtoNVVMTransforms
-  MLIRGPUtoROCDLTransforms
-  MLIRGPUtoSPIRVTransforms
-  MLIRGPUtoVulkanTransforms
   MLIROptLib
   MLIRParser
   MLIRPass
@@ -43,11 +35,8 @@ set(LIBS
   MLIRQuantizerSupport
   MLIRQuantizerTransforms
   MLIRSPIRV
-  MLIRLinalgToSPIRVTransforms
-  MLIRStandardToSPIRVTransforms
   MLIRSPIRVTestPasses
   MLIRSPIRVTransforms
-  MLIRStandardToLLVM
   MLIRTransforms
   MLIRTransformUtils
   MLIRTestDialect
@@ -55,8 +44,6 @@ set(LIBS
   MLIRTestPass
   MLIRTestTransforms
   MLIRSupport
-  MLIRVectorToLLVM
-  MLIRVectorToLoops
   MLIRIR
   MLIROptLib
   LLVMSupport

diff  --git a/mlir/tools/mlir-vulkan-runner/CMakeLists.txt b/mlir/tools/mlir-vulkan-runner/CMakeLists.txt
index f68ddab7c7b0..cadbeee5bf24 100644
--- a/mlir/tools/mlir-vulkan-runner/CMakeLists.txt
+++ b/mlir/tools/mlir-vulkan-runner/CMakeLists.txt
@@ -52,24 +52,20 @@ if (MLIR_VULKAN_RUNNER_ENABLED)
   )
 
   get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
+  get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS)
   set(LIBS
     ${dialect_libs}
+    ${conversion_libs}
     LLVMCore
     LLVMSupport
     MLIRJitRunner
     MLIRAnalysis
     MLIREDSC
     MLIRExecutionEngine
-    MLIRGPUtoCUDATransforms
-    MLIRGPUtoNVVMTransforms
-    MLIRGPUtoSPIRVTransforms
-    MLIRGPUtoVulkanTransforms
     MLIRIR
     MLIRLLVMIR
-    MLIRLoopToStandard
     MLIRParser
     MLIRSPIRVTransforms
-    MLIRStandardToLLVM
     MLIRSupport
     MLIRTargetLLVMIR
     MLIRTransforms


        


More information about the Mlir-commits mailing list