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") 15config("arkcompiler_public_config") { 16 include_dirs = [ 17 "$ark_root/compiler", 18 "$ark_root/compiler/code_info", 19 "$ark_root/compiler/optimizer/ir", 20 "$target_gen_dir/generated", 21 ] 22 23 include_dirs += platform_include_dirs 24 25 if (enable_bytecode_optimizer) { 26 defines = [ "ENABLE_BYTECODE_OPT" ] 27 } 28 29 is_x64 = 30 current_cpu == "amd64" || current_cpu == "x64" || current_cpu == "x86_64" 31 32 cflags_cc = [] 33 if (is_x64 || current_cpu == "arm64") { 34 if (!is_mingw) { 35 cflags_cc += [ 36 "-DPANDA_COMPILER_TARGET_AARCH64", 37 "-DUSE_VIXL_ARM64", 38 ] 39 } 40 } 41 if (ark_enable_compiler_x64) { 42 cflags_cc += [ "-DPANDA_COMPILER_TARGET_X86_64" ] 43 } 44} 45 46libarkcompiler_sources = [ 47 "compiler_logger.cpp", 48 "compiler_options.cpp", 49 "optimizer/analysis/dominators_tree.cpp", 50 "optimizer/analysis/linear_order.cpp", 51 "optimizer/analysis/liveness_analyzer.cpp", 52 "optimizer/analysis/loop_analyzer.cpp", 53 "optimizer/analysis/rpo.cpp", 54 "optimizer/ir/basicblock.cpp", 55 "optimizer/ir/dump.cpp", 56 "optimizer/ir/graph.cpp", 57 "optimizer/ir/graph_checker.cpp", 58 "optimizer/ir/graph_cloner.cpp", 59 "optimizer/ir/inst.cpp", 60 "optimizer/ir/locations.cpp", 61 "optimizer/ir_builder/inst_builder.cpp", 62 "optimizer/ir_builder/ir_builder.cpp", 63 "optimizer/optimizations/cleanup.cpp", 64 "optimizer/optimizations/lowering.cpp", 65 "optimizer/optimizations/move_constants.cpp", 66 "optimizer/optimizations/regalloc/interference_graph.cpp", 67 "optimizer/optimizations/regalloc/reg_alloc.cpp", 68 "optimizer/optimizations/regalloc/reg_alloc_base.cpp", 69 "optimizer/optimizations/regalloc/reg_alloc_graph_coloring.cpp", 70 "optimizer/optimizations/regalloc/reg_alloc_resolver.cpp", 71 "optimizer/optimizations/regalloc/reg_alloc_stat.cpp", 72 "optimizer/optimizations/regalloc/reg_map.cpp", 73 "optimizer/optimizations/regalloc/spill_fills_resolver.cpp", 74 "optimizer/optimizations/regalloc/split_resolver.cpp", 75 "optimizer/optimizations/vn.cpp", 76 "optimizer/pass.cpp", 77 "optimizer/pass_manager.cpp", 78 "optimizer/pass_manager_statistics.cpp", 79] 80 81libarkcompiler_sources += [ "$target_gen_dir/generated/inst_builder_gen.cpp" ] 82 83libarkcompiler_configs = [ 84 sdk_libc_secshared_config, 85 ":arkcompiler_public_config", 86 "$ark_root:ark_config", 87 "$ark_root/libpandabase:arkbase_public_config", 88 "$ark_root/libpandafile:arkfile_public_config", 89] 90 91ohos_shared_library("libarkcompiler") { 92 stack_protector_ret = false 93 sources = libarkcompiler_sources 94 95 configs = libarkcompiler_configs 96 97 deps = [ 98 ":codegen_language_extensions_h", 99 ":compiler_events_gen_h", 100 ":compiler_interface_extensions_inl_h", 101 ":compiler_logger_components_inc", 102 ":compiler_options_gen_h", 103 ":cpu_features_gen_inc", 104 ":intrinsics_codegen_ext_inl_h", 105 ":intrinsics_inline_inl", 106 ":intrinsics_ir_build_inl_h", 107 ":intrinsics_ir_build_static_call_inl", 108 ":intrinsics_ir_build_virtual_call_inl", 109 ":intrinsics_stub_inl", 110 ":intrinsics_stub_inl_h", 111 ":ir_dyn_base_types_h", 112 ":isa_gen_libarkcompiler_inst_builder_gen_cpp", 113 ":libarkcompiler_ecma_intrinsics_enum_inl", 114 ":libarkcompiler_generate_ecma_inl", 115 ":libarkcompiler_intrinsics_gen_inl_generate_operations_intrinsic_graph_inl", 116 ":libarkcompiler_intrinsics_gen_inl_generate_operations_intrinsic_inst_inl", 117 ":libarkcompiler_intrinsics_gen_inl_get_intrinsics_inl", 118 ":libarkcompiler_intrinsics_gen_inl_get_intrinsics_names_inl", 119 ":libarkcompiler_intrinsics_gen_inl_intrinsic_codegen_test_inl", 120 ":libarkcompiler_intrinsics_gen_inl_intrinsic_flags_test_inl", 121 ":libarkcompiler_intrinsics_gen_inl_intrinsics_codegen_inl", 122 ":libarkcompiler_intrinsics_gen_inl_intrinsics_codegen_inl_h", 123 ":libarkcompiler_intrinsics_gen_inl_intrinsics_enum_inl", 124 ":libarkcompiler_intrinsics_gen_inl_intrinsics_flags_inl", 125 ":libarkcompiler_intrinsics_gen_inl_intrinsics_ir_build_inl", 126 ":libarkcompiler_opcodes_h_IR-instructions_md", 127 ":libarkcompiler_opcodes_h_arch_info_gen_h", 128 ":libarkcompiler_opcodes_h_codegen_arm64_gen_inc", 129 ":libarkcompiler_opcodes_h_inst_checker_gen_h", 130 ":libarkcompiler_opcodes_h_opcodes_h", 131 ":source_languages_h", 132 "$ark_root/libpandabase:libarkbase", 133 "$ark_root/libpandafile:isa_gen_libarkfile_bytecode_instruction-inl_gen_h", 134 "$ark_root/libpandafile:isa_gen_libarkfile_bytecode_instruction_enum_gen_h", 135 "$ark_root/libpandafile:libarkfile", 136 "$ark_root/libpandafile:libarkfile_type_gen_h", 137 sdk_libc_secshared_dep, 138 ] 139 140 include_dirs = [ "$ark_root/compiler/optimizer" ] 141 142 output_extension = "so" 143 relative_install_dir = "ark" 144 part_name = "runtime_core" 145 subsystem_name = "arkcompiler" 146} 147 148ohos_static_library("libarkcompiler_frontend_static") { 149 stack_protector_ret = false 150 sources = libarkcompiler_sources 151 152 configs = libarkcompiler_configs 153 154 deps = [ 155 ":codegen_language_extensions_h", 156 ":compiler_events_gen_h", 157 ":compiler_interface_extensions_inl_h", 158 ":compiler_logger_components_inc", 159 ":compiler_options_gen_h", 160 ":cpu_features_gen_inc", 161 ":intrinsics_codegen_ext_inl_h", 162 ":intrinsics_inline_inl", 163 ":intrinsics_ir_build_inl_h", 164 ":intrinsics_ir_build_static_call_inl", 165 ":intrinsics_ir_build_virtual_call_inl", 166 ":intrinsics_stub_inl", 167 ":intrinsics_stub_inl_h", 168 ":ir_dyn_base_types_h", 169 ":isa_gen_libarkcompiler_inst_builder_gen_cpp", 170 ":libarkcompiler_ecma_intrinsics_enum_inl", 171 ":libarkcompiler_generate_ecma_inl", 172 ":libarkcompiler_intrinsics_gen_inl_generate_operations_intrinsic_graph_inl", 173 ":libarkcompiler_intrinsics_gen_inl_generate_operations_intrinsic_inst_inl", 174 ":libarkcompiler_intrinsics_gen_inl_get_intrinsics_inl", 175 ":libarkcompiler_intrinsics_gen_inl_get_intrinsics_names_inl", 176 ":libarkcompiler_intrinsics_gen_inl_intrinsic_codegen_test_inl", 177 ":libarkcompiler_intrinsics_gen_inl_intrinsic_flags_test_inl", 178 ":libarkcompiler_intrinsics_gen_inl_intrinsics_codegen_inl", 179 ":libarkcompiler_intrinsics_gen_inl_intrinsics_codegen_inl_h", 180 ":libarkcompiler_intrinsics_gen_inl_intrinsics_enum_inl", 181 ":libarkcompiler_intrinsics_gen_inl_intrinsics_flags_inl", 182 ":libarkcompiler_intrinsics_gen_inl_intrinsics_ir_build_inl", 183 ":libarkcompiler_opcodes_h_IR-instructions_md", 184 ":libarkcompiler_opcodes_h_arch_info_gen_h", 185 ":libarkcompiler_opcodes_h_codegen_arm64_gen_inc", 186 ":libarkcompiler_opcodes_h_inst_checker_gen_h", 187 ":libarkcompiler_opcodes_h_opcodes_h", 188 ":source_languages_h", 189 "$ark_root/libpandabase:libarkbase_frontend_static", 190 "$ark_root/libpandafile:isa_gen_libarkfile_bytecode_instruction-inl_gen_h", 191 "$ark_root/libpandafile:isa_gen_libarkfile_bytecode_instruction_enum_gen_h", 192 "$ark_root/libpandafile:libarkfile_frontend_static", 193 "$ark_root/libpandafile:libarkfile_type_gen_h", 194 sdk_libc_secshared_dep, 195 ] 196 197 include_dirs = [ "$ark_root/compiler/optimizer" ] 198 199 part_name = "runtime_core" 200 subsystem_name = "arkcompiler" 201} 202 203ark_isa_gen("isa_gen_libarkcompiler") { 204 template_files = [ "inst_builder_gen.cpp.erb" ] 205 sources = "optimizer/templates" 206 destination = "$target_gen_dir/generated" 207} 208 209ark_gen("libarkcompiler_intrinsics_gen_inl") { 210 data = "intrinsics.yaml" 211 template_files = [ 212 "intrinsics_enum.inl.erb", 213 "get_intrinsics.inl.erb", 214 "entrypoints_bridge_asm_macro.inl.erb", 215 "intrinsics_ir_build.inl.erb", 216 "get_intrinsics_names.inl.erb", 217 "generate_operations_intrinsic_inst.inl.erb", 218 "generate_operations_intrinsic_graph.inl.erb", 219 "intrinsic_codegen_test.inl.erb", 220 "intrinsic_flags_test.inl.erb", 221 "intrinsics_codegen.inl.h.erb", 222 "intrinsics_codegen.inl.erb", 223 "intrinsics_flags.inl.erb", 224 ] 225 sources = "optimizer/templates/intrinsics" 226 destination = "$target_gen_dir/generated" 227 requires = [ 228 "$ark_root/compiler/optimizer/templates/intrinsics/compiler_intrinsics.rb", 229 ] 230} 231 232ark_isa_gen("libarkcompiler") { 233 template_files = [ 234 "generate_ecma.inl.erb", 235 "ecma_intrinsics_enum.inl.erb", 236 ] 237 sources = "optimizer/templates" 238 requires = [ "$ark_root//assembler/asm_isapi.rb" ] 239 destination = "$target_gen_dir/generated" 240} 241 242ark_gen("libarkcompiler_opcodes_h") { 243 data = "$ark_root/compiler/optimizer/ir/instructions.yaml" 244 template_files = [ 245 "opcodes.h.erb", 246 "arch_info_gen.h.erb", 247 "inst_checker_gen.h.erb", 248 "IR-instructions.md.erb", 249 "codegen_arm64_gen.inc.erb", 250 ] 251 sources = "optimizer/templates" 252 destination = "$target_gen_dir/generated" 253 requires = [ "$ark_root/compiler/optimizer/templates/instructions.rb" ] 254} 255 256ark_gen_file("compiler_options_gen_h") { 257 template_file = "$ark_root/templates/options/options.h.erb" 258 data_file = "compiler.yaml" 259 requires = [ "$ark_root/templates/common.rb" ] 260 output_file = "$target_gen_dir/generated/compiler_options_gen.h" 261} 262 263ark_gen_file("cpu_features_gen_inc") { 264 template_file = "$ark_root/templates/cpu_features.inc.erb" 265 data_file = "compiler.yaml" 266 requires = [ "$ark_root/templates/common.rb" ] 267 output_file = "$target_gen_dir/generated/cpu_features.inc" 268} 269 270ark_gen_file("compiler_events_gen_h") { 271 template_file = "$ark_root/templates/events/events.h.erb" 272 data_file = "compiler.yaml" 273 requires = [ "$ark_root/templates/common.rb" ] 274 output_file = "$target_gen_dir/generated/compiler_events_gen.h" 275} 276 277ark_gen_file("compiler_logger_components_inc") { 278 template_file = 279 "$ark_root/templates/logger_components/logger_components.inc.erb" 280 data_file = "compiler.yaml" 281 requires = [ "$ark_root/templates/common.rb" ] 282 output_file = "$target_gen_dir/generated/compiler_logger_components.inc" 283} 284ark_gen_file("intrinsics_stub_inl") { 285 extra_dependencies = [ "$ark_root:concat_plugins_yamls" ] 286 template_file = "optimizer/templates/intrinsics/intrinsics_stub.inl.erb" 287 data_file = "$target_gen_dir/../plugin_options.yaml" 288 requires = [ "$ark_root/templates/plugin_options.rb" ] 289 output_file = "$target_gen_dir/generated/intrinsics_stub.inl" 290} 291ark_gen_file("intrinsics_stub_inl_h") { 292 extra_dependencies = [ "$ark_root:concat_plugins_yamls" ] 293 template_file = "optimizer/templates/intrinsics/intrinsics_stub.inl.h.erb" 294 data_file = "$target_gen_dir/../plugin_options.yaml" 295 requires = [ "$ark_root/templates/plugin_options.rb" ] 296 output_file = "$target_gen_dir/generated/intrinsics_stub.inl.h" 297} 298ark_gen_file("intrinsics_codegen_ext_inl_h") { 299 extra_dependencies = [ "$ark_root:concat_plugins_yamls" ] 300 template_file = 301 "optimizer/templates/intrinsics/intrinsics_codegen_ext.inl.h.erb" 302 data_file = "$target_gen_dir/../plugin_options.yaml" 303 requires = [ "$ark_root/templates/plugin_options.rb" ] 304 output_file = "$target_gen_dir/generated/intrinsics_codegen_ext.inl.h" 305} 306ark_gen_file("intrinsics_inline_inl") { 307 extra_dependencies = [ "$ark_root:concat_plugins_yamls" ] 308 template_file = "optimizer/templates/intrinsics/intrinsics_inline.inl.erb" 309 data_file = "$target_gen_dir/../plugin_options.yaml" 310 requires = [ "$ark_root/templates/plugin_options.rb" ] 311 output_file = "$target_gen_dir/generated/intrinsics_inline.inl" 312} 313ark_gen_file("intrinsics_ir_build_inl_h") { 314 extra_dependencies = [ "$ark_root:concat_plugins_yamls" ] 315 template_file = "optimizer/templates/intrinsics/intrinsics_ir_build.inl.h.erb" 316 data_file = "$target_gen_dir/../plugin_options.yaml" 317 requires = [ "$ark_root/templates/plugin_options.rb" ] 318 output_file = "$target_gen_dir/generated/intrinsics_ir_build.inl.h" 319} 320ark_gen_file("intrinsics_ir_build_static_call_inl") { 321 extra_dependencies = [ "$ark_root:concat_plugins_yamls" ] 322 template_file = 323 "optimizer/templates/intrinsics/intrinsics_ir_build_static_call.inl.erb" 324 data_file = "$target_gen_dir/../plugin_options.yaml" 325 requires = [ "$ark_root/templates/plugin_options.rb" ] 326 output_file = "$target_gen_dir/generated/intrinsics_ir_build_static_call.inl" 327} 328ark_gen_file("intrinsics_ir_build_virtual_call_inl") { 329 extra_dependencies = [ "$ark_root:concat_plugins_yamls" ] 330 template_file = 331 "optimizer/templates/intrinsics/intrinsics_ir_build_virtual_call.inl.erb" 332 data_file = "$target_gen_dir/../plugin_options.yaml" 333 requires = [ "$ark_root/templates/plugin_options.rb" ] 334 output_file = "$target_gen_dir/generated/intrinsics_ir_build_virtual_call.inl" 335} 336 337ark_gen_file("ir_dyn_base_types_h") { 338 extra_dependencies = [ "$ark_root:concat_plugins_yamls" ] 339 template_file = "optimizer/templates/ir-dyn-base-types.h.erb" 340 data_file = "$target_gen_dir/../plugin_options.yaml" 341 requires = [ "$ark_root/templates/plugin_options.rb" ] 342 output_file = "$target_gen_dir/generated/ir-dyn-base-types.h" 343} 344 345ark_gen_file("source_languages_h") { 346 extra_dependencies = [ "$ark_root:concat_plugins_yamls" ] 347 template_file = "optimizer/templates/source_languages.h.erb" 348 data_file = "$target_gen_dir/../plugin_options.yaml" 349 requires = [ "$ark_root/templates/plugin_options.rb" ] 350 output_file = "$target_gen_dir/generated/source_languages.h" 351} 352 353ark_gen_file("codegen_language_extensions_h") { 354 extra_dependencies = [ "$ark_root:concat_plugins_yamls" ] 355 template_file = "optimizer/templates/codegen_language_extensions.h.erb" 356 data_file = "$target_gen_dir/../plugin_options.yaml" 357 requires = [ "$ark_root/templates/plugin_options.rb" ] 358 output_file = "$target_gen_dir/generated/codegen_language_extensions.h" 359} 360 361ark_gen_file("compiler_interface_extensions_inl_h") { 362 extra_dependencies = [ "$ark_root:concat_plugins_yamls" ] 363 template_file = "optimizer/templates/compiler_interface_extensions.inl.h.erb" 364 data_file = "$target_gen_dir/../plugin_options.yaml" 365 requires = [ "$ark_root/templates/plugin_options.rb" ] 366 output_file = "$target_gen_dir/generated/compiler_interface_extensions.inl.h" 367} 368