Remove most of the TargetMachine::getSubtarget/getSubtargetImpl

calls that don't take a Function argument from Mips. Notable
exceptions: the AsmPrinter and MipsTargetObjectFile. The
latter needs to be fixed, and the former will be fixed when the
general AsmPrinter changes happen.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227512 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Christopher 2015-01-29 23:27:36 +00:00
parent 370056ca5d
commit 2d64c553b4
20 changed files with 196 additions and 309 deletions

View File

@ -22,7 +22,6 @@ namespace llvm {
class MipsTargetMachine; class MipsTargetMachine;
class FunctionPass; class FunctionPass;
FunctionPass *createMipsISelDag(MipsTargetMachine &TM);
FunctionPass *createMipsOptimizePICCallPass(MipsTargetMachine &TM); FunctionPass *createMipsOptimizePICCallPass(MipsTargetMachine &TM);
FunctionPass *createMipsDelaySlotFillerPass(MipsTargetMachine &TM); FunctionPass *createMipsDelaySlotFillerPass(MipsTargetMachine &TM);
FunctionPass *createMipsLongBranchPass(MipsTargetMachine &TM); FunctionPass *createMipsLongBranchPass(MipsTargetMachine &TM);

View File

@ -36,7 +36,7 @@ void Mips16FrameLowering::emitPrologue(MachineFunction &MF) const {
MachineBasicBlock &MBB = MF.front(); MachineBasicBlock &MBB = MF.front();
MachineFrameInfo *MFI = MF.getFrameInfo(); MachineFrameInfo *MFI = MF.getFrameInfo();
const Mips16InstrInfo &TII = const Mips16InstrInfo &TII =
*static_cast<const Mips16InstrInfo *>(MF.getSubtarget().getInstrInfo()); *static_cast<const Mips16InstrInfo *>(STI.getInstrInfo());
MachineBasicBlock::iterator MBBI = MBB.begin(); MachineBasicBlock::iterator MBBI = MBB.begin();
DebugLoc dl = MBBI != MBB.end() ? MBBI->getDebugLoc() : DebugLoc(); DebugLoc dl = MBBI != MBB.end() ? MBBI->getDebugLoc() : DebugLoc();
uint64_t StackSize = MFI->getStackSize(); uint64_t StackSize = MFI->getStackSize();
@ -84,7 +84,7 @@ void Mips16FrameLowering::emitEpilogue(MachineFunction &MF,
MachineBasicBlock::iterator MBBI = MBB.getLastNonDebugInstr(); MachineBasicBlock::iterator MBBI = MBB.getLastNonDebugInstr();
MachineFrameInfo *MFI = MF.getFrameInfo(); MachineFrameInfo *MFI = MF.getFrameInfo();
const Mips16InstrInfo &TII = const Mips16InstrInfo &TII =
*static_cast<const Mips16InstrInfo *>(MF.getSubtarget().getInstrInfo()); *static_cast<const Mips16InstrInfo *>(STI.getInstrInfo());
DebugLoc dl = MBBI->getDebugLoc(); DebugLoc dl = MBBI->getDebugLoc();
uint64_t StackSize = MFI->getStackSize(); uint64_t StackSize = MFI->getStackSize();
@ -154,7 +154,7 @@ eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
Amount = -Amount; Amount = -Amount;
const Mips16InstrInfo &TII = const Mips16InstrInfo &TII =
*static_cast<const Mips16InstrInfo *>(MF.getSubtarget().getInstrInfo()); *static_cast<const Mips16InstrInfo *>(STI.getInstrInfo());
TII.adjustStackPtr(Mips::SP, Amount, MBB, I); TII.adjustStackPtr(Mips::SP, Amount, MBB, I);
} }
@ -174,7 +174,7 @@ void Mips16FrameLowering::
processFunctionBeforeCalleeSavedScan(MachineFunction &MF, processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
RegScavenger *RS) const { RegScavenger *RS) const {
const Mips16InstrInfo &TII = const Mips16InstrInfo &TII =
*static_cast<const Mips16InstrInfo *>(MF.getSubtarget().getInstrInfo()); *static_cast<const Mips16InstrInfo *>(STI.getInstrInfo());
const MipsRegisterInfo &RI = TII.getRegisterInfo(); const MipsRegisterInfo &RI = TII.getRegisterInfo();
const BitVector Reserved = RI.getReservedRegs(MF); const BitVector Reserved = RI.getReservedRegs(MF);
bool SaveS2 = Reserved[Mips::S2]; bool SaveS2 = Reserved[Mips::S2];

View File

@ -37,7 +37,7 @@ using namespace llvm;
#define DEBUG_TYPE "mips-isel" #define DEBUG_TYPE "mips-isel"
bool Mips16DAGToDAGISel::runOnMachineFunction(MachineFunction &MF) { bool Mips16DAGToDAGISel::runOnMachineFunction(MachineFunction &MF) {
Subtarget = &TM.getSubtarget<MipsSubtarget>(); Subtarget = &static_cast<const MipsSubtarget &>(MF.getSubtarget());
if (!Subtarget->inMips16Mode()) if (!Subtarget->inMips16Mode())
return false; return false;
return MipsDAGToDAGISel::runOnMachineFunction(MF); return MipsDAGToDAGISel::runOnMachineFunction(MF);
@ -72,7 +72,7 @@ void Mips16DAGToDAGISel::initGlobalBaseReg(MachineFunction &MF) {
MachineBasicBlock &MBB = MF.front(); MachineBasicBlock &MBB = MF.front();
MachineBasicBlock::iterator I = MBB.begin(); MachineBasicBlock::iterator I = MBB.begin();
MachineRegisterInfo &RegInfo = MF.getRegInfo(); MachineRegisterInfo &RegInfo = MF.getRegInfo();
const TargetInstrInfo &TII = *MF.getSubtarget().getInstrInfo(); const TargetInstrInfo &TII = *Subtarget->getInstrInfo();
DebugLoc DL = I != MBB.end() ? I->getDebugLoc() : DebugLoc(); DebugLoc DL = I != MBB.end() ? I->getDebugLoc() : DebugLoc();
unsigned V0, V1, V2, GlobalBaseReg = MipsFI->getGlobalBaseReg(); unsigned V0, V1, V2, GlobalBaseReg = MipsFI->getGlobalBaseReg();
const TargetRegisterClass *RC = &Mips::CPU16RegsRegClass; const TargetRegisterClass *RC = &Mips::CPU16RegsRegClass;
@ -102,7 +102,7 @@ void Mips16DAGToDAGISel::initMips16SPAliasReg(MachineFunction &MF) {
MachineBasicBlock &MBB = MF.front(); MachineBasicBlock &MBB = MF.front();
MachineBasicBlock::iterator I = MBB.begin(); MachineBasicBlock::iterator I = MBB.begin();
const TargetInstrInfo &TII = *MF.getSubtarget().getInstrInfo(); const TargetInstrInfo &TII = *Subtarget->getInstrInfo();
DebugLoc DL = I != MBB.end() ? I->getDebugLoc() : DebugLoc(); DebugLoc DL = I != MBB.end() ? I->getDebugLoc() : DebugLoc();
unsigned Mips16SPAliasReg = MipsFI->getMips16SPAliasReg(); unsigned Mips16SPAliasReg = MipsFI->getMips16SPAliasReg();
@ -134,7 +134,7 @@ void Mips16DAGToDAGISel::getMips16SPRefReg(SDNode *Parent, SDValue &AliasReg) {
switch (SD->getMemoryVT().getSizeInBits()) { switch (SD->getMemoryVT().getSizeInBits()) {
case 8: case 8:
case 16: case 16:
AliasReg = TM.getSubtargetImpl()->getFrameLowering()->hasFP(*MF) AliasReg = Subtarget->getFrameLowering()->hasFP(*MF)
? AliasFPReg ? AliasFPReg
: getMips16SPAliasReg(); : getMips16SPAliasReg();
return; return;
@ -146,7 +146,7 @@ void Mips16DAGToDAGISel::getMips16SPRefReg(SDNode *Parent, SDValue &AliasReg) {
switch (SD->getMemoryVT().getSizeInBits()) { switch (SD->getMemoryVT().getSizeInBits()) {
case 8: case 8:
case 16: case 16:
AliasReg = TM.getSubtargetImpl()->getFrameLowering()->hasFP(*MF) AliasReg = Subtarget->getFrameLowering()->hasFP(*MF)
? AliasFPReg ? AliasFPReg
: getMips16SPAliasReg(); : getMips16SPAliasReg();
return; return;

View File

@ -522,8 +522,7 @@ MachineBasicBlock *Mips16TargetLowering::
emitSel16(unsigned Opc, MachineInstr *MI, MachineBasicBlock *BB) const { emitSel16(unsigned Opc, MachineInstr *MI, MachineBasicBlock *BB) const {
if (DontExpandCondPseudos16) if (DontExpandCondPseudos16)
return BB; return BB;
const TargetInstrInfo *TII = const TargetInstrInfo *TII = Subtarget.getInstrInfo();
getTargetMachine().getSubtargetImpl()->getInstrInfo();
DebugLoc DL = MI->getDebugLoc(); DebugLoc DL = MI->getDebugLoc();
// To "insert" a SELECT_CC instruction, we actually have to insert the // To "insert" a SELECT_CC instruction, we actually have to insert the
// diamond control-flow pattern. The incoming instruction knows the // diamond control-flow pattern. The incoming instruction knows the
@ -580,13 +579,12 @@ emitSel16(unsigned Opc, MachineInstr *MI, MachineBasicBlock *BB) const {
return BB; return BB;
} }
MachineBasicBlock *Mips16TargetLowering::emitSelT16 MachineBasicBlock *
(unsigned Opc1, unsigned Opc2, Mips16TargetLowering::emitSelT16(unsigned Opc1, unsigned Opc2, MachineInstr *MI,
MachineInstr *MI, MachineBasicBlock *BB) const { MachineBasicBlock *BB) const {
if (DontExpandCondPseudos16) if (DontExpandCondPseudos16)
return BB; return BB;
const TargetInstrInfo *TII = const TargetInstrInfo *TII = Subtarget.getInstrInfo();
getTargetMachine().getSubtargetImpl()->getInstrInfo();
DebugLoc DL = MI->getDebugLoc(); DebugLoc DL = MI->getDebugLoc();
// To "insert" a SELECT_CC instruction, we actually have to insert the // To "insert" a SELECT_CC instruction, we actually have to insert the
// diamond control-flow pattern. The incoming instruction knows the // diamond control-flow pattern. The incoming instruction knows the
@ -645,13 +643,13 @@ MachineBasicBlock *Mips16TargetLowering::emitSelT16
} }
MachineBasicBlock *Mips16TargetLowering::emitSeliT16 MachineBasicBlock *
(unsigned Opc1, unsigned Opc2, Mips16TargetLowering::emitSeliT16(unsigned Opc1, unsigned Opc2,
MachineInstr *MI, MachineBasicBlock *BB) const { MachineInstr *MI,
MachineBasicBlock *BB) const {
if (DontExpandCondPseudos16) if (DontExpandCondPseudos16)
return BB; return BB;
const TargetInstrInfo *TII = const TargetInstrInfo *TII = Subtarget.getInstrInfo();
getTargetMachine().getSubtargetImpl()->getInstrInfo();
DebugLoc DL = MI->getDebugLoc(); DebugLoc DL = MI->getDebugLoc();
// To "insert" a SELECT_CC instruction, we actually have to insert the // To "insert" a SELECT_CC instruction, we actually have to insert the
// diamond control-flow pattern. The incoming instruction knows the // diamond control-flow pattern. The incoming instruction knows the
@ -710,14 +708,13 @@ MachineBasicBlock *Mips16TargetLowering::emitSeliT16
} }
MachineBasicBlock MachineBasicBlock *
*Mips16TargetLowering::emitFEXT_T8I816_ins(unsigned BtOpc, unsigned CmpOpc, Mips16TargetLowering::emitFEXT_T8I816_ins(unsigned BtOpc, unsigned CmpOpc,
MachineInstr *MI, MachineInstr *MI,
MachineBasicBlock *BB) const { MachineBasicBlock *BB) const {
if (DontExpandCondPseudos16) if (DontExpandCondPseudos16)
return BB; return BB;
const TargetInstrInfo *TII = const TargetInstrInfo *TII = Subtarget.getInstrInfo();
getTargetMachine().getSubtargetImpl()->getInstrInfo();
unsigned regX = MI->getOperand(0).getReg(); unsigned regX = MI->getOperand(0).getReg();
unsigned regY = MI->getOperand(1).getReg(); unsigned regY = MI->getOperand(1).getReg();
MachineBasicBlock *target = MI->getOperand(2).getMBB(); MachineBasicBlock *target = MI->getOperand(2).getMBB();
@ -733,8 +730,7 @@ MachineBasicBlock *Mips16TargetLowering::emitFEXT_T8I8I16_ins(
MachineInstr *MI, MachineBasicBlock *BB) const { MachineInstr *MI, MachineBasicBlock *BB) const {
if (DontExpandCondPseudos16) if (DontExpandCondPseudos16)
return BB; return BB;
const TargetInstrInfo *TII = const TargetInstrInfo *TII = Subtarget.getInstrInfo();
getTargetMachine().getSubtargetImpl()->getInstrInfo();
unsigned regX = MI->getOperand(0).getReg(); unsigned regX = MI->getOperand(0).getReg();
int64_t imm = MI->getOperand(1).getImm(); int64_t imm = MI->getOperand(1).getImm();
MachineBasicBlock *target = MI->getOperand(2).getMBB(); MachineBasicBlock *target = MI->getOperand(2).getMBB();
@ -763,13 +759,12 @@ static unsigned Mips16WhichOp8uOr16simm
llvm_unreachable("immediate field not usable"); llvm_unreachable("immediate field not usable");
} }
MachineBasicBlock *Mips16TargetLowering::emitFEXT_CCRX16_ins( MachineBasicBlock *
unsigned SltOpc, Mips16TargetLowering::emitFEXT_CCRX16_ins(unsigned SltOpc, MachineInstr *MI,
MachineInstr *MI, MachineBasicBlock *BB) const { MachineBasicBlock *BB) const {
if (DontExpandCondPseudos16) if (DontExpandCondPseudos16)
return BB; return BB;
const TargetInstrInfo *TII = const TargetInstrInfo *TII = Subtarget.getInstrInfo();
getTargetMachine().getSubtargetImpl()->getInstrInfo();
unsigned CC = MI->getOperand(0).getReg(); unsigned CC = MI->getOperand(0).getReg();
unsigned regX = MI->getOperand(1).getReg(); unsigned regX = MI->getOperand(1).getReg();
unsigned regY = MI->getOperand(2).getReg(); unsigned regY = MI->getOperand(2).getReg();
@ -781,13 +776,13 @@ MachineBasicBlock *Mips16TargetLowering::emitFEXT_CCRX16_ins(
return BB; return BB;
} }
MachineBasicBlock *Mips16TargetLowering::emitFEXT_CCRXI16_ins( MachineBasicBlock *
unsigned SltiOpc, unsigned SltiXOpc, Mips16TargetLowering::emitFEXT_CCRXI16_ins(unsigned SltiOpc, unsigned SltiXOpc,
MachineInstr *MI, MachineBasicBlock *BB )const { MachineInstr *MI,
MachineBasicBlock *BB) const {
if (DontExpandCondPseudos16) if (DontExpandCondPseudos16)
return BB; return BB;
const TargetInstrInfo *TII = const TargetInstrInfo *TII = Subtarget.getInstrInfo();
getTargetMachine().getSubtargetImpl()->getInstrInfo();
unsigned CC = MI->getOperand(0).getReg(); unsigned CC = MI->getOperand(0).getReg();
unsigned regX = MI->getOperand(1).getReg(); unsigned regX = MI->getOperand(1).getReg();
int64_t Imm = MI->getOperand(2).getImm(); int64_t Imm = MI->getOperand(2).getImm();

View File

@ -65,7 +65,7 @@ bool Mips16RegisterInfo::saveScavengerRegister
const TargetRegisterClass *RC, const TargetRegisterClass *RC,
unsigned Reg) const { unsigned Reg) const {
DebugLoc DL; DebugLoc DL;
const TargetInstrInfo &TII = *MBB.getParent()->getSubtarget().getInstrInfo(); const TargetInstrInfo &TII = *Subtarget.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 +106,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 = MF.getSubtarget().getFrameLowering(); const TargetFrameLowering *TFI = Subtarget.getFrameLowering();
if (TFI->hasFP(MF)) { if (TFI->hasFP(MF)) {
FrameReg = Mips::S0; FrameReg = Mips::S0;
} }
@ -140,8 +140,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 *>( *static_cast<const Mips16InstrInfo *>(Subtarget.getInstrInfo());
MBB.getParent()->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

@ -448,14 +448,12 @@ bool MipsConstantIslands::runOnMachineFunction(MachineFunction &mf) {
// FIXME: // FIXME:
MF = &mf; MF = &mf;
MCP = mf.getConstantPool(); MCP = mf.getConstantPool();
STI = &mf.getTarget().getSubtarget<MipsSubtarget>(); STI = &static_cast<const MipsSubtarget &>(mf.getSubtarget());
DEBUG(dbgs() << "constant island machine function " << "\n"); DEBUG(dbgs() << "constant island machine function " << "\n");
if (!STI->inMips16Mode() || !MipsSubtarget::useConstantIslands()) { if (!STI->inMips16Mode() || !MipsSubtarget::useConstantIslands()) {
return false; return false;
} }
TII = (const Mips16InstrInfo *)MF->getTarget() TII = (const Mips16InstrInfo *)STI->getInstrInfo();
.getSubtargetImpl()
->getInstrInfo();
MFI = MF->getInfo<MipsFunctionInfo>(); MFI = MF->getInfo<MipsFunctionInfo>();
DEBUG(dbgs() << "constant island processing " << "\n"); DEBUG(dbgs() << "constant island processing " << "\n");
// //

View File

@ -69,7 +69,7 @@ namespace {
class RegDefsUses { class RegDefsUses {
public: public:
RegDefsUses(TargetMachine &TM); RegDefsUses(const TargetRegisterInfo &TRI);
void init(const MachineInstr &MI); void init(const MachineInstr &MI);
/// This function sets all caller-saved registers in Defs. /// This function sets all caller-saved registers in Defs.
@ -278,11 +278,7 @@ static void addLiveInRegs(Iter Filler, MachineBasicBlock &MBB) {
#ifndef NDEBUG #ifndef NDEBUG
const MachineFunction &MF = *MBB.getParent(); const MachineFunction &MF = *MBB.getParent();
assert(MF.getTarget() assert(MF.getSubtarget().getRegisterInfo()->getAllocatableSet(MF).test(R) &&
.getSubtargetImpl()
->getRegisterInfo()
->getAllocatableSet(MF)
.test(R) &&
"Shouldn't move an instruction with unallocatable registers across " "Shouldn't move an instruction with unallocatable registers across "
"basic block boundaries."); "basic block boundaries.");
#endif #endif
@ -292,9 +288,8 @@ static void addLiveInRegs(Iter Filler, MachineBasicBlock &MBB) {
} }
} }
RegDefsUses::RegDefsUses(TargetMachine &TM) RegDefsUses::RegDefsUses(const TargetRegisterInfo &TRI)
: TRI(*TM.getSubtargetImpl()->getRegisterInfo()), : TRI(TRI), Defs(TRI.getNumRegs(), false), Uses(TRI.getNumRegs(), false) {}
Defs(TRI.getNumRegs(), false), Uses(TRI.getNumRegs(), false) {}
void RegDefsUses::init(const MachineInstr &MI) { void RegDefsUses::init(const MachineInstr &MI) {
// Add all register operands which are explicit and non-variadic. // Add all register operands which are explicit and non-variadic.
@ -500,8 +495,8 @@ getUnderlyingObjects(const MachineInstr &MI,
// Replace Branch with the compact branch instruction. // Replace Branch with the compact branch instruction.
Iter Filler::replaceWithCompactBranch(MachineBasicBlock &MBB, Iter Filler::replaceWithCompactBranch(MachineBasicBlock &MBB,
Iter Branch, DebugLoc DL) { Iter Branch, DebugLoc DL) {
const MipsInstrInfo *TII= static_cast<const MipsInstrInfo *>( const MipsInstrInfo *TII = static_cast<const MipsInstrInfo *>(
TM.getSubtargetImpl()->getInstrInfo()); MBB.getParent()->getSubtarget().getInstrInfo());
unsigned NewOpcode = unsigned NewOpcode =
(((unsigned) Branch->getOpcode()) == Mips::BEQ) ? Mips::BEQZC_MM (((unsigned) Branch->getOpcode()) == Mips::BEQ) ? Mips::BEQZC_MM
@ -543,9 +538,10 @@ static int getEquivalentCallShort(int Opcode) {
/// We assume there is only one delay slot per delayed instruction. /// We assume there is only one delay slot per delayed instruction.
bool Filler::runOnMachineBasicBlock(MachineBasicBlock &MBB) { bool Filler::runOnMachineBasicBlock(MachineBasicBlock &MBB) {
bool Changed = false; bool Changed = false;
bool InMicroMipsMode = TM.getSubtarget<MipsSubtarget>().inMicroMipsMode(); const MipsSubtarget &STI =
const MipsInstrInfo *TII = static_cast<const MipsSubtarget &>(MBB.getParent()->getSubtarget());
static_cast<const MipsInstrInfo *>(TM.getSubtargetImpl()->getInstrInfo()); bool InMicroMipsMode = STI.inMicroMipsMode();
const MipsInstrInfo *TII = STI.getInstrInfo();
for (Iter I = MBB.begin(); I != MBB.end(); ++I) { for (Iter I = MBB.begin(); I != MBB.end(); ++I) {
if (!hasUnoccupiedSlot(&*I)) if (!hasUnoccupiedSlot(&*I))
@ -627,7 +623,8 @@ bool Filler::searchRange(MachineBasicBlock &MBB, IterTy Begin, IterTy End,
if (delayHasHazard(*I, RegDU, IM)) if (delayHasHazard(*I, RegDU, IM))
continue; continue;
if (TM.getSubtarget<MipsSubtarget>().isTargetNaCl()) { if (static_cast<const MipsSubtarget &>(MBB.getParent()->getSubtarget())
.isTargetNaCl()) {
// In NaCl, instructions that must be masked are forbidden in delay slots. // In NaCl, instructions that must be masked are forbidden in delay slots.
// We only check for loads, stores and SP changes. Calls, returns and // We only check for loads, stores and SP changes. Calls, returns and
// branches are not checked because non-NaCl targets never put them in // branches are not checked because non-NaCl targets never put them in
@ -660,7 +657,7 @@ bool Filler::searchBackward(MachineBasicBlock &MBB, Iter Slot) const {
if (DisableBackwardSearch) if (DisableBackwardSearch)
return false; return false;
RegDefsUses RegDU(TM); RegDefsUses RegDU(*MBB.getParent()->getSubtarget().getRegisterInfo());
MemDefsUses MemDU(MBB.getParent()->getFrameInfo()); MemDefsUses MemDU(MBB.getParent()->getFrameInfo());
ReverseIter Filler; ReverseIter Filler;
@ -681,7 +678,7 @@ bool Filler::searchForward(MachineBasicBlock &MBB, Iter Slot) const {
if (DisableForwardSearch || !Slot->isCall()) if (DisableForwardSearch || !Slot->isCall())
return false; return false;
RegDefsUses RegDU(TM); RegDefsUses RegDU(*MBB.getParent()->getSubtarget().getRegisterInfo());
NoMemInstr NM; NoMemInstr NM;
Iter Filler; Iter Filler;
@ -705,7 +702,7 @@ bool Filler::searchSuccBBs(MachineBasicBlock &MBB, Iter Slot) const {
if (!SuccBB) if (!SuccBB)
return false; return false;
RegDefsUses RegDU(TM); RegDefsUses RegDU(*MBB.getParent()->getSubtarget().getRegisterInfo());
bool HasMultipleSuccs = false; bool HasMultipleSuccs = false;
BB2BrMap BrMap; BB2BrMap BrMap;
std::unique_ptr<InspectMemInstr> IM; std::unique_ptr<InspectMemInstr> IM;
@ -757,8 +754,8 @@ MachineBasicBlock *Filler::selectSuccBB(MachineBasicBlock &B) const {
std::pair<MipsInstrInfo::BranchType, MachineInstr *> std::pair<MipsInstrInfo::BranchType, MachineInstr *>
Filler::getBranch(MachineBasicBlock &MBB, const MachineBasicBlock &Dst) const { Filler::getBranch(MachineBasicBlock &MBB, const MachineBasicBlock &Dst) const {
const MipsInstrInfo *TII = const MipsInstrInfo *TII = static_cast<const MipsInstrInfo *>(
static_cast<const MipsInstrInfo *>(TM.getSubtargetImpl()->getInstrInfo()); MBB.getParent()->getSubtarget().getInstrInfo());
MachineBasicBlock *TrueBB = nullptr, *FalseBB = nullptr; MachineBasicBlock *TrueBB = nullptr, *FalseBB = nullptr;
SmallVector<MachineInstr*, 2> BranchInstrs; SmallVector<MachineInstr*, 2> BranchInstrs;
SmallVector<MachineOperand, 2> Cond; SmallVector<MachineOperand, 2> Cond;

View File

@ -60,9 +60,9 @@ class MipsFastISel final : public FastISel {
/// Subtarget - Keep a pointer to the MipsSubtarget around so that we can /// Subtarget - Keep a pointer to the MipsSubtarget around so that we can
/// make the right decision when generating code for different targets. /// make the right decision when generating code for different targets.
const TargetMachine &TM; const TargetMachine &TM;
const MipsSubtarget *Subtarget;
const TargetInstrInfo &TII; const TargetInstrInfo &TII;
const TargetLowering &TLI; const TargetLowering &TLI;
const MipsSubtarget *Subtarget;
MipsFunctionInfo *MFI; MipsFunctionInfo *MFI;
// Convenience variables to avoid some queries. // Convenience variables to avoid some queries.
@ -157,9 +157,9 @@ public:
explicit MipsFastISel(FunctionLoweringInfo &funcInfo, explicit MipsFastISel(FunctionLoweringInfo &funcInfo,
const TargetLibraryInfo *libInfo) const TargetLibraryInfo *libInfo)
: FastISel(funcInfo, libInfo), TM(funcInfo.MF->getTarget()), : FastISel(funcInfo, libInfo), TM(funcInfo.MF->getTarget()),
TII(*TM.getSubtargetImpl()->getInstrInfo()), Subtarget(
TLI(*TM.getSubtargetImpl()->getTargetLowering()), &static_cast<const MipsSubtarget &>(funcInfo.MF->getSubtarget())),
Subtarget(&TM.getSubtarget<MipsSubtarget>()) { TII(*Subtarget->getInstrInfo()), TLI(*Subtarget->getTargetLowering()) {
MFI = funcInfo.MF->getInfo<MipsFunctionInfo>(); MFI = funcInfo.MF->getInfo<MipsFunctionInfo>();
Context = &funcInfo.Fn->getContext(); Context = &funcInfo.Fn->getContext();
TargetSupported = ((TM.getRelocationModel() == Reloc::PIC_) && TargetSupported = ((TM.getRelocationModel() == Reloc::PIC_) &&

View File

@ -100,7 +100,7 @@ bool MipsFrameLowering::hasFP(const MachineFunction &MF) const {
uint64_t MipsFrameLowering::estimateStackSize(const MachineFunction &MF) const { uint64_t MipsFrameLowering::estimateStackSize(const MachineFunction &MF) const {
const MachineFrameInfo *MFI = MF.getFrameInfo(); const MachineFrameInfo *MFI = MF.getFrameInfo();
const TargetRegisterInfo &TRI = *MF.getSubtarget().getRegisterInfo(); const TargetRegisterInfo &TRI = *STI.getRegisterInfo();
int64_t Offset = 0; int64_t Offset = 0;

View File

@ -47,7 +47,7 @@ using namespace llvm;
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
bool MipsDAGToDAGISel::runOnMachineFunction(MachineFunction &MF) { bool MipsDAGToDAGISel::runOnMachineFunction(MachineFunction &MF) {
Subtarget = &TM.getSubtarget<MipsSubtarget>(); Subtarget = &static_cast<const MipsSubtarget &>(MF.getSubtarget());
bool Ret = SelectionDAGISel::runOnMachineFunction(MF); bool Ret = SelectionDAGISel::runOnMachineFunction(MF);
processFunctionAfterISel(MF); processFunctionAfterISel(MF);
@ -230,12 +230,3 @@ SelectInlineAsmMemoryOperand(const SDValue &Op, char ConstraintCode,
OutOps.push_back(Op); OutOps.push_back(Op);
return false; return false;
} }
/// createMipsISelDag - This pass converts a legalized DAG into a
/// MIPS-specific DAG, ready for instruction scheduling.
FunctionPass *llvm::createMipsISelDag(MipsTargetMachine &TM) {
if (TM.getSubtargetImpl()->inMips16Mode())
return llvm::createMips16ISelDag(TM);
return llvm::createMipsSEISelDag(TM);
}

View File

@ -125,11 +125,6 @@ private:
char ConstraintCode, char ConstraintCode,
std::vector<SDValue> &OutOps) override; std::vector<SDValue> &OutOps) override;
}; };
/// createMipsISelDag - This pass converts a legalized DAG into a
/// MIPS-specific DAG, ready for instruction scheduling.
FunctionPass *createMipsISelDag(MipsTargetMachine &TM);
} }
#endif #endif

View File

@ -203,7 +203,7 @@ const char *MipsTargetLowering::getTargetNodeName(unsigned Opcode) const {
MipsTargetLowering::MipsTargetLowering(const MipsTargetMachine &TM, MipsTargetLowering::MipsTargetLowering(const MipsTargetMachine &TM,
const MipsSubtarget &STI) const MipsSubtarget &STI)
: TargetLowering(TM), Subtarget(STI) { : TargetLowering(TM), Subtarget(STI), ABI(TM.getABI()) {
// Mips does not have i1 type, so use i32 for // Mips does not have i1 type, so use i32 for
// setcc operations results (slt, sgt, ...). // setcc operations results (slt, sgt, ...).
setBooleanContents(ZeroOrOneBooleanContent); setBooleanContents(ZeroOrOneBooleanContent);
@ -393,14 +393,12 @@ MipsTargetLowering::MipsTargetLowering(const MipsTargetMachine &TM,
// The arguments on the stack are defined in terms of 4-byte slots on O32 // The arguments on the stack are defined in terms of 4-byte slots on O32
// and 8-byte slots on N32/N64. // and 8-byte slots on N32/N64.
setMinStackArgumentAlignment( setMinStackArgumentAlignment((ABI.IsN32() || ABI.IsN64()) ? 8 : 4);
(Subtarget.isABI_N32() || Subtarget.isABI_N64()) ? 8 : 4);
setStackPointerRegisterToSaveRestore(Subtarget.isABI_N64() ? Mips::SP_64 setStackPointerRegisterToSaveRestore(ABI.IsN64() ? Mips::SP_64 : Mips::SP);
: Mips::SP);
setExceptionPointerRegister(Subtarget.isABI_N64() ? Mips::A0_64 : Mips::A0); setExceptionPointerRegister(ABI.IsN64() ? Mips::A0_64 : Mips::A0);
setExceptionSelectorRegister(Subtarget.isABI_N64() ? Mips::A1_64 : Mips::A1); setExceptionSelectorRegister(ABI.IsN64() ? Mips::A1_64 : Mips::A1);
MaxStoresPerMemcpy = 16; MaxStoresPerMemcpy = 16;
@ -939,16 +937,14 @@ MipsTargetLowering::EmitInstrWithCustomInserter(MachineInstr *MI,
case Mips::DIVU: case Mips::DIVU:
case Mips::MOD: case Mips::MOD:
case Mips::MODU: case Mips::MODU:
return insertDivByZeroTrap( return insertDivByZeroTrap(MI, *BB, *Subtarget.getInstrInfo(), false);
MI, *BB, *getTargetMachine().getSubtargetImpl()->getInstrInfo(), false);
case Mips::PseudoDSDIV: case Mips::PseudoDSDIV:
case Mips::PseudoDUDIV: case Mips::PseudoDUDIV:
case Mips::DDIV: case Mips::DDIV:
case Mips::DDIVU: case Mips::DDIVU:
case Mips::DMOD: case Mips::DMOD:
case Mips::DMODU: case Mips::DMODU:
return insertDivByZeroTrap( return insertDivByZeroTrap(MI, *BB, *Subtarget.getInstrInfo(), true);
MI, *BB, *getTargetMachine().getSubtargetImpl()->getInstrInfo(), true);
case Mips::SEL_D: case Mips::SEL_D:
return emitSEL_D(MI, BB); return emitSEL_D(MI, BB);
@ -984,8 +980,7 @@ MipsTargetLowering::emitAtomicBinary(MachineInstr *MI, MachineBasicBlock *BB,
MachineFunction *MF = BB->getParent(); MachineFunction *MF = BB->getParent();
MachineRegisterInfo &RegInfo = MF->getRegInfo(); MachineRegisterInfo &RegInfo = MF->getRegInfo();
const TargetRegisterClass *RC = getRegClassFor(MVT::getIntegerVT(Size * 8)); const TargetRegisterClass *RC = getRegClassFor(MVT::getIntegerVT(Size * 8));
const TargetInstrInfo *TII = const TargetInstrInfo *TII = Subtarget.getInstrInfo();
getTargetMachine().getSubtargetImpl()->getInstrInfo();
DebugLoc DL = MI->getDebugLoc(); DebugLoc DL = MI->getDebugLoc();
unsigned LL, SC, AND, NOR, ZERO, BEQ; unsigned LL, SC, AND, NOR, ZERO, BEQ;
@ -1068,8 +1063,7 @@ MipsTargetLowering::emitAtomicBinary(MachineInstr *MI, MachineBasicBlock *BB,
MachineBasicBlock *MipsTargetLowering::emitSignExtendToI32InReg( MachineBasicBlock *MipsTargetLowering::emitSignExtendToI32InReg(
MachineInstr *MI, MachineBasicBlock *BB, unsigned Size, unsigned DstReg, MachineInstr *MI, MachineBasicBlock *BB, unsigned Size, unsigned DstReg,
unsigned SrcReg) const { unsigned SrcReg) const {
const TargetInstrInfo *TII = const TargetInstrInfo *TII = Subtarget.getInstrInfo();
getTargetMachine().getSubtargetImpl()->getInstrInfo();
DebugLoc DL = MI->getDebugLoc(); DebugLoc DL = MI->getDebugLoc();
if (Subtarget.hasMips32r2() && Size == 1) { if (Subtarget.hasMips32r2() && Size == 1) {
@ -1105,8 +1099,7 @@ MachineBasicBlock *MipsTargetLowering::emitAtomicBinaryPartword(
MachineFunction *MF = BB->getParent(); MachineFunction *MF = BB->getParent();
MachineRegisterInfo &RegInfo = MF->getRegInfo(); MachineRegisterInfo &RegInfo = MF->getRegInfo();
const TargetRegisterClass *RC = getRegClassFor(MVT::i32); const TargetRegisterClass *RC = getRegClassFor(MVT::i32);
const TargetInstrInfo *TII = const TargetInstrInfo *TII = Subtarget.getInstrInfo();
getTargetMachine().getSubtargetImpl()->getInstrInfo();
DebugLoc DL = MI->getDebugLoc(); DebugLoc DL = MI->getDebugLoc();
unsigned Dest = MI->getOperand(0).getReg(); unsigned Dest = MI->getOperand(0).getReg();
@ -1258,8 +1251,7 @@ MachineBasicBlock * MipsTargetLowering::emitAtomicCmpSwap(MachineInstr *MI,
MachineFunction *MF = BB->getParent(); MachineFunction *MF = BB->getParent();
MachineRegisterInfo &RegInfo = MF->getRegInfo(); MachineRegisterInfo &RegInfo = MF->getRegInfo();
const TargetRegisterClass *RC = getRegClassFor(MVT::getIntegerVT(Size * 8)); const TargetRegisterClass *RC = getRegClassFor(MVT::getIntegerVT(Size * 8));
const TargetInstrInfo *TII = const TargetInstrInfo *TII = Subtarget.getInstrInfo();
getTargetMachine().getSubtargetImpl()->getInstrInfo();
DebugLoc DL = MI->getDebugLoc(); DebugLoc DL = MI->getDebugLoc();
unsigned LL, SC, ZERO, BNE, BEQ; unsigned LL, SC, ZERO, BNE, BEQ;
@ -1341,8 +1333,7 @@ MipsTargetLowering::emitAtomicCmpSwapPartword(MachineInstr *MI,
MachineFunction *MF = BB->getParent(); MachineFunction *MF = BB->getParent();
MachineRegisterInfo &RegInfo = MF->getRegInfo(); MachineRegisterInfo &RegInfo = MF->getRegInfo();
const TargetRegisterClass *RC = getRegClassFor(MVT::i32); const TargetRegisterClass *RC = getRegClassFor(MVT::i32);
const TargetInstrInfo *TII = const TargetInstrInfo *TII = Subtarget.getInstrInfo();
getTargetMachine().getSubtargetImpl()->getInstrInfo();
DebugLoc DL = MI->getDebugLoc(); DebugLoc DL = MI->getDebugLoc();
unsigned Dest = MI->getOperand(0).getReg(); unsigned Dest = MI->getOperand(0).getReg();
@ -1479,10 +1470,8 @@ MipsTargetLowering::emitAtomicCmpSwapPartword(MachineInstr *MI,
MachineBasicBlock *MipsTargetLowering::emitSEL_D(MachineInstr *MI, MachineBasicBlock *MipsTargetLowering::emitSEL_D(MachineInstr *MI,
MachineBasicBlock *BB) const { MachineBasicBlock *BB) const {
MachineFunction *MF = BB->getParent(); MachineFunction *MF = BB->getParent();
const TargetRegisterInfo *TRI = const TargetRegisterInfo *TRI = Subtarget.getRegisterInfo();
getTargetMachine().getSubtargetImpl()->getRegisterInfo(); const TargetInstrInfo *TII = Subtarget.getInstrInfo();
const TargetInstrInfo *TII =
getTargetMachine().getSubtargetImpl()->getInstrInfo();
MachineRegisterInfo &RegInfo = MF->getRegInfo(); MachineRegisterInfo &RegInfo = MF->getRegInfo();
DebugLoc DL = MI->getDebugLoc(); DebugLoc DL = MI->getDebugLoc();
MachineBasicBlock::iterator II(MI); MachineBasicBlock::iterator II(MI);
@ -1526,8 +1515,7 @@ SDValue MipsTargetLowering::lowerBR_JT(SDValue Op, SelectionDAG &DAG) const {
false, 0); false, 0);
Chain = Addr.getValue(1); Chain = Addr.getValue(1);
if ((getTargetMachine().getRelocationModel() == Reloc::PIC_) || if ((getTargetMachine().getRelocationModel() == Reloc::PIC_) || ABI.IsN64()) {
Subtarget.isABI_N64()) {
// For PIC, the sequence is: // For PIC, the sequence is:
// BRIND(load(Jumptable + index) + RelocBase) // BRIND(load(Jumptable + index) + RelocBase)
// RelocBase can be JumpTable, GOT or some sort of global base. // RelocBase can be JumpTable, GOT or some sort of global base.
@ -1609,10 +1597,9 @@ SDValue MipsTargetLowering::lowerGlobalAddress(SDValue Op,
GlobalAddressSDNode *N = cast<GlobalAddressSDNode>(Op); GlobalAddressSDNode *N = cast<GlobalAddressSDNode>(Op);
const GlobalValue *GV = N->getGlobal(); const GlobalValue *GV = N->getGlobal();
if (getTargetMachine().getRelocationModel() != Reloc::PIC_ && if (getTargetMachine().getRelocationModel() != Reloc::PIC_ && !ABI.IsN64()) {
!Subtarget.isABI_N64()) {
const MipsTargetObjectFile &TLOF = const MipsTargetObjectFile &TLOF =
(const MipsTargetObjectFile&)getObjFileLowering(); (const MipsTargetObjectFile &)getObjFileLowering();
if (TLOF.IsGlobalInSmallSection(GV, getTargetMachine())) if (TLOF.IsGlobalInSmallSection(GV, getTargetMachine()))
// %gp_rel relocation // %gp_rel relocation
@ -1623,8 +1610,7 @@ SDValue MipsTargetLowering::lowerGlobalAddress(SDValue Op,
} }
if (GV->hasInternalLinkage() || (GV->hasLocalLinkage() && !isa<Function>(GV))) if (GV->hasInternalLinkage() || (GV->hasLocalLinkage() && !isa<Function>(GV)))
return getAddrLocal(N, SDLoc(N), Ty, DAG, return getAddrLocal(N, SDLoc(N), Ty, DAG, ABI.IsN32() || ABI.IsN64());
Subtarget.isABI_N32() || Subtarget.isABI_N64());
if (LargeGOT) if (LargeGOT)
return getAddrGlobalLargeGOT(N, SDLoc(N), Ty, DAG, MipsII::MO_GOT_HI16, return getAddrGlobalLargeGOT(N, SDLoc(N), Ty, DAG, MipsII::MO_GOT_HI16,
@ -1632,8 +1618,7 @@ SDValue MipsTargetLowering::lowerGlobalAddress(SDValue Op,
MachinePointerInfo::getGOT()); MachinePointerInfo::getGOT());
return getAddrGlobal(N, SDLoc(N), Ty, DAG, return getAddrGlobal(N, SDLoc(N), Ty, DAG,
(Subtarget.isABI_N32() || Subtarget.isABI_N64()) (ABI.IsN32() || ABI.IsN64()) ? MipsII::MO_GOT_DISP
? MipsII::MO_GOT_DISP
: MipsII::MO_GOT16, : MipsII::MO_GOT16,
DAG.getEntryNode(), MachinePointerInfo::getGOT()); DAG.getEntryNode(), MachinePointerInfo::getGOT());
} }
@ -1643,12 +1628,10 @@ SDValue MipsTargetLowering::lowerBlockAddress(SDValue Op,
BlockAddressSDNode *N = cast<BlockAddressSDNode>(Op); BlockAddressSDNode *N = cast<BlockAddressSDNode>(Op);
EVT Ty = Op.getValueType(); EVT Ty = Op.getValueType();
if (getTargetMachine().getRelocationModel() != Reloc::PIC_ && if (getTargetMachine().getRelocationModel() != Reloc::PIC_ && !ABI.IsN64())
!Subtarget.isABI_N64())
return getAddrNonPIC(N, SDLoc(N), Ty, DAG); return getAddrNonPIC(N, SDLoc(N), Ty, DAG);
return getAddrLocal(N, SDLoc(N), Ty, DAG, return getAddrLocal(N, SDLoc(N), Ty, DAG, ABI.IsN32() || ABI.IsN64());
Subtarget.isABI_N32() || Subtarget.isABI_N64());
} }
SDValue MipsTargetLowering:: SDValue MipsTargetLowering::
@ -1736,12 +1719,10 @@ lowerJumpTable(SDValue Op, SelectionDAG &DAG) const
JumpTableSDNode *N = cast<JumpTableSDNode>(Op); JumpTableSDNode *N = cast<JumpTableSDNode>(Op);
EVT Ty = Op.getValueType(); EVT Ty = Op.getValueType();
if (getTargetMachine().getRelocationModel() != Reloc::PIC_ && if (getTargetMachine().getRelocationModel() != Reloc::PIC_ && !ABI.IsN64())
!Subtarget.isABI_N64())
return getAddrNonPIC(N, SDLoc(N), Ty, DAG); return getAddrNonPIC(N, SDLoc(N), Ty, DAG);
return getAddrLocal(N, SDLoc(N), Ty, DAG, return getAddrLocal(N, SDLoc(N), Ty, DAG, ABI.IsN32() || ABI.IsN64());
Subtarget.isABI_N32() || Subtarget.isABI_N64());
} }
SDValue MipsTargetLowering:: SDValue MipsTargetLowering::
@ -1750,10 +1731,9 @@ lowerConstantPool(SDValue Op, SelectionDAG &DAG) const
ConstantPoolSDNode *N = cast<ConstantPoolSDNode>(Op); ConstantPoolSDNode *N = cast<ConstantPoolSDNode>(Op);
EVT Ty = Op.getValueType(); EVT Ty = Op.getValueType();
if (getTargetMachine().getRelocationModel() != Reloc::PIC_ && if (getTargetMachine().getRelocationModel() != Reloc::PIC_ && !ABI.IsN64()) {
!Subtarget.isABI_N64()) {
const MipsTargetObjectFile &TLOF = const MipsTargetObjectFile &TLOF =
(const MipsTargetObjectFile&)getObjFileLowering(); (const MipsTargetObjectFile &)getObjFileLowering();
if (TLOF.IsConstantInSmallSection(N->getConstVal(), getTargetMachine())) if (TLOF.IsConstantInSmallSection(N->getConstVal(), getTargetMachine()))
// %gp_rel relocation // %gp_rel relocation
@ -1762,8 +1742,7 @@ lowerConstantPool(SDValue Op, SelectionDAG &DAG) const
return getAddrNonPIC(N, SDLoc(N), Ty, DAG); return getAddrNonPIC(N, SDLoc(N), Ty, DAG);
} }
return getAddrLocal(N, SDLoc(N), Ty, DAG, return getAddrLocal(N, SDLoc(N), Ty, DAG, ABI.IsN32() || ABI.IsN64());
Subtarget.isABI_N32() || Subtarget.isABI_N64());
} }
SDValue MipsTargetLowering::lowerVASTART(SDValue Op, SelectionDAG &DAG) const { SDValue MipsTargetLowering::lowerVASTART(SDValue Op, SelectionDAG &DAG) const {
@ -1789,8 +1768,7 @@ SDValue MipsTargetLowering::lowerVAARG(SDValue Op, SelectionDAG &DAG) const {
unsigned Align = Node->getConstantOperandVal(3); unsigned Align = Node->getConstantOperandVal(3);
const Value *SV = cast<SrcValueSDNode>(Node->getOperand(2))->getValue(); const Value *SV = cast<SrcValueSDNode>(Node->getOperand(2))->getValue();
SDLoc DL(Node); SDLoc DL(Node);
unsigned ArgSlotSizeInBytes = unsigned ArgSlotSizeInBytes = (ABI.IsN32() || ABI.IsN64()) ? 8 : 4;
(Subtarget.isABI_N32() || Subtarget.isABI_N64()) ? 8 : 4;
SDValue VAListLoad = DAG.getLoad(getPointerTy(), DL, Chain, VAListPtr, SDValue VAListLoad = DAG.getLoad(getPointerTy(), DL, Chain, VAListPtr,
MachinePointerInfo(SV), false, false, false, MachinePointerInfo(SV), false, false, false,
@ -1953,9 +1931,8 @@ lowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const {
MFI->setFrameAddressIsTaken(true); MFI->setFrameAddressIsTaken(true);
EVT VT = Op.getValueType(); EVT VT = Op.getValueType();
SDLoc DL(Op); SDLoc DL(Op);
SDValue FrameAddr = SDValue FrameAddr = DAG.getCopyFromReg(
DAG.getCopyFromReg(DAG.getEntryNode(), DL, DAG.getEntryNode(), DL, ABI.IsN64() ? Mips::FP_64 : Mips::FP, VT);
Subtarget.isABI_N64() ? Mips::FP_64 : Mips::FP, VT);
return FrameAddr; return FrameAddr;
} }
@ -1971,7 +1948,7 @@ SDValue MipsTargetLowering::lowerRETURNADDR(SDValue Op,
MachineFunction &MF = DAG.getMachineFunction(); MachineFunction &MF = DAG.getMachineFunction();
MachineFrameInfo *MFI = MF.getFrameInfo(); MachineFrameInfo *MFI = MF.getFrameInfo();
MVT VT = Op.getSimpleValueType(); MVT VT = Op.getSimpleValueType();
unsigned RA = Subtarget.isABI_N64() ? Mips::RA_64 : Mips::RA; unsigned RA = ABI.IsN64() ? Mips::RA_64 : Mips::RA;
MFI->setReturnAddressIsTaken(true); MFI->setReturnAddressIsTaken(true);
// Return RA, which contains the return address. Mark it an implicit live-in. // Return RA, which contains the return address. Mark it an implicit live-in.
@ -1993,12 +1970,12 @@ SDValue MipsTargetLowering::lowerEH_RETURN(SDValue Op, SelectionDAG &DAG)
SDValue Offset = Op.getOperand(1); SDValue Offset = Op.getOperand(1);
SDValue Handler = Op.getOperand(2); SDValue Handler = Op.getOperand(2);
SDLoc DL(Op); SDLoc DL(Op);
EVT Ty = Subtarget.isABI_N64() ? MVT::i64 : MVT::i32; EVT Ty = ABI.IsN64() ? MVT::i64 : MVT::i32;
// Store stack offset in V1, store jump target in V0. Glue CopyToReg and // Store stack offset in V1, store jump target in V0. Glue CopyToReg and
// EH_RETURN nodes, so that instructions are emitted back-to-back. // EH_RETURN nodes, so that instructions are emitted back-to-back.
unsigned OffsetReg = Subtarget.isABI_N64() ? Mips::V1_64 : Mips::V1; unsigned OffsetReg = ABI.IsN64() ? Mips::V1_64 : Mips::V1;
unsigned AddrReg = Subtarget.isABI_N64() ? Mips::V0_64 : Mips::V0; unsigned AddrReg = ABI.IsN64() ? Mips::V0_64 : Mips::V0;
Chain = DAG.getCopyToReg(Chain, DL, OffsetReg, Offset, SDValue()); Chain = DAG.getCopyToReg(Chain, DL, OffsetReg, Offset, SDValue());
Chain = DAG.getCopyToReg(Chain, DL, AddrReg, Handler, Chain.getValue(1)); Chain = DAG.getCopyToReg(Chain, DL, AddrReg, Handler, Chain.getValue(1));
return DAG.getNode(MipsISD::EH_RETURN, DL, MVT::Other, Chain, return DAG.getNode(MipsISD::EH_RETURN, DL, MVT::Other, Chain,
@ -2295,9 +2272,8 @@ SDValue MipsTargetLowering::lowerFP_TO_SINT(SDValue Op,
static bool CC_MipsO32(unsigned ValNo, MVT ValVT, MVT LocVT, static bool CC_MipsO32(unsigned ValNo, MVT ValVT, MVT LocVT,
CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags,
CCState &State, const MCPhysReg *F64Regs) { CCState &State, const MCPhysReg *F64Regs) {
const MipsSubtarget &Subtarget = const MipsSubtarget &Subtarget = static_cast<const MipsSubtarget &>(
State.getMachineFunction().getTarget() State.getMachineFunction().getSubtarget());
.getSubtarget<const MipsSubtarget>();
static const unsigned IntRegsSize = 4, FloatRegsSize = 2; static const unsigned IntRegsSize = 4, FloatRegsSize = 2;
@ -2451,8 +2427,8 @@ getOpndList(SmallVectorImpl<SDValue> &Ops,
// used for the function (that is, Mips linker doesn't generate lazy binding // used for the function (that is, Mips linker doesn't generate lazy binding
// stub for a function whose address is taken in the program). // stub for a function whose address is taken in the program).
if (IsPICCall && !InternalLinkage && IsCallReloc) { if (IsPICCall && !InternalLinkage && IsCallReloc) {
unsigned GPReg = Subtarget.isABI_N64() ? Mips::GP_64 : Mips::GP; unsigned GPReg = ABI.IsN64() ? Mips::GP_64 : Mips::GP;
EVT Ty = Subtarget.isABI_N64() ? MVT::i64 : MVT::i32; EVT Ty = ABI.IsN64() ? MVT::i64 : MVT::i32;
RegsToPass.push_back(std::make_pair(GPReg, getGlobalReg(CLI.DAG, Ty))); RegsToPass.push_back(std::make_pair(GPReg, getGlobalReg(CLI.DAG, Ty)));
} }
@ -2475,8 +2451,7 @@ getOpndList(SmallVectorImpl<SDValue> &Ops,
RegsToPass[i].second.getValueType())); RegsToPass[i].second.getValueType()));
// Add a register mask operand representing the call-preserved registers. // Add a register mask operand representing the call-preserved registers.
const TargetRegisterInfo *TRI = const TargetRegisterInfo *TRI = Subtarget.getRegisterInfo();
getTargetMachine().getSubtargetImpl()->getRegisterInfo();
const uint32_t *Mask = TRI->getCallPreservedMask(CLI.CallConv); const uint32_t *Mask = TRI->getCallPreservedMask(CLI.CallConv);
assert(Mask && "Missing call preserved mask for calling convention"); assert(Mask && "Missing call preserved mask for calling convention");
if (Subtarget.inMips16HardFloat()) { if (Subtarget.inMips16HardFloat()) {
@ -2512,7 +2487,7 @@ MipsTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
MachineFunction &MF = DAG.getMachineFunction(); MachineFunction &MF = DAG.getMachineFunction();
MachineFrameInfo *MFI = MF.getFrameInfo(); MachineFrameInfo *MFI = MF.getFrameInfo();
const TargetFrameLowering *TFL = MF.getSubtarget().getFrameLowering(); const TargetFrameLowering *TFL = Subtarget.getFrameLowering();
MipsFunctionInfo *FuncInfo = MF.getInfo<MipsFunctionInfo>(); MipsFunctionInfo *FuncInfo = MF.getInfo<MipsFunctionInfo>();
bool IsPIC = getTargetMachine().getRelocationModel() == Reloc::PIC_; bool IsPIC = getTargetMachine().getRelocationModel() == Reloc::PIC_;
@ -2524,8 +2499,6 @@ MipsTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
// Allocate the reserved argument area. It seems strange to do this from the // Allocate the reserved argument area. It seems strange to do this from the
// caller side but removing it breaks the frame size calculation. // caller side but removing it breaks the frame size calculation.
const MipsABIInfo &ABI =
static_cast<const MipsTargetMachine &>(MF.getTarget()).getABI();
CCInfo.AllocateStack(ABI.GetCalleeAllocdArgSizeInBytes(CallConv), 1); CCInfo.AllocateStack(ABI.GetCalleeAllocdArgSizeInBytes(CallConv), 1);
CCInfo.AnalyzeCallOperands(Outs, CC_Mips, CLI.getArgs(), Callee.getNode()); CCInfo.AnalyzeCallOperands(Outs, CC_Mips, CLI.getArgs(), Callee.getNode());
@ -2556,8 +2529,7 @@ MipsTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
Chain = DAG.getCALLSEQ_START(Chain, NextStackOffsetVal, DL); Chain = DAG.getCALLSEQ_START(Chain, NextStackOffsetVal, DL);
SDValue StackPtr = DAG.getCopyFromReg( SDValue StackPtr = DAG.getCopyFromReg(
Chain, DL, Subtarget.isABI_N64() ? Mips::SP_64 : Mips::SP, Chain, DL, ABI.IsN64() ? Mips::SP_64 : Mips::SP, getPointerTy());
getPointerTy());
// With EABI is it possible to have 16 args on registers. // With EABI is it possible to have 16 args on registers.
std::deque< std::pair<unsigned, SDValue> > RegsToPass; std::deque< std::pair<unsigned, SDValue> > RegsToPass;
@ -2671,8 +2643,7 @@ MipsTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
// If the callee is a GlobalAddress/ExternalSymbol node (quite common, every // If the callee is a GlobalAddress/ExternalSymbol node (quite common, every
// direct call is) turn it into a TargetGlobalAddress/TargetExternalSymbol // direct call is) turn it into a TargetGlobalAddress/TargetExternalSymbol
// node so that legalize doesn't hack it. // node so that legalize doesn't hack it.
bool IsPICCall = bool IsPICCall = (ABI.IsN64() || IsPIC); // true if calls are translated to
(Subtarget.isABI_N64() || IsPIC); // true if calls are translated to
// jalr $25 // jalr $25
bool GlobalOrExternal = false, InternalLinkage = false, IsCallReloc = false; bool GlobalOrExternal = false, InternalLinkage = false, IsCallReloc = false;
SDValue CalleeLo; SDValue CalleeLo;
@ -2684,8 +2655,7 @@ MipsTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
InternalLinkage = Val->hasInternalLinkage(); InternalLinkage = Val->hasInternalLinkage();
if (InternalLinkage) if (InternalLinkage)
Callee = getAddrLocal(G, DL, Ty, DAG, Callee = getAddrLocal(G, DL, Ty, DAG, ABI.IsN32() || ABI.IsN64());
Subtarget.isABI_N32() || Subtarget.isABI_N64());
else if (LargeGOT) { else if (LargeGOT) {
Callee = getAddrGlobalLargeGOT(G, DL, Ty, DAG, MipsII::MO_CALL_HI16, Callee = getAddrGlobalLargeGOT(G, DL, Ty, DAG, MipsII::MO_CALL_HI16,
MipsII::MO_CALL_LO16, Chain, MipsII::MO_CALL_LO16, Chain,
@ -2704,7 +2674,7 @@ MipsTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
else if (ExternalSymbolSDNode *S = dyn_cast<ExternalSymbolSDNode>(Callee)) { else if (ExternalSymbolSDNode *S = dyn_cast<ExternalSymbolSDNode>(Callee)) {
const char *Sym = S->getSymbol(); const char *Sym = S->getSymbol();
if (!Subtarget.isABI_N64() && !IsPIC) // !N64 && static if (!ABI.IsN64() && !IsPIC) // !N64 && static
Callee = Callee =
DAG.getTargetExternalSymbol(Sym, getPointerTy(), MipsII::MO_NO_FLAG); DAG.getTargetExternalSymbol(Sym, getPointerTy(), MipsII::MO_NO_FLAG);
else if (LargeGOT) { else if (LargeGOT) {
@ -2889,8 +2859,6 @@ MipsTargetLowering::LowerFormalArguments(SDValue Chain,
SmallVector<CCValAssign, 16> ArgLocs; SmallVector<CCValAssign, 16> ArgLocs;
MipsCCState CCInfo(CallConv, IsVarArg, DAG.getMachineFunction(), ArgLocs, MipsCCState CCInfo(CallConv, IsVarArg, DAG.getMachineFunction(), ArgLocs,
*DAG.getContext()); *DAG.getContext());
const MipsABIInfo &ABI =
static_cast<const MipsTargetMachine &>(MF.getTarget()).getABI();
CCInfo.AllocateStack(ABI.GetCalleeAllocdArgSizeInBytes(CallConv), 1); CCInfo.AllocateStack(ABI.GetCalleeAllocdArgSizeInBytes(CallConv), 1);
Function::const_arg_iterator FuncArg = Function::const_arg_iterator FuncArg =
DAG.getMachineFunction().getFunction()->arg_begin(); DAG.getMachineFunction().getFunction()->arg_begin();
@ -2943,7 +2911,7 @@ MipsTargetLowering::LowerFormalArguments(SDValue Chain,
(RegVT == MVT::i64 && ValVT == MVT::f64) || (RegVT == MVT::i64 && ValVT == MVT::f64) ||
(RegVT == MVT::f64 && ValVT == MVT::i64)) (RegVT == MVT::f64 && ValVT == MVT::i64))
ArgValue = DAG.getNode(ISD::BITCAST, DL, ValVT, ArgValue); ArgValue = DAG.getNode(ISD::BITCAST, DL, ValVT, ArgValue);
else if (Subtarget.isABI_O32() && RegVT == MVT::i32 && else if (ABI.IsO32() && RegVT == MVT::i32 &&
ValVT == MVT::f64) { ValVT == MVT::f64) {
unsigned Reg2 = addLiveIn(DAG.getMachineFunction(), unsigned Reg2 = addLiveIn(DAG.getMachineFunction(),
getNextIntArgReg(ArgReg), RC); getNextIntArgReg(ArgReg), RC);
@ -2958,7 +2926,7 @@ MipsTargetLowering::LowerFormalArguments(SDValue Chain,
} else { // VA.isRegLoc() } else { // VA.isRegLoc()
MVT LocVT = VA.getLocVT(); MVT LocVT = VA.getLocVT();
if (Subtarget.isABI_O32()) { if (ABI.IsO32()) {
// We ought to be able to use LocVT directly but O32 sets it to i32 // We ought to be able to use LocVT directly but O32 sets it to i32
// when allocating floating point values to integer registers. // when allocating floating point values to integer registers.
// This shouldn't influence how we load the value into registers unless // This shouldn't influence how we load the value into registers unless
@ -2995,7 +2963,7 @@ MipsTargetLowering::LowerFormalArguments(SDValue Chain,
unsigned Reg = MipsFI->getSRetReturnReg(); unsigned Reg = MipsFI->getSRetReturnReg();
if (!Reg) { if (!Reg) {
Reg = MF.getRegInfo().createVirtualRegister( Reg = MF.getRegInfo().createVirtualRegister(
getRegClassFor(Subtarget.isABI_N64() ? MVT::i64 : MVT::i32)); getRegClassFor(ABI.IsN64() ? MVT::i64 : MVT::i32));
MipsFI->setSRetReturnReg(Reg); MipsFI->setSRetReturnReg(Reg);
} }
SDValue Copy = DAG.getCopyToReg(DAG.getEntryNode(), DL, Reg, InVals[i]); SDValue Copy = DAG.getCopyToReg(DAG.getEntryNode(), DL, Reg, InVals[i]);
@ -3112,7 +3080,7 @@ MipsTargetLowering::LowerReturn(SDValue Chain,
if (!Reg) if (!Reg)
llvm_unreachable("sret virtual register not created in the entry block"); llvm_unreachable("sret virtual register not created in the entry block");
SDValue Val = DAG.getCopyFromReg(Chain, DL, Reg, getPointerTy()); SDValue Val = DAG.getCopyFromReg(Chain, DL, Reg, getPointerTy());
unsigned V0 = Subtarget.isABI_N64() ? Mips::V0_64 : Mips::V0; unsigned V0 = ABI.IsN64() ? Mips::V0_64 : Mips::V0;
Chain = DAG.getCopyToReg(Chain, DL, V0, Val, Flag); Chain = DAG.getCopyToReg(Chain, DL, V0, Val, Flag);
Flag = Chain.getValue(1); Flag = Chain.getValue(1);
@ -3247,7 +3215,7 @@ parsePhysicalReg(StringRef C, std::string &Prefix,
std::pair<unsigned, const TargetRegisterClass *> MipsTargetLowering:: std::pair<unsigned, const TargetRegisterClass *> MipsTargetLowering::
parseRegForInlineAsmConstraint(StringRef C, MVT VT) const { parseRegForInlineAsmConstraint(StringRef C, MVT VT) const {
const TargetRegisterInfo *TRI = const TargetRegisterInfo *TRI =
getTargetMachine().getSubtargetImpl()->getRegisterInfo(); Subtarget.getRegisterInfo();
const TargetRegisterClass *RC; const TargetRegisterClass *RC;
std::string Prefix; std::string Prefix;
unsigned long long Reg; unsigned long long Reg;
@ -3523,7 +3491,7 @@ bool MipsTargetLowering::isFPImmLegal(const APFloat &Imm, EVT VT) const {
} }
unsigned MipsTargetLowering::getJumpTableEncoding() const { unsigned MipsTargetLowering::getJumpTableEncoding() const {
if (Subtarget.isABI_N64()) if (ABI.IsN64())
return MachineJumpTableInfo::EK_GPRel64BlockAddress; return MachineJumpTableInfo::EK_GPRel64BlockAddress;
return TargetLowering::getJumpTableEncoding(); return TargetLowering::getJumpTableEncoding();
@ -3541,8 +3509,6 @@ void MipsTargetLowering::copyByValRegs(
unsigned RegAreaSize = NumRegs * GPRSizeInBytes; unsigned RegAreaSize = NumRegs * GPRSizeInBytes;
unsigned FrameObjSize = std::max(Flags.getByValSize(), RegAreaSize); unsigned FrameObjSize = std::max(Flags.getByValSize(), RegAreaSize);
int FrameObjOffset; int FrameObjOffset;
const MipsABIInfo &ABI =
static_cast<const MipsTargetMachine &>(MF.getTarget()).getABI();
ArrayRef<MCPhysReg> ByValArgRegs = ABI.GetByValArgRegs(); ArrayRef<MCPhysReg> ByValArgRegs = ABI.GetByValArgRegs();
if (RegAreaSize) if (RegAreaSize)
@ -3594,10 +3560,7 @@ void MipsTargetLowering::passByValArg(
unsigned NumRegs = LastReg - FirstReg; unsigned NumRegs = LastReg - FirstReg;
if (NumRegs) { if (NumRegs) {
const ArrayRef<MCPhysReg> ArgRegs = const ArrayRef<MCPhysReg> ArgRegs = ABI.GetByValArgRegs();
static_cast<const MipsTargetMachine &>(DAG.getTarget())
.getABI()
.GetByValArgRegs();
bool LeftoverBytes = (NumRegs * RegSizeInBytes > ByValSizeInBytes); bool LeftoverBytes = (NumRegs * RegSizeInBytes > ByValSizeInBytes);
unsigned I = 0; unsigned I = 0;
@ -3680,10 +3643,7 @@ void MipsTargetLowering::writeVarArgRegs(std::vector<SDValue> &OutChains,
SDValue Chain, SDLoc DL, SDValue Chain, SDLoc DL,
SelectionDAG &DAG, SelectionDAG &DAG,
CCState &State) const { CCState &State) const {
const ArrayRef<MCPhysReg> ArgRegs = const ArrayRef<MCPhysReg> ArgRegs = ABI.GetVarArgRegs();
static_cast<const MipsTargetMachine &>(DAG.getTarget())
.getABI()
.GetVarArgRegs();
unsigned Idx = State.getFirstUnallocated(ArgRegs.data(), ArgRegs.size()); unsigned Idx = State.getFirstUnallocated(ArgRegs.data(), ArgRegs.size());
unsigned RegSizeInBytes = Subtarget.getGPRSizeInBytes(); unsigned RegSizeInBytes = Subtarget.getGPRSizeInBytes();
MVT RegTy = MVT::getIntegerVT(RegSizeInBytes * 8); MVT RegTy = MVT::getIntegerVT(RegSizeInBytes * 8);
@ -3699,8 +3659,6 @@ void MipsTargetLowering::writeVarArgRegs(std::vector<SDValue> &OutChains,
VaArgOffset = VaArgOffset =
RoundUpToAlignment(State.getNextStackOffset(), RegSizeInBytes); RoundUpToAlignment(State.getNextStackOffset(), RegSizeInBytes);
else { else {
const MipsABIInfo &ABI =
static_cast<const MipsTargetMachine &>(MF.getTarget()).getABI();
VaArgOffset = VaArgOffset =
(int)ABI.GetCalleeAllocdArgSizeInBytes(State.getCallingConv()) - (int)ABI.GetCalleeAllocdArgSizeInBytes(State.getCallingConv()) -
(int)(RegSizeInBytes * (ArgRegs.size() - Idx)); (int)(RegSizeInBytes * (ArgRegs.size() - Idx));
@ -3731,8 +3689,7 @@ void MipsTargetLowering::writeVarArgRegs(std::vector<SDValue> &OutChains,
void MipsTargetLowering::HandleByVal(CCState *State, unsigned &Size, void MipsTargetLowering::HandleByVal(CCState *State, unsigned &Size,
unsigned Align) const { unsigned Align) const {
MachineFunction &MF = State->getMachineFunction(); const TargetFrameLowering *TFL = Subtarget.getFrameLowering();
const TargetFrameLowering *TFL = MF.getSubtarget().getFrameLowering();
assert(Size && "Byval argument's size shouldn't be 0."); assert(Size && "Byval argument's size shouldn't be 0.");
@ -3743,13 +3700,10 @@ void MipsTargetLowering::HandleByVal(CCState *State, unsigned &Size,
if (State->getCallingConv() != CallingConv::Fast) { if (State->getCallingConv() != CallingConv::Fast) {
unsigned RegSizeInBytes = Subtarget.getGPRSizeInBytes(); unsigned RegSizeInBytes = Subtarget.getGPRSizeInBytes();
const ArrayRef<MCPhysReg> IntArgRegs = const ArrayRef<MCPhysReg> IntArgRegs = ABI.GetByValArgRegs();
static_cast<const MipsTargetMachine &>(MF.getTarget())
.getABI()
.GetByValArgRegs();
// FIXME: The O32 case actually describes no shadow registers. // FIXME: The O32 case actually describes no shadow registers.
const MCPhysReg *ShadowRegs = const MCPhysReg *ShadowRegs =
Subtarget.isABI_O32() ? IntArgRegs.data() : Mips64DPRegs; ABI.IsO32() ? IntArgRegs.data() : Mips64DPRegs;
// We used to check the size as well but we can't do that anymore since // We used to check the size as well but we can't do that anymore since
// CCState::HandleByVal() rounds up the size after calling this function. // CCState::HandleByVal() rounds up the size after calling this function.
@ -3786,7 +3740,7 @@ MipsTargetLowering::emitPseudoSELECT(MachineInstr *MI, MachineBasicBlock *BB,
"conditional-move instructions."); "conditional-move instructions.");
const TargetInstrInfo *TII = const TargetInstrInfo *TII =
getTargetMachine().getSubtargetImpl()->getInstrInfo(); Subtarget.getInstrInfo();
DebugLoc DL = MI->getDebugLoc(); DebugLoc DL = MI->getDebugLoc();
// To "insert" a SELECT instruction, we actually have to insert the // To "insert" a SELECT instruction, we actually have to insert the

View File

@ -15,6 +15,7 @@
#ifndef LLVM_LIB_TARGET_MIPS_MIPSISELLOWERING_H #ifndef LLVM_LIB_TARGET_MIPS_MIPSISELLOWERING_H
#define LLVM_LIB_TARGET_MIPS_MIPSISELLOWERING_H #define LLVM_LIB_TARGET_MIPS_MIPSISELLOWERING_H
#include "MCTargetDesc/MipsABIInfo.h"
#include "MCTargetDesc/MipsBaseInfo.h" #include "MCTargetDesc/MipsBaseInfo.h"
#include "Mips.h" #include "Mips.h"
#include "llvm/CodeGen/CallingConvLower.h" #include "llvm/CodeGen/CallingConvLower.h"
@ -361,6 +362,8 @@ namespace llvm {
// Subtarget Info // Subtarget Info
const MipsSubtarget &Subtarget; const MipsSubtarget &Subtarget;
// Cache the ABI from the TargetMachine, we use it everywhere.
const MipsABIInfo &ABI;
private: private:
// Create a TargetGlobalAddress node. // Create a TargetGlobalAddress node.

View File

@ -65,14 +65,7 @@ namespace {
MipsLongBranch(TargetMachine &tm) MipsLongBranch(TargetMachine &tm)
: MachineFunctionPass(ID), TM(tm), : MachineFunctionPass(ID), TM(tm),
IsPIC(TM.getRelocationModel() == Reloc::PIC_), IsPIC(TM.getRelocationModel() == Reloc::PIC_),
ABI(static_cast<const MipsTargetMachine &>(TM).getABI()), ABI(static_cast<const MipsTargetMachine &>(TM).getABI()) {}
LongBranchSeqSize(
!IsPIC ? 2
: (ABI.IsN64()
? 10
: (!TM.getSubtarget<MipsSubtarget>().isTargetNaCl()
? 9
: 10))) {}
const char *getPassName() const override { const char *getPassName() const override {
return "Mips Long Branch"; return "Mips Long Branch";
@ -175,7 +168,7 @@ void MipsLongBranch::initMBBInfo() {
MBBInfos.resize(MF->size()); MBBInfos.resize(MF->size());
const MipsInstrInfo *TII = const MipsInstrInfo *TII =
static_cast<const MipsInstrInfo *>(TM.getSubtargetImpl()->getInstrInfo()); static_cast<const MipsInstrInfo *>(MF->getSubtarget().getInstrInfo());
for (unsigned I = 0, E = MBBInfos.size(); I < E; ++I) { for (unsigned I = 0, E = MBBInfos.size(); I < E; ++I) {
MachineBasicBlock *MBB = MF->getBlockNumbered(I); MachineBasicBlock *MBB = MF->getBlockNumbered(I);
@ -221,8 +214,8 @@ int64_t MipsLongBranch::computeOffset(const MachineInstr *Br) {
// MachineBasicBlock operand MBBOpnd. // MachineBasicBlock operand MBBOpnd.
void MipsLongBranch::replaceBranch(MachineBasicBlock &MBB, Iter Br, void MipsLongBranch::replaceBranch(MachineBasicBlock &MBB, Iter Br,
DebugLoc DL, MachineBasicBlock *MBBOpnd) { DebugLoc DL, MachineBasicBlock *MBBOpnd) {
const MipsInstrInfo *TII = const MipsInstrInfo *TII = static_cast<const MipsInstrInfo *>(
static_cast<const MipsInstrInfo *>(TM.getSubtargetImpl()->getInstrInfo()); MBB.getParent()->getSubtarget().getInstrInfo());
unsigned NewOpc = TII->getOppositeBranchOpc(Br->getOpcode()); unsigned NewOpc = TII->getOppositeBranchOpc(Br->getOpcode());
const MCInstrDesc &NewDesc = TII->get(NewOpc); const MCInstrDesc &NewDesc = TII->get(NewOpc);
@ -263,9 +256,10 @@ void MipsLongBranch::expandToLongBranch(MBBInfo &I) {
const BasicBlock *BB = MBB->getBasicBlock(); const BasicBlock *BB = MBB->getBasicBlock();
MachineFunction::iterator FallThroughMBB = ++MachineFunction::iterator(MBB); MachineFunction::iterator FallThroughMBB = ++MachineFunction::iterator(MBB);
MachineBasicBlock *LongBrMBB = MF->CreateMachineBasicBlock(BB); MachineBasicBlock *LongBrMBB = MF->CreateMachineBasicBlock(BB);
const MipsSubtarget &Subtarget =
static_cast<const MipsSubtarget &>(MF->getSubtarget());
const MipsInstrInfo *TII = const MipsInstrInfo *TII =
static_cast<const MipsInstrInfo *>(TM.getSubtargetImpl()->getInstrInfo()); static_cast<const MipsInstrInfo *>(Subtarget.getInstrInfo());
MF->insert(FallThroughMBB, LongBrMBB); MF->insert(FallThroughMBB, LongBrMBB);
MBB->removeSuccessor(TgtMBB); MBB->removeSuccessor(TgtMBB);
@ -280,8 +274,6 @@ void MipsLongBranch::expandToLongBranch(MBBInfo &I) {
// We must select between the MIPS32r6/MIPS64r6 BAL (which is a normal // We must select between the MIPS32r6/MIPS64r6 BAL (which is a normal
// instruction) and the pre-MIPS32r6/MIPS64r6 definition (which is an // instruction) and the pre-MIPS32r6/MIPS64r6 definition (which is an
// pseudo-instruction wrapping BGEZAL). // pseudo-instruction wrapping BGEZAL).
const MipsSubtarget &Subtarget = TM.getSubtarget<MipsSubtarget>();
unsigned BalOp = Subtarget.hasMips32r6() ? Mips::BAL : Mips::BAL_BR; unsigned BalOp = Subtarget.hasMips32r6() ? Mips::BAL : Mips::BAL_BR;
if (!ABI.IsN64()) { if (!ABI.IsN64()) {
@ -338,7 +330,7 @@ void MipsLongBranch::expandToLongBranch(MBBInfo &I) {
BuildMI(*BalTgtMBB, Pos, DL, TII->get(Mips::LW), Mips::RA) BuildMI(*BalTgtMBB, Pos, DL, TII->get(Mips::LW), Mips::RA)
.addReg(Mips::SP).addImm(0); .addReg(Mips::SP).addImm(0);
if (!TM.getSubtarget<MipsSubtarget>().isTargetNaCl()) { if (!Subtarget.isTargetNaCl()) {
MIBundleBuilder(*BalTgtMBB, Pos) MIBundleBuilder(*BalTgtMBB, Pos)
.append(BuildMI(*MF, DL, TII->get(Mips::JR)).addReg(Mips::AT)) .append(BuildMI(*MF, DL, TII->get(Mips::JR)).addReg(Mips::AT))
.append(BuildMI(*MF, DL, TII->get(Mips::ADDiu), Mips::SP) .append(BuildMI(*MF, DL, TII->get(Mips::ADDiu), Mips::SP)
@ -457,14 +449,17 @@ static void emitGPDisp(MachineFunction &F, const MipsInstrInfo *TII) {
} }
bool MipsLongBranch::runOnMachineFunction(MachineFunction &F) { bool MipsLongBranch::runOnMachineFunction(MachineFunction &F) {
const MipsSubtarget &STI =
static_cast<const MipsSubtarget &>(F.getSubtarget());
const MipsInstrInfo *TII = const MipsInstrInfo *TII =
static_cast<const MipsInstrInfo *>(TM.getSubtargetImpl()->getInstrInfo()); static_cast<const MipsInstrInfo *>(STI.getInstrInfo());
LongBranchSeqSize =
!IsPIC ? 2 : (ABI.IsN64() ? 10 : (!STI.isTargetNaCl() ? 9 : 10));
const MipsSubtarget &STI = TM.getSubtarget<MipsSubtarget>();
if (STI.inMips16Mode() || !STI.enableLongBranchPass()) if (STI.inMips16Mode() || !STI.enableLongBranchPass())
return false; return false;
if ((TM.getRelocationModel() == Reloc::PIC_) && if ((TM.getRelocationModel() == Reloc::PIC_) &&
TM.getSubtarget<MipsSubtarget>().isABI_O32() && static_cast<const MipsTargetMachine &>(TM).getABI().IsO32() &&
F.getInfo<MipsFunctionInfo>()->globalBaseRegSet()) F.getInfo<MipsFunctionInfo>()->globalBaseRegSet())
emitGPDisp(F, TII); emitGPDisp(F, TII);
@ -486,10 +481,10 @@ bool MipsLongBranch::runOnMachineFunction(MachineFunction &F) {
if (!I->Br || I->HasLongBranch) if (!I->Br || I->HasLongBranch)
continue; continue;
int ShVal = TM.getSubtarget<MipsSubtarget>().inMicroMipsMode() ? 2 : 4; int ShVal = STI.inMicroMipsMode() ? 2 : 4;
int64_t Offset = computeOffset(I->Br) / ShVal; int64_t Offset = computeOffset(I->Br) / ShVal;
if (TM.getSubtarget<MipsSubtarget>().isTargetNaCl()) { if (STI.isTargetNaCl()) {
// The offset calculation does not include sandboxing instructions // The offset calculation does not include sandboxing instructions
// that will be added later in the MC layer. Since at this point we // that will be added later in the MC layer. Since at this point we
// don't know the exact amount of code that "sandboxing" will add, we // don't know the exact amount of code that "sandboxing" will add, we

View File

@ -7,10 +7,11 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "MipsMachineFunction.h"
#include "MCTargetDesc/MipsBaseInfo.h" #include "MCTargetDesc/MipsBaseInfo.h"
#include "MipsMachineFunction.h"
#include "MipsInstrInfo.h" #include "MipsInstrInfo.h"
#include "MipsSubtarget.h" #include "MipsSubtarget.h"
#include "MipsTargetMachine.h"
#include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/IR/Function.h" #include "llvm/IR/Function.h"
@ -78,11 +79,13 @@ unsigned MipsFunctionInfo::getGlobalBaseReg() {
if (GlobalBaseReg) if (GlobalBaseReg)
return GlobalBaseReg; return GlobalBaseReg;
const MipsSubtarget &ST = MF.getTarget().getSubtarget<MipsSubtarget>();
const TargetRegisterClass *RC = const TargetRegisterClass *RC =
ST.inMips16Mode() ? &Mips::CPU16RegsRegClass static_cast<const MipsSubtarget &>(MF.getSubtarget()).inMips16Mode()
: ST.isABI_N64() ? &Mips::GPR64RegClass ? &Mips::CPU16RegsRegClass
: static_cast<const MipsTargetMachine &>(MF.getTarget())
.getABI()
.IsN64()
? &Mips::GPR64RegClass
: &Mips::GPR32RegClass; : &Mips::GPR32RegClass;
return GlobalBaseReg = MF.getRegInfo().createVirtualRegister(RC); return GlobalBaseReg = MF.getRegInfo().createVirtualRegister(RC);
} }
@ -101,9 +104,10 @@ unsigned MipsFunctionInfo::getMips16SPAliasReg() {
void MipsFunctionInfo::createEhDataRegsFI() { void MipsFunctionInfo::createEhDataRegsFI() {
for (int I = 0; I < 4; ++I) { for (int I = 0; I < 4; ++I) {
const MipsSubtarget &ST = MF.getTarget().getSubtarget<MipsSubtarget>(); const TargetRegisterClass *RC =
const TargetRegisterClass *RC = ST.isABI_N64() ? static_cast<const MipsTargetMachine &>(MF.getTarget()).getABI().IsN64()
&Mips::GPR64RegClass : &Mips::GPR32RegClass; ? &Mips::GPR64RegClass
: &Mips::GPR32RegClass;
EhDataRegFI[I] = MF.getFrameInfo()->CreateStackObject(RC->getSize(), EhDataRegFI[I] = MF.getFrameInfo()->CreateStackObject(RC->getSize(),
RC->getAlignment(), false); RC->getAlignment(), false);

View File

@ -174,7 +174,7 @@ void MBBInfo::postVisit() {
// OptimizePICCall methods. // OptimizePICCall methods.
bool OptimizePICCall::runOnMachineFunction(MachineFunction &F) { bool OptimizePICCall::runOnMachineFunction(MachineFunction &F) {
if (F.getTarget().getSubtarget<MipsSubtarget>().inMips16Mode()) if (static_cast<const MipsSubtarget &>(F.getSubtarget()).inMips16Mode())
return false; return false;
// Do a pre-order traversal of the dominator tree. // Do a pre-order traversal of the dominator tree.

View File

@ -17,6 +17,7 @@
#include "MipsInstrInfo.h" #include "MipsInstrInfo.h"
#include "MipsMachineFunction.h" #include "MipsMachineFunction.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"
@ -62,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 = MF.getSubtarget().getFrameLowering(); const TargetFrameLowering *TFI = Subtarget.getFrameLowering();
return 28 - TFI->hasFP(MF); return 28 - TFI->hasFP(MF);
} }
case Mips::FGR32RegClassID: case Mips::FGR32RegClassID:
@ -167,7 +168,7 @@ getReservedRegs(const MachineFunction &MF) const {
Reserved.set(*Reg); Reserved.set(*Reg);
} }
// Reserve FP if this function should have a dedicated frame pointer register. // Reserve FP if this function should have a dedicated frame pointer register.
if (MF.getSubtarget().getFrameLowering()->hasFP(MF)) { if (Subtarget.getFrameLowering()->hasFP(MF)) {
if (Subtarget.inMips16Mode()) if (Subtarget.inMips16Mode())
Reserved.set(Mips::S0); Reserved.set(Mips::S0);
else { else {
@ -256,8 +257,9 @@ eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj,
unsigned MipsRegisterInfo:: unsigned MipsRegisterInfo::
getFrameRegister(const MachineFunction &MF) const { getFrameRegister(const MachineFunction &MF) const {
const TargetFrameLowering *TFI = MF.getSubtarget().getFrameLowering(); const TargetFrameLowering *TFI = Subtarget.getFrameLowering();
bool IsN64 = Subtarget.isABI_N64(); bool IsN64 =
static_cast<const MipsTargetMachine &>(MF.getTarget()).getABI().IsN64();
if (Subtarget.inMips16Mode()) if (Subtarget.inMips16Mode())
return TFI->hasFP(MF) ? Mips::S0 : Mips::SP; return TFI->hasFP(MF) ? Mips::S0 : Mips::SP;

View File

@ -71,11 +71,17 @@ private:
MachineFunction &MF; MachineFunction &MF;
MachineRegisterInfo &MRI; MachineRegisterInfo &MRI;
const MipsSubtarget &Subtarget;
const MipsSEInstrInfo &TII;
const MipsRegisterInfo &RegInfo;
}; };
} }
ExpandPseudo::ExpandPseudo(MachineFunction &MF_) ExpandPseudo::ExpandPseudo(MachineFunction &MF_)
: MF(MF_), MRI(MF.getRegInfo()) {} : MF(MF_), MRI(MF.getRegInfo()),
Subtarget(static_cast<const MipsSubtarget &>(MF.getSubtarget())),
TII(*static_cast<const MipsSEInstrInfo *>(Subtarget.getInstrInfo())),
RegInfo(*Subtarget.getRegisterInfo()) {}
bool ExpandPseudo::expand() { bool ExpandPseudo::expand() {
bool Expanded = false; bool Expanded = false;
@ -146,11 +152,6 @@ void ExpandPseudo::expandLoadCCond(MachineBasicBlock &MBB, Iter I) {
assert(I->getOperand(0).isReg() && I->getOperand(1).isFI()); assert(I->getOperand(0).isReg() && I->getOperand(1).isFI());
const MipsSEInstrInfo &TII =
*static_cast<const MipsSEInstrInfo *>(MF.getSubtarget().getInstrInfo());
const MipsRegisterInfo &RegInfo = *static_cast<const MipsRegisterInfo *>(
MF.getSubtarget().getRegisterInfo());
const TargetRegisterClass *RC = RegInfo.intRegClass(4); const TargetRegisterClass *RC = RegInfo.intRegClass(4);
unsigned VR = MRI.createVirtualRegister(RC); unsigned VR = MRI.createVirtualRegister(RC);
unsigned Dst = I->getOperand(0).getReg(), FI = I->getOperand(1).getIndex(); unsigned Dst = I->getOperand(0).getReg(), FI = I->getOperand(1).getIndex();
@ -166,11 +167,6 @@ void ExpandPseudo::expandStoreCCond(MachineBasicBlock &MBB, Iter I) {
assert(I->getOperand(0).isReg() && I->getOperand(1).isFI()); assert(I->getOperand(0).isReg() && I->getOperand(1).isFI());
const MipsSEInstrInfo &TII =
*static_cast<const MipsSEInstrInfo *>(MF.getSubtarget().getInstrInfo());
const MipsRegisterInfo &RegInfo = *static_cast<const MipsRegisterInfo *>(
MF.getSubtarget().getRegisterInfo());
const TargetRegisterClass *RC = RegInfo.intRegClass(4); const TargetRegisterClass *RC = RegInfo.intRegClass(4);
unsigned VR = MRI.createVirtualRegister(RC); unsigned VR = MRI.createVirtualRegister(RC);
unsigned Src = I->getOperand(0).getReg(), FI = I->getOperand(1).getIndex(); unsigned Src = I->getOperand(0).getReg(), FI = I->getOperand(1).getIndex();
@ -189,11 +185,6 @@ void ExpandPseudo::expandLoadACC(MachineBasicBlock &MBB, Iter I,
assert(I->getOperand(0).isReg() && I->getOperand(1).isFI()); assert(I->getOperand(0).isReg() && I->getOperand(1).isFI());
const MipsSEInstrInfo &TII =
*static_cast<const MipsSEInstrInfo *>(MF.getSubtarget().getInstrInfo());
const MipsRegisterInfo &RegInfo = *static_cast<const MipsRegisterInfo *>(
MF.getSubtarget().getRegisterInfo());
const TargetRegisterClass *RC = RegInfo.intRegClass(RegSize); const TargetRegisterClass *RC = RegInfo.intRegClass(RegSize);
unsigned VR0 = MRI.createVirtualRegister(RC); unsigned VR0 = MRI.createVirtualRegister(RC);
unsigned VR1 = MRI.createVirtualRegister(RC); unsigned VR1 = MRI.createVirtualRegister(RC);
@ -219,11 +210,6 @@ void ExpandPseudo::expandStoreACC(MachineBasicBlock &MBB, Iter I,
assert(I->getOperand(0).isReg() && I->getOperand(1).isFI()); assert(I->getOperand(0).isReg() && I->getOperand(1).isFI());
const MipsSEInstrInfo &TII =
*static_cast<const MipsSEInstrInfo *>(MF.getSubtarget().getInstrInfo());
const MipsRegisterInfo &RegInfo = *static_cast<const MipsRegisterInfo *>(
MF.getSubtarget().getRegisterInfo());
const TargetRegisterClass *RC = RegInfo.intRegClass(RegSize); const TargetRegisterClass *RC = RegInfo.intRegClass(RegSize);
unsigned VR0 = MRI.createVirtualRegister(RC); unsigned VR0 = MRI.createVirtualRegister(RC);
unsigned VR1 = MRI.createVirtualRegister(RC); unsigned VR1 = MRI.createVirtualRegister(RC);
@ -254,11 +240,6 @@ bool ExpandPseudo::expandCopyACC(MachineBasicBlock &MBB, Iter I,
// mfhi $vr1, src // mfhi $vr1, src
// copy dst_hi, $vr1 // copy dst_hi, $vr1
const MipsSEInstrInfo &TII =
*static_cast<const MipsSEInstrInfo *>(MF.getSubtarget().getInstrInfo());
const MipsRegisterInfo &RegInfo = *static_cast<const MipsRegisterInfo *>(
MF.getSubtarget().getRegisterInfo());
unsigned Dst = I->getOperand(0).getReg(), Src = I->getOperand(1).getReg(); unsigned Dst = I->getOperand(0).getReg(), Src = I->getOperand(1).getReg();
unsigned VRegSize = RegInfo.getMinimalPhysRegClass(Dst)->getSize() / 2; unsigned VRegSize = RegInfo.getMinimalPhysRegClass(Dst)->getSize() / 2;
const TargetRegisterClass *RC = RegInfo.intRegClass(VRegSize); const TargetRegisterClass *RC = RegInfo.intRegClass(VRegSize);
@ -298,16 +279,8 @@ bool ExpandPseudo::expandBuildPairF64(MachineBasicBlock &MBB,
// register). Unfortunately, we have to make this decision before register // register). Unfortunately, we have to make this decision before register
// allocation so for now we use a spill/reload sequence for all // allocation so for now we use a spill/reload sequence for all
// double-precision values in regardless of being an odd/even register. // double-precision values in regardless of being an odd/even register.
const TargetMachine &TM = MF.getTarget();
const MipsSubtarget &Subtarget = TM.getSubtarget<MipsSubtarget>();
if ((Subtarget.isABI_FPXX() && !Subtarget.hasMTHC1()) || if ((Subtarget.isABI_FPXX() && !Subtarget.hasMTHC1()) ||
(FP64 && !Subtarget.useOddSPReg())) { (FP64 && !Subtarget.useOddSPReg())) {
const MipsSEInstrInfo &TII = *static_cast<const MipsSEInstrInfo *>(
TM.getSubtargetImpl()->getInstrInfo());
const MipsRegisterInfo &TRI = *static_cast<const MipsRegisterInfo *>(
TM.getSubtargetImpl()->getRegisterInfo());
unsigned DstReg = I->getOperand(0).getReg(); unsigned DstReg = I->getOperand(0).getReg();
unsigned LoReg = I->getOperand(1).getReg(); unsigned LoReg = I->getOperand(1).getReg();
unsigned HiReg = I->getOperand(2).getReg(); unsigned HiReg = I->getOperand(2).getReg();
@ -327,11 +300,11 @@ bool ExpandPseudo::expandBuildPairF64(MachineBasicBlock &MBB,
int FI = MF.getInfo<MipsFunctionInfo>()->getMoveF64ViaSpillFI(RC2); int FI = MF.getInfo<MipsFunctionInfo>()->getMoveF64ViaSpillFI(RC2);
if (!Subtarget.isLittle()) if (!Subtarget.isLittle())
std::swap(LoReg, HiReg); std::swap(LoReg, HiReg);
TII.storeRegToStack(MBB, I, LoReg, I->getOperand(1).isKill(), FI, RC, &TRI, TII.storeRegToStack(MBB, I, LoReg, I->getOperand(1).isKill(), FI, RC,
0); &RegInfo, 0);
TII.storeRegToStack(MBB, I, HiReg, I->getOperand(2).isKill(), FI, RC, &TRI, TII.storeRegToStack(MBB, I, HiReg, I->getOperand(2).isKill(), FI, RC,
4); &RegInfo, 4);
TII.loadRegFromStack(MBB, I, DstReg, FI, RC2, &TRI, 0); TII.loadRegFromStack(MBB, I, DstReg, FI, RC2, &RegInfo, 0);
return true; return true;
} }
@ -359,15 +332,8 @@ bool ExpandPseudo::expandExtractElementF64(MachineBasicBlock &MBB,
// allocation so for now we use a spill/reload sequence for all // allocation so for now we use a spill/reload sequence for all
// double-precision values in regardless of being an odd/even register. // double-precision values in regardless of being an odd/even register.
const TargetMachine &TM = MF.getTarget();
const MipsSubtarget &Subtarget = TM.getSubtarget<MipsSubtarget>();
if ((Subtarget.isABI_FPXX() && !Subtarget.hasMTHC1()) || if ((Subtarget.isABI_FPXX() && !Subtarget.hasMTHC1()) ||
(FP64 && !Subtarget.useOddSPReg())) { (FP64 && !Subtarget.useOddSPReg())) {
const MipsSEInstrInfo &TII = *static_cast<const MipsSEInstrInfo *>(
TM.getSubtargetImpl()->getInstrInfo());
const MipsRegisterInfo &TRI = *static_cast<const MipsRegisterInfo *>(
TM.getSubtargetImpl()->getRegisterInfo());
unsigned DstReg = I->getOperand(0).getReg(); unsigned DstReg = I->getOperand(0).getReg();
unsigned SrcReg = I->getOperand(1).getReg(); unsigned SrcReg = I->getOperand(1).getReg();
unsigned N = I->getOperand(2).getImm(); unsigned N = I->getOperand(2).getImm();
@ -386,9 +352,9 @@ bool ExpandPseudo::expandExtractElementF64(MachineBasicBlock &MBB,
// We re-use the same spill slot each time so that the stack frame doesn't // We re-use the same spill slot each time so that the stack frame doesn't
// grow too much in functions with a large number of moves. // grow too much in functions with a large number of moves.
int FI = MF.getInfo<MipsFunctionInfo>()->getMoveF64ViaSpillFI(RC); int FI = MF.getInfo<MipsFunctionInfo>()->getMoveF64ViaSpillFI(RC);
TII.storeRegToStack(MBB, I, SrcReg, I->getOperand(1).isKill(), FI, RC, &TRI, TII.storeRegToStack(MBB, I, SrcReg, I->getOperand(1).isKill(), FI, RC,
0); &RegInfo, 0);
TII.loadRegFromStack(MBB, I, DstReg, FI, RC2, &TRI, Offset); TII.loadRegFromStack(MBB, I, DstReg, FI, RC2, &RegInfo, Offset);
return true; return true;
} }
@ -415,9 +381,9 @@ void MipsSEFrameLowering::emitPrologue(MachineFunction &MF) const {
MipsFunctionInfo *MipsFI = MF.getInfo<MipsFunctionInfo>(); MipsFunctionInfo *MipsFI = MF.getInfo<MipsFunctionInfo>();
const MipsSEInstrInfo &TII = const MipsSEInstrInfo &TII =
*static_cast<const MipsSEInstrInfo *>(MF.getSubtarget().getInstrInfo()); *static_cast<const MipsSEInstrInfo *>(STI.getInstrInfo());
const MipsRegisterInfo &RegInfo = *static_cast<const MipsRegisterInfo *>( const MipsRegisterInfo &RegInfo =
MF.getSubtarget().getRegisterInfo()); *static_cast<const MipsRegisterInfo *>(STI.getRegisterInfo());
MachineBasicBlock::iterator MBBI = MBB.begin(); MachineBasicBlock::iterator MBBI = MBB.begin();
DebugLoc dl = MBBI != MBB.end() ? MBBI->getDebugLoc() : DebugLoc(); DebugLoc dl = MBBI != MBB.end() ? MBBI->getDebugLoc() : DebugLoc();
@ -550,9 +516,9 @@ void MipsSEFrameLowering::emitEpilogue(MachineFunction &MF,
MipsFunctionInfo *MipsFI = MF.getInfo<MipsFunctionInfo>(); MipsFunctionInfo *MipsFI = MF.getInfo<MipsFunctionInfo>();
const MipsSEInstrInfo &TII = const MipsSEInstrInfo &TII =
*static_cast<const MipsSEInstrInfo *>(MF.getSubtarget().getInstrInfo()); *static_cast<const MipsSEInstrInfo *>(STI.getInstrInfo());
const MipsRegisterInfo &RegInfo = *static_cast<const MipsRegisterInfo *>( const MipsRegisterInfo &RegInfo =
MF.getSubtarget().getRegisterInfo()); *static_cast<const MipsRegisterInfo *>(STI.getRegisterInfo());
DebugLoc dl = MBBI->getDebugLoc(); DebugLoc dl = MBBI->getDebugLoc();
unsigned SP = STI.isABI_N64() ? Mips::SP_64 : Mips::SP; unsigned SP = STI.isABI_N64() ? Mips::SP_64 : Mips::SP;
@ -605,7 +571,7 @@ spillCalleeSavedRegisters(MachineBasicBlock &MBB,
const TargetRegisterInfo *TRI) const { const TargetRegisterInfo *TRI) const {
MachineFunction *MF = MBB.getParent(); MachineFunction *MF = MBB.getParent();
MachineBasicBlock *EntryBlock = MF->begin(); MachineBasicBlock *EntryBlock = MF->begin();
const TargetInstrInfo &TII = *MF->getSubtarget().getInstrInfo(); const TargetInstrInfo &TII = *STI.getInstrInfo();
for (unsigned i = 0, e = CSI.size(); i != e; ++i) { for (unsigned i = 0, e = CSI.size(); i != e; ++i) {
// Add the callee-saved register as live-in. Do not add if the register is // Add the callee-saved register as live-in. Do not add if the register is
@ -646,7 +612,7 @@ void MipsSEFrameLowering::
eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
MachineBasicBlock::iterator I) const { MachineBasicBlock::iterator I) const {
const MipsSEInstrInfo &TII = const MipsSEInstrInfo &TII =
*static_cast<const MipsSEInstrInfo *>(MF.getSubtarget().getInstrInfo()); *static_cast<const MipsSEInstrInfo *>(STI.getInstrInfo());
if (!hasReservedCallFrame(MF)) { if (!hasReservedCallFrame(MF)) {
int64_t Amount = I->getOperand(0).getImm(); int64_t Amount = I->getOperand(0).getImm();

View File

@ -37,7 +37,7 @@ using namespace llvm;
#define DEBUG_TYPE "mips-isel" #define DEBUG_TYPE "mips-isel"
bool MipsSEDAGToDAGISel::runOnMachineFunction(MachineFunction &MF) { bool MipsSEDAGToDAGISel::runOnMachineFunction(MachineFunction &MF) {
Subtarget = &TM.getSubtarget<MipsSubtarget>(); Subtarget = &static_cast<const MipsSubtarget &>(MF.getSubtarget());
if (Subtarget->inMips16Mode()) if (Subtarget->inMips16Mode())
return false; return false;
return MipsDAGToDAGISel::runOnMachineFunction(MF); return MipsDAGToDAGISel::runOnMachineFunction(MF);
@ -130,7 +130,7 @@ void MipsSEDAGToDAGISel::initGlobalBaseReg(MachineFunction &MF) {
MachineBasicBlock &MBB = MF.front(); MachineBasicBlock &MBB = MF.front();
MachineBasicBlock::iterator I = MBB.begin(); MachineBasicBlock::iterator I = MBB.begin();
MachineRegisterInfo &RegInfo = MF.getRegInfo(); MachineRegisterInfo &RegInfo = MF.getRegInfo();
const TargetInstrInfo &TII = *MF.getSubtarget().getInstrInfo(); const TargetInstrInfo &TII = *Subtarget->getInstrInfo();
DebugLoc DL = I != MBB.end() ? I->getDebugLoc() : DebugLoc(); DebugLoc DL = I != MBB.end() ? I->getDebugLoc() : DebugLoc();
unsigned V0, V1, GlobalBaseReg = MipsFI->getGlobalBaseReg(); unsigned V0, V1, GlobalBaseReg = MipsFI->getGlobalBaseReg();
const TargetRegisterClass *RC; const TargetRegisterClass *RC;

View File

@ -2747,8 +2747,7 @@ emitBPOSGE32(MachineInstr *MI, MachineBasicBlock *BB) const{
// $vr0 = phi($vr2, $fbb, $vr1, $tbb) // $vr0 = phi($vr2, $fbb, $vr1, $tbb)
MachineRegisterInfo &RegInfo = BB->getParent()->getRegInfo(); MachineRegisterInfo &RegInfo = BB->getParent()->getRegInfo();
const TargetInstrInfo *TII = const TargetInstrInfo *TII = Subtarget.getInstrInfo();
getTargetMachine().getSubtargetImpl()->getInstrInfo();
const TargetRegisterClass *RC = &Mips::GPR32RegClass; const TargetRegisterClass *RC = &Mips::GPR32RegClass;
DebugLoc DL = MI->getDebugLoc(); DebugLoc DL = MI->getDebugLoc();
const BasicBlock *LLVM_BB = BB->getBasicBlock(); const BasicBlock *LLVM_BB = BB->getBasicBlock();
@ -2813,8 +2812,7 @@ emitMSACBranchPseudo(MachineInstr *MI, MachineBasicBlock *BB,
// $rd = phi($rd1, $fbb, $rd2, $tbb) // $rd = phi($rd1, $fbb, $rd2, $tbb)
MachineRegisterInfo &RegInfo = BB->getParent()->getRegInfo(); MachineRegisterInfo &RegInfo = BB->getParent()->getRegInfo();
const TargetInstrInfo *TII = const TargetInstrInfo *TII = Subtarget.getInstrInfo();
getTargetMachine().getSubtargetImpl()->getInstrInfo();
const TargetRegisterClass *RC = &Mips::GPR32RegClass; const TargetRegisterClass *RC = &Mips::GPR32RegClass;
DebugLoc DL = MI->getDebugLoc(); DebugLoc DL = MI->getDebugLoc();
const BasicBlock *LLVM_BB = BB->getBasicBlock(); const BasicBlock *LLVM_BB = BB->getBasicBlock();
@ -2875,8 +2873,7 @@ emitMSACBranchPseudo(MachineInstr *MI, MachineBasicBlock *BB,
// for lane 1 because it would require FR=0 mode which isn't supported by MSA. // for lane 1 because it would require FR=0 mode which isn't supported by MSA.
MachineBasicBlock * MipsSETargetLowering:: MachineBasicBlock * MipsSETargetLowering::
emitCOPY_FW(MachineInstr *MI, MachineBasicBlock *BB) const{ emitCOPY_FW(MachineInstr *MI, MachineBasicBlock *BB) const{
const TargetInstrInfo *TII = const TargetInstrInfo *TII = Subtarget.getInstrInfo();
getTargetMachine().getSubtargetImpl()->getInstrInfo();
MachineRegisterInfo &RegInfo = BB->getParent()->getRegInfo(); MachineRegisterInfo &RegInfo = BB->getParent()->getRegInfo();
DebugLoc DL = MI->getDebugLoc(); DebugLoc DL = MI->getDebugLoc();
unsigned Fd = MI->getOperand(0).getReg(); unsigned Fd = MI->getOperand(0).getReg();
@ -2910,8 +2907,7 @@ MachineBasicBlock * MipsSETargetLowering::
emitCOPY_FD(MachineInstr *MI, MachineBasicBlock *BB) const{ emitCOPY_FD(MachineInstr *MI, MachineBasicBlock *BB) const{
assert(Subtarget.isFP64bit()); assert(Subtarget.isFP64bit());
const TargetInstrInfo *TII = const TargetInstrInfo *TII = Subtarget.getInstrInfo();
getTargetMachine().getSubtargetImpl()->getInstrInfo();
MachineRegisterInfo &RegInfo = BB->getParent()->getRegInfo(); MachineRegisterInfo &RegInfo = BB->getParent()->getRegInfo();
unsigned Fd = MI->getOperand(0).getReg(); unsigned Fd = MI->getOperand(0).getReg();
unsigned Ws = MI->getOperand(1).getReg(); unsigned Ws = MI->getOperand(1).getReg();
@ -2940,8 +2936,7 @@ emitCOPY_FD(MachineInstr *MI, MachineBasicBlock *BB) const{
MachineBasicBlock * MachineBasicBlock *
MipsSETargetLowering::emitINSERT_FW(MachineInstr *MI, MipsSETargetLowering::emitINSERT_FW(MachineInstr *MI,
MachineBasicBlock *BB) const { MachineBasicBlock *BB) const {
const TargetInstrInfo *TII = const TargetInstrInfo *TII = Subtarget.getInstrInfo();
getTargetMachine().getSubtargetImpl()->getInstrInfo();
MachineRegisterInfo &RegInfo = BB->getParent()->getRegInfo(); MachineRegisterInfo &RegInfo = BB->getParent()->getRegInfo();
DebugLoc DL = MI->getDebugLoc(); DebugLoc DL = MI->getDebugLoc();
unsigned Wd = MI->getOperand(0).getReg(); unsigned Wd = MI->getOperand(0).getReg();
@ -2975,8 +2970,7 @@ MipsSETargetLowering::emitINSERT_FD(MachineInstr *MI,
MachineBasicBlock *BB) const { MachineBasicBlock *BB) const {
assert(Subtarget.isFP64bit()); assert(Subtarget.isFP64bit());
const TargetInstrInfo *TII = const TargetInstrInfo *TII = Subtarget.getInstrInfo();
getTargetMachine().getSubtargetImpl()->getInstrInfo();
MachineRegisterInfo &RegInfo = BB->getParent()->getRegInfo(); MachineRegisterInfo &RegInfo = BB->getParent()->getRegInfo();
DebugLoc DL = MI->getDebugLoc(); DebugLoc DL = MI->getDebugLoc();
unsigned Wd = MI->getOperand(0).getReg(); unsigned Wd = MI->getOperand(0).getReg();
@ -3024,8 +3018,7 @@ MipsSETargetLowering::emitINSERT_DF_VIDX(MachineInstr *MI,
MachineBasicBlock *BB, MachineBasicBlock *BB,
unsigned EltSizeInBytes, unsigned EltSizeInBytes,
bool IsFP) const { bool IsFP) const {
const TargetInstrInfo *TII = const TargetInstrInfo *TII = Subtarget.getInstrInfo();
getTargetMachine().getSubtargetImpl()->getInstrInfo();
MachineRegisterInfo &RegInfo = BB->getParent()->getRegInfo(); MachineRegisterInfo &RegInfo = BB->getParent()->getRegInfo();
DebugLoc DL = MI->getDebugLoc(); DebugLoc DL = MI->getDebugLoc();
unsigned Wd = MI->getOperand(0).getReg(); unsigned Wd = MI->getOperand(0).getReg();
@ -3135,8 +3128,7 @@ MipsSETargetLowering::emitINSERT_DF_VIDX(MachineInstr *MI,
MachineBasicBlock * MachineBasicBlock *
MipsSETargetLowering::emitFILL_FW(MachineInstr *MI, MipsSETargetLowering::emitFILL_FW(MachineInstr *MI,
MachineBasicBlock *BB) const { MachineBasicBlock *BB) const {
const TargetInstrInfo *TII = const TargetInstrInfo *TII = Subtarget.getInstrInfo();
getTargetMachine().getSubtargetImpl()->getInstrInfo();
MachineRegisterInfo &RegInfo = BB->getParent()->getRegInfo(); MachineRegisterInfo &RegInfo = BB->getParent()->getRegInfo();
DebugLoc DL = MI->getDebugLoc(); DebugLoc DL = MI->getDebugLoc();
unsigned Wd = MI->getOperand(0).getReg(); unsigned Wd = MI->getOperand(0).getReg();
@ -3167,8 +3159,7 @@ MipsSETargetLowering::emitFILL_FD(MachineInstr *MI,
MachineBasicBlock *BB) const { MachineBasicBlock *BB) const {
assert(Subtarget.isFP64bit()); assert(Subtarget.isFP64bit());
const TargetInstrInfo *TII = const TargetInstrInfo *TII = Subtarget.getInstrInfo();
getTargetMachine().getSubtargetImpl()->getInstrInfo();
MachineRegisterInfo &RegInfo = BB->getParent()->getRegInfo(); MachineRegisterInfo &RegInfo = BB->getParent()->getRegInfo();
DebugLoc DL = MI->getDebugLoc(); DebugLoc DL = MI->getDebugLoc();
unsigned Wd = MI->getOperand(0).getReg(); unsigned Wd = MI->getOperand(0).getReg();
@ -3196,8 +3187,7 @@ MipsSETargetLowering::emitFILL_FD(MachineInstr *MI,
MachineBasicBlock * MachineBasicBlock *
MipsSETargetLowering::emitFEXP2_W_1(MachineInstr *MI, MipsSETargetLowering::emitFEXP2_W_1(MachineInstr *MI,
MachineBasicBlock *BB) const { MachineBasicBlock *BB) const {
const TargetInstrInfo *TII = const TargetInstrInfo *TII = Subtarget.getInstrInfo();
getTargetMachine().getSubtargetImpl()->getInstrInfo();
MachineRegisterInfo &RegInfo = BB->getParent()->getRegInfo(); MachineRegisterInfo &RegInfo = BB->getParent()->getRegInfo();
const TargetRegisterClass *RC = &Mips::MSA128WRegClass; const TargetRegisterClass *RC = &Mips::MSA128WRegClass;
unsigned Ws1 = RegInfo.createVirtualRegister(RC); unsigned Ws1 = RegInfo.createVirtualRegister(RC);
@ -3226,8 +3216,7 @@ MipsSETargetLowering::emitFEXP2_W_1(MachineInstr *MI,
MachineBasicBlock * MachineBasicBlock *
MipsSETargetLowering::emitFEXP2_D_1(MachineInstr *MI, MipsSETargetLowering::emitFEXP2_D_1(MachineInstr *MI,
MachineBasicBlock *BB) const { MachineBasicBlock *BB) const {
const TargetInstrInfo *TII = const TargetInstrInfo *TII = Subtarget.getInstrInfo();
getTargetMachine().getSubtargetImpl()->getInstrInfo();
MachineRegisterInfo &RegInfo = BB->getParent()->getRegInfo(); MachineRegisterInfo &RegInfo = BB->getParent()->getRegInfo();
const TargetRegisterClass *RC = &Mips::MSA128DRegClass; const TargetRegisterClass *RC = &Mips::MSA128DRegClass;
unsigned Ws1 = RegInfo.createVirtualRegister(RC); unsigned Ws1 = RegInfo.createVirtualRegister(RC);