blob: 54d3d0f80254c159eb1c7d8329ab0e1ccfee53dc [file] [log] [blame]
Antonio Maiorano4bde1c32020-03-27 15:01:53 -04001# 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.
Nicolas Capensb8afba12017-05-03 13:37:29 -040014
Antonio Maiorano4bde1c32020-03-27 15:01:53 -040015set(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/IceRNG.cpp
42 src/IceSwitchLowering.cpp
43 src/IceTargetLowering.cpp
44 src/IceThreading.cpp
45 src/IceTimerTree.cpp
46 src/IceTypes.cpp
47 src/IceVariableSplitting.cpp
48)
49
50if(ARCH STREQUAL "x86_64")
51 list(APPEND SUBZERO_SRC_FILES
52 src/IceTargetLoweringX86.cpp
53 src/IceInstX8664.cpp
54 src/IceTargetLoweringX8664.cpp
Nicolas Capensb8afba12017-05-03 13:37:29 -040055 )
Antonio Maiorano4bde1c32020-03-27 15:01:53 -040056 set(SUBZERO_TARGET_CPU X8664)
57elseif(ARCH STREQUAL "x86")
58 list(APPEND SUBZERO_SRC_FILES
59 src/IceTargetLoweringX86.cpp
60 src/IceInstX8632.cpp
61 src/IceTargetLoweringX8632.cpp
62 )
63 set(SUBZERO_TARGET_CPU X8632)
64elseif(ARCH STREQUAL "arm")
65 list(APPEND SUBZERO_SRC_FILES
66 src/IceAssemblerARM32.cpp
67 src/IceInstARM32.cpp
68 src/IceTargetLoweringARM32.cpp
69 )
70 set(SUBZERO_TARGET_CPU ARM32)
71elseif(ARCH STREQUAL "mipsel")
72 list(APPEND SUBZERO_SRC_FILES
73 src/IceAssemblerMIPS32.cpp
74 src/IceInstMIPS32.cpp
75 src/IceTargetLoweringMIPS32.cpp
76 )
77 set(SUBZERO_TARGET_CPU MIPS32)
Nicolas Capensb8afba12017-05-03 13:37:29 -040078else()
Antonio Maiorano4bde1c32020-03-27 15:01:53 -040079 message(FATAL_ERROR "Architecture '${ARCH}' not supported by Subzero")
Nicolas Capensb8afba12017-05-03 13:37:29 -040080endif()
81
Antonio Maiorano4bde1c32020-03-27 15:01:53 -040082if(WIN32)
83 list(APPEND SUBZERO_COMPILE_OPTIONS
84 "/wd4146" # unary minus operator applied to unsigned type, result still unsigned
85 "/wd4334" # ''operator' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
86 "/wd4996" # The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: new_name.
87 )
Nicolas Capensb8afba12017-05-03 13:37:29 -040088endif()
89
Antonio Maiorano4bde1c32020-03-27 15:01:53 -040090add_library(subzero STATIC EXCLUDE_FROM_ALL
91 ${SUBZERO_SRC_FILES}
92)
Nicolas Capensb8afba12017-05-03 13:37:29 -040093
Antonio Maiorano4bde1c32020-03-27 15:01:53 -040094set_target_properties(subzero PROPERTIES
95 POSITION_INDEPENDENT_CODE 1
96 FOLDER "Subzero"
97)
98
99target_include_directories(subzero
100 PUBLIC
101 # Add lib root as include dir, so client code can do #include "src/..."
102 # TODO: Split out headers into separate 'include' directory.
103 "."
104 "pnacl-llvm/include"
105)
106
107target_compile_options(subzero
108 PUBLIC
109 ${ROOT_PROJECT_COMPILE_OPTIONS}
110 ${SUBZERO_COMPILE_OPTIONS}
111)
112
113target_compile_definitions(subzero
114 PUBLIC
115 "SZTARGET=${SUBZERO_TARGET_CPU}"
116 "ALLOW_DUMP=0"
117 "ALLOW_TIMERS=0"
118 "ALLOW_LLVM_CL=0"
119 "ALLOW_LLVM_IR=0"
120 "ALLOW_LLVM_IR_AS_INPUT=0"
121 "ALLOW_MINIMAL_BUILD=0"
122 "ALLOW_WASM=0"
123 "ICE_THREAD_LOCAL_HACK=0"
124 PRIVATE
125 $<$<BOOL:${WIN32}>:"SUBZERO_USE_MICROSOFT_ABI">
126)
127
128target_link_libraries(subzero
129 PUBLIC
130 llvm-subzero
131)