forked from OSchip/llvm-project
parent
5dbf760e00
commit
b5932a5708
|
|
@ -110,34 +110,35 @@ static bool hasFP(MachineFunction &MF) {
|
||||||
void PowerPCRegisterInfo::
|
void PowerPCRegisterInfo::
|
||||||
eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
|
eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
|
||||||
MachineBasicBlock::iterator I) const {
|
MachineBasicBlock::iterator I) const {
|
||||||
if (hasFP(MF)) {
|
if (hasFP(MF)) {
|
||||||
// If we have a frame pointer, turn the adjcallstackdown instruction into a
|
// If we have a frame pointer, turn the adjcallstackdown instruction into a
|
||||||
// 'sub r1, r1, <amt>' and the adjcallstackup instruction into 'add r1, r1, <amt>'
|
// 'sub r1, r1, <amt>' and the adjcallstackup instruction into
|
||||||
MachineInstr *Old = I;
|
// 'add r1, r1, <amt>'
|
||||||
int Amount = Old->getOperand(0).getImmedValue();
|
MachineInstr *Old = I;
|
||||||
if (Amount != 0) {
|
int Amount = Old->getOperand(0).getImmedValue();
|
||||||
// We need to keep the stack aligned properly. To do this, we round the
|
if (Amount != 0) {
|
||||||
// amount of space needed for the outgoing arguments up to the next
|
// We need to keep the stack aligned properly. To do this, we round the
|
||||||
// alignment boundary.
|
// amount of space needed for the outgoing arguments up to the next
|
||||||
unsigned Align = MF.getTarget().getFrameInfo()->getStackAlignment();
|
// alignment boundary.
|
||||||
Amount = (Amount+Align-1)/Align*Align;
|
unsigned Align = MF.getTarget().getFrameInfo()->getStackAlignment();
|
||||||
|
Amount = (Amount+Align-1)/Align*Align;
|
||||||
|
|
||||||
MachineInstr *New;
|
MachineInstr *New;
|
||||||
if (Old->getOpcode() == PPC32::ADJCALLSTACKDOWN) {
|
if (Old->getOpcode() == PPC32::ADJCALLSTACKDOWN) {
|
||||||
New = BuildMI(PPC32::ADDI, 2, PPC32::R1).addReg(PPC32::R1)
|
New = BuildMI(PPC32::ADDI, 2, PPC32::R1).addReg(PPC32::R1)
|
||||||
.addSImm(-Amount);
|
.addSImm(-Amount);
|
||||||
} else {
|
} else {
|
||||||
assert(Old->getOpcode() == PPC32::ADJCALLSTACKUP);
|
assert(Old->getOpcode() == PPC32::ADJCALLSTACKUP);
|
||||||
New = BuildMI(PPC32::ADDI, 2, PPC32::R1).addReg(PPC32::R1)
|
New = BuildMI(PPC32::ADDI, 2, PPC32::R1).addReg(PPC32::R1)
|
||||||
.addSImm(Amount);
|
.addSImm(Amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace the pseudo instruction with a new instruction...
|
// Replace the pseudo instruction with a new instruction...
|
||||||
MBB.insert(I, New);
|
MBB.insert(I, New);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MBB.erase(I);
|
MBB.erase(I);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -223,7 +224,7 @@ void PowerPCRegisterInfo::emitEpilogue(MachineFunction &MF,
|
||||||
MachineBasicBlock::iterator MBBI = prior(MBB.end());
|
MachineBasicBlock::iterator MBBI = prior(MBB.end());
|
||||||
MachineInstr *MI;
|
MachineInstr *MI;
|
||||||
assert(MBBI->getOpcode() == PPC32::BLR &&
|
assert(MBBI->getOpcode() == PPC32::BLR &&
|
||||||
"Can only insert epilog into returning blocks");
|
"Can only insert epilog into returning blocks");
|
||||||
|
|
||||||
// Get the number of bytes allocated from the FrameInfo...
|
// Get the number of bytes allocated from the FrameInfo...
|
||||||
unsigned NumBytes = MFI->getStackSize();
|
unsigned NumBytes = MFI->getStackSize();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue