1// Copyright (C) 2023 The Android Open Source Project 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14// 15 16package { 17 default_applicable_licenses: ["Android-Apache-2.0"], 18} 19 20python_binary_host { 21 name: "berberis_gen_lir", 22 main: "gen_lir.py", 23 srcs: ["gen_lir.py"], 24 libs: ["gen_lir_lib"], 25} 26 27python_library_host { 28 name: "gen_lir_lib", 29 srcs: ["gen_lir_lib.py"], 30 libs: ["asm_defs_lib"], 31} 32 33python_binary_host { 34 name: "berberis_gen_reg_class", 35 main: "gen_reg_class.py", 36 srcs: ["gen_reg_class.py"], 37 libs: ["gen_reg_class_lib"], 38} 39 40python_library_host { 41 name: "gen_reg_class_lib", 42 srcs: ["gen_reg_class_lib.py"], 43} 44 45filegroup { 46 name: "libberberis_backend_machine_ir_gen_inputs_x86_64", 47 srcs: ["x86_64/lir_instructions.json"], 48} 49 50filegroup { 51 name: "libberberis_backend_reg_class_gen_inputs_x86_64", 52 srcs: ["x86_64/reg_class_def.json"], 53} 54 55filegroup { 56 name: "libberberis_backend_gen_inputs_riscv64_to_x86_64", 57 srcs: [ 58 ":libberberis_backend_machine_ir_gen_inputs_x86_64", 59 ":libberberis_machine_ir_intrinsic_binding_riscv64_to_x86_64", 60 ":libberberis_assembler_gen_inputs_x86_64", 61 ":libberberis_macro_assembler_gen_inputs_riscv64_to_x86_64", 62 ], 63} 64 65genrule_defaults { 66 name: "berberis_backend_machine_ir_gen_headers_x86_64_defaults", 67 out: [ 68 "insn-inl_x86_64.h", 69 "machine_info_x86_64-inl.h", 70 "machine_opcode_x86_64-inl.h", 71 "gen_machine_ir_x86_64-inl.h", 72 ], 73 tools: ["berberis_gen_lir"], 74 cmd: "$(location berberis_gen_lir) --headers $(out) $(in)", 75 // Targets using these defaults must provide the following guest-specific 76 // fields. lir instructions MUST end with `lir_instructions.json` and 77 // machine ir instrinsic bindngs MUST end with 78 // `machine_ir_intrinsice_binding.json`. Order matters and def's have no 79 // naming requirements: 80 // srcs: [ 81 // <lir_instructions.json> 82 // ... 83 // <machine_ir_intrinsic_binding.json> 84 // ... 85 // <def> 86 // ... 87 // ], 88} 89 90genrule { 91 name: "libberberis_backend_machine_ir_gen_headers_riscv64_to_x86_64", 92 defaults: ["berberis_backend_machine_ir_gen_headers_x86_64_defaults"], 93 srcs: [":libberberis_backend_gen_inputs_riscv64_to_x86_64"], 94} 95 96genrule_defaults { 97 name: "libberberis_backend_machine_ir_gen_sources_x86_64_defaults", 98 out: [ 99 "gen_code_emit_x86_64.cc", 100 "gen_code_debug_x86_64.cc", 101 ], 102 tools: ["berberis_gen_lir"], 103 cmd: "$(location berberis_gen_lir) --sources $(out) $(in)", 104 // Targets using these defaults must provide the following guest-specific 105 // fields. lir instructions MUST end with `lir_instructions.json` and 106 // machine ir instrinsic bindngs MUST end with 107 // `machine_ir_intrinsice_binding.json`. Order matters and def's have no 108 // naming requirements: 109 // srcs: [ 110 // <lir_instructions.json> 111 // ... 112 // <machine_ir_intrinsic_binding.json> 113 // ... 114 // <def> 115 // ... 116 // ], 117} 118 119genrule { 120 name: "libberberis_backend_machine_ir_gen_sources_riscv64_to_x86_64", 121 defaults: ["libberberis_backend_machine_ir_gen_sources_x86_64_defaults"], 122 srcs: [":libberberis_backend_gen_inputs_riscv64_to_x86_64"], 123} 124 125genrule { 126 name: "libberberis_backend_reg_class_gen_headers_x86_64", 127 out: ["machine_reg_class_x86_64-inl.h"], 128 srcs: [":libberberis_backend_reg_class_gen_inputs_x86_64"], 129 tools: ["berberis_gen_reg_class"], 130 cmd: "$(location berberis_gen_reg_class) $(out) $(in)", 131} 132 133cc_library_headers { 134 name: "libberberis_backend_headers", 135 defaults: ["berberis_defaults"], 136 host_supported: true, 137 export_include_dirs: ["include"], 138 header_libs: [ 139 "libberberis_assembler_headers", 140 "libberberis_base_headers", 141 ], 142 export_header_lib_headers: [ 143 "libberberis_assembler_headers", 144 "libberberis_base_headers", 145 ], 146} 147 148cc_library_headers { 149 name: "libberberis_backend_headers_riscv64_to_x86_64", 150 defaults: ["berberis_defaults_64"], 151 host_supported: true, 152 export_include_dirs: ["riscv64_to_x86_64/include"], 153 header_libs: [ 154 "libberberis_backend_headers", 155 "libberberis_guest_state_riscv64_headers", 156 "libberberis_macro_assembler_headers_riscv64_to_x86_64", 157 ], 158 export_header_lib_headers: [ 159 "libberberis_backend_headers", 160 "libberberis_guest_state_riscv64_headers", 161 "libberberis_macro_assembler_headers_riscv64_to_x86_64", 162 ], 163 generated_headers: [ 164 "libberberis_backend_machine_ir_gen_headers_riscv64_to_x86_64", 165 "libberberis_backend_reg_class_gen_headers_x86_64", 166 ], 167 export_generated_headers: [ 168 "libberberis_backend_machine_ir_gen_headers_riscv64_to_x86_64", 169 "libberberis_backend_reg_class_gen_headers_x86_64", 170 ], 171} 172 173filegroup { 174 name: "berberis_backend_srcs", 175 srcs: [ 176 "common/lifetime_analysis.cc", 177 "common/machine_ir_debug.cc", 178 "common/machine_ir_opt.cc", 179 "common/reg_alloc.cc", 180 "x86_64/code.cc", 181 "x86_64/code_debug.cc", 182 "x86_64/code_emit.cc", 183 "x86_64/context_liveness_analyzer.cc", 184 "x86_64/insn_folding.cc", 185 "x86_64/liveness_analyzer.cc", 186 "x86_64/local_guest_context_optimizer.cc", 187 "x86_64/loop_guest_context_optimizer.cc", 188 "x86_64/machine_ir_analysis.cc", 189 "x86_64/machine_ir_check.cc", 190 "x86_64/machine_ir_opt.cc", 191 "x86_64/rename_copy_uses.cc", 192 "x86_64/rename_vregs.cc", 193 "x86_64/rename_vregs_local.cc", 194 ], 195} 196 197cc_defaults { 198 name: "berberis_backend_defaults", 199 srcs: [ 200 ":berberis_backend_srcs", 201 ], 202 header_libs: [ 203 "libberberis_base_headers", 204 "libberberis_code_gen_lib_headers", 205 "libberberis_runtime_primitives_headers", 206 ], 207} 208 209cc_library_static { 210 name: "libberberis_backend_riscv64_to_x86_64", 211 defaults: [ 212 "berberis_defaults_64", 213 "berberis_backend_defaults", 214 ], 215 host_supported: true, 216 generated_sources: [ 217 "libberberis_backend_machine_ir_gen_sources_riscv64_to_x86_64", 218 ], 219 header_libs: [ 220 "libberberis_backend_headers_riscv64_to_x86_64", 221 ], 222 srcs: [ 223 "riscv64_to_x86_64/code_gen.cc", 224 ], 225} 226 227cc_library_headers { 228 name: "libberberis_backend_testing_x86_64_headers", 229 defaults: ["berberis_defaults_64"], 230 export_include_dirs: ["testing/include"], 231 host_supported: true, 232} 233 234filegroup { 235 name: "libberberis_backend_x86_64_test_srcs", 236 srcs: [ 237 "common/machine_ir_test.cc", 238 "x86_64/context_liveness_analyzer_test.cc", 239 "x86_64/insn_folding_test.cc", 240 "x86_64/liveness_analyzer_test.cc", 241 "x86_64/local_guest_context_optimizer_test.cc", 242 "x86_64/loop_guest_context_optimizer_test.cc", 243 "x86_64/machine_ir_analysis_test.cc", 244 "x86_64/machine_ir_check_test.cc", 245 "x86_64/machine_insn_intrinsics_tests.cc", 246 "x86_64/machine_ir_exec_test.cc", 247 "x86_64/machine_ir_opt_test.cc", 248 "x86_64/machine_ir_test.cc", 249 "x86_64/machine_ir_test_corpus.cc", 250 "x86_64/rename_copy_uses_test.cc", 251 "x86_64/rename_vregs_test.cc", 252 "x86_64/rename_vregs_local_test.cc", 253 ], 254} 255 256cc_defaults { 257 name: "libberberis_backend_x86_64_test_defaults", 258 srcs: [":libberberis_backend_x86_64_test_srcs"], 259 header_libs: [ 260 "libberberis_backend_testing_x86_64_headers", 261 "libberberis_code_gen_lib_headers", 262 "libberberis_guest_state_headers", 263 "berberis_test_utils_headers", 264 ], 265 // Targets using these defaults must provide the following guest-specific fields: 266 // header_libs: [ 267 // "libberberis_backend_headers_<guest>_to_x86_64", 268 // "libberberis_guest_state_<guest>_headers", 269 // ], 270} 271 272cc_test_library { 273 name: "libberberis_backend_riscv64_to_x86_64_unit_tests", 274 defaults: [ 275 "berberis_defaults_64", 276 "libberberis_backend_x86_64_test_defaults", 277 ], 278 host_supported: true, 279 header_libs: [ 280 "libberberis_backend_headers_riscv64_to_x86_64", 281 "libberberis_guest_state_riscv64_headers", 282 ], 283 shared: { 284 enabled: false, 285 }, 286} 287