[RISCV] Add RVVConstraint to SiFive custom matrix multiply instructions. (#124055)
[llvm-project.git] / utils / bazel / llvm-project-overlay / llvm / BUILD.bazel
blob56dff6b3ad500355f2f49adfc201540c6c276c3c
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("@bazel_skylib//rules:common_settings.bzl", "string_flag")
6 load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
7 load("@rules_python//python:defs.bzl", "py_binary")
8 load("//mlir:tblgen.bzl", "td_library")
9 load(":binary_alias.bzl", "binary_alias")
10 load(":config.bzl", "llvm_config_defines")
11 load(":driver.bzl", "generate_driver_selects", "generate_driver_tools_def", "llvm_driver_cc_binary", "select_driver_tools")
12 load(":enum_targets_gen.bzl", "enum_targets_gen")
13 load(":targets.bzl", "llvm_targets")
14 load(":tblgen.bzl", "gentbl")
16 package(
17     default_visibility = ["//visibility:public"],
18     features = ["layering_check"],
21 licenses(["notice"])
23 exports_files([
24     "LICENSE.TXT",
25     "cmake/modules/llvm-driver-template.cpp.in",
26     "include/llvm/BinaryFormat/Dwarf.def",
27     "include/llvm/CodeGen/SDNodeProperties.td",
28     "include/llvm/CodeGen/ValueTypes.td",
29     "include/llvm/Frontend/Directive/DirectiveBase.td",
30     "include/llvm/Frontend/OpenACC/ACC.td",
31     "include/llvm/Frontend/OpenMP/OMP.td",
32     "include/llvm/IR/Intrinsics.td",
33     "include/llvm/Option/OptParser.td",
34     "utils/lit/lit.py",
35     # This one is needed for building and vendoring out lldb from off tree.
36     "utils/lldbDataFormatters.py",
39 # It may be tempting to add compiler flags here, but that should be avoided.
40 # The necessary warnings and other compile flags should be provided by the
41 # toolchain or the `.bazelrc` file. This is just a workaround until we have a
42 # widely available feature to enable unlimited stack frame instead of using
43 # this `Make` variable.
44 llvm_copts = [
45     "$(STACK_FRAME_UNLIMITED)",
48 enum_targets_gen(
49     name = "targets_def_gen",
50     src = "include/llvm/Config/Targets.def.in",
51     out = "include/llvm/Config/Targets.def",
52     macro_name = "TARGET",
53     targets = llvm_targets,
56 # Enabled targets with ASM printers.
57 llvm_target_asm_printers = [
58     t
59     for t in llvm_targets
60     if glob(["lib/Target/{}/*AsmPrinter.cpp".format(t)])
63 enum_targets_gen(
64     name = "asm_printers_def_gen",
65     src = "include/llvm/Config/AsmPrinters.def.in",
66     out = "include/llvm/Config/AsmPrinters.def",
67     macro_name = "ASM_PRINTER",
68     targets = llvm_target_asm_printers,
71 # Enabled targets with ASM parsers.
72 llvm_target_asm_parsers = [
73     t
74     for t in llvm_targets
75     if glob(
76         ["lib/Target/{}/AsmParser/CMakeLists.txt".format(t)],
77         allow_empty = True,
78     )
81 enum_targets_gen(
82     name = "asm_parsers_def_gen",
83     src = "include/llvm/Config/AsmParsers.def.in",
84     out = "include/llvm/Config/AsmParsers.def",
85     macro_name = "ASM_PARSER",
86     targets = llvm_target_asm_parsers,
89 # Enabled targets with disassemblers.
90 llvm_target_disassemblers = [
91     t
92     for t in llvm_targets
93     if glob(
94         ["lib/Target/{}/Disassembler/CMakeLists.txt".format(t)],
95         allow_empty = True,
96     )
99 enum_targets_gen(
100     name = "disassemblers_def_gen",
101     src = "include/llvm/Config/Disassemblers.def.in",
102     out = "include/llvm/Config/Disassemblers.def",
103     macro_name = "DISASSEMBLER",
104     targets = llvm_target_disassemblers,
107 # Enabled targets with MCA.
108 llvm_target_mcas = [
109     t
110     for t in llvm_targets
111     if glob(
112         ["lib/Target/{}/MCA/CMakeLists.txt".format(t)],
113         allow_empty = True,
114     )
117 enum_targets_gen(
118     name = "target_mca_def_gen",
119     src = "include/llvm/Config/TargetMCAs.def.in",
120     out = "include/llvm/Config/TargetMCAs.def",
121     macro_name = "TARGETMCA",
122     targets = llvm_target_mcas,
125 # Enabled targets with exegesis.
126 llvm_target_exegesis = [
127     t
128     for t in llvm_targets
129     if glob(
130         ["tools/llvm-exegesis/lib/{}/CMakeLists.txt".format(t)],
131         allow_empty = True,
132     )
135 enum_targets_gen(
136     name = "target_exegesis_def_gen",
137     src = "include/llvm/Config/TargetExegesis.def.in",
138     out = "include/llvm/Config/TargetExegesis.def",
139     macro_name = "EXEGESIS",
140     placeholder_name = "@LLVM_ENUM_EXEGESIS@",
141     targets = llvm_target_exegesis,
144 expand_template(
145     name = "abi_breaking_h_gen",
146     out = "include/llvm/Config/abi-breaking.h",
147     substitutions = {
148         # Define to enable checks that alter the LLVM C++ ABI
149         "#cmakedefine01 LLVM_ENABLE_ABI_BREAKING_CHECKS": "#define LLVM_ENABLE_ABI_BREAKING_CHECKS 0",
151         # Define to enable reverse iteration of unordered llvm containers
152         "#cmakedefine01 LLVM_ENABLE_REVERSE_ITERATION": "#define LLVM_ENABLE_REVERSE_ITERATION 0",
153     },
154     template = "include/llvm/Config/abi-breaking.h.cmake",
157 # To enable diff testing out of tree
158 exports_files([
159     "include/llvm/Config/config.h.cmake",
160     "include/llvm/Config/llvm-config.h.cmake",
161     "include/llvm/Config/abi-breaking.h.cmake",
164 td_library(
165     name = "OptParserTdFiles",
166     srcs = ["include/llvm/Option/OptParser.td"],
167     includes = ["include"],
170 llvm_config_target_defines = [
171     "LLVM_HAS_{}_TARGET=1".format(t)
172     for t in llvm_targets
175 cc_library(
176     name = "config",
177     hdrs = [
178         "include/llvm/Config/abi-breaking.h",
179         "include/llvm/Config/llvm-config.h",
180     ],
181     copts = llvm_copts,
182     defines = llvm_config_defines + llvm_config_target_defines,
183     includes = ["include"],
184     textual_hdrs = [
185         "include/llvm/Config/AsmParsers.def",
186         "include/llvm/Config/AsmPrinters.def",
187         "include/llvm/Config/Disassemblers.def",
188         "include/llvm/Config/Targets.def",
189         "include/llvm/Config/TargetExegesis.def",
190         "include/llvm/Config/TargetMCAs.def",
191         # Needed for include scanner to find execinfo.h
192         "include/llvm/Config/config.h",
193     ],
196 cc_library(
197     name = "Demangle",
198     srcs = glob([
199         "lib/Demangle/*.cpp",
200     ]),
201     hdrs = glob([
202         "include/llvm/Demangle/*.h",
203         "include/llvm/Demangle/*.def",
204     ]),
205     copts = llvm_copts,
206     deps = [":config"],
209 genrule(
210     name = "generate_vcs_revision",
211     outs = ["include/llvm/Support/VCSRevision.h"],
212     cmd = "echo '#undef LLVM_REVISION' >> $@\n" +
213           "echo '#undef LLVM_REPOSITORY' >> $@\n",
216 genrule(
217     name = "generate_static_extension_registry",
218     outs = ["include/llvm/Support/Extension.def"],
219     cmd = "echo -e '// extension handlers' >> $@\n" +
220           "echo -e '#undef HANDLE_EXTENSION' >> $@\n",
223 cc_library(
224     name = "Support",
225     srcs = glob([
226         "lib/Support/*.c",
227         "lib/Support/*.cpp",
228         "lib/Support/*.h",
229         "lib/Support/*.inc",
230         # To avoid a dependency cycle.
231         "include/llvm/Option/*.h",
232     ]) + select({
233         "@platforms//os:windows": glob([
234             "lib/Support/Windows/*.inc",
235         ]),
236         "//conditions:default": glob([
237             "lib/Support/Unix/*.h",
238             "lib/Support/Unix/*.inc",
239         ]),
240     }) + [
241         "lib/Support/BLAKE3/blake3.c",
242         "lib/Support/BLAKE3/blake3_dispatch.c",
243         "lib/Support/BLAKE3/blake3_impl.h",
244         "lib/Support/BLAKE3/blake3_portable.c",
245         "lib/Support/BLAKE3/llvm_blake3_prefix.h",
246     ] + select({
247         "@platforms//cpu:aarch64": [
248             "lib/Support/BLAKE3/blake3_neon.c",
249         ],
250         "@platforms//cpu:x86_64": [
251             "lib/Support/BLAKE3/blake3_avx2_x86-64_unix.S",
252             "lib/Support/BLAKE3/blake3_avx512_x86-64_unix.S",
253             "lib/Support/BLAKE3/blake3_sse2_x86-64_unix.S",
254             "lib/Support/BLAKE3/blake3_sse41_x86-64_unix.S",
255         ],
256         "//conditions:default": [
257         ],
258     }),
259     hdrs = glob([
260         "include/llvm/Support/**/*.h",
261         "include/llvm/ADT/*.h",
262     ]) + [
263         "include/llvm-c/Core.h",
264         "include/llvm-c/DataTypes.h",
265         "include/llvm-c/Deprecated.h",
266         "include/llvm-c/DisassemblerTypes.h",
267         "include/llvm-c/Error.h",
268         "include/llvm-c/ErrorHandling.h",
269         "include/llvm-c/ExternC.h",
270         "include/llvm-c/Support.h",
271         "include/llvm-c/Types.h",
272         "include/llvm-c/blake3.h",
273         "include/llvm/ExecutionEngine/JITSymbol.h",
274         "include/llvm/Support/Extension.def",
275         "include/llvm/Support/VCSRevision.h",
276     ],
277     copts = llvm_copts,
278     defines = select({
279         "@platforms//cpu:aarch64": [
280         ],
281         "//conditions:default": [
282             "BLAKE3_USE_NEON=0",
283         ],
284     }) + select({
285         "@platforms//cpu:x86_64": [
286         ],
287         "//conditions:default": [
288             "BLAKE3_NO_AVX2",
289             "BLAKE3_NO_AVX512",
290             "BLAKE3_NO_SSE2",
291             "BLAKE3_NO_SSE41",
292         ],
293     }),
294     includes = ["include"],
295     linkopts = select({
296         "@platforms//os:windows": [
297             "ws2_32.lib",
298             "ntdll.lib",
299         ],
300         "@platforms//os:freebsd": [
301             "-pthread",
302             "-lexecinfo",
303             "-ldl",
304             "-lm",
305         ],
306         "@platforms//os:macos": [
307             "-pthread",
308             "-ldl",
309         ],
310         "//conditions:default": [
311             "-pthread",
312             "-ldl",
313             "-lm",
314         ],
315     }),
316     textual_hdrs = glob([
317         "include/llvm/Support/*.def",
318     ]),
319     deps = [
320         ":config",
321         ":Demangle",
322         # We unconditionally depend on the custom LLVM zlib wrapper. This will
323         # be an empty library unless zlib is enabled, in which case it will
324         # both provide the necessary dependencies and configuration defines.
325         "@llvm_zlib//:zlib",
326         # We unconditionally depend on the custom LLVM zstd wrapper. This will
327         # be an empty library unless zstd is enabled, in which case it will
328         # both provide the necessary dependencies and configuration defines.
329         "@llvm_zstd//:zstd",
330     ],
333 # Note: although FileCheck (the binary) is a test utility, some non-test
334 # targets depend on the FileCheck library target.
335 cc_library(
336     name = "FileCheckLib",
337     srcs = glob([
338         "lib/FileCheck/*.cpp",
339         "lib/FileCheck/*.h",
340     ]),
341     hdrs = glob(["include/llvm/FileCheck/*.h"]),
342     copts = llvm_copts,
343     deps = [":Support"],
346 cc_library(
347     name = "LineEditor",
348     srcs = glob([
349         "lib/LineEditor/*.cpp",
350     ]),
351     hdrs = glob(["include/llvm/LineEditor/*.h"]),
352     copts = llvm_copts,
353     deps = [
354         ":Support",
355         ":config",
356     ],
359 cc_library(
360     name = "Option",
361     srcs = glob([
362         "lib/Option/*.cpp",
363     ]),
364     hdrs = glob(["include/llvm/Option/*.h"]),
365     copts = llvm_copts,
366     deps = [
367         ":Support",
368         ":config",
369     ],
372 cc_library(
373     name = "TableGen",
374     srcs = glob([
375         "lib/TableGen/*.cpp",
376         "lib/TableGen/*.h",
377     ]),
378     hdrs = glob(["include/llvm/TableGen/*.h"]),
379     copts = llvm_copts,
380     deps = [
381         ":Support",
382         ":config",
383     ],
386 # This exists to avoid circular dependencies.
387 cc_library(
388     name = "ir_headers",
389     hdrs = glob(
390         [
391             "include/llvm/*.h",
392             "include/llvm/IR/*.h",
393         ],
394         exclude = [
395             "include/llvm/LinkAllPasses.h",
396         ],
397     ) + [
398         "include/llvm-c/Comdat.h",
399         "include/llvm-c/DebugInfo.h",
400         "include/llvm/IR/Value.def",
401     ],
402     copts = llvm_copts,
405 cc_library(
406     name = "BinaryFormat",
407     srcs = glob([
408         "lib/BinaryFormat/*.cpp",
409     ]),
410     hdrs = glob([
411         "include/llvm/BinaryFormat/*.h",
412     ]),
413     copts = llvm_copts,
414     includes = ["include"],
415     textual_hdrs = glob([
416         "include/llvm/BinaryFormat/*.def",
417         "include/llvm/BinaryFormat/ELFRelocs/*.def",
418     ]),
419     deps = [
420         ":Support",
421         ":TargetParser",
422     ],
425 cc_library(
426     name = "DebugInfo",
427     hdrs = glob(["include/llvm/DebugInfo/**/*.h"]),
428     copts = llvm_copts,
429     textual_hdrs = glob(["include/llvm/DebugInfo/**/*.def"]),
430     deps = [
431         ":Object",
432         ":Support",
433     ],
436 cc_library(
437     name = "DebugInfoMSF",
438     srcs = glob([
439         "lib/DebugInfo/MSF/*.cpp",
440     ]),
441     hdrs = glob(["include/llvm/DebugInfo/MSF/*.h"]),
442     copts = llvm_copts,
443     deps = [":Support"],
446 cc_library(
447     name = "DebugInfoBTF",
448     srcs = glob([
449         "lib/DebugInfo/BTF/*.cpp",
450     ]),
451     hdrs = glob(["include/llvm/DebugInfo/BTF/*.h"]) + [
452         "include/llvm/DebugInfo/BTF/BTF.def",
453     ],
454     copts = llvm_copts,
455     deps = [
456         ":DebugInfo",
457         ":Object",
458         ":Support",
459     ],
462 cc_library(
463     name = "DebugInfoCodeView",
464     srcs = glob([
465         "lib/DebugInfo/CodeView/*.cpp",
466     ]),
467     hdrs = glob([
468         "include/llvm/DebugInfo/CodeView/*.h",
469     ]),
470     copts = llvm_copts,
471     textual_hdrs = glob([
472         "include/llvm/DebugInfo/CodeView/*.def",
473     ]),
474     deps = [
475         ":BinaryFormat",
476         ":DebugInfoMSF",
477         ":Support",
478     ],
481 cc_library(
482     name = "DebugInfoLogicalView",
483     srcs = glob([
484         "lib/DebugInfo/LogicalView/**/*.cpp",
485     ]),
486     hdrs = glob([
487         "include/llvm/DebugInfo/LogicalView/**/*.h",
488     ]),
489     copts = llvm_copts,
490     deps = [
491         ":BinaryFormat",
492         ":DebugInfo",
493         ":DebugInfoCodeView",
494         ":DebugInfoDWARF",
495         ":DebugInfoPDB",
496         ":Demangle",
497         ":MC",
498         ":MCDisassembler",
499         ":Object",
500         ":Support",
501     ],
504 cc_library(
505     name = "DebugInfoPDB",
506     srcs = glob([
507         "lib/DebugInfo/PDB/*.cpp",
508         "lib/DebugInfo/PDB/Native/*.cpp",
509     ]),
510     hdrs = glob([
511         "include/llvm/DebugInfo/PDB/*.h",
512         "include/llvm/DebugInfo/PDB/Native/*.h",
513     ]),
514     copts = llvm_copts,
515     deps = [
516         ":BinaryFormat",
517         ":DebugInfo",
518         ":DebugInfoBTF",
519         ":DebugInfoCodeView",
520         ":DebugInfoMSF",
521         ":Object",
522         ":Support",
523         ":config",
524     ],
527 cc_library(
528     name = "Debuginfod",
529     srcs = glob([
530         "lib/Debuginfod/*.cpp",
531     ]),
532     hdrs = glob([
533         "include/llvm/Debuginfod/*.h",
534     ]),
535     copts = llvm_copts,
536     deps = [
537         ":BinaryFormat",
538         ":DebugInfoDWARF",
539         ":Object",
540         ":Support",
541         ":Symbolize",
542     ],
545 cc_library(
546     name = "MC",
547     srcs = glob([
548         "lib/MC/*.cpp",
549     ]),
550     hdrs = glob([
551         "include/llvm/MC/*.h",
552     ]),
553     copts = llvm_copts,
554     deps = [
555         ":BinaryFormat",
556         ":DebugInfoCodeView",
557         ":Support",
558         ":TargetParser",
559         ":config",
560         ":ir_headers",
561     ],
564 cc_library(
565     name = "DebugInfoDWARF",
566     srcs = glob([
567         "lib/DebugInfo/DWARF/*.cpp",
568     ]),
569     hdrs = glob(["include/llvm/DebugInfo/DWARF/*.h"]),
570     copts = llvm_copts,
571     deps = [
572         ":BinaryFormat",
573         ":DebugInfo",
574         ":MC",
575         ":Object",
576         ":Support",
577         ":TargetParser",
578     ],
581 cc_library(
582     name = "DebugInfoGSYM",
583     srcs = glob([
584         "lib/DebugInfo/GSYM/*.cpp",
585     ]),
586     hdrs = glob(["include/llvm/DebugInfo/GSYM/*.h"]),
587     copts = llvm_copts,
588     deps = [
589         ":DebugInfo",
590         ":DebugInfoDWARF",
591         ":MC",
592         ":Object",
593         ":Support",
594     ],
597 cc_library(
598     name = "Symbolize",
599     srcs = glob([
600         "lib/DebugInfo/Symbolize/*.cpp",
601     ]),
602     hdrs = glob([
603         "include/llvm/DebugInfo/Symbolize/*.h",
604         "include/llvm/Debuginfod/*.h",
605     ]),
606     copts = llvm_copts,
607     deps = [
608         ":BinaryFormat",
609         ":DebugInfo",
610         ":DebugInfoDWARF",
611         ":DebugInfoPDB",
612         ":Demangle",
613         ":Object",
614         ":Support",
615         ":TargetParser",
616     ],
619 # Command line flag to control which tools get included in the llvm driver binary.
620 # The macro also generates config_setting targets used by select_driver_tools().
621 generate_driver_selects(name = "driver-tools")
623 generate_driver_tools_def(
624     name = "gen_llvm_driver_tools_def",
625     out = "LLVMDriverTools.def",
626     driver_tools = select_driver_tools(":driver-tools"),
629 # Workaround inability to put `.def` files into `srcs` with a library
630 cc_library(
631     name = "llvm_driver_tools_def_lib",
632     includes = ["."],
633     textual_hdrs = ["LLVMDriverTools.def"],
636 cc_binary(
637     name = "llvm",
638     srcs = glob(["tools/llvm-driver/*.cpp"]),
639     deps = [
640         ":Support",
641         ":llvm_driver_tools_def_lib",
642     ] + select_driver_tools(":driver-tools"),
645 cc_binary(
646     name = "llvm-min-tblgen",
647     srcs = [
648         "utils/TableGen/Basic/ARMTargetDefEmitter.cpp",
649         "utils/TableGen/Basic/Attributes.cpp",
650         "utils/TableGen/Basic/CodeGenIntrinsics.cpp",
651         "utils/TableGen/Basic/CodeGenIntrinsics.h",
652         "utils/TableGen/Basic/SDNodeProperties.cpp",
653         "utils/TableGen/Basic/SDNodeProperties.h",
654         "utils/TableGen/Basic/TableGen.h",
655         "utils/TableGen/Basic/TableGen.cpp",
656         "utils/TableGen/Basic/SequenceToOffsetTable.h",
657         "utils/TableGen/Basic/DirectiveEmitter.cpp",
658         "utils/TableGen/Basic/IntrinsicEmitter.cpp",
659         "utils/TableGen/Basic/RISCVTargetDefEmitter.cpp",
660         "utils/TableGen/Basic/VTEmitter.cpp",
661         "utils/TableGen/llvm-min-tblgen.cpp",
662     ],
663     copts = llvm_copts,
664     stamp = 0,
665     deps = [
666         ":Support",
667         ":TableGen",
668         ":config",
669     ],
672 cc_library(
673     name = "TableGenGlobalISel",
674     srcs = [
675         "utils/TableGen/Common/GlobalISel/CodeExpander.cpp",
676     ],
677     hdrs = [
678         # We have to include these headers here as well as in the `hdrs` below
679         # to allow the `.cpp` files to use file-relative-inclusion to find
680         # them, even though consumers of this library use inclusion relative to
681         # `utils/TableGen` with the `strip_includes_prefix` of this library.
682         # This mixture appears to be incompatible with header modules.
683         "utils/TableGen/Common/GlobalISel/CodeExpander.h",
684         "utils/TableGen/Common/GlobalISel/CodeExpansions.h",
685     ],
686     copts = llvm_copts,
687     features = ["-header_modules"],
688     strip_include_prefix = "utils/TableGen",
689     deps = [
690         ":CodeGenTypes",
691         ":Support",
692         ":TableGen",
693         ":config",
694     ],
697 cc_library(
698     name = "llvm-tblgen-headers",
699     textual_hdrs = glob(["utils/TableGen/*.def"]),
702 cc_binary(
703     name = "llvm-tblgen",
704     srcs = glob(
705         [
706             "utils/TableGen/*.cpp",
707             "utils/TableGen/*.h",
708             "utils/TableGen/Basic/*.cpp",
709             "utils/TableGen/Basic/*.h",
710             "utils/TableGen/Common/*.cpp",
711             "utils/TableGen/Common/*.h",
712             "utils/TableGen/Common/GlobalISel/*.cpp",
713             "utils/TableGen/Common/GlobalISel/*.h",
715             # Some tablegen sources include headers from MC, so these have to be
716             # listed here. MC uses headers produced by tablegen, so it cannot be a
717             # regular dependency.
718             "include/llvm/MC/*.h",
719         ],
720         exclude = [
721             "utils/TableGen/Common/GlobalISel/CodeExpander.cpp",
722             "utils/TableGen/llvm-min-tblgen.cpp",
723         ],
724     ) + [
725         "include/llvm/TargetParser/SubtargetFeature.h",
726     ],
727     copts = llvm_copts,
728     includes = ["utils/TableGen"],
729     stamp = 0,
730     deps = [
731         ":CodeGenTypes",
732         ":Support",
733         ":TableGen",
734         ":TableGenGlobalISel",
735         ":TargetParser",
736         ":config",
737         ":llvm-tblgen-headers",
738         ":vt_gen",
739     ],
742 gentbl(
743     name = "intrinsic_enums_gen",
744     tbl_outs = [("-gen-intrinsic-enums", "include/llvm/IR/IntrinsicEnums.inc")],
745     tblgen = ":llvm-min-tblgen",
746     td_file = "include/llvm/IR/Intrinsics.td",
747     td_srcs = glob([
748         "include/llvm/CodeGen/*.td",
749         "include/llvm/IR/Intrinsics*.td",
750     ]),
753 gentbl(
754     name = "intrinsics_impl_gen",
755     tbl_outs = [("-gen-intrinsic-impl", "include/llvm/IR/IntrinsicImpl.inc")],
756     tblgen = ":llvm-min-tblgen",
757     td_file = "include/llvm/IR/Intrinsics.td",
758     td_srcs = glob([
759         "include/llvm/CodeGen/*.td",
760         "include/llvm/IR/Intrinsics*.td",
761     ]),
764 gentbl(
765     name = "vt_gen",
766     tbl_outs = [("-gen-vt", "include/llvm/CodeGen/GenVT.inc")],
767     tblgen = ":llvm-min-tblgen",
768     td_file = "include/llvm/CodeGen/ValueTypes.td",
769     td_srcs = [
770         "include/llvm/CodeGen/ValueTypes.td",
771     ],
774 # Note that the intrinsics are not currently set up so they can be pruned for
775 # disabled targets.
776 llvm_target_intrinsics_list = [
777     {
778         "name": "AArch64",
779         "intrinsic_prefix": "aarch64",
780     },
781     {
782         "name": "AMDGPU",
783         "intrinsic_prefix": "amdgcn",
784     },
785     {
786         "name": "ARM",
787         "intrinsic_prefix": "arm",
788     },
789     {
790         "name": "BPF",
791         "intrinsic_prefix": "bpf",
792     },
793     {
794         "name": "DirectX",
795         "intrinsic_prefix": "dx",
796     },
797     {
798         "name": "Hexagon",
799         "intrinsic_prefix": "hexagon",
800     },
801     {
802         "name": "LoongArch",
803         "intrinsic_prefix": "loongarch",
804     },
805     {
806         "name": "Mips",
807         "intrinsic_prefix": "mips",
808     },
809     {
810         "name": "NVPTX",
811         "intrinsic_prefix": "nvvm",
812     },
813     {
814         "name": "PowerPC",
815         "intrinsic_prefix": "ppc",
816     },
817     {
818         "name": "R600",
819         "intrinsic_prefix": "r600",
820     },
821     {
822         "name": "RISCV",
823         "intrinsic_prefix": "riscv",
824     },
825     {
826         "name": "S390",
827         "intrinsic_prefix": "s390",
828     },
829     {
830         "name": "SPIRV",
831         "intrinsic_prefix": "spv",
832     },
833     {
834         "name": "VE",
835         "intrinsic_prefix": "ve",
836     },
837     {
838         "name": "WebAssembly",
839         "intrinsic_prefix": "wasm",
840     },
841     {
842         "name": "X86",
843         "intrinsic_prefix": "x86",
844     },
845     {
846         "name": "XCore",
847         "intrinsic_prefix": "xcore",
848     },
852     gentbl(
853         name = "intrinsic_" + target["name"] + "_gen",
854         tbl_outs = [(
855             "-gen-intrinsic-enums -intrinsic-prefix=" + target["intrinsic_prefix"],
856             "include/llvm/IR/Intrinsics" + target["name"] + ".h",
857         )],
858         tblgen = ":llvm-min-tblgen",
859         td_file = "include/llvm/IR/Intrinsics.td",
860         td_srcs = glob([
861             "include/llvm/CodeGen/*.td",
862             "include/llvm/IR/*.td",
863         ]),
864     ),
865 ] for target in llvm_target_intrinsics_list]
867 gentbl(
868     name = "attributes_gen",
869     tbl_outs = [("-gen-attrs", "include/llvm/IR/Attributes.inc")],
870     tblgen = ":llvm-min-tblgen",
871     td_file = "include/llvm/IR/Attributes.td",
872     td_srcs = ["include/llvm/IR/Attributes.td"],
875 cc_library(
876     name = "BitstreamReader",
877     srcs = glob([
878         "lib/Bitstream/Reader/*.cpp",
879     ]),
880     hdrs = [
881         "include/llvm/Bitstream/BitCodeEnums.h",
882         "include/llvm/Bitstream/BitCodes.h",
883         "include/llvm/Bitstream/BitstreamReader.h",
884     ],
885     copts = llvm_copts,
886     deps = [
887         ":Support",
888     ],
891 cc_library(
892     name = "BitstreamWriter",
893     hdrs = [
894         "include/llvm/Bitstream/BitCodeEnums.h",
895         "include/llvm/Bitstream/BitCodes.h",
896         "include/llvm/Bitstream/BitstreamWriter.h",
897     ],
898     copts = llvm_copts,
899     deps = [
900         ":Support",
901     ],
904 cc_library(
905     name = "Remarks",
906     srcs = glob(
907         [
908             "lib/Remarks/*.cpp",
909             "lib/Remarks/*.h",
910         ],
911         exclude = ["lib/Remarks/RemarkLinker.cpp"],
912     ),
913     hdrs = glob(
914         [
915             "include/llvm/Remarks/*.h",
916         ],
917         exclude = ["include/llvm/Remarks/RemarkLinker.h"],
918     ) + [
919         "include/llvm-c/Remarks.h",
920     ],
921     copts = llvm_copts,
922     deps = [
923         ":BitstreamReader",
924         ":BitstreamWriter",
925         ":Support",
926     ],
929 cc_library(
930     name = "remark_linker",
931     srcs = ["lib/Remarks/RemarkLinker.cpp"],
932     hdrs = ["include/llvm/Remarks/RemarkLinker.h"],
933     copts = llvm_copts,
934     deps = [
935         ":Object",
936         ":Remarks",
937         ":Support",
938     ],
941 filegroup(
942     name = "llvm_intrinsics_headers",
943     srcs = [
944         "include/llvm/IR/Intrinsics" + target["name"] + ".h"
945         for target in llvm_target_intrinsics_list
946     ],
949 cc_library(
950     name = "Core",
951     srcs = glob([
952         "lib/IR/*.cpp",
953         "lib/IR/*.h",
954     ]),
955     hdrs = glob(
956         [
957             "include/llvm/*.h",
958             "include/llvm/IR/*.h",
959         ],
960         exclude = [
961             "include/llvm/LinkAllPasses.h",
962         ],
963     ) + [
964         "include/llvm-c/Comdat.h",
965         "include/llvm-c/DebugInfo.h",
966         "include/llvm/Analysis/SimplifyQuery.h",
967         "include/llvm/Analysis/ValueTracking.h",
968         "include/llvm/Analysis/WithCache.h",
969     ] + [":llvm_intrinsics_headers"],
970     copts = llvm_copts,
971     textual_hdrs = glob(["include/llvm/IR/*.def"]),
972     deps = [
973         ":BinaryFormat",
974         ":Demangle",
975         ":Remarks",
976         ":Support",
977         ":TargetParser",
978         ":attributes_gen",
979         ":config",
980         ":intrinsic_enums_gen",
981         ":intrinsics_impl_gen",
982     ],
985 cc_library(
986     name = "BitReader",
987     srcs = glob([
988         "lib/Bitcode/Reader/*.cpp",
989         "lib/Bitcode/Reader/*.h",
990     ]),
991     hdrs = [
992         "include/llvm-c/BitReader.h",
993         "include/llvm/Bitcode/BitcodeAnalyzer.h",
994         "include/llvm/Bitcode/BitcodeCommon.h",
995         "include/llvm/Bitcode/BitcodeReader.h",
996         "include/llvm/Bitcode/LLVMBitCodes.h",
997     ],
998     copts = llvm_copts,
999     deps = [
1000         ":BinaryFormat",
1001         ":BitstreamReader",
1002         ":Core",
1003         ":Support",
1004         ":TargetParser",
1005         ":config",
1006     ],
1009 cc_library(
1010     name = "MCParser",
1011     srcs = glob([
1012         "lib/MC/MCParser/*.cpp",
1013     ]),
1014     hdrs = glob(["include/llvm/MC/MCParser/*.h"]),
1015     copts = llvm_copts,
1016     deps = [
1017         ":BinaryFormat",
1018         ":DebugInfoCodeView",
1019         ":MC",
1020         ":Support",
1021         ":TargetParser",
1022         ":config",
1023     ],
1026 cc_library(
1027     name = "TextAPI",
1028     srcs = glob(
1029         [
1030             "lib/TextAPI/**/*.cpp",
1031         ],
1032         exclude = ["lib/TextAPI/BinaryReader/**"],
1033     ),
1034     hdrs = glob(
1035         [
1036             "include/llvm/TextAPI/**/*.h",
1037             "include/llvm/TextAPI/**/*.def",
1038             "lib/TextAPI/**/*.h",
1039         ],
1040         exclude = [
1041             "lib/TextAPI/BinaryReader/**",
1042             "include/llvm/TextAPI/DylibReader.h",
1043         ],
1044     ),
1045     copts = llvm_copts,
1046     deps = [
1047         ":BinaryFormat",
1048         ":Support",
1049         ":TargetParser",
1050     ],
1053 cc_library(
1054     name = "TextAPIBinaryReader",
1055     srcs = glob([
1056         "lib/TextAPI/BinaryReader/**/*.cpp",
1057     ]),
1058     hdrs = ["include/llvm/TextAPI/DylibReader.h"],
1059     copts = llvm_copts,
1060     deps = [
1061         ":DebugInfoDWARF",
1062         ":Object",
1063         ":Support",
1064         ":TargetParser",
1065         ":TextAPI",
1066     ],
1069 cc_library(
1070     name = "ObjCopy",
1071     srcs = glob([
1072         "lib/ObjCopy/**/*.cpp",
1073         "lib/ObjCopy/**/*.h",
1074     ]),
1075     hdrs = glob([
1076         "include/llvm/ObjCopy/**/*.h",
1077     ]),
1078     copts = llvm_copts,
1079     includes = ["lib/ObjCopy"],
1080     deps = [
1081         ":BinaryFormat",
1082         ":MC",
1083         ":Object",
1084         ":ObjectYAML",
1085         ":Option",
1086         ":Support",
1087         ":Target",
1088         ":intrinsics_impl_gen",
1089     ],
1092 cc_library(
1093     name = "Object",
1094     srcs = glob([
1095         "lib/Object/*.cpp",
1096         "lib/Object/*.h",
1097     ]),
1098     hdrs = glob([
1099         "include/llvm/Object/*.h",
1100     ]) + [
1101         "include/llvm-c/Object.h",
1102     ],
1103     copts = llvm_copts,
1104     deps = [
1105         ":BinaryFormat",
1106         ":BitReader",
1107         ":Core",
1108         ":IRReader",
1109         ":MC",
1110         ":MCParser",
1111         ":Support",
1112         ":TargetParser",
1113         ":TextAPI",
1114         ":config",
1115     ],
1118 cc_library(
1119     name = "ObjectYAML",
1120     srcs = glob([
1121         "lib/ObjectYAML/*.cpp",
1122     ]),
1123     hdrs = glob(["include/llvm/ObjectYAML/*.h"]),
1124     copts = llvm_copts,
1125     deps = [
1126         ":BinaryFormat",
1127         ":DebugInfoCodeView",
1128         ":MC",
1129         ":Object",
1130         ":Support",
1131         ":TargetParser",
1132     ],
1135 cc_library(
1136     name = "ProfileData",
1137     srcs = glob([
1138         "lib/ProfileData/*.cpp",
1139     ]),
1140     hdrs = glob([
1141         "include/llvm/ProfileData/*.h",
1142         "include/llvm/ProfileData/*.inc",
1143     ]),
1144     copts = llvm_copts,
1145     deps = [
1146         ":BitstreamReader",
1147         ":BitstreamWriter",
1148         ":Core",
1149         ":DebugInfo",
1150         ":DebugInfoDWARF",
1151         ":Demangle",
1152         ":Object",
1153         ":Support",
1154         ":Symbolize",
1155         ":TargetParser",
1156         ":config",
1157     ],
1160 cc_library(
1161     name = "Coverage",
1162     srcs = glob([
1163         "lib/ProfileData/Coverage/*.cpp",
1164     ]),
1165     hdrs = glob(["include/llvm/ProfileData/Coverage/*.h"]),
1166     copts = llvm_copts,
1167     deps = [
1168         ":BinaryFormat",
1169         ":Object",
1170         ":ProfileData",
1171         ":Support",
1172         ":TargetParser",
1173     ],
1176 cc_library(
1177     name = "Analysis",
1178     srcs = glob(
1179         [
1180             "lib/Analysis/*.cpp",
1181         ],
1182     ),
1183     hdrs = glob(
1184         [
1185             "include/llvm/Analysis/*.h",
1186             "include/llvm/Analysis/Utils/*.h",
1187         ],
1188     ) + [
1189         "include/llvm-c/Analysis.h",
1190     ],
1191     copts = llvm_copts,
1192     textual_hdrs = glob([
1193         "include/llvm/Analysis/*.def",
1194     ]),
1195     deps = [
1196         ":BinaryFormat",
1197         ":Core",
1198         ":Object",
1199         ":ProfileData",
1200         ":Support",
1201         ":TargetParser",
1202         ":config",
1203     ],
1206 cc_library(
1207     name = "BitWriter",
1208     srcs = glob([
1209         "lib/Bitcode/Writer/*.cpp",
1210         "lib/Bitcode/Writer/*.h",
1211     ]),
1212     hdrs = [
1213         "include/llvm-c/BitWriter.h",
1214         "include/llvm/Bitcode/BitcodeCommon.h",
1215         "include/llvm/Bitcode/BitcodeConvenience.h",
1216         "include/llvm/Bitcode/BitcodeWriter.h",
1217         "include/llvm/Bitcode/BitcodeWriterPass.h",
1218         "include/llvm/Bitcode/LLVMBitCodes.h",
1219     ],
1220     copts = llvm_copts,
1221     deps = [
1222         ":Analysis",
1223         ":BitReader",
1224         ":BitstreamWriter",
1225         ":Core",
1226         ":MC",
1227         ":Object",
1228         ":ProfileData",
1229         ":Support",
1230         ":TargetParser",
1231         ":config",
1232     ],
1235 cc_library(
1236     name = "Target",
1237     srcs = glob([
1238         "lib/Target/*.cpp",
1239     ]),
1240     hdrs = glob([
1241         "include/llvm/Target/*.h",
1242     ]) + [
1243         "include/llvm-c/Target.h",
1244         "include/llvm-c/TargetMachine.h",
1245     ],
1246     copts = llvm_copts,
1247     deps = [
1248         ":Analysis",
1249         ":BinaryFormat",
1250         ":Core",
1251         ":MC",
1252         ":Support",
1253         ":TargetParser",
1254         ":config",
1255     ],
1258 filegroup(
1259     name = "common_target_td_sources",
1260     srcs = glob([
1261         "include/llvm/CodeGen/*.td",
1262         "include/llvm/Frontend/Directive/*.td",
1263         "include/llvm/IR/Intrinsics*.td",
1264         "include/llvm/TableGen/*.td",
1265         "include/llvm/Target/*.td",
1266         "include/llvm/Target/GlobalISel/*.td",
1267     ]),
1270 gentbl(
1271     name = "ARMTargetParserDefGen",
1272     tbl_outs = [("-gen-arm-target-def", "include/llvm/TargetParser/ARMTargetParserDef.inc")],
1273     tblgen = ":llvm-min-tblgen",
1274     td_file = "lib/Target/ARM/ARM.td",
1275     td_srcs = [
1276         ":common_target_td_sources",
1277     ] + glob([
1278         "lib/Target/ARM/**/*.td",
1279     ]),
1282 gentbl(
1283     name = "AArch64TargetParserDefGen",
1284     tbl_outs = [("-gen-arm-target-def", "include/llvm/TargetParser/AArch64TargetParserDef.inc")],
1285     tblgen = ":llvm-min-tblgen",
1286     td_file = "lib/Target/AArch64/AArch64.td",
1287     td_srcs = [
1288         ":common_target_td_sources",
1289     ] + glob([
1290         "lib/Target/AArch64/**/*.td",
1291     ]),
1294 gentbl(
1295     name = "RISCVTargetParserDefGen",
1296     tbl_outs = [("-gen-riscv-target-def", "include/llvm/TargetParser/RISCVTargetParserDef.inc")],
1297     tblgen = ":llvm-min-tblgen",
1298     td_file = "lib/Target/RISCV/RISCV.td",
1299     td_srcs = [
1300         ":common_target_td_sources",
1301     ] + glob([
1302         "lib/Target/RISCV/**/*.td",
1303     ]),
1306 cc_library(
1307     name = "TargetParser",
1308     srcs = glob([
1309         "lib/TargetParser/*.cpp",
1310     ]) + select({
1311         "@platforms//os:windows": glob([
1312             "lib/TargetParser/Windows/*.inc",
1313         ]),
1314         "//conditions:default": glob([
1315             "lib/TargetParser/Unix/*.inc",
1316         ]),
1317     }),
1318     hdrs = glob([
1319         "include/llvm/TargetParser/*.h",
1320     ]),
1321     copts = llvm_copts,
1322     includes = ["include"],
1323     textual_hdrs = [
1324         "include/llvm/TargetParser/AArch64CPUFeatures.inc",
1325         "include/llvm/TargetParser/AArch64FeatPriorities.inc",
1326         "include/llvm/TargetParser/AArch64TargetParserDef.inc",
1327         "include/llvm/TargetParser/ARMTargetParserDef.inc",
1328         "include/llvm/TargetParser/RISCVTargetParserDef.inc",
1329     ] + glob([
1330         "include/llvm/TargetParser/*.def",
1331     ]),
1332     deps = [
1333         ":Support",
1334         ":config",
1335     ],
1338 cc_library(
1339     name = "DWP",
1340     srcs = glob([
1341         "lib/DWP/*.cpp",
1342     ]),
1343     hdrs = glob(["include/llvm/DWP/*.h"]),
1344     copts = llvm_copts,
1345     deps = [
1346         ":DebugInfoDWARF",
1347         ":MC",
1348         ":Object",
1349         ":Support",
1350         ":Target",
1351     ],
1354 cc_library(
1355     name = "TransformUtils",
1356     srcs = glob([
1357         "lib/Transforms/Utils/*.cpp",
1358     ]),
1359     hdrs = glob(["include/llvm/Transforms/Utils/*.h"]) + [
1360         "include/llvm/Transforms/Utils.h",
1361     ],
1362     copts = llvm_copts,
1363     deps = [
1364         ":Analysis",
1365         ":BinaryFormat",
1366         ":BitWriter",
1367         ":Core",
1368         ":ProfileData",
1369         ":Support",
1370         ":Target",
1371         ":TargetParser",
1372         ":config",
1373     ],
1376 gentbl(
1377     name = "InstCombineTableGen",
1378     strip_include_prefix = "lib/Target/AMDGPU",
1379     tbl_outs = [(
1380         "-gen-searchable-tables",
1381         "lib/Target/AMDGPU/InstCombineTables.inc",
1382     )],
1383     tblgen = ":llvm-tblgen",
1384     td_file = "lib/Target/AMDGPU/InstCombineTables.td",
1385     td_srcs = glob([
1386         "lib/Target/AMDGPU/*.td",
1387     ]) + [
1388         ":common_target_td_sources",
1389     ],
1392 cc_library(
1393     name = "InstCombine",
1394     srcs = glob([
1395         "lib/Transforms/InstCombine/*.cpp",
1396         "lib/Transforms/InstCombine/*.h",
1397     ]),
1398     hdrs = glob(["include/llvm/Transforms/InstCombine/*.h"]),
1399     copts = llvm_copts,
1400     deps = [
1401         ":Analysis",
1402         ":Core",
1403         ":Support",
1404         ":Target",
1405         ":TransformUtils",
1406         ":config",
1407     ],
1410 cc_library(
1411     name = "AggressiveInstCombine",
1412     srcs = glob([
1413         "lib/Transforms/AggressiveInstCombine/*.cpp",
1414         "lib/Transforms/AggressiveInstCombine/*.h",
1415     ]),
1416     hdrs = [
1417         "include/llvm/Transforms/AggressiveInstCombine/AggressiveInstCombine.h",
1418     ],
1419     copts = llvm_copts,
1420     deps = [
1421         ":Analysis",
1422         ":Core",
1423         ":Support",
1424         ":TransformUtils",
1425     ],
1428 cc_library(
1429     name = "Instrumentation",
1430     srcs = glob([
1431         "lib/Transforms/Instrumentation/*.cpp",
1432         "lib/Transforms/Instrumentation/*.h",
1433         "lib/Transforms/Instrumentation/*.inc",
1434     ]),
1435     hdrs = glob(["include/llvm/Transforms/Instrumentation/*.h"]) + [
1436         "include/llvm/Transforms/Utils/Instrumentation.h",
1437     ],
1438     copts = llvm_copts,
1439     deps = [
1440         ":Analysis",
1441         ":BinaryFormat",
1442         ":Core",
1443         ":Demangle",
1444         ":MC",
1445         ":ProfileData",
1446         ":Scalar",
1447         ":Support",
1448         ":Target",
1449         ":TargetParser",
1450         ":TransformUtils",
1451         ":config",
1452     ],
1455 cc_library(
1456     name = "ObjCARC",
1457     srcs = glob([
1458         "lib/Transforms/ObjCARC/*.cpp",
1459         "lib/Transforms/ObjCARC/*.h",
1460     ]),
1461     hdrs = ["include/llvm/Transforms/ObjCARC.h"],
1462     copts = llvm_copts,
1463     deps = [
1464         ":Analysis",
1465         ":Core",
1466         ":Support",
1467         ":Target",
1468         ":TransformUtils",
1469         ":config",
1470     ],
1473 cc_library(
1474     name = "SandboxIR",
1475     srcs = glob([
1476         "lib/SandboxIR/*.cpp",
1477     ]),
1478     hdrs = glob(["include/llvm/SandboxIR/*.h"]),
1479     copts = llvm_copts,
1480     textual_hdrs = ["include/llvm/SandboxIR/Values.def"],
1481     deps = [
1482         ":Analysis",
1483         ":Core",
1484         ":Support",
1485     ],
1488 cc_library(
1489     name = "Scalar",
1490     srcs = glob([
1491         "lib/Transforms/Scalar/*.cpp",
1492     ]),
1493     hdrs = glob(["include/llvm/Transforms/Scalar/*.h"]) + [
1494         "include/llvm/Transforms/Scalar.h",
1495     ],
1496     copts = llvm_copts,
1497     deps = [
1498         ":AggressiveInstCombine",
1499         ":Analysis",
1500         ":BinaryFormat",
1501         ":Core",
1502         ":InstCombine",
1503         ":ProfileData",
1504         ":Support",
1505         ":Target",
1506         ":TransformUtils",
1507         ":config",
1508     ],
1511 cc_library(
1512     name = "Vectorize",
1513     srcs = glob([
1514         "lib/Transforms/Vectorize/**/*.cpp",
1515         "lib/Transforms/Vectorize/**/*.h",
1516     ]),
1517     hdrs = glob([
1518         "include/llvm/Transforms/Vectorize/**/*.h",
1519     ]),
1520     copts = llvm_copts,
1521     textual_hdrs = [
1522         "lib/Transforms/Vectorize/SandboxVectorizer/Passes/PassRegistry.def",
1523     ],
1524     deps = [
1525         ":Analysis",
1526         ":Core",
1527         ":SandboxIR",
1528         ":Scalar",
1529         ":Support",
1530         ":Target",
1531         ":TransformUtils",
1532         ":config",
1533     ],
1536 cc_library(
1537     name = "FrontendDebug",
1538     hdrs = glob([
1539         "include/llvm/Frontend/Debug/*.h",
1540     ]),
1541     copts = llvm_copts,
1542     deps = [
1543         ":Support",
1544     ],
1547 cc_library(
1548     name = "FrontendDriver",
1549     srcs = glob([
1550         "lib/Frontend/Driver/*.cpp",
1551     ]),
1552     hdrs = glob([
1553         "include/llvm/Frontend/Driver/*.h",
1554     ]),
1555     copts = llvm_copts,
1556     deps = [
1557         ":Analysis",
1558         ":TargetParser",
1559     ],
1562 cc_library(
1563     name = "FrontendHLSL",
1564     srcs = glob([
1565         "lib/Frontend/HLSL/*.cpp",
1566     ]),
1567     hdrs = glob([
1568         "include/llvm/Frontend/HLSL/*.h",
1569     ]),
1570     copts = llvm_copts,
1571     deps = [
1572         ":Core",
1573         ":Support",
1574     ],
1577 cc_library(
1578     name = "FrontendOffloading",
1579     srcs = glob([
1580         "lib/Frontend/Offloading/*.cpp",
1581     ]),
1582     hdrs = glob([
1583         "include/llvm/Frontend/Offloading/*.h",
1584     ]),
1585     copts = llvm_copts,
1586     deps = [
1587         ":BinaryFormat",
1588         ":Core",
1589         ":Object",
1590         ":Support",
1591         ":TargetParser",
1592         ":TransformUtils",
1593     ],
1596 filegroup(
1597     name = "omp_td_files",
1598     srcs = glob([
1599         "include/llvm/Frontend/OpenMP/*.td",
1600         "include/llvm/Frontend/Directive/*.td",
1601     ]),
1604 gentbl(
1605     name = "omp_gen",
1606     library = False,
1607     tbl_outs = [
1608         ("--gen-directive-decl", "include/llvm/Frontend/OpenMP/OMP.h.inc"),
1609     ],
1610     tblgen = ":llvm-min-tblgen",
1611     td_file = "include/llvm/Frontend/OpenMP/OMP.td",
1612     td_srcs = [":omp_td_files"],
1615 gentbl(
1616     name = "omp_gen_impl",
1617     library = False,
1618     tbl_outs = [
1619         ("--gen-directive-impl", "include/llvm/Frontend/OpenMP/OMP.inc"),
1620     ],
1621     tblgen = ":llvm-min-tblgen",
1622     td_file = "include/llvm/Frontend/OpenMP/OMP.td",
1623     td_srcs = [":omp_td_files"],
1626 cc_library(
1627     name = "FrontendAtomic",
1628     srcs = glob([
1629         "lib/Frontend/Atomic/*.cpp",
1630     ]),
1631     hdrs = glob([
1632         "include/llvm/Frontend/Atomic/*.h",
1633     ]),
1634     copts = llvm_copts,
1635     deps = [
1636         ":Core",
1637         ":Support",
1638     ],
1641 cc_library(
1642     name = "FrontendOpenMP",
1643     srcs = glob([
1644         "lib/Frontend/OpenMP/*.cpp",
1645     ]),
1646     hdrs = glob([
1647         "include/llvm/Frontend/OpenMP/*.h",
1648     ]) + [
1649         "include/llvm/Frontend/OpenMP/OMP.h.inc",
1650         "include/llvm/Frontend/OpenMP/OMP.inc",
1651     ],
1652     copts = llvm_copts,
1653     textual_hdrs = glob([
1654         "include/llvm/Frontend/OpenMP/*.def",
1655     ]),
1656     deps = [
1657         ":Analysis",
1658         ":BitReader",
1659         ":Core",
1660         ":Demangle",
1661         ":FrontendAtomic",
1662         ":FrontendOffloading",
1663         ":MC",
1664         ":Scalar",
1665         ":Support",
1666         ":Target",
1667         ":TargetParser",
1668         ":TransformUtils",
1669     ],
1672 filegroup(
1673     name = "acc_td_files",
1674     srcs = glob([
1675         "include/llvm/Frontend/OpenACC/*.td",
1676         "include/llvm/Frontend/Directive/*.td",
1677     ]),
1680 gentbl(
1681     name = "acc_gen",
1682     library = False,
1683     tbl_outs = [
1684         ("--gen-directive-decl", "include/llvm/Frontend/OpenACC/ACC.h.inc"),
1685     ],
1686     tblgen = ":llvm-min-tblgen",
1687     td_file = "include/llvm/Frontend/OpenACC/ACC.td",
1688     td_srcs = [":acc_td_files"],
1691 gentbl(
1692     name = "acc_gen_impl",
1693     library = False,
1694     tbl_outs = [
1695         ("--gen-directive-impl", "include/llvm/Frontend/OpenACC/ACC.inc"),
1696     ],
1697     tblgen = ":llvm-min-tblgen",
1698     td_file = "include/llvm/Frontend/OpenACC/ACC.td",
1699     td_srcs = [":acc_td_files"],
1702 cc_library(
1703     name = "FrontendOpenACC",
1704     srcs = glob([
1705         "lib/Frontend/OpenACC/*.cpp",
1706     ]) + [
1707         "include/llvm/Frontend/OpenACC/ACC.inc",
1708     ],
1709     hdrs = ["include/llvm/Frontend/OpenACC/ACC.h.inc"],
1710     copts = llvm_copts,
1711     deps = [
1712         ":Analysis",
1713         ":Core",
1714         ":Support",
1715         ":TransformUtils",
1716     ],
1719 cc_library(
1720     name = "AsmParser",
1721     srcs = glob([
1722         "lib/AsmParser/*.cpp",
1723     ]),
1724     hdrs = glob(["include/llvm/AsmParser/*.h"]),
1725     copts = llvm_copts,
1726     deps = [
1727         ":BinaryFormat",
1728         ":Core",
1729         ":Support",
1730         ":attributes_gen",
1731     ],
1734 cc_library(
1735     name = "IRPrinter",
1736     srcs = glob([
1737         "lib/IRPrinter/*.cpp",
1738     ]),
1739     hdrs = glob([
1740         "include/llvm/IRPrinter/*.h",
1741     ]),
1742     copts = llvm_copts,
1743     deps = [
1744         ":Analysis",
1745         ":Core",
1746         ":Support",
1747     ],
1750 cc_library(
1751     name = "IRReader",
1752     srcs = glob([
1753         "lib/IRReader/*.cpp",
1754     ]),
1755     hdrs = glob([
1756         "include/llvm/IRReader/*.h",
1757     ]) + [
1758         "include/llvm-c/IRReader.h",
1759     ],
1760     copts = llvm_copts,
1761     deps = [
1762         ":AsmParser",
1763         ":BitReader",
1764         ":Core",
1765         ":Support",
1766         ":config",
1767     ],
1770 cc_library(
1771     name = "Linker",
1772     srcs = glob([
1773         "lib/Linker/*.cpp",
1774         "lib/Linker/*.h",
1775     ]),
1776     hdrs = glob([
1777         "include/llvm/Linker/*.h",
1778     ]) + [
1779         "include/llvm-c/Linker.h",
1780     ],
1781     copts = llvm_copts,
1782     deps = [
1783         ":Core",
1784         ":Object",
1785         ":Support",
1786         ":TargetParser",
1787         ":TransformUtils",
1788         ":config",
1789     ],
1792 cc_library(
1793     name = "IPO",
1794     srcs = glob([
1795         "lib/Transforms/IPO/*.cpp",
1796     ]),
1797     hdrs = glob([
1798         "include/llvm/Transforms/IPO/*.h",
1799     ]) + [
1800         "include/llvm/Transforms/IPO.h",
1801     ],
1802     copts = llvm_copts,
1803     deps = [
1804         ":AggressiveInstCombine",
1805         ":Analysis",
1806         ":BinaryFormat",
1807         ":BitReader",
1808         ":BitWriter",
1809         ":Core",
1810         ":FrontendOpenMP",
1811         ":IRPrinter",
1812         ":IRReader",
1813         ":InstCombine",
1814         ":Instrumentation",
1815         ":Linker",
1816         ":ObjCARC",
1817         ":Object",
1818         ":ProfileData",
1819         ":Scalar",
1820         ":Support",
1821         ":Target",
1822         ":TargetParser",
1823         ":TransformUtils",
1824         ":Vectorize",
1825         ":config",
1826         ":ir_headers",
1827     ],
1830 cc_library(
1831     name = "CFGuard",
1832     srcs = glob([
1833         "lib/Transforms/CFGuard/*.cpp",
1834     ]),
1835     hdrs = ["include/llvm/Transforms/CFGuard.h"],
1836     copts = llvm_copts,
1837     deps = [
1838         ":Core",
1839         ":Support",
1840         ":TargetParser",
1841     ],
1844 cc_library(
1845     name = "HipStdPar",
1846     srcs = glob([
1847         "lib/Transforms/HipStdPar/*.cpp",
1848     ]),
1849     hdrs = ["include/llvm/Transforms/HipStdPar/HipStdPar.h"],
1850     copts = llvm_copts,
1851     deps = [
1852         ":Analysis",
1853         ":Core",
1854         ":Support",
1855         ":TargetParser",
1856         ":TransformUtils",
1857     ],
1860 cc_library(
1861     name = "Coroutines",
1862     srcs = glob([
1863         "lib/Transforms/Coroutines/*.cpp",
1864         "lib/Transforms/Coroutines/*.h",
1865     ]),
1866     hdrs = glob(["include/llvm/Transforms/Coroutines/*.h"]),
1867     copts = llvm_copts,
1868     deps = [
1869         ":Analysis",
1870         ":BinaryFormat",
1871         ":Core",
1872         ":IPO",
1873         ":Scalar",
1874         ":Support",
1875         ":TransformUtils",
1876         ":config",
1877     ],
1880 # Meta-target for clients which depend on all of the transforms libraries.
1881 cc_library(
1882     name = "common_transforms",
1883     deps = [
1884         ":AggressiveInstCombine",
1885         ":CFGuard",
1886         ":Coroutines",
1887         ":IPO",
1888         ":InstCombine",
1889         ":Instrumentation",
1890         ":ObjCARC",
1891         ":Scalar",
1892         ":Vectorize",
1893     ],
1896 cc_library(
1897     name = "asm_printer_defs",
1898     copts = llvm_copts,
1899     textual_hdrs = glob(["lib/CodeGen/AsmPrinter/*.def"]),
1902 cc_library(
1903     name = "CodeGenTypes",
1904     srcs = glob([
1905         "lib/CodeGenTypes/**/*.cpp",
1906     ]),
1907     hdrs = glob([
1908         "include/llvm/CodeGenTypes/**/*.h",
1909     ]),
1910     copts = llvm_copts,
1911     deps = [
1912         ":Support",
1913         ":vt_gen",
1914     ],
1917 cc_library(
1918     name = "CGData",
1919     srcs = glob(["lib/CGData/**/*.cpp"]),
1920     hdrs = glob([
1921         "include/llvm/CGData/**/*.h",
1922         "include/llvm/CGData/**/*.inc",
1923     ]),
1924     copts = llvm_copts,
1925     deps = [
1926         ":BitReader",
1927         ":BitWriter",
1928         ":Core",
1929         ":Object",
1930         ":ObjectYAML",
1931         ":Support",
1932         ":TargetParser",
1933     ],
1936 cc_library(
1937     name = "CodeGen",
1938     srcs = glob(
1939         [
1940             "lib/CodeGen/**/*.cpp",
1941             "lib/CodeGen/**/*.h",
1942             "lib/CodeGen/SelectionDAG/*.cpp",
1943             "lib/CodeGen/SelectionDAG/*.h",
1944         ],
1945     ),
1946     hdrs = [
1947         "include/llvm/LinkAllPasses.h",
1948     ] + glob(
1949         [
1950             "include/llvm/CodeGen/**/*.h",
1951         ],
1952     ),
1953     copts = llvm_copts,
1954     textual_hdrs = glob([
1955         "include/llvm/CodeGen/**/*.def",
1956     ]),
1957     deps = [
1958         ":AggressiveInstCombine",
1959         ":Analysis",
1960         ":AsmParser",
1961         ":BinaryFormat",
1962         ":BitReader",
1963         ":BitWriter",
1964         ":CFGuard",
1965         ":CGData",
1966         ":CodeGenTypes",
1967         ":Core",
1968         ":DebugInfoCodeView",
1969         ":DebugInfoDWARF",
1970         ":IPO",
1971         ":IRPrinter",
1972         ":Instrumentation",
1973         ":MC",
1974         ":MCParser",
1975         ":ObjCARC",
1976         ":Object",
1977         ":ProfileData",
1978         ":Remarks",
1979         ":Scalar",
1980         ":Support",
1981         ":Target",
1982         ":TargetParser",
1983         ":TransformUtils",
1984         ":asm_printer_defs",
1985         ":config",
1986         ":vt_gen",
1987     ],
1990 cc_library(
1991     name = "MCDisassembler",
1992     srcs = glob([
1993         "lib/MC/MCDisassembler/*.cpp",
1994         "lib/MC/MCDisassembler/*.h",
1995     ]),
1996     hdrs = glob([
1997         "include/llvm/MC/MCDisassembler/*.h",
1998     ]) + [
1999         "include/llvm-c/Disassembler.h",
2000     ],
2001     copts = llvm_copts,
2002     deps = [
2003         ":BinaryFormat",
2004         ":MC",
2005         ":Support",
2006         ":TargetParser",
2007         ":config",
2008     ],
2011 llvm_target_lib_list = [lib for lib in [
2012     {
2013         "name": "AArch64",
2014         "short_name": "AArch64",
2015         "tbl_outs": [
2016             ("-gen-register-bank", "lib/Target/AArch64/AArch64GenRegisterBank.inc"),
2017             ("-gen-register-info", "lib/Target/AArch64/AArch64GenRegisterInfo.inc"),
2018             ("-gen-instr-info", "lib/Target/AArch64/AArch64GenInstrInfo.inc"),
2019             ("-gen-emitter", "lib/Target/AArch64/AArch64GenMCCodeEmitter.inc"),
2020             ("-gen-pseudo-lowering", "lib/Target/AArch64/AArch64GenMCPseudoLowering.inc"),
2021             ("-gen-asm-writer", "lib/Target/AArch64/AArch64GenAsmWriter.inc"),
2022             ("-gen-asm-writer -asmwriternum=1", "lib/Target/AArch64/AArch64GenAsmWriter1.inc"),
2023             ("-gen-asm-matcher", "lib/Target/AArch64/AArch64GenAsmMatcher.inc"),
2024             ("-gen-dag-isel", "lib/Target/AArch64/AArch64GenDAGISel.inc"),
2025             ("-gen-fast-isel", "lib/Target/AArch64/AArch64GenFastISel.inc"),
2026             ("-gen-global-isel", "lib/Target/AArch64/AArch64GenGlobalISel.inc"),
2027             ("-gen-global-isel-combiner -combiners=AArch64O0PreLegalizerCombiner", "lib/Target/AArch64/AArch64GenO0PreLegalizeGICombiner.inc"),
2028             ("-gen-global-isel-combiner -combiners=AArch64PreLegalizerCombiner", "lib/Target/AArch64/AArch64GenPreLegalizeGICombiner.inc"),
2029             ("-gen-global-isel-combiner -combiners=AArch64PostLegalizerCombiner", "lib/Target/AArch64/AArch64GenPostLegalizeGICombiner.inc"),
2030             ("-gen-global-isel-combiner -combiners=AArch64PostLegalizerLowering", "lib/Target/AArch64/AArch64GenPostLegalizeGILowering.inc"),
2031             ("-gen-callingconv", "lib/Target/AArch64/AArch64GenCallingConv.inc"),
2032             ("-gen-subtarget", "lib/Target/AArch64/AArch64GenSubtargetInfo.inc"),
2033             ("-gen-disassembler", "lib/Target/AArch64/AArch64GenDisassemblerTables.inc"),
2034             ("-gen-searchable-tables", "lib/Target/AArch64/AArch64GenSystemOperands.inc"),
2035             ("-gen-exegesis", "lib/Target/AArch64/AArch64GenExegesis.inc"),
2036         ],
2037     },
2038     {
2039         "name": "ARM",
2040         "short_name": "ARM",
2041         "tbl_outs": [
2042             ("-gen-register-bank", "lib/Target/ARM/ARMGenRegisterBank.inc"),
2043             ("-gen-register-info", "lib/Target/ARM/ARMGenRegisterInfo.inc"),
2044             ("-gen-searchable-tables", "lib/Target/ARM/ARMGenSystemRegister.inc"),
2045             ("-gen-instr-info", "lib/Target/ARM/ARMGenInstrInfo.inc"),
2046             ("-gen-emitter", "lib/Target/ARM/ARMGenMCCodeEmitter.inc"),
2047             ("-gen-pseudo-lowering", "lib/Target/ARM/ARMGenMCPseudoLowering.inc"),
2048             ("-gen-asm-writer", "lib/Target/ARM/ARMGenAsmWriter.inc"),
2049             ("-gen-asm-matcher", "lib/Target/ARM/ARMGenAsmMatcher.inc"),
2050             ("-gen-dag-isel", "lib/Target/ARM/ARMGenDAGISel.inc"),
2051             ("-gen-fast-isel", "lib/Target/ARM/ARMGenFastISel.inc"),
2052             ("-gen-global-isel", "lib/Target/ARM/ARMGenGlobalISel.inc"),
2053             ("-gen-callingconv", "lib/Target/ARM/ARMGenCallingConv.inc"),
2054             ("-gen-subtarget", "lib/Target/ARM/ARMGenSubtargetInfo.inc"),
2055             ("-gen-disassembler", "lib/Target/ARM/ARMGenDisassemblerTables.inc"),
2056         ],
2057     },
2058     {
2059         "name": "AMDGPU",
2060         "short_name": "AMDGPU",
2061         "tbl_outs": [
2062             ("-gen-register-bank", "lib/Target/AMDGPU/AMDGPUGenRegisterBank.inc"),
2063             ("-gen-register-info", "lib/Target/AMDGPU/AMDGPUGenRegisterInfo.inc"),
2064             ("-gen-instr-info", "lib/Target/AMDGPU/AMDGPUGenInstrInfo.inc"),
2065             ("-gen-emitter", "lib/Target/AMDGPU/AMDGPUGenMCCodeEmitter.inc"),
2066             ("-gen-pseudo-lowering", "lib/Target/AMDGPU/AMDGPUGenMCPseudoLowering.inc"),
2067             ("-gen-asm-writer", "lib/Target/AMDGPU/AMDGPUGenAsmWriter.inc"),
2068             ("-gen-asm-matcher", "lib/Target/AMDGPU/AMDGPUGenAsmMatcher.inc"),
2069             ("-gen-dag-isel", "lib/Target/AMDGPU/AMDGPUGenDAGISel.inc"),
2070             ("-gen-callingconv", "lib/Target/AMDGPU/AMDGPUGenCallingConv.inc"),
2071             ("-gen-subtarget", "lib/Target/AMDGPU/AMDGPUGenSubtargetInfo.inc"),
2072             ("-gen-disassembler", "lib/Target/AMDGPU/AMDGPUGenDisassemblerTables.inc"),
2073             ("-gen-searchable-tables", "lib/Target/AMDGPU/AMDGPUGenSearchableTables.inc"),
2074         ],
2075         "tbl_deps": [
2076             ":InstCombineTableGen",
2077             ":amdgpu_isel_target_gen",
2078             ":r600_target_gen",
2079         ],
2080     },
2081     {
2082         "name": "AVR",
2083         "short_name": "AVR",
2084         "tbl_outs": [
2085             ("-gen-asm-matcher", "lib/Target/AVR/AVRGenAsmMatcher.inc"),
2086             ("-gen-asm-writer", "lib/Target/AVR/AVRGenAsmWriter.inc"),
2087             ("-gen-callingconv", "lib/Target/AVR/AVRGenCallingConv.inc"),
2088             ("-gen-dag-isel", "lib/Target/AVR/AVRGenDAGISel.inc"),
2089             ("-gen-disassembler", "lib/Target/AVR/AVRGenDisassemblerTables.inc"),
2090             ("-gen-emitter", "lib/Target/AVR/AVRGenMCCodeEmitter.inc"),
2091             ("-gen-instr-info", "lib/Target/AVR/AVRGenInstrInfo.inc"),
2092             ("-gen-register-info", "lib/Target/AVR/AVRGenRegisterInfo.inc"),
2093             ("-gen-subtarget", "lib/Target/AVR/AVRGenSubtargetInfo.inc"),
2094         ],
2095     },
2096     {
2097         "name": "BPF",
2098         "short_name": "BPF",
2099         "tbl_outs": [
2100             ("-gen-register-bank", "lib/Target/BPF/BPFGenRegisterBank.inc"),
2101             ("-gen-asm-writer", "lib/Target/BPF/BPFGenAsmWriter.inc"),
2102             ("-gen-asm-matcher", "lib/Target/BPF/BPFGenAsmMatcher.inc"),
2103             ("-gen-callingconv", "lib/Target/BPF/BPFGenCallingConv.inc"),
2104             ("-gen-dag-isel", "lib/Target/BPF/BPFGenDAGISel.inc"),
2105             ("-gen-global-isel", "lib/Target/BPF/BPFGenGlobalISel.inc"),
2106             ("-gen-disassembler", "lib/Target/BPF/BPFGenDisassemblerTables.inc"),
2107             ("-gen-emitter", "lib/Target/BPF/BPFGenMCCodeEmitter.inc"),
2108             ("-gen-instr-info", "lib/Target/BPF/BPFGenInstrInfo.inc"),
2109             ("-gen-register-info", "lib/Target/BPF/BPFGenRegisterInfo.inc"),
2110             ("-gen-subtarget", "lib/Target/BPF/BPFGenSubtargetInfo.inc"),
2111         ],
2112     },
2113     {
2114         "name": "Hexagon",
2115         "short_name": "Hexagon",
2116         "tbl_outs": [
2117             ("-gen-asm-matcher", "lib/Target/Hexagon/HexagonGenAsmMatcher.inc"),
2118             ("-gen-asm-writer", "lib/Target/Hexagon/HexagonGenAsmWriter.inc"),
2119             ("-gen-callingconv", "lib/Target/Hexagon/HexagonGenCallingConv.inc"),
2120             ("-gen-dag-isel", "lib/Target/Hexagon/HexagonGenDAGISel.inc"),
2121             ("-gen-dfa-packetizer", "lib/Target/Hexagon/HexagonGenDFAPacketizer.inc"),
2122             ("-gen-disassembler", "lib/Target/Hexagon/HexagonGenDisassemblerTables.inc"),
2123             ("-gen-instr-info", "lib/Target/Hexagon/HexagonGenInstrInfo.inc"),
2124             ("-gen-emitter", "lib/Target/Hexagon/HexagonGenMCCodeEmitter.inc"),
2125             ("-gen-register-info", "lib/Target/Hexagon/HexagonGenRegisterInfo.inc"),
2126             ("-gen-subtarget", "lib/Target/Hexagon/HexagonGenSubtargetInfo.inc"),
2127         ],
2128     },
2129     {
2130         "name": "Lanai",
2131         "short_name": "Lanai",
2132         "tbl_outs": [
2133             ("-gen-asm-matcher", "lib/Target/Lanai/LanaiGenAsmMatcher.inc"),
2134             ("-gen-asm-writer", "lib/Target/Lanai/LanaiGenAsmWriter.inc"),
2135             ("-gen-callingconv", "lib/Target/Lanai/LanaiGenCallingConv.inc"),
2136             ("-gen-dag-isel", "lib/Target/Lanai/LanaiGenDAGISel.inc"),
2137             ("-gen-disassembler", "lib/Target/Lanai/LanaiGenDisassemblerTables.inc"),
2138             ("-gen-emitter", "lib/Target/Lanai/LanaiGenMCCodeEmitter.inc"),
2139             ("-gen-instr-info", "lib/Target/Lanai/LanaiGenInstrInfo.inc"),
2140             ("-gen-register-info", "lib/Target/Lanai/LanaiGenRegisterInfo.inc"),
2141             ("-gen-subtarget", "lib/Target/Lanai/LanaiGenSubtargetInfo.inc"),
2142         ],
2143     },
2144     {
2145         "name": "LoongArch",
2146         "short_name": "LoongArch",
2147         "tbl_outs": [
2148             ("-gen-asm-matcher", "lib/Target/LoongArch/LoongArchGenAsmMatcher.inc"),
2149             ("-gen-asm-writer", "lib/Target/LoongArch/LoongArchGenAsmWriter.inc"),
2150             ("-gen-dag-isel", "lib/Target/LoongArch/LoongArchGenDAGISel.inc"),
2151             ("-gen-disassembler", "lib/Target/LoongArch/LoongArchGenDisassemblerTables.inc"),
2152             ("-gen-emitter", "lib/Target/LoongArch/LoongArchGenMCCodeEmitter.inc"),
2153             ("-gen-instr-info", "lib/Target/LoongArch/LoongArchGenInstrInfo.inc"),
2154             ("-gen-pseudo-lowering", "lib/Target/LoongArch/LoongArchGenMCPseudoLowering.inc"),
2155             ("-gen-register-info", "lib/Target/LoongArch/LoongArchGenRegisterInfo.inc"),
2156             ("-gen-subtarget", "lib/Target/LoongArch/LoongArchGenSubtargetInfo.inc"),
2157         ],
2158     },
2159     {
2160         "name": "Mips",
2161         "short_name": "Mips",
2162         "tbl_outs": [
2163             ("-gen-asm-matcher", "lib/Target/Mips/MipsGenAsmMatcher.inc"),
2164             ("-gen-asm-writer", "lib/Target/Mips/MipsGenAsmWriter.inc"),
2165             ("-gen-callingconv", "lib/Target/Mips/MipsGenCallingConv.inc"),
2166             ("-gen-dag-isel", "lib/Target/Mips/MipsGenDAGISel.inc"),
2167             ("-gen-disassembler", "lib/Target/Mips/MipsGenDisassemblerTables.inc"),
2168             ("-gen-emitter", "lib/Target/Mips/MipsGenMCCodeEmitter.inc"),
2169             ("-gen-exegesis", "lib/Target/Mips/MipsGenExegesis.inc"),
2170             ("-gen-fast-isel", "lib/Target/Mips/MipsGenFastISel.inc"),
2171             ("-gen-global-isel", "lib/Target/Mips/MipsGenGlobalISel.inc"),
2172             ("-gen-global-isel-combiner -combiners=MipsPostLegalizerCombiner", "lib/Target/Mips/MipsGenPostLegalizeGICombiner.inc"),
2173             ("-gen-instr-info", "lib/Target/Mips/MipsGenInstrInfo.inc"),
2174             ("-gen-pseudo-lowering", "lib/Target/Mips/MipsGenMCPseudoLowering.inc"),
2175             ("-gen-register-bank", "lib/Target/Mips/MipsGenRegisterBank.inc"),
2176             ("-gen-register-info", "lib/Target/Mips/MipsGenRegisterInfo.inc"),
2177             ("-gen-subtarget", "lib/Target/Mips/MipsGenSubtargetInfo.inc"),
2178         ],
2179     },
2180     {
2181         "name": "MSP430",
2182         "short_name": "MSP430",
2183         "tbl_outs": [
2184             ("-gen-asm-matcher", "lib/Target/MSP430/MSP430GenAsmMatcher.inc"),
2185             ("-gen-asm-writer", "lib/Target/MSP430/MSP430GenAsmWriter.inc"),
2186             ("-gen-callingconv", "lib/Target/MSP430/MSP430GenCallingConv.inc"),
2187             ("-gen-dag-isel", "lib/Target/MSP430/MSP430GenDAGISel.inc"),
2188             ("-gen-disassembler", "lib/Target/MSP430/MSP430GenDisassemblerTables.inc"),
2189             ("-gen-emitter", "lib/Target/MSP430/MSP430GenMCCodeEmitter.inc"),
2190             ("-gen-instr-info", "lib/Target/MSP430/MSP430GenInstrInfo.inc"),
2191             ("-gen-register-info", "lib/Target/MSP430/MSP430GenRegisterInfo.inc"),
2192             ("-gen-subtarget", "lib/Target/MSP430/MSP430GenSubtargetInfo.inc"),
2193         ],
2194     },
2195     {
2196         "name": "NVPTX",
2197         "short_name": "NVPTX",
2198         "tbl_outs": [
2199             ("-gen-register-info", "lib/Target/NVPTX/NVPTXGenRegisterInfo.inc"),
2200             ("-gen-instr-info", "lib/Target/NVPTX/NVPTXGenInstrInfo.inc"),
2201             ("-gen-asm-writer", "lib/Target/NVPTX/NVPTXGenAsmWriter.inc"),
2202             ("-gen-dag-isel", "lib/Target/NVPTX/NVPTXGenDAGISel.inc"),
2203             ("-gen-subtarget", "lib/Target/NVPTX/NVPTXGenSubtargetInfo.inc"),
2204         ],
2205     },
2206     {
2207         "name": "PowerPC",
2208         "short_name": "PPC",
2209         "tbl_outs": [
2210             ("-gen-asm-writer", "lib/Target/PowerPC/PPCGenAsmWriter.inc"),
2211             ("-gen-asm-matcher", "lib/Target/PowerPC/PPCGenAsmMatcher.inc"),
2212             ("-gen-emitter", "lib/Target/PowerPC/PPCGenMCCodeEmitter.inc"),
2213             ("-gen-register-info", "lib/Target/PowerPC/PPCGenRegisterInfo.inc"),
2214             ("-gen-instr-info", "lib/Target/PowerPC/PPCGenInstrInfo.inc"),
2215             ("-gen-dag-isel", "lib/Target/PowerPC/PPCGenDAGISel.inc"),
2216             ("-gen-fast-isel", "lib/Target/PowerPC/PPCGenFastISel.inc"),
2217             ("-gen-callingconv", "lib/Target/PowerPC/PPCGenCallingConv.inc"),
2218             ("-gen-subtarget", "lib/Target/PowerPC/PPCGenSubtargetInfo.inc"),
2219             ("-gen-disassembler", "lib/Target/PowerPC/PPCGenDisassemblerTables.inc"),
2220             ("-gen-register-bank", "lib/Target/PowerPC/PPCGenRegisterBank.inc"),
2221             ("-gen-global-isel", "lib/Target/PowerPC/PPCGenGlobalISel.inc"),
2222             ("-gen-exegesis", "lib/Target/PowerPC/PPCGenExegesis.inc"),
2223         ],
2224     },
2225     {
2226         "name": "RISCV",
2227         "short_name": "RISCV",
2228         "tbl_outs": [
2229             ("-gen-asm-matcher", "lib/Target/RISCV/RISCVGenAsmMatcher.inc"),
2230             ("-gen-asm-writer", "lib/Target/RISCV/RISCVGenAsmWriter.inc"),
2231             ("-gen-compress-inst-emitter", "lib/Target/RISCV/RISCVGenCompressInstEmitter.inc"),
2232             ("-gen-dag-isel", "lib/Target/RISCV/RISCVGenDAGISel.inc"),
2233             ("-gen-disassembler", "lib/Target/RISCV/RISCVGenDisassemblerTables.inc"),
2234             ("-gen-instr-info", "lib/Target/RISCV/RISCVGenInstrInfo.inc"),
2235             ("-gen-macro-fusion-pred", "lib/Target/RISCV/RISCVGenMacroFusion.inc"),
2236             ("-gen-emitter", "lib/Target/RISCV/RISCVGenMCCodeEmitter.inc"),
2237             ("-gen-pseudo-lowering", "lib/Target/RISCV/RISCVGenMCPseudoLowering.inc"),
2238             ("-gen-register-bank", "lib/Target/RISCV/RISCVGenRegisterBank.inc"),
2239             ("-gen-register-info", "lib/Target/RISCV/RISCVGenRegisterInfo.inc"),
2240             ("-gen-subtarget", "lib/Target/RISCV/RISCVGenSubtargetInfo.inc"),
2241             ("-gen-searchable-tables", "lib/Target/RISCV/RISCVGenSearchableTables.inc"),
2242             ("-gen-exegesis", "lib/Target/RISCV/RISCVGenExegesis.inc"),
2243         ],
2244         "tbl_deps": [
2245             ":riscv_isel_target_gen",
2246         ],
2247     },
2248     {
2249         "name": "Sparc",
2250         "short_name": "Sparc",
2251         "tbl_outs": [
2252             ("-gen-asm-writer", "lib/Target/Sparc/SparcGenAsmWriter.inc"),
2253             ("-gen-asm-matcher", "lib/Target/Sparc/SparcGenAsmMatcher.inc"),
2254             ("-gen-emitter", "lib/Target/Sparc/SparcGenMCCodeEmitter.inc"),
2255             ("-gen-register-info", "lib/Target/Sparc/SparcGenRegisterInfo.inc"),
2256             ("-gen-instr-info", "lib/Target/Sparc/SparcGenInstrInfo.inc"),
2257             ("-gen-dag-isel", "lib/Target/Sparc/SparcGenDAGISel.inc"),
2258             ("-gen-callingconv", "lib/Target/Sparc/SparcGenCallingConv.inc"),
2259             ("-gen-subtarget", "lib/Target/Sparc/SparcGenSubtargetInfo.inc"),
2260             ("-gen-disassembler", "lib/Target/Sparc/SparcGenDisassemblerTables.inc"),
2261             ("-gen-searchable-tables", "lib/Target/Sparc/SparcGenSearchableTables.inc"),
2262         ],
2263     },
2264     {
2265         "name": "SPIRV",
2266         "short_name": "SPIRV",
2267         "tbl_outs": [
2268             ("-gen-asm-writer", "lib/Target/SPIRV/SPIRVGenAsmWriter.inc"),
2269             ("-gen-emitter", "lib/Target/SPIRV/SPIRVGenMCCodeEmitter.inc"),
2270             ("-gen-global-isel", "lib/Target/SPIRV/SPIRVGenGlobalISel.inc"),
2271             ("-gen-global-isel-combiner -combiners=SPIRVPreLegalizerCombiner", "lib/Target/SPIRV/SPIRVGenPreLegalizeGICombiner.inc"),
2272             ("-gen-instr-info", "lib/Target/SPIRV/SPIRVGenInstrInfo.inc"),
2273             ("-gen-register-bank", "lib/Target/SPIRV/SPIRVGenRegisterBank.inc"),
2274             ("-gen-register-info", "lib/Target/SPIRV/SPIRVGenRegisterInfo.inc"),
2275             ("-gen-searchable-tables", "lib/Target/SPIRV/SPIRVGenTables.inc"),
2276             ("-gen-subtarget", "lib/Target/SPIRV/SPIRVGenSubtargetInfo.inc"),
2277         ],
2278     },
2279     {
2280         "name": "SystemZ",
2281         "short_name": "SystemZ",
2282         "tbl_outs": [
2283             ("-gen-asm-matcher", "lib/Target/SystemZ/SystemZGenAsmMatcher.inc"),
2284             ("-gen-asm-writer", "lib/Target/SystemZ/SystemZGenGNUAsmWriter.inc"),
2285             ("-gen-asm-writer -asmwriternum=1", "lib/Target/SystemZ/SystemZGenHLASMAsmWriter.inc"),
2286             ("-gen-callingconv", "lib/Target/SystemZ/SystemZGenCallingConv.inc"),
2287             ("-gen-dag-isel", "lib/Target/SystemZ/SystemZGenDAGISel.inc"),
2288             ("-gen-disassembler", "lib/Target/SystemZ/SystemZGenDisassemblerTables.inc"),
2289             ("-gen-emitter", "lib/Target/SystemZ/SystemZGenMCCodeEmitter.inc"),
2290             ("-gen-instr-info", "lib/Target/SystemZ/SystemZGenInstrInfo.inc"),
2291             ("-gen-register-info", "lib/Target/SystemZ/SystemZGenRegisterInfo.inc"),
2292             ("-gen-subtarget", "lib/Target/SystemZ/SystemZGenSubtargetInfo.inc"),
2293         ],
2294     },
2295     {
2296         "name": "VE",
2297         "short_name": "VE",
2298         "tbl_outs": [
2299             ("-gen-asm-matcher", "lib/Target/VE/VEGenAsmMatcher.inc"),
2300             ("-gen-asm-writer", "lib/Target/VE/VEGenAsmWriter.inc"),
2301             ("-gen-callingconv", "lib/Target/VE/VEGenCallingConv.inc"),
2302             ("-gen-dag-isel", "lib/Target/VE/VEGenDAGISel.inc"),
2303             ("-gen-disassembler", "lib/Target/VE/VEGenDisassemblerTables.inc"),
2304             ("-gen-emitter", "lib/Target/VE/VEGenMCCodeEmitter.inc"),
2305             ("-gen-instr-info", "lib/Target/VE/VEGenInstrInfo.inc"),
2306             ("-gen-register-info", "lib/Target/VE/VEGenRegisterInfo.inc"),
2307             ("-gen-subtarget", "lib/Target/VE/VEGenSubtargetInfo.inc"),
2308         ],
2309     },
2310     {
2311         "name": "WebAssembly",
2312         "short_name": "WebAssembly",
2313         "tbl_outs": [
2314             ("-gen-disassembler", "lib/Target/WebAssembly/WebAssemblyGenDisassemblerTables.inc"),
2315             ("-gen-asm-writer", "lib/Target/WebAssembly/WebAssemblyGenAsmWriter.inc"),
2316             ("-gen-instr-info", "lib/Target/WebAssembly/WebAssemblyGenInstrInfo.inc"),
2317             ("-gen-dag-isel", "lib/Target/WebAssembly/WebAssemblyGenDAGISel.inc"),
2318             ("-gen-fast-isel", "lib/Target/WebAssembly/WebAssemblyGenFastISel.inc"),
2319             ("-gen-emitter", "lib/Target/WebAssembly/WebAssemblyGenMCCodeEmitter.inc"),
2320             ("-gen-register-info", "lib/Target/WebAssembly/WebAssemblyGenRegisterInfo.inc"),
2321             ("-gen-subtarget", "lib/Target/WebAssembly/WebAssemblyGenSubtargetInfo.inc"),
2322             ("-gen-asm-matcher", "lib/Target/WebAssembly/WebAssemblyGenAsmMatcher.inc"),
2323         ],
2324     },
2325     {
2326         "name": "X86",
2327         "short_name": "X86",
2328         "tbl_outs": [
2329             ("-gen-register-bank", "lib/Target/X86/X86GenRegisterBank.inc"),
2330             ("-gen-register-info", "lib/Target/X86/X86GenRegisterInfo.inc"),
2331             ("-gen-disassembler", "lib/Target/X86/X86GenDisassemblerTables.inc"),
2332             ("-gen-instr-info", "lib/Target/X86/X86GenInstrInfo.inc"),
2333             ("-gen-asm-writer", "lib/Target/X86/X86GenAsmWriter.inc"),
2334             ("-gen-asm-writer -asmwriternum=1", "lib/Target/X86/X86GenAsmWriter1.inc"),
2335             ("-gen-asm-matcher", "lib/Target/X86/X86GenAsmMatcher.inc"),
2336             ("-gen-dag-isel", "lib/Target/X86/X86GenDAGISel.inc"),
2337             ("-gen-fast-isel", "lib/Target/X86/X86GenFastISel.inc"),
2338             ("-gen-global-isel", "lib/Target/X86/X86GenGlobalISel.inc"),
2339             ("-gen-callingconv", "lib/Target/X86/X86GenCallingConv.inc"),
2340             ("-gen-subtarget", "lib/Target/X86/X86GenSubtargetInfo.inc"),
2341             ("-gen-x86-fold-tables -asmwriternum=1", "lib/Target/X86/X86GenFoldTables.inc"),
2342             ("-gen-x86-instr-mapping", "lib/Target/X86/X86GenInstrMapping.inc"),
2343             ("-gen-exegesis", "lib/Target/X86/X86GenExegesis.inc"),
2344             ("-gen-x86-mnemonic-tables -asmwriternum=1", "lib/Target/X86/X86GenMnemonicTables.inc"),
2345         ],
2346     },
2347     {
2348         "name": "XCore",
2349         "short_name": "XCore",
2350         "tbl_outs": [
2351             ("-gen-asm-writer", "lib/Target/XCore/XCoreGenAsmWriter.inc"),
2352             ("-gen-callingconv", "lib/Target/XCore/XCoreGenCallingConv.inc"),
2353             ("-gen-dag-isel", "lib/Target/XCore/XCoreGenDAGISel.inc"),
2354             ("-gen-disassembler", "lib/Target/XCore/XCoreGenDisassemblerTables.inc"),
2355             ("-gen-instr-info", "lib/Target/XCore/XCoreGenInstrInfo.inc"),
2356             ("-gen-register-info", "lib/Target/XCore/XCoreGenRegisterInfo.inc"),
2357             ("-gen-subtarget", "lib/Target/XCore/XCoreGenSubtargetInfo.inc"),
2358         ],
2359     },
2360 ] if lib["name"] in llvm_targets]
2362 cc_library(
2363     name = "x86_target_layering_problem_hdrs",
2364     textual_hdrs = ["lib/Target/X86/X86InstrInfo.h"],
2367 gentbl(
2368     name = "amdgpu_isel_target_gen",
2369     strip_include_prefix = "lib/Target/AMDGPU",
2370     tbl_outs = [
2371         ("-gen-global-isel", "lib/Target/AMDGPU/AMDGPUGenGlobalISel.inc"),
2372         ("-gen-global-isel-combiner -combiners=AMDGPUPreLegalizerCombiner", "lib/Target/AMDGPU/AMDGPUGenPreLegalizeGICombiner.inc"),
2373         ("-gen-global-isel-combiner -combiners=AMDGPUPostLegalizerCombiner", "lib/Target/AMDGPU/AMDGPUGenPostLegalizeGICombiner.inc"),
2374         ("-gen-global-isel-combiner -combiners=AMDGPURegBankCombiner", "lib/Target/AMDGPU/AMDGPUGenRegBankGICombiner.inc"),
2375     ],
2376     tblgen = ":llvm-tblgen",
2377     td_file = "lib/Target/AMDGPU/AMDGPUGISel.td",
2378     td_srcs = [
2379         ":common_target_td_sources",
2380     ] + glob([
2381         "lib/Target/AMDGPU/*.td",
2382     ]),
2385 gentbl(
2386     name = "r600_target_gen",
2387     strip_include_prefix = "lib/Target/AMDGPU",
2388     tbl_outs = [
2389         ("-gen-asm-writer", "lib/Target/AMDGPU/R600GenAsmWriter.inc"),
2390         ("-gen-callingconv", "lib/Target/AMDGPU/R600GenCallingConv.inc"),
2391         ("-gen-dag-isel", "lib/Target/AMDGPU/R600GenDAGISel.inc"),
2392         ("-gen-dfa-packetizer", "lib/Target/AMDGPU/R600GenDFAPacketizer.inc"),
2393         ("-gen-instr-info", "lib/Target/AMDGPU/R600GenInstrInfo.inc"),
2394         ("-gen-emitter", "lib/Target/AMDGPU/R600GenMCCodeEmitter.inc"),
2395         ("-gen-register-info", "lib/Target/AMDGPU/R600GenRegisterInfo.inc"),
2396         ("-gen-subtarget", "lib/Target/AMDGPU/R600GenSubtargetInfo.inc"),
2397     ],
2398     tblgen = ":llvm-tblgen",
2399     td_file = "lib/Target/AMDGPU/R600.td",
2400     td_srcs = [
2401         ":common_target_td_sources",
2402     ] + glob([
2403         "lib/Target/AMDGPU/*.td",
2404     ]),
2407 gentbl(
2408     name = "riscv_isel_target_gen",
2409     strip_include_prefix = "lib/Target/RISCV",
2410     tbl_outs = [
2411         ("-gen-global-isel", "lib/Target/RISCV/RISCVGenGlobalISel.inc"),
2412         ("-gen-global-isel-combiner -combiners=RISCVO0PreLegalizerCombiner", "lib/Target/RISCV/RISCVGenO0PreLegalizeGICombiner.inc"),
2413         ("-gen-global-isel-combiner -combiners=RISCVPostLegalizerCombiner", "lib/Target/RISCV/RISCVGenPostLegalizeGICombiner.inc"),
2414         ("-gen-global-isel-combiner -combiners=RISCVPreLegalizerCombiner", "lib/Target/RISCV/RISCVGenPreLegalizeGICombiner.inc"),
2415     ],
2416     tblgen = ":llvm-tblgen",
2417     td_file = "lib/Target/RISCV/RISCVGISel.td",
2418     td_srcs = [
2419         ":common_target_td_sources",
2420     ] + glob([
2421         "lib/Target/RISCV/**/*.td",
2422     ]),
2426     [gentbl(
2427         name = target["name"] + "CommonTableGen",
2428         strip_include_prefix = "lib/Target/" + target["name"],
2429         tbl_outs = target["tbl_outs"],
2430         tblgen = ":llvm-tblgen",
2431         # MSVC isn't happy with long string literals, while other compilers
2432         # which support them get significant compile time improvements with
2433         # them enabled. Ideally this flag would only be enabled on Windows via
2434         # a select() on `@platforms//os:windows,`, but that would
2435         # require refactoring gentbl from a macro into a rule.
2436         # TODO(#92): Refactor gentbl to support this use
2437         tblgen_args = "--long-string-literals=0",
2438         td_file = "lib/Target/" + target["name"] + "/" + target["short_name"] + ".td",
2439         td_srcs = [
2440             ":common_target_td_sources",
2441         ] + glob(
2442             [
2443                 "lib/Target/" + target["name"] + "/*.td",
2444                 "lib/Target/" + target["name"] + "/GISel/*.td",
2445             ],
2446             allow_empty = True,
2447         ),
2448         deps = target.get("tbl_deps", []),
2449     )],
2450     [cc_library(
2451         name = target["name"] + "Info",
2452         srcs = ["lib/Target/" + target["name"] + "/TargetInfo/" + target["name"] + "TargetInfo.cpp"],
2453         hdrs = glob(["lib/Target/" + target["name"] + "/TargetInfo/*.h"]),
2454         copts = llvm_copts,
2455         # Workaround for https://github.com/bazelbuild/bazel/issues/3828
2456         # TODO(gcmn): Remove this when upgrading to a Bazel version containing
2457         # https://github.com/bazelbuild/bazel/commit/e3b7e17b05f1
2458         includes = ["lib/Target/" + target["name"]],
2459         strip_include_prefix = "lib/Target/" + target["name"],
2460         deps = [
2461             ":" + target["name"] + "CommonTableGen",
2462             ":MC",
2463             ":Support",
2464             ":Target",
2465         ],
2466     )],
2467     # We cannot separate the `Utils` and `MCTargetDesc` sublibraries of
2468     # a number of targets due to crisscrossing inclusion of headers.
2469     [cc_library(
2470         name = target["name"] + "UtilsAndDesc",
2471         srcs = glob(
2472             [
2473                 "lib/Target/" + target["name"] + "/MCTargetDesc/*.cpp",
2474                 "lib/Target/" + target["name"] + "/Utils/*.cpp",
2476                 # We have to include these headers here as well as in the `hdrs`
2477                 # below to allow the `.cpp` files to use file-relative-inclusion to
2478                 # find them, even though consumers of this library use inclusion
2479                 # relative to the target with the `strip_includes_prefix` of this
2480                 # library. This mixture is likely incompatible with header modules.
2481                 "lib/Target/" + target["name"] + "/MCTargetDesc/*.h",
2482                 "lib/Target/" + target["name"] + "/Utils/*.h",
2483             ],
2484             allow_empty = True,
2485         ),
2486         hdrs = glob(
2487             [
2488                 "lib/Target/" + target["name"] + "/MCTargetDesc/*.h",
2489                 "lib/Target/" + target["name"] + "/Utils/*.h",
2491                 # This a bit of a hack to allow us to expose common, internal
2492                 # target header files to other libraries within the target via
2493                 # target-relative includes. This usage of headers is inherently
2494                 # non-modular as there is a mixture of target-relative inclusion
2495                 # using this rule and file-relative inclusion using the repeated
2496                 # listing of these headers in the `srcs` of subsequent rules.
2497                 "lib/Target/" + target["name"] + "/*.h",
2499                 # FIXME: The entries below should be `textual_hdrs` instead of
2500                 # `hdrs`, but unfortunately that doesn't work with
2501                 # `strip_include_prefix`:
2502                 # https://github.com/bazelbuild/bazel/issues/12424
2503                 #
2504                 # Once that issue is fixed and released, we can switch this to
2505                 # `textual_hdrs` and remove the feature disabling the various Bazel
2506                 # features (both current and under-development) that motivated the
2507                 # distinction between these two.
2508                 "lib/Target/" + target["name"] + "/*.def",
2509                 "lib/Target/" + target["name"] + "/*.inc",
2510                 "lib/Target/" + target["name"] + "/MCTargetDesc/*.def",
2511             ],
2512             allow_empty = True,
2513         ),
2514         copts = llvm_copts,
2515         features = [
2516             "-parse_headers",
2517             "-header_modules",
2518             "-layering_check",
2519         ],
2520         strip_include_prefix = "lib/Target/" + target["name"],
2521         deps = [
2522             ":BinaryFormat",
2523             ":CodeGen",
2524             ":CodeGenTypes",
2525             ":Core",
2526             ":DebugInfoCodeView",
2527             ":MC",
2528             ":MCDisassembler",
2529             ":Support",
2530             ":Target",
2531             ":config",
2532             ":" + target["name"] + "CommonTableGen",
2533             ":" + target["name"] + "Info",
2534         ],
2535     )],
2536     [cc_library(
2537         name = target["name"] + "CodeGen",
2538         srcs = glob(
2539             [
2540                 "lib/Target/" + target["name"] + "/GISel/*.cpp",
2541                 "lib/Target/" + target["name"] + "/GISel/*.h",
2542                 "lib/Target/" + target["name"] + "/*.cpp",
2543                 "lib/Target/" + target["name"] + "/*.h",
2544             ],
2545             allow_empty = True,
2546         ),
2547         hdrs = ["lib/Target/" + target["name"] + "/" + target["short_name"] + ".h"],
2548         copts = llvm_copts,
2549         features = ["-layering_check"],
2550         strip_include_prefix = "lib/Target/" + target["name"],
2551         textual_hdrs = glob(
2552             [
2553                 "lib/Target/" + target["name"] + "/*.def",
2554                 "lib/Target/" + target["name"] + "/*.inc",
2555             ],
2556             allow_empty = True,
2557         ),
2558         deps = [
2559             ":Analysis",
2560             ":BinaryFormat",
2561             ":CFGuard",
2562             ":CodeGen",
2563             ":CodeGenTypes",
2564             ":Core",
2565             ":IPO",
2566             ":MC",
2567             ":Passes",  # TODO(chandlerc): Likely a layering violation.
2568             ":ProfileData",
2569             ":Scalar",
2570             ":Support",
2571             ":Target",
2572             ":TransformUtils",
2573             ":Vectorize",
2574             ":config",
2575             ":" + target["name"] + "Analysis",
2576             ":" + target["name"] + "CommonTableGen",
2577             ":" + target["name"] + "Info",
2578             ":" + target["name"] + "UtilsAndDesc",
2579         ],
2580     )],
2581     [cc_library(
2582         name = target["name"] + "AsmParser",
2583         srcs = glob(
2584             [
2585                 "lib/Target/" + target["name"] + "/AsmParser/*.cpp",
2586                 "lib/Target/" + target["name"] + "/AsmParser/*.h",
2587             ],
2588             allow_empty = True,
2589         ),
2590         copts = llvm_copts,
2591         deps = [
2592             ":BinaryFormat",
2593             ":CodeGenTypes",
2594             ":MC",
2595             ":MCParser",
2596             ":Support",
2597             ":Target",
2598             ":TargetParser",
2599             ":" + target["name"] + "CodeGen",
2600             ":" + target["name"] + "CommonTableGen",
2601             ":" + target["name"] + "Info",
2602             ":" + target["name"] + "UtilsAndDesc",
2603         ],
2604     )],
2605     # This target is a bit of a hack to allow us to expose internal
2606     # disassembler header files via internal target-relative include paths.
2607     # This usage of headers is inherently non-modular as there is a mixture of
2608     # target-relative inclusion using this rule and same-directory inclusion
2609     # using the repeated listing of these headers in the `srcs` below.
2610     [cc_library(
2611         name = target["name"] + "DisassemblerInternalHeaders",
2612         # FIXME: This should be `textual_hdrs` instead of `hdrs`, but
2613         # unfortunately that doesn't work with `strip_include_prefix`:
2614         # https://github.com/bazelbuild/bazel/issues/12424
2615         #
2616         # Once that issue is fixed and released, we can switch this to
2617         # `textual_hdrs` and remove the feature disabling the various Bazel
2618         # features (both current and under-development) that motivated the
2619         # distinction between these two.
2620         hdrs = glob(
2621             [
2622                 "lib/Target/" + target["name"] + "/Disassembler/*.h",
2623             ],
2624             allow_empty = True,
2625         ),
2626         features = [
2627             "-parse_headers",
2628             "-header_modules",
2629         ],
2630         strip_include_prefix = "lib/Target/" + target["name"],
2631     )],
2632     [cc_library(
2633         name = target["name"] + "Disassembler",
2634         srcs = glob(
2635             [
2636                 "lib/Target/" + target["name"] + "/Disassembler/*.cpp",
2637                 "lib/Target/" + target["name"] + "/Disassembler/*.c",
2638                 "lib/Target/" + target["name"] + "/Disassembler/*.h",
2639             ],
2640             allow_empty = True,
2641         ),
2642         copts = llvm_copts,
2643         features = ["-layering_check"],
2644         deps = [
2645             ":CodeGenTypes",
2646             ":Core",
2647             ":MC",
2648             ":MCDisassembler",
2649             ":Support",
2650             ":Target",
2651             ":" + target["name"] + "CodeGen",
2652             ":" + target["name"] + "DisassemblerInternalHeaders",
2653             ":" + target["name"] + "CommonTableGen",
2654             ":" + target["name"] + "UtilsAndDesc",
2655         ],
2656     )],
2657     [cc_library(
2658         name = target["name"] + "TargetMCA",
2659         srcs = glob(
2660             [
2661                 "lib/Target/" + target["name"] + "/MCA/*.cpp",
2662                 "lib/Target/" + target["name"] + "/MCA/*.c",
2663                 "lib/Target/" + target["name"] + "/MCA/*.h",
2664             ],
2665             allow_empty = True,
2666         ),
2667         copts = llvm_copts,
2668         features = ["-layering_check"],
2669         deps = [
2670             ":CodeGenTypes",
2671             ":MC",
2672             ":MCA",
2673             ":MCParser",
2674             ":Support",
2675             ":" + target["name"] + "DisassemblerInternalHeaders",
2676             ":" + target["name"] + "Info",
2677             ":" + target["name"] + "UtilsAndDesc",
2678         ],
2679     )],
2680     [cc_library(
2681         name = target["name"] + "Analysis",
2682         srcs = glob(
2683             [
2684                 "lib/Target/" + target["name"] + "/Analysis/*.cpp",
2685                 "lib/Target/" + target["name"] + "/Analysis/*.h",
2686             ],
2687             allow_empty = True,
2688         ),
2689         copts = llvm_copts,
2690         features = ["-layering_check"],
2691         deps = [
2692             ":Analysis",
2693             ":Core",
2694             ":Support",
2695             ":TransformUtils",
2696         ],
2697     )],
2698 ] for target in llvm_target_lib_list]
2700 cc_library(
2701     name = "AllTargetsCodeGens",
2702     copts = llvm_copts,
2703     deps = [
2704         target["name"] + "CodeGen"
2705         for target in llvm_target_lib_list
2706     ],
2709 cc_library(
2710     name = "AllTargetsAsmParsers",
2711     copts = llvm_copts,
2712     deps = [
2713         target["name"] + "AsmParser"
2714         for target in llvm_target_lib_list
2715     ],
2718 cc_library(
2719     name = "AllTargetsDisassemblers",
2720     copts = llvm_copts,
2721     deps = [
2722         target["name"] + "Disassembler"
2723         for target in llvm_target_lib_list
2724     ],
2727 cc_library(
2728     name = "AllTargetsMCAs",
2729     copts = llvm_copts,
2730     deps = [
2731         target["name"] + "TargetMCA"
2732         for target in llvm_target_lib_list
2733     ],
2736 cc_library(
2737     name = "pass_registry_def",
2738     copts = llvm_copts,
2739     textual_hdrs = ["lib/Passes/PassRegistry.def"],
2742 cc_library(
2743     name = "Passes",
2744     srcs = glob([
2745         "lib/Passes/*.cpp",
2746     ]),
2747     hdrs = glob([
2748         "include/llvm/Passes/*.h",
2749         "include/llvm/Passes/*.def",
2750         "include/llvm/Passes/*.inc",
2751     ]) + ["include/llvm-c/Transforms/PassBuilder.h"],
2752     copts = llvm_copts,
2753     deps = [
2754         ":AggressiveInstCombine",
2755         ":Analysis",
2756         ":CFGuard",
2757         ":CodeGen",
2758         ":Core",
2759         ":Coroutines",
2760         ":HipStdPar",
2761         ":IPO",
2762         ":IRPrinter",
2763         ":InstCombine",
2764         ":Instrumentation",
2765         ":MC",
2766         ":ObjCARC",
2767         ":Scalar",
2768         ":Support",
2769         ":Target",
2770         ":TransformUtils",
2771         ":Vectorize",
2772         ":common_transforms",
2773         ":config",
2774         ":pass_registry_def",
2775     ],
2778 cc_library(
2779     name = "LTO",
2780     srcs = glob([
2781         "lib/LTO/*.cpp",
2782     ]),
2783     hdrs = glob([
2784         "include/llvm/LTO/*.h",
2785         "include/llvm/LTO/legacy/*.h",
2786     ]) + [
2787         "include/llvm-c/lto.h",
2788     ],
2789     copts = llvm_copts,
2790     deps = [
2791         ":Analysis",
2792         ":BitReader",
2793         ":BitWriter",
2794         ":CGData",
2795         ":CodeGen",
2796         ":CodeGenTypes",
2797         ":Core",
2798         ":IPO",
2799         ":IRPrinter",
2800         ":IRReader",
2801         ":Linker",
2802         ":MC",
2803         ":MCParser",
2804         ":ObjCARC",
2805         ":Object",
2806         ":Passes",
2807         ":Remarks",
2808         ":Scalar",
2809         ":Support",
2810         ":Target",
2811         ":TargetParser",
2812         ":TransformUtils",
2813         ":common_transforms",
2814         ":config",
2815     ],
2818 cc_library(
2819     name = "ExecutionEngine",
2820     srcs = glob([
2821         "lib/ExecutionEngine/*.cpp",
2822         "lib/ExecutionEngine/RuntimeDyld/*.cpp",
2823         "lib/ExecutionEngine/RuntimeDyld/*.h",
2824         "lib/ExecutionEngine/RuntimeDyld/Targets/*.cpp",
2825         "lib/ExecutionEngine/RuntimeDyld/Targets/*.h",
2826     ]),
2827     hdrs = glob(
2828         [
2829             "include/llvm/ExecutionEngine/*.h",
2830         ],
2831         exclude = [
2832             "include/llvm/ExecutionEngine/MCJIT*.h",
2833             "include/llvm/ExecutionEngine/OProfileWrapper.h",
2834         ],
2835     ) + [
2836         "include/llvm-c/ExecutionEngine.h",
2837     ],
2838     copts = llvm_copts,
2839     deps = [
2840         ":BinaryFormat",
2841         ":CodeGen",
2842         ":Core",
2843         ":DebugInfo",
2844         ":MC",
2845         ":MCDisassembler",
2846         ":Object",
2847         ":OrcShared",
2848         ":OrcTargetProcess",
2849         ":Passes",
2850         ":Support",
2851         ":Target",
2852         ":TargetParser",
2853         ":config",
2854     ],
2857 cc_library(
2858     name = "Interpreter",
2859     srcs = glob([
2860         "lib/ExecutionEngine/Interpreter/*.cpp",
2861         "lib/ExecutionEngine/Interpreter/*.h",
2862     ]),
2863     hdrs = ["include/llvm/ExecutionEngine/Interpreter.h"],
2864     copts = llvm_copts,
2865     deps = [
2866         ":CodeGen",
2867         ":Core",
2868         ":ExecutionEngine",
2869         ":Support",
2870         ":Target",
2871         ":config",
2872     ],
2875 gentbl(
2876     name = "JITLinkTableGen",
2877     strip_include_prefix = "lib/ExecutionEngine/JITLink",
2878     tbl_outs = [(
2879         "-gen-opt-parser-defs",
2880         "lib/ExecutionEngine/JITLink/COFFOptions.inc",
2881     )],
2882     tblgen = ":llvm-tblgen",
2883     td_file = "lib/ExecutionEngine/JITLink/COFFOptions.td",
2884     td_srcs = ["include/llvm/Option/OptParser.td"],
2887 cc_library(
2888     name = "JITLink",
2889     srcs = glob([
2890         "lib/ExecutionEngine/JITLink/*.cpp",
2891         "lib/ExecutionEngine/JITLink/*.h",
2892     ]),
2893     hdrs = glob([
2894         "include/llvm/ExecutionEngine/JITLink/*.h",
2895         "include/llvm/ExecutionEngine/Orc/*.h",
2896     ]),
2897     copts = llvm_copts,
2898     deps = [
2899         ":BinaryFormat",
2900         ":ExecutionEngine",
2901         ":JITLinkTableGen",
2902         ":Object",
2903         ":Option",
2904         ":OrcShared",
2905         ":OrcTargetProcess",
2906         ":Support",
2907         ":TargetParser",
2908         ":config",
2909     ],
2912 cc_library(
2913     name = "MCJIT",
2914     srcs = glob([
2915         "lib/ExecutionEngine/MCJIT/*.cpp",
2916         "lib/ExecutionEngine/MCJIT/*.h",
2917     ]),
2918     hdrs = glob(["include/llvm/ExecutionEngine/MCJIT*.h"]),
2919     copts = llvm_copts,
2920     deps = [
2921         ":CodeGen",
2922         ":Core",
2923         ":ExecutionEngine",
2924         ":MC",
2925         ":Object",
2926         ":Support",
2927         ":Target",
2928         ":config",
2929     ],
2932 cc_library(
2933     name = "OrcJIT",
2934     srcs = glob([
2935         "lib/ExecutionEngine/Orc/*.cpp",
2936     ]),
2937     hdrs = glob([
2938         "include/llvm/ExecutionEngine/Orc/*.h",
2939     ]) + [
2940         "include/llvm-c/LLJIT.h",
2941         "include/llvm-c/Orc.h",
2942         "include/llvm-c/OrcEE.h",
2943     ],
2944     copts = llvm_copts,
2945     linkopts = select({
2946         "@platforms//os:android": [],
2947         "@platforms//os:windows": [],
2948         "@platforms//os:freebsd": [],
2949         "@platforms//os:macos": [],
2950         "//conditions:default": [
2951             "-lrt",
2952         ],
2953     }),
2954     deps = [
2955         ":Analysis",
2956         ":BinaryFormat",
2957         ":BitReader",
2958         ":BitWriter",
2959         ":Core",
2960         ":DebugInfoDWARF",
2961         ":ExecutionEngine",
2962         ":JITLink",
2963         ":MC",
2964         ":MCDisassembler",
2965         ":Object",
2966         ":OrcShared",
2967         ":OrcTargetProcess",
2968         ":Passes",
2969         ":Support",
2970         ":Target",
2971         ":TargetParser",
2972         ":TransformUtils",
2973         ":WindowsDriver",
2974         ":config",
2975     ],
2978 cc_library(
2979     name = "OrcShared",
2980     srcs = glob([
2981         "lib/ExecutionEngine/Orc/Shared/*.cpp",
2982     ]),
2983     hdrs = glob([
2984         "include/llvm/ExecutionEngine/Orc/Shared/*.h",
2985     ] + [
2986         "include/llvm/ExecutionEngine/Orc/SymbolStringPool.h",
2987     ]),
2988     copts = llvm_copts,
2989     deps = [
2990         ":BinaryFormat",
2991         ":CodeGen",
2992         ":Core",
2993         ":DebugInfo",
2994         ":MC",
2995         ":MCDisassembler",
2996         ":Object",
2997         ":Passes",
2998         ":Support",
2999         ":Target",
3000         ":config",
3001     ],
3004 cc_library(
3005     name = "OrcDebugging",
3006     srcs = glob([
3007         "lib/ExecutionEngine/Orc/Debugging/*.cpp",
3008     ]),
3009     hdrs = glob([
3010         "include/llvm/ExecutionEngine/Orc/Debugging/*.h",
3011     ]) + ["include/llvm-c/LLJITUtils.h"],
3012     copts = llvm_copts,
3013     deps = [
3014         ":BinaryFormat",
3015         ":DebugInfo",
3016         ":JITLink",
3017         ":OrcJIT",
3018         ":OrcShared",
3019         ":Support",
3020         ":TargetParser",
3021     ],
3024 cc_library(
3025     name = "OrcTargetProcess",
3026     srcs = glob([
3027         "lib/ExecutionEngine/Orc/TargetProcess/*.cpp",
3028         "lib/ExecutionEngine/Orc/TargetProcess/*.h",
3029     ]),
3030     hdrs = glob([
3031         "include/llvm/ExecutionEngine/Orc/TargetProcess/*.h",
3032     ]),
3033     copts = llvm_copts,
3034     linkopts = select({
3035         "@platforms//os:android": [],
3036         "@platforms//os:windows": [],
3037         "@platforms//os:freebsd": [],
3038         "@platforms//os:macos": [],
3039         "//conditions:default": [
3040             "-lrt",
3041         ],
3042     }),
3043     deps = [
3044         ":BinaryFormat",
3045         ":CodeGen",
3046         ":Core",
3047         ":DebugInfo",
3048         ":MC",
3049         ":MCDisassembler",
3050         ":Object",
3051         ":OrcShared",
3052         ":Passes",
3053         ":Support",
3054         ":Target",
3055         ":TargetParser",
3056         ":config",
3057     ],
3060 cc_library(
3061     name = "DWARFLinker",
3062     srcs = glob([
3063         "lib/DWARFLinker/Classic/*.cpp",
3064     ]),
3065     hdrs = glob(["include/llvm/DWARFLinker/Classic/*.h"]),
3066     copts = llvm_copts,
3067     deps = [
3068         ":BinaryFormat",
3069         ":CodeGen",
3070         ":CodeGenTypes",
3071         ":DWARFLinkerBase",
3072         ":DebugInfoDWARF",
3073         ":MC",
3074         ":Support",
3075         ":Target",
3076         ":TargetParser",
3077     ],
3080 cc_library(
3081     name = "DWARFLinkerBase",
3082     srcs = glob([
3083         "lib/DWARFLinker/*.cpp",
3084     ]),
3085     hdrs = glob(["include/llvm/DWARFLinker/*.h"]),
3086     copts = llvm_copts,
3087     deps = [
3088         ":BinaryFormat",
3089         ":CodeGen",
3090         ":DebugInfoDWARF",
3091         ":Support",
3092         ":Target",
3093     ],
3096 cc_library(
3097     name = "DWARFLinkerParallel",
3098     srcs = glob([
3099         "lib/DWARFLinker/Parallel/*.cpp",
3100         "lib/DWARFLinker/Parallel/*.h",
3101     ]),
3102     hdrs = glob(["include/llvm/DWARFLinker/Parallel/*.h"]),
3103     copts = llvm_copts,
3104     deps = [
3105         ":BinaryFormat",
3106         ":CodeGen",
3107         ":DWARFLinkerBase",
3108         ":DebugInfoDWARF",
3109         ":MC",
3110         ":Object",
3111         ":Support",
3112         ":Target",
3113         ":TargetParser",
3114     ],
3117 gentbl(
3118     name = "DllOptionsTableGen",
3119     strip_include_prefix = "lib/ToolDrivers/llvm-dlltool",
3120     tbl_outs = [(
3121         "-gen-opt-parser-defs",
3122         "lib/ToolDrivers/llvm-dlltool/Options.inc",
3123     )],
3124     tblgen = ":llvm-tblgen",
3125     td_file = "lib/ToolDrivers/llvm-dlltool/Options.td",
3126     td_srcs = ["include/llvm/Option/OptParser.td"],
3129 cc_library(
3130     name = "DlltoolDriver",
3131     srcs = glob(["lib/ToolDrivers/llvm-dlltool/*.cpp"]),
3132     hdrs = glob(["include/llvm/ToolDrivers/llvm-dlltool/*.h"]),
3133     copts = llvm_copts,
3134     deps = [
3135         ":DllOptionsTableGen",
3136         ":Object",
3137         ":Option",
3138         ":Support",
3139         ":TargetParser",
3140     ],
3143 gentbl(
3144     name = "LibOptionsTableGen",
3145     strip_include_prefix = "lib/ToolDrivers/llvm-lib",
3146     tbl_outs = [(
3147         "-gen-opt-parser-defs",
3148         "lib/ToolDrivers/llvm-lib/Options.inc",
3149     )],
3150     tblgen = ":llvm-tblgen",
3151     td_file = "lib/ToolDrivers/llvm-lib/Options.td",
3152     td_srcs = ["include/llvm/Option/OptParser.td"],
3155 cc_library(
3156     name = "LibDriver",
3157     srcs = glob(["lib/ToolDrivers/llvm-lib/*.cpp"]),
3158     hdrs = glob(["include/llvm/ToolDrivers/llvm-lib/*.h"]),
3159     copts = llvm_copts,
3160     deps = [
3161         ":BinaryFormat",
3162         ":BitReader",
3163         ":LibOptionsTableGen",
3164         ":Object",
3165         ":Option",
3166         ":Support",
3167     ],
3170 cc_library(
3171     name = "InterfaceStub",
3172     srcs = glob([
3173         "lib/InterfaceStub/*.cpp",
3174     ]),
3175     hdrs = glob([
3176         "include/llvm/InterfaceStub/*.h",
3177     ]),
3178     copts = llvm_copts,
3179     deps = [
3180         ":BinaryFormat",
3181         ":MC",
3182         ":Object",
3183         ":Support",
3184         ":TargetParser",
3185         ":config",
3186     ],
3189 cc_library(
3190     name = "WindowsDriver",
3191     srcs = glob([
3192         "lib/WindowsDriver/*.cpp",
3193     ]),
3194     hdrs = glob([
3195         "include/llvm/WindowsDriver/*.h",
3196     ]),
3197     copts = llvm_copts,
3198     deps = [
3199         ":Option",
3200         ":Support",
3201         ":TargetParser",
3202     ],
3205 cc_library(
3206     name = "WindowsManifest",
3207     srcs = glob([
3208         "lib/WindowsManifest/*.cpp",
3209     ]),
3210     hdrs = glob([
3211         "include/llvm/WindowsManifest/*.h",
3212     ]),
3213     copts = llvm_copts,
3214     deps = [
3215         ":Support",
3216         ":config",
3217     ],
3220 cc_library(
3221     name = "MCA",
3222     srcs = glob([
3223         "lib/MCA/**/*.cpp",
3224     ]),
3225     hdrs = glob([
3226         "include/llvm/MCA/**/*.h",
3227     ]),
3228     copts = llvm_copts,
3229     deps = [
3230         ":MC",
3231         ":MCDisassembler",
3232         ":Object",
3233         ":Support",
3234     ],
3237 cc_library(
3238     name = "MCAApplication",
3239     srcs = glob([
3240         "tools/llvm-mca/Views/*.cpp",
3241     ]) + [
3242         mca_source
3243         for mca_source in glob(["tools/llvm-mca/*.cpp"])
3244         if mca_source != "tools/llvm-mca/llvm-mca.cpp"
3245     ],
3246     hdrs = glob([
3247         "tools/llvm-mca/*.h",
3248         "tools/llvm-mca/Views/*.h",
3249     ]),
3250     strip_include_prefix = "tools/llvm-mca",
3251     deps = [
3252         ":MC",
3253         ":MCA",
3254         ":MCParser",
3255         ":Support",
3256         ":TargetParser",
3257     ],
3260 cc_library(
3261     name = "XRay",
3262     srcs = glob([
3263         "lib/XRay/*.cpp",
3264     ]),
3265     hdrs = glob(["include/llvm/XRay/*.h"]),
3266     copts = llvm_copts,
3267     deps = [
3268         ":Object",
3269         ":Support",
3270         ":TargetParser",
3271     ],
3274 # A flag to pick which `pfm` to use for Exegesis.
3275 # Usage: `--@llvm-project//llvm:pfm=<disable|external|system>`.
3276 # Flag documentation: https://bazel.build/extending/config
3277 string_flag(
3278     name = "pfm",
3279     build_setting_default = "external",
3280     values = [
3281         "disable",  # Don't include pfm at all
3282         "external",  # Build pfm from source
3283         "system",  # Use system pfm (non hermetic)
3284     ],
3287 config_setting(
3288     name = "pfm_disable",
3289     flag_values = {":pfm": "disable"},
3292 config_setting(
3293     name = "pfm_external",
3294     flag_values = {":pfm": "external"},
3297 config_setting(
3298     name = "pfm_system",
3299     flag_values = {":pfm": "system"},
3302 cc_library(
3303     name = "maybe_pfm",
3304     # We want dependencies of this library to have -DHAVE_LIBPFM conditionally
3305     # defined, so we set `defines` instead of `copts`.
3306     defines = select({
3307         ":pfm_external": ["HAVE_LIBPFM=1"],
3308         ":pfm_system": ["HAVE_LIBPFM=1"],
3309         "//conditions:default": [],
3310     }),
3311     deps = select({
3312         ":pfm_external": ["@pfm//:pfm_external"],
3313         ":pfm_system": ["@pfm//:pfm_system"],
3314         "//conditions:default": [],
3315     }),
3318 cc_library(
3319     name = "Exegesis",
3320     srcs = glob(
3321         [
3322             "tools/llvm-exegesis/lib/*.cpp",
3323             # We have to include these headers here as well as in the `hdrs` below
3324             # to allow the `.cpp` files to use file-relative-inclusion to find
3325             # them, even though consumers of this library use inclusion relative to
3326             # `tools/llvm-exegesis/lib` with the `strip_includes_prefix` of this
3327             # library. This mixture appears to be incompatible with header modules.
3328             "tools/llvm-exegesis/lib/*.h",
3329         ] + [
3330             "tools/llvm-exegesis/lib/{}/*.cpp".format(t)
3331             for t in llvm_target_exegesis
3332         ] + [
3333             "tools/llvm-exegesis/lib/{}/*.h".format(t)
3334             for t in llvm_target_exegesis
3335         ],
3336         allow_empty = True,
3337     ),
3338     hdrs = glob(["tools/llvm-exegesis/lib/*.h"]),
3339     copts = llvm_copts,
3340     features = [
3341         "-header_modules",
3342         "-layering_check",
3343     ],
3344     strip_include_prefix = "tools/llvm-exegesis/lib",
3345     deps = [
3346         ":AllTargetsAsmParsers",
3347         ":AllTargetsCodeGens",
3348         ":CodeGen",
3349         ":CodeGenTypes",
3350         ":Core",
3351         ":ExecutionEngine",
3352         ":MC",
3353         ":MCA",
3354         ":MCDisassembler",
3355         ":Object",
3356         ":ObjectYAML",
3357         ":OrcJIT",
3358         ":Support",
3359         ":Target",
3360         ":config",
3361     ] + select({
3362         "@platforms//os:linux": [":maybe_pfm"],
3363         "//conditions:default": [],
3364     }),
3367 ################################################################################
3368 # LLVM toolchain and development binaries
3370 gentbl(
3371     name = "DsymutilTableGen",
3372     strip_include_prefix = "tools/dsymutil",
3373     tbl_outs = [(
3374         "-gen-opt-parser-defs",
3375         "tools/dsymutil/Options.inc",
3376     )],
3377     tblgen = ":llvm-tblgen",
3378     td_file = "tools/dsymutil/Options.td",
3379     td_srcs = ["include/llvm/Option/OptParser.td"],
3382 cc_library(
3383     name = "dsymutil-lib",
3384     srcs = glob([
3385         "tools/dsymutil/*.cpp",
3386         "tools/dsymutil/*.h",
3387     ]),
3388     copts = llvm_copts,
3389     deps = [
3390         ":AllTargetsCodeGens",
3391         ":BinaryFormat",
3392         ":CodeGen",
3393         ":CodeGenTypes",
3394         ":DWARFLinker",
3395         ":DWARFLinkerParallel",
3396         ":DebugInfo",
3397         ":DebugInfoDWARF",
3398         ":DsymutilTableGen",
3399         ":MC",
3400         ":Object",
3401         ":Option",
3402         ":Remarks",
3403         ":Support",
3404         ":Target",
3405         ":TargetParser",
3406         ":config",
3407         ":remark_linker",
3408     ],
3411 llvm_driver_cc_binary(
3412     name = "dsymutil",
3413     stamp = 0,
3414     deps = [":dsymutil-lib"],
3417 cc_binary(
3418     name = "llc",
3419     srcs = glob([
3420         "tools/llc/*.cpp",
3421         "tools/llc/*.h",
3422     ]),
3423     copts = llvm_copts,
3424     stamp = 0,
3425     deps = [
3426         ":AllTargetsAsmParsers",
3427         ":AllTargetsCodeGens",
3428         ":Analysis",
3429         ":AsmParser",
3430         ":BitReader",
3431         ":CodeGen",
3432         ":CodeGenTypes",
3433         ":Core",
3434         ":IRPrinter",
3435         ":IRReader",
3436         ":MC",
3437         ":Passes",
3438         ":Remarks",
3439         ":Scalar",
3440         ":Support",
3441         ":Target",
3442         ":TargetParser",
3443         ":TransformUtils",
3444     ],
3447 cc_binary(
3448     name = "lli",
3449     srcs = glob([
3450         "tools/lli/*.cpp",
3451         "tools/lli/*.h",
3452     ]),
3453     copts = llvm_copts,
3454     # ll scripts rely on symbols from dependent
3455     # libraries being resolvable.
3456     linkopts = select({
3457         "@platforms//os:windows": [],
3458         "@platforms//os:macos": [],
3459         "//conditions:default": [
3460             "-Wl,--undefined=_ZTIi",
3461             "-Wl,--export-dynamic-symbol=_ZTIi",
3462             "-Wl,--export-dynamic-symbol=__cxa_begin_catch",
3463             "-Wl,--export-dynamic-symbol=__cxa_end_catch",
3464             "-Wl,--export-dynamic-symbol=__gxx_personality_v0",
3465             "-Wl,--export-dynamic-symbol=__cxa_allocate_exception",
3466             "-Wl,--export-dynamic-symbol=__cxa_throw",
3467             "-Wl,--export-dynamic-symbol=llvm_orc_registerJITLoaderGDBWrapper",
3468             "-Wl,--export-dynamic-symbol=llvm_orc_registerEHFrameSectionWrapper",
3469             "-Wl,--export-dynamic-symbol=llvm_orc_deregisterEHFrameSectionWrapper",
3470         ],
3471     }),
3472     stamp = 0,
3473     deps = [
3474         ":AllTargetsAsmParsers",
3475         ":AllTargetsCodeGens",
3476         ":AsmParser",
3477         ":BitReader",
3478         ":CodeGen",
3479         ":Core",
3480         ":ExecutionEngine",
3481         ":IRPrinter",
3482         ":IRReader",
3483         ":Instrumentation",
3484         ":Interpreter",
3485         ":MCJIT",
3486         ":Object",
3487         ":OrcDebugging",
3488         ":OrcJIT",
3489         ":OrcTargetProcess",
3490         ":Support",
3491         ":TargetParser",
3492         ":config",
3493     ],
3496 cc_library(
3497     name = "llvm-ar-lib",
3498     srcs = glob(["tools/llvm-ar/*.cpp"]),
3499     copts = llvm_copts,
3500     deps = [
3501         ":AllTargetsAsmParsers",
3502         ":AllTargetsCodeGens",
3503         ":BinaryFormat",
3504         ":Core",
3505         ":DlltoolDriver",
3506         ":LibDriver",
3507         ":Object",
3508         ":Support",
3509         ":TargetParser",
3510     ],
3513 llvm_driver_cc_binary(
3514     name = "llvm-ar",
3515     stamp = 0,
3516     deps = [":llvm-ar-lib"],
3519 # We need to run llvm-ar with different basenames to make it run with
3520 # different behavior.
3521 binary_alias(
3522     name = "llvm-dlltool",
3523     binary = ":llvm-ar",
3526 binary_alias(
3527     name = "llvm-lib",
3528     binary = ":llvm-ar",
3531 binary_alias(
3532     name = "llvm-ranlib",
3533     binary = ":llvm-ar",
3536 cc_binary(
3537     name = "llvm-as",
3538     srcs = glob([
3539         "tools/llvm-as/*.cpp",
3540     ]),
3541     copts = llvm_copts,
3542     stamp = 0,
3543     deps = [
3544         ":Analysis",
3545         ":AsmParser",
3546         ":BitWriter",
3547         ":Core",
3548         ":Support",
3549     ],
3552 cc_binary(
3553     name = "llvm-bcanalyzer",
3554     srcs = glob([
3555         "tools/llvm-bcanalyzer/*.cpp",
3556     ]),
3557     copts = llvm_copts,
3558     stamp = 0,
3559     deps = [
3560         ":BitReader",
3561         ":Support",
3562     ],
3565 cc_binary(
3566     name = "llvm-cat",
3567     srcs = glob([
3568         "tools/llvm-cat/*.cpp",
3569     ]),
3570     copts = llvm_copts,
3571     stamp = 0,
3572     deps = [
3573         ":BitReader",
3574         ":BitWriter",
3575         ":Core",
3576         ":IRPrinter",
3577         ":IRReader",
3578         ":Support",
3579     ],
3582 gentbl(
3583     name = "CGDataOptsTableGen",
3584     strip_include_prefix = "tools/llvm-cgdata",
3585     tbl_outs = [(
3586         "-gen-opt-parser-defs",
3587         "tools/llvm-cgdata/Opts.inc",
3588     )],
3589     tblgen = ":llvm-tblgen",
3590     td_file = "tools/llvm-cgdata/Opts.td",
3591     td_srcs = ["include/llvm/Option/OptParser.td"],
3594 cc_library(
3595     name = "llvm-cgdata-lib",
3596     srcs = glob(["tools/llvm-cgdata/*.cpp"]),
3597     copts = llvm_copts,
3598     deps = [
3599         ":CGData",
3600         ":CGDataOptsTableGen",
3601         ":CodeGen",
3602         ":Core",
3603         ":Object",
3604         ":Option",
3605         ":Support",
3606     ],
3609 llvm_driver_cc_binary(
3610     name = "llvm-cgdata",
3611     stamp = 0,
3612     deps = [":llvm-cgdata-lib"],
3615 cc_binary(
3616     name = "llvm-cfi-verify",
3617     srcs = glob([
3618         "tools/llvm-cfi-verify/*.cpp",
3619         "tools/llvm-cfi-verify/lib/*.cpp",
3620         "tools/llvm-cfi-verify/lib/*.h",
3621     ]),
3622     copts = llvm_copts,
3623     stamp = 0,
3624     deps = [
3625         ":AllTargetsAsmParsers",
3626         ":AllTargetsCodeGens",
3627         ":AllTargetsDisassemblers",
3628         ":BinaryFormat",
3629         ":DebugInfoDWARF",
3630         ":MC",
3631         ":MCDisassembler",
3632         ":MCParser",
3633         ":Object",
3634         ":Support",
3635         ":Symbolize",
3636     ],
3639 cc_binary(
3640     name = "llvm-cov",
3641     srcs = glob([
3642         "tools/llvm-cov/*.cpp",
3643         "tools/llvm-cov/*.h",
3644     ]),
3645     copts = llvm_copts,
3646     stamp = 0,
3647     deps = [
3648         ":Coverage",
3649         ":Debuginfod",
3650         ":Instrumentation",
3651         ":Object",
3652         ":ProfileData",
3653         ":Support",
3654         ":TargetParser",
3655         ":config",
3656     ],
3659 gentbl(
3660     name = "CvtResTableGen",
3661     strip_include_prefix = "tools/llvm-cvtres",
3662     tbl_outs = [(
3663         "-gen-opt-parser-defs",
3664         "tools/llvm-cvtres/Opts.inc",
3665     )],
3666     tblgen = ":llvm-tblgen",
3667     td_file = "tools/llvm-cvtres/Opts.td",
3668     td_srcs = ["include/llvm/Option/OptParser.td"],
3671 cc_binary(
3672     name = "llvm-cvtres",
3673     srcs = glob([
3674         "tools/llvm-cvtres/*.cpp",
3675     ]),
3676     copts = llvm_copts,
3677     stamp = 0,
3678     deps = [
3679         ":BinaryFormat",
3680         ":CvtResTableGen",
3681         ":Object",
3682         ":Option",
3683         ":Support",
3684     ],
3687 cc_binary(
3688     name = "llvm-cxxdump",
3689     srcs = glob([
3690         "tools/llvm-cxxdump/*.cpp",
3691         "tools/llvm-cxxdump/*.h",
3692     ]),
3693     copts = llvm_copts,
3694     stamp = 0,
3695     deps = [
3696         ":AllTargetsCodeGens",
3697         ":BitReader",
3698         ":MC",
3699         ":Object",
3700         ":Support",
3701     ],
3704 cc_binary(
3705     name = "llvm-cxxmap",
3706     srcs = glob([
3707         "tools/llvm-cxxmap/*.cpp",
3708     ]),
3709     copts = llvm_copts,
3710     stamp = 0,
3711     deps = [
3712         ":ProfileData",
3713         ":Support",
3714     ],
3717 gentbl(
3718     name = "CxxfiltOptsTableGen",
3719     strip_include_prefix = "tools/llvm-cxxfilt",
3720     tbl_outs = [(
3721         "-gen-opt-parser-defs",
3722         "tools/llvm-cxxfilt/Opts.inc",
3723     )],
3724     tblgen = ":llvm-tblgen",
3725     td_file = "tools/llvm-cxxfilt/Opts.td",
3726     td_srcs = ["include/llvm/Option/OptParser.td"],
3729 cc_library(
3730     name = "llvm-cxxfilt-lib",
3731     srcs = glob(["tools/llvm-cxxfilt/*.cpp"]),
3732     copts = llvm_copts,
3733     deps = [
3734         ":CxxfiltOptsTableGen",
3735         ":Demangle",
3736         ":Option",
3737         ":Support",
3738         ":TargetParser",
3739     ],
3742 llvm_driver_cc_binary(
3743     name = "llvm-cxxfilt",
3744     stamp = 0,
3745     deps = [":llvm-cxxfilt-lib"],
3748 cc_binary(
3749     name = "llvm-debuginfo-analyzer",
3750     srcs = glob([
3751         "tools/llvm-debuginfo-analyzer/*.cpp",
3752         "tools/llvm-debuginfo-analyzer/*.h",
3753     ]),
3754     copts = llvm_copts,
3755     stamp = 0,
3756     deps = [
3757         ":AllTargetsCodeGens",
3758         ":AllTargetsDisassemblers",
3759         ":DebugInfoLogicalView",
3760         ":Support",
3761     ],
3764 gentbl(
3765     name = "DebugInfodFindOptsTableGen",
3766     strip_include_prefix = "tools/llvm-debuginfod-find",
3767     tbl_outs = [(
3768         "-gen-opt-parser-defs",
3769         "tools/llvm-debuginfod-find/Opts.inc",
3770     )],
3771     tblgen = ":llvm-tblgen",
3772     td_file = "tools/llvm-debuginfod-find/Opts.td",
3773     td_srcs = ["include/llvm/Option/OptParser.td"],
3776 cc_library(
3777     name = "llvm-debuginfod-find-lib",
3778     srcs = glob([
3779         "tools/llvm-debuginfod-find/*.cpp",
3780     ]),
3781     copts = llvm_copts,
3782     deps = [
3783         ":BitReader",
3784         ":Core",
3785         ":DebugInfodFindOptsTableGen",
3786         ":Debuginfod",
3787         ":Option",
3788         ":Support",
3789         ":Symbolize",
3790     ],
3793 llvm_driver_cc_binary(
3794     name = "llvm-debuginfod-find",
3795     stamp = 0,
3796     deps = [":llvm-debuginfod-find-lib"],
3799 cc_binary(
3800     name = "llvm-dis",
3801     srcs = glob([
3802         "tools/llvm-dis/*.cpp",
3803     ]),
3804     copts = llvm_copts,
3805     stamp = 0,
3806     deps = [
3807         ":Analysis",
3808         ":BitReader",
3809         ":Core",
3810         ":Support",
3811     ],
3814 cc_binary(
3815     name = "llvm-dwarfdump",
3816     srcs = glob([
3817         "tools/llvm-dwarfdump/*.cpp",
3818         "tools/llvm-dwarfdump/*.h",
3819     ]),
3820     copts = llvm_copts,
3821     stamp = 0,
3822     deps = [
3823         ":AllTargetsCodeGens",
3824         ":BinaryFormat",
3825         ":DebugInfo",
3826         ":DebugInfoDWARF",
3827         ":MC",
3828         ":Object",
3829         ":Support",
3830         ":TargetParser",
3831     ],
3834 gentbl(
3835     name = "DwarfutilOptionsTableGen",
3836     strip_include_prefix = "tools/llvm-dwarfutil",
3837     tbl_outs = [(
3838         "-gen-opt-parser-defs",
3839         "tools/llvm-dwarfutil/Options.inc",
3840     )],
3841     tblgen = ":llvm-tblgen",
3842     td_file = "tools/llvm-dwarfutil/Options.td",
3843     td_srcs = ["include/llvm/Option/OptParser.td"],
3846 cc_binary(
3847     name = "llvm-dwarfutil",
3848     srcs = glob([
3849         "tools/llvm-dwarfutil/*.cpp",
3850         "tools/llvm-dwarfutil/*.h",
3851     ]),
3852     copts = llvm_copts,
3853     stamp = 0,
3854     deps = [
3855         ":AllTargetsAsmParsers",
3856         ":AllTargetsCodeGens",
3857         ":CodeGenTypes",
3858         ":DWARFLinker",
3859         ":DWARFLinkerParallel",
3860         ":DebugInfoDWARF",
3861         ":DwarfutilOptionsTableGen",
3862         ":MC",
3863         ":ObjCopy",
3864         ":Object",
3865         ":Option",
3866         ":Support",
3867         ":Target",
3868         ":TargetParser",
3869     ],
3872 gentbl(
3873     name = "DwpOptionsTableGen",
3874     strip_include_prefix = "tools/llvm-dwp",
3875     tbl_outs = [(
3876         "-gen-opt-parser-defs",
3877         "tools/llvm-dwp/Opts.inc",
3878     )],
3879     tblgen = ":llvm-tblgen",
3880     td_file = "tools/llvm-dwp/Opts.td",
3881     td_srcs = ["include/llvm/Option/OptParser.td"],
3884 cc_library(
3885     name = "llvm-dwp-lib",
3886     srcs = glob(["tools/llvm-dwp/*.cpp"]),
3887     copts = llvm_copts,
3888     deps = [
3889         ":AllTargetsCodeGens",
3890         ":DWP",
3891         ":DwpOptionsTableGen",
3892         ":MC",
3893         ":Option",
3894         ":Support",
3895     ],
3898 llvm_driver_cc_binary(
3899     name = "llvm-dwp",
3900     stamp = 0,
3901     deps = [":llvm-dwp-lib"],
3904 cc_binary(
3905     name = "llvm-exegesis",
3906     srcs = [
3907         "tools/llvm-exegesis/llvm-exegesis.cpp",
3908     ],
3909     copts = llvm_copts,
3910     stamp = 0,
3911     deps = [
3912         ":AllTargetsAsmParsers",
3913         ":AllTargetsCodeGens",
3914         ":AllTargetsDisassemblers",
3915         ":CodeGenTypes",
3916         ":Exegesis",
3917         ":MC",
3918         ":MCParser",
3919         ":Object",
3920         ":Support",
3921         ":TargetParser",
3922         ":config",
3923     ],
3926 cc_binary(
3927     name = "llvm-extract",
3928     srcs = glob([
3929         "tools/llvm-extract/*.cpp",
3930     ]),
3931     copts = llvm_copts,
3932     stamp = 0,
3933     deps = [
3934         ":AsmParser",
3935         ":BitReader",
3936         ":BitWriter",
3937         ":Core",
3938         ":IPO",
3939         ":IRPrinter",
3940         ":IRReader",
3941         ":Passes",
3942         ":Support",
3943     ],
3946 gentbl(
3947     name = "GSYMUtilOptionsTableGen",
3948     strip_include_prefix = "tools/llvm-gsymutil",
3949     tbl_outs = [(
3950         "-gen-opt-parser-defs",
3951         "tools/llvm-gsymutil/Opts.inc",
3952     )],
3953     tblgen = ":llvm-tblgen",
3954     td_file = "tools/llvm-gsymutil/Opts.td",
3955     td_srcs = ["include/llvm/Option/OptParser.td"],
3958 cc_library(
3959     name = "llvm-gsymutil-lib",
3960     srcs = glob(["tools/llvm-gsymutil/*.cpp"]),
3961     copts = llvm_copts,
3962     deps = [
3963         ":AllTargetsCodeGens",
3964         ":DebugInfo",
3965         ":DebugInfoDWARF",
3966         ":DebugInfoGSYM",
3967         ":GSYMUtilOptionsTableGen",
3968         ":MC",
3969         ":Object",
3970         ":Option",
3971         ":Support",
3972         ":Target",
3973         ":TargetParser",
3974     ],
3977 llvm_driver_cc_binary(
3978     name = "llvm-gsymutil",
3979     stamp = 0,
3980     deps = [":llvm-gsymutil-lib"],
3983 gentbl(
3984     name = "IfsOptionsTableGen",
3985     strip_include_prefix = "tools/llvm-ifs",
3986     tbl_outs = [(
3987         "-gen-opt-parser-defs",
3988         "tools/llvm-ifs/Opts.inc",
3989     )],
3990     tblgen = ":llvm-tblgen",
3991     td_file = "tools/llvm-ifs/Opts.td",
3992     td_srcs = ["include/llvm/Option/OptParser.td"],
3995 cc_library(
3996     name = "llvm-ifs-lib",
3997     srcs = glob([
3998         "tools/llvm-ifs/*.cpp",
3999         "tools/llvm-ifs/*.h",
4000     ]),
4001     copts = llvm_copts,
4002     deps = [
4003         ":BinaryFormat",
4004         ":IfsOptionsTableGen",
4005         ":InterfaceStub",
4006         ":ObjectYAML",
4007         ":Option",
4008         ":Support",
4009         ":TargetParser",
4010         ":TextAPI",
4011     ],
4014 llvm_driver_cc_binary(
4015     name = "llvm-ifs",
4016     stamp = 0,
4017     deps = [":llvm-ifs-lib"],
4020 cc_binary(
4021     name = "llvm-jitlink",
4022     srcs = glob([
4023         "tools/llvm-jitlink/*.cpp",
4024         "tools/llvm-jitlink/*.h",
4025     ]),
4026     copts = llvm_copts,
4027     # Make symbols from the standard library dynamically resolvable.
4028     linkopts = select({
4029         "@platforms//os:windows": [],
4030         "@platforms//os:macos": [],
4031         "//conditions:default": [
4032             "-Wl,--undefined=_ZTIi",
4033             "-Wl,--export-dynamic-symbol=_ZTIi",
4034             "-Wl,--export-dynamic-symbol=__cxa_begin_catch",
4035             "-Wl,--export-dynamic-symbol=__cxa_end_catch",
4036             "-Wl,--export-dynamic-symbol=__gxx_personality_v0",
4037             "-Wl,--export-dynamic-symbol=__cxa_allocate_exception",
4038             "-Wl,--export-dynamic-symbol=__cxa_throw",
4039             "-Wl,--export-dynamic-symbol=llvm_orc_registerJITLoaderGDBWrapper",
4040         ],
4041     }),
4042     stamp = 0,
4043     deps = [
4044         ":AllTargetsAsmParsers",
4045         ":AllTargetsCodeGens",
4046         ":AllTargetsDisassemblers",
4047         ":AsmParser",
4048         ":BinaryFormat",
4049         ":BitReader",
4050         ":CodeGen",
4051         ":ExecutionEngine",
4052         ":MC",
4053         ":MCDisassembler",
4054         ":MCJIT",
4055         ":Object",
4056         ":OrcDebugging",
4057         ":OrcJIT",
4058         ":OrcShared",
4059         ":OrcTargetProcess",
4060         ":Support",
4061         ":TargetParser",
4062         ":config",
4063     ],
4066 gentbl(
4067     name = "LibtoolDarwinOptionsTableGen",
4068     strip_include_prefix = "tools/llvm-libtool-darwin",
4069     tbl_outs = [(
4070         "-gen-opt-parser-defs",
4071         "tools/llvm-libtool-darwin/Opts.inc",
4072     )],
4073     tblgen = ":llvm-tblgen",
4074     td_file = "tools/llvm-libtool-darwin/Opts.td",
4075     td_srcs = ["include/llvm/Option/OptParser.td"],
4078 cc_library(
4079     name = "llvm-libtool-darwin-lib",
4080     srcs = glob([
4081         "tools/llvm-libtool-darwin/*.cpp",
4082         "tools/llvm-libtool-darwin/*.h",
4083     ]),
4084     copts = llvm_copts,
4085     deps = [
4086         ":AllTargetsAsmParsers",
4087         ":AllTargetsCodeGens",
4088         ":BinaryFormat",
4089         ":Core",
4090         ":LibtoolDarwinOptionsTableGen",
4091         ":Object",
4092         ":Option",
4093         ":Support",
4094         ":TextAPI",
4095     ],
4098 llvm_driver_cc_binary(
4099     name = "llvm-libtool-darwin",
4100     stamp = 0,
4101     deps = [":llvm-libtool-darwin-lib"],
4104 cc_binary(
4105     name = "llvm-link",
4106     srcs = glob([
4107         "tools/llvm-link/*.cpp",
4108     ]),
4109     copts = llvm_copts,
4110     stamp = 0,
4111     deps = [
4112         ":AsmParser",
4113         ":BinaryFormat",
4114         ":BitReader",
4115         ":BitWriter",
4116         ":Core",
4117         ":IPO",
4118         ":IRPrinter",
4119         ":IRReader",
4120         ":Linker",
4121         ":Object",
4122         ":Support",
4123         ":TransformUtils",
4124     ],
4127 gentbl(
4128     name = "LipoOptsTableGen",
4129     strip_include_prefix = "tools/llvm-lipo",
4130     tbl_outs = [(
4131         "-gen-opt-parser-defs",
4132         "tools/llvm-lipo/LipoOpts.inc",
4133     )],
4134     tblgen = ":llvm-tblgen",
4135     td_file = "tools/llvm-lipo/LipoOpts.td",
4136     td_srcs = ["include/llvm/Option/OptParser.td"],
4139 cc_library(
4140     name = "llvm-lipo-lib",
4141     srcs = ["tools/llvm-lipo/llvm-lipo.cpp"],
4142     copts = llvm_copts,
4143     deps = [
4144         ":AllTargetsAsmParsers",
4145         ":BinaryFormat",
4146         ":Core",
4147         ":LipoOptsTableGen",
4148         ":Object",
4149         ":Option",
4150         ":Support",
4151         ":TargetParser",
4152         ":TextAPI",
4153     ],
4156 llvm_driver_cc_binary(
4157     name = "llvm-lipo",
4158     stamp = 0,
4159     deps = [":llvm-lipo-lib"],
4162 cc_binary(
4163     name = "llvm-lto",
4164     srcs = glob([
4165         "tools/llvm-lto/*.cpp",
4166     ]),
4167     copts = llvm_copts,
4168     stamp = 0,
4169     deps = [
4170         ":AllTargetsAsmParsers",
4171         ":AllTargetsCodeGens",
4172         ":BitReader",
4173         ":BitWriter",
4174         ":CodeGen",
4175         ":Core",
4176         ":IRPrinter",
4177         ":IRReader",
4178         ":LTO",
4179         ":Support",
4180         ":Target",
4181     ],
4184 cc_binary(
4185     name = "llvm-lto2",
4186     srcs = glob([
4187         "tools/llvm-lto2/*.cpp",
4188     ]),
4189     copts = llvm_copts,
4190     stamp = 0,
4191     deps = [
4192         ":AllTargetsAsmParsers",
4193         ":AllTargetsCodeGens",
4194         ":BitReader",
4195         ":CodeGen",
4196         ":Core",
4197         ":LTO",
4198         ":Passes",
4199         ":Remarks",
4200         ":Support",
4201     ],
4204 cc_binary(
4205     name = "llvm-mc",
4206     srcs = glob([
4207         "tools/llvm-mc/*.cpp",
4208         "tools/llvm-mc/*.h",
4209     ]),
4210     copts = llvm_copts,
4211     stamp = 0,
4212     deps = [
4213         ":AllTargetsAsmParsers",
4214         ":AllTargetsCodeGens",
4215         ":AllTargetsDisassemblers",
4216         ":MC",
4217         ":MCDisassembler",
4218         ":MCParser",
4219         ":Object",
4220         ":Support",
4221         ":TargetParser",
4222     ],
4225 cc_binary(
4226     name = "llvm-mca",
4227     srcs = [
4228         "tools/llvm-mca/llvm-mca.cpp",
4229     ],
4230     copts = llvm_copts,
4231     stamp = 0,
4232     deps = [
4233         ":AllTargetsAsmParsers",
4234         ":AllTargetsCodeGens",
4235         ":AllTargetsDisassemblers",
4236         ":AllTargetsMCAs",
4237         ":MC",
4238         ":MCA",
4239         ":MCAApplication",
4240         ":MCParser",
4241         ":Support",
4242         ":TargetParser",
4243     ],
4246 gentbl(
4247     name = "MlTableGen",
4248     strip_include_prefix = "tools/llvm-ml",
4249     tbl_outs = [(
4250         "-gen-opt-parser-defs",
4251         "tools/llvm-ml/Opts.inc",
4252     )],
4253     tblgen = ":llvm-tblgen",
4254     td_file = "tools/llvm-ml/Opts.td",
4255     td_srcs = ["include/llvm/Option/OptParser.td"],
4258 cc_library(
4259     name = "llvm-ml-lib",
4260     srcs = glob([
4261         "tools/llvm-ml/*.cpp",
4262         "tools/llvm-ml/*.h",
4263     ]),
4264     copts = llvm_copts,
4265     deps = [
4266         ":AllTargetsAsmParsers",
4267         ":AllTargetsCodeGens",
4268         ":AllTargetsDisassemblers",
4269         ":MC",
4270         ":MCDisassembler",
4271         ":MCParser",
4272         ":MlTableGen",
4273         ":Option",
4274         ":Support",
4275         ":TargetParser",
4276     ],
4279 llvm_driver_cc_binary(
4280     name = "llvm-ml",
4281     stamp = 0,
4282     deps = [":llvm-ml-lib"],
4285 cc_binary(
4286     name = "llvm-modextract",
4287     srcs = glob([
4288         "tools/llvm-modextract/*.cpp",
4289     ]),
4290     copts = llvm_copts,
4291     stamp = 0,
4292     deps = [
4293         ":BitReader",
4294         ":BitWriter",
4295         ":IRPrinter",
4296         ":IRReader",
4297         ":Support",
4298     ],
4301 gentbl(
4302     name = "MtTableGen",
4303     strip_include_prefix = "tools/llvm-mt",
4304     tbl_outs = [(
4305         "-gen-opt-parser-defs",
4306         "tools/llvm-mt/Opts.inc",
4307     )],
4308     tblgen = ":llvm-tblgen",
4309     td_file = "tools/llvm-mt/Opts.td",
4310     td_srcs = ["include/llvm/Option/OptParser.td"],
4313 cc_library(
4314     name = "llvm-mt-lib",
4315     srcs = glob(["tools/llvm-mt/*.cpp"]),
4316     copts = llvm_copts,
4317     deps = [
4318         ":MtTableGen",
4319         ":Option",
4320         ":Support",
4321         ":WindowsManifest",
4322         ":config",
4323     ],
4326 llvm_driver_cc_binary(
4327     name = "llvm-mt",
4328     stamp = 0,
4329     deps = [":llvm-mt-lib"],
4332 gentbl(
4333     name = "NmOptsTableGen",
4334     strip_include_prefix = "tools/llvm-nm",
4335     tbl_outs = [(
4336         "-gen-opt-parser-defs",
4337         "tools/llvm-nm/Opts.inc",
4338     )],
4339     tblgen = ":llvm-tblgen",
4340     td_file = "tools/llvm-nm/Opts.td",
4341     td_srcs = ["include/llvm/Option/OptParser.td"],
4344 cc_library(
4345     name = "llvm-nm-lib",
4346     srcs = glob(["tools/llvm-nm/*.cpp"]),
4347     copts = llvm_copts,
4348     deps = [
4349         ":AllTargetsAsmParsers",
4350         ":AllTargetsCodeGens",
4351         ":BinaryFormat",
4352         ":BitReader",
4353         ":Core",
4354         ":Demangle",
4355         ":NmOptsTableGen",
4356         ":Object",
4357         ":Option",
4358         ":Support",
4359         ":Symbolize",
4360         ":TargetParser",
4361     ],
4364 llvm_driver_cc_binary(
4365     name = "llvm-nm",
4366     stamp = 0,
4367     deps = [":llvm-nm-lib"],
4370 gentbl(
4371     name = "llvm-objcopy-opts",
4372     strip_include_prefix = "tools/llvm-objcopy",
4373     tbl_outs = [(
4374         "-gen-opt-parser-defs",
4375         "tools/llvm-objcopy/ObjcopyOpts.inc",
4376     )],
4377     tblgen = ":llvm-tblgen",
4378     td_file = "tools/llvm-objcopy/ObjcopyOpts.td",
4379     td_srcs = [
4380         "include/llvm/Option/OptParser.td",
4381         "tools/llvm-objcopy/CommonOpts.td",
4382     ],
4385 gentbl(
4386     name = "llvm-installnametool-opts",
4387     strip_include_prefix = "tools/llvm-objcopy",
4388     tbl_outs = [(
4389         "-gen-opt-parser-defs",
4390         "tools/llvm-objcopy/InstallNameToolOpts.inc",
4391     )],
4392     tblgen = ":llvm-tblgen",
4393     td_file = "tools/llvm-objcopy/InstallNameToolOpts.td",
4394     td_srcs = [
4395         "include/llvm/Option/OptParser.td",
4396         "tools/llvm-objcopy/CommonOpts.td",
4397     ],
4400 gentbl(
4401     name = "llvm-strip-opts",
4402     strip_include_prefix = "tools/llvm-objcopy",
4403     tbl_outs = [(
4404         "-gen-opt-parser-defs",
4405         "tools/llvm-objcopy/StripOpts.inc",
4406     )],
4407     tblgen = ":llvm-tblgen",
4408     td_file = "tools/llvm-objcopy/StripOpts.td",
4409     td_srcs = [
4410         "include/llvm/Option/OptParser.td",
4411         "tools/llvm-objcopy/CommonOpts.td",
4412     ],
4415 gentbl(
4416     name = "llvm-bitcode-strip-opts",
4417     strip_include_prefix = "tools/llvm-objcopy",
4418     tbl_outs = [(
4419         "-gen-opt-parser-defs",
4420         "tools/llvm-objcopy/BitcodeStripOpts.inc",
4421     )],
4422     tblgen = ":llvm-tblgen",
4423     td_file = "tools/llvm-objcopy/BitcodeStripOpts.td",
4424     td_srcs = [
4425         "include/llvm/Option/OptParser.td",
4426         "tools/llvm-objcopy/CommonOpts.td",
4427     ],
4430 cc_binary(
4431     name = "llvm-stress",
4432     srcs = glob([
4433         "tools/llvm-stress/*.cpp",
4434     ]),
4435     copts = llvm_copts,
4436     stamp = 0,
4437     deps = [
4438         ":Core",
4439         ":Support",
4440     ],
4443 cc_library(
4444     name = "llvm-objcopy-lib",
4445     srcs = glob([
4446         "tools/llvm-objcopy/*.cpp",
4447         "tools/llvm-objcopy/*.h",
4448     ]),
4449     copts = llvm_copts,
4450     deps = [
4451         ":BinaryFormat",
4452         ":MC",
4453         ":ObjCopy",
4454         ":Object",
4455         ":ObjectYAML",
4456         ":Option",
4457         ":Support",
4458         ":Target",
4459         ":TargetParser",
4460         ":llvm-bitcode-strip-opts",
4461         ":llvm-installnametool-opts",
4462         ":llvm-objcopy-opts",
4463         ":llvm-strip-opts",
4464     ],
4467 llvm_driver_cc_binary(
4468     name = "llvm-objcopy",
4469     stamp = 0,
4470     deps = [":llvm-objcopy-lib"],
4473 binary_alias(
4474     name = "llvm-strip",
4475     binary = ":llvm-objcopy",
4478 binary_alias(
4479     name = "llvm-bitcode-strip",
4480     binary = ":llvm-objcopy",
4483 binary_alias(
4484     name = "llvm-install-name-tool",
4485     binary = ":llvm-objcopy",
4488 cc_library(
4489     name = "llvm-objdump-lib",
4490     srcs = glob([
4491         "tools/llvm-objdump/*.cpp",
4492         "tools/llvm-objdump/*.h",
4493     ]),
4494     copts = llvm_copts,
4495     deps = [
4496         ":AllTargetsAsmParsers",
4497         ":AllTargetsCodeGens",
4498         ":AllTargetsDisassemblers",
4499         ":BinaryFormat",
4500         ":CodeGen",
4501         ":DebugInfo",
4502         ":DebugInfoDWARF",
4503         ":Debuginfod",
4504         ":Demangle",
4505         ":MC",
4506         ":MCDisassembler",
4507         ":ObjdumpOptsTableGen",
4508         ":Object",
4509         ":Option",
4510         ":OtoolOptsTableGen",
4511         ":Support",
4512         ":Symbolize",
4513         ":TargetParser",
4514         ":config",
4515     ],
4518 llvm_driver_cc_binary(
4519     name = "llvm-objdump",
4520     stamp = 0,
4521     deps = [":llvm-objdump-lib"],
4524 gentbl(
4525     name = "ObjdumpOptsTableGen",
4526     strip_include_prefix = "tools/llvm-objdump",
4527     tbl_outs = [(
4528         "-gen-opt-parser-defs",
4529         "tools/llvm-objdump/ObjdumpOpts.inc",
4530     )],
4531     tblgen = ":llvm-tblgen",
4532     td_file = "tools/llvm-objdump/ObjdumpOpts.td",
4533     td_srcs = ["include/llvm/Option/OptParser.td"],
4536 binary_alias(
4537     name = "llvm-otool",
4538     binary = ":llvm-objdump",
4541 gentbl(
4542     name = "OtoolOptsTableGen",
4543     strip_include_prefix = "tools/llvm-objdump",
4544     tbl_outs = [(
4545         "-gen-opt-parser-defs",
4546         "tools/llvm-objdump/OtoolOpts.inc",
4547     )],
4548     tblgen = ":llvm-tblgen",
4549     td_file = "tools/llvm-objdump/OtoolOpts.td",
4550     td_srcs = ["include/llvm/Option/OptParser.td"],
4553 cc_binary(
4554     name = "llvm-opt-report",
4555     srcs = glob([
4556         "tools/llvm-opt-report/*.cpp",
4557     ]),
4558     copts = llvm_copts,
4559     stamp = 0,
4560     deps = [
4561         ":AllTargetsCodeGens",
4562         ":Demangle",
4563         ":Remarks",
4564         ":Support",
4565     ],
4568 cc_binary(
4569     name = "llvm-pdbutil",
4570     srcs = glob([
4571         "tools/llvm-pdbutil/*.cpp",
4572         "tools/llvm-pdbutil/*.h",
4573     ]),
4574     copts = llvm_copts,
4575     stamp = 0,
4576     deps = [
4577         ":BinaryFormat",
4578         ":DebugInfoBTF",
4579         ":DebugInfoCodeView",
4580         ":DebugInfoMSF",
4581         ":DebugInfoPDB",
4582         ":Object",
4583         ":ObjectYAML",
4584         ":Support",
4585         ":config",
4586     ],
4589 cc_library(
4590     name = "llvm-profdata-lib",
4591     srcs = glob(["tools/llvm-profdata/*.cpp"]),
4592     copts = llvm_copts,
4593     deps = [
4594         ":Core",
4595         ":Debuginfod",
4596         ":Object",
4597         ":ProfileData",
4598         ":Support",
4599     ],
4602 llvm_driver_cc_binary(
4603     name = "llvm-profdata",
4604     stamp = 0,
4605     deps = [":llvm-profdata-lib"],
4608 cc_binary(
4609     name = "llvm-profgen",
4610     srcs = glob([
4611         "tools/llvm-profgen/*.cpp",
4612         "tools/llvm-profgen/*.h",
4613     ]),
4614     copts = llvm_copts,
4615     stamp = 0,
4616     deps = [
4617         ":AllTargetsCodeGens",
4618         ":AllTargetsDisassemblers",
4619         ":Core",
4620         ":DebugInfoDWARF",
4621         ":Demangle",
4622         ":IPO",
4623         ":MC",
4624         ":MCDisassembler",
4625         ":Object",
4626         ":ProfileData",
4627         ":Support",
4628         ":Symbolize",
4629         ":TargetParser",
4630     ],
4633 gentbl(
4634     name = "RcTableGen",
4635     strip_include_prefix = "tools/llvm-rc",
4636     tbl_outs = [(
4637         "-gen-opt-parser-defs",
4638         "tools/llvm-rc/Opts.inc",
4639     )],
4640     tblgen = ":llvm-tblgen",
4641     td_file = "tools/llvm-rc/Opts.td",
4642     td_srcs = ["include/llvm/Option/OptParser.td"],
4645 gentbl(
4646     name = "WindresTableGen",
4647     strip_include_prefix = "tools/llvm-rc",
4648     tbl_outs = [(
4649         "-gen-opt-parser-defs",
4650         "tools/llvm-rc/WindresOpts.inc",
4651     )],
4652     tblgen = ":llvm-tblgen",
4653     td_file = "tools/llvm-rc/WindresOpts.td",
4654     td_srcs = ["include/llvm/Option/OptParser.td"],
4657 # Workaround inability to put `.def` files into `srcs` with a library.
4658 cc_library(
4659     name = "llvm-rc-defs-lib",
4660     textual_hdrs = glob(["tools/llvm-rc/*.def"]),
4663 cc_library(
4664     name = "llvm-rc-lib",
4665     srcs = glob([
4666         "tools/llvm-rc/*.cpp",
4667         "tools/llvm-rc/*.h",
4668     ]),
4669     copts = llvm_copts,
4670     deps = [
4671         ":Object",
4672         ":Option",
4673         ":RcTableGen",
4674         ":Support",
4675         ":TargetParser",
4676         ":WindresTableGen",
4677         ":config",
4678         ":llvm-rc-defs-lib",
4679     ],
4682 llvm_driver_cc_binary(
4683     name = "llvm-rc",
4684     stamp = 0,
4685     deps = [":llvm-rc-lib"],
4688 binary_alias(
4689     name = "llvm-windres",
4690     binary = ":llvm-rc",
4693 gentbl(
4694     name = "ReadobjOptsTableGen",
4695     strip_include_prefix = "tools/llvm-readobj",
4696     tbl_outs = [(
4697         "-gen-opt-parser-defs",
4698         "tools/llvm-readobj/Opts.inc",
4699     )],
4700     tblgen = ":llvm-tblgen",
4701     td_file = "tools/llvm-readobj/Opts.td",
4702     td_srcs = ["include/llvm/Option/OptParser.td"],
4705 cc_library(
4706     name = "llvm-readobj-lib",
4707     srcs = glob([
4708         "tools/llvm-readobj/*.cpp",
4709         "tools/llvm-readobj/*.h",
4710     ]),
4711     copts = llvm_copts,
4712     deps = [
4713         ":AllTargetsCodeGens",
4714         ":BinaryFormat",
4715         ":BitReader",
4716         ":DebugInfoCodeView",
4717         ":DebugInfoDWARF",
4718         ":Demangle",
4719         ":MC",
4720         ":Object",
4721         ":Option",
4722         ":ReadobjOptsTableGen",
4723         ":Support",
4724     ],
4727 llvm_driver_cc_binary(
4728     name = "llvm-readobj",
4729     stamp = 0,
4730     deps = [":llvm-readobj-lib"],
4733 # Create an 'llvm-readelf' named binary from the 'llvm-readobj' tool.
4734 binary_alias(
4735     name = "llvm-readelf",
4736     binary = ":llvm-readobj",
4739 cc_binary(
4740     name = "llvm-reduce",
4741     srcs = glob([
4742         "tools/llvm-reduce/**/*.cpp",
4743         "tools/llvm-reduce/**/*.h",
4744     ]),
4745     copts = llvm_copts,
4746     includes = ["tools/llvm-reduce"],
4747     stamp = 0,
4748     deps = [
4749         ":AllTargetsAsmParsers",
4750         ":AllTargetsCodeGens",
4751         ":Analysis",
4752         ":BitReader",
4753         ":BitWriter",
4754         ":CodeGen",
4755         ":CodeGenTypes",
4756         ":Core",
4757         ":IPO",
4758         ":IRReader",
4759         ":MC",
4760         ":Passes",
4761         ":Support",
4762         ":Target",
4763         ":TargetParser",
4764         ":TransformUtils",
4765         ":config",
4766     ],
4769 cc_binary(
4770     name = "llvm-rtdyld",
4771     srcs = glob([
4772         "tools/llvm-rtdyld/*.cpp",
4773     ]),
4774     copts = llvm_copts,
4775     stamp = 0,
4776     deps = [
4777         ":AllTargetsCodeGens",
4778         ":AllTargetsDisassemblers",
4779         ":DebugInfo",
4780         ":DebugInfoDWARF",
4781         ":ExecutionEngine",
4782         ":MC",
4783         ":MCDisassembler",
4784         ":Object",
4785         ":Support",
4786     ],
4789 gentbl(
4790     name = "SizeOptsTableGen",
4791     strip_include_prefix = "tools/llvm-size",
4792     tbl_outs = [(
4793         "-gen-opt-parser-defs",
4794         "tools/llvm-size/Opts.inc",
4795     )],
4796     tblgen = ":llvm-tblgen",
4797     td_file = "tools/llvm-size/Opts.td",
4798     td_srcs = ["include/llvm/Option/OptParser.td"],
4801 cc_library(
4802     name = "llvm-size-lib",
4803     srcs = glob(["tools/llvm-size/*.cpp"]),
4804     copts = llvm_copts,
4805     deps = [
4806         ":Object",
4807         ":Option",
4808         ":SizeOptsTableGen",
4809         ":Support",
4810     ],
4813 llvm_driver_cc_binary(
4814     name = "llvm-size",
4815     stamp = 0,
4816     deps = [":llvm-size-lib"],
4819 cc_binary(
4820     name = "llvm-split",
4821     srcs = glob([
4822         "tools/llvm-split/*.cpp",
4823     ]),
4824     copts = llvm_copts,
4825     stamp = 0,
4826     deps = [
4827         ":AllTargetsAsmParsers",
4828         ":AllTargetsCodeGens",
4829         ":BitWriter",
4830         ":Core",
4831         ":IRPrinter",
4832         ":IRReader",
4833         ":MC",
4834         ":Support",
4835         ":Target",
4836         ":TargetParser",
4837         ":TransformUtils",
4838     ],
4841 gentbl(
4842     name = "StringsOptsTableGen",
4843     strip_include_prefix = "tools/llvm-strings",
4844     tbl_outs = [(
4845         "-gen-opt-parser-defs",
4846         "tools/llvm-strings/Opts.inc",
4847     )],
4848     tblgen = ":llvm-tblgen",
4849     td_file = "tools/llvm-strings/Opts.td",
4850     td_srcs = ["include/llvm/Option/OptParser.td"],
4853 cc_binary(
4854     name = "llvm-strings",
4855     srcs = glob([
4856         "tools/llvm-strings/*.cpp",
4857     ]),
4858     copts = llvm_copts,
4859     stamp = 0,
4860     deps = [
4861         ":Object",
4862         ":Option",
4863         ":StringsOptsTableGen",
4864         ":Support",
4865     ],
4868 gentbl(
4869     name = "SymbolizerOptsTableGen",
4870     strip_include_prefix = "tools/llvm-symbolizer",
4871     tbl_outs = [(
4872         "-gen-opt-parser-defs",
4873         "tools/llvm-symbolizer/Opts.inc",
4874     )],
4875     tblgen = ":llvm-tblgen",
4876     td_file = "tools/llvm-symbolizer/Opts.td",
4877     td_srcs = ["include/llvm/Option/OptParser.td"],
4880 cc_library(
4881     name = "llvm-symbolizer-lib",
4882     srcs = glob(["tools/llvm-symbolizer/*.cpp"]),
4883     copts = llvm_copts,
4884     deps = [
4885         ":DebugInfoDWARF",
4886         ":DebugInfoPDB",
4887         ":Debuginfod",
4888         ":Object",
4889         ":Option",
4890         ":Support",
4891         ":Symbolize",
4892         ":SymbolizerOptsTableGen",
4893         ":config",
4894     ],
4897 llvm_driver_cc_binary(
4898     name = "llvm-symbolizer",
4899     stamp = 0,
4900     deps = [":llvm-symbolizer-lib"],
4903 binary_alias(
4904     name = "llvm-addr2line",
4905     binary = ":llvm-symbolizer",
4908 cc_binary(
4909     name = "llvm-undname",
4910     srcs = glob([
4911         "tools/llvm-undname/*.cpp",
4912     ]),
4913     copts = llvm_copts,
4914     stamp = 0,
4915     deps = [
4916         ":Demangle",
4917         ":Support",
4918     ],
4921 cc_binary(
4922     name = "llvm-xray",
4923     srcs = glob([
4924         "tools/llvm-xray/*.cpp",
4925         "tools/llvm-xray/*.h",
4926     ]),
4927     copts = llvm_copts,
4928     stamp = 0,
4929     deps = [
4930         ":DebugInfoDWARF",
4931         ":Object",
4932         ":Support",
4933         ":Symbolize",
4934         ":XRay",
4935     ],
4938 cc_library(
4939     name = "opt-driver",
4940     srcs = glob([
4941         "tools/opt/*.cpp",
4942         "tools/opt/*.h",
4943     ]),
4944     copts = llvm_copts,
4945     linkopts = select({
4946         "@platforms//os:windows": [],
4947         "@platforms//os:macos": [],
4948         "//conditions:default": ["-Wl,--export-dynamic"],
4949     }),
4950     deps = [
4951         ":AllTargetsAsmParsers",
4952         ":AllTargetsCodeGens",
4953         ":Analysis",
4954         ":AsmParser",
4955         ":BitReader",
4956         ":BitWriter",
4957         ":CodeGen",
4958         ":Core",
4959         ":IPO",
4960         ":IRPrinter",
4961         ":IRReader",
4962         ":Instrumentation",
4963         ":MC",
4964         ":Passes",
4965         ":Remarks",
4966         ":Scalar",
4967         ":Support",
4968         ":Target",
4969         ":TargetParser",
4970         ":TransformUtils",
4971         ":common_transforms",
4972         ":config",
4973     ],
4976 cc_binary(
4977     name = "opt",
4978     stamp = 0,
4979     deps = [":opt-driver"],
4982 gentbl(
4983     name = "SancovOptsTableGen",
4984     strip_include_prefix = "tools/sancov",
4985     tbl_outs = [(
4986         "-gen-opt-parser-defs",
4987         "tools/sancov/Opts.inc",
4988     )],
4989     tblgen = ":llvm-tblgen",
4990     td_file = "tools/sancov/Opts.td",
4991     td_srcs = ["include/llvm/Option/OptParser.td"],
4994 cc_library(
4995     name = "sancov-lib",
4996     srcs = glob(["tools/sancov/*.cpp"]),
4997     copts = llvm_copts,
4998     deps = [
4999         ":AllTargetsCodeGens",
5000         ":AllTargetsDisassemblers",
5001         ":DebugInfoDWARF",
5002         ":DebugInfoPDB",
5003         ":MC",
5004         ":MCDisassembler",
5005         ":Object",
5006         ":Option",
5007         ":SancovOptsTableGen",
5008         ":Support",
5009         ":Symbolize",
5010     ],
5013 llvm_driver_cc_binary(
5014     name = "sancov",
5015     stamp = 0,
5016     deps = [":sancov-lib"],
5019 cc_binary(
5020     name = "sanstats",
5021     srcs = glob([
5022         "tools/sanstats/*.cpp",
5023     ]),
5024     copts = llvm_copts,
5025     stamp = 0,
5026     deps = [
5027         ":Support",
5028         ":Symbolize",
5029         ":TransformUtils",
5030     ],
5033 cc_binary(
5034     name = "split-file",
5035     srcs = glob([
5036         "utils/split-file/*.cpp",
5037     ]),
5038     copts = llvm_copts,
5039     stamp = 0,
5040     deps = [
5041         ":Support",
5042     ],
5045 ################################################################################
5046 # Begin testonly libraries
5048 cc_library(
5049     name = "FuzzMutate",
5050     testonly = True,
5051     srcs = glob(["lib/FuzzMutate/*.cpp"]),
5052     hdrs = glob(["include/llvm/FuzzMutate/*.h"]),
5053     copts = llvm_copts,
5054     includes = ["include"],
5055     deps = [
5056         ":Analysis",
5057         ":BitReader",
5058         ":BitWriter",
5059         ":Core",
5060         ":Scalar",
5061         ":Support",
5062         ":TargetParser",
5063         ":TransformUtils",
5064     ],
5067 cc_library(
5068     name = "Diff",
5069     testonly = True,
5070     srcs = glob(["tools/llvm-diff/lib/*.cpp"]),
5071     hdrs = glob(["tools/llvm-diff/lib/*.h"]),
5072     deps = [
5073         ":Core",
5074         ":Support",
5075     ],
5078 py_binary(
5079     name = "lit",
5080     testonly = True,
5081     srcs = ["utils/lit/lit.py"] + glob(["utils/lit/lit/**/*.py"]),
5082     imports = ["utils/lit"],
5085 py_binary(
5086     name = "extract_ir",
5087     srcs = [
5088         "utils/mlgo-utils/mlgo/__init__.py",
5089         "utils/mlgo-utils/mlgo/corpus/extract_ir.py",
5090         "utils/mlgo-utils/mlgo/corpus/extract_ir_lib.py",
5091     ],
5092     imports = ["utils/mlgo-utils"],
5095 py_binary(
5096     name = "combine_training_corpus",
5097     srcs = [
5098         "utils/mlgo-utils/mlgo/__init__.py",
5099         "utils/mlgo-utils/mlgo/corpus/combine_training_corpus.py",
5100         "utils/mlgo-utils/mlgo/corpus/combine_training_corpus_lib.py",
5101     ],
5102     imports = ["utils/mlgo-utils"],
5105 py_binary(
5106     name = "make_corpus",
5107     srcs = [
5108         "utils/mlgo-utils/mlgo/__init__.py",
5109         "utils/mlgo-utils/mlgo/corpus/make_corpus.py",
5110         "utils/mlgo-utils/mlgo/corpus/make_corpus_lib.py",
5111     ],
5112     imports = ["utils/mlgo-utils"],
5115 cc_library(
5116     name = "TestingADT",
5117     testonly = True,
5118     hdrs = glob([
5119         "include/llvm/Testing/ADT/*.h",
5120     ]),
5121     copts = llvm_copts,
5122     deps = [
5123         ":Support",
5124         "//third-party/unittest:gmock",
5125     ],
5128 cc_library(
5129     name = "TestingSupport",
5130     testonly = True,
5131     srcs = glob([
5132         "lib/Testing/Support/*.cpp",
5133     ]),
5134     hdrs = glob(["include/llvm/Testing/Support/*.h"]),
5135     copts = llvm_copts,
5136     deps = [
5137         ":Support",
5138         ":config",
5139         "//third-party/unittest:gmock",
5140         "//third-party/unittest:gtest",
5141     ],
5144 cc_library(
5145     name = "TestingAnnotations",
5146     testonly = True,
5147     srcs = ["lib/Testing/Annotations/Annotations.cpp"],
5148     hdrs = ["include/llvm/Testing/Annotations/Annotations.h"],
5149     copts = llvm_copts,
5150     deps = [":Support"],
5153 ################################################################################
5154 # Begin testonly binary utilities
5156 cc_binary(
5157     name = "FileCheck",
5158     testonly = True,
5159     srcs = glob([
5160         "utils/FileCheck/*.cpp",
5161     ]),
5162     copts = llvm_copts,
5163     stamp = 0,
5164     deps = [
5165         ":FileCheckLib",
5166         ":Support",
5167     ],
5170 cc_binary(
5171     name = "bugpoint",
5172     srcs = glob([
5173         "tools/bugpoint/*.cpp",
5174         "tools/bugpoint/*.h",
5175     ]),
5176     copts = llvm_copts,
5177     stamp = 0,
5178     deps = [
5179         ":AllTargetsAsmParsers",
5180         ":AllTargetsCodeGens",
5181         ":Analysis",
5182         ":AsmParser",
5183         ":BitReader",
5184         ":BitWriter",
5185         ":CodeGen",
5186         ":Core",
5187         ":IPO",
5188         ":IRPrinter",
5189         ":IRReader",
5190         ":Linker",
5191         ":Passes",
5192         ":Scalar",
5193         ":Support",
5194         ":TargetParser",
5195         ":TransformUtils",
5196         ":common_transforms",
5197         ":config",
5198     ],
5201 cc_binary(
5202     name = "count",
5203     testonly = True,
5204     srcs = glob([
5205         "utils/count/*.c",
5206     ]),
5207     stamp = 0,
5208     deps = [":Support"],
5211 cc_binary(
5212     name = "lli-child-target",
5213     testonly = True,
5214     srcs = glob([
5215         "tools/lli/ChildTarget/*.cpp",
5216     ]),
5217     copts = llvm_copts,
5218     # The tests load code into this binary that expect to see symbols
5219     # from libstdc++ such as __cxa_begin_catch and _ZTIi. The latter
5220     # isn't even used in the main binary, so we also need to force it
5221     # to be included.
5222     linkopts = select({
5223         "@platforms//os:windows": [],
5224         "@platforms//os:macos": [],
5225         "//conditions:default": [
5226             "-rdynamic",
5227             "-u_ZTIi",
5228         ],
5229     }),
5230     stamp = 0,
5231     deps = [
5232         ":OrcJIT",
5233         ":OrcTargetProcess",
5234         ":Support",
5235         ":attributes_gen",
5236         ":config",
5237         ":intrinsic_enums_gen",
5238     ],
5241 cc_binary(
5242     name = "llvm-c-test",
5243     testonly = True,
5244     srcs = glob([
5245         "tools/llvm-c-test/*.c",
5246         "tools/llvm-c-test/*.cpp",
5247         "tools/llvm-c-test/*.h",
5248     ]),
5249     stamp = 0,
5250     deps = [
5251         ":AllTargetsAsmParsers",
5252         ":AllTargetsCodeGens",
5253         ":AllTargetsDisassemblers",
5254         ":Analysis",
5255         ":BitReader",
5256         ":BitWriter",
5257         ":Core",
5258         ":ExecutionEngine",
5259         ":IPO",
5260         ":IRReader",
5261         ":InstCombine",
5262         ":LTO",
5263         ":Linker",
5264         ":MCDisassembler",
5265         ":Object",
5266         ":OrcJIT",
5267         ":Passes",
5268         ":Remarks",
5269         ":Scalar",
5270         ":Support",
5271         ":Target",
5272         ":TransformUtils",
5273         ":Vectorize",
5274     ],
5277 cc_binary(
5278     name = "llvm-diff",
5279     testonly = True,
5280     srcs = glob([
5281         "tools/llvm-diff/*.cpp",
5282     ]),
5283     copts = llvm_copts,
5284     stamp = 0,
5285     deps = [
5286         ":Core",
5287         ":Diff",
5288         ":IRPrinter",
5289         ":IRReader",
5290         ":Support",
5291     ],
5294 cc_binary(
5295     name = "llvm-isel-fuzzer",
5296     testonly = True,
5297     srcs = glob([
5298         "tools/llvm-isel-fuzzer/*.cpp",
5299     ]),
5300     copts = llvm_copts,
5301     stamp = 0,
5302     deps = [
5303         ":AllTargetsAsmParsers",
5304         ":AllTargetsCodeGens",
5305         ":Analysis",
5306         ":BitReader",
5307         ":BitWriter",
5308         ":CodeGen",
5309         ":Core",
5310         ":FuzzMutate",
5311         ":IRPrinter",
5312         ":IRReader",
5313         ":MC",
5314         ":Support",
5315         ":Target",
5316     ],
5319 # This is really a Python script, but call it sh_binary to ignore the hyphen in
5320 # the path, which py_binary does not allow.
5321 # Also, note: llvm-locstats expects llvm-dwarfdump to be in the same directory
5322 # when executed.
5323 sh_binary(
5324     name = "llvm-locstats",
5325     testonly = True,
5326     srcs = glob([
5327         "utils/llvm-locstats/*.py",
5328     ]),
5329     # llvm-locstats is a thin wrapper around llvm-dwarfdump.
5330     data = [":llvm-dwarfdump"],
5333 sh_binary(
5334     name = "llvm-original-di-preservation",
5335     testonly = True,
5336     srcs = ["utils/llvm-original-di-preservation.py"],
5339 cc_binary(
5340     name = "not",
5341     testonly = True,
5342     srcs = glob([
5343         "utils/not/*.cpp",
5344     ]),
5345     copts = llvm_copts,
5346     stamp = 0,
5347     deps = [":Support"],
5350 cc_binary(
5351     name = "llvm-opt-fuzzer",
5352     testonly = True,
5353     srcs = glob([
5354         "tools/llvm-opt-fuzzer/*.cpp",
5355     ]),
5356     copts = llvm_copts,
5357     stamp = 0,
5358     deps = [
5359         ":AllTargetsCodeGens",
5360         ":Analysis",
5361         ":BitReader",
5362         ":BitWriter",
5363         ":CodeGen",
5364         ":Core",
5365         ":Coroutines",
5366         ":FuzzMutate",
5367         ":MC",
5368         ":Passes",
5369         ":Support",
5370         ":Target",
5371     ],
5374 gentbl(
5375     name = "ReadTAPIOptsTableGen",
5376     strip_include_prefix = "tools/llvm-readtapi",
5377     tbl_outs = [(
5378         "-gen-opt-parser-defs",
5379         "tools/llvm-readtapi/TapiOpts.inc",
5380     )],
5381     tblgen = ":llvm-tblgen",
5382     td_file = "tools/llvm-readtapi/TapiOpts.td",
5383     td_srcs = ["include/llvm/Option/OptParser.td"],
5386 cc_binary(
5387     name = "llvm-readtapi",
5388     testonly = True,
5389     srcs = glob([
5390         "tools/llvm-readtapi/*.cpp",
5391         "tools/llvm-readtapi/*.h",
5392     ]),
5393     copts = llvm_copts,
5394     stamp = 0,
5395     deps = [
5396         ":BinaryFormat",
5397         ":Object",
5398         ":Option",
5399         ":ReadTAPIOptsTableGen",
5400         ":Support",
5401         ":TextAPI",
5402         ":TextAPIBinaryReader",
5403     ],
5406 gentbl(
5407     name = "TLICheckerOptsTableGen",
5408     strip_include_prefix = "tools/llvm-tli-checker",
5409     tbl_outs = [(
5410         "-gen-opt-parser-defs",
5411         "tools/llvm-tli-checker/Opts.inc",
5412     )],
5413     tblgen = ":llvm-tblgen",
5414     td_file = "tools/llvm-tli-checker/Opts.td",
5415     td_srcs = ["include/llvm/Option/OptParser.td"],
5418 cc_binary(
5419     name = "llvm-tli-checker",
5420     testonly = True,
5421     srcs = glob([
5422         "tools/llvm-tli-checker/*.cpp",
5423     ]),
5424     copts = llvm_copts,
5425     stamp = 0,
5426     deps = [
5427         ":Analysis",
5428         ":BinaryFormat",
5429         ":BitReader",
5430         ":BitstreamReader",
5431         ":Core",
5432         ":Demangle",
5433         ":MC",
5434         ":MCParser",
5435         ":Object",
5436         ":Option",
5437         ":Remarks",
5438         ":Support",
5439         ":TLICheckerOptsTableGen",
5440         ":TargetParser",
5441         ":TextAPI",
5442         ":config",
5443     ],
5446 cc_binary(
5447     name = "obj2yaml",
5448     testonly = True,
5449     srcs = glob([
5450         "tools/obj2yaml/*.cpp",
5451         "tools/obj2yaml/*.h",
5452     ]),
5453     copts = llvm_copts,
5454     stamp = 0,
5455     deps = [
5456         ":BinaryFormat",
5457         ":DebugInfoCodeView",
5458         ":DebugInfoDWARF",
5459         ":Object",
5460         ":ObjectYAML",
5461         ":Support",
5462     ],
5465 cc_binary(
5466     name = "verify-uselistorder",
5467     srcs = glob([
5468         "tools/verify-uselistorder/*.cpp",
5469     ]),
5470     copts = llvm_copts,
5471     stamp = 0,
5472     deps = [
5473         ":AsmParser",
5474         ":BitReader",
5475         ":BitWriter",
5476         ":Core",
5477         ":IRPrinter",
5478         ":IRReader",
5479         ":Support",
5480     ],
5483 cc_binary(
5484     name = "yaml2obj",
5485     testonly = True,
5486     srcs = glob([
5487         "tools/yaml2obj/*.cpp",
5488     ]),
5489     copts = llvm_copts,
5490     stamp = 0,
5491     deps = [
5492         ":BinaryFormat",
5493         ":DebugInfoCodeView",
5494         ":MC",
5495         ":Object",
5496         ":ObjectYAML",
5497         ":Support",
5498     ],
5501 cc_binary(
5502     name = "yaml-bench",
5503     testonly = True,
5504     srcs = glob([
5505         "utils/yaml-bench/*.cpp",
5506     ]),
5507     copts = llvm_copts,
5508     stamp = 0,
5509     deps = [
5510         ":Support",
5511     ],