1# Copyright 2018 Google Inc. All rights reserved. 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 15import("//build_overrides/build.gni") 16import("//build_overrides/spirv_tools.gni") 17if (build_with_chromium) { 18 import("//testing/test.gni") 19} 20 21spirv_headers = spirv_tools_spirv_headers_dir 22 23template("spvtools_core_tables") { 24 assert(defined(invoker.version), "Need version in $target_name generation.") 25 26 action("spvtools_core_tables_" + target_name) { 27 script = "utils/generate_grammar_tables.py" 28 29 version = invoker.version 30 31 core_json_file = 32 "${spirv_headers}/include/spirv/$version/spirv.core.grammar.json" 33 core_insts_file = "${target_gen_dir}/core.insts-$version.inc" 34 operand_kinds_file = "${target_gen_dir}/operand.kinds-$version.inc" 35 debuginfo_insts_file = "source/extinst.debuginfo.grammar.json" 36 cldebuginfo100_insts_file = "source/extinst.opencl.debuginfo.100.grammar.json" 37 38 sources = [ 39 core_json_file, 40 debuginfo_insts_file, 41 cldebuginfo100_insts_file, 42 ] 43 outputs = [ 44 core_insts_file, 45 operand_kinds_file, 46 ] 47 args = [ 48 "--spirv-core-grammar", 49 rebase_path(core_json_file, root_build_dir), 50 "--core-insts-output", 51 rebase_path(core_insts_file, root_build_dir), 52 "--extinst-debuginfo-grammar", 53 rebase_path(debuginfo_insts_file, root_build_dir), 54 "--extinst-cldebuginfo100-grammar", 55 rebase_path(cldebuginfo100_insts_file, root_build_dir), 56 "--operand-kinds-output", 57 rebase_path(operand_kinds_file, root_build_dir), 58 ] 59 } 60} 61 62template("spvtools_core_enums") { 63 assert(defined(invoker.version), "Need version in $target_name generation.") 64 65 action("spvtools_core_enums_" + target_name) { 66 script = "utils/generate_grammar_tables.py" 67 68 version = invoker.version 69 70 core_json_file = 71 "${spirv_headers}/include/spirv/$version/spirv.core.grammar.json" 72 debuginfo_insts_file = "source/extinst.debuginfo.grammar.json" 73 cldebuginfo100_insts_file = "source/extinst.opencl.debuginfo.100.grammar.json" 74 75 extension_enum_file = "${target_gen_dir}/extension_enum.inc" 76 extension_map_file = "${target_gen_dir}/enum_string_mapping.inc" 77 78 args = [ 79 "--spirv-core-grammar", 80 rebase_path(core_json_file, root_build_dir), 81 "--extinst-debuginfo-grammar", 82 rebase_path(debuginfo_insts_file, root_build_dir), 83 "--extinst-cldebuginfo100-grammar", 84 rebase_path(cldebuginfo100_insts_file, root_build_dir), 85 "--extension-enum-output", 86 rebase_path(extension_enum_file, root_build_dir), 87 "--enum-string-mapping-output", 88 rebase_path(extension_map_file, root_build_dir), 89 ] 90 inputs = [ 91 core_json_file, 92 debuginfo_insts_file, 93 cldebuginfo100_insts_file, 94 ] 95 outputs = [ 96 extension_enum_file, 97 extension_map_file, 98 ] 99 } 100} 101 102template("spvtools_glsl_tables") { 103 assert(defined(invoker.version), "Need version in $target_name generation.") 104 105 action("spvtools_glsl_tables_" + target_name) { 106 script = "utils/generate_grammar_tables.py" 107 108 version = invoker.version 109 110 core_json_file = 111 "${spirv_headers}/include/spirv/$version/spirv.core.grammar.json" 112 glsl_json_file = "${spirv_headers}/include/spirv/${version}/extinst.glsl.std.450.grammar.json" 113 debuginfo_insts_file = "source/extinst.debuginfo.grammar.json" 114 cldebuginfo100_insts_file = "source/extinst.opencl.debuginfo.100.grammar.json" 115 116 glsl_insts_file = "${target_gen_dir}/glsl.std.450.insts.inc" 117 118 args = [ 119 "--spirv-core-grammar", 120 rebase_path(core_json_file, root_build_dir), 121 "--extinst-debuginfo-grammar", 122 rebase_path(debuginfo_insts_file, root_build_dir), 123 "--extinst-cldebuginfo100-grammar", 124 rebase_path(cldebuginfo100_insts_file, root_build_dir), 125 "--extinst-glsl-grammar", 126 rebase_path(glsl_json_file, root_build_dir), 127 "--glsl-insts-output", 128 rebase_path(glsl_insts_file, root_build_dir), 129 ] 130 inputs = [ 131 core_json_file, 132 glsl_json_file, 133 debuginfo_insts_file, 134 cldebuginfo100_insts_file, 135 ] 136 outputs = [ 137 glsl_insts_file, 138 ] 139 } 140} 141 142template("spvtools_opencl_tables") { 143 assert(defined(invoker.version), "Need version in $target_name generation.") 144 145 action("spvtools_opencl_tables_" + target_name) { 146 script = "utils/generate_grammar_tables.py" 147 148 version = invoker.version 149 150 core_json_file = 151 "${spirv_headers}/include/spirv/$version/spirv.core.grammar.json" 152 opencl_json_file = "${spirv_headers}/include/spirv/${version}/extinst.opencl.std.100.grammar.json" 153 debuginfo_insts_file = "source/extinst.debuginfo.grammar.json" 154 cldebuginfo100_insts_file = "source/extinst.opencl.debuginfo.100.grammar.json" 155 156 opencl_insts_file = "${target_gen_dir}/opencl.std.insts.inc" 157 158 args = [ 159 "--spirv-core-grammar", 160 rebase_path(core_json_file, root_build_dir), 161 "--extinst-debuginfo-grammar", 162 rebase_path(debuginfo_insts_file, root_build_dir), 163 "--extinst-cldebuginfo100-grammar", 164 rebase_path(cldebuginfo100_insts_file, root_build_dir), 165 "--extinst-opencl-grammar", 166 rebase_path(opencl_json_file, root_build_dir), 167 "--opencl-insts-output", 168 rebase_path(opencl_insts_file, root_build_dir), 169 ] 170 inputs = [ 171 core_json_file, 172 opencl_json_file, 173 debuginfo_insts_file, 174 cldebuginfo100_insts_file, 175 ] 176 outputs = [ 177 opencl_insts_file, 178 ] 179 } 180} 181 182template("spvtools_language_header") { 183 assert(defined(invoker.name), "Need name in $target_name generation.") 184 185 action("spvtools_language_header_" + target_name) { 186 script = "utils/generate_language_headers.py" 187 188 name = invoker.name 189 extinst_output_base = "${target_gen_dir}/${name}" 190 191 args = [ 192 "--extinst-name", 193 "${name}", 194 "--extinst-grammar", 195 rebase_path(invoker.grammar_file, root_build_dir), 196 "--extinst-output-base", 197 rebase_path(extinst_output_base, root_build_dir), 198 ] 199 inputs = [ 200 invoker.grammar_file, 201 ] 202 outputs = [ 203 "${extinst_output_base}.h", 204 ] 205 } 206} 207 208template("spvtools_vendor_table") { 209 assert(defined(invoker.name), "Need name in $target_name generation.") 210 211 action("spvtools_vendor_tables_" + target_name) { 212 script = "utils/generate_grammar_tables.py" 213 214 name = invoker.name 215 extinst_vendor_grammar = "source/extinst.${name}.grammar.json" 216 extinst_file = "${target_gen_dir}/${name}.insts.inc" 217 218 args = [ 219 "--extinst-vendor-grammar", 220 rebase_path(extinst_vendor_grammar, root_build_dir), 221 "--vendor-insts-output", 222 rebase_path(extinst_file, root_build_dir), 223 "--vendor-operand-kind-prefix", 224 invoker.operand_kind_prefix 225 ] 226 inputs = [ 227 extinst_vendor_grammar, 228 ] 229 outputs = [ 230 extinst_file, 231 ] 232 } 233} 234 235action("spvtools_generators_inc") { 236 script = "utils/generate_registry_tables.py" 237 238 # TODO(dsinclair): Make work for chrome 239 xml_file = "${spirv_headers}/include/spirv/spir-v.xml" 240 inc_file = "${target_gen_dir}/generators.inc" 241 242 sources = [ 243 xml_file, 244 ] 245 outputs = [ 246 inc_file, 247 ] 248 args = [ 249 "--xml", 250 rebase_path(xml_file, root_build_dir), 251 "--generator", 252 rebase_path(inc_file, root_build_dir), 253 ] 254} 255 256action("spvtools_build_version") { 257 script = "utils/update_build_version.py" 258 259 src_dir = "." 260 inc_file = "${target_gen_dir}/build-version.inc" 261 262 outputs = [ 263 inc_file, 264 ] 265 args = [ 266 rebase_path(src_dir, root_build_dir), 267 rebase_path(inc_file, root_build_dir), 268 ] 269} 270 271spvtools_core_tables("unified1") { 272 version = "unified1" 273} 274spvtools_core_enums("unified1") { 275 version = "unified1" 276} 277spvtools_glsl_tables("glsl1-0") { 278 version = "1.0" 279} 280spvtools_opencl_tables("opencl1-0") { 281 version = "1.0" 282} 283spvtools_language_header("debuginfo") { 284 name = "DebugInfo" 285 grammar_file = "source/extinst.debuginfo.grammar.json" 286} 287spvtools_language_header("cldebuginfo100") { 288 name = "OpenCLDebugInfo100" 289 grammar_file = "source/extinst.opencl.debuginfo.100.grammar.json" 290} 291 292spvtools_vendor_tables = [ 293 ["spv-amd-shader-explicit-vertex-parameter", "...nil..."], 294 ["spv-amd-shader-trinary-minmax", "...nil..."], 295 ["spv-amd-gcn-shader", "...nil..."], 296 ["spv-amd-shader-ballot", "...nil..."], 297 ["debuginfo", "...nil..."], 298 ["opencl.debuginfo.100", "CLDEBUG100_"], 299] 300 301foreach(table_def, spvtools_vendor_tables) { 302 spvtools_vendor_table(table_def[0]) { 303 name = table_def[0] 304 operand_kind_prefix = table_def[1] 305 } 306} 307 308config("spvtools_public_config") { 309 include_dirs = [ "include" ] 310} 311 312config("spvtools_internal_config") { 313 include_dirs = [ 314 ".", 315 "$target_gen_dir", 316 "${spirv_headers}/include", 317 ] 318 319 configs = [ ":spvtools_public_config" ] 320 321 if (is_clang) { 322 cflags = [ 323 "-Wno-implicit-fallthrough", 324 "-Wno-newline-eof", 325 ] 326 } 327} 328 329source_set("spvtools_headers") { 330 sources = [ 331 "include/spirv-tools/instrument.hpp", 332 "include/spirv-tools/libspirv.h", 333 "include/spirv-tools/libspirv.hpp", 334 "include/spirv-tools/linker.hpp", 335 "include/spirv-tools/optimizer.hpp", 336 ] 337 338 public_configs = [ ":spvtools_public_config" ] 339} 340 341static_library("spvtools") { 342 deps = [ 343 ":spvtools_core_tables_unified1", 344 ":spvtools_generators_inc", 345 ":spvtools_glsl_tables_glsl1-0", 346 ":spvtools_language_header_debuginfo", 347 ":spvtools_language_header_cldebuginfo100", 348 ":spvtools_opencl_tables_opencl1-0", 349 ] 350 foreach(table_def, spvtools_vendor_tables) { 351 target_name = table_def[0] 352 deps += [ ":spvtools_vendor_tables_$target_name" ] 353 } 354 355 sources = [ 356 "source/assembly_grammar.cpp", 357 "source/assembly_grammar.h", 358 "source/binary.cpp", 359 "source/binary.h", 360 "source/cfa.h", 361 "source/diagnostic.cpp", 362 "source/diagnostic.h", 363 "source/disassemble.cpp", 364 "source/disassemble.h", 365 "source/enum_set.h", 366 "source/enum_string_mapping.cpp", 367 "source/enum_string_mapping.h", 368 "source/ext_inst.cpp", 369 "source/ext_inst.h", 370 "source/extensions.cpp", 371 "source/extensions.h", 372 "source/instruction.h", 373 "source/latest_version_glsl_std_450_header.h", 374 "source/latest_version_opencl_std_header.h", 375 "source/latest_version_spirv_header.h", 376 "source/libspirv.cpp", 377 "source/macro.h", 378 "source/name_mapper.cpp", 379 "source/name_mapper.h", 380 "source/opcode.cpp", 381 "source/opcode.h", 382 "source/operand.cpp", 383 "source/operand.h", 384 "source/parsed_operand.cpp", 385 "source/parsed_operand.h", 386 "source/print.cpp", 387 "source/print.h", 388 "source/spirv_constant.h", 389 "source/spirv_definition.h", 390 "source/spirv_endian.cpp", 391 "source/spirv_endian.h", 392 "source/spirv_optimizer_options.cpp", 393 "source/spirv_optimizer_options.h", 394 "source/spirv_target_env.cpp", 395 "source/spirv_target_env.h", 396 "source/spirv_validator_options.cpp", 397 "source/spirv_validator_options.h", 398 "source/table.cpp", 399 "source/table.h", 400 "source/text.cpp", 401 "source/text.h", 402 "source/text_handler.cpp", 403 "source/text_handler.h", 404 "source/util/bit_vector.cpp", 405 "source/util/bit_vector.h", 406 "source/util/bitutils.h", 407 "source/util/hex_float.h", 408 "source/util/ilist.h", 409 "source/util/ilist_node.h", 410 "source/util/make_unique.h", 411 "source/util/parse_number.cpp", 412 "source/util/parse_number.h", 413 "source/util/small_vector.h", 414 "source/util/string_utils.cpp", 415 "source/util/string_utils.h", 416 "source/util/timer.cpp", 417 "source/util/timer.h", 418 ] 419 420 public_deps = [ 421 ":spvtools_core_enums_unified1", 422 ":spvtools_headers", 423 "${spirv_headers}:spv_headers", 424 ] 425 426 if (build_with_chromium) { 427 configs -= [ "//build/config/compiler:chromium_code" ] 428 configs += [ "//build/config/compiler:no_chromium_code" ] 429 } 430 configs += [ ":spvtools_internal_config" ] 431} 432 433static_library("spvtools_val") { 434 sources = [ 435 "source/val/basic_block.cpp", 436 "source/val/basic_block.h", 437 "source/val/construct.cpp", 438 "source/val/construct.h", 439 "source/val/decoration.h", 440 "source/val/function.cpp", 441 "source/val/function.h", 442 "source/val/instruction.cpp", 443 "source/val/validate.cpp", 444 "source/val/validate.h", 445 "source/val/validate_adjacency.cpp", 446 "source/val/validate_annotation.cpp", 447 "source/val/validate_arithmetics.cpp", 448 "source/val/validate_atomics.cpp", 449 "source/val/validate_barriers.cpp", 450 "source/val/validate_bitwise.cpp", 451 "source/val/validate_builtins.cpp", 452 "source/val/validate_capability.cpp", 453 "source/val/validate_cfg.cpp", 454 "source/val/validate_composites.cpp", 455 "source/val/validate_constants.cpp", 456 "source/val/validate_conversion.cpp", 457 "source/val/validate_debug.cpp", 458 "source/val/validate_decorations.cpp", 459 "source/val/validate_derivatives.cpp", 460 "source/val/validate_execution_limitations.cpp", 461 "source/val/validate_extensions.cpp", 462 "source/val/validate_function.cpp", 463 "source/val/validate_id.cpp", 464 "source/val/validate_image.cpp", 465 "source/val/validate_instruction.cpp", 466 "source/val/validate_interfaces.cpp", 467 "source/val/validate_layout.cpp", 468 "source/val/validate_literals.cpp", 469 "source/val/validate_logicals.cpp", 470 "source/val/validate_memory.cpp", 471 "source/val/validate_memory_semantics.cpp", 472 "source/val/validate_memory_semantics.h", 473 "source/val/validate_misc.cpp", 474 "source/val/validate_mode_setting.cpp", 475 "source/val/validate_non_uniform.cpp", 476 "source/val/validate_primitives.cpp", 477 "source/val/validate_scopes.cpp", 478 "source/val/validate_scopes.h", 479 "source/val/validate_small_type_uses.cpp", 480 "source/val/validate_type.cpp", 481 "source/val/validation_state.cpp", 482 "source/val/validation_state.h", 483 ] 484 485 deps = [ 486 ":spvtools", 487 ":spvtools_language_header_cldebuginfo100", 488 ":spvtools_language_header_debuginfo", 489 ] 490 public_deps = [ 491 ":spvtools_headers", 492 ] 493 494 if (build_with_chromium) { 495 configs -= [ "//build/config/compiler:chromium_code" ] 496 configs += [ "//build/config/compiler:no_chromium_code" ] 497 } 498 configs += [ ":spvtools_internal_config" ] 499} 500 501static_library("spvtools_opt") { 502 sources = [ 503 "source/opt/aggressive_dead_code_elim_pass.cpp", 504 "source/opt/aggressive_dead_code_elim_pass.h", 505 "source/opt/amd_ext_to_khr.cpp", 506 "source/opt/amd_ext_to_khr.h", 507 "source/opt/basic_block.cpp", 508 "source/opt/basic_block.h", 509 "source/opt/block_merge_pass.cpp", 510 "source/opt/block_merge_pass.h", 511 "source/opt/block_merge_util.cpp", 512 "source/opt/block_merge_util.h", 513 "source/opt/build_module.cpp", 514 "source/opt/build_module.h", 515 "source/opt/ccp_pass.cpp", 516 "source/opt/ccp_pass.h", 517 "source/opt/cfg.cpp", 518 "source/opt/cfg.h", 519 "source/opt/cfg_cleanup_pass.cpp", 520 "source/opt/cfg_cleanup_pass.h", 521 "source/opt/code_sink.cpp", 522 "source/opt/code_sink.h", 523 "source/opt/combine_access_chains.cpp", 524 "source/opt/combine_access_chains.h", 525 "source/opt/compact_ids_pass.cpp", 526 "source/opt/compact_ids_pass.h", 527 "source/opt/composite.cpp", 528 "source/opt/composite.h", 529 "source/opt/const_folding_rules.cpp", 530 "source/opt/const_folding_rules.h", 531 "source/opt/constants.cpp", 532 "source/opt/constants.h", 533 "source/opt/convert_to_half_pass.cpp", 534 "source/opt/convert_to_half_pass.h", 535 "source/opt/copy_prop_arrays.cpp", 536 "source/opt/copy_prop_arrays.h", 537 "source/opt/dead_branch_elim_pass.cpp", 538 "source/opt/dead_branch_elim_pass.h", 539 "source/opt/dead_insert_elim_pass.cpp", 540 "source/opt/dead_insert_elim_pass.h", 541 "source/opt/dead_variable_elimination.cpp", 542 "source/opt/dead_variable_elimination.h", 543 "source/opt/decompose_initialized_variables_pass.cpp", 544 "source/opt/decompose_initialized_variables_pass.h", 545 "source/opt/decoration_manager.cpp", 546 "source/opt/decoration_manager.h", 547 "source/opt/def_use_manager.cpp", 548 "source/opt/def_use_manager.h", 549 "source/opt/desc_sroa.cpp", 550 "source/opt/desc_sroa.h", 551 "source/opt/dominator_analysis.cpp", 552 "source/opt/dominator_analysis.h", 553 "source/opt/dominator_tree.cpp", 554 "source/opt/dominator_tree.h", 555 "source/opt/eliminate_dead_constant_pass.cpp", 556 "source/opt/eliminate_dead_constant_pass.h", 557 "source/opt/eliminate_dead_functions_pass.cpp", 558 "source/opt/eliminate_dead_functions_pass.h", 559 "source/opt/eliminate_dead_functions_util.cpp", 560 "source/opt/eliminate_dead_functions_util.h", 561 "source/opt/eliminate_dead_members_pass.cpp", 562 "source/opt/eliminate_dead_members_pass.h", 563 "source/opt/feature_manager.cpp", 564 "source/opt/feature_manager.h", 565 "source/opt/fix_storage_class.cpp", 566 "source/opt/fix_storage_class.h", 567 "source/opt/flatten_decoration_pass.cpp", 568 "source/opt/flatten_decoration_pass.h", 569 "source/opt/fold.cpp", 570 "source/opt/fold.h", 571 "source/opt/fold_spec_constant_op_and_composite_pass.cpp", 572 "source/opt/fold_spec_constant_op_and_composite_pass.h", 573 "source/opt/folding_rules.cpp", 574 "source/opt/folding_rules.h", 575 "source/opt/freeze_spec_constant_value_pass.cpp", 576 "source/opt/freeze_spec_constant_value_pass.h", 577 "source/opt/function.cpp", 578 "source/opt/function.h", 579 "source/opt/generate_webgpu_initializers_pass.cpp", 580 "source/opt/generate_webgpu_initializers_pass.h", 581 "source/opt/graphics_robust_access_pass.cpp", 582 "source/opt/graphics_robust_access_pass.h", 583 "source/opt/if_conversion.cpp", 584 "source/opt/if_conversion.h", 585 "source/opt/inline_exhaustive_pass.cpp", 586 "source/opt/inline_exhaustive_pass.h", 587 "source/opt/inline_opaque_pass.cpp", 588 "source/opt/inline_opaque_pass.h", 589 "source/opt/inline_pass.cpp", 590 "source/opt/inline_pass.h", 591 "source/opt/inst_bindless_check_pass.cpp", 592 "source/opt/inst_bindless_check_pass.h", 593 "source/opt/inst_buff_addr_check_pass.cpp", 594 "source/opt/inst_buff_addr_check_pass.h", 595 "source/opt/instruction.cpp", 596 "source/opt/instruction.h", 597 "source/opt/instruction_list.cpp", 598 "source/opt/instruction_list.h", 599 "source/opt/instrument_pass.cpp", 600 "source/opt/instrument_pass.h", 601 "source/opt/ir_builder.h", 602 "source/opt/ir_context.cpp", 603 "source/opt/ir_context.h", 604 "source/opt/ir_loader.cpp", 605 "source/opt/ir_loader.h", 606 "source/opt/iterator.h", 607 "source/opt/legalize_vector_shuffle_pass.cpp", 608 "source/opt/legalize_vector_shuffle_pass.h", 609 "source/opt/licm_pass.cpp", 610 "source/opt/licm_pass.h", 611 "source/opt/local_access_chain_convert_pass.cpp", 612 "source/opt/local_access_chain_convert_pass.h", 613 "source/opt/local_redundancy_elimination.cpp", 614 "source/opt/local_redundancy_elimination.h", 615 "source/opt/local_single_block_elim_pass.cpp", 616 "source/opt/local_single_block_elim_pass.h", 617 "source/opt/local_single_store_elim_pass.cpp", 618 "source/opt/local_single_store_elim_pass.h", 619 "source/opt/log.h", 620 "source/opt/loop_dependence.cpp", 621 "source/opt/loop_dependence.h", 622 "source/opt/loop_dependence_helpers.cpp", 623 "source/opt/loop_descriptor.cpp", 624 "source/opt/loop_descriptor.h", 625 "source/opt/loop_fission.cpp", 626 "source/opt/loop_fission.h", 627 "source/opt/loop_fusion.cpp", 628 "source/opt/loop_fusion.h", 629 "source/opt/loop_fusion_pass.cpp", 630 "source/opt/loop_fusion_pass.h", 631 "source/opt/loop_peeling.cpp", 632 "source/opt/loop_peeling.h", 633 "source/opt/loop_unroller.cpp", 634 "source/opt/loop_unroller.h", 635 "source/opt/loop_unswitch_pass.cpp", 636 "source/opt/loop_unswitch_pass.h", 637 "source/opt/loop_utils.cpp", 638 "source/opt/loop_utils.h", 639 "source/opt/mem_pass.cpp", 640 "source/opt/mem_pass.h", 641 "source/opt/merge_return_pass.cpp", 642 "source/opt/merge_return_pass.h", 643 "source/opt/module.cpp", 644 "source/opt/module.h", 645 "source/opt/null_pass.h", 646 "source/opt/optimizer.cpp", 647 "source/opt/pass.cpp", 648 "source/opt/pass.h", 649 "source/opt/pass_manager.cpp", 650 "source/opt/pass_manager.h", 651 "source/opt/passes.h", 652 "source/opt/private_to_local_pass.cpp", 653 "source/opt/private_to_local_pass.h", 654 "source/opt/process_lines_pass.cpp", 655 "source/opt/process_lines_pass.h", 656 "source/opt/propagator.cpp", 657 "source/opt/propagator.h", 658 "source/opt/reduce_load_size.cpp", 659 "source/opt/reduce_load_size.h", 660 "source/opt/redundancy_elimination.cpp", 661 "source/opt/redundancy_elimination.h", 662 "source/opt/reflect.h", 663 "source/opt/register_pressure.cpp", 664 "source/opt/register_pressure.h", 665 "source/opt/relax_float_ops_pass.cpp", 666 "source/opt/relax_float_ops_pass.h", 667 "source/opt/remove_duplicates_pass.cpp", 668 "source/opt/remove_duplicates_pass.h", 669 "source/opt/replace_invalid_opc.cpp", 670 "source/opt/replace_invalid_opc.h", 671 "source/opt/scalar_analysis.cpp", 672 "source/opt/scalar_analysis.h", 673 "source/opt/scalar_analysis_nodes.h", 674 "source/opt/scalar_analysis_simplification.cpp", 675 "source/opt/scalar_replacement_pass.cpp", 676 "source/opt/scalar_replacement_pass.h", 677 "source/opt/set_spec_constant_default_value_pass.cpp", 678 "source/opt/set_spec_constant_default_value_pass.h", 679 "source/opt/simplification_pass.cpp", 680 "source/opt/simplification_pass.h", 681 "source/opt/split_invalid_unreachable_pass.cpp", 682 "source/opt/split_invalid_unreachable_pass.h", 683 "source/opt/ssa_rewrite_pass.cpp", 684 "source/opt/ssa_rewrite_pass.h", 685 "source/opt/strength_reduction_pass.cpp", 686 "source/opt/strength_reduction_pass.h", 687 "source/opt/strip_atomic_counter_memory_pass.cpp", 688 "source/opt/strip_atomic_counter_memory_pass.h", 689 "source/opt/strip_debug_info_pass.cpp", 690 "source/opt/strip_debug_info_pass.h", 691 "source/opt/strip_reflect_info_pass.cpp", 692 "source/opt/strip_reflect_info_pass.h", 693 "source/opt/struct_cfg_analysis.cpp", 694 "source/opt/struct_cfg_analysis.h", 695 "source/opt/tree_iterator.h", 696 "source/opt/type_manager.cpp", 697 "source/opt/type_manager.h", 698 "source/opt/types.cpp", 699 "source/opt/types.h", 700 "source/opt/unify_const_pass.cpp", 701 "source/opt/unify_const_pass.h", 702 "source/opt/upgrade_memory_model.cpp", 703 "source/opt/upgrade_memory_model.h", 704 "source/opt/value_number_table.cpp", 705 "source/opt/value_number_table.h", 706 "source/opt/vector_dce.cpp", 707 "source/opt/vector_dce.h", 708 "source/opt/workaround1209.cpp", 709 "source/opt/workaround1209.h", 710 "source/opt/wrap_opkill.cpp", 711 "source/opt/wrap_opkill.h", 712 ] 713 714 deps = [ 715 ":spvtools", 716 ":spvtools_language_header_cldebuginfo100", 717 ":spvtools_language_header_debuginfo", 718 ":spvtools_vendor_tables_spv-amd-shader-ballot", 719 ] 720 public_deps = [ 721 ":spvtools_headers", 722 ] 723 724 if (build_with_chromium) { 725 configs -= [ "//build/config/compiler:chromium_code" ] 726 configs += [ "//build/config/compiler:no_chromium_code" ] 727 } 728 configs += [ ":spvtools_internal_config" ] 729} 730 731static_library("spvtools_link") { 732 sources = [ 733 "source/link/linker.cpp", 734 ] 735 deps = [ 736 ":spvtools", 737 ":spvtools_opt", 738 ":spvtools_val", 739 ] 740 public_deps = [ 741 ":spvtools_headers", 742 ] 743 if (build_with_chromium) { 744 configs -= [ "//build/config/compiler:chromium_code" ] 745 configs += [ "//build/config/compiler:no_chromium_code" ] 746 } 747 configs += [ ":spvtools_internal_config" ] 748} 749 750static_library("spvtools_reduce") { 751 sources = [ 752 "source/reduce/change_operand_reduction_opportunity.cpp", 753 "source/reduce/change_operand_reduction_opportunity.h", 754 "source/reduce/change_operand_to_undef_reduction_opportunity.cpp", 755 "source/reduce/change_operand_to_undef_reduction_opportunity.h", 756 "source/reduce/conditional_branch_to_simple_conditional_branch_opportunity_finder.cpp", 757 "source/reduce/conditional_branch_to_simple_conditional_branch_opportunity_finder.h", 758 "source/reduce/conditional_branch_to_simple_conditional_branch_reduction_opportunity.cpp", 759 "source/reduce/conditional_branch_to_simple_conditional_branch_reduction_opportunity.h", 760 "source/reduce/merge_blocks_reduction_opportunity.cpp", 761 "source/reduce/merge_blocks_reduction_opportunity.h", 762 "source/reduce/merge_blocks_reduction_opportunity_finder.cpp", 763 "source/reduce/merge_blocks_reduction_opportunity_finder.h", 764 "source/reduce/operand_to_const_reduction_opportunity_finder.cpp", 765 "source/reduce/operand_to_const_reduction_opportunity_finder.h", 766 "source/reduce/operand_to_dominating_id_reduction_opportunity_finder.cpp", 767 "source/reduce/operand_to_dominating_id_reduction_opportunity_finder.h", 768 "source/reduce/operand_to_undef_reduction_opportunity_finder.cpp", 769 "source/reduce/operand_to_undef_reduction_opportunity_finder.h", 770 "source/reduce/reducer.cpp", 771 "source/reduce/reducer.h", 772 "source/reduce/reduction_opportunity.cpp", 773 "source/reduce/reduction_opportunity.h", 774 "source/reduce/reduction_opportunity_finder.h", 775 "source/reduce/reduction_pass.cpp", 776 "source/reduce/reduction_pass.h", 777 "source/reduce/reduction_util.cpp", 778 "source/reduce/reduction_util.h", 779 "source/reduce/remove_block_reduction_opportunity.cpp", 780 "source/reduce/remove_block_reduction_opportunity.h", 781 "source/reduce/remove_block_reduction_opportunity_finder.cpp", 782 "source/reduce/remove_block_reduction_opportunity_finder.h", 783 "source/reduce/remove_function_reduction_opportunity.cpp", 784 "source/reduce/remove_function_reduction_opportunity.h", 785 "source/reduce/remove_function_reduction_opportunity_finder.cpp", 786 "source/reduce/remove_function_reduction_opportunity_finder.h", 787 "source/reduce/remove_instruction_reduction_opportunity.cpp", 788 "source/reduce/remove_instruction_reduction_opportunity.h", 789 "source/reduce/remove_selection_reduction_opportunity.cpp", 790 "source/reduce/remove_selection_reduction_opportunity.h", 791 "source/reduce/remove_selection_reduction_opportunity_finder.cpp", 792 "source/reduce/remove_selection_reduction_opportunity_finder.h", 793 "source/reduce/remove_unreferenced_instruction_reduction_opportunity_finder.cpp", 794 "source/reduce/remove_unreferenced_instruction_reduction_opportunity_finder.h", 795 "source/reduce/simple_conditional_branch_to_branch_opportunity_finder.cpp", 796 "source/reduce/simple_conditional_branch_to_branch_opportunity_finder.h", 797 "source/reduce/simple_conditional_branch_to_branch_reduction_opportunity.cpp", 798 "source/reduce/simple_conditional_branch_to_branch_reduction_opportunity.h", 799 "source/reduce/structured_loop_to_selection_reduction_opportunity.cpp", 800 "source/reduce/structured_loop_to_selection_reduction_opportunity.h", 801 "source/reduce/structured_loop_to_selection_reduction_opportunity_finder.cpp", 802 "source/reduce/structured_loop_to_selection_reduction_opportunity_finder.h", 803 "source/spirv_reducer_options.cpp", 804 "source/spirv_reducer_options.h", 805 ] 806 deps = [ 807 ":spvtools", 808 ":spvtools_opt", 809 ] 810 public_deps = [ 811 ":spvtools_headers", 812 ] 813 if (build_with_chromium) { 814 configs -= [ "//build/config/compiler:chromium_code" ] 815 configs += [ "//build/config/compiler:no_chromium_code" ] 816 } 817 configs += [ ":spvtools_internal_config" ] 818} 819 820group("SPIRV-Tools") { 821 public_deps = [ 822 ":spvtools", 823 ":spvtools_link", 824 ":spvtools_opt", 825 ":spvtools_reduce", 826 ":spvtools_val", 827 ] 828} 829 830# The tests are scoped to Chromium to avoid needing to write gtest integration. 831# See Chromium's third_party/googletest/BUILD.gn for a complete integration. 832if (build_with_chromium) { 833 test("spvtools_test") { 834 sources = [ 835 "test/assembly_context_test.cpp", 836 "test/assembly_format_test.cpp", 837 "test/binary_destroy_test.cpp", 838 "test/binary_endianness_test.cpp", 839 "test/binary_header_get_test.cpp", 840 "test/binary_parse_test.cpp", 841 "test/binary_strnlen_s_test.cpp", 842 "test/binary_to_text.literal_test.cpp", 843 "test/binary_to_text_test.cpp", 844 "test/comment_test.cpp", 845 "test/enum_set_test.cpp", 846 "test/enum_string_mapping_test.cpp", 847 "test/ext_inst.debuginfo_test.cpp", 848 "test/ext_inst.glsl_test.cpp", 849 "test/ext_inst.opencl_test.cpp", 850 "test/ext_inst.cldebug100_test.cpp", 851 "test/fix_word_test.cpp", 852 "test/generator_magic_number_test.cpp", 853 "test/hex_float_test.cpp", 854 "test/immediate_int_test.cpp", 855 "test/libspirv_macros_test.cpp", 856 "test/name_mapper_test.cpp", 857 "test/named_id_test.cpp", 858 "test/opcode_make_test.cpp", 859 "test/opcode_require_capabilities_test.cpp", 860 "test/opcode_split_test.cpp", 861 "test/opcode_table_get_test.cpp", 862 "test/operand_capabilities_test.cpp", 863 "test/operand_pattern_test.cpp", 864 "test/operand_test.cpp", 865 "test/target_env_test.cpp", 866 "test/test_fixture.h", 867 "test/text_advance_test.cpp", 868 "test/text_destroy_test.cpp", 869 "test/text_literal_test.cpp", 870 "test/text_start_new_inst_test.cpp", 871 "test/text_to_binary.annotation_test.cpp", 872 "test/text_to_binary.barrier_test.cpp", 873 "test/text_to_binary.constant_test.cpp", 874 "test/text_to_binary.control_flow_test.cpp", 875 "test/text_to_binary.debug_test.cpp", 876 "test/text_to_binary.device_side_enqueue_test.cpp", 877 "test/text_to_binary.extension_test.cpp", 878 "test/text_to_binary.function_test.cpp", 879 "test/text_to_binary.group_test.cpp", 880 "test/text_to_binary.image_test.cpp", 881 "test/text_to_binary.literal_test.cpp", 882 "test/text_to_binary.memory_test.cpp", 883 "test/text_to_binary.misc_test.cpp", 884 "test/text_to_binary.mode_setting_test.cpp", 885 "test/text_to_binary.pipe_storage_test.cpp", 886 "test/text_to_binary.reserved_sampling_test.cpp", 887 "test/text_to_binary.subgroup_dispatch_test.cpp", 888 "test/text_to_binary.type_declaration_test.cpp", 889 "test/text_to_binary_test.cpp", 890 "test/text_word_get_test.cpp", 891 "test/unit_spirv.cpp", 892 "test/unit_spirv.h", 893 ] 894 895 deps = [ 896 ":spvtools", 897 ":spvtools_language_header_debuginfo", 898 ":spvtools_language_header_cldebuginfo100", 899 ":spvtools_val", 900 "//testing/gmock", 901 "//testing/gtest", 902 "//testing/gtest:gtest_main", 903 "//third_party/googletest:gmock", 904 "//third_party/googletest:gtest", 905 ] 906 907 if (is_clang) { 908 cflags_cc = [ "-Wno-self-assign" ] 909 } 910 911 configs += [ ":spvtools_internal_config" ] 912 } 913} 914 915if (spirv_tools_standalone) { 916 group("fuzzers") { 917 testonly = true 918 deps = [ 919 "test/fuzzers", 920 ] 921 } 922} 923 924source_set("spvtools_util_cli_consumer") { 925 sources = [ 926 "tools/util/cli_consumer.cpp", 927 "tools/util/cli_consumer.h", 928 ] 929 deps = [ 930 ":spvtools_headers", 931 ] 932 configs += [ ":spvtools_internal_config" ] 933} 934 935source_set("spvtools_software_version") { 936 sources = [ 937 "source/software_version.cpp", 938 ] 939 deps = [ 940 ":spvtools_build_version", 941 ":spvtools_headers", 942 ] 943 configs += [ ":spvtools_internal_config" ] 944} 945 946executable("spirv-as") { 947 sources = [ 948 "tools/as/as.cpp", 949 ] 950 deps = [ 951 ":spvtools", 952 ":spvtools_software_version", 953 ] 954 configs += [ ":spvtools_internal_config" ] 955} 956 957executable("spirv-dis") { 958 sources = [ 959 "tools/dis/dis.cpp", 960 ] 961 deps = [ 962 ":spvtools", 963 ":spvtools_software_version", 964 ] 965 configs += [ ":spvtools_internal_config" ] 966} 967 968executable("spirv-val") { 969 sources = [ 970 "tools/val/val.cpp", 971 ] 972 deps = [ 973 ":spvtools", 974 ":spvtools_software_version", 975 ":spvtools_util_cli_consumer", 976 ":spvtools_val", 977 ] 978 configs += [ ":spvtools_internal_config" ] 979} 980 981executable("spirv-cfg") { 982 sources = [ 983 "tools/cfg/bin_to_dot.cpp", 984 "tools/cfg/bin_to_dot.h", 985 "tools/cfg/cfg.cpp", 986 ] 987 deps = [ 988 ":spvtools", 989 ":spvtools_software_version", 990 ] 991 configs += [ ":spvtools_internal_config" ] 992} 993 994executable("spirv-opt") { 995 sources = [ 996 "tools/opt/opt.cpp", 997 ] 998 deps = [ 999 ":spvtools", 1000 ":spvtools_opt", 1001 ":spvtools_software_version", 1002 ":spvtools_util_cli_consumer", 1003 ":spvtools_val", 1004 ] 1005 configs += [ ":spvtools_internal_config" ] 1006} 1007 1008executable("spirv-link") { 1009 sources = [ 1010 "tools/link/linker.cpp", 1011 ] 1012 deps = [ 1013 ":spvtools", 1014 ":spvtools_link", 1015 ":spvtools_opt", 1016 ":spvtools_software_version", 1017 ":spvtools_val", 1018 ] 1019 configs += [ ":spvtools_internal_config" ] 1020} 1021 1022if (!is_ios) { 1023 # iOS does not allow std::system calls which spirv-reduce requires 1024 executable("spirv-reduce") { 1025 sources = [ 1026 "tools/reduce/reduce.cpp", 1027 ] 1028 deps = [ 1029 ":spvtools", 1030 ":spvtools_opt", 1031 ":spvtools_reduce", 1032 ":spvtools_software_version", 1033 ":spvtools_util_cli_consumer", 1034 ":spvtools_val", 1035 ] 1036 configs += [ ":spvtools_internal_config" ] 1037 } 1038} 1039 1040group("all_spirv_tools") { 1041 deps = [ 1042 ":spirv-as", 1043 ":spirv-cfg", 1044 ":spirv-dis", 1045 ":spirv-link", 1046 ":spirv-opt", 1047 ":spirv-val", 1048 ] 1049 if (!is_ios) { 1050 deps += [ ":spirv-reduce" ] 1051 } 1052} 1053