OSDN Git Service

b7dca6d72c5ed634baa44d42944913db7844e5ea
[android-x86/external-swiftshader.git] / src / Reactor / BUILD.gn
1 # Copyright 2016 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
15 import("../swiftshader.gni")
16
17 declare_args() {
18   # Currently, Subzero is not used by default
19   # LLVM is still the default backend
20   use_swiftshader_with_subzero = is_win || is_linux
21 }
22
23 # Need a separate config to ensure the warnings are added to the end.
24 config("swiftshader_subzero_common_private_config") {
25   defines = [
26     "ALLOW_DUMP=0",
27     "ALLOW_TIMERS=0",
28     "ALLOW_LLVM_CL=0",
29     "ALLOW_LLVM_IR=0",
30     "ALLOW_LLVM_IR_AS_INPUT=0",
31     "ALLOW_MINIMAL_BUILD=0",
32     "ALLOW_WASM=0",
33     "ICE_THREAD_LOCAL_HACK=0",
34   ]
35
36   if (is_win) {
37     defines += [ "SUBZERO_USE_MICROSOFT_ABI" ]
38   }
39
40   if (target_cpu == "x64") {
41     defines += [
42       "SZTARGET=X8664",
43       "SUBZERO_TARGET=X8664",
44     ]
45   } else {
46     defines += [
47       "SZTARGET=X8632",
48       "SUBZERO_TARGET=X8632",
49     ]
50   }
51
52   include_dirs = [
53     "../../third_party/subzero",
54     "../../third_party/subzero/pnacl-llvm/include/",
55     "../../third_party/llvm-subzero/include/",
56   ]
57
58   if (is_win) {
59     include_dirs += [ "../../third_party/llvm-subzero/build/Windows/include/" ]
60   } else if (is_linux) {
61     include_dirs += [ "../../third_party/llvm-subzero/build/Linux/include/" ]
62   } else if (is_mac) {
63     include_dirs += [ "../../third_party/llvm-subzero/build/MacOS/include/" ]
64   }
65 }
66
67 config("swiftshader_subzero_private_config") {
68   cflags = []
69
70   if (is_win) {
71     cflags += [
72       "/wd4005",
73       "/wd4018",
74       "/wd4141",
75       "/wd4146",
76       "/wd4245",  # conversion from int to unsigned int (llvm)
77       "/wd4267",
78       "/wd4310",
79       "/wd4334",
80       "/wd4389",
81       "/wd4701",
82       "/wd4702",
83       "/wd4703",
84       "/wd4706",
85       "/wd4800",
86     ]
87
88     if (!is_debug) {
89       cflags += [ "/wd4718" ]
90     }
91
92     if (is_clang) {
93       if (is_debug) {
94         cflags += [ "-Wno-sign-compare" ]
95       }
96     }
97   } else if (is_linux || is_mac) {
98     cflags += [ "-Wno-macro-redefined" ]
99   }
100
101   if (is_clang) {
102     cflags += [ "-Wno-header-hygiene" ]
103   }
104 }
105
106 config("swiftshader_reactor_with_subzero_private_config") {
107   cflags = []
108
109   if (is_win) {
110     cflags += [
111       "/wd4141",
112       "/wd4146",
113       "/wd4245",  # conversion from int to unsigned int (llvm)
114       "/wd4267",
115       "/wd4702",
116       "/wd4800",
117     ]
118
119     if (use_swiftshader_with_subzero) {
120       cflags += [
121         "/wd4018",  # signed/unsigned mismatch (llvm)
122         "/wd4310",  # cast truncates constant value (llvm)
123       ]
124     }
125
126     if (is_clang) {
127       if (is_debug) {
128         cflags += [ "-Wno-sign-compare" ]
129       }
130     }
131   }
132
133   if (is_clang) {
134     cflags += [ "-Wno-header-hygiene" ]
135   }
136 }
137
138 config("swiftshader_reactor_private_config") {
139   if (is_win) {
140     cflags = [
141       "/wd4201",  # nameless struct/union
142       "/wd4245",  # conversion from int to unsigned int (llvm)
143     ]
144   } else {
145     cflags = [
146       "-Wno-unused-local-typedef",
147       "-msse2",
148     ]
149
150     defines = [
151       "__STDC_CONSTANT_MACROS",
152       "__STDC_LIMIT_MACROS",
153     ]
154   }
155 }
156
157 if (use_swiftshader_with_subzero) {
158   swiftshader_source_set("swiftshader_subzero") {
159     subzero_dir = "../../third_party/subzero"
160     subzero_llvm_dir = "../../third_party/llvm-subzero"
161
162     sources = [
163       "$subzero_dir/src/IceAssembler.cpp",
164       "$subzero_dir/src/IceCfg.cpp",
165       "$subzero_dir/src/IceCfgNode.cpp",
166       "$subzero_dir/src/IceClFlags.cpp",
167       "$subzero_dir/src/IceELFObjectWriter.cpp",
168       "$subzero_dir/src/IceELFSection.cpp",
169       "$subzero_dir/src/IceFixups.cpp",
170       "$subzero_dir/src/IceGlobalContext.cpp",
171       "$subzero_dir/src/IceGlobalInits.cpp",
172       "$subzero_dir/src/IceInst.cpp",
173       "$subzero_dir/src/IceInstrumentation.cpp",
174       "$subzero_dir/src/IceIntrinsics.cpp",
175       "$subzero_dir/src/IceLiveness.cpp",
176       "$subzero_dir/src/IceLoopAnalyzer.cpp",
177       "$subzero_dir/src/IceMangling.cpp",
178       "$subzero_dir/src/IceMemory.cpp",
179       "$subzero_dir/src/IceOperand.cpp",
180       "$subzero_dir/src/IceRNG.cpp",
181       "$subzero_dir/src/IceRangeSpec.cpp",
182       "$subzero_dir/src/IceRegAlloc.cpp",
183       "$subzero_dir/src/IceRevision.cpp",
184       "$subzero_dir/src/IceSwitchLowering.cpp",
185       "$subzero_dir/src/IceTargetLowering.cpp",
186       "$subzero_dir/src/IceTargetLoweringX86.cpp",
187       "$subzero_dir/src/IceThreading.cpp",
188       "$subzero_dir/src/IceTimerTree.cpp",
189       "$subzero_dir/src/IceTypes.cpp",
190       "$subzero_dir/src/IceVariableSplitting.cpp",
191       "$subzero_llvm_dir/lib/Demangle/ItaniumDemangle.cpp",
192       "$subzero_llvm_dir/lib/Support/APInt.cpp",
193       "$subzero_llvm_dir/lib/Support/Atomic.cpp",
194       "$subzero_llvm_dir/lib/Support/CommandLine.cpp",
195       "$subzero_llvm_dir/lib/Support/ConvertUTF.cpp",
196       "$subzero_llvm_dir/lib/Support/ConvertUTFWrapper.cpp",
197       "$subzero_llvm_dir/lib/Support/Debug.cpp",
198       "$subzero_llvm_dir/lib/Support/Errno.cpp",
199       "$subzero_llvm_dir/lib/Support/ErrorHandling.cpp",
200       "$subzero_llvm_dir/lib/Support/FoldingSet.cpp",
201       "$subzero_llvm_dir/lib/Support/Hashing.cpp",
202       "$subzero_llvm_dir/lib/Support/Host.cpp",
203       "$subzero_llvm_dir/lib/Support/ManagedStatic.cpp",
204       "$subzero_llvm_dir/lib/Support/MemoryBuffer.cpp",
205       "$subzero_llvm_dir/lib/Support/Mutex.cpp",
206       "$subzero_llvm_dir/lib/Support/NativeFormatting.cpp",
207       "$subzero_llvm_dir/lib/Support/Path.cpp",
208       "$subzero_llvm_dir/lib/Support/Process.cpp",
209       "$subzero_llvm_dir/lib/Support/Program.cpp",
210       "$subzero_llvm_dir/lib/Support/Regex.cpp",
211       "$subzero_llvm_dir/lib/Support/Signals.cpp",
212       "$subzero_llvm_dir/lib/Support/SmallPtrSet.cpp",
213       "$subzero_llvm_dir/lib/Support/SmallVector.cpp",
214       "$subzero_llvm_dir/lib/Support/StringExtras.cpp",
215       "$subzero_llvm_dir/lib/Support/StringMap.cpp",
216       "$subzero_llvm_dir/lib/Support/StringRef.cpp",
217       "$subzero_llvm_dir/lib/Support/StringSaver.cpp",
218       "$subzero_llvm_dir/lib/Support/TargetParser.cpp",
219       "$subzero_llvm_dir/lib/Support/Threading.cpp",
220       "$subzero_llvm_dir/lib/Support/Timer.cpp",
221       "$subzero_llvm_dir/lib/Support/Triple.cpp",
222       "$subzero_llvm_dir/lib/Support/Twine.cpp",
223       "$subzero_llvm_dir/lib/Support/circular_raw_ostream.cpp",
224       "$subzero_llvm_dir/lib/Support/raw_os_ostream.cpp",
225       "$subzero_llvm_dir/lib/Support/raw_ostream.cpp",
226       "$subzero_llvm_dir/lib/Support/regcomp.c",
227       "$subzero_llvm_dir/lib/Support/regerror.c",
228       "$subzero_llvm_dir/lib/Support/regexec.c",
229       "$subzero_llvm_dir/lib/Support/regfree.c",
230       "$subzero_llvm_dir/lib/Support/regstrlcpy.c",
231     ]
232
233     if (target_cpu == "x64") {
234       sources += [
235         "$subzero_dir/src/IceInstX8664.cpp",
236         "$subzero_dir/src/IceTargetLoweringX8664.cpp",
237       ]
238     } else {
239       sources += [
240         "$subzero_dir/src/IceInstX8632.cpp",
241         "$subzero_dir/src/IceTargetLoweringX8632.cpp",
242       ]
243     }
244
245     configs = [
246       ":swiftshader_subzero_common_private_config",
247       ":swiftshader_subzero_private_config",
248     ]
249   }
250 }
251
252 swiftshader_source_set("swiftshader_reactor") {
253   deps = [
254     "../OpenGL/common:swiftshader_opengl_common",
255   ]
256
257   sources = [
258     "Routine.cpp",
259   ]
260
261   if (use_swiftshader_with_subzero) {
262     deps += [ ":swiftshader_subzero" ]
263
264     sources += [
265       "Optimizer.cpp",
266       "SubzeroReactor.cpp",
267     ]
268
269     configs = [
270       ":swiftshader_subzero_common_private_config",
271       ":swiftshader_reactor_with_subzero_private_config",
272     ]
273   } else {
274     deps += [ "../../third_party/LLVM:swiftshader_llvm" ]
275
276     sources += [
277       "LLVMReactor.cpp",
278       "LLVMRoutine.cpp",
279       "LLVMRoutineManager.cpp",
280     ]
281
282     configs = [ ":swiftshader_reactor_private_config" ]
283
284     include_dirs = [
285       "..",
286       "../Common",
287       "../../third_party/LLVM/include/",
288     ]
289   }
290 }