31 #define DEBUG_TYPE "framelowering" 32 STATISTIC(NumPESpillVSR,
"Number of spills to vector in prologue");
33 STATISTIC(NumPEReloadVSR,
"Number of reloads from vector in epilogue");
37 cl::desc(
"Enable spills in prologue to vector registers."),
43 PPC::V0 , PPC::V1 ,
PPC::V2 , PPC::V3 ,
PPC::V4 , PPC::V5 , PPC::V6 , PPC::V7 ,
44 PPC::V8 , PPC::V9 , PPC::V10, PPC::V11, PPC::V12, PPC::V13, PPC::V14, PPC::V15,
45 PPC::V16, PPC::V17, PPC::V18, PPC::V19, PPC::V20, PPC::V21, PPC::V22, PPC::V23,
46 PPC::V24, PPC::V25, PPC::V26, PPC::V27, PPC::V28, PPC::V29, PPC::V30, PPC::V31
69 return STI.
isPPC64() ? -8U : -4U;
72 return STI.
isPPC64() ? -8U : -4U;
85 return STI.
isPPC64() ? -16U : -8U;
100 STI.getPlatformStackAlignment(), 0),
110 unsigned &NumEntries)
const {
114 static const SpillSlot darwin64Offsets = {PPC::X31, -8};
115 return &darwin64Offsets;
117 static const SpillSlot darwinOffsets = {PPC::R31, -4};
118 return &darwinOffsets;
300 assert(MBBI != Entry->
end() && MBBI->getOpcode() == PPC::MTVRSAVE);
301 MBBI->eraseFromParent();
303 bool RemovedAllMTVRSAVEs =
true;
308 if (
I->isReturnBlock()) {
309 bool FoundIt =
false;
310 for (MBBI =
I->end(); MBBI !=
I->begin(); ) {
312 if (MBBI->getOpcode() == PPC::MTVRSAVE) {
313 MBBI->eraseFromParent();
318 RemovedAllMTVRSAVEs &= FoundIt;
324 if (RemovedAllMTVRSAVEs) {
326 assert(MBBI != Entry->
begin() &&
"UPDATE_VRSAVE is first instr in block?");
328 assert(MBBI->getOpcode() == PPC::MFVRSAVE &&
"VRSAVE instrs wandered?");
329 MBBI->eraseFromParent();
345 unsigned UsedRegMask = 0;
346 for (
unsigned i = 0; i != 32; ++i)
348 UsedRegMask |= 1 << (31-i);
354 if (VRRegNo[RegNo] == LI.first)
355 UsedRegMask &= ~(1 << (31-RegNo));
360 UsedRegMask != 0 && BI != BE; ++BI) {
367 if (!MO.
isReg() || !PPC::VRRCRegClass.contains(MO.
getReg()))
370 UsedRegMask &= ~(1 << (31-RegNo));
375 if (UsedRegMask == 0) {
384 if ((UsedRegMask & 0xFFFF) == UsedRegMask) {
385 if (DstReg != SrcReg)
393 }
else if ((UsedRegMask & 0xFFFF0000) == UsedRegMask) {
394 if (DstReg != SrcReg)
397 .
addImm(UsedRegMask >> 16);
401 .
addImm(UsedRegMask >> 16);
403 if (DstReg != SrcReg)
406 .
addImm(UsedRegMask >> 16);
410 .
addImm(UsedRegMask >> 16);
414 .
addImm(UsedRegMask & 0xFFFF);
459 bool UseEstimate)
const {
460 unsigned NewMaxCallFrameSize = 0;
462 &NewMaxCallFrameSize);
473 unsigned *NewMaxCallFrameSize)
const {
484 unsigned AlignMask =
std::max(MaxAlign, TargetAlign) - 1;
488 unsigned LR = RegInfo->getRARegister();
501 if (!DisableRedZone && CanUseRedZone && FitsInRedZone) {
511 maxCallFrameSize =
std::max(maxCallFrameSize, minCallFrameSize);
516 maxCallFrameSize = (maxCallFrameSize + AlignMask) & ~AlignMask;
519 if (NewMaxCallFrameSize)
520 *NewMaxCallFrameSize = maxCallFrameSize;
523 FrameSize += maxCallFrameSize;
526 FrameSize = (FrameSize + AlignMask) & ~AlignMask;
560 unsigned FPReg = is31 ? PPC::R31 : PPC::R1;
561 unsigned FP8Reg = is31 ? PPC::X31 : PPC::X1;
566 unsigned BP8Reg = HasBP ? (
unsigned) PPC::X30 : FP8Reg;
572 for (
unsigned I = 0,
E = MBBI->getNumOperands();
I !=
E; ++
I) {
615 bool TwoUniqueRegsRequired,
617 unsigned *SR2)
const {
619 unsigned R0 = Subtarget.
isPPC64() ? PPC::X0 : PPC::R0;
620 unsigned R12 = Subtarget.
isPPC64() ? PPC::X12 : PPC::R12;
627 assert (SR1 &&
"Asking for the second scratch register but not the first?");
638 if (UseAtEnd && !MBB->
empty()) {
644 if (MBBI == MBB->
end())
645 MBBI = std::prev(MBBI);
647 if (MBBI != MBB->
begin())
670 for (
int i = 0; CSRegs[i]; ++i)
676 *SR1 = FirstScratchReg == -1 ? (
unsigned)PPC::NoRegister : FirstScratchReg;
683 int SecondScratchReg = BV.
find_next(*SR1);
684 if (SecondScratchReg != -1)
685 *SR2 = SecondScratchReg;
687 *SR2 = TwoUniqueRegsRequired ? (
unsigned)PPC::NoRegister : *SR1;
692 if (BV.
count() < (TwoUniqueRegsRequired ? 2U : 1U))
709 int NegFrameSize = -FrameSize;
710 bool IsLargeFrame = !
isInt<16>(NegFrameSize);
715 return (IsLargeFrame || !HasRedZone) && HasBP && MaxAlign > 1;
721 return findScratchRegister(TmpMBB,
false,
722 twoUniqueScratchRegsRequired(TmpMBB));
728 return findScratchRegister(TmpMBB,
true);
731 bool PPCFrameLowering::stackUpdateCanBeMoved(
MachineFunction &MF)
const {
788 bool isPPC64 = Subtarget.
isPPC64();
791 bool isAIXABI = Subtarget.
isAIXABI();
794 "Unsupported PPC ABI.");
799 for (
unsigned i = 0; MBBI != MBB.
end(); ++i, ++MBBI) {
800 if (MBBI->getOpcode() == PPC::UPDATE_VRSAVE) {
813 int NegFrameSize = -FrameSize;
825 bool MustSaveCR = !MustSaveCRs.
empty();
827 bool HasFP =
hasFP(MF);
829 bool HasRedZone = isPPC64 || !isSVR4ABI;
831 unsigned SPReg = isPPC64 ? PPC::X1 : PPC::R1;
833 unsigned FPReg = isPPC64 ? PPC::X31 : PPC::R31;
834 unsigned LRReg = isPPC64 ? PPC::LR8 : PPC::LR;
835 unsigned TOCReg = isPPC64 ? PPC::X2 :
PPC::R2;
836 unsigned ScratchReg = 0;
837 unsigned TempReg = isPPC64 ? PPC::X12 : PPC::R12;
839 const MCInstrDesc& MFLRInst = TII.get(isPPC64 ? PPC::MFLR8
843 const MCInstrDesc& StoreUpdtInst = TII.get(isPPC64 ? PPC::STDU
845 const MCInstrDesc& StoreUpdtIdxInst = TII.get(isPPC64 ? PPC::STDUX
847 const MCInstrDesc& LoadImmShiftedInst = TII.get(isPPC64 ? PPC::LIS8
849 const MCInstrDesc& OrImmInst = TII.get(isPPC64 ? PPC::ORI8
851 const MCInstrDesc& OrInst = TII.get(isPPC64 ? PPC::OR8
853 const MCInstrDesc& SubtractCarryingInst = TII.get(isPPC64 ? PPC::SUBFC8
855 const MCInstrDesc& SubtractImmCarryingInst = TII.get(isPPC64 ? PPC::SUBFIC8
862 assert((isPPC64 || !isSVR4ABI || !(!FrameSize && (MustSaveLR || HasFP))) &&
863 "FrameSize must be >0 to save/restore the FP or LR for 32-bit SVR4.");
866 bool SingleScratchReg =
867 findScratchRegister(&MBB,
false, twoUniqueScratchRegsRequired(&MBB),
868 &ScratchReg, &TempReg);
869 assert(SingleScratchReg &&
870 "Required number of registers not available in this block");
872 SingleScratchReg = ScratchReg == TempReg;
881 assert(FPIndex &&
"No Frame Pointer Save Slot!");
893 assert(BPIndex &&
"No Base Pointer Save Slot!");
904 assert(PBPIndex &&
"No PIC Base Pointer Save Slot!");
910 if (HasBP && MaxAlign > 1)
912 "Invalid alignment!");
916 bool isLargeFrame = !
isInt<16>(NegFrameSize);
918 assert((isPPC64 || !MustSaveCR) &&
919 "Prologue CR saving supported only in 64-bit mode");
921 if (MustSaveCR && isAIXABI)
928 bool MovingStackUpdateDown =
false;
931 if (stackUpdateCanBeMoved(MF)) {
934 int FrIdx = CSI.getFrameIdx();
943 MovingStackUpdateDown =
true;
947 StackUpdateLoc = MBBI;
948 MovingStackUpdateDown =
false;
954 if (MovingStackUpdateDown) {
956 int FrIdx = CSI.getFrameIdx();
965 if (MustSaveCR && SingleScratchReg && MustSaveLR) {
970 unsigned MfcrOpcode = PPC::MFCR8;
972 if (isELFv2ABI && MustSaveCRs.
size() == 1) {
973 MfcrOpcode = PPC::MFOCRF8;
977 BuildMI(MBB, MBBI, dl, TII.get(MfcrOpcode), TempReg);
978 for (
unsigned i = 0,
e = MustSaveCRs.
size(); i !=
e; ++i)
979 MIB.
addReg(MustSaveCRs[i], CrState);
980 BuildMI(MBB, MBBI, dl, TII.get(PPC::STW8))
987 BuildMI(MBB, MBBI, dl, MFLRInst, ScratchReg);
990 !(SingleScratchReg && MustSaveLR)) {
995 unsigned MfcrOpcode = PPC::MFCR8;
997 if (isELFv2ABI && MustSaveCRs.
size() == 1) {
998 MfcrOpcode = PPC::MFOCRF8;
1002 BuildMI(MBB, MBBI, dl, TII.get(MfcrOpcode), TempReg);
1003 for (
unsigned i = 0,
e = MustSaveCRs.
size(); i !=
e; ++i)
1004 MIB.
addReg(MustSaveCRs[i], CrState);
1009 BuildMI(MBB, MBBI, dl, StoreInst)
1014 BuildMI(MBB, MBBI, dl, StoreInst)
1019 BuildMI(MBB, MBBI, dl, StoreInst)
1026 BuildMI(MBB, StackUpdateLoc, dl, StoreInst)
1032 !(SingleScratchReg && MustSaveLR)) {
1033 assert(HasRedZone &&
"A red zone is always available on PPC64");
1034 BuildMI(MBB, MBBI, dl, TII.get(PPC::STW8))
1047 if (HasBP && HasRedZone) {
1049 BuildMI(MBB, MBBI, dl, OrInst, BPReg)
1056 bool HasSTUX =
false;
1059 if (HasBP && MaxAlign > 1) {
1061 BuildMI(MBB, MBBI, dl, TII.get(PPC::RLDICL), ScratchReg)
1066 BuildMI(MBB, MBBI, dl, TII.get(PPC::RLWINM), ScratchReg)
1071 if (!isLargeFrame) {
1072 BuildMI(MBB, MBBI, dl, SubtractImmCarryingInst, ScratchReg)
1076 assert(!SingleScratchReg &&
"Only a single scratch reg available");
1077 BuildMI(MBB, MBBI, dl, LoadImmShiftedInst, TempReg)
1078 .
addImm(NegFrameSize >> 16);
1079 BuildMI(MBB, MBBI, dl, OrImmInst, TempReg)
1081 .
addImm(NegFrameSize & 0xFFFF);
1082 BuildMI(MBB, MBBI, dl, SubtractCarryingInst, ScratchReg)
1087 BuildMI(MBB, MBBI, dl, StoreUpdtIdxInst, SPReg)
1093 }
else if (!isLargeFrame) {
1094 BuildMI(MBB, StackUpdateLoc, dl, StoreUpdtInst, SPReg)
1100 BuildMI(MBB, MBBI, dl, LoadImmShiftedInst, ScratchReg)
1101 .
addImm(NegFrameSize >> 16);
1102 BuildMI(MBB, MBBI, dl, OrImmInst, ScratchReg)
1104 .
addImm(NegFrameSize & 0xFFFF);
1105 BuildMI(MBB, MBBI, dl, StoreUpdtIdxInst, SPReg)
1115 assert(isELFv2ABI &&
"TOC saves in the prologue only supported on ELFv2");
1116 BuildMI(MBB, StackUpdateLoc, dl, TII.get(PPC::STD))
1118 .addImm(TOCSaveOffset)
1123 assert(!isPPC64 &&
"A red zone is always available on PPC64");
1135 BuildMI(MBB, MBBI, dl, TII.get(PPC::SUBF), ScratchReg)
1139 if (ScratchReg == PPC::R0) {
1146 BuildMI(MBB, MBBI, dl, TII.get(PPC::ADDIC), ScratchReg)
1148 .
addImm(FPOffset-LastOffset);
1149 LastOffset = FPOffset;
1151 BuildMI(MBB, MBBI, dl, TII.get(PPC::STWX))
1158 BuildMI(MBB, MBBI, dl, TII.get(PPC::ADDIC), ScratchReg)
1160 .
addImm(PBPOffset-LastOffset);
1161 LastOffset = PBPOffset;
1162 BuildMI(MBB, MBBI, dl, TII.get(PPC::STWX))
1169 BuildMI(MBB, MBBI, dl, TII.get(PPC::ADDIC), ScratchReg)
1171 .
addImm(BPOffset-LastOffset);
1172 LastOffset = BPOffset;
1173 BuildMI(MBB, MBBI, dl, TII.get(PPC::STWX))
1178 BuildMI(MBB, MBBI, dl, TII.get(PPC::ADDIC), BPReg)
1189 BuildMI(MBB, MBBI, dl, StoreInst)
1194 BuildMI(MBB, MBBI, dl, StoreInst)
1199 BuildMI(MBB, MBBI, dl, StoreInst)
1203 BuildMI(MBB, MBBI, dl, OrInst, BPReg)
1214 BuildMI(MBB, MBBI, dl, StoreInst)
1216 .
addImm(FrameSize + FPOffset)
1219 BuildMI(MBB, MBBI, dl, StoreInst)
1221 .
addImm(FrameSize + PBPOffset)
1224 BuildMI(MBB, MBBI, dl, StoreInst)
1226 .
addImm(FrameSize + BPOffset)
1228 BuildMI(MBB, MBBI, dl, TII.get(PPC::ADDI), BPReg)
1252 BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
1253 .addCFIIndex(CFIIndex);
1260 BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
1261 .addCFIIndex(CFIIndex);
1269 BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
1270 .addCFIIndex(CFIIndex);
1278 BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
1279 .addCFIIndex(CFIIndex);
1287 BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
1288 .addCFIIndex(CFIIndex);
1294 BuildMI(MBB, MBBI, dl, OrInst, FPReg)
1298 if (!HasBP && needsCFI) {
1305 BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
1306 .addCFIIndex(CFIIndex);
1314 for (
unsigned I = 0,
E = CSI.size();
I !=
E; ++
I) {
1315 unsigned Reg = CSI[
I].getReg();
1316 if (Reg == PPC::LR || Reg == PPC::LR8 || Reg ==
PPC::RM)
continue;
1320 if (PPC::CRBITRCRegClass.
contains(Reg))
1323 if ((Reg == PPC::X2 || Reg ==
PPC::R2) && MustSaveTOC)
1328 if (isSVR4ABI && (PPC::CR2 <= Reg && Reg <= PPC::CR4)
1334 if (isSVR4ABI && isPPC64 && (PPC::CR2 <= Reg && Reg <= PPC::CR4)) {
1338 unsigned CRReg = isELFv2ABI?
Reg : (
unsigned) PPC::CR2;
1341 BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
1342 .addCFIIndex(CFIIndex);
1346 if (CSI[
I].isSpilledToReg()) {
1347 unsigned SpilledReg = CSI[
I].getDstReg();
1351 BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
1352 .addCFIIndex(CFIRegister);
1358 if (MovingStackUpdateDown)
1359 Offset -= NegFrameSize;
1363 BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
1364 .addCFIIndex(CFIIndex);
1375 if (MBBI != MBB.
end())
1376 dl = MBBI->getDebugLoc();
1388 bool isPPC64 = Subtarget.
isPPC64();
1396 bool MustSaveCR = !MustSaveCRs.
empty();
1398 bool HasFP =
hasFP(MF);
1402 unsigned SPReg = isPPC64 ? PPC::X1 : PPC::R1;
1404 unsigned FPReg = isPPC64 ? PPC::X31 : PPC::R31;
1405 unsigned ScratchReg = 0;
1406 unsigned TempReg = isPPC64 ? PPC::X12 : PPC::R12;
1407 const MCInstrDesc& MTLRInst = TII.get( isPPC64 ? PPC::MTLR8
1411 const MCInstrDesc& LoadImmShiftedInst = TII.get( isPPC64 ? PPC::LIS8
1413 const MCInstrDesc& OrInst = TII.get(isPPC64 ? PPC::OR8
1415 const MCInstrDesc& OrImmInst = TII.get( isPPC64 ? PPC::ORI8
1417 const MCInstrDesc& AddImmInst = TII.get( isPPC64 ? PPC::ADDI8
1419 const MCInstrDesc& AddInst = TII.get( isPPC64 ? PPC::ADD8
1427 bool SingleScratchReg = findScratchRegister(&MBB,
true,
false, &ScratchReg,
1429 assert(SingleScratchReg &&
1430 "Could not find an available scratch register");
1432 SingleScratchReg = ScratchReg == TempReg;
1437 assert(FPIndex &&
"No Frame Pointer Save Slot!");
1448 assert(BPIndex &&
"No Base Pointer Save Slot!");
1458 assert(PBPIndex &&
"No PIC Base Pointer Save Slot!");
1462 bool IsReturnBlock = (MBBI != MBB.
end() && MBBI->isReturn());
1464 if (IsReturnBlock) {
1465 unsigned RetOpcode = MBBI->getOpcode();
1466 bool UsesTCRet = RetOpcode == PPC::TCRETURNri ||
1467 RetOpcode == PPC::TCRETURNdi ||
1468 RetOpcode == PPC::TCRETURNai ||
1469 RetOpcode == PPC::TCRETURNri8 ||
1470 RetOpcode == PPC::TCRETURNdi8 ||
1471 RetOpcode == PPC::TCRETURNai8;
1476 assert(StackAdjust.
isImm() &&
"Expecting immediate value.");
1478 int StackAdj = StackAdjust.
getImm();
1479 int Delta = StackAdj - MaxTCRetDelta;
1480 assert((Delta >= 0) &&
"Delta must be positive");
1481 if (MaxTCRetDelta>0)
1482 FrameSize += (StackAdj +Delta);
1484 FrameSize += StackAdj;
1490 bool isLargeFrame = !
isInt<16>(FrameSize);
1504 unsigned RBReg = SPReg;
1512 if (stackUpdateCanBeMoved(MF)) {
1515 int FrIdx = CSI.getFrameIdx();
1527 StackUpdateLoc = MBBI;
1543 assert(HasFP &&
"Expecting a valid frame pointer.");
1546 if (!isLargeFrame) {
1547 BuildMI(MBB, MBBI, dl, AddImmInst, RBReg)
1550 BuildMI(MBB, MBBI, dl, LoadImmShiftedInst, ScratchReg)
1551 .
addImm(FrameSize >> 16);
1552 BuildMI(MBB, MBBI, dl, OrImmInst, ScratchReg)
1554 .
addImm(FrameSize & 0xFFFF);
1555 BuildMI(MBB, MBBI, dl, AddInst)
1562 BuildMI(MBB, StackUpdateLoc, dl, AddImmInst, SPReg)
1568 assert(FPOffset <= 0 && BPOffset <= 0 && PBPOffset <= 0 &&
1569 "Local offsets should be negative");
1571 FPOffset += FrameSize;
1572 BPOffset += FrameSize;
1573 PBPOffset += FrameSize;
1581 BuildMI(MBB, MBBI, dl, OrInst, ScratchReg)
1586 BuildMI(MBB, StackUpdateLoc, dl, LoadInst, RBReg)
1591 assert(RBReg != ScratchReg &&
"Should have avoided ScratchReg");
1596 assert((isPPC64 || !MustSaveCR) &&
1597 "Epilogue CR restoring supported only in 64-bit mode");
1601 if (MustSaveCR && SingleScratchReg && MustSaveLR) {
1604 assert(HasRedZone &&
"Expecting red zone");
1605 BuildMI(MBB, MBBI, dl, TII.get(PPC::LWZ8), TempReg)
1608 for (
unsigned i = 0,
e = MustSaveCRs.
size(); i !=
e; ++i)
1609 BuildMI(MBB, MBBI, dl, TII.get(PPC::MTOCRF8), MustSaveCRs[i])
1617 bool LoadedLR =
false;
1618 if (MustSaveLR && RBReg == SPReg &&
isInt<16>(LROffset+SPAdd)) {
1619 BuildMI(MBB, StackUpdateLoc, dl, LoadInst, ScratchReg)
1625 if (MustSaveCR && !(SingleScratchReg && MustSaveLR)) {
1627 assert(isPPC64 &&
"Expecting 64-bit mode");
1628 assert(RBReg == SPReg &&
"Should be using SP as a base register");
1629 BuildMI(MBB, MBBI, dl, TII.get(PPC::LWZ8), TempReg)
1637 if (HasRedZone || RBReg == SPReg)
1638 BuildMI(MBB, MBBI, dl, LoadInst, FPReg)
1642 BuildMI(MBB, MBBI, dl, LoadInst, ScratchReg)
1648 BuildMI(MBB, MBBI, dl, LoadInst, PPC::R30)
1653 BuildMI(MBB, MBBI, dl, LoadInst, BPReg)
1659 if (RBReg != SPReg || SPAdd != 0) {
1660 assert(!HasRedZone &&
"This should not happen with red zone");
1663 BuildMI(MBB, MBBI, dl, OrInst, SPReg)
1667 BuildMI(MBB, MBBI, dl, AddImmInst, SPReg)
1671 assert(RBReg != ScratchReg &&
"Should be using FP or SP as base register");
1673 BuildMI(MBB, MBBI, dl, OrInst, FPReg)
1678 if (MustSaveLR && !LoadedLR)
1679 BuildMI(MBB, MBBI, dl, LoadInst, ScratchReg)
1685 !(SingleScratchReg && MustSaveLR))
1686 for (
unsigned i = 0,
e = MustSaveCRs.
size(); i !=
e; ++i)
1687 BuildMI(MBB, MBBI, dl, TII.get(PPC::MTOCRF8), MustSaveCRs[i])
1691 BuildMI(MBB, StackUpdateLoc, dl, MTLRInst).
addReg(ScratchReg);
1695 if (IsReturnBlock) {
1696 unsigned RetOpcode = MBBI->getOpcode();
1698 (RetOpcode == PPC::BLR || RetOpcode == PPC::BLR8) &&
1703 if (CallerAllocatedAmt &&
isInt<16>(CallerAllocatedAmt)) {
1704 BuildMI(MBB, MBBI, dl, AddImmInst, SPReg)
1707 BuildMI(MBB, MBBI, dl, LoadImmShiftedInst, ScratchReg)
1708 .
addImm(CallerAllocatedAmt >> 16);
1709 BuildMI(MBB, MBBI, dl, OrImmInst, ScratchReg)
1711 .
addImm(CallerAllocatedAmt & 0xFFFF);
1712 BuildMI(MBB, MBBI, dl, AddInst)
1718 createTailCallBranchInstr(MBB);
1723 void PPCFrameLowering::createTailCallBranchInstr(
MachineBasicBlock &MBB)
const {
1727 assert(MBBI != MBB.
end() &&
"Failed to find the first terminator.");
1733 unsigned RetOpcode = MBBI->getOpcode();
1734 if (RetOpcode == PPC::TCRETURNdi) {
1737 BuildMI(MBB, MBBI, dl, TII.get(PPC::TAILB)).
1739 }
else if (RetOpcode == PPC::TCRETURNri) {
1741 assert(MBBI->getOperand(0).isReg() &&
"Expecting register operand.");
1742 BuildMI(MBB, MBBI, dl, TII.get(PPC::TAILBCTR));
1743 }
else if (RetOpcode == PPC::TCRETURNai) {
1746 BuildMI(MBB, MBBI, dl, TII.get(PPC::TAILBA)).addImm(JumpTarget.
getImm());
1747 }
else if (RetOpcode == PPC::TCRETURNdi8) {
1750 BuildMI(MBB, MBBI, dl, TII.get(PPC::TAILB8)).
1752 }
else if (RetOpcode == PPC::TCRETURNri8) {
1754 assert(MBBI->getOperand(0).isReg() &&
"Expecting register operand.");
1755 BuildMI(MBB, MBBI, dl, TII.get(PPC::TAILBCTR8));
1756 }
else if (RetOpcode == PPC::TCRETURNai8) {
1759 BuildMI(MBB, MBBI, dl, TII.get(PPC::TAILBA8)).addImm(JumpTarget.
getImm());
1772 unsigned LR = RegInfo->getRARegister();
1774 SavedRegs.
reset(LR);
1778 const bool isPPC64 = Subtarget.
isPPC64();
1813 SavedRegs.
reset(isPPC64 ? PPC::X31 : PPC::R31);
1817 SavedRegs.
reset(PPC::R30);
1828 if (!isPPC64 && !IsDarwinABI &&
1829 (SavedRegs.
test(PPC::CR2) ||
1830 SavedRegs.
test(PPC::CR3) ||
1831 SavedRegs.
test(PPC::CR4))) {
1857 createTailCallBranchInstr(MBB);
1862 if (CSI.empty() && !
needsFP(MF)) {
1867 unsigned MinGPR = PPC::R31;
1868 unsigned MinG8R = PPC::X31;
1869 unsigned MinFPR = PPC::F31;
1870 unsigned MinVR = Subtarget.
hasSPE() ? PPC::S31 : PPC::V31;
1872 bool HasGPSaveArea =
false;
1873 bool HasG8SaveArea =
false;
1874 bool HasFPSaveArea =
false;
1875 bool HasVRSAVESaveArea =
false;
1876 bool HasVRSaveArea =
false;
1883 for (
unsigned i = 0,
e = CSI.size(); i !=
e; ++i) {
1884 unsigned Reg = CSI[i].getReg();
1886 (Reg != PPC::X2 && Reg !=
PPC::R2)) &&
1887 "Not expecting to try to spill R2 in a function that must save TOC");
1888 if (PPC::GPRCRegClass.
contains(Reg)) {
1889 HasGPSaveArea =
true;
1896 }
else if (PPC::G8RCRegClass.
contains(Reg)) {
1897 HasG8SaveArea =
true;
1904 }
else if (PPC::F8RCRegClass.
contains(Reg)) {
1905 HasFPSaveArea =
true;
1912 }
else if (PPC::CRBITRCRegClass.
contains(Reg) ||
1915 }
else if (PPC::VRSAVERCRegClass.
contains(Reg)) {
1916 HasVRSAVESaveArea =
true;
1917 }
else if (PPC::VRRCRegClass.
contains(Reg) ||
1918 PPC::SPERCRegClass.
contains(Reg)) {
1921 HasVRSaveArea =
true;
1936 int64_t LowerBound = 0;
1942 LowerBound = TCSPDelta;
1947 if (HasFPSaveArea) {
1948 for (
unsigned i = 0,
e = FPRegs.
size(); i !=
e; ++i) {
1949 int FI = FPRegs[i].getFrameIdx();
1954 LowerBound -= (31 - TRI->getEncodingValue(MinFPR) + 1) * 8;
1961 assert(FI &&
"No Frame Pointer Save Slot!");
1964 HasGPSaveArea =
true;
1969 assert(FI &&
"No PIC Base Pointer Save Slot!");
1972 MinGPR = std::min<unsigned>(MinGPR, PPC::R30);
1973 HasGPSaveArea =
true;
1979 assert(FI &&
"No Base Pointer Save Slot!");
1983 if (PPC::G8RCRegClass.
contains(BP)) {
1984 MinG8R = std::min<unsigned>(MinG8R, BP);
1985 HasG8SaveArea =
true;
1986 }
else if (PPC::GPRCRegClass.
contains(BP)) {
1987 MinGPR = std::min<unsigned>(MinGPR, BP);
1988 HasGPSaveArea =
true;
1994 if (HasGPSaveArea || HasG8SaveArea) {
1997 for (
unsigned i = 0,
e = GPRegs.
size(); i !=
e; ++i) {
1998 if (!GPRegs[i].isSpilledToReg()) {
1999 int FI = GPRegs[i].getFrameIdx();
2006 for (
unsigned i = 0,
e = G8Regs.
size(); i !=
e; ++i) {
2007 if (!G8Regs[i].isSpilledToReg()) {
2008 int FI = G8Regs[i].getFrameIdx();
2014 std::min<unsigned>(TRI->getEncodingValue(MinGPR),
2015 TRI->getEncodingValue(MinG8R));
2018 LowerBound -= (31 - MinReg + 1) * 8;
2020 LowerBound -= (31 - MinReg + 1) * 4;
2031 for (
unsigned i = 0,
e = CSI.size(); i !=
e; ++i) {
2032 unsigned Reg = CSI[i].getReg();
2034 if ((Subtarget.
isSVR4ABI() && Reg == PPC::CR2)
2037 (PPC::CRBITRCRegClass.contains(Reg) ||
2038 PPC::CRRCRegClass.contains(Reg)))) {
2039 int FI = CSI[i].getFrameIdx();
2048 if (HasVRSAVESaveArea) {
2052 for (
unsigned i = 0,
e = CSI.size(); i !=
e; ++i) {
2053 unsigned Reg = CSI[i].getReg();
2055 if (PPC::VRSAVERCRegClass.
contains(Reg)) {
2056 int FI = CSI[i].getFrameIdx();
2067 if (HasVRSaveArea) {
2073 assert(LowerBound <= 0 &&
"Expect LowerBound have a non-positive value!");
2074 LowerBound &= ~(15);
2076 for (
unsigned i = 0,
e = VRegs.
size(); i !=
e; ++i) {
2077 int FI = VRegs[i].getFrameIdx();
2132 std::vector<CalleeSavedInfo> &CSI)
const {
2146 const MCPhysReg *CSRegs = RegInfo->getCalleeSavedRegs(&MF);
2147 for (
unsigned i = 0; CSRegs[i]; ++i)
2148 BVCalleeSaved.set(CSRegs[i]);
2153 if (BVCalleeSaved[
Reg] ||
2160 bool AllSpilledToReg =
true;
2161 for (
auto &CS : CSI) {
2162 if (BVAllocatable.
none())
2165 unsigned Reg = CS.getReg();
2166 if (!PPC::G8RCRegClass.
contains(Reg) && !PPC::GPRCRegClass.
contains(Reg)) {
2167 AllSpilledToReg =
false;
2171 unsigned VolatileVFReg = BVAllocatable.
find_first();
2172 if (VolatileVFReg < BVAllocatable.
size()) {
2173 CS.setDstReg(VolatileVFReg);
2174 BVAllocatable.
reset(VolatileVFReg);
2176 AllSpilledToReg =
false;
2179 return AllSpilledToReg;
2186 const std::vector<CalleeSavedInfo> &CSI,
2199 bool CRSpilled =
false;
2202 for (
unsigned i = 0,
e = CSI.size(); i !=
e; ++i) {
2203 unsigned Reg = CSI[i].getReg();
2207 if (Reg == PPC::VRSAVE && !Subtarget.
isDarwinABI())
2211 bool IsCRField = PPC::CR2 <= Reg && Reg <= PPC::CR4;
2223 if (CRSpilled && IsCRField) {
2229 if ((Reg == PPC::X2 || Reg ==
PPC::R2) && MustSaveTOC)
2244 CRMIB =
BuildMI(*MF, DL, TII.get(PPC::MFCR), PPC::R12)
2251 CSI[i].getFrameIdx()));
2254 if (CSI[i].isSpilledToReg()) {
2256 BuildMI(MBB, MI, DL, TII.get(PPC::MTVSRD), CSI[i].getDstReg())
2264 CSI[i].getFrameIdx(), RC, TRI);
2273 bool CR2Spilled,
bool CR3Spilled,
bool CR4Spilled,
2275 const std::vector<CalleeSavedInfo> &CSI,
unsigned CSIIndex) {
2289 CSI[CSIIndex].getFrameIdx()));
2290 RestoreOp = PPC::MTOCRF;
2295 MBB.
insert(MI,
BuildMI(*MF, DL, TII.get(RestoreOp), PPC::CR2)
2299 MBB.
insert(MI,
BuildMI(*MF, DL, TII.get(RestoreOp), PPC::CR3)
2303 MBB.
insert(MI,
BuildMI(*MF, DL, TII.get(RestoreOp), PPC::CR4)
2312 I->getOpcode() == PPC::ADJCALLSTACKUP) {
2314 if (
int CalleeAmt = I->getOperand(1).getImm()) {
2317 unsigned StackReg = is64Bit ? PPC::X1 : PPC::R1;
2318 unsigned TmpReg = is64Bit ? PPC::X0 : PPC::R0;
2319 unsigned ADDIInstr = is64Bit ? PPC::ADDI8 : PPC::ADDI;
2320 unsigned ADDInstr = is64Bit ? PPC::ADD8 : PPC::ADD4;
2321 unsigned LISInstr = is64Bit ? PPC::LIS8 : PPC::LIS;
2322 unsigned ORIInstr = is64Bit ? PPC::ORI8 : PPC::ORI;
2323 const DebugLoc &dl = I->getDebugLoc();
2326 BuildMI(MBB, I, dl, TII.
get(ADDIInstr), StackReg)
2331 BuildMI(MBB, MBBI, dl, TII.
get(LISInstr), TmpReg)
2332 .addImm(CalleeAmt >> 16);
2333 BuildMI(MBB, MBBI, dl, TII.
get(ORIInstr), TmpReg)
2335 .
addImm(CalleeAmt & 0xFFFF);
2336 BuildMI(MBB, MBBI, dl, TII.
get(ADDInstr), StackReg)
2343 return MBB.
erase(I);
2349 std::vector<CalleeSavedInfo> &CSI,
2361 bool CR2Spilled =
false;
2362 bool CR3Spilled =
false;
2363 bool CR4Spilled =
false;
2364 unsigned CSIIndex = 0;
2369 bool AtStart = I == MBB.
begin();
2374 for (
unsigned i = 0,
e = CSI.size(); i !=
e; ++i) {
2375 unsigned Reg = CSI[i].getReg();
2380 if (Reg == PPC::VRSAVE && !Subtarget.
isDarwinABI())
2383 if ((Reg == PPC::X2 || Reg ==
PPC::R2) && MustSaveTOC)
2386 if (Reg == PPC::CR2) {
2392 }
else if (Reg == PPC::CR3) {
2395 }
else if (Reg == PPC::CR4) {
2401 if ((CR2Spilled || CR3Spilled || CR4Spilled)
2402 && !(PPC::CR2 <= Reg && Reg <= PPC::CR4)) {
2405 CR2Spilled, CR3Spilled, CR4Spilled,
2406 MBB,
I, CSI, CSIIndex);
2407 CR2Spilled = CR3Spilled = CR4Spilled =
false;
2410 if (CSI[i].isSpilledToReg()) {
2413 BuildMI(MBB, I, DL, TII.get(PPC::MFVSRD),
Reg)
2420 "loadRegFromStackSlot didn't insert any code!");
2434 if (CR2Spilled || CR3Spilled || CR4Spilled) {
2437 MBB,
I, CSI, CSIIndex);
2444 return TOCSaveOffset;
2450 return FramePointerSaveOffset;
2456 return BasePointerSaveOffset;
BitVector getAllocatableSet(const MachineFunction &MF, const TargetRegisterClass *RC=nullptr) const
Returns a bitset indexed by register number indicating if a register is allocatable or not...
bool hasStackMap() const
This method may be called any time after instruction selection is complete to determine if there is a...
bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI) const override
spillCalleeSavedRegisters - Issues instruction(s) to spill all callee saved registers and returns tru...
const SpillSlot * getCalleeSavedSpillSlots(unsigned &NumEntries) const override
getCalleeSavedSpillSlots - This method returns a pointer to an array of pairs, that contains an entry...
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
bool isVRSAVESpilled() const
int getFramePointerSaveIndex() const
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
bool isPPC64() const
isPPC64 - Return true if we are generating code for 64-bit pointer mode.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
void addMustSaveCR(unsigned Reg)
bool isPhysRegModified(unsigned PhysReg, bool SkipNoReturnDef=false) const
Return true if the specified register is modified in this function.
void push_back(const T &Elt)
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
LLVM_NODISCARD unsigned addFrameInst(const MCCFIInstruction &Inst)
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
Describe properties that are true of each instruction in the target description file.
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int Offset)
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
static cl::opt< bool > EnablePEVectorSpills("ppc-enable-pe-vector-spills", cl::desc("Enable spills in prologue to vector registers."), cl::init(false), cl::Hidden)
unsigned determineFrameLayout(const MachineFunction &MF, bool UseEstimate=false, unsigned *NewMaxCallFrameSize=nullptr) const
Determine the frame layout but do not update the machine function.
MachineBasicBlock::iterator eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const override
This method is called during prolog/epilog code insertion to eliminate call frame setup and destroy p...
bool test(unsigned Idx) const
void setFramePointerSaveIndex(int Idx)
static unsigned computeTOCSaveOffset(const PPCSubtarget &STI)
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
constexpr bool isInt< 16 >(int64_t x)
STATISTIC(NumFunctions, "Total number of functions")
unsigned const TargetRegisterInfo * TRI
bool adjustsStack() const
Return true if this function adjusts the stack – e.g., when calling another function.
MachineModuleInfo & getMMI() const
An instruction for reading from memory.
static MCCFIInstruction createDefCfaOffset(MCSymbol *L, int Offset)
.cfi_def_cfa_offset modifies a rule for computing CFA.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
unsigned determineFrameLayoutAndUpdate(MachineFunction &MF, bool UseEstimate=false) const
Determine the frame layout and update the machine function.
unsigned getSpillSize(const TargetRegisterClass &RC) const
Return the size in bytes of the stack slot allocated to hold a spilled copy of a register from class ...
return AArch64::GPR64RegClass contains(Reg)
virtual void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
static void restoreCRs(bool isPPC64, bool is31, bool CR2Spilled, bool CR3Spilled, bool CR4Spilled, MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector< CalleeSavedInfo > &CSI, unsigned CSIIndex)
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override
unsigned getSpillAlignment(const TargetRegisterClass &RC) const
Return the minimum required alignment in bytes for a spill slot for a register of this class...
bool isFrameAddressTaken() const
This method may be called any time after instruction selection is complete to determine if there is a...
bool isReturnBlock() const
Convenience function that returns true if the block ends in a return instruction. ...
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
PPCFunctionInfo - This class is derived from MachineFunction private PowerPC target-specific informat...
const HexagonInstrInfo * TII
unsigned getNumOperands() const
Retuns the total number of operands.
MachineBasicBlock * getRestorePoint() const
int find_first() const
find_first - Returns the index of the first set bit, -1 if none of the bits are set.
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
void processFunctionBeforeFrameFinalized(MachineFunction &MF, RegScavenger *RS=nullptr) const override
processFunctionBeforeFrameFinalized - This method is called immediately before the specified function...
int find_next(unsigned Prev) const
find_next - Returns the index of the next set bit following the "Prev" bit.
void addScavengingSpillSlot(MachineFunction &MF, RegScavenger *RS) const
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
def_iterator def_begin(unsigned RegNo) const
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register...
static bool hasNonRISpills(const MachineFunction &MF)
void forward()
Move the internal MBB iterator and update register states.
int getDwarfRegNum(MCRegister RegNum, bool isEH) const
Map a target register to an equivalent dwarf register number.
const SmallVectorImpl< unsigned > & getMustSaveCRs() const
bool canUseAsEpilogue(const MachineBasicBlock &MBB) const override
Check whether or not the given MBB can be used as a epilogue for the target.
void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const override
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
BitVector getRegsAvailable(const TargetRegisterClass *RC)
Return all available registers in the register class in Mask.
bool DisableFramePointerElim(const MachineFunction &MF) const
DisableFramePointerElim - This returns true if frame pointer elimination optimization should be disab...
const MCContext & getContext() const
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
bool hasNonRISpills() const
const PPCTargetMachine & getTargetMachine() const
iterator getLastNonDebugInstr()
Returns an iterator to the last non-debug instruction in the basic block, or end().
An instruction for storing to memory.
void setReg(Register Reg)
Change the register this operand corresponds to.
bool hasBasePointer(const MachineFunction &MF) const
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
Analysis containing CSE Info
unsigned getKillRegState(bool B)
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
TargetInstrInfo - Interface to description of machine instruction set.
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const override
Code Generation virtual methods...
int getBasePointerSaveIndex() const
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
unsigned getNumRegs() const
Return the number of registers this target has (useful for sizing arrays holding per register informa...
initializer< Ty > init(const Ty &Val)
This file declares the machine register scavenger class.
unsigned const MachineRegisterInfo * MRI
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register)
.cfi_def_cfa_register modifies a rule for computing CFA.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
bool canUseAsPrologue(const MachineBasicBlock &MBB) const override
Methods used by shrink wrapping to determine if MBB can be used for the function prologue/epilogue.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void setStackSize(uint64_t Size)
Set the size of the stack.
bool requiresFrameIndexScavenging(const MachineFunction &MF) const override
bool isRegUsed(Register Reg, bool includeReserved=true) const
Return if a specific register is currently used.
bool isFixedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a fixed stack object.
const GlobalValue * getGlobal() const
bool enableShrinkWrapping(const MachineFunction &MF) const override
Returns true if the target will correctly handle shrink wrapping.
unsigned getMaxAlignment() const
Return the alignment in bytes that this function must be aligned to, which is greater than the defaul...
int getTailCallSPDelta() const
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
static unsigned computeReturnSaveOffset(const PPCSubtarget &STI)
void setBasePointerSaveIndex(int Idx)
unsigned GuaranteedTailCallOpt
GuaranteedTailCallOpt - This flag is enabled when -tailcallopt is specified on the commandline...
bool assignCalleeSavedSpillSlots(MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI) const override
This function will assign callee saved gprs to volatile vector registers for prologue spills when app...
uint16_t getEncodingValue(MCRegister RegNo) const
Returns the encoding for RegNo.
bool shrinkWrapDisabled() const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
const MachineBasicBlock & front() const
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static unsigned computeBasePointerSaveOffset(const PPCSubtarget &STI)
This struct is a compact representation of a valid (non-zero power of two) 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...
unsigned getFramePointerSaveOffset() const
getFramePointerSaveOffset - Return the previous frame offset to save the frame pointer.
void setCRSpillFrameIndex(int idx)
bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI) const override
restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee saved registers and returns...
const PPCRegisterInfo * getRegisterInfo() const override
Iterator for intrusive lists based on ilist_node.
constexpr bool isInt< 32 >(int64_t x)
size_type count() const
count - Returns the number of bits which are set.
Align max(MaybeAlign Lhs, Align Rhs)
unsigned getMaxCallFrameSize() const
Return the maximum size of a call frame that must be allocated for an outgoing function call...
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
const PPCInstrInfo * getInstrInfo() const override
void addScavengingFrameIndex(int FI)
Add a scavenging frame index.
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
constexpr size_t array_lengthof(T(&)[N])
Find the length of an array.
Information about stack frame layout on the target.
int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool IsImmutable, bool isAliased=false)
Create a new object at a fixed location on the stack.
Register getBaseRegister(const MachineFunction &MF) const
static bool spillsVRSAVE(const MachineFunction &MF)
static bool hasSpills(const MachineFunction &MF)
const Function & getFunction() const
Return the LLVM function that this machine code represents.
unsigned getMinReservedArea() const
The CalleeSavedInfo class tracks the information need to locate where a callee saved register is in t...
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
bool isPhysRegUsed(unsigned PhysReg) const
Return true if the specified register is modified or read in this function.
static bool spillsCR(const MachineFunction &MF)
unsigned getRedZoneSize() const
ArrayRef< std::pair< unsigned, unsigned > > liveins() const
unsigned getTOCSaveOffset() const
getTOCSaveOffset - Return the previous frame offset to save the TOC register – 64-bit SVR4 ABI only...
int getPICBasePointerSaveIndex() const
static bool MustSaveLR(const MachineFunction &MF, unsigned LR)
MustSaveLR - Return true if this function requires that we save the LR register onto the stack in the...
unsigned getBasePointerSaveOffset() const
getBasePointerSaveOffset - Return the previous frame offset to save the base pointer.
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
bool none() const
none - Returns true if none of the bits are set.
void setPICBasePointerSaveIndex(int Idx)
bool isLiveIn(unsigned Reg) const
Representation of each machine instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
uint64_t estimateStackSize(const MachineFunction &MF) const
Estimate and return the size of the stack frame.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
void enterBasicBlock(MachineBasicBlock &MBB)
Start tracking liveness from the begin of basic block MBB.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
unsigned getCRSaveOffset() const
getCRSaveOffset - Return the previous frame offset to save the CR register.
LLVM_NODISCARD bool empty() const
const std::vector< CalleeSavedInfo > & getCalleeSavedInfo() const
Returns a reference to call saved info vector for the current function.
bool isPositionIndependent() const
static void HandleVRSaveUpdate(MachineInstr &MI, const TargetInstrInfo &TII)
PPCFrameLowering(const PPCSubtarget &STI)
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
int64_t getOffset() const
Return the offset from the symbol in this operand.
void setMaxCallFrameSize(unsigned S)
bool needsFP(const MachineFunction &MF) const
static unsigned computeCRSaveOffset()
unsigned getReturnSaveOffset() const
getReturnSaveOffset - Return the previous frame offset to save the return address.
size_type size() const
size - Returns the number of bits in this bitvector.
bool isLRStoreRequired() const
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
static unsigned computeFramePointerSaveOffset(const PPCSubtarget &STI)
const TargetRegisterClass * getMinimalPhysRegClass(unsigned Reg, MVT VT=MVT::Other) const
Returns the Register Class of a physical register of the given type, picking the most sub register cl...
bool isReg() const
isReg - Tests if this is a MO_Register operand.
static void RemoveVRSaveCode(MachineInstr &MI)
RemoveVRSaveCode - We have found that this function does not need any code to manipulate the VRSAVE r...
unsigned getLinkageSize() const
getLinkageSize - Return the size of the PowerPC ABI linkage area.
MachineBasicBlock * getSavePoint() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static def_iterator def_end()
int CreateStackObject(uint64_t Size, Align Alignment, bool isSpillSlot, const AllocaInst *Alloca=nullptr, uint8_t ID=0)
Create a new statically sized stack object, returning a nonnegative identifier to represent it...
const MCRegisterInfo * getRegisterInfo() const
iterator_range< const_set_bits_iterator > set_bits() const
Fast - This calling convention attempts to make calls as fast as possible (e.g.
void setObjectOffset(int ObjectIdx, int64_t SPOffset)
Set the stack frame offset of the specified object.
bool hasPatchPoint() const
This method may be called any time after instruction selection is complete to determine if there is a...
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
Register getReg() const
getReg - Returns the register number.
const MachineOperand & getOperand(unsigned i) const
static const MCPhysReg VRRegNo[]
VRRegNo - Map from a numbered VR register to its enum value.
reg_begin/reg_end - Provide iteration support to walk over all definitions and uses of a register wit...
bool hasTailCall() const
Returns true if the function contains a tail call.
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects...
bool needsFrameMoves() const
True if this function needs frame moves for debug or exceptions.
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
static bool is64Bit(const char *name)
static unsigned computeLinkageSize(const PPCSubtarget &STI)
void setMustSaveLR(bool U)
MustSaveLR - This is set when the prolog/epilog inserter does its initial scan of the function...
static MCCFIInstruction createRegister(MCSymbol *L, unsigned Register1, unsigned Register2)
.cfi_register Previous value of Register1 is saved in register Register2.
Wrapper class representing virtual and physical registers.
void replaceFPWithRealFP(MachineFunction &MF) const
This class contains meta information specific to a module.
bool hasCalls() const
Return true if the current function has any function calls.