Update isl to isl-0.20-48-g13eba5b5
[polly-mirror.git] / lib / CMakeLists.txt
blob954654112c8dd2990d17fcf6e0ccf3783cdf9106
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        CodeGen/ManagedMemoryRewrite.cpp
13        )
14 endif (GPU_CODEGEN)
16 # Compile ISL into a separate library.
17 add_subdirectory(External)
19 set(POLLY_HEADER_FILES)
20 if (MSVC_IDE OR XCODE)
21   file(GLOB_RECURSE POLLY_HEADER_FILES "${POLLY_SOURCE_DIR}/include/polly/*.h")
22 endif ()
24 # Use an object-library to add the same files to multiple libs without requiring
25 # the sources them to be recompiled for each of them.
26 add_library(PollyCore OBJECT
27   Analysis/DependenceInfo.cpp
28   Analysis/PolyhedralInfo.cpp
29   Analysis/ScopDetection.cpp
30   Analysis/ScopDetectionDiagnostic.cpp
31   Analysis/ScopInfo.cpp
32   Analysis/ScopBuilder.cpp
33   Analysis/ScopGraphPrinter.cpp
34   Analysis/ScopPass.cpp
35   Analysis/PruneUnprofitable.cpp
36   CodeGen/BlockGenerators.cpp
37   ${ISL_CODEGEN_FILES}
38   CodeGen/LoopGenerators.cpp
39   CodeGen/IRBuilder.cpp
40   CodeGen/Utils.cpp
41   CodeGen/RuntimeDebugBuilder.cpp
42   CodeGen/CodegenCleanup.cpp
43   CodeGen/PerfMonitor.cpp
44   ${GPGPU_CODEGEN_FILES}
45   Exchange/JSONExporter.cpp
46   Support/GICHelper.cpp
47   Support/SCEVAffinator.cpp
48   Support/SCEVValidator.cpp
49   Support/RegisterPasses.cpp
50   Support/ScopHelper.cpp
51   Support/ScopLocation.cpp
52   Support/ISLTools.cpp
53   Support/DumpModulePass.cpp
54   Support/VirtualInstruction.cpp
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/ZoneAlgo.cpp
64   Transform/Simplify.cpp
65   Transform/MaximalStaticExpansion.cpp
66   Transform/RewriteByReferenceParameters.cpp
67   Transform/ScopInliner.cpp
68   ${POLLY_HEADER_FILES}
69   )
70 set_target_properties(PollyCore PROPERTIES FOLDER "Polly")
72 # Create the library that can be linked into LLVM's tools and Polly's unittests.
73 # It depends on all library it needs, such that with
74 # LLVM_POLLY_LINK_INTO_TOOLS=ON, its dependencies like PollyISL are linked as
75 # well.
76 add_polly_library(Polly $<TARGET_OBJECTS:PollyCore>)
77 target_link_libraries(Polly PUBLIC
78   ${ISL_TARGET}
81 # Additional dependencies for Polly-ACC.
82 if (GPU_CODEGEN)
83   target_link_libraries(Polly PUBLIC PollyPPCG)
84 endif ()
87 # Polly-ACC requires the NVPTX backend to work. Ask LLVM about its libraries.
88 set(nvptx_libs)
89 if (GPU_CODEGEN)
90   # This call emits an error if they NVPTX backend is not enable.
91   llvm_map_components_to_libnames(nvptx_libs NVPTX)
92 endif ()
94 if (LLVM_LINK_LLVM_DYLIB)
95   # The shlib/dylib contains all the LLVM components
96   # (including NVPTX is enabled) already. Adding them to target_link_libraries
97   # would cause them being twice in the address space
98   # (their LLVM*.a/so and their copies in libLLVM.so)
99   # which results in errors when the two instances try to register the same
100   # command-line switches.
101   target_link_libraries(Polly PUBLIC LLVM)
102 else ()
103   target_link_libraries(Polly PUBLIC
104     LLVMSupport
105     LLVMCore
106     LLVMScalarOpts
107     LLVMInstCombine
108     LLVMTransformUtils
109     LLVMAnalysis
110     LLVMipo
111     LLVMMC
112     LLVMPasses
113     LLVMLinker
114     LLVMIRReader
115     ${nvptx_libs}
116     # The libraries below are required for darwin: http://PR26392
117     LLVMBitReader
118     LLVMMCParser
119     LLVMObject
120     LLVMProfileData
121     LLVMTarget
122     LLVMVectorize
123     )
124 endif ()
126 # Create a loadable module Polly.so that can be loaded using
127 # LLVM's/clang's "-load" option.
128 if (MSVC)
129   # Add dummy target, because loadable modules are not supported on Windows
130   add_custom_target(LLVMPolly)
131   set_target_properties(LLVMPolly PROPERTIES FOLDER "Polly")
132 else ()
133   add_polly_loadable_module(LLVMPolly
134     Polly.cpp
135     $<TARGET_OBJECTS:PollyCore>
136   )
138   # Only add the dependencies that are not part of LLVM. The latter are assumed
139   # to be already available in the address space the module is loaded into.
140   # Adding them once more would have the effect that both copies try to register
141   # the same command line options, to which LLVM reacts with an error.
142   # If Polly-ACC is enabled, the NVPTX target is also expected to reside in the
143   # hosts. This is not the case for bugpoint. Use LLVM_POLLY_LINK_INTO_TOOLS=ON
144   # instead which will automatically resolve the additional dependencies by
145   # Polly.
146   target_link_libraries(LLVMPolly PUBLIC ${ISL_TARGET})
147   if (GPU_CODEGEN)
148     target_link_libraries(LLVMPolly PUBLIC PollyPPCG)
149   endif ()
151   set_target_properties(LLVMPolly
152     PROPERTIES
153     LINKER_LANGUAGE CXX
154     PREFIX "")
155 endif ()
157 if (TARGET intrinsics_gen)
158   # Check if we are building as part of an LLVM build
159   add_dependencies(PollyCore intrinsics_gen)
160 endif()