summaryrefslogtreecommitdiff
path: root/backend/src/CMakeLists.txt
blob: ce83c62fe2cbfeaf74f6d692846c40d6ae2b722f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
set (OCL_BITCODE_BIN "${BEIGNET_INSTALL_DIR}beignet.bc")
set (OCL_HEADER_DIR "${BEIGNET_INSTALL_DIR}/include")
set (OCL_PCH_OBJECT "${BEIGNET_INSTALL_DIR}beignet.pch")
set (GBE_OBJECT_DIR "${BEIGNET_INSTALL_DIR}/libgbe.so")
set (INTERP_OBJECT_DIR "${BEIGNET_INSTALL_DIR}/libgbeinterp.so")

configure_file (
    "GBEConfig.h.in"
    "GBEConfig.h"
)

#do not involve libocl if the standalone compiler is given,
if (NOT (USE_STANDALONE_GBE_COMPILER STREQUAL "true"))
add_subdirectory(libocl)
add_dependencies(beignet_bitcode libocl)
endif ()

set (LOCAL_GBE_OBJECT_DIR "${CMAKE_CURRENT_BINARY_DIR}/libgbe.so" PARENT_SCOPE)
set (LOCAL_INTERP_OBJECT_DIR "${CMAKE_CURRENT_BINARY_DIR}/libgbeinterp.so" PARENT_SCOPE)
set (LOCAL_OCL_BITCODE_BIN "${OCL_OBJECT_DIR}/beignet.bc" PARENT_SCOPE)
set (LOCAL_OCL_HEADER_DIR "${OCL_OBJECT_DIR}/include/" PARENT_SCOPE)
set (LOCAL_OCL_PCH_OBJECT "${OCL_OBJECT_DIR}/beignet.local.pch" PARENT_SCOPE)

set (GBE_SRC
    ${ocl_blob_file}
    sys/vector.hpp
    sys/map.hpp
    sys/set.hpp
    sys/intrusive_list.hpp
    sys/intrusive_list.cpp
    sys/exception.hpp
    sys/assert.cpp
    sys/assert.hpp
    sys/alloc.cpp
    sys/alloc.hpp
    sys/mutex.cpp
    sys/mutex.hpp
    sys/platform.cpp
    sys/platform.hpp
    sys/cvar.cpp
    sys/cvar.hpp
    ir/context.cpp
    ir/context.hpp
    ir/profile.cpp
    ir/profile.hpp
    ir/type.cpp
    ir/type.hpp
    ir/unit.cpp
    ir/unit.hpp
    ir/constant.cpp
    ir/constant.hpp
    ir/sampler.cpp
    ir/sampler.hpp
    ir/image.cpp
    ir/image.hpp
    ir/instruction.cpp
    ir/instruction.hpp
    ir/liveness.cpp
    ir/register.cpp
    ir/register.hpp
    ir/function.cpp
    ir/function.hpp
    ir/value.cpp
    ir/value.hpp
    ir/lowering.cpp
    ir/lowering.hpp
    ir/printf.cpp
    ir/printf.hpp
    ir/structural_analysis.cpp
    ir/structural_analysis.hpp
    ir/immediate.hpp
    ir/immediate.cpp
    backend/context.cpp
    backend/context.hpp
    backend/program.cpp
    backend/program.hpp
    backend/program.h
    llvm/llvm_sampler_fix.cpp
    llvm/llvm_bitcode_link.cpp
    llvm/llvm_gen_backend.cpp
    llvm/llvm_passes.cpp
    llvm/llvm_scalarize.cpp
    llvm/llvm_legalize.cpp
    llvm/llvm_intrinsic_lowering.cpp
    llvm/llvm_barrier_nodup.cpp
    llvm/llvm_printf_parser.cpp
    llvm/llvm_to_gen.cpp
    llvm/llvm_loadstore_optimization.cpp
    llvm/llvm_gen_backend.hpp
    llvm/llvm_gen_ocl_function.hxx
    llvm/llvm_unroll.cpp
    llvm/llvm_to_gen.hpp
    backend/gen/gen_mesa_disasm.c
    backend/gen_insn_selection.cpp
    backend/gen_insn_selection.hpp
    backend/gen_insn_scheduling.cpp
    backend/gen_insn_scheduling.hpp
    backend/gen_reg_allocation.cpp
    backend/gen_reg_allocation.hpp
    backend/gen_context.cpp
    backend/gen_context.cpp
    backend/gen75_context.hpp
    backend/gen75_context.cpp
    backend/gen8_context.hpp
    backend/gen8_context.cpp
    backend/gen_program.cpp
    backend/gen_program.hpp
    backend/gen_program.h
    backend/gen7_instruction.hpp
    backend/gen8_instruction.hpp
    backend/gen_defs.hpp
    backend/gen_insn_compact.cpp
    backend/gen_encoder.hpp
    backend/gen_encoder.cpp
    backend/gen7_encoder.hpp
    backend/gen7_encoder.cpp
    backend/gen75_encoder.hpp
    backend/gen75_encoder.cpp
    backend/gen8_encoder.hpp
    backend/gen8_encoder.cpp
    )

