xref: /llvm-project/polly/lib/CMakeLists.txt (revision c16538feb15ec1d8125192c782210d1a7eac63d7)
1set(LLVM_NO_RTTI 1)
2
3set(ISL_CODEGEN_FILES
4    CodeGen/IslAst.cpp
5    CodeGen/IslExprBuilder.cpp
6    CodeGen/IslNodeBuilder.cpp
7    CodeGen/CodeGeneration.cpp)
8
9# Compile ISL into a separate library.
10add_subdirectory(External)
11
12set(POLLY_HEADER_FILES)
13if (MSVC_IDE OR XCODE)
14  file(GLOB_RECURSE POLLY_HEADER_FILES "${POLLY_SOURCE_DIR}/include/polly/*.h")
15endif ()
16
17set(POLLY_COMPONENTS
18    Support
19    Core
20    ScalarOpts
21    InstCombine
22    TransformUtils
23    Analysis
24    ipo
25    MC
26    Passes
27    Linker
28    IRReader
29    Analysis
30    # The libraries below are required for darwin: http://PR26392
31    BitReader
32    MCParser
33    Object
34    ProfileData
35    Target
36    TargetParser
37    Vectorize
38)
39
40# Use an object-library to add the same files to multiple libs without requiring
41# the sources them to be recompiled for each of them.
42add_llvm_pass_plugin(Polly
43  NO_MODULE
44  SUBPROJECT Polly
45  Analysis/DependenceInfo.cpp
46  Analysis/PolyhedralInfo.cpp
47  Analysis/ScopDetection.cpp
48  Analysis/ScopDetectionDiagnostic.cpp
49  Analysis/ScopInfo.cpp
50  Analysis/ScopBuilder.cpp
51  Analysis/ScopGraphPrinter.cpp
52  Analysis/ScopPass.cpp
53  Analysis/PruneUnprofitable.cpp
54  CodeGen/BlockGenerators.cpp
55  ${ISL_CODEGEN_FILES}
56  CodeGen/LoopGenerators.cpp
57  CodeGen/LoopGeneratorsGOMP.cpp
58  CodeGen/LoopGeneratorsKMP.cpp
59  CodeGen/IRBuilder.cpp
60  CodeGen/Utils.cpp
61  CodeGen/RuntimeDebugBuilder.cpp
62  CodeGen/PerfMonitor.cpp
63  Exchange/JSONExporter.cpp
64  Support/GICHelper.cpp
65  Support/PollyDebug.cpp
66  Support/SCEVAffinator.cpp
67  Support/SCEVValidator.cpp
68  Support/RegisterPasses.cpp
69  Support/ScopHelper.cpp
70  Support/ScopLocation.cpp
71  Support/ISLTools.cpp
72  Support/DumpModulePass.cpp
73  Support/DumpFunctionPass.cpp
74  Support/VirtualInstruction.cpp
75  Transform/Canonicalization.cpp
76  Transform/CodePreparation.cpp
77  Transform/DeadCodeElimination.cpp
78  Transform/ScheduleOptimizer.cpp
79  Transform/ScheduleTreeTransform.cpp
80  Transform/FlattenSchedule.cpp
81  Transform/FlattenAlgo.cpp
82  Transform/ForwardOpTree.cpp
83  Transform/DeLICM.cpp
84  Transform/ZoneAlgo.cpp
85  Transform/Simplify.cpp
86  Transform/MaximalStaticExpansion.cpp
87  Transform/ScopInliner.cpp
88  Transform/ManualOptimizer.cpp
89  Transform/MatmulOptimizer.cpp
90  ${POLLY_HEADER_FILES}
91
92  LINK_COMPONENTS
93  ${POLLY_COMPONENTS}
94  )
95
96if (MSVC_IDE OR XCODE)
97  # Configure source groups for Polly source files. By default, in the IDE there
98  # will be a source and include folder. In the source folder will be all the
99  # source files in a flat list, and in the include folder will be all the
100  # headers in a flat list. Sets the CMake source_group for each folder such
101  # the organization of the sources and headers in the IDE matches how it is
102  # laid out on disk
103  setup_polly_source_groups(${CMAKE_CURRENT_LIST_DIR}
104    ${CMAKE_CURRENT_LIST_DIR}/../include/polly)
105endif()
106
107# Create the library that can be linked into LLVM's tools and Polly's unittests.
108# It depends on all library it needs, such that with
109# LLVM_POLLY_LINK_INTO_TOOLS=ON, its dependencies like PollyISL are linked as
110# well.
111target_link_libraries(Polly PUBLIC
112  ${ISL_TARGET}
113)
114
115# Create a loadable module Polly.so that can be loaded using
116# LLVM's/clang's "-load" option.
117if (WIN32 OR CYGWIN OR NOT LLVM_ENABLE_PIC)
118  # Add dummy target, either because loadable modules are not supported
119  # as on Windows or because PIC code has been disabled
120  add_custom_target(LLVMPolly)
121  set_target_properties(LLVMPolly PROPERTIES FOLDER "Polly/Loadable Modules")
122else ()
123  add_polly_loadable_module(LLVMPolly
124    Plugin/Polly.cpp
125    $<TARGET_OBJECTS:obj.Polly>
126  )
127
128  # Only add the dependencies that are not part of LLVM. The latter are assumed
129  # to be already available in the address space the module is loaded into.
130  # Adding them once more would have the effect that both copies try to register
131  # the same command line options, to which LLVM reacts with an error.
132  target_link_libraries(LLVMPolly PUBLIC ${ISL_TARGET})
133
134  set_target_properties(LLVMPolly
135    PROPERTIES
136    LINKER_LANGUAGE CXX
137    PREFIX "")
138endif ()
139
140if (TARGET intrinsics_gen)
141  # Check if we are building as part of an LLVM build
142  add_dependencies(obj.Polly intrinsics_gen)
143endif()
144