diff options
author | Anton Korobeynikov <asl@math.spbu.ru> | 2009-05-03 13:09:57 +0000 |
---|---|---|
committer | Anton Korobeynikov <asl@math.spbu.ru> | 2009-05-03 13:09:57 +0000 |
commit | aa29915b5822bd9af2a2b80eb95be59368743935 (patch) | |
tree | ed53b9645f44112849ae312a61d1b75998a5ac06 /lib/Target/MSP430/MSP430RegisterInfo.cpp | |
parent | cf14ae550051002283eabfb4dcbd67fa71f46f67 (diff) | |
download | llvm-aa29915b5822bd9af2a2b80eb95be59368743935.tar.gz llvm-aa29915b5822bd9af2a2b80eb95be59368743935.tar.bz2 llvm-aa29915b5822bd9af2a2b80eb95be59368743935.tar.xz |
First draft of stack slot loads / stores lowering
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70735 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/MSP430/MSP430RegisterInfo.cpp')
-rw-r--r-- | lib/Target/MSP430/MSP430RegisterInfo.cpp | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/lib/Target/MSP430/MSP430RegisterInfo.cpp b/lib/Target/MSP430/MSP430RegisterInfo.cpp index c7efa5e351..be187fa8e6 100644 --- a/lib/Target/MSP430/MSP430RegisterInfo.cpp +++ b/lib/Target/MSP430/MSP430RegisterInfo.cpp @@ -74,6 +74,11 @@ MSP430RegisterInfo::getReservedRegs(const MachineFunction &MF) const { return Reserved; } +const TargetRegisterClass* MSP430RegisterInfo::getPointerRegClass() const { + return &MSP430::GR16RegClass; +} + + bool MSP430RegisterInfo::hasFP(const MachineFunction &MF) const { return NoFramePointerElim || MF.getFrameInfo()->hasVarSizedObjects(); } @@ -143,7 +148,32 @@ eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, void MSP430RegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj, RegScavenger *RS) const { - assert(0 && "Not implemented yet!"); + assert(SPAdj == 0 && "Unexpected"); + + unsigned i = 0; + MachineInstr &MI = *II; + MachineFunction &MF = *MI.getParent()->getParent(); + while (!MI.getOperand(i).isFI()) { + ++i; + assert(i < MI.getNumOperands() && "Instr doesn't have FrameIndex operand!"); + } + + int FrameIndex = MI.getOperand(i).getIndex(); + + unsigned BasePtr = (hasFP(MF) ? MSP430::FPW : MSP430::SPW); + int Offset = MF.getFrameInfo()->getObjectOffset(FrameIndex); + + if (!hasFP(MF)) + Offset += MF.getFrameInfo()->getStackSize(); + + // Skip the saved PC + Offset += 2; + + MI.getOperand(i).ChangeToRegister(BasePtr, false); + + // Fold imm into offset + Offset += MI.getOperand(i+1).getImm(); + MI.getOperand(i+1).ChangeToImmediate(Offset); } void MSP430RegisterInfo::emitPrologue(MachineFunction &MF) const { |