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