llvm.org GIT mirror llvm / 44819cb
implemented sub correctly update the stack pointer in the prologue and epilogue git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29244 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 14 years ago
2 changed file(s) with 12 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
7575 def addri : InstARM<(ops IntRegs:$dst, IntRegs:$a, i32imm:$b),
7676 "add $dst, $a, $b",
7777 [(set IntRegs:$dst, (add IntRegs:$a, imm:$b))]>;
78
79 def subri : InstARM<(ops IntRegs:$dst, IntRegs:$a, i32imm:$b),
80 "sub $dst, $a, $b",
81 [(set IntRegs:$dst, (sub IntRegs:$a, imm:$b))]>;
116116
117117 void ARMRegisterInfo::emitPrologue(MachineFunction &MF) const {
118118 MachineBasicBlock &MBB = MF.front();
119 MachineBasicBlock::iterator MBBI = MBB.begin();
119120 MachineFrameInfo *MFI = MF.getFrameInfo();
120121 int NumBytes = (int) MFI->getStackSize();
121122
122123 //hack
123124 assert(NumBytes == 0);
124125
125 //add a sp = sp - 4
126 BuildMI(MBB, MBB.begin(), ARM::str, 1, ARM::R14).addReg(ARM::R13);
126 //sub sp, sp, #4
127 BuildMI(MBB, MBBI, ARM::subri, 2, ARM::R13).addReg(ARM::R13).addImm(4);
128 //str lr, [sp]
129 BuildMI(MBB, MBBI, ARM::str, 1, ARM::R14).addReg(ARM::R13);
127130 }
128131
129132 void ARMRegisterInfo::emitEpilogue(MachineFunction &MF,
137140 //hack
138141 assert(NumBytes == 0);
139142
143 //ldr lr, [sp]
140144 BuildMI(MBB, MBBI, ARM::ldr, 2, ARM::R14).addImm(0).addReg(ARM::R13);
141 //add a sp = sp + 4
145 //add sp, sp, #4
146 BuildMI(MBB, MBBI, ARM::addri, 2, ARM::R13).addReg(ARM::R13).addImm(4);
142147 }
143148
144149 unsigned ARMRegisterInfo::getRARegister() const {