source: trunk/lib_ir/CMakeLists.txt @ 4005

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

auto gen test files for i2 ops

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