set (GBE_LINK_LIBRARIES
    ${DRM_INTEL_LIBRARIES}
    ${DRM_LIBRARIES}
    ${CLANG_LIBRARIES}
    ${LLVM_MODULE_LIBS}
    ${LLVM_SYSTEM_LIBS}
    ${CMAKE_THREAD_LIBS_INIT}
    ${CMAKE_DL_LIBS}
    )

include_directories (.)
link_directories (${LLVM_LIBRARY_DIRS} ${DRM_LIBDIR})
include_directories(${LLVM_INCLUDE_DIRS})

#do not build libgbe.so if the standalone compiler is given
if (NOT (USE_STANDALONE_GBE_COMPILER STREQUAL "true"))
add_library (gbe SHARED ${GBE_SRC})
target_link_libraries(gbe ${GBE_LINK_LIBRARIES})
add_dependencies(gbe beignet_bitcode)
endif (NOT (USE_STANDALONE_GBE_COMPILER STREQUAL "true"))

add_library(gbeinterp SHARED gbe_bin_interpreter.cpp)

if (LLVM_VERSION_NODOT VERSION_EQUAL 34)
  find_library(TERMINFO NAMES tinfo ncurses)
  if (${TERMINFO} STREQUAL TERMINFO-NOTFOUND)
    message(FATAL_ERROR "no libtinfo or libncurses is found in system")
  else (${TERMINFO} STREQUAL TERMINFO-NOTFOUND)
    target_link_libraries(gbe ${TERMINFO})
    message(STATUS "use ${TERMINFO} as terminal control library")
  endif (${TERMINFO} STREQUAL TERMINFO-NOTFOUND)
endif(LLVM_VERSION_NODOT VERSION_EQUAL 34)

link_directories (${LLVM_LIBRARY_DIR} ${DRM_LIBDIR})

#do not build nor install if the standalone compiler is given
if (NOT (USE_STANDALONE_GBE_COMPILER STREQUAL "true"))
if (BUILD_STANDALONE_GBE_COMPILER STREQUAL "true")
macro(remove_cxx_flag flag)
  string(REPLACE "${flag}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endmacro()

remove_cxx_flag("-Wl,-E")
ADD_EXECUTABLE(gbe_bin_generater gbe_bin_generater.cpp ${GBE_SRC})
set_target_properties(gbe_bin_generater PROPERTIES LINK_FLAGS "-static")
TARGET_LINK_LIBRARIES(gbe_bin_generater ${GBE_LINK_LIBRARIES})

ADD_CUSTOM_TARGET(gbecompiler.tgz ALL
    COMMAND tar zcf ${OCL_OBJECT_DIR}/gbecompiler.tgz gbe_bin_generater -C ${OCL_OBJECT_DIR} beignet.bc -C ${OCL_OBJECT_DIR} beignet.pch -C ${OCL_OBJECT_DIR} include
    DEPENDS gbe_bin_generater beignet_bitcode
    )

else ()
ADD_EXECUTABLE(gbe_bin_generater gbe_bin_generater.cpp)
TARGET_LINK_LIBRARIES(gbe_bin_generater gbe)
endif ()

install (TARGETS gbe LIBRARY DESTINATION ${BEIGNET_INSTALL_DIR})
install (FILES ${OCL_OBJECT_DIR}/beignet.bc DESTINATION ${BEIGNET_INSTALL_DIR})
install (FILES ${OCL_OBJECT_DIR}/beignet.pch DESTINATION ${BEIGNET_INSTALL_DIR})
install (FILES ${OCL_HEADER_FILES} DESTINATION ${BEIGNET_INSTALL_DIR}/include)
endif (NOT (USE_STANDALONE_GBE_COMPILER STREQUAL "true"))

install (TARGETS gbeinterp LIBRARY DESTINATION ${BEIGNET_INSTALL_DIR})