source: trunk/lib_ir/CMakeLists.txt @ 4238

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

add test code for long stream addition i256, test passed.

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