source: trunk/lib_ir/CMakeLists.txt @ 3945

Last change on this file since 3945 was 3945, checked in by linmengl, 5 years ago

seperate s2p_ideal from s2p.ll, since it won't compile on SSE2 machine.

File size: 3.7 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(LLVM_OPT "opt-svn")
21set(LLVM_LLC "llc-svn")
22
23set(LLVM_LLC_FLAGS )#-x86-experimental-vector-shuffle-lowering)
24
25add_executable(test_s2p test_s2p.cpp s2p_optimized.o)
26add_executable(test_link test_link.cpp s2p_optimized.o)
27add_executable(test_pack test_pack.cpp s2p_optimized.o)
28
29# test packh_2,4,8 only on avx2
30if (USE_AVX2)
31    add_executable(test_pack_avx2 test_pack_avx2.cpp s2p_optimized.o)
32    add_test(
33      NAME ctest_pack_avx2
34      COMMAND ./test_pack_avx2)
35endif (USE_AVX2)
36
37include_directories("xmlwf/util" "xmlwf/lib")
38add_executable(xmlwf xmlwf/src/xmlwf.cpp s2p_optimized.o)
39
40add_executable(xmlwf_perf xmlwf/src/xmlwf.cpp s2p_optimized.o)
41set_target_properties(xmlwf_perf
42  PROPERTIES
43  COMPILE_FLAGS ${CXX_PERF_FLAGS}
44  )
45
46add_custom_target(asm_s2p
47  COMMAND ${LLVM_LLC} -O3 ${LLVM_SSE_FLAGS} s2p_optimized.bc
48  DEPENDS s2p_optimized.bc)
49
50# a little bit tricky here, on USE_AVX2, we need to append s2p_ideal.ll to s2p.ll
51# in order to have function s2p_ideal
52if (USE_AVX2)
53  message("---- Concat s2p.ll with s2p_ideal.ll")
54  add_custom_command(
55    OUTPUT s2p.ll
56    COMMAND cp ${PROJECT_SOURCE_DIR}/s2p.ll .
57    COMMAND cat ${PROJECT_SOURCE_DIR}/s2p_ideal.ll >> s2p.ll
58    DEPENDS ${PROJECT_SOURCE_DIR}/s2p.ll ${PROJECT_SOURCE_DIR}/s2p_ideal.ll)
59
60else (USE_AVX2)
61  add_custom_command(
62    OUTPUT s2p.ll
63    COMMAND cp ${PROJECT_SOURCE_DIR}/s2p.ll .
64    DEPENDS ${PROJECT_SOURCE_DIR}/s2p.ll)
65
66endif (USE_AVX2)
67
68# compile s2p.ll, and make sure test_s2p depends on it.
69add_custom_command(
70  OUTPUT  s2p_optimized.o s2p_optimized.bc
71  COMMAND ${LLVM_OPT} -O3 -std-compile-opts ${LLVM_SSE_FLAGS} s2p.ll -o s2p_optimized.bc
72  COMMAND ${LLVM_LLC} -O3 ${LLVM_SSE_FLAGS} -filetype=obj s2p_optimized.bc
73  DEPENDS s2p.ll)
74
75add_test(
76  NAME ctest_s2p
77  COMMAND python ${PROJECT_SOURCE_DIR}/test_s2p.py)
78add_test(
79  NAME ctest_link
80  COMMAND python ${PROJECT_SOURCE_DIR}/test_link.py)
81add_test(
82  NAME ctest_pack
83  COMMAND ./test_pack)
84add_test(
85  NAME ctest_xmlwf
86  COMMAND python ${PROJECT_SOURCE_DIR}/xmlwf/run_all.py)
87
88add_custom_target (check
89  COMMAND ${CMAKE_CTEST_COMMAND}
90  DEPENDS test_s2p test_link test_pack xmlwf)
91
92# `make check` also depends on test_pack_avx2
93if (USE_AVX2)
94  add_dependencies(check test_pack_avx2)
95endif (USE_AVX2)
96
97add_custom_target (perf_xmlwf
98  COMMAND python ${PROJECT_SOURCE_DIR}/xmlwf/perf_script.py
99  DEPENDS xmlwf_perf)
100
101
102# Try IR inline. Compile the whole xmlwf in IR and inline s2p into it.
103set(LLVM_LINK "llvm-link")
104set(LLVM_CLANG "/usr/local/bin/clang")
105# cxx_include should only be used for ir_inline approach.
106set(CXX_INCLUDE -I${PROJECT_SOURCE_DIR}/xmlwf/util -I${PROJECT_SOURCE_DIR}/xmlwf/lib)
107
108add_custom_target(xmlwf_ir_inline
109  COMMAND ${LLVM_LINK} ${PROJECT_SOURCE_DIR}/s2p.ll xmlwf.ll -o xmlwf_all.bc
110  COMMAND ${LLVM_OPT} -O3 -std-compile-opts -std-link-opts xmlwf_all.bc -o xmlwf_ir_inline.bc
111  COMMAND ${LLVM_LLC} -O3 ${LLVM_SSE_FLAGS} -filetype=obj xmlwf_ir_inline.bc
112  COMMAND ${CMAKE_CXX_COMPILER} xmlwf_ir_inline.o -o xmlwf_ir_inline
113  DEPENDS s2p.ll xmlwf.ll)
114
115add_custom_command(
116  OUTPUT xmlwf.ll
117  COMMAND ${LLVM_CLANG} -S -emit-llvm ${CXX_INCLUDE} ${PROJECT_SOURCE_DIR}/xmlwf/src/xmlwf.cpp ${CXX_PERF_FLAGS} -o xmlwf.ll
118  DEPENDS xmlwf/src/xmlwf.cpp)
119
Note: See TracBrowser for help on using the repository browser.