diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel @@ -33,30 +33,27 @@ targets = llvm_targets, ) +# Enabled targets with ASM printers. +llvm_target_asm_printers = [ + t + for t in llvm_targets + if glob(["lib/Target/{}/*AsmPrinter.cpp".format(t)]) +] + enum_targets_gen( name = "asm_printers_def_gen", src = "include/llvm/Config/AsmPrinters.def.in", out = "include/llvm/Config/AsmPrinters.def", macro_name = "ASM_PRINTER", - targets = llvm_targets, + targets = llvm_target_asm_printers, ) -# TODO(gcmn): We should derive these lists from the presence of CMakeLists.txt -# files, as is done in the CMake build. -# List of targets with ASM parsers, filtered to our list of overall targets. -llvm_target_asm_parsers = [t for t in [ - "AArch64", - "AMDGPU", - "ARM", - "BPF", - "Hexagon", - "Lanai", - "PowerPC", - "RISCV", - "Sparc", - "WebAssembly", - "X86", -] if t in llvm_targets] +# Enabled targets with ASM parsers. +llvm_target_asm_parsers = [ + t + for t in llvm_targets + if glob(["lib/Target/{}/AsmParser/CMakeLists.txt".format(t)]) +] enum_targets_gen( name = "asm_parsers_def_gen", @@ -66,20 +63,12 @@ targets = llvm_target_asm_parsers, ) -# List of targets with disassemblers, filtered to our list of overall targets. -llvm_target_disassemblers = [t for t in [ - "AArch64", - "AMDGPU", - "ARM", - "BPF", - "Hexagon", - "Lanai", - "PowerPC", - "RISCV", - "Sparc", - "WebAssembly", - "X86", -] if t in llvm_targets] +# Enabled targets with disassemblers. +llvm_target_disassemblers = [ + t + for t in llvm_targets + if glob(["lib/Target/{}/Disassembler/CMakeLists.txt".format(t)]) +] enum_targets_gen( name = "disassemblers_def_gen", @@ -89,10 +78,12 @@ targets = llvm_target_disassemblers, ) -# List of targets with mca, filtered to our list of overall targets. -llvm_target_mcas = [t for t in [ - "AMDGPU", -] if t in llvm_targets] +# Enabled targets with MCA. +llvm_target_mcas = [ + t + for t in llvm_targets + if glob(["lib/Target/{}/MCA/CMakeLists.txt".format(t)]) +] enum_targets_gen( name = "target_mca_def_gen",