forked from OSchip/llvm-project
Move X86RegisterInfo away from using the TargetMachine and only
using the subtarget. llvm-svn: 210595
This commit is contained in:
parent
20e8edf5c7
commit
1f8ad4f4a7
|
@ -197,14 +197,13 @@ void X86_MC::DetectFamilyModel(unsigned EAX, unsigned &Family,
|
|||
}
|
||||
}
|
||||
|
||||
unsigned X86_MC::getDwarfRegFlavour(StringRef TT, bool isEH) {
|
||||
Triple TheTriple(TT);
|
||||
if (TheTriple.getArch() == Triple::x86_64)
|
||||
unsigned X86_MC::getDwarfRegFlavour(Triple TT, bool isEH) {
|
||||
if (TT.getArch() == Triple::x86_64)
|
||||
return DWARFFlavour::X86_64;
|
||||
|
||||
if (TheTriple.isOSDarwin())
|
||||
if (TT.isOSDarwin())
|
||||
return isEH ? DWARFFlavour::X86_32_DarwinEH : DWARFFlavour::X86_32_Generic;
|
||||
if (TheTriple.isOSCygMing())
|
||||
if (TT.isOSCygMing())
|
||||
// Unsupported by now, just quick fallback
|
||||
return DWARFFlavour::X86_32_Generic;
|
||||
return DWARFFlavour::X86_32_Generic;
|
||||
|
@ -251,8 +250,8 @@ static MCRegisterInfo *createX86MCRegisterInfo(StringRef TT) {
|
|||
|
||||
MCRegisterInfo *X = new MCRegisterInfo();
|
||||
InitX86MCRegisterInfo(X, RA,
|
||||
X86_MC::getDwarfRegFlavour(TT, false),
|
||||
X86_MC::getDwarfRegFlavour(TT, true),
|
||||
X86_MC::getDwarfRegFlavour(TheTriple, false),
|
||||
X86_MC::getDwarfRegFlavour(TheTriple, true),
|
||||
RA);
|
||||
X86_MC::InitLLVM2SEHRegisterMapping(X);
|
||||
return X;
|
||||
|
|
|
@ -28,6 +28,7 @@ class MCSubtargetInfo;
|
|||
class MCRelocationInfo;
|
||||
class MCStreamer;
|
||||
class Target;
|
||||
class Triple;
|
||||
class StringRef;
|
||||
class raw_ostream;
|
||||
|
||||
|
@ -64,7 +65,7 @@ namespace X86_MC {
|
|||
|
||||
void DetectFamilyModel(unsigned EAX, unsigned &Family, unsigned &Model);
|
||||
|
||||
unsigned getDwarfRegFlavour(StringRef TT, bool isEH);
|
||||
unsigned getDwarfRegFlavour(Triple TT, bool isEH);
|
||||
|
||||
void InitLLVM2SEHRegisterMapping(MCRegisterInfo *MRI);
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ X86InstrInfo::X86InstrInfo(X86TargetMachine &tm)
|
|||
(tm.getSubtarget<X86Subtarget>().is64Bit()
|
||||
? X86::ADJCALLSTACKUP64
|
||||
: X86::ADJCALLSTACKUP32)),
|
||||
TM(tm), RI(tm) {
|
||||
TM(tm), RI(tm.getSubtarget<X86Subtarget>()) {
|
||||
|
||||
static const X86OpTblEntry OpTbl2Addr[] = {
|
||||
{ X86::ADC32ri, X86::ADC32mi, 0 },
|
||||
|
|
|
@ -53,20 +53,18 @@ static cl::opt<bool>
|
|||
EnableBasePointer("x86-use-base-pointer", cl::Hidden, cl::init(true),
|
||||
cl::desc("Enable use of a base pointer for complex stack frames"));
|
||||
|
||||
X86RegisterInfo::X86RegisterInfo(X86TargetMachine &tm)
|
||||
: X86GenRegisterInfo((tm.getSubtarget<X86Subtarget>().is64Bit()
|
||||
? X86::RIP : X86::EIP),
|
||||
X86_MC::getDwarfRegFlavour(tm.getTargetTriple(), false),
|
||||
X86_MC::getDwarfRegFlavour(tm.getTargetTriple(), true),
|
||||
(tm.getSubtarget<X86Subtarget>().is64Bit()
|
||||
? X86::RIP : X86::EIP)),
|
||||
TM(tm) {
|
||||
X86RegisterInfo::X86RegisterInfo(const X86Subtarget &STI)
|
||||
: X86GenRegisterInfo(
|
||||
(STI.is64Bit() ? X86::RIP : X86::EIP),
|
||||
X86_MC::getDwarfRegFlavour(STI.getTargetTriple(), false),
|
||||
X86_MC::getDwarfRegFlavour(STI.getTargetTriple(), true),
|
||||
(STI.is64Bit() ? X86::RIP : X86::EIP)),
|
||||
Subtarget(STI) {
|
||||
X86_MC::InitLLVM2SEHRegisterMapping(this);
|
||||
|
||||
// Cache some information.
|
||||
const X86Subtarget *Subtarget = &TM.getSubtarget<X86Subtarget>();
|
||||
Is64Bit = Subtarget->is64Bit();
|
||||
IsWin64 = Subtarget->isTargetWin64();
|
||||
Is64Bit = Subtarget.is64Bit();
|
||||
IsWin64 = Subtarget.isTargetWin64();
|
||||
|
||||
if (Is64Bit) {
|
||||
SlotSize = 8;
|
||||
|
@ -173,9 +171,8 @@ X86RegisterInfo::getLargestLegalSuperClass(const TargetRegisterClass *RC) const{
|
|||
}
|
||||
|
||||
const TargetRegisterClass *
|
||||
X86RegisterInfo::getPointerRegClass(const MachineFunction &MF, unsigned Kind)
|
||||
const {
|
||||
const X86Subtarget &Subtarget = TM.getSubtarget<X86Subtarget>();
|
||||
X86RegisterInfo::getPointerRegClass(const MachineFunction &MF,
|
||||
unsigned Kind) const {
|
||||
switch (Kind) {
|
||||
default: llvm_unreachable("Unexpected Kind in getPointerRegClass!");
|
||||
case 0: // Normal GPRs.
|
||||
|
@ -225,7 +222,7 @@ X86RegisterInfo::getRegPressureLimit(const TargetRegisterClass *RC,
|
|||
case X86::GR64RegClassID:
|
||||
return 12 - FPDiff;
|
||||
case X86::VR128RegClassID:
|
||||
return TM.getSubtarget<X86Subtarget>().is64Bit() ? 10 : 4;
|
||||
return Subtarget.is64Bit() ? 10 : 4;
|
||||
case X86::VR64RegClassID:
|
||||
return 4;
|
||||
}
|
||||
|
@ -233,8 +230,8 @@ X86RegisterInfo::getRegPressureLimit(const TargetRegisterClass *RC,
|
|||
|
||||
const MCPhysReg *
|
||||
X86RegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const {
|
||||
bool HasAVX = TM.getSubtarget<X86Subtarget>().hasAVX();
|
||||
bool HasAVX512 = TM.getSubtarget<X86Subtarget>().hasAVX512();
|
||||
bool HasAVX = Subtarget.hasAVX();
|
||||
bool HasAVX512 = Subtarget.hasAVX512();
|
||||
|
||||
assert(MF && "MachineFunction required");
|
||||
switch (MF->getFunction()->getCallingConv()) {
|
||||
|
@ -287,8 +284,8 @@ X86RegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const {
|
|||
|
||||
const uint32_t*
|
||||
X86RegisterInfo::getCallPreservedMask(CallingConv::ID CC) const {
|
||||
bool HasAVX = TM.getSubtarget<X86Subtarget>().hasAVX();
|
||||
bool HasAVX512 = TM.getSubtarget<X86Subtarget>().hasAVX512();
|
||||
bool HasAVX = Subtarget.hasAVX();
|
||||
bool HasAVX512 = Subtarget.hasAVX512();
|
||||
|
||||
switch (CC) {
|
||||
case CallingConv::GHC:
|
||||
|
@ -406,7 +403,7 @@ BitVector X86RegisterInfo::getReservedRegs(const MachineFunction &MF) const {
|
|||
Reserved.set(*AI);
|
||||
}
|
||||
}
|
||||
if (!Is64Bit || !TM.getSubtarget<X86Subtarget>().hasAVX512()) {
|
||||
if (!Is64Bit || !Subtarget.hasAVX512()) {
|
||||
for (unsigned n = 16; n != 32; ++n) {
|
||||
for (MCRegAliasIterator AI(X86::XMM0 + n, this, true); AI.isValid(); ++AI)
|
||||
Reserved.set(*AI);
|
||||
|
@ -459,7 +456,7 @@ bool X86RegisterInfo::canRealignStack(const MachineFunction &MF) const {
|
|||
bool X86RegisterInfo::needsStackRealignment(const MachineFunction &MF) const {
|
||||
const MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||
const Function *F = MF.getFunction();
|
||||
unsigned StackAlign = TM.getFrameLowering()->getStackAlignment();
|
||||
unsigned StackAlign = MF.getTarget().getFrameLowering()->getStackAlignment();
|
||||
bool requiresRealignment =
|
||||
((MFI->getMaxAlignment() > StackAlign) ||
|
||||
F->getAttributes().hasAttribute(AttributeSet::FunctionIndex,
|
||||
|
|
|
@ -22,11 +22,11 @@
|
|||
namespace llvm {
|
||||
class Type;
|
||||
class TargetInstrInfo;
|
||||
class X86TargetMachine;
|
||||
class X86Subtarget;
|
||||
|
||||
class X86RegisterInfo final : public X86GenRegisterInfo {
|
||||
public:
|
||||
X86TargetMachine &TM;
|
||||
const X86Subtarget &Subtarget;
|
||||
|
||||
private:
|
||||
/// Is64Bit - Is the target 64-bits.
|
||||
|
@ -55,7 +55,7 @@ private:
|
|||
unsigned BasePtr;
|
||||
|
||||
public:
|
||||
X86RegisterInfo(X86TargetMachine &tm);
|
||||
X86RegisterInfo(const X86Subtarget &STI);
|
||||
|
||||
// FIXME: This should be tablegen'd like getDwarfRegNum is
|
||||
int getSEHRegNum(unsigned i) const;
|
||||
|
|
Loading…
Reference in New Issue