[Lldb-commits] [lldb] r372952 - SystemInitializer: Use Targets.def to selectively initialize ABI plugins
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Thu Sep 26 02:47:33 PDT 2019
Author: labath
Date: Thu Sep 26 02:47:32 2019
New Revision: 372952
URL: http://llvm.org/viewvc/llvm-project?rev=372952&view=rev
Log:
SystemInitializer: Use Targets.def to selectively initialize ABI plugins
This avoids having to define additional macros in the cmake file, and
and also makes the logic in the cpp files more compact. It is also
easily extendible to other plugin types (instruction emulation?) that
should only be initialized if the corresponding llvm target is built.
Thanks to Ilya Birukov for pointing me to this file.
Modified:
lldb/trunk/source/API/CMakeLists.txt
lldb/trunk/source/API/SystemInitializerFull.cpp
lldb/trunk/tools/lldb-test/CMakeLists.txt
lldb/trunk/tools/lldb-test/SystemInitializerTest.cpp
Modified: lldb/trunk/source/API/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/CMakeLists.txt?rev=372952&r1=372951&r2=372952&view=diff
==============================================================================
--- lldb/trunk/source/API/CMakeLists.txt (original)
+++ lldb/trunk/source/API/CMakeLists.txt Thu Sep 26 02:47:32 2019
@@ -103,11 +103,6 @@ add_lldb_library(liblldb SHARED
${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()
Modified: lldb/trunk/source/API/SystemInitializerFull.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SystemInitializerFull.cpp?rev=372952&r1=372951&r2=372952&view=diff
==============================================================================
--- lldb/trunk/source/API/SystemInitializerFull.cpp (original)
+++ lldb/trunk/source/API/SystemInitializerFull.cpp Thu Sep 26 02:47:32 2019
@@ -131,6 +131,36 @@ SystemInitializerFull::SystemInitializer
SystemInitializerFull::~SystemInitializerFull() {}
+#define LLDB_PROCESS_AArch64(op) \
+ ABIMacOSX_arm64::op(); \
+ ABISysV_arm64::op();
+#define LLDB_PROCESS_ARM(op) \
+ ABIMacOSX_arm::op(); \
+ ABISysV_arm::op();
+#define LLDB_PROCESS_Hexagon(op) ABISysV_hexagon::op();
+#define LLDB_PROCESS_Mips(op) \
+ ABISysV_mips::op(); \
+ ABISysV_mips64::op();
+#define LLDB_PROCESS_PowerPC(op) \
+ ABISysV_ppc::op(); \
+ ABISysV_ppc64::op();
+#define LLDB_PROCESS_SystemZ(op) ABISysV_s390x::op();
+#define LLDB_PROCESS_X86(op) \
+ ABIMacOSX_i386::op(); \
+ ABISysV_i386::op(); \
+ ABISysV_x86_64::op(); \
+ ABIWindows_x86_64::op();
+
+#define LLDB_PROCESS_AMDGPU(op)
+#define LLDB_PROCESS_BPF(op)
+#define LLDB_PROCESS_Lanai(op)
+#define LLDB_PROCESS_MSP430(op)
+#define LLDB_PROCESS_NVPTX(op)
+#define LLDB_PROCESS_RISCV(op)
+#define LLDB_PROCESS_Sparc(op)
+#define LLDB_PROCESS_WebAssembly(op)
+#define LLDB_PROCESS_XCore(op)
+
llvm::Error SystemInitializerFull::Initialize() {
if (auto e = SystemInitializerCommon::Initialize())
return e;
@@ -174,34 +204,8 @@ llvm::Error SystemInitializerFull::Initi
ClangASTContext::Initialize();
-#ifdef LLVM_TARGET_AArch64_BUILT
- ABIMacOSX_arm64::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();
-#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
+#define LLVM_TARGET(t) LLDB_PROCESS_ ## t(Initialize)
+#include "llvm/Config/Targets.def"
ArchitectureArm::Initialize();
ArchitectureMips::Initialize();
@@ -302,34 +306,8 @@ void SystemInitializerFull::Terminate()
ArchitectureMips::Terminate();
ArchitecturePPC64::Terminate();
-#ifdef LLVM_TARGET_AArch64_BUILT
- ABIMacOSX_arm64::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();
-#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
+#define LLVM_TARGET(t) LLDB_PROCESS_ ## t(Terminate)
+#include "llvm/Config/Targets.def"
DisassemblerLLVMC::Terminate();
Modified: lldb/trunk/tools/lldb-test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-test/CMakeLists.txt?rev=372952&r1=372951&r2=372952&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-test/CMakeLists.txt (original)
+++ lldb/trunk/tools/lldb-test/CMakeLists.txt Thu Sep 26 02:47:32 2019
@@ -24,9 +24,4 @@ add_lldb_tool(lldb-test
Support
)
-foreach (t ${LLVM_TARGETS_TO_BUILD})
- set_property(SOURCE SystemInitializerTest.cpp APPEND PROPERTY
- COMPILE_DEFINITIONS "LLVM_TARGET_${t}_BUILT")
-endforeach()
-
include_directories(${LLDB_SOURCE_DIR}/source)
Modified: lldb/trunk/tools/lldb-test/SystemInitializerTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-test/SystemInitializerTest.cpp?rev=372952&r1=372951&r2=372952&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-test/SystemInitializerTest.cpp (original)
+++ lldb/trunk/tools/lldb-test/SystemInitializerTest.cpp Thu Sep 26 02:47:32 2019
@@ -112,6 +112,36 @@ SystemInitializerTest::SystemInitializer
SystemInitializerTest::~SystemInitializerTest() {}
+#define LLDB_PROCESS_AArch64(op) \
+ ABIMacOSX_arm64::op(); \
+ ABISysV_arm64::op();
+#define LLDB_PROCESS_ARM(op) \
+ ABIMacOSX_arm::op(); \
+ ABISysV_arm::op();
+#define LLDB_PROCESS_Hexagon(op) ABISysV_hexagon::op();
+#define LLDB_PROCESS_Mips(op) \
+ ABISysV_mips::op(); \
+ ABISysV_mips64::op();
+#define LLDB_PROCESS_PowerPC(op) \
+ ABISysV_ppc::op(); \
+ ABISysV_ppc64::op();
+#define LLDB_PROCESS_SystemZ(op) ABISysV_s390x::op();
+#define LLDB_PROCESS_X86(op) \
+ ABIMacOSX_i386::op(); \
+ ABISysV_i386::op(); \
+ ABISysV_x86_64::op(); \
+ ABIWindows_x86_64::op();
+
+#define LLDB_PROCESS_AMDGPU(op)
+#define LLDB_PROCESS_BPF(op)
+#define LLDB_PROCESS_Lanai(op)
+#define LLDB_PROCESS_MSP430(op)
+#define LLDB_PROCESS_NVPTX(op)
+#define LLDB_PROCESS_RISCV(op)
+#define LLDB_PROCESS_Sparc(op)
+#define LLDB_PROCESS_WebAssembly(op)
+#define LLDB_PROCESS_XCore(op)
+
llvm::Error SystemInitializerTest::Initialize() {
if (auto e = SystemInitializerCommon::Initialize())
return e;
@@ -145,34 +175,8 @@ llvm::Error SystemInitializerTest::Initi
ClangASTContext::Initialize();
-#ifdef LLVM_TARGET_AArch64_BUILT
- ABIMacOSX_arm64::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();
-#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
+#define LLVM_TARGET(t) LLDB_PROCESS_ ## t(Initialize)
+#include "llvm/Config/Targets.def"
ArchitectureArm::Initialize();
ArchitecturePPC64::Initialize();
@@ -262,34 +266,8 @@ void SystemInitializerTest::Terminate()
ClangASTContext::Terminate();
-#ifdef LLVM_TARGET_AArch64_BUILT
- ABIMacOSX_arm64::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();
-#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
+#define LLVM_TARGET(t) LLDB_PROCESS_ ## t(Terminate)
+#include "llvm/Config/Targets.def"
DisassemblerLLVMC::Terminate();
More information about the lldb-commits
mailing list