[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
This commit is contained in:
Stephen Neuendorffer 2020-02-26 16:31:14 -08:00
parent 5869552821
commit c07fb9e016
20 changed files with 30 additions and 45 deletions

View File

@ -54,3 +54,9 @@ function(add_mlir_dialect_library name)
set_property(GLOBAL APPEND PROPERTY MLIR_DIALECT_LIBS ${name}) set_property(GLOBAL APPEND PROPERTY MLIR_DIALECT_LIBS ${name})
add_llvm_library(${ARGV}) add_llvm_library(${ARGV})
endfunction(add_mlir_dialect_library) 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)

View File

@ -28,18 +28,17 @@ include_directories(include/)
include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/) include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS) get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS)
target_link_libraries(toyc-ch6 target_link_libraries(toyc-ch6
PRIVATE PRIVATE
${dialect_libs} ${dialect_libs}
MLIRAffineToStandard ${conversion_libs}
MLIRAnalysis MLIRAnalysis
MLIRExecutionEngine MLIRExecutionEngine
MLIRIR MLIRIR
MLIRLLVMIR MLIRLLVMIR
MLIRLoopToStandard
MLIRParser MLIRParser
MLIRPass MLIRPass
MLIRStandardToLLVM
MLIRTargetLLVMIR MLIRTargetLLVMIR
MLIRTransforms MLIRTransforms
) )

View File

@ -28,17 +28,16 @@ include_directories(include/)
include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/) include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS) get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS)
target_link_libraries(toyc-ch7 target_link_libraries(toyc-ch7
PRIVATE PRIVATE
${dialect_libs} ${dialect_libs}
MLIRAffineToStandard ${conversion_libs}
MLIRAnalysis MLIRAnalysis
MLIRExecutionEngine MLIRExecutionEngine
MLIRIR MLIRIR
MLIRLoopToStandard
MLIRParser MLIRParser
MLIRPass MLIRPass
MLIRStandardToLLVM
MLIRTargetLLVMIR MLIRTargetLLVMIR
MLIRTransforms MLIRTransforms
) )

View File

