create the raddr addressing mode that matches any register and the frame index
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 10 Jul 2006 01:41:35 +0000 (01:41 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 10 Jul 2006 01:41:35 +0000 (01:41 +0000)
use raddr for the ldr instruction. This removes a dummy mov from the assembly output
remove SelectFrameIndex
remove isLoadFromStackSlot
remove isStoreToStackSlot

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

lib/Target/ARM/ARMISelDAGToDAG.cpp
lib/Target/ARM/ARMInstrInfo.cpp
lib/Target/ARM/ARMInstrInfo.h
lib/Target/ARM/ARMInstrInfo.td
lib/Target/ARM/ARMRegisterInfo.cpp

index 413ca5959a113bc3099c0de3bd43b873601b750b..33413d6c5b507aa2a31cb1c88d4a5c8a4f055e45 100644 (file)
@@ -95,8 +95,7 @@ static SDOperand LowerFORMAL_ARGUMENT(SDOperand Op, SelectionDAG &DAG,
     // If the argument is actually used, emit a load from the right stack
       // slot.
     if (!Op.Val->hasNUsesOfValue(0, ArgNo)) {
-      //hack
-      unsigned ArgOffset = 0;
+      unsigned ArgOffset = (ArgNo - num_regs) * 4;
 
       MachineFrameInfo *MFI = MF.getFrameInfo();
       unsigned ObjSize = MVT::getSizeInBits(ObjectVT)/8;
@@ -165,6 +164,7 @@ public:
 
   void Select(SDOperand &Result, SDOperand Op);
   virtual void InstructionSelectBasicBlock(SelectionDAG &DAG);
+  bool SelectAddrReg(SDOperand N, SDOperand &Base);
 
   // Include the pieces autogenerated from the target description.
 #include "ARMGenDAGISel.inc"
@@ -183,12 +183,13 @@ void ARMDAGToDAGISel::InstructionSelectBasicBlock(SelectionDAG &DAG) {
   ScheduleAndEmitDAG(DAG);
 }
 
-static void SelectFrameIndex(SelectionDAG *CurDAG, SDOperand &Result, SDNode *N, SDOperand Op) {
-  int FI = cast<FrameIndexSDNode>(N)->getIndex();
-
-  SDOperand TFI = CurDAG->getTargetFrameIndex(FI, Op.getValueType());
-
-  Result = CurDAG->SelectNodeTo(N, ARM::movri, Op.getValueType(), TFI);
+bool ARMDAGToDAGISel::SelectAddrReg(SDOperand N, SDOperand &Base) {
+  if (FrameIndexSDNode *FI = dyn_cast<FrameIndexSDNode>(N)) {
+    Base = CurDAG->getTargetFrameIndex(FI->getIndex(), N.getValueType());
+  }
+  else
+    Base = N;
+  return true;      //any address fits in a register
 }
 
 void ARMDAGToDAGISel::Select(SDOperand &Result, SDOperand Op) {
@@ -198,10 +199,6 @@ void ARMDAGToDAGISel::Select(SDOperand &Result, SDOperand Op) {
   default:
     SelectCode(Result, Op);
     break;
-
-  case ISD::FrameIndex:
-    SelectFrameIndex(CurDAG, Result, N, Op);
-    break;
   }
 }
 
index 5abe8d688d6431340ebfa1fdb5477191097ee582..5437c1dda1059aeac6a16865bc871d69fc7ef72f 100644 (file)
@@ -41,25 +41,3 @@ bool ARMInstrInfo::isMoveInstr(const MachineInstr &MI,
     return true;
   }
 }
-
-/// 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 ARMInstrInfo::isLoadFromStackSlot(MachineInstr *MI,
-                                             int &FrameIndex) const {
-  assert(0 && "not implemented");
-  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 ARMInstrInfo::isStoreToStackSlot(MachineInstr *MI,
-                                            int &FrameIndex) const {
-  assert(0 && "not implemented");
-  return 0;
-}
index b203b2235f09437edfd86a9b65d29ea9fd88ca07..e75a71d0e2632b1cc75937e9cedc3b3ec98bc0b0 100644 (file)
@@ -36,20 +36,6 @@ public:
   ///
   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;
 };
 
 }
index 6ac9b0482ad6e698d88e7b4f32fc817c07283749..68913de1059e7f9a0507384e51f314449f25632e 100644 (file)
@@ -12,7 +12,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-
+// Define ARM specific addressing mode.
+ //register or frame index
+def raddr  : ComplexPattern<iPTR, 1, "SelectAddrReg", []>;
 
 //===----------------------------------------------------------------------===//
 // Instructions
@@ -42,7 +44,7 @@ def bxr: InstARM<(ops IntRegs:$dst), "bx $dst", [(brind IntRegs:$dst)]>;
 
 def ldr   : InstARM<(ops IntRegs:$dst, IntRegs:$addr),
                      "ldr $dst, [$addr]",
-                     [(set IntRegs:$dst, (load IntRegs:$addr))]>;
+                     [(set IntRegs:$dst, (load raddr:$addr))]>;
 
 def str  : InstARM<(ops IntRegs:$src, IntRegs:$addr),
                     "str $src, [$addr]",
index 007b2914a136834d36b72f9e399e3b9da0b55bb2..0c269eede23e8be272ded08a10343deb6b7013cf 100644 (file)
@@ -81,7 +81,7 @@ ARMRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II) const {
   MachineBasicBlock &MBB = *MI.getParent();
   MachineFunction &MF = *MBB.getParent();
 
-  assert (MI.getOpcode() == ARM::movri);
+  assert (MI.getOpcode() == ARM::ldr);
 
   unsigned FrameIdx = 1;