47#define DEBUG_TYPE "reginfo"
49#define GET_REGINFO_TARGET_DESC
50#include "PPCGenRegisterInfo.inc"
52STATISTIC(InflateGPRC,
"Number of gprc inputs for getLargestLegalClass");
53STATISTIC(InflateGP8RC,
"Number of g8rc inputs for getLargestLegalClass");
57 cl::desc(
"Enable use of a base pointer for complex stack frames"));
61 cl::desc(
"Force the use of a base pointer in every function"));
65 cl::desc(
"Enable spills from gpr to vsr rather than stack"));
69 cl::desc(
"Consider R1 caller preserved so stack saves of "
70 "caller preserved registers can be LICM candidates"),
75 cl::desc(
"Maximum search distance for definition of CR bit "
89 cl::desc(
"Emit information about accumulator register spills "
100 TM.isPPC64() ? 0 : 1,
101 TM.isPPC64() ? 0 : 1),
103 ImmToIdxMap[PPC::LD] = PPC::LDX; ImmToIdxMap[PPC::STD] = PPC::STDX;
104 ImmToIdxMap[PPC::LBZ] = PPC::LBZX; ImmToIdxMap[PPC::STB] = PPC::STBX;
105 ImmToIdxMap[PPC::LHZ] = PPC::LHZX; ImmToIdxMap[PPC::LHA] = PPC::LHAX;
106 ImmToIdxMap[PPC::LWZ] = PPC::LWZX; ImmToIdxMap[PPC::LWA] = PPC::LWAX;
107 ImmToIdxMap[PPC::LFS] = PPC::LFSX; ImmToIdxMap[PPC::LFD] = PPC::LFDX;
108 ImmToIdxMap[PPC::STH] = PPC::STHX; ImmToIdxMap[PPC::STW] = PPC::STWX;
109 ImmToIdxMap[PPC::STFS] = PPC::STFSX; ImmToIdxMap[PPC::STFD] = PPC::STFDX;
110 ImmToIdxMap[PPC::ADDI] = PPC::ADD4;
111 ImmToIdxMap[PPC::LWA_32] = PPC::LWAX_32;
114 ImmToIdxMap[PPC::LHA8] = PPC::LHAX8; ImmToIdxMap[PPC::LBZ8] = PPC::LBZX8;
115 ImmToIdxMap[PPC::LHZ8] = PPC::LHZX8; ImmToIdxMap[PPC::LWZ8] = PPC::LWZX8;
116 ImmToIdxMap[PPC::STB8] = PPC::STBX8; ImmToIdxMap[PPC::STH8] = PPC::STHX8;
117 ImmToIdxMap[PPC::STW8] = PPC::STWX8; ImmToIdxMap[PPC::STDU] = PPC::STDUX;
118 ImmToIdxMap[PPC::ADDI8] = PPC::ADD8;
119 ImmToIdxMap[PPC::LQ] = PPC::LQX_PSEUDO;
120 ImmToIdxMap[PPC::STQ] = PPC::STQX_PSEUDO;
123 ImmToIdxMap[PPC::DFLOADf32] = PPC::LXSSPX;
124 ImmToIdxMap[PPC::DFLOADf64] = PPC::LXSDX;
125 ImmToIdxMap[PPC::SPILLTOVSR_LD] = PPC::SPILLTOVSR_LDX;
126 ImmToIdxMap[PPC::SPILLTOVSR_ST] = PPC::SPILLTOVSR_STX;
127 ImmToIdxMap[PPC::DFSTOREf32] = PPC::STXSSPX;
128 ImmToIdxMap[PPC::DFSTOREf64] = PPC::STXSDX;
129 ImmToIdxMap[PPC::LXV] = PPC::LXVX;
130 ImmToIdxMap[PPC::LXSD] = PPC::LXSDX;
131 ImmToIdxMap[PPC::LXSSP] = PPC::LXSSPX;
132 ImmToIdxMap[PPC::STXV] = PPC::STXVX;
133 ImmToIdxMap[PPC::STXSD] = PPC::STXSDX;
134 ImmToIdxMap[PPC::STXSSP] = PPC::STXSSPX;
137 ImmToIdxMap[PPC::EVLDD] = PPC::EVLDDX;
138 ImmToIdxMap[PPC::EVSTDD] = PPC::EVSTDDX;
139 ImmToIdxMap[PPC::SPESTW] = PPC::SPESTWX;
140 ImmToIdxMap[PPC::SPELWZ] = PPC::SPELWZX;
143 ImmToIdxMap[PPC::PLBZ] = PPC::LBZX; ImmToIdxMap[PPC::PLBZ8] = PPC::LBZX8;
144 ImmToIdxMap[PPC::PLHZ] = PPC::LHZX; ImmToIdxMap[PPC::PLHZ8] = PPC::LHZX8;
145 ImmToIdxMap[PPC::PLHA] = PPC::LHAX; ImmToIdxMap[PPC::PLHA8] = PPC::LHAX8;
146 ImmToIdxMap[PPC::PLWZ] = PPC::LWZX; ImmToIdxMap[PPC::PLWZ8] = PPC::LWZX8;
147 ImmToIdxMap[PPC::PLWA] = PPC::LWAX; ImmToIdxMap[PPC::PLWA8] = PPC::LWAX;
148 ImmToIdxMap[PPC::PLD] = PPC::LDX; ImmToIdxMap[PPC::PSTD] = PPC::STDX;
150 ImmToIdxMap[PPC::PSTB] = PPC::STBX; ImmToIdxMap[PPC::PSTB8] = PPC::STBX8;
151 ImmToIdxMap[PPC::PSTH] = PPC::STHX; ImmToIdxMap[PPC::PSTH8] = PPC::STHX8;
152 ImmToIdxMap[PPC::PSTW] = PPC::STWX; ImmToIdxMap[PPC::PSTW8] = PPC::STWX8;
154 ImmToIdxMap[PPC::PLFS] = PPC::LFSX; ImmToIdxMap[PPC::PSTFS] = PPC::STFSX;
155 ImmToIdxMap[PPC::PLFD] = PPC::LFDX; ImmToIdxMap[PPC::PSTFD] = PPC::STFDX;
156 ImmToIdxMap[PPC::PLXSSP] = PPC::LXSSPX; ImmToIdxMap[PPC::PSTXSSP] = PPC::STXSSPX;
157 ImmToIdxMap[PPC::PLXSD] = PPC::LXSDX; ImmToIdxMap[PPC::PSTXSD] = PPC::STXSDX;
158 ImmToIdxMap[PPC::PLXV] = PPC::LXVX; ImmToIdxMap[PPC::PSTXV] = PPC::STXVX;
160 ImmToIdxMap[PPC::LXVP] = PPC::LXVPX;
161 ImmToIdxMap[PPC::STXVP] = PPC::STXVPX;
162 ImmToIdxMap[PPC::PLXVP] = PPC::LXVPX;
163 ImmToIdxMap[PPC::PSTXVP] = PPC::STXVPX;
175 return &PPC::G8RC_NOX0RegClass;
176 return &PPC::GPRC_NOR0RegClass;
180 return &PPC::G8RCRegClass;
181 return &PPC::GPRCRegClass;
190 if (Subtarget.hasVSX()) {
191 if (Subtarget.pairedVectorMemops())
192 return CSR_64_AllRegs_VSRP_SaveList;
194 return CSR_64_AllRegs_AIX_Dflt_VSX_SaveList;
195 return CSR_64_AllRegs_VSX_SaveList;
197 if (Subtarget.hasAltivec()) {
199 return CSR_64_AllRegs_AIX_Dflt_Altivec_SaveList;
200 return CSR_64_AllRegs_Altivec_SaveList;
202 return CSR_64_AllRegs_SaveList;
220 if (Subtarget.pairedVectorMemops())
221 return SaveR2 ? CSR_SVR64_ColdCC_R2_VSRP_SaveList
222 : CSR_SVR64_ColdCC_VSRP_SaveList;
223 if (Subtarget.hasAltivec())
224 return SaveR2 ? CSR_SVR64_ColdCC_R2_Altivec_SaveList
225 : CSR_SVR64_ColdCC_Altivec_SaveList;
226 return SaveR2 ? CSR_SVR64_ColdCC_R2_SaveList
227 : CSR_SVR64_ColdCC_SaveList;
230 if (Subtarget.pairedVectorMemops())
231 return CSR_SVR32_ColdCC_VSRP_SaveList;
232 else if (Subtarget.hasAltivec())
233 return CSR_SVR32_ColdCC_Altivec_SaveList;
234 else if (Subtarget.hasSPE())
235 return CSR_SVR32_ColdCC_SPE_SaveList;
236 return CSR_SVR32_ColdCC_SaveList;
240 if (Subtarget.pairedVectorMemops()) {
243 return SaveR2 ? CSR_PPC64_R2_SaveList : CSR_PPC64_SaveList;
244 return SaveR2 ? CSR_AIX64_R2_VSRP_SaveList : CSR_AIX64_VSRP_SaveList;
246 return SaveR2 ? CSR_SVR464_R2_VSRP_SaveList : CSR_SVR464_VSRP_SaveList;
248 if (Subtarget.hasAltivec() &&
250 return SaveR2 ? CSR_PPC64_R2_Altivec_SaveList
251 : CSR_PPC64_Altivec_SaveList;
253 return SaveR2 ? CSR_PPC64_R2_SaveList : CSR_PPC64_SaveList;
257 if (Subtarget.pairedVectorMemops())
259 : CSR_AIX32_SaveList;
260 if (Subtarget.hasAltivec())
262 : CSR_AIX32_SaveList;
263 return CSR_AIX32_SaveList;
265 if (Subtarget.pairedVectorMemops())
266 return CSR_SVR432_VSRP_SaveList;
267 if (Subtarget.hasAltivec())
268 return CSR_SVR432_Altivec_SaveList;
269 else if (Subtarget.hasSPE()) {
271 return CSR_SVR432_SPE_NO_S30_31_SaveList;
272 return CSR_SVR432_SPE_SaveList;
274 return CSR_SVR432_SaveList;
282 if (Subtarget.hasVSX()) {
283 if (Subtarget.pairedVectorMemops())
284 return CSR_64_AllRegs_VSRP_RegMask;
286 return CSR_64_AllRegs_AIX_Dflt_VSX_RegMask;
287 return CSR_64_AllRegs_VSX_RegMask;
289 if (Subtarget.hasAltivec()) {
291 return CSR_64_AllRegs_AIX_Dflt_Altivec_RegMask;
292 return CSR_64_AllRegs_Altivec_RegMask;
294 return CSR_64_AllRegs_RegMask;
298 if (Subtarget.pairedVectorMemops()) {
300 return TM.
isPPC64() ? CSR_PPC64_RegMask : CSR_AIX32_RegMask;
301 return TM.
isPPC64() ? CSR_AIX64_VSRP_RegMask : CSR_AIX32_VSRP_RegMask;
305 ? CSR_PPC64_Altivec_RegMask
308 ? CSR_AIX32_Altivec_RegMask
309 : CSR_AIX32_RegMask);
314 return Subtarget.pairedVectorMemops()
315 ? CSR_SVR64_ColdCC_VSRP_RegMask
316 : (Subtarget.hasAltivec() ? CSR_SVR64_ColdCC_Altivec_RegMask
317 : CSR_SVR64_ColdCC_RegMask);
319 return Subtarget.pairedVectorMemops()
320 ? CSR_SVR32_ColdCC_VSRP_RegMask
321 : (Subtarget.hasAltivec()
322 ? CSR_SVR32_ColdCC_Altivec_RegMask
323 : (Subtarget.hasSPE() ? CSR_SVR32_ColdCC_SPE_RegMask
324 : CSR_SVR32_ColdCC_RegMask));
328 return Subtarget.pairedVectorMemops()
329 ? CSR_SVR464_VSRP_RegMask
330 : (Subtarget.hasAltivec() ? CSR_PPC64_Altivec_RegMask
331 : CSR_PPC64_RegMask);
333 return Subtarget.pairedVectorMemops()
334 ? CSR_SVR432_VSRP_RegMask
335 : (Subtarget.hasAltivec()
336 ? CSR_SVR432_Altivec_RegMask
337 : (Subtarget.hasSPE()
339 ? CSR_SVR432_SPE_NO_S30_31_RegMask
340 : CSR_SVR432_SPE_RegMask)
341 : CSR_SVR432_RegMask));
346 return CSR_NoRegs_RegMask;
350 for (
unsigned PseudoReg : {PPC::ZERO, PPC::ZERO8, PPC::RM})
351 Mask[PseudoReg / 32] &= ~(1u << (PseudoReg % 32));
381 markSuperRegs(
Reserved, PPC::VRSAVE);
405 if (TFI->needsFP(MF))
420 if (!Subtarget.hasAltivec())
424 if (Subtarget.
isAIXABI() && Subtarget.hasAltivec() &&
428 for (
auto Reg : CSR_Altivec_SaveList) {
451 return PhysReg != PPC::R1 && PhysReg != PPC::X1;
473 if (FrameSize & ~0x7FFF) {
474 LLVM_DEBUG(
dbgs() <<
"TRUE - Frame size is too large for D-Form.\n");
483 if (CSI.isSpilledToReg())
486 int FrIdx = CSI.getFrameIdx();
490 unsigned Opcode = InstrInfo->getStoreOpcodeForSpill(RC);
495 LLVM_DEBUG(
dbgs() <<
"Memory Operand: " << InstrInfo->getName(Opcode)
496 <<
" for register " <<
printReg(Reg,
this) <<
".\n");
497 LLVM_DEBUG(
dbgs() <<
"TRUE - Not fixed frame object that requires "
509 if (InstrInfo->isXFormMemOp(Opcode)) {
510 LLVM_DEBUG(
dbgs() <<
"Memory Operand: " << InstrInfo->getName(Opcode)
511 <<
" for register " <<
printReg(Reg,
this) <<
".\n");
517 if ((Opcode == PPC::RESTORE_QUADWORD) || (Opcode == PPC::SPILL_QUADWORD)) {
518 LLVM_DEBUG(
dbgs() <<
"Memory Operand: " << InstrInfo->getName(Opcode)
519 <<
" for register " <<
printReg(Reg,
this) <<
".\n");
535 return !Subtarget.hasROPProtect();
553 !MFI.hasVarSizedObjects() && !MFI.hasOpaqueSPAdjustment())
577 VirtReg, Order, Hints, MF, VRM,
Matrix);
583 return BaseImplRetVal;
594 switch (
Use.getOpcode()) {
595 case TargetOpcode::COPY: {
596 ResultOp = &
Use.getOperand(0);
597 ResultReg = ResultOp->
getReg();
599 MRI->getRegClass(ResultReg)->contains(PPC::UACC0) &&
603 if (RegClass->
contains(PPC::VSRp0)) {
604 HintReg = getSubReg(UACCPhys, ResultOp->
getSubReg());
606 if (HintReg >= PPC::VSRp0 && HintReg <= PPC::VSRp31)
608 }
else if (RegClass->
contains(PPC::ACC0)) {
609 HintReg = PPC::ACC0 + (UACCPhys - PPC::UACC0);
610 if (HintReg >= PPC::ACC0 && HintReg <= PPC::ACC7)
616 case PPC::BUILD_UACC: {
617 ResultOp = &
Use.getOperand(0);
618 ResultReg = ResultOp->
getReg();
619 if (
MRI->getRegClass(ResultReg)->contains(PPC::ACC0) &&
622 assert((ACCPhys >= PPC::ACC0 && ACCPhys <= PPC::ACC7) &&
623 "Expecting an ACC register for BUILD_UACC.");
624 Register HintReg = PPC::UACC0 + (ACCPhys - PPC::ACC0);
631 return BaseImplRetVal;
637 const unsigned DefaultSafety = 1;
639 switch (RC->
getID()) {
642 case PPC::G8RC_NOX0RegClassID:
643 case PPC::GPRC_NOR0RegClassID:
644 case PPC::SPERCRegClassID:
645 case PPC::G8RCRegClassID:
646 case PPC::GPRCRegClassID: {
647 unsigned FP = TFI->
hasFP(MF) ? 1 : 0;
648 return 32 -
FP - DefaultSafety;
650 case PPC::F4RCRegClassID:
651 case PPC::F8RCRegClassID:
652 case PPC::VSLRCRegClassID:
653 return 32 - DefaultSafety;
654 case PPC::VFRCRegClassID:
655 case PPC::VRRCRegClassID: {
660 return 20 - DefaultSafety;
662 return 32 - DefaultSafety;
663 case PPC::VSFRCRegClassID:
664 case PPC::VSSRCRegClassID:
665 case PPC::VSRCRegClassID: {
670 return 52 - DefaultSafety;
672 return 64 - DefaultSafety;
673 case PPC::CRRCRegClassID:
674 return 8 - DefaultSafety;
682 const auto *DefaultSuperclass =
684 if (Subtarget.hasVSX()) {
693 RC == &PPC::G8RCRegClass) {
695 return &PPC::SPILLTOVSRRCRegClass;
702 if (getRegSizeInBits(**
I) != getRegSizeInBits(*RC))
705 switch ((*I)->getID()) {
706 case PPC::VSSRCRegClassID:
707 return Subtarget.hasP8Vector() ? *
I : DefaultSuperclass;
708 case PPC::VSFRCRegClassID:
709 case PPC::VSRCRegClassID:
711 case PPC::VSRpRCRegClassID:
712 return Subtarget.pairedVectorMemops() ? *
I : DefaultSuperclass;
713 case PPC::ACCRCRegClassID:
714 case PPC::UACCRCRegClassID:
715 return Subtarget.hasMMA() ? *
I : DefaultSuperclass;
720 return DefaultSuperclass;
754 "Maximum call-frame size not sufficiently aligned");
760 bool KillNegSizeReg =
MI.getOperand(1).isKill();
761 Register NegSizeReg =
MI.getOperand(1).getReg();
773 .
addImm(maxCallFrameSize);
781 .
addImm(maxCallFrameSize);
793 bool &KillNegSizeReg,
826 if (MaxAlign < TargetAlign && isInt<16>(FrameSize)) {
846 if (MaxAlign > TargetAlign) {
847 unsigned UnalNegSizeReg = NegSizeReg;
855 unsigned NegSizeReg1 = NegSizeReg;
860 KillNegSizeReg =
true;
863 if (MaxAlign > TargetAlign) {
864 unsigned UnalNegSizeReg = NegSizeReg;
872 unsigned NegSizeReg1 = NegSizeReg;
877 KillNegSizeReg =
true;
895 Register FramePointer =
MI.getOperand(0).getReg();
896 const Register ActualNegSizeReg =
MI.getOperand(1).getReg();
897 bool KillNegSizeReg =
MI.getOperand(2).isKill();
898 Register NegSizeReg =
MI.getOperand(2).getReg();
901 if (FramePointer == NegSizeReg) {
902 assert(KillNegSizeReg &&
"FramePointer is a def and NegSizeReg is an use, "
903 "NegSizeReg should be killed");
910 NegSizeReg = ActualNegSizeReg;
911 KillNegSizeReg =
false;
916 if (NegSizeReg != ActualNegSizeReg)
941 MI.getOperand(0).getReg())
942 .
addImm(maxCallFrameSize);
955 unsigned FrameIndex)
const {
979 if (SrcReg != PPC::CR0) {
986 .
addImm(getEncodingValue(SrcReg) * 4)
1000 unsigned FrameIndex)
const {
1015 Register DestReg =
MI.getOperand(0).getReg();
1016 assert(
MI.definesRegister(DestReg,
nullptr) &&
1017 "RESTORE_CR does not define its destination");
1024 if (DestReg != PPC::CR0) {
1028 unsigned ShiftBits = getEncodingValue(DestReg)*4;
1035 BuildMI(
MBB,
II, dl,
TII.get(LP64 ? PPC::MTOCRF8 : PPC::MTOCRF), DestReg)
1043 unsigned FrameIndex)
const {
1065 unsigned CRBitSpillDistance = 0;
1066 bool SeenUse =
false;
1067 for (; Ins != Rend; ++Ins) {
1069 if (Ins->modifiesRegister(SrcReg,
TRI))
1072 if (Ins->readsRegister(SrcReg,
TRI))
1080 if (!Ins->isDebugInstr())
1081 CRBitSpillDistance++;
1088 bool SpillsKnownBit =
false;
1090 switch (Ins->getOpcode()) {
1094 SpillsKnownBit =
true;
1099 SpillsKnownBit =
true;
1106 if (Subtarget.isISA3_1()) {
1116 if (Subtarget.isISA3_0()) {
1117 if (SrcReg == PPC::CR0LT || SrcReg == PPC::CR1LT ||
1118 SrcReg == PPC::CR2LT || SrcReg == PPC::CR3LT ||
1119 SrcReg == PPC::CR4LT || SrcReg == PPC::CR5LT ||
1120 SrcReg == PPC::CR6LT || SrcReg == PPC::CR7LT) {
1145 .
addImm(getEncodingValue(SrcReg))
1152 bool KillsCRBit =
MI.killsRegister(SrcReg,
TRI);
1155 if (SpillsKnownBit && KillsCRBit && !SeenUse) {
1156 Ins->setDesc(
TII.get(PPC::UNENCODED_NOP));
1157 Ins->removeOperand(0);
1162 unsigned FrameIndex)
const {
1177 Register DestReg =
MI.getOperand(0).getReg();
1178 assert(
MI.definesRegister(DestReg,
nullptr) &&
1179 "RESTORE_CRBIT does not define its destination");
1187 BuildMI(
MBB,
II, dl,
TII.get(LP64 ? PPC::MFOCRF8 : PPC::MFOCRF), RegO)
1190 unsigned ShiftBits = getEncodingValue(DestReg);
1192 BuildMI(
MBB,
II, dl,
TII.get(LP64 ? PPC::RLWIMI8 : PPC::RLWIMI), RegO)
1195 .
addImm(ShiftBits ? 32 - ShiftBits : 0)
1217 std::string Dest = PPC::ACCRCRegClass.contains(DestReg) ?
"acc" :
"uacc";
1218 std::string Src = PPC::ACCRCRegClass.contains(SrcReg) ?
"acc" :
"uacc";
1219 dbgs() <<
"Emitting copy from " << Src <<
" to " << Dest <<
":\n";
1231 dbgs() <<
"Emitting " << (IsPrimed ?
"acc" :
"uacc") <<
" register "
1232 << (IsRestore ?
"restore" :
"spill") <<
":\n";
1241 unsigned FrameIndex,
bool IsLittleEndian,
1242 bool IsKilled,
bool TwoPairs) {
1247 "Spilling register pairs does not support virtual registers.");
1250 Offset = IsLittleEndian ? 48 : 0;
1252 Offset = IsLittleEndian ? 16 : 0;
1253 Register Reg = (SrcReg > PPC::VSRp15) ? PPC::V0 + (SrcReg - PPC::VSRp16) * 2
1254 : PPC::VSL0 + (SrcReg - PPC::VSRp0) * 2;
1258 Offset += IsLittleEndian ? -16 : 16;
1263 Offset += IsLittleEndian ? -16 : 16;
1267 Offset += IsLittleEndian ? -16 : 16;
1278 unsigned FrameIndex)
const {
1280 "Expecting to do this only if paired vector stores are disabled.");
1289 bool IsKilled =
MI.getOperand(0).isKill();
1301 dbgs() <<
"Emitting wacc register " << (IsRestore ?
"restore" :
"spill")
1314 unsigned FrameIndex)
const {
1322 bool IsKilled =
MI.getOperand(0).isKill();
1324 bool IsPrimed = PPC::ACCRCRegClass.contains(SrcReg);
1326 PPC::VSRp0 + (SrcReg - (IsPrimed ? PPC::ACC0 : PPC::UACC0)) * 2;
1343 FrameIndex, IsLittleEndian ? 32 : 0);
1346 FrameIndex, IsLittleEndian ? 0 : 32);
1348 if (IsPrimed && !IsKilled)
1357 unsigned FrameIndex)
const {
1365 Register DestReg =
MI.getOperand(0).getReg();
1366 assert(
MI.definesRegister(DestReg,
nullptr) &&
1367 "RESTORE_ACC does not define its destination");
1369 bool IsPrimed = PPC::ACCRCRegClass.contains(DestReg);
1371 PPC::VSRp0 + (DestReg - (IsPrimed ? PPC::ACC0 : PPC::UACC0)) * 2;
1379 FrameIndex, IsLittleEndian ? 32 : 0);
1381 FrameIndex, IsLittleEndian ? 0 : 32);
1392 unsigned FrameIndex)
const {
1414 FrameIndex, IsLittleEndian ? 32 : 0);
1417 FrameIndex, IsLittleEndian ? 0 : 32);
1426 unsigned FrameIndex)
const {
1440 Register DestReg =
MI.getOperand(0).getReg();
1443 FrameIndex, IsLittleEndian ? 32 : 0);
1445 FrameIndex, IsLittleEndian ? 0 : 32);
1458 unsigned FrameIndex)
const {
1467 bool IsKilled =
MI.getOperand(0).isKill();
1469 Register Reg = PPC::X0 + (SrcReg - PPC::G8p0) * 2;
1474 FrameIndex, IsLittleEndian ? 8 : 0);
1477 FrameIndex, IsLittleEndian ? 0 : 8);
1485 unsigned FrameIndex)
const {
1493 Register DestReg =
MI.getOperand(0).getReg();
1494 assert(
MI.definesRegister(DestReg,
nullptr) &&
1495 "RESTORE_QUADWORD does not define its destination");
1497 Register Reg = PPC::X0 + (DestReg - PPC::G8p0) * 2;
1501 IsLittleEndian ? 8 : 0);
1503 IsLittleEndian ? 0 : 8);
1510 Register Reg,
int &FrameIdx)
const {
1519 if (PPC::CR2 <= Reg && Reg <= PPC::CR4) {
1537 case PPC::DFLOADf32:
1538 case PPC::DFLOADf64:
1539 case PPC::DFSTOREf32:
1540 case PPC::DFSTOREf64:
1561 unsigned OpC =
MI.getOpcode();
1567 unsigned FIOperandNum) {
1569 unsigned OffsetOperandNo = (FIOperandNum == 2) ? 1 : 2;
1570 if (
MI.isInlineAsm())
1571 OffsetOperandNo = FIOperandNum - 1;
1572 else if (
MI.getOpcode() == TargetOpcode::STACKMAP ||
1573 MI.getOpcode() == TargetOpcode::PATCHPOINT)
1574 OffsetOperandNo = FIOperandNum + 1;
1576 return OffsetOperandNo;
1581 int SPAdj,
unsigned FIOperandNum,
1583 assert(SPAdj == 0 &&
"Unexpected");
1601 int FrameIndex =
MI.getOperand(FIOperandNum).getIndex();
1608 unsigned OpC =
MI.getOpcode();
1610 if ((OpC == PPC::DYNAREAOFFSET || OpC == PPC::DYNAREAOFFSET8)) {
1617 if (FPSI && FrameIndex == FPSI &&
1618 (OpC == PPC::DYNALLOC || OpC == PPC::DYNALLOC8)) {
1624 if (FPSI && FrameIndex == FPSI &&
1625 (OpC == PPC::PREPARE_PROBED_ALLOCA_64 ||
1626 OpC == PPC::PREPARE_PROBED_ALLOCA_32 ||
1627 OpC == PPC::PREPARE_PROBED_ALLOCA_NEGSIZE_SAME_REG_64 ||
1628 OpC == PPC::PREPARE_PROBED_ALLOCA_NEGSIZE_SAME_REG_32)) {
1635 if (OpC == PPC::SPILL_CR) {
1638 }
else if (OpC == PPC::RESTORE_CR) {
1641 }
else if (OpC == PPC::SPILL_CRBIT) {
1644 }
else if (OpC == PPC::RESTORE_CRBIT) {
1647 }
else if (OpC == PPC::SPILL_ACC || OpC == PPC::SPILL_UACC) {
1650 }
else if (OpC == PPC::RESTORE_ACC || OpC == PPC::RESTORE_UACC) {
1656 }
else if (OpC == PPC::SPILL_WACC) {
1659 }
else if (OpC == PPC::RESTORE_WACC) {
1662 }
else if (OpC == PPC::SPILL_QUADWORD) {
1665 }
else if (OpC == PPC::RESTORE_QUADWORD) {
1671 MI.getOperand(FIOperandNum).ChangeToRegister(
1676 bool noImmForm = !
MI.isInlineAsm() && OpC != TargetOpcode::STACKMAP &&
1677 OpC != TargetOpcode::PATCHPOINT && !ImmToIdxMap.
count(OpC);
1681 Offset +=
MI.getOperand(OffsetOperandNo).getImm();
1696 if ((OpC == PPC::LXVP || OpC == PPC::STXVP) &&
1698 Subtarget.hasPrefixInstrs() && Subtarget.hasP10Vector()) {
1699 unsigned NewOpc = OpC == PPC::LXVP ? PPC::PLXVP : PPC::PSTXVP;
1700 MI.setDesc(
TII.get(NewOpc));
1710 assert(OpC != PPC::DBG_VALUE &&
1711 "This should be handled in a target-independent way");
1714 bool OffsetFitsMnemonic = (OpC == PPC::EVSTDD || OpC == PPC::EVLDD) ?
1717 if (
TII.isPrefixed(
MI.getOpcode()))
1718 OffsetFitsMnemonic = isInt<34>(
Offset);
1719 if (!noImmForm && ((OffsetFitsMnemonic &&
1721 OpC == TargetOpcode::STACKMAP ||
1722 OpC == TargetOpcode::PATCHPOINT)) {
1723 MI.getOperand(OffsetOperandNo).ChangeToImmediate(
Offset);
1734 unsigned NewOpcode = 0u;
1741 if (ScavengingFailed && Subtarget.hasDirectMove()) {
1744 SRegHi = SReg =
is64Bit ? PPC::X4 : PPC::R4;
1745 if (
MI.getOperand(0).getReg() == SReg)
1746 SRegHi = SReg = SReg + 1;
1759 else if (isInt<32>(
Offset)) {
1774 unsigned OperandBase;
1778 else if (OpC != TargetOpcode::INLINEASM &&
1779 OpC != TargetOpcode::INLINEASM_BR) {
1781 "No indexed form of load or store available!");
1782 NewOpcode = ImmToIdxMap.
find(OpC)->second;
1783 MI.setDesc(
TII.get(NewOpcode));
1786 OperandBase = OffsetOperandNo;
1789 Register StackReg =
MI.getOperand(FIOperandNum).getReg();
1790 MI.getOperand(OperandBase).ChangeToRegister(StackReg,
false);
1791 MI.getOperand(OperandBase + 1).ChangeToRegister(SReg,
false,
false,
true);
1795 if (ScavengingFailed && Subtarget.hasDirectMove())
1802 if (NewOpcode == PPC::LQX_PSEUDO || NewOpcode == PPC::STQX_PSEUDO) {
1803 assert(
is64Bit &&
"Quadword loads/stores only supported in 64-bit mode");
1808 MI.setDesc(
TII.get(NewOpcode == PPC::LQX_PSEUDO ? PPC::LQ : PPC::STQ));
1809 MI.getOperand(OperandBase + 1).ChangeToRegister(NewReg,
false);
1810 MI.getOperand(OperandBase).ChangeToImmediate(0);
1819 return TFI->
hasFP(MF) ? PPC::R31 : PPC::R1;
1821 return TFI->
hasFP(MF) ? PPC::X31 : PPC::X1;
1847 return hasStackRealignment(MF);
1867 unsigned OpC =
MI->getOpcode();
1868 if (!ImmToIdxMap.
count(OpC))
1872 if ((OpC == PPC::ADDI || OpC == PPC::ADDI8) &&
1873 MI->getOperand(2).getImm() == 0)
1902 unsigned ADDriOpc = TM.
isPPC64() ? PPC::ADDI8 : PPC::ADDI;
1907 DL = Ins->getDebugLoc();
1916 MRI.constrainRegClass(BaseReg,
TII.getRegClass(MCID, 0,
this, MF));
1926 unsigned FIOperandNum = 0;
1927 while (!
MI.getOperand(FIOperandNum).isFI()) {
1929 assert(FIOperandNum <
MI.getNumOperands() &&
1930 "Instr doesn't have FrameIndex operand!");
1933 MI.getOperand(FIOperandNum).ChangeToRegister(BaseReg,
false);
1935 Offset +=
MI.getOperand(OffsetOperandNo).getImm();
1936 MI.getOperand(OffsetOperandNo).ChangeToImmediate(
Offset);
1944 MRI.constrainRegClass(BaseReg,
1945 TII.getRegClass(MCID, FIOperandNum,
this, MF));
1951 unsigned FIOperandNum = 0;
1952 while (!
MI->getOperand(FIOperandNum).isFI()) {
1954 assert(FIOperandNum < MI->getNumOperands() &&
1955 "Instr doesn't have FrameIndex operand!");
1959 Offset +=
MI->getOperand(OffsetOperandNo).getImm();
1961 return MI->getOpcode() == PPC::DBG_VALUE ||
1962 MI->getOpcode() == TargetOpcode::STACKMAP ||
1963 MI->getOpcode() == TargetOpcode::PATCHPOINT ||
unsigned const MachineRegisterInfo * MRI
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file implements the BitVector class.
Analysis containing CSE Info
This file contains the declarations for the subclasses of Constant, which represent the different fla...
const HexagonInstrInfo * TII
static cl::opt< bool > EnableBasePointer("m68k-use-base-pointer", cl::Hidden, cl::init(true), cl::desc("Enable use of a base pointer for complex stack frames"))
unsigned const TargetRegisterInfo * TRI
uint64_t IntrinsicInst * II
cl::opt< bool > DisableAutoPairedVecSt("disable-auto-paired-vec-st", cl::desc("disable automatically generated 32byte paired vector stores"), cl::init(true), cl::Hidden)
static cl::opt< unsigned > MaxCRBitSpillDist("ppc-max-crbit-spill-dist", cl::desc("Maximum search distance for definition of CR bit " "spill on ppc"), cl::Hidden, cl::init(100))
static cl::opt< bool > EnableBasePointer("ppc-use-base-pointer", cl::Hidden, cl::init(true), cl::desc("Enable use of a base pointer for complex stack frames"))
static cl::opt< bool > EnableGPRToVecSpills("ppc-enable-gpr-to-vsr-spills", cl::Hidden, cl::init(false), cl::desc("Enable spills from gpr to vsr rather than stack"))
static cl::opt< bool > ReportAccMoves("ppc-report-acc-moves", cl::desc("Emit information about accumulator register spills " "and copies"), cl::Hidden, cl::init(false))
static void emitWAccSpillRestoreInfo(MachineBasicBlock &MBB, bool IsRestore)
static unsigned getOffsetONFromFION(const MachineInstr &MI, unsigned FIOperandNum)
static unsigned offsetMinAlignForOpcode(unsigned OpC)
static void emitAccSpillRestoreInfo(MachineBasicBlock &MBB, bool IsPrimed, bool IsRestore)
static unsigned offsetMinAlign(const MachineInstr &MI)
static cl::opt< bool > StackPtrConst("ppc-stack-ptr-caller-preserved", cl::desc("Consider R1 caller preserved so stack saves of " "caller preserved registers can be LICM candidates"), cl::init(true), cl::Hidden)
static void spillRegPairs(MachineBasicBlock &MBB, MachineBasicBlock::iterator II, DebugLoc DL, const TargetInstrInfo &TII, Register SrcReg, unsigned FrameIndex, bool IsLittleEndian, bool IsKilled, bool TwoPairs)
static cl::opt< bool > AlwaysBasePointer("ppc-always-use-base-pointer", cl::Hidden, cl::init(false), cl::desc("Force the use of a base pointer in every function"))
cl::opt< bool > DisableAutoPairedVecSt
This file declares the machine register scavenger class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
static bool is64Bit(const char *name)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool test(unsigned Idx) const
bool any() const
any - Returns true if any bit is set.
bool none() const
none - Returns true if none of the bits are set.
The CalleeSavedInfo class tracks the information need to locate where a callee saved register is in t...
iterator find(const_arg_type_t< KeyT > Val)
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Describe properties that are true of each instruction in the target description file.
MCRegAliasIterator enumerates all registers aliasing Reg.
Wrapper class representing physical registers. Should be passed by value.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects.
Align getMaxAlign() const
Return the alignment in bytes that this function must be aligned to, which is greater than the defaul...
uint64_t getMaxCallFrameSize() const
Return the maximum size of a call frame that must be allocated for an outgoing function call.
bool isCalleeSavedInfoValid() const
Has the callee saved info been calculated yet?
const std::vector< CalleeSavedInfo > & getCalleeSavedInfo() const
Returns a reference to call saved info vector for the current function.
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
bool isFixedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a fixed stack object.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
bool hasInlineAsm() const
Returns true if the function contains any inline assembly.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & addFrameIndex(int Idx) const
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addDef(Register RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register definition operand.
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
unsigned getSubReg() const
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
bool isAllocatable(MCRegister PhysReg) const
isAllocatable - Returns true when PhysReg belongs to an allocatable register class and it hasn't been...
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register.
uint64_t determineFrameLayout(const MachineFunction &MF, bool UseEstimate=false, unsigned *NewMaxCallFrameSize=nullptr) const
Determine the frame layout but do not update the machine function.
PPCFunctionInfo - This class is derived from MachineFunction private PowerPC target-specific informat...
int getFramePointerSaveIndex() const
bool usesTOCBasePtr() const
void resolveFrameIndex(MachineInstr &MI, Register BaseReg, int64_t Offset) const override
bool getRegAllocationHints(Register VirtReg, ArrayRef< MCPhysReg > Order, SmallVectorImpl< MCPhysReg > &Hints, const MachineFunction &MF, const VirtRegMap *VRM, const LiveRegMatrix *Matrix) const override
Register getFrameRegister(const MachineFunction &MF) const override
bool hasBasePointer(const MachineFunction &MF) const
Register getBaseRegister(const MachineFunction &MF) const
void prepareDynamicAlloca(MachineBasicBlock::iterator II, Register &NegSizeReg, bool &KillNegSizeReg, Register &FramePointer) const
To accomplish dynamic stack allocation, we have to calculate exact size subtracted from the stack poi...
void lowerCRBitSpilling(MachineBasicBlock::iterator II, unsigned FrameIndex) const
void lowerACCSpilling(MachineBasicBlock::iterator II, unsigned FrameIndex) const
lowerACCSpilling - Generate the code for spilling the accumulator register.
bool requiresFrameIndexScavenging(const MachineFunction &MF) const override
void lowerCRSpilling(MachineBasicBlock::iterator II, unsigned FrameIndex) const
lowerCRSpilling - Generate the code for spilling a CR register.
void lowerDynamicAreaOffset(MachineBasicBlock::iterator II) const
void lowerDynamicAlloc(MachineBasicBlock::iterator II) const
lowerDynamicAlloc - Generate the code for allocating an object in the current frame.
const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID CC) const override
void adjustStackMapLiveOutMask(uint32_t *Mask) const override
bool hasReservedSpillSlot(const MachineFunction &MF, Register Reg, int &FrameIdx) const override
const TargetRegisterClass * getPointerRegClass(const MachineFunction &MF, unsigned Kind=0) const override
getPointerRegClass - Return the register class to use to hold pointers.
bool isCallerPreservedPhysReg(MCRegister PhysReg, const MachineFunction &MF) const override
bool needsFrameBaseReg(MachineInstr *MI, int64_t Offset) const override
Returns true if the instruction's frame index reference would be better served by a base register oth...
const uint32_t * getNoPreservedMask() const override
void lowerCRRestore(MachineBasicBlock::iterator II, unsigned FrameIndex) const
bool eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj, unsigned FIOperandNum, RegScavenger *RS=nullptr) const override
void lowerQuadwordRestore(MachineBasicBlock::iterator II, unsigned FrameIndex) const
lowerQuadwordRestore - Generate code to restore paired general register.
static void emitAccCopyInfo(MachineBasicBlock &MBB, MCRegister DestReg, MCRegister SrcReg)
bool requiresVirtualBaseRegisters(const MachineFunction &MF) const override
void lowerCRBitRestore(MachineBasicBlock::iterator II, unsigned FrameIndex) const
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const override
Code Generation virtual methods...
Register materializeFrameBaseRegister(MachineBasicBlock *MBB, int FrameIdx, int64_t Offset) const override
Insert defining instruction(s) for BaseReg to be a pointer to FrameIdx at the beginning of the basic ...
unsigned getRegPressureLimit(const TargetRegisterClass *RC, MachineFunction &MF) const override
void lowerWACCRestore(MachineBasicBlock::iterator II, unsigned FrameIndex) const
lowerWACCRestore - Generate the code to restore the wide accumulator register.
void lowerPrepareProbedAlloca(MachineBasicBlock::iterator II) const
void lowerQuadwordSpilling(MachineBasicBlock::iterator II, unsigned FrameIndex) const
lowerQuadwordSpilling - Generate code to spill paired general register.
PPCRegisterInfo(const PPCTargetMachine &TM)
bool isFrameOffsetLegal(const MachineInstr *MI, Register BaseReg, int64_t Offset) const override
void lowerWACCSpilling(MachineBasicBlock::iterator II, unsigned FrameIndex) const
lowerWACCSpilling - Generate the code for spilling the wide accumulator register.
void lowerOctWordSpilling(MachineBasicBlock::iterator II, unsigned FrameIndex) const
Remove any STXVP[X] instructions and split them out into a pair of STXV[X] instructions if –disable-a...
bool isAsmClobberable(const MachineFunction &MF, MCRegister PhysReg) const override
BitVector getReservedRegs(const MachineFunction &MF) const override
const TargetRegisterClass * getLargestLegalSuperClass(const TargetRegisterClass *RC, const MachineFunction &MF) const override
void lowerACCRestore(MachineBasicBlock::iterator II, unsigned FrameIndex) const
lowerACCRestore - Generate the code to restore the accumulator register.
bool is32BitELFABI() const
bool isUsingPCRelativeCalls() const
const PPCInstrInfo * getInstrInfo() const override
bool isLittleEndian() const
MCRegister getTOCPointerRegister() const
MCRegister getStackPointerRegister() const
bool is64BitELFABI() const
const PPCRegisterInfo * getRegisterInfo() const override
Common code between 32-bit and 64-bit PowerPC targets.
BitVector getRegsAvailable(const TargetRegisterClass *RC)
Return all available registers in the register class in Mask.
Wrapper class representing virtual and physical registers.
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
static constexpr bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
Align getStackAlign() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
TargetInstrInfo - Interface to description of machine instruction set.
bool isPositionIndependent() const
bool getAIXExtendedAltivecABI() const
unsigned getID() const
Return the register class ID number.
bool contains(Register Reg) const
Return true if the specified register is included in this register class.
sc_iterator getSuperClasses() const
Returns a NULL-terminated list of super-classes.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual const TargetRegisterClass * getLargestLegalSuperClass(const TargetRegisterClass *RC, const MachineFunction &) const
Returns the largest super class of RC that is legal to use in the current sub-target and has the same...
virtual bool getRegAllocationHints(Register VirtReg, ArrayRef< MCPhysReg > Order, SmallVectorImpl< MCPhysReg > &Hints, const MachineFunction &MF, const VirtRegMap *VRM=nullptr, const LiveRegMatrix *Matrix=nullptr) const
Get a list of 'hint' registers that the register allocator should try first when allocating a physica...
A Use represents the edge between a Value definition and its users.
MCRegister getPhys(Register virtReg) const
returns the physical register mapped to the specified virtual register
bool hasPhys(Register virtReg) const
returns true if the specified virtual register is mapped to a physical register
@ AnyReg
OBSOLETED - Used for stack based JavaScript calls.
@ Cold
Attempts to make code in the caller as efficient as possible under the assumption that the call is no...
@ Implicit
Not emitted register (e.g. carry, or temporary result).
@ Kill
The last use of a register.
@ Undef
Value of the register doesn't matter.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
bool isAligned(Align Lhs, uint64_t SizeInBytes)
Checks that SizeInBytes is a multiple of the alignment.
static const MachineInstrBuilder & addFrameReference(const MachineInstrBuilder &MIB, int FI, int Offset=0, bool mem=true)
addFrameReference - This function is used to add a reference to the base of an abstract object on the...
static unsigned getCRFromCRBit(unsigned SrcReg)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
unsigned getKillRegState(bool B)
Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
This struct is a compact representation of a valid (non-zero power of two) alignment.
uint64_t value() const
This is a hole in the type system and should not be abused.