Skip to content

Commit 5ca7513

Browse files
committed
[PPC][NFC] Add Subtarget and replace all uses of PPCSubTarget with Subtarget.
Summary: In preparation for GlobalISel, PPCSubTarget needs to be renamed to Subtarget as there places in GlobalISel that assume the presence of the variable Subtarget. This patch introduces the variable Subtarget, and replaces all existing uses of PPCSubTarget with Subtarget. A subsequent patch will remove the definiton of PPCSubTarget, once any downstream users have the opportunity to rename any uses they have. Reviewers: hfinkel, nemanjai, jhibbits, #powerpc, echristo, lkail Reviewed By: #powerpc, echristo, lkail Subscribers: echristo, lkail, wuzish, nemanjai, hiraditya, jfb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D81623
1 parent 30deabf commit 5ca7513

File tree

8 files changed

+151
-149
lines changed

8 files changed

+151
-149
lines changed

llvm/lib/Target/PowerPC/PPCFastISel.cpp

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class PPCFastISel final : public FastISel {
8787

8888
const TargetMachine &TM;
8989
const PPCSubtarget *PPCSubTarget;
90+
const PPCSubtarget *Subtarget;
9091
PPCFunctionInfo *PPCFuncInfo;
9192
const TargetInstrInfo &TII;
9293
const TargetLowering &TLI;
@@ -97,12 +98,12 @@ class PPCFastISel final : public FastISel {
9798
const TargetLibraryInfo *LibInfo)
9899
: FastISel(FuncInfo, LibInfo), TM(FuncInfo.MF->getTarget()),
99100
PPCSubTarget(&FuncInfo.MF->getSubtarget<PPCSubtarget>()),
101+
Subtarget(&FuncInfo.MF->getSubtarget<PPCSubtarget>()),
100102
PPCFuncInfo(FuncInfo.MF->getInfo<PPCFunctionInfo>()),
101-
TII(*PPCSubTarget->getInstrInfo()),
102-
TLI(*PPCSubTarget->getTargetLowering()),
103+
TII(*Subtarget->getInstrInfo()), TLI(*Subtarget->getTargetLowering()),
103104
Context(&FuncInfo.Fn->getContext()) {}
104105

105-
// Backend specific FastISel code.
106+
// Backend specific FastISel code.
106107
private:
107108
bool fastSelectInstruction(const Instruction *I) override;
108109
unsigned fastMaterializeConstant(const Constant *C) override;
@@ -456,7 +457,7 @@ bool PPCFastISel::PPCEmitLoad(MVT VT, Register &ResultReg, Address &Addr,
456457
bool IsZExt, unsigned FP64LoadOpc) {
457458
unsigned Opc;
458459
bool UseOffset = true;
459-
bool HasSPE = PPCSubTarget->hasSPE();
460+
bool HasSPE = Subtarget->hasSPE();
460461

461462
// If ResultReg is given, it determines the register class of the load.
462463
// Otherwise, RC is the register class to use. If the result of the
@@ -498,7 +499,7 @@ bool PPCFastISel::PPCEmitLoad(MVT VT, Register &ResultReg, Address &Addr,
498499
UseOffset = ((Addr.Offset & 3) == 0);
499500
break;
500501
case MVT::f32:
501-
Opc = PPCSubTarget->hasSPE() ? PPC::SPELWZ : PPC::LFS;
502+
Opc = Subtarget->hasSPE() ? PPC::SPELWZ : PPC::LFS;
502503
break;
503504
case MVT::f64:
504505
Opc = FP64LoadOpc;
@@ -614,7 +615,7 @@ bool PPCFastISel::SelectLoad(const Instruction *I) {
614615

615616
Register ResultReg = 0;
616617
if (!PPCEmitLoad(VT, ResultReg, Addr, RC, true,
617-
PPCSubTarget->hasSPE() ? PPC::EVLDD : PPC::LFD))
618+
Subtarget->hasSPE() ? PPC::EVLDD : PPC::LFD))
618619
return false;
619620
updateValueMap(I, ResultReg);
620621
return true;
@@ -647,10 +648,10 @@ bool PPCFastISel::PPCEmitStore(MVT VT, unsigned SrcReg, Address &Addr) {
647648
UseOffset = ((Addr.Offset & 3) == 0);
648649
break;
649650
case MVT::f32:
650-
Opc = PPCSubTarget->hasSPE() ? PPC::SPESTW : PPC::STFS;
651+
Opc = Subtarget->hasSPE() ? PPC::SPESTW : PPC::STFS;
651652
break;
652653
case MVT::f64:
653-
Opc = PPCSubTarget->hasSPE() ? PPC::EVSTDD : PPC::STFD;
654+
Opc = Subtarget->hasSPE() ? PPC::EVSTDD : PPC::STFD;
654655
break;
655656
}
656657

@@ -794,8 +795,9 @@ bool PPCFastISel::SelectBranch(const Instruction *I) {
794795
return false;
795796

796797
BuildMI(*BrBB, FuncInfo.InsertPt, DbgLoc, TII.get(PPC::BCC))
797-
.addImm(PPCSubTarget->hasSPE() ? PPC::PRED_SPE : PPCPred)
798-
.addReg(CondReg).addMBB(TBB);
798+
.addImm(Subtarget->hasSPE() ? PPC::PRED_SPE : PPCPred)
799+
.addReg(CondReg)
800+
.addMBB(TBB);
799801
finishCondBranch(BI->getParent(), TBB, FBB);
800802
return true;
801803
}
@@ -827,7 +829,7 @@ bool PPCFastISel::PPCEmitCmp(const Value *SrcValue1, const Value *SrcValue2,
827829
return false;
828830
MVT SrcVT = SrcEVT.getSimpleVT();
829831

830-
if (SrcVT == MVT::i1 && PPCSubTarget->useCRBits())
832+
if (SrcVT == MVT::i1 && Subtarget->useCRBits())
831833
return false;
832834

833835
// See if operand 2 is an immediate encodeable in the compare.
@@ -836,7 +838,7 @@ bool PPCFastISel::PPCEmitCmp(const Value *SrcValue1, const Value *SrcValue2,
836838
// similar to ARM in this regard.
837839
long Imm = 0;
838840
bool UseImm = false;
839-
const bool HasSPE = PPCSubTarget->hasSPE();
841+
const bool HasSPE = Subtarget->hasSPE();
840842

841843
// Only 16-bit integer constants can be represented in compares for
842844
// PowerPC. Others will be materialized into a register.
@@ -988,7 +990,7 @@ bool PPCFastISel::SelectFPTrunc(const Instruction *I) {
988990
// Round the result to single precision.
989991
unsigned DestReg;
990992
auto RC = MRI.getRegClass(SrcReg);
991-
if (PPCSubTarget->hasSPE()) {
993+
if (Subtarget->hasSPE()) {
992994
DestReg = createResultReg(&PPC::GPRCRegClass);
993995
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
994996
TII.get(PPC::EFSCFD), DestReg)
@@ -1043,10 +1045,10 @@ unsigned PPCFastISel::PPCMoveToFPReg(MVT SrcVT, unsigned SrcReg,
10431045
if (SrcVT == MVT::i32) {
10441046
if (!IsSigned) {
10451047
LoadOpc = PPC::LFIWZX;
1046-
Addr.Offset = (PPCSubTarget->isLittleEndian()) ? 0 : 4;
1047-
} else if (PPCSubTarget->hasLFIWAX()) {
1048+
Addr.Offset = (Subtarget->isLittleEndian()) ? 0 : 4;
1049+
} else if (Subtarget->hasLFIWAX()) {
10481050
LoadOpc = PPC::LFIWAX;
1049-
Addr.Offset = (PPCSubTarget->isLittleEndian()) ? 0 : 4;
1051+
Addr.Offset = (Subtarget->isLittleEndian()) ? 0 : 4;
10501052
}
10511053
}
10521054

@@ -1086,7 +1088,7 @@ bool PPCFastISel::SelectIToFP(const Instruction *I, bool IsSigned) {
10861088
return false;
10871089

10881090
// Shortcut for SPE. Doesn't need to store/load, since it's all in the GPRs
1089-
if (PPCSubTarget->hasSPE()) {
1091+
if (Subtarget->hasSPE()) {
10901092
unsigned Opc;
10911093
if (DstVT == MVT::f32)
10921094
Opc = IsSigned ? PPC::EFSCFSI : PPC::EFSCFUI;
@@ -1103,15 +1105,15 @@ bool PPCFastISel::SelectIToFP(const Instruction *I, bool IsSigned) {
11031105

11041106
// We can only lower an unsigned convert if we have the newer
11051107
// floating-point conversion operations.
1106-
if (!IsSigned && !PPCSubTarget->hasFPCVT())
1108+
if (!IsSigned && !Subtarget->hasFPCVT())
11071109
return false;
11081110

11091111
// FIXME: For now we require the newer floating-point conversion operations
11101112
// (which are present only on P7 and A2 server models) when converting
11111113
// to single-precision float. Otherwise we have to generate a lot of
11121114
// fiddly code to avoid double rounding. If necessary, the fiddly code
11131115
// can be found in PPCTargetLowering::LowerINT_TO_FP().
1114-
if (DstVT == MVT::f32 && !PPCSubTarget->hasFPCVT())
1116+
if (DstVT == MVT::f32 && !Subtarget->hasFPCVT())
11151117
return false;
11161118

11171119
// Extend the input if necessary.
@@ -1168,7 +1170,7 @@ unsigned PPCFastISel::PPCMoveToIntReg(const Instruction *I, MVT VT,
11681170
// Reload it into a GPR. If we want an i32 on big endian, modify the
11691171
// address to have a 4-byte offset so we load from the right place.
11701172
if (VT == MVT::i32)
1171-
Addr.Offset = (PPCSubTarget->isLittleEndian()) ? 0 : 4;
1173+
Addr.Offset = (Subtarget->isLittleEndian()) ? 0 : 4;
11721174

11731175
// Look at the currently assigned register for this instruction
11741176
// to determine the required register class.
@@ -1196,8 +1198,8 @@ bool PPCFastISel::SelectFPToI(const Instruction *I, bool IsSigned) {
11961198
return false;
11971199

11981200
// If we don't have FCTIDUZ, or SPE, and we need it, punt to SelectionDAG.
1199-
if (DstVT == MVT::i64 && !IsSigned &&
1200-
!PPCSubTarget->hasFPCVT() && !PPCSubTarget->hasSPE())
1201+
if (DstVT == MVT::i64 && !IsSigned && !Subtarget->hasFPCVT() &&
1202+
!Subtarget->hasSPE())
12011203
return false;
12021204

12031205
Value *Src = I->getOperand(0);
@@ -1226,15 +1228,15 @@ bool PPCFastISel::SelectFPToI(const Instruction *I, bool IsSigned) {
12261228
unsigned Opc;
12271229
auto RC = MRI.getRegClass(SrcReg);
12281230

1229-
if (PPCSubTarget->hasSPE()) {
1231+
if (Subtarget->hasSPE()) {
12301232
DestReg = createResultReg(&PPC::GPRCRegClass);
12311233
if (IsSigned)
12321234
Opc = InRC == &PPC::GPRCRegClass ? PPC::EFSCTSIZ : PPC::EFDCTSIZ;
12331235
else
12341236
Opc = InRC == &PPC::GPRCRegClass ? PPC::EFSCTUIZ : PPC::EFDCTUIZ;
12351237
} else if (isVSFRCRegClass(RC)) {
12361238
DestReg = createResultReg(&PPC::VSFRCRegClass);
1237-
if (DstVT == MVT::i32)
1239+
if (DstVT == MVT::i32)
12381240
Opc = IsSigned ? PPC::XSCVDPSXWS : PPC::XSCVDPUXWS;
12391241
else
12401242
Opc = IsSigned ? PPC::XSCVDPSXDS : PPC::XSCVDPUXDS;
@@ -1244,7 +1246,7 @@ bool PPCFastISel::SelectFPToI(const Instruction *I, bool IsSigned) {
12441246
if (IsSigned)
12451247
Opc = PPC::FCTIWZ;
12461248
else
1247-
Opc = PPCSubTarget->hasFPCVT() ? PPC::FCTIWUZ : PPC::FCTIDZ;
1249+
Opc = Subtarget->hasFPCVT() ? PPC::FCTIWUZ : PPC::FCTIDZ;
12481250
else
12491251
Opc = IsSigned ? PPC::FCTIDZ : PPC::FCTIDUZ;
12501252
}
@@ -1254,8 +1256,9 @@ bool PPCFastISel::SelectFPToI(const Instruction *I, bool IsSigned) {
12541256
.addReg(SrcReg);
12551257

12561258
// Now move the integer value from a float register to an integer register.
1257-
unsigned IntReg = PPCSubTarget->hasSPE() ? DestReg :
1258-
PPCMoveToIntReg(I, DstVT, DestReg, IsSigned);
1259+
unsigned IntReg = Subtarget->hasSPE()
1260+
? DestReg
1261+
: PPCMoveToIntReg(I, DstVT, DestReg, IsSigned);
12591262

12601263
if (IntReg == 0)
12611264
return false;
@@ -1383,7 +1386,7 @@ bool PPCFastISel::processCallArgs(SmallVectorImpl<Value*> &Args,
13831386
CCState CCInfo(CC, IsVarArg, *FuncInfo.MF, ArgLocs, *Context);
13841387

13851388
// Reserve space for the linkage area on the stack.
1386-
unsigned LinkageSize = PPCSubTarget->getFrameLowering()->getLinkageSize();
1389+
unsigned LinkageSize = Subtarget->getFrameLowering()->getLinkageSize();
13871390
CCInfo.AllocateStack(LinkageSize, Align(8));
13881391

13891392
CCInfo.AnalyzeCallOperands(ArgVTs, ArgFlags, CC_PPC64_ELF_FIS);
@@ -1573,7 +1576,7 @@ bool PPCFastISel::fastLowerCall(CallLoweringInfo &CLI) {
15731576
else if (!isTypeLegal(RetTy, RetVT) && RetVT != MVT::i16 &&
15741577
RetVT != MVT::i8)
15751578
return false;
1576-
else if (RetVT == MVT::i1 && PPCSubTarget->useCRBits())
1579+
else if (RetVT == MVT::i1 && Subtarget->useCRBits())
15771580
// We can't handle boolean returns when CR bits are in use.
15781581
return false;
15791582

@@ -1995,7 +1998,7 @@ unsigned PPCFastISel::PPCMaterializeFP(const ConstantFP *CFP, MVT VT) {
19951998
// All FP constants are loaded from the constant pool.
19961999
Align Alignment = DL.getPrefTypeAlign(CFP->getType());
19972000
unsigned Idx = MCP.getConstantPoolIndex(cast<Constant>(CFP), Alignment);
1998-
const bool HasSPE = PPCSubTarget->hasSPE();
2001+
const bool HasSPE = Subtarget->hasSPE();
19992002
const TargetRegisterClass *RC;
20002003
if (HasSPE)
20012004
RC = ((VT == MVT::f32) ? &PPC::GPRCRegClass : &PPC::SPERCRegClass);
@@ -2089,7 +2092,7 @@ unsigned PPCFastISel::PPCMaterializeGV(const GlobalValue *GV, MVT VT) {
20892092
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(PPC::ADDIStocHA8),
20902093
HighPartReg).addReg(PPC::X2).addGlobalAddress(GV);
20912094

2092-
if (PPCSubTarget->isGVIndirectSymbol(GV)) {
2095+
if (Subtarget->isGVIndirectSymbol(GV)) {
20932096
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(PPC::LDtocL),
20942097
DestReg).addGlobalAddress(GV).addReg(HighPartReg);
20952098
} else {
@@ -2196,7 +2199,7 @@ unsigned PPCFastISel::PPCMaterializeInt(const ConstantInt *CI, MVT VT,
21962199
bool UseSExt) {
21972200
// If we're using CR bit registers for i1 values, handle that as a special
21982201
// case first.
2199-
if (VT == MVT::i1 && PPCSubTarget->useCRBits()) {
2202+
if (VT == MVT::i1 && Subtarget->useCRBits()) {
22002203
unsigned ImmReg = createResultReg(&PPC::CRBITRCRegClass);
22012204
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
22022205
TII.get(CI->isZero() ? PPC::CRUNSET : PPC::CRSET), ImmReg);
@@ -2351,7 +2354,7 @@ bool PPCFastISel::tryToFoldLoadIntoMI(MachineInstr *MI, unsigned OpNo,
23512354
Register ResultReg = MI->getOperand(0).getReg();
23522355

23532356
if (!PPCEmitLoad(VT, ResultReg, Addr, nullptr, IsZExt,
2354-
PPCSubTarget->hasSPE() ? PPC::EVLDD : PPC::LFD))
2357+
Subtarget->hasSPE() ? PPC::EVLDD : PPC::LFD))
23552358
return false;
23562359

23572360
MachineBasicBlock::iterator I(MI);
@@ -2378,7 +2381,7 @@ unsigned PPCFastISel::fastEmit_i(MVT Ty, MVT VT, unsigned Opc, uint64_t Imm) {
23782381

23792382
// If we're using CR bit registers for i1 values, handle that as a special
23802383
// case first.
2381-
if (VT == MVT::i1 && PPCSubTarget->useCRBits()) {
2384+
if (VT == MVT::i1 && Subtarget->useCRBits()) {
23822385
unsigned ImmReg = createResultReg(&PPC::CRBITRCRegClass);
23832386
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
23842387
TII.get(Imm == 0 ? PPC::CRUNSET : PPC::CRSET), ImmReg);

0 commit comments

Comments
 (0)