Author: Michał Górny
Date: 2021-10-06T22:21:48+02:00
New Revision: 67231650e6ef2dda02838cf9146a200ba7e08a84

URL: 
https://github.com/llvm/llvm-project/commit/67231650e6ef2dda02838cf9146a200ba7e08a84
DIFF: 
https://github.com/llvm/llvm-project/commit/67231650e6ef2dda02838cf9146a200ba7e08a84.diff

LOG: [lldb] [ABI/X86] Split base x86 and i386 classes

Split the ABIX86 class into two classes: base ABIX86 class that is
common to 32-bit and 64-bit ABIs, and ABIX86_i386 class that is the base
for 32-bit ABIs.  This removes the confusing concept that ABIX86
initializes 64-bit ABIs but is only the base for 32-bit ABIs.

Differential Revision: https://reviews.llvm.org/D111216

Added: 
    lldb/source/Plugins/ABI/X86/ABIX86_i386.cpp
    lldb/source/Plugins/ABI/X86/ABIX86_i386.h

Modified: 
    lldb/source/Plugins/ABI/X86/ABIMacOSX_i386.h
    lldb/source/Plugins/ABI/X86/ABISysV_i386.h
    lldb/source/Plugins/ABI/X86/ABIX86.cpp
    lldb/source/Plugins/ABI/X86/ABIX86.h
    lldb/source/Plugins/ABI/X86/ABIX86_64.h
    lldb/source/Plugins/ABI/X86/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/ABI/X86/ABIMacOSX_i386.h 
b/lldb/source/Plugins/ABI/X86/ABIMacOSX_i386.h
index a59e1b05a256..4c54645a6f95 100644
--- a/lldb/source/Plugins/ABI/X86/ABIMacOSX_i386.h
+++ b/lldb/source/Plugins/ABI/X86/ABIMacOSX_i386.h
@@ -9,11 +9,11 @@
 #ifndef LLDB_SOURCE_PLUGINS_ABI_X86_ABIMACOSX_I386_H
 #define LLDB_SOURCE_PLUGINS_ABI_X86_ABIMACOSX_I386_H
 
-#include "Plugins/ABI/X86/ABIX86.h"
+#include "Plugins/ABI/X86/ABIX86_i386.h"
 #include "lldb/Core/Value.h"
 #include "lldb/lldb-private.h"
 
