[AMDGPU] Make v8i16/v8f16 legal
[llvm-project.git] / utils / bazel / llvm-project-overlay / llvm / BUILD.bazel
blob85d79a29b571078ff3f7cee6f1e891d6224fd482
1 # This file is licensed under the Apache License v2.0 with LLVM Exceptions.
2 # See https://llvm.org/LICENSE.txt for license information.
3 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5 load(":template_rule.bzl", "template_rule")
6 load(":tblgen.bzl", "gentbl")
7 load(":config.bzl", "llvm_config_defines")
8 load(":targets.bzl", "llvm_targets")
9 load(":enum_targets_gen.bzl", "enum_targets_gen")
10 load(":binary_alias.bzl", "binary_alias")
12 package(
13     default_visibility = ["//visibility:public"],
14     licenses = ["notice"],
17 exports_files(["LICENSE.TXT"])
19 # It may be tempting to add compiler flags here, but that should be avoided.
20 # The necessary warnings and other compile flags should be provided by the
21 # toolchain or the `.bazelrc` file. This is just a workaround until we have a
22 # widely available feature to enable unlimited stack frame instead of using
23 # this `Make` variable.
24 llvm_copts = [
25     "$(STACK_FRAME_UNLIMITED)",
28 enum_targets_gen(
29     name = "targets_def_gen",
30     src = "include/llvm/Config/Targets.def.in",
31     out = "include/llvm/Config/Targets.def",
32     macro_name = "TARGET",
33     targets = llvm_targets,
36 # Enabled targets with ASM printers.
37 llvm_target_asm_printers = [
38     t
39     for t in llvm_targets
40     if glob(["lib/Target/{}/*AsmPrinter.cpp".format(t)])
43 enum_targets_gen(
44     name = "asm_printers_def_gen",
45     src = "include/llvm/Config/AsmPrinters.def.in",
46     out = "include/llvm/Config/AsmPrinters.def",
47     macro_name = "ASM_PRINTER",
48     targets = llvm_target_asm_printers,
51 # Enabled targets with ASM parsers.
52 llvm_target_asm_parsers = [
53     t
54     for t in llvm_targets
55     if glob(["lib/Target/{}/AsmParser/CMakeLists.txt".format(t)])
58 enum_targets_gen(
59     name = "asm_parsers_def_gen",
60     src = "include/llvm/Config/AsmParsers.def.in",
61     out = "include/llvm/Config/AsmParsers.def",
62     macro_name = "ASM_PARSER",
63     targets = llvm_target_asm_parsers,
66 # Enabled targets with disassemblers.
67 llvm_target_disassemblers = [
68     t
69     for t in llvm_targets
70     if glob(["lib/Target/{}/Disassembler/CMakeLists.txt".format(t)])
73 enum_targets_gen(
74     name = "disassemblers_def_gen",
75     src = "include/llvm/Config/Disassemblers.def.in",
76     out = "include/llvm/Config/Disassemblers.def",
77     macro_name = "DISASSEMBLER",
78     targets = llvm_target_disassemblers,
81 # Enabled targets with MCA.
82 llvm_target_mcas = [
83     t
84     for t in llvm_targets
85     if glob(["lib/Target/{}/MCA/CMakeLists.txt".format(t)])
88 enum_targets_gen(
89     name = "target_mca_def_gen",
90     src = "include/llvm/Config/TargetMCAs.def.in",
91     out = "include/llvm/Config/TargetMCAs.def",
92     macro_name = "TARGETMCA",
93     targets = llvm_target_mcas,
96 # TODO: Need to replace this with something that actually extracts the git
97 # commit from the LLVM source (submodule or http_archive).
98 genrule(
99     name = "version_info_gen",
100     outs = ["include/llvm/Config/VersionInfo.h"],
101     cmd = "echo '#define LLVM_VERSION_INFO \"git\"' > $@",
104 template_rule(
105     name = "abi_breaking_h_gen",
106     src = "include/llvm/Config/abi-breaking.h.cmake",
107     out = "include/llvm/Config/abi-breaking.h",
108     substitutions = {
109         # Define to enable checks that alter the LLVM C++ ABI
110         "#cmakedefine01 LLVM_ENABLE_ABI_BREAKING_CHECKS": "#define LLVM_ENABLE_ABI_BREAKING_CHECKS 0",
112         # Define to enable reverse iteration of unordered llvm containers
113         "#cmakedefine01 LLVM_ENABLE_REVERSE_ITERATION": "#define LLVM_ENABLE_REVERSE_ITERATION 0",
114     },
117 # To enable diff testing out of tree
118 exports_files([
119     "include/llvm/Config/config.h.cmake",
120     "include/llvm/Config/llvm-config.h.cmake",
121     "include/llvm/Config/abi-breaking.h.cmake",
124 cc_library(
125     name = "config",
126     hdrs = [
127         "include/llvm/Config/VersionInfo.h",
128         "include/llvm/Config/abi-breaking.h",
129         "include/llvm/Config/llvm-config.h",
130     ],
131     copts = llvm_copts,
132     defines = llvm_config_defines,
133     includes = ["include"],
134     textual_hdrs = [
135         "include/llvm/Config/AsmParsers.def",
136         "include/llvm/Config/AsmPrinters.def",
137         "include/llvm/Config/Disassemblers.def",
138         "include/llvm/Config/Targets.def",
139         "include/llvm/Config/TargetMCAs.def",
140         # Needed for include scanner to find execinfo.h
141         "include/llvm/Config/config.h",
142     ],
145 cc_library(
146     name = "Demangle",
147     srcs = glob([
148         "lib/Demangle/*.cpp",
149         "lib/Demangle/*.h",
150     ]),
151     hdrs = glob(["include/llvm/Demangle/*.h"]),
152     copts = llvm_copts,
153     deps = [":config"],
156 genrule(
157     name = "generate_vcs_revision",
158     outs = ["include/llvm/Support/VCSRevision.h"],
159     cmd = "echo '#define LLVM_REVISION \"git\"' >> $@\n" +
160           "echo '#undef LLVM_REPOSITORY' >> $@\n",
163 genrule(
164     name = "generate_static_extension_registry",
165     outs = ["include/llvm/Support/Extension.def"],
166     cmd = "echo -e '// extension handlers' >> $@\n" +
167           "echo -e '#undef HANDLE_EXTENSION' >> $@\n",
170 cc_library(
171     name = "Support",
172     srcs = glob([
173         "lib/Support/*.c",
174         "lib/Support/*.cpp",
175         "lib/Support/*.h",
176         "lib/Support/*.inc",
177         # To avoid a dependency cycle.
178         "include/llvm/Option/*.h",
179     ]) + select({
180         "@bazel_tools//src/conditions:windows": glob([
181             "lib/Support/Windows/*.h",
182             "lib/Support/Windows/*.inc",
183         ]),
184         "//conditions:default": glob([
185             "lib/Support/Unix/*.h",
186             "lib/Support/Unix/*.inc",
187         ]),
188     }),
189     hdrs = glob([
190         "include/llvm/Support/**/*.h",
191         "include/llvm/ADT/*.h",
192     ]) + [
193         "include/llvm-c/Core.h",
194         "include/llvm-c/DataTypes.h",
195         "include/llvm-c/Deprecated.h",
196         "include/llvm-c/DisassemblerTypes.h",
197         "include/llvm-c/Error.h",
198         "include/llvm-c/ErrorHandling.h",
199         "include/llvm-c/ExternC.h",
200         "include/llvm-c/Support.h",
201         "include/llvm-c/Types.h",
202         "include/llvm/ExecutionEngine/JITSymbol.h",
203         "include/llvm/Support/Extension.def",
204         "include/llvm/Support/VCSRevision.h",
205     ],
206     copts = llvm_copts,
207     includes = ["include"],
208     linkopts = select({
209         "@bazel_tools//src/conditions:windows": [],
210         "@bazel_tools//src/conditions:freebsd": [
211             "-pthread",
212             "-lexecinfo",
213             "-ldl",
214             "-lm",
215         ],
216         "//conditions:default": [
217             "-pthread",
218             "-ldl",
219             "-lm",
220         ],
221     }),
222     textual_hdrs = glob([
223         "include/llvm/Support/*.def",
224     ]),
225     deps = [
226         ":config",
227         ":Demangle",
228         # We unconditionally depend on the custom LLVM terminfo wrapper. This
229         # will be an empty library unless terminfo is enabled, in which case it
230         # will both provide the necessary dependencies and configuration
231         # defines.
232         "@llvm_terminfo//:terminfo",
233         # We unconditionally depend on the custom LLVM zlib wrapper. This will
234         # be an empty library unless zlib is enabled, in which case it will
235         # both provide the necessary dependencies and configuration defines.
236         "@llvm_zlib//:zlib",
237     ],
240 # Note: although FileCheck (the binary) is a test utility, some non-test
241 # targets depend on the FileCheck library target.
242 cc_library(
243     name = "FileCheckLib",
244     srcs = glob([
245         "lib/FileCheck/*.cpp",
246         "lib/FileCheck/*.h",
247     ]),
248     hdrs = glob(["include/llvm/FileCheck/*.h"]),
249     copts = llvm_copts,
250     deps = [":Support"],
253 cc_library(
254     name = "LineEditor",
255     srcs = glob([
256         "lib/LineEditor/*.cpp",
257         "lib/LineEditor/*.h",
258     ]),
259     hdrs = glob(["include/llvm/LineEditor/*.h"]),
260     copts = llvm_copts,
261     deps = [
262         ":Support",
263         ":config",
264     ],
267 cc_library(
268     name = "Option",
269     srcs = glob([
270         "lib/Option/*.cpp",
271         "lib/Option/*.h",
272     ]),
273     hdrs = glob(["include/llvm/Option/*.h"]),
274     copts = llvm_copts,
275     deps = [
276         ":Support",
277         ":config",
278     ],
281 cc_library(
282     name = "TableGen",
283     srcs = glob([
284         "lib/TableGen/*.cpp",
285         "lib/TableGen/*.h",
286     ]),
287     hdrs = glob(["include/llvm/TableGen/*.h"]),
288     copts = llvm_copts,
289     deps = [
290         ":Support",
291         ":config",
292     ],
295 # This exists to avoid circular dependencies.
296 cc_library(
297     name = "ir_headers",
298     hdrs = glob(
299         [
300             "include/llvm/*.h",
301             "include/llvm/IR/*.h",
302         ],
303         exclude = [
304             "include/llvm/LinkAllPasses.h",
305         ],
306     ) + [
307         "include/llvm/IR/Value.def",
308         "include/llvm-c/Comdat.h",
309         "include/llvm-c/DebugInfo.h",
310     ],
311     copts = llvm_copts,
314 cc_library(
315     name = "BinaryFormat",
316     srcs = glob([
317         "lib/BinaryFormat/*.cpp",
318         "lib/BinaryFormat/*.def",
319         "lib/BinaryFormat/*.h",
320     ]),
321     hdrs = glob([
322         "include/llvm/BinaryFormat/*.h",
323     ]),
324     copts = llvm_copts,
325     includes = ["include"],
326     textual_hdrs = glob([
327         "include/llvm/BinaryFormat/*.def",
328         "include/llvm/BinaryFormat/ELFRelocs/*.def",
329     ]),
330     deps = [
331         ":Support",
332     ],
335 cc_library(
336     name = "DebugInfo",
337     hdrs = glob(["include/llvm/DebugInfo/*.h"]),
338     copts = llvm_copts,
339     deps = [
340         ":Object",
341         ":Support",
342     ],
345 cc_library(
346     name = "DebugInfoMSF",
347     srcs = glob([
348         "lib/DebugInfo/MSF/*.cpp",
349         "lib/DebugInfo/MSF/*.h",
350     ]),
351     hdrs = glob(["include/llvm/DebugInfo/MSF/*.h"]),
352     copts = llvm_copts,
353     deps = [":Support"],
356 cc_library(
357     name = "DebugInfoCodeView",
358     srcs = glob([
359         "lib/DebugInfo/CodeView/*.cpp",
360         "lib/DebugInfo/CodeView/*.h",
361     ]),
362     hdrs = glob([
363         "include/llvm/DebugInfo/CodeView/*.h",
364     ]),
365     copts = llvm_copts,
366     textual_hdrs = glob([
367         "include/llvm/DebugInfo/CodeView/*.def",
368     ]),
369     deps = [
370         ":BinaryFormat",
371         ":DebugInfoMSF",
372         ":Support",
373     ],
376 cc_library(
377     name = "DebugInfoPDB",
378     srcs = glob([
379         "lib/DebugInfo/PDB/*.cpp",
380         "lib/DebugInfo/PDB/*.h",
381         "lib/DebugInfo/PDB/Native/*.cpp",
382         "lib/DebugInfo/PDB/Native/*.h",
383     ]),
384     hdrs = glob([
385         "include/llvm/DebugInfo/PDB/*.h",
386         "include/llvm/DebugInfo/PDB/Native/*.h",
387     ]),
388     copts = llvm_copts,
389     deps = [
390         ":BinaryFormat",
391         ":DebugInfo",
392         ":DebugInfoCodeView",
393         ":DebugInfoMSF",
394         ":Object",
395         ":Support",
396         ":config",
397     ],
400 cc_library(
401     name = "Debuginfod",
402     srcs = glob([
403         "lib/Debuginfod/*.cpp",
404     ]),
405     hdrs = glob([
406         "include/llvm/Debuginfod/*.h",
407     ]),
408     copts = llvm_copts,
409     deps = [
410         ":Support",
411     ],
414 cc_library(
415     name = "MC",
416     srcs = glob([
417         "lib/MC/*.cpp",
418         "lib/MC/*.h",
419     ]),
420     hdrs = glob([
421         "include/llvm/MC/*.h",
422         "include/llvm/MC/*.def",
423         "include/llvm/MC/*.inc",
424     ]),
425     copts = llvm_copts,
426     deps = [
427         ":BinaryFormat",
428         ":DebugInfoCodeView",
429         ":Support",
430         ":config",
431         ":ir_headers",
432     ],
435 cc_library(
436     name = "DebugInfoDWARF",
437     srcs = glob([
438         "lib/DebugInfo/DWARF/*.cpp",
439         "lib/DebugInfo/DWARF/*.h",
440     ]),
441     hdrs = glob(["include/llvm/DebugInfo/DWARF/*.h"]),
442     copts = llvm_copts,
443     deps = [
444         ":BinaryFormat",
445         ":DebugInfo",
446         ":MC",
447         ":Object",
448         ":Support",
449     ],
452 cc_library(
453     name = "Symbolize",
454     srcs = glob([
455         "lib/DebugInfo/Symbolize/*.cpp",
456         "lib/DebugInfo/Symbolize/*.h",
457     ]),
458     hdrs = glob(["include/llvm/DebugInfo/Symbolize/*.h"]),
459     copts = llvm_copts,
460     deps = [
461         ":BinaryFormat",
462         ":DebugInfo",
463         ":DebugInfoDWARF",
464         ":DebugInfoPDB",
465         ":Debuginfod",
466         ":Demangle",
467         ":Object",
468         ":Support",
469     ],
472 cc_library(
473     name = "tblgen",
474     srcs = glob([
475         "utils/TableGen/*.cpp",
476         "utils/TableGen/GlobalISel/*.cpp",
478         # Some tablegen sources include headers from MC, so these have to be
479         # listed here. MC uses headers produced by tablegen, so it cannot be a
480         # regular dependency.
481         "include/llvm/MC/*.h",
483         # We have to include these headers here as well as in the `hdrs` below
484         # to allow the `.cpp` files to use file-relative-inclusion to find
485         # them, even though consumers of this library use inclusion relative to
486         # `utils/TableGen` with the `strip_includes_prefix` of this library.
487         # This mixture appears to be incompatible with header modules.
488         "utils/TableGen/*.h",
489         "utils/TableGen/GlobalISel/*.h",
490     ]),
491     hdrs = glob([
492         "utils/TableGen/*.h",
493         "utils/TableGen/GlobalISel/*.h",
494     ]),
495     copts = llvm_copts,
496     features = ["-header_modules"],
497     strip_include_prefix = "utils/TableGen",
498     deps = [
499         ":Support",
500         ":TableGen",
501         ":config",
502     ],
505 cc_binary(
506     name = "llvm-tblgen",
507     copts = llvm_copts,
508     stamp = 0,
509     deps = [
510         ":tblgen",
511     ],
514 gentbl(
515     name = "intrinsic_enums_gen",
516     tbl_outs = [("-gen-intrinsic-enums", "include/llvm/IR/IntrinsicEnums.inc")],
517     tblgen = ":llvm-tblgen",
518     td_file = "include/llvm/IR/Intrinsics.td",
519     td_srcs = glob([
520         "include/llvm/CodeGen/*.td",
521         "include/llvm/IR/Intrinsics*.td",
522     ]),
525 gentbl(
526     name = "intrinsics_impl_gen",
527     tbl_outs = [("-gen-intrinsic-impl", "include/llvm/IR/IntrinsicImpl.inc")],
528     tblgen = ":llvm-tblgen",
529     td_file = "include/llvm/IR/Intrinsics.td",
530     td_srcs = glob([
531         "include/llvm/CodeGen/*.td",
532         "include/llvm/IR/Intrinsics*.td",
533     ]),
536 # Note that the intrinsics are not currently set up so they can be pruned for
537 # disabled targets.
538 llvm_target_intrinsics_list = [
539     {
540         "name": "AArch64",
541         "intrinsic_prefix": "aarch64",
542     },
543     {
544         "name": "AMDGPU",
545         "intrinsic_prefix": "amdgcn",
546     },
547     {
548         "name": "ARM",
549         "intrinsic_prefix": "arm",
550     },
551     {
552         "name": "BPF",
553         "intrinsic_prefix": "bpf",
554     },
555     {
556         "name": "Hexagon",
557         "intrinsic_prefix": "hexagon",
558     },
559     {
560         "name": "Mips",
561         "intrinsic_prefix": "mips",
562     },
563     {
564         "name": "NVPTX",
565         "intrinsic_prefix": "nvvm",
566     },
567     {
568         "name": "PowerPC",
569         "intrinsic_prefix": "ppc",
570     },
571     {
572         "name": "R600",
573         "intrinsic_prefix": "r600",
574     },
575     {
576         "name": "RISCV",
577         "intrinsic_prefix": "riscv",
578     },
579     {
580         "name": "S390",
581         "intrinsic_prefix": "s390",
582     },
583     {
584         "name": "VE",
585         "intrinsic_prefix": "ve",
586     },
587     {
588         "name": "WebAssembly",
589         "intrinsic_prefix": "wasm",
590     },
591     {
592         "name": "X86",
593         "intrinsic_prefix": "x86",
594     },
595     {
596         "name": "XCore",
597         "intrinsic_prefix": "xcore",
598     },
602     gentbl(
603         name = "intrinsic_" + target["name"] + "_gen",
604         tbl_outs = [(
605             "-gen-intrinsic-enums -intrinsic-prefix=" + target["intrinsic_prefix"],
606             "include/llvm/IR/Intrinsics" + target["name"] + ".h",
607         )],
608         tblgen = ":llvm-tblgen",
609         td_file = "include/llvm/IR/Intrinsics.td",
610         td_srcs = glob([
611             "include/llvm/CodeGen/*.td",
612             "include/llvm/IR/*.td",
613         ]),
614     ),
615 ] for target in llvm_target_intrinsics_list]
617 gentbl(
618     name = "attributes_gen",
619     tbl_outs = [("-gen-attrs", "include/llvm/IR/Attributes.inc")],
620     tblgen = ":llvm-tblgen",
621     td_file = "include/llvm/IR/Attributes.td",
622     td_srcs = [
623         "include/llvm/IR/Attributes.td",
624         "include/llvm/IR/AttributesAMDGPU.td",
625     ],
628 cc_library(
629     name = "BitstreamReader",
630     srcs = glob([
631         "lib/Bitstream/Reader/*.cpp",
632         "lib/Bitstream/Reader/*.h",
633     ]),
634     hdrs = [
635         "include/llvm/Bitstream/BitCodes.h",
636         "include/llvm/Bitstream/BitstreamReader.h",
637     ],
638     copts = llvm_copts,
639     deps = [
640         ":Support",
641     ],
644 cc_library(
645     name = "BitstreamWriter",
646     srcs = glob([
647         "lib/Bitstream/Writer/*.h",
648     ]),
649     hdrs = [
650         "include/llvm/Bitstream/BitCodes.h",
651         "include/llvm/Bitstream/BitstreamWriter.h",
652     ],
653     copts = llvm_copts,
654     deps = [
655         ":Support",
656     ],
659 cc_library(
660     name = "Remarks",
661     srcs = glob(
662         [
663             "lib/Remarks/*.cpp",
664             "lib/Remarks/*.h",
665         ],
666         exclude = ["lib/Remarks/RemarkLinker.cpp"],
667     ),
668     hdrs = glob(
669         [
670             "include/llvm/Remarks/*.h",
671         ],
672         exclude = ["include/llvm/Remarks/RemarkLinker.h"],
673     ) + [
674         "include/llvm-c/Remarks.h",
675     ],
676     copts = llvm_copts,
677     deps = [
678         ":BitstreamReader",
679         ":BitstreamWriter",
680         ":Support",
681     ],
684 cc_library(
685     name = "remark_linker",
686     srcs = ["lib/Remarks/RemarkLinker.cpp"],
687     hdrs = ["include/llvm/Remarks/RemarkLinker.h"],
688     copts = llvm_copts,
689     deps = [
690         ":Object",
691         ":Support",
692     ],
695 filegroup(
696     name = "llvm_intrinsics_headers",
697     srcs = [
698         "include/llvm/IR/Intrinsics" + target["name"] + ".h"
699         for target in llvm_target_intrinsics_list
700     ],
703 cc_library(
704     name = "Core",
705     srcs = glob([
706         "lib/IR/*.cpp",
707         "lib/IR/*.h",
708     ]),
709     hdrs = glob(
710         [
711             "include/llvm/*.h",
712             "include/llvm/IR/*.h",
713         ],
714         exclude = [
715             "include/llvm/LinkAllPasses.h",
716         ],
717     ) + [
718         "include/llvm-c/Comdat.h",
719         "include/llvm-c/DebugInfo.h",
720     ] + [":llvm_intrinsics_headers"],
721     copts = llvm_copts,
722     textual_hdrs = glob(["include/llvm/IR/*.def"]),
723     deps = [
724         ":BinaryFormat",
725         ":Remarks",
726         ":Support",
727         ":attributes_gen",
728         ":config",
729         ":intrinsic_enums_gen",
730         ":intrinsics_impl_gen",
731     ],
734 cc_library(
735     name = "BitReader",
736     srcs = glob([
737         "lib/Bitcode/Reader/*.cpp",
738         "lib/Bitcode/Reader/*.h",
739     ]),
740     hdrs = [
741         "include/llvm-c/BitReader.h",
742         "include/llvm/Bitcode/BitcodeAnalyzer.h",
743         "include/llvm/Bitcode/BitcodeCommon.h",
744         "include/llvm/Bitcode/BitcodeReader.h",
745         "include/llvm/Bitcode/LLVMBitCodes.h",
746     ],
747     copts = llvm_copts,
748     deps = [
749         ":BitstreamReader",
750         ":Core",
751         ":Support",
752         ":config",
753     ],
756 cc_library(
757     name = "MCParser",
758     srcs = glob([
759         "lib/MC/MCParser/*.cpp",
760         "lib/MC/MCParser/*.h",
761     ]),
762     hdrs = glob(["include/llvm/MC/MCParser/*.h"]),
763     copts = llvm_copts,
764     deps = [
765         ":BinaryFormat",
766         ":MC",
767         ":Support",
768         ":config",
769     ],
772 cc_library(
773     name = "TextAPI",
774     srcs = glob([
775         "lib/TextAPI/**/*.cpp",
776     ]),
777     hdrs = glob([
778         "include/llvm/TextAPI/**/*.h",
779         "include/llvm/TextAPI/**/*.def",
780         "lib/TextAPI/**/*.h",
781     ]),
782     copts = llvm_copts,
783     deps = [
784         ":BinaryFormat",
785         ":Support",
786     ],
789 cc_library(
790     name = "Object",
791     srcs = glob([
792         "lib/Object/*.cpp",
793         "lib/Object/*.h",
794     ]),
795     hdrs = glob([
796         "include/llvm/Object/*.h",
797     ]) + [
798         "include/llvm-c/Object.h",
799     ],
800     copts = llvm_copts,
801     deps = [
802         ":BinaryFormat",
803         ":BitReader",
804         ":Core",
805         ":MC",
806         ":MCParser",
807         ":Support",
808         ":TextAPI",
809         ":config",
810     ],
813 cc_library(
814     name = "ObjectYAML",
815     srcs = glob([
816         "lib/ObjectYAML/*.cpp",
817         "lib/ObjectYAML/*.h",
818     ]),
819     hdrs = glob(["include/llvm/ObjectYAML/*.h"]),
820     copts = llvm_copts,
821     deps = [
822         ":BinaryFormat",
823         ":DebugInfoCodeView",
824         ":Object",
825         ":Support",
826     ],
829 cc_library(
830     name = "ProfileData",
831     srcs = glob([
832         "lib/ProfileData/*.cpp",
833         "lib/ProfileData/*.h",
834     ]),
835     hdrs = glob([
836         "include/llvm/ProfileData/*.h",
837         "include/llvm/ProfileData/*.inc",
838     ]),
839     copts = llvm_copts,
840     deps = [
841         ":Core",
842         ":DebugInfoDWARF",
843         ":Support",
844         ":config",
845     ],
848 cc_library(
849     name = "Coverage",
850     srcs = glob([
851         "lib/ProfileData/Coverage/*.cpp",
852         "lib/ProfileData/Coverage/*.h",
853     ]),
854     hdrs = glob(["include/llvm/ProfileData/Coverage/*.h"]),
855     copts = llvm_copts,
856     deps = [
857         ":Object",
858         ":ProfileData",
859         ":Support",
860     ],
863 cc_library(
864     name = "Analysis",
865     srcs = glob(
866         [
867             "lib/Analysis/*.cpp",
868             "lib/Analysis/*.h",
869             "lib/Analysis/*.def",
870         ],
871     ),
872     hdrs = glob(
873         [
874             "include/llvm/Analysis/*.h",
875             "include/llvm/Analysis/Utils/*.h",
876         ],
877     ) + [
878         "include/llvm-c/Analysis.h",
879         "include/llvm-c/Initialization.h",
880     ],
881     copts = llvm_copts,
882     textual_hdrs = glob([
883         "include/llvm/Analysis/*.def",
884     ]),
885     deps = [
886         ":BinaryFormat",
887         ":Core",
888         ":Object",
889         ":ProfileData",
890         ":Support",
891         ":config",
892     ],
895 cc_library(
896     name = "BitWriter",
897     srcs = glob([
898         "lib/Bitcode/Writer/*.cpp",
899         "lib/Bitcode/Writer/*.h",
900     ]),
901     hdrs = [
902         "include/llvm-c/BitWriter.h",
903         "include/llvm/Bitcode/BitcodeCommon.h",
904         "include/llvm/Bitcode/BitcodeWriter.h",
905         "include/llvm/Bitcode/BitcodeWriterPass.h",
906         "include/llvm/Bitcode/LLVMBitCodes.h",
907     ],
908     copts = llvm_copts,
909     deps = [
910         ":Analysis",
911         ":BitstreamWriter",
912         ":Core",
913         ":MC",
914         ":Object",
915         ":Support",
916         ":config",
917     ],
920 cc_library(
921     name = "Target",
922     srcs = glob([
923         "lib/Target/*.cpp",
924         "lib/Target/*.h",
925     ]),
926     hdrs = glob([
927         "include/llvm/Target/*.h",
928     ]) + [
929         "include/llvm-c/Target.h",
930         "include/llvm-c/TargetMachine.h",
931     ],
932     copts = llvm_copts,
933     deps = [
934         ":Analysis",
935         ":BinaryFormat",
936         ":Core",
937         ":MC",
938         ":Support",
939         ":config",
940     ],
943 cc_library(
944     name = "DWP",
945     srcs = glob([
946         "lib/DWP/*.cpp",
947         "lib/DWP/*.h",
948     ]),
949     hdrs = glob(["include/llvm/DWP/*.h"]),
950     copts = llvm_copts,
951     deps = [
952         ":DebugInfoDWARF",
953         ":MC",
954         ":Object",
955         ":Support",
956         ":Target",
957     ],
960 cc_library(
961     name = "TransformUtils",
962     srcs = glob([
963         "lib/Transforms/Utils/*.cpp",
964         "lib/Transforms/Utils/*.h",
965     ]),
966     hdrs = glob(["include/llvm/Transforms/Utils/*.h"]) + [
967         "include/llvm/Transforms/Utils.h",
968         "include/llvm-c/Transforms/Utils.h",
969     ],
970     copts = llvm_copts,
971     deps = [
972         ":Analysis",
973         ":BinaryFormat",
974         ":BitWriter",
975         ":Core",
976         ":Support",
977         ":Target",
978         ":config",
979     ],
982 gentbl(
983     name = "InstCombineTableGen",
984     strip_include_prefix = "lib/Target/AMDGPU",
985     tbl_outs = [(
986         "-gen-searchable-tables",
987         "lib/Target/AMDGPU/InstCombineTables.inc",
988     )],
989     tblgen = ":llvm-tblgen",
990     td_file = "lib/Target/AMDGPU/InstCombineTables.td",
991     td_srcs = glob([
992         "include/llvm/CodeGen/*.td",
993         "include/llvm/IR/Intrinsics*.td",
994     ]) + [
995         "lib/Target/AMDGPU/InstCombineTables.td",
996         "include/llvm/TableGen/SearchableTable.td",
997     ],
1000 cc_library(
1001     name = "InstCombine",
1002     srcs = glob([
1003         "lib/Transforms/InstCombine/*.cpp",
1004         "lib/Transforms/InstCombine/*.h",
1005     ]),
1006     hdrs = glob(["include/llvm/Transforms/InstCombine/*.h"]) + [
1007         "include/llvm-c/Transforms/InstCombine.h",
1008     ],
1009     copts = llvm_copts,
1010     deps = [
1011         ":Analysis",
1012         ":Core",
1013         ":InstCombineTableGen",
1014         ":Support",
1015         ":Target",
1016         ":TransformUtils",
1017         ":config",
1018     ],
1021 cc_library(
1022     name = "AggressiveInstCombine",
1023     srcs = glob([
1024         "lib/Transforms/AggressiveInstCombine/*.cpp",
1025         "lib/Transforms/AggressiveInstCombine/*.h",
1026     ]),
1027     hdrs = [
1028         "include/llvm-c/Transforms/AggressiveInstCombine.h",
1029         "include/llvm/Transforms/AggressiveInstCombine/AggressiveInstCombine.h",
1030     ],
1031     copts = llvm_copts,
1032     deps = [
1033         ":Analysis",
1034         ":Core",
1035         ":Support",
1036         ":TransformUtils",
1037     ],
1040 cc_library(
1041     name = "Instrumentation",
1042     srcs = glob([
1043         "lib/Transforms/Instrumentation/*.cpp",
1044         "lib/Transforms/Instrumentation/*.h",
1045         "lib/Transforms/Instrumentation/*.inc",
1046     ]),
1047     hdrs = glob(["include/llvm/Transforms/Instrumentation/*.h"]) + [
1048         "include/llvm/Transforms/Instrumentation.h",
1049     ],
1050     copts = llvm_copts,
1051     deps = [
1052         ":Analysis",
1053         ":BinaryFormat",
1054         ":Core",
1055         ":MC",
1056         ":ProfileData",
1057         ":Support",
1058         ":TransformUtils",
1059         ":config",
1060     ],
1063 cc_library(
1064     name = "ObjCARC",
1065     srcs = glob([
1066         "lib/Transforms/ObjCARC/*.cpp",
1067         "lib/Transforms/ObjCARC/*.h",
1068     ]),
1069     hdrs = ["include/llvm/Transforms/ObjCARC.h"],
1070     copts = llvm_copts,
1071     deps = [
1072         ":Analysis",
1073         ":Core",
1074         ":Support",
1075         ":Target",
1076         ":TransformUtils",
1077         ":config",
1078     ],
1081 cc_library(
1082     name = "Scalar",
1083     srcs = glob([
1084         "lib/Transforms/Scalar/*.cpp",
1085         "lib/Transforms/Scalar/*.h",
1086     ]),
1087     hdrs = glob(["include/llvm/Transforms/Scalar/*.h"]) + [
1088         "include/llvm-c/Transforms/Scalar.h",
1089         "include/llvm/Transforms/Scalar.h",
1090     ],
1091     copts = llvm_copts,
1092     deps = [
1093         ":AggressiveInstCombine",
1094         ":Analysis",
1095         ":Core",
1096         ":InstCombine",
1097         ":ProfileData",
1098         ":Support",
1099         ":Target",
1100         ":TransformUtils",
1101         ":config",
1102     ],
1105 cc_library(
1106     name = "Vectorize",
1107     srcs = glob([
1108         "lib/Transforms/Vectorize/*.cpp",
1109         "lib/Transforms/Vectorize/*.h",
1110     ]),
1111     hdrs = glob([
1112         "include/llvm/Transforms/Vectorize/*.h",
1113     ]) + [
1114         "include/llvm-c/Transforms/Vectorize.h",
1115         "include/llvm/Transforms/Vectorize.h",
1116     ],
1117     copts = llvm_copts,
1118     deps = [
1119         ":Analysis",
1120         ":Core",
1121         ":Support",
1122         ":Target",
1123         ":TransformUtils",
1124         ":config",
1125     ],
1128 filegroup(
1129     name = "omp_td_files",
1130     srcs = glob([
1131         "include/llvm/Frontend/OpenMP/*.td",
1132         "include/llvm/Frontend/Directive/*.td",
1133     ]),
1136 gentbl(
1137     name = "omp_gen",
1138     library = False,
1139     tbl_outs = [
1140         ("--gen-directive-decl", "include/llvm/Frontend/OpenMP/OMP.h.inc"),
1141     ],
1142     tblgen = ":llvm-tblgen",
1143     td_file = "include/llvm/Frontend/OpenMP/OMP.td",
1144     td_srcs = [":omp_td_files"],
1147 gentbl(
1148     name = "omp_gen_impl",
1149     library = False,
1150     tbl_outs = [
1151         ("--gen-directive-impl", "include/llvm/Frontend/OpenMP/OMP.inc"),
1152     ],
1153     tblgen = ":llvm-tblgen",
1154     td_file = "include/llvm/Frontend/OpenMP/OMP.td",
1155     td_srcs = [":omp_td_files"],
1158 cc_library(
1159     name = "FrontendOpenMP",
1160     srcs = glob([
1161         "lib/Frontend/OpenMP/*.cpp",
1162     ]),
1163     hdrs = glob([
1164         "include/llvm/Frontend/OpenMP/*.h",
1165         "include/llvm/Frontend/OpenMP/OMP/*.h",
1166         "include/llvm/Frontend/*.h",
1167     ]) + [
1168         "include/llvm/Frontend/OpenMP/OMP.h.inc",
1169         "include/llvm/Frontend/OpenMP/OMP.inc",
1170     ],
1171     copts = llvm_copts,
1172     textual_hdrs = glob([
1173         "include/llvm/Frontend/OpenMP/*.def",
1174     ]),
1175     deps = [
1176         ":Analysis",
1177         ":Core",
1178         ":Scalar",
1179         ":Support",
1180         ":TransformUtils",
1181     ],
1184 filegroup(
1185     name = "acc_td_files",
1186     srcs = glob([
1187         "include/llvm/Frontend/OpenACC/*.td",
1188         "include/llvm/Frontend/Directive/*.td",
1189     ]),
1192 gentbl(
1193     name = "acc_gen",
1194     library = False,
1195     tbl_outs = [
1196         ("--gen-directive-decl", "include/llvm/Frontend/OpenACC/ACC.h.inc"),
1197     ],
1198     tblgen = ":llvm-tblgen",
1199     td_file = "include/llvm/Frontend/OpenACC/ACC.td",
1200     td_srcs = [":acc_td_files"],
1203 gentbl(
1204     name = "acc_gen_impl",
1205     library = False,
1206     tbl_outs = [
1207         ("--gen-directive-impl", "include/llvm/Frontend/OpenACC/ACC.inc"),
1208     ],
1209     tblgen = ":llvm-tblgen",
1210     td_file = "include/llvm/Frontend/OpenACC/ACC.td",
1211     td_srcs = [":acc_td_files"],
1214 cc_library(
1215     name = "FrontendOpenACC",
1216     srcs = glob([
1217         "lib/Frontend/OpenACC/*.cpp",
1218     ]) + [
1219         "include/llvm/Frontend/OpenACC/ACC.inc",
1220     ],
1221     hdrs = glob([
1222         "include/llvm/Frontend/OpenACC/*.h",
1223     ]) + ["include/llvm/Frontend/OpenACC/ACC.h.inc"],
1224     copts = llvm_copts,
1225     deps = [
1226         ":Analysis",
1227         ":Core",
1228         ":Support",
1229         ":TransformUtils",
1230     ],
1233 cc_library(
1234     name = "AsmParser",
1235     srcs = glob([
1236         "lib/AsmParser/*.cpp",
1237         "lib/AsmParser/*.h",
1238     ]),
1239     hdrs = glob(["include/llvm/AsmParser/*.h"]),
1240     copts = llvm_copts,
1241     deps = [
1242         ":BinaryFormat",
1243         ":Core",
1244         ":Support",
1245     ],
1248 cc_library(
1249     name = "IRReader",
1250     srcs = glob([
1251         "lib/IRReader/*.cpp",
1252         "lib/IRReader/*.h",
1253     ]),
1254     hdrs = glob([
1255         "include/llvm/IRReader/*.h",
1256     ]) + [
1257         "include/llvm-c/IRReader.h",
1258     ],
1259     copts = llvm_copts,
1260     deps = [
1261         ":AsmParser",
1262         ":BitReader",
1263         ":Core",
1264         ":Support",
1265         ":config",
1266     ],
1269 cc_library(
1270     name = "Linker",
1271     srcs = glob([
1272         "lib/Linker/*.cpp",
1273         "lib/Linker/*.h",
1274     ]),
1275     hdrs = glob([
1276         "include/llvm/Linker/*.h",
1277     ]) + [
1278         "include/llvm-c/Linker.h",
1279     ],
1280     copts = llvm_copts,
1281     deps = [
1282         ":Core",
1283         ":Support",
1284         ":TransformUtils",
1285         ":config",
1286     ],
1289 cc_library(
1290     name = "IPO",
1291     srcs = glob([
1292         "lib/Transforms/IPO/*.cpp",
1293         "lib/Transforms/IPO/*.h",
1294     ]),
1295     hdrs = glob([
1296         "include/llvm/Transforms/IPO/*.h",
1297     ]) + [
1298         "include/llvm-c/Transforms/IPO.h",
1299         "include/llvm-c/Transforms/PassManagerBuilder.h",
1300         "include/llvm/Transforms/IPO.h",
1301     ],
1302     copts = llvm_copts,
1303     deps = [
1304         ":AggressiveInstCombine",
1305         ":Analysis",
1306         ":BinaryFormat",
1307         ":BitReader",
1308         ":BitWriter",
1309         ":Core",
1310         ":FrontendOpenMP",
1311         ":IRReader",
1312         ":InstCombine",
1313         ":Instrumentation",
1314         ":Linker",
1315         ":ObjCARC",
1316         ":Object",
1317         ":ProfileData",
1318         ":Scalar",
1319         ":Support",
1320         ":Target",
1321         ":TransformUtils",
1322         ":Vectorize",
1323         ":config",
1324     ],
1327 cc_library(
1328     name = "CFGuard",
1329     srcs = glob([
1330         "lib/Transforms/CFGuard/*.cpp",
1331         "lib/Transforms/CFGuard/*.h",
1332     ]),
1333     hdrs = ["include/llvm/Transforms/CFGuard.h"],
1334     copts = llvm_copts,
1335     deps = [
1336         ":Core",
1337         ":Support",
1338     ],
1341 cc_library(
1342     name = "Coroutines",
1343     srcs = glob([
1344         "lib/Transforms/Coroutines/*.cpp",
1345         "lib/Transforms/Coroutines/*.h",
1346     ]),
1347     hdrs = [
1348         "include/llvm-c/Transforms/Coroutines.h",
1349         "include/llvm/Transforms/Coroutines.h",
1350         "include/llvm/Transforms/Coroutines/CoroCleanup.h",
1351         "include/llvm/Transforms/Coroutines/CoroEarly.h",
1352         "include/llvm/Transforms/Coroutines/CoroElide.h",
1353         "include/llvm/Transforms/Coroutines/CoroSplit.h",
1354     ],
1355     copts = llvm_copts,
1356     deps = [
1357         ":Analysis",
1358         ":Core",
1359         ":IPO",
1360         ":Scalar",
1361         ":Support",
1362         ":TransformUtils",
1363         ":config",
1364     ],
1367 # Meta-target for clients which depend on all of the transforms libraries.
1368 cc_library(
1369     name = "common_transforms",
1370     deps = [
1371         ":AggressiveInstCombine",
1372         ":CFGuard",
1373         ":Coroutines",
1374         ":IPO",
1375         ":InstCombine",
1376         ":Instrumentation",
1377         ":ObjCARC",
1378         ":Scalar",
1379         ":Vectorize",
1380     ],
1383 cc_library(
1384     name = "asm_printer_defs",
1385     copts = llvm_copts,
1386     textual_hdrs = glob(["lib/CodeGen/AsmPrinter/*.def"]),
1389 cc_library(
1390     name = "CodeGen",
1391     srcs = glob(
1392         [
1393             "lib/CodeGen/**/*.cpp",
1394             "lib/CodeGen/**/*.h",
1395             "lib/CodeGen/SelectionDAG/*.cpp",
1396             "lib/CodeGen/SelectionDAG/*.h",
1397         ],
1398     ),
1399     hdrs = [
1400         "include/llvm/LinkAllPasses.h",
1401     ] + glob(
1402         [
1403             "include/llvm/CodeGen/**/*.h",
1404         ],
1405     ),
1406     copts = llvm_copts,
1407     textual_hdrs = glob([
1408         "include/llvm/CodeGen/**/*.def",
1409         "include/llvm/CodeGen/**/*.inc",
1410     ]),
1411     deps = [
1412         ":Analysis",
1413         ":AsmParser",
1414         ":BinaryFormat",
1415         ":BitReader",
1416         ":BitWriter",
1417         ":Core",
1418         ":DebugInfoCodeView",
1419         ":DebugInfoDWARF",
1420         ":IPO",
1421         ":MC",
1422         ":MCParser",
1423         ":ProfileData",
1424         ":Remarks",
1425         ":Scalar",
1426         ":Support",
1427         ":Target",
1428         ":TransformUtils",
1429         ":asm_printer_defs",
1430         ":config",
1431     ],
1434 cc_library(
1435     name = "MCDisassembler",
1436     srcs = glob([
1437         "lib/MC/MCDisassembler/*.cpp",
1438         "lib/MC/MCDisassembler/*.h",
1439     ]),
1440     hdrs = glob([
1441         "include/llvm/MC/MCDisassembler/*.h",
1442     ]) + [
1443         "include/llvm-c/Disassembler.h",
1444     ],
1445     copts = llvm_copts,
1446     deps = [
1447         ":MC",
1448         ":Support",
1449         ":config",
1450     ],
1453 llvm_target_lib_list = [lib for lib in [
1454     {
1455         "name": "AArch64",
1456         "short_name": "AArch64",
1457         "tbl_outs": [
1458             ("-gen-register-bank", "lib/Target/AArch64/AArch64GenRegisterBank.inc"),
1459             ("-gen-register-info", "lib/Target/AArch64/AArch64GenRegisterInfo.inc"),
1460             ("-gen-instr-info", "lib/Target/AArch64/AArch64GenInstrInfo.inc"),
1461             ("-gen-emitter", "lib/Target/AArch64/AArch64GenMCCodeEmitter.inc"),
1462             ("-gen-pseudo-lowering", "lib/Target/AArch64/AArch64GenMCPseudoLowering.inc"),
1463             ("-gen-asm-writer", "lib/Target/AArch64/AArch64GenAsmWriter.inc"),
1464             ("-gen-asm-writer -asmwriternum=1", "lib/Target/AArch64/AArch64GenAsmWriter1.inc"),
1465             ("-gen-asm-matcher", "lib/Target/AArch64/AArch64GenAsmMatcher.inc"),
1466             ("-gen-dag-isel", "lib/Target/AArch64/AArch64GenDAGISel.inc"),
1467             ("-gen-fast-isel", "lib/Target/AArch64/AArch64GenFastISel.inc"),
1468             ("-gen-global-isel", "lib/Target/AArch64/AArch64GenGlobalISel.inc"),
1469             ("-gen-global-isel-combiner -combiners=AArch64O0PreLegalizerCombinerHelper", "lib/Target/AArch64/AArch64GenO0PreLegalizeGICombiner.inc"),
1470             ("-gen-global-isel-combiner -combiners=AArch64PreLegalizerCombinerHelper", "lib/Target/AArch64/AArch64GenPreLegalizeGICombiner.inc"),
1471             ("-gen-global-isel-combiner -combiners=AArch64PostLegalizerCombinerHelper", "lib/Target/AArch64/AArch64GenPostLegalizeGICombiner.inc"),
1472             ("-gen-global-isel-combiner -combiners=AArch64PostLegalizerLoweringHelper", "lib/Target/AArch64/AArch64GenPostLegalizeGILowering.inc"),
1473             ("-gen-callingconv", "lib/Target/AArch64/AArch64GenCallingConv.inc"),
1474             ("-gen-subtarget", "lib/Target/AArch64/AArch64GenSubtargetInfo.inc"),
1475             ("-gen-disassembler", "lib/Target/AArch64/AArch64GenDisassemblerTables.inc"),
1476             ("-gen-searchable-tables", "lib/Target/AArch64/AArch64GenSystemOperands.inc"),
1477         ],
1478     },
1479     {
1480         "name": "ARM",
1481         "short_name": "ARM",
1482         "tbl_outs": [
1483             ("-gen-register-bank", "lib/Target/ARM/ARMGenRegisterBank.inc"),
1484             ("-gen-register-info", "lib/Target/ARM/ARMGenRegisterInfo.inc"),
1485             ("-gen-searchable-tables", "lib/Target/ARM/ARMGenSystemRegister.inc"),
1486             ("-gen-instr-info", "lib/Target/ARM/ARMGenInstrInfo.inc"),
1487             ("-gen-emitter", "lib/Target/ARM/ARMGenMCCodeEmitter.inc"),
1488             ("-gen-pseudo-lowering", "lib/Target/ARM/ARMGenMCPseudoLowering.inc"),
1489             ("-gen-asm-writer", "lib/Target/ARM/ARMGenAsmWriter.inc"),
1490             ("-gen-asm-matcher", "lib/Target/ARM/ARMGenAsmMatcher.inc"),
1491             ("-gen-dag-isel", "lib/Target/ARM/ARMGenDAGISel.inc"),
1492             ("-gen-fast-isel", "lib/Target/ARM/ARMGenFastISel.inc"),
1493             ("-gen-global-isel", "lib/Target/ARM/ARMGenGlobalISel.inc"),
1494             ("-gen-callingconv", "lib/Target/ARM/ARMGenCallingConv.inc"),
1495             ("-gen-subtarget", "lib/Target/ARM/ARMGenSubtargetInfo.inc"),
1496             ("-gen-disassembler", "lib/Target/ARM/ARMGenDisassemblerTables.inc"),
1497         ],
1498     },
1499     {
1500         "name": "AMDGPU",
1501         "short_name": "AMDGPU",
1502         "tbl_outs": [
1503             ("-gen-register-bank", "lib/Target/AMDGPU/AMDGPUGenRegisterBank.inc"),
1504             ("-gen-register-info", "lib/Target/AMDGPU/AMDGPUGenRegisterInfo.inc"),
1505             ("-gen-instr-info", "lib/Target/AMDGPU/AMDGPUGenInstrInfo.inc"),
1506             ("-gen-emitter", "lib/Target/AMDGPU/AMDGPUGenMCCodeEmitter.inc"),
1507             ("-gen-pseudo-lowering", "lib/Target/AMDGPU/AMDGPUGenMCPseudoLowering.inc"),
1508             ("-gen-asm-writer", "lib/Target/AMDGPU/AMDGPUGenAsmWriter.inc"),
1509             ("-gen-asm-matcher", "lib/Target/AMDGPU/AMDGPUGenAsmMatcher.inc"),
1510             ("-gen-dag-isel", "lib/Target/AMDGPU/AMDGPUGenDAGISel.inc"),
1511             ("-gen-callingconv", "lib/Target/AMDGPU/AMDGPUGenCallingConv.inc"),
1512             ("-gen-subtarget", "lib/Target/AMDGPU/AMDGPUGenSubtargetInfo.inc"),
1513             ("-gen-disassembler", "lib/Target/AMDGPU/AMDGPUGenDisassemblerTables.inc"),
1514             ("-gen-searchable-tables", "lib/Target/AMDGPU/AMDGPUGenSearchableTables.inc"),
1515         ],
1516         "tbl_deps": [
1517             ":amdgpu_isel_target_gen",
1518             ":r600_target_gen",
1519         ],
1520     },
1521     {
1522         "name": "AVR",
1523         "short_name": "AVR",
1524         "tbl_outs": [
1525             ("-gen-asm-matcher", "lib/Target/AVR/AVRGenAsmMatcher.inc"),
1526             ("-gen-asm-writer", "lib/Target/AVR/AVRGenAsmWriter.inc"),
1527             ("-gen-callingconv", "lib/Target/AVR/AVRGenCallingConv.inc"),
1528             ("-gen-dag-isel", "lib/Target/AVR/AVRGenDAGISel.inc"),
1529             ("-gen-disassembler", "lib/Target/AVR/AVRGenDisassemblerTables.inc"),
1530             ("-gen-emitter", "lib/Target/AVR/AVRGenMCCodeEmitter.inc"),
1531             ("-gen-instr-info", "lib/Target/AVR/AVRGenInstrInfo.inc"),
1532             ("-gen-register-info", "lib/Target/AVR/AVRGenRegisterInfo.inc"),
1533             ("-gen-subtarget", "lib/Target/AVR/AVRGenSubtargetInfo.inc"),
1534         ],
1535     },
1536     {
1537         "name": "BPF",
1538         "short_name": "BPF",
1539         "tbl_outs": [
1540             ("-gen-asm-writer", "lib/Target/BPF/BPFGenAsmWriter.inc"),
1541             ("-gen-asm-matcher", "lib/Target/BPF/BPFGenAsmMatcher.inc"),
1542             ("-gen-callingconv", "lib/Target/BPF/BPFGenCallingConv.inc"),
1543             ("-gen-dag-isel", "lib/Target/BPF/BPFGenDAGISel.inc"),
1544             ("-gen-disassembler", "lib/Target/BPF/BPFGenDisassemblerTables.inc"),
1545             ("-gen-emitter", "lib/Target/BPF/BPFGenMCCodeEmitter.inc"),
1546             ("-gen-instr-info", "lib/Target/BPF/BPFGenInstrInfo.inc"),
1547             ("-gen-register-info", "lib/Target/BPF/BPFGenRegisterInfo.inc"),
1548             ("-gen-subtarget", "lib/Target/BPF/BPFGenSubtargetInfo.inc"),
1549         ],
1550     },
1551     {
1552         "name": "Hexagon",
1553         "short_name": "Hexagon",
1554         "tbl_outs": [
1555             ("-gen-asm-matcher", "lib/Target/Hexagon/HexagonGenAsmMatcher.inc"),
1556             ("-gen-asm-writer", "lib/Target/Hexagon/HexagonGenAsmWriter.inc"),
1557             ("-gen-callingconv", "lib/Target/Hexagon/HexagonGenCallingConv.inc"),
1558             ("-gen-dag-isel", "lib/Target/Hexagon/HexagonGenDAGISel.inc"),
1559             ("-gen-dfa-packetizer", "lib/Target/Hexagon/HexagonGenDFAPacketizer.inc"),
1560             ("-gen-disassembler", "lib/Target/Hexagon/HexagonGenDisassemblerTables.inc"),
1561             ("-gen-instr-info", "lib/Target/Hexagon/HexagonGenInstrInfo.inc"),
1562             ("-gen-emitter", "lib/Target/Hexagon/HexagonGenMCCodeEmitter.inc"),
1563             ("-gen-register-info", "lib/Target/Hexagon/HexagonGenRegisterInfo.inc"),
1564             ("-gen-subtarget", "lib/Target/Hexagon/HexagonGenSubtargetInfo.inc"),
1565         ],
1566     },
1567     {
1568         "name": "Lanai",
1569         "short_name": "Lanai",
1570         "tbl_outs": [
1571             ("-gen-asm-matcher", "lib/Target/Lanai/LanaiGenAsmMatcher.inc"),
1572             ("-gen-asm-writer", "lib/Target/Lanai/LanaiGenAsmWriter.inc"),
1573             ("-gen-callingconv", "lib/Target/Lanai/LanaiGenCallingConv.inc"),
1574             ("-gen-dag-isel", "lib/Target/Lanai/LanaiGenDAGISel.inc"),
1575             ("-gen-disassembler", "lib/Target/Lanai/LanaiGenDisassemblerTables.inc"),
1576             ("-gen-emitter", "lib/Target/Lanai/LanaiGenMCCodeEmitter.inc"),
1577             ("-gen-instr-info", "lib/Target/Lanai/LanaiGenInstrInfo.inc"),
1578             ("-gen-register-info", "lib/Target/Lanai/LanaiGenRegisterInfo.inc"),
1579             ("-gen-subtarget", "lib/Target/Lanai/LanaiGenSubtargetInfo.inc"),
1580         ],
1581     },
1582     {
1583         "name": "Mips",
1584         "short_name": "Mips",
1585         "tbl_outs": [
1586             ("-gen-asm-matcher", "lib/Target/Mips/MipsGenAsmMatcher.inc"),
1587             ("-gen-asm-writer", "lib/Target/Mips/MipsGenAsmWriter.inc"),
1588             ("-gen-callingconv", "lib/Target/Mips/MipsGenCallingConv.inc"),
1589             ("-gen-dag-isel", "lib/Target/Mips/MipsGenDAGISel.inc"),
1590             ("-gen-disassembler", "lib/Target/Mips/MipsGenDisassemblerTables.inc"),
1591             ("-gen-emitter", "lib/Target/Mips/MipsGenMCCodeEmitter.inc"),
1592             ("-gen-exegesis", "lib/Target/Mips/MipsGenExegesis.inc"),
1593             ("-gen-fast-isel", "lib/Target/Mips/MipsGenFastISel.inc"),
1594             ("-gen-global-isel", "lib/Target/Mips/MipsGenGlobalISel.inc"),
1595             ("-gen-instr-info", "lib/Target/Mips/MipsGenInstrInfo.inc"),
1596             ("-gen-pseudo-lowering", "lib/Target/Mips/MipsGenMCPseudoLowering.inc"),
1597             ("-gen-register-bank", "lib/Target/Mips/MipsGenRegisterBank.inc"),
1598             ("-gen-register-info", "lib/Target/Mips/MipsGenRegisterInfo.inc"),
1599             ("-gen-subtarget", "lib/Target/Mips/MipsGenSubtargetInfo.inc"),
1600         ],
1601     },
1602     {
1603         "name": "MSP430",
1604         "short_name": "MSP430",
1605         "tbl_outs": [
1606             ("-gen-asm-matcher", "lib/Target/MSP430/MSP430GenAsmMatcher.inc"),
1607             ("-gen-asm-writer", "lib/Target/MSP430/MSP430GenAsmWriter.inc"),
1608             ("-gen-callingconv", "lib/Target/MSP430/MSP430GenCallingConv.inc"),
1609             ("-gen-dag-isel", "lib/Target/MSP430/MSP430GenDAGISel.inc"),
1610             ("-gen-disassembler", "lib/Target/MSP430/MSP430GenDisassemblerTables.inc"),
1611             ("-gen-emitter", "lib/Target/MSP430/MSP430GenMCCodeEmitter.inc"),
1612             ("-gen-instr-info", "lib/Target/MSP430/MSP430GenInstrInfo.inc"),
1613             ("-gen-register-info", "lib/Target/MSP430/MSP430GenRegisterInfo.inc"),
1614             ("-gen-subtarget", "lib/Target/MSP430/MSP430GenSubtargetInfo.inc"),
1615         ],
1616     },
1617     {
1618         "name": "NVPTX",
1619         "short_name": "NVPTX",
1620         "tbl_outs": [
1621             ("-gen-register-info", "lib/Target/NVPTX/NVPTXGenRegisterInfo.inc"),
1622             ("-gen-instr-info", "lib/Target/NVPTX/NVPTXGenInstrInfo.inc"),
1623             ("-gen-asm-writer", "lib/Target/NVPTX/NVPTXGenAsmWriter.inc"),
1624             ("-gen-dag-isel", "lib/Target/NVPTX/NVPTXGenDAGISel.inc"),
1625             ("-gen-subtarget", "lib/Target/NVPTX/NVPTXGenSubtargetInfo.inc"),
1626         ],
1627     },
1628     {
1629         "name": "PowerPC",
1630         "short_name": "PPC",
1631         "tbl_outs": [
1632             ("-gen-asm-writer", "lib/Target/PowerPC/PPCGenAsmWriter.inc"),
1633             ("-gen-asm-matcher", "lib/Target/PowerPC/PPCGenAsmMatcher.inc"),
1634             ("-gen-emitter", "lib/Target/PowerPC/PPCGenMCCodeEmitter.inc"),
1635             ("-gen-register-info", "lib/Target/PowerPC/PPCGenRegisterInfo.inc"),
1636             ("-gen-instr-info", "lib/Target/PowerPC/PPCGenInstrInfo.inc"),
1637             ("-gen-dag-isel", "lib/Target/PowerPC/PPCGenDAGISel.inc"),
1638             ("-gen-fast-isel", "lib/Target/PowerPC/PPCGenFastISel.inc"),
1639             ("-gen-callingconv", "lib/Target/PowerPC/PPCGenCallingConv.inc"),
1640             ("-gen-subtarget", "lib/Target/PowerPC/PPCGenSubtargetInfo.inc"),
1641             ("-gen-disassembler", "lib/Target/PowerPC/PPCGenDisassemblerTables.inc"),
1642             ("-gen-register-bank", "lib/Target/PowerPC/PPCGenRegisterBank.inc"),
1643             ("-gen-global-isel", "lib/Target/PowerPC/PPCGenGlobalISel.inc"),
1644         ],
1645     },
1646     {
1647         "name": "Sparc",
1648         "short_name": "Sparc",
1649         "tbl_outs": [
1650             ("-gen-asm-writer", "lib/Target/Sparc/SparcGenAsmWriter.inc"),
1651             ("-gen-asm-matcher", "lib/Target/Sparc/SparcGenAsmMatcher.inc"),
1652             ("-gen-emitter", "lib/Target/Sparc/SparcGenMCCodeEmitter.inc"),
1653             ("-gen-register-info", "lib/Target/Sparc/SparcGenRegisterInfo.inc"),
1654             ("-gen-instr-info", "lib/Target/Sparc/SparcGenInstrInfo.inc"),
1655             ("-gen-dag-isel", "lib/Target/Sparc/SparcGenDAGISel.inc"),
1656             ("-gen-callingconv", "lib/Target/Sparc/SparcGenCallingConv.inc"),
1657             ("-gen-subtarget", "lib/Target/Sparc/SparcGenSubtargetInfo.inc"),
1658             ("-gen-disassembler", "lib/Target/Sparc/SparcGenDisassemblerTables.inc"),
1659         ],
1660     },
1661     {
1662         "name": "SystemZ",
1663         "short_name": "SystemZ",
1664         "tbl_outs": [
1665             ("-gen-asm-matcher", "lib/Target/SystemZ/SystemZGenAsmMatcher.inc"),
1666             ("-gen-asm-writer", "lib/Target/SystemZ/SystemZGenAsmWriter.inc"),
1667             ("-gen-callingconv", "lib/Target/SystemZ/SystemZGenCallingConv.inc"),
1668             ("-gen-dag-isel", "lib/Target/SystemZ/SystemZGenDAGISel.inc"),
1669             ("-gen-disassembler", "lib/Target/SystemZ/SystemZGenDisassemblerTables.inc"),
1670             ("-gen-emitter", "lib/Target/SystemZ/SystemZGenMCCodeEmitter.inc"),
1671             ("-gen-instr-info", "lib/Target/SystemZ/SystemZGenInstrInfo.inc"),
1672             ("-gen-register-info", "lib/Target/SystemZ/SystemZGenRegisterInfo.inc"),
1673             ("-gen-subtarget", "lib/Target/SystemZ/SystemZGenSubtargetInfo.inc"),
1674         ],
1675     },
1676     {
1677         "name": "RISCV",
1678         "short_name": "RISCV",
1679         "tbl_outs": [
1680             ("-gen-asm-matcher", "lib/Target/RISCV/RISCVGenAsmMatcher.inc"),
1681             ("-gen-asm-writer", "lib/Target/RISCV/RISCVGenAsmWriter.inc"),
1682             ("-gen-compress-inst-emitter", "lib/Target/RISCV/RISCVGenCompressInstEmitter.inc"),
1683             ("-gen-dag-isel", "lib/Target/RISCV/RISCVGenDAGISel.inc"),
1684             ("-gen-disassembler", "lib/Target/RISCV/RISCVGenDisassemblerTables.inc"),
1685             ("-gen-global-isel", "lib/Target/RISCV/RISCVGenGlobalISel.inc"),
1686             ("-gen-instr-info", "lib/Target/RISCV/RISCVGenInstrInfo.inc"),
1687             ("-gen-emitter", "lib/Target/RISCV/RISCVGenMCCodeEmitter.inc"),
1688             ("-gen-pseudo-lowering", "lib/Target/RISCV/RISCVGenMCPseudoLowering.inc"),
1689             ("-gen-register-bank", "lib/Target/RISCV/RISCVGenRegisterBank.inc"),
1690             ("-gen-register-info", "lib/Target/RISCV/RISCVGenRegisterInfo.inc"),
1691             ("-gen-subtarget", "lib/Target/RISCV/RISCVGenSubtargetInfo.inc"),
1692             ("-gen-searchable-tables", "lib/Target/RISCV/RISCVGenSearchableTables.inc"),
1693         ],
1694     },
1695     {
1696         "name": "WebAssembly",
1697         "short_name": "WebAssembly",
1698         "tbl_outs": [
1699             ("-gen-disassembler", "lib/Target/WebAssembly/WebAssemblyGenDisassemblerTables.inc"),
1700             ("-gen-asm-writer", "lib/Target/WebAssembly/WebAssemblyGenAsmWriter.inc"),
1701             ("-gen-instr-info", "lib/Target/WebAssembly/WebAssemblyGenInstrInfo.inc"),
1702             ("-gen-dag-isel", "lib/Target/WebAssembly/WebAssemblyGenDAGISel.inc"),
1703             ("-gen-fast-isel", "lib/Target/WebAssembly/WebAssemblyGenFastISel.inc"),
1704             ("-gen-emitter", "lib/Target/WebAssembly/WebAssemblyGenMCCodeEmitter.inc"),
1705             ("-gen-register-info", "lib/Target/WebAssembly/WebAssemblyGenRegisterInfo.inc"),
1706             ("-gen-subtarget", "lib/Target/WebAssembly/WebAssemblyGenSubtargetInfo.inc"),
1707             ("-gen-asm-matcher", "lib/Target/WebAssembly/WebAssemblyGenAsmMatcher.inc"),
1708         ],
1709     },
1710     {
1711         "name": "X86",
1712         "short_name": "X86",
1713         "tbl_outs": [
1714             ("-gen-register-bank", "lib/Target/X86/X86GenRegisterBank.inc"),
1715             ("-gen-register-info", "lib/Target/X86/X86GenRegisterInfo.inc"),
1716             ("-gen-disassembler", "lib/Target/X86/X86GenDisassemblerTables.inc"),
1717             ("-gen-instr-info", "lib/Target/X86/X86GenInstrInfo.inc"),
1718             ("-gen-asm-writer", "lib/Target/X86/X86GenAsmWriter.inc"),
1719             ("-gen-asm-writer -asmwriternum=1", "lib/Target/X86/X86GenAsmWriter1.inc"),
1720             ("-gen-asm-matcher", "lib/Target/X86/X86GenAsmMatcher.inc"),
1721             ("-gen-dag-isel", "lib/Target/X86/X86GenDAGISel.inc"),
1722             ("-gen-fast-isel", "lib/Target/X86/X86GenFastISel.inc"),
1723             ("-gen-global-isel", "lib/Target/X86/X86GenGlobalISel.inc"),
1724             ("-gen-callingconv", "lib/Target/X86/X86GenCallingConv.inc"),
1725             ("-gen-subtarget", "lib/Target/X86/X86GenSubtargetInfo.inc"),
1726             ("-gen-x86-EVEX2VEX-tables", "lib/Target/X86/X86GenEVEX2VEXTables.inc"),
1727             ("-gen-exegesis", "lib/Target/X86/X86GenExegesis.inc"),
1728         ],
1729     },
1730     {
1731         "name": "XCore",
1732         "short_name": "XCore",
1733         "tbl_outs": [
1734             ("-gen-asm-writer", "lib/Target/XCore/XCoreGenAsmWriter.inc"),
1735             ("-gen-callingconv", "lib/Target/XCore/XCoreGenCallingConv.inc"),
1736             ("-gen-dag-isel", "lib/Target/XCore/XCoreGenDAGISel.inc"),
1737             ("-gen-disassembler", "lib/Target/XCore/XCoreGenDisassemblerTables.inc"),
1738             ("-gen-instr-info", "lib/Target/XCore/XCoreGenInstrInfo.inc"),
1739             ("-gen-register-info", "lib/Target/XCore/XCoreGenRegisterInfo.inc"),
1740             ("-gen-subtarget", "lib/Target/XCore/XCoreGenSubtargetInfo.inc"),
1741         ],
1742     },
1743 ] if lib["name"] in llvm_targets]
1745 cc_library(
1746     name = "x86_target_layering_problem_hdrs",
1747     textual_hdrs = ["lib/Target/X86/X86InstrInfo.h"],
1750 filegroup(
1751     name = "common_target_td_sources",
1752     srcs = glob([
1753         "include/llvm/CodeGen/*.td",
1754         "include/llvm/Frontend/Directive/*.td",
1755         "include/llvm/IR/Intrinsics*.td",
1756         "include/llvm/TableGen/*.td",
1757         "include/llvm/Target/*.td",
1758         "include/llvm/Target/GlobalISel/*.td",
1759     ]),
1762 gentbl(
1763     name = "amdgpu_isel_target_gen",
1764     strip_include_prefix = "lib/Target/AMDGPU",
1765     tbl_outs = [
1766         ("-gen-global-isel", "lib/Target/AMDGPU/AMDGPUGenGlobalISel.inc"),
1767         ("-gen-global-isel-combiner -combiners=AMDGPUPreLegalizerCombinerHelper", "lib/Target/AMDGPU/AMDGPUGenPreLegalizeGICombiner.inc"),
1768         ("-gen-global-isel-combiner -combiners=AMDGPUPostLegalizerCombinerHelper", "lib/Target/AMDGPU/AMDGPUGenPostLegalizeGICombiner.inc"),
1769         ("-gen-global-isel-combiner -combiners=AMDGPURegBankCombinerHelper", "lib/Target/AMDGPU/AMDGPUGenRegBankGICombiner.inc"),
1770     ],
1771     tblgen = ":llvm-tblgen",
1772     td_file = "lib/Target/AMDGPU/AMDGPUGISel.td",
1773     td_srcs = [
1774         ":common_target_td_sources",
1775     ] + glob([
1776         "lib/Target/AMDGPU/*.td",
1777     ]),
1780 gentbl(
1781     name = "r600_target_gen",
1782     strip_include_prefix = "lib/Target/AMDGPU",
1783     tbl_outs = [
1784         ("-gen-asm-writer", "lib/Target/AMDGPU/R600GenAsmWriter.inc"),
1785         ("-gen-callingconv", "lib/Target/AMDGPU/R600GenCallingConv.inc"),
1786         ("-gen-dag-isel", "lib/Target/AMDGPU/R600GenDAGISel.inc"),
1787         ("-gen-dfa-packetizer", "lib/Target/AMDGPU/R600GenDFAPacketizer.inc"),
1788         ("-gen-instr-info", "lib/Target/AMDGPU/R600GenInstrInfo.inc"),
1789         ("-gen-emitter", "lib/Target/AMDGPU/R600GenMCCodeEmitter.inc"),
1790         ("-gen-register-info", "lib/Target/AMDGPU/R600GenRegisterInfo.inc"),
1791         ("-gen-subtarget", "lib/Target/AMDGPU/R600GenSubtargetInfo.inc"),
1792     ],
1793     tblgen = ":llvm-tblgen",
1794     td_file = "lib/Target/AMDGPU/R600.td",
1795     td_srcs = [
1796         ":common_target_td_sources",
1797     ] + glob([
1798         "lib/Target/AMDGPU/*.td",
1799     ]),
1803     [gentbl(
1804         name = target["name"] + "CommonTableGen",
1805         strip_include_prefix = "lib/Target/" + target["name"],
1806         tbl_outs = target["tbl_outs"],
1807         tblgen = ":llvm-tblgen",
1808         # MSVC isn't happy with long string literals, while other compilers
1809         # which support them get significant compile time improvements with
1810         # them enabled. Ideally this flag would only be enabled on Windows via
1811         # a select() on `@bazel_tools//src/conditions:windows,`, but that would
1812         # require refactoring gentbl from a macro into a rule.
1813         # TODO(#92): Refactor gentbl to support this use
1814         tblgen_args = "--long-string-literals=0",
1815         td_file = "lib/Target/" + target["name"] + "/" + target["short_name"] + ".td",
1816         td_srcs = [
1817             ":common_target_td_sources",
1818         ] + glob([
1819             "lib/Target/" + target["name"] + "/*.td",
1820             "lib/Target/" + target["name"] + "/GISel/*.td",
1821         ]),
1822         deps = target.get("tbl_deps", []),
1823     )],
1824     [cc_library(
1825         name = target["name"] + "Info",
1826         srcs = ["lib/Target/" + target["name"] + "/TargetInfo/" + target["name"] + "TargetInfo.cpp"],
1827         hdrs = glob(["lib/Target/" + target["name"] + "/TargetInfo/*.h"]),
1828         copts = llvm_copts,
1829         # Workaround for https://github.com/bazelbuild/bazel/issues/3828
1830         # TODO(gcmn): Remove this when upgrading to a Bazel version containing
1831         # https://github.com/bazelbuild/bazel/commit/e3b7e17b05f1
1832         includes = ["lib/Target/" + target["name"]],
1833         strip_include_prefix = "lib/Target/" + target["name"],
1834         deps = [
1835             ":" + target["name"] + "CommonTableGen",
1836             ":Support",
1837             ":Target",
1838         ],
1839     )],
1840     # We cannot separate the `Utils` and `MCTargetDesc` sublibraries of
1841     # a number of targets due to crisscrossing inclusion of headers.
1842     [cc_library(
1843         name = target["name"] + "UtilsAndDesc",
1844         srcs = glob([
1845             "lib/Target/" + target["name"] + "/MCTargetDesc/*.cpp",
1846             "lib/Target/" + target["name"] + "/Utils/*.cpp",
1848             # We have to include these headers here as well as in the `hdrs`
1849             # below to allow the `.cpp` files to use file-relative-inclusion to
1850             # find them, even though consumers of this library use inclusion
1851             # relative to the target with the `strip_includes_prefix` of this
1852             # library. This mixture is likely incompatible with header modules.
1853             "lib/Target/" + target["name"] + "/MCTargetDesc/*.h",
1854             "lib/Target/" + target["name"] + "/Utils/*.h",
1855         ]),
1856         hdrs = glob([
1857             "lib/Target/" + target["name"] + "/MCTargetDesc/*.h",
1858             "lib/Target/" + target["name"] + "/Utils/*.h",
1860             # This a bit of a hack to allow us to expose common, internal
1861             # target header files to other libraries within the target via
1862             # target-relative includes. This usage of headers is inherently
1863             # non-modular as there is a mixture of target-relative inclusion
1864             # using this rule and file-relative inclusion using the repeated
1865             # listing of these headers in the `srcs` of subsequent rules.
1866             "lib/Target/" + target["name"] + "/*.h",
1868             # FIXME: The entries below should be `textual_hdrs` instead of
1869             # `hdrs`, but unfortunately that doesn't work with
1870             # `strip_include_prefix`:
1871             # https://github.com/bazelbuild/bazel/issues/12424
1872             #
1873             # Once that issue is fixed and released, we can switch this to
1874             # `textual_hdrs` and remove the feature disabling the various Bazel
1875             # features (both current and under-development) that motivated the
1876             # distinction between these two.
1877             "lib/Target/" + target["name"] + "/*.def",
1878             "lib/Target/" + target["name"] + "/*.inc",
1879         ]),
1880         copts = llvm_copts,
1881         features = [
1882             "-parse_headers",
1883             "-header_modules",
1884         ],
1885         strip_include_prefix = "lib/Target/" + target["name"],
1886         deps = [
1887             ":BinaryFormat",
1888             # Depending on `:CodeGen` headers in this library is almost
1889             # certainly a layering problem in numerous targets.
1890             ":CodeGen",
1891             ":DebugInfoCodeView",
1892             ":MC",
1893             ":MCDisassembler",
1894             ":Support",
1895             ":Target",
1896             ":config",
1897             ":" + target["name"] + "CommonTableGen",
1898             ":" + target["name"] + "Info",
1899         ],
1900     )],
1901     [cc_library(
1902         name = target["name"] + "CodeGen",
1903         srcs = glob([
1904             "lib/Target/" + target["name"] + "/GISel/*.cpp",
1905             "lib/Target/" + target["name"] + "/GISel/*.h",
1906             "lib/Target/" + target["name"] + "/*.cpp",
1907             "lib/Target/" + target["name"] + "/*.h",
1908         ]),
1909         hdrs = ["lib/Target/" + target["name"] + "/" + target["short_name"] + ".h"],
1910         copts = llvm_copts,
1911         strip_include_prefix = "lib/Target/" + target["name"],
1912         textual_hdrs = glob([
1913             "lib/Target/" + target["name"] + "/*.def",
1914             "lib/Target/" + target["name"] + "/*.inc",
1915         ]),
1916         deps = [
1917             ":Analysis",
1918             ":BinaryFormat",
1919             ":CFGuard",
1920             ":CodeGen",
1921             ":Core",
1922             ":IPO",
1923             ":MC",
1924             ":Passes",  # TODO(chandlerc): Likely a layering violation.
1925             ":ProfileData",
1926             ":Scalar",
1927             ":Support",
1928             ":Target",
1929             ":TransformUtils",
1930             ":Vectorize",
1931             ":config",
1932             ":" + target["name"] + "CommonTableGen",
1933             ":" + target["name"] + "Info",
1934             ":" + target["name"] + "UtilsAndDesc",
1935         ],
1936     )],
1937     [cc_library(
1938         name = target["name"] + "AsmParser",
1939         srcs = glob([
1940             "lib/Target/" + target["name"] + "/AsmParser/*.cpp",
1941             "lib/Target/" + target["name"] + "/AsmParser/*.h",
1942         ]),
1943         copts = llvm_copts,
1944         deps = [
1945             ":BinaryFormat",
1946             ":MC",
1947             ":MCParser",
1948             ":Support",
1949             ":Target",
1950             ":" + target["name"] + "CodeGen",
1951             ":" + target["name"] + "CommonTableGen",
1952             ":" + target["name"] + "UtilsAndDesc",
1953         ],
1954     )],
1955     # This target is a bit of a hack to allow us to expose internal
1956     # disassembler header files via internal target-relative include paths.
1957     # This usage of headers is inherently non-modular as there is a mixture of
1958     # target-relative inclusion using this rule and same-directory inclusion
1959     # using the repeated listing of these headers in the `srcs` below.
1960     [cc_library(
1961         name = target["name"] + "DisassemblerInternalHeaders",
1962         # FIXME: This should be `textual_hdrs` instead of `hdrs`, but
1963         # unfortunately that doesn't work with `strip_include_prefix`:
1964         # https://github.com/bazelbuild/bazel/issues/12424
1965         #
1966         # Once that issue is fixed and released, we can switch this to
1967         # `textual_hdrs` and remove the feature disabling the various Bazel
1968         # features (both current and under-development) that motivated the
1969         # distinction between these two.
1970         hdrs = glob([
1971             "lib/Target/" + target["name"] + "/Disassembler/*.h",
1972         ]),
1973         features = [
1974             "-parse_headers",
1975             "-header_modules",
1976         ],
1977         strip_include_prefix = "lib/Target/" + target["name"],
1978     )],
1979     [cc_library(
1980         name = target["name"] + "Disassembler",
1981         srcs = glob([
1982             "lib/Target/" + target["name"] + "/Disassembler/*.cpp",
1983             "lib/Target/" + target["name"] + "/Disassembler/*.c",
1984             "lib/Target/" + target["name"] + "/Disassembler/*.h",
1985         ]),
1986         copts = llvm_copts,
1987         deps = [
1988             ":CodeGen",
1989             ":Core",
1990             ":MC",
1991             ":MCDisassembler",
1992             ":Support",
1993             ":Target",
1994             ":" + target["name"] + "CodeGen",
1995             ":" + target["name"] + "DisassemblerInternalHeaders",
1996             ":" + target["name"] + "CommonTableGen",
1997             ":" + target["name"] + "UtilsAndDesc",
1998         ],
1999     )],
2000     [cc_library(
2001         name = target["name"] + "TargetMCA",
2002         srcs = glob([
2003             "lib/Target/" + target["name"] + "/MCA/*.cpp",
2004             "lib/Target/" + target["name"] + "/MCA/*.c",
2005             "lib/Target/" + target["name"] + "/MCA/*.h",
2006         ]),
2007         copts = llvm_copts,
2008         deps = [
2009             ":MC",
2010             ":MCA",
2011             ":MCParser",
2012             ":Support",
2013             ":" + target["name"] + "DisassemblerInternalHeaders",
2014             ":" + target["name"] + "Info",
2015             ":" + target["name"] + "UtilsAndDesc",
2016         ],
2017     )],
2018 ] for target in llvm_target_lib_list]
2020 cc_library(
2021     name = "AllTargetsCodeGens",
2022     copts = llvm_copts,
2023     deps = [
2024         target["name"] + "CodeGen"
2025         for target in llvm_target_lib_list
2026     ],
2029 cc_library(
2030     name = "AllTargetsAsmParsers",
2031     copts = llvm_copts,
2032     deps = [
2033         target["name"] + "AsmParser"
2034         for target in llvm_target_lib_list
2035     ],
2038 cc_library(
2039     name = "AllTargetsDisassemblers",
2040     copts = llvm_copts,
2041     deps = [
2042         target["name"] + "Disassembler"
2043         for target in llvm_target_lib_list
2044     ],
2047 cc_library(
2048     name = "AllTargetsMCAs",
2049     copts = llvm_copts,
2050     deps = [
2051         target["name"] + "TargetMCA"
2052         for target in llvm_target_lib_list
2053     ],
2056 cc_library(
2057     name = "pass_registry_def",
2058     copts = llvm_copts,
2059     textual_hdrs = ["lib/Passes/PassRegistry.def"],
2062 cc_library(
2063     name = "MLPolicies",
2064     srcs = glob([
2065         "lib/Analysis/ML/*.cpp",
2066         "lib/Analysis/ML/*.h",
2067     ]),
2068     hdrs = glob([
2069         "include/llvm/Analysis/ML/*.h",
2070     ]),
2071     copts = llvm_copts,
2072     deps = [
2073         ":Analysis",
2074         ":Core",
2075         ":Support",
2076     ],
2079 cc_library(
2080     name = "Passes",
2081     srcs = glob([
2082         "lib/Passes/*.cpp",
2083         "lib/Passes/*.h",
2084     ]),
2085     hdrs = glob(["include/llvm/Passes/*.h"]) + ["include/llvm-c/Transforms/PassBuilder.h"],
2086     copts = llvm_copts,
2087     deps = [
2088         ":Analysis",
2089         ":CodeGen",
2090         ":Core",
2091         ":Coroutines",
2092         ":MLPolicies",
2093         ":Support",
2094         ":Target",
2095         ":TransformUtils",
2096         ":common_transforms",
2097         ":config",
2098         ":pass_registry_def",
2099     ],
2102 cc_library(
2103     name = "LTO",
2104     srcs = glob([
2105         "lib/LTO/*.cpp",
2106         "lib/LTO/*.h",
2107     ]),
2108     hdrs = glob([
2109         "include/llvm/LTO/*.h",
2110         "include/llvm/LTO/legacy/*.h",
2111     ]) + [
2112         "include/llvm-c/lto.h",
2113     ],
2114     copts = llvm_copts,
2115     deps = [
2116         ":Analysis",
2117         ":BitReader",
2118         ":BitWriter",
2119         ":CodeGen",
2120         ":Core",
2121         ":IRReader",
2122         ":Linker",
2123         ":MC",
2124         ":MCParser",
2125         ":Object",
2126         ":Passes",
2127         ":Support",
2128         ":Target",
2129         ":TransformUtils",
2130         ":common_transforms",
2131         ":config",
2132     ],
2135 cc_library(
2136     name = "ExecutionEngine",
2137     srcs = glob([
2138         "lib/ExecutionEngine/*.cpp",
2139         "lib/ExecutionEngine/*.h",
2140         "lib/ExecutionEngine/RuntimeDyld/*.cpp",
2141         "lib/ExecutionEngine/RuntimeDyld/*.h",
2142         "lib/ExecutionEngine/RuntimeDyld/Targets/*.cpp",
2143         "lib/ExecutionEngine/RuntimeDyld/Targets/*.h",
2144     ]),
2145     hdrs = glob(
2146         [
2147             "include/llvm/ExecutionEngine/*.h",
2148         ],
2149         exclude = [
2150             "include/llvm/ExecutionEngine/MCJIT*.h",
2151             "include/llvm/ExecutionEngine/OProfileWrapper.h",
2152         ],
2153     ) + [
2154         "include/llvm-c/ExecutionEngine.h",
2155     ],
2156     copts = llvm_copts,
2157     deps = [
2158         ":BinaryFormat",
2159         ":CodeGen",
2160         ":Core",
2161         ":DebugInfo",
2162         ":MC",
2163         ":MCDisassembler",
2164         ":Object",
2165         ":OrcTargetProcess",
2166         ":Passes",
2167         ":Support",
2168         ":Target",
2169         ":config",
2170     ],
2173 cc_library(
2174     name = "Interpreter",
2175     srcs = glob([
2176         "lib/ExecutionEngine/Interpreter/*.cpp",
2177         "lib/ExecutionEngine/Interpreter/*.h",
2178     ]),
2179     hdrs = ["include/llvm/ExecutionEngine/Interpreter.h"],
2180     copts = llvm_copts,
2181     deps = [
2182         ":CodeGen",
2183         ":Core",
2184         ":ExecutionEngine",
2185         ":Support",
2186         ":Target",
2187         ":config",
2188     ],
2191 cc_library(
2192     name = "JITLink",
2193     srcs = glob([
2194         "lib/ExecutionEngine/JITLink/*.cpp",
2195         "lib/ExecutionEngine/JITLink/*.h",
2196     ]),
2197     hdrs = glob([
2198         "include/llvm/ExecutionEngine/JITLink/*.h",
2199     ]),
2200     copts = llvm_copts,
2201     deps = [
2202         ":ExecutionEngine",
2203         ":Object",
2204         ":OrcTargetProcess",
2205         ":Support",
2206         ":config",
2207     ],
2210 cc_library(
2211     name = "MCJIT",
2212     srcs = glob([
2213         "lib/ExecutionEngine/MCJIT/*.cpp",
2214         "lib/ExecutionEngine/MCJIT/*.h",
2215     ]),
2216     hdrs = glob(["include/llvm/ExecutionEngine/MCJIT*.h"]),
2217     copts = llvm_copts,
2218     deps = [
2219         ":CodeGen",
2220         ":Core",
2221         ":ExecutionEngine",
2222         ":MC",
2223         ":Object",
2224         ":Support",
2225         ":Target",
2226         ":config",
2227     ],
2230 cc_library(
2231     name = "OrcJIT",
2232     srcs = glob([
2233         "lib/ExecutionEngine/Orc/*.cpp",
2234         "lib/ExecutionEngine/Orc/*.h",
2235     ]),
2236     hdrs = glob([
2237         "include/llvm/ExecutionEngine/Orc/*.h",
2238         "include/llvm/ExecutionEngine/Orc/RPC/*.h",
2239     ]) + [
2240         "include/llvm-c/LLJIT.h",
2241         "include/llvm-c/Orc.h",
2242         "include/llvm-c/OrcEE.h",
2243     ],
2244     copts = llvm_copts,
2245     deps = [
2246         ":BitReader",
2247         ":BitWriter",
2248         ":Core",
2249         ":ExecutionEngine",
2250         ":JITLink",
2251         ":MC",
2252         ":Object",
2253         ":OrcShared",
2254         ":OrcTargetProcess",
2255         ":Support",
2256         ":Target",
2257         ":TransformUtils",
2258         ":config",
2259     ],
2262 cc_library(
2263     name = "OrcShared",
2264     srcs = glob([
2265         "lib/ExecutionEngine/Orc/Shared/*.cpp",
2266     ]),
2267     hdrs = glob([
2268         "include/llvm/ExecutionEngine/Orc/Shared/*.h",
2269     ]),
2270     copts = llvm_copts,
2271     deps = [
2272         ":BinaryFormat",
2273         ":CodeGen",
2274         ":Core",
2275         ":DebugInfo",
2276         ":MC",
2277         ":MCDisassembler",
2278         ":Object",
2279         ":Passes",
2280         ":Support",
2281         ":Target",
2282         ":config",
2283     ],
2286 cc_library(
2287     name = "OrcTargetProcess",
2288     srcs = glob([
2289         "lib/ExecutionEngine/Orc/TargetProcess/*.cpp",
2290         "lib/ExecutionEngine/Orc/TargetProcess/*.h",
2291     ]),
2292     hdrs = glob([
2293         "include/llvm/ExecutionEngine/Orc/TargetProcess/*.h",
2294     ]),
2295     copts = llvm_copts,
2296     deps = [
2297         ":BinaryFormat",
2298         ":CodeGen",
2299         ":Core",
2300         ":DebugInfo",
2301         ":MC",
2302         ":MCDisassembler",
2303         ":Object",
2304         ":OrcShared",
2305         ":Passes",
2306         ":Support",
2307         ":Target",
2308         ":config",
2309     ],
2312 cc_library(
2313     name = "DWARFLinker",
2314     srcs = glob([
2315         "lib/DWARFLinker/*.cpp",
2316         "lib/DWARFLinker/*.h",
2317     ]),
2318     hdrs = glob(["include/llvm/DWARFLinker/*.h"]),
2319     copts = llvm_copts,
2320     deps = [
2321         ":CodeGen",
2322         ":DebugInfoDWARF",
2323         ":Support",
2324     ],
2327 gentbl(
2328     name = "DllOptionsTableGen",
2329     strip_include_prefix = "lib/ToolDrivers/llvm-dlltool",
2330     tbl_outs = [(
2331         "-gen-opt-parser-defs",
2332         "lib/ToolDrivers/llvm-dlltool/Options.inc",
2333     )],
2334     tblgen = ":llvm-tblgen",
2335     td_file = "lib/ToolDrivers/llvm-dlltool/Options.td",
2336     td_srcs = ["include/llvm/Option/OptParser.td"],
2339 cc_library(
2340     name = "DlltoolDriver",
2341     srcs = glob(["lib/ToolDrivers/llvm-dlltool/*.cpp"]),
2342     hdrs = glob(["include/llvm/ToolDrivers/llvm-dlltool/*.h"]),
2343     copts = llvm_copts,
2344     deps = [
2345         ":DllOptionsTableGen",
2346         ":Object",
2347         ":Option",
2348         ":Support",
2349     ],
2352 gentbl(
2353     name = "LibOptionsTableGen",
2354     strip_include_prefix = "lib/ToolDrivers/llvm-lib",
2355     tbl_outs = [(
2356         "-gen-opt-parser-defs",
2357         "lib/ToolDrivers/llvm-lib/Options.inc",
2358     )],
2359     tblgen = ":llvm-tblgen",
2360     td_file = "lib/ToolDrivers/llvm-lib/Options.td",
2361     td_srcs = ["include/llvm/Option/OptParser.td"],
2364 cc_library(
2365     name = "LibDriver",
2366     srcs = glob(["lib/ToolDrivers/llvm-lib/*.cpp"]),
2367     hdrs = glob(["include/llvm/ToolDrivers/llvm-lib/*.h"]),
2368     copts = llvm_copts,
2369     deps = [
2370         ":BinaryFormat",
2371         ":LibOptionsTableGen",
2372         ":Object",
2373         ":Option",
2374         ":Support",
2375     ],
2378 cc_library(
2379     name = "InterfaceStub",
2380     srcs = glob([
2381         "lib/InterfaceStub/*.cpp",
2382         "lib/InterfaceStub/*.h",
2383     ]),
2384     hdrs = glob([
2385         "include/llvm/InterfaceStub/*.h",
2386     ]),
2387     copts = llvm_copts,
2388     deps = [
2389         ":Object",
2390         ":Support",
2391         ":config",
2392     ],
2395 cc_library(
2396     name = "WindowsManifest",
2397     srcs = glob([
2398         "lib/WindowsManifest/*.cpp",
2399     ]),
2400     hdrs = glob([
2401         "include/llvm/WindowsManifest/*.h",
2402     ]),
2403     copts = llvm_copts,
2404     linkopts = [
2405         # Libxml2 is required to process Windows manifests. Without this,
2406         # lld uses Microsoft mt.exe instead, which is not cross-platform.
2407         "-lxml2",
2408     ],
2409     tags = [
2410         "manual",  # External dependency (libxml)
2411         "nobuildkite",  # TODO(gcmn): Fix remote execution and re-enable
2412     ],
2413     deps = [
2414         ":Support",
2415         ":config",
2416     ],
2419 # FIXME: This library should use `textual_hdrs` instead of `hdrs` as we don't
2420 # want to parse or build modules for them (and haven't duplicated the necessary
2421 # dependencies), but unfortunately that doesn't work with
2422 # `strip_include_prefix`: https://github.com/bazelbuild/bazel/issues/12424
2424 # For now, we simply disable features that might rely on the headers parsing.
2425 cc_library(
2426     name = "llvm-objcopy-headers",
2427     hdrs = glob(["tools/llvm-objcopy/**/*.h"]),
2428     features = [
2429         "-parse_headers",
2430         "-header_modules",
2431     ],
2432     strip_include_prefix = "tools/llvm-objcopy",
2435 cc_library(
2436     name = "MCA",
2437     srcs = glob([
2438         "lib/MCA/**/*.cpp",
2439         "lib/MCA/**/*.h",
2440     ]),
2441     hdrs = glob([
2442         "include/llvm/MCA/**/*.h",
2443     ]),
2444     copts = llvm_copts,
2445     deps = [
2446         ":MC",
2447         ":MCDisassembler",
2448         ":Object",
2449         ":Support",
2450     ],
2453 cc_library(
2454     name = "llvm-mca-headers",
2455     hdrs = glob([
2456         "tools/llvm-mca/*.h",
2457         "tools/llvm-mca/Views/*.h",
2458     ]),
2459     strip_include_prefix = "tools/llvm-mca",
2462 cc_library(
2463     name = "XRay",
2464     srcs = glob([
2465         "lib/XRay/*.cpp",
2466         "lib/XRay/*.h",
2467     ]),
2468     hdrs = glob(["include/llvm/XRay/*.h"]),
2469     copts = llvm_copts,
2470     deps = [
2471         ":Object",
2472         ":Support",
2473     ],
2476 cc_library(
2477     name = "Exegesis",
2478     srcs = glob([
2479         "tools/llvm-exegesis/lib/*.cpp",
2480         "tools/llvm-exegesis/lib/X86/*.cpp",
2481         "tools/llvm-exegesis/lib/X86/*.h",
2482         # We have to include these headers here as well as in the `hdrs` below
2483         # to allow the `.cpp` files to use file-relative-inclusion to find
2484         # them, even though consumers of this library use inclusion relative to
2485         # `tools/llvm-exegesis/lib` with the `strip_includes_prefix` of this
2486         # library. This mixture appears to be incompatible with header modules.
2487         "tools/llvm-exegesis/lib/*.h",
2488     ]),
2489     hdrs = glob(["tools/llvm-exegesis/lib/*.h"]),
2490     copts = llvm_copts + ["-DHAVE_LIBPFM=1"],
2491     defines = ["LLVM_EXEGESIS_INITIALIZE_NATIVE_TARGET=InitializeX86ExegesisTarget"],
2492     features = ["-header_modules"],
2493     strip_include_prefix = "tools/llvm-exegesis/lib",
2494     tags = [
2495         "manual",  # External dependency (libpfm4)
2496         "nobuildkite",  # TODO(chandlerc): Add support for fetching and building libpfm4 and enable this.
2497     ],
2498     deps = [
2499         ":AllTargetsAsmParsers",
2500         ":AllTargetsCodeGens",
2501         ":CodeGen",
2502         ":Core",
2503         ":ExecutionEngine",
2504         ":MC",
2505         ":MCDisassembler",
2506         ":MCJIT",
2507         ":Object",
2508         ":ObjectYAML",
2509         ":Support",
2510         ":Target",
2511         ":config",
2512     ],
2515 ################################################################################
2516 # LLVM toolchain and development binaries
2518 gentbl(
2519     name = "DsymutilTableGen",
2520     strip_include_prefix = "tools/dsymutil",
2521     tbl_outs = [(
2522         "-gen-opt-parser-defs",
2523         "tools/dsymutil/Options.inc",
2524     )],
2525     tblgen = ":llvm-tblgen",
2526     td_file = "tools/dsymutil/Options.td",
2527     td_srcs = ["include/llvm/Option/OptParser.td"],
2530 cc_binary(
2531     name = "dsymutil",
2532     srcs = glob([
2533         "tools/dsymutil/*.cpp",
2534         "tools/dsymutil/*.h",
2535     ]),
2536     copts = llvm_copts,
2537     stamp = 0,
2538     deps = [
2539         ":AllTargetsCodeGens",
2540         ":BinaryFormat",
2541         ":CodeGen",
2542         ":DWARFLinker",
2543         ":DebugInfo",
2544         ":DebugInfoDWARF",
2545         ":DsymutilTableGen",
2546         ":MC",
2547         ":Object",
2548         ":Option",
2549         ":Support",
2550         ":Target",
2551         ":config",
2552         ":remark_linker",
2553     ],
2556 cc_binary(
2557     name = "llc",
2558     srcs = glob([
2559         "tools/llc/*.cpp",
2560         "tools/llc/*.h",
2561     ]),
2562     copts = llvm_copts,
2563     stamp = 0,
2564     deps = [
2565         ":AllTargetsAsmParsers",
2566         ":AllTargetsCodeGens",
2567         ":Analysis",
2568         ":AsmParser",
2569         ":BitReader",
2570         ":CodeGen",
2571         ":Core",
2572         ":IRReader",
2573         ":MC",
2574         ":Support",
2575         ":Target",
2576         ":TransformUtils",
2577     ],
2580 cc_binary(
2581     name = "lli",
2582     srcs = glob([
2583         "tools/lli/*.cpp",
2584         "tools/lli/*.h",
2585     ]),
2586     copts = llvm_copts,
2587     # ll scripts rely on symbols from dependent
2588     # libraries being resolvable.
2589     linkopts = select({
2590         "@bazel_tools//src/conditions:windows": [],
2591         "@bazel_tools//src/conditions:darwin": [],
2592         "//conditions:default": [
2593             "-Wl,--undefined=_ZTIi",
2594             "-Wl,--export-dynamic-symbol=_ZTIi",
2595             "-Wl,--export-dynamic-symbol=__cxa_begin_catch",
2596             "-Wl,--export-dynamic-symbol=__cxa_end_catch",
2597             "-Wl,--export-dynamic-symbol=__gxx_personality_v0",
2598             "-Wl,--export-dynamic-symbol=__cxa_allocate_exception",
2599             "-Wl,--export-dynamic-symbol=__cxa_throw",
2600             "-Wl,--export-dynamic-symbol=llvm_orc_registerJITLoaderGDBWrapper",
2601             "-Wl,--export-dynamic-symbol=llvm_orc_registerEHFrameSectionWrapper",
2602             "-Wl,--export-dynamic-symbol=llvm_orc_deregisterEHFrameSectionWrapper",
2603         ],
2604     }),
2605     stamp = 0,
2606     deps = [
2607         ":AllTargetsAsmParsers",
2608         ":AllTargetsCodeGens",
2609         ":AsmParser",
2610         ":BitReader",
2611         ":CodeGen",
2612         ":Core",
2613         ":ExecutionEngine",
2614         ":IRReader",
2615         ":Instrumentation",
2616         ":Interpreter",
2617         ":MCJIT",
2618         ":Object",
2619         ":OrcJIT",
2620         ":Support",
2621         ":config",
2622     ],
2625 cc_binary(
2626     name = "llvm-ar",
2627     srcs = glob([
2628         "tools/llvm-ar/*.cpp",
2629         "tools/llvm-ar/*.h",
2630     ]),
2631     copts = llvm_copts,
2632     stamp = 0,
2633     deps = [
2634         ":AllTargetsAsmParsers",
2635         ":AllTargetsCodeGens",
2636         ":Core",
2637         ":DlltoolDriver",
2638         ":LibDriver",
2639         ":Object",
2640         ":Support",
2641     ],
2644 # We need to run llvm-ar with different basenames to make it run with
2645 # different behavior.
2646 binary_alias(
2647     name = "llvm-dlltool",
2648     binary = ":llvm-ar",
2651 binary_alias(
2652     name = "llvm-lib",
2653     binary = ":llvm-ar",
2656 binary_alias(
2657     name = "llvm-ranlib",
2658     binary = ":llvm-ar",
2661 cc_binary(
2662     name = "llvm-as",
2663     srcs = glob([
2664         "tools/llvm-as/*.cpp",
2665         "tools/llvm-as/*.h",
2666     ]),
2667     copts = llvm_copts,
2668     stamp = 0,
2669     deps = [
2670         ":Analysis",
2671         ":AsmParser",
2672         ":BitWriter",
2673         ":Core",
2674         ":Support",
2675     ],
2678 cc_binary(
2679     name = "llvm-bcanalyzer",
2680     srcs = glob([
2681         "tools/llvm-bcanalyzer/*.cpp",
2682         "tools/llvm-bcanalyzer/*.h",
2683     ]),
2684     copts = llvm_copts,
2685     stamp = 0,
2686     deps = [
2687         ":BitReader",
2688         ":Support",
2689     ],
2692 cc_binary(
2693     name = "llvm-cat",
2694     srcs = glob([
2695         "tools/llvm-cat/*.cpp",
2696     ]),
2697     copts = llvm_copts,
2698     stamp = 0,
2699     deps = [
2700         ":BitReader",
2701         ":BitWriter",
2702         ":Core",
2703         ":IRReader",
2704         ":Support",
2705     ],
2708 cc_binary(
2709     name = "llvm-cfi-verify",
2710     srcs = glob([
2711         "tools/llvm-cfi-verify/*.cpp",
2712         "tools/llvm-cfi-verify/lib/*.cpp",
2713         "tools/llvm-cfi-verify/lib/*.h",
2714     ]),
2715     copts = llvm_copts,
2716     stamp = 0,
2717     deps = [
2718         ":AllTargetsAsmParsers",
2719         ":AllTargetsCodeGens",
2720         ":AllTargetsDisassemblers",
2721         ":BinaryFormat",
2722         ":DebugInfoDWARF",
2723         ":MC",
2724         ":MCDisassembler",
2725         ":MCParser",
2726         ":Object",
2727         ":Support",
2728         ":Symbolize",
2729     ],
2732 cc_binary(
2733     name = "llvm-cov",
2734     srcs = glob([
2735         "tools/llvm-cov/*.cpp",
2736         "tools/llvm-cov/*.h",
2737     ]),
2738     copts = llvm_copts,
2739     stamp = 0,
2740     deps = [
2741         ":Coverage",
2742         ":Instrumentation",
2743         ":Object",
2744         ":ProfileData",
2745         ":Support",
2746     ],
2749 gentbl(
2750     name = "CvtResTableGen",
2751     strip_include_prefix = "tools/llvm-cvtres",
2752     tbl_outs = [(
2753         "-gen-opt-parser-defs",
2754         "tools/llvm-cvtres/Opts.inc",
2755     )],
2756     tblgen = ":llvm-tblgen",
2757     td_file = "tools/llvm-cvtres/Opts.td",
2758     td_srcs = ["include/llvm/Option/OptParser.td"],
2761 cc_binary(
2762     name = "llvm-cvtres",
2763     srcs = glob([
2764         "tools/llvm-cvtres/*.cpp",
2765         "tools/llvm-cvtres/*.h",
2766     ]),
2767     copts = llvm_copts,
2768     stamp = 0,
2769     deps = [
2770         ":CvtResTableGen",
2771         ":Object",
2772         ":Option",
2773         ":Support",
2774     ],
2777 cc_binary(
2778     name = "llvm-cxxdump",
2779     srcs = glob([
2780         "tools/llvm-cxxdump/*.cpp",
2781         "tools/llvm-cxxdump/*.h",
2782     ]),
2783     copts = llvm_copts,
2784     stamp = 0,
2785     deps = [
2786         ":AllTargetsCodeGens",
2787         ":BitReader",
2788         ":Object",
2789         ":Support",
2790     ],
2793 cc_binary(
2794     name = "llvm-cxxmap",
2795     srcs = glob([
2796         "tools/llvm-cxxmap/*.cpp",
2797         "tools/llvm-cxxmap/*.h",
2798     ]),
2799     copts = llvm_copts,
2800     stamp = 0,
2801     deps = [
2802         ":Support",
2803     ],
2806 gentbl(
2807     name = "CxxfiltOptsTableGen",
2808     strip_include_prefix = "tools/llvm-cxxfilt",
2809     tbl_outs = [(
2810         "-gen-opt-parser-defs",
2811         "tools/llvm-cxxfilt/Opts.inc",
2812     )],
2813     tblgen = ":llvm-tblgen",
2814     td_file = "tools/llvm-cxxfilt/Opts.td",
2815     td_srcs = ["include/llvm/Option/OptParser.td"],
2818 cc_binary(
2819     name = "llvm-cxxfilt",
2820     srcs = glob([
2821         "tools/llvm-cxxfilt/*.cpp",
2822         "tools/llvm-cxxfilt/*.h",
2823     ]),
2824     copts = llvm_copts,
2825     stamp = 0,
2826     deps = [
2827         ":CxxfiltOptsTableGen",
2828         ":Demangle",
2829         ":Option",
2830         ":Support",
2831     ],
2834 cc_binary(
2835     name = "llvm-dis",
2836     srcs = glob([
2837         "tools/llvm-dis/*.cpp",
2838         "tools/llvm-dis/*.h",
2839     ]),
2840     copts = llvm_copts,
2841     stamp = 0,
2842     deps = [
2843         ":Analysis",
2844         ":BitReader",
2845         ":Core",
2846         ":Support",
2847     ],
2850 cc_binary(
2851     name = "llvm-dwarfdump",
2852     srcs = glob([
2853         "tools/llvm-dwarfdump/*.cpp",
2854         "tools/llvm-dwarfdump/*.h",
2855     ]),
2856     copts = llvm_copts,
2857     stamp = 0,
2858     deps = [
2859         ":AllTargetsCodeGens",
2860         ":BinaryFormat",
2861         ":DebugInfo",
2862         ":DebugInfoDWARF",
2863         ":MC",
2864         ":Object",
2865         ":Support",
2866     ],
2869 cc_binary(
2870     name = "llvm-dwp",
2871     srcs = glob([
2872         "tools/llvm-dwp/*.cpp",
2873         "tools/llvm-dwp/*.h",
2874     ]),
2875     copts = llvm_copts,
2876     stamp = 0,
2877     deps = [
2878         ":AllTargetsCodeGens",
2879         ":DWP",
2880         ":MC",
2881         ":Support",
2882     ],
2885 cc_binary(
2886     name = "llvm-exegesis",
2887     srcs = [
2888         "tools/llvm-exegesis/llvm-exegesis.cpp",
2889     ],
2890     copts = llvm_copts + ["-DHAVE_LIBPFM=0"],
2891     linkopts = ["-lpfm"],
2892     stamp = 0,
2893     tags = [
2894         "manual",  # External dependency (libpfm4 through Exegesis)
2895         "nobuildkite",  # TODO(chandlerc): Enable when the library builds.
2896     ],
2897     deps = [
2898         ":AllTargetsAsmParsers",
2899         ":AllTargetsCodeGens",
2900         ":AllTargetsDisassemblers",
2901         ":Exegesis",
2902         ":MC",
2903         ":MCParser",
2904         ":Object",
2905         ":Support",
2906         ":config",
2907     ],
2910 cc_binary(
2911     name = "llvm-extract",
2912     srcs = glob([
2913         "tools/llvm-extract/*.cpp",
2914         "tools/llvm-extract/*.h",
2915     ]),
2916     copts = llvm_copts,
2917     stamp = 0,
2918     deps = [
2919         ":AsmParser",
2920         ":BitReader",
2921         ":BitWriter",
2922         ":Core",
2923         ":IPO",
2924         ":IRReader",
2925         ":Support",
2926     ],
2929 cc_binary(
2930     name = "llvm-ifs",
2931     srcs = glob([
2932         "tools/llvm-ifs/*.cpp",
2933         "tools/llvm-ifs/*.h",
2934     ]),
2935     copts = llvm_copts,
2936     stamp = 0,
2937     deps = [
2938         ":InterfaceStub",
2939         ":ObjectYAML",
2940         ":Support",
2941         ":TextAPI",
2942     ],
2945 cc_binary(
2946     name = "llvm-jitlink",
2947     srcs = glob([
2948         "tools/llvm-jitlink/*.cpp",
2949         "tools/llvm-jitlink/*.h",
2950     ]),
2951     copts = llvm_copts,
2952     # Make symbols from the standard library dynamically resolvable.
2953     linkopts = select({
2954         "@bazel_tools//src/conditions:windows": [],
2955         "@bazel_tools//src/conditions:darwin": [],
2956         "//conditions:default": [
2957             "-Wl,--undefined=_ZTIi",
2958             "-Wl,--export-dynamic-symbol=_ZTIi",
2959             "-Wl,--export-dynamic-symbol=__cxa_begin_catch",
2960             "-Wl,--export-dynamic-symbol=__cxa_end_catch",
2961             "-Wl,--export-dynamic-symbol=__gxx_personality_v0",
2962             "-Wl,--export-dynamic-symbol=__cxa_allocate_exception",
2963             "-Wl,--export-dynamic-symbol=__cxa_throw",
2964             "-Wl,--export-dynamic-symbol=llvm_orc_registerJITLoaderGDBWrapper",
2965         ],
2966     }),
2967     stamp = 0,
2968     deps = [
2969         ":AllTargetsAsmParsers",
2970         ":AllTargetsCodeGens",
2971         ":AllTargetsDisassemblers",
2972         ":AsmParser",
2973         ":BitReader",
2974         ":CodeGen",
2975         ":ExecutionEngine",
2976         ":MCJIT",
2977         ":Object",
2978         ":OrcJIT",
2979         ":Support",
2980         ":config",
2981     ],
2984 cc_binary(
2985     name = "llvm-libtool-darwin",
2986     srcs = glob([
2987         "tools/llvm-libtool-darwin/*.cpp",
2988         "tools/llvm-libtool-darwin/*.h",
2989     ]),
2990     copts = llvm_copts,
2991     stamp = 0,
2992     deps = [
2993         ":BinaryFormat",
2994         ":Object",
2995         ":Support",
2996     ],
2999 cc_binary(
3000     name = "llvm-link",
3001     srcs = glob([
3002         "tools/llvm-link/*.cpp",
3003         "tools/llvm-link/*.h",
3004     ]),
3005     copts = llvm_copts,
3006     stamp = 0,
3007     deps = [
3008         ":AsmParser",
3009         ":BitReader",
3010         ":BitWriter",
3011         ":Core",
3012         ":IPO",
3013         ":IRReader",
3014         ":Linker",
3015         ":Object",
3016         ":Support",
3017         ":TransformUtils",
3018     ],
3021 gentbl(
3022     name = "LipoOptsTableGen",
3023     strip_include_prefix = "tools/llvm-lipo",
3024     tbl_outs = [(
3025         "-gen-opt-parser-defs",
3026         "tools/llvm-lipo/LipoOpts.inc",
3027     )],
3028     tblgen = ":llvm-tblgen",
3029     td_file = "tools/llvm-lipo/LipoOpts.td",
3030     td_srcs = ["include/llvm/Option/OptParser.td"],
3033 cc_binary(
3034     name = "llvm-lipo",
3035     srcs = [
3036         "tools/llvm-lipo/llvm-lipo.cpp",
3037     ],
3038     copts = llvm_copts,
3039     stamp = 0,
3040     deps = [
3041         ":LipoOptsTableGen",
3042         ":Object",
3043         ":Option",
3044         ":Support",
3045     ],
3048 cc_binary(
3049     name = "llvm-lto",
3050     srcs = glob([
3051         "tools/llvm-lto/*.cpp",
3052         "tools/llvm-lto/*.h",
3053     ]),
3054     copts = llvm_copts,
3055     stamp = 0,
3056     deps = [
3057         ":AllTargetsAsmParsers",
3058         ":AllTargetsCodeGens",
3059         ":BitReader",
3060         ":BitWriter",
3061         ":CodeGen",
3062         ":Core",
3063         ":IRReader",
3064         ":LTO",
3065         ":Support",
3066         ":Target",
3067     ],
3070 cc_binary(
3071     name = "llvm-lto2",
3072     srcs = glob([
3073         "tools/llvm-lto2/*.cpp",
3074         "tools/llvm-lto2/*.h",
3075     ]),
3076     copts = llvm_copts,
3077     stamp = 0,
3078     deps = [
3079         ":AllTargetsAsmParsers",
3080         ":AllTargetsCodeGens",
3081         ":BitReader",
3082         ":CodeGen",
3083         ":Core",
3084         ":LTO",
3085         ":Support",
3086     ],
3089 cc_binary(
3090     name = "llvm-mc",
3091     srcs = glob([
3092         "tools/llvm-mc/*.cpp",
3093         "tools/llvm-mc/*.h",
3094     ]),
3095     copts = llvm_copts,
3096     stamp = 0,
3097     deps = [
3098         ":AllTargetsAsmParsers",
3099         ":AllTargetsCodeGens",
3100         ":AllTargetsDisassemblers",
3101         ":MC",
3102         ":MCDisassembler",
3103         ":MCParser",
3104         ":Object",
3105         ":Support",
3106     ],
3109 cc_binary(
3110     name = "llvm-mca",
3111     srcs = glob([
3112         "tools/llvm-mca/*.cpp",
3113         "tools/llvm-mca/*.h",
3114         "tools/llvm-mca/Views/*.cpp",
3115         "tools/llvm-mca/Views/*.h",
3116     ]),
3117     copts = llvm_copts,
3118     stamp = 0,
3119     deps = [
3120         ":AllTargetsAsmParsers",
3121         ":AllTargetsCodeGens",
3122         ":AllTargetsDisassemblers",
3123         ":AllTargetsMCAs",
3124         ":MC",
3125         ":MCA",
3126         ":MCParser",
3127         ":Support",
3128         ":llvm-mca-headers",
3129     ],
3132 gentbl(
3133     name = "MlTableGen",
3134     strip_include_prefix = "tools/llvm-ml",
3135     tbl_outs = [(
3136         "-gen-opt-parser-defs",
3137         "tools/llvm-ml/Opts.inc",
3138     )],
3139     tblgen = ":llvm-tblgen",
3140     td_file = "tools/llvm-ml/Opts.td",
3141     td_srcs = ["include/llvm/Option/OptParser.td"],
3144 cc_binary(
3145     name = "llvm-ml",
3146     srcs = glob([
3147         "tools/llvm-ml/*.cpp",
3148         "tools/llvm-ml/*.h",
3149     ]),
3150     copts = llvm_copts,
3151     stamp = 0,
3152     deps = [
3153         ":AllTargetsAsmParsers",
3154         ":AllTargetsCodeGens",
3155         ":AllTargetsDisassemblers",
3156         ":MC",
3157         ":MCParser",
3158         ":MlTableGen",
3159         ":Option",
3160         ":Support",
3161     ],
3164 cc_binary(
3165     name = "llvm-modextract",
3166     srcs = glob([
3167         "tools/llvm-modextract/*.cpp",
3168     ]),
3169     copts = llvm_copts,
3170     stamp = 0,
3171     deps = [
3172         ":BitReader",
3173         ":BitWriter",
3174         ":IRReader",
3175         ":Support",
3176     ],
3179 gentbl(
3180     name = "MtTableGen",
3181     strip_include_prefix = "tools/llvm-mt",
3182     tbl_outs = [(
3183         "-gen-opt-parser-defs",
3184         "tools/llvm-mt/Opts.inc",
3185     )],
3186     tblgen = ":llvm-tblgen",
3187     td_file = "tools/llvm-mt/Opts.td",
3188     td_srcs = ["include/llvm/Option/OptParser.td"],
3191 cc_binary(
3192     name = "llvm-mt",
3193     srcs = glob([
3194         "tools/llvm-mt/*.cpp",
3195         "tools/llvm-mt/*.h",
3196     ]),
3197     copts = llvm_copts,
3198     stamp = 0,
3199     tags = [
3200         "manual",  # TODO(gcmn): External dependency (through WindowsManifest)
3201         "nobuildkite",  # TODO(gcmn): Re-enable when WindowsManifest builds
3202     ],
3203     deps = [
3204         ":MtTableGen",
3205         ":Option",
3206         ":Support",
3207         ":WindowsManifest",
3208     ],
3211 gentbl(
3212     name = "NmOptsTableGen",
3213     strip_include_prefix = "tools/llvm-nm",
3214     tbl_outs = [(
3215         "-gen-opt-parser-defs",
3216         "tools/llvm-nm/Opts.inc",
3217     )],
3218     tblgen = ":llvm-tblgen",
3219     td_file = "tools/llvm-nm/Opts.td",
3220     td_srcs = ["include/llvm/Option/OptParser.td"],
3223 cc_binary(
3224     name = "llvm-nm",
3225     srcs = glob([
3226         "tools/llvm-nm/*.cpp",
3227         "tools/llvm-nm/*.h",
3228     ]),
3229     copts = llvm_copts,
3230     stamp = 0,
3231     deps = [
3232         ":AllTargetsAsmParsers",
3233         ":AllTargetsCodeGens",
3234         ":BinaryFormat",
3235         ":BitReader",
3236         ":Core",
3237         ":Demangle",
3238         ":NmOptsTableGen",
3239         ":Object",
3240         ":Option",
3241         ":Support",
3242     ],
3245 gentbl(
3246     name = "llvm-objcopy-opts",
3247     strip_include_prefix = "tools/llvm-objcopy",
3248     tbl_outs = [(
3249         "-gen-opt-parser-defs",
3250         "tools/llvm-objcopy/ObjcopyOpts.inc",
3251     )],
3252     tblgen = ":llvm-tblgen",
3253     td_file = "tools/llvm-objcopy/ObjcopyOpts.td",
3254     td_srcs = [
3255         "include/llvm/Option/OptParser.td",
3256         "tools/llvm-objcopy/CommonOpts.td",
3257     ],
3260 gentbl(
3261     name = "llvm-installnametool-opts",
3262     strip_include_prefix = "tools/llvm-objcopy",
3263     tbl_outs = [(
3264         "-gen-opt-parser-defs",
3265         "tools/llvm-objcopy/InstallNameToolOpts.inc",
3266     )],
3267     tblgen = ":llvm-tblgen",
3268     td_file = "tools/llvm-objcopy/InstallNameToolOpts.td",
3269     td_srcs = [
3270         "include/llvm/Option/OptParser.td",
3271         "tools/llvm-objcopy/CommonOpts.td",
3272     ],
3275 gentbl(
3276     name = "llvm-strip-opts",
3277     strip_include_prefix = "tools/llvm-objcopy",
3278     tbl_outs = [(
3279         "-gen-opt-parser-defs",
3280         "tools/llvm-objcopy/StripOpts.inc",
3281     )],
3282     tblgen = ":llvm-tblgen",
3283     td_file = "tools/llvm-objcopy/StripOpts.td",
3284     td_srcs = [
3285         "include/llvm/Option/OptParser.td",
3286         "tools/llvm-objcopy/CommonOpts.td",
3287     ],
3290 gentbl(
3291     name = "llvm-bitcode-strip-opts",
3292     strip_include_prefix = "tools/llvm-objcopy",
3293     tbl_outs = [(
3294         "-gen-opt-parser-defs",
3295         "tools/llvm-objcopy/BitcodeStripOpts.inc",
3296     )],
3297     tblgen = ":llvm-tblgen",
3298     td_file = "tools/llvm-objcopy/BitcodeStripOpts.td",
3299     td_srcs = [
3300         "include/llvm/Option/OptParser.td",
3301         "tools/llvm-objcopy/CommonOpts.td",
3302     ],
3305 cc_binary(
3306     name = "llvm-stress",
3307     srcs = glob([
3308         "tools/llvm-stress/*.cpp",
3309         "tools/llvm-stress/*.h",
3310     ]),
3311     copts = llvm_copts,
3312     stamp = 0,
3313     deps = [
3314         ":Core",
3315         ":Support",
3316     ],
3319 cc_binary(
3320     name = "llvm-objcopy",
3321     srcs = glob([
3322         "tools/llvm-objcopy/**/*.cpp",
3323         # Note that we redundantly include the headers here to allow files to
3324         # include same-directory headers in addition to including headers via
3325         # the `llvm-objcopy-headers` rule's stripped include prefix.
3326         "tools/llvm-objcopy/**/*.h",
3327     ]),
3328     copts = llvm_copts,
3329     stamp = 0,
3330     deps = [
3331         ":BinaryFormat",
3332         ":MC",
3333         ":Object",
3334         ":ObjectYAML",
3335         ":Option",
3336         ":Support",
3337         ":Target",
3338         ":llvm-bitcode-strip-opts",
3339         ":llvm-installnametool-opts",
3340         ":llvm-objcopy-headers",
3341         ":llvm-objcopy-opts",
3342         ":llvm-strip-opts",
3343     ],
3346 binary_alias(
3347     name = "llvm-strip",
3348     binary = ":llvm-objcopy",
3351 binary_alias(
3352     name = "llvm-bitcode-strip",
3353     binary = ":llvm-objcopy",
3356 binary_alias(
3357     name = "llvm-install-name-tool",
3358     binary = ":llvm-objcopy",
3361 cc_binary(
3362     name = "llvm-objdump",
3363     srcs = glob([
3364         "tools/llvm-objdump/*.cpp",
3365         "tools/llvm-objdump/*.h",
3366     ]),
3367     copts = llvm_copts,
3368     stamp = 0,
3369     deps = [
3370         ":AllTargetsAsmParsers",
3371         ":AllTargetsCodeGens",
3372         ":AllTargetsDisassemblers",
3373         ":BinaryFormat",
3374         ":CodeGen",
3375         ":DebugInfo",
3376         ":DebugInfoDWARF",
3377         ":Demangle",
3378         ":MC",
3379         ":MCDisassembler",
3380         ":ObjdumpOptsTableGen",
3381         ":Object",
3382         ":Option",
3383         ":OtoolOptsTableGen",
3384         ":Support",
3385         ":Symbolize",
3386         ":config",
3387     ],
3390 gentbl(
3391     name = "ObjdumpOptsTableGen",
3392     strip_include_prefix = "tools/llvm-objdump",
3393     tbl_outs = [(
3394         "-gen-opt-parser-defs",
3395         "tools/llvm-objdump/ObjdumpOpts.inc",
3396     )],
3397     tblgen = ":llvm-tblgen",
3398     td_file = "tools/llvm-objdump/ObjdumpOpts.td",
3399     td_srcs = ["include/llvm/Option/OptParser.td"],
3402 binary_alias(
3403     name = "llvm-otool",
3404     binary = ":llvm-objdump",
3407 gentbl(
3408     name = "OtoolOptsTableGen",
3409     strip_include_prefix = "tools/llvm-objdump",
3410     tbl_outs = [(
3411         "-gen-opt-parser-defs",
3412         "tools/llvm-objdump/OtoolOpts.inc",
3413     )],
3414     tblgen = ":llvm-tblgen",
3415     td_file = "tools/llvm-objdump/OtoolOpts.td",
3416     td_srcs = ["include/llvm/Option/OptParser.td"],
3419 cc_binary(
3420     name = "llvm-opt-report",
3421     srcs = glob([
3422         "tools/llvm-opt-report/*.cpp",
3423     ]),
3424     copts = llvm_copts,
3425     stamp = 0,
3426     deps = [
3427         ":AllTargetsCodeGens",
3428         ":Demangle",
3429         ":Remarks",
3430         ":Support",
3431     ],
3434 cc_binary(
3435     name = "llvm-pdbutil",
3436     srcs = glob([
3437         "tools/llvm-pdbutil/*.cpp",
3438         "tools/llvm-pdbutil/*.h",
3439     ]),
3440     copts = llvm_copts,
3441     stamp = 0,
3442     deps = [
3443         ":BinaryFormat",
3444         ":DebugInfoCodeView",
3445         ":DebugInfoMSF",
3446         ":DebugInfoPDB",
3447         ":Object",
3448         ":ObjectYAML",
3449         ":Support",
3450         ":config",
3451     ],
3454 cc_binary(
3455     name = "llvm-profdata",
3456     srcs = glob([
3457         "tools/llvm-profdata/*.cpp",
3458         "tools/llvm-profdata/*.h",
3459     ]),
3460     copts = llvm_copts,
3461     stamp = 0,
3462     deps = [
3463         ":Core",
3464         ":ProfileData",
3465         ":Support",
3466     ],
3469 cc_binary(
3470     name = "llvm-profgen",
3471     srcs = glob([
3472         "tools/llvm-profgen/*.cpp",
3473         "tools/llvm-profgen/*.h",
3474     ]),
3475     copts = llvm_copts,
3476     stamp = 0,
3477     deps = [
3478         ":AllTargetsCodeGens",
3479         ":AllTargetsDisassemblers",
3480         ":Symbolize",
3481     ],
3484 gentbl(
3485     name = "RcTableGen",
3486     strip_include_prefix = "tools/llvm-rc",
3487     tbl_outs = [(
3488         "-gen-opt-parser-defs",
3489         "tools/llvm-rc/Opts.inc",
3490     )],
3491     tblgen = ":llvm-tblgen",
3492     td_file = "tools/llvm-rc/Opts.td",
3493     td_srcs = ["include/llvm/Option/OptParser.td"],
3496 gentbl(
3497     name = "WindresTableGen",
3498     strip_include_prefix = "tools/llvm-rc",
3499     tbl_outs = [(
3500         "-gen-opt-parser-defs",
3501         "tools/llvm-rc/WindresOpts.inc",
3502     )],
3503     tblgen = ":llvm-tblgen",
3504     td_file = "tools/llvm-rc/WindresOpts.td",
3505     td_srcs = ["include/llvm/Option/OptParser.td"],
3508 # Workaround inability to put `.def` files into `srcs` with a library.
3509 cc_library(
3510     name = "llvm-rc-defs-lib",
3511     textual_hdrs = glob(["tools/llvm-rc/*.def"]),
3514 cc_binary(
3515     name = "llvm-rc",
3516     srcs = glob([
3517         "tools/llvm-rc/*.cpp",
3518         "tools/llvm-rc/*.h",
3519     ]),
3520     copts = llvm_copts,
3521     stamp = 0,
3522     deps = [
3523         ":Object",
3524         ":Option",
3525         ":RcTableGen",
3526         ":Support",
3527         ":WindresTableGen",
3528         ":llvm-rc-defs-lib",
3529     ],
3532 binary_alias(
3533     name = "llvm-windres",
3534     binary = ":llvm-rc",
3537 gentbl(
3538     name = "ReadobjOptsTableGen",
3539     strip_include_prefix = "tools/llvm-readobj",
3540     tbl_outs = [(
3541         "-gen-opt-parser-defs",
3542         "tools/llvm-readobj/Opts.inc",
3543     )],
3544     tblgen = ":llvm-tblgen",
3545     td_file = "tools/llvm-readobj/Opts.td",
3546     td_srcs = ["include/llvm/Option/OptParser.td"],
3549 cc_binary(
3550     name = "llvm-readobj",
3551     srcs = glob([
3552         "tools/llvm-readobj/*.cpp",
3553         "tools/llvm-readobj/*.h",
3554     ]),
3555     copts = llvm_copts,
3556     stamp = 0,
3557     deps = [
3558         ":AllTargetsCodeGens",
3559         ":BinaryFormat",
3560         ":BitReader",
3561         ":DebugInfoCodeView",
3562         ":DebugInfoDWARF",
3563         ":Demangle",
3564         ":Object",
3565         ":Option",
3566         ":ReadobjOptsTableGen",
3567         ":Support",
3568     ],
3571 # Create an 'llvm-readelf' named binary from the 'llvm-readobj' tool.
3572 binary_alias(
3573     name = "llvm-readelf",
3574     binary = ":llvm-readobj",
3577 cc_binary(
3578     name = "llvm-reduce",
3579     srcs = glob([
3580         "tools/llvm-reduce/**/*.cpp",
3581         "tools/llvm-reduce/**/*.h",
3582     ]),
3583     copts = llvm_copts,
3584     includes = ["tools/llvm-reduce"],
3585     stamp = 0,
3586     deps = [
3587         ":AllTargetsAsmParsers",
3588         ":AllTargetsCodeGens",
3589         ":BitReader",
3590         ":Core",
3591     ],
3594 cc_binary(
3595     name = "llvm-rtdyld",
3596     srcs = glob([
3597         "tools/llvm-rtdyld/*.cpp",
3598         "tools/llvm-rtdyld/*.h",
3599     ]),
3600     copts = llvm_copts,
3601     stamp = 0,
3602     deps = [
3603         ":AllTargetsCodeGens",
3604         ":AllTargetsDisassemblers",
3605         ":DebugInfo",
3606         ":DebugInfoDWARF",
3607         ":ExecutionEngine",
3608         ":MC",
3609         ":MCDisassembler",
3610         ":Object",
3611         ":Support",
3612     ],
3615 gentbl(
3616     name = "SizeOptsTableGen",
3617     strip_include_prefix = "tools/llvm-size",
3618     tbl_outs = [(
3619         "-gen-opt-parser-defs",
3620         "tools/llvm-size/Opts.inc",
3621     )],
3622     tblgen = ":llvm-tblgen",
3623     td_file = "tools/llvm-size/Opts.td",
3624     td_srcs = ["include/llvm/Option/OptParser.td"],
3627 cc_binary(
3628     name = "llvm-size",
3629     srcs = glob([
3630         "tools/llvm-size/*.cpp",
3631         "tools/llvm-size/*.h",
3632     ]),
3633     copts = llvm_copts,
3634     stamp = 0,
3635     deps = [
3636         ":Object",
3637         ":Option",
3638         ":SizeOptsTableGen",
3639         ":Support",
3640     ],
3643 cc_binary(
3644     name = "llvm-split",
3645     srcs = glob([
3646         "tools/llvm-split/*.cpp",
3647         "tools/llvm-split/*.h",
3648     ]),
3649     copts = llvm_copts,
3650     stamp = 0,
3651     deps = [
3652         ":BitWriter",
3653         ":Core",
3654         ":IRReader",
3655         ":Support",
3656         ":TransformUtils",
3657     ],
3660 gentbl(
3661     name = "StringsOptsTableGen",
3662     strip_include_prefix = "tools/llvm-strings",
3663     tbl_outs = [(
3664         "-gen-opt-parser-defs",
3665         "tools/llvm-strings/Opts.inc",
3666     )],
3667     tblgen = ":llvm-tblgen",
3668     td_file = "tools/llvm-strings/Opts.td",
3669     td_srcs = ["include/llvm/Option/OptParser.td"],
3672 cc_binary(
3673     name = "llvm-strings",
3674     srcs = glob([
3675         "tools/llvm-strings/*.cpp",
3676         "tools/llvm-strings/*.h",
3677     ]),
3678     copts = llvm_copts,
3679     stamp = 0,
3680     deps = [
3681         ":Object",
3682         ":Option",
3683         ":StringsOptsTableGen",
3684         ":Support",
3685     ],
3688 gentbl(
3689     name = "SymbolizerOptsTableGen",
3690     strip_include_prefix = "tools/llvm-symbolizer",
3691     tbl_outs = [(
3692         "-gen-opt-parser-defs",
3693         "tools/llvm-symbolizer/Opts.inc",
3694     )],
3695     tblgen = ":llvm-tblgen",
3696     td_file = "tools/llvm-symbolizer/Opts.td",
3697     td_srcs = ["include/llvm/Option/OptParser.td"],
3700 cc_binary(
3701     name = "llvm-symbolizer",
3702     srcs = glob([
3703         "tools/llvm-symbolizer/*.cpp",
3704         "tools/llvm-symbolizer/*.h",
3705     ]),
3706     copts = llvm_copts,
3707     stamp = 0,
3708     deps = [
3709         ":DebugInfoDWARF",
3710         ":DebugInfoPDB",
3711         ":Debuginfod",
3712         ":Object",
3713         ":Option",
3714         ":Support",
3715         ":Symbolize",
3716         ":SymbolizerOptsTableGen",
3717     ],
3720 binary_alias(
3721     name = "llvm-addr2line",
3722     binary = ":llvm-symbolizer",
3725 cc_binary(
3726     name = "llvm-undname",
3727     srcs = glob([
3728         "tools/llvm-undname/*.cpp",
3729         "tools/llvm-undname/*.h",
3730     ]),
3731     copts = llvm_copts,
3732     stamp = 0,
3733     deps = [
3734         ":Demangle",
3735         ":Support",
3736     ],
3739 cc_binary(
3740     name = "llvm-xray",
3741     srcs = glob([
3742         "tools/llvm-xray/*.cpp",
3743         "tools/llvm-xray/*.cc",
3744         "tools/llvm-xray/*.h",
3745     ]),
3746     copts = llvm_copts,
3747     stamp = 0,
3748     deps = [
3749         ":DebugInfoDWARF",
3750         ":Object",
3751         ":Support",
3752         ":Symbolize",
3753         ":XRay",
3754     ],
3757 cc_binary(
3758     name = "opt",
3759     srcs = glob([
3760         "tools/opt/*.cpp",
3761         "tools/opt/*.h",
3762     ]),
3763     copts = llvm_copts,
3764     linkopts = select({
3765         "@bazel_tools//src/conditions:windows": [],
3766         "@bazel_tools//src/conditions:darwin": [],
3767         "//conditions:default": ["-Wl,--export-dynamic"],
3768     }),
3769     stamp = 0,
3770     deps = [
3771         ":AllTargetsAsmParsers",
3772         ":AllTargetsCodeGens",
3773         ":Analysis",
3774         ":AsmParser",
3775         ":BitReader",
3776         ":BitWriter",
3777         ":CodeGen",
3778         ":Core",
3779         ":IRReader",
3780         ":MC",
3781         ":Passes",
3782         ":Support",
3783         ":Target",
3784         ":TransformUtils",
3785         ":common_transforms",
3786         ":config",
3787     ],
3790 cc_binary(
3791     name = "sancov",
3792     srcs = glob([
3793         "tools/sancov/*.cpp",
3794         "tools/sancov/*.h",
3795     ]),
3796     copts = llvm_copts,
3797     stamp = 0,
3798     deps = [
3799         ":AllTargetsCodeGens",
3800         ":AllTargetsDisassemblers",
3801         ":DebugInfoDWARF",
3802         ":DebugInfoPDB",
3803         ":MC",
3804         ":MCDisassembler",
3805         ":Object",
3806         ":Support",
3807         ":Symbolize",
3808     ],
3811 cc_binary(
3812     name = "sanstats",
3813     srcs = glob([
3814         "tools/sanstats/*.cpp",
3815         "tools/sanstats/*.h",
3816     ]),
3817     copts = llvm_copts,
3818     stamp = 0,
3819     deps = [
3820         ":Support",
3821         ":Symbolize",
3822         ":TransformUtils",
3823     ],
3826 cc_binary(
3827     name = "split-file",
3828     srcs = glob([
3829         "tools/split-file/*.cpp",
3830         "tools/split-file/*.h",
3831     ]),
3832     copts = llvm_copts,
3833     stamp = 0,
3834     deps = [
3835         ":Support",
3836     ],
3839 ################################################################################
3840 # Begin testonly libraries
3842 cc_library(
3843     name = "FuzzMutate",
3844     testonly = True,
3845     srcs = glob(["lib/FuzzMutate/*.cpp"]),
3846     hdrs = glob(["include/llvm/FuzzMutate/*.h"]),
3847     copts = llvm_copts,
3848     includes = ["include"],
3849     deps = [
3850         ":Analysis",
3851         ":BitReader",
3852         ":BitWriter",
3853         ":Core",
3854         ":Scalar",
3855         ":Support",
3856     ],
3859 cc_library(
3860     name = "Diff",
3861     testonly = True,
3862     srcs = glob(["tools/llvm-diff/lib/*.cpp"]),
3863     hdrs = glob(["tools/llvm-diff/lib/*.h"]),
3864     deps = [
3865         ":Core",
3866         ":Support",
3867     ],
3870 # A hacky library to expose some internal headers of gtest to its own
3871 # implementation source files using a stripped include prefix rather than
3872 # file-relative-inclusion.
3874 # FIXME: This file should be in `textual_hdrs` instead of `hdrs`, but
3875 # unfortunately that doesn't work with `strip_include_prefix`:
3876 # https://github.com/bazelbuild/bazel/issues/12424
3878 # For now, simply disable parsing and header modules.
3879 cc_library(
3880     name = "gtest_internal_headers",
3881     testonly = True,
3882     hdrs = ["utils/unittest/googletest/src/gtest-internal-inl.h"],
3883     features = [
3884         "-parse_headers",
3885         "-header_modules",
3886     ],
3887     strip_include_prefix = "utils/unittest/googletest",
3890 cc_library(
3891     name = "gtest",
3892     testonly = True,
3893     srcs = glob(
3894         [
3895             "utils/unittest/googletest/include/**/*.h",
3896             "utils/unittest/googletest/src/*.cc",
3897         ],
3898         exclude = [
3899             "utils/unittest/googletest/src/gtest-all.cc",
3900             "utils/unittest/googletest/include/gtest/gtest_pred_impl.h",
3901         ],
3902     ) + [
3903     ],
3904     hdrs = ["utils/unittest/googletest/include/gtest/gtest.h"],
3905     copts = llvm_copts,
3906     defines = [
3907         "GTEST_HAS_RTTI=0",
3908         "__STDC_LIMIT_MACROS",
3909         "__STDC_CONSTANT_MACROS",
3910     ] + select({
3911         "@bazel_tools//src/conditions:windows": ["GTEST_USE_OWN_TR1_TUPLE=0"],
3912         "//conditions:default": ["GTEST_USE_OWN_TR1_TUPLE=1"],
3913     }),
3914     includes = [
3915         "include",
3916         "utils/unittest/googletest/include",
3917     ],
3918     textual_hdrs = [
3919         "utils/unittest/googletest/include/gtest/gtest_pred_impl.h",
3920     ],
3921     deps = [
3922         ":Support",
3923         ":gtest_internal_headers",
3924     ],
3927 cc_library(
3928     name = "gtest_main",
3929     testonly = True,
3930     srcs = ["utils/unittest/UnitTestMain/TestMain.cpp"],
3931     copts = llvm_copts,
3932     deps = [
3933         ":Support",
3934         ":gmock",
3935         ":gtest",
3936     ],
3939 cc_library(
3940     name = "gmock",
3941     testonly = True,
3942     srcs = glob(
3943         [
3944             "utils/unittest/googlemock/include/**/*.h",
3945             "utils/unittest/googlemock/src/*.cc",
3946         ],
3947         exclude = ["utils/unittest/googlemock/src/gmock-all.cc"],
3948     ),
3949     hdrs = [
3950         "utils/unittest/googlemock/include/gmock/gmock.h",
3951         "utils/unittest/googlemock/include/gmock/gmock-matchers.h",
3952     ],
3953     copts = llvm_copts,
3954     includes = [
3955         "include",
3956         "utils/unittest/googlemock/include",
3957     ],
3958     deps = [":gtest"],
3961 py_binary(
3962     name = "lit",
3963     testonly = True,
3964     srcs = ["utils/lit/lit.py"] + glob(["utils/lit/lit/**/*.py"]),
3967 cc_library(
3968     name = "TestingSupport",
3969     testonly = True,
3970     srcs = glob([
3971         "lib/Testing/Support/*.cpp",
3972         "lib/Testing/Support/*.h",
3973     ]),
3974     hdrs = glob([
3975         "include/llvm/Testing/Support/*.h",
3976     ]),
3977     copts = llvm_copts,
3978     deps = [
3979         ":Support",
3980         ":config",
3981         ":gmock",
3982         ":gtest",
3983     ],
3986 ################################################################################
3987 # Begin testonly binary utilities
3989 cc_binary(
3990     name = "FileCheck",
3991     testonly = True,
3992     srcs = glob([
3993         "utils/FileCheck/*.cpp",
3994         "utils/FileCheck/*.h",
3995     ]),
3996     copts = llvm_copts,
3997     stamp = 0,
3998     deps = [":FileCheckLib"],
4001 cc_binary(
4002     name = "bugpoint",
4003     srcs = glob([
4004         "tools/bugpoint/*.cpp",
4005         "tools/bugpoint/*.h",
4006     ]),
4007     copts = llvm_copts,
4008     stamp = 0,
4009     deps = [
4010         ":AllTargetsAsmParsers",
4011         ":AllTargetsCodeGens",
4012         ":Analysis",
4013         ":AsmParser",
4014         ":BitReader",
4015         ":BitWriter",
4016         ":CodeGen",
4017         ":Core",
4018         ":IRReader",
4019         ":Linker",
4020         ":Passes",
4021         ":Support",
4022         ":TransformUtils",
4023         ":common_transforms",
4024         ":config",
4025     ],
4028 cc_binary(
4029     name = "count",
4030     testonly = True,
4031     srcs = glob([
4032         "utils/count/*.c",
4033         "utils/count/*.h",
4034     ]),
4035     stamp = 0,
4038 cc_binary(
4039     name = "lli-child-target",
4040     testonly = True,
4041     srcs = glob([
4042         "tools/lli/ChildTarget/*.cpp",
4043         "tools/lli/ChildTarget/*.h",
4044     ]),
4045     copts = llvm_copts,
4046     # The tests load code into this binary that expect to see symbols
4047     # from libstdc++ such as __cxa_begin_catch and _ZTIi. The latter
4048     # isn't even used in the main binary, so we also need to force it
4049     # to be included.
4050     linkopts = select({
4051         "@bazel_tools//src/conditions:windows": [],
4052         "@bazel_tools//src/conditions:darwin": [],
4053         "//conditions:default": [
4054             "-rdynamic",
4055             "-u_ZTIi",
4056         ],
4057     }),
4058     stamp = 0,
4059     deps = [
4060         ":OrcJIT",
4061         ":Support",
4062         ":attributes_gen",
4063         ":config",
4064         ":intrinsic_enums_gen",
4065     ],
4068 cc_binary(
4069     name = "llvm-c-test",
4070     testonly = True,
4071     srcs = glob([
4072         "tools/llvm-c-test/*.c",
4073         "tools/llvm-c-test/*.cpp",
4074         "tools/llvm-c-test/*.h",
4075     ]),
4076     stamp = 0,
4077     deps = [
4078         ":AllTargetsAsmParsers",
4079         ":AllTargetsCodeGens",
4080         ":AllTargetsDisassemblers",
4081         ":Analysis",
4082         ":BitReader",
4083         ":BitWriter",
4084         ":Core",
4085         ":ExecutionEngine",
4086         ":IPO",
4087         ":LTO",
4088         ":Linker",
4089         ":MCDisassembler",
4090         ":Object",
4091         ":OrcJIT",
4092         ":Scalar",
4093         ":Support",
4094         ":Target",
4095         ":Vectorize",
4096     ],
4099 cc_binary(
4100     name = "llvm-diff",
4101     testonly = True,
4102     srcs = glob([
4103         "tools/llvm-diff/*.cpp",
4104         "tools/llvm-diff/*.h",
4105     ]),
4106     copts = llvm_copts,
4107     stamp = 0,
4108     deps = [
4109         ":Core",
4110         ":Diff",
4111         ":IRReader",
4112         ":Support",
4113     ],
4116 cc_binary(
4117     name = "llvm-isel-fuzzer",
4118     testonly = True,
4119     srcs = glob([
4120         "tools/llvm-isel-fuzzer/*.cpp",
4121         "tools/llvm-isel-fuzzer/*.h",
4122     ]),
4123     copts = llvm_copts,
4124     stamp = 0,
4125     deps = [
4126         ":AllTargetsAsmParsers",
4127         ":AllTargetsCodeGens",
4128         ":Analysis",
4129         ":BitReader",
4130         ":BitWriter",
4131         ":CodeGen",
4132         ":Core",
4133         ":FuzzMutate",
4134         ":IRReader",
4135         ":Support",
4136         ":Target",
4137     ],
4140 # This is really a Python script, but call it sh_binary to ignore the hyphen in
4141 # the path, which py_binary does not allow.
4142 # Also, note: llvm-locstats expects llvm-dwarfdump to be in the same directory
4143 # when executed.
4144 sh_binary(
4145     name = "llvm-locstats",
4146     testonly = True,
4147     srcs = glob([
4148         "utils/llvm-locstats/*.py",
4149     ]),
4150     # llvm-locstats is a thin wrapper around llvm-dwarfdump.
4151     data = [":llvm-dwarfdump"],
4154 sh_binary(
4155     name = "llvm-original-di-preservation",
4156     testonly = True,
4157     srcs = ["utils/llvm-original-di-preservation.py"],
4160 cc_binary(
4161     name = "not",
4162     testonly = True,
4163     srcs = glob([
4164         "utils/not/*.cpp",
4165         "utils/not/*.h",
4166     ]),
4167     copts = llvm_copts,
4168     stamp = 0,
4169     deps = [":Support"],
4172 cc_binary(
4173     name = "llvm-opt-fuzzer",
4174     testonly = True,
4175     srcs = glob([
4176         "tools/llvm-opt-fuzzer/*.cpp",
4177     ]),
4178     copts = llvm_copts,
4179     stamp = 0,
4180     deps = [
4181         ":AllTargetsCodeGens",
4182         ":Analysis",
4183         ":BitReader",
4184         ":BitWriter",
4185         ":CodeGen",
4186         ":Core",
4187         ":Coroutines",
4188         ":FuzzMutate",
4189         ":Passes",
4190         ":Support",
4191     ],
4194 cc_binary(
4195     name = "llvm-tapi-diff",
4196     testonly = True,
4197     srcs = glob([
4198         "tools/llvm-tapi-diff/*.cpp",
4199         "tools/llvm-tapi-diff/*.h",
4200     ]),
4201     copts = llvm_copts,
4202     stamp = 0,
4203     deps = [
4204         ":Object",
4205         ":Support",
4206         ":TextAPI",
4207     ],
4210 gentbl(
4211     name = "TLICheckerOptsTableGen",
4212     strip_include_prefix = "tools/llvm-tli-checker",
4213     tbl_outs = [(
4214         "-gen-opt-parser-defs",
4215         "tools/llvm-tli-checker/Opts.inc",
4216     )],
4217     tblgen = ":llvm-tblgen",
4218     td_file = "tools/llvm-tli-checker/Opts.td",
4219     td_srcs = ["include/llvm/Option/OptParser.td"],
4222 cc_binary(
4223     name = "llvm-tli-checker",
4224     testonly = True,
4225     srcs = glob([
4226         "tools/llvm-tli-checker/*.cpp",
4227         "tools/llvm-tli-checker/*.h",
4228     ]),
4229     copts = llvm_copts,
4230     stamp = 0,
4231     deps = [
4232         ":Analysis",
4233         ":BinaryFormat",
4234         ":BitReader",
4235         ":BitstreamReader",
4236         ":Core",
4237         ":Demangle",
4238         ":MC",
4239         ":MCParser",
4240         ":Object",
4241         ":Option",
4242         ":Remarks",
4243         ":Support",
4244         ":TextAPI",
4245         ":TLICheckerOptsTableGen",
4246     ],
4249 cc_binary(
4250     name = "obj2yaml",
4251     testonly = True,
4252     srcs = glob([
4253         "tools/obj2yaml/*.cpp",
4254         "tools/obj2yaml/*.h",
4255     ]),
4256     copts = llvm_copts,
4257     stamp = 0,
4258     deps = [
4259         ":BinaryFormat",
4260         ":DebugInfoCodeView",
4261         ":DebugInfoDWARF",
4262         ":Object",
4263         ":ObjectYAML",
4264         ":Support",
4265     ],
4268 cc_binary(
4269     name = "verify-uselistorder",
4270     srcs = glob([
4271         "tools/verify-uselistorder/*.cpp",
4272         "tools/verify-uselistorder/*.h",
4273     ]),
4274     copts = llvm_copts,
4275     stamp = 0,
4276     deps = [
4277         ":AsmParser",
4278         ":BitReader",
4279         ":BitWriter",
4280         ":Core",
4281         ":IRReader",
4282         ":Support",
4283     ],
4286 cc_binary(
4287     name = "yaml2obj",
4288     testonly = True,
4289     srcs = glob([
4290         "tools/yaml2obj/*.cpp",
4291         "tools/yaml2obj/*.h",
4292     ]),
4293     copts = llvm_copts,
4294     stamp = 0,
4295     deps = [
4296         ":BinaryFormat",
4297         ":DebugInfoCodeView",
4298         ":MC",
4299         ":Object",
4300         ":ObjectYAML",
4301         ":Support",
4302     ],
4305 cc_binary(
4306     name = "yaml-bench",
4307     testonly = True,
4308     srcs = glob([
4309         "utils/yaml-bench/*.cpp",
4310     ]),
4311     copts = llvm_copts,
4312     stamp = 0,
4313     deps = [
4314         ":Support",
4315     ],