mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-28 19:31:58 +00:00
Move some more hooks to TargetFrameInfo
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119904 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3ca136312a
commit
82f58740c7
@ -137,6 +137,16 @@ public:
|
||||
/// on entry to all functions. Note that LabelID is ignored (assumed to be
|
||||
/// the beginning of the function.)
|
||||
virtual void getInitialFrameState(std::vector<MachineMove> &Moves) const;
|
||||
|
||||
/// getFrameIndexOffset - Returns the displacement from the frame register to
|
||||
/// the stack frame of the specified index.
|
||||
virtual int getFrameIndexOffset(const MachineFunction &MF, int FI) const;
|
||||
|
||||
/// getFrameIndexReference - This method should return the base register
|
||||
/// and offset used to reference a frame index location. The offset is
|
||||
/// returned directly, and the base register is returned via FrameReg.
|
||||
virtual int getFrameIndexReference(const MachineFunction &MF, int FI,
|
||||
unsigned &FrameReg) const;
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
@ -730,22 +730,6 @@ public:
|
||||
/// for values allocated in the current stack frame.
|
||||
virtual unsigned getFrameRegister(const MachineFunction &MF) const = 0;
|
||||
|
||||
/// getFrameIndexOffset - Returns the displacement from the frame register to
|
||||
/// the stack frame of the specified index.
|
||||
virtual int getFrameIndexOffset(const MachineFunction &MF, int FI) const;
|
||||
|
||||
/// getFrameIndexReference - This method should return the base register
|
||||
/// and offset used to reference a frame index location. The offset is
|
||||
/// returned directly, and the base register is returned via FrameReg.
|
||||
virtual int getFrameIndexReference(const MachineFunction &MF, int FI,
|
||||
unsigned &FrameReg) const {
|
||||
// By default, assume all frame indices are referenced via whatever
|
||||
// getFrameRegister() says. The target can override this if it's doing
|
||||
// something different.
|
||||
FrameReg = getFrameRegister(MF);
|
||||
return getFrameIndexOffset(MF, FI);
|
||||
}
|
||||
|
||||
/// getRARegister - This method should return the register where the return
|
||||
/// address can be found.
|
||||
virtual unsigned getRARegister() const = 0;
|
||||
|
@ -594,8 +594,8 @@ void DwarfDebug::addSourceLine(DIE *Die, DINameSpace NS) {
|
||||
void DwarfDebug::addVariableAddress(DbgVariable *&DV, DIE *Die, int64_t FI) {
|
||||
MachineLocation Location;
|
||||
unsigned FrameReg;
|
||||
const TargetRegisterInfo *RI = Asm->TM.getRegisterInfo();
|
||||
int Offset = RI->getFrameIndexReference(*Asm->MF, FI, FrameReg);
|
||||
const TargetFrameInfo *TFI = Asm->TM.getFrameInfo();
|
||||
int Offset = TFI->getFrameIndexReference(*Asm->MF, FI, FrameReg);
|
||||
Location.set(FrameReg, Offset);
|
||||
|
||||
if (DV->variableHasComplexAddress())
|
||||
|
@ -373,12 +373,12 @@ void MachineCodeAnalysis::FindSafePoints(MachineFunction &MF) {
|
||||
}
|
||||
|
||||
void MachineCodeAnalysis::FindStackOffsets(MachineFunction &MF) {
|
||||
const TargetRegisterInfo *TRI = TM->getRegisterInfo();
|
||||
assert(TRI && "TargetRegisterInfo not available!");
|
||||
const TargetFrameInfo *TFI = TM->getFrameInfo();
|
||||
assert(TFI && "TargetRegisterInfo not available!");
|
||||
|
||||
for (GCFunctionInfo::roots_iterator RI = FI->roots_begin(),
|
||||
RE = FI->roots_end(); RI != RE; ++RI)
|
||||
RI->StackOffset = TRI->getFrameIndexOffset(MF, RI->Num);
|
||||
RI->StackOffset = TFI->getFrameIndexOffset(MF, RI->Num);
|
||||
}
|
||||
|
||||
bool MachineCodeAnalysis::runOnMachineFunction(MachineFunction &MF) {
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "ARMAddressingModes.h"
|
||||
#include "ARMBaseInstrInfo.h"
|
||||
#include "ARMBaseRegisterInfo.h"
|
||||
#include "ARMFrameInfo.h"
|
||||
#include "ARMInstrInfo.h"
|
||||
#include "ARMMachineFunctionInfo.h"
|
||||
#include "ARMSubtarget.h"
|
||||
@ -924,97 +925,6 @@ ARMBaseRegisterInfo::getFrameRegister(const MachineFunction &MF) const {
|
||||
return ARM::SP;
|
||||
}
|
||||
|
||||
// Provide a base+offset reference to an FI slot for debug info. It's the
|
||||
// same as what we use for resolving the code-gen references for now.
|
||||
// FIXME: This can go wrong when references are SP-relative and simple call
|
||||
// frames aren't used.
|
||||
int
|
||||
ARMBaseRegisterInfo::getFrameIndexReference(const MachineFunction &MF, int FI,
|
||||
unsigned &FrameReg) const {
|
||||
return ResolveFrameIndexReference(MF, FI, FrameReg, 0);
|
||||
}
|
||||
|
||||
int
|
||||
ARMBaseRegisterInfo::ResolveFrameIndexReference(const MachineFunction &MF,
|
||||
int FI,
|
||||
unsigned &FrameReg,
|
||||
int SPAdj) const {
|
||||
const MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||
const TargetFrameInfo *TFI = MF.getTarget().getFrameInfo();
|
||||
const ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
|
||||
int Offset = MFI->getObjectOffset(FI) + MFI->getStackSize();
|
||||
int FPOffset = Offset - AFI->getFramePtrSpillOffset();
|
||||
bool isFixed = MFI->isFixedObjectIndex(FI);
|
||||
|
||||
FrameReg = ARM::SP;
|
||||
Offset += SPAdj;
|
||||
if (AFI->isGPRCalleeSavedArea1Frame(FI))
|
||||
return Offset - AFI->getGPRCalleeSavedArea1Offset();
|
||||
else if (AFI->isGPRCalleeSavedArea2Frame(FI))
|
||||
return Offset - AFI->getGPRCalleeSavedArea2Offset();
|
||||
else if (AFI->isDPRCalleeSavedAreaFrame(FI))
|
||||
return Offset - AFI->getDPRCalleeSavedAreaOffset();
|
||||
|
||||
// When dynamically realigning the stack, use the frame pointer for
|
||||
// parameters, and the stack/base pointer for locals.
|
||||
if (needsStackRealignment(MF)) {
|
||||
assert (TFI->hasFP(MF) && "dynamic stack realignment without a FP!");
|
||||
if (isFixed) {
|
||||
FrameReg = getFrameRegister(MF);
|
||||
Offset = FPOffset;
|
||||
} else if (MFI->hasVarSizedObjects()) {
|
||||
assert(hasBasePointer(MF) &&
|
||||
"VLAs and dynamic stack alignment, but missing base pointer!");
|
||||
FrameReg = BasePtr;
|
||||
}
|
||||
return Offset;
|
||||
}
|
||||
|
||||
// If there is a frame pointer, use it when we can.
|
||||
if (TFI->hasFP(MF) && AFI->hasStackFrame()) {
|
||||
// Use frame pointer to reference fixed objects. Use it for locals if
|
||||
// there are VLAs (and thus the SP isn't reliable as a base).
|
||||
if (isFixed || (MFI->hasVarSizedObjects() && !hasBasePointer(MF))) {
|
||||
FrameReg = getFrameRegister(MF);
|
||||
return FPOffset;
|
||||
} else if (MFI->hasVarSizedObjects()) {
|
||||
assert(hasBasePointer(MF) && "missing base pointer!");
|
||||
// Try to use the frame pointer if we can, else use the base pointer
|
||||
// since it's available. This is handy for the emergency spill slot, in
|
||||
// particular.
|
||||
if (AFI->isThumb2Function()) {
|
||||
if (FPOffset >= -255 && FPOffset < 0) {
|
||||
FrameReg = getFrameRegister(MF);
|
||||
return FPOffset;
|
||||
}
|
||||
} else
|
||||
FrameReg = BasePtr;
|
||||
} else if (AFI->isThumb2Function()) {
|
||||
// In Thumb2 mode, the negative offset is very limited. Try to avoid
|
||||
// out of range references.
|
||||
if (FPOffset >= -255 && FPOffset < 0) {
|
||||
FrameReg = getFrameRegister(MF);
|
||||
return FPOffset;
|
||||
}
|
||||
} else if (Offset > (FPOffset < 0 ? -FPOffset : FPOffset)) {
|
||||
// Otherwise, use SP or FP, whichever is closer to the stack slot.
|
||||
FrameReg = getFrameRegister(MF);
|
||||
return FPOffset;
|
||||
}
|
||||
}
|
||||
// Use the base pointer if we have one.
|
||||
if (hasBasePointer(MF))
|
||||
FrameReg = BasePtr;
|
||||
return Offset;
|
||||
}
|
||||
|
||||
int
|
||||
ARMBaseRegisterInfo::getFrameIndexOffset(const MachineFunction &MF,
|
||||
int FI) const {
|
||||
unsigned FrameReg;
|
||||
return getFrameIndexReference(MF, FI, FrameReg);
|
||||
}
|
||||
|
||||
unsigned ARMBaseRegisterInfo::getEHExceptionRegister() const {
|
||||
llvm_unreachable("What is the exception register");
|
||||
return 0;
|
||||
@ -1560,6 +1470,8 @@ ARMBaseRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
|
||||
MachineInstr &MI = *II;
|
||||
MachineBasicBlock &MBB = *MI.getParent();
|
||||
MachineFunction &MF = *MBB.getParent();
|
||||
const ARMFrameInfo *TFI =
|
||||
static_cast<const ARMFrameInfo*>(MF.getTarget().getFrameInfo());
|
||||
ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
|
||||
assert(!AFI->isThumb1OnlyFunction() &&
|
||||
"This eliminateFrameIndex does not support Thumb1!");
|
||||
@ -1572,7 +1484,7 @@ ARMBaseRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
|
||||
int FrameIndex = MI.getOperand(i).getIndex();
|
||||
unsigned FrameReg;
|
||||
|
||||
int Offset = ResolveFrameIndexReference(MF, FrameIndex, FrameReg, SPAdj);
|
||||
int Offset = TFI->ResolveFrameIndexReference(MF, FrameIndex, FrameReg, SPAdj);
|
||||
|
||||
// Special handling of dbg_value instructions.
|
||||
if (MI.isDebugValue()) {
|
||||
|
@ -161,11 +161,6 @@ public:
|
||||
unsigned getRARegister() const;
|
||||
unsigned getFrameRegister(const MachineFunction &MF) const;
|
||||
unsigned getBaseRegister() const { return BasePtr; }
|
||||
int getFrameIndexReference(const MachineFunction &MF, int FI,
|
||||
unsigned &FrameReg) const;
|
||||
int ResolveFrameIndexReference(const MachineFunction &MF, int FI,
|
||||
unsigned &FrameReg, int SPAdj) const;
|
||||
int getFrameIndexOffset(const MachineFunction &MF, int FI) const;
|
||||
|
||||
// Exception handling queries.
|
||||
unsigned getEHExceptionRegister() const;
|
||||
|
@ -383,3 +383,93 @@ void ARMFrameInfo::emitEpilogue(MachineFunction &MF,
|
||||
if (VARegSaveSize)
|
||||
emitSPUpdate(isARM, MBB, MBBI, dl, TII, VARegSaveSize);
|
||||
}
|
||||
|
||||
// Provide a base+offset reference to an FI slot for debug info. It's the
|
||||
// same as what we use for resolving the code-gen references for now.
|
||||
// FIXME: This can go wrong when references are SP-relative and simple call
|
||||
// frames aren't used.
|
||||
int
|
||||
ARMFrameInfo::getFrameIndexReference(const MachineFunction &MF, int FI,
|
||||
unsigned &FrameReg) const {
|
||||
return ResolveFrameIndexReference(MF, FI, FrameReg, 0);
|
||||
}
|
||||
|
||||
int
|
||||
ARMFrameInfo::ResolveFrameIndexReference(const MachineFunction &MF,
|
||||
int FI,
|
||||
unsigned &FrameReg,
|
||||
int SPAdj) const {
|
||||
const MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||
const ARMBaseRegisterInfo *RegInfo =
|
||||
static_cast<const ARMBaseRegisterInfo*>(MF.getTarget().getRegisterInfo());
|
||||
const ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
|
||||
int Offset = MFI->getObjectOffset(FI) + MFI->getStackSize();
|
||||
int FPOffset = Offset - AFI->getFramePtrSpillOffset();
|
||||
bool isFixed = MFI->isFixedObjectIndex(FI);
|
||||
|
||||
FrameReg = ARM::SP;
|
||||
Offset += SPAdj;
|
||||
if (AFI->isGPRCalleeSavedArea1Frame(FI))
|
||||
return Offset - AFI->getGPRCalleeSavedArea1Offset();
|
||||
else if (AFI->isGPRCalleeSavedArea2Frame(FI))
|
||||
return Offset - AFI->getGPRCalleeSavedArea2Offset();
|
||||
else if (AFI->isDPRCalleeSavedAreaFrame(FI))
|
||||
return Offset - AFI->getDPRCalleeSavedAreaOffset();
|
||||
|
||||
// When dynamically realigning the stack, use the frame pointer for
|
||||
// parameters, and the stack/base pointer for locals.
|
||||
if (RegInfo->needsStackRealignment(MF)) {
|
||||
assert (hasFP(MF) && "dynamic stack realignment without a FP!");
|
||||
if (isFixed) {
|
||||
FrameReg = RegInfo->getFrameRegister(MF);
|
||||
Offset = FPOffset;
|
||||
} else if (MFI->hasVarSizedObjects()) {
|
||||
assert(RegInfo->hasBasePointer(MF) &&
|
||||
"VLAs and dynamic stack alignment, but missing base pointer!");
|
||||
FrameReg = RegInfo->getBaseRegister();
|
||||
}
|
||||
return Offset;
|
||||
}
|
||||
|
||||
// If there is a frame pointer, use it when we can.
|
||||
if (hasFP(MF) && AFI->hasStackFrame()) {
|
||||
// Use frame pointer to reference fixed objects. Use it for locals if
|
||||
// there are VLAs (and thus the SP isn't reliable as a base).
|
||||
if (isFixed || (MFI->hasVarSizedObjects() && !RegInfo->hasBasePointer(MF))) {
|
||||
FrameReg = RegInfo->getFrameRegister(MF);
|
||||
return FPOffset;
|
||||
} else if (MFI->hasVarSizedObjects()) {
|
||||
assert(RegInfo->hasBasePointer(MF) && "missing base pointer!");
|
||||
// Try to use the frame pointer if we can, else use the base pointer
|
||||
// since it's available. This is handy for the emergency spill slot, in
|
||||
// particular.
|
||||
if (AFI->isThumb2Function()) {
|
||||
if (FPOffset >= -255 && FPOffset < 0) {
|
||||
FrameReg = RegInfo->getFrameRegister(MF);
|
||||
return FPOffset;
|
||||
}
|
||||
} else
|
||||
FrameReg = RegInfo->getBaseRegister();
|
||||
} else if (AFI->isThumb2Function()) {
|
||||
// In Thumb2 mode, the negative offset is very limited. Try to avoid
|
||||
// out of range references.
|
||||
if (FPOffset >= -255 && FPOffset < 0) {
|
||||
FrameReg = RegInfo->getFrameRegister(MF);
|
||||
return FPOffset;
|
||||
}
|
||||
} else if (Offset > (FPOffset < 0 ? -FPOffset : FPOffset)) {
|
||||
// Otherwise, use SP or FP, whichever is closer to the stack slot.
|
||||
FrameReg = RegInfo->getFrameRegister(MF);
|
||||
return FPOffset;
|
||||
}
|
||||
}
|
||||
// Use the base pointer if we have one.
|
||||
if (RegInfo->hasBasePointer(MF))
|
||||
FrameReg = RegInfo->getBaseRegister();
|
||||
return Offset;
|
||||
}
|
||||
|
||||
int ARMFrameInfo::getFrameIndexOffset(const MachineFunction &MF, int FI) const {
|
||||
unsigned FrameReg;
|
||||
return getFrameIndexReference(MF, FI, FrameReg);
|
||||
}
|
||||
|
@ -38,6 +38,12 @@ public:
|
||||
bool hasFP(const MachineFunction &MF) const;
|
||||
bool hasReservedCallFrame(const MachineFunction &MF) const;
|
||||
bool canSimplifyCallFramePseudos(const MachineFunction &MF) const;
|
||||
int getFrameIndexReference(const MachineFunction &MF, int FI,
|
||||
unsigned &FrameReg) const;
|
||||
int ResolveFrameIndexReference(const MachineFunction &MF, int FI,
|
||||
unsigned &FrameReg, int SPAdj) const;
|
||||
int getFrameIndexOffset(const MachineFunction &MF, int FI) const;
|
||||
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
@ -176,3 +176,24 @@ void SystemZFrameInfo::emitEpilogue(MachineFunction &MF,
|
||||
MI.getOperand(i).ChangeToImmediate(Offset);
|
||||
}
|
||||
}
|
||||
|
||||
int SystemZFrameInfo::getFrameIndexOffset(const MachineFunction &MF,
|
||||
int FI) const {
|
||||
const MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||
const SystemZMachineFunctionInfo *SystemZMFI =
|
||||
MF.getInfo<SystemZMachineFunctionInfo>();
|
||||
int Offset = MFI->getObjectOffset(FI) + MFI->getOffsetAdjustment();
|
||||
uint64_t StackSize = MFI->getStackSize();
|
||||
|
||||
// Fixed objects are really located in the "previous" frame.
|
||||
if (FI < 0)
|
||||
StackSize -= SystemZMFI->getCalleeSavedFrameSize();
|
||||
|
||||
Offset += StackSize - getOffsetOfLocalArea();
|
||||
|
||||
// Skip the register save area if we generated the stack frame.
|
||||
if (StackSize || MFI->hasCalls())
|
||||
Offset -= getOffsetOfLocalArea();
|
||||
|
||||
return Offset;
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ public:
|
||||
|
||||
bool hasReservedCallFrame(const MachineFunction &MF) const { return true; }
|
||||
bool hasFP(const MachineFunction &MF) const;
|
||||
int getFrameIndexOffset(const MachineFunction &MF, int FI) const;
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
@ -64,28 +64,6 @@ eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
|
||||
MBB.erase(I);
|
||||
}
|
||||
|
||||
int SystemZRegisterInfo::getFrameIndexOffset(const MachineFunction &MF,
|
||||
int FI) const {
|
||||
const TargetFrameInfo &TFI = *MF.getTarget().getFrameInfo();
|
||||
const MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||
const SystemZMachineFunctionInfo *SystemZMFI =
|
||||
MF.getInfo<SystemZMachineFunctionInfo>();
|
||||
int Offset = MFI->getObjectOffset(FI) + MFI->getOffsetAdjustment();
|
||||
uint64_t StackSize = MFI->getStackSize();
|
||||
|
||||
// Fixed objects are really located in the "previous" frame.
|
||||
if (FI < 0)
|
||||
StackSize -= SystemZMFI->getCalleeSavedFrameSize();
|
||||
|
||||
Offset += StackSize - TFI.getOffsetOfLocalArea();
|
||||
|
||||
// Skip the register save area if we generated the stack frame.
|
||||
if (StackSize || MFI->hasCalls())
|
||||
Offset -= TFI.getOffsetOfLocalArea();
|
||||
|
||||
return Offset;
|
||||
}
|
||||
|
||||
void
|
||||
SystemZRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
|
||||
int SPAdj, RegScavenger *RS) const {
|
||||
@ -113,7 +91,7 @@ SystemZRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
|
||||
// Offset is a either 12-bit unsigned or 20-bit signed integer.
|
||||
// FIXME: handle "too long" displacements.
|
||||
int Offset =
|
||||
getFrameIndexOffset(MF, FrameIndex) + MI.getOperand(i+1).getImm();
|
||||
TFI->getFrameIndexOffset(MF, FrameIndex) + MI.getOperand(i+1).getImm();
|
||||
|
||||
// Check whether displacement is too long to fit into 12 bit zext field.
|
||||
MI.setDesc(TII.getMemoryInstr(MI.getOpcode(), Offset));
|
||||
|
@ -34,8 +34,6 @@ struct SystemZRegisterInfo : public SystemZGenRegisterInfo {
|
||||
|
||||
BitVector getReservedRegs(const MachineFunction &MF) const;
|
||||
|
||||
int getFrameIndexOffset(const MachineFunction &MF, int FI) const;
|
||||
|
||||
void eliminateCallFramePseudoInstr(MachineFunction &MF,
|
||||
MachineBasicBlock &MBB,
|
||||
MachineBasicBlock::iterator I) const;
|
||||
|
@ -11,7 +11,12 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Codegen/MachineFrameInfo.h"
|
||||
#include "llvm/Codegen/MachineFunction.h"
|
||||
#include "llvm/Target/TargetFrameInfo.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Target/TargetRegisterInfo.h"
|
||||
|
||||
#include <cstdlib>
|
||||
using namespace llvm;
|
||||
|
||||
@ -24,3 +29,24 @@ void
|
||||
TargetFrameInfo::getInitialFrameState(std::vector<MachineMove> &Moves) const {
|
||||
// Default is to do nothing.
|
||||
}
|
||||
|
||||
/// getFrameIndexOffset - Returns the displacement from the frame register to
|
||||
/// the stack frame of the specified index. This is the default implementation
|
||||
/// which is overridden for some targets.
|
||||
int TargetFrameInfo::getFrameIndexOffset(const MachineFunction &MF,
|
||||
int FI) const {
|
||||
const MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||
return MFI->getObjectOffset(FI) + MFI->getStackSize() -
|
||||
getOffsetOfLocalArea() + MFI->getOffsetAdjustment();
|
||||
}
|
||||
|
||||
int TargetFrameInfo::getFrameIndexReference(const MachineFunction &MF, int FI,
|
||||
unsigned &FrameReg) const {
|
||||
const TargetRegisterInfo *RI = MF.getTarget().getRegisterInfo();
|
||||
|
||||
// By default, assume all frame indices are referenced via whatever
|
||||
// getFrameRegister() says. The target can override this if it's doing
|
||||
// something different.
|
||||
FrameReg = RI->getFrameRegister(MF);
|
||||
return getFrameIndexOffset(MF, FI);
|
||||
}
|
||||
|
@ -87,17 +87,6 @@ BitVector TargetRegisterInfo::getAllocatableSet(const MachineFunction &MF,
|
||||
return Allocatable;
|
||||
}
|
||||
|
||||
/// getFrameIndexOffset - Returns the displacement from the frame register to
|
||||
/// the stack frame of the specified index. This is the default implementation
|
||||
/// which is overridden for some targets.
|
||||
int TargetRegisterInfo::getFrameIndexOffset(const MachineFunction &MF,
|
||||
int FI) const {
|
||||
const TargetFrameInfo &TFI = *MF.getTarget().getFrameInfo();
|
||||
const MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||
return MFI->getObjectOffset(FI) + MFI->getStackSize() -
|
||||
TFI.getOffsetOfLocalArea() + MFI->getOffsetAdjustment();
|
||||
}
|
||||
|
||||
const TargetRegisterClass *
|
||||
llvm::getCommonSubClass(const TargetRegisterClass *A,
|
||||
const TargetRegisterClass *B) {
|
||||
|
@ -764,3 +764,38 @@ X86FrameInfo::getInitialFrameState(std::vector<MachineMove> &Moves) const {
|
||||
MachineLocation CSSrc(RI->getRARegister());
|
||||
Moves.push_back(MachineMove(0, CSDst, CSSrc));
|
||||
}
|
||||
|
||||
int X86FrameInfo::getFrameIndexOffset(const MachineFunction &MF, int FI) const {
|
||||
const X86RegisterInfo *RI =
|
||||
static_cast<const X86RegisterInfo*>(MF.getTarget().getRegisterInfo());
|
||||
const MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||
int Offset = MFI->getObjectOffset(FI) - getOffsetOfLocalArea();
|
||||
uint64_t StackSize = MFI->getStackSize();
|
||||
|
||||
if (RI->needsStackRealignment(MF)) {
|
||||
if (FI < 0) {
|
||||
// Skip the saved EBP.
|
||||
Offset += RI->getSlotSize();
|
||||
} else {
|
||||
unsigned Align = MFI->getObjectAlignment(FI);
|
||||
assert((-(Offset + StackSize)) % Align == 0);
|
||||
Align = 0;
|
||||
return Offset + StackSize;
|
||||
}
|
||||
// FIXME: Support tail calls
|
||||
} else {
|
||||
if (!hasFP(MF))
|
||||
return Offset + StackSize;
|
||||
|
||||
// Skip the saved EBP.
|
||||
Offset += RI->getSlotSize();
|
||||
|
||||
// Skip the RETADDR move area
|
||||
const X86MachineFunctionInfo *X86FI = MF.getInfo<X86MachineFunctionInfo>();
|
||||
int TailCallReturnAddrDelta = X86FI->getTCReturnAddrDelta();
|
||||
if (TailCallReturnAddrDelta < 0)
|
||||
Offset -= TailCallReturnAddrDelta;
|
||||
}
|
||||
|
||||
return Offset;
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ public:
|
||||
bool hasReservedCallFrame(const MachineFunction &MF) const;
|
||||
|
||||
void getInitialFrameState(std::vector<MachineMove> &Moves) const;
|
||||
int getFrameIndexOffset(const MachineFunction &MF, int FI) const;
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
@ -464,41 +464,6 @@ bool X86RegisterInfo::hasReservedSpillSlot(const MachineFunction &MF,
|
||||
return false;
|
||||
}
|
||||
|
||||
int
|
||||
X86RegisterInfo::getFrameIndexOffset(const MachineFunction &MF, int FI) const {
|
||||
const TargetFrameInfo *TFI = MF.getTarget().getFrameInfo();
|
||||
const MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||
int Offset = MFI->getObjectOffset(FI) - TFI->getOffsetOfLocalArea();
|
||||
uint64_t StackSize = MFI->getStackSize();
|
||||
|
||||
if (needsStackRealignment(MF)) {
|
||||
if (FI < 0) {
|
||||
// Skip the saved EBP.
|
||||
Offset += SlotSize;
|
||||
} else {
|
||||
unsigned Align = MFI->getObjectAlignment(FI);
|
||||
assert((-(Offset + StackSize)) % Align == 0);
|
||||
Align = 0;
|
||||
return Offset + StackSize;
|
||||
}
|
||||
// FIXME: Support tail calls
|
||||
} else {
|
||||
if (!TFI->hasFP(MF))
|
||||
return Offset + StackSize;
|
||||
|
||||
// Skip the saved EBP.
|
||||
Offset += SlotSize;
|
||||
|
||||
// Skip the RETADDR move area
|
||||
const X86MachineFunctionInfo *X86FI = MF.getInfo<X86MachineFunctionInfo>();
|
||||
int TailCallReturnAddrDelta = X86FI->getTCReturnAddrDelta();
|
||||
if (TailCallReturnAddrDelta < 0)
|
||||
Offset -= TailCallReturnAddrDelta;
|
||||
}
|
||||
|
||||
return Offset;
|
||||
}
|
||||
|
||||
static unsigned getSUBriOpcode(unsigned is64Bit, int64_t Imm) {
|
||||
if (is64Bit) {
|
||||
if (isInt<8>(Imm))
|
||||
@ -631,7 +596,7 @@ X86RegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
|
||||
const MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||
FIOffset = MFI->getObjectOffset(FrameIndex) - TFI->getOffsetOfLocalArea();
|
||||
} else
|
||||
FIOffset = getFrameIndexOffset(MF, FrameIndex);
|
||||
FIOffset = TFI->getFrameIndexOffset(MF, FrameIndex);
|
||||
|
||||
if (MI.getOperand(i+3).isImm()) {
|
||||
// Offset is a 32-bit integer.
|
||||
|
@ -135,8 +135,6 @@ public:
|
||||
// FIXME: Move to FrameInfok
|
||||
unsigned getSlotSize() const { return SlotSize; }
|
||||
|
||||
int getFrameIndexOffset(const MachineFunction &MF, int FI) const;
|
||||
|
||||
// Exception handling queries.
|
||||
unsigned getEHExceptionRegister() const;
|
||||
unsigned getEHHandlerRegister() const;
|
||||
|
Loading…
Reference in New Issue
Block a user