Cleanup ImmToIdxMap and noImmForm in PPCRegisterInfo
authorHal Finkel <hfinkel@anl.gov>
Sun, 31 Mar 2013 14:43:31 +0000 (14:43 +0000)
committerHal Finkel <hfinkel@anl.gov>
Sun, 31 Mar 2013 14:43:31 +0000 (14:43 +0000)
ImmToIdxMap should be a DenseMap (not a std::map) because there
is no ordering requirement. Also, we don't need a separate list
of instructions for noImmForm in eliminateFrameIndex, because this
list is essentially the complement of the keys in ImmToIdxMap.

No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178450 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/PowerPC/PPCRegisterInfo.cpp
lib/Target/PowerPC/PPCRegisterInfo.h

index 67cf13603b59f97c82545d24b3bb8d80325b4a3b..c3231868768ce561ed0a9f36db04a0c0badb3025 100644 (file)
@@ -526,24 +526,10 @@ PPCRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
     break;
   }
 
-  bool noImmForm = false;
-  switch (OpC) {
-  case PPC::LFIWAX:
-  case PPC::LVEBX:
-  case PPC::LVEHX:
-  case PPC::LVEWX:
-  case PPC::LVX:
-  case PPC::LVXL:
-  case PPC::LVSL:
-  case PPC::LVSR:
-  case PPC::STVEBX:
-  case PPC::STVEHX:
-  case PPC::STVEWX:
-  case PPC::STVX:
-  case PPC::STVXL:
-    noImmForm = true;
-    break;
-  }
+  // If the instruction is not present in ImmToIdxMap, then it has no immediate
+  // form (and must be r+r).
+  bool noImmForm = !MI.isInlineAsm() &&
+    (ImmToIdxMap.find(OpC) == ImmToIdxMap.end());
 
   // Now add the frame object offset to the offset from r1.
   int Offset = MFI->getObjectOffset(FrameIndex);
index 231bcd16846d8cc0ddb382cebfd5c369114dab71..7e6683eeb2ef6b5401bbc149d0c4ffa9366f09f9 100644 (file)
@@ -15,8 +15,8 @@
 #ifndef POWERPC32_REGISTERINFO_H
 #define POWERPC32_REGISTERINFO_H
 
+#include "llvm/ADT/DenseMap.h"
 #include "PPC.h"
-#include <map>
 
 #define GET_REGINFO_HEADER
 #include "PPCGenRegisterInfo.inc"
@@ -27,7 +27,7 @@ class TargetInstrInfo;
 class Type;
 
 class PPCRegisterInfo : public PPCGenRegisterInfo {
-  std::map<unsigned, unsigned> ImmToIdxMap;
+  DenseMap<unsigned, unsigned> ImmToIdxMap;
   const PPCSubtarget &Subtarget;
   const TargetInstrInfo &TII;
 public: