1# Copyright (c) 2021-2022 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/ark_config.gni") 15 16config("bytecodeopt_public_config") { 17 include_dirs = [ 18 "$target_gen_dir", 19 "$ark_root/bytecode_optimizer", 20 ] 21 if (enable_bytecode_optimizer) { 22 defines = [ "ENABLE_BYTECODE_OPT" ] 23 } 24} 25 26libarkbytecodeopt_sources = [ 27 "$ark_root/bytecode_optimizer/bytecode_analysis_results.cpp", 28 "$ark_root/bytecode_optimizer/codegen.cpp", 29 "$ark_root/bytecode_optimizer/common.cpp", 30 "$ark_root/bytecode_optimizer/constant_propagation/constant_propagation.cpp", 31 "$ark_root/bytecode_optimizer/constant_propagation/lattice_element.cpp", 32 "$ark_root/bytecode_optimizer/module_constant_analyzer.cpp", 33 "$ark_root/bytecode_optimizer/optimize_bytecode.cpp", 34 "$ark_root/bytecode_optimizer/reg_acc_alloc.cpp", 35 "$ark_root/bytecode_optimizer/reg_encoder.cpp", 36] 37 38libarkbytecodeopt_configs = [ 39 "$ark_root:ark_config", 40 ":bytecodeopt_public_config", 41 "$ark_root/compiler:arkcompiler_public_config", 42 "$ark_root/libpandabase:arkbase_public_config", 43 "$ark_root/libpandafile:arkfile_public_config", 44 "$ark_root/assembler:arkassembler_public_config", 45] 46 47ohos_shared_library("libarkbytecodeopt") { 48 stack_protector_ret = false 49 sources = libarkbytecodeopt_sources 50 51 configs = libarkbytecodeopt_configs 52 53 deps = [ 54 ":bytecodeopt_options_gen_h", 55 ":codegen_intrinsics_cpp", 56 ":codegen_visitors_inc", 57 ":isa_gen_arkbytecodeopt_check_width_cpp", 58 ":isa_gen_arkbytecodeopt_check_width_h", 59 ":isa_gen_arkbytecodeopt_insn_selection_cpp", 60 ":isa_gen_arkbytecodeopt_insn_selection_h", 61 ":reg_encoder_visitors_inc", 62 "$ark_root/assembler:libarkassembler", 63 "$ark_root/compiler:libarkcompiler", 64 "$ark_root/libpandabase:libarkbase", 65 "$ark_root/libpandafile:libarkfile", 66 ] 67 68 external_deps = [ sdk_libc_secshared_dep ] 69 70 relative_install_dir = "ark" 71 output_extension = "so" 72 part_name = "runtime_core" 73 subsystem_name = "arkcompiler" 74} 75 76ohos_static_library("libarkbytecodeopt_frontend_static") { 77 stack_protector_ret = false 78 sources = libarkbytecodeopt_sources 79 80 configs = libarkbytecodeopt_configs 81 82 deps = [ 83 ":bytecodeopt_options_gen_h", 84 ":codegen_intrinsics_cpp", 85 ":codegen_visitors_inc", 86 ":isa_gen_arkbytecodeopt_check_width_cpp", 87 ":isa_gen_arkbytecodeopt_check_width_h", 88 ":isa_gen_arkbytecodeopt_insn_selection_cpp", 89 ":isa_gen_arkbytecodeopt_insn_selection_h", 90 ":reg_encoder_visitors_inc", 91 "$ark_root/assembler:libarkassembler_frontend_static", 92 "$ark_root/compiler:libarkcompiler_frontend_static", 93 "$ark_root/libpandabase:libarkbase_frontend_static", 94 "$ark_root/libpandafile:libarkfile_frontend_static", 95 ] 96 97 if (is_arkui_x) { 98 deps += [ "$ark_third_party_root/bounds_checking_function:libsec_static" ] 99 } else { 100 external_deps = [ sdk_libc_secshared_dep ] 101 } 102 103 part_name = "runtime_core" 104 subsystem_name = "arkcompiler" 105} 106 107ark_isa_gen("isa_gen_arkbytecodeopt") { 108 template_files = [ 109 "insn_selection.h.erb", 110 "insn_selection.cpp.erb", 111 "check_width.cpp.erb", 112 "check_width.h.erb", 113 ] 114 sources = "templates" 115 destination = "$target_gen_dir/generated" 116 requires = [ 117 "bytecode_optimizer_isapi.rb", 118 "$ark_root/assembler/asm_isapi.rb", 119 ] 120} 121 122ark_gen_file("bytecodeopt_options_gen_h") { 123 template_file = "../templates/options/options.h.erb" 124 data_file = "options.yaml" 125 requires = [ "../templates/common.rb" ] 126 output_file = "$target_gen_dir/generated/bytecodeopt_options_gen.h" 127} 128 129ark_gen_file("reg_encoder_visitors_inc") { 130 extra_dependencies = [ "$ark_root:concat_plugins_yamls" ] 131 template_file = "templates/reg_encoder_visitors.inc.erb" 132 data_file = "$target_gen_dir/../plugin_options.yaml" 133 requires = [ "$ark_root/templates/plugin_options.rb" ] 134 output_file = "$target_gen_dir/generated/reg_encoder_visitors.inc" 135} 136 137ark_gen_file("codegen_visitors_inc") { 138 extra_dependencies = [ "$ark_root:concat_plugins_yamls" ] 139 template_file = "templates/codegen_visitors.inc.erb" 140 data_file = "$target_gen_dir/../plugin_options.yaml" 141 requires = [ "$ark_root/templates/plugin_options.rb" ] 142 output_file = "$target_gen_dir/generated/codegen_visitors.inc" 143} 144 145ark_gen_file("codegen_intrinsics_cpp") { 146 extra_dependencies = [ "$ark_root:concat_plugins_yamls" ] 147 template_file = "templates/codegen_intrinsics.cpp.erb" 148 data_file = "$target_gen_dir/../plugin_options.yaml" 149 requires = [ "$ark_root/templates/plugin_options.rb" ] 150 output_file = "$target_gen_dir/generated/codegen_intrinsics.cpp" 151} 152