source: trunk/lib_ir/CMakeLists.txt @ 4050

Last change on this file since 4050 was 4050, checked in by linmengl, 4 years ago

add p2s.ll file, p2s_step works now

File size: 4.0 KB
Line 
1cmake_minimum_required (VERSION 2.8)
2project (IR_Library)
3
4enable_testing()
5
6option (USE_AVX2 "Compile for Haswell arch with AVX2, BMI, BMI2")
7if (USE_AVX2)
8    message("---- Compiling for AVX2")
9    set(CXX_SSE_FLAGS "-msse2 -m64") #"-march=core-avx2")
10    set(LLVM_SSE_FLAGS "-mattr=+sse,+sse2,+avx2,+bmi2,+bmi -march=x86-64")
11else (USE_AVX2)
12    set(CXX_SSE_FLAGS "-msse2")
13    set(LLVM_SSE_FLAGS "-mattr=+sse,+sse2")
14endif (USE_AVX2)
15
16# perf_flags for xmlwf perf script
17set(CXX_PERF_FLAGS "-DBUFFER_PROFILING -DPERF_SCRIPT")
18set(CMAKE_CXX_FLAGS "${CXX_SSE_FLAGS} -std=c++11 ")
19
20set(LL_SOURCE_FILES s2p.ll p2s.ll)
21if (USE_AVX2)
22  #append s2p_ideal.ll to source list
23  set(LL_SOURCE_FILES {LL_SOURCE_FILES} s2p_ideal.ll)
24endif (USE_AVX2)
25
26set(LLVM_OPT "opt-svn")
27set(LLVM_LLC "llc-svn")
28set(LLVM_LINK "llvm-link")
29
30add_executable(test_s2p test_s2p.cpp ir_impl.o)
31add_executable(test_link test_link.cpp ir_impl.o)
32add_executable(test_pack test_pack.cpp ir_impl.o)
33
34# gen/ is used to test llc backend.
35add_subdirectory(gen)
36
37# test packh_2,4,8 only on avx2
38if (USE_AVX2)
39    add_executable(test_pack_avx2 test_pack_avx2.cpp ir_impl.o)
40    add_test(
41      NAME ctest_pack_avx2
42      COMMAND ./test_pack_avx2)
43endif (USE_AVX2)
44
45include_directories("xmlwf/util" "xmlwf/lib")
46add_executable(xmlwf xmlwf/src/xmlwf.cpp ir_impl.o)
47
48# xmlwf_perf compiles with additional flags and is only used for the perf_xmlwf
49# targets below.
50add_executable(xmlwf_perf xmlwf/src/xmlwf.cpp ir_impl.o)
51set_target_properties(xmlwf_perf
52  PROPERTIES
53  COMPILE_FLAGS ${CXX_PERF_FLAGS}
54  )
55
56add_executable(u8u16 u8u16/src/u8u16.cpp ir_impl.o)
57
58add_custom_target(asm
59  COMMAND ${LLVM_LLC} -O3 ${LLVM_SSE_FLAGS} ir_impl_opt.bc
60  DEPENDS ir_impl_opt.bc)
61
62# link ll source files together into ir_impl.bc
63message("---- Link ${LL_SOURCE_FILES} ----")
64add_custom_command(
65  OUTPUT  ir_impl.bc
66  COMMAND ${LLVM_LINK} ${LL_SOURCE_FILES} -o ${CMAKE_BINARY_DIR}/ir_impl.bc
67  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
68  DEPENDS ${LL_SOURCE_FILES})
69
70# compile ir_impl.bc
71add_custom_command(
72  OUTPUT  ir_impl.o ir_impl_opt.bc
73  COMMAND ${LLVM_OPT} -O3 -std-compile-opts ${LLVM_SSE_FLAGS} ir_impl.bc -o ir_impl_opt.bc
74  COMMAND ${LLVM_LLC} -O3 ${LLVM_SSE_FLAGS} -filetype=obj ir_impl_opt.bc -o ir_impl.o
75  DEPENDS ir_impl.bc)
76
77add_test(
78  NAME ctest_s2p
79  COMMAND python ${PROJECT_SOURCE_DIR}/test_s2p.py)
80add_test(
81  NAME ctest_link
82  COMMAND python ${PROJECT_SOURCE_DIR}/test_link.py)
83add_test(
84  NAME ctest_pack
85  COMMAND ./test_pack)
86add_test(
87  NAME ctest_xmlwf
88  COMMAND python ${PROJECT_SOURCE_DIR}/xmlwf/run_all.py)
89add_test(
90  NAME ctest_u8u16
91  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../../proto/u8u16/QA
92  COMMAND ${PROJECT_SOURCE_DIR}/u8u16/run_all ${CMAKE_BINARY_DIR}/u8u16)
93
94add_custom_target (check
95  COMMAND ${CMAKE_CTEST_COMMAND}
96  DEPENDS test_s2p test_link test_pack test_llc xmlwf u8u16)
97
98# `make check` also depends on test_pack_avx2
99if (USE_AVX2)
100  add_dependencies(check test_pack_avx2)
101endif (USE_AVX2)
102
103# performance scripts here
104add_custom_target (perf_xmlwf
105  COMMAND python ${PROJECT_SOURCE_DIR}/xmlwf/perf_script.py
106  DEPENDS xmlwf_perf)
107
108add_custom_target (perf_u8u16
109  COMMAND python ${PROJECT_SOURCE_DIR}/u8u16/perf_script.py
110  DEPENDS u8u16)
111
112# Try IR inline. Compile the whole xmlwf in IR and inline s2p into it.
113set(LLVM_LINK "llvm-link")
114set(LLVM_CLANG "/usr/local/bin/clang")
115# cxx_include should only be used for ir_inline approach.
116set(CXX_INCLUDE -I${PROJECT_SOURCE_DIR}/xmlwf/util -I${PROJECT_SOURCE_DIR}/xmlwf/lib)
117
118add_custom_target(xmlwf_ir_inline
119  COMMAND ${LLVM_LINK} ${PROJECT_SOURCE_DIR}/s2p.ll xmlwf.ll -o xmlwf_all.bc
120  COMMAND ${LLVM_OPT} -O3 -std-compile-opts -std-link-opts xmlwf_all.bc -o xmlwf_ir_inline.bc
121  COMMAND ${LLVM_LLC} -O3 ${LLVM_SSE_FLAGS} -filetype=obj xmlwf_ir_inline.bc
122  COMMAND ${CMAKE_CXX_COMPILER} xmlwf_ir_inline.o -o xmlwf_ir_inline
123  DEPENDS s2p.ll xmlwf.ll)
124
125add_custom_command(
126  OUTPUT xmlwf.ll
127  COMMAND ${LLVM_CLANG} -S -emit-llvm ${CXX_INCLUDE} ${PROJECT_SOURCE_DIR}/xmlwf/src/xmlwf.cpp ${CXX_PERF_FLAGS} -o xmlwf.ll
128  DEPENDS xmlwf/src/xmlwf.cpp)
129
Note: See TracBrowser for help on using the repository browser.