Remove the need to cache the subtarget in the Mips TargetRegisterInfo

classes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232012 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Christopher 2015-03-12 05:43:57 +00:00
parent a56999c5de
commit ae02704ac7
10 changed files with 26 additions and 26 deletions

View File

@ -1,4 +1,3 @@
//===-- Mips16InstrInfo.cpp - Mips16 Instruction Information --------------===// //===-- Mips16InstrInfo.cpp - Mips16 Instruction Information --------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
@ -32,7 +31,7 @@ using namespace llvm;
#define DEBUG_TYPE "mips16-instrinfo" #define DEBUG_TYPE "mips16-instrinfo"
Mips16InstrInfo::Mips16InstrInfo(const MipsSubtarget &STI) Mips16InstrInfo::Mips16InstrInfo(const MipsSubtarget &STI)
: MipsInstrInfo(STI, Mips::Bimm16), RI(STI) {} : MipsInstrInfo(STI, Mips::Bimm16), RI() {}
const MipsRegisterInfo &Mips16InstrInfo::getRegisterInfo() const { const MipsRegisterInfo &Mips16InstrInfo::getRegisterInfo() const {
return RI; return RI;

View File

@ -18,7 +18,7 @@
#include "MipsInstrInfo.h" #include "MipsInstrInfo.h"
namespace llvm { namespace llvm {
class MipsSubtarget;
class Mips16InstrInfo : public MipsInstrInfo { class Mips16InstrInfo : public MipsInstrInfo {
const Mips16RegisterInfo RI; const Mips16RegisterInfo RI;

View File

@ -41,8 +41,7 @@ using namespace llvm;
#define DEBUG_TYPE "mips16-registerinfo" #define DEBUG_TYPE "mips16-registerinfo"
Mips16RegisterInfo::Mips16RegisterInfo(const MipsSubtarget &ST) Mips16RegisterInfo::Mips16RegisterInfo() : MipsRegisterInfo() {}
: MipsRegisterInfo(ST) {}
bool Mips16RegisterInfo::requiresRegisterScavenging bool Mips16RegisterInfo::requiresRegisterScavenging
(const MachineFunction &MF) const { (const MachineFunction &MF) const {
@ -65,7 +64,7 @@ bool Mips16RegisterInfo::saveScavengerRegister
const TargetRegisterClass *RC, const TargetRegisterClass *RC,
unsigned Reg) const { unsigned Reg) const {
DebugLoc DL; DebugLoc DL;
const TargetInstrInfo &TII = *Subtarget.getInstrInfo(); const TargetInstrInfo &TII = *MBB.getParent()->getSubtarget().getInstrInfo();
TII.copyPhysReg(MBB, I, DL, Mips::T0, Reg, true); TII.copyPhysReg(MBB, I, DL, Mips::T0, Reg, true);
TII.copyPhysReg(MBB, UseMI, DL, Reg, Mips::T0, true); TII.copyPhysReg(MBB, UseMI, DL, Reg, Mips::T0, true);
return true; return true;
@ -106,7 +105,7 @@ void Mips16RegisterInfo::eliminateFI(MachineBasicBlock::iterator II,
if (FrameIndex >= MinCSFI && FrameIndex <= MaxCSFI) if (FrameIndex >= MinCSFI && FrameIndex <= MaxCSFI)
FrameReg = Mips::SP; FrameReg = Mips::SP;
else { else {
const TargetFrameLowering *TFI = Subtarget.getFrameLowering(); const TargetFrameLowering *TFI = MF.getSubtarget().getFrameLowering();
if (TFI->hasFP(MF)) { if (TFI->hasFP(MF)) {
FrameReg = Mips::S0; FrameReg = Mips::S0;
} }
@ -140,7 +139,7 @@ void Mips16RegisterInfo::eliminateFI(MachineBasicBlock::iterator II,
DebugLoc DL = II->getDebugLoc(); DebugLoc DL = II->getDebugLoc();
unsigned NewImm; unsigned NewImm;
const Mips16InstrInfo &TII = const Mips16InstrInfo &TII =
*static_cast<const Mips16InstrInfo *>(Subtarget.getInstrInfo()); *static_cast<const Mips16InstrInfo *>(MF.getSubtarget().getInstrInfo());
FrameReg = TII.loadImmediate(FrameReg, Offset, MBB, II, DL, NewImm); FrameReg = TII.loadImmediate(FrameReg, Offset, MBB, II, DL, NewImm);
Offset = SignExtend64<16>(NewImm); Offset = SignExtend64<16>(NewImm);
IsKill = true; IsKill = true;

View File

@ -21,7 +21,7 @@ class Mips16InstrInfo;
class Mips16RegisterInfo : public MipsRegisterInfo { class Mips16RegisterInfo : public MipsRegisterInfo {
public: public:
Mips16RegisterInfo(const MipsSubtarget &Subtarget); Mips16RegisterInfo();
bool requiresRegisterScavenging(const MachineFunction &MF) const override; bool requiresRegisterScavenging(const MachineFunction &MF) const override;

View File

@ -29,7 +29,7 @@
#include "MipsGenInstrInfo.inc" #include "MipsGenInstrInfo.inc"
namespace llvm { namespace llvm {
class MipsSubtarget;
class MipsInstrInfo : public MipsGenInstrInfo { class MipsInstrInfo : public MipsGenInstrInfo {
virtual void anchor(); virtual void anchor();
protected: protected:

View File

@ -43,14 +43,14 @@ using namespace llvm;
#define GET_REGINFO_TARGET_DESC #define GET_REGINFO_TARGET_DESC
#include "MipsGenRegisterInfo.inc" #include "MipsGenRegisterInfo.inc"
MipsRegisterInfo::MipsRegisterInfo(const MipsSubtarget &ST) MipsRegisterInfo::MipsRegisterInfo() : MipsGenRegisterInfo(Mips::RA) {}
: MipsGenRegisterInfo(Mips::RA), Subtarget(ST) {}
unsigned MipsRegisterInfo::getPICCallReg() { return Mips::T9; } unsigned MipsRegisterInfo::getPICCallReg() { return Mips::T9; }
const TargetRegisterClass * const TargetRegisterClass *
MipsRegisterInfo::getPointerRegClass(const MachineFunction &MF, MipsRegisterInfo::getPointerRegClass(const MachineFunction &MF,
unsigned Kind) const { unsigned Kind) const {
const MipsSubtarget &Subtarget = MF.getSubtarget<MipsSubtarget>();
return Subtarget.isABI_N64() ? &Mips::GPR64RegClass : &Mips::GPR32RegClass; return Subtarget.isABI_N64() ? &Mips::GPR64RegClass : &Mips::GPR32RegClass;
} }
@ -63,7 +63,7 @@ MipsRegisterInfo::getRegPressureLimit(const TargetRegisterClass *RC,
case Mips::GPR32RegClassID: case Mips::GPR32RegClassID:
case Mips::GPR64RegClassID: case Mips::GPR64RegClassID:
case Mips::DSPRRegClassID: { case Mips::DSPRRegClassID: {
const TargetFrameLowering *TFI = Subtarget.getFrameLowering(); const TargetFrameLowering *TFI = MF.getSubtarget().getFrameLowering();
return 28 - TFI->hasFP(MF); return 28 - TFI->hasFP(MF);
} }
case Mips::FGR32RegClassID: case Mips::FGR32RegClassID:
@ -82,6 +82,7 @@ MipsRegisterInfo::getRegPressureLimit(const TargetRegisterClass *RC,
/// Mips Callee Saved Registers /// Mips Callee Saved Registers
const MCPhysReg * const MCPhysReg *
MipsRegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const { MipsRegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const {
const MipsSubtarget &Subtarget = MF->getSubtarget<MipsSubtarget>();
if (Subtarget.isSingleFloat()) if (Subtarget.isSingleFloat())
return CSR_SingleFloatOnly_SaveList; return CSR_SingleFloatOnly_SaveList;
@ -103,6 +104,7 @@ MipsRegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const {
const uint32_t * const uint32_t *
MipsRegisterInfo::getCallPreservedMask(const MachineFunction &MF, MipsRegisterInfo::getCallPreservedMask(const MachineFunction &MF,
CallingConv::ID) const { CallingConv::ID) const {
const MipsSubtarget &Subtarget = MF.getSubtarget<MipsSubtarget>();
if (Subtarget.isSingleFloat()) if (Subtarget.isSingleFloat())
return CSR_SingleFloatOnly_RegMask; return CSR_SingleFloatOnly_RegMask;
@ -136,6 +138,7 @@ getReservedRegs(const MachineFunction &MF) const {
}; };
BitVector Reserved(getNumRegs()); BitVector Reserved(getNumRegs());
const MipsSubtarget &Subtarget = MF.getSubtarget<MipsSubtarget>();
typedef TargetRegisterClass::const_iterator RegIter; typedef TargetRegisterClass::const_iterator RegIter;
for (unsigned I = 0; I < array_lengthof(ReservedGPR32); ++I) for (unsigned I = 0; I < array_lengthof(ReservedGPR32); ++I)
@ -258,6 +261,7 @@ eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj,
unsigned MipsRegisterInfo:: unsigned MipsRegisterInfo::
getFrameRegister(const MachineFunction &MF) const { getFrameRegister(const MachineFunction &MF) const {
const MipsSubtarget &Subtarget = MF.getSubtarget<MipsSubtarget>();
const TargetFrameLowering *TFI = Subtarget.getFrameLowering(); const TargetFrameLowering *TFI = Subtarget.getFrameLowering();
bool IsN64 = bool IsN64 =
static_cast<const MipsTargetMachine &>(MF.getTarget()).getABI().IsN64(); static_cast<const MipsTargetMachine &>(MF.getTarget()).getABI().IsN64();

View File

@ -21,15 +21,11 @@
#include "MipsGenRegisterInfo.inc" #include "MipsGenRegisterInfo.inc"
namespace llvm { namespace llvm {
class MipsSubtarget;
class Type; class Type;
class MipsRegisterInfo : public MipsGenRegisterInfo { class MipsRegisterInfo : public MipsGenRegisterInfo {
protected:
const MipsSubtarget &Subtarget;
public: public:
MipsRegisterInfo(const MipsSubtarget &Subtarget); MipsRegisterInfo();
/// getRegisterNumbering - Given the enum value for some register, e.g. /// getRegisterNumbering - Given the enum value for some register, e.g.
/// Mips::RA, return the number that it corresponds to (e.g. 31). /// Mips::RA, return the number that it corresponds to (e.g. 31).

View File

@ -27,7 +27,7 @@ using namespace llvm;
MipsSEInstrInfo::MipsSEInstrInfo(const MipsSubtarget &STI) MipsSEInstrInfo::MipsSEInstrInfo(const MipsSubtarget &STI)
: MipsInstrInfo(STI, STI.getRelocationModel() == Reloc::PIC_ ? Mips::B : MipsInstrInfo(STI, STI.getRelocationModel() == Reloc::PIC_ ? Mips::B
: Mips::J), : Mips::J),
RI(STI) {} RI() {}
const MipsRegisterInfo &MipsSEInstrInfo::getRegisterInfo() const { const MipsRegisterInfo &MipsSEInstrInfo::getRegisterInfo() const {
return RI; return RI;

View File

@ -18,6 +18,7 @@
#include "MipsMachineFunction.h" #include "MipsMachineFunction.h"
#include "MipsSEInstrInfo.h" #include "MipsSEInstrInfo.h"
#include "MipsSubtarget.h" #include "MipsSubtarget.h"
#include "MipsTargetMachine.h"
#include "llvm/ADT/BitVector.h" #include "llvm/ADT/BitVector.h"
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineFrameInfo.h"
@ -41,8 +42,7 @@ using namespace llvm;
#define DEBUG_TYPE "mips-reg-info" #define DEBUG_TYPE "mips-reg-info"
MipsSERegisterInfo::MipsSERegisterInfo(const MipsSubtarget &ST) MipsSERegisterInfo::MipsSERegisterInfo() : MipsRegisterInfo() {}
: MipsRegisterInfo(ST) {}
bool MipsSERegisterInfo:: bool MipsSERegisterInfo::
requiresRegisterScavenging(const MachineFunction &MF) const { requiresRegisterScavenging(const MachineFunction &MF) const {
@ -110,6 +110,8 @@ void MipsSERegisterInfo::eliminateFI(MachineBasicBlock::iterator II,
MachineFunction &MF = *MI.getParent()->getParent(); MachineFunction &MF = *MI.getParent()->getParent();
MachineFrameInfo *MFI = MF.getFrameInfo(); MachineFrameInfo *MFI = MF.getFrameInfo();
MipsFunctionInfo *MipsFI = MF.getInfo<MipsFunctionInfo>(); MipsFunctionInfo *MipsFI = MF.getInfo<MipsFunctionInfo>();
bool isN64 =
static_cast<const MipsTargetMachine &>(MF.getTarget()).getABI().IsN64();
const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo(); const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo();
int MinCSFI = 0; int MinCSFI = 0;
@ -132,7 +134,7 @@ void MipsSERegisterInfo::eliminateFI(MachineBasicBlock::iterator II,
unsigned FrameReg; unsigned FrameReg;
if ((FrameIndex >= MinCSFI && FrameIndex <= MaxCSFI) || EhDataRegFI) if ((FrameIndex >= MinCSFI && FrameIndex <= MaxCSFI) || EhDataRegFI)
FrameReg = Subtarget.isABI_N64() ? Mips::SP_64 : Mips::SP; FrameReg = isN64 ? Mips::SP_64 : Mips::SP;
else else
FrameReg = getFrameRegister(MF); FrameReg = getFrameRegister(MF);
@ -165,9 +167,9 @@ void MipsSERegisterInfo::eliminateFI(MachineBasicBlock::iterator II,
// (where n < 16) and doesn't, but does fit into 16-bits then use an ADDiu // (where n < 16) and doesn't, but does fit into 16-bits then use an ADDiu
MachineBasicBlock &MBB = *MI.getParent(); MachineBasicBlock &MBB = *MI.getParent();
DebugLoc DL = II->getDebugLoc(); DebugLoc DL = II->getDebugLoc();
unsigned ADDiu = Subtarget.isABI_N64() ? Mips::DADDiu : Mips::ADDiu; unsigned ADDiu = isN64 ? Mips::DADDiu : Mips::ADDiu;
const TargetRegisterClass *RC = const TargetRegisterClass *RC =
Subtarget.isABI_N64() ? &Mips::GPR64RegClass : &Mips::GPR32RegClass; isN64 ? &Mips::GPR64RegClass : &Mips::GPR32RegClass;
MachineRegisterInfo &RegInfo = MBB.getParent()->getRegInfo(); MachineRegisterInfo &RegInfo = MBB.getParent()->getRegInfo();
unsigned Reg = RegInfo.createVirtualRegister(RC); unsigned Reg = RegInfo.createVirtualRegister(RC);
const MipsSEInstrInfo &TII = const MipsSEInstrInfo &TII =
@ -183,7 +185,7 @@ void MipsSERegisterInfo::eliminateFI(MachineBasicBlock::iterator II,
// instructions. // instructions.
MachineBasicBlock &MBB = *MI.getParent(); MachineBasicBlock &MBB = *MI.getParent();
DebugLoc DL = II->getDebugLoc(); DebugLoc DL = II->getDebugLoc();
unsigned ADDu = Subtarget.isABI_N64() ? Mips::DADDu : Mips::ADDu; unsigned ADDu = isN64 ? Mips::DADDu : Mips::ADDu;
unsigned NewImm = 0; unsigned NewImm = 0;
const MipsSEInstrInfo &TII = const MipsSEInstrInfo &TII =
*static_cast<const MipsSEInstrInfo *>( *static_cast<const MipsSEInstrInfo *>(

View File

@ -22,7 +22,7 @@ class MipsSEInstrInfo;
class MipsSERegisterInfo : public MipsRegisterInfo { class MipsSERegisterInfo : public MipsRegisterInfo {
public: public:
MipsSERegisterInfo(const MipsSubtarget &Subtarget); MipsSERegisterInfo();
bool requiresRegisterScavenging(const MachineFunction &MF) const override; bool requiresRegisterScavenging(const MachineFunction &MF) const override;