[Lldb-commits] [lldb] r360868 - Simplify Triple::ppc64{, le} checks with Triple::isPPC64()

Fangrui Song via lldb-commits lldb-commits at lists.llvm.org
Thu May 16 02:07:33 PDT 2019


Author: maskray
Date: Thu May 16 02:07:33 2019
New Revision: 360868

URL: http://llvm.org/viewvc/llvm-project?rev=360868&view=rev
Log:
Simplify Triple::ppc64{,le} checks with Triple::isPPC64()

While here, update some ppc64le specific check to isPPC64(), if it
applies to big-endian as well, in the hope that it will ease the support
of big-endian if people are interested in this area. The big-endian
variant is used by at least FreeBSD, Gentoo Linux, Adélie Linux, and
Void Linux.

Modified:
    lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
    lldb/trunk/source/Plugins/Architecture/PPC64/ArchitecturePPC64.cpp
    lldb/trunk/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp
    lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Modified: lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp?rev=360868&r1=360867&r2=360868&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp Thu May 16 02:07:33 2019
@@ -69,10 +69,8 @@ lldb::ByteOrder ABISysV_ppc64::GetByteOr
 ABISP
 ABISysV_ppc64::CreateInstance(lldb::ProcessSP process_sp,
                               const ArchSpec &arch) {
-  if (arch.GetTriple().getArch() == llvm::Triple::ppc64 ||
-      arch.GetTriple().getArch() == llvm::Triple::ppc64le) {
+  if (arch.GetTriple().isPPC64())
     return ABISP(new ABISysV_ppc64(process_sp));
-  }
   return ABISP();
 }
 

Modified: lldb/trunk/source/Plugins/Architecture/PPC64/ArchitecturePPC64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Architecture/PPC64/ArchitecturePPC64.cpp?rev=360868&r1=360867&r2=360868&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Architecture/PPC64/ArchitecturePPC64.cpp (original)
+++ lldb/trunk/source/Plugins/Architecture/PPC64/ArchitecturePPC64.cpp Thu May 16 02:07:33 2019
@@ -35,11 +35,10 @@ void ArchitecturePPC64::Terminate() {
 }
 
 std::unique_ptr<Architecture> ArchitecturePPC64::Create(const ArchSpec &arch) {
-  if ((arch.GetMachine() != llvm::Triple::ppc64 &&
-       arch.GetMachine() != llvm::Triple::ppc64le) ||
-      arch.GetTriple().getObjectFormat() != llvm::Triple::ObjectFormatType::ELF)
-    return nullptr;
-  return std::unique_ptr<Architecture>(new ArchitecturePPC64());
+  if (arch.GetTriple().isPPC64() &&
+      arch.GetTriple().getObjectFormat() == llvm::Triple::ObjectFormatType::ELF)
+    return std::unique_ptr<Architecture>(new ArchitecturePPC64());
+  return nullptr;
 }
 
 ConstString ArchitecturePPC64::GetPluginName() { return GetPluginNameStatic(); }

Modified: lldb/trunk/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp?rev=360868&r1=360867&r2=360868&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp (original)
+++ lldb/trunk/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp Thu May 16 02:07:33 2019
@@ -55,23 +55,15 @@ EmulateInstruction *
 EmulateInstructionPPC64::CreateInstance(const ArchSpec &arch,
                                         InstructionType inst_type) {
   if (EmulateInstructionPPC64::SupportsEmulatingInstructionsOfTypeStatic(
-          inst_type)) {
-    if (arch.GetTriple().getArch() == llvm::Triple::ppc64 ||
-        arch.GetTriple().getArch() == llvm::Triple::ppc64le) {
+          inst_type))
+    if (arch.GetTriple().isPPC64())
       return new EmulateInstructionPPC64(arch);
-    }
-  }
 
   return nullptr;
 }
 
 bool EmulateInstructionPPC64::SetTargetTriple(const ArchSpec &arch) {
-  if (arch.GetTriple().getArch() == llvm::Triple::ppc64)
-    return true;
-  else if (arch.GetTriple().getArch() == llvm::Triple::ppc64le)
-    return true;
-
-  return false;
+  return arch.GetTriple().isPPC64();
 }
 
 static bool LLDBTableGetRegisterInfo(uint32_t reg_num, RegisterInfo &reg_info) {

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp?rev=360868&r1=360867&r2=360868&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp Thu May 16 02:07:33 2019
@@ -1007,7 +1007,7 @@ NativeProcessLinux::SetupSoftwareSingleS
       // Arm mode
       error = SetSoftwareBreakpoint(next_pc, 4);
     }
-  } else if (m_arch.IsMIPS() || m_arch.GetMachine() == llvm::Triple::ppc64le)
+  } else if (m_arch.IsMIPS() || m_arch.GetTriple().isPPC64())
     error = SetSoftwareBreakpoint(next_pc, 4);
   else {
     // No size hint is given for the next breakpoint

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=360868&r1=360867&r2=360868&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Thu May 16 02:07:33 2019
@@ -1711,21 +1711,21 @@ lldb_private::Status
 GDBRemoteCommunicationClient::GetWatchpointsTriggerAfterInstruction(
     bool &after, const ArchSpec &arch) {
   Status error;
-  llvm::Triple::ArchType atype = arch.GetMachine();
+  llvm::Triple triple = arch.GetTriple();
 
   // we assume watchpoints will happen after running the relevant opcode and we
   // only want to override this behavior if we have explicitly received a
   // qHostInfo telling us otherwise
   if (m_qHostInfo_is_valid != eLazyBoolYes) {
-    // On targets like MIPS and ppc64le, watchpoint exceptions are always
+    // On targets like MIPS and ppc64, watchpoint exceptions are always
     // generated before the instruction is executed. The connected target may
     // not support qHostInfo or qWatchpointSupportInfo packets.
-    after = !(arch.IsMIPS() || atype == llvm::Triple::ppc64le);
+    after = !(triple.isMIPS() || triple.isPPC64());
   } else {
-    // For MIPS and ppc64le, set m_watchpoints_trigger_after_instruction to
+    // For MIPS and ppc64, set m_watchpoints_trigger_after_instruction to
     // eLazyBoolNo if it is not calculated before.
     if (m_watchpoints_trigger_after_instruction == eLazyBoolCalculate &&
-        (arch.IsMIPS() || atype == llvm::Triple::ppc64le))
+        (triple.isMIPS() || triple.isPPC64()))
       m_watchpoints_trigger_after_instruction = eLazyBoolNo;
 
     after = (m_watchpoints_trigger_after_instruction != eLazyBoolNo);




More information about the lldb-commits mailing list