[ForwardOpTree] Introduce the -polly-optree pass.
[polly-mirror.git] / lib / CMakeLists.txt
blobe41a20c097fac7dfb29a5fdf9b4bc3963ab5dc38
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/ForwardOpTree.cpp
62   Transform/DeLICM.cpp
63   Transform/Simplify.cpp
64   ${POLLY_HEADER_FILES}
65   )
66 set_target_properties(PollyCore PROPERTIES FOLDER "Polly")
68 # Create the library that can be linked into LLVM's tools and Polly's unittests.
69 # It depends on all library it needs, such that with
70 # LLVM_POLLY_LINK_INTO_TOOLS=ON, its dependencies like PollyISL are linked as
71 # well.
72 add_polly_library(Polly $<TARGET_OBJECTS:PollyCore>)
73 target_link_libraries(Polly
74   ${ISL_TARGET}
75   ${JSONCPP_LIBRARIES}
78 # Additional dependencies for Polly-ACC.
79 if (GPU_CODEGEN)
80   target_link_libraries(Polly PollyPPCG)
81 endif ()
84 # Polly-ACC requires the NVPTX backend to work. Ask LLVM about its libraries.
85 set(nvptx_libs)
86 if (GPU_CODEGEN)
87   # This call emits an error if they NVPTX backend is not enable.
88   llvm_map_components_to_libnames(nvptx_libs NVPTX)
89 endif ()
91 if (LLVM_LINK_LLVM_DYLIB)
92   # The shlib/dylib contains all the LLVM components
93   # (including NVPTX is enabled) already. Adding them to target_link_libraries
94   # would cause them being twice in the address space
95   # (their LLVM*.a/so and their copies in libLLVM.so)
96   # which results in errors when the two instances try to register the same
97   # command-line switches.
98   target_link_libraries(Polly LLVM)
99 else ()
100   target_link_libraries(Polly
101     LLVMSupport
102     LLVMCore
103     LLVMScalarOpts
104     LLVMInstCombine
105     LLVMTransformUtils
106     LLVMAnalysis
107     LLVMipo
108     LLVMMC
109     LLVMPasses
110     ${nvptx_libs}
111     # The libraries below are required for darwin: http://PR26392
112     LLVMBitReader
113     LLVMMCParser
114     LLVMObject
115     LLVMProfileData
116     LLVMTarget
117     LLVMVectorize
118     )
119 endif ()
121 # Create a loadable module Polly.so that can be loaded using
122 # LLVM's/clang's "-load" option.
123 if (MSVC)
124   # Add dummy target, because loadable modules are not supported on Windows
125   add_custom_target(LLVMPolly)
126   set_target_properties(LLVMPolly PROPERTIES FOLDER "Polly")
127 else ()
128   add_polly_loadable_module(LLVMPolly
129     Polly.cpp
130     $<TARGET_OBJECTS:PollyCore>
131   )
133   # Only add the dependencies that are not part of LLVM. The latter are assumed
134   # to be already available in the address space the module is loaded into.
135   # Adding them once more would have the effect that both copies try to register
136   # the same command line options, to which LLVM reacts with an error.
137   # If Polly-ACC is enabled, the NVPTX target is also expected to reside in the
138   # hosts. This is not the case for bugpoint. Use LLVM_POLLY_LINK_INTO_TOOLS=ON
139   # instead which will automatically resolve the additional dependencies by
140   # Polly.
141   target_link_libraries(LLVMPolly ${ISL_TARGET} ${JSONCPP_LIBRARIES})
142   if (GPU_CODEGEN)
143     target_link_libraries(LLVMPolly PollyPPCG)
144   endif ()
146   set_target_properties(LLVMPolly
147     PROPERTIES
148     LINKER_LANGUAGE CXX
149     PREFIX "")
150 endif ()
152 if (TARGET intrinsics_gen)
153   # Check if we are building as part of an LLVM build
154   add_dependencies(PollyCore intrinsics_gen)
155 endif()