• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-2024 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/runtime_core/static_core/ark_config.gni")
15import("//arkcompiler/runtime_core/static_vm_config.gni")
16import("$ark_root/plugins/plugins.gni")
17
18if (ark_standalone_build) {
19  import("$build_root/ark.gni")
20} else {
21  import("//build/ohos.gni")
22}
23
24ohos_static_library("libarktsbytecodeopt_package") {
25  deps = []
26  if (enable_static_vm) {
27    deps += [ ":libarktsbytecodeopt_frontend_static" ]
28  }
29
30  part_name = ark_part_name
31  subsystem_name = "$ark_subsystem_name"
32}
33
34config("bytecodeopt_public_config") {
35  include_dirs = [
36    "$target_gen_dir",
37    "$ark_root/bytecode_optimizer",
38  ]
39  if (enable_bytecode_optimizer && plugin_enable_bytecode_optimizer) {
40    defines = [ "ENABLE_BYTECODE_OPT" ]
41  }
42}
43
44if (!ark_static_standalone_build) {
45  ohos_shared_headers("bytecode_optimizer_headers") {
46    include_dirs = [
47      "$target_gen_dir",
48      "$ark_root/bytecode_optimizer",
49    ]
50    part_name = ark_part_name
51    subsystem_name = "$ark_subsystem_name"
52  }
53}
54
55libarkbytecodeopt_sources = [
56  "$ark_root/bytecode_optimizer/bytecodeopt_peepholes.cpp",
57  "$ark_root/bytecode_optimizer/canonicalization.cpp",
58  "$ark_root/bytecode_optimizer/check_resolver.cpp",
59  "$ark_root/bytecode_optimizer/codegen.cpp",
60  "$ark_root/bytecode_optimizer/common.cpp",
61  "$ark_root/bytecode_optimizer/const_array_resolver.cpp",
62  "$ark_root/bytecode_optimizer/optimize_bytecode.cpp",
63  "$ark_root/bytecode_optimizer/reg_acc_alloc.cpp",
64  "$ark_root/bytecode_optimizer/reg_encoder.cpp",
65  "$ark_root/bytecode_optimizer/runtime_adapter.cpp",
66]
67libarkbytecodeopt_sources += plugin_libarkbytecodeopt_sources
68
69libarkbytecodeopt_configs = [
70  "$ark_root:ark_config",
71  ":bytecodeopt_public_config",
72  "$ark_root/compiler:arkcompiler_public_config",
73  "$ark_root/libpandabase:arkbase_public_config",
74  "$ark_root/libpandafile:arkfile_public_config",
75  "$ark_root/assembler:arkassembler_public_config",
76  "$ark_root/runtime:arkruntime_public_config",
77]
78
79libarkbytecodeopt_configs += plugin_bytecodeopt_configs
80
81if (abckit_enable) {
82  libabckit_path = "$ark_root/../libabckit"
83  libabckit_deps = [
84    "$libabckit_path/src/templates/abckit_intrinsics:abckit_ark_gen_abckit_intrinsics_inl",
85    "$libabckit_path/src/templates/abckit_intrinsics:abckit_ark_gen_abckit_intrinsics_vreg_width_h",
86  ]
87}
88
89ohos_shared_library("libarktsbytecodeopt") {
90  sources = libarkbytecodeopt_sources
91
92  configs = libarkbytecodeopt_configs
93
94  deps = [
95    ":bytecodeopt_options_gen_h",
96    ":codegen_call_intrinsics_inc",
97    ":codegen_intrinsics_cpp",
98    ":codegen_visitors_inc",
99    ":get_intrinsic_id_inc",
100    ":isa_gen_arkbytecodeopt_check_width_cpp",
101    ":isa_gen_arkbytecodeopt_check_width_h",
102    ":isa_gen_arkbytecodeopt_insn_selection_cpp",
103    ":isa_gen_arkbytecodeopt_insn_selection_h",
104    ":reg_encoder_visitors_inc",
105    "$ark_root/assembler:libarktsassembler",
106    "$ark_root/compiler:libarktscompiler",
107    "$ark_root/libpandabase:libarktsbase",
108    "$ark_root/libpandafile:libarktsfile",
109  ]
110
111  deps += plugin_bytecodeopt_deps
112  if (abckit_enable) {
113    deps += libabckit_deps
114  }
115
116  external_deps = [ sdk_libc_secshared_dep ]
117
118  if (is_mingw || is_win) {
119    output_extension = "dll"
120  } else {
121    output_extension = "so"
122  }
123  part_name = ark_part_name
124  subsystem_name = "$ark_subsystem_name"
125}
126
127ohos_static_library("libarktsbytecodeopt_frontend_static") {
128  sources = libarkbytecodeopt_sources
129
130  configs = libarkbytecodeopt_configs
131
132  deps = [
133    ":bytecodeopt_options_gen_h",
134    ":codegen_call_intrinsics_inc",
135    ":codegen_intrinsics_cpp",
136    ":codegen_visitors_inc",
137    ":get_intrinsic_id_inc",
138    ":isa_gen_arkbytecodeopt_check_width_cpp",
139    ":isa_gen_arkbytecodeopt_check_width_h",
140    ":isa_gen_arkbytecodeopt_insn_selection_cpp",
141    ":isa_gen_arkbytecodeopt_insn_selection_h",
142    ":reg_encoder_visitors_inc",
143    "$ark_root/assembler:libarktsassembler_frontend_static",
144    "$ark_root/compiler:libarktscompiler_frontend_static",
145    "$ark_root/libpandabase:libarktsbase_frontend_static",
146    "$ark_root/libpandafile:libarktsfile_frontend_static",
147  ]
148
149  deps += plugin_bytecodeopt_deps
150
151  if (abckit_enable) {
152    deps += libabckit_deps
153  }
154
155  external_deps = [ sdk_libc_secshared_dep ]
156
157  part_name = ark_part_name
158  subsystem_name = "$ark_subsystem_name"
159}
160
161ark_isa_gen("isa_gen_arkbytecodeopt") {
162  template_files = [
163    "insn_selection.h.erb",
164    "insn_selection.cpp.erb",
165    "check_width.cpp.erb",
166    "check_width.h.erb",
167  ]
168  sources = "templates"
169  destination = "$target_gen_dir/generated"
170  requires = [
171    "bytecode_optimizer_isapi.rb",
172    "$ark_root/assembler/asm_isapi.rb",
173  ]
174}
175
176ark_gen_file("bytecodeopt_options_gen_h") {
177  template_file = "../templates/options/options.h.erb"
178  data = [ "options.yaml" ]
179  api = [ "../templates/common.rb" ]
180  output_file = "$target_gen_dir/generated/bytecodeopt_options_gen.h"
181}
182
183ark_gen_file("reg_encoder_visitors_inc") {
184  extra_dependencies = [ "$ark_root:concat_plugins_yamls" ]
185  template_file = "templates/reg_encoder_visitors.inc.erb"
186  data = [ ark_plugin_options_yaml ]
187  api = [ "$ark_root/templates/plugin_options.rb" ]
188  output_file = "$target_gen_dir/generated/reg_encoder_visitors.inc"
189}
190
191ark_gen_file("codegen_visitors_inc") {
192  extra_dependencies = [ "$ark_root:concat_plugins_yamls" ]
193  template_file = "templates/codegen_visitors.inc.erb"
194  data = [ ark_plugin_options_yaml ]
195  api = [ "$ark_root/templates/plugin_options.rb" ]
196  output_file = "$target_gen_dir/generated/codegen_visitors.inc"
197}
198
199ark_gen_file("codegen_intrinsics_cpp") {
200  extra_dependencies = [ "$ark_root:concat_plugins_yamls" ]
201  template_file = "templates/codegen_intrinsics.cpp.erb"
202  data = [ ark_plugin_options_yaml ]
203  api = [ "$ark_root/templates/plugin_options.rb" ]
204  output_file = "$target_gen_dir/generated/codegen_intrinsics.cpp"
205}
206
207ark_gen_file("codegen_call_intrinsics_inc") {
208  extra_dependencies = [
209    "$ark_root/runtime:arkruntime_gen_intrinsics_yaml",
210    "$ark_root:concat_plugins_yamls",
211  ]
212  template_file = "templates/codegen_call_intrinsics.inc.erb"
213  data = [
214    "$target_gen_dir/../runtime/intrinsics.yaml",
215    ark_plugin_options_yaml,
216  ]
217  api = [
218    "$ark_root/runtime/templates/intrinsics.rb",
219    "$ark_root/templates/plugin_options.rb",
220  ]
221  output_file = "$target_gen_dir/generated/codegen_call_intrinsics.inc"
222}
223
224ark_gen_file("get_intrinsic_id_inc") {
225  extra_dependencies = [ "$ark_root/runtime:arkruntime_gen_intrinsics_yaml" ]
226  template_file = "templates/get_intrinsic_id.inc.erb"
227  data = [ "$target_gen_dir/../runtime/intrinsics.yaml" ]
228  api = [ "$ark_root/runtime/templates/intrinsics.rb" ]
229  output_file = "$target_gen_dir/generated/get_intrinsic_id.inc"
230}
231