mirror of
https://github.com/RPCS3/llvm.git
synced 2024-11-25 12:49:50 +00:00
[mips] Add function MipsFrameLowering::estimateStackSize.
This function estimates stack size and will be called before PrologEpilogInserter scans the callee-saved registers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167313 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
294166d541
commit
265f191b57
@ -98,3 +98,37 @@ bool MipsFrameLowering::hasFP(const MachineFunction &MF) const {
|
|||||||
return MF.getTarget().Options.DisableFramePointerElim(MF) ||
|
return MF.getTarget().Options.DisableFramePointerElim(MF) ||
|
||||||
MFI->hasVarSizedObjects() || MFI->isFrameAddressTaken();
|
MFI->hasVarSizedObjects() || MFI->isFrameAddressTaken();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t MipsFrameLowering::estimateStackSize(const MachineFunction &MF) const {
|
||||||
|
const MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||||
|
const TargetRegisterInfo &TRI = *MF.getTarget().getRegisterInfo();
|
||||||
|
|
||||||
|
int64_t Offset = 0;
|
||||||
|
|
||||||
|
// Iterate over fixed sized objects.
|
||||||
|
for (int I = MFI->getObjectIndexBegin(); I != 0; ++I)
|
||||||
|
Offset = std::max(Offset, -MFI->getObjectOffset(I));
|
||||||
|
|
||||||
|
// Conservatively assume all callee-saved registers will be saved.
|
||||||
|
for (const uint16_t *R = TRI.getCalleeSavedRegs(&MF); *R; ++R) {
|
||||||
|
unsigned Size = TRI.getMinimalPhysRegClass(*R)->getSize();
|
||||||
|
Offset = RoundUpToAlignment(Offset + Size, Size);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned MaxAlign = MFI->getMaxAlignment();
|
||||||
|
|
||||||
|
// Check that MaxAlign is not zero if there is a stack object that is not a
|
||||||
|
// callee-saved spill.
|
||||||
|
assert(!MFI->getObjectIndexEnd() || MaxAlign);
|
||||||
|
|
||||||
|
// Iterate over other objects.
|
||||||
|
for (unsigned I = 0, E = MFI->getObjectIndexEnd(); I != E; ++I)
|
||||||
|
Offset = RoundUpToAlignment(Offset + MFI->getObjectSize(I), MaxAlign);
|
||||||
|
|
||||||
|
// Call frame.
|
||||||
|
if (MFI->adjustsStack() && hasReservedCallFrame(MF))
|
||||||
|
Offset = RoundUpToAlignment(Offset + MFI->getMaxCallFrameSize(),
|
||||||
|
std::max(MaxAlign, getStackAlignment()));
|
||||||
|
|
||||||
|
return RoundUpToAlignment(Offset, getStackAlignment());
|
||||||
|
}
|
||||||
|
@ -34,6 +34,9 @@ public:
|
|||||||
const MipsSubtarget &ST);
|
const MipsSubtarget &ST);
|
||||||
|
|
||||||
bool hasFP(const MachineFunction &MF) const;
|
bool hasFP(const MachineFunction &MF) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
uint64_t estimateStackSize(const MachineFunction &MF) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Create MipsInstrInfo objects.
|
/// Create MipsInstrInfo objects.
|
||||||
|
Loading…
Reference in New Issue
Block a user