mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Clean up where SlotSize should be used instead of pointer size.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166664 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a2b88163af
commit
aa3c2c09d9
@ -313,11 +313,11 @@ void X86FrameLowering::emitCalleeSavedFrameMoves(MachineFunction &MF,
|
||||
if (CSI.empty()) return;
|
||||
|
||||
std::vector<MachineMove> &Moves = MMI.getFrameMoves();
|
||||
const DataLayout *TD = TM.getDataLayout();
|
||||
const X86RegisterInfo *RegInfo = TM.getRegisterInfo();
|
||||
bool HasFP = hasFP(MF);
|
||||
|
||||
// Calculate amount of bytes used for return address storing.
|
||||
int stackGrowth = -TD->getPointerSize(0);
|
||||
int stackGrowth = -RegInfo->getSlotSize();
|
||||
|
||||
// FIXME: This is dirty hack. The code itself is pretty mess right now.
|
||||
// It should be rewritten from scratch and generalized sometimes.
|
||||
@ -715,9 +715,8 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF) const {
|
||||
// ELSE => DW_CFA_offset_extended
|
||||
|
||||
std::vector<MachineMove> &Moves = MMI.getFrameMoves();
|
||||
const DataLayout *TD = MF.getTarget().getDataLayout();
|
||||
uint64_t NumBytes = 0;
|
||||
int stackGrowth = -TD->getPointerSize(0);
|
||||
int stackGrowth = -SlotSize;
|
||||
|
||||
if (HasFP) {
|
||||
// Calculate required stack adjustment.
|
||||
|
@ -2184,16 +2184,14 @@ X86TargetLowering::EmitTailCallLoadRetAddr(SelectionDAG &DAG,
|
||||
/// optimization is performed and it is required (FPDiff!=0).
|
||||
static SDValue
|
||||
EmitTailCallStoreRetAddr(SelectionDAG & DAG, MachineFunction &MF,
|
||||
SDValue Chain, SDValue RetAddrFrIdx,
|
||||
bool Is64Bit, int FPDiff, DebugLoc dl) {
|
||||
SDValue Chain, SDValue RetAddrFrIdx, EVT PtrVT,
|
||||
unsigned SlotSize, int FPDiff, DebugLoc dl) {
|
||||
// Store the return address to the appropriate stack slot.
|
||||
if (!FPDiff) return Chain;
|
||||
// Calculate the new stack slot for the return address.
|
||||
int SlotSize = Is64Bit ? 8 : 4;
|
||||
int NewReturnAddrFI =
|
||||
MF.getFrameInfo()->CreateFixedObject(SlotSize, FPDiff-SlotSize, false);
|
||||
EVT VT = Is64Bit ? MVT::i64 : MVT::i32;
|
||||
SDValue NewRetAddrFrIdx = DAG.getFrameIndex(NewReturnAddrFI, VT);
|
||||
SDValue NewRetAddrFrIdx = DAG.getFrameIndex(NewReturnAddrFI, PtrVT);
|
||||
Chain = DAG.getStore(Chain, dl, RetAddrFrIdx, NewRetAddrFrIdx,
|
||||
MachinePointerInfo::getFixedStack(NewReturnAddrFI),
|
||||
false, false, 0);
|
||||
@ -2462,7 +2460,8 @@ X86TargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
|
||||
&MemOpChains2[0], MemOpChains2.size());
|
||||
|
||||
// Store the return address to the appropriate stack slot.
|
||||
Chain = EmitTailCallStoreRetAddr(DAG, MF, Chain, RetAddrFrIdx, Is64Bit,
|
||||
Chain = EmitTailCallStoreRetAddr(DAG, MF, Chain, RetAddrFrIdx,
|
||||
getPointerTy(), RegInfo->getSlotSize(),
|
||||
FPDiff, dl);
|
||||
}
|
||||
|
||||
@ -2674,7 +2673,7 @@ X86TargetLowering::GetAlignedArgumentStackSize(unsigned StackSize,
|
||||
unsigned StackAlignment = TFI.getStackAlignment();
|
||||
uint64_t AlignMask = StackAlignment - 1;
|
||||
int64_t Offset = StackSize;
|
||||
uint64_t SlotSize = TD->getPointerSize(0);
|
||||
unsigned SlotSize = RegInfo->getSlotSize();
|
||||
if ( (Offset & AlignMask) <= (StackAlignment - SlotSize) ) {
|
||||
// Number smaller than 12 so just add the difference.
|
||||
Offset += ((StackAlignment - SlotSize) - (Offset & AlignMask));
|
||||
@ -3042,7 +3041,7 @@ SDValue X86TargetLowering::getReturnAddressFrameIndex(SelectionDAG &DAG) const {
|
||||
|
||||
if (ReturnAddrIndex == 0) {
|
||||
// Set up a frame object for the return address.
|
||||
uint64_t SlotSize = TD->getPointerSize(0);
|
||||
unsigned SlotSize = RegInfo->getSlotSize();
|
||||
ReturnAddrIndex = MF.getFrameInfo()->CreateFixedObject(SlotSize, -SlotSize,
|
||||
false);
|
||||
FuncInfo->setRAIndex(ReturnAddrIndex);
|
||||
@ -10544,21 +10543,21 @@ SDValue X86TargetLowering::LowerRETURNADDR(SDValue Op,
|
||||
|
||||
unsigned Depth = cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue();
|
||||
DebugLoc dl = Op.getDebugLoc();
|
||||
EVT PtrVT = getPointerTy();
|
||||
|
||||
if (Depth > 0) {
|
||||
SDValue FrameAddr = LowerFRAMEADDR(Op, DAG);
|
||||
SDValue Offset =
|
||||
DAG.getConstant(TD->getPointerSize(0),
|
||||
Subtarget->is64Bit() ? MVT::i64 : MVT::i32);
|
||||
return DAG.getLoad(getPointerTy(), dl, DAG.getEntryNode(),
|
||||
DAG.getNode(ISD::ADD, dl, getPointerTy(),
|
||||
DAG.getConstant(RegInfo->getSlotSize(), PtrVT);
|
||||
return DAG.getLoad(PtrVT, dl, DAG.getEntryNode(),
|
||||
DAG.getNode(ISD::ADD, dl, PtrVT,
|
||||
FrameAddr, Offset),
|
||||
MachinePointerInfo(), false, false, false, 0);
|
||||
}
|
||||
|
||||
// Just load the return address.
|
||||
SDValue RetAddrFI = getReturnAddressFrameIndex(DAG);
|
||||
return DAG.getLoad(getPointerTy(), dl, DAG.getEntryNode(),
|
||||
return DAG.getLoad(PtrVT, dl, DAG.getEntryNode(),
|
||||
RetAddrFI, MachinePointerInfo(), false, false, false, 0);
|
||||
}
|
||||
|
||||
@ -10580,7 +10579,7 @@ SDValue X86TargetLowering::LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const {
|
||||
|
||||
SDValue X86TargetLowering::LowerFRAME_TO_ARGS_OFFSET(SDValue Op,
|
||||
SelectionDAG &DAG) const {
|
||||
return DAG.getIntPtrConstant(2*TD->getPointerSize(0));
|
||||
return DAG.getIntPtrConstant(2 * RegInfo->getSlotSize());
|
||||
}
|
||||
|
||||
SDValue X86TargetLowering::LowerEH_RETURN(SDValue Op, SelectionDAG &DAG) const {
|
||||
@ -10595,7 +10594,7 @@ SDValue X86TargetLowering::LowerEH_RETURN(SDValue Op, SelectionDAG &DAG) const {
|
||||
unsigned StoreAddrReg = (Subtarget->is64Bit() ? X86::RCX : X86::ECX);
|
||||
|
||||
SDValue StoreAddr = DAG.getNode(ISD::ADD, dl, getPointerTy(), Frame,
|
||||
DAG.getIntPtrConstant(TD->getPointerSize(0)));
|
||||
DAG.getIntPtrConstant(RegInfo->getSlotSize()));
|
||||
StoreAddr = DAG.getNode(ISD::ADD, dl, getPointerTy(), StoreAddr, Offset);
|
||||
Chain = DAG.getStore(Chain, dl, Handler, StoreAddr, MachinePointerInfo(),
|
||||
false, false, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user