mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-21 00:32:23 +00:00
Code clean up. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122528 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b0ad9cf935
commit
e4a2dd2f1a
@ -492,39 +492,43 @@ void X86RegisterInfo::
|
|||||||
eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
|
eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
|
||||||
MachineBasicBlock::iterator I) const {
|
MachineBasicBlock::iterator I) const {
|
||||||
const TargetFrameInfo *TFI = MF.getTarget().getFrameInfo();
|
const TargetFrameInfo *TFI = MF.getTarget().getFrameInfo();
|
||||||
|
bool reseveCallFrame = TFI->hasReservedCallFrame(MF);
|
||||||
|
int Opcode = I->getOpcode();
|
||||||
|
bool isDestroy = Opcode == getCallFrameDestroyOpcode();
|
||||||
|
DebugLoc DL = I->getDebugLoc();
|
||||||
|
uint64_t Amount = !reseveCallFrame ? I->getOperand(0).getImm() : 0;
|
||||||
|
uint64_t CalleeAmt = isDestroy ? I->getOperand(1).getImm() : 0;
|
||||||
|
I = MBB.erase(I);
|
||||||
|
|
||||||
if (!TFI->hasReservedCallFrame(MF)) {
|
if (!reseveCallFrame) {
|
||||||
// If the stack pointer can be changed after prologue, turn the
|
// If the stack pointer can be changed after prologue, turn the
|
||||||
// adjcallstackup instruction into a 'sub ESP, <amt>' and the
|
// adjcallstackup instruction into a 'sub ESP, <amt>' and the
|
||||||
// adjcallstackdown instruction into 'add ESP, <amt>'
|
// adjcallstackdown instruction into 'add ESP, <amt>'
|
||||||
// TODO: consider using push / pop instead of sub + store / add
|
// TODO: consider using push / pop instead of sub + store / add
|
||||||
MachineInstr *Old = I;
|
if (Amount == 0)
|
||||||
uint64_t Amount = Old->getOperand(0).getImm();
|
return;
|
||||||
if (Amount != 0) {
|
|
||||||
// We need to keep the stack aligned properly. To do this, we round the
|
// We need to keep the stack aligned properly. To do this, we round the
|
||||||
// amount of space needed for the outgoing arguments up to the next
|
// amount of space needed for the outgoing arguments up to the next
|
||||||
// alignment boundary.
|
// alignment boundary.
|
||||||
Amount = (Amount + StackAlign - 1) / StackAlign * StackAlign;
|
Amount = (Amount + StackAlign - 1) / StackAlign * StackAlign;
|
||||||
|
|
||||||
MachineInstr *New = 0;
|
MachineInstr *New = 0;
|
||||||
if (Old->getOpcode() == getCallFrameSetupOpcode()) {
|
if (Opcode == getCallFrameSetupOpcode()) {
|
||||||
New = BuildMI(MF, Old->getDebugLoc(),
|
New = BuildMI(MF, DL, TII.get(getSUBriOpcode(Is64Bit, Amount)),
|
||||||
TII.get(getSUBriOpcode(Is64Bit, Amount)),
|
|
||||||
StackPtr)
|
StackPtr)
|
||||||
.addReg(StackPtr)
|
.addReg(StackPtr)
|
||||||
.addImm(Amount);
|
.addImm(Amount);
|
||||||
} else {
|
} else {
|
||||||
assert(Old->getOpcode() == getCallFrameDestroyOpcode());
|
assert(Opcode == getCallFrameDestroyOpcode());
|
||||||
|
|
||||||
// Factor out the amount the callee already popped.
|
// Factor out the amount the callee already popped.
|
||||||
uint64_t CalleeAmt = Old->getOperand(1).getImm();
|
|
||||||
Amount -= CalleeAmt;
|
Amount -= CalleeAmt;
|
||||||
|
|
||||||
if (Amount) {
|
if (Amount) {
|
||||||
unsigned Opc = getADDriOpcode(Is64Bit, Amount);
|
unsigned Opc = getADDriOpcode(Is64Bit, Amount);
|
||||||
New = BuildMI(MF, Old->getDebugLoc(), TII.get(Opc), StackPtr)
|
New = BuildMI(MF, DL, TII.get(Opc), StackPtr)
|
||||||
.addReg(StackPtr)
|
.addReg(StackPtr).addImm(Amount);
|
||||||
.addImm(Amount);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -535,19 +539,17 @@ eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
|
|||||||
// Replace the pseudo instruction with a new instruction.
|
// Replace the pseudo instruction with a new instruction.
|
||||||
MBB.insert(I, New);
|
MBB.insert(I, New);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} else if (I->getOpcode() == getCallFrameDestroyOpcode()) {
|
|
||||||
|
if (Opcode == getCallFrameDestroyOpcode() && CalleeAmt) {
|
||||||
// If we are performing frame pointer elimination and if the callee pops
|
// If we are performing frame pointer elimination and if the callee pops
|
||||||
// something off the stack pointer, add it back. We do this until we have
|
// something off the stack pointer, add it back. We do this until we have
|
||||||
// more advanced stack pointer tracking ability.
|
// more advanced stack pointer tracking ability.
|
||||||
if (uint64_t CalleeAmt = I->getOperand(1).getImm()) {
|
|
||||||
unsigned Opc = getSUBriOpcode(Is64Bit, CalleeAmt);
|
unsigned Opc = getSUBriOpcode(Is64Bit, CalleeAmt);
|
||||||
MachineInstr *Old = I;
|
MachineInstr *New = BuildMI(MF, DL, TII.get(Opc), StackPtr)
|
||||||
MachineInstr *New =
|
.addReg(StackPtr).addImm(CalleeAmt);
|
||||||
BuildMI(MF, Old->getDebugLoc(), TII.get(Opc),
|
|
||||||
StackPtr)
|
|
||||||
.addReg(StackPtr)
|
|
||||||
.addImm(CalleeAmt);
|
|
||||||
|
|
||||||
// The EFLAGS implicit def is dead.
|
// The EFLAGS implicit def is dead.
|
||||||
New->getOperand(3).setIsDead();
|
New->getOperand(3).setIsDead();
|
||||||
@ -555,9 +557,6 @@ eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MBB.erase(I);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
X86RegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
|
X86RegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
|
||||||
int SPAdj, RegScavenger *RS) const{
|
int SPAdj, RegScavenger *RS) const{
|
||||||
|
Loading…
Reference in New Issue
Block a user