32 #define DEBUG_TYPE "framelowering" 33 STATISTIC(NumNoNeedForFrame,
"Number of functions without frames");
34 STATISTIC(NumPESpillVSR,
"Number of spills to vector in prologue");
35 STATISTIC(NumPEReloadVSR,
"Number of reloads from vector in epilogue");
39 cl::desc(
"Enable spills in prologue to vector registers."),
45 PPC::V0 , PPC::V1 ,
PPC::V2 , PPC::V3 ,
PPC::V4 , PPC::V5 , PPC::V6 , PPC::V7 ,
46 PPC::V8 , PPC::V9 , PPC::V10, PPC::V11, PPC::V12, PPC::V13, PPC::V14, PPC::V15,
47 PPC::V16, PPC::V17, PPC::V18, PPC::V19, PPC::V20, PPC::V21, PPC::V22, PPC::V23,
48 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;
95 STI.getPlatformStackAlignment(), 0),
104 unsigned &NumEntries)
const {
108 static const SpillSlot darwin64Offsets = {PPC::X31, -8};
109 return &darwin64Offsets;
111 static const SpillSlot darwinOffsets = {PPC::R31, -4};
112 return &darwinOffsets;
294 assert(MBBI != Entry->
end() && MBBI->getOpcode() == PPC::MTVRSAVE);
295 MBBI->eraseFromParent();
297 bool RemovedAllMTVRSAVEs =
true;
302 if (
I->isReturnBlock()) {
303 bool FoundIt =
false;
304 for (MBBI =
I->end(); MBBI !=
I->begin(); ) {
306 if (MBBI->getOpcode() == PPC::MTVRSAVE) {
307 MBBI->eraseFromParent();
312 RemovedAllMTVRSAVEs &= FoundIt;
318 if (RemovedAllMTVRSAVEs) {
320 assert(MBBI != Entry->
begin() &&
"UPDATE_VRSAVE is first instr in block?");
322 assert(MBBI->getOpcode() == PPC::MFVRSAVE &&
"VRSAVE instrs wandered?");
323 MBBI->eraseFromParent();
339 unsigned UsedRegMask = 0;
340 for (
unsigned i = 0; i != 32; ++i)
342 UsedRegMask |= 1 << (31-i);
348 if (VRRegNo[RegNo] == LI.first)
349 UsedRegMask &= ~(1 << (31-RegNo));
354 UsedRegMask != 0 && BI != BE; ++BI) {
361 if (!MO.
isReg() || !PPC::VRRCRegClass.contains(MO.
getReg()))
364 UsedRegMask &= ~(1 << (31-RegNo));
369 if (UsedRegMask == 0) {
378 if ((UsedRegMask & 0xFFFF) == UsedRegMask) {
379 if (DstReg != SrcReg)
387 }
else if ((UsedRegMask & 0xFFFF0000) == UsedRegMask) {
388 if (DstReg != SrcReg)
391 .
addImm(UsedRegMask >> 16);
395 .
addImm(UsedRegMask >> 16);
397 if (DstReg != SrcReg)
400 .
addImm(UsedRegMask >> 16);
404 .
addImm(UsedRegMask >> 16);
408 .
addImm(UsedRegMask & 0xFFFF);
453 bool UseEstimate)
const {
463 unsigned AlignMask =
std::max(MaxAlign, TargetAlign) - 1;
467 unsigned LR = RegInfo->getRARegister();
479 if (!DisableRedZone && CanUseRedZone && FitsInRedZone) {
492 maxCallFrameSize =
std::max(maxCallFrameSize, minCallFrameSize);
497 maxCallFrameSize = (maxCallFrameSize + AlignMask) & ~AlignMask;
504 FrameSize += maxCallFrameSize;
507 FrameSize = (FrameSize + AlignMask) & ~AlignMask;
545 unsigned FPReg = is31 ? PPC::R31 : PPC::R1;
546 unsigned FP8Reg = is31 ? PPC::X31 : PPC::X1;
551 unsigned BP8Reg = HasBP ? (
unsigned) PPC::X30 : FP8Reg;
557 for (
unsigned I = 0,
E = MBBI->getNumOperands();
I !=
E; ++
I) {
600 bool TwoUniqueRegsRequired,
602 unsigned *SR2)
const {
604 unsigned R0 = Subtarget.
isPPC64() ? PPC::X0 : PPC::R0;
605 unsigned R12 = Subtarget.
isPPC64() ? PPC::X12 : PPC::R12;
612 assert (SR1 &&
"Asking for the second scratch register but not the first?");
623 if (UseAtEnd && !MBB->
empty()) {
629 if (MBBI == MBB->
end())
630 MBBI = std::prev(MBBI);
632 if (MBBI != MBB->
begin())
655 for (
int i = 0; CSRegs[i]; ++i)
661 *SR1 = FirstScratchReg == -1 ? (
unsigned)PPC::NoRegister : FirstScratchReg;
668 int SecondScratchReg = BV.
find_next(*SR1);
669 if (SecondScratchReg != -1)
670 *SR2 = SecondScratchReg;
672 *SR2 = TwoUniqueRegsRequired ? (
unsigned)PPC::NoRegister : *SR1;
677 if (BV.
count() < (TwoUniqueRegsRequired ? 2U : 1U))
694 int NegFrameSize = -FrameSize;
695 bool IsLargeFrame = !
isInt<16>(NegFrameSize);
700 return (IsLargeFrame || !HasRedZone) && HasBP && MaxAlign > 1;
706 return findScratchRegister(TmpMBB,
false,
707 twoUniqueScratchRegsRequired(TmpMBB));
713 return findScratchRegister(TmpMBB,
true);
730 bool isPPC64 = Subtarget.
isPPC64();
735 "Currently only Darwin and SVR4 ABIs are supported for PowerPC.");
740 for (
unsigned i = 0; MBBI != MBB.
end(); ++i, ++MBBI) {
741 if (MBBI->getOpcode() == PPC::UPDATE_VRSAVE) {
752 int NegFrameSize = -FrameSize;
763 bool MustSaveCR = !MustSaveCRs.
empty();
765 bool HasFP =
hasFP(MF);
767 bool HasRedZone = isPPC64 || !isSVR4ABI;
769 unsigned SPReg = isPPC64 ? PPC::X1 : PPC::R1;
771 unsigned FPReg = isPPC64 ? PPC::X31 : PPC::R31;
772 unsigned LRReg = isPPC64 ? PPC::LR8 : PPC::LR;
773 unsigned ScratchReg = 0;
774 unsigned TempReg = isPPC64 ? PPC::X12 : PPC::R12;
776 const MCInstrDesc& MFLRInst = TII.get(isPPC64 ? PPC::MFLR8
780 const MCInstrDesc& StoreUpdtInst = TII.get(isPPC64 ? PPC::STDU
782 const MCInstrDesc& StoreUpdtIdxInst = TII.get(isPPC64 ? PPC::STDUX
784 const MCInstrDesc& LoadImmShiftedInst = TII.get(isPPC64 ? PPC::LIS8
786 const MCInstrDesc& OrImmInst = TII.get(isPPC64 ? PPC::ORI8
788 const MCInstrDesc& OrInst = TII.get(isPPC64 ? PPC::OR8
790 const MCInstrDesc& SubtractCarryingInst = TII.get(isPPC64 ? PPC::SUBFC8
792 const MCInstrDesc& SubtractImmCarryingInst = TII.get(isPPC64 ? PPC::SUBFIC8
799 assert((isPPC64 || !isSVR4ABI || !(!FrameSize && (MustSaveLR || HasFP))) &&
800 "FrameSize must be >0 to save/restore the FP or LR for 32-bit SVR4.");
803 bool SingleScratchReg =
804 findScratchRegister(&MBB,
false, twoUniqueScratchRegsRequired(&MBB),
805 &ScratchReg, &TempReg);
806 assert(SingleScratchReg &&
807 "Required number of registers not available in this block");
809 SingleScratchReg = ScratchReg == TempReg;
818 assert(FPIndex &&
"No Frame Pointer Save Slot!");
830 assert(BPIndex &&
"No Base Pointer Save Slot!");
841 assert(PBPIndex &&
"No PIC Base Pointer Save Slot!");
847 if (HasBP && MaxAlign > 1)
849 "Invalid alignment!");
853 bool isLargeFrame = !
isInt<16>(NegFrameSize);
855 assert((isPPC64 || !MustSaveCR) &&
856 "Prologue CR saving supported only in 64-bit mode");
860 if (MustSaveCR && SingleScratchReg && MustSaveLR) {
865 unsigned MfcrOpcode = PPC::MFCR8;
867 if (isELFv2ABI && MustSaveCRs.
size() == 1) {
868 MfcrOpcode = PPC::MFOCRF8;
872 BuildMI(MBB, MBBI, dl, TII.get(MfcrOpcode), TempReg);
873 for (
unsigned i = 0, e = MustSaveCRs.
size(); i != e; ++i)
874 MIB.
addReg(MustSaveCRs[i], CrState);
875 BuildMI(MBB, MBBI, dl, TII.get(PPC::STW8))
882 BuildMI(MBB, MBBI, dl, MFLRInst, ScratchReg);
885 !(SingleScratchReg && MustSaveLR)) {
890 unsigned MfcrOpcode = PPC::MFCR8;
892 if (isELFv2ABI && MustSaveCRs.
size() == 1) {
893 MfcrOpcode = PPC::MFOCRF8;
897 BuildMI(MBB, MBBI, dl, TII.get(MfcrOpcode), TempReg);
898 for (
unsigned i = 0, e = MustSaveCRs.
size(); i != e; ++i)
899 MIB.
addReg(MustSaveCRs[i], CrState);
904 BuildMI(MBB, MBBI, dl, StoreInst)
909 BuildMI(MBB, MBBI, dl, StoreInst)
914 BuildMI(MBB, MBBI, dl, StoreInst)
921 BuildMI(MBB, MBBI, dl, StoreInst)
927 !(SingleScratchReg && MustSaveLR)) {
928 assert(HasRedZone &&
"A red zone is always available on PPC64");
929 BuildMI(MBB, MBBI, dl, TII.get(PPC::STW8))
942 if (HasBP && HasRedZone) {
944 BuildMI(MBB, MBBI, dl, OrInst, BPReg)
951 bool HasSTUX =
false;
954 if (HasBP && MaxAlign > 1) {
956 BuildMI(MBB, MBBI, dl, TII.get(PPC::RLDICL), ScratchReg)
961 BuildMI(MBB, MBBI, dl, TII.get(PPC::RLWINM), ScratchReg)
967 BuildMI(MBB, MBBI, dl, SubtractImmCarryingInst, ScratchReg)
971 assert(!SingleScratchReg &&
"Only a single scratch reg available");
972 BuildMI(MBB, MBBI, dl, LoadImmShiftedInst, TempReg)
973 .
addImm(NegFrameSize >> 16);
974 BuildMI(MBB, MBBI, dl, OrImmInst, TempReg)
976 .
addImm(NegFrameSize & 0xFFFF);
977 BuildMI(MBB, MBBI, dl, SubtractCarryingInst, ScratchReg)
982 BuildMI(MBB, MBBI, dl, StoreUpdtIdxInst, SPReg)
988 }
else if (!isLargeFrame) {
989 BuildMI(MBB, MBBI, dl, StoreUpdtInst, SPReg)
995 BuildMI(MBB, MBBI, dl, LoadImmShiftedInst, ScratchReg)
996 .
addImm(NegFrameSize >> 16);
997 BuildMI(MBB, MBBI, dl, OrImmInst, ScratchReg)
999 .
addImm(NegFrameSize & 0xFFFF);
1000 BuildMI(MBB, MBBI, dl, StoreUpdtIdxInst, SPReg)
1008 assert(!isPPC64 &&
"A red zone is always available on PPC64");
1020 BuildMI(MBB, MBBI, dl, TII.get(PPC::SUBF), ScratchReg)
1024 if (ScratchReg == PPC::R0) {
1031 BuildMI(MBB, MBBI, dl, TII.get(PPC::ADDIC), ScratchReg)
1033 .
addImm(FPOffset-LastOffset);
1034 LastOffset = FPOffset;
1036 BuildMI(MBB, MBBI, dl, TII.get(PPC::STWX))
1043 BuildMI(MBB, MBBI, dl, TII.get(PPC::ADDIC), ScratchReg)
1045 .
addImm(PBPOffset-LastOffset);
1046 LastOffset = PBPOffset;
1047 BuildMI(MBB, MBBI, dl, TII.get(PPC::STWX))
1054 BuildMI(MBB, MBBI, dl, TII.get(PPC::ADDIC), ScratchReg)
1056 .
addImm(BPOffset-LastOffset);
1057 LastOffset = BPOffset;
1058 BuildMI(MBB, MBBI, dl, TII.get(PPC::STWX))
1063 BuildMI(MBB, MBBI, dl, TII.get(PPC::ADDIC), BPReg)
1074 BuildMI(MBB, MBBI, dl, StoreInst)
1079 BuildMI(MBB, MBBI, dl, StoreInst)
1084 BuildMI(MBB, MBBI, dl, StoreInst)
1088 BuildMI(MBB, MBBI, dl, OrInst, BPReg)
1099 BuildMI(MBB, MBBI, dl, StoreInst)
1101 .
addImm(FrameSize + FPOffset)
1104 BuildMI(MBB, MBBI, dl, StoreInst)
1106 .
addImm(FrameSize + PBPOffset)
1109 BuildMI(MBB, MBBI, dl, StoreInst)
1111 .
addImm(FrameSize + BPOffset)
1113 BuildMI(MBB, MBBI, dl, TII.get(PPC::ADDI), BPReg)
1137 BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
1138 .addCFIIndex(CFIIndex);
1145 BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
1146 .addCFIIndex(CFIIndex);
1154 BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
1155 .addCFIIndex(CFIIndex);
1163 BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
1164 .addCFIIndex(CFIIndex);
1172 BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
1173 .addCFIIndex(CFIIndex);
1179 BuildMI(MBB, MBBI, dl, OrInst, FPReg)
1183 if (!HasBP && needsCFI) {
1190 BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
1191 .addCFIIndex(CFIIndex);
1199 for (
unsigned I = 0,
E = CSI.size();
I !=
E; ++
I) {
1200 unsigned Reg = CSI[
I].getReg();
1201 if (Reg == PPC::LR || Reg == PPC::LR8 || Reg ==
PPC::RM)
continue;
1205 if (PPC::CRBITRCRegClass.
contains(Reg))
1210 if (isSVR4ABI && (PPC::CR2 <= Reg && Reg <= PPC::CR4)
1216 if (isSVR4ABI && isPPC64 && (PPC::CR2 <= Reg && Reg <= PPC::CR4)) {
1220 unsigned CRReg = isELFv2ABI?
Reg : (
unsigned) PPC::CR2;
1223 BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
1224 .addCFIIndex(CFIIndex);
1228 if (CSI[
I].isSpilledToReg()) {
1229 unsigned SpilledReg = CSI[
I].getDstReg();
1233 BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
1234 .addCFIIndex(CFIRegister);
1239 BuildMI(MBB, MBBI, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
1240 .addCFIIndex(CFIIndex);
1251 if (MBBI != MBB.
end())
1252 dl = MBBI->getDebugLoc();
1264 bool isPPC64 = Subtarget.
isPPC64();
1272 bool MustSaveCR = !MustSaveCRs.
empty();
1274 bool HasFP =
hasFP(MF);
1278 unsigned SPReg = isPPC64 ? PPC::X1 : PPC::R1;
1280 unsigned FPReg = isPPC64 ? PPC::X31 : PPC::R31;
1281 unsigned ScratchReg = 0;
1282 unsigned TempReg = isPPC64 ? PPC::X12 : PPC::R12;
1283 const MCInstrDesc& MTLRInst = TII.get( isPPC64 ? PPC::MTLR8
1287 const MCInstrDesc& LoadImmShiftedInst = TII.get( isPPC64 ? PPC::LIS8
1289 const MCInstrDesc& OrInst = TII.get(isPPC64 ? PPC::OR8
1291 const MCInstrDesc& OrImmInst = TII.get( isPPC64 ? PPC::ORI8
1293 const MCInstrDesc& AddImmInst = TII.get( isPPC64 ? PPC::ADDI8
1295 const MCInstrDesc& AddInst = TII.get( isPPC64 ? PPC::ADD8
1303 bool SingleScratchReg = findScratchRegister(&MBB,
true,
false, &ScratchReg,
1305 assert(SingleScratchReg &&
1306 "Could not find an available scratch register");
1308 SingleScratchReg = ScratchReg == TempReg;
1313 assert(FPIndex &&
"No Frame Pointer Save Slot!");
1324 assert(BPIndex &&
"No Base Pointer Save Slot!");
1334 assert(PBPIndex &&
"No PIC Base Pointer Save Slot!");
1338 bool IsReturnBlock = (MBBI != MBB.
end() && MBBI->isReturn());
1340 if (IsReturnBlock) {
1341 unsigned RetOpcode = MBBI->getOpcode();
1342 bool UsesTCRet = RetOpcode == PPC::TCRETURNri ||
1343 RetOpcode == PPC::TCRETURNdi ||
1344 RetOpcode == PPC::TCRETURNai ||
1345 RetOpcode == PPC::TCRETURNri8 ||
1346 RetOpcode == PPC::TCRETURNdi8 ||
1347 RetOpcode == PPC::TCRETURNai8;
1352 assert(StackAdjust.
isImm() &&
"Expecting immediate value.");
1354 int StackAdj = StackAdjust.
getImm();
1355 int Delta = StackAdj - MaxTCRetDelta;
1356 assert((Delta >= 0) &&
"Delta must be positive");
1357 if (MaxTCRetDelta>0)
1358 FrameSize += (StackAdj +Delta);
1360 FrameSize += StackAdj;
1366 bool isLargeFrame = !
isInt<16>(FrameSize);
1380 unsigned RBReg = SPReg;
1393 assert(HasFP &&
"Expecting a valid frame pointer.");
1396 if (!isLargeFrame) {
1397 BuildMI(MBB, MBBI, dl, AddImmInst, RBReg)
1400 BuildMI(MBB, MBBI, dl, LoadImmShiftedInst, ScratchReg)
1401 .
addImm(FrameSize >> 16);
1402 BuildMI(MBB, MBBI, dl, OrImmInst, ScratchReg)
1404 .
addImm(FrameSize & 0xFFFF);
1405 BuildMI(MBB, MBBI, dl, AddInst)
1412 BuildMI(MBB, MBBI, dl, AddImmInst, SPReg)
1418 assert(FPOffset <= 0 && BPOffset <= 0 && PBPOffset <= 0 &&
1419 "Local offsets should be negative");
1421 FPOffset += FrameSize;
1422 BPOffset += FrameSize;
1423 PBPOffset += FrameSize;
1431 BuildMI(MBB, MBBI, dl, OrInst, ScratchReg)
1436 BuildMI(MBB, MBBI, dl, LoadInst, RBReg)
1441 assert(RBReg != ScratchReg &&
"Should have avoided ScratchReg");
1446 assert((isPPC64 || !MustSaveCR) &&
1447 "Epilogue CR restoring supported only in 64-bit mode");
1451 if (MustSaveCR && SingleScratchReg && MustSaveLR) {
1454 assert(HasRedZone &&
"Expecting red zone");
1455 BuildMI(MBB, MBBI, dl, TII.get(PPC::LWZ8), TempReg)
1458 for (
unsigned i = 0, e = MustSaveCRs.
size(); i != e; ++i)
1459 BuildMI(MBB, MBBI, dl, TII.get(PPC::MTOCRF8), MustSaveCRs[i])
1467 bool LoadedLR =
false;
1468 if (MustSaveLR && RBReg == SPReg &&
isInt<16>(LROffset+SPAdd)) {
1469 BuildMI(MBB, MBBI, dl, LoadInst, ScratchReg)
1475 if (MustSaveCR && !(SingleScratchReg && MustSaveLR)) {
1477 assert(isPPC64 &&
"Expecting 64-bit mode");
1478 assert(RBReg == SPReg &&
"Should be using SP as a base register");
1479 BuildMI(MBB, MBBI, dl, TII.get(PPC::LWZ8), TempReg)
1487 if (HasRedZone || RBReg == SPReg)
1488 BuildMI(MBB, MBBI, dl, LoadInst, FPReg)
1492 BuildMI(MBB, MBBI, dl, LoadInst, ScratchReg)
1498 BuildMI(MBB, MBBI, dl, LoadInst, PPC::R30)
1503 BuildMI(MBB, MBBI, dl, LoadInst, BPReg)
1509 if (RBReg != SPReg || SPAdd != 0) {
1510 assert(!HasRedZone &&
"This should not happen with red zone");
1513 BuildMI(MBB, MBBI, dl, OrInst, SPReg)
1517 BuildMI(MBB, MBBI, dl, AddImmInst, SPReg)
1521 assert(RBReg != ScratchReg &&
"Should be using FP or SP as base register");
1523 BuildMI(MBB, MBBI, dl, OrInst, FPReg)
1528 if (MustSaveLR && !LoadedLR)
1529 BuildMI(MBB, MBBI, dl, LoadInst, ScratchReg)
1535 !(SingleScratchReg && MustSaveLR))
1536 for (
unsigned i = 0, e = MustSaveCRs.
size(); i != e; ++i)
1537 BuildMI(MBB, MBBI, dl, TII.get(PPC::MTOCRF8), MustSaveCRs[i])
1545 if (IsReturnBlock) {
1546 unsigned RetOpcode = MBBI->getOpcode();
1548 (RetOpcode == PPC::BLR || RetOpcode == PPC::BLR8) &&
1553 if (CallerAllocatedAmt &&
isInt<16>(CallerAllocatedAmt)) {
1554 BuildMI(MBB, MBBI, dl, AddImmInst, SPReg)
1557 BuildMI(MBB, MBBI, dl, LoadImmShiftedInst, ScratchReg)
1558 .
addImm(CallerAllocatedAmt >> 16);
1559 BuildMI(MBB, MBBI, dl, OrImmInst, ScratchReg)
1561 .
addImm(CallerAllocatedAmt & 0xFFFF);
1562 BuildMI(MBB, MBBI, dl, AddInst)
1568 createTailCallBranchInstr(MBB);
1573 void PPCFrameLowering::createTailCallBranchInstr(
MachineBasicBlock &MBB)
const {
1577 assert(MBBI != MBB.
end() &&
"Failed to find the first terminator.");
1583 unsigned RetOpcode = MBBI->getOpcode();
1584 if (RetOpcode == PPC::TCRETURNdi) {
1587 BuildMI(MBB, MBBI, dl, TII.get(PPC::TAILB)).
1589 }
else if (RetOpcode == PPC::TCRETURNri) {
1591 assert(MBBI->getOperand(0).isReg() &&
"Expecting register operand.");
1592 BuildMI(MBB, MBBI, dl, TII.get(PPC::TAILBCTR));
1593 }
else if (RetOpcode == PPC::TCRETURNai) {
1596 BuildMI(MBB, MBBI, dl, TII.get(PPC::TAILBA)).addImm(JumpTarget.
getImm());
1597 }
else if (RetOpcode == PPC::TCRETURNdi8) {
1600 BuildMI(MBB, MBBI, dl, TII.get(PPC::TAILB8)).
1602 }
else if (RetOpcode == PPC::TCRETURNri8) {
1604 assert(MBBI->getOperand(0).isReg() &&
"Expecting register operand.");
1605 BuildMI(MBB, MBBI, dl, TII.get(PPC::TAILBCTR8));
1606 }
else if (RetOpcode == PPC::TCRETURNai8) {
1609 BuildMI(MBB, MBBI, dl, TII.get(PPC::TAILBA8)).addImm(JumpTarget.
getImm());
1622 unsigned LR = RegInfo->getRARegister();
1624 SavedRegs.
reset(LR);
1628 bool isPPC64 = Subtarget.
isPPC64();
1663 SavedRegs.
reset(isPPC64 ? PPC::X31 : PPC::R31);
1667 SavedRegs.
reset(PPC::R30);
1678 if (!isPPC64 && !isDarwinABI &&
1679 (SavedRegs.
test(PPC::CR2) ||
1680 SavedRegs.
test(PPC::CR3) ||
1681 SavedRegs.
test(PPC::CR4))) {
1707 createTailCallBranchInstr(MBB);
1712 if (CSI.empty() && !
needsFP(MF)) {
1717 unsigned MinGPR = PPC::R31;
1718 unsigned MinG8R = PPC::X31;
1719 unsigned MinFPR = PPC::F31;
1720 unsigned MinVR = Subtarget.
hasSPE() ? PPC::S31 : PPC::V31;
1722 bool HasGPSaveArea =
false;
1723 bool HasG8SaveArea =
false;
1724 bool HasFPSaveArea =
false;
1725 bool HasVRSAVESaveArea =
false;
1726 bool HasVRSaveArea =
false;
1733 for (
unsigned i = 0, e = CSI.size(); i != e; ++i) {
1734 unsigned Reg = CSI[i].getReg();
1735 if (PPC::GPRCRegClass.
contains(Reg) ||
1736 PPC::SPE4RCRegClass.
contains(Reg)) {
1737 HasGPSaveArea =
true;
1744 }
else if (PPC::G8RCRegClass.
contains(Reg)) {
1745 HasG8SaveArea =
true;
1752 }
else if (PPC::F8RCRegClass.
contains(Reg)) {
1753 HasFPSaveArea =
true;
1760 }
else if (PPC::CRBITRCRegClass.
contains(Reg) ||
1763 }
else if (PPC::VRSAVERCRegClass.
contains(Reg)) {
1764 HasVRSAVESaveArea =
true;
1765 }
else if (PPC::VRRCRegClass.
contains(Reg) ||
1766 PPC::SPERCRegClass.
contains(Reg)) {
1769 HasVRSaveArea =
true;
1784 int64_t LowerBound = 0;
1790 LowerBound = TCSPDelta;
1795 if (HasFPSaveArea) {
1796 for (
unsigned i = 0, e = FPRegs.
size(); i != e; ++i) {
1797 int FI = FPRegs[i].getFrameIdx();
1802 LowerBound -= (31 - TRI->getEncodingValue(MinFPR) + 1) * 8;
1809 assert(FI &&
"No Frame Pointer Save Slot!");
1812 HasGPSaveArea =
true;
1817 assert(FI &&
"No PIC Base Pointer Save Slot!");
1820 MinGPR = std::min<unsigned>(MinGPR, PPC::R30);
1821 HasGPSaveArea =
true;
1827 assert(FI &&
"No Base Pointer Save Slot!");
1831 if (PPC::G8RCRegClass.
contains(BP)) {
1832 MinG8R = std::min<unsigned>(MinG8R, BP);
1833 HasG8SaveArea =
true;
1834 }
else if (PPC::GPRCRegClass.
contains(BP)) {
1835 MinGPR = std::min<unsigned>(MinGPR, BP);
1836 HasGPSaveArea =
true;
1842 if (HasGPSaveArea || HasG8SaveArea) {
1845 for (
unsigned i = 0, e = GPRegs.
size(); i != e; ++i) {
1846 if (!GPRegs[i].isSpilledToReg()) {
1847 int FI = GPRegs[i].getFrameIdx();
1854 for (
unsigned i = 0, e = G8Regs.
size(); i != e; ++i) {
1855 if (!G8Regs[i].isSpilledToReg()) {
1856 int FI = G8Regs[i].getFrameIdx();
1862 std::min<unsigned>(TRI->getEncodingValue(MinGPR),
1863 TRI->getEncodingValue(MinG8R));
1866 LowerBound -= (31 - MinReg + 1) * 8;
1868 LowerBound -= (31 - MinReg + 1) * 4;
1879 for (
unsigned i = 0, e = CSI.size(); i != e; ++i) {
1880 unsigned Reg = CSI[i].getReg();
1882 if ((Subtarget.
isSVR4ABI() && Reg == PPC::CR2)
1885 (PPC::CRBITRCRegClass.contains(Reg) ||
1886 PPC::CRRCRegClass.contains(Reg)))) {
1887 int FI = CSI[i].getFrameIdx();
1896 if (HasVRSAVESaveArea) {
1900 for (
unsigned i = 0, e = CSI.size(); i != e; ++i) {
1901 unsigned Reg = CSI[i].getReg();
1903 if (PPC::VRSAVERCRegClass.
contains(Reg)) {
1904 int FI = CSI[i].getFrameIdx();
1915 if (HasVRSaveArea) {
1921 assert(LowerBound <= 0 &&
"Expect LowerBound have a non-positive value!");
1922 LowerBound &= ~(15);
1924 for (
unsigned i = 0, e = VRegs.
size(); i != e; ++i) {
1925 int FI = VRegs[i].getFrameIdx();
1980 std::vector<CalleeSavedInfo> &CSI)
const {
1995 for (
unsigned i = 0; CSRegs[i]; ++i)
1996 BVCalleeSaved.set(CSRegs[i]);
2001 if (BVCalleeSaved[
Reg] ||
2008 bool AllSpilledToReg =
true;
2009 for (
auto &CS : CSI) {
2010 if (BVAllocatable.
none())
2013 unsigned Reg = CS.getReg();
2014 if (!PPC::G8RCRegClass.
contains(Reg) && !PPC::GPRCRegClass.
contains(Reg)) {
2015 AllSpilledToReg =
false;
2019 unsigned VolatileVFReg = BVAllocatable.
find_first();
2020 if (VolatileVFReg < BVAllocatable.
size()) {
2021 CS.setDstReg(VolatileVFReg);
2022 BVAllocatable.
reset(VolatileVFReg);
2024 AllSpilledToReg =
false;
2027 return AllSpilledToReg;
2034 const std::vector<CalleeSavedInfo> &CSI,
2045 bool CRSpilled =
false;
2048 for (
unsigned i = 0, e = CSI.size(); i != e; ++i) {
2049 unsigned Reg = CSI[i].getReg();
2053 if (Reg == PPC::VRSAVE && !Subtarget.
isDarwinABI())
2057 bool IsCRField = PPC::CR2 <= Reg && Reg <= PPC::CR4;
2069 if (CRSpilled && IsCRField) {
2086 CRMIB =
BuildMI(*MF, DL, TII.get(PPC::MFCR), PPC::R12)
2093 CSI[i].getFrameIdx()));
2096 if (CSI[i].isSpilledToReg()) {
2098 BuildMI(MBB, MI, DL, TII.get(PPC::MTVSRD), CSI[i].getDstReg())
2106 CSI[i].getFrameIdx(), RC, TRI);
2115 bool CR2Spilled,
bool CR3Spilled,
bool CR4Spilled,
2117 const std::vector<CalleeSavedInfo> &CSI,
unsigned CSIIndex) {
2131 CSI[CSIIndex].getFrameIdx()));
2132 RestoreOp = PPC::MTOCRF;
2137 MBB.
insert(MI,
BuildMI(*MF, DL, TII.get(RestoreOp), PPC::CR2)
2141 MBB.
insert(MI,
BuildMI(*MF, DL, TII.get(RestoreOp), PPC::CR3)
2145 MBB.
insert(MI,
BuildMI(*MF, DL, TII.get(RestoreOp), PPC::CR4)
2154 I->getOpcode() == PPC::ADJCALLSTACKUP) {
2156 if (
int CalleeAmt = I->getOperand(1).getImm()) {
2159 unsigned StackReg = is64Bit ? PPC::X1 : PPC::R1;
2160 unsigned TmpReg = is64Bit ? PPC::X0 : PPC::R0;
2161 unsigned ADDIInstr = is64Bit ? PPC::ADDI8 : PPC::ADDI;
2162 unsigned ADDInstr = is64Bit ? PPC::ADD8 : PPC::ADD4;
2163 unsigned LISInstr = is64Bit ? PPC::LIS8 : PPC::LIS;
2164 unsigned ORIInstr = is64Bit ? PPC::ORI8 : PPC::ORI;
2165 const DebugLoc &dl = I->getDebugLoc();
2168 BuildMI(MBB, I, dl, TII.
get(ADDIInstr), StackReg)
2173 BuildMI(MBB, MBBI, dl, TII.
get(LISInstr), TmpReg)
2174 .addImm(CalleeAmt >> 16);
2175 BuildMI(MBB, MBBI, dl, TII.
get(ORIInstr), TmpReg)
2177 .
addImm(CalleeAmt & 0xFFFF);
2178 BuildMI(MBB, MBBI, dl, TII.
get(ADDInstr), StackReg)
2185 return MBB.
erase(I);
2191 std::vector<CalleeSavedInfo> &CSI,
2201 bool CR2Spilled =
false;
2202 bool CR3Spilled =
false;
2203 bool CR4Spilled =
false;
2204 unsigned CSIIndex = 0;
2209 bool AtStart = I == MBB.
begin();
2214 for (
unsigned i = 0, e = CSI.size(); i != e; ++i) {
2215 unsigned Reg = CSI[i].getReg();
2220 if (Reg == PPC::VRSAVE && !Subtarget.
isDarwinABI())
2223 if (Reg == PPC::CR2) {
2229 }
else if (Reg == PPC::CR3) {
2232 }
else if (Reg == PPC::CR4) {
2238 if ((CR2Spilled || CR3Spilled || CR4Spilled)
2239 && !(PPC::CR2 <= Reg && Reg <= PPC::CR4)) {
2242 CR2Spilled, CR3Spilled, CR4Spilled,
2243 MBB,
I, CSI, CSIIndex);
2244 CR2Spilled = CR3Spilled = CR4Spilled =
false;
2247 if (CSI[i].isSpilledToReg()) {
2250 BuildMI(MBB, I, DL, TII.get(PPC::MFVSRD),
Reg)
2257 "loadRegFromStackSlot didn't insert any code!");
2271 if (CR2Spilled || CR3Spilled || CR4Spilled) {
2274 MBB,
I, CSI, CSIIndex);
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...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
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
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
bool hasDebugInfo() const
Returns true if valid debug info is present.
bool isRegUsed(unsigned Reg, bool includeReserved=true) const
Return if a specific register is currently used.
int getFramePointerSaveIndex() const
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.
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.
unsigned getReg() const
getReg - Returns the register number.
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)
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.
int CreateStackObject(uint64_t Size, unsigned 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...
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 ...
int getDwarfRegNum(unsigned RegNum, bool isEH) const
Map a target register to an equivalent dwarf register number.
def_iterator def_begin(unsigned RegNo) const
LLVM_NODISCARD unsigned addFrameInst(const MCCFIInstruction &Inst)
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.
Fast - This calling convention attempts to make calls as fast as possible (e.g.
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.
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.
unsigned getKillRegState(bool B)
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
unsigned getBasePointerSaveOffset() const
getBasePointerSaveOffset - Return the previous frame offset to save the base pointer.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
TargetInstrInfo - Interface to description of machine instruction set.
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 getBaseRegister(const MachineFunction &MF) const
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)
void addLiveIn(MCPhysReg PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
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.
static bool is64Bit(const char *name)
const GlobalValue * getGlobal() const
static ManagedStatic< OptionRegistry > OR
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...
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)
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...
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.
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...
unsigned estimateStackSize(const MachineFunction &MF) const
Estimate and return the size of the stack frame.
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.
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
bool needsUnwindTableEntry() const
True if this function needs an unwind table.
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
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...
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.
uint16_t getEncodingValue(unsigned RegNo) const
Returns the encoding for RegNo.
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.
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 setReg(unsigned Reg)
Change the register this operand corresponds to.
void setMaxCallFrameSize(unsigned S)
unsigned getFramePointerSaveOffset() const
getFramePointerSaveOffset - Return the previous frame offset to save the frame pointer.
bool needsFP(const MachineFunction &MF) const
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 MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
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()
const MCRegisterInfo * getRegisterInfo() const
iterator_range< const_set_bits_iterator > set_bits() const
unsigned determineFrameLayout(MachineFunction &MF, bool UpdateMF=true, bool UseEstimate=false) const
determineFrameLayout - Determine the size of the frame and maximum call frame size.
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
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...
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.
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.