1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 12:12:47 +01:00

[VE] Remove magic numbers 176

Remove magic numbers 176 from VE source codes and update comments.

Reviewed By: simoll

Differential Revision: https://reviews.llvm.org/D91958
This commit is contained in:
Kazushi (Jam) Marukawa 2020-11-22 21:57:22 +09:00
parent 1ac4a188a1
commit 9b05fc71b4
5 changed files with 18 additions and 14 deletions

View File

@ -323,8 +323,8 @@ void VEFrameLowering::emitPrologue(MachineFunction &MF,
// Get the number of bytes to allocate from the FrameInfo
uint64_t NumBytes = MFI.getStackSize();
// The VE ABI requires a reserved 176 bytes area at the top
// of stack as described in VESubtarget.cpp. So, we adjust it here.
// The VE ABI requires a reserved area at the top of stack as described
// in VESubtarget.cpp. So, we adjust it here.
NumBytes = STI.getAdjustedFrameSize(NumBytes);
// Finally, ensure that the size is sufficiently aligned for the

View File

@ -341,7 +341,7 @@ SDValue VETargetLowering::LowerFormalArguments(
MachineFunction &MF = DAG.getMachineFunction();
// Get the base offset of the incoming arguments stack space.
unsigned ArgsBaseOffset = 176;
unsigned ArgsBaseOffset = Subtarget->getRsaSize();
// Get the size of the preserved arguments area
unsigned ArgsPreserved = 64;
@ -411,7 +411,7 @@ SDValue VETargetLowering::LowerFormalArguments(
// The registers are exhausted. This argument was passed on the stack.
assert(VA.isMemLoc());
// The CC_VE_Full/Half functions compute stack offsets relative to the
// beginning of the arguments area at %fp+176.
// beginning of the arguments area at %fp + the size of reserved area.
unsigned Offset = VA.getLocMemOffset() + ArgsBaseOffset;
unsigned ValSize = VA.getValVT().getSizeInBits() / 8;
@ -446,7 +446,7 @@ SDValue VETargetLowering::LowerFormalArguments(
// TODO: need to calculate offset correctly once we support f128.
unsigned ArgOffset = ArgLocs.size() * 8;
VEMachineFunctionInfo *FuncInfo = MF.getInfo<VEMachineFunctionInfo>();
// Skip the 176 bytes of register save area.
// Skip the reserved area at the top of stack.
FuncInfo->setVarArgsFrameOffset(ArgOffset + ArgsBaseOffset);
return Chain;
@ -489,7 +489,7 @@ SDValue VETargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
CLI.IsTailCall = false;
// Get the base offset of the outgoing arguments stack space.
unsigned ArgsBaseOffset = 176;
unsigned ArgsBaseOffset = Subtarget->getRsaSize();
// Get the size of the preserved arguments area
unsigned ArgsPreserved = 8 * 8u;
@ -631,8 +631,7 @@ SDValue VETargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
// Create a store off the stack pointer for this argument.
SDValue StackPtr = DAG.getRegister(VE::SX11, PtrVT);
// The argument area starts at %fp+176 in the callee frame,
// %sp+176 in ours.
// The argument area starts at %fp/%sp + the size of reserved area.
SDValue PtrOff =
DAG.getIntPtrConstant(VA.getLocMemOffset() + ArgsBaseOffset, DL);
PtrOff = DAG.getNode(ISD::ADD, DL, PtrVT, StackPtr, PtrOff);

View File

@ -915,8 +915,8 @@ bool VEInstrInfo::expandGetStackTopPseudo(MachineInstr &MI) const {
const MachineFrameInfo &MFI = MF.getFrameInfo();
const VEFrameLowering &TFL = *STI.getFrameLowering();
// The VE ABI requires a reserved 176 bytes area at the top
// of stack as described in VESubtarget.cpp. So, we adjust it here.
// The VE ABI requires a reserved area at the top of stack as described
// in VEFrameLowering.cpp. So, we adjust it here.
unsigned NumBytes = STI.getAdjustedFrameSize(0);
// Also adds the size of parameter area.

View File

@ -50,9 +50,10 @@ VESubtarget::VESubtarget(const Triple &TT, const std::string &CPU,
uint64_t VESubtarget::getAdjustedFrameSize(uint64_t FrameSize) const {
// Calculate adjusted frame size by adding the size of RSA frame,
// return address, and frame poitner as described in VEFrameLowering.cpp.
const VEFrameLowering *TFL = getFrameLowering();
FrameSize += 176; // For RSA, RA, and FP.
FrameSize = alignTo(FrameSize, 16); // Requires 16 bytes alignment.
FrameSize += getRsaSize();
FrameSize = alignTo(FrameSize, TFL->getStackAlign());
return FrameSize;
}

View File

@ -70,10 +70,14 @@ public:
VESubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
/// Given a actual stack size as determined by FrameInfo, this function
/// returns adjusted framesize which includes space for register window
/// spills and arguments.
/// returns adjusted framesize which includes space for RSA, return
/// address, and frame poitner.
uint64_t getAdjustedFrameSize(uint64_t FrameSize) const;
/// Get the size of RSA, return address, and frame pointer as described
/// in VEFrameLowering.cpp.
unsigned getRsaSize(void) const { return 176; };
bool isTargetLinux() const { return TargetTriple.isOSLinux(); }
};