Lines Matching refs:MF

162 static unsigned estimateRSStackSizeLimit(MachineFunction &MF) {  in estimateRSStackSizeLimit()  argument
166 for (MachineBasicBlock &MBB : MF) { in estimateRSStackSizeLimit()
187 bool AArch64FrameLowering::canUseRedZone(const MachineFunction &MF) const { in canUseRedZone()
192 if (MF.getFunction().hasFnAttribute(Attribute::NoRedZone)) in canUseRedZone()
195 const MachineFrameInfo &MFI = MF.getFrameInfo(); in canUseRedZone()
196 const AArch64FunctionInfo *AFI = MF.getInfo<AArch64FunctionInfo>(); in canUseRedZone()
199 return !(MFI.hasCalls() || hasFP(MF) || NumBytes > 128); in canUseRedZone()
204 bool AArch64FrameLowering::hasFP(const MachineFunction &MF) const { in hasFP()
205 const MachineFrameInfo &MFI = MF.getFrameInfo(); in hasFP()
206 const TargetRegisterInfo *RegInfo = MF.getSubtarget().getRegisterInfo(); in hasFP()
210 if (MF.hasEHFunclets()) in hasFP()
213 if (MFI.hasCalls() && MF.getTarget().Options.DisableFramePointerElim(MF)) in hasFP()
217 RegInfo->needsStackRealignment(MF)) in hasFP()
232 if (MF.hasLocalEscape()) in hasFP()
244 AArch64FrameLowering::hasReservedCallFrame(const MachineFunction &MF) const { in hasReservedCallFrame()
245 return !MF.getFrameInfo().hasVarSizedObjects(); in hasReservedCallFrame()
249 MachineFunction &MF, MachineBasicBlock &MBB, in eliminateCallFramePseudoInstr() argument
252 static_cast<const AArch64InstrInfo *>(MF.getSubtarget().getInstrInfo()); in eliminateCallFramePseudoInstr()
258 const TargetFrameLowering *TFI = MF.getSubtarget().getFrameLowering(); in eliminateCallFramePseudoInstr()
259 if (!TFI->hasReservedCallFrame(MF)) { in eliminateCallFramePseudoInstr()
294 static bool ShouldSignReturnAddress(MachineFunction &MF) { in ShouldSignReturnAddress() argument
299 const Function &F = MF.getFunction(); in ShouldSignReturnAddress()
312 for (const auto &Info : MF.getFrameInfo().getCalleeSavedInfo()) in ShouldSignReturnAddress()
321 MachineFunction &MF = *MBB.getParent(); in emitCalleeSavedFrameMoves() local
322 MachineFrameInfo &MFI = MF.getFrameInfo(); in emitCalleeSavedFrameMoves()
323 const TargetSubtargetInfo &STI = MF.getSubtarget(); in emitCalleeSavedFrameMoves()
338 unsigned CFIIndex = MF.addFrameInst( in emitCalleeSavedFrameMoves()
358 MachineFunction *MF = MBB->getParent(); in findScratchNonCalleeSaveRegister() local
361 if (&MF->front() == MBB) in findScratchNonCalleeSaveRegister()
364 const AArch64Subtarget &Subtarget = MF->getSubtarget<AArch64Subtarget>(); in findScratchNonCalleeSaveRegister()
370 const MCPhysReg *CSRegs = MF->getRegInfo().getCalleeSavedRegs(); in findScratchNonCalleeSaveRegister()
375 const MachineRegisterInfo &MRI = MF->getRegInfo(); in findScratchNonCalleeSaveRegister()
388 const MachineFunction *MF = MBB.getParent(); in canUseAsPrologue() local
390 const AArch64Subtarget &Subtarget = MF->getSubtarget<AArch64Subtarget>(); in canUseAsPrologue()
394 if (!RegInfo->needsStackRealignment(*MF)) in canUseAsPrologue()
401 static bool windowsRequiresStackProbe(MachineFunction &MF, in windowsRequiresStackProbe() argument
403 const AArch64Subtarget &Subtarget = MF.getSubtarget<AArch64Subtarget>(); in windowsRequiresStackProbe()
406 const Function &F = MF.getFunction(); in windowsRequiresStackProbe()
419 MachineFunction &MF, unsigned StackBumpBytes) const { in shouldCombineCSRLocalStackBump() argument
420 AArch64FunctionInfo *AFI = MF.getInfo<AArch64FunctionInfo>(); in shouldCombineCSRLocalStackBump()
421 const MachineFrameInfo &MFI = MF.getFrameInfo(); in shouldCombineCSRLocalStackBump()
422 const AArch64Subtarget &Subtarget = MF.getSubtarget<AArch64Subtarget>(); in shouldCombineCSRLocalStackBump()
430 if (StackBumpBytes >= 512 || windowsRequiresStackProbe(MF, StackBumpBytes)) in shouldCombineCSRLocalStackBump()
436 if (RegInfo->needsStackRealignment(MF)) in shouldCombineCSRLocalStackBump()
442 if (canUseRedZone(MF)) in shouldCombineCSRLocalStackBump()
455 MachineFunction &MF = *MBB->getParent(); in InsertSEH() local
460 const AArch64Subtarget &Subtarget = MF.getSubtarget<AArch64Subtarget>(); in InsertSEH()
472 MIB = BuildMI(MF, DL, TII.get(AArch64::SEH_SaveFRegP_X)) in InsertSEH()
486 MIB = BuildMI(MF, DL, TII.get(AArch64::SEH_SaveFPLR_X)) in InsertSEH()
490 MIB = BuildMI(MF, DL, TII.get(AArch64::SEH_SaveRegP_X)) in InsertSEH()
502 MIB = BuildMI(MF, DL, TII.get(AArch64::SEH_SaveFReg_X)) in InsertSEH()
513 MIB = BuildMI(MF, DL, TII.get(AArch64::SEH_SaveReg_X)) in InsertSEH()
523 MIB = BuildMI(MF, DL, TII.get(AArch64::SEH_SaveFRegP)) in InsertSEH()
535 MIB = BuildMI(MF, DL, TII.get(AArch64::SEH_SaveFPLR)) in InsertSEH()
539 MIB = BuildMI(MF, DL, TII.get(AArch64::SEH_SaveRegP)) in InsertSEH()
549 MIB = BuildMI(MF, DL, TII.get(AArch64::SEH_SaveReg)) in InsertSEH()
558 MIB = BuildMI(MF, DL, TII.get(AArch64::SEH_SaveFReg)) in InsertSEH()
779 static bool ShouldSignWithAKey(MachineFunction &MF) { in ShouldSignWithAKey() argument
780 const Function &F = MF.getFunction(); in ShouldSignWithAKey()
790 static bool needsWinCFI(const MachineFunction &MF) { in needsWinCFI() argument
791 const Function &F = MF.getFunction(); in needsWinCFI()
792 return MF.getTarget().getMCAsmInfo()->usesWindowsCFI() && in needsWinCFI()
796 void AArch64FrameLowering::emitPrologue(MachineFunction &MF, in emitPrologue() argument
799 const MachineFrameInfo &MFI = MF.getFrameInfo(); in emitPrologue()
800 const Function &F = MF.getFunction(); in emitPrologue()
801 const AArch64Subtarget &Subtarget = MF.getSubtarget<AArch64Subtarget>(); in emitPrologue()
804 MachineModuleInfo &MMI = MF.getMMI(); in emitPrologue()
805 AArch64FunctionInfo *AFI = MF.getInfo<AArch64FunctionInfo>(); in emitPrologue()
807 !MF.getTarget().getMCAsmInfo()->usesWindowsCFI(); in emitPrologue()
808 bool HasFP = hasFP(MF); in emitPrologue()
809 bool NeedsWinCFI = needsWinCFI(MF); in emitPrologue()
810 MF.setHasWinCFI(NeedsWinCFI); in emitPrologue()
822 if (ShouldSignReturnAddress(MF)) { in emitPrologue()
823 if (ShouldSignWithAKey(MF)) in emitPrologue()
834 MF.addFrameInst(MCCFIInstruction::createNegateRAState(nullptr)); in emitPrologue()
842 if (MF.getFunction().getCallingConv() == CallingConv::GHC) in emitPrologue()
851 int NumBytes = IsFunclet ? (int)getWinEHFuncletFrameSize(MF) in emitPrologue()
853 if (!AFI->hasStackFrame() && !windowsRequiresStackProbe(MF, NumBytes)) { in emitPrologue()
861 if (canUseRedZone(MF)) { in emitPrologue()
871 unsigned CFIIndex = MF.addFrameInst( in emitPrologue()
887 Subtarget.isCallingConvWin64(MF.getFunction().getCallingConv()); in emitPrologue()
896 bool CombineSPBump = shouldCombineCSRLocalStackBump(MF, NumBytes); in emitPrologue()
944 if (windowsRequiresStackProbe(MF, NumBytes)) { in emitPrologue()
978 switch (MF.getTarget().getCodeModel()) { in emitPrologue()
1031 const bool NeedsRealignment = RegInfo->needsStackRealignment(MF); in emitPrologue()
1040 if (!canUseRedZone(MF)) in emitPrologue()
1082 if (RegInfo->hasBasePointer(MF)) { in emitPrologue()
1097 const DataLayout &TD = MF.getDataLayout(); in emitPrologue()
1099 unsigned FramePtr = RegInfo->getFrameRegister(MF); in emitPrologue()
1169 unsigned CFIIndex = MF.addFrameInst(MCCFIInstruction::createDefCfa( in emitPrologue()
1176 unsigned CFIIndex = MF.addFrameInst( in emitPrologue()
1189 static void InsertReturnAddressAuth(MachineFunction &MF, in InsertReturnAddressAuth() argument
1191 if (!ShouldSignReturnAddress(MF)) in InsertReturnAddressAuth()
1193 const AArch64Subtarget &Subtarget = MF.getSubtarget<AArch64Subtarget>(); in InsertReturnAddressAuth()
1208 TII->get(ShouldSignWithAKey(MF) ? AArch64::RETAA : AArch64::RETAB)) in InsertReturnAddressAuth()
1214 TII->get(ShouldSignWithAKey(MF) ? AArch64::AUTIASP : AArch64::AUTIBSP)) in InsertReturnAddressAuth()
1229 void AArch64FrameLowering::emitEpilogue(MachineFunction &MF, in emitEpilogue() argument
1232 MachineFrameInfo &MFI = MF.getFrameInfo(); in emitEpilogue()
1233 const AArch64Subtarget &Subtarget = MF.getSubtarget<AArch64Subtarget>(); in emitEpilogue()
1237 bool NeedsWinCFI = needsWinCFI(MF); in emitEpilogue()
1249 int NumBytes = IsFunclet ? (int)getWinEHFuncletFrameSize(MF) in emitEpilogue()
1251 AArch64FunctionInfo *AFI = MF.getInfo<AArch64FunctionInfo>(); in emitEpilogue()
1255 if (MF.getFunction().getCallingConv() == CallingConv::GHC) in emitEpilogue()
1303 auto Cleanup = make_scope_exit([&] { InsertReturnAddressAuth(MF, MBB); }); in emitEpilogue()
1306 Subtarget.isCallingConvWin64(MF.getFunction().getCallingConv()); in emitEpilogue()
1318 if (MF.hasEHFunclets()) in emitEpilogue()
1320 bool CombineSPBump = shouldCombineCSRLocalStackBump(MF, NumBytes); in emitEpilogue()
1377 if (!hasFP(MF)) { in emitEpilogue()
1378 bool RedZone = canUseRedZone(MF); in emitEpilogue()
1454 int AArch64FrameLowering::getFrameIndexReference(const MachineFunction &MF, in getFrameIndexReference() argument
1457 return resolveFrameIndexReference(MF, FI, FrameReg); in getFrameIndexReference()
1460 int AArch64FrameLowering::resolveFrameIndexReference(const MachineFunction &MF, in resolveFrameIndexReference() argument
1463 const MachineFrameInfo &MFI = MF.getFrameInfo(); in resolveFrameIndexReference()
1465 MF.getSubtarget().getRegisterInfo()); in resolveFrameIndexReference()
1466 const AArch64FunctionInfo *AFI = MF.getInfo<AArch64FunctionInfo>(); in resolveFrameIndexReference()
1467 const AArch64Subtarget &Subtarget = MF.getSubtarget<AArch64Subtarget>(); in resolveFrameIndexReference()
1469 Subtarget.isCallingConvWin64(MF.getFunction().getCallingConv()); in resolveFrameIndexReference()
1488 UseFP = hasFP(MF); in resolveFrameIndexReference()
1489 } else if (isCSR && RegInfo->needsStackRealignment(MF)) { in resolveFrameIndexReference()
1493 assert(hasFP(MF) && "Re-aligned stack must have frame pointer"); in resolveFrameIndexReference()
1495 } else if (hasFP(MF) && !RegInfo->needsStackRealignment(MF)) { in resolveFrameIndexReference()
1507 bool CanUseBP = RegInfo->hasBasePointer(MF); in resolveFrameIndexReference()
1520 } else if (MF.hasEHFunclets() && !RegInfo->hasBasePointer(MF)) { in resolveFrameIndexReference()
1525 Subtarget.isCallingConvWin64(MF.getFunction().getCallingConv()) && in resolveFrameIndexReference()
1536 assert(((isFixed || isCSR) || !RegInfo->needsStackRealignment(MF) || !UseFP) && in resolveFrameIndexReference()
1541 FrameReg = RegInfo->getFrameRegister(MF); in resolveFrameIndexReference()
1546 if (RegInfo->hasBasePointer(MF)) in resolveFrameIndexReference()
1555 if (canUseRedZone(MF)) in resolveFrameIndexReference()
1562 static unsigned getPrologueDeath(MachineFunction &MF, unsigned Reg) { in getPrologueDeath() argument
1568 bool IsLiveIn = MF.getRegInfo().isLiveIn(Reg); in getPrologueDeath()
1572 static bool produceCompactUnwindFrame(MachineFunction &MF) { in produceCompactUnwindFrame() argument
1573 const AArch64Subtarget &Subtarget = MF.getSubtarget<AArch64Subtarget>(); in produceCompactUnwindFrame()
1574 AttributeList Attrs = MF.getFunction().getAttributes(); in produceCompactUnwindFrame()
1614 MachineFunction &MF, const std::vector<CalleeSavedInfo> &CSI, in computeCalleeSaveRegisterPairs() argument
1621 bool NeedsWinCFI = needsWinCFI(MF); in computeCalleeSaveRegisterPairs()
1622 AArch64FunctionInfo *AFI = MF.getInfo<AArch64FunctionInfo>(); in computeCalleeSaveRegisterPairs()
1623 MachineFrameInfo &MFI = MF.getFrameInfo(); in computeCalleeSaveRegisterPairs()
1624 CallingConv::ID CC = MF.getFunction().getCallingConv(); in computeCalleeSaveRegisterPairs()
1629 assert((!produceCompactUnwindFrame(MF) || in computeCalleeSaveRegisterPairs()
1676 MF.getFunction().hasFnAttribute(Attribute::ShadowCallStack)) { in computeCalleeSaveRegisterPairs()
1677 if (!MF.getSubtarget<AArch64Subtarget>().isXRegisterReserved(18)) in computeCalleeSaveRegisterPairs()
1694 assert((!produceCompactUnwindFrame(MF) || in computeCalleeSaveRegisterPairs()
1732 MachineFunction &MF = *MBB.getParent(); in spillCalleeSavedRegisters() local
1733 const TargetInstrInfo &TII = *MF.getSubtarget().getInstrInfo(); in spillCalleeSavedRegisters()
1734 bool NeedsWinCFI = needsWinCFI(MF); in spillCalleeSavedRegisters()
1739 computeCalleeSaveRegisterPairs(MF, CSI, TRI, RegPairs, in spillCalleeSavedRegisters()
1741 const MachineRegisterInfo &MRI = MF.getRegInfo(); in spillCalleeSavedRegisters()
1756 if (!MF.getFunction().hasFnAttribute(Attribute::NoUnwind)) { in spillCalleeSavedRegisters()
1767 MF.addFrameInst(MCCFIInstruction::createEscape(nullptr, CFIInst)); in spillCalleeSavedRegisters()
1835 MIB.addReg(Reg2, getPrologueDeath(MF, Reg2)); in spillCalleeSavedRegisters()
1836 MIB.addMemOperand(MF.getMachineMemOperand( in spillCalleeSavedRegisters()
1837 MachinePointerInfo::getFixedStack(MF, FrameIdxReg2), in spillCalleeSavedRegisters()
1840 MIB.addReg(Reg1, getPrologueDeath(MF, Reg1)) in spillCalleeSavedRegisters()
1845 MIB.addMemOperand(MF.getMachineMemOperand( in spillCalleeSavedRegisters()
1846 MachinePointerInfo::getFixedStack(MF,FrameIdxReg1), in spillCalleeSavedRegisters()
1859 MachineFunction &MF = *MBB.getParent(); in restoreCalleeSavedRegisters() local
1860 const TargetInstrInfo &TII = *MF.getSubtarget().getInstrInfo(); in restoreCalleeSavedRegisters()
1863 bool NeedsWinCFI = needsWinCFI(MF); in restoreCalleeSavedRegisters()
1869 computeCalleeSaveRegisterPairs(MF, CSI, TRI, RegPairs, in restoreCalleeSavedRegisters()
1921 MIB.addMemOperand(MF.getMachineMemOperand( in restoreCalleeSavedRegisters()
1922 MachinePointerInfo::getFixedStack(MF, FrameIdxReg2), in restoreCalleeSavedRegisters()
1930 MIB.addMemOperand(MF.getMachineMemOperand( in restoreCalleeSavedRegisters()
1931 MachinePointerInfo::getFixedStack(MF, FrameIdxReg1), in restoreCalleeSavedRegisters()
1956 void AArch64FrameLowering::determineCalleeSaves(MachineFunction &MF, in determineCalleeSaves() argument
1961 if (MF.getFunction().getCallingConv() == CallingConv::GHC) in determineCalleeSaves()
1964 TargetFrameLowering::determineCalleeSaves(MF, SavedRegs, RS); in determineCalleeSaves()
1966 MF.getSubtarget().getRegisterInfo()); in determineCalleeSaves()
1967 AArch64FunctionInfo *AFI = MF.getInfo<AArch64FunctionInfo>(); in determineCalleeSaves()
1971 MachineFrameInfo &MFI = MF.getFrameInfo(); in determineCalleeSaves()
1972 const MCPhysReg *CSRegs = MF.getRegInfo().getCalleeSavedRegs(); in determineCalleeSaves()
1974 unsigned BasePointerReg = RegInfo->hasBasePointer(MF) in determineCalleeSaves()
1991 !RegInfo->isReservedReg(MF, Reg)) { in determineCalleeSaves()
2001 if (produceCompactUnwindFrame(MF) && PairedReg != AArch64::NoRegister && in determineCalleeSaves()
2005 !RegInfo->isReservedReg(MF, PairedReg)) in determineCalleeSaves()
2012 const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo(); in determineCalleeSaves()
2013 const MachineRegisterInfo &MRI = MF.getRegInfo(); in determineCalleeSaves()
2021 unsigned EstimatedStackSize = MFI.estimateStackSize(MF); in determineCalleeSaves()
2022 if (hasFP(MF) || in determineCalleeSaves()
2023 windowsRequiresStackProbe(MF, EstimatedStackSize + CSStackSize + 16)) { in determineCalleeSaves()
2039 unsigned EstimatedStackSizeLimit = estimateRSStackSizeLimit(MF); in determineCalleeSaves()
2041 if (BigStack || !CanEliminateFrame || RegInfo->cannotEliminateFrame(MF)) in determineCalleeSaves()
2058 if (produceCompactUnwindFrame(MF)) in determineCalleeSaves()
2065 if (!ExtraCSSpill || MF.getRegInfo().isPhysRegUsed(ExtraCSSpill)) { in determineCalleeSaves()
2066 const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo(); in determineCalleeSaves()
2091 const MachineFunction &MF) const { in enableStackSlotScavenging()
2092 const AArch64FunctionInfo *AFI = MF.getInfo<AArch64FunctionInfo>(); in enableStackSlotScavenging()
2097 MachineFunction &MF, RegScavenger *RS) const { in processFunctionBeforeFrameFinalized() argument
2100 if (!MF.hasEHFunclets()) in processFunctionBeforeFrameFinalized()
2102 const TargetInstrInfo &TII = *MF.getSubtarget().getInstrInfo(); in processFunctionBeforeFrameFinalized()
2103 MachineFrameInfo &MFI = MF.getFrameInfo(); in processFunctionBeforeFrameFinalized()
2104 WinEHFuncInfo &EHInfo = *MF.getWinEHFuncInfo(); in processFunctionBeforeFrameFinalized()
2106 MachineBasicBlock &MBB = MF.front(); in processFunctionBeforeFrameFinalized()
2133 const MachineFunction &MF, int FI, unsigned &FrameReg, in getFrameIndexReferencePreferSP() argument
2135 const MachineFrameInfo &MFI = MF.getFrameInfo(); in getFrameIndexReferencePreferSP()
2145 const MachineFunction &MF) const { in getWinEHParentFrameOffset()
2152 const MachineFunction &MF) const { in getWinEHFuncletFrameSize()
2155 MF.getInfo<AArch64FunctionInfo>()->getCalleeSavedStackSize(); in getWinEHFuncletFrameSize()
2157 return alignTo(CSSize + MF.getFrameInfo().getMaxCallFrameSize(), in getWinEHFuncletFrameSize()