implement isStoreToStackSlot for PPC
authorChris Lattner <sabre@nondot.org>
Thu, 2 Feb 2006 20:16:12 +0000 (20:16 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 2 Feb 2006 20:16:12 +0000 (20:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25914 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/PowerPC/PPCInstrInfo.cpp
lib/Target/PowerPC/PPCInstrInfo.h

index 322d027504cffcbed2da9cbc72e7a4b6b8b76e02..66251c0b23208d2701727ca69efba34894064f15 100644 (file)
@@ -95,8 +95,25 @@ unsigned PPCInstrInfo::isLoadFromStackSlot(MachineInstr *MI,
     break;
   }
   return 0;
-                                              }
+}
 
+unsigned PPCInstrInfo::isStoreToStackSlot(MachineInstr *MI, 
+                                          int &FrameIndex) const {
+  switch (MI->getOpcode()) {
+  default: break;
+  //case PPC::ST:  ?
+  case PPC::STW:
+  case PPC::STFS:
+  case PPC::STFD:
+    if (MI->getOperand(1).isImmediate() && !MI->getOperand(1).getImmedValue() &&
+        MI->getOperand(2).isFrameIndex()) {
+      FrameIndex = MI->getOperand(2).getFrameIndex();
+      return MI->getOperand(0).getReg();
+    }
+    break;
+  }
+  return 0;
+}
 
 // commuteInstruction - We can commute rlwimi instructions, but only if the
 // rotate amt is zero.  We also have to munge the immediates a bit.
index d0be2d6ba3ea606d288fd0c4592d733a125b688c..f046e5dfb02aaac3a417acc8d0c35a252400c8f1 100644 (file)
@@ -40,6 +40,7 @@ public:
                            unsigned& destReg) const;
 
   unsigned isLoadFromStackSlot(MachineInstr *MI, int &FrameIndex) const;
+  unsigned isStoreToStackSlot(MachineInstr *MI, int &FrameIndex) const;
 
   // commuteInstruction - We can commute rlwimi instructions, but only if the
   // rotate amt is zero.  We also have to munge the immediates a bit.