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 @@ -41,6 +41,8 @@ targets = llvm_targets, ) +# 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", @@ -87,6 +89,19 @@ 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] + +enum_targets_gen( + name = "target_mca_def_gen", + src = "include/llvm/Config/TargetMCAs.def.in", + out = "include/llvm/Config/TargetMCAs.def", + macro_name = "TARGETMCA", + targets = llvm_target_mcas, +) + # TODO: Need to replace this with something that actually extracts the git # commit from the LLVM source (submodule or http_archive). genrule( @@ -130,6 +145,7 @@ "include/llvm/Config/AsmPrinters.def", "include/llvm/Config/Disassemblers.def", "include/llvm/Config/Targets.def", + "include/llvm/Config/TargetMCAs.def", # Needed for include scanner to find execinfo.h "include/llvm/Config/config.h", ], @@ -1891,6 +1907,24 @@ ":" + target["name"] + "UtilsAndDesc", ], )], + [cc_library( + name = target["name"] + "TargetMCA", + srcs = glob([ + "lib/Target/" + target["name"] + "/MCA/*.cpp", + "lib/Target/" + target["name"] + "/MCA/*.c", + "lib/Target/" + target["name"] + "/MCA/*.h", + ]), + copts = llvm_copts, + deps = [ + ":MC", + ":MCA", + ":MCParser", + ":Support", + ":" + target["name"] + "DisassemblerInternalHeaders", + ":" + target["name"] + "Info", + ":" + target["name"] + "UtilsAndDesc", + ], + )], ] for target in llvm_target_lib_list] cc_library( @@ -1920,6 +1954,15 @@ ], ) +cc_library( + name = "AllTargetsMCAs", + copts = llvm_copts, + deps = [ + target["name"] + "TargetMCA" + for target in llvm_target_lib_list + ], +) + cc_library( name = "pass_registry_def", copts = llvm_copts, @@ -2985,6 +3028,7 @@ ":AllTargetsAsmParsers", ":AllTargetsCodeGens", ":AllTargetsDisassemblers", + ":AllTargetsMCAs", ":MC", ":MCA", ":MCParser", diff --git a/utils/bazel/llvm-project-overlay/llvm/config.bzl b/utils/bazel/llvm-project-overlay/llvm/config.bzl --- a/utils/bazel/llvm-project-overlay/llvm/config.bzl +++ b/utils/bazel/llvm-project-overlay/llvm/config.bzl @@ -13,6 +13,7 @@ "LLVM_NATIVE_TARGET=LLVMInitialize{}Target".format(arch), "LLVM_NATIVE_TARGETINFO=LLVMInitialize{}TargetInfo".format(arch), "LLVM_NATIVE_TARGETMC=LLVMInitialize{}TargetMC".format(arch), + "LLVM_NATIVE_TARGETMCA=LLVMInitialize{}TargetMCA".format(arch), "LLVM_HOST_TRIPLE=\\\"{}\\\"".format(triple), "LLVM_DEFAULT_TARGET_TRIPLE=\\\"{}\\\"".format(triple), ] diff --git a/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/llvm-config.h b/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/llvm-config.h --- a/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/llvm-config.h +++ b/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/llvm-config.h @@ -58,6 +58,9 @@ /* LLVM name for the native target MC init function, if available */ /* LLVM_NATIVE_TARGETMC defined in Bazel */ +/* LLVM name for the native target MCA init function, if available */ +/* LLVM_NATIVE_TARGETMCA defined in Bazel */ + /* Define if this is Unixish platform */ /* LLVM_ON_UNIX defined in Bazel */ diff --git a/utils/bazel/llvm_configs/llvm-config.h.cmake b/utils/bazel/llvm_configs/llvm-config.h.cmake --- a/utils/bazel/llvm_configs/llvm-config.h.cmake +++ b/utils/bazel/llvm_configs/llvm-config.h.cmake @@ -50,6 +50,9 @@ /* LLVM name for the native target MC init function, if available */ #cmakedefine LLVM_NATIVE_TARGETMC LLVMInitialize${LLVM_NATIVE_ARCH}TargetMC +/* LLVM name for the native target MCA init function, if available */ +#cmakedefine LLVM_NATIVE_TARGETMCA LLVMInitialize${LLVM_NATIVE_ARCH}TargetMCA + /* Define if this is Unixish platform */ #cmakedefine LLVM_ON_UNIX ${LLVM_ON_UNIX}