[Polly][NewPM] Reenable ScopPassManager unittest
[polly-mirror.git] / lib / CMakeLists.txt
blob751c9b47b0dd3824b7f2d5a407efdafbbe1eaf46
1 set(LLVM_NO_RTTI 1)
3 set(ISL_CODEGEN_FILES
4     CodeGen/IslAst.cpp
5     CodeGen/IslExprBuilder.cpp
6     CodeGen/IslNodeBuilder.cpp
7     CodeGen/CodeGeneration.cpp)
9 if (GPU_CODEGEN)
10   set (GPGPU_CODEGEN_FILES
11        CodeGen/PPCGCodeGeneration.cpp
12        )
13 endif (GPU_CODEGEN)
15 # Compile ISL into a separate library.
16 add_subdirectory(External)
18 set(POLLY_HEADER_FILES)
19 if (MSVC_IDE OR XCODE)
20   file(GLOB_RECURSE POLLY_HEADER_FILES "${POLLY_SOURCE_DIR}/include/polly/*.h")
21 endif ()
23 # Use an object-library to add the same files to multiple libs without requiring
24 # the sources them to be recompiled for each of them.
25 add_library(PollyCore OBJECT
26   Analysis/DependenceInfo.cpp
27   Analysis/PolyhedralInfo.cpp
28   Analysis/ScopDetection.cpp
29   Analysis/ScopDetectionDiagnostic.cpp
30   Analysis/ScopInfo.cpp
31   Analysis/ScopBuilder.cpp
32   Analysis/ScopGraphPrinter.cpp
33   Analysis/ScopPass.cpp
34   Analysis/PruneUnprofitable.cpp
35   CodeGen/BlockGenerators.cpp
36   ${ISL_CODEGEN_FILES}
37   CodeGen/LoopGenerators.cpp
38   CodeGen/IRBuilder.cpp
39   CodeGen/Utils.cpp
40   CodeGen/RuntimeDebugBuilder.cpp
41   CodeGen/CodegenCleanup.cpp
42   CodeGen/PerfMonitor.cpp
43   ${GPGPU_CODEGEN_FILES}
44   Exchange/JSONExporter.cpp
45   Support/GICHelper.cpp
46   Support/SCEVAffinator.cpp
47   Support/SCEVValidator.cpp
48   Support/RegisterPasses.cpp
49   Support/ScopHelper.cpp
50   Support/ScopLocation.cpp
51   Support/ISLTools.cpp
52   Support/DumpModulePass.cpp
53   Support/VirtualInstruction.cpp
54   ${POLLY_JSON_FILES}
55   Transform/Canonicalization.cpp
56   Transform/CodePreparation.cpp
57   Transform/DeadCodeElimination.cpp
58   Transform/ScheduleOptimizer.cpp
59   Transform/FlattenSchedule.cpp
60   Transform/FlattenAlgo.cpp
61   Transform/DeLICM.cpp
62   Transform/Simplify.cpp
63   ${POLLY_HEADER_FILES}
64   )
65 set_target_properties(PollyCore PROPERTIES FOLDER "Polly")
67 # Create the library that can be linked into LLVM's tools and Polly's unittests.
68 # It depends on all library it needs, such that with
69 # LLVM_POLLY_LINK_INTO_TOOLS=ON, its dependencies like PollyISL are linked as
70 # well.
71 add_polly_library(Polly $<TARGET_OBJECTS:PollyCore>)
72 target_link_libraries(Polly
73   ${ISL_TARGET}
74   ${JSONCPP_LIBRARIES}
77 # Additional dependencies for Polly-ACC.
78 if (GPU_CODEGEN)
79   target_link_libraries(Polly PollyPPCG)
80 endif ()
82 # Add Polly's LLVM dependencies.
83 # When built inside the LLVM source tree, these are CMake targets that will
84 # depend on their dependencies and CMake ensures they are added in the right
85 # order.
86 # If Polly is built independently, just add all LLVM libraries. LLVM_ROOT_DIR
87 # might have been configured to compile to individual libraries or a single
88 # libLLVM.so (called dylib), reported by llvm-config, so there is no fixed list
89 # of required libraries.
90 if (DEFINED LLVM_MAIN_SRC_DIR)
92   # Polly-ACC requires the NVPTX backend to work. Ask LLVM about its libraries.
93   set(nvptx_libs)
94   if (GPU_CODEGEN)
95     # This call emits an error if they NVPTX backend is not enable.
96     llvm_map_components_to_libnames(nvptx_libs NVPTX)
97   endif ()
99   if (LLVM_LINK_LLVM_DYLIB)
100     # The shlib/dylib contains all the LLVM components
101     # (including NVPTX is enabled) already. Adding them to target_link_libraries
102     # would cause them being twice in the address space
103     # (their LLVM*.a/so and their copies in libLLVM.so)
104     # which results in errors when the two instances try to register the same
105     # command-line switches.
106     target_link_libraries(Polly LLVM)
107   else ()
108     target_link_libraries(Polly
109       LLVMSupport
110       LLVMCore
111       LLVMScalarOpts
112       LLVMInstCombine
113       LLVMTransformUtils
114       LLVMAnalysis
115       LLVMipo
116       LLVMMC
117       LLVMPasses
118       ${nvptx_libs}
119 # The libraries below are required for darwin: http://PR26392
120       LLVMBitReader
121       LLVMMCParser
122       LLVMObject
123       LLVMProfileData
124       LLVMTarget
125       LLVMVectorize
126     )
127   endif ()
128 else ()
129   # When Polly-ACC is enabled, we assume that the host LLVM was also built with
130   # the NVPTX target enabled.
131   target_link_libraries(Polly
132     ${LLVM_LIBS}
133     ${LLVM_SYSTEM_LIBS}
134   )
135 endif ()
137 # Create a loadable module Polly.so that can be loaded using
138 # LLVM's/clang's "-load" option.
139 if (MSVC)
140   # Add dummy target, because loadable modules are not supported on Windows
141   add_custom_target(LLVMPolly)
142   set_target_properties(LLVMPolly PROPERTIES FOLDER "Polly")
143 else ()
144   add_polly_loadable_module(LLVMPolly
145     Polly.cpp
146     $<TARGET_OBJECTS:PollyCore>
147   )
149   # Only add the dependencies that are not part of LLVM. The latter are assumed
150   # to be already available in the address space the module is loaded into.
151   # Adding them once more would have the effect that both copies try to register
152   # the same command line options, to which LLVM reacts with an error.
153   # If Polly-ACC is enabled, the NVPTX target is also expected to reside in the
154   # hosts. This is not the case for bugpoint. Use LLVM_POLLY_LINK_INTO_TOOLS=ON
155   # instead which will automatically resolve the additional dependencies by
156   # Polly.
157   target_link_libraries(LLVMPolly ${ISL_TARGET} ${JSONCPP_LIBRARIES})
158   if (GPU_CODEGEN)
159     target_link_libraries(LLVMPolly PollyPPCG)
160   endif ()
162   set_target_properties(LLVMPolly
163     PROPERTIES
164     LINKER_LANGUAGE CXX
165     PREFIX "")
166 endif ()
168 if (TARGET intrinsics_gen)
169   # Check if we are building as part of an LLVM build
170   add_dependencies(PollyCore intrinsics_gen)
171 endif()