mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
[mips] Implement eliminateCallFramePseudoInstr() in MipsFrameLowering. NFC.
Summary: Avoid duplicate code in Mips16FrameLowering and MipsSEFrameLowering by providing an implementation of the eliminateCallFramePseudoInstr() function from their base class. Depends on D8640. Reviewers: dsanders Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D8641 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233909 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -143,22 +143,6 @@ bool Mips16FrameLowering::restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Eliminate ADJCALLSTACKDOWN, ADJCALLSTACKUP pseudo instructions
|
|
||||||
void Mips16FrameLowering::
|
|
||||||
eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
|
|
||||||
MachineBasicBlock::iterator I) const {
|
|
||||||
if (!hasReservedCallFrame(MF)) {
|
|
||||||
int64_t Amount = I->getOperand(0).getImm();
|
|
||||||
|
|
||||||
if (I->getOpcode() == Mips::ADJCALLSTACKDOWN)
|
|
||||||
Amount = -Amount;
|
|
||||||
|
|
||||||
STI.getInstrInfo()->adjustStackPtr(Mips::SP, Amount, MBB, I);
|
|
||||||
}
|
|
||||||
|
|
||||||
MBB.erase(I);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Mips16FrameLowering::hasReservedCallFrame(const MachineFunction &MF) const {
|
Mips16FrameLowering::hasReservedCallFrame(const MachineFunction &MF) const {
|
||||||
const MachineFrameInfo *MFI = MF.getFrameInfo();
|
const MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||||
|
@@ -26,10 +26,6 @@ public:
|
|||||||
void emitPrologue(MachineFunction &MF) const override;
|
void emitPrologue(MachineFunction &MF) const override;
|
||||||
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
|
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
|
||||||
|
|
||||||
void eliminateCallFramePseudoInstr(MachineFunction &MF,
|
|
||||||
MachineBasicBlock &MBB,
|
|
||||||
MachineBasicBlock::iterator I) const override;
|
|
||||||
|
|
||||||
bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
|
bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
|
||||||
MachineBasicBlock::iterator MI,
|
MachineBasicBlock::iterator MI,
|
||||||
const std::vector<CalleeSavedInfo> &CSI,
|
const std::vector<CalleeSavedInfo> &CSI,
|
||||||
|
@@ -131,3 +131,20 @@ uint64_t MipsFrameLowering::estimateStackSize(const MachineFunction &MF) const {
|
|||||||
|
|
||||||
return RoundUpToAlignment(Offset, getStackAlignment());
|
return RoundUpToAlignment(Offset, getStackAlignment());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Eliminate ADJCALLSTACKDOWN, ADJCALLSTACKUP pseudo instructions
|
||||||
|
void MipsFrameLowering::
|
||||||
|
eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
|
||||||
|
MachineBasicBlock::iterator I) const {
|
||||||
|
unsigned SP = STI.getABI().IsN64() ? Mips::SP_64 : Mips::SP;
|
||||||
|
|
||||||
|
if (!hasReservedCallFrame(MF)) {
|
||||||
|
int64_t Amount = I->getOperand(0).getImm();
|
||||||
|
if (I->getOpcode() == Mips::ADJCALLSTACKDOWN)
|
||||||
|
Amount = -Amount;
|
||||||
|
|
||||||
|
STI.getInstrInfo()->adjustStackPtr(SP, Amount, MBB, I);
|
||||||
|
}
|
||||||
|
|
||||||
|
MBB.erase(I);
|
||||||
|
}
|
||||||
|
@@ -32,6 +32,11 @@ public:
|
|||||||
|
|
||||||
bool hasFP(const MachineFunction &MF) const override;
|
bool hasFP(const MachineFunction &MF) const override;
|
||||||
|
|
||||||
|
void
|
||||||
|
eliminateCallFramePseudoInstr(MachineFunction &MF,
|
||||||
|
MachineBasicBlock &MBB,
|
||||||
|
MachineBasicBlock::iterator I) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint64_t estimateStackSize(const MachineFunction &MF) const;
|
uint64_t estimateStackSize(const MachineFunction &MF) const;
|
||||||
};
|
};
|
||||||
|
@@ -607,23 +607,6 @@ MipsSEFrameLowering::hasReservedCallFrame(const MachineFunction &MF) const {
|
|||||||
!MFI->hasVarSizedObjects();
|
!MFI->hasVarSizedObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Eliminate ADJCALLSTACKDOWN, ADJCALLSTACKUP pseudo instructions
|
|
||||||
void MipsSEFrameLowering::
|
|
||||||
eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
|
|
||||||
MachineBasicBlock::iterator I) const {
|
|
||||||
if (!hasReservedCallFrame(MF)) {
|
|
||||||
int64_t Amount = I->getOperand(0).getImm();
|
|
||||||
|
|
||||||
if (I->getOpcode() == Mips::ADJCALLSTACKDOWN)
|
|
||||||
Amount = -Amount;
|
|
||||||
|
|
||||||
unsigned SP = STI.isABI_N64() ? Mips::SP_64 : Mips::SP;
|
|
||||||
STI.getInstrInfo()->adjustStackPtr(SP, Amount, MBB, I);
|
|
||||||
}
|
|
||||||
|
|
||||||
MBB.erase(I);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MipsSEFrameLowering::
|
void MipsSEFrameLowering::
|
||||||
processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
|
processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
|
||||||
RegScavenger *RS) const {
|
RegScavenger *RS) const {
|
||||||
|
@@ -27,10 +27,6 @@ public:
|
|||||||
void emitPrologue(MachineFunction &MF) const override;
|
void emitPrologue(MachineFunction &MF) const override;
|
||||||
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
|
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
|
||||||
|
|
||||||
void eliminateCallFramePseudoInstr(MachineFunction &MF,
|
|
||||||
MachineBasicBlock &MBB,
|
|
||||||
MachineBasicBlock::iterator I) const override;
|
|
||||||
|
|
||||||
bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
|
bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
|
||||||
MachineBasicBlock::iterator MI,
|
MachineBasicBlock::iterator MI,
|
||||||
const std::vector<CalleeSavedInfo> &CSI,
|
const std::vector<CalleeSavedInfo> &CSI,
|
||||||
|
Reference in New Issue
Block a user