[llvm-commits] CVS: llvm/lib/Target/SparcV8/SparcV8InstrInfo.cpp SparcV8InstrInfo.h

Chris Lattner lattner at cs.uiuc.edu
Thu Feb 2 22:45:07 PST 2006



Changes in directory llvm/lib/Target/SparcV8:

SparcV8InstrInfo.cpp updated: 1.9 -> 1.10
SparcV8InstrInfo.h updated: 1.5 -> 1.6
---
Log message:

Implement isLoadFromStackSlot and isStoreToStackSlot


---
Diffs of the changes:  (+52 -0)

 SparcV8InstrInfo.cpp |   38 ++++++++++++++++++++++++++++++++++++++
 SparcV8InstrInfo.h   |   14 ++++++++++++++
 2 files changed, 52 insertions(+)


Index: llvm/lib/Target/SparcV8/SparcV8InstrInfo.cpp
diff -u llvm/lib/Target/SparcV8/SparcV8InstrInfo.cpp:1.9 llvm/lib/Target/SparcV8/SparcV8InstrInfo.cpp:1.10
--- llvm/lib/Target/SparcV8/SparcV8InstrInfo.cpp:1.9	Sun Dec 18 00:40:34 2005
+++ llvm/lib/Target/SparcV8/SparcV8InstrInfo.cpp	Fri Feb  3 00:44:54 2006
@@ -57,3 +57,41 @@
   }
   return false;
 }
+
+/// isLoadFromStackSlot - If the specified machine instruction is a direct
+/// load from a stack slot, return the virtual or physical register number of
+/// the destination along with the FrameIndex of the loaded stack slot.  If
+/// not, return 0.  This predicate must return 0 if the instruction has
+/// any side effects other than loading from the stack slot.
+unsigned SparcV8InstrInfo::isLoadFromStackSlot(MachineInstr *MI,
+                                               int &FrameIndex) const {
+  if (MI->getOpcode() == V8::LDri ||
+      MI->getOpcode() == V8::LDFri ||
+      MI->getOpcode() == V8::LDDFri) {
+    if (MI->getOperand(1).isFrameIndex() && MI->getOperand(2).isImmediate() &&
+        MI->getOperand(2).getImmedValue() == 0) {
+      FrameIndex = MI->getOperand(1).getFrameIndex();
+      return MI->getOperand(0).getReg();
+    }
+  }
+  return 0;
+}
+
+/// isStoreToStackSlot - If the specified machine instruction is a direct
+/// store to a stack slot, return the virtual or physical register number of
+/// the source reg along with the FrameIndex of the loaded stack slot.  If
+/// not, return 0.  This predicate must return 0 if the instruction has
+/// any side effects other than storing to the stack slot.
+unsigned SparcV8InstrInfo::isStoreToStackSlot(MachineInstr *MI,
+                                              int &FrameIndex) const {
+  if (MI->getOpcode() == V8::STri ||
+      MI->getOpcode() == V8::STFri ||
+      MI->getOpcode() == V8::STDFri) {
+    if (MI->getOperand(0).isFrameIndex() && MI->getOperand(1).isImmediate() &&
+        MI->getOperand(1).getImmedValue() == 0) {
+      FrameIndex = MI->getOperand(0).getFrameIndex();
+      return MI->getOperand(2).getReg();
+    }
+  }
+  return 0;
+}


Index: llvm/lib/Target/SparcV8/SparcV8InstrInfo.h
diff -u llvm/lib/Target/SparcV8/SparcV8InstrInfo.h:1.5 llvm/lib/Target/SparcV8/SparcV8InstrInfo.h:1.6
--- llvm/lib/Target/SparcV8/SparcV8InstrInfo.h:1.5	Thu Apr 21 18:21:30 2005
+++ llvm/lib/Target/SparcV8/SparcV8InstrInfo.h	Fri Feb  3 00:44:54 2006
@@ -47,6 +47,20 @@
   ///
   virtual bool isMoveInstr(const MachineInstr &MI,
                            unsigned &SrcReg, unsigned &DstReg) const;
+  
+  /// isLoadFromStackSlot - If the specified machine instruction is a direct
+  /// load from a stack slot, return the virtual or physical register number of
+  /// the destination along with the FrameIndex of the loaded stack slot.  If
+  /// not, return 0.  This predicate must return 0 if the instruction has
+  /// any side effects other than loading from the stack slot.
+  virtual unsigned isLoadFromStackSlot(MachineInstr *MI, int &FrameIndex) const;
+  
+  /// isStoreToStackSlot - If the specified machine instruction is a direct
+  /// store to a stack slot, return the virtual or physical register number of
+  /// the source reg along with the FrameIndex of the loaded stack slot.  If
+  /// not, return 0.  This predicate must return 0 if the instruction has
+  /// any side effects other than storing to the stack slot.
+  virtual unsigned isStoreToStackSlot(MachineInstr *MI, int &FrameIndex) const;
 };
 
 }






More information about the llvm-commits mailing list