Move X86RegisterInfo away from using the TargetMachine and only

using the subtarget.

llvm-svn: 210595
This commit is contained in:
Eric Christopher 2014-06-10 22:34:28 +00:00
parent 20e8edf5c7
commit 1f8ad4f4a7
5 changed files with 30 additions and 33 deletions

View File

@ -197,14 +197,13 @@ void X86_MC::DetectFamilyModel(unsigned EAX, unsigned &Family,
} }
} }
unsigned X86_MC::getDwarfRegFlavour(StringRef TT, bool isEH) { unsigned X86_MC::getDwarfRegFlavour(Triple TT, bool isEH) {
Triple TheTriple(TT); if (TT.getArch() == Triple::x86_64)
if (TheTriple.getArch() == Triple::x86_64)
return DWARFFlavour::X86_64; return DWARFFlavour::X86_64;
if (TheTriple.isOSDarwin()) if (TT.isOSDarwin())
return isEH ? DWARFFlavour::X86_32_DarwinEH : DWARFFlavour::X86_32_Generic; return isEH ? DWARFFlavour::X86_32_DarwinEH : DWARFFlavour::X86_32_Generic;
if (TheTriple.isOSCygMing()) if (TT.isOSCygMing())
// Unsupported by now, just quick fallback // Unsupported by now, just quick fallback
return DWARFFlavour::X86_32_Generic; return DWARFFlavour::X86_32_Generic;
return DWARFFlavour::X86_32_Generic; return DWARFFlavour::X86_32_Generic;
@ -251,8 +250,8 @@ static MCRegisterInfo *createX86MCRegisterInfo(StringRef TT) {
MCRegisterInfo *X = new MCRegisterInfo(); MCRegisterInfo *X = new MCRegisterInfo();
InitX86MCRegisterInfo(X, RA, InitX86MCRegisterInfo(X, RA,
X86_MC::getDwarfRegFlavour(TT, false), X86_MC::getDwarfRegFlavour(TheTriple, false),
X86_MC::getDwarfRegFlavour(TT, true), X86_MC::getDwarfRegFlavour(TheTriple, true),
RA); RA);
X86_MC::InitLLVM2SEHRegisterMapping(X); X86_MC::InitLLVM2SEHRegisterMapping(X);
return X; return X;

View File

@ -28,6 +28,7 @@ class MCSubtargetInfo;
class MCRelocationInfo; class MCRelocationInfo;
class MCStreamer; class MCStreamer;
class Target; class Target;
class Triple;
class StringRef; class StringRef;
class raw_ostream; class raw_ostream;
@ -64,7 +65,7 @@ namespace X86_MC {
void DetectFamilyModel(unsigned EAX, unsigned &Family, unsigned &Model); void DetectFamilyModel(unsigned EAX, unsigned &Family, unsigned &Model);
unsigned getDwarfRegFlavour(StringRef TT, bool isEH); unsigned getDwarfRegFlavour(Triple TT, bool isEH);
void InitLLVM2SEHRegisterMapping(MCRegisterInfo *MRI); void InitLLVM2SEHRegisterMapping(MCRegisterInfo *MRI);

View File

@ -105,7 +105,7 @@ X86InstrInfo::X86InstrInfo(X86TargetMachine &tm)
(tm.getSubtarget<X86Subtarget>().is64Bit() (tm.getSubtarget<X86Subtarget>().is64Bit()
? X86::ADJCALLSTACKUP64 ? X86::ADJCALLSTACKUP64
: X86::ADJCALLSTACKUP32)), : X86::ADJCALLSTACKUP32)),
TM(tm), RI(tm) { TM(tm), RI(tm.getSubtarget<X86Subtarget>()) {
static const X86OpTblEntry OpTbl2Addr[] = { static const X86OpTblEntry OpTbl2Addr[] = {
{ X86::ADC32ri, X86::ADC32mi, 0 }, { X86::ADC32ri, X86::ADC32mi, 0 },

View File

@ -53,20 +53,18 @@ static cl::opt<bool>
EnableBasePointer("x86-use-base-pointer", cl::Hidden, cl::init(true), EnableBasePointer("x86-use-base-pointer", cl::Hidden, cl::init(true),
cl::desc("Enable use of a base pointer for complex stack frames")); cl::desc("Enable use of a base pointer for complex stack frames"));
X86RegisterInfo::X86RegisterInfo(X86TargetMachine &tm) X86RegisterInfo::X86RegisterInfo(const X86Subtarget &STI)
: X86GenRegisterInfo((tm.getSubtarget<X86Subtarget>().is64Bit() : X86GenRegisterInfo(
? X86::RIP : X86::EIP), (STI.is64Bit() ? X86::RIP : X86::EIP),
X86_MC::getDwarfRegFlavour(tm.getTargetTriple(), false), X86_MC::getDwarfRegFlavour(STI.getTargetTriple(), false),
X86_MC::getDwarfRegFlavour(tm.getTargetTriple(), true), X86_MC::getDwarfRegFlavour(STI.getTargetTriple(), true),
(tm.getSubtarget<X86Subtarget>().is64Bit() (STI.is64Bit() ? X86::RIP : X86::EIP)),
? X86::RIP : X86::EIP)), Subtarget(STI) {
TM(tm) {
X86_MC::InitLLVM2SEHRegisterMapping(this); X86_MC::InitLLVM2SEHRegisterMapping(this);
// Cache some information. // Cache some information.
const X86Subtarget *Subtarget = &TM.getSubtarget<X86Subtarget>(); Is64Bit = Subtarget.is64Bit();
Is64Bit = Subtarget->is64Bit(); IsWin64 = Subtarget.isTargetWin64();
IsWin64 = Subtarget->isTargetWin64();
if (Is64Bit) { if (Is64Bit) {
SlotSize = 8; SlotSize = 8;
@ -173,9 +171,8 @@ X86RegisterInfo::getLargestLegalSuperClass(const TargetRegisterClass *RC) const{
} }
const TargetRegisterClass * const TargetRegisterClass *
X86RegisterInfo::getPointerRegClass(const MachineFunction &MF, unsigned Kind) X86RegisterInfo::getPointerRegClass(const MachineFunction &MF,
const { unsigned Kind) const {
const X86Subtarget &Subtarget = TM.getSubtarget<X86Subtarget>();
switch (Kind) { switch (Kind) {
default: llvm_unreachable("Unexpected Kind in getPointerRegClass!"); default: llvm_unreachable("Unexpected Kind in getPointerRegClass!");
case 0: // Normal GPRs. case 0: // Normal GPRs.
@ -225,7 +222,7 @@ X86RegisterInfo::getRegPressureLimit(const TargetRegisterClass *RC,
case X86::GR64RegClassID: case X86::GR64RegClassID:
return 12 - FPDiff; return 12 - FPDiff;
case X86::VR128RegClassID: case X86::VR128RegClassID:
return TM.getSubtarget<X86Subtarget>().is64Bit() ? 10 : 4; return Subtarget.is64Bit() ? 10 : 4;
case X86::VR64RegClassID: case X86::VR64RegClassID:
return 4; return 4;
} }
@ -233,8 +230,8 @@ X86RegisterInfo::getRegPressureLimit(const TargetRegisterClass *RC,
const MCPhysReg * const MCPhysReg *
X86RegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const { X86RegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const {
bool HasAVX = TM.getSubtarget<X86Subtarget>().hasAVX(); bool HasAVX = Subtarget.hasAVX();
bool HasAVX512 = TM.getSubtarget<X86Subtarget>().hasAVX512(); bool HasAVX512 = Subtarget.hasAVX512();
assert(MF && "MachineFunction required"); assert(MF && "MachineFunction required");
switch (MF->getFunction()->getCallingConv()) { switch (MF->getFunction()->getCallingConv()) {
@ -287,8 +284,8 @@ X86RegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const {
const uint32_t* const uint32_t*
X86RegisterInfo::getCallPreservedMask(CallingConv::ID CC) const { X86RegisterInfo::getCallPreservedMask(CallingConv::ID CC) const {
bool HasAVX = TM.getSubtarget<X86Subtarget>().hasAVX(); bool HasAVX = Subtarget.hasAVX();
bool HasAVX512 = TM.getSubtarget<X86Subtarget>().hasAVX512(); bool HasAVX512 = Subtarget.hasAVX512();
switch (CC) { switch (CC) {
case CallingConv::GHC: case CallingConv::GHC:
@ -406,7 +403,7 @@ BitVector X86RegisterInfo::getReservedRegs(const MachineFunction &MF) const {
Reserved.set(*AI); Reserved.set(*AI);
} }
} }
if (!Is64Bit || !TM.getSubtarget<X86Subtarget>().hasAVX512()) { if (!Is64Bit || !Subtarget.hasAVX512()) {
for (unsigned n = 16; n != 32; ++n) { for (unsigned n = 16; n != 32; ++n) {
for (MCRegAliasIterator AI(X86::XMM0 + n, this, true); AI.isValid(); ++AI) for (MCRegAliasIterator AI(X86::XMM0 + n, this, true); AI.isValid(); ++AI)
Reserved.set(*AI); Reserved.set(*AI);
@ -459,7 +456,7 @@ bool X86RegisterInfo::canRealignStack(const MachineFunction &MF) const {
bool X86RegisterInfo::needsStackRealignment(const MachineFunction &MF) const { bool X86RegisterInfo::needsStackRealignment(const MachineFunction &MF) const {
const MachineFrameInfo *MFI = MF.getFrameInfo(); const MachineFrameInfo *MFI = MF.getFrameInfo();
const Function *F = MF.getFunction(); const Function *F = MF.getFunction();
unsigned StackAlign = TM.getFrameLowering()->getStackAlignment(); unsigned StackAlign = MF.getTarget().getFrameLowering()->getStackAlignment();
bool requiresRealignment = bool requiresRealignment =
((MFI->getMaxAlignment() > StackAlign) || ((MFI->getMaxAlignment() > StackAlign) ||
F->getAttributes().hasAttribute(AttributeSet::FunctionIndex, F->getAttributes().hasAttribute(AttributeSet::FunctionIndex,

View File

@ -22,11 +22,11 @@
namespace llvm { namespace llvm {
class Type; class Type;
class TargetInstrInfo; class TargetInstrInfo;
class X86TargetMachine; class X86Subtarget;
class X86RegisterInfo final : public X86GenRegisterInfo { class X86RegisterInfo final : public X86GenRegisterInfo {
public: public:
X86TargetMachine &TM; const X86Subtarget &Subtarget;
private: private:
/// Is64Bit - Is the target 64-bits. /// Is64Bit - Is the target 64-bits.
@ -55,7 +55,7 @@ private:
unsigned BasePtr; unsigned BasePtr;
public: public:
X86RegisterInfo(X86TargetMachine &tm); X86RegisterInfo(const X86Subtarget &STI);
// FIXME: This should be tablegen'd like getDwarfRegNum is // FIXME: This should be tablegen'd like getDwarfRegNum is
int getSEHRegNum(unsigned i) const; int getSEHRegNum(unsigned i) const;