mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
Reuse a bunch of cached subtargets and remove getSubtarget calls
without a Function argument. llvm-svn: 227644
This commit is contained in:
parent
a36bf06411
commit
d7f5849392
@ -45,10 +45,7 @@ namespace {
|
||||
const SparcSubtarget *Subtarget;
|
||||
|
||||
static char ID;
|
||||
Filler(TargetMachine &tm)
|
||||
: MachineFunctionPass(ID), TM(tm),
|
||||
Subtarget(&TM.getSubtarget<SparcSubtarget>()) {
|
||||
}
|
||||
Filler(TargetMachine &tm) : MachineFunctionPass(ID), TM(tm) {}
|
||||
|
||||
const char *getPassName() const override {
|
||||
return "SPARC Delay Slot Filler";
|
||||
@ -57,6 +54,7 @@ namespace {
|
||||
bool runOnMachineBasicBlock(MachineBasicBlock &MBB);
|
||||
bool runOnMachineFunction(MachineFunction &F) override {
|
||||
bool Changed = false;
|
||||
Subtarget = &F.getSubtarget<SparcSubtarget>();
|
||||
|
||||
// This pass invalidates liveness information when it reorders
|
||||
// instructions to fill delay slot.
|
||||
@ -109,8 +107,8 @@ FunctionPass *llvm::createSparcDelaySlotFillerPass(TargetMachine &tm) {
|
||||
///
|
||||
bool Filler::runOnMachineBasicBlock(MachineBasicBlock &MBB) {
|
||||
bool Changed = false;
|
||||
|
||||
const TargetInstrInfo *TII = TM.getSubtargetImpl()->getInstrInfo();
|
||||
Subtarget = &MBB.getParent()->getSubtarget<SparcSubtarget>();
|
||||
const TargetInstrInfo *TII = Subtarget->getInstrInfo();
|
||||
|
||||
for (MachineBasicBlock::iterator I = MBB.begin(); I != MBB.end(); ) {
|
||||
MachineBasicBlock::iterator MI = I;
|
||||
@ -187,7 +185,7 @@ Filler::findDelayInstr(MachineBasicBlock &MBB,
|
||||
if (J->getOpcode() == SP::RESTORErr
|
||||
|| J->getOpcode() == SP::RESTOREri) {
|
||||
// change retl to ret.
|
||||
slot->setDesc(TM.getSubtargetImpl()->getInstrInfo()->get(SP::RET));
|
||||
slot->setDesc(Subtarget->getInstrInfo()->get(SP::RET));
|
||||
return J;
|
||||
}
|
||||
}
|
||||
@ -329,8 +327,7 @@ void Filler::insertDefsUses(MachineBasicBlock::iterator MI,
|
||||
bool Filler::IsRegInSet(SmallSet<unsigned, 32>& RegSet, unsigned Reg)
|
||||
{
|
||||
// Check Reg and all aliased Registers.
|
||||
for (MCRegAliasIterator AI(Reg, TM.getSubtargetImpl()->getRegisterInfo(),
|
||||
true);
|
||||
for (MCRegAliasIterator AI(Reg, Subtarget->getRegisterInfo(), true);
|
||||
AI.isValid(); ++AI)
|
||||
if (RegSet.count(*AI))
|
||||
return true;
|
||||
@ -483,7 +480,7 @@ bool Filler::tryCombineRestoreWithPrevInst(MachineBasicBlock &MBB,
|
||||
if (PrevInst->isBundledWithSucc())
|
||||
return false;
|
||||
|
||||
const TargetInstrInfo *TII = TM.getSubtargetImpl()->getInstrInfo();
|
||||
const TargetInstrInfo *TII = Subtarget->getInstrInfo();
|
||||
|
||||
switch (PrevInst->getOpcode()) {
|
||||
default: break;
|
||||
|
@ -278,7 +278,7 @@ void SparcAsmPrinter::EmitInstruction(const MachineInstr *MI)
|
||||
}
|
||||
|
||||
void SparcAsmPrinter::EmitFunctionBodyStart() {
|
||||
if (!TM.getSubtarget<SparcSubtarget>().is64Bit())
|
||||
if (!MF->getSubtarget<SparcSubtarget>().is64Bit())
|
||||
return;
|
||||
|
||||
const MachineRegisterInfo &MRI = MF->getRegInfo();
|
||||
|
@ -103,9 +103,7 @@ void SparcFrameLowering::emitPrologue(MachineFunction &MF) const {
|
||||
SAVEri = SP::ADDri;
|
||||
SAVErr = SP::ADDrr;
|
||||
}
|
||||
NumBytes =
|
||||
-MF.getTarget().getSubtarget<SparcSubtarget>().getAdjustedFrameSize(
|
||||
NumBytes);
|
||||
NumBytes = -MF.getSubtarget<SparcSubtarget>().getAdjustedFrameSize(NumBytes);
|
||||
emitSPAdjustment(MF, MBB, MBBI, NumBytes, SAVErr, SAVEri);
|
||||
|
||||
MachineModuleInfo &MMI = MF.getMMI();
|
||||
@ -168,8 +166,7 @@ void SparcFrameLowering::emitEpilogue(MachineFunction &MF,
|
||||
if (NumBytes == 0)
|
||||
return;
|
||||
|
||||
NumBytes = MF.getTarget().getSubtarget<SparcSubtarget>().getAdjustedFrameSize(
|
||||
NumBytes);
|
||||
NumBytes = MF.getSubtarget<SparcSubtarget>().getAdjustedFrameSize(NumBytes);
|
||||
emitSPAdjustment(MF, MBB, MBBI, NumBytes, SP::ADDrr, SP::ADDri);
|
||||
}
|
||||
|
||||
|
@ -32,13 +32,13 @@ namespace {
|
||||
class SparcDAGToDAGISel : public SelectionDAGISel {
|
||||
/// Subtarget - Keep a pointer to the Sparc Subtarget around so that we can
|
||||
/// make the right decision when generating code for different targets.
|
||||
const SparcSubtarget &Subtarget;
|
||||
SparcTargetMachine &TM;
|
||||
const SparcSubtarget *Subtarget;
|
||||
public:
|
||||
explicit SparcDAGToDAGISel(SparcTargetMachine &tm)
|
||||
: SelectionDAGISel(tm),
|
||||
Subtarget(tm.getSubtarget<SparcSubtarget>()),
|
||||
TM(tm) {
|
||||
explicit SparcDAGToDAGISel(SparcTargetMachine &tm) : SelectionDAGISel(tm) {}
|
||||
|
||||
bool runOnMachineFunction(MachineFunction &MF) override {
|
||||
Subtarget = &MF.getSubtarget<SparcSubtarget>();
|
||||
return SelectionDAGISel::runOnMachineFunction(MF);
|
||||
}
|
||||
|
||||
SDNode *Select(SDNode *N) override;
|
||||
@ -66,8 +66,7 @@ private:
|
||||
} // end anonymous namespace
|
||||
|
||||
SDNode* SparcDAGToDAGISel::getGlobalBaseReg() {
|
||||
unsigned GlobalBaseReg =
|
||||
TM.getSubtargetImpl()->getInstrInfo()->getGlobalBaseReg(MF);
|
||||
unsigned GlobalBaseReg = Subtarget->getInstrInfo()->getGlobalBaseReg(MF);
|
||||
return CurDAG->getRegister(GlobalBaseReg, TLI->getPointerTy()).getNode();
|
||||
}
|
||||
|
||||
|
@ -914,8 +914,7 @@ SparcTargetLowering::LowerCall_32(TargetLowering::CallLoweringInfo &CLI,
|
||||
RegsToPass[i].second.getValueType()));
|
||||
|
||||
// Add a register mask operand representing the call-preserved registers.
|
||||
const SparcRegisterInfo *TRI =
|
||||
getTargetMachine().getSubtarget<SparcSubtarget>().getRegisterInfo();
|
||||
const SparcRegisterInfo *TRI = Subtarget->getRegisterInfo();
|
||||
const uint32_t *Mask = ((hasReturnsTwice)
|
||||
? TRI->getRTCallPreservedMask(CallConv)
|
||||
: TRI->getCallPreservedMask(CallConv));
|
||||
@ -1227,8 +1226,7 @@ SparcTargetLowering::LowerCall_64(TargetLowering::CallLoweringInfo &CLI,
|
||||
RegsToPass[i].second.getValueType()));
|
||||
|
||||
// Add a register mask operand representing the call-preserved registers.
|
||||
const SparcRegisterInfo *TRI =
|
||||
getTargetMachine().getSubtarget<SparcSubtarget>().getRegisterInfo();
|
||||
const SparcRegisterInfo *TRI = Subtarget->getRegisterInfo();
|
||||
const uint32_t *Mask =
|
||||
((hasReturnsTwice) ? TRI->getRTCallPreservedMask(CLI.CallConv)
|
||||
: TRI->getCallPreservedMask(CLI.CallConv));
|
||||
@ -1365,10 +1363,9 @@ static SPCC::CondCodes FPCondCCodeToFCC(ISD::CondCode CC) {
|
||||
}
|
||||
}
|
||||
|
||||
SparcTargetLowering::SparcTargetLowering(TargetMachine &TM)
|
||||
: TargetLowering(TM) {
|
||||
Subtarget = &TM.getSubtarget<SparcSubtarget>();
|
||||
|
||||
SparcTargetLowering::SparcTargetLowering(TargetMachine &TM,
|
||||
const SparcSubtarget &STI)
|
||||
: TargetLowering(TM), Subtarget(&STI) {
|
||||
// Set up the register classes.
|
||||
addRegisterClass(MVT::i32, &SP::IntRegsRegClass);
|
||||
addRegisterClass(MVT::f32, &SP::FPRegsRegClass);
|
||||
@ -1907,10 +1904,8 @@ SDValue SparcTargetLowering::LowerGlobalTLSAddress(SDValue Op,
|
||||
Ops.push_back(Callee);
|
||||
Ops.push_back(Symbol);
|
||||
Ops.push_back(DAG.getRegister(SP::O0, PtrVT));
|
||||
const uint32_t *Mask = getTargetMachine()
|
||||
.getSubtargetImpl()
|
||||
->getRegisterInfo()
|
||||
->getCallPreservedMask(CallingConv::C);
|
||||
const uint32_t *Mask =
|
||||
Subtarget->getRegisterInfo()->getCallPreservedMask(CallingConv::C);
|
||||
assert(Mask && "Missing call preserved mask for calling convention");
|
||||
Ops.push_back(DAG.getRegisterMask(Mask));
|
||||
Ops.push_back(InFlag);
|
||||
@ -2906,8 +2901,7 @@ MachineBasicBlock*
|
||||
SparcTargetLowering::expandSelectCC(MachineInstr *MI,
|
||||
MachineBasicBlock *BB,
|
||||
unsigned BROpcode) const {
|
||||
const TargetInstrInfo &TII =
|
||||
*getTargetMachine().getSubtargetImpl()->getInstrInfo();
|
||||
const TargetInstrInfo &TII = *Subtarget->getInstrInfo();
|
||||
DebugLoc dl = MI->getDebugLoc();
|
||||
unsigned CC = (SPCC::CondCodes)MI->getOperand(3).getImm();
|
||||
|
||||
@ -2968,8 +2962,7 @@ SparcTargetLowering::expandAtomicRMW(MachineInstr *MI,
|
||||
MachineBasicBlock *MBB,
|
||||
unsigned Opcode,
|
||||
unsigned CondCode) const {
|
||||
const TargetInstrInfo &TII =
|
||||
*getTargetMachine().getSubtargetImpl()->getInstrInfo();
|
||||
const TargetInstrInfo &TII = *Subtarget->getInstrInfo();
|
||||
MachineRegisterInfo &MRI = MBB->getParent()->getRegInfo();
|
||||
DebugLoc DL = MI->getDebugLoc();
|
||||
|
||||
|
@ -54,7 +54,7 @@ namespace llvm {
|
||||
class SparcTargetLowering : public TargetLowering {
|
||||
const SparcSubtarget *Subtarget;
|
||||
public:
|
||||
SparcTargetLowering(TargetMachine &TM);
|
||||
SparcTargetLowering(TargetMachine &TM, const SparcSubtarget &STI);
|
||||
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
|
||||
|
||||
/// computeKnownBitsForTargetNode - Determine which of the bits specified
|
||||
|
@ -22,38 +22,38 @@ include "SparcInstrFormats.td"
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// 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.
|
||||
def Is64Bit : Predicate<"Subtarget.is64Bit()">;
|
||||
def Is64Bit : Predicate<"Subtarget->is64Bit()">;
|
||||
|
||||
// HasV9 - This predicate is true when the target processor supports V9
|
||||
// instructions. Note that the machine may be running in 32-bit mode.
|
||||
def HasV9 : Predicate<"Subtarget.isV9()">,
|
||||
def HasV9 : Predicate<"Subtarget->isV9()">,
|
||||
AssemblerPredicate<"FeatureV9">;
|
||||
|
||||
// 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
|
||||
// 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.
|
||||
def HasVIS : Predicate<"Subtarget.isVIS()">,
|
||||
def HasVIS : Predicate<"Subtarget->isVIS()">,
|
||||
AssemblerPredicate<"FeatureVIS">;
|
||||
def HasVIS2 : Predicate<"Subtarget.isVIS2()">,
|
||||
def HasVIS2 : Predicate<"Subtarget->isVIS2()">,
|
||||
AssemblerPredicate<"FeatureVIS2">;
|
||||
def HasVIS3 : Predicate<"Subtarget.isVIS3()">,
|
||||
def HasVIS3 : Predicate<"Subtarget->isVIS3()">,
|
||||
AssemblerPredicate<"FeatureVIS3">;
|
||||
|
||||
// HasHardQuad - This is true when the target processor supports quad floating
|
||||
// point instructions.
|
||||
def HasHardQuad : Predicate<"Subtarget.hasHardQuad()">;
|
||||
def HasHardQuad : Predicate<"Subtarget->hasHardQuad()">;
|
||||
|
||||
// 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
|
||||
// to use when appropriate. In either of these cases, the instruction selector
|
||||
// will pick deprecated instructions.
|
||||
def UseDeprecatedInsts : Predicate<"Subtarget.useDeprecatedV8Instructions()">;
|
||||
def UseDeprecatedInsts : Predicate<"Subtarget->useDeprecatedV8Instructions()">;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Instruction Pattern Stuff
|
||||
|
@ -53,7 +53,7 @@ SparcSubtarget::SparcSubtarget(const std::string &TT, const std::string &CPU,
|
||||
const std::string &FS, TargetMachine &TM,
|
||||
bool 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) {}
|
||||
|
||||
int SparcSubtarget::getAdjustedFrameSize(int frameSize) const {
|
||||
|
Loading…
Reference in New Issue
Block a user