source: trunk/lib_ir/CMakeLists.txt @ 3938

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

add back packh_8,4,2 / packl_8, 4, 2

File size: 2.9 KB
RevLine 
[3909]1cmake_minimum_required (VERSION 2.8)
2project (IR_Library)
3
[3936]4option (USE_AVX2 "Compile for Haswell arch with AVX2, BMI, BMI2")
5if (USE_AVX2)
6    message("---- Compiling for AVX2")
[3938]7    set(CXX_SSE_FLAGS "-msse2 -m64") #"-march=core-avx2")
8    set(LLVM_SSE_FLAGS "-mattr=+sse,+sse2,+avx2,+bmi2,+bmi -march=x86-64")
[3936]9else (USE_AVX2)
10    set(CXX_SSE_FLAGS "-msse2")
11    set(LLVM_SSE_FLAGS "-mattr=+sse,+sse2")
12endif (USE_AVX2)
13
[3927]14# perf_flags for xmlwf perf script
15set(CXX_PERF_FLAGS "-DBUFFER_PROFILING -DPERF_SCRIPT")
[3925]16set(CMAKE_CXX_FLAGS "${CXX_SSE_FLAGS} -std=c++11 ")
[3909]17
18set(LLVM_OPT "opt-svn")
19set(LLVM_LLC "llc-svn")
20
[3927]21set(LLVM_LLC_FLAGS )#-x86-experimental-vector-shuffle-lowering)
22
[3909]23add_executable(test_s2p test_s2p.cpp s2p_optimized.o)
24add_executable(test_link test_link.cpp s2p_optimized.o)
[3918]25add_executable(test_pack test_pack.cpp s2p_optimized.o)
[3909]26
[3922]27include_directories("xmlwf/util" "xmlwf/lib")
28add_executable(xmlwf xmlwf/src/xmlwf.cpp s2p_optimized.o)
29
[3925]30add_executable(xmlwf_perf xmlwf/src/xmlwf.cpp s2p_optimized.o)
31set_target_properties(xmlwf_perf
32  PROPERTIES
[3927]33  COMPILE_FLAGS ${CXX_PERF_FLAGS}
[3925]34  )
35
[3927]36add_custom_target(asm_s2p
37  COMMAND ${LLVM_LLC} -O3 ${LLVM_SSE_FLAGS} s2p_optimized.bc
38  DEPENDS s2p_optimized.bc)
39
[3909]40# compile s2p.ll, and make sure test_s2p depends on it.
41add_custom_command(
[3927]42  OUTPUT  s2p_optimized.o s2p_optimized.bc
43  COMMAND ${LLVM_OPT} -O3 -std-compile-opts ${LLVM_SSE_FLAGS} ${PROJECT_SOURCE_DIR}/s2p.ll -o s2p_optimized.bc
[3909]44  COMMAND ${LLVM_LLC} -O3 ${LLVM_SSE_FLAGS} -filetype=obj s2p_optimized.bc
45  DEPENDS ${PROJECT_SOURCE_DIR}/s2p.ll)
46
47enable_testing()
48add_test(
49  NAME ctest_s2p
50  COMMAND python ${PROJECT_SOURCE_DIR}/test_s2p.py)
51add_test(
52  NAME ctest_link
53  COMMAND python ${PROJECT_SOURCE_DIR}/test_link.py)
[3918]54add_test(
55  NAME ctest_pack
56  COMMAND ./test_pack)
[3922]57add_test(
58  NAME ctest_xmlwf
59  COMMAND python ${PROJECT_SOURCE_DIR}/xmlwf/run_all.py)
[3909]60
61add_custom_target (check
62  COMMAND ${CMAKE_CTEST_COMMAND}
[3922]63  DEPENDS test_s2p test_link test_pack xmlwf)
[3924]64
65add_custom_target (perf_xmlwf
66  COMMAND python ${PROJECT_SOURCE_DIR}/xmlwf/perf_script.py
[3925]67  DEPENDS xmlwf_perf)
[3927]68
69
70# Try IR inline. Compile the whole xmlwf in IR and inline s2p into it.
71set(LLVM_LINK "llvm-link")
72set(LLVM_CLANG "/usr/local/bin/clang")
73# cxx_include should only be used for ir_inline approach.
74set(CXX_INCLUDE -I${PROJECT_SOURCE_DIR}/xmlwf/util -I${PROJECT_SOURCE_DIR}/xmlwf/lib)
75
76add_custom_target(xmlwf_ir_inline
77  COMMAND ${LLVM_LINK} ${PROJECT_SOURCE_DIR}/s2p.ll xmlwf.ll -o xmlwf_all.bc
78  COMMAND ${LLVM_OPT} -O3 -std-compile-opts -std-link-opts xmlwf_all.bc -o xmlwf_ir_inline.bc
79  COMMAND ${LLVM_LLC} -O3 ${LLVM_SSE_FLAGS} -filetype=obj xmlwf_ir_inline.bc
80  COMMAND ${CMAKE_CXX_COMPILER} xmlwf_ir_inline.o -o xmlwf_ir_inline
81  DEPENDS s2p.ll xmlwf.ll)
82
83add_custom_command(
84  OUTPUT xmlwf.ll
85  COMMAND ${LLVM_CLANG} -S -emit-llvm ${CXX_INCLUDE} ${PROJECT_SOURCE_DIR}/xmlwf/src/xmlwf.cpp ${CXX_PERF_FLAGS} -o xmlwf.ll
86  DEPENDS xmlwf/src/xmlwf.cpp)
87
Note: See TracBrowser for help on using the repository browser.