37#define GET_CC_REGISTER_LISTS
38#include "AArch64GenCallingConv.inc"
39#define GET_REGINFO_TARGET_DESC
40#include "AArch64GenRegisterInfo.inc"
54 if (AArch64::PPRRegClass.
contains(Reg))
57 if (AArch64::ZPRRegClass.
contains(Reg)) {
58 RegToUseForCFI = getSubReg(Reg, AArch64::dsub);
59 for (
int I = 0; CSR_AArch64_AAPCS_SaveList[
I]; ++
I) {
60 if (CSR_AArch64_AAPCS_SaveList[
I] == RegToUseForCFI)
72 assert(MF &&
"Invalid MachineFunction pointer.");
80 if (TLI->supportSwiftError() &&
81 F.getAttributes().hasAttrSomewhere(Attribute::SwiftError)) {
83 return CSR_Darwin_AArch64_AAPCS_SwiftError_SaveList;
85 return CSR_Win_AArch64_AAPCS_SwiftError_SaveList;
86 return CSR_AArch64_AAPCS_SwiftError_SaveList;
89 switch (
F.getCallingConv()) {
93 return CSR_AArch64_NoRegs_SaveList;
97 return CSR_AArch64_NoneRegs_SaveList;
100 return CSR_AArch64_AllRegs_SaveList;
103 return CSR_Win_AArch64_Arm64EC_Thunk_SaveList;
107 return CSR_Darwin_AArch64_RT_MostRegs_SaveList;
109 return CSR_Win_AArch64_RT_MostRegs_SaveList;
110 return CSR_AArch64_RT_MostRegs_SaveList;
114 return CSR_Darwin_AArch64_RT_AllRegs_SaveList;
116 return CSR_Win_AArch64_RT_AllRegs_SaveList;
117 return CSR_AArch64_RT_AllRegs_SaveList;
122 "Calling convention CFGuard_Check is unsupported on Darwin.");
123 return CSR_Win_AArch64_CFGuard_Check_SaveList;
127 return CSR_Darwin_AArch64_AAPCS_SwiftTail_SaveList;
129 return CSR_Win_AArch64_AAPCS_SwiftTail_SaveList;
130 return CSR_AArch64_AAPCS_SwiftTail_SaveList;
134 return CSR_Darwin_AArch64_AAVPCS_SaveList;
136 return CSR_Win_AArch64_AAVPCS_SaveList;
137 return CSR_AArch64_AAVPCS_SaveList;
142 "Calling convention SVE_VectorCall is unsupported on Darwin.");
144 return CSR_Win_AArch64_SVE_AAPCS_SaveList;
145 return CSR_AArch64_SVE_AAPCS_SaveList;
149 "Calling convention "
150 "AArch64_SME_ABI_Support_Routines_PreserveMost_From_X0 is only "
151 "supported to improve calls to SME ACLE save/restore/disable-za "
152 "functions, and is not intended to be used beyond that scope.");
156 "Calling convention "
157 "AArch64_SME_ABI_Support_Routines_PreserveMost_From_X1 is "
158 "only supported to improve calls to SME ACLE __arm_get_current_vg "
159 "function, and is not intended to be used beyond that scope.");
163 "Calling convention "
164 "AArch64_SME_ABI_Support_Routines_PreserveMost_From_X2 is "
165 "only supported to improve calls to SME ACLE __arm_sme_state "
166 "and is not intended to be used beyond that scope.");
170 return CSR_Darwin_AArch64_AAPCS_Win64_SaveList;
172 return CSR_Win_AArch64_AAPCS_SaveList;
173 return CSR_AArch64_AAPCS_X18_SaveList;
177 return AFI.isSplitCSR() ? CSR_Darwin_AArch64_CXX_TLS_PE_SaveList
178 : CSR_Darwin_AArch64_CXX_TLS_SaveList;
185 return AFI.hasSVE_AAPCS(*MF) ? CSR_Darwin_AArch64_SVE_AAPCS_SaveList
186 : CSR_Darwin_AArch64_AAPCS_SaveList;
188 return AFI.hasSVE_AAPCS(*MF) ? CSR_Win_AArch64_SVE_AAPCS_SaveList
189 : CSR_Win_AArch64_AAPCS_SaveList;
190 return AFI.hasSVE_AAPCS(*MF) ? CSR_AArch64_SVE_AAPCS_SaveList
191 : CSR_AArch64_AAPCS_SaveList;
197 assert(MF &&
"Invalid MachineFunction pointer.");
200 return CSR_Darwin_AArch64_CXX_TLS_ViaCopy_SaveList;
211 for (
size_t i = 0; i < AArch64::GPR64commonRegClass.getNumRegs(); ++i) {
213 UpdatedCSRs.
push_back(AArch64::GPR64commonRegClass.getRegister(i));
223 unsigned Idx)
const {
225 if (RC == &AArch64::GPR32allRegClass && Idx == AArch64::hsub)
226 return &AArch64::FPR32RegClass;
227 else if (RC == &AArch64::GPR64allRegClass && Idx == AArch64::hsub)
228 return &AArch64::FPR64RegClass;
231 return AArch64GenRegisterInfo::getSubClassWithSubReg(RC, Idx);
238 "Invalid subtarget for getDarwinCallPreservedMask");
241 return CSR_Darwin_AArch64_CXX_TLS_RegMask;
243 return CSR_Darwin_AArch64_AAVPCS_RegMask;
245 return CSR_Darwin_AArch64_SVE_AAPCS_RegMask;
247 return CSR_AArch64_SME_ABI_Support_Routines_PreserveMost_From_X0_RegMask;
249 return CSR_AArch64_SME_ABI_Support_Routines_PreserveMost_From_X1_RegMask;
251 return CSR_AArch64_SME_ABI_Support_Routines_PreserveMost_From_X2_RegMask;
254 "Calling convention CFGuard_Check is unsupported on Darwin.");
259 return CSR_Darwin_AArch64_AAPCS_SwiftError_RegMask;
261 return CSR_Darwin_AArch64_AAPCS_SwiftTail_RegMask;
263 return CSR_Darwin_AArch64_RT_MostRegs_RegMask;
265 return CSR_Darwin_AArch64_RT_AllRegs_RegMask;
266 return CSR_Darwin_AArch64_AAPCS_RegMask;
275 return SCS ? CSR_AArch64_NoRegs_SCS_RegMask : CSR_AArch64_NoRegs_RegMask;
277 return SCS ? CSR_AArch64_NoneRegs_SCS_RegMask
278 : CSR_AArch64_NoneRegs_RegMask;
280 return SCS ? CSR_AArch64_AllRegs_SCS_RegMask : CSR_AArch64_AllRegs_RegMask;
290 return SCS ? CSR_AArch64_AAVPCS_SCS_RegMask : CSR_AArch64_AAVPCS_RegMask;
292 return SCS ? CSR_AArch64_SVE_AAPCS_SCS_RegMask
293 : CSR_AArch64_SVE_AAPCS_RegMask;
295 return CSR_AArch64_SME_ABI_Support_Routines_PreserveMost_From_X0_RegMask;
297 return CSR_AArch64_SME_ABI_Support_Routines_PreserveMost_From_X1_RegMask;
299 return CSR_AArch64_SME_ABI_Support_Routines_PreserveMost_From_X2_RegMask;
301 return CSR_Win_AArch64_CFGuard_Check_RegMask;
305 return SCS ? CSR_AArch64_AAPCS_SwiftError_SCS_RegMask
306 : CSR_AArch64_AAPCS_SwiftError_RegMask;
310 return CSR_AArch64_AAPCS_SwiftTail_RegMask;
313 return SCS ? CSR_AArch64_RT_MostRegs_SCS_RegMask
314 : CSR_AArch64_RT_MostRegs_RegMask;
316 return SCS ? CSR_AArch64_RT_AllRegs_SCS_RegMask
317 : CSR_AArch64_RT_AllRegs_RegMask;
319 return SCS ? CSR_AArch64_AAPCS_SCS_RegMask : CSR_AArch64_AAPCS_RegMask;
325 return CSR_AArch64_AAPCS_RegMask;
332 return CSR_Darwin_AArch64_TLS_RegMask;
334 assert(TT.isOSBinFormatELF() &&
"Invalid target");
335 return CSR_AArch64_TLS_ELF_RegMask;
342 memcpy(UpdatedMask, *Mask,
sizeof(UpdatedMask[0]) * RegMaskSize);
344 for (
size_t i = 0; i < AArch64::GPR64commonRegClass.getNumRegs(); ++i) {
347 subregs_inclusive(AArch64::GPR64commonRegClass.getRegister(i))) {
350 UpdatedMask[SubReg / 32] |= 1u << (SubReg % 32);
358 return CSR_AArch64_SMStartStop_RegMask;
363 return CSR_AArch64_SME_ABI_Support_Routines_PreserveMost_From_X0_RegMask;
367 return CSR_AArch64_NoRegs_RegMask;
382 return CSR_Darwin_AArch64_AAPCS_ThisReturn_RegMask;
383 return CSR_AArch64_AAPCS_ThisReturn_RegMask;
387 return CSR_AArch64_StackProbe_Windows_RegMask;
390std::optional<std::string>
394 return std::string(
"X19 is used as the frame base pointer register.");
405 for (
unsigned i = AArch64::B16; i <= AArch64::B31; ++i)
411 " is clobbered by asynchronous signals when using Arm64EC.";
422 markSuperRegs(
Reserved, AArch64::WSP);
423 markSuperRegs(
Reserved, AArch64::WZR);
426 markSuperRegs(
Reserved, AArch64::W29);
431 markSuperRegs(
Reserved, AArch64::W13);
432 markSuperRegs(
Reserved, AArch64::W14);
433 markSuperRegs(
Reserved, AArch64::W23);
434 markSuperRegs(
Reserved, AArch64::W24);
435 markSuperRegs(
Reserved, AArch64::W28);
436 for (
unsigned i = AArch64::B16; i <= AArch64::B31; ++i)
441 markSuperRegs(
Reserved, AArch64::W28);
442 markSuperRegs(
Reserved, AArch64::W27);
443 markSuperRegs(
Reserved, AArch64::W26);
444 markSuperRegs(
Reserved, AArch64::W25);
446 markSuperRegs(
Reserved, AArch64::LR);
447 markSuperRegs(
Reserved, AArch64::W30);
451 for (
size_t i = 0; i < AArch64::GPR32commonRegClass.getNumRegs(); ++i) {
453 markSuperRegs(
Reserved, AArch64::GPR32commonRegClass.getRegister(i));
457 markSuperRegs(
Reserved, AArch64::W19);
461 markSuperRegs(
Reserved, AArch64::W16);
469 for (
MCPhysReg SubReg : subregs_inclusive(AArch64::ZA))
482 markSuperRegs(
Reserved, AArch64::FPCR);
483 markSuperRegs(
Reserved, AArch64::FPMR);
484 markSuperRegs(
Reserved, AArch64::FPSR);
487 markSuperRegs(
Reserved, AArch64::X27);
488 markSuperRegs(
Reserved, AArch64::X28);
489 markSuperRegs(
Reserved, AArch64::W27);
490 markSuperRegs(
Reserved, AArch64::W28);
499 static_assert(AArch64::W30_HI - AArch64::W0_HI == 30,
500 "Unexpected order of registers");
501 Reserved.set(AArch64::W0_HI, AArch64::W30_HI + 1);
502 static_assert(AArch64::B31_HI - AArch64::B0_HI == 31,
503 "Unexpected order of registers");
504 Reserved.set(AArch64::B0_HI, AArch64::B31_HI + 1);
505 static_assert(AArch64::H31_HI - AArch64::H0_HI == 31,
506 "Unexpected order of registers");
507 Reserved.set(AArch64::H0_HI, AArch64::H31_HI + 1);
508 static_assert(AArch64::S31_HI - AArch64::S0_HI == 31,
509 "Unexpected order of registers");
510 Reserved.set(AArch64::S0_HI, AArch64::S31_HI + 1);
511 static_assert(AArch64::D31_HI - AArch64::D0_HI == 31,
512 "Unexpected order of registers");
513 Reserved.set(AArch64::D0_HI, AArch64::D31_HI + 1);
514 static_assert(AArch64::Q31_HI - AArch64::Q0_HI == 31,
515 "Unexpected order of registers");
516 Reserved.set(AArch64::Q0_HI, AArch64::Q31_HI + 1);
524 for (
size_t i = 0; i < AArch64::GPR32commonRegClass.getNumRegs(); ++i) {
528 markSuperRegs(
Reserved, AArch64::GPR32commonRegClass.getRegister(i));
536 for (
size_t i = 0; i < AArch64::GPR32commonRegClass.getNumRegs(); ++i) {
538 markSuperRegs(
Reserved, AArch64::GPR32commonRegClass.getRegister(i));
550 markSuperRegs(
Reserved, AArch64::W30);
578 for (
size_t i = 0; i < 8; ++i) {
589 " function calls if any of the argument registers is reserved.")});
602 if (PhysReg == AArch64::ZA || PhysReg == AArch64::ZT0)
610 return &AArch64::GPR64spRegClass;
615 if (RC == &AArch64::CCRRegClass)
616 return &AArch64::GPR64RegClass;
634 if (hasStackRealignment(MF))
639 if (ST.hasSVE() || ST.isStreaming()) {
642 if (!AFI->hasCalculatedStackSizeSVE() || AFI->hasSVEStackSize())
653 if (ST.getStreamingHazardSize() &&
654 !AFI->getSMEFnAttrs().hasNonStreamingInterfaceAndBody()) {
686 return HasReg(CC_AArch64_GHC_ArgRegs, Reg);
689 return HasReg(CC_AArch64_Preserve_None_ArgRegs, Reg);
701 return HasReg(CC_AArch64_Win64_VarArg_ArgRegs, Reg);
704 return HasReg(CC_AArch64_Win64PCS_ArgRegs, Reg);
707 return HasReg(CC_AArch64_Win64PCS_Swift_ArgRegs, Reg) ||
708 HasReg(CC_AArch64_Win64PCS_ArgRegs, Reg);
714 return HasReg(CC_AArch64_AAPCS_ArgRegs, Reg);
717 return HasReg(CC_AArch64_AAPCS_ArgRegs, Reg) ||
718 HasReg(CC_AArch64_AAPCS_Swift_ArgRegs, Reg);
724 return HasReg(CC_AArch64_DarwinPCS_ArgRegs, Reg);
727 return HasReg(CC_AArch64_DarwinPCS_ArgRegs, Reg) ||
728 HasReg(CC_AArch64_DarwinPCS_Swift_ArgRegs, Reg);
732 return HasReg(CC_AArch64_DarwinPCS_ILP32_VarArg_ArgRegs, Reg);
733 return HasReg(CC_AArch64_DarwinPCS_VarArg_ArgRegs, Reg);
736 HasReg(CC_AArch64_Win64_VarArg_ArgRegs, Reg);
737 return HasReg(CC_AArch64_Win64PCS_ArgRegs, Reg);
739 return HasReg(CC_AArch64_Win64_CFGuard_Check_ArgRegs, Reg);
746 return HasReg(CC_AArch64_Win64PCS_ArgRegs, Reg);
747 return HasReg(CC_AArch64_AAPCS_ArgRegs, Reg);
754 return TFI->
hasFP(MF) ? AArch64::FP : AArch64::SP;
781 "Expected SVE area to be calculated by this point");
805 for (
unsigned i = 0; !
MI->getOperand(i).isFI(); ++i)
806 assert(i < MI->getNumOperands() &&
807 "Instr doesn't have FrameIndex operand!");
818 if (!
MI->mayLoad() && !
MI->mayStore())
833 int64_t FPOffset =
Offset - 16 * 20;
870 assert(
MI &&
"Unable to get the legal offset for nil instruction.");
883 if (Ins !=
MBB->end())
884 DL = Ins->getDebugLoc();
908 while (!
MI.getOperand(i).isFI()) {
910 assert(i <
MI.getNumOperands() &&
"Instr doesn't have FrameIndex operand!");
917 assert(
Done &&
"Unable to resolve frame index!");
931 if (
MI.getOpcode() == AArch64::STGloop ||
932 MI.getOpcode() == AArch64::STZGloop) {
933 assert(FIOperandNum == 3 &&
934 "Wrong frame index operand for STGloop/STZGloop");
935 unsigned Op =
MI.getOpcode() == AArch64::STGloop ? AArch64::STGloop_wback
936 : AArch64::STZGloop_wback;
937 ScratchReg =
MI.getOperand(1).getReg();
938 MI.getOperand(3).ChangeToRegister(ScratchReg,
false,
false,
true);
940 MI.tieOperands(1, 3);
943 MI.getMF()->getRegInfo().createVirtualRegister(&AArch64::GPR64RegClass);
944 MI.getOperand(FIOperandNum)
945 .ChangeToRegister(ScratchReg,
false,
false,
true);
955 assert(
Offset.getScalable() % 2 == 0 &&
"Invalid frame offset");
961 int64_t VGSized =
Offset.getScalable() / 2;
963 Ops.push_back(dwarf::DW_OP_constu);
964 Ops.push_back(VGSized);
965 Ops.append({dwarf::DW_OP_bregx, VG, 0ULL});
966 Ops.push_back(dwarf::DW_OP_mul);
967 Ops.push_back(dwarf::DW_OP_plus);
968 }
else if (VGSized < 0) {
969 Ops.push_back(dwarf::DW_OP_constu);
970 Ops.push_back(-VGSized);
971 Ops.append({dwarf::DW_OP_bregx, VG, 0ULL});
972 Ops.push_back(dwarf::DW_OP_mul);
973 Ops.push_back(dwarf::DW_OP_minus);
978 int SPAdj,
unsigned FIOperandNum,
980 assert(SPAdj == 0 &&
"Unexpected");
989 int FrameIndex =
MI.getOperand(FIOperandNum).getIndex();
995 if (
MI.getOpcode() == TargetOpcode::STACKMAP ||
996 MI.getOpcode() == TargetOpcode::PATCHPOINT ||
997 MI.getOpcode() == TargetOpcode::STATEPOINT) {
1003 MI.getOperand(FIOperandNum).ChangeToRegister(FrameReg,
false );
1004 MI.getOperand(FIOperandNum + 1).ChangeToImmediate(
Offset.getFixed());
1008 if (
MI.getOpcode() == TargetOpcode::LOCAL_ESCAPE) {
1012 "Frame offsets with a scalable component are not supported");
1018 if (
MI.getOpcode() == AArch64::TAGPstack) {
1021 FrameReg =
MI.getOperand(3).getReg();
1024 }
else if (Tagged) {
1033 MF, FrameIndex, FrameReg,
false,
true);
1042 MI.getOperand(FIOperandNum)
1043 .ChangeToRegister(ScratchReg,
false,
false,
true);
1046 FrameReg = AArch64::SP;
1051 MF, FrameIndex, FrameReg,
false,
true);
1058 assert((!RS || !RS->isScavengingFrameIndex(FrameIndex)) &&
1059 "Emergency spill slot is out of reach");
1074 switch (RC->
getID()) {
1077 case AArch64::GPR32RegClassID:
1078 case AArch64::GPR32spRegClassID:
1079 case AArch64::GPR32allRegClassID:
1080 case AArch64::GPR64spRegClassID:
1081 case AArch64::GPR64allRegClassID:
1082 case AArch64::GPR64RegClassID:
1083 case AArch64::GPR32commonRegClassID:
1084 case AArch64::GPR64commonRegClassID:
1086 - (TFI->
hasFP(MF) || TT.isOSDarwin())
1089 case AArch64::FPR8RegClassID:
1090 case AArch64::FPR16RegClassID:
1091 case AArch64::FPR32RegClassID:
1092 case AArch64::FPR64RegClassID:
1093 case AArch64::FPR128RegClassID:
1096 case AArch64::MatrixIndexGPR32_8_11RegClassID:
1097 case AArch64::MatrixIndexGPR32_12_15RegClassID:
1100 case AArch64::DDRegClassID:
1101 case AArch64::DDDRegClassID:
1102 case AArch64::DDDDRegClassID:
1103 case AArch64::QQRegClassID:
1104 case AArch64::QQQRegClassID:
1105 case AArch64::QQQQRegClassID:
1108 case AArch64::FPR128_loRegClassID:
1109 case AArch64::FPR64_loRegClassID:
1110 case AArch64::FPR16_loRegClassID:
1112 case AArch64::FPR128_0to7RegClassID:
1123 if (!ST.useDistinctPredicateDstReg() ||
1124 !AArch64::PPRRegClass.hasSubClassEq(RegRC) || !MRI.
hasOneDef(VirtReg) ||
1135 Op1Reg = VRM->
getPhys(Op1Reg);
1150 for (
unsigned I = 0;; ++
I) {
1154 if (AArch64::PPRRegClass.
contains(R))
1163 bool PrefA = (
A != Op1Reg) && CanUseReg(
A);
1164 bool PrefB = (
B != Op1Reg) && CanUseReg(
B);
1165 return PrefA && !PrefB;
1199 bool ConsiderOnlyHints =
1206 if (AArch64::ZPRRegClass.hasSubClassEq(RegRC)) {
1209 if (DefOp.isImplicit() ||
1214 unsigned InstFlags =
1218 auto AddHintIfSuitable = [&](
MCPhysReg R,
1223 if (PhysReg && MO.getSubReg())
1224 PhysReg = getSubReg(PhysReg, MO.getSubReg());
1235 AddHintIfSuitable(R, Def.getOperand(2)) ||
1236 AddHintIfSuitable(R, Def.getOperand(3)) ||
1237 AddHintIfSuitable(R, Def.getOperand(4));
1241 AddHintIfSuitable(R, Def.getOperand(2)) ||
1242 AddHintIfSuitable(R, Def.getOperand(3));
1246 AddHintIfSuitable(R, Def.getOperand(2));
1249 AddHintIfSuitable(R, Def.getOperand(3));
1253 AddHintIfSuitable(R, Def.getOperand(1));
1260 return ConsiderOnlyHints;
1265 return ConsiderOnlyHints;
1267 if (!ST.hasSME() || !ST.isStreaming())
1279 unsigned RegID = RegRC->
getID();
1280 if (RegID == AArch64::ZPR2StridedOrContiguousRegClassID ||
1281 RegID == AArch64::ZPR4StridedOrContiguousRegClassID) {
1285 if (
Use.getOpcode() != AArch64::COPY_INTO_TRANSPOSED_TUPLE)
1291 if (!Src.getSubReg() || !Dst.getSubReg())
1296 case AArch64::ZPR2StridedOrContiguousRegClassID:
1297 StridedRC = &AArch64::ZPR2StridedRegClass;
1299 case AArch64::ZPR4StridedOrContiguousRegClassID:
1300 StridedRC = &AArch64::ZPR4StridedRegClass;
1311 unsigned TupleSize =
Use.getOperand(2).getImm();
1312 unsigned TupIdx = Dst.getSubReg() - AArch64::zsub0;
1315 bool IsMulZPR = TupleID == AArch64::ZPR2Mul2RegClassID ||
1316 TupleID == AArch64::ZPR4Mul4RegClassID;
1321 auto &Src = Def.getOperand(1);
1322 return Def.getOpcode() ==
Use.getOpcode() &&
1363 if (CopyWithAssignedSrc ==
Copies.end()) {
1366 for (
unsigned I = 0;
I < StridedOrder.
size(); ++
I) {
1371 unsigned SubRegIdx = Src.getSubReg();
1373 (getSubReg(Reg, SubRegIdx) - AArch64::Z0) % TupleSize != TupIdx)
1379 auto IsFreeConsecutiveReg = [&](
unsigned I) {
1380 unsigned R = Reg - TupIdx +
I;
1383 ((getSubReg(R, AArch64::zsub0) - AArch64::Z0) ==
1384 (getSubReg(R - 1, AArch64::zsub0) - AArch64::Z0) + 1)) &&
1385 !
Matrix->isPhysRegUsed(R);
1387 if (
all_of(
seq(0U, TupleSize), IsFreeConsecutiveReg))
1400 unsigned AssignedTupIdx = AssignedDst.
getSubReg() - AArch64::zsub0;
1402 getSubReg(VRM->
getPhys(AssignedSrc.
getReg()), AArch64::zsub0) +
1403 (TupIdx - AssignedTupIdx);
1405 for (
unsigned I = 0;
I < StridedOrder.
size(); ++
I)
1406 if (getSubReg(StridedOrder[
I], AArch64::zsub0) == TargetStartReg)
1417 if (Def.getOpcode() != AArch64::COPY_INTO_TRANSPOSED_TUPLE)
1423 if (!Src.getSubReg() || !Dst.getSubReg())
1430 if (!VRM->
hasPhys(Src.getReg()))
1438 if (getSubReg(R, Dst.getSubReg()) == SrcZPR)
1452 else if (hasStackRealignment(MF))
1470 ((DstRC->
getID() == AArch64::GPR64RegClassID) ||
1471 (DstRC->
getID() == AArch64::GPR64commonRegClassID)) &&
1472 MI->getOperand(0).getSubReg() &&
MI->getOperand(1).getSubReg())
1479 switch (
MI.getOpcode()) {
1480 case AArch64::COALESCER_BARRIER_FPR16:
1481 case AArch64::COALESCER_BARRIER_FPR32:
1482 case AArch64::COALESCER_BARRIER_FPR64:
1483 case AArch64::COALESCER_BARRIER_FPR128:
1499 if (
MI->isCopy() && SubReg != DstSubReg &&
1500 (AArch64::ZPRRegClass.hasSubClassEq(DstRC) ||
1501 AArch64::ZPRRegClass.hasSubClassEq(SrcRC))) {
1502 unsigned SrcReg =
MI->getOperand(1).getReg();
1505 unsigned DstReg =
MI->getOperand(0).getReg();
1515 return R == AArch64::VG;
1519 return (LLVMReg >= AArch64::Z0 && LLVMReg <= AArch64::Z31) ||
1520 (LLVMReg >= AArch64::P0 && LLVMReg <= AArch64::P15);
static bool isTargetWindows(const MachineFunction &MF)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static Register createScratchRegisterForInstruction(MachineInstr &MI, unsigned FIOperandNum, const AArch64InstrInfo *TII)
static bool HandleDestructivePredicateHint(Register VirtReg, ArrayRef< MCPhysReg > Order, SmallVectorImpl< MCPhysReg > &Hints, const VirtRegMap *VRM, const MachineRegisterInfo &MRI, const TargetInstrInfo &TII, const AArch64Subtarget &ST, const LiveRegMatrix *Matrix)
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file implements the BitVector class.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
This file contains constants used for implementing Dwarf debug support.
const HexagonInstrInfo * TII
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
uint64_t IntrinsicInst * II
This file declares the machine register scavenger class.
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
static unsigned getDwarfRegNum(MCRegister Reg, const TargetRegisterInfo *TRI)
Go up the super-register chain until we hit a valid dwarf register number.
StackOffset getNonLocalFrameIndexReference(const MachineFunction &MF, int FI) const override
getNonLocalFrameIndexReference - This method returns the offset used to reference a frame index locat...
bool isFPReserved(const MachineFunction &MF) const
Should the Frame Pointer be reserved for the current function?
StackOffset resolveFrameIndexReference(const MachineFunction &MF, int FI, Register &FrameReg, bool PreferFP, bool ForSimm) const
AArch64FunctionInfo - This class is derived from MachineFunctionInfo and contains private AArch64-spe...
unsigned getTaggedBasePointerOffset() const
bool hasStackHazardSlotIndex() const
bool hasCalculatedStackSizeSVE() const
bool hasSVEStackSize() const
static const char * getRegisterName(MCRegister Reg, unsigned AltIdx=AArch64::NoRegAltName)
BitVector getStrictlyReservedRegs(const MachineFunction &MF) const
const TargetRegisterClass * getCrossCopyRegClass(const TargetRegisterClass *RC) const override
const uint32_t * getThisReturnPreservedMask(const MachineFunction &MF, CallingConv::ID) const
getThisReturnPreservedMask - Returns a call preserved mask specific to the case that 'returned' is on...
MCRegister getBaseRegister() const
bool isReservedReg(const MachineFunction &MF, MCRegister Reg) const
const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID) const override
const MCPhysReg * getCalleeSavedRegsViaCopy(const MachineFunction *MF) const
bool isIgnoredCVReg(MCRegister LLVMReg) const override
BitVector getReservedRegs(const MachineFunction &MF) const override
const TargetRegisterClass * getPointerRegClass(unsigned Kind=0) const override
bool shouldCoalesce(MachineInstr *MI, const TargetRegisterClass *SrcRC, unsigned SubReg, const TargetRegisterClass *DstRC, unsigned DstSubReg, const TargetRegisterClass *NewRC, LiveIntervals &LIS) const override
SrcRC and DstRC will be morphed into NewRC if this returns true.
bool requiresVirtualBaseRegisters(const MachineFunction &MF) const override
bool isUserReservedReg(const MachineFunction &MF, MCRegister Reg) const
const TargetRegisterClass * getSubClassWithSubReg(const TargetRegisterClass *RC, unsigned Idx) const override
unsigned getRegPressureLimit(const TargetRegisterClass *RC, MachineFunction &MF) const override
bool getRegAllocationHints(Register VirtReg, ArrayRef< MCPhysReg > Order, SmallVectorImpl< MCPhysReg > &Hints, const MachineFunction &MF, const VirtRegMap *VRM, const LiveRegMatrix *Matrix) const override
Register materializeFrameBaseRegister(MachineBasicBlock *MBB, int FrameIdx, int64_t Offset) const override
Insert defining instruction(s) for BaseReg to be a pointer to FrameIdx at the beginning of the basic ...
void UpdateCustomCalleeSavedRegs(MachineFunction &MF) const
bool requiresRegisterScavenging(const MachineFunction &MF) const override
bool isFrameOffsetLegal(const MachineInstr *MI, Register BaseReg, int64_t Offset) const override
BitVector getUserReservedRegs(const MachineFunction &MF) const
void resolveFrameIndex(MachineInstr &MI, Register BaseReg, int64_t Offset) const override
bool needsFrameBaseReg(MachineInstr *MI, int64_t Offset) const override
needsFrameBaseReg - Returns true if the instruction's frame index reference would be better served by...
const uint32_t * getWindowsStackProbePreservedMask() const
Stack probing calls preserve different CSRs to the normal CC.
bool regNeedsCFI(MCRegister Reg, MCRegister &RegToUseForCFI) const
Return whether the register needs a CFI entry.
bool isAnyArgRegReserved(const MachineFunction &MF) const
void emitReservedArgRegCallError(const MachineFunction &MF) const
bool isStrictlyReservedReg(const MachineFunction &MF, MCRegister Reg) const
bool eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj, unsigned FIOperandNum, RegScavenger *RS=nullptr) const override
const uint32_t * getTLSCallPreservedMask() const
const uint32_t * getNoPreservedMask() const override
Register getFrameRegister(const MachineFunction &MF) const override
bool shouldAnalyzePhysregInMachineLoopInfo(MCRegister R) const override
void getOffsetOpcodes(const StackOffset &Offset, SmallVectorImpl< uint64_t > &Ops) const override
bool isAsmClobberable(const MachineFunction &MF, MCRegister PhysReg) const override
AArch64RegisterInfo(const Triple &TT, unsigned HwMode)
const uint32_t * SMEABISupportRoutinesCallPreservedMaskFromX0() const
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const override
Code Generation virtual methods...
const uint32_t * getCustomEHPadPreservedMask(const MachineFunction &MF) const override
unsigned getLocalAddressRegister(const MachineFunction &MF) const
bool hasBasePointer(const MachineFunction &MF) const
const uint32_t * getDarwinCallPreservedMask(const MachineFunction &MF, CallingConv::ID) const
const uint32_t * getSMStartStopCallPreservedMask() const
bool useFPForScavengingIndex(const MachineFunction &MF) const override
bool cannotEliminateFrame(const MachineFunction &MF) const
bool isArgumentRegister(const MachineFunction &MF, MCRegister Reg) const override
void UpdateCustomCallPreservedMask(MachineFunction &MF, const uint32_t **Mask) const
std::optional< std::string > explainReservedReg(const MachineFunction &MF, MCRegister PhysReg) const override
bool requiresFrameIndexScavenging(const MachineFunction &MF) const override
bool isTargetWindows() const
bool enableSRLTSubregToRegMitigation() const
bool isLRReservedForRA() const
bool isTargetDarwin() const
bool isTargetILP32() const
bool isXRegisterReservedForRA(size_t i) const
const AArch64TargetLowering * getTargetLowering() const override
bool isXRegCustomCalleeSaved(size_t i) const
bool isWindowsArm64EC() const
bool isXRegisterReserved(size_t i) const
bool isCallingConvWin64(CallingConv::ID CC, bool IsVarArg) const
bool isTargetLinux() const
bool supportSwiftError() const override
Return true if the target supports swifterror attribute.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
static LLVM_ABI void appendOffset(SmallVectorImpl< uint64_t > &Ops, int64_t Offset)
Append Ops with operations to apply the Offset.
Implements a dense probed hash-table based set.
Diagnostic information for unsupported feature in backend.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
AttributeList getAttributes() const
Return the attribute list for this Function.
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Describe properties that are true of each instruction in the target description file.
unsigned getID() const
getID() - Return the register class ID number.
bool contains(MCRegister Reg) const
contains - Return true if the specified register is included in this register class.
bool regsOverlap(MCRegister RegA, MCRegister RegB) const
Returns true if the two registers are equal or alias each other.
Wrapper class representing physical registers. Should be passed by value.
MCSubRegIterator enumerates all sub-registers of Reg.
bool isValid() const
Returns true if this iterator is not yet at the end.
MachineInstrBundleIterator< MachineInstr > iterator
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 ...
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects.
bool adjustsStack() const
Return true if this function adjusts the stack – e.g., when calling another function.
bool isFrameAddressTaken() const
This method may be called any time after instruction selection is complete to determine if there is a...
int64_t getLocalFrameSize() const
Get the size of the local object blob.
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
uint32_t * allocateRegMask()
Allocate and initialize a register mask with NumRegister bits.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
LLVM_ABI bool disableFramePointerElim() const
Returns true if frame pointer elimination should be disabled for this function.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
const MachineFunctionProperties & getProperties() const
Get the function properties.
bool hasEHFunclets() const
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & addFrameIndex(int Idx) const
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MachineOperand & getOperand(unsigned i) const
MachineOperand class - Representation of each machine instruction operand.
unsigned getSubReg() const
LLVM_ABI void ChangeToImmediate(int64_t ImmVal, unsigned TargetFlags=0)
ChangeToImmediate - Replace this operand with a new immediate operand of the specified value.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
static unsigned getRegMaskSize(unsigned NumRegs)
Returns number of elements needed for a regmask array.
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
iterator_range< def_instr_iterator > def_instructions(Register Reg) const
bool subRegLivenessEnabled() const
MachineOperand * getOneDef(Register Reg) const
Returns the defining operand if there is exactly one operand defining the specified register,...
defusechain_instr_iterator< false, true, false, true > def_instr_iterator
def_instr_iterator/def_instr_begin/def_instr_end - Walk all defs of the specified register,...
LLVM_ABI Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
bool def_empty(Register RegNo) const
def_empty - Return true if there are no instructions defining the specified register (it may be live-...
LLVM_ABI const MCPhysReg * getCalleeSavedRegs() const
Returns list of callee saved registers.
iterator_range< use_instr_nodbg_iterator > use_nodbg_instructions(Register Reg) const
iterator_range< def_iterator > def_operands(Register Reg) const
bool hasOneDef(Register RegNo) const
Return true if there is exactly one operand defining the specified register.
LLVM_ABI void setCalleeSavedRegs(ArrayRef< MCPhysReg > CSRs)
Sets the updated Callee Saved Registers list.
LLVM_ABI const TargetRegisterClass * constrainRegClass(Register Reg, const TargetRegisterClass *RC, unsigned MinNumRegs=0)
constrainRegClass - Constrain the register class of the specified virtual register to be a common sub...
Wrapper class representing virtual and physical registers.
constexpr bool isValid() const
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StackOffset holds a fixed and a scalable offset in bytes.
int64_t getFixed() const
Returns the fixed component of the stack.
bool hasFP(const MachineFunction &MF) const
hasFP - Return true if the specified function should have a dedicated frame pointer register.
TargetInstrInfo - Interface to description of machine instruction set.
virtual bool getRegAllocationHints(Register VirtReg, ArrayRef< MCPhysReg > Order, SmallVectorImpl< MCPhysReg > &Hints, const MachineFunction &MF, const VirtRegMap *VRM=nullptr, const LiveRegMatrix *Matrix=nullptr) const
Get a list of 'hint' registers that the register allocator should try first when allocating a physica...
Triple - Helper class for working with autoconf configuration names.
A Use represents the edge between a Value definition and its users.
MCRegister getPhys(Register virtReg) const
returns the physical register mapped to the specified virtual register
bool hasPhys(Register virtReg) const
returns true if the specified virtual register is mapped to a physical register
std::pair< iterator, bool > insert(const ValueT &V)
bool contains(const_arg_type_t< ValueT > V) const
Check if the set contains the given element.
A range adaptor for a pair of iterators.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ MO_TAGGED
MO_TAGGED - With MO_PAGE, indicates that the page includes a memory tag in bits 56-63.
static unsigned getShifterImm(AArch64_AM::ShiftExtendType ST, unsigned Imm)
getShifterImm - Encode the shift type and amount: imm: 6-bit shift amount shifter: 000 ==> lsl 001 ==...
void initLLVMToCVRegMapping(MCRegisterInfo *MRI)
@ DestructiveBinaryShImmUnpred
@ DestructiveInstTypeMask
@ DestructiveUnaryPassthru
@ DestructiveBinaryImmUnpred
@ DestructiveTernaryCommWithRev
@ DestructiveBinaryCommWithRev
int32_t getSVEPseudoMap(uint32_t Opcode)
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ AArch64_VectorCall
Used between AArch64 Advanced SIMD functions.
@ Swift
Calling convention for Swift.
@ AArch64_SVE_VectorCall
Used between AArch64 SVE functions.
@ CFGuard_Check
Special calling convention on Windows for calling the Control Guard Check ICall funtion.
@ PreserveMost
Used for runtime calls that preserves most registers.
@ AnyReg
OBSOLETED - Used for stack based JavaScript calls.
@ AArch64_SME_ABI_Support_Routines_PreserveMost_From_X2
Preserve X2-X15, X19-X29, SP, Z0-Z31, P0-P15.
@ CXX_FAST_TLS
Used for access functions.
@ AArch64_SME_ABI_Support_Routines_PreserveMost_From_X0
Preserve X0-X13, X19-X29, SP, Z0-Z31, P0-P15.
@ GHC
Used by the Glasgow Haskell Compiler (GHC).
@ AArch64_SME_ABI_Support_Routines_PreserveMost_From_X1
Preserve X1-X15, X19-X29, SP, Z0-Z31, P0-P15.
@ PreserveAll
Used for runtime calls that preserves (almost) all registers.
@ Fast
Attempts to make calls as fast as possible (e.g.
@ PreserveNone
Used for runtime calls that preserves none general registers.
@ Tail
Attemps to make calls as fast as possible while guaranteeing that tail call optimization can always b...
@ Win64
The C convention as implemented on Windows/x86-64 and AArch64.
@ SwiftTail
This follows the Swift calling convention in how arguments are passed but guarantees tail calls will ...
@ GRAAL
Used by GraalVM. Two additional registers are reserved.
@ ARM64EC_Thunk_X64
Calling convention used in the ARM64EC ABI to implement calls between x64 code and thunks.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
void stable_sort(R &&Range)
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
int isAArch64FrameOffsetLegal(const MachineInstr &MI, StackOffset &Offset, bool *OutUseUnscaledOp=nullptr, unsigned *OutUnscaledOp=nullptr, int64_t *EmittableOffset=nullptr)
Check if the Offset is a valid frame offset for MI.
@ AArch64FrameOffsetIsLegal
Offset is legal.
@ AArch64FrameOffsetCanUpdate
Offset can apply, at least partly.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
void emitFrameOffset(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, StackOffset Offset, const TargetInstrInfo *TII, MachineInstr::MIFlag=MachineInstr::NoFlags, bool SetNZCV=false, bool NeedsWinCFI=false, bool *HasWinCFI=nullptr, bool EmitCFAOffset=false, StackOffset InitialOffset={}, unsigned FrameReg=AArch64::SP)
emitFrameOffset - Emit instructions as needed to set DestReg to SrcReg plus Offset.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
DWARFExpression::Operation Op
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
constexpr auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.
bool rewriteAArch64FrameIndex(MachineInstr &MI, unsigned FrameRegIdx, unsigned FrameReg, StackOffset &Offset, const AArch64InstrInfo *TII)
rewriteAArch64FrameIndex - Rewrite MI to access 'Offset' bytes from the FP.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
MCRegisterClass TargetRegisterClass