From: Jordan Rupprecht Date: Thu, 22 Sep 2022 22:00:15 +0000 (-0700) Subject: [bazel] Port 47afaf2eb02b1424a9aba241ccd02393a0cbc648 to bazel X-Git-Tag: upstream/17.0.6~32719 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5b2f838db42ea190fdda147a33b5f0fcc8145689;p=platform%2Fupstream%2Fllvm.git [bazel] Port 47afaf2eb02b1424a9aba241ccd02393a0cbc648 to bazel --- diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel index 7de7a9c..6d97a37 100644 --- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel @@ -92,6 +92,22 @@ enum_targets_gen( targets = llvm_target_mcas, ) +# Enabled targets with exegesis. +llvm_target_exegesis = [ + t + for t in llvm_targets + if glob(["tools/llvm-exegesis/lib/{}/CMakeLists.txt".format(t)]) +] + +enum_targets_gen( + name = "target_exegesis_def_gen", + src = "include/llvm/Config/TargetExegesis.def.in", + out = "include/llvm/Config/TargetExegesis.def", + macro_name = "EXEGESIS", + placeholder_name = "@LLVM_ENUM_EXEGESIS@", + targets = llvm_target_exegesis, +) + template_rule( name = "abi_breaking_h_gen", src = "include/llvm/Config/abi-breaking.h.cmake", @@ -126,6 +142,7 @@ cc_library( "include/llvm/Config/AsmPrinters.def", "include/llvm/Config/Disassemblers.def", "include/llvm/Config/Targets.def", + "include/llvm/Config/TargetExegesis.def", "include/llvm/Config/TargetMCAs.def", # Needed for include scanner to find execinfo.h "include/llvm/Config/config.h", @@ -1526,6 +1543,7 @@ llvm_target_lib_list = [lib for lib in [ ("-gen-subtarget", "lib/Target/AArch64/AArch64GenSubtargetInfo.inc"), ("-gen-disassembler", "lib/Target/AArch64/AArch64GenDisassemblerTables.inc"), ("-gen-searchable-tables", "lib/Target/AArch64/AArch64GenSystemOperands.inc"), + ("-gen-exegesis", "lib/Target/AArch64/AArch64GenExegesis.inc"), ], }, { @@ -1694,6 +1712,7 @@ llvm_target_lib_list = [lib for lib in [ ("-gen-disassembler", "lib/Target/PowerPC/PPCGenDisassemblerTables.inc"), ("-gen-register-bank", "lib/Target/PowerPC/PPCGenRegisterBank.inc"), ("-gen-global-isel", "lib/Target/PowerPC/PPCGenGlobalISel.inc"), + ("-gen-exegesis", "lib/Target/PowerPC/PPCGenExegesis.inc"), ], }, { @@ -2576,6 +2595,9 @@ cc_library( name = "Exegesis", srcs = glob([ "tools/llvm-exegesis/lib/*.cpp", + "tools/llvm-exegesis/lib/AArch64/*.cpp", + "tools/llvm-exegesis/lib/Mips/*.cpp", + "tools/llvm-exegesis/lib/PowerPC/*.cpp", "tools/llvm-exegesis/lib/X86/*.cpp", "tools/llvm-exegesis/lib/X86/*.h", # We have to include these headers here as well as in the `hdrs` below @@ -2587,7 +2609,6 @@ cc_library( ]), hdrs = glob(["tools/llvm-exegesis/lib/*.h"]), copts = llvm_copts + ["-DHAVE_LIBPFM=1"], - defines = ["LLVM_EXEGESIS_INITIALIZE_NATIVE_TARGET=InitializeX86ExegesisTarget"], features = ["-header_modules"], strip_include_prefix = "tools/llvm-exegesis/lib", tags = [ diff --git a/utils/bazel/llvm-project-overlay/llvm/enum_targets_gen.bzl b/utils/bazel/llvm-project-overlay/llvm/enum_targets_gen.bzl index cf25fe62..998b706 100644 --- a/utils/bazel/llvm-project-overlay/llvm/enum_targets_gen.bzl +++ b/utils/bazel/llvm-project-overlay/llvm/enum_targets_gen.bzl @@ -30,7 +30,9 @@ a select is not allowed to be passed to a rule within another data structure. """ def enum_targets_gen_impl(ctx): - to_replace = "@LLVM_ENUM_{}S@".format(ctx.attr.macro_name) + to_replace = ctx.attr.placeholder_name + if not to_replace: + to_replace = "@LLVM_ENUM_{}S@".format(ctx.attr.macro_name) replacement = "\n".join([ "LLVM_{}({})\n".format(ctx.attr.macro_name, t) for t in ctx.attr.targets @@ -57,6 +59,10 @@ enum_targets_gen = rule( " macro invocations generated `LLVM_{}(TARGET)`. Should be" + " all caps and singular, e.g. 'DISASSEMBLER'", ), + "placeholder_name": attr.string( + doc = "The name of the placeholder. If unset, this defaults to" + + " `@LLVM_ENUM_{macro_name}S@`", + ), }, # output_to_genfiles is required for header files. output_to_genfiles = True,