• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2020 The SwiftShader Authors. All Rights Reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#    http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15set(ROOT_PROJECT_COMPILE_OPTIONS
16    ${SWIFTSHADER_COMPILE_OPTIONS}
17    ${WARNINGS_AS_ERRORS}
18)
19
20set(SUBZERO_SRC_FILES
21    src/IceAssembler.cpp
22    src/IceCfg.cpp
23    src/IceCfgNode.cpp
24    src/IceClFlags.cpp
25    src/IceELFObjectWriter.cpp
26    src/IceELFSection.cpp
27    src/IceFixups.cpp
28    src/IceGlobalContext.cpp
29    src/IceGlobalInits.cpp
30    src/IceInst.cpp
31    src/IceInstrumentation.cpp
32    src/IceIntrinsics.cpp
33    src/IceLiveness.cpp
34    src/IceLoopAnalyzer.cpp
35    src/IceMangling.cpp
36    src/IceMemory.cpp
37    src/IceOperand.cpp
38    src/IceRangeSpec.cpp
39    src/IceRegAlloc.cpp
40    src/IceRevision.cpp
41    src/IceSwitchLowering.cpp
42    src/IceTargetLowering.cpp
43    src/IceThreading.cpp
44    src/IceTimerTree.cpp
45    src/IceTypes.cpp
46    src/IceVariableSplitting.cpp
47)
48
49if(ARCH STREQUAL "x86_64")
50    list(APPEND SUBZERO_SRC_FILES
51        src/IceTargetLoweringX86.cpp
52        src/IceInstX8664.cpp
53        src/IceTargetLoweringX8664.cpp
54    )
55    set(SUBZERO_TARGET_CPU X8664)
56elseif(ARCH STREQUAL "x86")
57    list(APPEND SUBZERO_SRC_FILES
58        src/IceTargetLoweringX86.cpp
59        src/IceInstX8632.cpp
60        src/IceTargetLoweringX8632.cpp
61    )
62    set(SUBZERO_TARGET_CPU X8632)
63elseif(ARCH STREQUAL "arm")
64    list(APPEND SUBZERO_SRC_FILES
65        src/IceAssemblerARM32.cpp
66        src/IceInstARM32.cpp
67        src/IceTargetLoweringARM32.cpp
68    )
69    set(SUBZERO_TARGET_CPU ARM32)
70elseif(ARCH STREQUAL "mipsel")
71    list(APPEND SUBZERO_SRC_FILES
72        src/IceAssemblerMIPS32.cpp
73        src/IceInstMIPS32.cpp
74        src/IceTargetLoweringMIPS32.cpp
75    )
76    set(SUBZERO_TARGET_CPU MIPS32)
77else()
78    message(WARNING "Architecture '${ARCH}' not supported by Subzero")
79endif()
80
81if(WIN32)
82    list(APPEND SUBZERO_COMPILE_OPTIONS
83        "/wd4146" # unary minus operator applied to unsigned type, result still unsigned
84        "/wd4334" # ''operator' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
85        "/wd4996" # The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: new_name.
86    )
87endif()
88
89add_library(subzero STATIC EXCLUDE_FROM_ALL
90    ${SUBZERO_SRC_FILES}
91)
92
93set_target_properties(subzero PROPERTIES
94    POSITION_INDEPENDENT_CODE 1
95)
96
97target_include_directories(subzero
98    PUBLIC
99        # Add lib root as include dir, so client code can do #include "src/..."
100        # TODO: Split out headers into separate 'include' directory.
101        "."
102        "pnacl-llvm/include"
103)
104
105target_compile_options(subzero
106    PRIVATE
107        ${ROOT_PROJECT_COMPILE_OPTIONS}
108        ${SUBZERO_COMPILE_OPTIONS}
109)
110
111target_compile_definitions(subzero
112    PUBLIC
113        "SZTARGET=${SUBZERO_TARGET_CPU}"
114        "ALLOW_DUMP=0"
115        "ALLOW_TIMERS=0"
116        "ALLOW_LLVM_CL=0"
117        "ALLOW_LLVM_IR=0"
118        "ALLOW_LLVM_IR_AS_INPUT=0"
119        "ALLOW_MINIMAL_BUILD=0"
120        "ALLOW_WASM=0"
121        "ICE_THREAD_LOCAL_HACK=0"
122    PRIVATE
123        $<$<BOOL:${WIN32}>:"SUBZERO_USE_MICROSOFT_ABI">
124)
125
126target_link_libraries(subzero
127    PUBLIC
128        llvm-subzero
129)
130