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