1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

Reuse a bunch of cached subtargets and remove getSubtarget calls

without a Function argument.

llvm-svn: 227644
This commit is contained in:
Eric Christopher 2015-01-30 23:46:43 +00:00
parent a36bf06411
commit d7f5849392
8 changed files with 37 additions and 51 deletions

View File

@ -45,10 +45,7 @@ namespace {
const SparcSubtarget *Subtarget; const SparcSubtarget *Subtarget;
static char ID; static char ID;
Filler(TargetMachine &tm) Filler(TargetMachine &tm) : MachineFunctionPass(ID), TM(tm) {}
: MachineFunctionPass(ID), TM(tm),
Subtarget(&TM.getSubtarget<SparcSubtarget>()) {
}
const char *getPassName() const override { const char *getPassName() const override {
return "SPARC Delay Slot Filler"; return "SPARC Delay Slot Filler";
@ -57,6 +54,7 @@ namespace {
bool runOnMachineBasicBlock(MachineBasicBlock &MBB); bool runOnMachineBasicBlock(MachineBasicBlock &MBB);
bool runOnMachineFunction(MachineFunction &F) override { bool runOnMachineFunction(MachineFunction &F) override {
bool Changed = false; bool Changed = false;
Subtarget = &F.getSubtarget<SparcSubtarget>();
// This pass invalidates liveness information when it reorders // This pass invalidates liveness information when it reorders
// instructions to fill delay slot. // instructions to fill delay slot.
@ -109,8 +107,8 @@ FunctionPass *llvm::createSparcDelaySlotFillerPass(TargetMachine &tm) {
/// ///
bool Filler::runOnMachineBasicBlock(MachineBasicBlock &MBB) { bool Filler::runOnMachineBasicBlock(MachineBasicBlock &MBB) {
bool Changed = false; bool Changed = false;
Subtarget = &MBB.getParent()->getSubtarget<SparcSubtarget>();
const TargetInstrInfo *TII = TM.getSubtargetImpl()->getInstrInfo(); const TargetInstrInfo *TII = Subtarget->getInstrInfo();
for (MachineBasicBlock::iterator I = MBB.begin(); I != MBB.end(); ) { for (MachineBasicBlock::iterator I = MBB.begin(); I != MBB.end(); ) {
MachineBasicBlock::iterator MI = I; MachineBasicBlock::iterator MI = I;
@ -187,7 +185,7 @@ Filler::findDelayInstr(MachineBasicBlock &MBB,
if (J->getOpcode() == SP::RESTORErr if (J->getOpcode() == SP::RESTORErr
|| J->getOpcode() == SP::RESTOREri) { || J->getOpcode() == SP::RESTOREri) {
// change retl to ret. // change retl to ret.
slot->setDesc(TM.getSubtargetImpl()->getInstrInfo()->get(SP::RET)); slot->setDesc(Subtarget->getInstrInfo()->get(SP::RET));
return J; return J;
} }
} }
@ -329,8 +327,7 @@ void Filler::insertDefsUses(MachineBasicBlock::iterator MI,
bool Filler::IsRegInSet(SmallSet<unsigned, 32>& RegSet, unsigned Reg) bool Filler::IsRegInSet(SmallSet<unsigned, 32>& RegSet, unsigned Reg)
{ {
// Check Reg and all aliased Registers. // Check Reg and all aliased Registers.
for (MCRegAliasIterator AI(Reg, TM.getSubtargetImpl()->getRegisterInfo(), for (MCRegAliasIterator AI(Reg, Subtarget->getRegisterInfo(), true);
true);
AI.isValid(); ++AI) AI.isValid(); ++AI)
if (RegSet.count(*AI)) if (RegSet.count(*AI))
return true; return true;
@ -483,7 +480,7 @@ bool Filler::tryCombineRestoreWithPrevInst(MachineBasicBlock &MBB,
if (PrevInst->isBundledWithSucc()) if (PrevInst->isBundledWithSucc())
return false; return false;
const TargetInstrInfo *TII = TM.getSubtargetImpl()->getInstrInfo(); const TargetInstrInfo *TII = Subtarget->getInstrInfo();
switch (PrevInst->getOpcode()) { switch (PrevInst->getOpcode()) {
default: break; default: break;

View File

@ -278,7 +278,7 @@ void SparcAsmPrinter::EmitInstruction(const MachineInstr *MI)
} }
void SparcAsmPrinter::EmitFunctionBodyStart() { void SparcAsmPrinter::EmitFunctionBodyStart() {
if (!TM.getSubtarget<SparcSubtarget>().is64Bit()) if (!MF->getSubtarget<SparcSubtarget>().is64Bit())
return; return;
const MachineRegisterInfo &MRI = MF->getRegInfo(); const MachineRegisterInfo &MRI = MF->getRegInfo();

View File

@ -103,9 +103,7 @@ void SparcFrameLowering::emitPrologue(MachineFunction &MF) const {
SAVEri = SP::ADDri; SAVEri = SP::ADDri;
SAVErr = SP::ADDrr; SAVErr = SP::ADDrr;
} }
NumBytes = NumBytes = -MF.getSubtarget<SparcSubtarget>().getAdjustedFrameSize(NumBytes);
-MF.getTarget().getSubtarget<SparcSubtarget>().getAdjustedFrameSize(
NumBytes);
emitSPAdjustment(MF, MBB, MBBI, NumBytes, SAVErr, SAVEri); emitSPAdjustment(MF, MBB, MBBI, NumBytes, SAVErr, SAVEri);
MachineModuleInfo &MMI = MF.getMMI(); MachineModuleInfo &MMI = MF.getMMI();
@ -168,8 +166,7 @@ void SparcFrameLowering::emitEpilogue(MachineFunction &MF,
if (NumBytes == 0) if (NumBytes == 0)
return; return;
NumBytes = MF.getTarget().getSubtarget<SparcSubtarget>().getAdjustedFrameSize( NumBytes = MF.getSubtarget<SparcSubtarget>().getAdjustedFrameSize(NumBytes);
NumBytes);
emitSPAdjustment(MF, MBB, MBBI, NumBytes, SP::ADDrr, SP::ADDri); emitSPAdjustment(MF, MBB, MBBI, NumBytes, SP::ADDrr, SP::ADDri);
} }

View File

@ -32,13 +32,13 @@ namespace {
class SparcDAGToDAGISel : public SelectionDAGISel { class SparcDAGToDAGISel : public SelectionDAGISel {
/// Subtarget - Keep a pointer to the Sparc Subtarget around so that we can /// Subtarget - Keep a pointer to the Sparc Subtarget 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 SparcSubtarget &Subtarget; const SparcSubtarget *Subtarget;
SparcTargetMachine &TM;
public: public:
explicit SparcDAGToDAGISel(SparcTargetMachine &tm) explicit SparcDAGToDAGISel(SparcTargetMachine &tm) : SelectionDAGISel(tm) {}
: SelectionDAGISel(tm),
Subtarget(tm.getSubtarget<SparcSubtarget>()), bool runOnMachineFunction(MachineFunction &MF) override {
TM(tm) { Subtarget = &MF.getSubtarget<SparcSubtarget>();
return SelectionDAGISel::runOnMachineFunction(MF);
} }
SDNode *Select(SDNode *N) override; SDNode *Select(SDNode *N) override;
@ -66,8 +66,7 @@ private:
} // end anonymous namespace } // end anonymous namespace
SDNode* SparcDAGToDAGISel::getGlobalBaseReg() { SDNode* SparcDAGToDAGISel::getGlobalBaseReg() {
unsigned GlobalBaseReg = unsigned GlobalBaseReg = Subtarget->getInstrInfo()->getGlobalBaseReg(MF);
TM.getSubtargetImpl()->getInstrInfo()->getGlobalBaseReg(MF);
return CurDAG->getRegister(GlobalBaseReg, TLI->getPointerTy()).getNode(); return CurDAG->getRegister(GlobalBaseReg, TLI->getPointerTy()).getNode();
} }

View File

@ -914,8 +914,7 @@ SparcTargetLowering::LowerCall_32(TargetLowering::CallLoweringInfo &CLI,
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 SparcRegisterInfo *TRI = const SparcRegisterInfo *TRI = Subtarget->getRegisterInfo();
getTargetMachine().getSubtarget<SparcSubtarget>().getRegisterInfo();
const uint32_t *Mask = ((hasReturnsTwice) const uint32_t *Mask = ((hasReturnsTwice)
? TRI->getRTCallPreservedMask(CallConv) ? TRI->getRTCallPreservedMask(CallConv)
: TRI->getCallPreservedMask(CallConv)); : TRI->getCallPreservedMask(CallConv));
@ -1227,8 +1226,7 @@ SparcTargetLowering::LowerCall_64(TargetLowering::CallLoweringInfo &CLI,
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 SparcRegisterInfo *TRI = const SparcRegisterInfo *TRI = Subtarget->getRegisterInfo();
getTargetMachine().getSubtarget<SparcSubtarget>().getRegisterInfo();
const uint32_t *Mask = const uint32_t *Mask =
((hasReturnsTwice) ? TRI->getRTCallPreservedMask(CLI.CallConv) ((hasReturnsTwice) ? TRI->getRTCallPreservedMask(CLI.CallConv)
: TRI->getCallPreservedMask(CLI.CallConv)); : TRI->getCallPreservedMask(CLI.CallConv));
@ -1365,10 +1363,9 @@ static SPCC::CondCodes FPCondCCodeToFCC(ISD::CondCode CC) {
} }
} }
SparcTargetLowering::SparcTargetLowering(TargetMachine &TM) SparcTargetLowering::SparcTargetLowering(TargetMachine &TM,
: TargetLowering(TM) { const SparcSubtarget &STI)
Subtarget = &TM.getSubtarget<SparcSubtarget>(); : TargetLowering(TM), Subtarget(&STI) {
// Set up the register classes. // Set up the register classes.
addRegisterClass(MVT::i32, &SP::IntRegsRegClass); addRegisterClass(MVT::i32, &SP::IntRegsRegClass);
addRegisterClass(MVT::f32, &SP::FPRegsRegClass); addRegisterClass(MVT::f32, &SP::FPRegsRegClass);
@ -1907,10 +1904,8 @@ SDValue SparcTargetLowering::LowerGlobalTLSAddress(SDValue Op,
Ops.push_back(Callee); Ops.push_back(Callee);
Ops.push_back(Symbol); Ops.push_back(Symbol);
Ops.push_back(DAG.getRegister(SP::O0, PtrVT)); Ops.push_back(DAG.getRegister(SP::O0, PtrVT));
const uint32_t *Mask = getTargetMachine() const uint32_t *Mask =
.getSubtargetImpl() Subtarget->getRegisterInfo()->getCallPreservedMask(CallingConv::C);
->getRegisterInfo()
->getCallPreservedMask(CallingConv::C);
assert(Mask && "Missing call preserved mask for calling convention"); assert(Mask && "Missing call preserved mask for calling convention");
Ops.push_back(DAG.getRegisterMask(Mask)); Ops.push_back(DAG.getRegisterMask(Mask));
Ops.push_back(InFlag); Ops.push_back(InFlag);
@ -2906,8 +2901,7 @@ MachineBasicBlock*
SparcTargetLowering::expandSelectCC(MachineInstr *MI, SparcTargetLowering::expandSelectCC(MachineInstr *MI,
MachineBasicBlock *BB, MachineBasicBlock *BB,
unsigned BROpcode) const { unsigned BROpcode) const {
const TargetInstrInfo &TII = const TargetInstrInfo &TII = *Subtarget->getInstrInfo();
*getTargetMachine().getSubtargetImpl()->getInstrInfo();
DebugLoc dl = MI->getDebugLoc(); DebugLoc dl = MI->getDebugLoc();
unsigned CC = (SPCC::CondCodes)MI->getOperand(3).getImm(); unsigned CC = (SPCC::CondCodes)MI->getOperand(3).getImm();
@ -2968,8 +2962,7 @@ SparcTargetLowering::expandAtomicRMW(MachineInstr *MI,
MachineBasicBlock *MBB, MachineBasicBlock *MBB,
unsigned Opcode, unsigned Opcode,
unsigned CondCode) const { unsigned CondCode) const {
const TargetInstrInfo &TII = const TargetInstrInfo &TII = *Subtarget->getInstrInfo();
*getTargetMachine().getSubtargetImpl()->getInstrInfo();
MachineRegisterInfo &MRI = MBB->getParent()->getRegInfo(); MachineRegisterInfo &MRI = MBB->getParent()->getRegInfo();
DebugLoc DL = MI->getDebugLoc(); DebugLoc DL = MI->getDebugLoc();

View File

@ -54,7 +54,7 @@ namespace llvm {
class SparcTargetLowering : public TargetLowering { class SparcTargetLowering : public TargetLowering {
const SparcSubtarget *Subtarget; const SparcSubtarget *Subtarget;
public: public:
SparcTargetLowering(TargetMachine &TM); SparcTargetLowering(TargetMachine &TM, const SparcSubtarget &STI);
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override; SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
/// computeKnownBitsForTargetNode - Determine which of the bits specified /// computeKnownBitsForTargetNode - Determine which of the bits specified

View File

@ -22,38 +22,38 @@ include "SparcInstrFormats.td"
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// True when generating 32-bit code. // True when generating 32-bit code.
def Is32Bit : Predicate<"!Subtarget.is64Bit()">; def Is32Bit : Predicate<"!Subtarget->is64Bit()">;
// True when generating 64-bit code. This also implies HasV9. // True when generating 64-bit code. This also implies HasV9.
def Is64Bit : Predicate<"Subtarget.is64Bit()">; def Is64Bit : Predicate<"Subtarget->is64Bit()">;
// HasV9 - This predicate is true when the target processor supports V9 // HasV9 - This predicate is true when the target processor supports V9
// instructions. Note that the machine may be running in 32-bit mode. // instructions. Note that the machine may be running in 32-bit mode.
def HasV9 : Predicate<"Subtarget.isV9()">, def HasV9 : Predicate<"Subtarget->isV9()">,
AssemblerPredicate<"FeatureV9">; AssemblerPredicate<"FeatureV9">;
// HasNoV9 - This predicate is true when the target doesn't have V9 // HasNoV9 - This predicate is true when the target doesn't have V9
// instructions. Use of this is just a hack for the isel not having proper // instructions. Use of this is just a hack for the isel not having proper
// costs for V8 instructions that are more expensive than their V9 ones. // costs for V8 instructions that are more expensive than their V9 ones.
def HasNoV9 : Predicate<"!Subtarget.isV9()">; def HasNoV9 : Predicate<"!Subtarget->isV9()">;
// HasVIS - This is true when the target processor has VIS extensions. // HasVIS - This is true when the target processor has VIS extensions.
def HasVIS : Predicate<"Subtarget.isVIS()">, def HasVIS : Predicate<"Subtarget->isVIS()">,
AssemblerPredicate<"FeatureVIS">; AssemblerPredicate<"FeatureVIS">;
def HasVIS2 : Predicate<"Subtarget.isVIS2()">, def HasVIS2 : Predicate<"Subtarget->isVIS2()">,
AssemblerPredicate<"FeatureVIS2">; AssemblerPredicate<"FeatureVIS2">;
def HasVIS3 : Predicate<"Subtarget.isVIS3()">, def HasVIS3 : Predicate<"Subtarget->isVIS3()">,
AssemblerPredicate<"FeatureVIS3">; AssemblerPredicate<"FeatureVIS3">;
// HasHardQuad - This is true when the target processor supports quad floating // HasHardQuad - This is true when the target processor supports quad floating
// point instructions. // point instructions.
def HasHardQuad : Predicate<"Subtarget.hasHardQuad()">; def HasHardQuad : Predicate<"Subtarget->hasHardQuad()">;
// UseDeprecatedInsts - This predicate is true when the target processor is a // UseDeprecatedInsts - This predicate is true when the target processor is a
// V8, or when it is V9 but the V8 deprecated instructions are efficient enough // V8, or when it is V9 but the V8 deprecated instructions are efficient enough
// to use when appropriate. In either of these cases, the instruction selector // to use when appropriate. In either of these cases, the instruction selector
// will pick deprecated instructions. // will pick deprecated instructions.
def UseDeprecatedInsts : Predicate<"Subtarget.useDeprecatedV8Instructions()">; def UseDeprecatedInsts : Predicate<"Subtarget->useDeprecatedV8Instructions()">;
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Instruction Pattern Stuff // Instruction Pattern Stuff

View File

@ -53,7 +53,7 @@ SparcSubtarget::SparcSubtarget(const std::string &TT, const std::string &CPU,
const std::string &FS, TargetMachine &TM, const std::string &FS, TargetMachine &TM,
bool is64Bit) bool is64Bit)
: SparcGenSubtargetInfo(TT, CPU, FS), Is64Bit(is64Bit), : SparcGenSubtargetInfo(TT, CPU, FS), Is64Bit(is64Bit),
InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM), InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
TSInfo(*TM.getDataLayout()), FrameLowering(*this) {} TSInfo(*TM.getDataLayout()), FrameLowering(*this) {}
int SparcSubtarget::getAdjustedFrameSize(int frameSize) const { int SparcSubtarget::getAdjustedFrameSize(int frameSize) const {