66#define GET_INSTRINFO_CTOR_DTOR
67#include "AArch64GenInstrInfo.inc"
69#define DEBUG_TYPE "AArch64InstrInfo"
71STATISTIC(NumCopyInstrs,
"Number of COPY instructions expanded");
72STATISTIC(NumZCRegMoveInstrsGPR,
"Number of zero-cycle GPR register move "
73 "instructions expanded from canonical COPY");
74STATISTIC(NumZCRegMoveInstrsFPR,
"Number of zero-cycle FPR register move "
75 "instructions expanded from canonical COPY");
76STATISTIC(NumZCZeroingInstrsGPR,
"Number of zero-cycle GPR zeroing "
77 "instructions expanded from canonical COPY");
82 cl::desc(
"Restrict range of CB instructions (DEBUG)"));
86 cl::desc(
"Restrict range of TB[N]Z instructions (DEBUG)"));
90 cl::desc(
"Restrict range of CB[N]Z instructions (DEBUG)"));
94 cl::desc(
"Restrict range of Bcc instructions (DEBUG)"));
98 cl::desc(
"Restrict range of B instructions (DEBUG)"));
102 cl::desc(
"Restrict range of instructions to search for the "
103 "machine-combiner gather pattern optimization"));
108 RI(STI.getTargetTriple(), STI.getHwMode()), Subtarget(STI) {}
119 auto Op =
MI.getOpcode();
120 if (
Op == AArch64::INLINEASM ||
Op == AArch64::INLINEASM_BR)
121 return getInlineAsmLength(
MI.getOperand(0).getSymbolName(), *MAI);
125 if (
MI.isMetaInstruction())
130 unsigned NumBytes = 0;
134 NumBytes =
Desc.getSize() ?
Desc.getSize() : 4;
137 if (!MFI->shouldSignReturnAddress(*MF))
141 auto Method = STI.getAuthenticatedLRCheckMethod(*MF);
149 switch (
Desc.getOpcode()) {
152 return Desc.getSize();
159 case TargetOpcode::STACKMAP:
162 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
164 case TargetOpcode::PATCHPOINT:
167 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
169 case TargetOpcode::STATEPOINT:
171 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
176 case TargetOpcode::PATCHABLE_FUNCTION_ENTER:
181 F.getFnAttributeAsParsedInteger(
"patchable-function-entry", 9) * 4;
183 case TargetOpcode::PATCHABLE_FUNCTION_EXIT:
184 case TargetOpcode::PATCHABLE_TAIL_CALL:
185 case TargetOpcode::PATCHABLE_TYPED_EVENT_CALL:
189 case TargetOpcode::PATCHABLE_EVENT_CALL:
195 NumBytes =
MI.getOperand(1).getImm();
197 case TargetOpcode::BUNDLE:
198 NumBytes = getInstBundleLength(
MI);
205unsigned AArch64InstrInfo::getInstBundleLength(
const MachineInstr &
MI)
const {
209 while (++
I != E &&
I->isInsideBundle()) {
210 assert(!
I->isBundle() &&
"No nested bundle!");
245 case AArch64::CBWPri:
246 case AArch64::CBXPri:
247 case AArch64::CBWPrr:
248 case AArch64::CBXPrr:
256 case AArch64::CBBAssertExt:
257 case AArch64::CBHAssertExt:
288 case AArch64::CBWPri:
289 case AArch64::CBXPri:
290 case AArch64::CBBAssertExt:
291 case AArch64::CBHAssertExt:
292 case AArch64::CBWPrr:
293 case AArch64::CBXPrr:
299 int64_t BrOffset)
const {
301 assert(Bits >= 3 &&
"max branch displacement must be enough to jump"
302 "over conditional branch expansion");
303 return isIntN(Bits, BrOffset / 4);
308 switch (
MI.getOpcode()) {
312 return MI.getOperand(0).getMBB();
317 return MI.getOperand(2).getMBB();
323 return MI.getOperand(1).getMBB();
324 case AArch64::CBWPri:
325 case AArch64::CBXPri:
326 case AArch64::CBBAssertExt:
327 case AArch64::CBHAssertExt:
328 case AArch64::CBWPrr:
329 case AArch64::CBXPrr:
330 return MI.getOperand(3).getMBB();
340 assert(RS &&
"RegScavenger required for long branching");
342 "new block should be inserted for expanding unconditional branch");
345 "restore block should be inserted for restoring clobbered registers");
352 "Branch offsets outside of the signed 33-bit range not supported");
363 RS->enterBasicBlockEnd(
MBB);
366 constexpr Register Reg = AArch64::X16;
367 if (!RS->isRegUsed(Reg)) {
368 insertUnconditionalBranch(
MBB, &NewDestBB,
DL);
375 Register Scavenged = RS->FindUnusedReg(&AArch64::GPR64RegClass);
376 if (Scavenged != AArch64::NoRegister &&
378 buildIndirectBranch(Scavenged, NewDestBB);
379 RS->setRegUsed(Scavenged);
388 "Unable to insert indirect branch inside function that has red zone");
411 bool AllowModify)
const {
418 if (
I->getOpcode() == AArch64::SpeculationBarrierISBDSBEndBB ||
419 I->getOpcode() == AArch64::SpeculationBarrierSBEndBB) {
423 if (!isUnpredicatedTerminator(*
I))
430 unsigned LastOpc = LastInst->
getOpcode();
431 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
446 unsigned SecondLastOpc = SecondLastInst->
getOpcode();
453 LastInst = SecondLastInst;
455 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
460 SecondLastInst = &*
I;
461 SecondLastOpc = SecondLastInst->
getOpcode();
472 LastInst = SecondLastInst;
474 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
476 "unreachable unconditional branches removed above");
485 SecondLastInst = &*
I;
486 SecondLastOpc = SecondLastInst->
getOpcode();
490 if (SecondLastInst &&
I !=
MBB.begin() && isUnpredicatedTerminator(*--
I))
506 I->eraseFromParent();
515 I->eraseFromParent();
524 MachineBranchPredicate &MBP,
525 bool AllowModify)
const {
537 assert(MBP.TrueDest &&
"expected!");
538 MBP.FalseDest = FBB ? FBB :
MBB.getNextNode();
540 MBP.ConditionDef =
nullptr;
541 MBP.SingleUseCondition =
false;
551 if (
I ==
MBB.begin())
567 if (
MI.modifiesRegister(AArch64::NZCV,
nullptr)) {
568 MBP.ConditionDef = &
MI;
577 case AArch64::CBNZX: {
581 MBP.Predicate = (
Opc == AArch64::CBNZX ||
Opc == AArch64::CBNZW)
582 ? MachineBranchPredicate::PRED_NE
583 : MachineBranchPredicate::PRED_EQ;
584 Register CondReg = MBP.LHS.getReg();
593 case AArch64::TBNZX: {
614 Cond[1].setImm(AArch64::CBNZW);
617 Cond[1].setImm(AArch64::CBZW);
620 Cond[1].setImm(AArch64::CBNZX);
623 Cond[1].setImm(AArch64::CBZX);
626 Cond[1].setImm(AArch64::TBNZW);
629 Cond[1].setImm(AArch64::TBZW);
632 Cond[1].setImm(AArch64::TBNZX);
635 Cond[1].setImm(AArch64::TBZX);
639 case AArch64::CBWPri:
640 case AArch64::CBXPri:
641 case AArch64::CBBAssertExt:
642 case AArch64::CBHAssertExt:
643 case AArch64::CBWPrr:
644 case AArch64::CBXPrr: {
657 int *BytesRemoved)
const {
667 I->eraseFromParent();
671 if (
I ==
MBB.begin()) {
684 I->eraseFromParent();
691void AArch64InstrInfo::instantiateCondBranch(
716 if (
Cond.size() > 5) {
727 assert(
TBB &&
"insertBranch must not be told to insert a fallthrough");
754 unsigned Opc =
MI.getOpcode();
761 if (
MI.getOperand(0).getReg() == AArch64::WZR ||
762 MI.getOperand(0).getReg() == AArch64::XZR) {
764 dbgs() <<
"Removing always taken branch: " <<
MI);
767 for (
auto *S : Succs)
769 MBB->removeSuccessor(S);
771 while (
MBB->rbegin() != &
MI)
772 MBB->rbegin()->eraseFromParent();
773 MI.eraseFromParent();
783 if (
MI.getOperand(0).getReg() == AArch64::WZR ||
784 MI.getOperand(0).getReg() == AArch64::XZR) {
786 dbgs() <<
"Removing never taken branch: " <<
MI);
788 MI.getParent()->removeSuccessor(
Target);
789 MI.eraseFromParent();
802 if (!
DefMI->isFullCopy())
804 VReg =
DefMI->getOperand(1).getReg();
813 unsigned *NewReg =
nullptr) {
818 bool Is64Bit = AArch64::GPR64allRegClass.hasSubClassEq(MRI.
getRegClass(VReg));
822 switch (
DefMI->getOpcode()) {
823 case AArch64::SUBREG_TO_REG:
827 if (!
DefMI->getOperand(1).isReg())
829 if (!
DefMI->getOperand(2).isImm() ||
830 DefMI->getOperand(2).getImm() != AArch64::sub_32)
833 if (
DefMI->getOpcode() != AArch64::MOVi32imm)
835 if (!
DefMI->getOperand(1).isImm() ||
DefMI->getOperand(1).getImm() != 1)
838 SrcReg = AArch64::XZR;
839 Opc = AArch64::CSINCXr;
842 case AArch64::MOVi32imm:
843 case AArch64::MOVi64imm:
844 if (!
DefMI->getOperand(1).isImm() ||
DefMI->getOperand(1).getImm() != 1)
846 SrcReg = Is64Bit ? AArch64::XZR : AArch64::WZR;
847 Opc = Is64Bit ? AArch64::CSINCXr : AArch64::CSINCWr;
850 case AArch64::ADDSXri:
851 case AArch64::ADDSWri:
853 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
858 case AArch64::ADDXri:
859 case AArch64::ADDWri:
861 if (!
DefMI->getOperand(2).isImm() ||
DefMI->getOperand(2).getImm() != 1 ||
862 DefMI->getOperand(3).getImm() != 0)
864 SrcReg =
DefMI->getOperand(1).getReg();
865 Opc = Is64Bit ? AArch64::CSINCXr : AArch64::CSINCWr;
868 case AArch64::ORNXrr:
869 case AArch64::ORNWrr: {
872 if (ZReg != AArch64::XZR && ZReg != AArch64::WZR)
874 SrcReg =
DefMI->getOperand(2).getReg();
875 Opc = Is64Bit ? AArch64::CSINVXr : AArch64::CSINVWr;
879 case AArch64::SUBSXrr:
880 case AArch64::SUBSWrr:
882 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
887 case AArch64::SUBXrr:
888 case AArch64::SUBWrr: {
891 if (ZReg != AArch64::XZR && ZReg != AArch64::WZR)
893 SrcReg =
DefMI->getOperand(2).getReg();
894 Opc = Is64Bit ? AArch64::CSNEGXr : AArch64::CSNEGWr;
900 assert(
Opc && SrcReg &&
"Missing parameters");
912 int &FalseCycles)
const {
923 if (!RI.getCommonSubClass(RC, MRI.
getRegClass(DstReg)))
927 unsigned ExtraCondLat =
Cond.size() != 1;
931 if (AArch64::GPR64allRegClass.hasSubClassEq(RC) ||
932 AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
934 CondCycles = 1 + ExtraCondLat;
935 TrueCycles = FalseCycles = 1;
945 if (AArch64::FPR64RegClass.hasSubClassEq(RC) ||
946 AArch64::FPR32RegClass.hasSubClassEq(RC)) {
947 CondCycles = 5 + ExtraCondLat;
948 TrueCycles = FalseCycles = 2;
965 switch (
Cond.size()) {
1020 case AArch64::TBNZW:
1021 case AArch64::TBNZX:
1043 unsigned SubsOpc, SubsDestReg;
1049 case AArch64::CBWPri:
1050 SubsOpc = AArch64::SUBSWri;
1051 SubsDestReg = AArch64::WZR;
1054 case AArch64::CBXPri:
1055 SubsOpc = AArch64::SUBSXri;
1056 SubsDestReg = AArch64::XZR;
1059 case AArch64::CBWPrr:
1060 SubsOpc = AArch64::SUBSWrr;
1061 SubsDestReg = AArch64::WZR;
1064 case AArch64::CBXPrr:
1065 SubsOpc = AArch64::SUBSXrr;
1066 SubsDestReg = AArch64::XZR;
1095 switch (ExtendType) {
1101 "Unexpected compare-and-branch instruction for SXTB shift-extend");
1102 ExtOpc = AArch64::SBFMWri;
1108 "Unexpected compare-and-branch instruction for SXTH shift-extend");
1109 ExtOpc = AArch64::SBFMWri;
1115 "Unexpected compare-and-branch instruction for UXTB shift-extend");
1116 ExtOpc = AArch64::ANDWri;
1122 "Unexpected compare-and-branch instruction for UXTH shift-extend");
1123 ExtOpc = AArch64::ANDWri;
1132 if (ExtOpc != AArch64::ANDWri)
1134 MBBI.addImm(ExtBits);
1162 bool TryFold =
false;
1164 RC = &AArch64::GPR64RegClass;
1165 Opc = AArch64::CSELXr;
1168 RC = &AArch64::GPR32RegClass;
1169 Opc = AArch64::CSELWr;
1172 RC = &AArch64::FPR64RegClass;
1173 Opc = AArch64::FCSELDrrr;
1175 RC = &AArch64::FPR32RegClass;
1176 Opc = AArch64::FCSELSrrr;
1178 assert(RC &&
"Unsupported regclass");
1182 unsigned NewReg = 0;
1205 (FalseReg.
isVirtual() || FalseReg == AArch64::WZR ||
1206 FalseReg == AArch64::XZR) &&
1207 "FalseReg was folded into a non-virtual register other than WZR or XZR");
1224 assert(BitSize == 64 &&
"Only bit sizes of 32 or 64 allowed");
1229 return Is.
size() <= 2;
1234 assert(
MI.isCopy() &&
"Expected COPY instruction");
1240 if (
Reg.isVirtual())
1242 if (
Reg.isPhysical())
1243 return RI.getMinimalPhysRegClass(
Reg);
1248 if (DstRC && SrcRC && !RI.getCommonSubClass(DstRC, SrcRC))
1251 return MI.isAsCheapAsAMove();
1257 if (Subtarget.hasExynosCheapAsMoveHandling()) {
1258 if (isExynosCheapAsMove(
MI))
1260 return MI.isAsCheapAsAMove();
1263 switch (
MI.getOpcode()) {
1265 return MI.isAsCheapAsAMove();
1267 case TargetOpcode::COPY:
1270 case AArch64::ADDWrs:
1271 case AArch64::ADDXrs:
1272 case AArch64::SUBWrs:
1273 case AArch64::SUBXrs:
1274 return Subtarget.hasALULSLFast() &&
MI.getOperand(3).getImm() <= 4;
1279 case AArch64::MOVi32imm:
1281 case AArch64::MOVi64imm:
1286bool AArch64InstrInfo::isFalkorShiftExtFast(
const MachineInstr &
MI) {
1287 switch (
MI.getOpcode()) {
1291 case AArch64::ADDWrs:
1292 case AArch64::ADDXrs:
1293 case AArch64::ADDSWrs:
1294 case AArch64::ADDSXrs: {
1295 unsigned Imm =
MI.getOperand(3).getImm();
1302 case AArch64::ADDWrx:
1303 case AArch64::ADDXrx:
1304 case AArch64::ADDXrx64:
1305 case AArch64::ADDSWrx:
1306 case AArch64::ADDSXrx:
1307 case AArch64::ADDSXrx64: {
1308 unsigned Imm =
MI.getOperand(3).getImm();
1320 case AArch64::SUBWrs:
1321 case AArch64::SUBSWrs: {
1322 unsigned Imm =
MI.getOperand(3).getImm();
1324 return ShiftVal == 0 ||
1328 case AArch64::SUBXrs:
1329 case AArch64::SUBSXrs: {
1330 unsigned Imm =
MI.getOperand(3).getImm();
1332 return ShiftVal == 0 ||
1336 case AArch64::SUBWrx:
1337 case AArch64::SUBXrx:
1338 case AArch64::SUBXrx64:
1339 case AArch64::SUBSWrx:
1340 case AArch64::SUBSXrx:
1341 case AArch64::SUBSXrx64: {
1342 unsigned Imm =
MI.getOperand(3).getImm();
1354 case AArch64::LDRBBroW:
1355 case AArch64::LDRBBroX:
1356 case AArch64::LDRBroW:
1357 case AArch64::LDRBroX:
1358 case AArch64::LDRDroW:
1359 case AArch64::LDRDroX:
1360 case AArch64::LDRHHroW:
1361 case AArch64::LDRHHroX:
1362 case AArch64::LDRHroW:
1363 case AArch64::LDRHroX:
1364 case AArch64::LDRQroW:
1365 case AArch64::LDRQroX:
1366 case AArch64::LDRSBWroW:
1367 case AArch64::LDRSBWroX:
1368 case AArch64::LDRSBXroW:
1369 case AArch64::LDRSBXroX:
1370 case AArch64::LDRSHWroW:
1371 case AArch64::LDRSHWroX:
1372 case AArch64::LDRSHXroW:
1373 case AArch64::LDRSHXroX:
1374 case AArch64::LDRSWroW:
1375 case AArch64::LDRSWroX:
1376 case AArch64::LDRSroW:
1377 case AArch64::LDRSroX:
1378 case AArch64::LDRWroW:
1379 case AArch64::LDRWroX:
1380 case AArch64::LDRXroW:
1381 case AArch64::LDRXroX:
1382 case AArch64::PRFMroW:
1383 case AArch64::PRFMroX:
1384 case AArch64::STRBBroW:
1385 case AArch64::STRBBroX:
1386 case AArch64::STRBroW:
1387 case AArch64::STRBroX:
1388 case AArch64::STRDroW:
1389 case AArch64::STRDroX:
1390 case AArch64::STRHHroW:
1391 case AArch64::STRHHroX:
1392 case AArch64::STRHroW:
1393 case AArch64::STRHroX:
1394 case AArch64::STRQroW:
1395 case AArch64::STRQroX:
1396 case AArch64::STRSroW:
1397 case AArch64::STRSroX:
1398 case AArch64::STRWroW:
1399 case AArch64::STRWroX:
1400 case AArch64::STRXroW:
1401 case AArch64::STRXroX: {
1402 unsigned IsSigned =
MI.getOperand(3).getImm();
1409 unsigned Opc =
MI.getOpcode();
1413 case AArch64::SEH_StackAlloc:
1414 case AArch64::SEH_SaveFPLR:
1415 case AArch64::SEH_SaveFPLR_X:
1416 case AArch64::SEH_SaveReg:
1417 case AArch64::SEH_SaveReg_X:
1418 case AArch64::SEH_SaveRegP:
1419 case AArch64::SEH_SaveRegP_X:
1420 case AArch64::SEH_SaveFReg:
1421 case AArch64::SEH_SaveFReg_X:
1422 case AArch64::SEH_SaveFRegP:
1423 case AArch64::SEH_SaveFRegP_X:
1424 case AArch64::SEH_SetFP:
1425 case AArch64::SEH_AddFP:
1426 case AArch64::SEH_Nop:
1427 case AArch64::SEH_PrologEnd:
1428 case AArch64::SEH_EpilogStart:
1429 case AArch64::SEH_EpilogEnd:
1430 case AArch64::SEH_PACSignLR:
1431 case AArch64::SEH_SaveAnyRegI:
1432 case AArch64::SEH_SaveAnyRegIP:
1433 case AArch64::SEH_SaveAnyRegQP:
1434 case AArch64::SEH_SaveAnyRegQPX:
1435 case AArch64::SEH_AllocZ:
1436 case AArch64::SEH_SaveZReg:
1437 case AArch64::SEH_SavePReg:
1444 unsigned &SubIdx)
const {
1445 switch (
MI.getOpcode()) {
1448 case AArch64::SBFMXri:
1449 case AArch64::UBFMXri:
1452 if (
MI.getOperand(2).getImm() != 0 ||
MI.getOperand(3).getImm() != 31)
1455 SrcReg =
MI.getOperand(1).getReg();
1456 DstReg =
MI.getOperand(0).getReg();
1457 SubIdx = AArch64::sub_32;
1466 int64_t OffsetA = 0, OffsetB = 0;
1467 TypeSize WidthA(0,
false), WidthB(0,
false);
1468 bool OffsetAIsScalable =
false, OffsetBIsScalable =
false;
1489 OffsetAIsScalable == OffsetBIsScalable) {
1490 int LowOffset = OffsetA < OffsetB ? OffsetA : OffsetB;
1491 int HighOffset = OffsetA < OffsetB ? OffsetB : OffsetA;
1492 TypeSize LowWidth = (LowOffset == OffsetA) ? WidthA : WidthB;
1493 if (LowWidth.
isScalable() == OffsetAIsScalable &&
1511 switch (
MI.getOpcode()) {
1514 if (
MI.getOperand(0).getImm() == 0x14)
1521 case AArch64::MSRpstatesvcrImm1:
1528 auto Next = std::next(
MI.getIterator());
1529 return Next !=
MBB->end() &&
Next->isCFIInstruction();
1536 Register &SrcReg2, int64_t &CmpMask,
1537 int64_t &CmpValue)
const {
1541 assert(
MI.getNumOperands() >= 2 &&
"All AArch64 cmps should have 2 operands");
1542 if (!
MI.getOperand(1).isReg() ||
MI.getOperand(1).getSubReg())
1545 switch (
MI.getOpcode()) {
1548 case AArch64::PTEST_PP:
1549 case AArch64::PTEST_PP_ANY:
1550 case AArch64::PTEST_PP_FIRST:
1551 SrcReg =
MI.getOperand(0).getReg();
1552 SrcReg2 =
MI.getOperand(1).getReg();
1553 if (
MI.getOperand(2).getSubReg())
1560 case AArch64::SUBSWrr:
1561 case AArch64::SUBSWrs:
1562 case AArch64::SUBSWrx:
1563 case AArch64::SUBSXrr:
1564 case AArch64::SUBSXrs:
1565 case AArch64::SUBSXrx:
1566 case AArch64::ADDSWrr:
1567 case AArch64::ADDSWrs:
1568 case AArch64::ADDSWrx:
1569 case AArch64::ADDSXrr:
1570 case AArch64::ADDSXrs:
1571 case AArch64::ADDSXrx:
1573 SrcReg =
MI.getOperand(1).getReg();
1574 SrcReg2 =
MI.getOperand(2).getReg();
1577 if (
MI.getOperand(2).getSubReg())
1583 case AArch64::SUBSWri:
1584 case AArch64::ADDSWri:
1585 case AArch64::SUBSXri:
1586 case AArch64::ADDSXri:
1587 SrcReg =
MI.getOperand(1).getReg();
1590 CmpValue =
MI.getOperand(2).getImm();
1592 case AArch64::ANDSWri:
1593 case AArch64::ANDSXri:
1596 SrcReg =
MI.getOperand(1).getReg();
1600 MI.getOperand(2).getImm(),
1601 MI.getOpcode() == AArch64::ANDSWri ? 32 : 64);
1610 assert(
MBB &&
"Can't get MachineBasicBlock here");
1612 assert(MF &&
"Can't get MachineFunction here");
1617 for (
unsigned OpIdx = 0, EndIdx = Instr.getNumOperands();
OpIdx < EndIdx;
1624 if (!OpRegCstraints)
1632 "Operand has register constraints without being a register!");
1635 if (
Reg.isPhysical()) {
1652 bool MIDefinesZeroReg =
false;
1653 if (
MI.definesRegister(AArch64::WZR,
nullptr) ||
1654 MI.definesRegister(AArch64::XZR,
nullptr))
1655 MIDefinesZeroReg =
true;
1657 switch (
MI.getOpcode()) {
1659 return MI.getOpcode();
1660 case AArch64::ADDSWrr:
1661 return AArch64::ADDWrr;
1662 case AArch64::ADDSWri:
1663 return MIDefinesZeroReg ? AArch64::ADDSWri : AArch64::ADDWri;
1664 case AArch64::ADDSWrs:
1665 return MIDefinesZeroReg ? AArch64::ADDSWrs : AArch64::ADDWrs;
1666 case AArch64::ADDSWrx:
1667 return AArch64::ADDWrx;
1668 case AArch64::ADDSXrr:
1669 return AArch64::ADDXrr;
1670 case AArch64::ADDSXri:
1671 return MIDefinesZeroReg ? AArch64::ADDSXri : AArch64::ADDXri;
1672 case AArch64::ADDSXrs:
1673 return MIDefinesZeroReg ? AArch64::ADDSXrs : AArch64::ADDXrs;
1674 case AArch64::ADDSXrx:
1675 return AArch64::ADDXrx;
1676 case AArch64::SUBSWrr:
1677 return AArch64::SUBWrr;
1678 case AArch64::SUBSWri:
1679 return MIDefinesZeroReg ? AArch64::SUBSWri : AArch64::SUBWri;
1680 case AArch64::SUBSWrs:
1681 return MIDefinesZeroReg ? AArch64::SUBSWrs : AArch64::SUBWrs;
1682 case AArch64::SUBSWrx:
1683 return AArch64::SUBWrx;
1684 case AArch64::SUBSXrr:
1685 return AArch64::SUBXrr;
1686 case AArch64::SUBSXri:
1687 return MIDefinesZeroReg ? AArch64::SUBSXri : AArch64::SUBXri;
1688 case AArch64::SUBSXrs:
1689 return MIDefinesZeroReg ? AArch64::SUBSXrs : AArch64::SUBXrs;
1690 case AArch64::SUBSXrx:
1691 return AArch64::SUBXrx;
1706 if (To == To->getParent()->begin())
1711 if (To->getParent() != From->getParent())
1723 Instr.modifiesRegister(AArch64::NZCV,
TRI)) ||
1724 ((AccessToCheck &
AK_Read) && Instr.readsRegister(AArch64::NZCV,
TRI)))
1730std::optional<unsigned>
1734 unsigned MaskOpcode =
Mask->getOpcode();
1735 unsigned PredOpcode = Pred->
getOpcode();
1736 bool PredIsPTestLike = isPTestLikeOpcode(PredOpcode);
1737 bool PredIsWhileLike = isWhileOpcode(PredOpcode);
1739 if (PredIsWhileLike) {
1743 if ((Mask == Pred) && PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1750 getElementSizeForOpcode(MaskOpcode) ==
1751 getElementSizeForOpcode(PredOpcode))
1757 if (PTest->
getOpcode() == AArch64::PTEST_PP_FIRST &&
1764 if (PredIsPTestLike) {
1769 if ((Mask == Pred) && PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1777 if (Mask != PTestLikeMask && PTestLikeMask->isFullCopy() &&
1778 PTestLikeMask->getOperand(1).getReg().isVirtual())
1786 getElementSizeForOpcode(MaskOpcode) ==
1787 getElementSizeForOpcode(PredOpcode)) {
1788 if (Mask == PTestLikeMask || PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1814 uint64_t PredElementSize = getElementSizeForOpcode(PredOpcode);
1816 PTest->
getOpcode() == AArch64::PTEST_PP_ANY))
1824 switch (PredOpcode) {
1825 case AArch64::AND_PPzPP:
1826 case AArch64::BIC_PPzPP:
1827 case AArch64::EOR_PPzPP:
1828 case AArch64::NAND_PPzPP:
1829 case AArch64::NOR_PPzPP:
1830 case AArch64::ORN_PPzPP:
1831 case AArch64::ORR_PPzPP:
1832 case AArch64::BRKA_PPzP:
1833 case AArch64::BRKPA_PPzPP:
1834 case AArch64::BRKB_PPzP:
1835 case AArch64::BRKPB_PPzPP:
1836 case AArch64::RDFFR_PPz: {
1840 if (Mask != PredMask)
1844 case AArch64::BRKN_PPzP: {
1848 if ((MaskOpcode != AArch64::PTRUE_B) ||
1849 (
Mask->getOperand(1).getImm() != 31))
1853 case AArch64::PTRUE_B:
1866bool AArch64InstrInfo::optimizePTestInstr(
1867 MachineInstr *PTest,
unsigned MaskReg,
unsigned PredReg,
1872 if (Pred->
isCopy() && PTest->
getOpcode() == AArch64::PTEST_PP_FIRST) {
1876 if (
Op.isReg() &&
Op.getReg().isVirtual() &&
1877 Op.getSubReg() == AArch64::psub0)
1881 unsigned PredOpcode = Pred->
getOpcode();
1882 auto NewOp = canRemovePTestInstr(PTest, Mask, Pred, MRI);
1898 if (*NewOp != PredOpcode) {
1909 for (; i !=
e; ++i) {
1940 if (DeadNZCVIdx != -1) {
1959 if (CmpInstr.
getOpcode() == AArch64::PTEST_PP ||
1960 CmpInstr.
getOpcode() == AArch64::PTEST_PP_ANY ||
1961 CmpInstr.
getOpcode() == AArch64::PTEST_PP_FIRST)
1962 return optimizePTestInstr(&CmpInstr, SrcReg, SrcReg2, MRI);
1971 if (CmpValue == 0 && substituteCmpToZero(CmpInstr, SrcReg, *MRI))
1973 return (CmpValue == 0 || CmpValue == 1) &&
1974 removeCmpToZeroOrOne(CmpInstr, SrcReg, CmpValue, *MRI);
1982 switch (Instr.getOpcode()) {
1984 return AArch64::INSTRUCTION_LIST_END;
1986 case AArch64::ADDSWrr:
1987 case AArch64::ADDSWri:
1988 case AArch64::ADDSXrr:
1989 case AArch64::ADDSXri:
1990 case AArch64::ADDSWrx:
1991 case AArch64::ADDSXrx:
1992 case AArch64::SUBSWrr:
1993 case AArch64::SUBSWri:
1994 case AArch64::SUBSWrx:
1995 case AArch64::SUBSXrr:
1996 case AArch64::SUBSXri:
1997 case AArch64::SUBSXrx:
1998 case AArch64::ANDSWri:
1999 case AArch64::ANDSWrr:
2000 case AArch64::ANDSWrs:
2001 case AArch64::ANDSXri:
2002 case AArch64::ANDSXrr:
2003 case AArch64::ANDSXrs:
2004 case AArch64::BICSWrr:
2005 case AArch64::BICSXrr:
2006 case AArch64::BICSWrs:
2007 case AArch64::BICSXrs:
2008 return Instr.getOpcode();
2010 case AArch64::ADDWrr:
2011 return AArch64::ADDSWrr;
2012 case AArch64::ADDWri:
2013 return AArch64::ADDSWri;
2014 case AArch64::ADDXrr:
2015 return AArch64::ADDSXrr;
2016 case AArch64::ADDXri:
2017 return AArch64::ADDSXri;
2018 case AArch64::ADDWrx:
2019 return AArch64::ADDSWrx;
2020 case AArch64::ADDXrx:
2021 return AArch64::ADDSXrx;
2022 case AArch64::ADCWr:
2023 return AArch64::ADCSWr;
2024 case AArch64::ADCXr:
2025 return AArch64::ADCSXr;
2026 case AArch64::SUBWrr:
2027 return AArch64::SUBSWrr;
2028 case AArch64::SUBWri:
2029 return AArch64::SUBSWri;
2030 case AArch64::SUBXrr:
2031 return AArch64::SUBSXrr;
2032 case AArch64::SUBXri:
2033 return AArch64::SUBSXri;
2034 case AArch64::SUBWrx:
2035 return AArch64::SUBSWrx;
2036 case AArch64::SUBXrx:
2037 return AArch64::SUBSXrx;
2038 case AArch64::SBCWr:
2039 return AArch64::SBCSWr;
2040 case AArch64::SBCXr:
2041 return AArch64::SBCSXr;
2042 case AArch64::ANDWri:
2043 return AArch64::ANDSWri;
2044 case AArch64::ANDXri:
2045 return AArch64::ANDSXri;
2046 case AArch64::ANDWrr:
2047 return AArch64::ANDSWrr;
2048 case AArch64::ANDWrs:
2049 return AArch64::ANDSWrs;
2050 case AArch64::ANDXrr:
2051 return AArch64::ANDSXrr;
2052 case AArch64::ANDXrs:
2053 return AArch64::ANDSXrs;
2054 case AArch64::BICWrr:
2055 return AArch64::BICSWrr;
2056 case AArch64::BICXrr:
2057 return AArch64::BICSXrr;
2058 case AArch64::BICWrs:
2059 return AArch64::BICSWrs;
2060 case AArch64::BICXrs:
2061 return AArch64::BICSXrs;
2067 for (
auto *BB :
MBB->successors())
2068 if (BB->isLiveIn(AArch64::NZCV))
2077 switch (Instr.getOpcode()) {
2081 case AArch64::Bcc: {
2082 int Idx = Instr.findRegisterUseOperandIdx(AArch64::NZCV,
nullptr);
2087 case AArch64::CSINVWr:
2088 case AArch64::CSINVXr:
2089 case AArch64::CSINCWr:
2090 case AArch64::CSINCXr:
2091 case AArch64::CSELWr:
2092 case AArch64::CSELXr:
2093 case AArch64::CSNEGWr:
2094 case AArch64::CSNEGXr:
2095 case AArch64::FCSELSrrr:
2096 case AArch64::FCSELDrrr: {
2097 int Idx = Instr.findRegisterUseOperandIdx(AArch64::NZCV,
nullptr);
2111 Instr.getOperand(CCIdx).
getImm())
2164std::optional<UsedNZCV>
2169 if (
MI.getParent() != CmpParent)
2170 return std::nullopt;
2173 return std::nullopt;
2178 if (Instr.readsRegister(AArch64::NZCV, &
TRI)) {
2181 return std::nullopt;
2186 if (Instr.modifiesRegister(AArch64::NZCV, &
TRI))
2189 return NZCVUsedAfterCmp;
2193 return Opcode == AArch64::ADDSWri || Opcode == AArch64::ADDSXri;
2197 return Opcode == AArch64::SUBSWri || Opcode == AArch64::SUBSXri;
2203 case AArch64::ANDSWri:
2204 case AArch64::ANDSWrr:
2205 case AArch64::ANDSWrs:
2206 case AArch64::ANDSXri:
2207 case AArch64::ANDSXrr:
2208 case AArch64::ANDSXrs:
2209 case AArch64::BICSWrr:
2210 case AArch64::BICSXrr:
2211 case AArch64::BICSWrs:
2212 case AArch64::BICSXrs:
2238 const unsigned CmpOpcode = CmpInstr.
getOpcode();
2244 "Caller guarantees that CmpInstr compares with constant 0");
2247 if (!NZVCUsed || NZVCUsed->C)
2270bool AArch64InstrInfo::substituteCmpToZero(
2281 if (NewOpc == AArch64::INSTRUCTION_LIST_END)
2288 MI->setDesc(
get(NewOpc));
2293 MI->addRegisterDefined(AArch64::NZCV, &
TRI);
2305 assert((CmpValue == 0 || CmpValue == 1) &&
2306 "Only comparisons to 0 or 1 considered for removal!");
2309 unsigned MIOpc =
MI.getOpcode();
2310 if (MIOpc == AArch64::CSINCWr) {
2311 if (
MI.getOperand(1).getReg() != AArch64::WZR ||
2312 MI.getOperand(2).getReg() != AArch64::WZR)
2314 }
else if (MIOpc == AArch64::CSINCXr) {
2315 if (
MI.getOperand(1).getReg() != AArch64::XZR ||
2316 MI.getOperand(2).getReg() != AArch64::XZR)
2326 if (
MI.findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
true) != -1)
2330 const unsigned CmpOpcode = CmpInstr.
getOpcode();
2332 if (CmpValue && !IsSubsRegImm)
2334 if (!CmpValue && !IsSubsRegImm && !
isADDSRegImm(CmpOpcode))
2339 if (MIUsedNZCV.
C || MIUsedNZCV.
V)
2342 std::optional<UsedNZCV> NZCVUsedAfterCmp =
2346 if (!NZCVUsedAfterCmp || NZCVUsedAfterCmp->C || NZCVUsedAfterCmp->V)
2349 if ((MIUsedNZCV.
Z && NZCVUsedAfterCmp->N) ||
2350 (MIUsedNZCV.
N && NZCVUsedAfterCmp->Z))
2353 if (MIUsedNZCV.
N && !CmpValue)
2395bool AArch64InstrInfo::removeCmpToZeroOrOne(
2402 SmallVector<MachineInstr *, 4> CCUseInstrs;
2403 bool IsInvertCC =
false;
2411 for (MachineInstr *CCUseInstr : CCUseInstrs) {
2413 assert(Idx >= 0 &&
"Unexpected instruction using CC.");
2414 MachineOperand &CCOperand = CCUseInstr->getOperand(Idx);
2423bool AArch64InstrInfo::expandPostRAPseudo(
MachineInstr &
MI)
const {
2424 if (
MI.getOpcode() != TargetOpcode::LOAD_STACK_GUARD &&
2425 MI.getOpcode() != AArch64::CATCHRET)
2428 MachineBasicBlock &
MBB = *
MI.getParent();
2430 auto TRI = Subtarget.getRegisterInfo();
2433 if (
MI.getOpcode() == AArch64::CATCHRET) {
2435 const TargetInstrInfo *
TII =
2437 MachineBasicBlock *TargetMBB =
MI.getOperand(0).getMBB();
2442 FirstEpilogSEH = std::prev(FirstEpilogSEH);
2444 FirstEpilogSEH = std::next(FirstEpilogSEH);
2459 if (
M.getStackProtectorGuard() ==
"sysreg") {
2460 const AArch64SysReg::SysReg *SrcReg =
2461 AArch64SysReg::lookupSysRegByName(
M.getStackProtectorGuardReg());
2469 int Offset =
M.getStackProtectorGuardOffset();
2520 const GlobalValue *GV =
2523 unsigned OpFlags = Subtarget.ClassifyGlobalReference(GV, TM);
2529 if (Subtarget.isTargetILP32()) {
2530 unsigned Reg32 =
TRI->getSubReg(
Reg, AArch64::sub_32);
2544 assert(!Subtarget.isTargetILP32() &&
"how can large exist in ILP32?");
2571 if (Subtarget.isTargetILP32()) {
2572 unsigned Reg32 =
TRI->getSubReg(
Reg, AArch64::sub_32);
2595 switch (
MI.getOpcode()) {
2598 case AArch64::MOVZWi:
2599 case AArch64::MOVZXi:
2600 if (
MI.getOperand(1).isImm() &&
MI.getOperand(1).getImm() == 0) {
2601 assert(
MI.getDesc().getNumOperands() == 3 &&
2602 MI.getOperand(2).getImm() == 0 &&
"invalid MOVZi operands");
2606 case AArch64::ANDWri:
2607 return MI.getOperand(1).getReg() == AArch64::WZR;
2608 case AArch64::ANDXri:
2609 return MI.getOperand(1).getReg() == AArch64::XZR;
2610 case TargetOpcode::COPY:
2611 return MI.getOperand(1).getReg() == AArch64::WZR;
2619 switch (
MI.getOpcode()) {
2622 case TargetOpcode::COPY: {
2625 return (AArch64::GPR32RegClass.
contains(DstReg) ||
2626 AArch64::GPR64RegClass.
contains(DstReg));
2628 case AArch64::ORRXrs:
2629 if (
MI.getOperand(1).getReg() == AArch64::XZR) {
2630 assert(
MI.getDesc().getNumOperands() == 4 &&
2631 MI.getOperand(3).getImm() == 0 &&
"invalid ORRrs operands");
2635 case AArch64::ADDXri:
2636 if (
MI.getOperand(2).getImm() == 0) {
2637 assert(
MI.getDesc().getNumOperands() == 4 &&
2638 MI.getOperand(3).getImm() == 0 &&
"invalid ADDXri operands");
2649 switch (
MI.getOpcode()) {
2652 case TargetOpcode::COPY: {
2654 return AArch64::FPR128RegClass.contains(DstReg);
2656 case AArch64::ORRv16i8:
2657 if (
MI.getOperand(1).getReg() ==
MI.getOperand(2).getReg()) {
2658 assert(
MI.getDesc().getNumOperands() == 3 &&
MI.getOperand(0).isReg() &&
2659 "invalid ORRv16i8 operands");
2671 case AArch64::LDRWui:
2672 case AArch64::LDRXui:
2673 case AArch64::LDRBui:
2674 case AArch64::LDRHui:
2675 case AArch64::LDRSui:
2676 case AArch64::LDRDui:
2677 case AArch64::LDRQui:
2678 case AArch64::LDR_PXI:
2684 int &FrameIndex)
const {
2688 if (
MI.getOperand(0).getSubReg() == 0 &&
MI.getOperand(1).isFI() &&
2689 MI.getOperand(2).isImm() &&
MI.getOperand(2).getImm() == 0) {
2690 FrameIndex =
MI.getOperand(1).getIndex();
2691 return MI.getOperand(0).getReg();
2700 case AArch64::STRWui:
2701 case AArch64::STRXui:
2702 case AArch64::STRBui:
2703 case AArch64::STRHui:
2704 case AArch64::STRSui:
2705 case AArch64::STRDui:
2706 case AArch64::STRQui:
2707 case AArch64::STR_PXI:
2713 int &FrameIndex)
const {
2717 if (
MI.getOperand(0).getSubReg() == 0 &&
MI.getOperand(1).isFI() &&
2718 MI.getOperand(2).isImm() &&
MI.getOperand(2).getImm() == 0) {
2719 FrameIndex =
MI.getOperand(1).getIndex();
2720 return MI.getOperand(0).getReg();
2726 int &FrameIndex)
const {
2741 return MI.getOperand(0).getReg();
2747 int &FrameIndex)
const {
2762 return MI.getOperand(0).getReg();
2770 return MMO->getFlags() & MOSuppressPair;
2776 if (
MI.memoperands_empty())
2784 return MMO->getFlags() & MOStridedAccess;
2792 case AArch64::STURSi:
2793 case AArch64::STRSpre:
2794 case AArch64::STURDi:
2795 case AArch64::STRDpre:
2796 case AArch64::STURQi:
2797 case AArch64::STRQpre:
2798 case AArch64::STURBBi:
2799 case AArch64::STURHHi:
2800 case AArch64::STURWi:
2801 case AArch64::STRWpre:
2802 case AArch64::STURXi:
2803 case AArch64::STRXpre:
2804 case AArch64::LDURSi:
2805 case AArch64::LDRSpre:
2806 case AArch64::LDURDi:
2807 case AArch64::LDRDpre:
2808 case AArch64::LDURQi:
2809 case AArch64::LDRQpre:
2810 case AArch64::LDURWi:
2811 case AArch64::LDRWpre:
2812 case AArch64::LDURXi:
2813 case AArch64::LDRXpre:
2814 case AArch64::LDRSWpre:
2815 case AArch64::LDURSWi:
2816 case AArch64::LDURHHi:
2817 case AArch64::LDURBBi:
2818 case AArch64::LDURSBWi:
2819 case AArch64::LDURSHWi:
2827 case AArch64::PRFMui:
return AArch64::PRFUMi;
2828 case AArch64::LDRXui:
return AArch64::LDURXi;
2829 case AArch64::LDRWui:
return AArch64::LDURWi;
2830 case AArch64::LDRBui:
return AArch64::LDURBi;
2831 case AArch64::LDRHui:
return AArch64::LDURHi;
2832 case AArch64::LDRSui:
return AArch64::LDURSi;
2833 case AArch64::LDRDui:
return AArch64::LDURDi;
2834 case AArch64::LDRQui:
return AArch64::LDURQi;
2835 case AArch64::LDRBBui:
return AArch64::LDURBBi;
2836 case AArch64::LDRHHui:
return AArch64::LDURHHi;
2837 case AArch64::LDRSBXui:
return AArch64::LDURSBXi;
2838 case AArch64::LDRSBWui:
return AArch64::LDURSBWi;
2839 case AArch64::LDRSHXui:
return AArch64::LDURSHXi;
2840 case AArch64::LDRSHWui:
return AArch64::LDURSHWi;
2841 case AArch64::LDRSWui:
return AArch64::LDURSWi;
2842 case AArch64::STRXui:
return AArch64::STURXi;
2843 case AArch64::STRWui:
return AArch64::STURWi;
2844 case AArch64::STRBui:
return AArch64::STURBi;
2845 case AArch64::STRHui:
return AArch64::STURHi;
2846 case AArch64::STRSui:
return AArch64::STURSi;
2847 case AArch64::STRDui:
return AArch64::STURDi;
2848 case AArch64::STRQui:
return AArch64::STURQi;
2849 case AArch64::STRBBui:
return AArch64::STURBBi;
2850 case AArch64::STRHHui:
return AArch64::STURHHi;
2859 case AArch64::LDAPURBi:
2860 case AArch64::LDAPURHi:
2861 case AArch64::LDAPURi:
2862 case AArch64::LDAPURSBWi:
2863 case AArch64::LDAPURSBXi:
2864 case AArch64::LDAPURSHWi:
2865 case AArch64::LDAPURSHXi:
2866 case AArch64::LDAPURSWi:
2867 case AArch64::LDAPURXi:
2868 case AArch64::LDR_PPXI:
2869 case AArch64::LDR_PXI:
2870 case AArch64::LDR_ZXI:
2871 case AArch64::LDR_ZZXI:
2872 case AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS:
2873 case AArch64::LDR_ZZZXI:
2874 case AArch64::LDR_ZZZZXI:
2875 case AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS:
2876 case AArch64::LDRBBui:
2877 case AArch64::LDRBui:
2878 case AArch64::LDRDui:
2879 case AArch64::LDRHHui:
2880 case AArch64::LDRHui:
2881 case AArch64::LDRQui:
2882 case AArch64::LDRSBWui:
2883 case AArch64::LDRSBXui:
2884 case AArch64::LDRSHWui:
2885 case AArch64::LDRSHXui:
2886 case AArch64::LDRSui:
2887 case AArch64::LDRSWui:
2888 case AArch64::LDRWui:
2889 case AArch64::LDRXui:
2890 case AArch64::LDURBBi:
2891 case AArch64::LDURBi:
2892 case AArch64::LDURDi:
2893 case AArch64::LDURHHi:
2894 case AArch64::LDURHi:
2895 case AArch64::LDURQi:
2896 case AArch64::LDURSBWi:
2897 case AArch64::LDURSBXi:
2898 case AArch64::LDURSHWi:
2899 case AArch64::LDURSHXi:
2900 case AArch64::LDURSi:
2901 case AArch64::LDURSWi:
2902 case AArch64::LDURWi:
2903 case AArch64::LDURXi:
2904 case AArch64::PRFMui:
2905 case AArch64::PRFUMi:
2906 case AArch64::ST2Gi:
2908 case AArch64::STLURBi:
2909 case AArch64::STLURHi:
2910 case AArch64::STLURWi:
2911 case AArch64::STLURXi:
2912 case AArch64::StoreSwiftAsyncContext:
2913 case AArch64::STR_PPXI:
2914 case AArch64::STR_PXI:
2915 case AArch64::STR_ZXI:
2916 case AArch64::STR_ZZXI:
2917 case AArch64::STR_ZZXI_STRIDED_CONTIGUOUS:
2918 case AArch64::STR_ZZZXI:
2919 case AArch64::STR_ZZZZXI:
2920 case AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS:
2921 case AArch64::STRBBui:
2922 case AArch64::STRBui:
2923 case AArch64::STRDui:
2924 case AArch64::STRHHui:
2925 case AArch64::STRHui:
2926 case AArch64::STRQui:
2927 case AArch64::STRSui:
2928 case AArch64::STRWui:
2929 case AArch64::STRXui:
2930 case AArch64::STURBBi:
2931 case AArch64::STURBi:
2932 case AArch64::STURDi:
2933 case AArch64::STURHHi:
2934 case AArch64::STURHi:
2935 case AArch64::STURQi:
2936 case AArch64::STURSi:
2937 case AArch64::STURWi:
2938 case AArch64::STURXi:
2939 case AArch64::STZ2Gi:
2940 case AArch64::STZGi:
2941 case AArch64::TAGPstack:
2943 case AArch64::LD1B_D_IMM:
2944 case AArch64::LD1B_H_IMM:
2945 case AArch64::LD1B_IMM:
2946 case AArch64::LD1B_S_IMM:
2947 case AArch64::LD1D_IMM:
2948 case AArch64::LD1H_D_IMM:
2949 case AArch64::LD1H_IMM:
2950 case AArch64::LD1H_S_IMM:
2951 case AArch64::LD1RB_D_IMM:
2952 case AArch64::LD1RB_H_IMM:
2953 case AArch64::LD1RB_IMM:
2954 case AArch64::LD1RB_S_IMM:
2955 case AArch64::LD1RD_IMM:
2956 case AArch64::LD1RH_D_IMM:
2957 case AArch64::LD1RH_IMM:
2958 case AArch64::LD1RH_S_IMM:
2959 case AArch64::LD1RSB_D_IMM:
2960 case AArch64::LD1RSB_H_IMM:
2961 case AArch64::LD1RSB_S_IMM:
2962 case AArch64::LD1RSH_D_IMM:
2963 case AArch64::LD1RSH_S_IMM:
2964 case AArch64::LD1RSW_IMM:
2965 case AArch64::LD1RW_D_IMM:
2966 case AArch64::LD1RW_IMM:
2967 case AArch64::LD1SB_D_IMM:
2968 case AArch64::LD1SB_H_IMM:
2969 case AArch64::LD1SB_S_IMM:
2970 case AArch64::LD1SH_D_IMM:
2971 case AArch64::LD1SH_S_IMM:
2972 case AArch64::LD1SW_D_IMM:
2973 case AArch64::LD1W_D_IMM:
2974 case AArch64::LD1W_IMM:
2975 case AArch64::LD2B_IMM:
2976 case AArch64::LD2D_IMM:
2977 case AArch64::LD2H_IMM:
2978 case AArch64::LD2W_IMM:
2979 case AArch64::LD3B_IMM:
2980 case AArch64::LD3D_IMM:
2981 case AArch64::LD3H_IMM:
2982 case AArch64::LD3W_IMM:
2983 case AArch64::LD4B_IMM:
2984 case AArch64::LD4D_IMM:
2985 case AArch64::LD4H_IMM:
2986 case AArch64::LD4W_IMM:
2988 case AArch64::LDNF1B_D_IMM:
2989 case AArch64::LDNF1B_H_IMM:
2990 case AArch64::LDNF1B_IMM:
2991 case AArch64::LDNF1B_S_IMM:
2992 case AArch64::LDNF1D_IMM:
2993 case AArch64::LDNF1H_D_IMM:
2994 case AArch64::LDNF1H_IMM:
2995 case AArch64::LDNF1H_S_IMM:
2996 case AArch64::LDNF1SB_D_IMM:
2997 case AArch64::LDNF1SB_H_IMM:
2998 case AArch64::LDNF1SB_S_IMM:
2999 case AArch64::LDNF1SH_D_IMM:
3000 case AArch64::LDNF1SH_S_IMM:
3001 case AArch64::LDNF1SW_D_IMM:
3002 case AArch64::LDNF1W_D_IMM:
3003 case AArch64::LDNF1W_IMM:
3004 case AArch64::LDNPDi:
3005 case AArch64::LDNPQi:
3006 case AArch64::LDNPSi:
3007 case AArch64::LDNPWi:
3008 case AArch64::LDNPXi:
3009 case AArch64::LDNT1B_ZRI:
3010 case AArch64::LDNT1D_ZRI:
3011 case AArch64::LDNT1H_ZRI:
3012 case AArch64::LDNT1W_ZRI:
3013 case AArch64::LDPDi:
3014 case AArch64::LDPQi:
3015 case AArch64::LDPSi:
3016 case AArch64::LDPWi:
3017 case AArch64::LDPXi:
3018 case AArch64::LDRBBpost:
3019 case AArch64::LDRBBpre:
3020 case AArch64::LDRBpost:
3021 case AArch64::LDRBpre:
3022 case AArch64::LDRDpost:
3023 case AArch64::LDRDpre:
3024 case AArch64::LDRHHpost:
3025 case AArch64::LDRHHpre:
3026 case AArch64::LDRHpost:
3027 case AArch64::LDRHpre:
3028 case AArch64::LDRQpost:
3029 case AArch64::LDRQpre:
3030 case AArch64::LDRSpost:
3031 case AArch64::LDRSpre:
3032 case AArch64::LDRWpost:
3033 case AArch64::LDRWpre:
3034 case AArch64::LDRXpost:
3035 case AArch64::LDRXpre:
3036 case AArch64::ST1B_D_IMM:
3037 case AArch64::ST1B_H_IMM:
3038 case AArch64::ST1B_IMM:
3039 case AArch64::ST1B_S_IMM:
3040 case AArch64::ST1D_IMM:
3041 case AArch64::ST1H_D_IMM:
3042 case AArch64::ST1H_IMM:
3043 case AArch64::ST1H_S_IMM:
3044 case AArch64::ST1W_D_IMM:
3045 case AArch64::ST1W_IMM:
3046 case AArch64::ST2B_IMM:
3047 case AArch64::ST2D_IMM:
3048 case AArch64::ST2H_IMM:
3049 case AArch64::ST2W_IMM:
3050 case AArch64::ST3B_IMM:
3051 case AArch64::ST3D_IMM:
3052 case AArch64::ST3H_IMM:
3053 case AArch64::ST3W_IMM:
3054 case AArch64::ST4B_IMM:
3055 case AArch64::ST4D_IMM:
3056 case AArch64::ST4H_IMM:
3057 case AArch64::ST4W_IMM:
3058 case AArch64::STGPi:
3059 case AArch64::STGPreIndex:
3060 case AArch64::STZGPreIndex:
3061 case AArch64::ST2GPreIndex:
3062 case AArch64::STZ2GPreIndex:
3063 case AArch64::STGPostIndex:
3064 case AArch64::STZGPostIndex:
3065 case AArch64::ST2GPostIndex:
3066 case AArch64::STZ2GPostIndex:
3067 case AArch64::STNPDi:
3068 case AArch64::STNPQi:
3069 case AArch64::STNPSi:
3070 case AArch64::STNPWi:
3071 case AArch64::STNPXi:
3072 case AArch64::STNT1B_ZRI:
3073 case AArch64::STNT1D_ZRI:
3074 case AArch64::STNT1H_ZRI:
3075 case AArch64::STNT1W_ZRI:
3076 case AArch64::STPDi:
3077 case AArch64::STPQi:
3078 case AArch64::STPSi:
3079 case AArch64::STPWi:
3080 case AArch64::STPXi:
3081 case AArch64::STRBBpost:
3082 case AArch64::STRBBpre:
3083 case AArch64::STRBpost:
3084 case AArch64::STRBpre:
3085 case AArch64::STRDpost:
3086 case AArch64::STRDpre:
3087 case AArch64::STRHHpost:
3088 case AArch64::STRHHpre:
3089 case AArch64::STRHpost:
3090 case AArch64::STRHpre:
3091 case AArch64::STRQpost:
3092 case AArch64::STRQpre:
3093 case AArch64::STRSpost:
3094 case AArch64::STRSpre:
3095 case AArch64::STRWpost:
3096 case AArch64::STRWpre:
3097 case AArch64::STRXpost:
3098 case AArch64::STRXpre:
3100 case AArch64::LDPDpost:
3101 case AArch64::LDPDpre:
3102 case AArch64::LDPQpost:
3103 case AArch64::LDPQpre:
3104 case AArch64::LDPSpost:
3105 case AArch64::LDPSpre:
3106 case AArch64::LDPWpost:
3107 case AArch64::LDPWpre:
3108 case AArch64::LDPXpost:
3109 case AArch64::LDPXpre:
3110 case AArch64::STGPpre:
3111 case AArch64::STGPpost:
3112 case AArch64::STPDpost:
3113 case AArch64::STPDpre:
3114 case AArch64::STPQpost:
3115 case AArch64::STPQpre:
3116 case AArch64::STPSpost:
3117 case AArch64::STPSpre:
3118 case AArch64::STPWpost:
3119 case AArch64::STPWpre:
3120 case AArch64::STPXpost:
3121 case AArch64::STPXpre:
3127 switch (
MI.getOpcode()) {
3131 case AArch64::STRSui:
3132 case AArch64::STRDui:
3133 case AArch64::STRQui:
3134 case AArch64::STRXui:
3135 case AArch64::STRWui:
3136 case AArch64::LDRSui:
3137 case AArch64::LDRDui:
3138 case AArch64::LDRQui:
3139 case AArch64::LDRXui:
3140 case AArch64::LDRWui:
3141 case AArch64::LDRSWui:
3143 case AArch64::STURSi:
3144 case AArch64::STRSpre:
3145 case AArch64::STURDi:
3146 case AArch64::STRDpre:
3147 case AArch64::STURQi:
3148 case AArch64::STRQpre:
3149 case AArch64::STURWi:
3150 case AArch64::STRWpre:
3151 case AArch64::STURXi:
3152 case AArch64::STRXpre:
3153 case AArch64::LDURSi:
3154 case AArch64::LDRSpre:
3155 case AArch64::LDURDi:
3156 case AArch64::LDRDpre:
3157 case AArch64::LDURQi:
3158 case AArch64::LDRQpre:
3159 case AArch64::LDURWi:
3160 case AArch64::LDRWpre:
3161 case AArch64::LDURXi:
3162 case AArch64::LDRXpre:
3163 case AArch64::LDURSWi:
3164 case AArch64::LDRSWpre:
3166 case AArch64::LDR_ZXI:
3167 case AArch64::STR_ZXI:
3173 switch (
MI.getOpcode()) {
3176 "Unexpected instruction - was a new tail call opcode introduced?");
3178 case AArch64::TCRETURNdi:
3179 case AArch64::TCRETURNri:
3180 case AArch64::TCRETURNrix16x17:
3181 case AArch64::TCRETURNrix17:
3182 case AArch64::TCRETURNrinotx16:
3183 case AArch64::TCRETURNriALL:
3184 case AArch64::AUTH_TCRETURN:
3185 case AArch64::AUTH_TCRETURN_BTI:
3195 case AArch64::ADDWri:
3196 return AArch64::ADDSWri;
3197 case AArch64::ADDWrr:
3198 return AArch64::ADDSWrr;
3199 case AArch64::ADDWrs:
3200 return AArch64::ADDSWrs;
3201 case AArch64::ADDWrx:
3202 return AArch64::ADDSWrx;
3203 case AArch64::ANDWri:
3204 return AArch64::ANDSWri;
3205 case AArch64::ANDWrr:
3206 return AArch64::ANDSWrr;
3207 case AArch64::ANDWrs:
3208 return AArch64::ANDSWrs;
3209 case AArch64::BICWrr:
3210 return AArch64::BICSWrr;
3211 case AArch64::BICWrs:
3212 return AArch64::BICSWrs;
3213 case AArch64::SUBWri:
3214 return AArch64::SUBSWri;
3215 case AArch64::SUBWrr:
3216 return AArch64::SUBSWrr;
3217 case AArch64::SUBWrs:
3218 return AArch64::SUBSWrs;
3219 case AArch64::SUBWrx:
3220 return AArch64::SUBSWrx;
3222 case AArch64::ADDXri:
3223 return AArch64::ADDSXri;
3224 case AArch64::ADDXrr:
3225 return AArch64::ADDSXrr;
3226 case AArch64::ADDXrs:
3227 return AArch64::ADDSXrs;
3228 case AArch64::ADDXrx:
3229 return AArch64::ADDSXrx;
3230 case AArch64::ANDXri:
3231 return AArch64::ANDSXri;
3232 case AArch64::ANDXrr:
3233 return AArch64::ANDSXrr;
3234 case AArch64::ANDXrs:
3235 return AArch64::ANDSXrs;
3236 case AArch64::BICXrr:
3237 return AArch64::BICSXrr;
3238 case AArch64::BICXrs:
3239 return AArch64::BICSXrs;
3240 case AArch64::SUBXri:
3241 return AArch64::SUBSXri;
3242 case AArch64::SUBXrr:
3243 return AArch64::SUBSXrr;
3244 case AArch64::SUBXrs:
3245 return AArch64::SUBSXrs;
3246 case AArch64::SUBXrx:
3247 return AArch64::SUBSXrx;
3249 case AArch64::AND_PPzPP:
3250 return AArch64::ANDS_PPzPP;
3251 case AArch64::BIC_PPzPP:
3252 return AArch64::BICS_PPzPP;
3253 case AArch64::EOR_PPzPP:
3254 return AArch64::EORS_PPzPP;
3255 case AArch64::NAND_PPzPP:
3256 return AArch64::NANDS_PPzPP;
3257 case AArch64::NOR_PPzPP:
3258 return AArch64::NORS_PPzPP;
3259 case AArch64::ORN_PPzPP:
3260 return AArch64::ORNS_PPzPP;
3261 case AArch64::ORR_PPzPP:
3262 return AArch64::ORRS_PPzPP;
3263 case AArch64::BRKA_PPzP:
3264 return AArch64::BRKAS_PPzP;
3265 case AArch64::BRKPA_PPzPP:
3266 return AArch64::BRKPAS_PPzPP;
3267 case AArch64::BRKB_PPzP:
3268 return AArch64::BRKBS_PPzP;
3269 case AArch64::BRKPB_PPzPP:
3270 return AArch64::BRKPBS_PPzPP;
3271 case AArch64::BRKN_PPzP:
3272 return AArch64::BRKNS_PPzP;
3273 case AArch64::RDFFR_PPz:
3274 return AArch64::RDFFRS_PPz;
3275 case AArch64::PTRUE_B:
3276 return AArch64::PTRUES_B;
3287 if (
MI.hasOrderedMemoryRef())
3292 assert((
MI.getOperand(IsPreLdSt ? 2 : 1).isReg() ||
3293 MI.getOperand(IsPreLdSt ? 2 : 1).isFI()) &&
3294 "Expected a reg or frame index operand.");
3298 bool IsImmPreLdSt = IsPreLdSt &&
MI.getOperand(3).isImm();
3300 if (!
MI.getOperand(2).isImm() && !IsImmPreLdSt)
3313 if (
MI.getOperand(1).isReg() && !IsPreLdSt) {
3314 Register BaseReg =
MI.getOperand(1).getReg();
3316 if (
MI.modifiesRegister(BaseReg,
TRI))
3322 switch (
MI.getOpcode()) {
3325 case AArch64::LDR_ZXI:
3326 case AArch64::STR_ZXI:
3327 if (!Subtarget.isLittleEndian() ||
3328 Subtarget.getSVEVectorSizeInBits() != 128)
3341 const MCAsmInfo *MAI =
MI.getMF()->getTarget().getMCAsmInfo();
3343 MI.getMF()->getFunction().needsUnwindTableEntry();
3349 if (Subtarget.isPaired128Slow()) {
3350 switch (
MI.getOpcode()) {
3353 case AArch64::LDURQi:
3354 case AArch64::STURQi:
3355 case AArch64::LDRQui:
3356 case AArch64::STRQui:
3383std::optional<ExtAddrMode>
3388 bool OffsetIsScalable;
3389 if (!getMemOperandWithOffset(MemI,
Base,
Offset, OffsetIsScalable,
TRI))
3390 return std::nullopt;
3393 return std::nullopt;
3408 int64_t OffsetScale = 1;
3413 case AArch64::LDURQi:
3414 case AArch64::STURQi:
3418 case AArch64::LDURDi:
3419 case AArch64::STURDi:
3420 case AArch64::LDURXi:
3421 case AArch64::STURXi:
3425 case AArch64::LDURWi:
3426 case AArch64::LDURSWi:
3427 case AArch64::STURWi:
3431 case AArch64::LDURHi:
3432 case AArch64::STURHi:
3433 case AArch64::LDURHHi:
3434 case AArch64::STURHHi:
3435 case AArch64::LDURSHXi:
3436 case AArch64::LDURSHWi:
3440 case AArch64::LDRBroX:
3441 case AArch64::LDRBBroX:
3442 case AArch64::LDRSBXroX:
3443 case AArch64::LDRSBWroX:
3444 case AArch64::STRBroX:
3445 case AArch64::STRBBroX:
3446 case AArch64::LDURBi:
3447 case AArch64::LDURBBi:
3448 case AArch64::LDURSBXi:
3449 case AArch64::LDURSBWi:
3450 case AArch64::STURBi:
3451 case AArch64::STURBBi:
3452 case AArch64::LDRBui:
3453 case AArch64::LDRBBui:
3454 case AArch64::LDRSBXui:
3455 case AArch64::LDRSBWui:
3456 case AArch64::STRBui:
3457 case AArch64::STRBBui:
3461 case AArch64::LDRQroX:
3462 case AArch64::STRQroX:
3463 case AArch64::LDRQui:
3464 case AArch64::STRQui:
3469 case AArch64::LDRDroX:
3470 case AArch64::STRDroX:
3471 case AArch64::LDRXroX:
3472 case AArch64::STRXroX:
3473 case AArch64::LDRDui:
3474 case AArch64::STRDui:
3475 case AArch64::LDRXui:
3476 case AArch64::STRXui:
3481 case AArch64::LDRWroX:
3482 case AArch64::LDRSWroX:
3483 case AArch64::STRWroX:
3484 case AArch64::LDRWui:
3485 case AArch64::LDRSWui:
3486 case AArch64::STRWui:
3491 case AArch64::LDRHroX:
3492 case AArch64::STRHroX:
3493 case AArch64::LDRHHroX:
3494 case AArch64::STRHHroX:
3495 case AArch64::LDRSHXroX:
3496 case AArch64::LDRSHWroX:
3497 case AArch64::LDRHui:
3498 case AArch64::STRHui:
3499 case AArch64::LDRHHui:
3500 case AArch64::STRHHui:
3501 case AArch64::LDRSHXui:
3502 case AArch64::LDRSHWui:
3510 if (BaseRegOp.
isReg() && BaseRegOp.
getReg() == Reg)
3534 case AArch64::SBFMXri:
3547 AM.
Scale = OffsetScale;
3552 case TargetOpcode::SUBREG_TO_REG: {
3568 if (
DefMI.getOpcode() != AArch64::ORRWrs ||
3569 DefMI.getOperand(1).getReg() != AArch64::WZR ||
3570 DefMI.getOperand(3).getImm() != 0)
3577 AM.
Scale = OffsetScale;
3588 auto validateOffsetForLDP = [](
unsigned NumBytes, int64_t OldOffset,
3589 int64_t NewOffset) ->
bool {
3590 int64_t MinOffset, MaxOffset;
3607 return OldOffset < MinOffset || OldOffset > MaxOffset ||
3608 (NewOffset >= MinOffset && NewOffset <= MaxOffset);
3610 auto canFoldAddSubImmIntoAddrMode = [&](int64_t Disp) ->
bool {
3612 int64_t NewOffset = OldOffset + Disp;
3613 if (!isLegalAddressingMode(NumBytes, NewOffset, 0))
3617 if (!validateOffsetForLDP(NumBytes, OldOffset, NewOffset))
3627 auto canFoldAddRegIntoAddrMode =
3632 if ((
unsigned)Scale != Scale)
3634 if (!isLegalAddressingMode(NumBytes, 0, Scale))
3646 return (Opcode == AArch64::STURQi || Opcode == AArch64::STRQui) &&
3647 Subtarget.isSTRQroSlow();
3656 case AArch64::ADDXri:
3662 return canFoldAddSubImmIntoAddrMode(Disp);
3664 case AArch64::SUBXri:
3670 return canFoldAddSubImmIntoAddrMode(-Disp);
3672 case AArch64::ADDXrs: {
3685 if (Shift != 2 && Shift != 3 && Subtarget.hasAddrLSLSlow14())
3687 if (avoidSlowSTRQ(MemI))
3690 return canFoldAddRegIntoAddrMode(1ULL << Shift);
3693 case AArch64::ADDXrr:
3701 if (!OptSize && avoidSlowSTRQ(MemI))
3703 return canFoldAddRegIntoAddrMode(1);
3705 case AArch64::ADDXrx:
3713 if (!OptSize && avoidSlowSTRQ(MemI))
3722 return canFoldAddRegIntoAddrMode(
3737 case AArch64::LDURQi:
3738 case AArch64::LDRQui:
3739 return AArch64::LDRQroX;
3740 case AArch64::STURQi:
3741 case AArch64::STRQui:
3742 return AArch64::STRQroX;
3743 case AArch64::LDURDi:
3744 case AArch64::LDRDui:
3745 return AArch64::LDRDroX;
3746 case AArch64::STURDi:
3747 case AArch64::STRDui:
3748 return AArch64::STRDroX;
3749 case AArch64::LDURXi:
3750 case AArch64::LDRXui:
3751 return AArch64::LDRXroX;
3752 case AArch64::STURXi:
3753 case AArch64::STRXui:
3754 return AArch64::STRXroX;
3755 case AArch64::LDURWi:
3756 case AArch64::LDRWui:
3757 return AArch64::LDRWroX;
3758 case AArch64::LDURSWi:
3759 case AArch64::LDRSWui:
3760 return AArch64::LDRSWroX;
3761 case AArch64::STURWi:
3762 case AArch64::STRWui:
3763 return AArch64::STRWroX;
3764 case AArch64::LDURHi:
3765 case AArch64::LDRHui:
3766 return AArch64::LDRHroX;
3767 case AArch64::STURHi:
3768 case AArch64::STRHui:
3769 return AArch64::STRHroX;
3770 case AArch64::LDURHHi:
3771 case AArch64::LDRHHui:
3772 return AArch64::LDRHHroX;
3773 case AArch64::STURHHi:
3774 case AArch64::STRHHui:
3775 return AArch64::STRHHroX;
3776 case AArch64::LDURSHXi:
3777 case AArch64::LDRSHXui:
3778 return AArch64::LDRSHXroX;
3779 case AArch64::LDURSHWi:
3780 case AArch64::LDRSHWui:
3781 return AArch64::LDRSHWroX;
3782 case AArch64::LDURBi:
3783 case AArch64::LDRBui:
3784 return AArch64::LDRBroX;
3785 case AArch64::LDURBBi:
3786 case AArch64::LDRBBui:
3787 return AArch64::LDRBBroX;
3788 case AArch64::LDURSBXi:
3789 case AArch64::LDRSBXui:
3790 return AArch64::LDRSBXroX;
3791 case AArch64::LDURSBWi:
3792 case AArch64::LDRSBWui:
3793 return AArch64::LDRSBWroX;
3794 case AArch64::STURBi:
3795 case AArch64::STRBui:
3796 return AArch64::STRBroX;
3797 case AArch64::STURBBi:
3798 case AArch64::STRBBui:
3799 return AArch64::STRBBroX;
3811 case AArch64::LDURQi:
3813 return AArch64::LDRQui;
3814 case AArch64::STURQi:
3816 return AArch64::STRQui;
3817 case AArch64::LDURDi:
3819 return AArch64::LDRDui;
3820 case AArch64::STURDi:
3822 return AArch64::STRDui;
3823 case AArch64::LDURXi:
3825 return AArch64::LDRXui;
3826 case AArch64::STURXi:
3828 return AArch64::STRXui;
3829 case AArch64::LDURWi:
3831 return AArch64::LDRWui;
3832 case AArch64::LDURSWi:
3834 return AArch64::LDRSWui;
3835 case AArch64::STURWi:
3837 return AArch64::STRWui;
3838 case AArch64::LDURHi:
3840 return AArch64::LDRHui;
3841 case AArch64::STURHi:
3843 return AArch64::STRHui;
3844 case AArch64::LDURHHi:
3846 return AArch64::LDRHHui;
3847 case AArch64::STURHHi:
3849 return AArch64::STRHHui;
3850 case AArch64::LDURSHXi:
3852 return AArch64::LDRSHXui;
3853 case AArch64::LDURSHWi:
3855 return AArch64::LDRSHWui;
3856 case AArch64::LDURBi:
3858 return AArch64::LDRBui;
3859 case AArch64::LDURBBi:
3861 return AArch64::LDRBBui;
3862 case AArch64::LDURSBXi:
3864 return AArch64::LDRSBXui;
3865 case AArch64::LDURSBWi:
3867 return AArch64::LDRSBWui;
3868 case AArch64::STURBi:
3870 return AArch64::STRBui;
3871 case AArch64::STURBBi:
3873 return AArch64::STRBBui;
3874 case AArch64::LDRQui:
3875 case AArch64::STRQui:
3878 case AArch64::LDRDui:
3879 case AArch64::STRDui:
3880 case AArch64::LDRXui:
3881 case AArch64::STRXui:
3884 case AArch64::LDRWui:
3885 case AArch64::LDRSWui:
3886 case AArch64::STRWui:
3889 case AArch64::LDRHui:
3890 case AArch64::STRHui:
3891 case AArch64::LDRHHui:
3892 case AArch64::STRHHui:
3893 case AArch64::LDRSHXui:
3894 case AArch64::LDRSHWui:
3897 case AArch64::LDRBui:
3898 case AArch64::LDRBBui:
3899 case AArch64::LDRSBXui:
3900 case AArch64::LDRSBWui:
3901 case AArch64::STRBui:
3902 case AArch64::STRBBui:
3916 case AArch64::LDURQi:
3917 case AArch64::STURQi:
3918 case AArch64::LDURDi:
3919 case AArch64::STURDi:
3920 case AArch64::LDURXi:
3921 case AArch64::STURXi:
3922 case AArch64::LDURWi:
3923 case AArch64::LDURSWi:
3924 case AArch64::STURWi:
3925 case AArch64::LDURHi:
3926 case AArch64::STURHi:
3927 case AArch64::LDURHHi:
3928 case AArch64::STURHHi:
3929 case AArch64::LDURSHXi:
3930 case AArch64::LDURSHWi:
3931 case AArch64::LDURBi:
3932 case AArch64::STURBi:
3933 case AArch64::LDURBBi:
3934 case AArch64::STURBBi:
3935 case AArch64::LDURSBWi:
3936 case AArch64::LDURSBXi:
3938 case AArch64::LDRQui:
3939 return AArch64::LDURQi;
3940 case AArch64::STRQui:
3941 return AArch64::STURQi;
3942 case AArch64::LDRDui:
3943 return AArch64::LDURDi;
3944 case AArch64::STRDui:
3945 return AArch64::STURDi;
3946 case AArch64::LDRXui:
3947 return AArch64::LDURXi;
3948 case AArch64::STRXui:
3949 return AArch64::STURXi;
3950 case AArch64::LDRWui:
3951 return AArch64::LDURWi;
3952 case AArch64::LDRSWui:
3953 return AArch64::LDURSWi;
3954 case AArch64::STRWui:
3955 return AArch64::STURWi;
3956 case AArch64::LDRHui:
3957 return AArch64::LDURHi;
3958 case AArch64::STRHui:
3959 return AArch64::STURHi;
3960 case AArch64::LDRHHui:
3961 return AArch64::LDURHHi;
3962 case AArch64::STRHHui:
3963 return AArch64::STURHHi;
3964 case AArch64::LDRSHXui:
3965 return AArch64::LDURSHXi;
3966 case AArch64::LDRSHWui:
3967 return AArch64::LDURSHWi;
3968 case AArch64::LDRBBui:
3969 return AArch64::LDURBBi;
3970 case AArch64::LDRBui:
3971 return AArch64::LDURBi;
3972 case AArch64::STRBBui:
3973 return AArch64::STURBBi;
3974 case AArch64::STRBui:
3975 return AArch64::STURBi;
3976 case AArch64::LDRSBWui:
3977 return AArch64::LDURSBWi;
3978 case AArch64::LDRSBXui:
3979 return AArch64::LDURSBXi;
3992 case AArch64::LDRQroX:
3993 case AArch64::LDURQi:
3994 case AArch64::LDRQui:
3995 return AArch64::LDRQroW;
3996 case AArch64::STRQroX:
3997 case AArch64::STURQi:
3998 case AArch64::STRQui:
3999 return AArch64::STRQroW;
4000 case AArch64::LDRDroX:
4001 case AArch64::LDURDi:
4002 case AArch64::LDRDui:
4003 return AArch64::LDRDroW;
4004 case AArch64::STRDroX:
4005 case AArch64::STURDi:
4006 case AArch64::STRDui:
4007 return AArch64::STRDroW;
4008 case AArch64::LDRXroX:
4009 case AArch64::LDURXi:
4010 case AArch64::LDRXui:
4011 return AArch64::LDRXroW;
4012 case AArch64::STRXroX:
4013 case AArch64::STURXi:
4014 case AArch64::STRXui:
4015 return AArch64::STRXroW;
4016 case AArch64::LDRWroX:
4017 case AArch64::LDURWi:
4018 case AArch64::LDRWui:
4019 return AArch64::LDRWroW;
4020 case AArch64::LDRSWroX:
4021 case AArch64::LDURSWi:
4022 case AArch64::LDRSWui:
4023 return AArch64::LDRSWroW;
4024 case AArch64::STRWroX:
4025 case AArch64::STURWi:
4026 case AArch64::STRWui:
4027 return AArch64::STRWroW;
4028 case AArch64::LDRHroX:
4029 case AArch64::LDURHi:
4030 case AArch64::LDRHui:
4031 return AArch64::LDRHroW;
4032 case AArch64::STRHroX:
4033 case AArch64::STURHi:
4034 case AArch64::STRHui:
4035 return AArch64::STRHroW;
4036 case AArch64::LDRHHroX:
4037 case AArch64::LDURHHi:
4038 case AArch64::LDRHHui:
4039 return AArch64::LDRHHroW;
4040 case AArch64::STRHHroX:
4041 case AArch64::STURHHi:
4042 case AArch64::STRHHui:
4043 return AArch64::STRHHroW;
4044 case AArch64::LDRSHXroX:
4045 case AArch64::LDURSHXi:
4046 case AArch64::LDRSHXui:
4047 return AArch64::LDRSHXroW;
4048 case AArch64::LDRSHWroX:
4049 case AArch64::LDURSHWi:
4050 case AArch64::LDRSHWui:
4051 return AArch64::LDRSHWroW;
4052 case AArch64::LDRBroX:
4053 case AArch64::LDURBi:
4054 case AArch64::LDRBui:
4055 return AArch64::LDRBroW;
4056 case AArch64::LDRBBroX:
4057 case AArch64::LDURBBi:
4058 case AArch64::LDRBBui:
4059 return AArch64::LDRBBroW;
4060 case AArch64::LDRSBXroX:
4061 case AArch64::LDURSBXi:
4062 case AArch64::LDRSBXui:
4063 return AArch64::LDRSBXroW;
4064 case AArch64::LDRSBWroX:
4065 case AArch64::LDURSBWi:
4066 case AArch64::LDRSBWui:
4067 return AArch64::LDRSBWroW;
4068 case AArch64::STRBroX:
4069 case AArch64::STURBi:
4070 case AArch64::STRBui:
4071 return AArch64::STRBroW;
4072 case AArch64::STRBBroX:
4073 case AArch64::STURBBi:
4074 case AArch64::STRBBui:
4075 return AArch64::STRBBroW;
4100 return B.getInstr();
4104 "Addressing mode not supported for folding");
4121 return B.getInstr();
4128 "Address offset can be a register or an immediate, but not both");
4149 return B.getInstr();
4153 "Function must not be called with an addressing mode it can't handle");
4162 case AArch64::LD1Fourv16b_POST:
4163 case AArch64::LD1Fourv1d_POST:
4164 case AArch64::LD1Fourv2d_POST:
4165 case AArch64::LD1Fourv2s_POST:
4166 case AArch64::LD1Fourv4h_POST:
4167 case AArch64::LD1Fourv4s_POST:
4168 case AArch64::LD1Fourv8b_POST:
4169 case AArch64::LD1Fourv8h_POST:
4170 case AArch64::LD1Onev16b_POST:
4171 case AArch64::LD1Onev1d_POST:
4172 case AArch64::LD1Onev2d_POST:
4173 case AArch64::LD1Onev2s_POST:
4174 case AArch64::LD1Onev4h_POST:
4175 case AArch64::LD1Onev4s_POST:
4176 case AArch64::LD1Onev8b_POST:
4177 case AArch64::LD1Onev8h_POST:
4178 case AArch64::LD1Rv16b_POST:
4179 case AArch64::LD1Rv1d_POST:
4180 case AArch64::LD1Rv2d_POST:
4181 case AArch64::LD1Rv2s_POST:
4182 case AArch64::LD1Rv4h_POST:
4183 case AArch64::LD1Rv4s_POST:
4184 case AArch64::LD1Rv8b_POST:
4185 case AArch64::LD1Rv8h_POST:
4186 case AArch64::LD1Threev16b_POST:
4187 case AArch64::LD1Threev1d_POST:
4188 case AArch64::LD1Threev2d_POST:
4189 case AArch64::LD1Threev2s_POST:
4190 case AArch64::LD1Threev4h_POST:
4191 case AArch64::LD1Threev4s_POST:
4192 case AArch64::LD1Threev8b_POST:
4193 case AArch64::LD1Threev8h_POST:
4194 case AArch64::LD1Twov16b_POST:
4195 case AArch64::LD1Twov1d_POST:
4196 case AArch64::LD1Twov2d_POST:
4197 case AArch64::LD1Twov2s_POST:
4198 case AArch64::LD1Twov4h_POST:
4199 case AArch64::LD1Twov4s_POST:
4200 case AArch64::LD1Twov8b_POST:
4201 case AArch64::LD1Twov8h_POST:
4202 case AArch64::LD1i16_POST:
4203 case AArch64::LD1i32_POST:
4204 case AArch64::LD1i64_POST:
4205 case AArch64::LD1i8_POST:
4206 case AArch64::LD2Rv16b_POST:
4207 case AArch64::LD2Rv1d_POST:
4208 case AArch64::LD2Rv2d_POST:
4209 case AArch64::LD2Rv2s_POST:
4210 case AArch64::LD2Rv4h_POST:
4211 case AArch64::LD2Rv4s_POST:
4212 case AArch64::LD2Rv8b_POST:
4213 case AArch64::LD2Rv8h_POST:
4214 case AArch64::LD2Twov16b_POST:
4215 case AArch64::LD2Twov2d_POST:
4216 case AArch64::LD2Twov2s_POST:
4217 case AArch64::LD2Twov4h_POST:
4218 case AArch64::LD2Twov4s_POST:
4219 case AArch64::LD2Twov8b_POST:
4220 case AArch64::LD2Twov8h_POST:
4221 case AArch64::LD2i16_POST:
4222 case AArch64::LD2i32_POST:
4223 case AArch64::LD2i64_POST:
4224 case AArch64::LD2i8_POST:
4225 case AArch64::LD3Rv16b_POST:
4226 case AArch64::LD3Rv1d_POST:
4227 case AArch64::LD3Rv2d_POST:
4228 case AArch64::LD3Rv2s_POST:
4229 case AArch64::LD3Rv4h_POST:
4230 case AArch64::LD3Rv4s_POST:
4231 case AArch64::LD3Rv8b_POST:
4232 case AArch64::LD3Rv8h_POST:
4233 case AArch64::LD3Threev16b_POST:
4234 case AArch64::LD3Threev2d_POST:
4235 case AArch64::LD3Threev2s_POST:
4236 case AArch64::LD3Threev4h_POST:
4237 case AArch64::LD3Threev4s_POST:
4238 case AArch64::LD3Threev8b_POST:
4239 case AArch64::LD3Threev8h_POST:
4240 case AArch64::LD3i16_POST:
4241 case AArch64::LD3i32_POST:
4242 case AArch64::LD3i64_POST:
4243 case AArch64::LD3i8_POST:
4244 case AArch64::LD4Fourv16b_POST:
4245 case AArch64::LD4Fourv2d_POST:
4246 case AArch64::LD4Fourv2s_POST:
4247 case AArch64::LD4Fourv4h_POST:
4248 case AArch64::LD4Fourv4s_POST:
4249 case AArch64::LD4Fourv8b_POST:
4250 case AArch64::LD4Fourv8h_POST:
4251 case AArch64::LD4Rv16b_POST:
4252 case AArch64::LD4Rv1d_POST:
4253 case AArch64::LD4Rv2d_POST:
4254 case AArch64::LD4Rv2s_POST:
4255 case AArch64::LD4Rv4h_POST:
4256 case AArch64::LD4Rv4s_POST:
4257 case AArch64::LD4Rv8b_POST:
4258 case AArch64::LD4Rv8h_POST:
4259 case AArch64::LD4i16_POST:
4260 case AArch64::LD4i32_POST:
4261 case AArch64::LD4i64_POST:
4262 case AArch64::LD4i8_POST:
4263 case AArch64::LDAPRWpost:
4264 case AArch64::LDAPRXpost:
4265 case AArch64::LDIAPPWpost:
4266 case AArch64::LDIAPPXpost:
4267 case AArch64::LDPDpost:
4268 case AArch64::LDPQpost:
4269 case AArch64::LDPSWpost:
4270 case AArch64::LDPSpost:
4271 case AArch64::LDPWpost:
4272 case AArch64::LDPXpost:
4273 case AArch64::LDRBBpost:
4274 case AArch64::LDRBpost:
4275 case AArch64::LDRDpost:
4276 case AArch64::LDRHHpost:
4277 case AArch64::LDRHpost:
4278 case AArch64::LDRQpost:
4279 case AArch64::LDRSBWpost:
4280 case AArch64::LDRSBXpost:
4281 case AArch64::LDRSHWpost:
4282 case AArch64::LDRSHXpost:
4283 case AArch64::LDRSWpost:
4284 case AArch64::LDRSpost:
4285 case AArch64::LDRWpost:
4286 case AArch64::LDRXpost:
4287 case AArch64::ST1Fourv16b_POST:
4288 case AArch64::ST1Fourv1d_POST:
4289 case AArch64::ST1Fourv2d_POST:
4290 case AArch64::ST1Fourv2s_POST:
4291 case AArch64::ST1Fourv4h_POST:
4292 case AArch64::ST1Fourv4s_POST:
4293 case AArch64::ST1Fourv8b_POST:
4294 case AArch64::ST1Fourv8h_POST:
4295 case AArch64::ST1Onev16b_POST:
4296 case AArch64::ST1Onev1d_POST:
4297 case AArch64::ST1Onev2d_POST:
4298 case AArch64::ST1Onev2s_POST:
4299 case AArch64::ST1Onev4h_POST:
4300 case AArch64::ST1Onev4s_POST:
4301 case AArch64::ST1Onev8b_POST:
4302 case AArch64::ST1Onev8h_POST:
4303 case AArch64::ST1Threev16b_POST:
4304 case AArch64::ST1Threev1d_POST:
4305 case AArch64::ST1Threev2d_POST:
4306 case AArch64::ST1Threev2s_POST:
4307 case AArch64::ST1Threev4h_POST:
4308 case AArch64::ST1Threev4s_POST:
4309 case AArch64::ST1Threev8b_POST:
4310 case AArch64::ST1Threev8h_POST:
4311 case AArch64::ST1Twov16b_POST:
4312 case AArch64::ST1Twov1d_POST:
4313 case AArch64::ST1Twov2d_POST:
4314 case AArch64::ST1Twov2s_POST:
4315 case AArch64::ST1Twov4h_POST:
4316 case AArch64::ST1Twov4s_POST:
4317 case AArch64::ST1Twov8b_POST:
4318 case AArch64::ST1Twov8h_POST:
4319 case AArch64::ST1i16_POST:
4320 case AArch64::ST1i32_POST:
4321 case AArch64::ST1i64_POST:
4322 case AArch64::ST1i8_POST:
4323 case AArch64::ST2GPostIndex:
4324 case AArch64::ST2Twov16b_POST:
4325 case AArch64::ST2Twov2d_POST:
4326 case AArch64::ST2Twov2s_POST:
4327 case AArch64::ST2Twov4h_POST:
4328 case AArch64::ST2Twov4s_POST:
4329 case AArch64::ST2Twov8b_POST:
4330 case AArch64::ST2Twov8h_POST:
4331 case AArch64::ST2i16_POST:
4332 case AArch64::ST2i32_POST:
4333 case AArch64::ST2i64_POST:
4334 case AArch64::ST2i8_POST:
4335 case AArch64::ST3Threev16b_POST:
4336 case AArch64::ST3Threev2d_POST:
4337 case AArch64::ST3Threev2s_POST:
4338 case AArch64::ST3Threev4h_POST:
4339 case AArch64::ST3Threev4s_POST:
4340 case AArch64::ST3Threev8b_POST:
4341 case AArch64::ST3Threev8h_POST:
4342 case AArch64::ST3i16_POST:
4343 case AArch64::ST3i32_POST:
4344 case AArch64::ST3i64_POST:
4345 case AArch64::ST3i8_POST:
4346 case AArch64::ST4Fourv16b_POST:
4347 case AArch64::ST4Fourv2d_POST:
4348 case AArch64::ST4Fourv2s_POST:
4349 case AArch64::ST4Fourv4h_POST:
4350 case AArch64::ST4Fourv4s_POST:
4351 case AArch64::ST4Fourv8b_POST:
4352 case AArch64::ST4Fourv8h_POST:
4353 case AArch64::ST4i16_POST:
4354 case AArch64::ST4i32_POST:
4355 case AArch64::ST4i64_POST:
4356 case AArch64::ST4i8_POST:
4357 case AArch64::STGPostIndex:
4358 case AArch64::STGPpost:
4359 case AArch64::STPDpost:
4360 case AArch64::STPQpost:
4361 case AArch64::STPSpost:
4362 case AArch64::STPWpost:
4363 case AArch64::STPXpost:
4364 case AArch64::STRBBpost:
4365 case AArch64::STRBpost:
4366 case AArch64::STRDpost:
4367 case AArch64::STRHHpost:
4368 case AArch64::STRHpost:
4369 case AArch64::STRQpost:
4370 case AArch64::STRSpost:
4371 case AArch64::STRWpost:
4372 case AArch64::STRXpost:
4373 case AArch64::STZ2GPostIndex:
4374 case AArch64::STZGPostIndex:
4381 bool &OffsetIsScalable,
TypeSize &Width,
4402 int64_t Dummy1, Dummy2;
4424 return BaseOp->
isReg() || BaseOp->
isFI();
4431 assert(OfsOp.
isImm() &&
"Offset operand wasn't immediate.");
4436 TypeSize &Width, int64_t &MinOffset,
4437 int64_t &MaxOffset) {
4443 MinOffset = MaxOffset = 0;
4446 case AArch64::LDRQui:
4447 case AArch64::STRQui:
4453 case AArch64::LDRXui:
4454 case AArch64::LDRDui:
4455 case AArch64::STRXui:
4456 case AArch64::STRDui:
4457 case AArch64::PRFMui:
4463 case AArch64::LDRWui:
4464 case AArch64::LDRSui:
4465 case AArch64::LDRSWui:
4466 case AArch64::STRWui:
4467 case AArch64::STRSui:
4473 case AArch64::LDRHui:
4474 case AArch64::LDRHHui:
4475 case AArch64::LDRSHWui:
4476 case AArch64::LDRSHXui:
4477 case AArch64::STRHui:
4478 case AArch64::STRHHui:
4484 case AArch64::LDRBui:
4485 case AArch64::LDRBBui:
4486 case AArch64::LDRSBWui:
4487 case AArch64::LDRSBXui:
4488 case AArch64::STRBui:
4489 case AArch64::STRBBui:
4496 case AArch64::STRQpre:
4497 case AArch64::LDRQpost:
4503 case AArch64::LDRDpost:
4504 case AArch64::LDRDpre:
4505 case AArch64::LDRXpost:
4506 case AArch64::LDRXpre:
4507 case AArch64::STRDpost:
4508 case AArch64::STRDpre:
4509 case AArch64::STRXpost:
4510 case AArch64::STRXpre:
4516 case AArch64::STRWpost:
4517 case AArch64::STRWpre:
4518 case AArch64::LDRWpost:
4519 case AArch64::LDRWpre:
4520 case AArch64::STRSpost:
4521 case AArch64::STRSpre:
4522 case AArch64::LDRSpost:
4523 case AArch64::LDRSpre:
4529 case AArch64::LDRHpost:
4530 case AArch64::LDRHpre:
4531 case AArch64::STRHpost:
4532 case AArch64::STRHpre:
4533 case AArch64::LDRHHpost:
4534 case AArch64::LDRHHpre:
4535 case AArch64::STRHHpost:
4536 case AArch64::STRHHpre:
4542 case AArch64::LDRBpost:
4543 case AArch64::LDRBpre:
4544 case AArch64::STRBpost:
4545 case AArch64::STRBpre:
4546 case AArch64::LDRBBpost:
4547 case AArch64::LDRBBpre:
4548 case AArch64::STRBBpost:
4549 case AArch64::STRBBpre:
4556 case AArch64::LDURQi:
4557 case AArch64::STURQi:
4563 case AArch64::LDURXi:
4564 case AArch64::LDURDi:
4565 case AArch64::LDAPURXi:
4566 case AArch64::STURXi:
4567 case AArch64::STURDi:
4568 case AArch64::STLURXi:
4569 case AArch64::PRFUMi:
4575 case AArch64::LDURWi:
4576 case AArch64::LDURSi:
4577 case AArch64::LDURSWi:
4578 case AArch64::LDAPURi:
4579 case AArch64::LDAPURSWi:
4580 case AArch64::STURWi:
4581 case AArch64::STURSi:
4582 case AArch64::STLURWi:
4588 case AArch64::LDURHi:
4589 case AArch64::LDURHHi:
4590 case AArch64::LDURSHXi:
4591 case AArch64::LDURSHWi:
4592 case AArch64::LDAPURHi:
4593 case AArch64::LDAPURSHWi:
4594 case AArch64::LDAPURSHXi:
4595 case AArch64::STURHi:
4596 case AArch64::STURHHi:
4597 case AArch64::STLURHi:
4603 case AArch64::LDURBi:
4604 case AArch64::LDURBBi:
4605 case AArch64::LDURSBXi:
4606 case AArch64::LDURSBWi:
4607 case AArch64::LDAPURBi:
4608 case AArch64::LDAPURSBWi:
4609 case AArch64::LDAPURSBXi:
4610 case AArch64::STURBi:
4611 case AArch64::STURBBi:
4612 case AArch64::STLURBi:
4619 case AArch64::LDPQi:
4620 case AArch64::LDNPQi:
4621 case AArch64::STPQi:
4622 case AArch64::STNPQi:
4623 case AArch64::LDPQpost:
4624 case AArch64::LDPQpre:
4625 case AArch64::STPQpost:
4626 case AArch64::STPQpre:
4632 case AArch64::LDPXi:
4633 case AArch64::LDPDi:
4634 case AArch64::LDNPXi:
4635 case AArch64::LDNPDi:
4636 case AArch64::STPXi:
4637 case AArch64::STPDi:
4638 case AArch64::STNPXi:
4639 case AArch64::STNPDi:
4640 case AArch64::LDPDpost:
4641 case AArch64::LDPDpre:
4642 case AArch64::LDPXpost:
4643 case AArch64::LDPXpre:
4644 case AArch64::STPDpost:
4645 case AArch64::STPDpre:
4646 case AArch64::STPXpost:
4647 case AArch64::STPXpre:
4653 case AArch64::LDPWi:
4654 case AArch64::LDPSi:
4655 case AArch64::LDNPWi:
4656 case AArch64::LDNPSi:
4657 case AArch64::STPWi:
4658 case AArch64::STPSi:
4659 case AArch64::STNPWi:
4660 case AArch64::STNPSi:
4661 case AArch64::LDPSpost:
4662 case AArch64::LDPSpre:
4663 case AArch64::LDPWpost:
4664 case AArch64::LDPWpre:
4665 case AArch64::STPSpost:
4666 case AArch64::STPSpre:
4667 case AArch64::STPWpost:
4668 case AArch64::STPWpre:
4674 case AArch64::StoreSwiftAsyncContext:
4687 case AArch64::TAGPstack:
4697 case AArch64::STGPreIndex:
4698 case AArch64::STGPostIndex:
4699 case AArch64::STZGi:
4700 case AArch64::STZGPreIndex:
4701 case AArch64::STZGPostIndex:
4708 case AArch64::STR_ZZZZXI:
4709 case AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS:
4710 case AArch64::LDR_ZZZZXI:
4711 case AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS:
4717 case AArch64::STR_ZZZXI:
4718 case AArch64::LDR_ZZZXI:
4724 case AArch64::STR_ZZXI:
4725 case AArch64::STR_ZZXI_STRIDED_CONTIGUOUS:
4726 case AArch64::LDR_ZZXI:
4727 case AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS:
4733 case AArch64::LDR_PXI:
4734 case AArch64::STR_PXI:
4740 case AArch64::LDR_PPXI:
4741 case AArch64::STR_PPXI:
4747 case AArch64::LDR_ZXI:
4748 case AArch64::STR_ZXI:
4754 case AArch64::LD1B_IMM:
4755 case AArch64::LD1H_IMM:
4756 case AArch64::LD1W_IMM:
4757 case AArch64::LD1D_IMM:
4758 case AArch64::LDNT1B_ZRI:
4759 case AArch64::LDNT1H_ZRI:
4760 case AArch64::LDNT1W_ZRI:
4761 case AArch64::LDNT1D_ZRI:
4762 case AArch64::ST1B_IMM:
4763 case AArch64::ST1H_IMM:
4764 case AArch64::ST1W_IMM:
4765 case AArch64::ST1D_IMM:
4766 case AArch64::STNT1B_ZRI:
4767 case AArch64::STNT1H_ZRI:
4768 case AArch64::STNT1W_ZRI:
4769 case AArch64::STNT1D_ZRI:
4770 case AArch64::LDNF1B_IMM:
4771 case AArch64::LDNF1H_IMM:
4772 case AArch64::LDNF1W_IMM:
4773 case AArch64::LDNF1D_IMM:
4781 case AArch64::LD2B_IMM:
4782 case AArch64::LD2H_IMM:
4783 case AArch64::LD2W_IMM:
4784 case AArch64::LD2D_IMM:
4785 case AArch64::ST2B_IMM:
4786 case AArch64::ST2H_IMM:
4787 case AArch64::ST2W_IMM:
4788 case AArch64::ST2D_IMM:
4794 case AArch64::LD3B_IMM:
4795 case AArch64::LD3H_IMM:
4796 case AArch64::LD3W_IMM:
4797 case AArch64::LD3D_IMM:
4798 case AArch64::ST3B_IMM:
4799 case AArch64::ST3H_IMM:
4800 case AArch64::ST3W_IMM:
4801 case AArch64::ST3D_IMM:
4807 case AArch64::LD4B_IMM:
4808 case AArch64::LD4H_IMM:
4809 case AArch64::LD4W_IMM:
4810 case AArch64::LD4D_IMM:
4811 case AArch64::ST4B_IMM:
4812 case AArch64::ST4H_IMM:
4813 case AArch64::ST4W_IMM:
4814 case AArch64::ST4D_IMM:
4820 case AArch64::LD1B_H_IMM:
4821 case AArch64::LD1SB_H_IMM:
4822 case AArch64::LD1H_S_IMM:
4823 case AArch64::LD1SH_S_IMM:
4824 case AArch64::LD1W_D_IMM:
4825 case AArch64::LD1SW_D_IMM:
4826 case AArch64::ST1B_H_IMM:
4827 case AArch64::ST1H_S_IMM:
4828 case AArch64::ST1W_D_IMM:
4829 case AArch64::LDNF1B_H_IMM:
4830 case AArch64::LDNF1SB_H_IMM:
4831 case AArch64::LDNF1H_S_IMM:
4832 case AArch64::LDNF1SH_S_IMM:
4833 case AArch64::LDNF1W_D_IMM:
4834 case AArch64::LDNF1SW_D_IMM:
4842 case AArch64::LD1B_S_IMM:
4843 case AArch64::LD1SB_S_IMM:
4844 case AArch64::LD1H_D_IMM:
4845 case AArch64::LD1SH_D_IMM:
4846 case AArch64::ST1B_S_IMM:
4847 case AArch64::ST1H_D_IMM:
4848 case AArch64::LDNF1B_S_IMM:
4849 case AArch64::LDNF1SB_S_IMM:
4850 case AArch64::LDNF1H_D_IMM:
4851 case AArch64::LDNF1SH_D_IMM:
4859 case AArch64::LD1B_D_IMM:
4860 case AArch64::LD1SB_D_IMM:
4861 case AArch64::ST1B_D_IMM:
4862 case AArch64::LDNF1B_D_IMM:
4863 case AArch64::LDNF1SB_D_IMM:
4871 case AArch64::ST2Gi:
4872 case AArch64::ST2GPreIndex:
4873 case AArch64::ST2GPostIndex:
4874 case AArch64::STZ2Gi:
4875 case AArch64::STZ2GPreIndex:
4876 case AArch64::STZ2GPostIndex:
4882 case AArch64::STGPi:
4883 case AArch64::STGPpost:
4884 case AArch64::STGPpre:
4890 case AArch64::LD1RB_IMM:
4891 case AArch64::LD1RB_H_IMM:
4892 case AArch64::LD1RB_S_IMM:
4893 case AArch64::LD1RB_D_IMM:
4894 case AArch64::LD1RSB_H_IMM:
4895 case AArch64::LD1RSB_S_IMM:
4896 case AArch64::LD1RSB_D_IMM:
4902 case AArch64::LD1RH_IMM:
4903 case AArch64::LD1RH_S_IMM:
4904 case AArch64::LD1RH_D_IMM:
4905 case AArch64::LD1RSH_S_IMM:
4906 case AArch64::LD1RSH_D_IMM:
4912 case AArch64::LD1RW_IMM:
4913 case AArch64::LD1RW_D_IMM:
4914 case AArch64::LD1RSW_IMM:
4920 case AArch64::LD1RD_IMM:
4936 case AArch64::LDRBui:
4937 case AArch64::LDRBBui:
4938 case AArch64::LDURBBi:
4939 case AArch64::LDRSBWui:
4940 case AArch64::LDURSBWi:
4941 case AArch64::STRBui:
4942 case AArch64::STRBBui:
4943 case AArch64::STURBBi:
4945 case AArch64::LDRHui:
4946 case AArch64::LDRHHui:
4947 case AArch64::LDURHHi:
4948 case AArch64::LDRSHWui:
4949 case AArch64::LDURSHWi:
4950 case AArch64::STRHui:
4951 case AArch64::STRHHui:
4952 case AArch64::STURHHi:
4954 case AArch64::LDRSui:
4955 case AArch64::LDURSi:
4956 case AArch64::LDRSpre:
4957 case AArch64::LDRSWui:
4958 case AArch64::LDURSWi:
4959 case AArch64::LDRSWpre:
4960 case AArch64::LDRWpre:
4961 case AArch64::LDRWui:
4962 case AArch64::LDURWi:
4963 case AArch64::STRSui:
4964 case AArch64::STURSi:
4965 case AArch64::STRSpre:
4966 case AArch64::STRWui:
4967 case AArch64::STURWi:
4968 case AArch64::STRWpre:
4969 case AArch64::LDPSi:
4970 case AArch64::LDPSWi:
4971 case AArch64::LDPWi:
4972 case AArch64::STPSi:
4973 case AArch64::STPWi:
4975 case AArch64::LDRDui:
4976 case AArch64::LDURDi:
4977 case AArch64::LDRDpre:
4978 case AArch64::LDRXui:
4979 case AArch64::LDURXi:
4980 case AArch64::LDRXpre:
4981 case AArch64::STRDui:
4982 case AArch64::STURDi:
4983 case AArch64::STRDpre:
4984 case AArch64::STRXui:
4985 case AArch64::STURXi:
4986 case AArch64::STRXpre:
4987 case AArch64::LDPDi:
4988 case AArch64::LDPXi:
4989 case AArch64::STPDi:
4990 case AArch64::STPXi:
4992 case AArch64::LDRQui:
4993 case AArch64::LDURQi:
4994 case AArch64::STRQui:
4995 case AArch64::STURQi:
4996 case AArch64::STRQpre:
4997 case AArch64::LDPQi:
4998 case AArch64::LDRQpre:
4999 case AArch64::STPQi:
5001 case AArch64::STZGi:
5002 case AArch64::ST2Gi:
5003 case AArch64::STZ2Gi:
5004 case AArch64::STGPi:
5010 switch (
MI.getOpcode()) {
5013 case AArch64::LDRWpre:
5014 case AArch64::LDRXpre:
5015 case AArch64::LDRSWpre:
5016 case AArch64::LDRSpre:
5017 case AArch64::LDRDpre:
5018 case AArch64::LDRQpre:
5024 switch (
MI.getOpcode()) {
5027 case AArch64::STRWpre:
5028 case AArch64::STRXpre:
5029 case AArch64::STRSpre:
5030 case AArch64::STRDpre:
5031 case AArch64::STRQpre:
5041 switch (
MI.getOpcode()) {
5044 case AArch64::LDURBBi:
5045 case AArch64::LDURHHi:
5046 case AArch64::LDURWi:
5047 case AArch64::LDRBBui:
5048 case AArch64::LDRHHui:
5049 case AArch64::LDRWui:
5050 case AArch64::LDRBBroX:
5051 case AArch64::LDRHHroX:
5052 case AArch64::LDRWroX:
5053 case AArch64::LDRBBroW:
5054 case AArch64::LDRHHroW:
5055 case AArch64::LDRWroW:
5061 switch (
MI.getOpcode()) {
5064 case AArch64::LDURSBWi:
5065 case AArch64::LDURSHWi:
5066 case AArch64::LDURSBXi:
5067 case AArch64::LDURSHXi:
5068 case AArch64::LDURSWi:
5069 case AArch64::LDRSBWui:
5070 case AArch64::LDRSHWui:
5071 case AArch64::LDRSBXui:
5072 case AArch64::LDRSHXui:
5073 case AArch64::LDRSWui:
5074 case AArch64::LDRSBWroX:
5075 case AArch64::LDRSHWroX:
5076 case AArch64::LDRSBXroX:
5077 case AArch64::LDRSHXroX:
5078 case AArch64::LDRSWroX:
5079 case AArch64::LDRSBWroW:
5080 case AArch64::LDRSHWroW:
5081 case AArch64::LDRSBXroW:
5082 case AArch64::LDRSHXroW:
5083 case AArch64::LDRSWroW:
5089 switch (
MI.getOpcode()) {
5092 case AArch64::LDPSi:
5093 case AArch64::LDPSWi:
5094 case AArch64::LDPDi:
5095 case AArch64::LDPQi:
5096 case AArch64::LDPWi:
5097 case AArch64::LDPXi:
5098 case AArch64::STPSi:
5099 case AArch64::STPDi:
5100 case AArch64::STPQi:
5101 case AArch64::STPWi:
5102 case AArch64::STPXi:
5103 case AArch64::STGPi:
5109 assert(
MI.mayLoadOrStore() &&
"Load or store instruction expected");
5113 return MI.getOperand(Idx);
5118 assert(
MI.mayLoadOrStore() &&
"Load or store instruction expected");
5122 return MI.getOperand(Idx);
5127 switch (
MI.getOpcode()) {
5130 case AArch64::LDRBroX:
5131 case AArch64::LDRBBroX:
5132 case AArch64::LDRSBXroX:
5133 case AArch64::LDRSBWroX:
5134 case AArch64::LDRHroX:
5135 case AArch64::LDRHHroX:
5136 case AArch64::LDRSHXroX:
5137 case AArch64::LDRSHWroX:
5138 case AArch64::LDRWroX:
5139 case AArch64::LDRSroX:
5140 case AArch64::LDRSWroX:
5141 case AArch64::LDRDroX:
5142 case AArch64::LDRXroX:
5143 case AArch64::LDRQroX:
5144 return MI.getOperand(4);
5150 if (
MI.getParent() ==
nullptr)
5160 auto Reg =
Op.getReg();
5161 if (Reg.isPhysical())
5162 return AArch64::FPR16RegClass.contains(Reg);
5164 return TRC == &AArch64::FPR16RegClass ||
5165 TRC == &AArch64::FPR16_loRegClass;
5174 auto Reg =
Op.getReg();
5175 if (Reg.isPhysical())
5176 return AArch64::FPR128RegClass.contains(Reg);
5178 return TRC == &AArch64::FPR128RegClass ||
5179 TRC == &AArch64::FPR128_loRegClass;
5185 switch (
MI.getOpcode()) {
5188 case AArch64::PACIASP:
5189 case AArch64::PACIBSP:
5192 case AArch64::PAUTH_PROLOGUE:
5195 case AArch64::HINT: {
5196 unsigned Imm =
MI.getOperand(0).getImm();
5198 if (Imm == 32 || Imm == 34 || Imm == 36 || Imm == 38)
5201 if (Imm == 25 || Imm == 27)
5213 assert(Reg.isPhysical() &&
"Expected physical register in isFpOrNEON");
5214 return AArch64::FPR128RegClass.contains(Reg) ||
5215 AArch64::FPR64RegClass.contains(Reg) ||
5216 AArch64::FPR32RegClass.contains(Reg) ||
5217 AArch64::FPR16RegClass.contains(Reg) ||
5218 AArch64::FPR8RegClass.contains(Reg);
5225 auto Reg =
Op.getReg();
5226 if (Reg.isPhysical())
5230 return TRC == &AArch64::FPR128RegClass ||
5231 TRC == &AArch64::FPR128_loRegClass ||
5232 TRC == &AArch64::FPR64RegClass ||
5233 TRC == &AArch64::FPR64_loRegClass ||
5234 TRC == &AArch64::FPR32RegClass || TRC == &AArch64::FPR16RegClass ||
5235 TRC == &AArch64::FPR8RegClass;
5257 if (FirstOpc == SecondOpc)
5263 case AArch64::STRSui:
5264 case AArch64::STURSi:
5265 return SecondOpc == AArch64::STRSui || SecondOpc == AArch64::STURSi;
5266 case AArch64::STRDui:
5267 case AArch64::STURDi:
5268 return SecondOpc == AArch64::STRDui || SecondOpc == AArch64::STURDi;
5269 case AArch64::STRQui:
5270 case AArch64::STURQi:
5271 return SecondOpc == AArch64::STRQui || SecondOpc == AArch64::STURQi;
5272 case AArch64::STRWui:
5273 case AArch64::STURWi:
5274 return SecondOpc == AArch64::STRWui || SecondOpc == AArch64::STURWi;
5275 case AArch64::STRXui:
5276 case AArch64::STURXi:
5277 return SecondOpc == AArch64::STRXui || SecondOpc == AArch64::STURXi;
5278 case AArch64::LDRSui:
5279 case AArch64::LDURSi:
5280 return SecondOpc == AArch64::LDRSui || SecondOpc == AArch64::LDURSi;
5281 case AArch64::LDRDui:
5282 case AArch64::LDURDi:
5283 return SecondOpc == AArch64::LDRDui || SecondOpc == AArch64::LDURDi;
5284 case AArch64::LDRQui:
5285 case AArch64::LDURQi:
5286 return SecondOpc == AArch64::LDRQui || SecondOpc == AArch64::LDURQi;
5287 case AArch64::LDRWui:
5288 case AArch64::LDURWi:
5289 return SecondOpc == AArch64::LDRSWui || SecondOpc == AArch64::LDURSWi;
5290 case AArch64::LDRSWui:
5291 case AArch64::LDURSWi:
5292 return SecondOpc == AArch64::LDRWui || SecondOpc == AArch64::LDURWi;
5293 case AArch64::LDRXui:
5294 case AArch64::LDURXi:
5295 return SecondOpc == AArch64::LDRXui || SecondOpc == AArch64::LDURXi;
5302 int64_t Offset1,
unsigned Opcode1,
int FI2,
5303 int64_t Offset2,
unsigned Opcode2) {
5309 assert(ObjectOffset1 <= ObjectOffset2 &&
"Object offsets are not ordered.");
5312 if (ObjectOffset1 % Scale1 != 0)
5314 ObjectOffset1 /= Scale1;
5316 if (ObjectOffset2 % Scale2 != 0)
5318 ObjectOffset2 /= Scale2;
5319 ObjectOffset1 += Offset1;
5320 ObjectOffset2 += Offset2;
5321 return ObjectOffset1 + 1 == ObjectOffset2;
5333 int64_t OpOffset2,
bool OffsetIsScalable2,
unsigned ClusterSize,
5334 unsigned NumBytes)
const {
5344 "Only base registers and frame indices are supported.");
5351 if (ClusterSize > 2)
5358 unsigned FirstOpc = FirstLdSt.
getOpcode();
5359 unsigned SecondOpc = SecondLdSt.
getOpcode();
5379 if (Offset1 > 63 || Offset1 < -64)
5384 if (BaseOp1.
isFI()) {
5386 "Caller should have ordered offsets.");
5391 BaseOp2.
getIndex(), Offset2, SecondOpc);
5394 assert(Offset1 <= Offset2 &&
"Caller should have ordered offsets.");
5396 return Offset1 + 1 == Offset2;
5406 if (
Reg.isPhysical())
5415 return ((DestReg - SrcReg) & 0x1f) < NumRegs;
5424 assert(Subtarget.hasNEON() &&
"Unexpected register copy without NEON");
5426 uint16_t DestEncoding =
TRI->getEncodingValue(DestReg);
5427 uint16_t SrcEncoding =
TRI->getEncodingValue(SrcReg);
5428 unsigned NumRegs = Indices.
size();
5430 int SubReg = 0, End = NumRegs, Incr = 1;
5432 SubReg = NumRegs - 1;
5437 for (; SubReg != End; SubReg += Incr) {
5449 unsigned Opcode,
unsigned ZeroReg,
5452 unsigned NumRegs = Indices.
size();
5455 uint16_t DestEncoding =
TRI->getEncodingValue(DestReg);
5456 uint16_t SrcEncoding =
TRI->getEncodingValue(SrcReg);
5457 assert(DestEncoding % NumRegs == 0 && SrcEncoding % NumRegs == 0 &&
5458 "GPR reg sequences should not be able to overlap");
5461 for (
unsigned SubReg = 0; SubReg != NumRegs; ++SubReg) {
5482 unsigned Opc =
MI.getOpcode();
5483 if (
Opc == AArch64::MSRpstatesvcrImm1 ||
Opc == AArch64::MSRpstatePseudo) {
5485 int64_t PState =
MI.getOperand(0).getImm();
5486 if (PState == AArch64SVCR::SVCRSM || PState == AArch64SVCR::SVCRSMZA) {
5488 return MI.getOperand(1).getImm() == 1;
5507 bool RenamableSrc)
const {
5509 if (AArch64::GPR32spRegClass.
contains(DestReg) &&
5510 AArch64::GPR32spRegClass.
contains(SrcReg)) {
5511 if (DestReg == AArch64::WSP || SrcReg == AArch64::WSP) {
5513 if (Subtarget.hasZeroCycleRegMoveGPR64() &&
5514 !Subtarget.hasZeroCycleRegMoveGPR32()) {
5516 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5517 &AArch64::GPR64spRegClass);
5518 MCRegister SrcRegX = RI.getMatchingSuperReg(SrcReg, AArch64::sub_32,
5519 &AArch64::GPR64spRegClass);
5529 ++NumZCRegMoveInstrsGPR;
5535 if (Subtarget.hasZeroCycleRegMoveGPR32())
5536 ++NumZCRegMoveInstrsGPR;
5538 }
else if (Subtarget.hasZeroCycleRegMoveGPR64() &&
5539 !Subtarget.hasZeroCycleRegMoveGPR32()) {
5541 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5542 &AArch64::GPR64spRegClass);
5543 assert(DestRegX.
isValid() &&
"Destination super-reg not valid");
5544 MCRegister SrcRegX = RI.getMatchingSuperReg(SrcReg, AArch64::sub_32,
5545 &AArch64::GPR64spRegClass);
5555 ++NumZCRegMoveInstrsGPR;
5561 if (Subtarget.hasZeroCycleRegMoveGPR32())
5562 ++NumZCRegMoveInstrsGPR;
5568 if (AArch64::GPR32spRegClass.
contains(DestReg) && SrcReg == AArch64::WZR) {
5569 if (Subtarget.hasZeroCycleZeroingGPR64() &&
5570 !Subtarget.hasZeroCycleZeroingGPR32()) {
5571 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5572 &AArch64::GPR64spRegClass);
5573 assert(DestRegX.
isValid() &&
"Destination super-reg not valid");
5577 ++NumZCZeroingInstrsGPR;
5578 }
else if (Subtarget.hasZeroCycleZeroingGPR32()) {
5582 ++NumZCZeroingInstrsGPR;
5591 if (AArch64::GPR64spRegClass.
contains(DestReg) &&
5592 AArch64::GPR64spRegClass.
contains(SrcReg)) {
5593 if (DestReg == AArch64::SP || SrcReg == AArch64::SP) {
5599 if (Subtarget.hasZeroCycleRegMoveGPR64())
5600 ++NumZCRegMoveInstrsGPR;
5606 if (Subtarget.hasZeroCycleRegMoveGPR64())
5607 ++NumZCRegMoveInstrsGPR;
5613 if (AArch64::GPR64spRegClass.
contains(DestReg) && SrcReg == AArch64::XZR) {
5614 if (Subtarget.hasZeroCycleZeroingGPR64()) {
5618 ++NumZCZeroingInstrsGPR;
5628 if (AArch64::PPRRegClass.
contains(DestReg) &&
5629 AArch64::PPRRegClass.
contains(SrcReg)) {
5630 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
5631 "Unexpected SVE register.");
5641 bool DestIsPNR = AArch64::PNRRegClass.contains(DestReg);
5642 bool SrcIsPNR = AArch64::PNRRegClass.contains(SrcReg);
5643 if (DestIsPNR || SrcIsPNR) {
5645 return (R - AArch64::PN0) + AArch64::P0;
5650 if (PPRSrcReg != PPRDestReg) {
5662 if (AArch64::ZPRRegClass.
contains(DestReg) &&
5663 AArch64::ZPRRegClass.
contains(SrcReg)) {
5664 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
5665 "Unexpected SVE register.");
5673 if ((AArch64::ZPR2RegClass.
contains(DestReg) ||
5674 AArch64::ZPR2StridedOrContiguousRegClass.
contains(DestReg)) &&
5675 (AArch64::ZPR2RegClass.
contains(SrcReg) ||
5676 AArch64::ZPR2StridedOrContiguousRegClass.
contains(SrcReg))) {
5677 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
5678 "Unexpected SVE register.");
5679 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1};
5686 if (AArch64::ZPR3RegClass.
contains(DestReg) &&
5687 AArch64::ZPR3RegClass.
contains(SrcReg)) {
5688 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
5689 "Unexpected SVE register.");
5690 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1,
5698 if ((AArch64::ZPR4RegClass.
contains(DestReg) ||
5699 AArch64::ZPR4StridedOrContiguousRegClass.
contains(DestReg)) &&
5700 (AArch64::ZPR4RegClass.
contains(SrcReg) ||
5701 AArch64::ZPR4StridedOrContiguousRegClass.
contains(SrcReg))) {
5702 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
5703 "Unexpected SVE register.");
5704 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1,
5705 AArch64::zsub2, AArch64::zsub3};
5712 if (AArch64::DDDDRegClass.
contains(DestReg) &&
5713 AArch64::DDDDRegClass.
contains(SrcReg)) {
5714 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1,
5715 AArch64::dsub2, AArch64::dsub3};
5722 if (AArch64::DDDRegClass.
contains(DestReg) &&
5723 AArch64::DDDRegClass.
contains(SrcReg)) {
5724 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1,
5732 if (AArch64::DDRegClass.
contains(DestReg) &&
5733 AArch64::DDRegClass.
contains(SrcReg)) {
5734 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1};
5741 if (AArch64::QQQQRegClass.
contains(DestReg) &&
5742 AArch64::QQQQRegClass.
contains(SrcReg)) {
5743 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1,
5744 AArch64::qsub2, AArch64::qsub3};
5751 if (AArch64::QQQRegClass.
contains(DestReg) &&
5752 AArch64::QQQRegClass.
contains(SrcReg)) {
5753 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1,
5761 if (AArch64::QQRegClass.
contains(DestReg) &&
5762 AArch64::QQRegClass.
contains(SrcReg)) {
5763 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1};
5769 if (AArch64::XSeqPairsClassRegClass.
contains(DestReg) &&
5770 AArch64::XSeqPairsClassRegClass.
contains(SrcReg)) {
5771 static const unsigned Indices[] = {AArch64::sube64, AArch64::subo64};
5773 AArch64::XZR, Indices);
5777 if (AArch64::WSeqPairsClassRegClass.
contains(DestReg) &&
5778 AArch64::WSeqPairsClassRegClass.
contains(SrcReg)) {
5779 static const unsigned Indices[] = {AArch64::sube32, AArch64::subo32};
5781 AArch64::WZR, Indices);
5785 if (AArch64::FPR128RegClass.
contains(DestReg) &&
5786 AArch64::FPR128RegClass.
contains(SrcReg)) {
5790 if ((Subtarget.isSVEorStreamingSVEAvailable() &&
5791 !Subtarget.isNeonAvailable()) ||
5795 .
addReg(AArch64::Z0 + (SrcReg - AArch64::Q0))
5796 .
addReg(AArch64::Z0 + (SrcReg - AArch64::Q0));
5797 }
else if (Subtarget.isNeonAvailable()) {
5801 if (Subtarget.hasZeroCycleRegMoveFPR128())
5802 ++NumZCRegMoveInstrsFPR;
5818 if (AArch64::FPR64RegClass.
contains(DestReg) &&
5819 AArch64::FPR64RegClass.
contains(SrcReg)) {
5820 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
5821 !Subtarget.hasZeroCycleRegMoveFPR64() &&
5822 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
5824 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::dsub,
5825 &AArch64::FPR128RegClass);
5826 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::dsub,
5827 &AArch64::FPR128RegClass);
5836 ++NumZCRegMoveInstrsFPR;
5840 if (Subtarget.hasZeroCycleRegMoveFPR64())
5841 ++NumZCRegMoveInstrsFPR;
5846 if (AArch64::FPR32RegClass.
contains(DestReg) &&
5847 AArch64::FPR32RegClass.
contains(SrcReg)) {
5848 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
5849 !Subtarget.hasZeroCycleRegMoveFPR64() &&
5850 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
5852 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::ssub,
5853 &AArch64::FPR128RegClass);
5854 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::ssub,
5855 &AArch64::FPR128RegClass);
5864 ++NumZCRegMoveInstrsFPR;
5865 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
5866 !Subtarget.hasZeroCycleRegMoveFPR32()) {
5867 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::ssub,
5868 &AArch64::FPR64RegClass);
5869 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::ssub,
5870 &AArch64::FPR64RegClass);
5878 ++NumZCRegMoveInstrsFPR;
5882 if (Subtarget.hasZeroCycleRegMoveFPR32())
5883 ++NumZCRegMoveInstrsFPR;
5888 if (AArch64::FPR16RegClass.
contains(DestReg) &&
5889 AArch64::FPR16RegClass.
contains(SrcReg)) {
5890 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
5891 !Subtarget.hasZeroCycleRegMoveFPR64() &&
5892 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
5894 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
5895 &AArch64::FPR128RegClass);
5896 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
5897 &AArch64::FPR128RegClass);
5906 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
5907 !Subtarget.hasZeroCycleRegMoveFPR32()) {
5908 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
5909 &AArch64::FPR64RegClass);
5910 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
5911 &AArch64::FPR64RegClass);
5920 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
5921 &AArch64::FPR32RegClass);
5922 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
5923 &AArch64::FPR32RegClass);
5930 if (AArch64::FPR8RegClass.
contains(DestReg) &&
5931 AArch64::FPR8RegClass.
contains(SrcReg)) {
5932 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
5933 !Subtarget.hasZeroCycleRegMoveFPR64() &&
5934 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
5936 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
5937 &AArch64::FPR128RegClass);
5938 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
5939 &AArch64::FPR128RegClass);
5948 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
5949 !Subtarget.hasZeroCycleRegMoveFPR32()) {
5950 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
5951 &AArch64::FPR64RegClass);
5952 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
5953 &AArch64::FPR64RegClass);
5962 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
5963 &AArch64::FPR32RegClass);
5964 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
5965 &AArch64::FPR32RegClass);
5973 if (AArch64::FPR64RegClass.
contains(DestReg) &&
5974 AArch64::GPR64RegClass.
contains(SrcReg)) {
5975 if (AArch64::XZR == SrcReg) {
5983 if (AArch64::GPR64RegClass.
contains(DestReg) &&
5984 AArch64::FPR64RegClass.
contains(SrcReg)) {
5990 if (AArch64::FPR32RegClass.
contains(DestReg) &&
5991 AArch64::GPR32RegClass.
contains(SrcReg)) {
5992 if (AArch64::WZR == SrcReg) {
6000 if (AArch64::GPR32RegClass.
contains(DestReg) &&
6001 AArch64::FPR32RegClass.
contains(SrcReg)) {
6007 if (DestReg == AArch64::NZCV) {
6008 assert(AArch64::GPR64RegClass.
contains(SrcReg) &&
"Invalid NZCV copy");
6010 .
addImm(AArch64SysReg::NZCV)
6016 if (SrcReg == AArch64::NZCV) {
6017 assert(AArch64::GPR64RegClass.
contains(DestReg) &&
"Invalid NZCV copy");
6019 .
addImm(AArch64SysReg::NZCV)
6025 errs() << RI.getRegAsmName(DestReg) <<
" = COPY " << RI.getRegAsmName(SrcReg)
6036 unsigned SubIdx0,
unsigned SubIdx1,
int FI,
6041 SrcReg0 =
TRI.getSubReg(SrcReg, SubIdx0);
6043 SrcReg1 =
TRI.getSubReg(SrcReg, SubIdx1);
6056 Register SrcReg,
bool isKill,
int FI,
6071 switch (RI.getSpillSize(*RC)) {
6073 if (AArch64::FPR8RegClass.hasSubClassEq(RC))
6074 Opc = AArch64::STRBui;
6077 if (AArch64::FPR16RegClass.hasSubClassEq(RC))
6078 Opc = AArch64::STRHui;
6079 else if (AArch64::PNRRegClass.hasSubClassEq(RC) ||
6080 AArch64::PPRRegClass.hasSubClassEq(RC)) {
6081 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6082 "Unexpected register store without SVE store instructions");
6083 Opc = AArch64::STR_PXI;
6089 if (AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
6090 Opc = AArch64::STRWui;
6094 assert(SrcReg != AArch64::WSP);
6095 }
else if (AArch64::FPR32RegClass.hasSubClassEq(RC))
6096 Opc = AArch64::STRSui;
6097 else if (AArch64::PPR2RegClass.hasSubClassEq(RC)) {
6098 Opc = AArch64::STR_PPXI;
6103 if (AArch64::GPR64allRegClass.hasSubClassEq(RC)) {
6104 Opc = AArch64::STRXui;
6108 assert(SrcReg != AArch64::SP);
6109 }
else if (AArch64::FPR64RegClass.hasSubClassEq(RC)) {
6110 Opc = AArch64::STRDui;
6111 }
else if (AArch64::WSeqPairsClassRegClass.hasSubClassEq(RC)) {
6113 get(AArch64::STPWi), SrcReg, isKill,
6114 AArch64::sube32, AArch64::subo32, FI, MMO);
6119 if (AArch64::FPR128RegClass.hasSubClassEq(RC))
6120 Opc = AArch64::STRQui;
6121 else if (AArch64::DDRegClass.hasSubClassEq(RC)) {
6122 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6123 Opc = AArch64::ST1Twov1d;
6125 }
else if (AArch64::XSeqPairsClassRegClass.hasSubClassEq(RC)) {
6127 get(AArch64::STPXi), SrcReg, isKill,
6128 AArch64::sube64, AArch64::subo64, FI, MMO);
6130 }
else if (AArch64::ZPRRegClass.hasSubClassEq(RC)) {
6131 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6132 "Unexpected register store without SVE store instructions");
6133 Opc = AArch64::STR_ZXI;
6138 if (AArch64::DDDRegClass.hasSubClassEq(RC)) {
6139 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6140 Opc = AArch64::ST1Threev1d;
6145 if (AArch64::DDDDRegClass.hasSubClassEq(RC)) {
6146 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6147 Opc = AArch64::ST1Fourv1d;
6149 }
else if (AArch64::QQRegClass.hasSubClassEq(RC)) {
6150 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6151 Opc = AArch64::ST1Twov2d;
6153 }
else if (AArch64::ZPR2StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6154 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6155 "Unexpected register store without SVE store instructions");
6156 Opc = AArch64::STR_ZZXI_STRIDED_CONTIGUOUS;
6158 }
else if (AArch64::ZPR2RegClass.hasSubClassEq(RC)) {
6159 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6160 "Unexpected register store without SVE store instructions");
6161 Opc = AArch64::STR_ZZXI;
6166 if (AArch64::QQQRegClass.hasSubClassEq(RC)) {
6167 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6168 Opc = AArch64::ST1Threev2d;
6170 }
else if (AArch64::ZPR3RegClass.hasSubClassEq(RC)) {
6171 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6172 "Unexpected register store without SVE store instructions");
6173 Opc = AArch64::STR_ZZZXI;
6178 if (AArch64::QQQQRegClass.hasSubClassEq(RC)) {
6179 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6180 Opc = AArch64::ST1Fourv2d;
6182 }
else if (AArch64::ZPR4StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6183 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6184 "Unexpected register store without SVE store instructions");
6185 Opc = AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS;
6187 }
else if (AArch64::ZPR4RegClass.hasSubClassEq(RC)) {
6188 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6189 "Unexpected register store without SVE store instructions");
6190 Opc = AArch64::STR_ZZZZXI;
6195 assert(
Opc &&
"Unknown register class");
6206 MI.addMemOperand(MMO);
6213 Register DestReg,
unsigned SubIdx0,
6214 unsigned SubIdx1,
int FI,
6218 bool IsUndef =
true;
6220 DestReg0 =
TRI.getSubReg(DestReg, SubIdx0);
6222 DestReg1 =
TRI.getSubReg(DestReg, SubIdx1);
6251 switch (
TRI.getSpillSize(*RC)) {
6253 if (AArch64::FPR8RegClass.hasSubClassEq(RC))
6254 Opc = AArch64::LDRBui;
6257 bool IsPNR = AArch64::PNRRegClass.hasSubClassEq(RC);
6258 if (AArch64::FPR16RegClass.hasSubClassEq(RC))
6259 Opc = AArch64::LDRHui;
6260 else if (IsPNR || AArch64::PPRRegClass.hasSubClassEq(RC)) {
6261 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6262 "Unexpected register load without SVE load instructions");
6265 Opc = AArch64::LDR_PXI;
6271 if (AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
6272 Opc = AArch64::LDRWui;
6276 assert(DestReg != AArch64::WSP);
6277 }
else if (AArch64::FPR32RegClass.hasSubClassEq(RC))
6278 Opc = AArch64::LDRSui;
6279 else if (AArch64::PPR2RegClass.hasSubClassEq(RC)) {
6280 Opc = AArch64::LDR_PPXI;
6285 if (AArch64::GPR64allRegClass.hasSubClassEq(RC)) {
6286 Opc = AArch64::LDRXui;
6290 assert(DestReg != AArch64::SP);
6291 }
else if (AArch64::FPR64RegClass.hasSubClassEq(RC)) {
6292 Opc = AArch64::LDRDui;
6293 }
else if (AArch64::WSeqPairsClassRegClass.hasSubClassEq(RC)) {
6295 get(AArch64::LDPWi), DestReg, AArch64::sube32,
6296 AArch64::subo32, FI, MMO);
6301 if (AArch64::FPR128RegClass.hasSubClassEq(RC))
6302 Opc = AArch64::LDRQui;
6303 else if (AArch64::DDRegClass.hasSubClassEq(RC)) {
6304 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6305 Opc = AArch64::LD1Twov1d;
6307 }
else if (AArch64::XSeqPairsClassRegClass.hasSubClassEq(RC)) {
6309 get(AArch64::LDPXi), DestReg, AArch64::sube64,
6310 AArch64::subo64, FI, MMO);
6312 }
else if (AArch64::ZPRRegClass.hasSubClassEq(RC)) {
6313 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6314 "Unexpected register load without SVE load instructions");
6315 Opc = AArch64::LDR_ZXI;
6320 if (AArch64::DDDRegClass.hasSubClassEq(RC)) {
6321 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6322 Opc = AArch64::LD1Threev1d;
6327 if (AArch64::DDDDRegClass.hasSubClassEq(RC)) {
6328 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6329 Opc = AArch64::LD1Fourv1d;
6331 }
else if (AArch64::QQRegClass.hasSubClassEq(RC)) {
6332 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6333 Opc = AArch64::LD1Twov2d;
6335 }
else if (AArch64::ZPR2StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6336 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6337 "Unexpected register load without SVE load instructions");
6338 Opc = AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS;
6340 }
else if (AArch64::ZPR2RegClass.hasSubClassEq(RC)) {
6341 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6342 "Unexpected register load without SVE load instructions");
6343 Opc = AArch64::LDR_ZZXI;
6348 if (AArch64::QQQRegClass.hasSubClassEq(RC)) {
6349 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6350 Opc = AArch64::LD1Threev2d;
6352 }
else if (AArch64::ZPR3RegClass.hasSubClassEq(RC)) {
6353 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6354 "Unexpected register load without SVE load instructions");
6355 Opc = AArch64::LDR_ZZZXI;
6360 if (AArch64::QQQQRegClass.hasSubClassEq(RC)) {
6361 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6362 Opc = AArch64::LD1Fourv2d;
6364 }
else if (AArch64::ZPR4StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6365 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6366 "Unexpected register load without SVE load instructions");
6367 Opc = AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS;
6369 }
else if (AArch64::ZPR4RegClass.hasSubClassEq(RC)) {
6370 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6371 "Unexpected register load without SVE load instructions");
6372 Opc = AArch64::LDR_ZZZZXI;
6378 assert(
Opc &&
"Unknown register class");
6388 MI.addMemOperand(MMO);
6395 UseMI.getIterator()),
6397 return I.modifiesRegister(AArch64::NZCV, TRI) ||
6398 I.readsRegister(AArch64::NZCV, TRI);
6402void AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
6407 assert(
Offset.getScalable() % 2 == 0 &&
"Invalid frame offset");
6414 ByteSized =
Offset.getFixed();
6415 VGSized =
Offset.getScalable() / 2;
6421void AArch64InstrInfo::decomposeStackOffsetForFrameOffsets(
6423 int64_t &NumDataVectors) {
6427 assert(
Offset.getScalable() % 2 == 0 &&
"Invalid frame offset");
6429 NumBytes =
Offset.getFixed();
6431 NumPredicateVectors =
Offset.getScalable() / 2;
6436 if (NumPredicateVectors % 8 == 0 || NumPredicateVectors < -64 ||
6437 NumPredicateVectors > 62) {
6438 NumDataVectors = NumPredicateVectors / 8;
6439 NumPredicateVectors -= NumDataVectors * 8;
6465 Expr.
push_back((
char)dwarf::DW_OP_bregx);
6473 int64_t OffsetFromDefCFA) {
6487 Comment << (NumBytes < 0 ?
" - " :
" + ") << std::abs(NumBytes);
6488 if (!RegScale.empty())
6498 int64_t NumBytes, NumVGScaledBytes;
6499 AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
Offset, NumBytes,
6501 std::string CommentBuffer;
6504 if (
Reg == AArch64::SP)
6506 else if (
Reg == AArch64::FP)
6513 unsigned DwarfReg =
TRI.getDwarfRegNum(
Reg,
true);
6514 assert(DwarfReg <= 31 &&
"DwarfReg out of bounds (0..31)");
6516 Expr.
push_back(dwarf::DW_OP_breg0 + DwarfReg);
6519 if (NumVGScaledBytes) {
6529 DefCfaExpr.
push_back(dwarf::DW_CFA_def_cfa_expression);
6537 unsigned FrameReg,
unsigned Reg,
6539 bool LastAdjustmentWasScalable) {
6540 if (
Offset.getScalable())
6543 if (FrameReg == Reg && !LastAdjustmentWasScalable)
6546 unsigned DwarfReg =
TRI.getDwarfRegNum(Reg,
true);
6553 std::optional<int64_t> IncomingVGOffsetFromDefCFA) {
6554 int64_t NumBytes, NumVGScaledBytes;
6555 AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
6556 OffsetFromDefCFA, NumBytes, NumVGScaledBytes);
6558 unsigned DwarfReg =
TRI.getDwarfRegNum(Reg,
true);
6561 if (!NumVGScaledBytes)
6564 std::string CommentBuffer;
6569 assert(NumVGScaledBytes &&
"Expected scalable offset");
6573 if (IncomingVGOffsetFromDefCFA) {
6575 VGRegScale =
"* IncomingVG";
6578 VGRegScale =
"* VG";
6582 OffsetExpr.
push_back(dwarf::DW_OP_plus);
6591 CfaExpr.
push_back(dwarf::DW_CFA_expression);
6606 unsigned SrcReg, int64_t
Offset,
unsigned Opc,
6609 bool *HasWinCFI,
bool EmitCFAOffset,
6612 unsigned MaxEncoding, ShiftSize;
6614 case AArch64::ADDXri:
6615 case AArch64::ADDSXri:
6616 case AArch64::SUBXri:
6617 case AArch64::SUBSXri:
6618 MaxEncoding = 0xfff;
6621 case AArch64::ADDVL_XXI:
6622 case AArch64::ADDPL_XXI:
6623 case AArch64::ADDSVL_XXI:
6624 case AArch64::ADDSPL_XXI:
6639 if (
Opc == AArch64::ADDVL_XXI ||
Opc == AArch64::ADDSVL_XXI)
6641 else if (
Opc == AArch64::ADDPL_XXI ||
Opc == AArch64::ADDSPL_XXI)
6655 const unsigned MaxEncodableValue = MaxEncoding << ShiftSize;
6657 if (TmpReg == AArch64::XZR)
6658 TmpReg =
MBB.getParent()->getRegInfo().createVirtualRegister(
6659 &AArch64::GPR64RegClass);
6661 uint64_t ThisVal = std::min<uint64_t>(
Offset, MaxEncodableValue);
6662 unsigned LocalShiftSize = 0;
6663 if (ThisVal > MaxEncoding) {
6664 ThisVal = ThisVal >> ShiftSize;
6665 LocalShiftSize = ShiftSize;
6667 assert((ThisVal >> ShiftSize) <= MaxEncoding &&
6668 "Encoding cannot handle value that big");
6670 Offset -= ThisVal << LocalShiftSize;
6675 .
addImm(Sign * (
int)ThisVal);
6685 if (Sign == -1 ||
Opc == AArch64::SUBXri ||
Opc == AArch64::SUBSXri)
6686 CFAOffset += Change;
6688 CFAOffset -= Change;
6689 if (EmitCFAOffset && DestReg == TmpReg) {
6702 int Imm = (int)(ThisVal << LocalShiftSize);
6703 if (VScale != 1 && DestReg == AArch64::SP) {
6709 }
else if ((DestReg == AArch64::FP && SrcReg == AArch64::SP) ||
6710 (SrcReg == AArch64::FP && DestReg == AArch64::SP)) {
6711 assert(VScale == 1 &&
"Expected non-scalable operation");
6720 assert(
Offset == 0 &&
"Expected remaining offset to be zero to "
6721 "emit a single SEH directive");
6722 }
else if (DestReg == AArch64::SP) {
6723 assert(VScale == 1 &&
"Expected non-scalable operation");
6726 assert(SrcReg == AArch64::SP &&
"Unexpected SrcReg for SEH_StackAlloc");
6739 unsigned DestReg,
unsigned SrcReg,
6742 bool NeedsWinCFI,
bool *HasWinCFI,
6744 unsigned FrameReg) {
6751 bool UseSVL =
F.hasFnAttribute(
"aarch64_pstate_sm_body");
6753 int64_t Bytes, NumPredicateVectors, NumDataVectors;
6754 AArch64InstrInfo::decomposeStackOffsetForFrameOffsets(
6755 Offset, Bytes, NumPredicateVectors, NumDataVectors);
6758 bool NeedsFinalDefNZCV = SetNZCV && (NumPredicateVectors || NumDataVectors);
6759 if (NeedsFinalDefNZCV)
6763 if (Bytes || (!
Offset && SrcReg != DestReg)) {
6764 assert((DestReg != AArch64::SP || Bytes % 8 == 0) &&
6765 "SP increment/decrement not 8-byte aligned");
6766 unsigned Opc = SetNZCV ? AArch64::ADDSXri : AArch64::ADDXri;
6769 Opc = SetNZCV ? AArch64::SUBSXri : AArch64::SUBXri;
6772 NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
6774 CFAOffset += (
Opc == AArch64::ADDXri ||
Opc == AArch64::ADDSXri)
6781 assert(!(NeedsWinCFI && NumPredicateVectors) &&
6782 "WinCFI can't allocate fractions of an SVE data vector");
6784 if (NumDataVectors) {
6786 UseSVL ? AArch64::ADDSVL_XXI : AArch64::ADDVL_XXI,
TII,
6787 Flag, NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
6793 if (NumPredicateVectors) {
6794 assert(DestReg != AArch64::SP &&
"Unaligned access to SP");
6796 UseSVL ? AArch64::ADDSPL_XXI : AArch64::ADDPL_XXI,
TII,
6797 Flag, NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
6801 if (NeedsFinalDefNZCV)
6822 if (
MI.isFullCopy()) {
6825 if (SrcReg == AArch64::SP && DstReg.
isVirtual()) {
6829 if (DstReg == AArch64::SP && SrcReg.
isVirtual()) {
6834 if (SrcReg == AArch64::NZCV || DstReg == AArch64::NZCV)
6862 if (
MI.isCopy() &&
Ops.size() == 1 &&
6864 (
Ops[0] == 0 ||
Ops[0] == 1)) {
6865 bool IsSpill =
Ops[0] == 0;
6866 bool IsFill = !IsSpill;
6878 :
TRI.getMinimalPhysRegClass(Reg);
6884 "Mismatched register size in non subreg COPY");
6891 return &*--InsertPt;
6903 if (IsSpill && DstMO.
isUndef() && SrcReg == AArch64::WZR &&
6906 "Unexpected subreg on physical register");
6908 FrameIndex, &AArch64::GPR64RegClass,
Register());
6909 return &*--InsertPt;
6926 case AArch64::sub_32:
6927 if (AArch64::GPR64RegClass.hasSubClassEq(
getRegClass(DstReg)))
6928 FillRC = &AArch64::GPR32RegClass;
6931 FillRC = &AArch64::FPR32RegClass;
6934 FillRC = &AArch64::FPR64RegClass;
6940 TRI.getRegSizeInBits(*FillRC) &&
6941 "Mismatched regclass size on folded subreg COPY");
6960 bool *OutUseUnscaledOp,
6961 unsigned *OutUnscaledOp,
6962 int64_t *EmittableOffset) {
6964 if (EmittableOffset)
6965 *EmittableOffset = 0;
6966 if (OutUseUnscaledOp)
6967 *OutUseUnscaledOp =
false;
6973 switch (
MI.getOpcode()) {
6976 case AArch64::LD1Rv1d:
6977 case AArch64::LD1Rv2s:
6978 case AArch64::LD1Rv2d:
6979 case AArch64::LD1Rv4h:
6980 case AArch64::LD1Rv4s:
6981 case AArch64::LD1Rv8b:
6982 case AArch64::LD1Rv8h:
6983 case AArch64::LD1Rv16b:
6984 case AArch64::LD1Twov2d:
6985 case AArch64::LD1Threev2d:
6986 case AArch64::LD1Fourv2d:
6987 case AArch64::LD1Twov1d:
6988 case AArch64::LD1Threev1d:
6989 case AArch64::LD1Fourv1d:
6990 case AArch64::ST1Twov2d:
6991 case AArch64::ST1Threev2d:
6992 case AArch64::ST1Fourv2d:
6993 case AArch64::ST1Twov1d:
6994 case AArch64::ST1Threev1d:
6995 case AArch64::ST1Fourv1d:
6996 case AArch64::ST1i8:
6997 case AArch64::ST1i16:
6998 case AArch64::ST1i32:
6999 case AArch64::ST1i64:
7001 case AArch64::IRGstack:
7002 case AArch64::STGloop:
7003 case AArch64::STZGloop:
7008 TypeSize ScaleValue(0U,
false), Width(0U,
false);
7009 int64_t MinOff, MaxOff;
7015 bool IsMulVL = ScaleValue.isScalable();
7016 unsigned Scale = ScaleValue.getKnownMinValue();
7026 std::optional<unsigned> UnscaledOp =
7028 bool useUnscaledOp = UnscaledOp && (
Offset % Scale ||
Offset < 0);
7029 if (useUnscaledOp &&
7034 Scale = ScaleValue.getKnownMinValue();
7035 assert(IsMulVL == ScaleValue.isScalable() &&
7036 "Unscaled opcode has different value for scalable");
7038 int64_t Remainder =
Offset % Scale;
7039 assert(!(Remainder && useUnscaledOp) &&
7040 "Cannot have remainder when using unscaled op");
7042 assert(MinOff < MaxOff &&
"Unexpected Min/Max offsets");
7043 int64_t NewOffset =
Offset / Scale;
7044 if (MinOff <= NewOffset && NewOffset <= MaxOff)
7047 NewOffset = NewOffset < 0 ? MinOff : MaxOff;
7051 if (EmittableOffset)
7052 *EmittableOffset = NewOffset;
7053 if (OutUseUnscaledOp)
7054 *OutUseUnscaledOp = useUnscaledOp;
7055 if (OutUnscaledOp && UnscaledOp)
7056 *OutUnscaledOp = *UnscaledOp;
7069 unsigned Opcode =
MI.getOpcode();
7070 unsigned ImmIdx = FrameRegIdx + 1;
7072 if (Opcode == AArch64::ADDSXri || Opcode == AArch64::ADDXri) {
7077 MI.eraseFromParent();
7083 unsigned UnscaledOp;
7086 &UnscaledOp, &NewOffset);
7090 MI.getOperand(FrameRegIdx).ChangeToRegister(FrameReg,
false);
7092 MI.setDesc(
TII->get(UnscaledOp));
7094 MI.getOperand(ImmIdx).ChangeToImmediate(NewOffset);
7110bool AArch64InstrInfo::useMachineCombiner()
const {
return true; }
7115 case AArch64::ADDSWrr:
7116 case AArch64::ADDSWri:
7117 case AArch64::ADDSXrr:
7118 case AArch64::ADDSXri:
7119 case AArch64::SUBSWrr:
7120 case AArch64::SUBSXrr:
7122 case AArch64::SUBSWri:
7123 case AArch64::SUBSXri:
7134 case AArch64::ADDWrr:
7135 case AArch64::ADDWri:
7136 case AArch64::SUBWrr:
7137 case AArch64::ADDSWrr:
7138 case AArch64::ADDSWri:
7139 case AArch64::SUBSWrr:
7141 case AArch64::SUBWri:
7142 case AArch64::SUBSWri:
7153 case AArch64::ADDXrr:
7154 case AArch64::ADDXri:
7155 case AArch64::SUBXrr:
7156 case AArch64::ADDSXrr:
7157 case AArch64::ADDSXri:
7158 case AArch64::SUBSXrr:
7160 case AArch64::SUBXri:
7161 case AArch64::SUBSXri:
7162 case AArch64::ADDv8i8:
7163 case AArch64::ADDv16i8:
7164 case AArch64::ADDv4i16:
7165 case AArch64::ADDv8i16:
7166 case AArch64::ADDv2i32:
7167 case AArch64::ADDv4i32:
7168 case AArch64::SUBv8i8:
7169 case AArch64::SUBv16i8:
7170 case AArch64::SUBv4i16:
7171 case AArch64::SUBv8i16:
7172 case AArch64::SUBv2i32:
7173 case AArch64::SUBv4i32:
7186 case AArch64::FADDHrr:
7187 case AArch64::FADDSrr:
7188 case AArch64::FADDDrr:
7189 case AArch64::FADDv4f16:
7190 case AArch64::FADDv8f16:
7191 case AArch64::FADDv2f32:
7192 case AArch64::FADDv2f64:
7193 case AArch64::FADDv4f32:
7194 case AArch64::FSUBHrr:
7195 case AArch64::FSUBSrr:
7196 case AArch64::FSUBDrr:
7197 case AArch64::FSUBv4f16:
7198 case AArch64::FSUBv8f16:
7199 case AArch64::FSUBv2f32:
7200 case AArch64::FSUBv2f64:
7201 case AArch64::FSUBv4f32:
7220 unsigned CombineOpc,
unsigned ZeroReg = 0,
7221 bool CheckZeroReg =
false) {
7228 if (!
MI ||
MI->getParent() != &
MBB ||
MI->getOpcode() != CombineOpc)
7235 assert(
MI->getNumOperands() >= 4 &&
MI->getOperand(0).isReg() &&
7236 MI->getOperand(1).isReg() &&
MI->getOperand(2).isReg() &&
7237 MI->getOperand(3).isReg() &&
"MAdd/MSub must have a least 4 regs");
7239 if (
MI->getOperand(3).getReg() != ZeroReg)
7244 MI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
true) == -1)
7253 unsigned MulOpc,
unsigned ZeroReg) {
7268bool AArch64InstrInfo::isAssociativeAndCommutative(
const MachineInstr &Inst,
7269 bool Invert)
const {
7275 case AArch64::FADDHrr:
7276 case AArch64::FADDSrr:
7277 case AArch64::FADDDrr:
7278 case AArch64::FMULHrr:
7279 case AArch64::FMULSrr:
7280 case AArch64::FMULDrr:
7281 case AArch64::FMULX16:
7282 case AArch64::FMULX32:
7283 case AArch64::FMULX64:
7285 case AArch64::FADDv4f16:
7286 case AArch64::FADDv8f16:
7287 case AArch64::FADDv2f32:
7288 case AArch64::FADDv4f32:
7289 case AArch64::FADDv2f64:
7290 case AArch64::FMULv4f16:
7291 case AArch64::FMULv8f16:
7292 case AArch64::FMULv2f32:
7293 case AArch64::FMULv4f32:
7294 case AArch64::FMULv2f64:
7295 case AArch64::FMULXv4f16:
7296 case AArch64::FMULXv8f16:
7297 case AArch64::FMULXv2f32:
7298 case AArch64::FMULXv4f32:
7299 case AArch64::FMULXv2f64:
7303 case AArch64::FADD_ZZZ_H:
7304 case AArch64::FADD_ZZZ_S:
7305 case AArch64::FADD_ZZZ_D:
7306 case AArch64::FMUL_ZZZ_H:
7307 case AArch64::FMUL_ZZZ_S:
7308 case AArch64::FMUL_ZZZ_D:
7319 case AArch64::ADDWrr:
7320 case AArch64::ADDXrr:
7321 case AArch64::ANDWrr:
7322 case AArch64::ANDXrr:
7323 case AArch64::ORRWrr:
7324 case AArch64::ORRXrr:
7325 case AArch64::EORWrr:
7326 case AArch64::EORXrr:
7327 case AArch64::EONWrr:
7328 case AArch64::EONXrr:
7332 case AArch64::ADDv8i8:
7333 case AArch64::ADDv16i8:
7334 case AArch64::ADDv4i16:
7335 case AArch64::ADDv8i16:
7336 case AArch64::ADDv2i32:
7337 case AArch64::ADDv4i32:
7338 case AArch64::ADDv1i64:
7339 case AArch64::ADDv2i64:
7340 case AArch64::MULv8i8:
7341 case AArch64::MULv16i8:
7342 case AArch64::MULv4i16:
7343 case AArch64::MULv8i16:
7344 case AArch64::MULv2i32:
7345 case AArch64::MULv4i32:
7346 case AArch64::ANDv8i8:
7347 case AArch64::ANDv16i8:
7348 case AArch64::ORRv8i8:
7349 case AArch64::ORRv16i8:
7350 case AArch64::EORv8i8:
7351 case AArch64::EORv16i8:
7353 case AArch64::ADD_ZZZ_B:
7354 case AArch64::ADD_ZZZ_H:
7355 case AArch64::ADD_ZZZ_S:
7356 case AArch64::ADD_ZZZ_D:
7357 case AArch64::MUL_ZZZ_B:
7358 case AArch64::MUL_ZZZ_H:
7359 case AArch64::MUL_ZZZ_S:
7360 case AArch64::MUL_ZZZ_D:
7361 case AArch64::AND_ZZZ:
7362 case AArch64::ORR_ZZZ:
7363 case AArch64::EOR_ZZZ:
7394 auto setFound = [&](
int Opcode,
int Operand,
unsigned ZeroReg,
7402 auto setVFound = [&](
int Opcode,
int Operand,
unsigned Pattern) {
7414 case AArch64::ADDWrr:
7416 "ADDWrr does not have register operands");
7417 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULADDW_OP1);
7418 setFound(AArch64::MADDWrrr, 2, AArch64::WZR, MCP::MULADDW_OP2);
7420 case AArch64::ADDXrr:
7421 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULADDX_OP1);
7422 setFound(AArch64::MADDXrrr, 2, AArch64::XZR, MCP::MULADDX_OP2);
7424 case AArch64::SUBWrr:
7425 setFound(AArch64::MADDWrrr, 2, AArch64::WZR, MCP::MULSUBW_OP2);
7426 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULSUBW_OP1);
7428 case AArch64::SUBXrr:
7429 setFound(AArch64::MADDXrrr, 2, AArch64::XZR, MCP::MULSUBX_OP2);
7430 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULSUBX_OP1);
7432 case AArch64::ADDWri:
7433 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULADDWI_OP1);
7435 case AArch64::ADDXri:
7436 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULADDXI_OP1);
7438 case AArch64::SUBWri:
7439 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULSUBWI_OP1);
7441 case AArch64::SUBXri:
7442 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULSUBXI_OP1);
7444 case AArch64::ADDv8i8:
7445 setVFound(AArch64::MULv8i8, 1, MCP::MULADDv8i8_OP1);
7446 setVFound(AArch64::MULv8i8, 2, MCP::MULADDv8i8_OP2);
7448 case AArch64::ADDv16i8:
7449 setVFound(AArch64::MULv16i8, 1, MCP::MULADDv16i8_OP1);
7450 setVFound(AArch64::MULv16i8, 2, MCP::MULADDv16i8_OP2);
7452 case AArch64::ADDv4i16:
7453 setVFound(AArch64::MULv4i16, 1, MCP::MULADDv4i16_OP1);
7454 setVFound(AArch64::MULv4i16, 2, MCP::MULADDv4i16_OP2);
7455 setVFound(AArch64::MULv4i16_indexed, 1, MCP::MULADDv4i16_indexed_OP1);
7456 setVFound(AArch64::MULv4i16_indexed, 2, MCP::MULADDv4i16_indexed_OP2);
7458 case AArch64::ADDv8i16:
7459 setVFound(AArch64::MULv8i16, 1, MCP::MULADDv8i16_OP1);
7460 setVFound(AArch64::MULv8i16, 2, MCP::MULADDv8i16_OP2);
7461 setVFound(AArch64::MULv8i16_indexed, 1, MCP::MULADDv8i16_indexed_OP1);
7462 setVFound(AArch64::MULv8i16_indexed, 2, MCP::MULADDv8i16_indexed_OP2);
7464 case AArch64::ADDv2i32:
7465 setVFound(AArch64::MULv2i32, 1, MCP::MULADDv2i32_OP1);
7466 setVFound(AArch64::MULv2i32, 2, MCP::MULADDv2i32_OP2);
7467 setVFound(AArch64::MULv2i32_indexed, 1, MCP::MULADDv2i32_indexed_OP1);
7468 setVFound(AArch64::MULv2i32_indexed, 2, MCP::MULADDv2i32_indexed_OP2);
7470 case AArch64::ADDv4i32:
7471 setVFound(AArch64::MULv4i32, 1, MCP::MULADDv4i32_OP1);
7472 setVFound(AArch64::MULv4i32, 2, MCP::MULADDv4i32_OP2);
7473 setVFound(AArch64::MULv4i32_indexed, 1, MCP::MULADDv4i32_indexed_OP1);
7474 setVFound(AArch64::MULv4i32_indexed, 2, MCP::MULADDv4i32_indexed_OP2);
7476 case AArch64::SUBv8i8:
7477 setVFound(AArch64::MULv8i8, 1, MCP::MULSUBv8i8_OP1);
7478 setVFound(AArch64::MULv8i8, 2, MCP::MULSUBv8i8_OP2);
7480 case AArch64::SUBv16i8:
7481 setVFound(AArch64::MULv16i8, 1, MCP::MULSUBv16i8_OP1);
7482 setVFound(AArch64::MULv16i8, 2, MCP::MULSUBv16i8_OP2);
7484 case AArch64::SUBv4i16:
7485 setVFound(AArch64::MULv4i16, 1, MCP::MULSUBv4i16_OP1);
7486 setVFound(AArch64::MULv4i16, 2, MCP::MULSUBv4i16_OP2);
7487 setVFound(AArch64::MULv4i16_indexed, 1, MCP::MULSUBv4i16_indexed_OP1);
7488 setVFound(AArch64::MULv4i16_indexed, 2, MCP::MULSUBv4i16_indexed_OP2);
7490 case AArch64::SUBv8i16:
7491 setVFound(AArch64::MULv8i16, 1, MCP::MULSUBv8i16_OP1);
7492 setVFound(AArch64::MULv8i16, 2, MCP::MULSUBv8i16_OP2);
7493 setVFound(AArch64::MULv8i16_indexed, 1, MCP::MULSUBv8i16_indexed_OP1);
7494 setVFound(AArch64::MULv8i16_indexed, 2, MCP::MULSUBv8i16_indexed_OP2);
7496 case AArch64::SUBv2i32:
7497 setVFound(AArch64::MULv2i32, 1, MCP::MULSUBv2i32_OP1);
7498 setVFound(AArch64::MULv2i32, 2, MCP::MULSUBv2i32_OP2);
7499 setVFound(AArch64::MULv2i32_indexed, 1, MCP::MULSUBv2i32_indexed_OP1);
7500 setVFound(AArch64::MULv2i32_indexed, 2, MCP::MULSUBv2i32_indexed_OP2);
7502 case AArch64::SUBv4i32:
7503 setVFound(AArch64::MULv4i32, 1, MCP::MULSUBv4i32_OP1);
7504 setVFound(AArch64::MULv4i32, 2, MCP::MULSUBv4i32_OP2);
7505 setVFound(AArch64::MULv4i32_indexed, 1, MCP::MULSUBv4i32_indexed_OP1);
7506 setVFound(AArch64::MULv4i32_indexed, 2, MCP::MULSUBv4i32_indexed_OP2);
7512bool AArch64InstrInfo::isAccumulationOpcode(
unsigned Opcode)
const {
7516 case AArch64::UABALB_ZZZ_D:
7517 case AArch64::UABALB_ZZZ_H:
7518 case AArch64::UABALB_ZZZ_S:
7519 case AArch64::UABALT_ZZZ_D:
7520 case AArch64::UABALT_ZZZ_H:
7521 case AArch64::UABALT_ZZZ_S:
7522 case AArch64::SABALB_ZZZ_D:
7523 case AArch64::SABALB_ZZZ_S:
7524 case AArch64::SABALB_ZZZ_H:
7525 case AArch64::SABALT_ZZZ_D:
7526 case AArch64::SABALT_ZZZ_S:
7527 case AArch64::SABALT_ZZZ_H:
7528 case AArch64::UABALv16i8_v8i16:
7529 case AArch64::UABALv2i32_v2i64:
7530 case AArch64::UABALv4i16_v4i32:
7531 case AArch64::UABALv4i32_v2i64:
7532 case AArch64::UABALv8i16_v4i32:
7533 case AArch64::UABALv8i8_v8i16:
7534 case AArch64::UABAv16i8:
7535 case AArch64::UABAv2i32:
7536 case AArch64::UABAv4i16:
7537 case AArch64::UABAv4i32:
7538 case AArch64::UABAv8i16:
7539 case AArch64::UABAv8i8:
7540 case AArch64::SABALv16i8_v8i16:
7541 case AArch64::SABALv2i32_v2i64:
7542 case AArch64::SABALv4i16_v4i32:
7543 case AArch64::SABALv4i32_v2i64:
7544 case AArch64::SABALv8i16_v4i32:
7545 case AArch64::SABALv8i8_v8i16:
7546 case AArch64::SABAv16i8:
7547 case AArch64::SABAv2i32:
7548 case AArch64::SABAv4i16:
7549 case AArch64::SABAv4i32:
7550 case AArch64::SABAv8i16:
7551 case AArch64::SABAv8i8:
7558unsigned AArch64InstrInfo::getAccumulationStartOpcode(
7559 unsigned AccumulationOpcode)
const {
7560 switch (AccumulationOpcode) {
7563 case AArch64::UABALB_ZZZ_D:
7564 return AArch64::UABDLB_ZZZ_D;
7565 case AArch64::UABALB_ZZZ_H:
7566 return AArch64::UABDLB_ZZZ_H;
7567 case AArch64::UABALB_ZZZ_S:
7568 return AArch64::UABDLB_ZZZ_S;
7569 case AArch64::UABALT_ZZZ_D:
7570 return AArch64::UABDLT_ZZZ_D;
7571 case AArch64::UABALT_ZZZ_H:
7572 return AArch64::UABDLT_ZZZ_H;
7573 case AArch64::UABALT_ZZZ_S:
7574 return AArch64::UABDLT_ZZZ_S;
7575 case AArch64::UABALv16i8_v8i16:
7576 return AArch64::UABDLv16i8_v8i16;
7577 case AArch64::UABALv2i32_v2i64:
7578 return AArch64::UABDLv2i32_v2i64;
7579 case AArch64::UABALv4i16_v4i32:
7580 return AArch64::UABDLv4i16_v4i32;
7581 case AArch64::UABALv4i32_v2i64:
7582 return AArch64::UABDLv4i32_v2i64;
7583 case AArch64::UABALv8i16_v4i32:
7584 return AArch64::UABDLv8i16_v4i32;
7585 case AArch64::UABALv8i8_v8i16:
7586 return AArch64::UABDLv8i8_v8i16;
7587 case AArch64::UABAv16i8:
7588 return AArch64::UABDv16i8;
7589 case AArch64::UABAv2i32:
7590 return AArch64::UABDv2i32;
7591 case AArch64::UABAv4i16:
7592 return AArch64::UABDv4i16;
7593 case AArch64::UABAv4i32:
7594 return AArch64::UABDv4i32;
7595 case AArch64::UABAv8i16:
7596 return AArch64::UABDv8i16;
7597 case AArch64::UABAv8i8:
7598 return AArch64::UABDv8i8;
7599 case AArch64::SABALB_ZZZ_D:
7600 return AArch64::SABDLB_ZZZ_D;
7601 case AArch64::SABALB_ZZZ_S:
7602 return AArch64::SABDLB_ZZZ_S;
7603 case AArch64::SABALB_ZZZ_H:
7604 return AArch64::SABDLB_ZZZ_H;
7605 case AArch64::SABALT_ZZZ_D:
7606 return AArch64::SABDLT_ZZZ_D;
7607 case AArch64::SABALT_ZZZ_S:
7608 return AArch64::SABDLT_ZZZ_S;
7609 case AArch64::SABALT_ZZZ_H:
7610 return AArch64::SABDLT_ZZZ_H;
7611 case AArch64::SABALv16i8_v8i16:
7612 return AArch64::SABDLv16i8_v8i16;
7613 case AArch64::SABALv2i32_v2i64:
7614 return AArch64::SABDLv2i32_v2i64;
7615 case AArch64::SABALv4i16_v4i32:
7616 return AArch64::SABDLv4i16_v4i32;
7617 case AArch64::SABALv4i32_v2i64:
7618 return AArch64::SABDLv4i32_v2i64;
7619 case AArch64::SABALv8i16_v4i32:
7620 return AArch64::SABDLv8i16_v4i32;
7621 case AArch64::SABALv8i8_v8i16:
7622 return AArch64::SABDLv8i8_v8i16;
7623 case AArch64::SABAv16i8:
7624 return AArch64::SABDv16i8;
7625 case AArch64::SABAv2i32:
7626 return AArch64::SABAv2i32;
7627 case AArch64::SABAv4i16:
7628 return AArch64::SABDv4i16;
7629 case AArch64::SABAv4i32:
7630 return AArch64::SABDv4i32;
7631 case AArch64::SABAv8i16:
7632 return AArch64::SABDv8i16;
7633 case AArch64::SABAv8i8:
7634 return AArch64::SABDv8i8;
7650 auto Match = [&](
int Opcode,
int Operand,
unsigned Pattern) ->
bool {
7662 assert(
false &&
"Unsupported FP instruction in combiner\n");
7664 case AArch64::FADDHrr:
7666 "FADDHrr does not have register operands");
7668 Found = Match(AArch64::FMULHrr, 1, MCP::FMULADDH_OP1);
7669 Found |= Match(AArch64::FMULHrr, 2, MCP::FMULADDH_OP2);
7671 case AArch64::FADDSrr:
7673 "FADDSrr does not have register operands");
7675 Found |= Match(AArch64::FMULSrr, 1, MCP::FMULADDS_OP1) ||
7676 Match(AArch64::FMULv1i32_indexed, 1, MCP::FMLAv1i32_indexed_OP1);
7678 Found |= Match(AArch64::FMULSrr, 2, MCP::FMULADDS_OP2) ||
7679 Match(AArch64::FMULv1i32_indexed, 2, MCP::FMLAv1i32_indexed_OP2);
7681 case AArch64::FADDDrr:
7682 Found |= Match(AArch64::FMULDrr, 1, MCP::FMULADDD_OP1) ||
7683 Match(AArch64::FMULv1i64_indexed, 1, MCP::FMLAv1i64_indexed_OP1);
7685 Found |= Match(AArch64::FMULDrr, 2, MCP::FMULADDD_OP2) ||
7686 Match(AArch64::FMULv1i64_indexed, 2, MCP::FMLAv1i64_indexed_OP2);
7688 case AArch64::FADDv4f16:
7689 Found |= Match(AArch64::FMULv4i16_indexed, 1, MCP::FMLAv4i16_indexed_OP1) ||
7690 Match(AArch64::FMULv4f16, 1, MCP::FMLAv4f16_OP1);
7692 Found |= Match(AArch64::FMULv4i16_indexed, 2, MCP::FMLAv4i16_indexed_OP2) ||
7693 Match(AArch64::FMULv4f16, 2, MCP::FMLAv4f16_OP2);
7695 case AArch64::FADDv8f16:
7696 Found |= Match(AArch64::FMULv8i16_indexed, 1, MCP::FMLAv8i16_indexed_OP1) ||
7697 Match(AArch64::FMULv8f16, 1, MCP::FMLAv8f16_OP1);
7699 Found |= Match(AArch64::FMULv8i16_indexed, 2, MCP::FMLAv8i16_indexed_OP2) ||
7700 Match(AArch64::FMULv8f16, 2, MCP::FMLAv8f16_OP2);
7702 case AArch64::FADDv2f32:
7703 Found |= Match(AArch64::FMULv2i32_indexed, 1, MCP::FMLAv2i32_indexed_OP1) ||
7704 Match(AArch64::FMULv2f32, 1, MCP::FMLAv2f32_OP1);
7706 Found |= Match(AArch64::FMULv2i32_indexed, 2, MCP::FMLAv2i32_indexed_OP2) ||
7707 Match(AArch64::FMULv2f32, 2, MCP::FMLAv2f32_OP2);
7709 case AArch64::FADDv2f64:
7710 Found |= Match(AArch64::FMULv2i64_indexed, 1, MCP::FMLAv2i64_indexed_OP1) ||
7711 Match(AArch64::FMULv2f64, 1, MCP::FMLAv2f64_OP1);
7713 Found |= Match(AArch64::FMULv2i64_indexed, 2, MCP::FMLAv2i64_indexed_OP2) ||
7714 Match(AArch64::FMULv2f64, 2, MCP::FMLAv2f64_OP2);
7716 case AArch64::FADDv4f32:
7717 Found |= Match(AArch64::FMULv4i32_indexed, 1, MCP::FMLAv4i32_indexed_OP1) ||
7718 Match(AArch64::FMULv4f32, 1, MCP::FMLAv4f32_OP1);
7720 Found |= Match(AArch64::FMULv4i32_indexed, 2, MCP::FMLAv4i32_indexed_OP2) ||
7721 Match(AArch64::FMULv4f32, 2, MCP::FMLAv4f32_OP2);
7723 case AArch64::FSUBHrr:
7724 Found = Match(AArch64::FMULHrr, 1, MCP::FMULSUBH_OP1);
7725 Found |= Match(AArch64::FMULHrr, 2, MCP::FMULSUBH_OP2);
7726 Found |= Match(AArch64::FNMULHrr, 1, MCP::FNMULSUBH_OP1);
7728 case AArch64::FSUBSrr:
7729 Found = Match(AArch64::FMULSrr, 1, MCP::FMULSUBS_OP1);
7731 Found |= Match(AArch64::FMULSrr, 2, MCP::FMULSUBS_OP2) ||
7732 Match(AArch64::FMULv1i32_indexed, 2, MCP::FMLSv1i32_indexed_OP2);
7734 Found |= Match(AArch64::FNMULSrr, 1, MCP::FNMULSUBS_OP1);
7736 case AArch64::FSUBDrr:
7737 Found = Match(AArch64::FMULDrr, 1, MCP::FMULSUBD_OP1);
7739 Found |= Match(AArch64::FMULDrr, 2, MCP::FMULSUBD_OP2) ||
7740 Match(AArch64::FMULv1i64_indexed, 2, MCP::FMLSv1i64_indexed_OP2);
7742 Found |= Match(AArch64::FNMULDrr, 1, MCP::FNMULSUBD_OP1);
7744 case AArch64::FSUBv4f16:
7745 Found |= Match(AArch64::FMULv4i16_indexed, 2, MCP::FMLSv4i16_indexed_OP2) ||
7746 Match(AArch64::FMULv4f16, 2, MCP::FMLSv4f16_OP2);
7748 Found |= Match(AArch64::FMULv4i16_indexed, 1, MCP::FMLSv4i16_indexed_OP1) ||
7749 Match(AArch64::FMULv4f16, 1, MCP::FMLSv4f16_OP1);
7751 case AArch64::FSUBv8f16:
7752 Found |= Match(AArch64::FMULv8i16_indexed, 2, MCP::FMLSv8i16_indexed_OP2) ||
7753 Match(AArch64::FMULv8f16, 2, MCP::FMLSv8f16_OP2);
7755 Found |= Match(AArch64::FMULv8i16_indexed, 1, MCP::FMLSv8i16_indexed_OP1) ||
7756 Match(AArch64::FMULv8f16, 1, MCP::FMLSv8f16_OP1);
7758 case AArch64::FSUBv2f32:
7759 Found |= Match(AArch64::FMULv2i32_indexed, 2, MCP::FMLSv2i32_indexed_OP2) ||
7760 Match(AArch64::FMULv2f32, 2, MCP::FMLSv2f32_OP2);
7762 Found |= Match(AArch64::FMULv2i32_indexed, 1, MCP::FMLSv2i32_indexed_OP1) ||
7763 Match(AArch64::FMULv2f32, 1, MCP::FMLSv2f32_OP1);
7765 case AArch64::FSUBv2f64:
7766 Found |= Match(AArch64::FMULv2i64_indexed, 2, MCP::FMLSv2i64_indexed_OP2) ||
7767 Match(AArch64::FMULv2f64, 2, MCP::FMLSv2f64_OP2);
7769 Found |= Match(AArch64::FMULv2i64_indexed, 1, MCP::FMLSv2i64_indexed_OP1) ||
7770 Match(AArch64::FMULv2f64, 1, MCP::FMLSv2f64_OP1);
7772 case AArch64::FSUBv4f32:
7773 Found |= Match(AArch64::FMULv4i32_indexed, 2, MCP::FMLSv4i32_indexed_OP2) ||
7774 Match(AArch64::FMULv4f32, 2, MCP::FMLSv4f32_OP2);
7776 Found |= Match(AArch64::FMULv4i32_indexed, 1, MCP::FMLSv4i32_indexed_OP1) ||
7777 Match(AArch64::FMULv4f32, 1, MCP::FMLSv4f32_OP1);
7788 auto Match = [&](
unsigned Opcode,
int Operand,
unsigned Pattern) ->
bool {
7795 if (
MI &&
MI->getOpcode() == TargetOpcode::COPY &&
7796 MI->getOperand(1).getReg().isVirtual())
7798 if (
MI &&
MI->getOpcode() == Opcode) {
7810 case AArch64::FMULv2f32:
7811 Found = Match(AArch64::DUPv2i32lane, 1, MCP::FMULv2i32_indexed_OP1);
7812 Found |= Match(AArch64::DUPv2i32lane, 2, MCP::FMULv2i32_indexed_OP2);
7814 case AArch64::FMULv2f64:
7815 Found = Match(AArch64::DUPv2i64lane, 1, MCP::FMULv2i64_indexed_OP1);
7816 Found |= Match(AArch64::DUPv2i64lane, 2, MCP::FMULv2i64_indexed_OP2);
7818 case AArch64::FMULv4f16:
7819 Found = Match(AArch64::DUPv4i16lane, 1, MCP::FMULv4i16_indexed_OP1);
7820 Found |= Match(AArch64::DUPv4i16lane, 2, MCP::FMULv4i16_indexed_OP2);
7822 case AArch64::FMULv4f32:
7823 Found = Match(AArch64::DUPv4i32lane, 1, MCP::FMULv4i32_indexed_OP1);
7824 Found |= Match(AArch64::DUPv4i32lane, 2, MCP::FMULv4i32_indexed_OP2);
7826 case AArch64::FMULv8f16:
7827 Found = Match(AArch64::DUPv8i16lane, 1, MCP::FMULv8i16_indexed_OP1);
7828 Found |= Match(AArch64::DUPv8i16lane, 2, MCP::FMULv8i16_indexed_OP2);
7841 auto Match = [&](
unsigned Opcode,
unsigned Pattern) ->
bool {
7844 if (
MI !=
nullptr && (
MI->getOpcode() == Opcode) &&
7859 case AArch64::FNEGDr:
7861 case AArch64::FNEGSr:
7993 case AArch64::SUBWrr:
7994 case AArch64::SUBSWrr:
7995 case AArch64::SUBXrr:
7996 case AArch64::SUBSXrr:
8041 unsigned LoadLaneOpCode,
unsigned NumLanes) {
8064 while (!RemainingLanes.
empty() && CurrInstr &&
8065 CurrInstr->getOpcode() == LoadLaneOpCode &&
8067 CurrInstr->getNumOperands() == 4) {
8068 RemainingLanes.
erase(CurrInstr->getOperand(2).getImm());
8074 if (!RemainingLanes.
empty())
8078 if (CurrInstr->getOpcode() != TargetOpcode::SUBREG_TO_REG)
8082 auto Lane0LoadReg = CurrInstr->getOperand(1).getReg();
8083 unsigned SingleLaneSizeInBits = 128 / NumLanes;
8084 if (
TRI->getRegSizeInBits(Lane0LoadReg, MRI) != SingleLaneSizeInBits)
8100 RemainingLoadInstrs.
insert(LoadInstrs.
begin(), LoadInstrs.
end());
8103 for (; MBBItr !=
MBB->begin() && RemainingSteps > 0 &&
8104 !RemainingLoadInstrs.
empty();
8105 --MBBItr, --RemainingSteps) {
8109 RemainingLoadInstrs.
erase(&CurrInstr);
8119 if (RemainingSteps == 0 && !RemainingLoadInstrs.
empty())
8145 case AArch64::LD1i32:
8147 case AArch64::LD1i16:
8149 case AArch64::LD1i8:
8165 unsigned Pattern,
unsigned NumLanes) {
8173 for (
unsigned i = 0; i < NumLanes - 1; ++i) {
8181 return A->getOperand(2).getImm() >
B->getOperand(2).getImm();
8187 auto LoadToLaneInstrsAscending =
llvm::reverse(LoadToLaneInstrs);
8193 auto CreateLD1Instruction = [&](
MachineInstr *OriginalInstr,
8194 Register SrcRegister,
unsigned Lane,
8196 bool OffsetRegisterKillState) {
8204 InstrIdxForVirtReg.
insert(std::make_pair(NewRegister, InsInstrs.
size()));
8205 InsInstrs.
push_back(LoadIndexIntoRegister);
8211 auto CreateLDRInstruction = [&](
unsigned NumLanes,
Register DestReg,
8217 Opcode = AArch64::LDRSui;
8220 Opcode = AArch64::LDRHui;
8223 Opcode = AArch64::LDRBui;
8227 "Got unsupported number of lanes in machine-combiner gather pattern");
8236 auto LanesToLoadToReg0 =
8238 LoadToLaneInstrsAscending.begin() + NumLanes / 2);
8239 Register PrevReg = SubregToReg->getOperand(0).getReg();
8241 const MachineOperand &OffsetRegOperand = LoadInstr->getOperand(3);
8242 PrevReg = CreateLD1Instruction(LoadInstr, PrevReg, Index + 1,
8243 OffsetRegOperand.
getReg(),
8244 OffsetRegOperand.
isKill());
8251 MachineInstr *Lane0Load = *LoadToLaneInstrsAscending.begin();
8253 *std::next(LoadToLaneInstrsAscending.begin(), NumLanes / 2);
8260 CreateLDRInstruction(NumLanes, DestRegForMiddleIndex,
8261 OriginalSplitToLoadOffsetOperand.
getReg(),
8262 OriginalSplitToLoadOffsetOperand.
isKill());
8264 InstrIdxForVirtReg.
insert(
8265 std::make_pair(DestRegForMiddleIndex, InsInstrs.
size()));
8266 InsInstrs.
push_back(MiddleIndexLoadInstr);
8271 unsigned SubregType;
8274 SubregType = AArch64::ssub;
8277 SubregType = AArch64::hsub;
8280 SubregType = AArch64::bsub;
8284 "Got invalid NumLanes for machine-combiner gather pattern");
8287 auto SubRegToRegInstr =
8289 DestRegForSubregToReg)
8292 InstrIdxForVirtReg.
insert(
8293 std::make_pair(DestRegForSubregToReg, InsInstrs.
size()));
8297 auto LanesToLoadToReg1 =
8299 LoadToLaneInstrsAscending.end());
8300 PrevReg = SubRegToRegInstr->getOperand(0).getReg();
8302 const MachineOperand &OffsetRegOperand = LoadInstr->getOperand(3);
8303 PrevReg = CreateLD1Instruction(LoadInstr, PrevReg, Index + 1,
8304 OffsetRegOperand.
getReg(),
8305 OffsetRegOperand.
isKill());
8308 if (Index == NumLanes / 2 - 2) {
8343bool AArch64InstrInfo::getMachineCombinerPatterns(
8345 bool DoRegPressureReduce)
const {
8366 DoRegPressureReduce);
8395 const Register *ReplacedAddend =
nullptr) {
8396 assert(IdxMulOpd == 1 || IdxMulOpd == 2);
8398 unsigned IdxOtherOpd = IdxMulOpd == 1 ? 2 : 1;
8401 Register SrcReg0 = MUL->getOperand(1).getReg();
8402 bool Src0IsKill = MUL->getOperand(1).isKill();
8403 Register SrcReg1 = MUL->getOperand(2).getReg();
8404 bool Src1IsKill = MUL->getOperand(2).isKill();
8408 if (ReplacedAddend) {
8410 SrcReg2 = *ReplacedAddend;
8437 .
addImm(MUL->getOperand(3).getImm());
8444 assert(
false &&
"Invalid FMA instruction kind \n");
8458 if (AArch64::FPR32RegClass.hasSubClassEq(RC))
8459 Opc = AArch64::FNMADDSrrr;
8460 else if (AArch64::FPR64RegClass.hasSubClassEq(RC))
8461 Opc = AArch64::FNMADDDrrr;
8495 unsigned IdxDupOp,
unsigned MulOpc,
8497 assert(((IdxDupOp == 1) || (IdxDupOp == 2)) &&
8498 "Invalid index of FMUL operand");
8506 if (Dup->
getOpcode() == TargetOpcode::COPY)
8515 unsigned IdxMulOp = IdxDupOp == 1 ? 2 : 1;
8556 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
8571 genNeg(MF, MRI,
TII, Root, InsInstrs, InstrIdxForVirtReg, MnegOpc, RC);
8598 genNeg(MF, MRI,
TII, Root, InsInstrs, InstrIdxForVirtReg, MnegOpc, RC);
8626 unsigned IdxMulOpd,
unsigned MaddOpc,
unsigned VR,
8628 assert(IdxMulOpd == 1 || IdxMulOpd == 2);
8632 Register SrcReg0 = MUL->getOperand(1).getReg();
8633 bool Src0IsKill = MUL->getOperand(1).isKill();
8634 Register SrcReg1 = MUL->getOperand(2).getReg();
8635 bool Src1IsKill = MUL->getOperand(2).isKill();
8665 assert(IdxOpd1 == 1 || IdxOpd1 == 2);
8666 unsigned IdxOtherOpd = IdxOpd1 == 1 ? 2 : 1;
8680 if (Opcode == AArch64::SUBSWrr)
8681 Opcode = AArch64::SUBWrr;
8682 else if (Opcode == AArch64::SUBSXrr)
8683 Opcode = AArch64::SUBXrr;
8685 assert((Opcode == AArch64::SUBWrr || Opcode == AArch64::SUBXrr) &&
8686 "Unexpected instruction opcode.");
8703 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
8710unsigned AArch64InstrInfo::getReduceOpcodeForAccumulator(
8711 unsigned int AccumulatorOpCode)
const {
8712 switch (AccumulatorOpCode) {
8713 case AArch64::UABALB_ZZZ_D:
8714 case AArch64::SABALB_ZZZ_D:
8715 case AArch64::UABALT_ZZZ_D:
8716 case AArch64::SABALT_ZZZ_D:
8717 return AArch64::ADD_ZZZ_D;
8718 case AArch64::UABALB_ZZZ_H:
8719 case AArch64::SABALB_ZZZ_H:
8720 case AArch64::UABALT_ZZZ_H:
8721 case AArch64::SABALT_ZZZ_H:
8722 return AArch64::ADD_ZZZ_H;
8723 case AArch64::UABALB_ZZZ_S:
8724 case AArch64::SABALB_ZZZ_S:
8725 case AArch64::UABALT_ZZZ_S:
8726 case AArch64::SABALT_ZZZ_S:
8727 return AArch64::ADD_ZZZ_S;
8728 case AArch64::UABALv16i8_v8i16:
8729 case AArch64::SABALv8i8_v8i16:
8730 case AArch64::SABAv8i16:
8731 case AArch64::UABAv8i16:
8732 return AArch64::ADDv8i16;
8733 case AArch64::SABALv2i32_v2i64:
8734 case AArch64::UABALv2i32_v2i64:
8735 case AArch64::SABALv4i32_v2i64:
8736 return AArch64::ADDv2i64;
8737 case AArch64::UABALv4i16_v4i32:
8738 case AArch64::SABALv4i16_v4i32:
8739 case AArch64::SABALv8i16_v4i32:
8740 case AArch64::SABAv4i32:
8741 case AArch64::UABAv4i32:
8742 return AArch64::ADDv4i32;
8743 case AArch64::UABALv4i32_v2i64:
8744 return AArch64::ADDv2i64;
8745 case AArch64::UABALv8i16_v4i32:
8746 return AArch64::ADDv4i32;
8747 case AArch64::UABALv8i8_v8i16:
8748 case AArch64::SABALv16i8_v8i16:
8749 return AArch64::ADDv8i16;
8750 case AArch64::UABAv16i8:
8751 case AArch64::SABAv16i8:
8752 return AArch64::ADDv16i8;
8753 case AArch64::UABAv4i16:
8754 case AArch64::SABAv4i16:
8755 return AArch64::ADDv4i16;
8756 case AArch64::UABAv2i32:
8757 case AArch64::SABAv2i32:
8758 return AArch64::ADDv2i32;
8759 case AArch64::UABAv8i8:
8760 case AArch64::SABAv8i8:
8761 return AArch64::ADDv8i8;
8770void AArch64InstrInfo::genAlternativeCodeSequence(
8780 MachineInstr *
MUL =
nullptr;
8781 const TargetRegisterClass *RC;
8787 DelInstrs, InstrIdxForVirtReg);
8793 InstrIdxForVirtReg);
8799 InstrIdxForVirtReg);
8808 Opc = AArch64::MADDWrrr;
8809 RC = &AArch64::GPR32RegClass;
8811 Opc = AArch64::MADDXrrr;
8812 RC = &AArch64::GPR64RegClass;
8823 Opc = AArch64::MADDWrrr;
8824 RC = &AArch64::GPR32RegClass;
8826 Opc = AArch64::MADDXrrr;
8827 RC = &AArch64::GPR64RegClass;
8840 const TargetRegisterClass *RC;
8841 unsigned BitSize, MovImm;
8844 MovImm = AArch64::MOVi32imm;
8845 RC = &AArch64::GPR32spRegClass;
8847 Opc = AArch64::MADDWrrr;
8848 RC = &AArch64::GPR32RegClass;
8850 MovImm = AArch64::MOVi64imm;
8851 RC = &AArch64::GPR64spRegClass;
8853 Opc = AArch64::MADDXrrr;
8854 RC = &AArch64::GPR64RegClass;
8865 uint64_t UImm =
SignExtend64(IsSub ? -Imm : Imm, BitSize);
8869 if (Insn.
size() != 1)
8871 MachineInstrBuilder MIB1 =
8872 BuildMI(MF, MIMetadata(Root),
TII->get(MovImm), NewVR)
8873 .
addImm(IsSub ? -Imm : Imm);
8875 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
8886 const TargetRegisterClass *SubRC;
8887 unsigned SubOpc, ZeroReg;
8889 SubOpc = AArch64::SUBWrr;
8890 SubRC = &AArch64::GPR32spRegClass;
8891 ZeroReg = AArch64::WZR;
8892 Opc = AArch64::MADDWrrr;
8893 RC = &AArch64::GPR32RegClass;
8895 SubOpc = AArch64::SUBXrr;
8896 SubRC = &AArch64::GPR64spRegClass;
8897 ZeroReg = AArch64::XZR;
8898 Opc = AArch64::MADDXrrr;
8899 RC = &AArch64::GPR64RegClass;
8903 MachineInstrBuilder MIB1 =
8904 BuildMI(MF, MIMetadata(Root),
TII->get(SubOpc), NewVR)
8908 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
8919 Opc = AArch64::MSUBWrrr;
8920 RC = &AArch64::GPR32RegClass;
8922 Opc = AArch64::MSUBXrrr;
8923 RC = &AArch64::GPR64RegClass;
8928 Opc = AArch64::MLAv8i8;
8929 RC = &AArch64::FPR64RegClass;
8933 Opc = AArch64::MLAv8i8;
8934 RC = &AArch64::FPR64RegClass;
8938 Opc = AArch64::MLAv16i8;
8939 RC = &AArch64::FPR128RegClass;
8943 Opc = AArch64::MLAv16i8;
8944 RC = &AArch64::FPR128RegClass;
8948 Opc = AArch64::MLAv4i16;
8949 RC = &AArch64::FPR64RegClass;
8953 Opc = AArch64::MLAv4i16;
8954 RC = &AArch64::FPR64RegClass;
8958 Opc = AArch64::MLAv8i16;
8959 RC = &AArch64::FPR128RegClass;
8963 Opc = AArch64::MLAv8i16;
8964 RC = &AArch64::FPR128RegClass;
8968 Opc = AArch64::MLAv2i32;
8969 RC = &AArch64::FPR64RegClass;
8973 Opc = AArch64::MLAv2i32;
8974 RC = &AArch64::FPR64RegClass;
8978 Opc = AArch64::MLAv4i32;
8979 RC = &AArch64::FPR128RegClass;
8983 Opc = AArch64::MLAv4i32;
8984 RC = &AArch64::FPR128RegClass;
8989 Opc = AArch64::MLAv8i8;
8990 RC = &AArch64::FPR64RegClass;
8992 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i8,
8996 Opc = AArch64::MLSv8i8;
8997 RC = &AArch64::FPR64RegClass;
9001 Opc = AArch64::MLAv16i8;
9002 RC = &AArch64::FPR128RegClass;
9004 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv16i8,
9008 Opc = AArch64::MLSv16i8;
9009 RC = &AArch64::FPR128RegClass;
9013 Opc = AArch64::MLAv4i16;
9014 RC = &AArch64::FPR64RegClass;
9016 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i16,
9020 Opc = AArch64::MLSv4i16;
9021 RC = &AArch64::FPR64RegClass;
9025 Opc = AArch64::MLAv8i16;
9026 RC = &AArch64::FPR128RegClass;
9028 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i16,
9032 Opc = AArch64::MLSv8i16;
9033 RC = &AArch64::FPR128RegClass;
9037 Opc = AArch64::MLAv2i32;
9038 RC = &AArch64::FPR64RegClass;
9040 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv2i32,
9044 Opc = AArch64::MLSv2i32;
9045 RC = &AArch64::FPR64RegClass;
9049 Opc = AArch64::MLAv4i32;
9050 RC = &AArch64::FPR128RegClass;
9052 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i32,
9056 Opc = AArch64::MLSv4i32;
9057 RC = &AArch64::FPR128RegClass;
9062 Opc = AArch64::MLAv4i16_indexed;
9063 RC = &AArch64::FPR64RegClass;
9067 Opc = AArch64::MLAv4i16_indexed;
9068 RC = &AArch64::FPR64RegClass;
9072 Opc = AArch64::MLAv8i16_indexed;
9073 RC = &AArch64::FPR128RegClass;
9077 Opc = AArch64::MLAv8i16_indexed;
9078 RC = &AArch64::FPR128RegClass;
9082 Opc = AArch64::MLAv2i32_indexed;
9083 RC = &AArch64::FPR64RegClass;
9087 Opc = AArch64::MLAv2i32_indexed;
9088 RC = &AArch64::FPR64RegClass;
9092 Opc = AArch64::MLAv4i32_indexed;
9093 RC = &AArch64::FPR128RegClass;
9097 Opc = AArch64::MLAv4i32_indexed;
9098 RC = &AArch64::FPR128RegClass;
9103 Opc = AArch64::MLAv4i16_indexed;
9104 RC = &AArch64::FPR64RegClass;
9106 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i16,
9110 Opc = AArch64::MLSv4i16_indexed;
9111 RC = &AArch64::FPR64RegClass;
9115 Opc = AArch64::MLAv8i16_indexed;
9116 RC = &AArch64::FPR128RegClass;
9118 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i16,
9122 Opc = AArch64::MLSv8i16_indexed;
9123 RC = &AArch64::FPR128RegClass;
9127 Opc = AArch64::MLAv2i32_indexed;
9128 RC = &AArch64::FPR64RegClass;
9130 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv2i32,
9134 Opc = AArch64::MLSv2i32_indexed;
9135 RC = &AArch64::FPR64RegClass;
9139 Opc = AArch64::MLAv4i32_indexed;
9140 RC = &AArch64::FPR128RegClass;
9142 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i32,
9146 Opc = AArch64::MLSv4i32_indexed;
9147 RC = &AArch64::FPR128RegClass;
9153 Opc = AArch64::FMADDHrrr;
9154 RC = &AArch64::FPR16RegClass;
9158 Opc = AArch64::FMADDSrrr;
9159 RC = &AArch64::FPR32RegClass;
9163 Opc = AArch64::FMADDDrrr;
9164 RC = &AArch64::FPR64RegClass;
9169 Opc = AArch64::FMADDHrrr;
9170 RC = &AArch64::FPR16RegClass;
9174 Opc = AArch64::FMADDSrrr;
9175 RC = &AArch64::FPR32RegClass;
9179 Opc = AArch64::FMADDDrrr;
9180 RC = &AArch64::FPR64RegClass;
9185 Opc = AArch64::FMLAv1i32_indexed;
9186 RC = &AArch64::FPR32RegClass;
9191 Opc = AArch64::FMLAv1i32_indexed;
9192 RC = &AArch64::FPR32RegClass;
9198 Opc = AArch64::FMLAv1i64_indexed;
9199 RC = &AArch64::FPR64RegClass;
9204 Opc = AArch64::FMLAv1i64_indexed;
9205 RC = &AArch64::FPR64RegClass;
9211 RC = &AArch64::FPR64RegClass;
9212 Opc = AArch64::FMLAv4i16_indexed;
9217 RC = &AArch64::FPR64RegClass;
9218 Opc = AArch64::FMLAv4f16;
9223 RC = &AArch64::FPR64RegClass;
9224 Opc = AArch64::FMLAv4i16_indexed;
9229 RC = &AArch64::FPR64RegClass;
9230 Opc = AArch64::FMLAv4f16;
9237 RC = &AArch64::FPR64RegClass;
9239 Opc = AArch64::FMLAv2i32_indexed;
9243 Opc = AArch64::FMLAv2f32;
9250 RC = &AArch64::FPR64RegClass;
9252 Opc = AArch64::FMLAv2i32_indexed;
9256 Opc = AArch64::FMLAv2f32;
9263 RC = &AArch64::FPR128RegClass;
9264 Opc = AArch64::FMLAv8i16_indexed;
9269 RC = &AArch64::FPR128RegClass;
9270 Opc = AArch64::FMLAv8f16;
9275 RC = &AArch64::FPR128RegClass;
9276 Opc = AArch64::FMLAv8i16_indexed;
9281 RC = &AArch64::FPR128RegClass;
9282 Opc = AArch64::FMLAv8f16;
9289 RC = &AArch64::FPR128RegClass;
9291 Opc = AArch64::FMLAv2i64_indexed;
9295 Opc = AArch64::FMLAv2f64;
9302 RC = &AArch64::FPR128RegClass;
9304 Opc = AArch64::FMLAv2i64_indexed;
9308 Opc = AArch64::FMLAv2f64;
9316 RC = &AArch64::FPR128RegClass;
9318 Opc = AArch64::FMLAv4i32_indexed;
9322 Opc = AArch64::FMLAv4f32;
9330 RC = &AArch64::FPR128RegClass;
9332 Opc = AArch64::FMLAv4i32_indexed;
9336 Opc = AArch64::FMLAv4f32;
9343 Opc = AArch64::FNMSUBHrrr;
9344 RC = &AArch64::FPR16RegClass;
9348 Opc = AArch64::FNMSUBSrrr;
9349 RC = &AArch64::FPR32RegClass;
9353 Opc = AArch64::FNMSUBDrrr;
9354 RC = &AArch64::FPR64RegClass;
9359 Opc = AArch64::FNMADDHrrr;
9360 RC = &AArch64::FPR16RegClass;
9364 Opc = AArch64::FNMADDSrrr;
9365 RC = &AArch64::FPR32RegClass;
9369 Opc = AArch64::FNMADDDrrr;
9370 RC = &AArch64::FPR64RegClass;
9375 Opc = AArch64::FMSUBHrrr;
9376 RC = &AArch64::FPR16RegClass;
9380 Opc = AArch64::FMSUBSrrr;
9381 RC = &AArch64::FPR32RegClass;
9385 Opc = AArch64::FMSUBDrrr;
9386 RC = &AArch64::FPR64RegClass;
9391 Opc = AArch64::FMLSv1i32_indexed;
9392 RC = &AArch64::FPR32RegClass;
9398 Opc = AArch64::FMLSv1i64_indexed;
9399 RC = &AArch64::FPR64RegClass;
9406 RC = &AArch64::FPR64RegClass;
9408 MachineInstrBuilder MIB1 =
9409 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv4f16), NewVR)
9412 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9414 Opc = AArch64::FMLAv4f16;
9418 Opc = AArch64::FMLAv4i16_indexed;
9425 RC = &AArch64::FPR64RegClass;
9426 Opc = AArch64::FMLSv4f16;
9431 RC = &AArch64::FPR64RegClass;
9432 Opc = AArch64::FMLSv4i16_indexed;
9439 RC = &AArch64::FPR64RegClass;
9441 Opc = AArch64::FMLSv2i32_indexed;
9445 Opc = AArch64::FMLSv2f32;
9453 RC = &AArch64::FPR128RegClass;
9455 MachineInstrBuilder MIB1 =
9456 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv8f16), NewVR)
9459 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9461 Opc = AArch64::FMLAv8f16;
9465 Opc = AArch64::FMLAv8i16_indexed;
9472 RC = &AArch64::FPR128RegClass;
9473 Opc = AArch64::FMLSv8f16;
9478 RC = &AArch64::FPR128RegClass;
9479 Opc = AArch64::FMLSv8i16_indexed;
9486 RC = &AArch64::FPR128RegClass;
9488 Opc = AArch64::FMLSv2i64_indexed;
9492 Opc = AArch64::FMLSv2f64;
9500 RC = &AArch64::FPR128RegClass;
9502 Opc = AArch64::FMLSv4i32_indexed;
9506 Opc = AArch64::FMLSv4f32;
9513 RC = &AArch64::FPR64RegClass;
9515 MachineInstrBuilder MIB1 =
9516 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv2f32), NewVR)
9519 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9521 Opc = AArch64::FMLAv2i32_indexed;
9525 Opc = AArch64::FMLAv2f32;
9533 RC = &AArch64::FPR128RegClass;
9535 MachineInstrBuilder MIB1 =
9536 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv4f32), NewVR)
9539 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9541 Opc = AArch64::FMLAv4i32_indexed;
9545 Opc = AArch64::FMLAv4f32;
9553 RC = &AArch64::FPR128RegClass;
9555 MachineInstrBuilder MIB1 =
9556 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv2f64), NewVR)
9559 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9561 Opc = AArch64::FMLAv2i64_indexed;
9565 Opc = AArch64::FMLAv2f64;
9577 &AArch64::FPR128RegClass, MRI);
9586 &AArch64::FPR128RegClass, MRI);
9595 &AArch64::FPR128_loRegClass, MRI);
9604 &AArch64::FPR128RegClass, MRI);
9613 &AArch64::FPR128_loRegClass, MRI);
9647 for (
auto *
MI : InsInstrs)
9648 MI->setFlags(Flags);
9689 bool IsNegativeBranch =
false;
9690 bool IsTestAndBranch =
false;
9691 unsigned TargetBBInMI = 0;
9692 switch (
MI.getOpcode()) {
9696 case AArch64::CBWPri:
9697 case AArch64::CBXPri:
9698 case AArch64::CBBAssertExt:
9699 case AArch64::CBHAssertExt:
9700 case AArch64::CBWPrr:
9701 case AArch64::CBXPrr:
9707 case AArch64::CBNZW:
9708 case AArch64::CBNZX:
9710 IsNegativeBranch =
true;
9715 IsTestAndBranch =
true;
9717 case AArch64::TBNZW:
9718 case AArch64::TBNZX:
9720 IsNegativeBranch =
true;
9721 IsTestAndBranch =
true;
9727 if (IsTestAndBranch &&
MI.getOperand(1).getImm())
9731 assert(
MI.getParent() &&
"Incomplete machine instruction\n");
9742 while (
DefMI->isCopy()) {
9751 switch (
DefMI->getOpcode()) {
9755 case AArch64::ANDWri:
9756 case AArch64::ANDXri: {
9757 if (IsTestAndBranch)
9764 bool Is32Bit = (
DefMI->getOpcode() == AArch64::ANDWri);
9766 DefMI->getOperand(2).getImm(), Is32Bit ? 32 : 64);
9781 unsigned Opc = (Imm < 32)
9782 ? (IsNegativeBranch ? AArch64::TBNZW : AArch64::TBZW)
9783 : (IsNegativeBranch ? AArch64::TBNZX : AArch64::TBZX);
9796 if (!Is32Bit && Imm < 32)
9798 MI.eraseFromParent();
9802 case AArch64::CSINCWr:
9803 case AArch64::CSINCXr: {
9804 if (!(
DefMI->getOperand(1).getReg() == AArch64::WZR &&
9805 DefMI->getOperand(2).getReg() == AArch64::WZR) &&
9806 !(
DefMI->getOperand(1).getReg() == AArch64::XZR &&
9807 DefMI->getOperand(2).getReg() == AArch64::XZR))
9810 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
9823 if (IsNegativeBranch)
9826 MI.eraseFromParent();
9832std::pair<unsigned, unsigned>
9833AArch64InstrInfo::decomposeMachineOperandsTargetFlags(
unsigned TF)
const {
9835 return std::make_pair(TF & Mask, TF & ~Mask);
9839AArch64InstrInfo::getSerializableDirectMachineOperandTargetFlags()
const {
9842 static const std::pair<unsigned, const char *> TargetFlags[] = {
9843 {MO_PAGE,
"aarch64-page"}, {
MO_PAGEOFF,
"aarch64-pageoff"},
9844 {
MO_G3,
"aarch64-g3"}, {
MO_G2,
"aarch64-g2"},
9845 {
MO_G1,
"aarch64-g1"}, {
MO_G0,
"aarch64-g0"},
9851AArch64InstrInfo::getSerializableBitmaskMachineOperandTargetFlags()
const {
9852 using namespace AArch64II;
9854 static const std::pair<unsigned, const char *> TargetFlags[] = {
9857 {
MO_NC,
"aarch64-nc"},
9858 {
MO_S,
"aarch64-s"},
9869AArch64InstrInfo::getSerializableMachineMemOperandTargetFlags()
const {
9870 static const std::pair<MachineMemOperand::Flags, const char *> TargetFlags[] =
9972 MachineFunction *MF =
C.getMF();
9974 const AArch64RegisterInfo *ARI =
9975 static_cast<const AArch64RegisterInfo *
>(&
TRI);
9978 for (
unsigned Reg : AArch64::GPR64RegClass) {
9980 Reg != AArch64::LR &&
9981 Reg != AArch64::X16 &&
9982 Reg != AArch64::X17 &&
9983 C.isAvailableAcrossAndOutOfSeq(
Reg,
TRI) &&
9984 C.isAvailableInsideSeq(
Reg,
TRI))
10015 return SubtargetA.hasV8_3aOps() == SubtargetB.hasV8_3aOps();
10018std::optional<std::unique_ptr<outliner::OutlinedFunction>>
10019AArch64InstrInfo::getOutliningCandidateInfo(
10021 std::vector<outliner::Candidate> &RepeatedSequenceLocs,
10022 unsigned MinRepeats)
const {
10023 unsigned SequenceSize = 0;
10024 for (
auto &
MI : RepeatedSequenceLocs[0])
10027 unsigned NumBytesToCreateFrame = 0;
10033 MachineInstr &LastMI = RepeatedSequenceLocs[0].back();
10034 MachineInstr &FirstMI = RepeatedSequenceLocs[0].front();
10035 if (LastMI.
getOpcode() == AArch64::ADRP &&
10038 return std::nullopt;
10043 if ((FirstMI.
getOpcode() == AArch64::ADDXri ||
10044 FirstMI.
getOpcode() == AArch64::LDRXui) &&
10047 return std::nullopt;
10058 if (std::adjacent_find(
10059 RepeatedSequenceLocs.begin(), RepeatedSequenceLocs.end(),
10060 [](
const outliner::Candidate &a,
const outliner::Candidate &b) {
10063 if (outliningCandidatesSigningScopeConsensus(a, b) &&
10064 outliningCandidatesSigningKeyConsensus(a, b) &&
10065 outliningCandidatesV8_3OpsConsensus(a, b)) {
10069 }) != RepeatedSequenceLocs.end()) {
10070 return std::nullopt;
10087 unsigned NumBytesToCheckLRInTCEpilogue = 0;
10088 const auto RASignCondition = RepeatedSequenceLocs[0]
10091 ->getSignReturnAddressCondition();
10094 NumBytesToCreateFrame += 8;
10097 auto LRCheckMethod = Subtarget.getAuthenticatedLRCheckMethod(
10098 *RepeatedSequenceLocs[0].getMF());
10099 NumBytesToCheckLRInTCEpilogue =
10103 if (isTailCallReturnInst(RepeatedSequenceLocs[0].
back()))
10104 SequenceSize += NumBytesToCheckLRInTCEpilogue;
10112 for (
auto &
MI :
C) {
10113 if (
MI.modifiesRegister(AArch64::SP, &
TRI)) {
10114 switch (
MI.getOpcode()) {
10115 case AArch64::ADDXri:
10116 case AArch64::ADDWri:
10117 assert(
MI.getNumOperands() == 4 &&
"Wrong number of operands");
10118 assert(
MI.getOperand(2).isImm() &&
10119 "Expected operand to be immediate");
10120 assert(
MI.getOperand(1).isReg() &&
10121 "Expected operand to be a register");
10125 if (
MI.getOperand(1).getReg() == AArch64::SP)
10126 SPValue +=
MI.getOperand(2).getImm();
10130 case AArch64::SUBXri:
10131 case AArch64::SUBWri:
10132 assert(
MI.getNumOperands() == 4 &&
"Wrong number of operands");
10133 assert(
MI.getOperand(2).isImm() &&
10134 "Expected operand to be immediate");
10135 assert(
MI.getOperand(1).isReg() &&
10136 "Expected operand to be a register");
10140 if (
MI.getOperand(1).getReg() == AArch64::SP)
10141 SPValue -=
MI.getOperand(2).getImm();
10158 if (RepeatedSequenceLocs.size() < MinRepeats)
10159 return std::nullopt;
10163 unsigned FlagsSetInAll = 0xF;
10167 FlagsSetInAll &=
C.Flags;
10169 unsigned LastInstrOpcode = RepeatedSequenceLocs[0].back().getOpcode();
10172 auto SetCandidateCallInfo =
10173 [&RepeatedSequenceLocs](
unsigned CallID,
unsigned NumBytesForCall) {
10175 C.setCallInfo(CallID, NumBytesForCall);
10179 NumBytesToCreateFrame += 4;
10187 unsigned CFICount = 0;
10188 for (
auto &
I : RepeatedSequenceLocs[0]) {
10189 if (
I.isCFIInstruction())
10199 std::vector<MCCFIInstruction> CFIInstructions =
10200 C.getMF()->getFrameInstructions();
10202 if (CFICount > 0 && CFICount != CFIInstructions.size())
10203 return std::nullopt;
10211 if (!
MI.modifiesRegister(AArch64::SP, &
TRI) &&
10212 !
MI.readsRegister(AArch64::SP, &
TRI))
10218 if (
MI.modifiesRegister(AArch64::SP, &
TRI))
10223 if (
MI.mayLoadOrStore()) {
10226 bool OffsetIsScalable;
10230 if (!getMemOperandWithOffset(
MI,
Base,
Offset, OffsetIsScalable, &
TRI) ||
10231 !
Base->isReg() ||
Base->getReg() != AArch64::SP)
10235 if (OffsetIsScalable)
10243 TypeSize Scale(0U,
false), DummyWidth(0U,
false);
10244 getMemOpInfo(
MI.getOpcode(), Scale, DummyWidth, MinOffset, MaxOffset);
10247 if (
Offset < MinOffset * (int64_t)Scale.getFixedValue() ||
10248 Offset > MaxOffset * (int64_t)Scale.getFixedValue())
10263 bool AllStackInstrsSafe =
10268 if (RepeatedSequenceLocs[0].
back().isTerminator()) {
10270 NumBytesToCreateFrame = 0;
10271 unsigned NumBytesForCall = 4 + NumBytesToCheckLRInTCEpilogue;
10275 else if (LastInstrOpcode == AArch64::BL ||
10276 ((LastInstrOpcode == AArch64::BLR ||
10277 LastInstrOpcode == AArch64::BLRNoIP) &&
10281 NumBytesToCreateFrame = NumBytesToCheckLRInTCEpilogue;
10289 unsigned NumBytesNoStackCalls = 0;
10290 std::vector<outliner::Candidate> CandidatesWithoutStackFixups;
10296 ?
C.isAvailableAcrossAndOutOfSeq(AArch64::LR,
TRI)
10305 C.getMF()->getFunction().hasFnAttribute(Attribute::NoReturn);
10308 if (LRAvailable && !IsNoReturn) {
10309 NumBytesNoStackCalls += 4;
10311 CandidatesWithoutStackFixups.push_back(
C);
10316 else if (findRegisterToSaveLRTo(
C)) {
10317 NumBytesNoStackCalls += 12;
10319 CandidatesWithoutStackFixups.push_back(
C);
10324 else if (
C.isAvailableInsideSeq(AArch64::SP,
TRI)) {
10325 NumBytesNoStackCalls += 12;
10327 CandidatesWithoutStackFixups.push_back(
C);
10333 NumBytesNoStackCalls += SequenceSize;
10340 if (!AllStackInstrsSafe ||
10341 NumBytesNoStackCalls <= RepeatedSequenceLocs.size() * 12) {
10342 RepeatedSequenceLocs = CandidatesWithoutStackFixups;
10344 if (RepeatedSequenceLocs.size() < MinRepeats)
10345 return std::nullopt;
10398 (!
C.isAvailableAcrossAndOutOfSeq(AArch64::LR,
TRI) ||
10399 !findRegisterToSaveLRTo(
C));
10405 if (RepeatedSequenceLocs.size() < MinRepeats)
10406 return std::nullopt;
10415 bool ModStackToSaveLR =
false;
10418 ModStackToSaveLR =
true;
10427 ModStackToSaveLR =
true;
10429 if (ModStackToSaveLR) {
10431 if (!AllStackInstrsSafe)
10432 return std::nullopt;
10435 NumBytesToCreateFrame += 8;
10442 return std::nullopt;
10444 return std::make_unique<outliner::OutlinedFunction>(
10445 RepeatedSequenceLocs, SequenceSize, NumBytesToCreateFrame, FrameID);
10448void AArch64InstrInfo::mergeOutliningCandidateAttributes(
10449 Function &
F, std::vector<outliner::Candidate> &Candidates)
const {
10453 const auto &CFn = Candidates.front().getMF()->getFunction();
10455 if (CFn.hasFnAttribute(
"ptrauth-returns"))
10456 F.addFnAttr(CFn.getFnAttribute(
"ptrauth-returns"));
10457 if (CFn.hasFnAttribute(
"ptrauth-auth-traps"))
10458 F.addFnAttr(CFn.getFnAttribute(
"ptrauth-auth-traps"));
10461 if (CFn.hasFnAttribute(
"sign-return-address"))
10462 F.addFnAttr(CFn.getFnAttribute(
"sign-return-address"));
10463 if (CFn.hasFnAttribute(
"sign-return-address-key"))
10464 F.addFnAttr(CFn.getFnAttribute(
"sign-return-address-key"));
10466 AArch64GenInstrInfo::mergeOutliningCandidateAttributes(
F, Candidates);
10469bool AArch64InstrInfo::isFunctionSafeToOutlineFrom(
10474 if (!OutlineFromLinkOnceODRs &&
F.hasLinkOnceODRLinkage())
10481 if (
F.hasSection())
10487 AArch64FunctionInfo *AFI = MF.
getInfo<AArch64FunctionInfo>();
10488 if (!AFI || AFI->
hasRedZone().value_or(
true))
10508 unsigned &Flags)
const {
10510 "Must track liveness!");
10512 std::pair<MachineBasicBlock::iterator, MachineBasicBlock::iterator>>
10527 auto AreAllUnsafeRegsDead = [&LRU]() {
10528 return LRU.available(AArch64::W16) && LRU.available(AArch64::W17) &&
10529 LRU.available(AArch64::NZCV);
10544 bool LRAvailableEverywhere =
true;
10546 LRU.addLiveOuts(
MBB);
10548 auto UpdateWholeMBBFlags = [&
Flags](
const MachineInstr &
MI) {
10549 if (
MI.isCall() && !
MI.isTerminator())
10555 auto CreateNewRangeStartingAt =
10556 [&RangeBegin, &RangeEnd,
10558 RangeBegin = NewBegin;
10559 RangeEnd = std::next(RangeBegin);
10562 auto SaveRangeIfNonEmpty = [&RangeLen, &
Ranges, &RangeBegin, &RangeEnd]() {
10568 if (!RangeBegin.isEnd() && RangeBegin->isBundledWithPred())
10570 if (!RangeEnd.isEnd() && RangeEnd->isBundledWithPred())
10572 Ranges.emplace_back(RangeBegin, RangeEnd);
10580 for (; FirstPossibleEndPt !=
MBB.
instr_rend(); ++FirstPossibleEndPt) {
10581 LRU.stepBackward(*FirstPossibleEndPt);
10584 UpdateWholeMBBFlags(*FirstPossibleEndPt);
10585 if (AreAllUnsafeRegsDead())
10592 CreateNewRangeStartingAt(FirstPossibleEndPt->getIterator());
10597 LRU.stepBackward(
MI);
10598 UpdateWholeMBBFlags(
MI);
10599 if (!AreAllUnsafeRegsDead()) {
10600 SaveRangeIfNonEmpty();
10601 CreateNewRangeStartingAt(
MI.getIterator());
10604 LRAvailableEverywhere &= LRU.available(AArch64::LR);
10605 RangeBegin =
MI.getIterator();
10610 if (AreAllUnsafeRegsDead())
10611 SaveRangeIfNonEmpty();
10619 if (!LRAvailableEverywhere)
10627 unsigned Flags)
const {
10628 MachineInstr &
MI = *MIT;
10632 switch (
MI.getOpcode()) {
10633 case AArch64::PACM:
10634 case AArch64::PACIASP:
10635 case AArch64::PACIBSP:
10636 case AArch64::PACIASPPC:
10637 case AArch64::PACIBSPPC:
10638 case AArch64::AUTIASP:
10639 case AArch64::AUTIBSP:
10640 case AArch64::AUTIASPPCi:
10641 case AArch64::AUTIASPPCr:
10642 case AArch64::AUTIBSPPCi:
10643 case AArch64::AUTIBSPPCr:
10644 case AArch64::RETAA:
10645 case AArch64::RETAB:
10646 case AArch64::RETAASPPCi:
10647 case AArch64::RETAASPPCr:
10648 case AArch64::RETABSPPCi:
10649 case AArch64::RETABSPPCr:
10650 case AArch64::EMITBKEY:
10651 case AArch64::PAUTH_PROLOGUE:
10652 case AArch64::PAUTH_EPILOGUE:
10662 if (
MI.isCFIInstruction())
10666 if (
MI.isTerminator())
10672 for (
const MachineOperand &MOP :
MI.operands()) {
10675 assert(!MOP.isCFIIndex());
10678 if (MOP.isReg() && !MOP.isImplicit() &&
10679 (MOP.getReg() == AArch64::LR || MOP.getReg() == AArch64::W30))
10686 if (
MI.getOpcode() == AArch64::ADRP)
10706 for (
const MachineOperand &MOP :
MI.operands()) {
10707 if (MOP.isGlobal()) {
10715 if (Callee &&
Callee->getName() ==
"\01_mcount")
10723 if (
MI.getOpcode() == AArch64::BLR ||
10724 MI.getOpcode() == AArch64::BLRNoIP ||
MI.getOpcode() == AArch64::BL)
10728 return UnknownCallOutlineType;
10736 return UnknownCallOutlineType;
10744 return UnknownCallOutlineType;
10765 for (MachineInstr &
MI :
MBB) {
10766 const MachineOperand *
Base;
10767 TypeSize Width(0,
false);
10769 bool OffsetIsScalable;
10772 if (!
MI.mayLoadOrStore() ||
10775 (
Base->isReg() &&
Base->getReg() != AArch64::SP))
10779 TypeSize Scale(0U,
false);
10780 int64_t Dummy1, Dummy2;
10783 assert(StackOffsetOperand.
isImm() &&
"Stack offset wasn't immediate!");
10785 assert(Scale != 0 &&
"Unexpected opcode!");
10786 assert(!OffsetIsScalable &&
"Expected offset to be a byte offset");
10791 int64_t NewImm = (
Offset + 16) / (int64_t)Scale.getFixedValue();
10792 StackOffsetOperand.
setImm(NewImm);
10798 bool ShouldSignReturnAddr) {
10799 if (!ShouldSignReturnAddr)
10805 TII->get(AArch64::PAUTH_EPILOGUE))
10809void AArch64InstrInfo::buildOutlinedFrame(
10813 AArch64FunctionInfo *FI = MF.
getInfo<AArch64FunctionInfo>();
10821 unsigned TailOpcode;
10823 TailOpcode = AArch64::TCRETURNdi;
10827 TailOpcode = AArch64::TCRETURNriALL;
10838 bool IsLeafFunction =
true;
10841 auto IsNonTailCall = [](
const MachineInstr &
MI) {
10842 return MI.isCall() && !
MI.isReturn();
10852 "Can only fix up stack references once");
10853 fixupPostOutline(
MBB);
10855 IsLeafFunction =
false;
10866 Et = std::prev(
MBB.
end());
10876 if (MF.
getInfo<AArch64FunctionInfo>()->needsDwarfUnwindInfo(MF)) {
10880 CFIBuilder.buildDefCFAOffset(16);
10884 CFIBuilder.buildOffset(AArch64::LR, -16);
10898 RASignCondition, !IsLeafFunction);
10927 fixupPostOutline(
MBB);
10938 .addGlobalAddress(
M.getNamedValue(MF.
getName()))
10948 .addGlobalAddress(
M.getNamedValue(MF.
getName())));
10957 MachineInstr *Save;
10958 MachineInstr *Restore;
10964 assert(
Reg &&
"No callee-saved register available?");
10998 .addGlobalAddress(
M.getNamedValue(MF.
getName())));
11006bool AArch64InstrInfo::shouldOutlineFromFunctionByDefault(
11014 bool AllowSideEffects)
const {
11016 const AArch64Subtarget &STI = MF.
getSubtarget<AArch64Subtarget>();
11019 if (
TRI.isGeneralPurposeRegister(MF,
Reg)) {
11032 assert(STI.hasNEON() &&
"Expected to have NEON.");
11038std::optional<DestSourcePair>
11043 if (((
MI.getOpcode() == AArch64::ORRWrs &&
11044 MI.getOperand(1).getReg() == AArch64::WZR &&
11045 MI.getOperand(3).getImm() == 0x0) ||
11046 (
MI.getOpcode() == AArch64::ORRWrr &&
11047 MI.getOperand(1).getReg() == AArch64::WZR)) &&
11049 (!
MI.getOperand(0).getReg().isVirtual() ||
11050 MI.getOperand(0).getSubReg() == 0) &&
11051 (!
MI.getOperand(0).getReg().isPhysical() ||
11056 if (
MI.getOpcode() == AArch64::ORRXrs &&
11057 MI.getOperand(1).getReg() == AArch64::XZR &&
11058 MI.getOperand(3).getImm() == 0x0)
11061 return std::nullopt;
11064std::optional<DestSourcePair>
11066 if ((
MI.getOpcode() == AArch64::ORRWrs &&
11067 MI.getOperand(1).getReg() == AArch64::WZR &&
11068 MI.getOperand(3).getImm() == 0x0) ||
11069 (
MI.getOpcode() == AArch64::ORRWrr &&
11070 MI.getOperand(1).getReg() == AArch64::WZR))
11072 return std::nullopt;
11075std::optional<RegImmPair>
11084 return std::nullopt;
11086 switch (
MI.getOpcode()) {
11088 return std::nullopt;
11089 case AArch64::SUBWri:
11090 case AArch64::SUBXri:
11091 case AArch64::SUBSWri:
11092 case AArch64::SUBSXri:
11095 case AArch64::ADDSWri:
11096 case AArch64::ADDSXri:
11097 case AArch64::ADDWri:
11098 case AArch64::ADDXri: {
11100 if (!
MI.getOperand(0).isReg() || !
MI.getOperand(1).isReg() ||
11101 !
MI.getOperand(2).isImm())
11102 return std::nullopt;
11103 int Shift =
MI.getOperand(3).getImm();
11104 assert((Shift == 0 || Shift == 12) &&
"Shift can be either 0 or 12");
11108 return RegImmPair{
MI.getOperand(1).getReg(),
Offset};
11114static std::optional<ParamLoadedValue>
11118 auto DestSrc =
TII->isCopyLikeInstr(
MI);
11120 return std::nullopt;
11122 Register DestReg = DestSrc->Destination->getReg();
11123 Register SrcReg = DestSrc->Source->getReg();
11126 return std::nullopt;
11131 if (DestReg == DescribedReg)
11135 if (
MI.getOpcode() == AArch64::ORRWrs &&
11136 TRI->isSuperRegister(DestReg, DescribedReg))
11140 if (
MI.getOpcode() == AArch64::ORRXrs &&
11141 TRI->isSubRegister(DestReg, DescribedReg)) {
11142 Register SrcSubReg =
TRI->getSubReg(SrcReg, AArch64::sub_32);
11146 assert(!
TRI->isSuperOrSubRegisterEq(DestReg, DescribedReg) &&
11147 "Unhandled ORR[XW]rs copy case");
11149 return std::nullopt;
11152bool AArch64InstrInfo::isFunctionSafeToSplit(
const MachineFunction &MF)
const {
11157 if (MF.
getInfo<AArch64FunctionInfo>()->hasRedZone().value_or(
true))
11163bool AArch64InstrInfo::isMBBSafeToSplitToCold(
11167 auto isAsmGoto = [](
const MachineInstr &
MI) {
11168 return MI.getOpcode() == AArch64::INLINEASM_BR;
11178 auto containsMBB = [&
MBB](
const MachineJumpTableEntry &JTE) {
11185 for (
const MachineInstr &
MI :
MBB) {
11186 switch (
MI.getOpcode()) {
11187 case TargetOpcode::G_BRJT:
11188 case AArch64::JumpTableDest32:
11189 case AArch64::JumpTableDest16:
11190 case AArch64::JumpTableDest8:
11201std::optional<ParamLoadedValue>
11204 const MachineFunction *MF =
MI.getMF();
11206 switch (
MI.getOpcode()) {
11207 case AArch64::MOVZWi:
11208 case AArch64::MOVZXi: {
11211 if (!
TRI->isSuperRegisterEq(
MI.getOperand(0).getReg(),
Reg))
11212 return std::nullopt;
11214 if (!
MI.getOperand(1).isImm())
11215 return std::nullopt;
11216 int64_t Immediate =
MI.getOperand(1).getImm();
11217 int Shift =
MI.getOperand(2).getImm();
11221 case AArch64::ORRWrs:
11222 case AArch64::ORRXrs:
11229bool AArch64InstrInfo::isExtendLikelyToBeFolded(
11232 ExtMI.
getOpcode() == TargetOpcode::G_ZEXT ||
11233 ExtMI.
getOpcode() == TargetOpcode::G_ANYEXT);
11236 if (ExtMI.
getOpcode() == TargetOpcode::G_ANYEXT)
11246 return UserMI->
getOpcode() == TargetOpcode::G_PTR_ADD;
11249uint64_t AArch64InstrInfo::getElementSizeForOpcode(
unsigned Opc)
const {
11253bool AArch64InstrInfo::isPTestLikeOpcode(
unsigned Opc)
const {
11257bool AArch64InstrInfo::isWhileOpcode(
unsigned Opc)
const {
11262AArch64InstrInfo::getTailDuplicateSize(
CodeGenOptLevel OptLevel)
const {
11266bool AArch64InstrInfo::isLegalAddressingMode(
unsigned NumBytes, int64_t
Offset,
11267 unsigned Scale)
const {
11278 unsigned Shift =
Log2_64(NumBytes);
11279 if (NumBytes &&
Offset > 0 && (
Offset / NumBytes) <= (1LL << 12) - 1 &&
11287 return Scale == 1 || (Scale > 0 && Scale == NumBytes);
11292 return AArch64::BLRNoIP;
11294 return AArch64::BLR;
11299 Register TargetReg,
bool FrameSetup)
const {
11300 assert(TargetReg != AArch64::SP &&
"New top of stack cannot already be in SP");
11312 MF.
insert(MBBInsertPoint, LoopTestMBB);
11315 MF.
insert(MBBInsertPoint, LoopBodyMBB);
11317 MF.
insert(MBBInsertPoint, ExitMBB);
11327 BuildMI(*LoopTestMBB, LoopTestMBB->
end(),
DL,
TII->get(AArch64::SUBSXrx64),
11335 BuildMI(*LoopTestMBB, LoopTestMBB->
end(),
DL,
TII->get(AArch64::Bcc))
11341 BuildMI(*LoopBodyMBB, LoopBodyMBB->
end(),
DL,
TII->get(AArch64::LDRXui))
11358 BuildMI(*ExitMBB, ExitMBB->
end(),
DL,
TII->get(AArch64::ADDXri), AArch64::SP)
11377 MBB.addSuccessor(LoopTestMBB);
11383 return ExitMBB->
begin();
11400 unsigned CompCounterOprNum;
11404 unsigned UpdateCounterOprNum;
11408 bool IsUpdatePriorComp;
11420 TII(MF->getSubtarget().getInstrInfo()),
11421 TRI(MF->getSubtarget().getRegisterInfo()), MRI(MF->getRegInfo()),
11422 LoopBB(LoopBB), CondBranch(CondBranch), Comp(Comp),
11423 CompCounterOprNum(CompCounterOprNum), Update(Update),
11424 UpdateCounterOprNum(UpdateCounterOprNum),
Init(
Init),
11425 IsUpdatePriorComp(IsUpdatePriorComp),
Cond(
Cond.begin(),
Cond.end()) {}
11427 bool shouldIgnoreForPipelining(
const MachineInstr *
MI)
const override {
11433 std::optional<bool> createTripCountGreaterCondition(
11434 int TC, MachineBasicBlock &
MBB,
11435 SmallVectorImpl<MachineOperand> &CondParam)
override {
11443 void createRemainingIterationsGreaterCondition(
11444 int TC, MachineBasicBlock &
MBB, SmallVectorImpl<MachineOperand> &
Cond,
11445 DenseMap<MachineInstr *, MachineInstr *> &LastStage0Insts)
override;
11447 void setPreheader(MachineBasicBlock *NewPreheader)
override {}
11449 void adjustTripCount(
int TripCountAdjust)
override {}
11451 bool isMVEExpanderSupported()
override {
return true; }
11470 }
else if (
I == ReplaceOprNum) {
11475 MBB.insert(InsertTo, NewMI);
11479void AArch64PipelinerLoopInfo::createRemainingIterationsGreaterCondition(
11495 assert(CondBranch->getOpcode() == AArch64::Bcc);
11499 if (CondBranch->getOperand(1).getMBB() == LoopBB)
11506 auto AccumulateCond = [&](
Register CurCond,
11517 if (!LastStage0Insts.
empty() && LastStage0Insts[Comp]->getParent() == &
MBB) {
11521 for (
int I = 0;
I <= TC; ++
I) {
11527 AccCond = AccumulateCond(AccCond, CC);
11531 if (Update != Comp && IsUpdatePriorComp) {
11533 LastStage0Insts[Comp]->getOperand(CompCounterOprNum).getReg();
11534 NextCounter =
cloneInstr(Update, UpdateCounterOprNum, Counter,
MBB,
11538 NextCounter = LastStage0Insts[Update]->getOperand(0).getReg();
11540 }
else if (Update != Comp) {
11545 Counter = NextCounter;
11549 if (LastStage0Insts.
empty()) {
11553 if (IsUpdatePriorComp)
11558 Counter = LastStage0Insts[Comp]->getOperand(CompCounterOprNum).getReg();
11561 for (
int I = 0;
I <= TC; ++
I) {
11565 AccCond = AccumulateCond(AccCond, CC);
11566 if (
I != TC && Update != Comp)
11569 Counter = NextCounter;
11585 assert(Phi.getNumOperands() == 5);
11586 if (Phi.getOperand(2).getMBB() ==
MBB) {
11587 RegMBB = Phi.getOperand(1).getReg();
11588 RegOther = Phi.getOperand(3).getReg();
11590 assert(Phi.getOperand(4).getMBB() ==
MBB);
11591 RegMBB = Phi.getOperand(3).getReg();
11592 RegOther = Phi.getOperand(1).getReg();
11597 if (!
Reg.isVirtual())
11606 unsigned &UpdateCounterOprNum,
Register &InitReg,
11607 bool &IsUpdatePriorComp) {
11621 if (!
Reg.isVirtual())
11624 UpdateInst =
nullptr;
11625 UpdateCounterOprNum = 0;
11627 IsUpdatePriorComp =
true;
11631 if (Def->getParent() != LoopBB)
11633 if (Def->isCopy()) {
11635 if (Def->getOperand(0).getSubReg() || Def->getOperand(1).getSubReg())
11637 CurReg = Def->getOperand(1).getReg();
11638 }
else if (Def->isPHI()) {
11642 IsUpdatePriorComp =
false;
11647 switch (Def->getOpcode()) {
11648 case AArch64::ADDSXri:
11649 case AArch64::ADDSWri:
11650 case AArch64::SUBSXri:
11651 case AArch64::SUBSWri:
11652 case AArch64::ADDXri:
11653 case AArch64::ADDWri:
11654 case AArch64::SUBXri:
11655 case AArch64::SUBWri:
11657 UpdateCounterOprNum = 1;
11659 case AArch64::ADDSXrr:
11660 case AArch64::ADDSWrr:
11661 case AArch64::SUBSXrr:
11662 case AArch64::SUBSWrr:
11663 case AArch64::ADDXrr:
11664 case AArch64::ADDWrr:
11665 case AArch64::SUBXrr:
11666 case AArch64::SUBWrr:
11669 UpdateCounterOprNum = 1;
11671 UpdateCounterOprNum = 2;
11678 CurReg = Def->getOperand(UpdateCounterOprNum).getReg();
11693std::unique_ptr<TargetInstrInfo::PipelinerLoopInfo>
11704 if (
MI.isCall() ||
MI.hasUnmodeledSideEffects())
11715 if (
TBB == LoopBB && FBB == LoopBB)
11719 if (
TBB != LoopBB && FBB ==
nullptr)
11722 assert((
TBB == LoopBB || FBB == LoopBB) &&
11723 "The Loop must be a single-basic-block loop");
11728 if (CondBranch->
getOpcode() != AArch64::Bcc)
11736 unsigned CompCounterOprNum = 0;
11738 if (
MI.modifiesRegister(AArch64::NZCV, &
TRI)) {
11742 switch (
MI.getOpcode()) {
11743 case AArch64::SUBSXri:
11744 case AArch64::SUBSWri:
11745 case AArch64::ADDSXri:
11746 case AArch64::ADDSWri:
11748 CompCounterOprNum = 1;
11750 case AArch64::ADDSWrr:
11751 case AArch64::ADDSXrr:
11752 case AArch64::SUBSWrr:
11753 case AArch64::SUBSXrr:
11757 if (isWhileOpcode(
MI.getOpcode())) {
11764 if (CompCounterOprNum == 0) {
11766 CompCounterOprNum = 2;
11768 CompCounterOprNum = 1;
11780 bool IsUpdatePriorComp;
11781 unsigned UpdateCounterOprNum;
11783 Update, UpdateCounterOprNum,
Init, IsUpdatePriorComp))
11786 return std::make_unique<AArch64PipelinerLoopInfo>(
11787 LoopBB, CondBranch, Comp, CompCounterOprNum, Update, UpdateCounterOprNum,
11797 TypeSize Scale(0U,
false), Width(0U,
false);
11798 int64_t MinOffset, MaxOffset;
11799 if (
getMemOpInfo(
MI.getOpcode(), Scale, Width, MinOffset, MaxOffset)) {
11801 if (
MI.getOperand(ImmIdx).isImm() && !
MI.getOperand(ImmIdx - 1).isFI()) {
11802 int64_t Imm =
MI.getOperand(ImmIdx).getImm();
11803 if (Imm < MinOffset || Imm > MaxOffset) {
11804 ErrInfo =
"Unexpected immediate on load/store instruction";
11810 const MCInstrDesc &MCID =
MI.getDesc();
11812 const MachineOperand &MO =
MI.getOperand(
Op);
11816 ErrInfo =
"OPERAND_IMPLICIT_IMM_0 should be 0";
11825 ErrInfo =
"OPERAND_SHIFT_MSL should be msl shift of 8 or 16";
11836#define GET_INSTRINFO_HELPERS
11837#define GET_INSTRMAP_INFO
11838#include "AArch64GenInstrInfo.inc"
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 bool isFrameStoreOpcode(int Opcode)
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 bool isFrameLoadOpcode(int Opcode)
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 bool isCheapCopy(const MachineInstr &MI, const AArch64RegisterInfo &RI)
static bool isANDOpcode(MachineInstr &MI)
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 bool canPairLdStOpc(unsigned FirstOpc, unsigned SecondOpc)
static bool mustAvoidNeonAtMBBI(const AArch64Subtarget &Subtarget, MachineBasicBlock &MBB, MachineBasicBlock::iterator I)
Returns true if in a streaming call site region without SME-FA64.
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 isInStreamingCallSiteRegion(MachineBasicBlock &MBB, MachineBasicBlock::iterator I)
Returns true if the instruction at I is in a streaming call site region, within a single basic block.
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 const MachineInstrBuilder & AddSubReg(const MachineInstrBuilder &MIB, MCRegister Reg, unsigned SubIdx, RegState State, const TargetRegisterInfo *TRI)
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 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 unsigned canFoldIntoCSel(const MachineRegisterInfo &MRI, unsigned VReg, unsigned *NewReg=nullptr)
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)
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
DXIL Forward Handle Accesses
const HexagonInstrInfo * TII
Module.h This file contains the declarations for the Module class.
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
Machine Check Debug Module
Register const TargetRegisterInfo * TRI
Promote Memory to Register
static MCRegister 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.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
#define DEBUG_WITH_TYPE(TYPE,...)
DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug information.
static bool canCombine(MachineBasicBlock &MBB, MachineOperand &MO, unsigned CombineOpc=0)
AArch64FunctionInfo - This class is derived from MachineFunctionInfo and contains private AArch64-spe...
SignReturnAddress getSignReturnAddressCondition() const
bool hasStreamingModeChanges() const
void setOutliningStyle(const std::string &Style)
std::optional< bool > hasRedZone() const
static bool shouldSignReturnAddress(SignReturnAddress Condition, bool IsLRSpilled)
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 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 int findCondCodeUseOperandIdxForBranchOrSelect(const MachineInstr &Instr)
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
unsigned getInstSizeInBytes(const MachineInstr &MI) const override
GetInstSize - Return the number of bytes of code the specified instruction may be.
static bool isZExtLoad(const MachineInstr &MI)
Returns whether the instruction is a zero-extending load.
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 isBranchOffsetInRange(unsigned BranchOpc, int64_t BrOffset) const override
bool canInsertSelect(const MachineBasicBlock &, ArrayRef< MachineOperand > Cond, Register, Register, Register, int &, int &, int &) const override
Register isLoadFromStackSlotPostFE(const MachineInstr &MI, int &FrameIndex) const override
Check for post-frame ptr elimination stack locations as well.
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
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.
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
void insertIndirectBranch(MachineBasicBlock &MBB, MachineBasicBlock &NewDestBB, MachineBasicBlock &RestoreBB, const DebugLoc &DL, int64_t BrOffset, RegScavenger *RS) const override
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register DestReg, int FrameIndex, const TargetRegisterClass *RC, Register VReg, unsigned SubReg=0, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
static bool isPairableLdStInst(const MachineInstr &MI)
Return true if pairing the given load or store may be paired with another.
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, Register VReg, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
static bool isSExtLoad(const MachineInstr &MI)
Returns whether the instruction is a sign-extending load.
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.
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
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.
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
bool isThroughputPattern(unsigned Pattern) const override
Return true when a code sequence can improve throughput.
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
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.
Register isStoreToStackSlotPostFE(const MachineInstr &MI, int &FrameIndex) const override
Check for post-frame ptr elimination stack locations as well.
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
Return true when there is potentially a faster code sequence for an instruction chain ending in Root.
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?
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 isAsCheapAsAMove(const MachineInstr &MI) 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 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 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 isSVEorStreamingSVEAvailable() const
Returns true if the target has access to either the full range of SVE instructions,...
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.
This is an important base class in LLVM.
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...
LLVM_ABI InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
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.
Instances of this class represent a single low-level machine instruction.
Describe properties that are true of each instruction in the target description file.
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
ArrayRef< MCOperandInfo > operands() const
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()
LLVM_ABI iterator getFirstTerminator()
Returns an iterator to the first terminator instruction 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()
Instructions::iterator instr_iterator
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.
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.
BasicBlockListType::iterator iterator
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
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)
CreateMachineInstr - Allocate a new MachineInstr.
void insert(iterator MBBI, MachineBasicBlock *MBB)
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
const MachineInstrBuilder & setMemRefs(ArrayRef< MachineMemOperand * > MMOs) const
const MachineInstrBuilder & addCFIIndex(unsigned CFIIndex) const
const MachineInstrBuilder & addUse(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a virtual register use operand.
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
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 & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
const MachineInstrBuilder & addDef(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a virtual register definition operand.
const MachineInstrBuilder & setMIFlags(unsigned Flags) const
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
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 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.
LLVM_ABI MachineInstrBundleIterator< MachineInstr > eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
const std::vector< MachineJumpTableEntry > & getJumpTables() const
A description of a memory reference used in the backend.
@ MOVolatile
The memory access is volatile.
@ 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.
unsigned getTargetFlags() const
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,...
LLVM_ABI bool hasOneNonDBGUse(Register RegNo) const
hasOneNonDBGUse - Return true if there is exactly one non-Debug use of the specified register.
bool tracksLiveness() const
tracksLiveness - Returns true when tracking register liveness accurately.
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
LLVM_ABI void clearKillFlags(Register Reg) const
clearKillFlags - Iterate over all the uses of the given register and clear the kill flag from the Mac...
LLVM_ABI MachineInstr * getVRegDef(Register Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
bool use_nodbg_empty(Register RegNo) const
use_nodbg_empty - Return true if there are no non-Debug instructions using the specified register.
LLVM_ABI Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
bool reservedRegsFrozen() const
reservedRegsFrozen - Returns true after freezeReservedRegs() was called to ensure the set of reserved...
bool def_empty(Register RegNo) const
def_empty - Return true if there are no instructions defining the specified register (it may be live-...
use_instr_nodbg_iterator use_instr_nodbg_begin(Register RegNo) const
bool hasOneDef(Register RegNo) const
Return true if there is exactly one operand defining the specified register.
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.
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.
CodeModel::Model getCodeModel() const
Returns the code model.
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)
Value * getOperand(unsigned i) const
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()
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_DLLIMPORT
MO_DLLIMPORT - On a symbol operand, this represents that the reference to the symbol is for an import...
@ 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_S
MO_S - Indicates that the bits of the symbol operand represented by MO_G0 etc are signed.
@ 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_PREL
MO_PREL - Indicates that the bits of the symbol operand represented by MO_G0 etc are PC relative.
@ MO_G0
MO_G0 - A symbol operand with this flag (granule 0) represents the bits 0-15 of a 64-bit address,...
@ MO_ARM64EC_CALLMANGLE
MO_ARM64EC_CALLMANGLE - Operand refers to the Arm64EC-mangled version of a symbol,...
@ MO_PAGE
MO_PAGE - A symbol operand with this flag represents the pc-relative offset of the 4K page containing...
@ MO_HI12
MO_HI12 - This flag indicates that a symbol operand represents the bits 13-24 of a 64-bit address,...
@ MO_TLS
MO_TLS - Indicates that the operand being accessed is some kind of thread-local symbol.
@ MO_G2
MO_G2 - A symbol operand with this flag (granule 2) represents the bits 32-47 of a 64-bit address,...
@ MO_TAGGED
MO_TAGGED - With MO_PAGE, indicates that the page includes a memory tag in bits 56-63.
@ MO_G3
MO_G3 - A symbol operand with this flag (granule 3) represents the high 16-bits of a 64-bit address,...
@ MO_COFFSTUB
MO_COFFSTUB - On a symbol operand "FOO", this indicates that the reference is actually to the "....
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 getExtendType(unsigned Imm)
getExtendType - Extract the extend type for operands of arithmetic ops.
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.
@ ScalablePredicateVector
initializer< Ty > init(const Ty &Val)
InstrType
Represents how an instruction should be mapped by the outliner.
LLVM_ABI Instruction & back() const
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
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)
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.
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
RegState
Flags to represent properties of register accesses.
@ Implicit
Not emitted register (e.g. carry, or temporary result).
@ Kill
The last use of a register.
@ Undef
Value of the register doesn't matter.
@ Define
Register definition.
@ Renamable
Register that may be renamed.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
constexpr RegState getKillRegState(bool B)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
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.
static bool isSEHInstruction(const MachineInstr &MI)
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
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
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)
constexpr RegState getDefRegState(bool B)
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.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
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.
static MCRegister getXRegFromWReg(MCRegister Reg)
MCCFIInstruction createCFAOffset(const TargetRegisterInfo &MRI, unsigned Reg, const StackOffset &OffsetFromDefCFA, std::optional< int64_t > IncomingVGOffsetFromDefCFA)
FunctionAddr VTableAddr Next
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
static bool isUncondBranchOpcode(int Opc)
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
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.
void appendLEB128(SmallVectorImpl< U > &Buffer, T Value)
bool optimizeTerminators(MachineBasicBlock *MBB, const TargetInstrInfo &TII)
std::pair< MachineOperand, DIExpression * > ParamLoadedValue
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 ...
auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.
static const MachineMemOperand::Flags MOStridedAccess
constexpr RegState getUndefRegState(bool B)
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.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Used to describe addressing mode similar to ExtAddrMode in CodeGenPrepare.
LLVM_ABI static const MBBSectionID ColdSectionID
This class contains a discriminated union of information about pointers in memory operands,...
static LLVM_ABI MachinePointerInfo getUnknownStack(MachineFunction &MF)
Stack memory without other information.
static LLVM_ABI MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
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.