File tree Expand file tree Collapse file tree 19 files changed +79
-26
lines changed Expand file tree Collapse file tree 19 files changed +79
-26
lines changed Original file line number Diff line number Diff line change @@ -34,9 +34,11 @@ include_directories( ${MLIR_INCLUDE_DIR})
34
34
35
35
add_subdirectory (include /mlir )
36
36
add_subdirectory (lib )
37
- add_subdirectory (tools )
38
37
add_subdirectory (unittests )
39
38
add_subdirectory (test )
39
+ # Tools needs to come late to ensure that MLIR_ALL_LIBS is populated.
40
+ # Generally things after this point may depend on MLIR_ALL_LIBS or libMLIR.so.
41
+ add_subdirectory (tools )
40
42
41
43
if ( LLVM_INCLUDE_EXAMPLES )
42
44
add_subdirectory (examples )
Original file line number Diff line number Diff line change @@ -49,14 +49,20 @@ function(add_mlir_dialect dialect dialect_doc_filename)
49
49
add_dependencies (mlir-doc ${dialect_doc_filename} DocGen )
50
50
endfunction ()
51
51
52
+ # Declare a library which can be compiled in libMLIR.so
53
+ macro (add_mlir_library name )
54
+ set_property (GLOBAL APPEND PROPERTY MLIR_ALL_LIBS ${name} )
55
+ add_llvm_library (${ARGV} )
56
+ endmacro (add_mlir_library )
57
+
52
58
# Declare the library associated with a dialect.
53
59
function (add_mlir_dialect_library name )
54
60
set_property (GLOBAL APPEND PROPERTY MLIR_DIALECT_LIBS ${name} )
55
- add_llvm_library (${ARGV} )
61
+ add_mlir_library (${ARGV} )
56
62
endfunction (add_mlir_dialect_library )
57
63
58
64
# Declare the library associated with a conversion.
59
65
function (add_mlir_conversion_library name )
60
66
set_property (GLOBAL APPEND PROPERTY MLIR_CONVERSION_LIBS ${name} )
61
- add_llvm_library (${ARGV} )
67
+ add_mlir_library (${ARGV} )
62
68
endfunction (add_mlir_conversion_library )
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ set(LLVM_OPTIONAL_SOURCES
12
12
Verifier.cpp
13
13
)
14
14
15
- add_llvm_library (MLIRAnalysis
15
+ add_mlir_library (MLIRAnalysis
16
16
CallGraph.cpp
17
17
InferTypeOpInterface.cpp
18
18
Liveness.cpp
@@ -35,7 +35,7 @@ add_llvm_library(MLIRAnalysis
35
35
LLVMSupport
36
36
)
37
37
38
- add_llvm_library (MLIRLoopAnalysis
38
+ add_mlir_library (MLIRLoopAnalysis
39
39
AffineAnalysis.cpp
40
40
AffineStructures.cpp
41
41
LoopAnalysis.cpp
Original file line number Diff line number Diff line change @@ -12,12 +12,11 @@ add_subdirectory(SPIRV)
12
12
add_subdirectory (StandardOps )
13
13
add_subdirectory (VectorOps )
14
14
15
-
16
15
set (LLVM_OPTIONAL_SOURCES
17
16
Traits.cpp
18
17
)
19
18
20
- add_llvm_library (MLIRDialect
19
+ add_mlir_library (MLIRDialect
21
20
Traits.cpp
22
21
23
22
ADDITIONAL_HEADER_DIRS
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ set(LLVM_OPTIONAL_SOURCES
3
3
CoreAPIs.cpp
4
4
)
5
5
6
- add_llvm_library (MLIREDSC
6
+ add_mlir_library (MLIREDSC
7
7
Builders.cpp
8
8
9
9
ADDITIONAL_HEADER_DIRS
@@ -15,7 +15,7 @@ add_llvm_library(MLIREDSC
15
15
LLVMSupport
16
16
)
17
17
18
- add_llvm_library (MLIREDSCInterface
18
+ add_mlir_library (MLIREDSCInterface
19
19
CoreAPIs.cpp
20
20
21
21
ADDITIONAL_HEADER_DIRS
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ set(LLVM_OPTIONAL_SOURCES
6
6
)
7
7
8
8
llvm_map_components_to_libnames (outlibs "nativecodegen" "IPO" )
9
- add_llvm_library (MLIRExecutionEngine
9
+ add_mlir_library (MLIRExecutionEngine
10
10
ExecutionEngine.cpp
11
11
OptUtils.cpp
12
12
Original file line number Diff line number Diff line change 1
1
file (GLOB globbed *.c *.cpp )
2
- add_llvm_library (MLIRIR
2
+ add_mlir_library (MLIRIR
3
3
${globbed}
4
4
5
5
ADDITIONAL_HEADER_DIRS
Original file line number Diff line number Diff line change 1
- add_llvm_library (MLIRParser
1
+ add_mlir_library (MLIRParser
2
2
Lexer.cpp
3
3
Parser.cpp
4
4
Token.cpp
Original file line number Diff line number Diff line change 1
1
file (GLOB globbed *.c *.cpp )
2
- add_llvm_library (MLIRPass
2
+ add_mlir_library (MLIRPass
3
3
${globbed}
4
4
5
5
ADDITIONAL_HEADER_DIRS
Original file line number Diff line number Diff line change 1
1
# Support.
2
- add_llvm_library (MLIRQuantizerSupport
2
+ add_mlir_library (MLIRQuantizerSupport
3
3
Support/Configuration.cpp
4
4
Support/ConstraintAnalysisGraph.cpp
5
5
Support/Metadata.cpp
@@ -19,7 +19,7 @@ add_llvm_library(MLIRQuantizerSupport
19
19
)
20
20
21
21
# Configurations.
22
- add_llvm_library (MLIRQuantizerFxpMathConfig
22
+ add_mlir_library (MLIRQuantizerFxpMathConfig
23
23
Configurations /FxpMathConfig.cpp
24
24
25
25
ADDITIONAL_HEADER_DIRS
@@ -38,7 +38,7 @@ add_llvm_library(MLIRQuantizerFxpMathConfig
38
38
)
39
39
40
40
# Transforms.
41
- add_llvm_library (MLIRQuantizerTransforms
41
+ add_mlir_library (MLIRQuantizerTransforms
42
42
Transforms/AddDefaultStatsTestPass.cpp
43
43
Transforms/InferQuantizedTypesPass.cpp
44
44
Transforms/RemoveInstrumentationPass.cpp
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ set(LLVM_OPTIONAL_SOURCES
7
7
TranslateClParser.cpp
8
8
)
9
9
10
- add_llvm_library (MLIRSupport
10
+ add_mlir_library (MLIRSupport
11
11
FileUtilities.cpp
12
12
StorageUniquer.cpp
13
13
ToolUtilities.cpp
@@ -20,7 +20,7 @@ add_llvm_library(MLIRSupport
20
20
${LLVM_PTHREAD_LIB}
21
21
)
22
22
23
- add_llvm_library (MLIROptLib
23
+ add_mlir_library (MLIROptLib
24
24
MlirOptMain.cpp
25
25
26
26
ADDITIONAL_HEADER_DIRS
@@ -34,7 +34,7 @@ add_llvm_library(MLIROptLib
34
34
LLVMSupport
35
35
)
36
36
37
- add_llvm_library (MLIRTranslateClParser
37
+ add_mlir_library (MLIRTranslateClParser
38
38
TranslateClParser.cpp
39
39
40
40
ADDITIONAL_HEADER_DIRS
Original file line number Diff line number Diff line change 1
- add_llvm_library (MLIRTargetLLVMIRModuleTranslation
1
+ add_mlir_library (MLIRTargetLLVMIRModuleTranslation
2
2
LLVMIR/DebugTranslation.cpp
3
3
LLVMIR/ModuleTranslation.cpp
4
4
@@ -19,7 +19,7 @@ add_llvm_library(MLIRTargetLLVMIRModuleTranslation
19
19
MLIRTranslation
20
20
)
21
21
22
- add_llvm_library (MLIRTargetLLVMIR
22
+ add_mlir_library (MLIRTargetLLVMIR
23
23
LLVMIR/ConvertFromLLVMIR.cpp
24
24
LLVMIR/ConvertToLLVMIR.cpp
25
25
@@ -36,7 +36,8 @@ add_llvm_library(MLIRTargetLLVMIR
36
36
LLVMIRReader
37
37
LLVMSupport
38
38
)
39
- add_llvm_library (MLIRTargetNVVMIR
39
+
40
+ add_mlir_library (MLIRTargetNVVMIR
40
41
LLVMIR/ConvertToNVVMIR.cpp
41
42
42
43
ADDITIONAL_HEADER_DIRS
@@ -56,7 +57,7 @@ add_llvm_library(MLIRTargetNVVMIR
56
57
LLVMSupport
57
58
)
58
59
59
- add_llvm_library (MLIRTargetROCDLIR
60
+ add_mlir_library (MLIRTargetROCDLIR
60
61
LLVMIR/ConvertToROCDLIR.cpp
61
62
62
63
ADDITIONAL_HEADER_DIRS
Original file line number Diff line number Diff line change 1
1
add_subdirectory (Utils )
2
2
3
- add_llvm_library (MLIRTransforms
3
+ add_mlir_library (MLIRTransforms
4
4
AffineDataCopyGeneration.cpp
5
5
AffineLoopInvariantCodeMotion.cpp
6
6
Canonicalizer.cpp
Original file line number Diff line number Diff line change 1
- add_llvm_library (MLIRTransformUtils
1
+ add_mlir_library (MLIRTransformUtils
2
2
FoldUtils.cpp
3
3
GreedyPatternRewriteDriver.cpp
4
4
InliningUtils.cpp
Original file line number Diff line number Diff line change 1
- add_llvm_library (MLIRTranslation
1
+ add_mlir_library (MLIRTranslation
2
2
Translation.cpp
3
3
4
4
ADDITIONAL_HEADER_DIRS
Original file line number Diff line number Diff line change @@ -4,3 +4,4 @@ add_subdirectory(mlir-opt)
4
4
add_subdirectory (mlir-tblgen )
5
5
add_subdirectory (mlir-translate )
6
6
add_subdirectory (mlir-vulkan-runner )
7
+ add_subdirectory (mlir-shlib )
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ set(LLVM_OPTIONAL_SOURCES
4
4
5
5
set (LIB_LIBS
6
6
MLIRAnalysis
7
+ MLIRIR
7
8
MLIRLLVMIR
8
9
MLIROptLib
9
10
MLIRParser
Original file line number Diff line number Diff line change
1
+ # Building libmlir-cpp.so fails if LLVM_ENABLE_PIC=Off
2
+ if (NOT LLVM_ENABLE_PIC )
3
+ return ()
4
+ endif ()
5
+
6
+ # Building libmlir-cpp.so may not work on MSVC
7
+ if (MSVC )
8
+ return ()
9
+ endif ()
10
+
11
+ get_property (mlir_libs GLOBAL PROPERTY MLIR_ALL_LIBS )
12
+ list (REMOVE_DUPLICATES mlir_libs )
13
+
14
+ foreach (lib ${mlir_libs} )
15
+ if (XCODE )
16
+ # Xcode doesn't support object libraries, so we have to trick it into
17
+ # linking the static libraries instead.
18
+ list (APPEND _DEPS "-force_load" ${lib} )
19
+ else ()
20
+ list (APPEND _OBJECTS $< TARGET_OBJECTS:obj.${lib} > )
21
+ endif ()
22
+ list (APPEND _DEPS $< TARGET_PROPERTY:${lib} ,LINK_LIBRARIES> )
23
+ endforeach ()
24
+
25
+ if (MLIR_LINK_MLIR_DYLIB )
26
+ set (INSTALL_WITH_TOOLCHAIN INSTALL_WITH_TOOLCHAIN )
27
+ endif ()
28
+
29
+ # libMLIR.so depends on LLVM components. To avoid multiple
30
+ # copies of those LLVM components, libMLIR.so depends on libLLVM.so.
31
+ # This probably won't work if some LLVM components are not included
32
+ # in libLLVM.so.
33
+ if (LLVM_BUILD_LLVM_DYLIB )
34
+ add_llvm_library (MLIR
35
+ SHARED
36
+ ${INSTALL_WITH_TOOLCHAIN}
37
+
38
+ mlir-shlib.cpp
39
+ )
40
+ target_link_libraries (MLIR PRIVATE LLVM ${LLVM_PTHREAD_LIB} )
41
+ whole_archive_link (MLIR ${mlir_libs} )
42
+ endif ()
Original file line number Diff line number Diff line change
1
+ // Intentionally empty source file to make CMake happy
You can’t perform that action at this time.
0 commit comments