Have ABI plugins vend llvm MCRegisterInfo data
Summary:
I was recently surprised to learn that there is a total of 2 (two) users
of the register info definitions contained in the ABI plugins. Yet, the
defitions themselves span nearly 10kLOC.
The two users are:
- dwarf expression pretty printer
- the mechanism for augmenting the register info definitions obtained
over gdb-remote protocol (AugmentRegisterInfoViaABI)
Both of these uses need the DWARF an EH register numbers, which is
information that is already available in LLVM. This patch makes it
possible to do so.
It adds a GetMCRegisterInfo method to the ABI class, which every class
is expected to implement. Normally, it should be sufficient to obtain
the definitions from the appropriate llvm::Target object (for which I
provide a utility function), but the subclasses are free to construct it
in any way they deem fit.
We should be able to always get the MCRegisterInfo object from llvm,
with one important exception: if the relevant llvm target was disabled
at compile time. To handle this, I add a mechanism to disable the
compilation of ABI plugins based on the value of LLVM_TARGETS_TO_BUILD
cmake setting. This ensures all our existing are able to create their
MCRegisterInfo objects.
The new MCRegisterInfo api is not used yet, but the intention is to make
use of it in follow-up patches.
Reviewers: jasonmolenda, aprantl, JDevlieghere, tatyana-krasnukha
Subscribers: wuzish, nemanjai, mgorny, kbarton, atanasyan, lldb-commits
Differential Revision: https://reviews.llvm.org/D67965
llvm-svn: 372862
diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt
index d93b8b5..ff42cb3 100644
--- a/lldb/source/API/CMakeLists.txt
+++ b/lldb/source/API/CMakeLists.txt
@@ -103,6 +103,11 @@
${option_install_prefix}
)
+foreach (t ${LLVM_TARGETS_TO_BUILD})
+ set_property(SOURCE SystemInitializerFull.cpp APPEND PROPERTY
+ COMPILE_DEFINITIONS "LLVM_TARGET_${t}_BUILT")
+endforeach()
+
if (MSVC)
set_source_files_properties(SBReproducer.cpp PROPERTIES COMPILE_FLAGS /bigobj)
endif()
diff --git a/lldb/source/API/SystemInitializerFull.cpp b/lldb/source/API/SystemInitializerFull.cpp
index e7f2206..f71dd51 100644
--- a/lldb/source/API/SystemInitializerFull.cpp
+++ b/lldb/source/API/SystemInitializerFull.cpp
@@ -174,20 +174,34 @@
ClangASTContext::Initialize();
- ABIMacOSX_i386::Initialize();
- ABIMacOSX_arm::Initialize();
+#ifdef LLVM_TARGET_AArch64_BUILT
ABIMacOSX_arm64::Initialize();
- ABISysV_arm::Initialize();
ABISysV_arm64::Initialize();
+#endif
+#ifdef LLVM_TARGET_ARM_BUILT
+ ABIMacOSX_arm::Initialize();
+ ABISysV_arm::Initialize();
+#endif
+#ifdef LLVM_TARGET_Hexagon_BUILT
ABISysV_hexagon::Initialize();
- ABISysV_i386::Initialize();
- ABISysV_x86_64::Initialize();
- ABISysV_ppc::Initialize();
- ABISysV_ppc64::Initialize();
+#endif
+#ifdef LLVM_TARGET_Mips_BUILT
ABISysV_mips::Initialize();
ABISysV_mips64::Initialize();
+#endif
+#ifdef LLVM_TARGET_PowerPC_BUILT
+ ABISysV_ppc::Initialize();
+ ABISysV_ppc64::Initialize();
+#endif
+#ifdef LLVM_TARGET_SystemZ_BUILT
ABISysV_s390x::Initialize();
+#endif
+#ifdef LLVM_TARGET_X86_BUILT
+ ABIMacOSX_i386::Initialize();
+ ABISysV_i386::Initialize();
+ ABISysV_x86_64::Initialize();
ABIWindows_x86_64::Initialize();
+#endif
ArchitectureArm::Initialize();
ArchitectureMips::Initialize();
@@ -288,20 +302,35 @@
ArchitectureMips::Terminate();
ArchitecturePPC64::Terminate();
- ABIMacOSX_i386::Terminate();
- ABIMacOSX_arm::Terminate();
+#ifdef LLVM_TARGET_AArch64_BUILT
ABIMacOSX_arm64::Terminate();
- ABISysV_arm::Terminate();
ABISysV_arm64::Terminate();
+#endif
+#ifdef LLVM_TARGET_ARM_BUILT
+ ABIMacOSX_arm::Terminate();
+ ABISysV_arm::Terminate();
+#endif
+#ifdef LLVM_TARGET_Hexagon_BUILT
ABISysV_hexagon::Terminate();
- ABISysV_i386::Terminate();
- ABISysV_x86_64::Terminate();
- ABISysV_ppc::Terminate();
- ABISysV_ppc64::Terminate();
+#endif
+#ifdef LLVM_TARGET_Mips_BUILT
ABISysV_mips::Terminate();
ABISysV_mips64::Terminate();
+#endif
+#ifdef LLVM_TARGET_PowerPC_BUILT
+ ABISysV_ppc::Terminate();
+ ABISysV_ppc64::Terminate();
+#endif
+#ifdef LLVM_TARGET_SystemZ_BUILT
ABISysV_s390x::Terminate();
+#endif
+#ifdef LLVM_TARGET_X86_BUILT
+ ABIMacOSX_i386::Terminate();
+ ABISysV_i386::Terminate();
+ ABISysV_x86_64::Terminate();
ABIWindows_x86_64::Terminate();
+#endif
+
DisassemblerLLVMC::Terminate();
JITLoaderGDB::Terminate();