1# Copyright (c) 2023 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("//arkcompiler/ets_runtime/js_runtime_config.gni")
15
16include_directories = [
17  "${MAPLEALL_ROOT}/maple_be/include/cg",
18  "${MAPLEALL_ROOT}/maple_be/include/litecg",
19  "${MAPLEALL_ROOT}/maple_be/include/ad",
20  "${MAPLEALL_ROOT}/maple_be/include/ad/target",
21  "${MAPLEALL_ROOT}/maple_be/include/be",
22  "${MAPLEALL_ROOT}/maple_driver/include",
23  "${MAPLEALL_ROOT}/maple_util/include",
24  "${MAPLEALL_ROOT}/maple_ir/include",
25  "${MAPLEALL_ROOT}/maple_me/include",
26  "${MAPLEALL_ROOT}/mpl2mpl/include",
27  "${MAPLEALL_ROOT}/mempool/include",
28  "${MAPLEALL_ROOT}/maple_ipa/include",
29  "${MAPLEALL_ROOT}/maple_ipa/include/old",
30  "${MAPLEALL_ROOT}/maple_phase/include",
31]
32if (enable_jit_code_sign) {
33  include_directories += [ "$js_root/ecmascript/compiler" ]
34}
35
36deps_libcg = [
37  ":libmplbe",
38  "${MAPLEALL_ROOT}/mempool:libmempool",
39  "${MAPLEALL_ROOT}/maple_phase:libmplphase",
40  "${MAPLEALL_ROOT}/mpl2mpl:libmpl2mpl",
41  "${MAPLEALL_ROOT}/maple_ir:libmplir",
42  "${MAPLEALL_ROOT}/maple_util:libmplutil",
43  "${MAPLEALL_ROOT}/maple_me:libmplme",
44]
45
46deps_libmplbe = [ ":libcglowerer" ]
47
48if (TARGET == "aarch64" || TARGET == "x86_64") {
49  include_directories += [
50    "${MAPLEALL_ROOT}/maple_be/include/cg/x86_64",
51    "${MAPLEALL_ROOT}/maple_be/include/be/x86_64",
52    "${MAPLEALL_ROOT}/maple_be/include/cg/aarch64",
53    "${MAPLEALL_ROOT}/maple_be/include/be/aarch64",
54  ]
55  deps_libcg += [
56    ":libcgx8664",
57    ":libcgaarch64",
58    ":libcgphases",
59    "${MAPLEALL_ROOT}/maple_driver:libmaple_driver",
60  ]
61}
62
63if (TARGET == "ark") {
64  include_directories += [
65    "${MAPLEALL_ROOT}/maple_be/include/cg/ark",
66    "${MAPLEALL_ROOT}/maple_be/include/be/ark",
67  ]
68  deps_libcg += [ ":libcgark" ]
69}
70
71src_libcglowerer = [ "src/be/lower.cpp" ]
72
73src_libmplbe = [
74  "src/be/becommon.cpp",
75  "src/be/switch_lowerer.cpp",
76]
77
78src_libcgaarch64 = [
79  "src/cg/aarch64/aarch64_targetinfo.cpp",
80  "src/cg/aarch64/aarch64_abi.cpp",
81  "src/cg/aarch64/aarch64_call_conv.cpp",
82  "src/cg/aarch64/aarch64_cfi_generator.cpp",
83  "src/cg/aarch64/aarch64_cgfunc.cpp",
84  "src/cg/aarch64/aarch64_emitter.cpp",
85  "src/cg/aarch64/aarch64_obj_emitter.cpp",
86  "src/cg/aarch64/aarch64_fixshortbranch.cpp",
87  "src/cg/aarch64/aarch64_proepilog.cpp",
88  "src/cg/aarch64/aarch64_operand.cpp",
89  "src/cg/aarch64/aarch64_reg_info.cpp",
90  "src/cg/aarch64/aarch64_insn.cpp",
91  "src/cg/aarch64/aarch64_isa.cpp",
92  "src/cg/aarch64/aarch64_memlayout.cpp",
93  "src/cg/aarch64/aarch64_args.cpp",
94  "src/cg/aarch64/aarch64_live.cpp",
95  "src/cg/aarch64/aarch64_offset_adjust.cpp",
96  "src/cg/aarch64/aarch64_optimize_common.cpp",
97  "src/cg/aarch64/aarch64_peep.cpp",
98  "src/cg/aarch64/aarch64_cg.cpp",
99  "src/cg/aarch64/aarch64_cfgo.cpp",
100  "src/cg/aarch64/aarch64_imm_valid.cpp",
101]
102
103src_libcgx86phases = [
104  "src/cg/peep.cpp",
105  "src/cg/cfgo.cpp",
106  "src/cg/cg_dominance.cpp",
107  "src/cg/cg_stackmap_computation.cpp",
108]
109
110src_libcgx8664 = [
111  "src/cg/x86_64/x64_targetinfo.cpp",
112  "src/cg/x86_64/x64_cg.cpp",
113  "src/cg/x86_64/x64_MPIsel.cpp",
114  "src/cg/x86_64/x64_cgfunc.cpp",
115  "src/cg/x86_64/x64_memlayout.cpp",
116  "src/cg/x86_64/x64_emitter.cpp",
117  "src/cg/x86_64/x64_abi.cpp",
118  "src/cg/x86_64/x64_call_conv.cpp",
119  "src/cg/x86_64/x64_standardize.cpp",
120  "src/cg/x86_64/x64_reg_info.cpp",
121  "src/cg/x86_64/x64_proepilog.cpp",
122  "src/cg/x86_64/x64_args.cpp",
123  "src/cg/x86_64/x64_peep.cpp",
124  "src/cg/x86_64/x64_cfgo.cpp",
125  "src/cg/x86_64/x64_isa.cpp",
126  "src/cg/x86_64/x64_optimize_common.cpp",
127  "src/cg/x86_64/elf_assembler.cpp",
128  "src/cg/x86_64/asm_assembler.cpp",
129]
130
131src_libcgark = [ "src/cg/ark/foo.cpp" ]
132
133src_libcgphases = [
134  "src/cg/cfi_generator.cpp",
135  "src/cg/cfgo.cpp",
136  "src/cg/peep.cpp",
137  "src/cg/cg_dominance.cpp",
138]
139
140src_libcg = [
141  "src/cg/args.cpp",
142  "src/cg/cg_irbuilder.cpp",
143  "src/cg/cfi.cpp",
144  "src/cg/cgbb.cpp",
145  "src/cg/operand.cpp",
146  "src/cg/cgfunc.cpp",
147  "src/cg/cg_cfg.cpp",
148  "src/cg/cg_option.cpp",
149  "src/cg/cg_options.cpp",
150  "src/cg/optimize_common.cpp",
151  "src/cg/emit.cpp",
152  "src/cg/obj_emit.cpp",
153  "src/cg/ifile.cpp",
154  "src/cg/live.cpp",
155  "src/cg/loop.cpp",
156  "src/cg/isel.cpp",
157  "src/cg/standardize.cpp",
158  "src/cg/memlayout.cpp",
159  "src/cg/label_creation.cpp",
160  "src/cg/offset_adjust.cpp",
161  "src/cg/reg_alloc.cpp",
162  "src/cg/reg_alloc_lsra.cpp",
163  "src/cg/proepilog.cpp",
164  "src/cg/cg.cpp",
165  "src/cg/isa.cpp",
166  "src/cg/insn.cpp",
167  "src/cg/cg_phasemanager.cpp",
168  "src/litecg/litecg.cpp",
169  "src/litecg/lmir_builder.cpp",
170  "src/cg/target_registry.cpp",
171  "src/cg/target_select.cpp",
172]
173
174ohos_source_set("libcglowerer") {
175  stack_protector_ret = false
176  if (enable_sanitize) {
177    sanitize = {
178      cfi = true
179      cfi_cross_dso = true
180      debug = false
181    }
182    branch_protector_ret = "pac_ret"
183  }
184  configs = [ "${MAPLEALL_ROOT}:mapleallcompilecfg" ]
185  sources = src_libcglowerer
186  include_dirs = include_directories
187  external_deps = [ "bounds_checking_function:libsec_static" ]
188  part_name = "ets_runtime"
189  subsystem_name = "arkcompiler"
190}
191
192ohos_static_library("libmplbe") {
193  stack_protector_ret = false
194  if (enable_sanitize) {
195    sanitize = {
196      cfi = true
197      cfi_cross_dso = true
198      debug = false
199    }
200    branch_protector_ret = "pac_ret"
201  }
202  configs = [ "${MAPLEALL_ROOT}:mapleallcompilecfg" ]
203  sources = src_libmplbe
204  deps = deps_libmplbe
205  include_dirs = include_directories
206  output_dir = "${root_out_dir}/lib/${HOST_ARCH}"
207  external_deps = [ "bounds_checking_function:libsec_static" ]
208  part_name = "ets_runtime"
209  subsystem_name = "arkcompiler"
210}
211
212ohos_source_set("libcgaarch64") {
213  stack_protector_ret = false
214  if (enable_sanitize) {
215    sanitize = {
216      cfi = true
217      cfi_cross_dso = true
218      debug = false
219    }
220    branch_protector_ret = "pac_ret"
221  }
222  configs = [ "${MAPLEALL_ROOT}:mapleallcompilecfg" ]
223  sources = src_libcgaarch64
224  include_dirs = include_directories
225  defines = []
226  external_deps = [ "bounds_checking_function:libsec_static" ]
227  if (enable_jit_code_sign) {
228    defines += [ "JIT_ENABLE_CODE_SIGN" ]
229    external_deps += [ "code_signature:libjit_code_sign" ]
230    if (disable_fort_switch) {
231      defines += [ "JIT_FORT_DISABLE" ]
232    }
233  }
234  part_name = "ets_runtime"
235  subsystem_name = "arkcompiler"
236}
237
238ohos_source_set("libcgx8664") {
239  stack_protector_ret = false
240  if (enable_sanitize) {
241    sanitize = {
242      cfi = true
243      cfi_cross_dso = true
244      debug = false
245    }
246    branch_protector_ret = "pac_ret"
247  }
248  configs = [ "${MAPLEALL_ROOT}:mapleallcompilecfg" ]
249  sources = src_libcgx8664
250  include_dirs = include_directories
251  external_deps = [ "bounds_checking_function:libsec_static" ]
252  part_name = "ets_runtime"
253  subsystem_name = "arkcompiler"
254}
255
256ohos_source_set("libcgx86phases") {
257  stack_protector_ret = false
258  if (enable_sanitize) {
259    sanitize = {
260      cfi = true
261      cfi_cross_dso = true
262      debug = false
263    }
264    branch_protector_ret = "pac_ret"
265  }
266  configs = [ "${MAPLEALL_ROOT}:mapleallcompilecfg" ]
267  sources = src_libcgx86phases
268  include_dirs = include_directories
269  external_deps = [ "bounds_checking_function:libsec_static" ]
270  part_name = "ets_runtime"
271  subsystem_name = "arkcompiler"
272}
273
274ohos_static_library("libcgark") {
275  stack_protector_ret = false
276  if (enable_sanitize) {
277    sanitize = {
278      cfi = true
279      cfi_cross_dso = true
280      debug = false
281    }
282    branch_protector_ret = "pac_ret"
283  }
284  configs = [ "${MAPLEALL_ROOT}:mapleallcompilecfg" ]
285  sources = src_libcgark
286  include_dirs = include_directories
287  external_deps = [ "bounds_checking_function:libsec_static" ]
288  part_name = "ets_runtime"
289  subsystem_name = "arkcompiler"
290}
291
292ohos_source_set("libcgphases") {
293  stack_protector_ret = false
294  if (enable_sanitize) {
295    sanitize = {
296      cfi = true
297      cfi_cross_dso = true
298      debug = false
299    }
300    branch_protector_ret = "pac_ret"
301  }
302  configs = [ "${MAPLEALL_ROOT}:mapleallcompilecfg" ]
303  sources = src_libcgphases
304  include_dirs = include_directories
305  external_deps = [ "bounds_checking_function:libsec_static" ]
306  part_name = "ets_runtime"
307  subsystem_name = "arkcompiler"
308}
309
310ohos_static_library("libcg") {
311  stack_protector_ret = false
312  if (enable_sanitize) {
313    sanitize = {
314      cfi = true
315      cfi_cross_dso = true
316      debug = false
317    }
318    branch_protector_ret = "pac_ret"
319  }
320  configs = [ "${MAPLEALL_ROOT}:mapleallcompilecfg" ]
321  sources = src_libcg
322  include_dirs = include_directories
323  deps = deps_libcg
324  output_dir = "${root_out_dir}/lib/${HOST_ARCH}"
325  defines = []
326  external_deps = [ "bounds_checking_function:libsec_static" ]
327  part_name = "ets_runtime"
328  subsystem_name = "arkcompiler"
329}
330