// 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;
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"
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) {
default:
SelectCode(Result, Op);
break;
-
- case ISD::FrameIndex:
- SelectFrameIndex(CurDAG, Result, N, Op);
- break;
}
}
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;
-}
///
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;
};
}
//
//===----------------------------------------------------------------------===//
-
+// Define ARM specific addressing mode.
+ //register or frame index
+def raddr : ComplexPattern<iPTR, 1, "SelectAddrReg", []>;
//===----------------------------------------------------------------------===//
// Instructions
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]",
MachineBasicBlock &MBB = *MI.getParent();
MachineFunction &MF = *MBB.getParent();
- assert (MI.getOpcode() == ARM::movri);
+ assert (MI.getOpcode() == ARM::ldr);
unsigned FrameIdx = 1;