source: trunk/lib_ir/CMakeLists.txt @ 4143

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

add test code for add_with_carry_ir, detect a bug on AVX2.

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