-class ABIMacOSX_i386 : public ABIX86 {
+class ABIMacOSX_i386 : public ABIX86_i386 {
 public:
   ~ABIMacOSX_i386() override = default;
 
@@ -92,7 +92,7 @@ class ABIMacOSX_i386 : public ABIX86 {
   }
 
 private:
-  using ABIX86::ABIX86; // Call CreateInstance instead.
+  using ABIX86_i386::ABIX86_i386; // Call CreateInstance instead.
 };
 
 #endif // LLDB_SOURCE_PLUGINS_ABI_X86_ABIMACOSX_I386_H

diff  --git a/lldb/source/Plugins/ABI/X86/ABISysV_i386.h 
b/lldb/source/Plugins/ABI/X86/ABISysV_i386.h
index 651e467ad576..c3a584366b2a 100644
--- a/lldb/source/Plugins/ABI/X86/ABISysV_i386.h
+++ b/lldb/source/Plugins/ABI/X86/ABISysV_i386.h
@@ -9,10 +9,10 @@
 #ifndef LLDB_SOURCE_PLUGINS_ABI_X86_ABISYSV_I386_H
 #define LLDB_SOURCE_PLUGINS_ABI_X86_ABISYSV_I386_H
 
-#include "Plugins/ABI/X86/ABIX86.h"
+#include "Plugins/ABI/X86/ABIX86_i386.h"
 #include "lldb/lldb-private.h"
 
-class ABISysV_i386 : public ABIX86 {
+class ABISysV_i386 : public ABIX86_i386 {
 public:
   ~ABISysV_i386() override = default;
 
@@ -95,7 +95,7 @@ class ABISysV_i386 : public ABIX86 {
   bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info);
 
 private:
-  using ABIX86::ABIX86; // Call CreateInstance instead.
+  using ABIX86_i386::ABIX86_i386; // Call CreateInstance instead.
 };
 
 #endif // LLDB_SOURCE_PLUGINS_ABI_X86_ABISYSV_I386_H

diff  --git a/lldb/source/Plugins/ABI/X86/ABIX86.cpp 
b/lldb/source/Plugins/ABI/X86/ABIX86.cpp
index bf5ab669417e..c02680009e3e 100644
--- a/lldb/source/Plugins/ABI/X86/ABIX86.cpp
+++ b/lldb/source/Plugins/ABI/X86/ABIX86.cpp
@@ -1,4 +1,4 @@
-//===-- X86.h 
-------------------------------------------------------------===//
+//===-- ABIX86.cpp 
--------------------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -28,16 +28,3 @@ void ABIX86::Terminate() {
   ABISysV_x86_64::Terminate();
   ABIWindows_x86_64::Terminate();
 }
-
-uint32_t ABIX86::GetGenericNum(llvm::StringRef name) {
-  return llvm::StringSwitch<uint32_t>(name)
-      .Case("eip", LLDB_REGNUM_GENERIC_PC)
-      .Case("esp", LLDB_REGNUM_GENERIC_SP)
-      .Case("ebp", LLDB_REGNUM_GENERIC_FP)
-      .Case("eflags", LLDB_REGNUM_GENERIC_FLAGS)
-      .Case("edi", LLDB_REGNUM_GENERIC_ARG1)
-      .Case("esi", LLDB_REGNUM_GENERIC_ARG2)
-      .Case("edx", LLDB_REGNUM_GENERIC_ARG3)
-      .Case("ecx", LLDB_REGNUM_GENERIC_ARG4)
-      .Default(LLDB_INVALID_REGNUM);
-}

diff  --git a/lldb/source/Plugins/ABI/X86/ABIX86.h 
b/lldb/source/Plugins/ABI/X86/ABIX86.h
index 22521cacf180..2c25aac0bdc8 100644
--- a/lldb/source/Plugins/ABI/X86/ABIX86.h
+++ b/lldb/source/Plugins/ABI/X86/ABIX86.h
@@ -1,4 +1,4 @@
-//===-- X86.h ---------------------------------------------------*- C++ 
-*-===//
+//===-- ABIX86.h ------------------------------------------------*- C++ 
-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -10,15 +10,15 @@
 #define LLDB_SOURCE_PLUGINS_ABI_X86_ABIX86_H
 
 #include "lldb/Target/ABI.h"
+#include "lldb/lldb-private.h"
 
 class ABIX86 : public lldb_private::MCBasedABI {
 public:
   static void Initialize();
   static void Terminate();
 
-  uint32_t GetGenericNum(llvm::StringRef name) override;
-
 private:
   using lldb_private::MCBasedABI::MCBasedABI;
 };
+
 #endif

diff  --git a/lldb/source/Plugins/ABI/X86/ABIX86_64.h 
b/lldb/source/Plugins/ABI/X86/ABIX86_64.h
index e65c2d97d897..8fc98507adee 100644
--- a/lldb/source/Plugins/ABI/X86/ABIX86_64.h
+++ b/lldb/source/Plugins/ABI/X86/ABIX86_64.h
@@ -9,10 +9,9 @@
 #ifndef LLDB_SOURCE_PLUGINS_ABI_X86_ABIX86_64_H
 #define LLDB_SOURCE_PLUGINS_ABI_X86_ABIX86_64_H
 
-#include "lldb/Target/ABI.h"
-#include "lldb/lldb-private.h"
+#include "Plugins/ABI/X86/ABIX86.h"
 
-class ABIX86_64 : public lldb_private::MCBasedABI {
+class ABIX86_64 : public ABIX86 {
 protected:
   std::string GetMCName(std::string name) override {
     MapRegisterName(name, "stmm", "st");
@@ -20,7 +19,7 @@ class ABIX86_64 : public lldb_private::MCBasedABI {
   }
 
 private:
-  using lldb_private::MCBasedABI::MCBasedABI;
+  using ABIX86::ABIX86;
 };
 
 #endif // LLDB_SOURCE_PLUGINS_ABI_X86_ABIX86_64_H

diff  --git a/lldb/source/Plugins/ABI/X86/ABIX86_i386.cpp 
b/lldb/source/Plugins/ABI/X86/ABIX86_i386.cpp
new file mode 100644
index 000000000000..e376f0eb2bc7
--- /dev/null
+++ b/lldb/source/Plugins/ABI/X86/ABIX86_i386.cpp
@@ -0,0 +1,22 @@
+//===-- ABIX86_i386.cpp 
---------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "ABIX86_i386.h"
+
+uint32_t ABIX86_i386::GetGenericNum(llvm::StringRef name) {
+  return llvm::StringSwitch<uint32_t>(name)
+      .Case("eip", LLDB_REGNUM_GENERIC_PC)
+      .Case("esp", LLDB_REGNUM_GENERIC_SP)
+      .Case("ebp", LLDB_REGNUM_GENERIC_FP)
+      .Case("eflags", LLDB_REGNUM_GENERIC_FLAGS)
+      .Case("edi", LLDB_REGNUM_GENERIC_ARG1)
+      .Case("esi", LLDB_REGNUM_GENERIC_ARG2)
+      .Case("edx", LLDB_REGNUM_GENERIC_ARG3)
+      .Case("ecx", LLDB_REGNUM_GENERIC_ARG4)
+      .Default(LLDB_INVALID_REGNUM);
+}

diff  --git a/lldb/source/Plugins/ABI/X86/ABIX86_i386.h 
b/lldb/source/Plugins/ABI/X86/ABIX86_i386.h
new file mode 100644
index 000000000000..cb3baa5150fc
--- /dev/null
+++ b/lldb/source/Plugins/ABI/X86/ABIX86_i386.h
@@ -0,0 +1,22 @@
+//===-- ABIX86_i386.h -------------------------------------------*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SOURCE_PLUGINS_ABI_X86_ABIX86_I386_H
+#define LLDB_SOURCE_PLUGINS_ABI_X86_ABIX86_I386_H
+
+#include "Plugins/ABI/X86/ABIX86.h"
+
+class ABIX86_i386 : public ABIX86 {
+public:
+  uint32_t GetGenericNum(llvm::StringRef name) override;
+
+private:
+  using ABIX86::ABIX86;
+};
+
+#endif

diff  --git a/lldb/source/Plugins/ABI/X86/CMakeLists.txt 
b/lldb/source/Plugins/ABI/X86/CMakeLists.txt
index ec8ed622549b..dd55212517a7 100644
--- a/lldb/source/Plugins/ABI/X86/CMakeLists.txt
+++ b/lldb/source/Plugins/ABI/X86/CMakeLists.txt
@@ -1,5 +1,6 @@
 add_lldb_library(lldbPluginABIX86 PLUGIN
   ABIX86.cpp
+  ABIX86_i386.cpp
   ABIMacOSX_i386.cpp
   ABISysV_i386.cpp
   ABISysV_x86_64.cpp


        
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to