@ -1,4 +1,4 @@
add_llvm_library(MLIRAffineToStandard add_mlir_conversion_library(MLIRAffineToStandard
AffineToStandard.cpp AffineToStandard.cpp
ADDITIONAL_HEADER_DIRS ADDITIONAL_HEADER_DIRS

View File

@ -10,7 +10,7 @@ if (MLIR_CUDA_CONVERSIONS_ENABLED)
list(APPEND SOURCES "ConvertKernelFuncToCubin.cpp") list(APPEND SOURCES "ConvertKernelFuncToCubin.cpp")
endif() endif()
add_llvm_library(MLIRGPUtoCUDATransforms ${SOURCES}) add_mlir_conversion_library(MLIRGPUtoCUDATransforms ${SOURCES})
target_link_libraries(MLIRGPUtoCUDATransforms target_link_libraries(MLIRGPUtoCUDATransforms
MLIRGPU MLIRGPU
MLIRLLVMIR MLIRLLVMIR

View File

@ -2,7 +2,7 @@ set(LLVM_TARGET_DEFINITIONS GPUToNVVM.td)
mlir_tablegen(GPUToNVVM.cpp.inc -gen-rewriters) mlir_tablegen(GPUToNVVM.cpp.inc -gen-rewriters)
add_public_tablegen_target(MLIRGPUToNVVMIncGen) add_public_tablegen_target(MLIRGPUToNVVMIncGen)
add_llvm_library(MLIRGPUtoNVVMTransforms add_mlir_conversion_library(MLIRGPUtoNVVMTransforms
LowerGpuOpsToNVVMOps.cpp LowerGpuOpsToNVVMOps.cpp
) )

View File

@ -1,4 +1,4 @@
add_llvm_library(MLIRGPUtoROCDLTransforms add_mlir_conversion_library(MLIRGPUtoROCDLTransforms
LowerGpuOpsToROCDLOps.cpp LowerGpuOpsToROCDLOps.cpp
) )
target_link_libraries(MLIRGPUtoROCDLTransforms target_link_libraries(MLIRGPUtoROCDLTransforms

View File

@ -2,7 +2,7 @@ set(LLVM_TARGET_DEFINITIONS GPUToSPIRV.td)
mlir_tablegen(GPUToSPIRV.cpp.inc -gen-rewriters) mlir_tablegen(GPUToSPIRV.cpp.inc -gen-rewriters)
add_public_tablegen_target(MLIRGPUToSPIRVIncGen) add_public_tablegen_target(MLIRGPUToSPIRVIncGen)
add_llvm_library(MLIRGPUtoSPIRVTransforms add_mlir_conversion_library(MLIRGPUtoSPIRVTransforms
ConvertGPUToSPIRV.cpp ConvertGPUToSPIRV.cpp
ConvertGPUToSPIRVPass.cpp ConvertGPUToSPIRVPass.cpp
) )

View File

@ -1,4 +1,4 @@
add_llvm_library(MLIRGPUtoVulkanTransforms add_mlir_conversion_library(MLIRGPUtoVulkanTransforms
ConvertLaunchFuncToVulkanCalls.cpp ConvertLaunchFuncToVulkanCalls.cpp
) )

View File

@ -1,4 +1,4 @@
add_llvm_library(MLIRLinalgToLLVM add_mlir_conversion_library(MLIRLinalgToLLVM
LinalgToLLVM.cpp LinalgToLLVM.cpp
ADDITIONAL_HEADER_DIRS ADDITIONAL_HEADER_DIRS

View File

@ -1,4 +1,4 @@
add_llvm_library(MLIRLinalgToSPIRVTransforms add_mlir_conversion_library(MLIRLinalgToSPIRVTransforms
LinalgToSPIRV.cpp LinalgToSPIRV.cpp
LinalgToSPIRVPass.cpp LinalgToSPIRVPass.cpp

View File

@ -1,4 +1,4 @@
add_llvm_library(MLIRLoopToStandard add_mlir_conversion_library(MLIRLoopToStandard
ConvertLoopToStandard.cpp ConvertLoopToStandard.cpp
ADDITIONAL_HEADER_DIRS ADDITIONAL_HEADER_DIRS

View File

@ -11,7 +11,7 @@ set(LIBS
LLVMSupport LLVMSupport
) )
add_llvm_library(MLIRLoopsToGPU add_mlir_conversion_library(MLIRLoopsToGPU
LoopsToGPU.cpp LoopsToGPU.cpp
LoopsToGPUPass.cpp LoopsToGPUPass.cpp

View File

@ -1,4 +1,4 @@
add_llvm_library(MLIRStandardToLLVM add_mlir_conversion_library(MLIRStandardToLLVM
ConvertStandardToLLVM.cpp ConvertStandardToLLVM.cpp
ADDITIONAL_HEADER_DIRS ADDITIONAL_HEADER_DIRS

View File

@ -2,7 +2,7 @@ set(LLVM_TARGET_DEFINITIONS StandardToSPIRV.td)
mlir_tablegen(StandardToSPIRV.cpp.inc -gen-rewriters) mlir_tablegen(StandardToSPIRV.cpp.inc -gen-rewriters)
add_public_tablegen_target(MLIRStandardToSPIRVIncGen) add_public_tablegen_target(MLIRStandardToSPIRVIncGen)
add_llvm_library(MLIRStandardToSPIRVTransforms add_mlir_conversion_library(MLIRStandardToSPIRVTransforms
ConvertStandardToSPIRV.cpp ConvertStandardToSPIRV.cpp
ConvertStandardToSPIRVPass.cpp ConvertStandardToSPIRVPass.cpp
LegalizeStandardForSPIRV.cpp LegalizeStandardForSPIRV.cpp

View File

@ -1,4 +1,4 @@
add_llvm_library(MLIRVectorToLLVM add_mlir_conversion_library(MLIRVectorToLLVM
ConvertVectorToLLVM.cpp ConvertVectorToLLVM.cpp
ADDITIONAL_HEADER_DIRS ADDITIONAL_HEADER_DIRS

View File

@ -1,4 +1,4 @@
add_llvm_library(MLIRVectorToLoops add_mlir_conversion_library(MLIRVectorToLoops
ConvertVectorToLoops.cpp ConvertVectorToLoops.cpp
ADDITIONAL_HEADER_DIRS ADDITIONAL_HEADER_DIRS

View File

@ -36,20 +36,18 @@ if(MLIR_CUDA_RUNNER_ENABLED)
) )
get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS) get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS)
set(LIBS set(LIBS
${dialect_libs} ${dialect_libs}
${conversion_libs}
LLVMCore LLVMCore
LLVMSupport LLVMSupport
MLIRJitRunner MLIRJitRunner
MLIRAnalysis MLIRAnalysis
MLIREDSC MLIREDSC
MLIRExecutionEngine MLIRExecutionEngine
MLIRGPUtoCUDATransforms
MLIRGPUtoNVVMTransforms
MLIRIR MLIRIR
MLIRLoopToStandard
MLIRParser MLIRParser
MLIRStandardToLLVM
MLIRSupport MLIRSupport
MLIRTargetLLVMIR MLIRTargetLLVMIR
MLIRTransforms MLIRTransforms

View File

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

View File

@ -52,24 +52,20 @@ if (MLIR_VULKAN_RUNNER_ENABLED)
) )
get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS) get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS)
set(LIBS set(LIBS
${dialect_libs} ${dialect_libs}
${conversion_libs}
LLVMCore LLVMCore
LLVMSupport LLVMSupport
MLIRJitRunner MLIRJitRunner
MLIRAnalysis MLIRAnalysis
MLIREDSC MLIREDSC
MLIRExecutionEngine MLIRExecutionEngine
MLIRGPUtoCUDATransforms
MLIRGPUtoNVVMTransforms
MLIRGPUtoSPIRVTransforms
MLIRGPUtoVulkanTransforms
MLIRIR MLIRIR
MLIRLLVMIR MLIRLLVMIR
MLIRLoopToStandard
MLIRParser MLIRParser
MLIRSPIRVTransforms MLIRSPIRVTransforms
MLIRStandardToLLVM
MLIRSupport MLIRSupport
MLIRTargetLLVMIR MLIRTargetLLVMIR
MLIRTransforms MLIRTransforms