65#define GET_INSTRINFO_CTOR_DTOR
66#include "AArch64GenInstrInfo.inc"
70 cl::desc(
"Restrict range of CB instructions (DEBUG)"));
74 cl::desc(
"Restrict range of TB[N]Z instructions (DEBUG)"));
78 cl::desc(
"Restrict range of CB[N]Z instructions (DEBUG)"));
82 cl::desc(
"Restrict range of Bcc instructions (DEBUG)"));
86 cl::desc(
"Restrict range of B instructions (DEBUG)"));
90 cl::desc(
"Restrict range of instructions to search for the "
91 "machine-combiner gather pattern optimization"));
96 RI(STI.getTargetTriple(), STI.getHwMode()), Subtarget(STI) {}
107 auto Op =
MI.getOpcode();
108 if (
Op == AArch64::INLINEASM ||
Op == AArch64::INLINEASM_BR)
109 return getInlineAsmLength(
MI.getOperand(0).getSymbolName(), *MAI);
113 if (
MI.isMetaInstruction())
118 unsigned NumBytes = 0;
122 NumBytes =
Desc.getSize() ?
Desc.getSize() : 4;
125 if (!MFI->shouldSignReturnAddress(MF))
137 switch (
Desc.getOpcode()) {
140 return Desc.getSize();
147 case TargetOpcode::STACKMAP:
150 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
152 case TargetOpcode::PATCHPOINT:
155 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
157 case TargetOpcode::STATEPOINT:
159 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
164 case TargetOpcode::PATCHABLE_FUNCTION_ENTER:
169 F.getFnAttributeAsParsedInteger(
"patchable-function-entry", 9) * 4;
171 case TargetOpcode::PATCHABLE_FUNCTION_EXIT:
172 case TargetOpcode::PATCHABLE_TAIL_CALL:
173 case TargetOpcode::PATCHABLE_TYPED_EVENT_CALL:
177 case TargetOpcode::PATCHABLE_EVENT_CALL:
183 NumBytes =
MI.getOperand(1).getImm();
185 case TargetOpcode::BUNDLE:
186 NumBytes = getInstBundleLength(
MI);
193unsigned AArch64InstrInfo::getInstBundleLength(
const MachineInstr &
MI)
const {
197 while (++
I != E &&
I->isInsideBundle()) {
198 assert(!
I->isBundle() &&
"No nested bundle!");
233 case AArch64::CBWPri:
234 case AArch64::CBXPri:
235 case AArch64::CBWPrr:
236 case AArch64::CBXPrr:
265 case AArch64::CBWPri:
266 case AArch64::CBXPri:
267 case AArch64::CBWPrr:
268 case AArch64::CBXPrr:
274 int64_t BrOffset)
const {
276 assert(Bits >= 3 &&
"max branch displacement must be enough to jump"
277 "over conditional branch expansion");
278 return isIntN(Bits, BrOffset / 4);
283 switch (
MI.getOpcode()) {
287 return MI.getOperand(0).getMBB();
292 return MI.getOperand(2).getMBB();
298 return MI.getOperand(1).getMBB();
299 case AArch64::CBWPri:
300 case AArch64::CBXPri:
301 case AArch64::CBWPrr:
302 case AArch64::CBXPrr:
303 return MI.getOperand(3).getMBB();
313 assert(RS &&
"RegScavenger required for long branching");
315 "new block should be inserted for expanding unconditional branch");
318 "restore block should be inserted for restoring clobbered registers");
323 if (!isInt<33>(BrOffset))
325 "Branch offsets outside of the signed 33-bit range not supported");
339 constexpr Register Reg = AArch64::X16;
341 insertUnconditionalBranch(
MBB, &NewDestBB,
DL);
349 if (Scavenged != AArch64::NoRegister &&
351 buildIndirectBranch(Scavenged, NewDestBB);
361 "Unable to insert indirect branch inside function that has red zone");
384 bool AllowModify)
const {
391 if (
I->getOpcode() == AArch64::SpeculationBarrierISBDSBEndBB ||
392 I->getOpcode() == AArch64::SpeculationBarrierSBEndBB) {
396 if (!isUnpredicatedTerminator(*
I))
403 unsigned LastOpc = LastInst->
getOpcode();
404 if (
I ==
MBB.
begin() || !isUnpredicatedTerminator(*--
I)) {
419 unsigned SecondLastOpc = SecondLastInst->
getOpcode();
426 LastInst = SecondLastInst;
428 if (
I ==
MBB.
begin() || !isUnpredicatedTerminator(*--
I)) {
433 SecondLastInst = &*
I;
434 SecondLastOpc = SecondLastInst->
getOpcode();
445 LastInst = SecondLastInst;
447 if (
I ==
MBB.
begin() || !isUnpredicatedTerminator(*--
I)) {
449 "unreachable unconditional branches removed above");
458 SecondLastInst = &*
I;
459 SecondLastOpc = SecondLastInst->
getOpcode();
463 if (SecondLastInst &&
I !=
MBB.
begin() && isUnpredicatedTerminator(*--
I))
479 I->eraseFromParent();
488 I->eraseFromParent();
497 MachineBranchPredicate &MBP,
498 bool AllowModify)
const {
508 if (
I->getOpcode() == AArch64::SpeculationBarrierISBDSBEndBB ||
509 I->getOpcode() == AArch64::SpeculationBarrierSBEndBB) {
513 if (!isUnpredicatedTerminator(*
I))
518 unsigned LastOpc = LastInst->
getOpcode();
533 assert(MBP.TrueDest &&
"expected!");
536 MBP.ConditionDef =
nullptr;
537 MBP.SingleUseCondition =
false;
541 MBP.Predicate = (LastOpc == AArch64::CBNZX || LastOpc == AArch64::CBNZW)
542 ? MachineBranchPredicate::PRED_NE
543 : MachineBranchPredicate::PRED_EQ;
559 Cond[1].setImm(AArch64::CBNZW);
562 Cond[1].setImm(AArch64::CBZW);
565 Cond[1].setImm(AArch64::CBNZX);
568 Cond[1].setImm(AArch64::CBZX);
571 Cond[1].setImm(AArch64::TBNZW);
574 Cond[1].setImm(AArch64::TBZW);
577 Cond[1].setImm(AArch64::TBNZX);
580 Cond[1].setImm(AArch64::TBZX);
584 case AArch64::CBWPri:
585 case AArch64::CBXPri:
586 case AArch64::CBWPrr:
587 case AArch64::CBXPrr: {
600 int *BytesRemoved)
const {
610 I->eraseFromParent();
627 I->eraseFromParent();
634void AArch64InstrInfo::instantiateCondBranch(
664 assert(
TBB &&
"insertBranch must not be told to insert a fallthrough");
703 unsigned *NewVReg =
nullptr) {
708 bool Is64Bit = AArch64::GPR64allRegClass.hasSubClassEq(
MRI.getRegClass(VReg));
711 unsigned SrcOpNum = 0;
713 case AArch64::ADDSXri:
714 case AArch64::ADDSWri:
721 case AArch64::ADDXri:
722 case AArch64::ADDWri:
728 Opc = Is64Bit ? AArch64::CSINCXr : AArch64::CSINCWr;
731 case AArch64::ORNXrr:
732 case AArch64::ORNWrr: {
735 if (ZReg != AArch64::XZR && ZReg != AArch64::WZR)
738 Opc = Is64Bit ? AArch64::CSINVXr : AArch64::CSINVWr;
742 case AArch64::SUBSXrr:
743 case AArch64::SUBSWrr:
750 case AArch64::SUBXrr:
751 case AArch64::SUBWrr: {
754 if (ZReg != AArch64::XZR && ZReg != AArch64::WZR)
757 Opc = Is64Bit ? AArch64::CSNEGXr : AArch64::CSNEGWr;
763 assert(
Opc && SrcOpNum &&
"Missing parameters");
775 int &FalseCycles)
const {
779 RI.getCommonSubClass(
MRI.getRegClass(TrueReg),
MRI.getRegClass(FalseReg));
786 if (!RI.getCommonSubClass(RC,
MRI.getRegClass(DstReg)))
790 unsigned ExtraCondLat =
Cond.size() != 1;
794 if (AArch64::GPR64allRegClass.hasSubClassEq(RC) ||
795 AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
797 CondCycles = 1 + ExtraCondLat;
798 TrueCycles = FalseCycles = 1;
808 if (AArch64::FPR64RegClass.hasSubClassEq(RC) ||
809 AArch64::FPR32RegClass.hasSubClassEq(RC)) {
810 CondCycles = 5 + ExtraCondLat;
811 TrueCycles = FalseCycles = 2;
828 switch (
Cond.size()) {
860 MRI.constrainRegClass(SrcReg, &AArch64::GPR64spRegClass);
866 MRI.constrainRegClass(SrcReg, &AArch64::GPR32spRegClass);
905 unsigned SUBSOpC, SUBSDestReg;
911 case AArch64::CBWPri:
912 SUBSOpC = AArch64::SUBSWri;
913 SUBSDestReg = AArch64::WZR;
916 case AArch64::CBXPri:
917 SUBSOpC = AArch64::SUBSXri;
918 SUBSDestReg = AArch64::XZR;
921 case AArch64::CBWPrr:
922 SUBSOpC = AArch64::SUBSWrr;
923 SUBSDestReg = AArch64::WZR;
926 case AArch64::CBXPrr:
927 SUBSOpC = AArch64::SUBSXrr;
928 SUBSDestReg = AArch64::XZR;
947 bool TryFold =
false;
948 if (
MRI.constrainRegClass(DstReg, &AArch64::GPR64RegClass)) {
949 RC = &AArch64::GPR64RegClass;
950 Opc = AArch64::CSELXr;
952 }
else if (
MRI.constrainRegClass(DstReg, &AArch64::GPR32RegClass)) {
953 RC = &AArch64::GPR32RegClass;
954 Opc = AArch64::CSELWr;
956 }
else if (
MRI.constrainRegClass(DstReg, &AArch64::FPR64RegClass)) {
957 RC = &AArch64::FPR64RegClass;
958 Opc = AArch64::FCSELDrrr;
959 }
else if (
MRI.constrainRegClass(DstReg, &AArch64::FPR32RegClass)) {
960 RC = &AArch64::FPR32RegClass;
961 Opc = AArch64::FCSELSrrr;
963 assert(RC &&
"Unsupported regclass");
967 unsigned NewVReg = 0;
982 MRI.clearKillFlags(NewVReg);
987 MRI.constrainRegClass(TrueReg, RC);
988 MRI.constrainRegClass(FalseReg, RC);
1003 assert(BitSize == 64 &&
"Only bit sizes of 32 or 64 allowed");
1008 return Is.
size() <= 2;
1014 if (Subtarget.hasExynosCheapAsMoveHandling()) {
1015 if (isExynosCheapAsMove(
MI))
1017 return MI.isAsCheapAsAMove();
1020 switch (
MI.getOpcode()) {
1022 return MI.isAsCheapAsAMove();
1024 case AArch64::ADDWrs:
1025 case AArch64::ADDXrs:
1026 case AArch64::SUBWrs:
1027 case AArch64::SUBXrs:
1028 return Subtarget.hasALULSLFast() &&
MI.getOperand(3).getImm() <= 4;
1033 case AArch64::MOVi32imm:
1035 case AArch64::MOVi64imm:
1041 switch (
MI.getOpcode()) {
1045 case AArch64::ADDWrs:
1046 case AArch64::ADDXrs:
1047 case AArch64::ADDSWrs:
1048 case AArch64::ADDSXrs: {
1049 unsigned Imm =
MI.getOperand(3).getImm();
1056 case AArch64::ADDWrx:
1057 case AArch64::ADDXrx:
1058 case AArch64::ADDXrx64:
1059 case AArch64::ADDSWrx:
1060 case AArch64::ADDSXrx:
1061 case AArch64::ADDSXrx64: {
1062 unsigned Imm =
MI.getOperand(3).getImm();
1074 case AArch64::SUBWrs:
1075 case AArch64::SUBSWrs: {
1076 unsigned Imm =
MI.getOperand(3).getImm();
1078 return ShiftVal == 0 ||
1082 case AArch64::SUBXrs:
1083 case AArch64::SUBSXrs: {
1084 unsigned Imm =
MI.getOperand(3).getImm();
1086 return ShiftVal == 0 ||
1090 case AArch64::SUBWrx:
1091 case AArch64::SUBXrx:
1092 case AArch64::SUBXrx64:
1093 case AArch64::SUBSWrx:
1094 case AArch64::SUBSXrx:
1095 case AArch64::SUBSXrx64: {
1096 unsigned Imm =
MI.getOperand(3).getImm();
1108 case AArch64::LDRBBroW:
1109 case AArch64::LDRBBroX:
1110 case AArch64::LDRBroW:
1111 case AArch64::LDRBroX:
1112 case AArch64::LDRDroW:
1113 case AArch64::LDRDroX:
1114 case AArch64::LDRHHroW:
1115 case AArch64::LDRHHroX:
1116 case AArch64::LDRHroW:
1117 case AArch64::LDRHroX:
1118 case AArch64::LDRQroW:
1119 case AArch64::LDRQroX:
1120 case AArch64::LDRSBWroW:
1121 case AArch64::LDRSBWroX:
1122 case AArch64::LDRSBXroW:
1123 case AArch64::LDRSBXroX:
1124 case AArch64::LDRSHWroW:
1125 case AArch64::LDRSHWroX:
1126 case AArch64::LDRSHXroW:
1127 case AArch64::LDRSHXroX:
1128 case AArch64::LDRSWroW:
1129 case AArch64::LDRSWroX:
1130 case AArch64::LDRSroW:
1131 case AArch64::LDRSroX:
1132 case AArch64::LDRWroW:
1133 case AArch64::LDRWroX:
1134 case AArch64::LDRXroW:
1135 case AArch64::LDRXroX:
1136 case AArch64::PRFMroW:
1137 case AArch64::PRFMroX:
1138 case AArch64::STRBBroW:
1139 case AArch64::STRBBroX:
1140 case AArch64::STRBroW:
1141 case AArch64::STRBroX:
1142 case AArch64::STRDroW:
1143 case AArch64::STRDroX:
1144 case AArch64::STRHHroW:
1145 case AArch64::STRHHroX:
1146 case AArch64::STRHroW:
1147 case AArch64::STRHroX:
1148 case AArch64::STRQroW:
1149 case AArch64::STRQroX:
1150 case AArch64::STRSroW:
1151 case AArch64::STRSroX:
1152 case AArch64::STRWroW:
1153 case AArch64::STRWroX:
1154 case AArch64::STRXroW:
1155 case AArch64::STRXroX: {
1156 unsigned IsSigned =
MI.getOperand(3).getImm();
1163 unsigned Opc =
MI.getOpcode();
1167 case AArch64::SEH_StackAlloc:
1168 case AArch64::SEH_SaveFPLR:
1169 case AArch64::SEH_SaveFPLR_X:
1170 case AArch64::SEH_SaveReg:
1171 case AArch64::SEH_SaveReg_X:
1172 case AArch64::SEH_SaveRegP:
1173 case AArch64::SEH_SaveRegP_X:
1174 case AArch64::SEH_SaveFReg:
1175 case AArch64::SEH_SaveFReg_X:
1176 case AArch64::SEH_SaveFRegP:
1177 case AArch64::SEH_SaveFRegP_X:
1178 case AArch64::SEH_SetFP:
1179 case AArch64::SEH_AddFP:
1180 case AArch64::SEH_Nop:
1181 case AArch64::SEH_PrologEnd:
1182 case AArch64::SEH_EpilogStart:
1183 case AArch64::SEH_EpilogEnd:
1184 case AArch64::SEH_PACSignLR:
1185 case AArch64::SEH_SaveAnyRegQP:
1186 case AArch64::SEH_SaveAnyRegQPX:
1187 case AArch64::SEH_AllocZ:
1188 case AArch64::SEH_SaveZReg:
1189 case AArch64::SEH_SavePReg:
1196 unsigned &SubIdx)
const {
1197 switch (
MI.getOpcode()) {
1200 case AArch64::SBFMXri:
1201 case AArch64::UBFMXri:
1204 if (
MI.getOperand(2).getImm() != 0 ||
MI.getOperand(3).getImm() != 31)
1207 SrcReg =
MI.getOperand(1).getReg();
1208 DstReg =
MI.getOperand(0).getReg();
1209 SubIdx = AArch64::sub_32;
1218 int64_t OffsetA = 0, OffsetB = 0;
1219 TypeSize WidthA(0,
false), WidthB(0,
false);
1220 bool OffsetAIsScalable =
false, OffsetBIsScalable =
false;
1241 OffsetAIsScalable == OffsetBIsScalable) {
1242 int LowOffset = OffsetA < OffsetB ? OffsetA : OffsetB;
1243 int HighOffset = OffsetA < OffsetB ? OffsetB : OffsetA;
1244 TypeSize LowWidth = (LowOffset == OffsetA) ? WidthA : WidthB;
1245 if (LowWidth.
isScalable() == OffsetAIsScalable &&
1263 switch (
MI.getOpcode()) {
1266 if (
MI.getOperand(0).getImm() == 0x14)
1273 case AArch64::MSRpstatesvcrImm1:
1280 auto Next = std::next(
MI.getIterator());
1281 return Next !=
MBB->
end() && Next->isCFIInstruction();
1288 Register &SrcReg2, int64_t &CmpMask,
1289 int64_t &CmpValue)
const {
1293 assert(
MI.getNumOperands() >= 2 &&
"All AArch64 cmps should have 2 operands");
1294 if (!
MI.getOperand(1).isReg() ||
MI.getOperand(1).getSubReg())
1297 switch (
MI.getOpcode()) {
1300 case AArch64::PTEST_PP:
1301 case AArch64::PTEST_PP_ANY:
1302 SrcReg =
MI.getOperand(0).getReg();
1303 SrcReg2 =
MI.getOperand(1).getReg();
1304 if (
MI.getOperand(2).getSubReg())
1311 case AArch64::SUBSWrr:
1312 case AArch64::SUBSWrs:
1313 case AArch64::SUBSWrx:
1314 case AArch64::SUBSXrr:
1315 case AArch64::SUBSXrs:
1316 case AArch64::SUBSXrx:
1317 case AArch64::ADDSWrr:
1318 case AArch64::ADDSWrs:
1319 case AArch64::ADDSWrx:
1320 case AArch64::ADDSXrr:
1321 case AArch64::ADDSXrs:
1322 case AArch64::ADDSXrx:
1324 SrcReg =
MI.getOperand(1).getReg();
1325 SrcReg2 =
MI.getOperand(2).getReg();
1328 if (
MI.getOperand(2).getSubReg())
1334 case AArch64::SUBSWri:
1335 case AArch64::ADDSWri:
1336 case AArch64::SUBSXri:
1337 case AArch64::ADDSXri:
1338 SrcReg =
MI.getOperand(1).getReg();
1341 CmpValue =
MI.getOperand(2).getImm();
1343 case AArch64::ANDSWri:
1344 case AArch64::ANDSXri:
1347 SrcReg =
MI.getOperand(1).getReg();
1351 MI.getOperand(2).getImm(),
1352 MI.getOpcode() == AArch64::ANDSWri ? 32 : 64);
1361 assert(
MBB &&
"Can't get MachineBasicBlock here");
1363 assert(MF &&
"Can't get MachineFunction here");
1368 for (
unsigned OpIdx = 0, EndIdx = Instr.getNumOperands();
OpIdx < EndIdx;
1375 if (!OpRegCstraints)
1383 "Operand has register constraints without being a register!");
1386 if (Reg.isPhysical()) {
1387 if (!OpRegCstraints->
contains(Reg))
1390 !
MRI->constrainRegClass(Reg, OpRegCstraints))
1403 bool MIDefinesZeroReg =
false;
1404 if (
MI.definesRegister(AArch64::WZR,
nullptr) ||
1405 MI.definesRegister(AArch64::XZR,
nullptr))
1406 MIDefinesZeroReg =
true;
1408 switch (
MI.getOpcode()) {
1410 return MI.getOpcode();
1411 case AArch64::ADDSWrr:
1412 return AArch64::ADDWrr;
1413 case AArch64::ADDSWri:
1414 return MIDefinesZeroReg ? AArch64::ADDSWri : AArch64::ADDWri;
1415 case AArch64::ADDSWrs:
1416 return MIDefinesZeroReg ? AArch64::ADDSWrs : AArch64::ADDWrs;
1417 case AArch64::ADDSWrx:
1418 return AArch64::ADDWrx;
1419 case AArch64::ADDSXrr:
1420 return AArch64::ADDXrr;
1421 case AArch64::ADDSXri:
1422 return MIDefinesZeroReg ? AArch64::ADDSXri : AArch64::ADDXri;
1423 case AArch64::ADDSXrs:
1424 return MIDefinesZeroReg ? AArch64::ADDSXrs : AArch64::ADDXrs;
1425 case AArch64::ADDSXrx:
1426 return AArch64::ADDXrx;
1427 case AArch64::SUBSWrr:
1428 return AArch64::SUBWrr;
1429 case AArch64::SUBSWri:
1430 return MIDefinesZeroReg ? AArch64::SUBSWri : AArch64::SUBWri;
1431 case AArch64::SUBSWrs:
1432 return MIDefinesZeroReg ? AArch64::SUBSWrs : AArch64::SUBWrs;
1433 case AArch64::SUBSWrx:
1434 return AArch64::SUBWrx;
1435 case AArch64::SUBSXrr:
1436 return AArch64::SUBXrr;
1437 case AArch64::SUBSXri:
1438 return MIDefinesZeroReg ? AArch64::SUBSXri : AArch64::SUBXri;
1439 case AArch64::SUBSXrs:
1440 return MIDefinesZeroReg ? AArch64::SUBSXrs : AArch64::SUBXrs;
1441 case AArch64::SUBSXrx:
1442 return AArch64::SUBXrx;
1457 if (To == To->getParent()->begin())
1462 if (To->getParent() !=
From->getParent())
1474 Instr.modifiesRegister(AArch64::NZCV,
TRI)) ||
1475 ((AccessToCheck &
AK_Read) && Instr.readsRegister(AArch64::NZCV,
TRI)))
1481std::optional<unsigned>
1485 unsigned MaskOpcode =
Mask->getOpcode();
1486 unsigned PredOpcode = Pred->
getOpcode();
1490 if (PredIsWhileLike) {
1494 if ((Mask == Pred) && PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1508 if (PredIsPTestLike) {
1513 if ((Mask == Pred) && PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1521 if (Mask != PTestLikeMask && PTestLikeMask->isFullCopy() &&
1522 PTestLikeMask->getOperand(1).getReg().isVirtual())
1524 MRI->getUniqueVRegDef(PTestLikeMask->getOperand(1).getReg());
1532 if (Mask == PTestLikeMask || PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1560 PTest->
getOpcode() == AArch64::PTEST_PP_ANY))
1568 switch (PredOpcode) {
1569 case AArch64::AND_PPzPP:
1570 case AArch64::BIC_PPzPP:
1571 case AArch64::EOR_PPzPP:
1572 case AArch64::NAND_PPzPP:
1573 case AArch64::NOR_PPzPP:
1574 case AArch64::ORN_PPzPP:
1575 case AArch64::ORR_PPzPP:
1576 case AArch64::BRKA_PPzP:
1577 case AArch64::BRKPA_PPzPP:
1578 case AArch64::BRKB_PPzP:
1579 case AArch64::BRKPB_PPzPP:
1580 case AArch64::RDFFR_PPz: {
1584 if (Mask != PredMask)
1588 case AArch64::BRKN_PPzP: {
1592 if ((MaskOpcode != AArch64::PTRUE_B) ||
1593 (
Mask->getOperand(1).getImm() != 31))
1597 case AArch64::PTRUE_B:
1610bool AArch64InstrInfo::optimizePTestInstr(
1611 MachineInstr *PTest,
unsigned MaskReg,
unsigned PredReg,
1613 auto *
Mask =
MRI->getUniqueVRegDef(MaskReg);
1614 auto *Pred =
MRI->getUniqueVRegDef(PredReg);
1615 unsigned PredOpcode = Pred->
getOpcode();
1616 auto NewOp = canRemovePTestInstr(PTest, Mask, Pred,
MRI);
1632 if (*NewOp != PredOpcode) {
1643 for (; i !=
e; ++i) {
1674 if (DeadNZCVIdx != -1) {
1693 if (CmpInstr.
getOpcode() == AArch64::PTEST_PP ||
1694 CmpInstr.
getOpcode() == AArch64::PTEST_PP_ANY)
1695 return optimizePTestInstr(&CmpInstr, SrcReg, SrcReg2,
MRI);
1704 if (CmpValue == 0 && substituteCmpToZero(CmpInstr, SrcReg, *
MRI))
1706 return (CmpValue == 0 || CmpValue == 1) &&
1707 removeCmpToZeroOrOne(CmpInstr, SrcReg, CmpValue, *
MRI);
1715 switch (Instr.getOpcode()) {
1717 return AArch64::INSTRUCTION_LIST_END;
1719 case AArch64::ADDSWrr:
1720 case AArch64::ADDSWri:
1721 case AArch64::ADDSXrr:
1722 case AArch64::ADDSXri:
1723 case AArch64::SUBSWrr:
1724 case AArch64::SUBSWri:
1725 case AArch64::SUBSXrr:
1726 case AArch64::SUBSXri:
1727 return Instr.getOpcode();
1729 case AArch64::ADDWrr:
1730 return AArch64::ADDSWrr;
1731 case AArch64::ADDWri:
1732 return AArch64::ADDSWri;
1733 case AArch64::ADDXrr:
1734 return AArch64::ADDSXrr;
1735 case AArch64::ADDXri:
1736 return AArch64::ADDSXri;
1737 case AArch64::ADCWr:
1738 return AArch64::ADCSWr;
1739 case AArch64::ADCXr:
1740 return AArch64::ADCSXr;
1741 case AArch64::SUBWrr:
1742 return AArch64::SUBSWrr;
1743 case AArch64::SUBWri:
1744 return AArch64::SUBSWri;
1745 case AArch64::SUBXrr:
1746 return AArch64::SUBSXrr;
1747 case AArch64::SUBXri:
1748 return AArch64::SUBSXri;
1749 case AArch64::SBCWr:
1750 return AArch64::SBCSWr;
1751 case AArch64::SBCXr:
1752 return AArch64::SBCSXr;
1753 case AArch64::ANDWri:
1754 return AArch64::ANDSWri;
1755 case AArch64::ANDXri:
1756 return AArch64::ANDSXri;
1763 if (BB->isLiveIn(AArch64::NZCV))
1772 switch (Instr.getOpcode()) {
1776 case AArch64::Bcc: {
1777 int Idx = Instr.findRegisterUseOperandIdx(AArch64::NZCV,
nullptr);
1782 case AArch64::CSINVWr:
1783 case AArch64::CSINVXr:
1784 case AArch64::CSINCWr:
1785 case AArch64::CSINCXr:
1786 case AArch64::CSELWr:
1787 case AArch64::CSELXr:
1788 case AArch64::CSNEGWr:
1789 case AArch64::CSNEGXr:
1790 case AArch64::FCSELSrrr:
1791 case AArch64::FCSELDrrr: {
1792 int Idx = Instr.findRegisterUseOperandIdx(AArch64::NZCV,
nullptr);
1805 Instr.getOperand(CCIdx).getImm())
1858std::optional<UsedNZCV>
1863 if (
MI.getParent() != CmpParent)
1864 return std::nullopt;
1867 return std::nullopt;
1872 if (Instr.readsRegister(AArch64::NZCV, &
TRI)) {
1875 return std::nullopt;
1880 if (Instr.modifiesRegister(AArch64::NZCV, &
TRI))
1883 return NZCVUsedAfterCmp;
1887 return Opcode == AArch64::ADDSWri || Opcode == AArch64::ADDSXri;
1891 return Opcode == AArch64::SUBSWri || Opcode == AArch64::SUBSXri;
1913 const unsigned CmpOpcode = CmpInstr.
getOpcode();
1919 "Caller guarantees that CmpInstr compares with constant 0");
1922 if (!NZVCUsed || NZVCUsed->C)
1944bool AArch64InstrInfo::substituteCmpToZero(
1955 if (NewOpc == AArch64::INSTRUCTION_LIST_END)
1962 MI->setDesc(
get(NewOpc));
1967 MI->addRegisterDefined(AArch64::NZCV, &
TRI);
1979 assert((CmpValue == 0 || CmpValue == 1) &&
1980 "Only comparisons to 0 or 1 considered for removal!");
1983 unsigned MIOpc =
MI.getOpcode();
1984 if (MIOpc == AArch64::CSINCWr) {
1985 if (
MI.getOperand(1).getReg() != AArch64::WZR ||
1986 MI.getOperand(2).getReg() != AArch64::WZR)
1988 }
else if (MIOpc == AArch64::CSINCXr) {
1989 if (
MI.getOperand(1).getReg() != AArch64::XZR ||
1990 MI.getOperand(2).getReg() != AArch64::XZR)
2000 if (
MI.findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
true) != -1)
2004 const unsigned CmpOpcode = CmpInstr.
getOpcode();
2006 if (CmpValue && !IsSubsRegImm)
2008 if (!CmpValue && !IsSubsRegImm && !
isADDSRegImm(CmpOpcode))
2013 if (MIUsedNZCV.
C || MIUsedNZCV.
V)
2016 std::optional<UsedNZCV> NZCVUsedAfterCmp =
2020 if (!NZCVUsedAfterCmp || NZCVUsedAfterCmp->C || NZCVUsedAfterCmp->V)
2023 if ((MIUsedNZCV.
Z && NZCVUsedAfterCmp->N) ||
2024 (MIUsedNZCV.
N && NZCVUsedAfterCmp->Z))
2027 if (MIUsedNZCV.
N && !CmpValue)
2069bool AArch64InstrInfo::removeCmpToZeroOrOne(
2077 bool IsInvertCC =
false;
2087 assert(
Idx >= 0 &&
"Unexpected instruction using CC.");
2098 if (
MI.getOpcode() != TargetOpcode::LOAD_STACK_GUARD &&
2099 MI.getOpcode() != AArch64::CATCHRET)
2107 if (
MI.getOpcode() == AArch64::CATCHRET) {
2116 FirstEpilogSEH = std::prev(FirstEpilogSEH);
2118 FirstEpilogSEH = std::next(FirstEpilogSEH);
2133 if (M.getStackProtectorGuard() ==
"sysreg") {
2135 AArch64SysReg::lookupSysRegByName(M.getStackProtectorGuardReg());
2143 int Offset = M.getStackProtectorGuardOffset();
2195 cast<GlobalValue>((*
MI.memoperands_begin())->getValue());
2204 unsigned Reg32 =
TRI->getSubReg(Reg, AArch64::sub_32);
2246 unsigned Reg32 =
TRI->getSubReg(Reg, AArch64::sub_32);
2269 switch (
MI.getOpcode()) {
2272 case AArch64::MOVZWi:
2273 case AArch64::MOVZXi:
2274 if (
MI.getOperand(1).isImm() &&
MI.getOperand(1).getImm() == 0) {
2275 assert(
MI.getDesc().getNumOperands() == 3 &&
2276 MI.getOperand(2).getImm() == 0 &&
"invalid MOVZi operands");
2280 case AArch64::ANDWri:
2281 return MI.getOperand(1).getReg() == AArch64::WZR;
2282 case AArch64::ANDXri:
2283 return MI.getOperand(1).getReg() == AArch64::XZR;
2284 case TargetOpcode::COPY:
2285 return MI.getOperand(1).getReg() == AArch64::WZR;
2293 switch (
MI.getOpcode()) {
2296 case TargetOpcode::COPY: {
2299 return (AArch64::GPR32RegClass.
contains(DstReg) ||
2300 AArch64::GPR64RegClass.
contains(DstReg));
2302 case AArch64::ORRXrs:
2303 if (
MI.getOperand(1).getReg() == AArch64::XZR) {
2304 assert(
MI.getDesc().getNumOperands() == 4 &&
2305 MI.getOperand(3).getImm() == 0 &&
"invalid ORRrs operands");
2309 case AArch64::ADDXri:
2310 if (
MI.getOperand(2).getImm() == 0) {
2311 assert(
MI.getDesc().getNumOperands() == 4 &&
2312 MI.getOperand(3).getImm() == 0 &&
"invalid ADDXri operands");
2323 switch (
MI.getOpcode()) {
2326 case TargetOpcode::COPY: {
2328 return AArch64::FPR128RegClass.contains(DstReg);
2330 case AArch64::ORRv16i8:
2331 if (
MI.getOperand(1).getReg() ==
MI.getOperand(2).getReg()) {
2332 assert(
MI.getDesc().getNumOperands() == 3 &&
MI.getOperand(0).isReg() &&
2333 "invalid ORRv16i8 operands");
2342 int &FrameIndex)
const {
2343 switch (
MI.getOpcode()) {
2346 case AArch64::LDRWui:
2347 case AArch64::LDRXui:
2348 case AArch64::LDRBui:
2349 case AArch64::LDRHui:
2350 case AArch64::LDRSui:
2351 case AArch64::LDRDui:
2352 case AArch64::LDRQui:
2353 case AArch64::LDR_PXI:
2354 if (
MI.getOperand(0).getSubReg() == 0 &&
MI.getOperand(1).isFI() &&
2355 MI.getOperand(2).isImm() &&
MI.getOperand(2).getImm() == 0) {
2356 FrameIndex =
MI.getOperand(1).getIndex();
2357 return MI.getOperand(0).getReg();
2366 int &FrameIndex)
const {
2367 switch (
MI.getOpcode()) {
2370 case AArch64::STRWui:
2371 case AArch64::STRXui:
2372 case AArch64::STRBui:
2373 case AArch64::STRHui:
2374 case AArch64::STRSui:
2375 case AArch64::STRDui:
2376 case AArch64::STRQui:
2377 case AArch64::STR_PXI:
2378 if (
MI.getOperand(0).getSubReg() == 0 &&
MI.getOperand(1).isFI() &&
2379 MI.getOperand(2).isImm() &&
MI.getOperand(2).getImm() == 0) {
2380 FrameIndex =
MI.getOperand(1).getIndex();
2381 return MI.getOperand(0).getReg();
2391 return MMO->getFlags() & MOSuppressPair;
2397 if (
MI.memoperands_empty())
2405 return MMO->getFlags() & MOStridedAccess;
2413 case AArch64::STURSi:
2414 case AArch64::STRSpre:
2415 case AArch64::STURDi:
2416 case AArch64::STRDpre:
2417 case AArch64::STURQi:
2418 case AArch64::STRQpre:
2419 case AArch64::STURBBi:
2420 case AArch64::STURHHi:
2421 case AArch64::STURWi:
2422 case AArch64::STRWpre:
2423 case AArch64::STURXi:
2424 case AArch64::STRXpre:
2425 case AArch64::LDURSi:
2426 case AArch64::LDRSpre:
2427 case AArch64::LDURDi:
2428 case AArch64::LDRDpre:
2429 case AArch64::LDURQi:
2430 case AArch64::LDRQpre:
2431 case AArch64::LDURWi:
2432 case AArch64::LDRWpre:
2433 case AArch64::LDURXi:
2434 case AArch64::LDRXpre:
2435 case AArch64::LDRSWpre:
2436 case AArch64::LDURSWi:
2437 case AArch64::LDURHHi:
2438 case AArch64::LDURBBi:
2439 case AArch64::LDURSBWi:
2440 case AArch64::LDURSHWi:
2448 case AArch64::PRFMui:
return AArch64::PRFUMi;
2449 case AArch64::LDRXui:
return AArch64::LDURXi;
2450 case AArch64::LDRWui:
return AArch64::LDURWi;
2451 case AArch64::LDRBui:
return AArch64::LDURBi;
2452 case AArch64::LDRHui:
return AArch64::LDURHi;
2453 case AArch64::LDRSui:
return AArch64::LDURSi;
2454 case AArch64::LDRDui:
return AArch64::LDURDi;
2455 case AArch64::LDRQui:
return AArch64::LDURQi;
2456 case AArch64::LDRBBui:
return AArch64::LDURBBi;
2457 case AArch64::LDRHHui:
return AArch64::LDURHHi;
2458 case AArch64::LDRSBXui:
return AArch64::LDURSBXi;
2459 case AArch64::LDRSBWui:
return AArch64::LDURSBWi;
2460 case AArch64::LDRSHXui:
return AArch64::LDURSHXi;
2461 case AArch64::LDRSHWui:
return AArch64::LDURSHWi;
2462 case AArch64::LDRSWui:
return AArch64::LDURSWi;
2463 case AArch64::STRXui:
return AArch64::STURXi;
2464 case AArch64::STRWui:
return AArch64::STURWi;
2465 case AArch64::STRBui:
return AArch64::STURBi;
2466 case AArch64::STRHui:
return AArch64::STURHi;
2467 case AArch64::STRSui:
return AArch64::STURSi;
2468 case AArch64::STRDui:
return AArch64::STURDi;
2469 case AArch64::STRQui:
return AArch64::STURQi;
2470 case AArch64::STRBBui:
return AArch64::STURBBi;
2471 case AArch64::STRHHui:
return AArch64::STURHHi;
2480 case AArch64::LDAPURBi:
2481 case AArch64::LDAPURHi:
2482 case AArch64::LDAPURi:
2483 case AArch64::LDAPURSBWi:
2484 case AArch64::LDAPURSBXi:
2485 case AArch64::LDAPURSHWi:
2486 case AArch64::LDAPURSHXi:
2487 case AArch64::LDAPURSWi:
2488 case AArch64::LDAPURXi:
2489 case AArch64::LDR_PPXI:
2490 case AArch64::LDR_PXI:
2491 case AArch64::LDR_ZXI:
2492 case AArch64::LDR_ZZXI:
2493 case AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS:
2494 case AArch64::LDR_ZZZXI:
2495 case AArch64::LDR_ZZZZXI:
2496 case AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS:
2497 case AArch64::LDRBBui:
2498 case AArch64::LDRBui:
2499 case AArch64::LDRDui:
2500 case AArch64::LDRHHui:
2501 case AArch64::LDRHui:
2502 case AArch64::LDRQui:
2503 case AArch64::LDRSBWui:
2504 case AArch64::LDRSBXui:
2505 case AArch64::LDRSHWui:
2506 case AArch64::LDRSHXui:
2507 case AArch64::LDRSui:
2508 case AArch64::LDRSWui:
2509 case AArch64::LDRWui:
2510 case AArch64::LDRXui:
2511 case AArch64::LDURBBi:
2512 case AArch64::LDURBi:
2513 case AArch64::LDURDi:
2514 case AArch64::LDURHHi:
2515 case AArch64::LDURHi:
2516 case AArch64::LDURQi:
2517 case AArch64::LDURSBWi:
2518 case AArch64::LDURSBXi:
2519 case AArch64::LDURSHWi:
2520 case AArch64::LDURSHXi:
2521 case AArch64::LDURSi:
2522 case AArch64::LDURSWi:
2523 case AArch64::LDURWi:
2524 case AArch64::LDURXi:
2525 case AArch64::PRFMui:
2526 case AArch64::PRFUMi:
2527 case AArch64::ST2Gi:
2529 case AArch64::STLURBi:
2530 case AArch64::STLURHi:
2531 case AArch64::STLURWi:
2532 case AArch64::STLURXi:
2533 case AArch64::StoreSwiftAsyncContext:
2534 case AArch64::STR_PPXI:
2535 case AArch64::STR_PXI:
2536 case AArch64::STR_ZXI:
2537 case AArch64::STR_ZZXI:
2538 case AArch64::STR_ZZXI_STRIDED_CONTIGUOUS:
2539 case AArch64::STR_ZZZXI:
2540 case AArch64::STR_ZZZZXI:
2541 case AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS:
2542 case AArch64::STRBBui:
2543 case AArch64::STRBui:
2544 case AArch64::STRDui:
2545 case AArch64::STRHHui:
2546 case AArch64::STRHui:
2547 case AArch64::STRQui:
2548 case AArch64::STRSui:
2549 case AArch64::STRWui:
2550 case AArch64::STRXui:
2551 case AArch64::STURBBi:
2552 case AArch64::STURBi:
2553 case AArch64::STURDi:
2554 case AArch64::STURHHi:
2555 case AArch64::STURHi:
2556 case AArch64::STURQi:
2557 case AArch64::STURSi:
2558 case AArch64::STURWi:
2559 case AArch64::STURXi:
2560 case AArch64::STZ2Gi:
2561 case AArch64::STZGi:
2562 case AArch64::TAGPstack:
2563 case AArch64::SPILL_PPR_TO_ZPR_SLOT_PSEUDO:
2564 case AArch64::FILL_PPR_FROM_ZPR_SLOT_PSEUDO:
2566 case AArch64::LD1B_D_IMM:
2567 case AArch64::LD1B_H_IMM:
2568 case AArch64::LD1B_IMM:
2569 case AArch64::LD1B_S_IMM:
2570 case AArch64::LD1D_IMM:
2571 case AArch64::LD1H_D_IMM:
2572 case AArch64::LD1H_IMM:
2573 case AArch64::LD1H_S_IMM:
2574 case AArch64::LD1RB_D_IMM:
2575 case AArch64::LD1RB_H_IMM:
2576 case AArch64::LD1RB_IMM:
2577 case AArch64::LD1RB_S_IMM:
2578 case AArch64::LD1RD_IMM:
2579 case AArch64::LD1RH_D_IMM:
2580 case AArch64::LD1RH_IMM:
2581 case AArch64::LD1RH_S_IMM:
2582 case AArch64::LD1RSB_D_IMM:
2583 case AArch64::LD1RSB_H_IMM:
2584 case AArch64::LD1RSB_S_IMM:
2585 case AArch64::LD1RSH_D_IMM:
2586 case AArch64::LD1RSH_S_IMM:
2587 case AArch64::LD1RSW_IMM:
2588 case AArch64::LD1RW_D_IMM:
2589 case AArch64::LD1RW_IMM:
2590 case AArch64::LD1SB_D_IMM:
2591 case AArch64::LD1SB_H_IMM:
2592 case AArch64::LD1SB_S_IMM:
2593 case AArch64::LD1SH_D_IMM:
2594 case AArch64::LD1SH_S_IMM:
2595 case AArch64::LD1SW_D_IMM:
2596 case AArch64::LD1W_D_IMM:
2597 case AArch64::LD1W_IMM:
2598 case AArch64::LD2B_IMM:
2599 case AArch64::LD2D_IMM:
2600 case AArch64::LD2H_IMM:
2601 case AArch64::LD2W_IMM:
2602 case AArch64::LD3B_IMM:
2603 case AArch64::LD3D_IMM:
2604 case AArch64::LD3H_IMM:
2605 case AArch64::LD3W_IMM:
2606 case AArch64::LD4B_IMM:
2607 case AArch64::LD4D_IMM:
2608 case AArch64::LD4H_IMM:
2609 case AArch64::LD4W_IMM:
2611 case AArch64::LDNF1B_D_IMM:
2612 case AArch64::LDNF1B_H_IMM:
2613 case AArch64::LDNF1B_IMM:
2614 case AArch64::LDNF1B_S_IMM:
2615 case AArch64::LDNF1D_IMM:
2616 case AArch64::LDNF1H_D_IMM:
2617 case AArch64::LDNF1H_IMM:
2618 case AArch64::LDNF1H_S_IMM:
2619 case AArch64::LDNF1SB_D_IMM:
2620 case AArch64::LDNF1SB_H_IMM:
2621 case AArch64::LDNF1SB_S_IMM:
2622 case AArch64::LDNF1SH_D_IMM:
2623 case AArch64::LDNF1SH_S_IMM:
2624 case AArch64::LDNF1SW_D_IMM:
2625 case AArch64::LDNF1W_D_IMM:
2626 case AArch64::LDNF1W_IMM:
2627 case AArch64::LDNPDi:
2628 case AArch64::LDNPQi:
2629 case AArch64::LDNPSi:
2630 case AArch64::LDNPWi:
2631 case AArch64::LDNPXi:
2632 case AArch64::LDNT1B_ZRI:
2633 case AArch64::LDNT1D_ZRI:
2634 case AArch64::LDNT1H_ZRI:
2635 case AArch64::LDNT1W_ZRI:
2636 case AArch64::LDPDi:
2637 case AArch64::LDPQi:
2638 case AArch64::LDPSi:
2639 case AArch64::LDPWi:
2640 case AArch64::LDPXi:
2641 case AArch64::LDRBBpost:
2642 case AArch64::LDRBBpre:
2643 case AArch64::LDRBpost:
2644 case AArch64::LDRBpre:
2645 case AArch64::LDRDpost:
2646 case AArch64::LDRDpre:
2647 case AArch64::LDRHHpost:
2648 case AArch64::LDRHHpre:
2649 case AArch64::LDRHpost:
2650 case AArch64::LDRHpre:
2651 case AArch64::LDRQpost:
2652 case AArch64::LDRQpre:
2653 case AArch64::LDRSpost:
2654 case AArch64::LDRSpre:
2655 case AArch64::LDRWpost:
2656 case AArch64::LDRWpre:
2657 case AArch64::LDRXpost:
2658 case AArch64::LDRXpre:
2659 case AArch64::ST1B_D_IMM:
2660 case AArch64::ST1B_H_IMM:
2661 case AArch64::ST1B_IMM:
2662 case AArch64::ST1B_S_IMM:
2663 case AArch64::ST1D_IMM:
2664 case AArch64::ST1H_D_IMM:
2665 case AArch64::ST1H_IMM:
2666 case AArch64::ST1H_S_IMM:
2667 case AArch64::ST1W_D_IMM:
2668 case AArch64::ST1W_IMM:
2669 case AArch64::ST2B_IMM:
2670 case AArch64::ST2D_IMM:
2671 case AArch64::ST2H_IMM:
2672 case AArch64::ST2W_IMM:
2673 case AArch64::ST3B_IMM:
2674 case AArch64::ST3D_IMM:
2675 case AArch64::ST3H_IMM:
2676 case AArch64::ST3W_IMM:
2677 case AArch64::ST4B_IMM:
2678 case AArch64::ST4D_IMM:
2679 case AArch64::ST4H_IMM:
2680 case AArch64::ST4W_IMM:
2681 case AArch64::STGPi:
2682 case AArch64::STGPreIndex:
2683 case AArch64::STZGPreIndex:
2684 case AArch64::ST2GPreIndex:
2685 case AArch64::STZ2GPreIndex:
2686 case AArch64::STGPostIndex:
2687 case AArch64::STZGPostIndex:
2688 case AArch64::ST2GPostIndex:
2689 case AArch64::STZ2GPostIndex:
2690 case AArch64::STNPDi:
2691 case AArch64::STNPQi:
2692 case AArch64::STNPSi:
2693 case AArch64::STNPWi:
2694 case AArch64::STNPXi:
2695 case AArch64::STNT1B_ZRI:
2696 case AArch64::STNT1D_ZRI:
2697 case AArch64::STNT1H_ZRI:
2698 case AArch64::STNT1W_ZRI:
2699 case AArch64::STPDi:
2700 case AArch64::STPQi:
2701 case AArch64::STPSi:
2702 case AArch64::STPWi:
2703 case AArch64::STPXi:
2704 case AArch64::STRBBpost:
2705 case AArch64::STRBBpre:
2706 case AArch64::STRBpost:
2707 case AArch64::STRBpre:
2708 case AArch64::STRDpost:
2709 case AArch64::STRDpre:
2710 case AArch64::STRHHpost:
2711 case AArch64::STRHHpre:
2712 case AArch64::STRHpost:
2713 case AArch64::STRHpre:
2714 case AArch64::STRQpost:
2715 case AArch64::STRQpre:
2716 case AArch64::STRSpost:
2717 case AArch64::STRSpre:
2718 case AArch64::STRWpost:
2719 case AArch64::STRWpre:
2720 case AArch64::STRXpost:
2721 case AArch64::STRXpre:
2723 case AArch64::LDPDpost:
2724 case AArch64::LDPDpre:
2725 case AArch64::LDPQpost:
2726 case AArch64::LDPQpre:
2727 case AArch64::LDPSpost:
2728 case AArch64::LDPSpre:
2729 case AArch64::LDPWpost:
2730 case AArch64::LDPWpre:
2731 case AArch64::LDPXpost:
2732 case AArch64::LDPXpre:
2733 case AArch64::STGPpre:
2734 case AArch64::STGPpost:
2735 case AArch64::STPDpost:
2736 case AArch64::STPDpre:
2737 case AArch64::STPQpost:
2738 case AArch64::STPQpre:
2739 case AArch64::STPSpost:
2740 case AArch64::STPSpre:
2741 case AArch64::STPWpost:
2742 case AArch64::STPWpre:
2743 case AArch64::STPXpost:
2744 case AArch64::STPXpre:
2750 switch (
MI.getOpcode()) {
2754 case AArch64::STRSui:
2755 case AArch64::STRDui:
2756 case AArch64::STRQui:
2757 case AArch64::STRXui:
2758 case AArch64::STRWui:
2759 case AArch64::LDRSui:
2760 case AArch64::LDRDui:
2761 case AArch64::LDRQui:
2762 case AArch64::LDRXui:
2763 case AArch64::LDRWui:
2764 case AArch64::LDRSWui:
2766 case AArch64::STURSi:
2767 case AArch64::STRSpre:
2768 case AArch64::STURDi:
2769 case AArch64::STRDpre:
2770 case AArch64::STURQi:
2771 case AArch64::STRQpre:
2772 case AArch64::STURWi:
2773 case AArch64::STRWpre:
2774 case AArch64::STURXi:
2775 case AArch64::STRXpre:
2776 case AArch64::LDURSi:
2777 case AArch64::LDRSpre:
2778 case AArch64::LDURDi:
2779 case AArch64::LDRDpre:
2780 case AArch64::LDURQi:
2781 case AArch64::LDRQpre:
2782 case AArch64::LDURWi:
2783 case AArch64::LDRWpre:
2784 case AArch64::LDURXi:
2785 case AArch64::LDRXpre:
2786 case AArch64::LDURSWi:
2787 case AArch64::LDRSWpre:
2789 case AArch64::LDR_ZXI:
2790 case AArch64::STR_ZXI:
2796 switch (
MI.getOpcode()) {
2799 "Unexpected instruction - was a new tail call opcode introduced?");
2801 case AArch64::TCRETURNdi:
2802 case AArch64::TCRETURNri:
2803 case AArch64::TCRETURNrix16x17:
2804 case AArch64::TCRETURNrix17:
2805 case AArch64::TCRETURNrinotx16:
2806 case AArch64::TCRETURNriALL:
2807 case AArch64::AUTH_TCRETURN:
2808 case AArch64::AUTH_TCRETURN_BTI:
2818 case AArch64::ADDWri:
2819 return AArch64::ADDSWri;
2820 case AArch64::ADDWrr:
2821 return AArch64::ADDSWrr;
2822 case AArch64::ADDWrs:
2823 return AArch64::ADDSWrs;
2824 case AArch64::ADDWrx:
2825 return AArch64::ADDSWrx;
2826 case AArch64::ANDWri:
2827 return AArch64::ANDSWri;
2828 case AArch64::ANDWrr:
2829 return AArch64::ANDSWrr;
2830 case AArch64::ANDWrs:
2831 return AArch64::ANDSWrs;
2832 case AArch64::BICWrr:
2833 return AArch64::BICSWrr;
2834 case AArch64::BICWrs:
2835 return AArch64::BICSWrs;
2836 case AArch64::SUBWri:
2837 return AArch64::SUBSWri;
2838 case AArch64::SUBWrr:
2839 return AArch64::SUBSWrr;
2840 case AArch64::SUBWrs:
2841 return AArch64::SUBSWrs;
2842 case AArch64::SUBWrx:
2843 return AArch64::SUBSWrx;
2845 case AArch64::ADDXri:
2846 return AArch64::ADDSXri;
2847 case AArch64::ADDXrr:
2848 return AArch64::ADDSXrr;
2849 case AArch64::ADDXrs:
2850 return AArch64::ADDSXrs;
2851 case AArch64::ADDXrx:
2852 return AArch64::ADDSXrx;
2853 case AArch64::ANDXri:
2854 return AArch64::ANDSXri;
2855 case AArch64::ANDXrr:
2856 return AArch64::ANDSXrr;
2857 case AArch64::ANDXrs:
2858 return AArch64::ANDSXrs;
2859 case AArch64::BICXrr:
2860 return AArch64::BICSXrr;
2861 case AArch64::BICXrs:
2862 return AArch64::BICSXrs;
2863 case AArch64::SUBXri:
2864 return AArch64::SUBSXri;
2865 case AArch64::SUBXrr:
2866 return AArch64::SUBSXrr;
2867 case AArch64::SUBXrs:
2868 return AArch64::SUBSXrs;
2869 case AArch64::SUBXrx:
2870 return AArch64::SUBSXrx;
2872 case AArch64::AND_PPzPP:
2873 return AArch64::ANDS_PPzPP;
2874 case AArch64::BIC_PPzPP:
2875 return AArch64::BICS_PPzPP;
2876 case AArch64::EOR_PPzPP:
2877 return AArch64::EORS_PPzPP;
2878 case AArch64::NAND_PPzPP:
2879 return AArch64::NANDS_PPzPP;
2880 case AArch64::NOR_PPzPP:
2881 return AArch64::NORS_PPzPP;
2882 case AArch64::ORN_PPzPP:
2883 return AArch64::ORNS_PPzPP;
2884 case AArch64::ORR_PPzPP:
2885 return AArch64::ORRS_PPzPP;
2886 case AArch64::BRKA_PPzP:
2887 return AArch64::BRKAS_PPzP;
2888 case AArch64::BRKPA_PPzPP:
2889 return AArch64::BRKPAS_PPzPP;
2890 case AArch64::BRKB_PPzP:
2891 return AArch64::BRKBS_PPzP;
2892 case AArch64::BRKPB_PPzPP:
2893 return AArch64::BRKPBS_PPzPP;
2894 case AArch64::BRKN_PPzP:
2895 return AArch64::BRKNS_PPzP;
2896 case AArch64::RDFFR_PPz:
2897 return AArch64::RDFFRS_PPz;
2898 case AArch64::PTRUE_B:
2899 return AArch64::PTRUES_B;
2910 if (
MI.hasOrderedMemoryRef())
2915 assert((
MI.getOperand(IsPreLdSt ? 2 : 1).isReg() ||
2916 MI.getOperand(IsPreLdSt ? 2 : 1).isFI()) &&
2917 "Expected a reg or frame index operand.");
2921 bool IsImmPreLdSt = IsPreLdSt &&
MI.getOperand(3).isImm();
2923 if (!
MI.getOperand(2).isImm() && !IsImmPreLdSt)
2936 if (
MI.getOperand(1).isReg() && !IsPreLdSt) {
2937 Register BaseReg =
MI.getOperand(1).getReg();
2939 if (
MI.modifiesRegister(BaseReg,
TRI))
2945 switch (
MI.getOpcode()) {
2948 case AArch64::LDR_ZXI:
2949 case AArch64::STR_ZXI:
2964 const MCAsmInfo *MAI =
MI.getMF()->getTarget().getMCAsmInfo();
2966 MI.getMF()->getFunction().needsUnwindTableEntry();
2972 if (Subtarget.isPaired128Slow()) {
2973 switch (
MI.getOpcode()) {
2976 case AArch64::LDURQi:
2977 case AArch64::STURQi:
2978 case AArch64::LDRQui:
2979 case AArch64::STRQui:
3006std::optional<ExtAddrMode>
3011 bool OffsetIsScalable;
3012 if (!getMemOperandWithOffset(MemI,
Base,
Offset, OffsetIsScalable,
TRI))
3013 return std::nullopt;
3016 return std::nullopt;
3031 int64_t OffsetScale = 1;
3036 case AArch64::LDURQi:
3037 case AArch64::STURQi:
3041 case AArch64::LDURDi:
3042 case AArch64::STURDi:
3043 case AArch64::LDURXi:
3044 case AArch64::STURXi:
3048 case AArch64::LDURWi:
3049 case AArch64::LDURSWi:
3050 case AArch64::STURWi:
3054 case AArch64::LDURHi:
3055 case AArch64::STURHi:
3056 case AArch64::LDURHHi:
3057 case AArch64::STURHHi:
3058 case AArch64::LDURSHXi:
3059 case AArch64::LDURSHWi:
3063 case AArch64::LDRBroX:
3064 case AArch64::LDRBBroX:
3065 case AArch64::LDRSBXroX:
3066 case AArch64::LDRSBWroX:
3067 case AArch64::STRBroX:
3068 case AArch64::STRBBroX:
3069 case AArch64::LDURBi:
3070 case AArch64::LDURBBi:
3071 case AArch64::LDURSBXi:
3072 case AArch64::LDURSBWi:
3073 case AArch64::STURBi:
3074 case AArch64::STURBBi:
3075 case AArch64::LDRBui:
3076 case AArch64::LDRBBui:
3077 case AArch64::LDRSBXui:
3078 case AArch64::LDRSBWui:
3079 case AArch64::STRBui:
3080 case AArch64::STRBBui:
3084 case AArch64::LDRQroX:
3085 case AArch64::STRQroX:
3086 case AArch64::LDRQui:
3087 case AArch64::STRQui:
3092 case AArch64::LDRDroX:
3093 case AArch64::STRDroX:
3094 case AArch64::LDRXroX:
3095 case AArch64::STRXroX:
3096 case AArch64::LDRDui:
3097 case AArch64::STRDui:
3098 case AArch64::LDRXui:
3099 case AArch64::STRXui:
3104 case AArch64::LDRWroX:
3105 case AArch64::LDRSWroX:
3106 case AArch64::STRWroX:
3107 case AArch64::LDRWui:
3108 case AArch64::LDRSWui:
3109 case AArch64::STRWui:
3114 case AArch64::LDRHroX:
3115 case AArch64::STRHroX:
3116 case AArch64::LDRHHroX:
3117 case AArch64::STRHHroX:
3118 case AArch64::LDRSHXroX:
3119 case AArch64::LDRSHWroX:
3120 case AArch64::LDRHui:
3121 case AArch64::STRHui:
3122 case AArch64::LDRHHui:
3123 case AArch64::STRHHui:
3124 case AArch64::LDRSHXui:
3125 case AArch64::LDRSHWui:
3133 if (BaseRegOp.
isReg() && BaseRegOp.
getReg() == Reg)
3157 case AArch64::SBFMXri:
3170 AM.
Scale = OffsetScale;
3175 case TargetOpcode::SUBREG_TO_REG: {
3188 if (!OffsetReg.
isVirtual() || !
MRI.hasOneNonDBGUse(OffsetReg))
3192 if (
DefMI.getOpcode() != AArch64::ORRWrs ||
3194 DefMI.getOperand(3).getImm() != 0)
3201 AM.
Scale = OffsetScale;
3212 auto validateOffsetForLDP = [](
unsigned NumBytes, int64_t OldOffset,
3213 int64_t NewOffset) ->
bool {
3214 int64_t MinOffset, MaxOffset;
3231 return OldOffset < MinOffset || OldOffset > MaxOffset ||
3232 (NewOffset >= MinOffset && NewOffset <= MaxOffset);
3234 auto canFoldAddSubImmIntoAddrMode = [&](int64_t Disp) ->
bool {
3236 int64_t NewOffset = OldOffset + Disp;
3241 if (!validateOffsetForLDP(NumBytes, OldOffset, NewOffset))
3251 auto canFoldAddRegIntoAddrMode =
3256 if ((
unsigned)Scale != Scale)
3270 return (Opcode == AArch64::STURQi || Opcode == AArch64::STRQui) &&
3271 Subtarget.isSTRQroSlow();
3280 case AArch64::ADDXri:
3286 return canFoldAddSubImmIntoAddrMode(Disp);
3288 case AArch64::SUBXri:
3294 return canFoldAddSubImmIntoAddrMode(-Disp);
3296 case AArch64::ADDXrs: {
3309 if (Shift != 2 && Shift != 3 && Subtarget.hasAddrLSLSlow14())
3311 if (avoidSlowSTRQ(MemI))
3314 return canFoldAddRegIntoAddrMode(1ULL << Shift);
3317 case AArch64::ADDXrr:
3325 if (!OptSize && avoidSlowSTRQ(MemI))
3327 return canFoldAddRegIntoAddrMode(1);
3329 case AArch64::ADDXrx:
3337 if (!OptSize && avoidSlowSTRQ(MemI))
3346 return canFoldAddRegIntoAddrMode(
3361 case AArch64::LDURQi:
3362 case AArch64::LDRQui:
3363 return AArch64::LDRQroX;
3364 case AArch64::STURQi:
3365 case AArch64::STRQui:
3366 return AArch64::STRQroX;
3367 case AArch64::LDURDi:
3368 case AArch64::LDRDui:
3369 return AArch64::LDRDroX;
3370 case AArch64::STURDi:
3371 case AArch64::STRDui:
3372 return AArch64::STRDroX;
3373 case AArch64::LDURXi:
3374 case AArch64::LDRXui:
3375 return AArch64::LDRXroX;
3376 case AArch64::STURXi:
3377 case AArch64::STRXui:
3378 return AArch64::STRXroX;
3379 case AArch64::LDURWi:
3380 case AArch64::LDRWui:
3381 return AArch64::LDRWroX;
3382 case AArch64::LDURSWi:
3383 case AArch64::LDRSWui:
3384 return AArch64::LDRSWroX;
3385 case AArch64::STURWi:
3386 case AArch64::STRWui:
3387 return AArch64::STRWroX;
3388 case AArch64::LDURHi:
3389 case AArch64::LDRHui:
3390 return AArch64::LDRHroX;
3391 case AArch64::STURHi:
3392 case AArch64::STRHui:
3393 return AArch64::STRHroX;
3394 case AArch64::LDURHHi:
3395 case AArch64::LDRHHui:
3396 return AArch64::LDRHHroX;
3397 case AArch64::STURHHi:
3398 case AArch64::STRHHui:
3399 return AArch64::STRHHroX;
3400 case AArch64::LDURSHXi:
3401 case AArch64::LDRSHXui:
3402 return AArch64::LDRSHXroX;
3403 case AArch64::LDURSHWi:
3404 case AArch64::LDRSHWui:
3405 return AArch64::LDRSHWroX;
3406 case AArch64::LDURBi:
3407 case AArch64::LDRBui:
3408 return AArch64::LDRBroX;
3409 case AArch64::LDURBBi:
3410 case AArch64::LDRBBui:
3411 return AArch64::LDRBBroX;
3412 case AArch64::LDURSBXi:
3413 case AArch64::LDRSBXui:
3414 return AArch64::LDRSBXroX;
3415 case AArch64::LDURSBWi:
3416 case AArch64::LDRSBWui:
3417 return AArch64::LDRSBWroX;
3418 case AArch64::STURBi:
3419 case AArch64::STRBui:
3420 return AArch64::STRBroX;
3421 case AArch64::STURBBi:
3422 case AArch64::STRBBui:
3423 return AArch64::STRBBroX;
3435 case AArch64::LDURQi:
3437 return AArch64::LDRQui;
3438 case AArch64::STURQi:
3440 return AArch64::STRQui;
3441 case AArch64::LDURDi:
3443 return AArch64::LDRDui;
3444 case AArch64::STURDi:
3446 return AArch64::STRDui;
3447 case AArch64::LDURXi:
3449 return AArch64::LDRXui;
3450 case AArch64::STURXi:
3452 return AArch64::STRXui;
3453 case AArch64::LDURWi:
3455 return AArch64::LDRWui;
3456 case AArch64::LDURSWi:
3458 return AArch64::LDRSWui;
3459 case AArch64::STURWi:
3461 return AArch64::STRWui;
3462 case AArch64::LDURHi:
3464 return AArch64::LDRHui;
3465 case AArch64::STURHi:
3467 return AArch64::STRHui;
3468 case AArch64::LDURHHi:
3470 return AArch64::LDRHHui;
3471 case AArch64::STURHHi:
3473 return AArch64::STRHHui;
3474 case AArch64::LDURSHXi:
3476 return AArch64::LDRSHXui;
3477 case AArch64::LDURSHWi:
3479 return AArch64::LDRSHWui;
3480 case AArch64::LDURBi:
3482 return AArch64::LDRBui;
3483 case AArch64::LDURBBi:
3485 return AArch64::LDRBBui;
3486 case AArch64::LDURSBXi:
3488 return AArch64::LDRSBXui;
3489 case AArch64::LDURSBWi:
3491 return AArch64::LDRSBWui;
3492 case AArch64::STURBi:
3494 return AArch64::STRBui;
3495 case AArch64::STURBBi:
3497 return AArch64::STRBBui;
3498 case AArch64::LDRQui:
3499 case AArch64::STRQui:
3502 case AArch64::LDRDui:
3503 case AArch64::STRDui:
3504 case AArch64::LDRXui:
3505 case AArch64::STRXui:
3508 case AArch64::LDRWui:
3509 case AArch64::LDRSWui:
3510 case AArch64::STRWui:
3513 case AArch64::LDRHui:
3514 case AArch64::STRHui:
3515 case AArch64::LDRHHui:
3516 case AArch64::STRHHui:
3517 case AArch64::LDRSHXui:
3518 case AArch64::LDRSHWui:
3521 case AArch64::LDRBui:
3522 case AArch64::LDRBBui:
3523 case AArch64::LDRSBXui:
3524 case AArch64::LDRSBWui:
3525 case AArch64::STRBui:
3526 case AArch64::STRBBui:
3540 case AArch64::LDURQi:
3541 case AArch64::STURQi:
3542 case AArch64::LDURDi:
3543 case AArch64::STURDi:
3544 case AArch64::LDURXi:
3545 case AArch64::STURXi:
3546 case AArch64::LDURWi:
3547 case AArch64::LDURSWi:
3548 case AArch64::STURWi:
3549 case AArch64::LDURHi:
3550 case AArch64::STURHi:
3551 case AArch64::LDURHHi:
3552 case AArch64::STURHHi:
3553 case AArch64::LDURSHXi:
3554 case AArch64::LDURSHWi:
3555 case AArch64::LDURBi:
3556 case AArch64::STURBi:
3557 case AArch64::LDURBBi:
3558 case AArch64::STURBBi:
3559 case AArch64::LDURSBWi:
3560 case AArch64::LDURSBXi:
3562 case AArch64::LDRQui:
3563 return AArch64::LDURQi;
3564 case AArch64::STRQui:
3565 return AArch64::STURQi;
3566 case AArch64::LDRDui:
3567 return AArch64::LDURDi;
3568 case AArch64::STRDui:
3569 return AArch64::STURDi;
3570 case AArch64::LDRXui:
3571 return AArch64::LDURXi;
3572 case AArch64::STRXui:
3573 return AArch64::STURXi;
3574 case AArch64::LDRWui:
3575 return AArch64::LDURWi;
3576 case AArch64::LDRSWui:
3577 return AArch64::LDURSWi;
3578 case AArch64::STRWui:
3579 return AArch64::STURWi;
3580 case AArch64::LDRHui:
3581 return AArch64::LDURHi;
3582 case AArch64::STRHui:
3583 return AArch64::STURHi;
3584 case AArch64::LDRHHui:
3585 return AArch64::LDURHHi;
3586 case AArch64::STRHHui:
3587 return AArch64::STURHHi;
3588 case AArch64::LDRSHXui:
3589 return AArch64::LDURSHXi;
3590 case AArch64::LDRSHWui:
3591 return AArch64::LDURSHWi;
3592 case AArch64::LDRBBui:
3593 return AArch64::LDURBBi;
3594 case AArch64::LDRBui:
3595 return AArch64::LDURBi;
3596 case AArch64::STRBBui:
3597 return AArch64::STURBBi;
3598 case AArch64::STRBui:
3599 return AArch64::STURBi;
3600 case AArch64::LDRSBWui:
3601 return AArch64::LDURSBWi;
3602 case AArch64::LDRSBXui:
3603 return AArch64::LDURSBXi;
3616 case AArch64::LDRQroX:
3617 case AArch64::LDURQi:
3618 case AArch64::LDRQui:
3619 return AArch64::LDRQroW;
3620 case AArch64::STRQroX:
3621 case AArch64::STURQi:
3622 case AArch64::STRQui:
3623 return AArch64::STRQroW;
3624 case AArch64::LDRDroX:
3625 case AArch64::LDURDi:
3626 case AArch64::LDRDui:
3627 return AArch64::LDRDroW;
3628 case AArch64::STRDroX:
3629 case AArch64::STURDi:
3630 case AArch64::STRDui:
3631 return AArch64::STRDroW;
3632 case AArch64::LDRXroX:
3633 case AArch64::LDURXi:
3634 case AArch64::LDRXui:
3635 return AArch64::LDRXroW;
3636 case AArch64::STRXroX:
3637 case AArch64::STURXi:
3638 case AArch64::STRXui:
3639 return AArch64::STRXroW;
3640 case AArch64::LDRWroX:
3641 case AArch64::LDURWi:
3642 case AArch64::LDRWui:
3643 return AArch64::LDRWroW;
3644 case AArch64::LDRSWroX:
3645 case AArch64::LDURSWi:
3646 case AArch64::LDRSWui:
3647 return AArch64::LDRSWroW;
3648 case AArch64::STRWroX:
3649 case AArch64::STURWi:
3650 case AArch64::STRWui:
3651 return AArch64::STRWroW;
3652 case AArch64::LDRHroX:
3653 case AArch64::LDURHi:
3654 case AArch64::LDRHui:
3655 return AArch64::LDRHroW;
3656 case AArch64::STRHroX:
3657 case AArch64::STURHi:
3658 case AArch64::STRHui:
3659 return AArch64::STRHroW;
3660 case AArch64::LDRHHroX:
3661 case AArch64::LDURHHi:
3662 case AArch64::LDRHHui:
3663 return AArch64::LDRHHroW;
3664 case AArch64::STRHHroX:
3665 case AArch64::STURHHi:
3666 case AArch64::STRHHui:
3667 return AArch64::STRHHroW;
3668 case AArch64::LDRSHXroX:
3669 case AArch64::LDURSHXi:
3670 case AArch64::LDRSHXui:
3671 return AArch64::LDRSHXroW;
3672 case AArch64::LDRSHWroX:
3673 case AArch64::LDURSHWi:
3674 case AArch64::LDRSHWui:
3675 return AArch64::LDRSHWroW;
3676 case AArch64::LDRBroX:
3677 case AArch64::LDURBi:
3678 case AArch64::LDRBui:
3679 return AArch64::LDRBroW;
3680 case AArch64::LDRBBroX:
3681 case AArch64::LDURBBi:
3682 case AArch64::LDRBBui:
3683 return AArch64::LDRBBroW;
3684 case AArch64::LDRSBXroX:
3685 case AArch64::LDURSBXi:
3686 case AArch64::LDRSBXui:
3687 return AArch64::LDRSBXroW;
3688 case AArch64::LDRSBWroX:
3689 case AArch64::LDURSBWi:
3690 case AArch64::LDRSBWui:
3691 return AArch64::LDRSBWroW;
3692 case AArch64::STRBroX:
3693 case AArch64::STURBi:
3694 case AArch64::STRBui:
3695 return AArch64::STRBroW;
3696 case AArch64::STRBBroX:
3697 case AArch64::STURBBi:
3698 case AArch64::STRBBui:
3699 return AArch64::STRBBroW;
3714 MRI.constrainRegClass(AM.
BaseReg, &AArch64::GPR64spRegClass);
3724 return B.getInstr();
3728 "Addressing mode not supported for folding");
3745 return B.getInstr();
3752 "Address offset can be a register or an immediate, but not both");
3754 MRI.constrainRegClass(AM.
BaseReg, &AArch64::GPR64spRegClass);
3759 OffsetReg =
MRI.createVirtualRegister(&AArch64::GPR32RegClass);
3773 return B.getInstr();
3777 "Function must not be called with an addressing mode it can't handle");
3786 case AArch64::LD1Fourv16b_POST:
3787 case AArch64::LD1Fourv1d_POST:
3788 case AArch64::LD1Fourv2d_POST:
3789 case AArch64::LD1Fourv2s_POST:
3790 case AArch64::LD1Fourv4h_POST:
3791 case AArch64::LD1Fourv4s_POST:
3792 case AArch64::LD1Fourv8b_POST:
3793 case AArch64::LD1Fourv8h_POST:
3794 case AArch64::LD1Onev16b_POST:
3795 case AArch64::LD1Onev1d_POST:
3796 case AArch64::LD1Onev2d_POST:
3797 case AArch64::LD1Onev2s_POST:
3798 case AArch64::LD1Onev4h_POST:
3799 case AArch64::LD1Onev4s_POST:
3800 case AArch64::LD1Onev8b_POST:
3801 case AArch64::LD1Onev8h_POST:
3802 case AArch64::LD1Rv16b_POST:
3803 case AArch64::LD1Rv1d_POST:
3804 case AArch64::LD1Rv2d_POST:
3805 case AArch64::LD1Rv2s_POST:
3806 case AArch64::LD1Rv4h_POST:
3807 case AArch64::LD1Rv4s_POST:
3808 case AArch64::LD1Rv8b_POST:
3809 case AArch64::LD1Rv8h_POST:
3810 case AArch64::LD1Threev16b_POST:
3811 case AArch64::LD1Threev1d_POST:
3812 case AArch64::LD1Threev2d_POST:
3813 case AArch64::LD1Threev2s_POST:
3814 case AArch64::LD1Threev4h_POST:
3815 case AArch64::LD1Threev4s_POST:
3816 case AArch64::LD1Threev8b_POST:
3817 case AArch64::LD1Threev8h_POST:
3818 case AArch64::LD1Twov16b_POST:
3819 case AArch64::LD1Twov1d_POST:
3820 case AArch64::LD1Twov2d_POST:
3821 case AArch64::LD1Twov2s_POST:
3822 case AArch64::LD1Twov4h_POST:
3823 case AArch64::LD1Twov4s_POST:
3824 case AArch64::LD1Twov8b_POST:
3825 case AArch64::LD1Twov8h_POST:
3826 case AArch64::LD1i16_POST:
3827 case AArch64::LD1i32_POST:
3828 case AArch64::LD1i64_POST:
3829 case AArch64::LD1i8_POST:
3830 case AArch64::LD2Rv16b_POST:
3831 case AArch64::LD2Rv1d_POST:
3832 case AArch64::LD2Rv2d_POST:
3833 case AArch64::LD2Rv2s_POST:
3834 case AArch64::LD2Rv4h_POST:
3835 case AArch64::LD2Rv4s_POST:
3836 case AArch64::LD2Rv8b_POST:
3837 case AArch64::LD2Rv8h_POST:
3838 case AArch64::LD2Twov16b_POST:
3839 case AArch64::LD2Twov2d_POST:
3840 case AArch64::LD2Twov2s_POST:
3841 case AArch64::LD2Twov4h_POST:
3842 case AArch64::LD2Twov4s_POST:
3843 case AArch64::LD2Twov8b_POST:
3844 case AArch64::LD2Twov8h_POST:
3845 case AArch64::LD2i16_POST:
3846 case AArch64::LD2i32_POST:
3847 case AArch64::LD2i64_POST:
3848 case AArch64::LD2i8_POST:
3849 case AArch64::LD3Rv16b_POST:
3850 case AArch64::LD3Rv1d_POST:
3851 case AArch64::LD3Rv2d_POST:
3852 case AArch64::LD3Rv2s_POST:
3853 case AArch64::LD3Rv4h_POST:
3854 case AArch64::LD3Rv4s_POST:
3855 case AArch64::LD3Rv8b_POST:
3856 case AArch64::LD3Rv8h_POST:
3857 case AArch64::LD3Threev16b_POST:
3858 case AArch64::LD3Threev2d_POST:
3859 case AArch64::LD3Threev2s_POST:
3860 case AArch64::LD3Threev4h_POST:
3861 case AArch64::LD3Threev4s_POST:
3862 case AArch64::LD3Threev8b_POST:
3863 case AArch64::LD3Threev8h_POST:
3864 case AArch64::LD3i16_POST:
3865 case AArch64::LD3i32_POST:
3866 case AArch64::LD3i64_POST:
3867 case AArch64::LD3i8_POST:
3868 case AArch64::LD4Fourv16b_POST:
3869 case AArch64::LD4Fourv2d_POST:
3870 case AArch64::LD4Fourv2s_POST:
3871 case AArch64::LD4Fourv4h_POST:
3872 case AArch64::LD4Fourv4s_POST:
3873 case AArch64::LD4Fourv8b_POST:
3874 case AArch64::LD4Fourv8h_POST:
3875 case AArch64::LD4Rv16b_POST:
3876 case AArch64::LD4Rv1d_POST:
3877 case AArch64::LD4Rv2d_POST:
3878 case AArch64::LD4Rv2s_POST:
3879 case AArch64::LD4Rv4h_POST:
3880 case AArch64::LD4Rv4s_POST:
3881 case AArch64::LD4Rv8b_POST:
3882 case AArch64::LD4Rv8h_POST:
3883 case AArch64::LD4i16_POST:
3884 case AArch64::LD4i32_POST:
3885 case AArch64::LD4i64_POST:
3886 case AArch64::LD4i8_POST:
3887 case AArch64::LDAPRWpost:
3888 case AArch64::LDAPRXpost:
3889 case AArch64::LDIAPPWpost:
3890 case AArch64::LDIAPPXpost:
3891 case AArch64::LDPDpost:
3892 case AArch64::LDPQpost:
3893 case AArch64::LDPSWpost:
3894 case AArch64::LDPSpost:
3895 case AArch64::LDPWpost:
3896 case AArch64::LDPXpost:
3897 case AArch64::LDRBBpost:
3898 case AArch64::LDRBpost:
3899 case AArch64::LDRDpost:
3900 case AArch64::LDRHHpost:
3901 case AArch64::LDRHpost:
3902 case AArch64::LDRQpost:
3903 case AArch64::LDRSBWpost:
3904 case AArch64::LDRSBXpost:
3905 case AArch64::LDRSHWpost:
3906 case AArch64::LDRSHXpost:
3907 case AArch64::LDRSWpost:
3908 case AArch64::LDRSpost:
3909 case AArch64::LDRWpost:
3910 case AArch64::LDRXpost:
3911 case AArch64::ST1Fourv16b_POST:
3912 case AArch64::ST1Fourv1d_POST:
3913 case AArch64::ST1Fourv2d_POST:
3914 case AArch64::ST1Fourv2s_POST:
3915 case AArch64::ST1Fourv4h_POST:
3916 case AArch64::ST1Fourv4s_POST:
3917 case AArch64::ST1Fourv8b_POST:
3918 case AArch64::ST1Fourv8h_POST:
3919 case AArch64::ST1Onev16b_POST:
3920 case AArch64::ST1Onev1d_POST:
3921 case AArch64::ST1Onev2d_POST:
3922 case AArch64::ST1Onev2s_POST:
3923 case AArch64::ST1Onev4h_POST:
3924 case AArch64::ST1Onev4s_POST:
3925 case AArch64::ST1Onev8b_POST:
3926 case AArch64::ST1Onev8h_POST:
3927 case AArch64::ST1Threev16b_POST:
3928 case AArch64::ST1Threev1d_POST:
3929 case AArch64::ST1Threev2d_POST:
3930 case AArch64::ST1Threev2s_POST:
3931 case AArch64::ST1Threev4h_POST:
3932 case AArch64::ST1Threev4s_POST:
3933 case AArch64::ST1Threev8b_POST:
3934 case AArch64::ST1Threev8h_POST:
3935 case AArch64::ST1Twov16b_POST:
3936 case AArch64::ST1Twov1d_POST:
3937 case AArch64::ST1Twov2d_POST:
3938 case AArch64::ST1Twov2s_POST:
3939 case AArch64::ST1Twov4h_POST:
3940 case AArch64::ST1Twov4s_POST:
3941 case AArch64::ST1Twov8b_POST:
3942 case AArch64::ST1Twov8h_POST:
3943 case AArch64::ST1i16_POST:
3944 case AArch64::ST1i32_POST:
3945 case AArch64::ST1i64_POST:
3946 case AArch64::ST1i8_POST:
3947 case AArch64::ST2GPostIndex:
3948 case AArch64::ST2Twov16b_POST:
3949 case AArch64::ST2Twov2d_POST:
3950 case AArch64::ST2Twov2s_POST:
3951 case AArch64::ST2Twov4h_POST:
3952 case AArch64::ST2Twov4s_POST:
3953 case AArch64::ST2Twov8b_POST:
3954 case AArch64::ST2Twov8h_POST:
3955 case AArch64::ST2i16_POST:
3956 case AArch64::ST2i32_POST:
3957 case AArch64::ST2i64_POST:
3958 case AArch64::ST2i8_POST:
3959 case AArch64::ST3Threev16b_POST:
3960 case AArch64::ST3Threev2d_POST:
3961 case AArch64::ST3Threev2s_POST:
3962 case AArch64::ST3Threev4h_POST:
3963 case AArch64::ST3Threev4s_POST:
3964 case AArch64::ST3Threev8b_POST:
3965 case AArch64::ST3Threev8h_POST:
3966 case AArch64::ST3i16_POST:
3967 case AArch64::ST3i32_POST:
3968 case AArch64::ST3i64_POST:
3969 case AArch64::ST3i8_POST:
3970 case AArch64::ST4Fourv16b_POST:
3971 case AArch64::ST4Fourv2d_POST:
3972 case AArch64::ST4Fourv2s_POST:
3973 case AArch64::ST4Fourv4h_POST:
3974 case AArch64::ST4Fourv4s_POST:
3975 case AArch64::ST4Fourv8b_POST:
3976 case AArch64::ST4Fourv8h_POST:
3977 case AArch64::ST4i16_POST:
3978 case AArch64::ST4i32_POST:
3979 case AArch64::ST4i64_POST:
3980 case AArch64::ST4i8_POST:
3981 case AArch64::STGPostIndex:
3982 case AArch64::STGPpost:
3983 case AArch64::STPDpost:
3984 case AArch64::STPQpost:
3985 case AArch64::STPSpost:
3986 case AArch64::STPWpost:
3987 case AArch64::STPXpost:
3988 case AArch64::STRBBpost:
3989 case AArch64::STRBpost:
3990 case AArch64::STRDpost:
3991 case AArch64::STRHHpost:
3992 case AArch64::STRHpost:
3993 case AArch64::STRQpost:
3994 case AArch64::STRSpost:
3995 case AArch64::STRWpost:
3996 case AArch64::STRXpost:
3997 case AArch64::STZ2GPostIndex:
3998 case AArch64::STZGPostIndex:
4005 bool &OffsetIsScalable,
TypeSize &Width,
4026 int64_t Dummy1, Dummy2;
4048 return BaseOp->
isReg() || BaseOp->
isFI();
4055 assert(OfsOp.
isImm() &&
"Offset operand wasn't immediate.");
4060 TypeSize &Width, int64_t &MinOffset,
4061 int64_t &MaxOffset) {
4067 MinOffset = MaxOffset = 0;
4070 case AArch64::LDRQui:
4071 case AArch64::STRQui:
4077 case AArch64::LDRXui:
4078 case AArch64::LDRDui:
4079 case AArch64::STRXui:
4080 case AArch64::STRDui:
4081 case AArch64::PRFMui:
4087 case AArch64::LDRWui:
4088 case AArch64::LDRSui:
4089 case AArch64::LDRSWui:
4090 case AArch64::STRWui:
4091 case AArch64::STRSui:
4097 case AArch64::LDRHui:
4098 case AArch64::LDRHHui:
4099 case AArch64::LDRSHWui:
4100 case AArch64::LDRSHXui:
4101 case AArch64::STRHui:
4102 case AArch64::STRHHui:
4108 case AArch64::LDRBui:
4109 case AArch64::LDRBBui:
4110 case AArch64::LDRSBWui:
4111 case AArch64::LDRSBXui:
4112 case AArch64::STRBui:
4113 case AArch64::STRBBui:
4120 case AArch64::STRQpre:
4121 case AArch64::LDRQpost:
4127 case AArch64::LDRDpost:
4128 case AArch64::LDRDpre:
4129 case AArch64::LDRXpost:
4130 case AArch64::LDRXpre:
4131 case AArch64::STRDpost:
4132 case AArch64::STRDpre:
4133 case AArch64::STRXpost:
4134 case AArch64::STRXpre:
4140 case AArch64::STRWpost:
4141 case AArch64::STRWpre:
4142 case AArch64::LDRWpost:
4143 case AArch64::LDRWpre:
4144 case AArch64::STRSpost:
4145 case AArch64::STRSpre:
4146 case AArch64::LDRSpost:
4147 case AArch64::LDRSpre:
4153 case AArch64::LDRHpost:
4154 case AArch64::LDRHpre:
4155 case AArch64::STRHpost:
4156 case AArch64::STRHpre:
4157 case AArch64::LDRHHpost:
4158 case AArch64::LDRHHpre:
4159 case AArch64::STRHHpost:
4160 case AArch64::STRHHpre:
4166 case AArch64::LDRBpost:
4167 case AArch64::LDRBpre:
4168 case AArch64::STRBpost:
4169 case AArch64::STRBpre:
4170 case AArch64::LDRBBpost:
4171 case AArch64::LDRBBpre:
4172 case AArch64::STRBBpost:
4173 case AArch64::STRBBpre:
4180 case AArch64::LDURQi:
4181 case AArch64::STURQi:
4187 case AArch64::LDURXi:
4188 case AArch64::LDURDi:
4189 case AArch64::LDAPURXi:
4190 case AArch64::STURXi:
4191 case AArch64::STURDi:
4192 case AArch64::STLURXi:
4193 case AArch64::PRFUMi:
4199 case AArch64::LDURWi:
4200 case AArch64::LDURSi:
4201 case AArch64::LDURSWi:
4202 case AArch64::LDAPURi:
4203 case AArch64::LDAPURSWi:
4204 case AArch64::STURWi:
4205 case AArch64::STURSi:
4206 case AArch64::STLURWi:
4212 case AArch64::LDURHi:
4213 case AArch64::LDURHHi:
4214 case AArch64::LDURSHXi:
4215 case AArch64::LDURSHWi:
4216 case AArch64::LDAPURHi:
4217 case AArch64::LDAPURSHWi:
4218 case AArch64::LDAPURSHXi:
4219 case AArch64::STURHi:
4220 case AArch64::STURHHi:
4221 case AArch64::STLURHi:
4227 case AArch64::LDURBi:
4228 case AArch64::LDURBBi:
4229 case AArch64::LDURSBXi:
4230 case AArch64::LDURSBWi:
4231 case AArch64::LDAPURBi:
4232 case AArch64::LDAPURSBWi:
4233 case AArch64::LDAPURSBXi:
4234 case AArch64::STURBi:
4235 case AArch64::STURBBi:
4236 case AArch64::STLURBi:
4243 case AArch64::LDPQi:
4244 case AArch64::LDNPQi:
4245 case AArch64::STPQi:
4246 case AArch64::STNPQi:
4247 case AArch64::LDPQpost:
4248 case AArch64::LDPQpre:
4249 case AArch64::STPQpost:
4250 case AArch64::STPQpre:
4256 case AArch64::LDPXi:
4257 case AArch64::LDPDi:
4258 case AArch64::LDNPXi:
4259 case AArch64::LDNPDi:
4260 case AArch64::STPXi:
4261 case AArch64::STPDi:
4262 case AArch64::STNPXi:
4263 case AArch64::STNPDi:
4264 case AArch64::LDPDpost:
4265 case AArch64::LDPDpre:
4266 case AArch64::LDPXpost:
4267 case AArch64::LDPXpre:
4268 case AArch64::STPDpost:
4269 case AArch64::STPDpre:
4270 case AArch64::STPXpost:
4271 case AArch64::STPXpre:
4277 case AArch64::LDPWi:
4278 case AArch64::LDPSi:
4279 case AArch64::LDNPWi:
4280 case AArch64::LDNPSi:
4281 case AArch64::STPWi:
4282 case AArch64::STPSi:
4283 case AArch64::STNPWi:
4284 case AArch64::STNPSi:
4285 case AArch64::LDPSpost:
4286 case AArch64::LDPSpre:
4287 case AArch64::LDPWpost:
4288 case AArch64::LDPWpre:
4289 case AArch64::STPSpost:
4290 case AArch64::STPSpre:
4291 case AArch64::STPWpost:
4292 case AArch64::STPWpre:
4298 case AArch64::StoreSwiftAsyncContext:
4311 case AArch64::TAGPstack:
4321 case AArch64::STGPreIndex:
4322 case AArch64::STGPostIndex:
4323 case AArch64::STZGi:
4324 case AArch64::STZGPreIndex:
4325 case AArch64::STZGPostIndex:
4332 case AArch64::STR_ZZZZXI:
4333 case AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS:
4334 case AArch64::LDR_ZZZZXI:
4335 case AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS:
4341 case AArch64::STR_ZZZXI:
4342 case AArch64::LDR_ZZZXI:
4348 case AArch64::STR_ZZXI:
4349 case AArch64::STR_ZZXI_STRIDED_CONTIGUOUS:
4350 case AArch64::LDR_ZZXI:
4351 case AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS:
4357 case AArch64::LDR_PXI:
4358 case AArch64::STR_PXI:
4364 case AArch64::LDR_PPXI:
4365 case AArch64::STR_PPXI:
4371 case AArch64::SPILL_PPR_TO_ZPR_SLOT_PSEUDO:
4372 case AArch64::FILL_PPR_FROM_ZPR_SLOT_PSEUDO:
4373 case AArch64::LDR_ZXI:
4374 case AArch64::STR_ZXI:
4380 case AArch64::LD1B_IMM:
4381 case AArch64::LD1H_IMM:
4382 case AArch64::LD1W_IMM:
4383 case AArch64::LD1D_IMM:
4384 case AArch64::LDNT1B_ZRI:
4385 case AArch64::LDNT1H_ZRI:
4386 case AArch64::LDNT1W_ZRI:
4387 case AArch64::LDNT1D_ZRI:
4388 case AArch64::ST1B_IMM:
4389 case AArch64::ST1H_IMM:
4390 case AArch64::ST1W_IMM:
4391 case AArch64::ST1D_IMM:
4392 case AArch64::STNT1B_ZRI:
4393 case AArch64::STNT1H_ZRI:
4394 case AArch64::STNT1W_ZRI:
4395 case AArch64::STNT1D_ZRI:
4396 case AArch64::LDNF1B_IMM:
4397 case AArch64::LDNF1H_IMM:
4398 case AArch64::LDNF1W_IMM:
4399 case AArch64::LDNF1D_IMM:
4407 case AArch64::LD2B_IMM:
4408 case AArch64::LD2H_IMM:
4409 case AArch64::LD2W_IMM:
4410 case AArch64::LD2D_IMM:
4411 case AArch64::ST2B_IMM:
4412 case AArch64::ST2H_IMM:
4413 case AArch64::ST2W_IMM:
4414 case AArch64::ST2D_IMM:
4420 case AArch64::LD3B_IMM:
4421 case AArch64::LD3H_IMM:
4422 case AArch64::LD3W_IMM:
4423 case AArch64::LD3D_IMM:
4424 case AArch64::ST3B_IMM:
4425 case AArch64::ST3H_IMM:
4426 case AArch64::ST3W_IMM:
4427 case AArch64::ST3D_IMM:
4433 case AArch64::LD4B_IMM:
4434 case AArch64::LD4H_IMM:
4435 case AArch64::LD4W_IMM:
4436 case AArch64::LD4D_IMM:
4437 case AArch64::ST4B_IMM:
4438 case AArch64::ST4H_IMM:
4439 case AArch64::ST4W_IMM:
4440 case AArch64::ST4D_IMM:
4446 case AArch64::LD1B_H_IMM:
4447 case AArch64::LD1SB_H_IMM:
4448 case AArch64::LD1H_S_IMM:
4449 case AArch64::LD1SH_S_IMM:
4450 case AArch64::LD1W_D_IMM:
4451 case AArch64::LD1SW_D_IMM:
4452 case AArch64::ST1B_H_IMM:
4453 case AArch64::ST1H_S_IMM:
4454 case AArch64::ST1W_D_IMM:
4455 case AArch64::LDNF1B_H_IMM:
4456 case AArch64::LDNF1SB_H_IMM:
4457 case AArch64::LDNF1H_S_IMM:
4458 case AArch64::LDNF1SH_S_IMM:
4459 case AArch64::LDNF1W_D_IMM:
4460 case AArch64::LDNF1SW_D_IMM:
4468 case AArch64::LD1B_S_IMM:
4469 case AArch64::LD1SB_S_IMM:
4470 case AArch64::LD1H_D_IMM:
4471 case AArch64::LD1SH_D_IMM:
4472 case AArch64::ST1B_S_IMM:
4473 case AArch64::ST1H_D_IMM:
4474 case AArch64::LDNF1B_S_IMM:
4475 case AArch64::LDNF1SB_S_IMM:
4476 case AArch64::LDNF1H_D_IMM:
4477 case AArch64::LDNF1SH_D_IMM:
4485 case AArch64::LD1B_D_IMM:
4486 case AArch64::LD1SB_D_IMM:
4487 case AArch64::ST1B_D_IMM:
4488 case AArch64::LDNF1B_D_IMM:
4489 case AArch64::LDNF1SB_D_IMM:
4497 case AArch64::ST2Gi:
4498 case AArch64::ST2GPreIndex:
4499 case AArch64::ST2GPostIndex:
4500 case AArch64::STZ2Gi:
4501 case AArch64::STZ2GPreIndex:
4502 case AArch64::STZ2GPostIndex:
4508 case AArch64::STGPi:
4509 case AArch64::STGPpost:
4510 case AArch64::STGPpre:
4516 case AArch64::LD1RB_IMM:
4517 case AArch64::LD1RB_H_IMM:
4518 case AArch64::LD1RB_S_IMM:
4519 case AArch64::LD1RB_D_IMM:
4520 case AArch64::LD1RSB_H_IMM:
4521 case AArch64::LD1RSB_S_IMM:
4522 case AArch64::LD1RSB_D_IMM:
4528 case AArch64::LD1RH_IMM:
4529 case AArch64::LD1RH_S_IMM:
4530 case AArch64::LD1RH_D_IMM:
4531 case AArch64::LD1RSH_S_IMM:
4532 case AArch64::LD1RSH_D_IMM:
4538 case AArch64::LD1RW_IMM:
4539 case AArch64::LD1RW_D_IMM:
4540 case AArch64::LD1RSW_IMM:
4546 case AArch64::LD1RD_IMM:
4562 case AArch64::LDRBBui:
4563 case AArch64::LDURBBi:
4564 case AArch64::LDRSBWui:
4565 case AArch64::LDURSBWi:
4566 case AArch64::STRBBui:
4567 case AArch64::STURBBi:
4569 case AArch64::LDRHHui:
4570 case AArch64::LDURHHi:
4571 case AArch64::LDRSHWui:
4572 case AArch64::LDURSHWi:
4573 case AArch64::STRHHui:
4574 case AArch64::STURHHi:
4576 case AArch64::LDRSui:
4577 case AArch64::LDURSi:
4578 case AArch64::LDRSpre:
4579 case AArch64::LDRSWui:
4580 case AArch64::LDURSWi:
4581 case AArch64::LDRSWpre:
4582 case AArch64::LDRWpre:
4583 case AArch64::LDRWui:
4584 case AArch64::LDURWi:
4585 case AArch64::STRSui:
4586 case AArch64::STURSi:
4587 case AArch64::STRSpre:
4588 case AArch64::STRWui:
4589 case AArch64::STURWi:
4590 case AArch64::STRWpre:
4591 case AArch64::LDPSi:
4592 case AArch64::LDPSWi:
4593 case AArch64::LDPWi:
4594 case AArch64::STPSi:
4595 case AArch64::STPWi:
4597 case AArch64::LDRDui:
4598 case AArch64::LDURDi:
4599 case AArch64::LDRDpre:
4600 case AArch64::LDRXui:
4601 case AArch64::LDURXi:
4602 case AArch64::LDRXpre:
4603 case AArch64::STRDui:
4604 case AArch64::STURDi:
4605 case AArch64::STRDpre:
4606 case AArch64::STRXui:
4607 case AArch64::STURXi:
4608 case AArch64::STRXpre:
4609 case AArch64::LDPDi:
4610 case AArch64::LDPXi:
4611 case AArch64::STPDi:
4612 case AArch64::STPXi:
4614 case AArch64::LDRQui:
4615 case AArch64::LDURQi:
4616 case AArch64::STRQui:
4617 case AArch64::STURQi:
4618 case AArch64::STRQpre:
4619 case AArch64::LDPQi:
4620 case AArch64::LDRQpre:
4621 case AArch64::STPQi:
4623 case AArch64::STZGi:
4624 case AArch64::ST2Gi:
4625 case AArch64::STZ2Gi:
4626 case AArch64::STGPi:
4632 switch (
MI.getOpcode()) {
4635 case AArch64::LDRWpre:
4636 case AArch64::LDRXpre:
4637 case AArch64::LDRSWpre:
4638 case AArch64::LDRSpre:
4639 case AArch64::LDRDpre:
4640 case AArch64::LDRQpre:
4646 switch (
MI.getOpcode()) {
4649 case AArch64::STRWpre:
4650 case AArch64::STRXpre:
4651 case AArch64::STRSpre:
4652 case AArch64::STRDpre:
4653 case AArch64::STRQpre:
4663 switch (
MI.getOpcode()) {
4666 case AArch64::LDPSi:
4667 case AArch64::LDPSWi:
4668 case AArch64::LDPDi:
4669 case AArch64::LDPQi:
4670 case AArch64::LDPWi:
4671 case AArch64::LDPXi:
4672 case AArch64::STPSi:
4673 case AArch64::STPDi:
4674 case AArch64::STPQi:
4675 case AArch64::STPWi:
4676 case AArch64::STPXi:
4677 case AArch64::STGPi:
4683 assert(
MI.mayLoadOrStore() &&
"Load or store instruction expected");
4687 return MI.getOperand(
Idx);
4692 assert(
MI.mayLoadOrStore() &&
"Load or store instruction expected");
4696 return MI.getOperand(
Idx);
4701 switch (
MI.getOpcode()) {
4704 case AArch64::LDRBroX:
4705 case AArch64::LDRBBroX:
4706 case AArch64::LDRSBXroX:
4707 case AArch64::LDRSBWroX:
4708 case AArch64::LDRHroX:
4709 case AArch64::LDRHHroX:
4710 case AArch64::LDRSHXroX:
4711 case AArch64::LDRSHWroX:
4712 case AArch64::LDRWroX:
4713 case AArch64::LDRSroX:
4714 case AArch64::LDRSWroX:
4715 case AArch64::LDRDroX:
4716 case AArch64::LDRXroX:
4717 case AArch64::LDRQroX:
4718 return MI.getOperand(4);
4724 if (
MI.getParent() ==
nullptr)
4734 auto Reg =
Op.getReg();
4735 if (Reg.isPhysical())
4736 return AArch64::FPR16RegClass.
contains(Reg);
4738 return TRC == &AArch64::FPR16RegClass ||
4739 TRC == &AArch64::FPR16_loRegClass;
4748 auto Reg =
Op.getReg();
4749 if (Reg.isPhysical())
4750 return AArch64::FPR128RegClass.
contains(Reg);
4752 return TRC == &AArch64::FPR128RegClass ||
4753 TRC == &AArch64::FPR128_loRegClass;
4759 switch (
MI.getOpcode()) {
4762 case AArch64::PACIASP:
4763 case AArch64::PACIBSP:
4766 case AArch64::PAUTH_PROLOGUE:
4769 case AArch64::HINT: {
4770 unsigned Imm =
MI.getOperand(0).getImm();
4772 if (Imm == 32 || Imm == 34 || Imm == 36 || Imm == 38)
4775 if (Imm == 25 || Imm == 27)
4787 assert(Reg.isPhysical() &&
"Expected physical register in isFpOrNEON");
4788 return AArch64::FPR128RegClass.contains(Reg) ||
4789 AArch64::FPR64RegClass.contains(Reg) ||
4790 AArch64::FPR32RegClass.contains(Reg) ||
4791 AArch64::FPR16RegClass.contains(Reg) ||
4792 AArch64::FPR8RegClass.contains(Reg);
4799 auto Reg =
Op.getReg();
4800 if (Reg.isPhysical())
4804 return TRC == &AArch64::FPR128RegClass ||
4805 TRC == &AArch64::FPR128_loRegClass ||
4806 TRC == &AArch64::FPR64RegClass ||
4807 TRC == &AArch64::FPR64_loRegClass ||
4808 TRC == &AArch64::FPR32RegClass || TRC == &AArch64::FPR16RegClass ||
4809 TRC == &AArch64::FPR8RegClass;
4831 if (FirstOpc == SecondOpc)
4837 case AArch64::STRSui:
4838 case AArch64::STURSi:
4839 return SecondOpc == AArch64::STRSui || SecondOpc == AArch64::STURSi;
4840 case AArch64::STRDui:
4841 case AArch64::STURDi:
4842 return SecondOpc == AArch64::STRDui || SecondOpc == AArch64::STURDi;
4843 case AArch64::STRQui:
4844 case AArch64::STURQi:
4845 return SecondOpc == AArch64::STRQui || SecondOpc == AArch64::STURQi;
4846 case AArch64::STRWui:
4847 case AArch64::STURWi:
4848 return SecondOpc == AArch64::STRWui || SecondOpc == AArch64::STURWi;
4849 case AArch64::STRXui:
4850 case AArch64::STURXi:
4851 return SecondOpc == AArch64::STRXui || SecondOpc == AArch64::STURXi;
4852 case AArch64::LDRSui:
4853 case AArch64::LDURSi:
4854 return SecondOpc == AArch64::LDRSui || SecondOpc == AArch64::LDURSi;
4855 case AArch64::LDRDui:
4856 case AArch64::LDURDi:
4857 return SecondOpc == AArch64::LDRDui || SecondOpc == AArch64::LDURDi;
4858 case AArch64::LDRQui:
4859 case AArch64::LDURQi:
4860 return SecondOpc == AArch64::LDRQui || SecondOpc == AArch64::LDURQi;
4861 case AArch64::LDRWui:
4862 case AArch64::LDURWi:
4863 return SecondOpc == AArch64::LDRSWui || SecondOpc == AArch64::LDURSWi;
4864 case AArch64::LDRSWui:
4865 case AArch64::LDURSWi:
4866 return SecondOpc == AArch64::LDRWui || SecondOpc == AArch64::LDURWi;
4867 case AArch64::LDRXui:
4868 case AArch64::LDURXi:
4869 return SecondOpc == AArch64::LDRXui || SecondOpc == AArch64::LDURXi;
4876 int64_t Offset1,
unsigned Opcode1,
int FI2,
4877 int64_t Offset2,
unsigned Opcode2) {
4883 assert(ObjectOffset1 <= ObjectOffset2 &&
"Object offsets are not ordered.");
4886 if (ObjectOffset1 % Scale1 != 0)
4888 ObjectOffset1 /= Scale1;
4890 if (ObjectOffset2 % Scale2 != 0)
4892 ObjectOffset2 /= Scale2;
4893 ObjectOffset1 += Offset1;
4894 ObjectOffset2 += Offset2;
4895 return ObjectOffset1 + 1 == ObjectOffset2;
4907 int64_t OpOffset2,
bool OffsetIsScalable2,
unsigned ClusterSize,
4908 unsigned NumBytes)
const {
4918 "Only base registers and frame indices are supported.");
4925 if (ClusterSize > 2)
4932 unsigned FirstOpc = FirstLdSt.
getOpcode();
4933 unsigned SecondOpc = SecondLdSt.
getOpcode();
4953 if (Offset1 > 63 || Offset1 < -64)
4958 if (BaseOp1.
isFI()) {
4960 "Caller should have ordered offsets.");
4965 BaseOp2.
getIndex(), Offset2, SecondOpc);
4968 assert(Offset1 <= Offset2 &&
"Caller should have ordered offsets.");
4970 return Offset1 + 1 == Offset2;
4978 return MIB.
addReg(Reg, State);
4980 if (Reg.isPhysical())
4981 return MIB.
addReg(
TRI->getSubReg(Reg, SubIdx), State);
4982 return MIB.
addReg(Reg, State, SubIdx);
4989 return ((DestReg - SrcReg) & 0x1f) < NumRegs;
4998 assert(Subtarget.hasNEON() &&
"Unexpected register copy without NEON");
5000 uint16_t DestEncoding =
TRI->getEncodingValue(DestReg);
5001 uint16_t SrcEncoding =
TRI->getEncodingValue(SrcReg);
5002 unsigned NumRegs = Indices.
size();
5004 int SubReg = 0,
End = NumRegs, Incr = 1;
5023 unsigned Opcode,
unsigned ZeroReg,
5026 unsigned NumRegs = Indices.
size();
5029 uint16_t DestEncoding =
TRI->getEncodingValue(DestReg);
5030 uint16_t SrcEncoding =
TRI->getEncodingValue(SrcReg);
5031 assert(DestEncoding % NumRegs == 0 && SrcEncoding % NumRegs == 0 &&
5032 "GPR reg sequences should not be able to overlap");
5049 bool RenamableSrc)
const {
5050 if (AArch64::GPR32spRegClass.
contains(DestReg) &&
5051 (AArch64::GPR32spRegClass.
contains(SrcReg) || SrcReg == AArch64::WZR)) {
5054 if (DestReg == AArch64::WSP || SrcReg == AArch64::WSP) {
5056 if (Subtarget.hasZeroCycleRegMoveGPR64() &&
5057 !Subtarget.hasZeroCycleRegMoveGPR32()) {
5060 DestReg, AArch64::sub_32, &AArch64::GPR64spRegClass);
5062 SrcReg, AArch64::sub_32, &AArch64::GPR64spRegClass);
5078 }
else if (SrcReg == AArch64::WZR && Subtarget.hasZeroCycleZeroingGPR32()) {
5083 if (Subtarget.hasZeroCycleRegMoveGPR64() &&
5084 !Subtarget.hasZeroCycleRegMoveGPR32()) {
5087 DestReg, AArch64::sub_32, &AArch64::GPR64spRegClass);
5088 assert(DestRegX.
isValid() &&
"Destination super-reg not valid");
5090 SrcReg == AArch64::WZR
5092 :
TRI->getMatchingSuperReg(SrcReg, AArch64::sub_32,
5093 &AArch64::GPR64spRegClass);
5114 if (AArch64::PPRRegClass.
contains(DestReg) &&
5115 AArch64::PPRRegClass.
contains(SrcReg)) {
5117 "Unexpected SVE register.");
5127 bool DestIsPNR = AArch64::PNRRegClass.contains(DestReg);
5128 bool SrcIsPNR = AArch64::PNRRegClass.contains(SrcReg);
5129 if (DestIsPNR || SrcIsPNR) {
5131 return (R - AArch64::PN0) + AArch64::P0;
5136 if (PPRSrcReg != PPRDestReg) {
5148 if (AArch64::ZPRRegClass.
contains(DestReg) &&
5149 AArch64::ZPRRegClass.
contains(SrcReg)) {
5151 "Unexpected SVE register.");
5159 if ((AArch64::ZPR2RegClass.
contains(DestReg) ||
5160 AArch64::ZPR2StridedOrContiguousRegClass.
contains(DestReg)) &&
5161 (AArch64::ZPR2RegClass.
contains(SrcReg) ||
5162 AArch64::ZPR2StridedOrContiguousRegClass.
contains(SrcReg))) {
5164 "Unexpected SVE register.");
5165 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1};
5172 if (AArch64::ZPR3RegClass.
contains(DestReg) &&
5173 AArch64::ZPR3RegClass.
contains(SrcReg)) {
5175 "Unexpected SVE register.");
5176 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1,
5184 if ((AArch64::ZPR4RegClass.
contains(DestReg) ||
5185 AArch64::ZPR4StridedOrContiguousRegClass.
contains(DestReg)) &&
5186 (AArch64::ZPR4RegClass.
contains(SrcReg) ||
5187 AArch64::ZPR4StridedOrContiguousRegClass.
contains(SrcReg))) {
5189 "Unexpected SVE register.");
5190 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1,
5191 AArch64::zsub2, AArch64::zsub3};
5197 if (AArch64::GPR64spRegClass.
contains(DestReg) &&
5198 (AArch64::GPR64spRegClass.
contains(SrcReg) || SrcReg == AArch64::XZR)) {
5199 if (DestReg == AArch64::SP || SrcReg == AArch64::SP) {
5205 }
else if (SrcReg == AArch64::XZR && Subtarget.hasZeroCycleZeroingGPR64()) {
5219 if (AArch64::DDDDRegClass.
contains(DestReg) &&
5220 AArch64::DDDDRegClass.
contains(SrcReg)) {
5221 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1,
5222 AArch64::dsub2, AArch64::dsub3};
5229 if (AArch64::DDDRegClass.
contains(DestReg) &&
5230 AArch64::DDDRegClass.
contains(SrcReg)) {
5231 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1,
5239 if (AArch64::DDRegClass.
contains(DestReg) &&
5240 AArch64::DDRegClass.
contains(SrcReg)) {
5241 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1};
5248 if (AArch64::QQQQRegClass.
contains(DestReg) &&
5249 AArch64::QQQQRegClass.
contains(SrcReg)) {
5250 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1,
5251 AArch64::qsub2, AArch64::qsub3};
5258 if (AArch64::QQQRegClass.
contains(DestReg) &&
5259 AArch64::QQQRegClass.
contains(SrcReg)) {
5260 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1,
5268 if (AArch64::QQRegClass.
contains(DestReg) &&
5269 AArch64::QQRegClass.
contains(SrcReg)) {
5270 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1};
5276 if (AArch64::XSeqPairsClassRegClass.
contains(DestReg) &&
5277 AArch64::XSeqPairsClassRegClass.
contains(SrcReg)) {
5278 static const unsigned Indices[] = {AArch64::sube64, AArch64::subo64};
5280 AArch64::XZR, Indices);
5284 if (AArch64::WSeqPairsClassRegClass.
contains(DestReg) &&
5285 AArch64::WSeqPairsClassRegClass.
contains(SrcReg)) {
5286 static const unsigned Indices[] = {AArch64::sube32, AArch64::subo32};
5288 AArch64::WZR, Indices);
5292 if (AArch64::FPR128RegClass.
contains(DestReg) &&
5293 AArch64::FPR128RegClass.
contains(SrcReg)) {
5298 .
addReg(AArch64::Z0 + (SrcReg - AArch64::Q0))
5299 .
addReg(AArch64::Z0 + (SrcReg - AArch64::Q0));
5319 if (AArch64::FPR64RegClass.
contains(DestReg) &&
5320 AArch64::FPR64RegClass.
contains(SrcReg)) {
5321 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
5322 !Subtarget.hasZeroCycleRegMoveFPR64() &&
5323 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.
isNeonAvailable()) {
5325 MCRegister DestRegQ =
TRI->getMatchingSuperReg(DestReg, AArch64::dsub,
5326 &AArch64::FPR128RegClass);
5327 MCRegister SrcRegQ =
TRI->getMatchingSuperReg(SrcReg, AArch64::dsub,
5328 &AArch64::FPR128RegClass);
5344 if (AArch64::FPR32RegClass.
contains(DestReg) &&
5345 AArch64::FPR32RegClass.
contains(SrcReg)) {
5346 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
5347 !Subtarget.hasZeroCycleRegMoveFPR64() &&
5348 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.
isNeonAvailable()) {
5350 MCRegister DestRegQ =
TRI->getMatchingSuperReg(DestReg, AArch64::ssub,
5351 &AArch64::FPR128RegClass);
5352 MCRegister SrcRegQ =
TRI->getMatchingSuperReg(SrcReg, AArch64::ssub,
5353 &AArch64::FPR128RegClass);
5362 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
5363 !Subtarget.hasZeroCycleRegMoveFPR32()) {
5365 MCRegister DestRegD =
TRI->getMatchingSuperReg(DestReg, AArch64::ssub,
5366 &AArch64::FPR64RegClass);
5367 MCRegister SrcRegD =
TRI->getMatchingSuperReg(SrcReg, AArch64::ssub,
5368 &AArch64::FPR64RegClass);
5383 if (AArch64::FPR16RegClass.
contains(DestReg) &&
5384 AArch64::FPR16RegClass.
contains(SrcReg)) {
5385 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
5386 !Subtarget.hasZeroCycleRegMoveFPR64() &&
5387 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.
isNeonAvailable()) {
5389 MCRegister DestRegQ =
TRI->getMatchingSuperReg(DestReg, AArch64::hsub,
5390 &AArch64::FPR128RegClass);
5391 MCRegister SrcRegQ =
TRI->getMatchingSuperReg(SrcReg, AArch64::hsub,
5392 &AArch64::FPR128RegClass);
5401 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
5402 !Subtarget.hasZeroCycleRegMoveFPR32()) {
5404 MCRegister DestRegD =
TRI->getMatchingSuperReg(DestReg, AArch64::hsub,
5405 &AArch64::FPR64RegClass);
5406 MCRegister SrcRegD =
TRI->getMatchingSuperReg(SrcReg, AArch64::hsub,
5407 &AArch64::FPR64RegClass);
5416 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
5417 &AArch64::FPR32RegClass);
5418 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
5419 &AArch64::FPR32RegClass);
5426 if (AArch64::FPR8RegClass.
contains(DestReg) &&
5427 AArch64::FPR8RegClass.
contains(SrcReg)) {
5428 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
5429 !Subtarget.hasZeroCycleRegMoveFPR64() &&
5430 !Subtarget.hasZeroCycleRegMoveFPR64() && Subtarget.
isNeonAvailable()) {
5432 MCRegister DestRegQ =
TRI->getMatchingSuperReg(DestReg, AArch64::bsub,
5433 &AArch64::FPR128RegClass);
5434 MCRegister SrcRegQ =
TRI->getMatchingSuperReg(SrcReg, AArch64::bsub,
5435 &AArch64::FPR128RegClass);
5444 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
5445 !Subtarget.hasZeroCycleRegMoveFPR32()) {
5447 MCRegister DestRegD =
TRI->getMatchingSuperReg(DestReg, AArch64::bsub,
5448 &AArch64::FPR64RegClass);
5449 MCRegister SrcRegD =
TRI->getMatchingSuperReg(SrcReg, AArch64::bsub,
5450 &AArch64::FPR64RegClass);
5459 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
5460 &AArch64::FPR32RegClass);
5461 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
5462 &AArch64::FPR32RegClass);
5470 if (AArch64::FPR64RegClass.
contains(DestReg) &&
5471 AArch64::GPR64RegClass.
contains(SrcReg)) {
5476 if (AArch64::GPR64RegClass.
contains(DestReg) &&
5477 AArch64::FPR64RegClass.
contains(SrcReg)) {
5483 if (AArch64::FPR32RegClass.
contains(DestReg) &&
5484 AArch64::GPR32RegClass.
contains(SrcReg)) {
5489 if (AArch64::GPR32RegClass.
contains(DestReg) &&
5490 AArch64::FPR32RegClass.
contains(SrcReg)) {
5496 if (DestReg == AArch64::NZCV) {
5497 assert(AArch64::GPR64RegClass.
contains(SrcReg) &&
"Invalid NZCV copy");
5499 .
addImm(AArch64SysReg::NZCV)
5505 if (SrcReg == AArch64::NZCV) {
5506 assert(AArch64::GPR64RegClass.
contains(DestReg) &&
"Invalid NZCV copy");
5508 .
addImm(AArch64SysReg::NZCV)
5515 errs() <<
TRI.getRegAsmName(DestReg) <<
" = COPY "
5516 <<
TRI.getRegAsmName(SrcReg) <<
"\n";
5526 unsigned SubIdx0,
unsigned SubIdx1,
int FI,
5531 SrcReg0 =
TRI.getSubReg(SrcReg, SubIdx0);
5533 SrcReg1 =
TRI.getSubReg(SrcReg, SubIdx1);
5546 Register SrcReg,
bool isKill,
int FI,
5562 switch (
TRI->getSpillSize(*RC)) {
5564 if (AArch64::FPR8RegClass.hasSubClassEq(RC))
5565 Opc = AArch64::STRBui;
5568 if (AArch64::FPR16RegClass.hasSubClassEq(RC))
5569 Opc = AArch64::STRHui;
5570 else if (AArch64::PNRRegClass.hasSubClassEq(RC) ||
5571 AArch64::PPRRegClass.hasSubClassEq(RC)) {
5573 "Unexpected register store without SVE store instructions");
5574 Opc = AArch64::STR_PXI;
5580 if (AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
5581 Opc = AArch64::STRWui;
5585 assert(SrcReg != AArch64::WSP);
5586 }
else if (AArch64::FPR32RegClass.hasSubClassEq(RC))
5587 Opc = AArch64::STRSui;
5588 else if (AArch64::PPR2RegClass.hasSubClassEq(RC)) {
5589 Opc = AArch64::STR_PPXI;
5594 if (AArch64::GPR64allRegClass.hasSubClassEq(RC)) {
5595 Opc = AArch64::STRXui;
5599 assert(SrcReg != AArch64::SP);
5600 }
else if (AArch64::FPR64RegClass.hasSubClassEq(RC)) {
5601 Opc = AArch64::STRDui;
5602 }
else if (AArch64::WSeqPairsClassRegClass.hasSubClassEq(RC)) {
5604 get(AArch64::STPWi), SrcReg, isKill,
5605 AArch64::sube32, AArch64::subo32, FI, MMO);
5610 if (AArch64::FPR128RegClass.hasSubClassEq(RC))
5611 Opc = AArch64::STRQui;
5612 else if (AArch64::DDRegClass.hasSubClassEq(RC)) {
5613 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
5614 Opc = AArch64::ST1Twov1d;
5616 }
else if (AArch64::XSeqPairsClassRegClass.hasSubClassEq(RC)) {
5618 get(AArch64::STPXi), SrcReg, isKill,
5619 AArch64::sube64, AArch64::subo64, FI, MMO);
5621 }
else if (AArch64::ZPRRegClass.hasSubClassEq(RC)) {
5623 "Unexpected register store without SVE store instructions");
5624 Opc = AArch64::STR_ZXI;
5626 }
else if (AArch64::PPRRegClass.hasSubClassEq(RC)) {
5628 "Unexpected predicate store without SVE store instructions");
5629 Opc = AArch64::SPILL_PPR_TO_ZPR_SLOT_PSEUDO;
5634 if (AArch64::DDDRegClass.hasSubClassEq(RC)) {
5635 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
5636 Opc = AArch64::ST1Threev1d;
5641 if (AArch64::DDDDRegClass.hasSubClassEq(RC)) {
5642 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
5643 Opc = AArch64::ST1Fourv1d;
5645 }
else if (AArch64::QQRegClass.hasSubClassEq(RC)) {
5646 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
5647 Opc = AArch64::ST1Twov2d;
5649 }
else if (AArch64::ZPR2StridedOrContiguousRegClass.hasSubClassEq(RC)) {
5651 "Unexpected register store without SVE store instructions");
5652 Opc = AArch64::STR_ZZXI_STRIDED_CONTIGUOUS;
5654 }
else if (AArch64::ZPR2RegClass.hasSubClassEq(RC)) {
5656 "Unexpected register store without SVE store instructions");
5657 Opc = AArch64::STR_ZZXI;
5662 if (AArch64::QQQRegClass.hasSubClassEq(RC)) {
5663 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
5664 Opc = AArch64::ST1Threev2d;
5666 }
else if (AArch64::ZPR3RegClass.hasSubClassEq(RC)) {
5668 "Unexpected register store without SVE store instructions");
5669 Opc = AArch64::STR_ZZZXI;
5674 if (AArch64::QQQQRegClass.hasSubClassEq(RC)) {
5675 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
5676 Opc = AArch64::ST1Fourv2d;
5678 }
else if (AArch64::ZPR4StridedOrContiguousRegClass.hasSubClassEq(RC)) {
5680 "Unexpected register store without SVE store instructions");
5681 Opc = AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS;
5683 }
else if (AArch64::ZPR4RegClass.hasSubClassEq(RC)) {
5685 "Unexpected register store without SVE store instructions");
5686 Opc = AArch64::STR_ZZZZXI;
5691 assert(
Opc &&
"Unknown register class");
5702 MI.addMemOperand(MMO);
5709 Register DestReg,
unsigned SubIdx0,
5710 unsigned SubIdx1,
int FI,
5714 bool IsUndef =
true;
5716 DestReg0 =
TRI.getSubReg(DestReg, SubIdx0);
5718 DestReg1 =
TRI.getSubReg(DestReg, SubIdx1);
5745 switch (
TRI->getSpillSize(*RC)) {
5747 if (AArch64::FPR8RegClass.hasSubClassEq(RC))
5748 Opc = AArch64::LDRBui;
5751 bool IsPNR = AArch64::PNRRegClass.hasSubClassEq(RC);
5752 if (AArch64::FPR16RegClass.hasSubClassEq(RC))
5753 Opc = AArch64::LDRHui;
5754 else if (IsPNR || AArch64::PPRRegClass.hasSubClassEq(RC)) {
5756 "Unexpected register load without SVE load instructions");
5759 Opc = AArch64::LDR_PXI;
5765 if (AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
5766 Opc = AArch64::LDRWui;
5770 assert(DestReg != AArch64::WSP);
5771 }
else if (AArch64::FPR32RegClass.hasSubClassEq(RC))
5772 Opc = AArch64::LDRSui;
5773 else if (AArch64::PPR2RegClass.hasSubClassEq(RC)) {
5774 Opc = AArch64::LDR_PPXI;
5779 if (AArch64::GPR64allRegClass.hasSubClassEq(RC)) {
5780 Opc = AArch64::LDRXui;
5784 assert(DestReg != AArch64::SP);
5785 }
else if (AArch64::FPR64RegClass.hasSubClassEq(RC)) {
5786 Opc = AArch64::LDRDui;
5787 }
else if (AArch64::WSeqPairsClassRegClass.hasSubClassEq(RC)) {
5789 get(AArch64::LDPWi), DestReg, AArch64::sube32,
5790 AArch64::subo32, FI, MMO);
5795 if (AArch64::FPR128RegClass.hasSubClassEq(RC))
5796 Opc = AArch64::LDRQui;
5797 else if (AArch64::DDRegClass.hasSubClassEq(RC)) {
5798 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
5799 Opc = AArch64::LD1Twov1d;
5801 }
else if (AArch64::XSeqPairsClassRegClass.hasSubClassEq(RC)) {
5803 get(AArch64::LDPXi), DestReg, AArch64::sube64,
5804 AArch64::subo64, FI, MMO);
5806 }
else if (AArch64::ZPRRegClass.hasSubClassEq(RC)) {
5808 "Unexpected register load without SVE load instructions");
5809 Opc = AArch64::LDR_ZXI;
5811 }
else if (AArch64::PPRRegClass.hasSubClassEq(RC)) {
5813 "Unexpected predicate load without SVE load instructions");
5814 Opc = AArch64::FILL_PPR_FROM_ZPR_SLOT_PSEUDO;
5819 if (AArch64::DDDRegClass.hasSubClassEq(RC)) {
5820 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
5821 Opc = AArch64::LD1Threev1d;
5826 if (AArch64::DDDDRegClass.hasSubClassEq(RC)) {
5827 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
5828 Opc = AArch64::LD1Fourv1d;
5830 }
else if (AArch64::QQRegClass.hasSubClassEq(RC)) {
5831 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
5832 Opc = AArch64::LD1Twov2d;
5834 }
else if (AArch64::ZPR2StridedOrContiguousRegClass.hasSubClassEq(RC)) {
5836 "Unexpected register load without SVE load instructions");
5837 Opc = AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS;
5839 }
else if (AArch64::ZPR2RegClass.hasSubClassEq(RC)) {
5841 "Unexpected register load without SVE load instructions");
5842 Opc = AArch64::LDR_ZZXI;
5847 if (AArch64::QQQRegClass.hasSubClassEq(RC)) {
5848 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
5849 Opc = AArch64::LD1Threev2d;
5851 }
else if (AArch64::ZPR3RegClass.hasSubClassEq(RC)) {
5853 "Unexpected register load without SVE load instructions");
5854 Opc = AArch64::LDR_ZZZXI;
5859 if (AArch64::QQQQRegClass.hasSubClassEq(RC)) {
5860 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
5861 Opc = AArch64::LD1Fourv2d;
5863 }
else if (AArch64::ZPR4StridedOrContiguousRegClass.hasSubClassEq(RC)) {
5865 "Unexpected register load without SVE load instructions");
5866 Opc = AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS;
5868 }
else if (AArch64::ZPR4RegClass.hasSubClassEq(RC)) {
5870 "Unexpected register load without SVE load instructions");
5871 Opc = AArch64::LDR_ZZZZXI;
5877 assert(
Opc &&
"Unknown register class");
5887 MI.addMemOperand(MMO);
5894 UseMI.getIterator()),
5896 return I.modifiesRegister(AArch64::NZCV, TRI) ||
5897 I.readsRegister(AArch64::NZCV, TRI);
5906 assert(
Offset.getScalable() % 2 == 0 &&
"Invalid frame offset");
5913 ByteSized =
Offset.getFixed();
5914 VGSized =
Offset.getScalable() / 2;
5922 int64_t &NumDataVectors) {
5926 assert(
Offset.getScalable() % 2 == 0 &&
"Invalid frame offset");
5928 NumBytes =
Offset.getFixed();
5930 NumPredicateVectors =
Offset.getScalable() / 2;
5935 if (NumPredicateVectors % 8 == 0 || NumPredicateVectors < -64 ||
5936 NumPredicateVectors > 62) {
5937 NumDataVectors = NumPredicateVectors / 8;
5938 NumPredicateVectors -= NumDataVectors * 8;
5957 appendLEB128<LEB128Sign::Signed>(Expr,
Constant);
5964 Expr.
push_back((
char)dwarf::DW_OP_bregx);
5965 appendLEB128<LEB128Sign::Unsigned>(Expr, RegNum);
5972 int64_t OffsetFromDefCFA) {
5986 Comment << (NumBytes < 0 ?
" - " :
" + ") << std::abs(NumBytes);
5987 if (!RegScale.empty())
5997 int64_t NumBytes, NumVGScaledBytes;
6000 std::string CommentBuffer;
6003 if (Reg == AArch64::SP)
6005 else if (Reg == AArch64::FP)
6012 unsigned DwarfReg =
TRI.getDwarfRegNum(Reg,
true);
6013 assert(DwarfReg <= 31 &&
"DwarfReg out of bounds (0..31)");
6015 Expr.
push_back(dwarf::DW_OP_breg0 + DwarfReg);
6016 appendLEB128<LEB128Sign::Signed>(Expr, NumBytes);
6018 if (NumVGScaledBytes) {
6028 DefCfaExpr.
push_back(dwarf::DW_CFA_def_cfa_expression);
6029 appendLEB128<LEB128Sign::Unsigned>(DefCfaExpr, Expr.
size());
6036 unsigned FrameReg,
unsigned Reg,
6038 bool LastAdjustmentWasScalable) {
6039 if (
Offset.getScalable())
6042 if (FrameReg == Reg && !LastAdjustmentWasScalable)
6045 unsigned DwarfReg =
TRI.getDwarfRegNum(Reg,
true);
6052 std::optional<int64_t> IncomingVGOffsetFromDefCFA) {
6053 int64_t NumBytes, NumVGScaledBytes;
6055 OffsetFromDefCFA, NumBytes, NumVGScaledBytes);
6057 unsigned DwarfReg =
TRI.getDwarfRegNum(Reg,
true);
6060 if (!NumVGScaledBytes)
6063 std::string CommentBuffer;
6068 assert(NumVGScaledBytes &&
"Expected scalable offset");
6072 if (IncomingVGOffsetFromDefCFA) {
6074 VGRegScale =
"* IncomingVG";
6077 VGRegScale =
"* VG";
6081 OffsetExpr.
push_back(dwarf::DW_OP_plus);
6090 CfaExpr.
push_back(dwarf::DW_CFA_expression);
6091 appendLEB128<LEB128Sign::Unsigned>(CfaExpr, DwarfReg);
6092 appendLEB128<LEB128Sign::Unsigned>(CfaExpr, OffsetExpr.
size());
6105 unsigned SrcReg, int64_t
Offset,
unsigned Opc,
6108 bool *HasWinCFI,
bool EmitCFAOffset,
6111 unsigned MaxEncoding, ShiftSize;
6113 case AArch64::ADDXri:
6114 case AArch64::ADDSXri:
6115 case AArch64::SUBXri:
6116 case AArch64::SUBSXri:
6117 MaxEncoding = 0xfff;
6120 case AArch64::ADDVL_XXI:
6121 case AArch64::ADDPL_XXI:
6122 case AArch64::ADDSVL_XXI:
6123 case AArch64::ADDSPL_XXI:
6138 if (
Opc == AArch64::ADDVL_XXI ||
Opc == AArch64::ADDSVL_XXI)
6140 else if (
Opc == AArch64::ADDPL_XXI ||
Opc == AArch64::ADDSPL_XXI)
6154 const unsigned MaxEncodableValue = MaxEncoding << ShiftSize;
6156 if (TmpReg == AArch64::XZR)
6158 &AArch64::GPR64RegClass);
6160 uint64_t ThisVal = std::min<uint64_t>(
Offset, MaxEncodableValue);
6161 unsigned LocalShiftSize = 0;
6162 if (ThisVal > MaxEncoding) {
6163 ThisVal = ThisVal >> ShiftSize;
6164 LocalShiftSize = ShiftSize;
6166 assert((ThisVal >> ShiftSize) <= MaxEncoding &&
6167 "Encoding cannot handle value that big");
6169 Offset -= ThisVal << LocalShiftSize;
6174 .
addImm(Sign * (
int)ThisVal);
6184 if (Sign == -1 ||
Opc == AArch64::SUBXri ||
Opc == AArch64::SUBSXri)
6185 CFAOffset += Change;
6187 CFAOffset -= Change;
6188 if (EmitCFAOffset && DestReg == TmpReg) {
6201 int Imm = (int)(ThisVal << LocalShiftSize);
6202 if (VScale != 1 && DestReg == AArch64::SP) {
6208 }
else if ((DestReg == AArch64::FP && SrcReg == AArch64::SP) ||
6209 (SrcReg == AArch64::FP && DestReg == AArch64::SP)) {
6210 assert(VScale == 1 &&
"Expected non-scalable operation");
6219 assert(
Offset == 0 &&
"Expected remaining offset to be zero to "
6220 "emit a single SEH directive");
6221 }
else if (DestReg == AArch64::SP) {
6222 assert(VScale == 1 &&
"Expected non-scalable operation");
6225 assert(SrcReg == AArch64::SP &&
"Unexpected SrcReg for SEH_StackAlloc");
6238 unsigned DestReg,
unsigned SrcReg,
6241 bool NeedsWinCFI,
bool *HasWinCFI,
6243 unsigned FrameReg) {
6250 bool UseSVL =
F.hasFnAttribute(
"aarch64_pstate_sm_body");
6252 int64_t Bytes, NumPredicateVectors, NumDataVectors;
6254 Offset, Bytes, NumPredicateVectors, NumDataVectors);
6257 if (Bytes || (!
Offset && SrcReg != DestReg)) {
6258 assert((DestReg != AArch64::SP || Bytes % 8 == 0) &&
6259 "SP increment/decrement not 8-byte aligned");
6260 unsigned Opc = SetNZCV ? AArch64::ADDSXri : AArch64::ADDXri;
6263 Opc = SetNZCV ? AArch64::SUBSXri : AArch64::SUBXri;
6266 NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
6268 CFAOffset += (
Opc == AArch64::ADDXri ||
Opc == AArch64::ADDSXri)
6275 assert(!(SetNZCV && (NumPredicateVectors || NumDataVectors)) &&
6276 "SetNZCV not supported with SVE vectors");
6277 assert(!(NeedsWinCFI && NumPredicateVectors) &&
6278 "WinCFI can't allocate fractions of an SVE data vector");
6280 if (NumDataVectors) {
6282 UseSVL ? AArch64::ADDSVL_XXI : AArch64::ADDVL_XXI,
TII,
6283 Flag, NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
6289 if (NumPredicateVectors) {
6290 assert(DestReg != AArch64::SP &&
"Unaligned access to SP");
6292 UseSVL ? AArch64::ADDSPL_XXI : AArch64::ADDPL_XXI,
TII,
6293 Flag, NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
6312 if (
MI.isFullCopy()) {
6315 if (SrcReg == AArch64::SP && DstReg.
isVirtual()) {
6319 if (DstReg == AArch64::SP && SrcReg.
isVirtual()) {
6324 if (SrcReg == AArch64::NZCV || DstReg == AArch64::NZCV)
6352 if (
MI.isCopy() && Ops.
size() == 1 &&
6354 (Ops[0] == 0 || Ops[0] == 1)) {
6355 bool IsSpill = Ops[0] == 0;
6356 bool IsFill = !IsSpill;
6368 :
TRI.getMinimalPhysRegClass(Reg);
6374 "Mismatched register size in non subreg COPY");
6381 return &*--InsertPt;
6393 if (IsSpill && DstMO.
isUndef() && SrcReg == AArch64::WZR &&
6396 "Unexpected subreg on physical register");
6398 FrameIndex, &AArch64::GPR64RegClass, &
TRI,
6400 return &*--InsertPt;
6417 case AArch64::sub_32:
6418 if (AArch64::GPR64RegClass.hasSubClassEq(
getRegClass(DstReg)))
6419 FillRC = &AArch64::GPR32RegClass;
6422 FillRC = &AArch64::FPR32RegClass;
6425 FillRC = &AArch64::FPR64RegClass;
6431 TRI.getRegSizeInBits(*FillRC) &&
6432 "Mismatched regclass size on folded subreg COPY");
6451 bool *OutUseUnscaledOp,
6452 unsigned *OutUnscaledOp,
6453 int64_t *EmittableOffset) {
6455 if (EmittableOffset)
6456 *EmittableOffset = 0;
6457 if (OutUseUnscaledOp)
6458 *OutUseUnscaledOp =
false;
6464 switch (
MI.getOpcode()) {
6467 case AArch64::LD1Rv1d:
6468 case AArch64::LD1Rv2s:
6469 case AArch64::LD1Rv2d:
6470 case AArch64::LD1Rv4h:
6471 case AArch64::LD1Rv4s:
6472 case AArch64::LD1Rv8b:
6473 case AArch64::LD1Rv8h:
6474 case AArch64::LD1Rv16b:
6475 case AArch64::LD1Twov2d:
6476 case AArch64::LD1Threev2d:
6477 case AArch64::LD1Fourv2d:
6478 case AArch64::LD1Twov1d:
6479 case AArch64::LD1Threev1d:
6480 case AArch64::LD1Fourv1d:
6481 case AArch64::ST1Twov2d:
6482 case AArch64::ST1Threev2d:
6483 case AArch64::ST1Fourv2d:
6484 case AArch64::ST1Twov1d:
6485 case AArch64::ST1Threev1d:
6486 case AArch64::ST1Fourv1d:
6487 case AArch64::ST1i8:
6488 case AArch64::ST1i16:
6489 case AArch64::ST1i32:
6490 case AArch64::ST1i64:
6492 case AArch64::IRGstack:
6493 case AArch64::STGloop:
6494 case AArch64::STZGloop:
6499 TypeSize ScaleValue(0U,
false), Width(0U,
false);
6500 int64_t MinOff, MaxOff;
6506 bool IsMulVL = ScaleValue.isScalable();
6507 unsigned Scale = ScaleValue.getKnownMinValue();
6517 std::optional<unsigned> UnscaledOp =
6519 bool useUnscaledOp = UnscaledOp && (
Offset % Scale ||
Offset < 0);
6520 if (useUnscaledOp &&
6525 Scale = ScaleValue.getKnownMinValue();
6526 assert(IsMulVL == ScaleValue.isScalable() &&
6527 "Unscaled opcode has different value for scalable");
6529 int64_t Remainder =
Offset % Scale;
6530 assert(!(Remainder && useUnscaledOp) &&
6531 "Cannot have remainder when using unscaled op");
6533 assert(MinOff < MaxOff &&
"Unexpected Min/Max offsets");
6534 int64_t NewOffset =
Offset / Scale;
6535 if (MinOff <= NewOffset && NewOffset <= MaxOff)
6538 NewOffset = NewOffset < 0 ? MinOff : MaxOff;
6542 if (EmittableOffset)
6543 *EmittableOffset = NewOffset;
6544 if (OutUseUnscaledOp)
6545 *OutUseUnscaledOp = useUnscaledOp;
6546 if (OutUnscaledOp && UnscaledOp)
6547 *OutUnscaledOp = *UnscaledOp;
6560 unsigned Opcode =
MI.getOpcode();
6561 unsigned ImmIdx = FrameRegIdx + 1;
6563 if (Opcode == AArch64::ADDSXri || Opcode == AArch64::ADDXri) {
6568 MI.eraseFromParent();
6574 unsigned UnscaledOp;
6577 &UnscaledOp, &NewOffset);
6581 MI.getOperand(FrameRegIdx).ChangeToRegister(FrameReg,
false);
6583 MI.setDesc(
TII->get(UnscaledOp));
6585 MI.getOperand(ImmIdx).ChangeToImmediate(NewOffset);
6608 case AArch64::ADDSWrr:
6609 case AArch64::ADDSWri:
6610 case AArch64::ADDSXrr:
6611 case AArch64::ADDSXri:
6612 case AArch64::SUBSWrr:
6613 case AArch64::SUBSXrr:
6615 case AArch64::SUBSWri:
6616 case AArch64::SUBSXri:
6627 case AArch64::ADDWrr:
6628 case AArch64::ADDWri:
6629 case AArch64::SUBWrr:
6630 case AArch64::ADDSWrr:
6631 case AArch64::ADDSWri:
6632 case AArch64::SUBSWrr:
6634 case AArch64::SUBWri:
6635 case AArch64::SUBSWri:
6646 case AArch64::ADDXrr:
6647 case AArch64::ADDXri:
6648 case AArch64::SUBXrr:
6649 case AArch64::ADDSXrr:
6650 case AArch64::ADDSXri:
6651 case AArch64::SUBSXrr:
6653 case AArch64::SUBXri:
6654 case AArch64::SUBSXri:
6655 case AArch64::ADDv8i8:
6656 case AArch64::ADDv16i8:
6657 case AArch64::ADDv4i16:
6658 case AArch64::ADDv8i16:
6659 case AArch64::ADDv2i32:
6660 case AArch64::ADDv4i32:
6661 case AArch64::SUBv8i8:
6662 case AArch64::SUBv16i8:
6663 case AArch64::SUBv4i16:
6664 case AArch64::SUBv8i16:
6665 case AArch64::SUBv2i32:
6666 case AArch64::SUBv4i32:
6679 case AArch64::FADDHrr:
6680 case AArch64::FADDSrr:
6681 case AArch64::FADDDrr:
6682 case AArch64::FADDv4f16:
6683 case AArch64::FADDv8f16:
6684 case AArch64::FADDv2f32:
6685 case AArch64::FADDv2f64:
6686 case AArch64::FADDv4f32:
6687 case AArch64::FSUBHrr:
6688 case AArch64::FSUBSrr:
6689 case AArch64::FSUBDrr:
6690 case AArch64::FSUBv4f16:
6691 case AArch64::FSUBv8f16:
6692 case AArch64::FSUBv2f32:
6693 case AArch64::FSUBv2f64:
6694 case AArch64::FSUBv4f32:
6713 unsigned CombineOpc,
unsigned ZeroReg = 0,
6714 bool CheckZeroReg =
false) {
6721 if (!
MI ||
MI->getParent() != &
MBB || (
unsigned)
MI->getOpcode() != CombineOpc)
6724 if (!
MRI.hasOneNonDBGUse(
MI->getOperand(0).getReg()))
6728 assert(
MI->getNumOperands() >= 4 &&
MI->getOperand(0).isReg() &&
6729 MI->getOperand(1).isReg() &&
MI->getOperand(2).isReg() &&
6730 MI->getOperand(3).isReg() &&
"MAdd/MSub must have a least 4 regs");
6732 if (
MI->getOperand(3).getReg() != ZeroReg)
6737 MI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
true) == -1)
6746 unsigned MulOpc,
unsigned ZeroReg) {
6762 bool Invert)
const {
6768 case AArch64::FADDHrr:
6769 case AArch64::FADDSrr:
6770 case AArch64::FADDDrr:
6771 case AArch64::FMULHrr:
6772 case AArch64::FMULSrr:
6773 case AArch64::FMULDrr:
6774 case AArch64::FMULX16:
6775 case AArch64::FMULX32:
6776 case AArch64::FMULX64:
6778 case AArch64::FADDv4f16:
6779 case AArch64::FADDv8f16:
6780 case AArch64::FADDv2f32:
6781 case AArch64::FADDv4f32:
6782 case AArch64::FADDv2f64:
6783 case AArch64::FMULv4f16:
6784 case AArch64::FMULv8f16:
6785 case AArch64::FMULv2f32:
6786 case AArch64::FMULv4f32:
6787 case AArch64::FMULv2f64:
6788 case AArch64::FMULXv4f16:
6789 case AArch64::FMULXv8f16:
6790 case AArch64::FMULXv2f32:
6791 case AArch64::FMULXv4f32:
6792 case AArch64::FMULXv2f64:
6796 case AArch64::FADD_ZZZ_H:
6797 case AArch64::FADD_ZZZ_S:
6798 case AArch64::FADD_ZZZ_D:
6799 case AArch64::FMUL_ZZZ_H:
6800 case AArch64::FMUL_ZZZ_S:
6801 case AArch64::FMUL_ZZZ_D:
6812 case AArch64::ADDWrr:
6813 case AArch64::ADDXrr:
6814 case AArch64::ANDWrr:
6815 case AArch64::ANDXrr:
6816 case AArch64::ORRWrr:
6817 case AArch64::ORRXrr:
6818 case AArch64::EORWrr:
6819 case AArch64::EORXrr:
6820 case AArch64::EONWrr:
6821 case AArch64::EONXrr:
6825 case AArch64::ADDv8i8:
6826 case AArch64::ADDv16i8:
6827 case AArch64::ADDv4i16:
6828 case AArch64::ADDv8i16:
6829 case AArch64::ADDv2i32:
6830 case AArch64::ADDv4i32:
6831 case AArch64::ADDv1i64:
6832 case AArch64::ADDv2i64:
6833 case AArch64::MULv8i8:
6834 case AArch64::MULv16i8:
6835 case AArch64::MULv4i16:
6836 case AArch64::MULv8i16:
6837 case AArch64::MULv2i32:
6838 case AArch64::MULv4i32:
6839 case AArch64::ANDv8i8:
6840 case AArch64::ANDv16i8:
6841 case AArch64::ORRv8i8:
6842 case AArch64::ORRv16i8:
6843 case AArch64::EORv8i8:
6844 case AArch64::EORv16i8:
6846 case AArch64::ADD_ZZZ_B:
6847 case AArch64::ADD_ZZZ_H:
6848 case AArch64::ADD_ZZZ_S:
6849 case AArch64::ADD_ZZZ_D:
6850 case AArch64::MUL_ZZZ_B:
6851 case AArch64::MUL_ZZZ_H:
6852 case AArch64::MUL_ZZZ_S:
6853 case AArch64::MUL_ZZZ_D:
6854 case AArch64::AND_ZZZ:
6855 case AArch64::ORR_ZZZ:
6856 case AArch64::EOR_ZZZ:
6887 auto setFound = [&](
int Opcode,
int Operand,
unsigned ZeroReg,
6895 auto setVFound = [&](
int Opcode,
int Operand,
unsigned Pattern) {
6907 case AArch64::ADDWrr:
6909 "ADDWrr does not have register operands");
6910 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULADDW_OP1);
6911 setFound(AArch64::MADDWrrr, 2, AArch64::WZR, MCP::MULADDW_OP2);
6913 case AArch64::ADDXrr:
6914 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULADDX_OP1);
6915 setFound(AArch64::MADDXrrr, 2, AArch64::XZR, MCP::MULADDX_OP2);
6917 case AArch64::SUBWrr:
6918 setFound(AArch64::MADDWrrr, 2, AArch64::WZR, MCP::MULSUBW_OP2);
6919 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULSUBW_OP1);
6921 case AArch64::SUBXrr:
6922 setFound(AArch64::MADDXrrr, 2, AArch64::XZR, MCP::MULSUBX_OP2);
6923 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULSUBX_OP1);
6925 case AArch64::ADDWri:
6926 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULADDWI_OP1);
6928 case AArch64::ADDXri:
6929 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULADDXI_OP1);
6931 case AArch64::SUBWri:
6932 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULSUBWI_OP1);
6934 case AArch64::SUBXri:
6935 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULSUBXI_OP1);
6937 case AArch64::ADDv8i8:
6938 setVFound(AArch64::MULv8i8, 1, MCP::MULADDv8i8_OP1);
6939 setVFound(AArch64::MULv8i8, 2, MCP::MULADDv8i8_OP2);
6941 case AArch64::ADDv16i8:
6942 setVFound(AArch64::MULv16i8, 1, MCP::MULADDv16i8_OP1);
6943 setVFound(AArch64::MULv16i8, 2, MCP::MULADDv16i8_OP2);
6945 case AArch64::ADDv4i16:
6946 setVFound(AArch64::MULv4i16, 1, MCP::MULADDv4i16_OP1);
6947 setVFound(AArch64::MULv4i16, 2, MCP::MULADDv4i16_OP2);
6948 setVFound(AArch64::MULv4i16_indexed, 1, MCP::MULADDv4i16_indexed_OP1);
6949 setVFound(AArch64::MULv4i16_indexed, 2, MCP::MULADDv4i16_indexed_OP2);
6951 case AArch64::ADDv8i16:
6952 setVFound(AArch64::MULv8i16, 1, MCP::MULADDv8i16_OP1);
6953 setVFound(AArch64::MULv8i16, 2, MCP::MULADDv8i16_OP2);
6954 setVFound(AArch64::MULv8i16_indexed, 1, MCP::MULADDv8i16_indexed_OP1);
6955 setVFound(AArch64::MULv8i16_indexed, 2, MCP::MULADDv8i16_indexed_OP2);
6957 case AArch64::ADDv2i32:
6958 setVFound(AArch64::MULv2i32, 1, MCP::MULADDv2i32_OP1);
6959 setVFound(AArch64::MULv2i32, 2, MCP::MULADDv2i32_OP2);
6960 setVFound(AArch64::MULv2i32_indexed, 1, MCP::MULADDv2i32_indexed_OP1);
6961 setVFound(AArch64::MULv2i32_indexed, 2, MCP::MULADDv2i32_indexed_OP2);
6963 case AArch64::ADDv4i32:
6964 setVFound(AArch64::MULv4i32, 1, MCP::MULADDv4i32_OP1);
6965 setVFound(AArch64::MULv4i32, 2, MCP::MULADDv4i32_OP2);
6966 setVFound(AArch64::MULv4i32_indexed, 1, MCP::MULADDv4i32_indexed_OP1);
6967 setVFound(AArch64::MULv4i32_indexed, 2, MCP::MULADDv4i32_indexed_OP2);
6969 case AArch64::SUBv8i8:
6970 setVFound(AArch64::MULv8i8, 1, MCP::MULSUBv8i8_OP1);
6971 setVFound(AArch64::MULv8i8, 2, MCP::MULSUBv8i8_OP2);
6973 case AArch64::SUBv16i8:
6974 setVFound(AArch64::MULv16i8, 1, MCP::MULSUBv16i8_OP1);
6975 setVFound(AArch64::MULv16i8, 2, MCP::MULSUBv16i8_OP2);
6977 case AArch64::SUBv4i16:
6978 setVFound(AArch64::MULv4i16, 1, MCP::MULSUBv4i16_OP1);
6979 setVFound(AArch64::MULv4i16, 2, MCP::MULSUBv4i16_OP2);
6980 setVFound(AArch64::MULv4i16_indexed, 1, MCP::MULSUBv4i16_indexed_OP1);
6981 setVFound(AArch64::MULv4i16_indexed, 2, MCP::MULSUBv4i16_indexed_OP2);
6983 case AArch64::SUBv8i16:
6984 setVFound(AArch64::MULv8i16, 1, MCP::MULSUBv8i16_OP1);
6985 setVFound(AArch64::MULv8i16, 2, MCP::MULSUBv8i16_OP2);
6986 setVFound(AArch64::MULv8i16_indexed, 1, MCP::MULSUBv8i16_indexed_OP1);
6987 setVFound(AArch64::MULv8i16_indexed, 2, MCP::MULSUBv8i16_indexed_OP2);
6989 case AArch64::SUBv2i32:
6990 setVFound(AArch64::MULv2i32, 1, MCP::MULSUBv2i32_OP1);
6991 setVFound(AArch64::MULv2i32, 2, MCP::MULSUBv2i32_OP2);
6992 setVFound(AArch64::MULv2i32_indexed, 1, MCP::MULSUBv2i32_indexed_OP1);
6993 setVFound(AArch64::MULv2i32_indexed, 2, MCP::MULSUBv2i32_indexed_OP2);
6995 case AArch64::SUBv4i32:
6996 setVFound(AArch64::MULv4i32, 1, MCP::MULSUBv4i32_OP1);
6997 setVFound(AArch64::MULv4i32, 2, MCP::MULSUBv4i32_OP2);
6998 setVFound(AArch64::MULv4i32_indexed, 1, MCP::MULSUBv4i32_indexed_OP1);
6999 setVFound(AArch64::MULv4i32_indexed, 2, MCP::MULSUBv4i32_indexed_OP2);
7009 case AArch64::UABALB_ZZZ_D:
7010 case AArch64::UABALB_ZZZ_H:
7011 case AArch64::UABALB_ZZZ_S:
7012 case AArch64::UABALT_ZZZ_D:
7013 case AArch64::UABALT_ZZZ_H:
7014 case AArch64::UABALT_ZZZ_S:
7015 case AArch64::SABALB_ZZZ_D:
7016 case AArch64::SABALB_ZZZ_S:
7017 case AArch64::SABALB_ZZZ_H:
7018 case AArch64::SABALT_ZZZ_D:
7019 case AArch64::SABALT_ZZZ_S:
7020 case AArch64::SABALT_ZZZ_H:
7021 case AArch64::UABALv16i8_v8i16:
7022 case AArch64::UABALv2i32_v2i64:
7023 case AArch64::UABALv4i16_v4i32:
7024 case AArch64::UABALv4i32_v2i64:
7025 case AArch64::UABALv8i16_v4i32:
7026 case AArch64::UABALv8i8_v8i16:
7027 case AArch64::UABAv16i8:
7028 case AArch64::UABAv2i32:
7029 case AArch64::UABAv4i16:
7030 case AArch64::UABAv4i32:
7031 case AArch64::UABAv8i16:
7032 case AArch64::UABAv8i8:
7033 case AArch64::SABALv16i8_v8i16:
7034 case AArch64::SABALv2i32_v2i64:
7035 case AArch64::SABALv4i16_v4i32:
7036 case AArch64::SABALv4i32_v2i64:
7037 case AArch64::SABALv8i16_v4i32:
7038 case AArch64::SABALv8i8_v8i16:
7039 case AArch64::SABAv16i8:
7040 case AArch64::SABAv2i32:
7041 case AArch64::SABAv4i16:
7042 case AArch64::SABAv4i32:
7043 case AArch64::SABAv8i16:
7044 case AArch64::SABAv8i8:
7052 unsigned AccumulationOpcode)
const {
7053 switch (AccumulationOpcode) {
7056 case AArch64::UABALB_ZZZ_D:
7057 return AArch64::UABDLB_ZZZ_D;
7058 case AArch64::UABALB_ZZZ_H:
7059 return AArch64::UABDLB_ZZZ_H;
7060 case AArch64::UABALB_ZZZ_S:
7061 return AArch64::UABDLB_ZZZ_S;
7062 case AArch64::UABALT_ZZZ_D:
7063 return AArch64::UABDLT_ZZZ_D;
7064 case AArch64::UABALT_ZZZ_H:
7065 return AArch64::UABDLT_ZZZ_H;
7066 case AArch64::UABALT_ZZZ_S:
7067 return AArch64::UABDLT_ZZZ_S;
7068 case AArch64::UABALv16i8_v8i16:
7069 return AArch64::UABDLv16i8_v8i16;
7070 case AArch64::UABALv2i32_v2i64:
7071 return AArch64::UABDLv2i32_v2i64;
7072 case AArch64::UABALv4i16_v4i32:
7073 return AArch64::UABDLv4i16_v4i32;
7074 case AArch64::UABALv4i32_v2i64:
7075 return AArch64::UABDLv4i32_v2i64;
7076 case AArch64::UABALv8i16_v4i32:
7077 return AArch64::UABDLv8i16_v4i32;
7078 case AArch64::UABALv8i8_v8i16:
7079 return AArch64::UABDLv8i8_v8i16;
7080 case AArch64::UABAv16i8:
7081 return AArch64::UABDv16i8;
7082 case AArch64::UABAv2i32:
7083 return AArch64::UABDv2i32;
7084 case AArch64::UABAv4i16:
7085 return AArch64::UABDv4i16;
7086 case AArch64::UABAv4i32:
7087 return AArch64::UABDv4i32;
7088 case AArch64::UABAv8i16:
7089 return AArch64::UABDv8i16;
7090 case AArch64::UABAv8i8:
7091 return AArch64::UABDv8i8;
7092 case AArch64::SABALB_ZZZ_D:
7093 return AArch64::SABDLB_ZZZ_D;
7094 case AArch64::SABALB_ZZZ_S:
7095 return AArch64::SABDLB_ZZZ_S;
7096 case AArch64::SABALB_ZZZ_H:
7097 return AArch64::SABDLB_ZZZ_H;
7098 case AArch64::SABALT_ZZZ_D:
7099 return AArch64::SABDLT_ZZZ_D;
7100 case AArch64::SABALT_ZZZ_S:
7101 return AArch64::SABDLT_ZZZ_S;
7102 case AArch64::SABALT_ZZZ_H:
7103 return AArch64::SABDLT_ZZZ_H;
7104 case AArch64::SABALv16i8_v8i16:
7105 return AArch64::SABDLv16i8_v8i16;
7106 case AArch64::SABALv2i32_v2i64:
7107 return AArch64::SABDLv2i32_v2i64;
7108 case AArch64::SABALv4i16_v4i32:
7109 return AArch64::SABDLv4i16_v4i32;
7110 case AArch64::SABALv4i32_v2i64:
7111 return AArch64::SABDLv4i32_v2i64;
7112 case AArch64::SABALv8i16_v4i32:
7113 return AArch64::SABDLv8i16_v4i32;
7114 case AArch64::SABALv8i8_v8i16:
7115 return AArch64::SABDLv8i8_v8i16;
7116 case AArch64::SABAv16i8:
7117 return AArch64::SABDv16i8;
7118 case AArch64::SABAv2i32:
7119 return AArch64::SABAv2i32;
7120 case AArch64::SABAv4i16:
7121 return AArch64::SABDv4i16;
7122 case AArch64::SABAv4i32:
7123 return AArch64::SABDv4i32;
7124 case AArch64::SABAv8i16:
7125 return AArch64::SABDv8i16;
7126 case AArch64::SABAv8i8:
7127 return AArch64::SABDv8i8;
7143 auto Match = [&](
int Opcode,
int Operand,
unsigned Pattern) ->
bool {
7155 assert(
false &&
"Unsupported FP instruction in combiner\n");
7157 case AArch64::FADDHrr:
7159 "FADDHrr does not have register operands");
7161 Found = Match(AArch64::FMULHrr, 1, MCP::FMULADDH_OP1);
7162 Found |= Match(AArch64::FMULHrr, 2, MCP::FMULADDH_OP2);
7164 case AArch64::FADDSrr:
7166 "FADDSrr does not have register operands");
7168 Found |= Match(AArch64::FMULSrr, 1, MCP::FMULADDS_OP1) ||
7169 Match(AArch64::FMULv1i32_indexed, 1, MCP::FMLAv1i32_indexed_OP1);
7171 Found |= Match(AArch64::FMULSrr, 2, MCP::FMULADDS_OP2) ||
7172 Match(AArch64::FMULv1i32_indexed, 2, MCP::FMLAv1i32_indexed_OP2);
7174 case AArch64::FADDDrr:
7175 Found |= Match(AArch64::FMULDrr, 1, MCP::FMULADDD_OP1) ||
7176 Match(AArch64::FMULv1i64_indexed, 1, MCP::FMLAv1i64_indexed_OP1);
7178 Found |= Match(AArch64::FMULDrr, 2, MCP::FMULADDD_OP2) ||
7179 Match(AArch64::FMULv1i64_indexed, 2, MCP::FMLAv1i64_indexed_OP2);
7181 case AArch64::FADDv4f16:
7182 Found |= Match(AArch64::FMULv4i16_indexed, 1, MCP::FMLAv4i16_indexed_OP1) ||
7183 Match(AArch64::FMULv4f16, 1, MCP::FMLAv4f16_OP1);
7185 Found |= Match(AArch64::FMULv4i16_indexed, 2, MCP::FMLAv4i16_indexed_OP2) ||
7186 Match(AArch64::FMULv4f16, 2, MCP::FMLAv4f16_OP2);
7188 case AArch64::FADDv8f16:
7189 Found |= Match(AArch64::FMULv8i16_indexed, 1, MCP::FMLAv8i16_indexed_OP1) ||
7190 Match(AArch64::FMULv8f16, 1, MCP::FMLAv8f16_OP1);
7192 Found |= Match(AArch64::FMULv8i16_indexed, 2, MCP::FMLAv8i16_indexed_OP2) ||
7193 Match(AArch64::FMULv8f16, 2, MCP::FMLAv8f16_OP2);
7195 case AArch64::FADDv2f32:
7196 Found |= Match(AArch64::FMULv2i32_indexed, 1, MCP::FMLAv2i32_indexed_OP1) ||
7197 Match(AArch64::FMULv2f32, 1, MCP::FMLAv2f32_OP1);
7199 Found |= Match(AArch64::FMULv2i32_indexed, 2, MCP::FMLAv2i32_indexed_OP2) ||
7200 Match(AArch64::FMULv2f32, 2, MCP::FMLAv2f32_OP2);
7202 case AArch64::FADDv2f64:
7203 Found |= Match(AArch64::FMULv2i64_indexed, 1, MCP::FMLAv2i64_indexed_OP1) ||
7204 Match(AArch64::FMULv2f64, 1, MCP::FMLAv2f64_OP1);
7206 Found |= Match(AArch64::FMULv2i64_indexed, 2, MCP::FMLAv2i64_indexed_OP2) ||
7207 Match(AArch64::FMULv2f64, 2, MCP::FMLAv2f64_OP2);
7209 case AArch64::FADDv4f32:
7210 Found |= Match(AArch64::FMULv4i32_indexed, 1, MCP::FMLAv4i32_indexed_OP1) ||
7211 Match(AArch64::FMULv4f32, 1, MCP::FMLAv4f32_OP1);
7213 Found |= Match(AArch64::FMULv4i32_indexed, 2, MCP::FMLAv4i32_indexed_OP2) ||
7214 Match(AArch64::FMULv4f32, 2, MCP::FMLAv4f32_OP2);
7216 case AArch64::FSUBHrr:
7217 Found = Match(AArch64::FMULHrr, 1, MCP::FMULSUBH_OP1);
7218 Found |= Match(AArch64::FMULHrr, 2, MCP::FMULSUBH_OP2);
7219 Found |= Match(AArch64::FNMULHrr, 1, MCP::FNMULSUBH_OP1);
7221 case AArch64::FSUBSrr:
7222 Found = Match(AArch64::FMULSrr, 1, MCP::FMULSUBS_OP1);
7224 Found |= Match(AArch64::FMULSrr, 2, MCP::FMULSUBS_OP2) ||
7225 Match(AArch64::FMULv1i32_indexed, 2, MCP::FMLSv1i32_indexed_OP2);
7227 Found |= Match(AArch64::FNMULSrr, 1, MCP::FNMULSUBS_OP1);
7229 case AArch64::FSUBDrr:
7230 Found = Match(AArch64::FMULDrr, 1, MCP::FMULSUBD_OP1);
7232 Found |= Match(AArch64::FMULDrr, 2, MCP::FMULSUBD_OP2) ||
7233 Match(AArch64::FMULv1i64_indexed, 2, MCP::FMLSv1i64_indexed_OP2);
7235 Found |= Match(AArch64::FNMULDrr, 1, MCP::FNMULSUBD_OP1);
7237 case AArch64::FSUBv4f16:
7238 Found |= Match(AArch64::FMULv4i16_indexed, 2, MCP::FMLSv4i16_indexed_OP2) ||
7239 Match(AArch64::FMULv4f16, 2, MCP::FMLSv4f16_OP2);
7241 Found |= Match(AArch64::FMULv4i16_indexed, 1, MCP::FMLSv4i16_indexed_OP1) ||
7242 Match(AArch64::FMULv4f16, 1, MCP::FMLSv4f16_OP1);
7244 case AArch64::FSUBv8f16:
7245 Found |= Match(AArch64::FMULv8i16_indexed, 2, MCP::FMLSv8i16_indexed_OP2) ||
7246 Match(AArch64::FMULv8f16, 2, MCP::FMLSv8f16_OP2);
7248 Found |= Match(AArch64::FMULv8i16_indexed, 1, MCP::FMLSv8i16_indexed_OP1) ||
7249 Match(AArch64::FMULv8f16, 1, MCP::FMLSv8f16_OP1);
7251 case AArch64::FSUBv2f32:
7252 Found |= Match(AArch64::FMULv2i32_indexed, 2, MCP::FMLSv2i32_indexed_OP2) ||
7253 Match(AArch64::FMULv2f32, 2, MCP::FMLSv2f32_OP2);
7255 Found |= Match(AArch64::FMULv2i32_indexed, 1, MCP::FMLSv2i32_indexed_OP1) ||
7256 Match(AArch64::FMULv2f32, 1, MCP::FMLSv2f32_OP1);
7258 case AArch64::FSUBv2f64:
7259 Found |= Match(AArch64::FMULv2i64_indexed, 2, MCP::FMLSv2i64_indexed_OP2) ||
7260 Match(AArch64::FMULv2f64, 2, MCP::FMLSv2f64_OP2);
7262 Found |= Match(AArch64::FMULv2i64_indexed, 1, MCP::FMLSv2i64_indexed_OP1) ||
7263 Match(AArch64::FMULv2f64, 1, MCP::FMLSv2f64_OP1);
7265 case AArch64::FSUBv4f32:
7266 Found |= Match(AArch64::FMULv4i32_indexed, 2, MCP::FMLSv4i32_indexed_OP2) ||
7267 Match(AArch64::FMULv4f32, 2, MCP::FMLSv4f32_OP2);
7269 Found |= Match(AArch64::FMULv4i32_indexed, 1, MCP::FMLSv4i32_indexed_OP1) ||
7270 Match(AArch64::FMULv4f32, 1, MCP::FMLSv4f32_OP1);
7281 auto Match = [&](
unsigned Opcode,
int Operand,
unsigned Pattern) ->
bool {
7288 if (
MI &&
MI->getOpcode() == TargetOpcode::COPY &&
7289 MI->getOperand(1).getReg().isVirtual())
7290 MI =
MRI.getUniqueVRegDef(
MI->getOperand(1).getReg());
7291 if (
MI &&
MI->getOpcode() == Opcode) {
7303 case AArch64::FMULv2f32:
7304 Found = Match(AArch64::DUPv2i32lane, 1, MCP::FMULv2i32_indexed_OP1);
7305 Found |= Match(AArch64::DUPv2i32lane, 2, MCP::FMULv2i32_indexed_OP2);
7307 case AArch64::FMULv2f64:
7308 Found = Match(AArch64::DUPv2i64lane, 1, MCP::FMULv2i64_indexed_OP1);
7309 Found |= Match(AArch64::DUPv2i64lane, 2, MCP::FMULv2i64_indexed_OP2);
7311 case AArch64::FMULv4f16:
7312 Found = Match(AArch64::DUPv4i16lane, 1, MCP::FMULv4i16_indexed_OP1);
7313 Found |= Match(AArch64::DUPv4i16lane, 2, MCP::FMULv4i16_indexed_OP2);
7315 case AArch64::FMULv4f32:
7316 Found = Match(AArch64::DUPv4i32lane, 1, MCP::FMULv4i32_indexed_OP1);
7317 Found |= Match(AArch64::DUPv4i32lane, 2, MCP::FMULv4i32_indexed_OP2);
7319 case AArch64::FMULv8f16:
7320 Found = Match(AArch64::DUPv8i16lane, 1, MCP::FMULv8i16_indexed_OP1);
7321 Found |= Match(AArch64::DUPv8i16lane, 2, MCP::FMULv8i16_indexed_OP2);
7334 auto Match = [&](
unsigned Opcode,
unsigned Pattern) ->
bool {
7337 if (
MI !=
nullptr && (
MI->getOpcode() == Opcode) &&
7338 MRI.hasOneNonDBGUse(
MI->getOperand(0).getReg()) &&
7352 case AArch64::FNEGDr:
7354 case AArch64::FNEGSr:
7486 case AArch64::SUBWrr:
7487 case AArch64::SUBSWrr:
7488 case AArch64::SUBXrr:
7489 case AArch64::SUBSXrr:
7534 unsigned LoadLaneOpCode,
unsigned NumLanes) {
7554 auto Range = llvm::seq<unsigned>(1, NumLanes - 1);
7557 while (!RemainingLanes.
empty() && CurrInstr &&
7558 CurrInstr->getOpcode() == LoadLaneOpCode &&
7559 MRI.hasOneNonDBGUse(CurrInstr->getOperand(0).getReg()) &&
7560 CurrInstr->getNumOperands() == 4) {
7561 RemainingLanes.
erase(CurrInstr->getOperand(2).getImm());
7563 CurrInstr =
MRI.getUniqueVRegDef(CurrInstr->getOperand(1).getReg());
7567 if (!RemainingLanes.
empty())
7571 if (CurrInstr->getOpcode() != TargetOpcode::SUBREG_TO_REG)
7575 auto Lane0LoadReg = CurrInstr->getOperand(2).getReg();
7576 unsigned SingleLaneSizeInBits = 128 / NumLanes;
7577 if (
TRI->getRegSizeInBits(Lane0LoadReg,
MRI) != SingleLaneSizeInBits)
7581 if (!
MRI.hasOneNonDBGUse(Lane0LoadReg))
7584 LoadInstrs.
push_back(
MRI.getUniqueVRegDef(Lane0LoadReg));
7593 RemainingLoadInstrs.
insert(LoadInstrs.
begin(), LoadInstrs.
end());
7596 for (; MBBItr !=
MBB->
begin() && RemainingSteps > 0 &&
7597 !RemainingLoadInstrs.
empty();
7598 --MBBItr, --RemainingSteps) {
7602 RemainingLoadInstrs.
erase(&CurrInstr);
7612 if (RemainingSteps == 0 && !RemainingLoadInstrs.
empty())
7638 case AArch64::LD1i32:
7640 case AArch64::LD1i16:
7642 case AArch64::LD1i8:
7658 unsigned Pattern,
unsigned NumLanes) {
7666 for (
unsigned i = 0; i < NumLanes - 1; ++i) {
7674 return A->getOperand(2).
getImm() >
B->getOperand(2).getImm();
7679 MRI.getUniqueVRegDef(SubregToReg->getOperand(2).getReg()));
7680 auto LoadToLaneInstrsAscending =
llvm::reverse(LoadToLaneInstrs);
7686 auto CreateLD1Instruction = [&](
MachineInstr *OriginalInstr,
7687 Register SrcRegister,
unsigned Lane,
7689 bool OffsetRegisterKillState) {
7690 auto NewRegister =
MRI.createVirtualRegister(FPR128RegClass);
7697 InstrIdxForVirtReg.
insert(std::make_pair(NewRegister, InsInstrs.
size()));
7698 InsInstrs.
push_back(LoadIndexIntoRegister);
7704 auto CreateLDRInstruction = [&](
unsigned NumLanes,
Register DestReg,
7710 Opcode = AArch64::LDRSui;
7713 Opcode = AArch64::LDRHui;
7716 Opcode = AArch64::LDRBui;
7720 "Got unsupported number of lanes in machine-combiner gather pattern");
7729 auto LanesToLoadToReg0 =
7731 LoadToLaneInstrsAscending.begin() + NumLanes / 2);
7732 Register PrevReg = SubregToReg->getOperand(0).getReg();
7734 const MachineOperand &OffsetRegOperand = LoadInstr->getOperand(3);
7735 PrevReg = CreateLD1Instruction(LoadInstr, PrevReg, Index + 1,
7736 OffsetRegOperand.
getReg(),
7737 OffsetRegOperand.
isKill());
7744 MachineInstr *Lane0Load = *LoadToLaneInstrsAscending.begin();
7746 *std::next(LoadToLaneInstrsAscending.begin(), NumLanes / 2);
7747 Register DestRegForMiddleIndex =
MRI.createVirtualRegister(
7753 CreateLDRInstruction(NumLanes, DestRegForMiddleIndex,
7754 OriginalSplitToLoadOffsetOperand.
getReg(),
7755 OriginalSplitToLoadOffsetOperand.
isKill());
7757 InstrIdxForVirtReg.
insert(
7758 std::make_pair(DestRegForMiddleIndex, InsInstrs.
size()));
7759 InsInstrs.
push_back(MiddleIndexLoadInstr);
7763 Register DestRegForSubregToReg =
MRI.createVirtualRegister(FPR128RegClass);
7764 unsigned SubregType;
7767 SubregType = AArch64::ssub;
7770 SubregType = AArch64::hsub;
7773 SubregType = AArch64::bsub;
7777 "Got invalid NumLanes for machine-combiner gather pattern");
7780 auto SubRegToRegInstr =
7782 DestRegForSubregToReg)
7786 InstrIdxForVirtReg.
insert(
7787 std::make_pair(DestRegForSubregToReg, InsInstrs.
size()));
7791 auto LanesToLoadToReg1 =
7793 LoadToLaneInstrsAscending.end());
7794 PrevReg = SubRegToRegInstr->getOperand(0).getReg();
7796 const MachineOperand &OffsetRegOperand = LoadInstr->getOperand(3);
7797 PrevReg = CreateLD1Instruction(LoadInstr, PrevReg, Index + 1,
7798 OffsetRegOperand.
getReg(),
7799 OffsetRegOperand.
isKill());
7802 if (Index == NumLanes / 2 - 2) {
7839 bool DoRegPressureReduce)
const {
7860 DoRegPressureReduce);
7889 const Register *ReplacedAddend =
nullptr) {
7890 assert(IdxMulOpd == 1 || IdxMulOpd == 2);
7892 unsigned IdxOtherOpd = IdxMulOpd == 1 ? 2 : 1;
7895 Register SrcReg0 = MUL->getOperand(1).getReg();
7896 bool Src0IsKill = MUL->getOperand(1).isKill();
7897 Register SrcReg1 = MUL->getOperand(2).getReg();
7898 bool Src1IsKill = MUL->getOperand(2).isKill();
7902 if (ReplacedAddend) {
7904 SrcReg2 = *ReplacedAddend;
7912 MRI.constrainRegClass(ResultReg, RC);
7914 MRI.constrainRegClass(SrcReg0, RC);
7916 MRI.constrainRegClass(SrcReg1, RC);
7918 MRI.constrainRegClass(SrcReg2, RC);
7921 if (kind == FMAInstKind::Default)
7926 else if (kind == FMAInstKind::Indexed)
7931 .
addImm(MUL->getOperand(3).getImm());
7932 else if (kind == FMAInstKind::Accumulator)
7938 assert(
false &&
"Invalid FMA instruction kind \n");
7952 if (AArch64::FPR32RegClass.hasSubClassEq(RC))
7953 Opc = AArch64::FNMADDSrrr;
7954 else if (AArch64::FPR64RegClass.hasSubClassEq(RC))
7955 Opc = AArch64::FNMADDDrrr;
7967 MRI.constrainRegClass(ResultReg, RC);
7969 MRI.constrainRegClass(SrcReg0, RC);
7971 MRI.constrainRegClass(SrcReg1, RC);
7973 MRI.constrainRegClass(SrcReg2, RC);
7989 unsigned IdxDupOp,
unsigned MulOpc,
7991 assert(((IdxDupOp == 1) || (IdxDupOp == 2)) &&
7992 "Invalid index of FMUL operand");
8000 if (Dup->
getOpcode() == TargetOpcode::COPY)
8004 MRI.clearKillFlags(DupSrcReg);
8005 MRI.constrainRegClass(DupSrcReg, RC);
8009 unsigned IdxMulOp = IdxDupOp == 1 ? 2 : 1;
8033 FMAInstKind::Accumulator);
8050 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
8065 genNeg(MF,
MRI,
TII, Root, InsInstrs, InstrIdxForVirtReg, MnegOpc, RC);
8067 FMAInstKind::Accumulator, &NewVR);
8079 FMAInstKind::Indexed);
8092 genNeg(MF,
MRI,
TII, Root, InsInstrs, InstrIdxForVirtReg, MnegOpc, RC);
8095 FMAInstKind::Indexed, &NewVR);
8120 unsigned IdxMulOpd,
unsigned MaddOpc,
unsigned VR,
8122 assert(IdxMulOpd == 1 || IdxMulOpd == 2);
8126 Register SrcReg0 = MUL->getOperand(1).getReg();
8127 bool Src0IsKill = MUL->getOperand(1).isKill();
8128 Register SrcReg1 = MUL->getOperand(2).getReg();
8129 bool Src1IsKill = MUL->getOperand(2).isKill();
8132 MRI.constrainRegClass(ResultReg, RC);
8134 MRI.constrainRegClass(SrcReg0, RC);
8136 MRI.constrainRegClass(SrcReg1, RC);
8138 MRI.constrainRegClass(VR, RC);
8159 assert(IdxOpd1 == 1 || IdxOpd1 == 2);
8160 unsigned IdxOtherOpd = IdxOpd1 == 1 ? 2 : 1;
8174 if (Opcode == AArch64::SUBSWrr)
8175 Opcode = AArch64::SUBWrr;
8176 else if (Opcode == AArch64::SUBSXrr)
8177 Opcode = AArch64::SUBXrr;
8179 assert((Opcode == AArch64::SUBWrr || Opcode == AArch64::SUBXrr) &&
8180 "Unexpected instruction opcode.");
8197 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
8205 unsigned int AccumulatorOpCode)
const {
8206 switch (AccumulatorOpCode) {
8207 case AArch64::UABALB_ZZZ_D:
8208 case AArch64::SABALB_ZZZ_D:
8209 case AArch64::UABALT_ZZZ_D:
8210 case AArch64::SABALT_ZZZ_D:
8211 return AArch64::ADD_ZZZ_D;
8212 case AArch64::UABALB_ZZZ_H:
8213 case AArch64::SABALB_ZZZ_H:
8214 case AArch64::UABALT_ZZZ_H:
8215 case AArch64::SABALT_ZZZ_H:
8216 return AArch64::ADD_ZZZ_H;
8217 case AArch64::UABALB_ZZZ_S:
8218 case AArch64::SABALB_ZZZ_S:
8219 case AArch64::UABALT_ZZZ_S:
8220 case AArch64::SABALT_ZZZ_S:
8221 return AArch64::ADD_ZZZ_S;
8222 case AArch64::UABALv16i8_v8i16:
8223 case AArch64::SABALv8i8_v8i16:
8224 case AArch64::SABAv8i16:
8225 case AArch64::UABAv8i16:
8226 return AArch64::ADDv8i16;
8227 case AArch64::SABALv2i32_v2i64:
8228 case AArch64::UABALv2i32_v2i64:
8229 case AArch64::SABALv4i32_v2i64:
8230 return AArch64::ADDv2i64;
8231 case AArch64::UABALv4i16_v4i32:
8232 case AArch64::SABALv4i16_v4i32:
8233 case AArch64::SABALv8i16_v4i32:
8234 case AArch64::SABAv4i32:
8235 case AArch64::UABAv4i32:
8236 return AArch64::ADDv4i32;
8237 case AArch64::UABALv4i32_v2i64:
8238 return AArch64::ADDv2i64;
8239 case AArch64::UABALv8i16_v4i32:
8240 return AArch64::ADDv4i32;
8241 case AArch64::UABALv8i8_v8i16:
8242 case AArch64::SABALv16i8_v8i16:
8243 return AArch64::ADDv8i16;
8244 case AArch64::UABAv16i8:
8245 case AArch64::SABAv16i8:
8246 return AArch64::ADDv16i8;
8247 case AArch64::UABAv4i16:
8248 case AArch64::SABAv4i16:
8249 return AArch64::ADDv4i16;
8250 case AArch64::UABAv2i32:
8251 case AArch64::SABAv2i32:
8252 return AArch64::ADDv2i32;
8253 case AArch64::UABAv8i8:
8254 case AArch64::SABAv8i8:
8255 return AArch64::ADDv8i8;
8281 DelInstrs, InstrIdxForVirtReg);
8287 InstrIdxForVirtReg);
8293 InstrIdxForVirtReg);
8302 Opc = AArch64::MADDWrrr;
8303 RC = &AArch64::GPR32RegClass;
8305 Opc = AArch64::MADDXrrr;
8306 RC = &AArch64::GPR64RegClass;
8317 Opc = AArch64::MADDWrrr;
8318 RC = &AArch64::GPR32RegClass;
8320 Opc = AArch64::MADDXrrr;
8321 RC = &AArch64::GPR64RegClass;
8335 unsigned BitSize, MovImm;
8338 MovImm = AArch64::MOVi32imm;
8339 RC = &AArch64::GPR32spRegClass;
8341 Opc = AArch64::MADDWrrr;
8342 RC = &AArch64::GPR32RegClass;
8344 MovImm = AArch64::MOVi64imm;
8345 RC = &AArch64::GPR64spRegClass;
8347 Opc = AArch64::MADDXrrr;
8348 RC = &AArch64::GPR64RegClass;
8363 if (Insn.
size() != 1)
8367 .
addImm(IsSub ? -Imm : Imm);
8369 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
8381 unsigned SubOpc, ZeroReg;
8383 SubOpc = AArch64::SUBWrr;
8384 SubRC = &AArch64::GPR32spRegClass;
8385 ZeroReg = AArch64::WZR;
8386 Opc = AArch64::MADDWrrr;
8387 RC = &AArch64::GPR32RegClass;
8389 SubOpc = AArch64::SUBXrr;
8390 SubRC = &AArch64::GPR64spRegClass;
8391 ZeroReg = AArch64::XZR;
8392 Opc = AArch64::MADDXrrr;
8393 RC = &AArch64::GPR64RegClass;
8395 Register NewVR =
MRI.createVirtualRegister(SubRC);
8402 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
8413 Opc = AArch64::MSUBWrrr;
8414 RC = &AArch64::GPR32RegClass;
8416 Opc = AArch64::MSUBXrrr;
8417 RC = &AArch64::GPR64RegClass;
8422 Opc = AArch64::MLAv8i8;
8423 RC = &AArch64::FPR64RegClass;
8427 Opc = AArch64::MLAv8i8;
8428 RC = &AArch64::FPR64RegClass;
8432 Opc = AArch64::MLAv16i8;
8433 RC = &AArch64::FPR128RegClass;
8437 Opc = AArch64::MLAv16i8;
8438 RC = &AArch64::FPR128RegClass;
8442 Opc = AArch64::MLAv4i16;
8443 RC = &AArch64::FPR64RegClass;
8447 Opc = AArch64::MLAv4i16;
8448 RC = &AArch64::FPR64RegClass;
8452 Opc = AArch64::MLAv8i16;
8453 RC = &AArch64::FPR128RegClass;
8457 Opc = AArch64::MLAv8i16;
8458 RC = &AArch64::FPR128RegClass;
8462 Opc = AArch64::MLAv2i32;
8463 RC = &AArch64::FPR64RegClass;
8467 Opc = AArch64::MLAv2i32;
8468 RC = &AArch64::FPR64RegClass;
8472 Opc = AArch64::MLAv4i32;
8473 RC = &AArch64::FPR128RegClass;
8477 Opc = AArch64::MLAv4i32;
8478 RC = &AArch64::FPR128RegClass;
8483 Opc = AArch64::MLAv8i8;
8484 RC = &AArch64::FPR64RegClass;
8486 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i8,
8490 Opc = AArch64::MLSv8i8;
8491 RC = &AArch64::FPR64RegClass;
8495 Opc = AArch64::MLAv16i8;
8496 RC = &AArch64::FPR128RegClass;
8498 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv16i8,
8502 Opc = AArch64::MLSv16i8;
8503 RC = &AArch64::FPR128RegClass;
8507 Opc = AArch64::MLAv4i16;
8508 RC = &AArch64::FPR64RegClass;
8510 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i16,
8514 Opc = AArch64::MLSv4i16;
8515 RC = &AArch64::FPR64RegClass;
8519 Opc = AArch64::MLAv8i16;
8520 RC = &AArch64::FPR128RegClass;
8522 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i16,
8526 Opc = AArch64::MLSv8i16;
8527 RC = &AArch64::FPR128RegClass;
8531 Opc = AArch64::MLAv2i32;
8532 RC = &AArch64::FPR64RegClass;
8534 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv2i32,
8538 Opc = AArch64::MLSv2i32;
8539 RC = &AArch64::FPR64RegClass;
8543 Opc = AArch64::MLAv4i32;
8544 RC = &AArch64::FPR128RegClass;
8546 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i32,
8550 Opc = AArch64::MLSv4i32;
8551 RC = &AArch64::FPR128RegClass;
8556 Opc = AArch64::MLAv4i16_indexed;
8557 RC = &AArch64::FPR64RegClass;
8561 Opc = AArch64::MLAv4i16_indexed;
8562 RC = &AArch64::FPR64RegClass;
8566 Opc = AArch64::MLAv8i16_indexed;
8567 RC = &AArch64::FPR128RegClass;
8571 Opc = AArch64::MLAv8i16_indexed;
8572 RC = &AArch64::FPR128RegClass;
8576 Opc = AArch64::MLAv2i32_indexed;
8577 RC = &AArch64::FPR64RegClass;
8581 Opc = AArch64::MLAv2i32_indexed;
8582 RC = &AArch64::FPR64RegClass;
8586 Opc = AArch64::MLAv4i32_indexed;
8587 RC = &AArch64::FPR128RegClass;
8591 Opc = AArch64::MLAv4i32_indexed;
8592 RC = &AArch64::FPR128RegClass;
8597 Opc = AArch64::MLAv4i16_indexed;
8598 RC = &AArch64::FPR64RegClass;
8600 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i16,
8604 Opc = AArch64::MLSv4i16_indexed;
8605 RC = &AArch64::FPR64RegClass;
8609 Opc = AArch64::MLAv8i16_indexed;
8610 RC = &AArch64::FPR128RegClass;
8612 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i16,
8616 Opc = AArch64::MLSv8i16_indexed;
8617 RC = &AArch64::FPR128RegClass;
8621 Opc = AArch64::MLAv2i32_indexed;
8622 RC = &AArch64::FPR64RegClass;
8624 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv2i32,
8628 Opc = AArch64::MLSv2i32_indexed;
8629 RC = &AArch64::FPR64RegClass;
8633 Opc = AArch64::MLAv4i32_indexed;
8634 RC = &AArch64::FPR128RegClass;
8636 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i32,
8640 Opc = AArch64::MLSv4i32_indexed;
8641 RC = &AArch64::FPR128RegClass;
8647 Opc = AArch64::FMADDHrrr;
8648 RC = &AArch64::FPR16RegClass;
8652 Opc = AArch64::FMADDSrrr;
8653 RC = &AArch64::FPR32RegClass;
8657 Opc = AArch64::FMADDDrrr;
8658 RC = &AArch64::FPR64RegClass;
8663 Opc = AArch64::FMADDHrrr;
8664 RC = &AArch64::FPR16RegClass;
8668 Opc = AArch64::FMADDSrrr;
8669 RC = &AArch64::FPR32RegClass;
8673 Opc = AArch64::FMADDDrrr;
8674 RC = &AArch64::FPR64RegClass;
8679 Opc = AArch64::FMLAv1i32_indexed;
8680 RC = &AArch64::FPR32RegClass;
8682 FMAInstKind::Indexed);
8685 Opc = AArch64::FMLAv1i32_indexed;
8686 RC = &AArch64::FPR32RegClass;
8688 FMAInstKind::Indexed);
8692 Opc = AArch64::FMLAv1i64_indexed;
8693 RC = &AArch64::FPR64RegClass;
8695 FMAInstKind::Indexed);
8698 Opc = AArch64::FMLAv1i64_indexed;
8699 RC = &AArch64::FPR64RegClass;
8701 FMAInstKind::Indexed);
8705 RC = &AArch64::FPR64RegClass;
8706 Opc = AArch64::FMLAv4i16_indexed;
8708 FMAInstKind::Indexed);
8711 RC = &AArch64::FPR64RegClass;
8712 Opc = AArch64::FMLAv4f16;
8714 FMAInstKind::Accumulator);
8717 RC = &AArch64::FPR64RegClass;
8718 Opc = AArch64::FMLAv4i16_indexed;
8720 FMAInstKind::Indexed);
8723 RC = &AArch64::FPR64RegClass;
8724 Opc = AArch64::FMLAv4f16;
8726 FMAInstKind::Accumulator);
8731 RC = &AArch64::FPR64RegClass;
8733 Opc = AArch64::FMLAv2i32_indexed;
8735 FMAInstKind::Indexed);
8737 Opc = AArch64::FMLAv2f32;
8739 FMAInstKind::Accumulator);
8744 RC = &AArch64::FPR64RegClass;
8746 Opc = AArch64::FMLAv2i32_indexed;
8748 FMAInstKind::Indexed);
8750 Opc = AArch64::FMLAv2f32;
8752 FMAInstKind::Accumulator);
8757 RC = &AArch64::FPR128RegClass;
8758 Opc = AArch64::FMLAv8i16_indexed;
8760 FMAInstKind::Indexed);
8763 RC = &AArch64::FPR128RegClass;
8764 Opc = AArch64::FMLAv8f16;
8766 FMAInstKind::Accumulator);
8769 RC = &AArch64::FPR128RegClass;
8770 Opc = AArch64::FMLAv8i16_indexed;
8772 FMAInstKind::Indexed);
8775 RC = &AArch64::FPR128RegClass;
8776 Opc = AArch64::FMLAv8f16;
8778 FMAInstKind::Accumulator);
8783 RC = &AArch64::FPR128RegClass;
8785 Opc = AArch64::FMLAv2i64_indexed;
8787 FMAInstKind::Indexed);
8789 Opc = AArch64::FMLAv2f64;
8791 FMAInstKind::Accumulator);
8796 RC = &AArch64::FPR128RegClass;
8798 Opc = AArch64::FMLAv2i64_indexed;
8800 FMAInstKind::Indexed);
8802 Opc = AArch64::FMLAv2f64;
8804 FMAInstKind::Accumulator);
8810 RC = &AArch64::FPR128RegClass;
8812 Opc = AArch64::FMLAv4i32_indexed;
8814 FMAInstKind::Indexed);
8816 Opc = AArch64::FMLAv4f32;
8818 FMAInstKind::Accumulator);
8824 RC = &AArch64::FPR128RegClass;
8826 Opc = AArch64::FMLAv4i32_indexed;
8828 FMAInstKind::Indexed);
8830 Opc = AArch64::FMLAv4f32;
8832 FMAInstKind::Accumulator);
8837 Opc = AArch64::FNMSUBHrrr;
8838 RC = &AArch64::FPR16RegClass;
8842 Opc = AArch64::FNMSUBSrrr;
8843 RC = &AArch64::FPR32RegClass;
8847 Opc = AArch64::FNMSUBDrrr;
8848 RC = &AArch64::FPR64RegClass;
8853 Opc = AArch64::FNMADDHrrr;
8854 RC = &AArch64::FPR16RegClass;
8858 Opc = AArch64::FNMADDSrrr;
8859 RC = &AArch64::FPR32RegClass;
8863 Opc = AArch64::FNMADDDrrr;
8864 RC = &AArch64::FPR64RegClass;
8869 Opc = AArch64::FMSUBHrrr;
8870 RC = &AArch64::FPR16RegClass;
8874 Opc = AArch64::FMSUBSrrr;
8875 RC = &AArch64::FPR32RegClass;
8879 Opc = AArch64::FMSUBDrrr;
8880 RC = &AArch64::FPR64RegClass;
8885 Opc = AArch64::FMLSv1i32_indexed;
8886 RC = &AArch64::FPR32RegClass;
8888 FMAInstKind::Indexed);
8892 Opc = AArch64::FMLSv1i64_indexed;
8893 RC = &AArch64::FPR64RegClass;
8895 FMAInstKind::Indexed);
8900 RC = &AArch64::FPR64RegClass;
8906 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
8908 Opc = AArch64::FMLAv4f16;
8910 FMAInstKind::Accumulator, &NewVR);
8912 Opc = AArch64::FMLAv4i16_indexed;
8914 FMAInstKind::Indexed, &NewVR);
8919 RC = &AArch64::FPR64RegClass;
8920 Opc = AArch64::FMLSv4f16;
8922 FMAInstKind::Accumulator);
8925 RC = &AArch64::FPR64RegClass;
8926 Opc = AArch64::FMLSv4i16_indexed;
8928 FMAInstKind::Indexed);
8933 RC = &AArch64::FPR64RegClass;
8935 Opc = AArch64::FMLSv2i32_indexed;
8937 FMAInstKind::Indexed);
8939 Opc = AArch64::FMLSv2f32;
8941 FMAInstKind::Accumulator);
8947 RC = &AArch64::FPR128RegClass;
8953 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
8955 Opc = AArch64::FMLAv8f16;
8957 FMAInstKind::Accumulator, &NewVR);
8959 Opc = AArch64::FMLAv8i16_indexed;
8961 FMAInstKind::Indexed, &NewVR);
8966 RC = &AArch64::FPR128RegClass;
8967 Opc = AArch64::FMLSv8f16;
8969 FMAInstKind::Accumulator);
8972 RC = &AArch64::FPR128RegClass;
8973 Opc = AArch64::FMLSv8i16_indexed;
8975 FMAInstKind::Indexed);
8980 RC = &AArch64::FPR128RegClass;
8982 Opc = AArch64::FMLSv2i64_indexed;
8984 FMAInstKind::Indexed);
8986 Opc = AArch64::FMLSv2f64;
8988 FMAInstKind::Accumulator);
8994 RC = &AArch64::FPR128RegClass;
8996 Opc = AArch64::FMLSv4i32_indexed;
8998 FMAInstKind::Indexed);
9000 Opc = AArch64::FMLSv4f32;
9002 FMAInstKind::Accumulator);
9007 RC = &AArch64::FPR64RegClass;
9013 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9015 Opc = AArch64::FMLAv2i32_indexed;
9017 FMAInstKind::Indexed, &NewVR);
9019 Opc = AArch64::FMLAv2f32;
9021 FMAInstKind::Accumulator, &NewVR);
9027 RC = &AArch64::FPR128RegClass;
9033 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9035 Opc = AArch64::FMLAv4i32_indexed;
9037 FMAInstKind::Indexed, &NewVR);
9039 Opc = AArch64::FMLAv4f32;
9041 FMAInstKind::Accumulator, &NewVR);
9047 RC = &AArch64::FPR128RegClass;
9053 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9055 Opc = AArch64::FMLAv2i64_indexed;
9057 FMAInstKind::Indexed, &NewVR);
9059 Opc = AArch64::FMLAv2f64;
9061 FMAInstKind::Accumulator, &NewVR);
9071 &AArch64::FPR128RegClass,
MRI);
9080 &AArch64::FPR128RegClass,
MRI);
9089 &AArch64::FPR128_loRegClass,
MRI);
9098 &AArch64::FPR128RegClass,
MRI);
9107 &AArch64::FPR128_loRegClass,
MRI);
9141 for (
auto *
MI : InsInstrs)
9142 MI->setFlags(Flags);
9183 bool IsNegativeBranch =
false;
9184 bool IsTestAndBranch =
false;
9185 unsigned TargetBBInMI = 0;
9186 switch (
MI.getOpcode()) {
9190 case AArch64::CBWPri:
9191 case AArch64::CBXPri:
9192 case AArch64::CBWPrr:
9193 case AArch64::CBXPrr:
9199 case AArch64::CBNZW:
9200 case AArch64::CBNZX:
9202 IsNegativeBranch =
true;
9207 IsTestAndBranch =
true;
9209 case AArch64::TBNZW:
9210 case AArch64::TBNZX:
9212 IsNegativeBranch =
true;
9213 IsTestAndBranch =
true;
9219 if (IsTestAndBranch &&
MI.getOperand(1).getImm())
9223 assert(
MI.getParent() &&
"Incomplete machine instruction\n");
9236 if (!
MRI->hasOneNonDBGUse(CopyVReg))
9238 if (!
MRI->hasOneDef(CopyVReg))
9247 case AArch64::ANDWri:
9248 case AArch64::ANDXri: {
9249 if (IsTestAndBranch)
9253 if (!
MRI->hasOneNonDBGUse(VReg))
9267 assert(!
MRI->def_empty(NewReg) &&
"Register must be defined.");
9273 unsigned Opc = (Imm < 32)
9274 ? (IsNegativeBranch ? AArch64::TBNZW : AArch64::TBZW)
9275 : (IsNegativeBranch ? AArch64::TBNZX : AArch64::TBZX);
9288 if (!Is32Bit && Imm < 32)
9290 MI.eraseFromParent();
9294 case AArch64::CSINCWr:
9295 case AArch64::CSINCXr: {
9315 if (IsNegativeBranch)
9318 MI.eraseFromParent();
9324std::pair<unsigned, unsigned>
9327 return std::make_pair(TF & Mask, TF & ~Mask);
9332 using namespace AArch64II;
9334 static const std::pair<unsigned, const char *> TargetFlags[] = {
9335 {MO_PAGE,
"aarch64-page"}, {MO_PAGEOFF,
"aarch64-pageoff"},
9336 {MO_G3,
"aarch64-g3"}, {MO_G2,
"aarch64-g2"},
9337 {MO_G1,
"aarch64-g1"}, {MO_G0,
"aarch64-g0"},
9338 {MO_HI12,
"aarch64-hi12"}};
9344 using namespace AArch64II;
9346 static const std::pair<unsigned, const char *> TargetFlags[] = {
9347 {MO_COFFSTUB,
"aarch64-coffstub"},
9348 {MO_GOT,
"aarch64-got"},
9349 {MO_NC,
"aarch64-nc"},
9350 {MO_S,
"aarch64-s"},
9351 {MO_TLS,
"aarch64-tls"},
9352 {MO_DLLIMPORT,
"aarch64-dllimport"},
9353 {MO_PREL,
"aarch64-prel"},
9354 {MO_TAGGED,
"aarch64-tagged"},
9355 {MO_ARM64EC_CALLMANGLE,
"aarch64-arm64ec-callmangle"},
9362 static const std::pair<MachineMemOperand::Flags, const char *> TargetFlags[] =
9470 for (
unsigned Reg : AArch64::GPR64RegClass) {
9472 Reg != AArch64::LR &&
9473 Reg != AArch64::X16 &&
9474 Reg != AArch64::X17 &&
9475 C.isAvailableAcrossAndOutOfSeq(
Reg,
TRI) &&
9476 C.isAvailableInsideSeq(
Reg,
TRI))
9507 return SubtargetA.hasV8_3aOps() == SubtargetB.hasV8_3aOps();
9510std::optional<std::unique_ptr<outliner::OutlinedFunction>>
9513 std::vector<outliner::Candidate> &RepeatedSequenceLocs,
9514 unsigned MinRepeats)
const {
9515 unsigned SequenceSize = 0;
9516 for (
auto &
MI : RepeatedSequenceLocs[0])
9519 unsigned NumBytesToCreateFrame = 0;
9529 if (std::adjacent_find(
9530 RepeatedSequenceLocs.begin(), RepeatedSequenceLocs.end(),
9534 if (outliningCandidatesSigningScopeConsensus(a, b) &&
9535 outliningCandidatesSigningKeyConsensus(a, b) &&
9536 outliningCandidatesV8_3OpsConsensus(a, b)) {
9540 }) != RepeatedSequenceLocs.end()) {
9541 return std::nullopt;
9558 unsigned NumBytesToCheckLRInTCEpilogue = 0;
9559 if (RepeatedSequenceLocs[0]
9561 ->getInfo<AArch64FunctionInfo>()
9562 ->shouldSignReturnAddress(
true)) {
9564 NumBytesToCreateFrame += 8;
9567 auto LRCheckMethod = Subtarget.getAuthenticatedLRCheckMethod(
9568 *RepeatedSequenceLocs[0].getMF());
9569 NumBytesToCheckLRInTCEpilogue =
9573 if (isTailCallReturnInst(RepeatedSequenceLocs[0].back()))
9574 SequenceSize += NumBytesToCheckLRInTCEpilogue;
9582 for (
auto &
MI :
C) {
9583 if (
MI.modifiesRegister(AArch64::SP, &
TRI)) {
9584 switch (
MI.getOpcode()) {
9585 case AArch64::ADDXri:
9586 case AArch64::ADDWri:
9587 assert(
MI.getNumOperands() == 4 &&
"Wrong number of operands");
9589 "Expected operand to be immediate");
9591 "Expected operand to be a register");
9595 if (
MI.getOperand(1).getReg() == AArch64::SP)
9596 SPValue +=
MI.getOperand(2).getImm();
9600 case AArch64::SUBXri:
9601 case AArch64::SUBWri:
9602 assert(
MI.getNumOperands() == 4 &&
"Wrong number of operands");
9604 "Expected operand to be immediate");
9606 "Expected operand to be a register");
9610 if (
MI.getOperand(1).getReg() == AArch64::SP)
9611 SPValue -=
MI.getOperand(2).getImm();
9628 if (RepeatedSequenceLocs.size() < MinRepeats)
9629 return std::nullopt;
9633 unsigned FlagsSetInAll = 0xF;
9637 FlagsSetInAll &=
C.Flags;
9639 unsigned LastInstrOpcode = RepeatedSequenceLocs[0].back().getOpcode();
9642 auto SetCandidateCallInfo =
9643 [&RepeatedSequenceLocs](
unsigned CallID,
unsigned NumBytesForCall) {
9645 C.setCallInfo(CallID, NumBytesForCall);
9649 NumBytesToCreateFrame += 4;
9652 return C.getMF()->getInfo<AArch64FunctionInfo>()->branchTargetEnforcement();
9657 unsigned CFICount = 0;
9658 for (
auto &
I : RepeatedSequenceLocs[0]) {
9659 if (
I.isCFIInstruction())
9669 std::vector<MCCFIInstruction> CFIInstructions =
9670 C.getMF()->getFrameInstructions();
9672 if (CFICount > 0 && CFICount != CFIInstructions.size())
9673 return std::nullopt;
9681 if (!
MI.modifiesRegister(AArch64::SP, &
TRI) &&
9682 !
MI.readsRegister(AArch64::SP, &
TRI))
9688 if (
MI.modifiesRegister(AArch64::SP, &
TRI))
9693 if (
MI.mayLoadOrStore()) {
9696 bool OffsetIsScalable;
9700 if (!getMemOperandWithOffset(
MI,
Base,
Offset, OffsetIsScalable, &
TRI) ||
9701 !
Base->isReg() ||
Base->getReg() != AArch64::SP)
9705 if (OffsetIsScalable)
9713 TypeSize Scale(0U,
false), DummyWidth(0U,
false);
9714 getMemOpInfo(
MI.getOpcode(), Scale, DummyWidth, MinOffset, MaxOffset);
9717 if (
Offset < MinOffset * (int64_t)Scale.getFixedValue() ||
9718 Offset > MaxOffset * (int64_t)Scale.getFixedValue())
9733 bool AllStackInstrsSafe =
9738 if (RepeatedSequenceLocs[0].back().isTerminator()) {
9740 NumBytesToCreateFrame = 0;
9741 unsigned NumBytesForCall = 4 + NumBytesToCheckLRInTCEpilogue;
9745 else if (LastInstrOpcode == AArch64::BL ||
9746 ((LastInstrOpcode == AArch64::BLR ||
9747 LastInstrOpcode == AArch64::BLRNoIP) &&
9751 NumBytesToCreateFrame = NumBytesToCheckLRInTCEpilogue;
9759 unsigned NumBytesNoStackCalls = 0;
9760 std::vector<outliner::Candidate> CandidatesWithoutStackFixups;
9765 (
C.Flags & MachineOutlinerMBBFlags::LRUnavailableSomewhere)
9766 ?
C.isAvailableAcrossAndOutOfSeq(AArch64::LR,
TRI)
9775 C.getMF()->getFunction().hasFnAttribute(Attribute::NoReturn);
9778 if (LRAvailable && !IsNoReturn) {
9779 NumBytesNoStackCalls += 4;
9781 CandidatesWithoutStackFixups.push_back(
C);
9786 else if (findRegisterToSaveLRTo(
C)) {
9787 NumBytesNoStackCalls += 12;
9789 CandidatesWithoutStackFixups.push_back(
C);
9794 else if (
C.isAvailableInsideSeq(AArch64::SP,
TRI)) {
9795 NumBytesNoStackCalls += 12;
9797 CandidatesWithoutStackFixups.push_back(
C);
9803 NumBytesNoStackCalls += SequenceSize;
9810 if (!AllStackInstrsSafe ||
9811 NumBytesNoStackCalls <= RepeatedSequenceLocs.size() * 12) {
9812 RepeatedSequenceLocs = CandidatesWithoutStackFixups;
9814 if (RepeatedSequenceLocs.size() < MinRepeats)
9815 return std::nullopt;
9864 if (FlagsSetInAll & MachineOutlinerMBBFlags::HasCalls) {
9868 (!
C.isAvailableAcrossAndOutOfSeq(AArch64::LR,
TRI) ||
9869 !findRegisterToSaveLRTo(
C));
9875 if (RepeatedSequenceLocs.size() < MinRepeats)
9876 return std::nullopt;
9881 if (FlagsSetInAll & MachineOutlinerMBBFlags::HasCalls) {
9885 bool ModStackToSaveLR =
false;
9888 ModStackToSaveLR =
true;
9897 ModStackToSaveLR =
true;
9899 if (ModStackToSaveLR) {
9901 if (!AllStackInstrsSafe)
9902 return std::nullopt;
9905 NumBytesToCreateFrame += 8;
9912 return std::nullopt;
9914 return std::make_unique<outliner::OutlinedFunction>(
9915 RepeatedSequenceLocs, SequenceSize, NumBytesToCreateFrame, FrameID);
9919 Function &
F, std::vector<outliner::Candidate> &Candidates)
const {
9923 const auto &CFn = Candidates.front().getMF()->getFunction();
9925 if (CFn.hasFnAttribute(
"ptrauth-returns"))
9926 F.addFnAttr(CFn.getFnAttribute(
"ptrauth-returns"));
9927 if (CFn.hasFnAttribute(
"ptrauth-auth-traps"))
9928 F.addFnAttr(CFn.getFnAttribute(
"ptrauth-auth-traps"));
9931 if (CFn.hasFnAttribute(
"sign-return-address"))
9932 F.addFnAttr(CFn.getFnAttribute(
"sign-return-address"));
9933 if (CFn.hasFnAttribute(
"sign-return-address-key"))
9934 F.addFnAttr(CFn.getFnAttribute(
"sign-return-address-key"));
9936 AArch64GenInstrInfo::mergeOutliningCandidateAttributes(
F, Candidates);
9944 if (!OutlineFromLinkOnceODRs &&
F.hasLinkOnceODRLinkage())
9958 if (!AFI || AFI->
hasRedZone().value_or(
true))
9978 unsigned &Flags)
const {
9980 "Must track liveness!");
9982 std::pair<MachineBasicBlock::iterator, MachineBasicBlock::iterator>>
9997 auto AreAllUnsafeRegsDead = [&LRU]() {
10014 bool LRAvailableEverywhere =
true;
10019 if (
MI.isCall() && !
MI.isTerminator())
10020 Flags |= MachineOutlinerMBBFlags::HasCalls;
10025 auto CreateNewRangeStartingAt =
10026 [&RangeBegin, &RangeEnd,
10028 RangeBegin = NewBegin;
10029 RangeEnd = std::next(RangeBegin);
10032 auto SaveRangeIfNonEmpty = [&RangeLen, &Ranges, &RangeBegin, &RangeEnd]() {
10038 if (!RangeBegin.isEnd() && RangeBegin->isBundledWithPred())
10040 if (!RangeEnd.isEnd() && RangeEnd->isBundledWithPred())
10042 Ranges.emplace_back(RangeBegin, RangeEnd);
10050 for (; FirstPossibleEndPt !=
MBB.
instr_rend(); ++FirstPossibleEndPt) {
10054 UpdateWholeMBBFlags(*FirstPossibleEndPt);
10055 if (AreAllUnsafeRegsDead())
10062 CreateNewRangeStartingAt(FirstPossibleEndPt->getIterator());
10068 UpdateWholeMBBFlags(
MI);
10069 if (!AreAllUnsafeRegsDead()) {
10070 SaveRangeIfNonEmpty();
10071 CreateNewRangeStartingAt(
MI.getIterator());
10074 LRAvailableEverywhere &= LRU.
available(AArch64::LR);
10075 RangeBegin =
MI.getIterator();
10080 if (AreAllUnsafeRegsDead())
10081 SaveRangeIfNonEmpty();
10082 if (Ranges.empty())
10086 std::reverse(Ranges.begin(), Ranges.end());
10089 if (!LRAvailableEverywhere)
10090 Flags |= MachineOutlinerMBBFlags::LRUnavailableSomewhere;
10097 unsigned Flags)
const {
10102 switch (
MI.getOpcode()) {
10103 case AArch64::PACM:
10104 case AArch64::PACIASP:
10105 case AArch64::PACIBSP:
10106 case AArch64::PACIASPPC:
10107 case AArch64::PACIBSPPC:
10108 case AArch64::AUTIASP:
10109 case AArch64::AUTIBSP:
10110 case AArch64::AUTIASPPCi:
10111 case AArch64::AUTIASPPCr:
10112 case AArch64::AUTIBSPPCi:
10113 case AArch64::AUTIBSPPCr:
10114 case AArch64::RETAA:
10115 case AArch64::RETAB:
10116 case AArch64::RETAASPPCi:
10117 case AArch64::RETAASPPCr:
10118 case AArch64::RETABSPPCi:
10119 case AArch64::RETABSPPCr:
10120 case AArch64::EMITBKEY:
10121 case AArch64::PAUTH_PROLOGUE:
10122 case AArch64::PAUTH_EPILOGUE:
10132 if (
MI.isCFIInstruction())
10136 if (
MI.isTerminator())
10145 assert(!MOP.isCFIIndex());
10148 if (MOP.isReg() && !MOP.isImplicit() &&
10149 (MOP.getReg() == AArch64::LR || MOP.getReg() == AArch64::W30))
10156 if (
MI.getOpcode() == AArch64::ADRP)
10177 if (MOP.isGlobal()) {
10178 Callee = dyn_cast<Function>(MOP.getGlobal());
10185 if (Callee && Callee->getName() ==
"\01_mcount")
10193 if (
MI.getOpcode() == AArch64::BLR ||
10194 MI.getOpcode() == AArch64::BLRNoIP ||
MI.getOpcode() == AArch64::BL)
10198 return UnknownCallOutlineType;
10206 return UnknownCallOutlineType;
10214 return UnknownCallOutlineType;
10239 bool OffsetIsScalable;
10242 if (!
MI.mayLoadOrStore() ||
10245 (
Base->isReg() &&
Base->getReg() != AArch64::SP))
10250 int64_t Dummy1, Dummy2;
10253 assert(StackOffsetOperand.
isImm() &&
"Stack offset wasn't immediate!");
10255 assert(Scale != 0 &&
"Unexpected opcode!");
10256 assert(!OffsetIsScalable &&
"Expected offset to be a byte offset");
10261 int64_t NewImm = (
Offset + 16) / (int64_t)Scale.getFixedValue();
10262 StackOffsetOperand.
setImm(NewImm);
10268 bool ShouldSignReturnAddr) {
10269 if (!ShouldSignReturnAddr)
10275 TII->get(AArch64::PAUTH_EPILOGUE))
10291 unsigned TailOpcode;
10292 if (Call->getOpcode() == AArch64::BL) {
10293 TailOpcode = AArch64::TCRETURNdi;
10295 assert(Call->getOpcode() == AArch64::BLR ||
10296 Call->getOpcode() == AArch64::BLRNoIP);
10297 TailOpcode = AArch64::TCRETURNriALL;
10300 .
add(Call->getOperand(0))
10303 Call->eraseFromParent();
10308 bool IsLeafFunction =
true;
10312 return MI.isCall() && !
MI.isReturn();
10322 "Can only fix up stack references once");
10323 fixupPostOutline(
MBB);
10325 IsLeafFunction =
false;
10336 Et = std::prev(
MBB.
end());
10395 fixupPostOutline(
MBB);
10406 .addGlobalAddress(M.getNamedValue(MF.
getName()))
10416 .addGlobalAddress(M.getNamedValue(MF.
getName())));
10431 Register Reg = findRegisterToSaveLRTo(
C);
10432 assert(Reg &&
"No callee-saved register available?");
10466 .addGlobalAddress(M.getNamedValue(MF.
getName())));
10482 bool AllowSideEffects)
const {
10487 if (
TRI.isGeneralPurposeRegister(MF, Reg)) {
10500 assert(STI.hasNEON() &&
"Expected to have NEON.");
10501 Register Reg64 =
TRI.getSubReg(Reg, AArch64::dsub);
10506std::optional<DestSourcePair>
10511 if (((
MI.getOpcode() == AArch64::ORRWrs &&
10512 MI.getOperand(1).getReg() == AArch64::WZR &&
10513 MI.getOperand(3).getImm() == 0x0) ||
10514 (
MI.getOpcode() == AArch64::ORRWrr &&
10515 MI.getOperand(1).getReg() == AArch64::WZR)) &&
10517 (!
MI.getOperand(0).getReg().isVirtual() ||
10518 MI.getOperand(0).getSubReg() == 0) &&
10519 (!
MI.getOperand(0).getReg().isPhysical() ||
10524 if (
MI.getOpcode() == AArch64::ORRXrs &&
10525 MI.getOperand(1).getReg() == AArch64::XZR &&
10526 MI.getOperand(3).getImm() == 0x0)
10529 return std::nullopt;
10532std::optional<DestSourcePair>
10534 if ((
MI.getOpcode() == AArch64::ORRWrs &&
10535 MI.getOperand(1).getReg() == AArch64::WZR &&
10536 MI.getOperand(3).getImm() == 0x0) ||
10537 (
MI.getOpcode() == AArch64::ORRWrr &&
10538 MI.getOperand(1).getReg() == AArch64::WZR))
10540 return std::nullopt;
10543std::optional<RegImmPair>
10552 return std::nullopt;
10554 switch (
MI.getOpcode()) {
10556 return std::nullopt;
10557 case AArch64::SUBWri:
10558 case AArch64::SUBXri:
10559 case AArch64::SUBSWri:
10560 case AArch64::SUBSXri:
10563 case AArch64::ADDSWri:
10564 case AArch64::ADDSXri:
10565 case AArch64::ADDWri:
10566 case AArch64::ADDXri: {
10568 if (!
MI.getOperand(0).isReg() || !
MI.getOperand(1).isReg() ||
10569 !
MI.getOperand(2).isImm())
10570 return std::nullopt;
10571 int Shift =
MI.getOperand(3).getImm();
10572 assert((Shift == 0 || Shift == 12) &&
"Shift can be either 0 or 12");
10573 Offset = Sign * (
MI.getOperand(2).getImm() << Shift);
10582static std::optional<ParamLoadedValue>
10586 auto DestSrc =
TII->isCopyLikeInstr(
MI);
10588 return std::nullopt;
10590 Register DestReg = DestSrc->Destination->getReg();
10591 Register SrcReg = DestSrc->Source->getReg();
10596 if (DestReg == DescribedReg)
10600 if (
MI.getOpcode() == AArch64::ORRWrs &&
10601 TRI->isSuperRegister(DestReg, DescribedReg))
10605 if (
MI.getOpcode() == AArch64::ORRXrs &&
10606 TRI->isSubRegister(DestReg, DescribedReg)) {
10607 Register SrcSubReg =
TRI->getSubReg(SrcReg, AArch64::sub_32);
10611 assert(!
TRI->isSuperOrSubRegisterEq(DestReg, DescribedReg) &&
10612 "Unhandled ORR[XW]rs copy case");
10614 return std::nullopt;
10633 return MI.getOpcode() == AArch64::INLINEASM_BR;
10651 switch (
MI.getOpcode()) {
10652 case TargetOpcode::G_BRJT:
10653 case AArch64::JumpTableDest32:
10654 case AArch64::JumpTableDest16:
10655 case AArch64::JumpTableDest8:
10666std::optional<ParamLoadedValue>
10671 switch (
MI.getOpcode()) {
10672 case AArch64::MOVZWi:
10673 case AArch64::MOVZXi: {
10676 if (!
TRI->isSuperRegisterEq(
MI.getOperand(0).getReg(), Reg))
10677 return std::nullopt;
10679 if (!
MI.getOperand(1).isImm())
10680 return std::nullopt;
10681 int64_t Immediate =
MI.getOperand(1).getImm();
10682 int Shift =
MI.getOperand(2).getImm();
10686 case AArch64::ORRWrs:
10687 case AArch64::ORRXrs:
10697 ExtMI.
getOpcode() == TargetOpcode::G_ZEXT ||
10698 ExtMI.
getOpcode() == TargetOpcode::G_ANYEXT);
10701 if (ExtMI.
getOpcode() == TargetOpcode::G_ANYEXT)
10705 if (!
MRI.hasOneNonDBGUse(DefReg))
10710 auto *UserMI = &*
MRI.use_instr_nodbg_begin(DefReg);
10711 return UserMI->getOpcode() == TargetOpcode::G_PTR_ADD;
10732 unsigned Scale)
const {
10743 unsigned Shift =
Log2_64(NumBytes);
10744 if (NumBytes &&
Offset > 0 && (
Offset / NumBytes) <= (1LL << 12) - 1 &&
10752 return Scale == 1 || (Scale > 0 && Scale == NumBytes);
10757 return AArch64::BLRNoIP;
10759 return AArch64::BLR;
10764 Register TargetReg,
bool FrameSetup)
const {
10765 assert(TargetReg != AArch64::SP &&
"New top of stack cannot already be in SP");
10777 MF.
insert(MBBInsertPoint, LoopTestMBB);
10780 MF.
insert(MBBInsertPoint, LoopBodyMBB);
10782 MF.
insert(MBBInsertPoint, ExitMBB);
10792 BuildMI(*LoopTestMBB, LoopTestMBB->
end(),
DL,
TII->get(AArch64::SUBSXrx64),
10800 BuildMI(*LoopTestMBB, LoopTestMBB->
end(),
DL,
TII->get(AArch64::Bcc))
10806 BuildMI(*LoopBodyMBB, LoopBodyMBB->
end(),
DL,
TII->get(AArch64::STRXui))
10819 BuildMI(*ExitMBB, ExitMBB->
end(),
DL,
TII->get(AArch64::ADDXri), AArch64::SP)
10844 return ExitMBB->
begin();
10861 unsigned CompCounterOprNum;
10865 unsigned UpdateCounterOprNum;
10869 bool IsUpdatePriorComp;
10881 TII(MF->getSubtarget().getInstrInfo()),
10882 TRI(MF->getSubtarget().getRegisterInfo()),
MRI(MF->getRegInfo()),
10883 LoopBB(LoopBB), CondBranch(CondBranch), Comp(Comp),
10884 CompCounterOprNum(CompCounterOprNum), Update(Update),
10885 UpdateCounterOprNum(UpdateCounterOprNum),
Init(
Init),
10886 IsUpdatePriorComp(IsUpdatePriorComp),
Cond(
Cond.begin(),
Cond.end()) {}
10888 bool shouldIgnoreForPipelining(
const MachineInstr *
MI)
const override {
10894 std::optional<bool> createTripCountGreaterCondition(
10904 void createRemainingIterationsGreaterCondition(
10910 void adjustTripCount(
int TripCountAdjust)
override {}
10912 bool isMVEExpanderSupported()
override {
return true; }
10930 Result =
MRI.createVirtualRegister(
10933 }
else if (
I == ReplaceOprNum) {
10934 MRI.constrainRegClass(
10944void AArch64PipelinerLoopInfo::createRemainingIterationsGreaterCondition(
10960 assert(CondBranch->getOpcode() == AArch64::Bcc);
10964 if (CondBranch->getOperand(1).getMBB() == LoopBB)
10971 auto AccumulateCond = [&](
Register CurCond,
10973 Register NewCond =
MRI.createVirtualRegister(&AArch64::GPR64commonRegClass);
10982 if (!LastStage0Insts.
empty() && LastStage0Insts[Comp]->getParent() == &
MBB) {
10986 for (
int I = 0;
I <= TC; ++
I) {
10992 AccCond = AccumulateCond(AccCond, CC);
10996 if (Update != Comp && IsUpdatePriorComp) {
10998 LastStage0Insts[Comp]->getOperand(CompCounterOprNum).getReg();
10999 NextCounter =
cloneInstr(Update, UpdateCounterOprNum, Counter,
MBB,
11003 NextCounter = LastStage0Insts[Update]->getOperand(0).getReg();
11005 }
else if (Update != Comp) {
11010 Counter = NextCounter;
11014 if (LastStage0Insts.
empty()) {
11018 if (IsUpdatePriorComp)
11023 Counter = LastStage0Insts[Comp]->getOperand(CompCounterOprNum).getReg();
11026 for (
int I = 0;
I <= TC; ++
I) {
11030 AccCond = AccumulateCond(AccCond, CC);
11031 if (
I != TC && Update != Comp)
11034 Counter = NextCounter;
11050 assert(Phi.getNumOperands() == 5);
11051 if (Phi.getOperand(2).getMBB() ==
MBB) {
11052 RegMBB = Phi.getOperand(1).getReg();
11053 RegOther = Phi.getOperand(3).getReg();
11055 assert(Phi.getOperand(4).getMBB() ==
MBB);
11056 RegMBB = Phi.getOperand(3).getReg();
11057 RegOther = Phi.getOperand(1).getReg();
11062 if (!Reg.isVirtual())
11065 return MRI.getVRegDef(Reg)->getParent() != BB;
11071 unsigned &UpdateCounterOprNum,
Register &InitReg,
11072 bool &IsUpdatePriorComp) {
11086 if (!Reg.isVirtual())
11089 UpdateInst =
nullptr;
11090 UpdateCounterOprNum = 0;
11092 IsUpdatePriorComp =
true;
11096 if (Def->getParent() != LoopBB)
11098 if (Def->isCopy()) {
11100 if (Def->getOperand(0).getSubReg() || Def->getOperand(1).getSubReg())
11102 CurReg = Def->getOperand(1).getReg();
11103 }
else if (Def->isPHI()) {
11107 IsUpdatePriorComp =
false;
11112 switch (Def->getOpcode()) {
11113 case AArch64::ADDSXri:
11114 case AArch64::ADDSWri:
11115 case AArch64::SUBSXri:
11116 case AArch64::SUBSWri:
11117 case AArch64::ADDXri:
11118 case AArch64::ADDWri:
11119 case AArch64::SUBXri:
11120 case AArch64::SUBWri:
11122 UpdateCounterOprNum = 1;
11124 case AArch64::ADDSXrr:
11125 case AArch64::ADDSWrr:
11126 case AArch64::SUBSXrr:
11127 case AArch64::SUBSWrr:
11128 case AArch64::ADDXrr:
11129 case AArch64::ADDWrr:
11130 case AArch64::SUBXrr:
11131 case AArch64::SUBWrr:
11134 UpdateCounterOprNum = 1;
11136 UpdateCounterOprNum = 2;
11143 CurReg = Def->getOperand(UpdateCounterOprNum).getReg();
11158std::unique_ptr<TargetInstrInfo::PipelinerLoopInfo>
11169 if (
MI.isCall() ||
MI.hasUnmodeledSideEffects())
11180 if (
TBB == LoopBB && FBB == LoopBB)
11184 if (
TBB != LoopBB && FBB ==
nullptr)
11187 assert((
TBB == LoopBB || FBB == LoopBB) &&
11188 "The Loop must be a single-basic-block loop");
11193 if (CondBranch->
getOpcode() != AArch64::Bcc)
11201 unsigned CompCounterOprNum = 0;
11203 if (
MI.modifiesRegister(AArch64::NZCV, &
TRI)) {
11207 switch (
MI.getOpcode()) {
11208 case AArch64::SUBSXri:
11209 case AArch64::SUBSWri:
11210 case AArch64::ADDSXri:
11211 case AArch64::ADDSWri:
11213 CompCounterOprNum = 1;
11215 case AArch64::ADDSWrr:
11216 case AArch64::ADDSXrr:
11217 case AArch64::SUBSWrr:
11218 case AArch64::SUBSXrr:
11229 if (CompCounterOprNum == 0) {
11231 CompCounterOprNum = 2;
11233 CompCounterOprNum = 1;
11245 bool IsUpdatePriorComp;
11246 unsigned UpdateCounterOprNum;
11248 Update, UpdateCounterOprNum,
Init, IsUpdatePriorComp))
11251 return std::make_unique<AArch64PipelinerLoopInfo>(
11252 LoopBB, CondBranch, Comp, CompCounterOprNum, Update, UpdateCounterOprNum,
11263 TypeSize Scale(0U,
false), Width(0U,
false);
11264 int64_t MinOffset, MaxOffset;
11265 if (
getMemOpInfo(
MI.getOpcode(), Scale, Width, MinOffset, MaxOffset)) {
11267 if (
MI.getOperand(ImmIdx).isImm() && !
MI.getOperand(ImmIdx - 1).isFI()) {
11268 int64_t Imm =
MI.getOperand(ImmIdx).getImm();
11269 if (Imm < MinOffset || Imm > MaxOffset) {
11270 ErrInfo =
"Unexpected immediate on load/store instruction";
11278#define GET_INSTRINFO_HELPERS
11279#define GET_INSTRMAP_INFO
11280#include "AArch64GenInstrInfo.inc"
unsigned const MachineRegisterInfo * MRI
MachineInstrBuilder & UseMI
MachineInstrBuilder MachineInstrBuilder & DefMI
static bool forwardCopyWillClobberTuple(unsigned DestReg, unsigned SrcReg, unsigned NumRegs)
static cl::opt< unsigned > BCCDisplacementBits("aarch64-bcc-offset-bits", cl::Hidden, cl::init(19), cl::desc("Restrict range of Bcc instructions (DEBUG)"))
static Register genNeg(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, DenseMap< Register, unsigned > &InstrIdxForVirtReg, unsigned MnegOpc, const TargetRegisterClass *RC)
genNeg - Helper to generate an intermediate negation of the second operand of Root
static cl::opt< unsigned > GatherOptSearchLimit("aarch64-search-limit", cl::Hidden, cl::init(2048), cl::desc("Restrict range of instructions to search for the " "machine-combiner gather pattern optimization"))
static bool getMaddPatterns(MachineInstr &Root, SmallVectorImpl< unsigned > &Patterns)
Find instructions that can be turned into madd.
static AArch64CC::CondCode findCondCodeUsedByInstr(const MachineInstr &Instr)
Find a condition code used by the instruction.
static MachineInstr * genFusedMultiplyAcc(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, unsigned IdxMulOpd, unsigned MaddOpc, const TargetRegisterClass *RC)
genFusedMultiplyAcc - Helper to generate fused multiply accumulate instructions.
static MachineInstr * genFusedMultiplyAccNeg(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, DenseMap< Register, unsigned > &InstrIdxForVirtReg, unsigned IdxMulOpd, unsigned MaddOpc, unsigned MnegOpc, const TargetRegisterClass *RC)
genFusedMultiplyAccNeg - Helper to generate fused multiply accumulate instructions with an additional...
static bool isCombineInstrCandidate64(unsigned Opc)
static unsigned removeCopies(const MachineRegisterInfo &MRI, unsigned VReg)
static bool areCFlagsAccessedBetweenInstrs(MachineBasicBlock::iterator From, MachineBasicBlock::iterator To, const TargetRegisterInfo *TRI, const AccessKind AccessToCheck=AK_All)
True when condition flags are accessed (either by writing or reading) on the instruction trace starti...
static bool getFMAPatterns(MachineInstr &Root, SmallVectorImpl< unsigned > &Patterns)
Floating-Point Support.
static bool isADDSRegImm(unsigned Opcode)
static void appendOffsetComment(int NumBytes, llvm::raw_string_ostream &Comment, StringRef RegScale={})
static unsigned sForm(MachineInstr &Instr)
Get opcode of S version of Instr.
static bool isCombineInstrSettingFlag(unsigned Opc)
static bool getFNEGPatterns(MachineInstr &Root, SmallVectorImpl< unsigned > &Patterns)
static bool getIndVarInfo(Register Reg, const MachineBasicBlock *LoopBB, MachineInstr *&UpdateInst, unsigned &UpdateCounterOprNum, Register &InitReg, bool &IsUpdatePriorComp)
If Reg is an induction variable, return true and set some parameters.
static const MachineInstrBuilder & AddSubReg(const MachineInstrBuilder &MIB, MCRegister Reg, unsigned SubIdx, unsigned State, const TargetRegisterInfo *TRI)
static bool canPairLdStOpc(unsigned FirstOpc, unsigned SecondOpc)
static int findCondCodeUseOperandIdxForBranchOrSelect(const MachineInstr &Instr)
static bool isPostIndexLdStOpcode(unsigned Opcode)
Return true if the opcode is a post-index ld/st instruction, which really loads from base+0.
static unsigned getBranchDisplacementBits(unsigned Opc)
static cl::opt< unsigned > CBDisplacementBits("aarch64-cb-offset-bits", cl::Hidden, cl::init(9), cl::desc("Restrict range of CB instructions (DEBUG)"))
static std::optional< ParamLoadedValue > describeORRLoadedValue(const MachineInstr &MI, Register DescribedReg, const TargetInstrInfo *TII, const TargetRegisterInfo *TRI)
If the given ORR instruction is a copy, and DescribedReg overlaps with the destination register then,...
static bool getFMULPatterns(MachineInstr &Root, SmallVectorImpl< unsigned > &Patterns)
static void appendReadRegExpr(SmallVectorImpl< char > &Expr, unsigned RegNum)
static MachineInstr * genMaddR(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, unsigned IdxMulOpd, unsigned MaddOpc, unsigned VR, const TargetRegisterClass *RC)
genMaddR - Generate madd instruction and combine mul and add using an extra virtual register Example ...
static Register cloneInstr(const MachineInstr *MI, unsigned ReplaceOprNum, Register ReplaceReg, MachineBasicBlock &MBB, MachineBasicBlock::iterator InsertTo)
Clone an instruction from MI.
static bool scaleOffset(unsigned Opc, int64_t &Offset)
static bool canCombineWithFMUL(MachineBasicBlock &MBB, MachineOperand &MO, unsigned MulOpc)
unsigned scaledOffsetOpcode(unsigned Opcode, unsigned &Scale)
static MachineInstr * genFusedMultiplyIdx(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, unsigned IdxMulOpd, unsigned MaddOpc, const TargetRegisterClass *RC)
genFusedMultiplyIdx - Helper to generate fused multiply accumulate instructions.
static MachineInstr * genIndexedMultiply(MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, unsigned IdxDupOp, unsigned MulOpc, const TargetRegisterClass *RC, MachineRegisterInfo &MRI)
Fold (FMUL x (DUP y lane)) into (FMUL_indexed x y lane)
static bool isSUBSRegImm(unsigned Opcode)
static bool UpdateOperandRegClass(MachineInstr &Instr)
static const TargetRegisterClass * getRegClass(const MachineInstr &MI, Register Reg)
static bool canCmpInstrBeRemoved(MachineInstr &MI, MachineInstr &CmpInstr, int CmpValue, const TargetRegisterInfo &TRI, SmallVectorImpl< MachineInstr * > &CCUseInstrs, bool &IsInvertCC)
unsigned unscaledOffsetOpcode(unsigned Opcode)
static bool getLoadPatterns(MachineInstr &Root, SmallVectorImpl< unsigned > &Patterns)
Search for patterns of LD instructions we can optimize.
static bool canInstrSubstituteCmpInstr(MachineInstr &MI, MachineInstr &CmpInstr, const TargetRegisterInfo &TRI)
Check if CmpInstr can be substituted by MI.
static UsedNZCV getUsedNZCV(AArch64CC::CondCode CC)
static bool isCombineInstrCandidateFP(const MachineInstr &Inst)
static void appendLoadRegExpr(SmallVectorImpl< char > &Expr, int64_t OffsetFromDefCFA)
static void appendConstantExpr(SmallVectorImpl< char > &Expr, int64_t Constant, dwarf::LocationAtom Operation)
static unsigned convertToNonFlagSettingOpc(const MachineInstr &MI)
Return the opcode that does not set flags when possible - otherwise return the original opcode.
static bool outliningCandidatesV8_3OpsConsensus(const outliner::Candidate &a, const outliner::Candidate &b)
static bool isCombineInstrCandidate32(unsigned Opc)
static void parseCondBranch(MachineInstr *LastInst, MachineBasicBlock *&Target, SmallVectorImpl< MachineOperand > &Cond)
static unsigned offsetExtendOpcode(unsigned Opcode)
static void loadRegPairFromStackSlot(const TargetRegisterInfo &TRI, MachineBasicBlock &MBB, MachineBasicBlock::iterator InsertBefore, const MCInstrDesc &MCID, Register DestReg, unsigned SubIdx0, unsigned SubIdx1, int FI, MachineMemOperand *MMO)
static void generateGatherLanePattern(MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, SmallVectorImpl< MachineInstr * > &DelInstrs, DenseMap< Register, unsigned > &InstrIdxForVirtReg, unsigned Pattern, unsigned NumLanes)
Generate optimized instruction sequence for gather load patterns to improve Memory-Level Parallelism ...
static bool getMiscPatterns(MachineInstr &Root, SmallVectorImpl< unsigned > &Patterns)
Find other MI combine patterns.
static bool outliningCandidatesSigningKeyConsensus(const outliner::Candidate &a, const outliner::Candidate &b)
static bool outliningCandidatesSigningScopeConsensus(const outliner::Candidate &a, const outliner::Candidate &b)
static bool shouldClusterFI(const MachineFrameInfo &MFI, int FI1, int64_t Offset1, unsigned Opcode1, int FI2, int64_t Offset2, unsigned Opcode2)
static cl::opt< unsigned > TBZDisplacementBits("aarch64-tbz-offset-bits", cl::Hidden, cl::init(14), cl::desc("Restrict range of TB[N]Z instructions (DEBUG)"))
static void extractPhiReg(const MachineInstr &Phi, const MachineBasicBlock *MBB, Register &RegMBB, Register &RegOther)
static MCCFIInstruction createDefCFAExpression(const TargetRegisterInfo &TRI, unsigned Reg, const StackOffset &Offset)
static bool isDefinedOutside(Register Reg, const MachineBasicBlock *BB)
static MachineInstr * genFusedMultiply(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, unsigned IdxMulOpd, unsigned MaddOpc, const TargetRegisterClass *RC, FMAInstKind kind=FMAInstKind::Default, const Register *ReplacedAddend=nullptr)
genFusedMultiply - Generate fused multiply instructions.
static bool getGatherLanePattern(MachineInstr &Root, SmallVectorImpl< unsigned > &Patterns, unsigned LoadLaneOpCode, unsigned NumLanes)
Check if the given instruction forms a gather load pattern that can be optimized for better Memory-Le...
static MachineInstr * genFusedMultiplyIdxNeg(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, DenseMap< Register, unsigned > &InstrIdxForVirtReg, unsigned IdxMulOpd, unsigned MaddOpc, unsigned MnegOpc, const TargetRegisterClass *RC)
genFusedMultiplyAccNeg - Helper to generate fused multiply accumulate instructions with an additional...
static bool isCombineInstrCandidate(unsigned Opc)
static unsigned regOffsetOpcode(unsigned Opcode)
MachineOutlinerClass
Constants defining how certain sequences should be outlined.
@ MachineOutlinerTailCall
Emit a save, restore, call, and return.
@ MachineOutlinerRegSave
Emit a call and tail-call.
@ MachineOutlinerNoLRSave
Only emit a branch.
@ MachineOutlinerThunk
Emit a call and return.
static cl::opt< unsigned > BDisplacementBits("aarch64-b-offset-bits", cl::Hidden, cl::init(26), cl::desc("Restrict range of B instructions (DEBUG)"))
static bool areCFlagsAliveInSuccessors(const MachineBasicBlock *MBB)
Check if AArch64::NZCV should be alive in successors of MBB.
static void emitFrameOffsetAdj(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, int64_t Offset, unsigned Opc, const TargetInstrInfo *TII, MachineInstr::MIFlag Flag, bool NeedsWinCFI, bool *HasWinCFI, bool EmitCFAOffset, StackOffset CFAOffset, unsigned FrameReg)
static bool isCheapImmediate(const MachineInstr &MI, unsigned BitSize)
static cl::opt< unsigned > CBZDisplacementBits("aarch64-cbz-offset-bits", cl::Hidden, cl::init(19), cl::desc("Restrict range of CB[N]Z instructions (DEBUG)"))
static unsigned canFoldIntoCSel(const MachineRegisterInfo &MRI, unsigned VReg, unsigned *NewVReg=nullptr)
static void genSubAdd2SubSub(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, SmallVectorImpl< MachineInstr * > &DelInstrs, unsigned IdxOpd1, DenseMap< Register, unsigned > &InstrIdxForVirtReg)
Do the following transformation A - (B + C) ==> (A - B) - C A - (B + C) ==> (A - C) - B.
static void signOutlinedFunction(MachineFunction &MF, MachineBasicBlock &MBB, const AArch64InstrInfo *TII, bool ShouldSignReturnAddr)
static MachineInstr * genFNegatedMAD(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs)
static bool canCombineWithMUL(MachineBasicBlock &MBB, MachineOperand &MO, unsigned MulOpc, unsigned ZeroReg)
static void storeRegPairToStackSlot(const TargetRegisterInfo &TRI, MachineBasicBlock &MBB, MachineBasicBlock::iterator InsertBefore, const MCInstrDesc &MCID, Register SrcReg, bool IsKill, unsigned SubIdx0, unsigned SubIdx1, int FI, MachineMemOperand *MMO)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
static const Function * getParent(const Value *V)
BlockVerifier::State From
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
const HexagonInstrInfo * TII
Module.h This file contains the declarations for the Module class.
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
Register const TargetRegisterInfo * TRI
static unsigned getReg(const MCDisassembler *D, unsigned RC, unsigned RegNo)
MachineInstr unsigned OpIdx
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
PowerPC Reduce CR logical Operation
const SmallVectorImpl< MachineOperand > MachineBasicBlock * TBB
const SmallVectorImpl< MachineOperand > & Cond
This file declares the machine register scavenger class.
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
This file defines the SmallSet class.
This file defines the SmallVector class.
static bool canCombine(MachineBasicBlock &MBB, MachineOperand &MO, unsigned CombineOpc=0)
AArch64FunctionInfo - This class is derived from MachineFunctionInfo and contains private AArch64-spe...
bool hasStreamingModeChanges() const
bool shouldSignReturnAddress(const MachineFunction &MF) const
void setOutliningStyle(const std::string &Style)
bool needsDwarfUnwindInfo(const MachineFunction &MF) const
std::optional< bool > hasRedZone() const
bool shouldSignWithBKey() const
static bool isHForm(const MachineInstr &MI)
Returns whether the instruction is in H form (16 bit operands)
void insertSelect(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, Register DstReg, ArrayRef< MachineOperand > Cond, Register TrueReg, Register FalseReg) const override
static bool hasBTISemantics(const MachineInstr &MI)
Returns whether the instruction can be compatible with non-zero BTYPE.
static bool isQForm(const MachineInstr &MI)
Returns whether the instruction is in Q form (128 bit operands)
static void decomposeStackOffsetForFrameOffsets(const StackOffset &Offset, int64_t &NumBytes, int64_t &NumPredicateVectors, int64_t &NumDataVectors)
Returns the offset in parts to which this frame offset can be decomposed for the purpose of describin...
static bool getMemOpInfo(unsigned Opcode, TypeSize &Scale, TypeSize &Width, int64_t &MinOffset, int64_t &MaxOffset)
Returns true if opcode Opc is a memory operation.
static bool isTailCallReturnInst(const MachineInstr &MI)
Returns true if MI is one of the TCRETURN* instructions.
static bool isFPRCopy(const MachineInstr &MI)
Does this instruction rename an FPR without modifying bits?
MachineInstr * emitLdStWithAddr(MachineInstr &MemI, const ExtAddrMode &AM) const override
std::optional< DestSourcePair > isCopyInstrImpl(const MachineInstr &MI) const override
If the specific machine instruction is an instruction that moves/copies value from one register to an...
MachineBasicBlock * getBranchDestBlock(const MachineInstr &MI) const override
std::optional< RegImmPair > isAddImmediate(const MachineInstr &MI, Register Reg) const override
unsigned getInstSizeInBytes(const MachineInstr &MI) const override
GetInstSize - Return the number of bytes of code the specified instruction may be.
uint64_t getElementSizeForOpcode(unsigned Opc) const
Returns the vector element size (B, H, S or D) of an SVE opcode.
bool areMemAccessesTriviallyDisjoint(const MachineInstr &MIa, const MachineInstr &MIb) const override
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, Register DestReg, Register SrcReg, bool KillSrc, bool RenamableDest=false, bool RenamableSrc=false) const override
static bool isGPRCopy(const MachineInstr &MI)
Does this instruction rename a GPR without modifying bits?
static unsigned convertToFlagSettingOpc(unsigned Opc)
Return the opcode that set flags when possible.
bool getMachineCombinerPatterns(MachineInstr &Root, SmallVectorImpl< unsigned > &Patterns, bool DoRegPressureReduce) const override
Return true when there is potentially a faster code sequence for an instruction chain ending in Root.
bool isBranchOffsetInRange(unsigned BranchOpc, int64_t BrOffset) const override
bool canInsertSelect(const MachineBasicBlock &, ArrayRef< MachineOperand > Cond, Register, Register, Register, int &, int &, int &) const override
static const MachineOperand & getLdStOffsetOp(const MachineInstr &MI)
Returns the immediate offset operator of a load/store.
bool isCoalescableExtInstr(const MachineInstr &MI, Register &SrcReg, Register &DstReg, unsigned &SubIdx) const override
bool isWhileOpcode(unsigned Opc) const
Returns true if the opcode is for an SVE WHILE## instruction.
static std::optional< unsigned > getUnscaledLdSt(unsigned Opc)
Returns the unscaled load/store for the scaled load/store opcode, if there is a corresponding unscale...
static bool hasUnscaledLdStOffset(unsigned Opc)
Return true if it has an unscaled load/store offset.
static const MachineOperand & getLdStAmountOp(const MachineInstr &MI)
Returns the shift amount operator of a load/store.
static bool isPreLdSt(const MachineInstr &MI)
Returns whether the instruction is a pre-indexed load/store.
bool isAccumulationOpcode(unsigned Opcode) const override
Returns true if \P Opcode is an instruction which performs accumulation into a destination register.
MachineBasicBlock::iterator insertOutlinedCall(Module &M, MachineBasicBlock &MBB, MachineBasicBlock::iterator &It, MachineFunction &MF, outliner::Candidate &C) const override
std::optional< ExtAddrMode > getAddrModeFromMemoryOp(const MachineInstr &MemI, const TargetRegisterInfo *TRI) const override
bool getMemOperandsWithOffsetWidth(const MachineInstr &MI, SmallVectorImpl< const MachineOperand * > &BaseOps, int64_t &Offset, bool &OffsetIsScalable, LocationSize &Width, const TargetRegisterInfo *TRI) const override
bool analyzeBranchPredicate(MachineBasicBlock &MBB, MachineBranchPredicate &MBP, bool AllowModify) const override
static bool isSEHInstruction(const MachineInstr &MI)
Return true if the instructions is a SEH instruction used for unwinding on Windows.
void insertIndirectBranch(MachineBasicBlock &MBB, MachineBasicBlock &NewDestBB, MachineBasicBlock &RestoreBB, const DebugLoc &DL, int64_t BrOffset, RegScavenger *RS) const override
SmallVector< std::pair< MachineBasicBlock::iterator, MachineBasicBlock::iterator > > getOutlinableRanges(MachineBasicBlock &MBB, unsigned &Flags) const override
static bool isPairableLdStInst(const MachineInstr &MI)
Return true if pairing the given load or store may be paired with another.
const AArch64RegisterInfo & getRegisterInfo() const
getRegisterInfo - TargetInstrInfo is a superset of MRegister info.
static bool isPreSt(const MachineInstr &MI)
Returns whether the instruction is a pre-indexed store.
MachineInstr * foldMemoryOperandImpl(MachineFunction &MF, MachineInstr &MI, ArrayRef< unsigned > Ops, MachineBasicBlock::iterator InsertPt, int FrameIndex, LiveIntervals *LIS=nullptr, VirtRegMap *VRM=nullptr) const override
void insertNoop(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const override
AArch64InstrInfo(const AArch64Subtarget &STI)
static bool isPairedLdSt(const MachineInstr &MI)
Returns whether the instruction is a paired load/store.
outliner::InstrType getOutliningTypeImpl(const MachineModuleInfo &MMI, MachineBasicBlock::iterator &MIT, unsigned Flags) const override
bool useMachineCombiner() const override
AArch64 supports MachineCombiner.
ArrayRef< std::pair< MachineMemOperand::Flags, const char * > > getSerializableMachineMemOperandTargetFlags() const override
void genAlternativeCodeSequence(MachineInstr &Root, unsigned Pattern, SmallVectorImpl< MachineInstr * > &InsInstrs, SmallVectorImpl< MachineInstr * > &DelInstrs, DenseMap< Register, unsigned > &InstrIdxForVirtReg) const override
When getMachineCombinerPatterns() finds patterns, this function generates the instructions that could...
bool isExtendLikelyToBeFolded(MachineInstr &ExtMI, MachineRegisterInfo &MRI) const override
static bool isFalkorShiftExtFast(const MachineInstr &MI)
Returns true if the instruction has a shift by immediate that can be executed in one cycle less.
std::optional< ParamLoadedValue > describeLoadedValue(const MachineInstr &MI, Register Reg) const override
bool getMemOperandWithOffsetWidth(const MachineInstr &MI, const MachineOperand *&BaseOp, int64_t &Offset, bool &OffsetIsScalable, TypeSize &Width, const TargetRegisterInfo *TRI) const
If OffsetIsScalable is set to 'true', the offset is scaled by vscale.
Register isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
unsigned getAccumulationStartOpcode(unsigned Opcode) const override
Returns an opcode which defines the accumulator used by \P Opcode.
static bool isStridedAccess(const MachineInstr &MI)
Return true if the given load or store is a strided memory access.
bool shouldClusterMemOps(ArrayRef< const MachineOperand * > BaseOps1, int64_t Offset1, bool OffsetIsScalable1, ArrayRef< const MachineOperand * > BaseOps2, int64_t Offset2, bool OffsetIsScalable2, unsigned ClusterSize, unsigned NumBytes) const override
Detect opportunities for ldp/stp formation.
bool expandPostRAPseudo(MachineInstr &MI) const override
unsigned int getTailDuplicateSize(CodeGenOptLevel OptLevel) const override
bool isFunctionSafeToOutlineFrom(MachineFunction &MF, bool OutlineFromLinkOnceODRs) const override
bool shouldOutlineFromFunctionByDefault(MachineFunction &MF) const override
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
bool isThroughputPattern(unsigned Pattern) const override
Return true when a code sequence can improve throughput.
void buildClearRegister(Register Reg, MachineBasicBlock &MBB, MachineBasicBlock::iterator Iter, DebugLoc &DL, bool AllowSideEffects=true) const override
void buildOutlinedFrame(MachineBasicBlock &MBB, MachineFunction &MF, const outliner::OutlinedFunction &OF) const override
ArrayRef< std::pair< unsigned, const char * > > getSerializableDirectMachineOperandTargetFlags() const override
MachineOperand & getMemOpBaseRegImmOfsOffsetOperand(MachineInstr &LdSt) const
Return the immediate offset of the base register in a load/store LdSt.
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify=false) const override
unsigned getReduceOpcodeForAccumulator(unsigned int AccumulatorOpCode) const override
bool canFoldIntoAddrMode(const MachineInstr &MemI, Register Reg, const MachineInstr &AddrI, ExtAddrMode &AM) const override
static bool isLdStPairSuppressed(const MachineInstr &MI)
Return true if pairing the given load or store is hinted to be unprofitable.
bool isFunctionSafeToSplit(const MachineFunction &MF) const override
bool isAssociativeAndCommutative(const MachineInstr &Inst, bool Invert) const override
Return true when Inst is associative and commutative so that it can be reassociated.
std::unique_ptr< TargetInstrInfo::PipelinerLoopInfo > analyzeLoopForPipelining(MachineBasicBlock *LoopBB) const override
bool isSchedulingBoundary(const MachineInstr &MI, const MachineBasicBlock *MBB, const MachineFunction &MF) const override
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
MachineBasicBlock::iterator probedStackAlloc(MachineBasicBlock::iterator MBBI, Register TargetReg, bool FrameSetup) const
bool optimizeCompareInstr(MachineInstr &CmpInstr, Register SrcReg, Register SrcReg2, int64_t CmpMask, int64_t CmpValue, const MachineRegisterInfo *MRI) const override
optimizeCompareInstr - Convert the instruction supplying the argument to the comparison into one that...
static unsigned getLoadStoreImmIdx(unsigned Opc)
Returns the index for the immediate for a given instruction.
static bool isGPRZero(const MachineInstr &MI)
Does this instruction set its full destination register to zero?
std::pair< unsigned, unsigned > decomposeMachineOperandsTargetFlags(unsigned TF) const override
void copyGPRRegTuple(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, bool KillSrc, unsigned Opcode, unsigned ZeroReg, llvm::ArrayRef< unsigned > Indices) const
bool analyzeCompare(const MachineInstr &MI, Register &SrcReg, Register &SrcReg2, int64_t &CmpMask, int64_t &CmpValue) const override
analyzeCompare - For a comparison instruction, return the source registers in SrcReg and SrcReg2,...
CombinerObjective getCombinerObjective(unsigned Pattern) const override
static bool isFpOrNEON(Register Reg)
Returns whether the physical register is FP or NEON.
bool isMBBSafeToSplitToCold(const MachineBasicBlock &MBB) const override
bool isAsCheapAsAMove(const MachineInstr &MI) const override
bool isLegalAddressingMode(unsigned NumBytes, int64_t Offset, unsigned Scale) const
std::optional< std::unique_ptr< outliner::OutlinedFunction > > getOutliningCandidateInfo(const MachineModuleInfo &MMI, std::vector< outliner::Candidate > &RepeatedSequenceLocs, unsigned MinRepeats) const override
std::optional< DestSourcePair > isCopyLikeInstrImpl(const MachineInstr &MI) const override
static void suppressLdStPair(MachineInstr &MI)
Hint that pairing the given load or store is unprofitable.
Register isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
static bool isPreLd(const MachineInstr &MI)
Returns whether the instruction is a pre-indexed load.
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI, Register VReg, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
ArrayRef< std::pair< unsigned, const char * > > getSerializableBitmaskMachineOperandTargetFlags() const override
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI, Register VReg, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
void copyPhysRegTuple(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, bool KillSrc, unsigned Opcode, llvm::ArrayRef< unsigned > Indices) const
bool optimizeCondBranch(MachineInstr &MI) const override
Replace csincr-branch sequence by simple conditional branch.
static int getMemScale(unsigned Opc)
Scaling factor for (scaled or unscaled) load or store.
bool isCandidateToMergeOrPair(const MachineInstr &MI) const
Return true if this is a load/store that can be potentially paired/merged.
MCInst getNop() const override
static const MachineOperand & getLdStBaseOp(const MachineInstr &MI)
Returns the base register operator of a load/store.
bool isPTestLikeOpcode(unsigned Opc) const
Returns true if the opcode is for an SVE instruction that sets the condition codes as if it's results...
void mergeOutliningCandidateAttributes(Function &F, std::vector< outliner::Candidate > &Candidates) const override
static void decomposeStackOffsetForDwarfOffsets(const StackOffset &Offset, int64_t &ByteSized, int64_t &VGSized)
bool isReservedReg(const MachineFunction &MF, MCRegister Reg) const
const AArch64RegisterInfo * getRegisterInfo() const override
bool isNeonAvailable() const
Returns true if the target has NEON and the function at runtime is known to have NEON enabled (e....
bool isTargetILP32() const
bool isSVEorStreamingSVEAvailable() const
Returns true if the target has access to either the full range of SVE instructions,...
unsigned ClassifyGlobalReference(const GlobalValue *GV, const TargetMachine &TM) const
ClassifyGlobalReference - Find the target operand flags that describe how a global value should be re...
bool isLittleEndian() const
unsigned getSVEVectorSizeInBits() const
AArch64PAuth::AuthCheckMethod getAuthenticatedLRCheckMethod(const MachineFunction &MF) const
Choose a method of checking LR before performing a tail call.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
const T & front() const
front - Get the first element.
size_t size() const
size - Get the array size.
Helper class for creating CFI instructions and inserting them into MIR.
void buildDefCFAOffset(int64_t Offset, MCSymbol *Label=nullptr) const
void buildOffset(MCRegister Reg, int64_t Offset) const
This is an important base class in LLVM.
This class represents an Operation in the Expression.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
bool hasOptSize() const
Optimize this function for size (-Os) or minimum size (-Oz).
bool hasMinSize() const
Optimize this function for minimum size (-Oz).
Module * getParent()
Get the module that this global value is contained inside of...
A set of register units used to track register liveness.
bool available(MCRegister Reg) const
Returns true if no part of physical register Reg is live.
LLVM_ABI void stepBackward(const MachineInstr &MI)
Updates liveness when stepping backwards over the instruction MI.
LLVM_ABI void addLiveOuts(const MachineBasicBlock &MBB)
Adds registers living out of block MBB.
static LocationSize precise(uint64_t Value)
This class is intended to be used as a base class for asm properties and features specific to the tar...
bool usesWindowsCFI() const
static MCCFIInstruction cfiDefCfa(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_def_cfa defines a rule for computing CFA as: take address from Register and add Offset to it.
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
static MCCFIInstruction cfiDefCfaOffset(MCSymbol *L, int64_t Offset, SMLoc Loc={})
.cfi_def_cfa_offset modifies a rule for computing CFA.
static MCCFIInstruction createEscape(MCSymbol *L, StringRef Vals, SMLoc Loc={}, StringRef Comment="")
.cfi_escape Allows the user to add arbitrary bytes to the unwind info.
MCInstBuilder & addImm(int64_t Val)
Add a new integer immediate operand.
Instances of this class represent a single low-level machine instruction.
Describe properties that are true of each instruction in the target description file.
Wrapper class representing physical registers. Should be passed by value.
constexpr bool isValid() const
static constexpr unsigned NoRegister
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
bool isInlineAsmBrIndirectTarget() const
Returns true if this is the indirect dest of an INLINEASM_BR.
unsigned pred_size() const
LLVM_ABI void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)
Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...
LLVM_ABI instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
reverse_instr_iterator instr_rbegin()
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
LLVM_ABI iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
MBBSectionID getSectionID() const
Returns the section ID of this basic block.
LLVM_ABI void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
reverse_instr_iterator instr_rend()
LLVM_ABI DebugLoc findDebugLoc(instr_iterator MBBI)
Find the next valid DebugLoc starting at MBBI, skipping any debug instructions.
Instructions::iterator instr_iterator
LLVM_ABI iterator getLastNonDebugInstr(bool SkipPseudoOp=true)
Returns an iterator to the last non-debug instruction in the basic block, or end().
LLVM_ABI bool isLayoutSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB will be emitted immediately after this block, such that if this bloc...
instr_iterator instr_end()
Instructions::const_iterator const_instr_iterator
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
LLVM_ABI instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
iterator_range< succ_iterator > successors()
LLVM_ABI instr_iterator getFirstInstrTerminator()
Same getFirstTerminator but it ignores bundles and return an instr_iterator instead.
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
MachineInstrBundleIterator< MachineInstr > iterator
void setMachineBlockAddressTaken()
Set this block to indicate that its address is used as something other than the target of a terminato...
LLVM_ABI bool isLiveIn(MCRegister Reg, LaneBitmask LaneMask=LaneBitmask::getAll()) const
Return true if the specified register is in the live in set.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects.
void setStackID(int ObjectIdx, uint8_t ID)
bool isCalleeSavedInfoValid() const
Has the callee saved info been calculated yet?
Align getObjectAlign(int ObjectIdx) const
Return the alignment of the specified stack object.
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
unsigned getNumObjects() const
Return the number of objects.
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
bool isFixedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a fixed stack object.
unsigned addFrameInst(const MCCFIInstruction &Inst)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, LLT MemTy, Align base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
MachineInstr * CloneMachineInstr(const MachineInstr *Orig)
Create a new MachineInstr which is a copy of Orig, identical in all ways except the instruction has n...
const MachineJumpTableInfo * getJumpTableInfo() const
getJumpTableInfo - Return the jump table info object for the current function.
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *BB=nullptr, std::optional< UniqueBBID > BBID=std::nullopt)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
void insert(iterator MBBI, MachineBasicBlock *MBB)
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
Register getReg(unsigned Idx) const
Get the register for the operand index.
const MachineInstrBuilder & setMemRefs(ArrayRef< MachineMemOperand * > MMOs) const
const MachineInstrBuilder & addCFIIndex(unsigned CFIIndex) const
const MachineInstrBuilder & setMIFlag(MachineInstr::MIFlag Flag) const
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & add(const MachineOperand &MO) const
const MachineInstrBuilder & addSym(MCSymbol *Sym, unsigned char TargetFlags=0) const
const MachineInstrBuilder & addFrameIndex(int Idx) const
const MachineInstrBuilder & addGlobalAddress(const GlobalValue *GV, int64_t Offset=0, unsigned TargetFlags=0) const
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
const MachineInstrBuilder & addUse(Register RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register use operand.
const MachineInstrBuilder & setMIFlags(unsigned Flags) const
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
const MachineInstrBuilder & addDef(Register RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register definition operand.
reverse_iterator getReverse() const
Get a reverse iterator to the same node.
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
bool mayLoadOrStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read or modify memory.
const MachineBasicBlock * getParent() const
bool isCall(QueryType Type=AnyInBundle) const
bool getFlag(MIFlag Flag) const
Return whether an MI flag is set.
LLVM_ABI uint32_t mergeFlagsWith(const MachineInstr &Other) const
Return the MIFlags which represent both MachineInstrs.
unsigned getNumOperands() const
Retuns the total number of operands.
LLVM_ABI unsigned getNumExplicitOperands() const
Returns the number of non-implicit operands.
bool mayLoad(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read memory.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
LLVM_ABI bool hasUnmodeledSideEffects() const
Return true if this instruction has side effects that are not modeled by mayLoad / mayStore,...
bool registerDefIsDead(Register Reg, const TargetRegisterInfo *TRI) const
Returns true if the register is dead in this machine instruction.
bool definesRegister(Register Reg, const TargetRegisterInfo *TRI) const
Return true if the MachineInstr fully defines the specified register.
LLVM_ABI void setDesc(const MCInstrDesc &TID)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one.
LLVM_ABI bool hasOrderedMemoryRef() const
Return true if this instruction may have an ordered or volatile memory reference, or if the informati...
LLVM_ABI const MachineFunction * getMF() const
Return the function that contains the basic block that this instruction belongs to.
ArrayRef< MachineMemOperand * > memoperands() const
Access to memory operands of the instruction.
LLVM_ABI bool isLoadFoldBarrier() const
Returns true if it is illegal to fold a load across this instruction.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
LLVM_ABI void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
LLVM_ABI void removeOperand(unsigned OpNo)
Erase an operand from an instruction, leaving it with one fewer operand than it started with.
LLVM_ABI void addRegisterDefined(Register Reg, const TargetRegisterInfo *RegInfo=nullptr)
We have determined MI defines a register.
const MachineOperand & getOperand(unsigned i) const
uint32_t getFlags() const
Return the MI flags bitvector.
LLVM_ABI int findRegisterDefOperandIdx(Register Reg, const TargetRegisterInfo *TRI, bool isDead=false, bool Overlap=false) const
Returns the operand index that is a def of the specified register or -1 if it is not found.
const std::vector< MachineJumpTableEntry > & getJumpTables() const
A description of a memory reference used in the backend.
@ MOLoad
The memory access reads data.
@ MOStore
The memory access writes data.
This class contains meta information specific to a module.
LLVM_ABI MachineFunction * getMachineFunction(const Function &F) const
Returns the MachineFunction associated to IR function F if there is one, otherwise nullptr.
MachineOperand class - Representation of each machine instruction operand.
void setSubReg(unsigned subReg)
unsigned getSubReg() const
void setImm(int64_t immVal)
bool isReg() const
isReg - Tests if this is a MO_Register operand.
MachineBasicBlock * getMBB() const
void setIsDead(bool Val=true)
LLVM_ABI void setReg(Register Reg)
Change the register this operand corresponds to.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
void setIsKill(bool Val=true)
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
static MachineOperand CreateImm(int64_t Val)
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
void setIsUndef(bool Val=true)
Register getReg() const
getReg - Returns the register number.
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
LLVM_ABI bool isIdenticalTo(const MachineOperand &Other) const
Returns true if this operand is identical to the specified operand except for liveness related flags ...
static MachineOperand CreateReg(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
bool tracksLiveness() const
tracksLiveness - Returns true when tracking register liveness accurately.
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 reservedRegsFrozen() const
reservedRegsFrozen - Returns true after freezeReservedRegs() was called to ensure the set of reserved...
const TargetRegisterClass * getRegClassOrNull(Register Reg) const
Return the register class of Reg, or null if Reg has not been assigned a register class yet.
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...
LLVM_ABI MachineInstr * getUniqueVRegDef(Register Reg) const
getUniqueVRegDef - Return the unique machine instr that defines the specified virtual register or nul...
A Module instance is used to store all the information related to an LLVM module.
MI-level patchpoint operands.
uint32_t getNumPatchBytes() const
Return the number of patchable bytes the given patchpoint should emit.
void enterBasicBlockEnd(MachineBasicBlock &MBB)
Start tracking liveness from the end of basic block MBB.
bool isRegUsed(Register Reg, bool includeReserved=true) const
Return if a specific register is currently used.
Register FindUnusedReg(const TargetRegisterClass *RC) const
Find an unused register of the specified register class.
void setRegUsed(Register Reg, LaneBitmask LaneMask=LaneBitmask::getAll())
Tell the scavenger a register is used.
Wrapper class representing virtual and physical registers.
MCRegister asMCReg() const
Utility to check-convert this value to a MCRegister.
constexpr bool isValid() const
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
static constexpr bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
Represents a location in source code.
bool erase(PtrType Ptr)
Remove pointer from the set.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
void append(StringRef RHS)
Append from a StringRef.
StringRef str() const
Explicit conversion to StringRef.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
MI-level stackmap operands.
uint32_t getNumPatchBytes() const
Return the number of patchable bytes the given stackmap should emit.
StackOffset holds a fixed and a scalable offset in bytes.
int64_t getFixed() const
Returns the fixed component of the stack.
int64_t getScalable() const
Returns the scalable component of the stack.
static StackOffset get(int64_t Fixed, int64_t Scalable)
static StackOffset getScalable(int64_t Scalable)
static StackOffset getFixed(int64_t Fixed)
MI-level Statepoint operands.
uint32_t getNumPatchBytes() const
Return the number of patchable bytes the given statepoint should emit.
StringRef - Represent a constant reference to a string, i.e.
Object returned by analyzeLoopForPipelining.
TargetInstrInfo - Interface to description of machine instruction set.
virtual void genAlternativeCodeSequence(MachineInstr &Root, unsigned Pattern, SmallVectorImpl< MachineInstr * > &InsInstrs, SmallVectorImpl< MachineInstr * > &DelInstrs, DenseMap< Register, unsigned > &InstIdxForVirtReg) const
When getMachineCombinerPatterns() finds patterns, this function generates the instructions that could...
virtual std::optional< ParamLoadedValue > describeLoadedValue(const MachineInstr &MI, Register Reg) const
Produce the expression describing the MI loading a value into the physical register Reg.
virtual bool getMachineCombinerPatterns(MachineInstr &Root, SmallVectorImpl< unsigned > &Patterns, bool DoRegPressureReduce) const
Return true when there is potentially a faster code sequence for an instruction chain ending in Root.
virtual bool isSchedulingBoundary(const MachineInstr &MI, const MachineBasicBlock *MBB, const MachineFunction &MF) const
Test if the given instruction should be considered a scheduling boundary.
virtual CombinerObjective getCombinerObjective(unsigned Pattern) const
Return the objective of a combiner pattern.
virtual bool isFunctionSafeToSplit(const MachineFunction &MF) const
Return true if the function is a viable candidate for machine function splitting.
Primary interface to the complete machine description for the target machine.
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
bool contains(Register Reg) const
Return true if the specified register is included in this register class.
bool hasSubClassEq(const TargetRegisterClass *RC) const
Returns true if RC is a sub-class of or equal to this class.
bool hasSuperClassEq(const TargetRegisterClass *RC) const
Returns true if RC is a super-class of or equal to this class.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
TargetSubtargetInfo - Generic base class for all target subtargets.
virtual const TargetInstrInfo * getInstrInfo() const
virtual const TargetRegisterInfo * getRegisterInfo() const =0
Return the target's register information.
Target - Wrapper for Target specific information.
static constexpr TypeSize getFixed(ScalarTy ExactSize)
static constexpr TypeSize getScalable(ScalarTy MinimumSize)
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
self_iterator getIterator()
NodeTy * getNextNode()
Get the next node, or nullptr for the list tail.
A raw_ostream that writes to an std::string.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static CondCode getInvertedCondCode(CondCode Code)
@ MO_NC
MO_NC - Indicates whether the linker is expected to check the symbol reference for overflow.
@ MO_G1
MO_G1 - A symbol operand with this flag (granule 1) represents the bits 16-31 of a 64-bit address,...
@ MO_PAGEOFF
MO_PAGEOFF - A symbol operand with this flag represents the offset of that symbol within a 4K page.
@ MO_GOT
MO_GOT - This flag indicates that a symbol operand represents the address of the GOT entry for the sy...
@ MO_G0
MO_G0 - A symbol operand with this flag (granule 0) represents the bits 0-15 of a 64-bit address,...
@ MO_PAGE
MO_PAGE - A symbol operand with this flag represents the pc-relative offset of the 4K page containing...
@ MO_G2
MO_G2 - A symbol operand with this flag (granule 2) represents the bits 32-47 of a 64-bit address,...
@ MO_G3
MO_G3 - A symbol operand with this flag (granule 3) represents the high 16-bits of a 64-bit address,...
unsigned getCheckerSizeInBytes(AuthCheckMethod Method)
Returns the number of bytes added by checkAuthenticatedRegister.
static uint64_t decodeLogicalImmediate(uint64_t val, unsigned regSize)
decodeLogicalImmediate - Decode a logical immediate value in the form "N:immr:imms" (where the immr a...
static unsigned getShiftValue(unsigned Imm)
getShiftValue - Extract the shift value.
static unsigned getArithExtendImm(AArch64_AM::ShiftExtendType ET, unsigned Imm)
getArithExtendImm - Encode the extend type and shift amount for an arithmetic instruction: imm: 3-bit...
static unsigned getArithShiftValue(unsigned Imm)
getArithShiftValue - get the arithmetic shift value.
static uint64_t encodeLogicalImmediate(uint64_t imm, unsigned regSize)
encodeLogicalImmediate - Return the encoded immediate value for a logical immediate instruction of th...
static AArch64_AM::ShiftExtendType getArithExtendType(unsigned Imm)
static AArch64_AM::ShiftExtendType getShiftType(unsigned Imm)
getShiftType - Extract the shift type.
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 expandMOVImm(uint64_t Imm, unsigned BitSize, SmallVectorImpl< ImmInsnModel > &Insn)
Expand a MOVi32imm or MOVi64imm pseudo instruction to one or more real move-immediate instructions to...
static const uint64_t InstrFlagIsWhile
static const uint64_t InstrFlagIsPTestLike
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
@ C
The default llvm calling convention, compatible with C.
@ Implicit
Not emitted register (e.g. carry, or temporary result).
@ Renamable
Register that may be renamed.
@ Define
Register definition.
@ Kill
The last use of a register.
@ Undef
Value of the register doesn't matter.
Reg
All possible values of the reg field in the ModR/M byte.
initializer< Ty > init(const Ty &Val)
InstrType
Represents how an instruction should be mapped by the outliner.
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
static bool isCondBranchOpcode(int Opc)
std::pair< MachineOperand, DIExpression * > ParamLoadedValue
MCCFIInstruction createDefCFA(const TargetRegisterInfo &TRI, unsigned FrameReg, unsigned Reg, const StackOffset &Offset, bool LastAdjustmentWasScalable=true)
static bool isPTrueOpcode(unsigned Opc)
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
bool succeeded(LogicalResult Result)
Utility function that returns true if the provided LogicalResult corresponds to a success value.
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.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
static bool isIndirectBranchOpcode(int Opc)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
unsigned getBLRCallOpcode(const MachineFunction &MF)
Return opcode to be used for indirect calls.
@ AArch64FrameOffsetIsLegal
Offset is legal.
@ AArch64FrameOffsetCanUpdate
Offset can apply, at least partly.
@ AArch64FrameOffsetCannotUpdate
Offset cannot apply.
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
unsigned Log2_64(uint64_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
auto reverse(ContainerTy &&C)
MachineInstr * getImm(const MachineOperand &MO, const MachineRegisterInfo *MRI)
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
void sort(IteratorTy Start, IteratorTy End)
AArch64MachineCombinerPattern
@ MULSUBv2i32_indexed_OP1
@ MULADDv4i16_indexed_OP2
@ MULSUBv8i16_indexed_OP2
@ MULSUBv4i16_indexed_OP2
@ MULSUBv4i32_indexed_OP2
@ MULADDv2i32_indexed_OP1
@ MULADDv4i32_indexed_OP1
@ MULADDv2i32_indexed_OP2
@ MULSUBv4i16_indexed_OP1
@ MULADDv4i32_indexed_OP2
@ MULSUBv8i16_indexed_OP1
@ MULSUBv2i32_indexed_OP2
@ MULADDv8i16_indexed_OP1
@ MULSUBv4i32_indexed_OP1
@ MULADDv8i16_indexed_OP2
@ MULADDv4i16_indexed_OP1
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)
CombinerObjective
The combiner's goal may differ based on which pattern it is attempting to optimize.
std::optional< UsedNZCV > examineCFlagsUse(MachineInstr &MI, MachineInstr &CmpInstr, const TargetRegisterInfo &TRI, SmallVectorImpl< MachineInstr * > *CCUseInstrs=nullptr)
CodeGenOptLevel
Code generation optimization level.
auto instructionsWithoutDebug(IterT It, IterT End, bool SkipPseudoOp=true)
Construct a range iterator which begins at It and moves forwards until End is reached,...
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
auto drop_end(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the last N elements excluded.
unsigned getUndefRegState(bool B)
static MCRegister getXRegFromWReg(MCRegister Reg)
unsigned getDefRegState(bool B)
MCCFIInstruction createCFAOffset(const TargetRegisterInfo &MRI, unsigned Reg, const StackOffset &OffsetFromDefCFA, std::optional< int64_t > IncomingVGOffsetFromDefCFA)
unsigned getKillRegState(bool B)
DWARFExpression::Operation Op
static bool isUncondBranchOpcode(int Opc)
void erase_if(Container &C, UnaryPredicate P)
Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...
constexpr bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
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.
static const MachineMemOperand::Flags MOSuppressPair
constexpr int64_t SignExtend64(uint64_t x)
Sign-extend the number in the bottom B bits of X to a 64-bit integer.
bool isNZCVTouchedInInstructionRange(const MachineInstr &DefMI, const MachineInstr &UseMI, const TargetRegisterInfo *TRI)
Return true if there is an instruction /after/ DefMI and before UseMI which either reads or clobbers ...
static const MachineMemOperand::Flags MOStridedAccess
@ Default
The result values are uniform if and only if all operands are uniform.
void fullyRecomputeLiveIns(ArrayRef< MachineBasicBlock * > MBBs)
Convenience function for recomputing live-in's for a set of MBBs until the computation converges.
LLVM_ABI Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
Description of the encoding of one expression Op.
Used to describe addressing mode similar to ExtAddrMode in CodeGenPrepare.
LLVM_ABI static const MBBSectionID ColdSectionID
MachineJumpTableEntry - One jump table in the jump table info.
This class contains a discriminated union of information about pointers in memory operands,...
static LLVM_ABI MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
Used to describe a register and immediate addition.
An individual sequence of instructions to be replaced with a call to an outlined function.
MachineFunction * getMF() const
The information necessary to create an outlined function for some class of candidate.