forked from OSchip/llvm-project
Remove uses of the TargetMachine from X86FrameLowering.
llvm-svn: 210223
This commit is contained in:
parent
c6f338dd5e
commit
11b05cccfa
|
|
@ -45,7 +45,7 @@ bool X86FrameLowering::hasReservedCallFrame(const MachineFunction &MF) const {
|
||||||
bool X86FrameLowering::hasFP(const MachineFunction &MF) const {
|
bool X86FrameLowering::hasFP(const MachineFunction &MF) const {
|
||||||
const MachineFrameInfo *MFI = MF.getFrameInfo();
|
const MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||||
const MachineModuleInfo &MMI = MF.getMMI();
|
const MachineModuleInfo &MMI = MF.getMMI();
|
||||||
const TargetRegisterInfo *RegInfo = TM.getRegisterInfo();
|
const TargetRegisterInfo *RegInfo = MF.getTarget().getRegisterInfo();
|
||||||
|
|
||||||
return (MF.getTarget().Options.DisableFramePointerElim(MF) ||
|
return (MF.getTarget().Options.DisableFramePointerElim(MF) ||
|
||||||
RegInfo->needsStackRealignment(MF) ||
|
RegInfo->needsStackRealignment(MF) ||
|
||||||
|
|
@ -312,13 +312,14 @@ void X86FrameLowering::emitCalleeSavedFrameMoves(
|
||||||
MachineFrameInfo *MFI = MF.getFrameInfo();
|
MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||||
MachineModuleInfo &MMI = MF.getMMI();
|
MachineModuleInfo &MMI = MF.getMMI();
|
||||||
const MCRegisterInfo *MRI = MMI.getContext().getRegisterInfo();
|
const MCRegisterInfo *MRI = MMI.getContext().getRegisterInfo();
|
||||||
const X86InstrInfo &TII = *TM.getInstrInfo();
|
const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo();
|
||||||
|
|
||||||
// Add callee saved registers to move list.
|
// Add callee saved registers to move list.
|
||||||
const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo();
|
const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo();
|
||||||
if (CSI.empty()) return;
|
if (CSI.empty()) return;
|
||||||
|
|
||||||
const X86RegisterInfo *RegInfo = TM.getRegisterInfo();
|
const X86RegisterInfo *RegInfo =
|
||||||
|
static_cast<const X86RegisterInfo *>(MF.getTarget().getRegisterInfo());
|
||||||
bool HasFP = hasFP(MF);
|
bool HasFP = hasFP(MF);
|
||||||
|
|
||||||
// Calculate amount of bytes used for return address storing.
|
// Calculate amount of bytes used for return address storing.
|
||||||
|
|
@ -400,8 +401,9 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF) const {
|
||||||
MachineBasicBlock::iterator MBBI = MBB.begin();
|
MachineBasicBlock::iterator MBBI = MBB.begin();
|
||||||
MachineFrameInfo *MFI = MF.getFrameInfo();
|
MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||||
const Function *Fn = MF.getFunction();
|
const Function *Fn = MF.getFunction();
|
||||||
const X86RegisterInfo *RegInfo = TM.getRegisterInfo();
|
const X86RegisterInfo *RegInfo =
|
||||||
const X86InstrInfo &TII = *TM.getInstrInfo();
|
static_cast<const X86RegisterInfo *>(MF.getTarget().getRegisterInfo());
|
||||||
|
const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo();
|
||||||
MachineModuleInfo &MMI = MF.getMMI();
|
MachineModuleInfo &MMI = MF.getMMI();
|
||||||
X86MachineFunctionInfo *X86FI = MF.getInfo<X86MachineFunctionInfo>();
|
X86MachineFunctionInfo *X86FI = MF.getInfo<X86MachineFunctionInfo>();
|
||||||
bool needsFrameMoves = MMI.hasDebugInfo() ||
|
bool needsFrameMoves = MMI.hasDebugInfo() ||
|
||||||
|
|
@ -719,8 +721,9 @@ void X86FrameLowering::emitEpilogue(MachineFunction &MF,
|
||||||
MachineBasicBlock &MBB) const {
|
MachineBasicBlock &MBB) const {
|
||||||
const MachineFrameInfo *MFI = MF.getFrameInfo();
|
const MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||||
X86MachineFunctionInfo *X86FI = MF.getInfo<X86MachineFunctionInfo>();
|
X86MachineFunctionInfo *X86FI = MF.getInfo<X86MachineFunctionInfo>();
|
||||||
const X86RegisterInfo *RegInfo = TM.getRegisterInfo();
|
const X86RegisterInfo *RegInfo =
|
||||||
const X86InstrInfo &TII = *TM.getInstrInfo();
|
static_cast<const X86RegisterInfo *>(MF.getTarget().getRegisterInfo());
|
||||||
|
const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo();
|
||||||
MachineBasicBlock::iterator MBBI = MBB.getLastNonDebugInstr();
|
MachineBasicBlock::iterator MBBI = MBB.getLastNonDebugInstr();
|
||||||
assert(MBBI != MBB.end() && "Returning block has no instructions");
|
assert(MBBI != MBB.end() && "Returning block has no instructions");
|
||||||
unsigned RetOpcode = MBBI->getOpcode();
|
unsigned RetOpcode = MBBI->getOpcode();
|
||||||
|
|
@ -1065,9 +1068,10 @@ bool X86FrameLowering::restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
|
||||||
|
|
||||||
void
|
void
|
||||||
X86FrameLowering::processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
|
X86FrameLowering::processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
|
||||||
RegScavenger *RS) const {
|
RegScavenger *RS) const {
|
||||||
MachineFrameInfo *MFI = MF.getFrameInfo();
|
MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||||
const X86RegisterInfo *RegInfo = TM.getRegisterInfo();
|
const X86RegisterInfo *RegInfo =
|
||||||
|
static_cast<const X86RegisterInfo *>(MF.getTarget().getRegisterInfo());
|
||||||
unsigned SlotSize = RegInfo->getSlotSize();
|
unsigned SlotSize = RegInfo->getSlotSize();
|
||||||
|
|
||||||
X86MachineFunctionInfo *X86FI = MF.getInfo<X86MachineFunctionInfo>();
|
X86MachineFunctionInfo *X86FI = MF.getInfo<X86MachineFunctionInfo>();
|
||||||
|
|
@ -1160,7 +1164,7 @@ void
|
||||||
X86FrameLowering::adjustForSegmentedStacks(MachineFunction &MF) const {
|
X86FrameLowering::adjustForSegmentedStacks(MachineFunction &MF) const {
|
||||||
MachineBasicBlock &prologueMBB = MF.front();
|
MachineBasicBlock &prologueMBB = MF.front();
|
||||||
MachineFrameInfo *MFI = MF.getFrameInfo();
|
MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||||
const X86InstrInfo &TII = *TM.getInstrInfo();
|
const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo();
|
||||||
uint64_t StackSize;
|
uint64_t StackSize;
|
||||||
bool Is64Bit = STI.is64Bit();
|
bool Is64Bit = STI.is64Bit();
|
||||||
unsigned TlsReg, TlsOffset;
|
unsigned TlsReg, TlsOffset;
|
||||||
|
|
@ -1368,9 +1372,11 @@ X86FrameLowering::adjustForSegmentedStacks(MachineFunction &MF) const {
|
||||||
/// temp0 = sp - MaxStack
|
/// temp0 = sp - MaxStack
|
||||||
/// if( temp0 < SP_LIMIT(P) ) goto IncStack else goto OldStart
|
/// if( temp0 < SP_LIMIT(P) ) goto IncStack else goto OldStart
|
||||||
void X86FrameLowering::adjustForHiPEPrologue(MachineFunction &MF) const {
|
void X86FrameLowering::adjustForHiPEPrologue(MachineFunction &MF) const {
|
||||||
const X86InstrInfo &TII = *TM.getInstrInfo();
|
const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo();
|
||||||
MachineFrameInfo *MFI = MF.getFrameInfo();
|
MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||||
const unsigned SlotSize = TM.getRegisterInfo()->getSlotSize();
|
const unsigned SlotSize =
|
||||||
|
static_cast<const X86RegisterInfo *>(MF.getTarget().getRegisterInfo())
|
||||||
|
->getSlotSize();
|
||||||
const bool Is64Bit = STI.is64Bit();
|
const bool Is64Bit = STI.is64Bit();
|
||||||
DebugLoc DL;
|
DebugLoc DL;
|
||||||
// HiPE-specific values
|
// HiPE-specific values
|
||||||
|
|
@ -1499,8 +1505,9 @@ void X86FrameLowering::adjustForHiPEPrologue(MachineFunction &MF) const {
|
||||||
void X86FrameLowering::
|
void X86FrameLowering::
|
||||||
eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
|
eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
|
||||||
MachineBasicBlock::iterator I) const {
|
MachineBasicBlock::iterator I) const {
|
||||||
const X86InstrInfo &TII = *TM.getInstrInfo();
|
const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo();
|
||||||
const X86RegisterInfo &RegInfo = *TM.getRegisterInfo();
|
const X86RegisterInfo &RegInfo =
|
||||||
|
*static_cast<const X86RegisterInfo *>(MF.getTarget().getRegisterInfo());
|
||||||
unsigned StackPtr = RegInfo.getStackRegister();
|
unsigned StackPtr = RegInfo.getStackRegister();
|
||||||
bool reseveCallFrame = hasReservedCallFrame(MF);
|
bool reseveCallFrame = hasReservedCallFrame(MF);
|
||||||
int Opcode = I->getOpcode();
|
int Opcode = I->getOpcode();
|
||||||
|
|
@ -1522,7 +1529,7 @@ eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
|
||||||
// We need to keep the stack aligned properly. To do this, we round the
|
// We need to keep the stack aligned properly. To do this, we round the
|
||||||
// amount of space needed for the outgoing arguments up to the next
|
// amount of space needed for the outgoing arguments up to the next
|
||||||
// alignment boundary.
|
// alignment boundary.
|
||||||
unsigned StackAlign = TM.getFrameLowering()->getStackAlignment();
|
unsigned StackAlign = MF.getTarget().getFrameLowering()->getStackAlignment();
|
||||||
Amount = (Amount + StackAlign - 1) / StackAlign * StackAlign;
|
Amount = (Amount + StackAlign - 1) / StackAlign * StackAlign;
|
||||||
|
|
||||||
MachineInstr *New = nullptr;
|
MachineInstr *New = nullptr;
|
||||||
|
|
|
||||||
|
|
@ -23,14 +23,13 @@ class MCSymbol;
|
||||||
class X86TargetMachine;
|
class X86TargetMachine;
|
||||||
|
|
||||||
class X86FrameLowering : public TargetFrameLowering {
|
class X86FrameLowering : public TargetFrameLowering {
|
||||||
const X86TargetMachine &TM;
|
|
||||||
const X86Subtarget &STI;
|
const X86Subtarget &STI;
|
||||||
public:
|
public:
|
||||||
explicit X86FrameLowering(const X86TargetMachine &tm, const X86Subtarget &sti)
|
explicit X86FrameLowering(const X86Subtarget &sti)
|
||||||
: TargetFrameLowering(StackGrowsDown,
|
: TargetFrameLowering(StackGrowsDown,
|
||||||
sti.getStackAlignment(),
|
sti.getStackAlignment(),
|
||||||
(sti.is64Bit() ? -8 : -4)),
|
(sti.is64Bit() ? -8 : -4)),
|
||||||
TM(tm), STI(sti) {
|
STI(sti) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void emitCalleeSavedFrameMoves(MachineBasicBlock &MBB,
|
void emitCalleeSavedFrameMoves(MachineBasicBlock &MBB,
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ X86TargetMachine::X86TargetMachine(const Target &T, StringRef TT,
|
||||||
CodeGenOpt::Level OL)
|
CodeGenOpt::Level OL)
|
||||||
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
||||||
Subtarget(TT, CPU, FS, Options.StackAlignmentOverride),
|
Subtarget(TT, CPU, FS, Options.StackAlignmentOverride),
|
||||||
FrameLowering(*this, Subtarget),
|
FrameLowering(Subtarget),
|
||||||
InstrItins(Subtarget.getInstrItineraryData()),
|
InstrItins(Subtarget.getInstrItineraryData()),
|
||||||
DL(computeDataLayout(*getSubtargetImpl())),
|
DL(computeDataLayout(*getSubtargetImpl())),
|
||||||
InstrInfo(*this),
|
InstrInfo(*this),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue