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) {}
118 switch (
MI.getOpcode()) {
129 if (
MI.getOperand(0).getReg() != AArch64::LR)
138 if (MO.isReg() && MO.isDef() && MO.getReg() == AArch64::LR)
156 auto Op =
MI.getOpcode();
157 if (
Op == AArch64::INLINEASM ||
Op == AArch64::INLINEASM_BR)
158 return getInlineAsmLength(
MI.getOperand(0).getSymbolName(), MAI);
162 if (
MI.isMetaInstruction())
167 unsigned NumBytes = 0;
177 NumBytes =
Desc.getSize() ?
Desc.getSize() : 4;
180 if (!MFI->shouldSignReturnAddress(*MF))
183 auto Method = STI.getAuthenticatedLRCheckMethod(*MF);
191 switch (
Desc.getOpcode()) {
194 return Desc.getSize();
201 case TargetOpcode::STACKMAP:
204 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
206 case TargetOpcode::PATCHPOINT:
209 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
211 case TargetOpcode::STATEPOINT:
213 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
218 case TargetOpcode::PATCHABLE_FUNCTION_ENTER:
223 F.getFnAttributeAsParsedInteger(
"patchable-function-entry", 9) * 4;
225 case TargetOpcode::PATCHABLE_FUNCTION_EXIT:
226 case TargetOpcode::PATCHABLE_TAIL_CALL:
227 case TargetOpcode::PATCHABLE_TYPED_EVENT_CALL:
231 case TargetOpcode::PATCHABLE_EVENT_CALL:
237 NumBytes =
MI.getOperand(1).getImm();
239 case AArch64::MOVaddr:
240 case AArch64::MOVaddrJT:
241 case AArch64::MOVaddrCP:
242 case AArch64::MOVaddrBA:
243 case AArch64::MOVaddrTLS:
244 case AArch64::MOVaddrEXT: {
248 MI.getOperand(1).getTargetFlags(),
249 Subtarget.isTargetMachO(), Insn);
250 NumBytes = Insn.
size() * 4;
254 case AArch64::MOVi32imm:
255 case AArch64::MOVi64imm: {
257 unsigned BitSize =
Desc.getOpcode() == AArch64::MOVi32imm ? 32 : 64;
260 NumBytes = Insn.
size() * 4;
264 case TargetOpcode::BUNDLE:
265 NumBytes = getInstBundleSize(
MI);
301 case AArch64::CBWPri:
302 case AArch64::CBXPri:
303 case AArch64::CBWPrr:
304 case AArch64::CBXPrr:
312 case AArch64::CBBAssertExt:
313 case AArch64::CBHAssertExt:
344 case AArch64::CBWPri:
345 case AArch64::CBXPri:
346 case AArch64::CBBAssertExt:
347 case AArch64::CBHAssertExt:
348 case AArch64::CBWPrr:
349 case AArch64::CBXPrr:
355 int64_t BrOffset)
const {
357 assert(Bits >= 3 &&
"max branch displacement must be enough to jump"
358 "over conditional branch expansion");
359 return isIntN(Bits, BrOffset / 4);
364 switch (
MI.getOpcode()) {
368 return MI.getOperand(0).getMBB();
373 return MI.getOperand(2).getMBB();
379 return MI.getOperand(1).getMBB();
380 case AArch64::CBWPri:
381 case AArch64::CBXPri:
382 case AArch64::CBBAssertExt:
383 case AArch64::CBHAssertExt:
384 case AArch64::CBWPrr:
385 case AArch64::CBXPrr:
386 return MI.getOperand(3).getMBB();
396 assert(RS &&
"RegScavenger required for long branching");
398 "new block should be inserted for expanding unconditional branch");
401 "restore block should be inserted for restoring clobbered registers");
408 "Branch offsets outside of the signed 33-bit range not supported");
419 RS->enterBasicBlockEnd(
MBB);
422 constexpr Register Reg = AArch64::X16;
423 if (!RS->isRegUsed(Reg)) {
424 insertUnconditionalBranch(
MBB, &NewDestBB,
DL);
435 Register Scavenged = RS->FindUnusedReg(&AArch64::GPR64RegClass);
436 if (Scavenged != AArch64::NoRegister) {
437 buildIndirectBranch(Scavenged, NewDestBB);
438 RS->setRegUsed(Scavenged);
447 "Unable to insert indirect branch inside function that has red zone");
470 bool AllowModify)
const {
477 if (
I->getOpcode() == AArch64::SpeculationBarrierISBDSBEndBB ||
478 I->getOpcode() == AArch64::SpeculationBarrierSBEndBB) {
482 if (!isUnpredicatedTerminator(*
I))
489 unsigned LastOpc = LastInst->
getOpcode();
490 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
505 unsigned SecondLastOpc = SecondLastInst->
getOpcode();
512 LastInst = SecondLastInst;
514 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
519 SecondLastInst = &*
I;
520 SecondLastOpc = SecondLastInst->
getOpcode();
531 LastInst = SecondLastInst;
533 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
535 "unreachable unconditional branches removed above");
544 SecondLastInst = &*
I;
545 SecondLastOpc = SecondLastInst->
getOpcode();
549 if (SecondLastInst &&
I !=
MBB.begin() && isUnpredicatedTerminator(*--
I))
565 I->eraseFromParent();
574 I->eraseFromParent();
583 MachineBranchPredicate &MBP,
584 bool AllowModify)
const {
596 assert(MBP.TrueDest &&
"expected!");
597 MBP.FalseDest = FBB ? FBB :
MBB.getNextNode();
599 MBP.ConditionDef =
nullptr;
600 MBP.SingleUseCondition =
false;
610 if (
I ==
MBB.begin())
626 if (
MI.modifiesRegister(AArch64::NZCV,
nullptr)) {
627 MBP.ConditionDef = &
MI;
636 case AArch64::CBNZX: {
640 MBP.Predicate = (
Opc == AArch64::CBNZX ||
Opc == AArch64::CBNZW)
641 ? MachineBranchPredicate::PRED_NE
642 : MachineBranchPredicate::PRED_EQ;
643 Register CondReg = MBP.LHS.getReg();
652 case AArch64::TBNZX: {
673 Cond[1].setImm(AArch64::CBNZW);
676 Cond[1].setImm(AArch64::CBZW);
679 Cond[1].setImm(AArch64::CBNZX);
682 Cond[1].setImm(AArch64::CBZX);
685 Cond[1].setImm(AArch64::TBNZW);
688 Cond[1].setImm(AArch64::TBZW);
691 Cond[1].setImm(AArch64::TBNZX);
694 Cond[1].setImm(AArch64::TBZX);
698 case AArch64::CBWPri:
699 case AArch64::CBXPri:
700 case AArch64::CBBAssertExt:
701 case AArch64::CBHAssertExt:
702 case AArch64::CBWPrr:
703 case AArch64::CBXPrr: {
716 int *BytesRemoved)
const {
726 I->eraseFromParent();
730 if (
I ==
MBB.begin()) {
743 I->eraseFromParent();
750void AArch64InstrInfo::instantiateCondBranch(
775 if (
Cond.size() > 5) {
786 assert(
TBB &&
"insertBranch must not be told to insert a fallthrough");
813 unsigned Opc =
MI.getOpcode();
820 if (
MI.getOperand(0).getReg() == AArch64::WZR ||
821 MI.getOperand(0).getReg() == AArch64::XZR) {
823 dbgs() <<
"Removing always taken branch: " <<
MI);
826 for (
auto *S : Succs)
828 MBB->removeSuccessor(S);
830 while (
MBB->rbegin() != &
MI)
831 MBB->rbegin()->eraseFromParent();
832 MI.eraseFromParent();
842 if (
MI.getOperand(0).getReg() == AArch64::WZR ||
843 MI.getOperand(0).getReg() == AArch64::XZR) {
845 dbgs() <<
"Removing never taken branch: " <<
MI);
847 MI.getParent()->removeSuccessor(
Target);
848 MI.eraseFromParent();
861 if (!
DefMI->isFullCopy())
863 VReg =
DefMI->getOperand(1).getReg();
872 unsigned *NewReg =
nullptr) {
877 bool Is64Bit = AArch64::GPR64allRegClass.hasSubClassEq(MRI.
getRegClass(VReg));
881 switch (
DefMI->getOpcode()) {
882 case AArch64::SUBREG_TO_REG:
886 if (!
DefMI->getOperand(1).isReg())
888 if (!
DefMI->getOperand(2).isImm() ||
889 DefMI->getOperand(2).getImm() != AArch64::sub_32)
892 if (
DefMI->getOpcode() != AArch64::MOVi32imm)
894 if (!
DefMI->getOperand(1).isImm() ||
DefMI->getOperand(1).getImm() != 1)
897 SrcReg = AArch64::XZR;
898 Opc = AArch64::CSINCXr;
901 case AArch64::MOVi32imm:
902 case AArch64::MOVi64imm:
903 if (!
DefMI->getOperand(1).isImm() ||
DefMI->getOperand(1).getImm() != 1)
905 SrcReg = Is64Bit ? AArch64::XZR : AArch64::WZR;
906 Opc = Is64Bit ? AArch64::CSINCXr : AArch64::CSINCWr;
909 case AArch64::ADDSXri:
910 case AArch64::ADDSWri:
912 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
917 case AArch64::ADDXri:
918 case AArch64::ADDWri:
920 if (!
DefMI->getOperand(2).isImm() ||
DefMI->getOperand(2).getImm() != 1 ||
921 DefMI->getOperand(3).getImm() != 0)
923 SrcReg =
DefMI->getOperand(1).getReg();
924 Opc = Is64Bit ? AArch64::CSINCXr : AArch64::CSINCWr;
927 case AArch64::ORNXrr:
928 case AArch64::ORNWrr: {
931 if (ZReg != AArch64::XZR && ZReg != AArch64::WZR)
933 SrcReg =
DefMI->getOperand(2).getReg();
934 Opc = Is64Bit ? AArch64::CSINVXr : AArch64::CSINVWr;
938 case AArch64::SUBSXrr:
939 case AArch64::SUBSWrr:
941 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
946 case AArch64::SUBXrr:
947 case AArch64::SUBWrr: {
950 if (ZReg != AArch64::XZR && ZReg != AArch64::WZR)
952 SrcReg =
DefMI->getOperand(2).getReg();
953 Opc = Is64Bit ? AArch64::CSNEGXr : AArch64::CSNEGWr;
959 assert(
Opc && SrcReg &&
"Missing parameters");
971 int &FalseCycles)
const {
982 if (!RI.getCommonSubClass(RC, MRI.
getRegClass(DstReg)))
986 unsigned ExtraCondLat =
Cond.size() != 1;
990 if (AArch64::GPR64allRegClass.hasSubClassEq(RC) ||
991 AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
993 CondCycles = 1 + ExtraCondLat;
994 TrueCycles = FalseCycles = 1;
1004 if (AArch64::FPR64RegClass.hasSubClassEq(RC) ||
1005 AArch64::FPR32RegClass.hasSubClassEq(RC)) {
1006 CondCycles = 5 + ExtraCondLat;
1007 TrueCycles = FalseCycles = 2;
1024 switch (
Cond.size()) {
1044 case AArch64::CBNZW:
1048 case AArch64::CBNZX:
1079 case AArch64::TBNZW:
1080 case AArch64::TBNZX:
1102 unsigned SubsOpc, SubsDestReg;
1108 case AArch64::CBWPri:
1109 SubsOpc = AArch64::SUBSWri;
1110 SubsDestReg = AArch64::WZR;
1113 case AArch64::CBXPri:
1114 SubsOpc = AArch64::SUBSXri;
1115 SubsDestReg = AArch64::XZR;
1118 case AArch64::CBWPrr:
1119 SubsOpc = AArch64::SUBSWrr;
1120 SubsDestReg = AArch64::WZR;
1123 case AArch64::CBXPrr:
1124 SubsOpc = AArch64::SUBSXrr;
1125 SubsDestReg = AArch64::XZR;
1154 switch (ExtendType) {
1160 "Unexpected compare-and-branch instruction for SXTB shift-extend");
1161 ExtOpc = AArch64::SBFMWri;
1167 "Unexpected compare-and-branch instruction for SXTH shift-extend");
1168 ExtOpc = AArch64::SBFMWri;
1174 "Unexpected compare-and-branch instruction for UXTB shift-extend");
1175 ExtOpc = AArch64::ANDWri;
1181 "Unexpected compare-and-branch instruction for UXTH shift-extend");
1182 ExtOpc = AArch64::ANDWri;
1191 if (ExtOpc != AArch64::ANDWri)
1193 MBBI.addImm(ExtBits);
1221 bool TryFold =
false;
1223 RC = &AArch64::GPR64RegClass;
1224 Opc = AArch64::CSELXr;
1227 RC = &AArch64::GPR32RegClass;
1228 Opc = AArch64::CSELWr;
1231 RC = &AArch64::FPR64RegClass;
1232 Opc = AArch64::FCSELDrrr;
1234 RC = &AArch64::FPR32RegClass;
1235 Opc = AArch64::FCSELSrrr;
1237 assert(RC &&
"Unsupported regclass");
1241 unsigned NewReg = 0;
1264 (FalseReg.
isVirtual() || FalseReg == AArch64::WZR ||
1265 FalseReg == AArch64::XZR) &&
1266 "FalseReg was folded into a non-virtual register other than WZR or XZR");
1283 assert(BitSize == 64 &&
"Only bit sizes of 32 or 64 allowed");
1288 return Is.
size() <= 2;
1293 assert(
MI.isCopy() &&
"Expected COPY instruction");
1299 if (
Reg.isVirtual())
1301 if (
Reg.isPhysical())
1302 return RI.getMinimalPhysRegClass(
Reg);
1307 if (DstRC && SrcRC && !RI.getCommonSubClass(DstRC, SrcRC))
1310 return MI.isAsCheapAsAMove();
1316 if (Subtarget.hasExynosCheapAsMoveHandling()) {
1317 if (isExynosCheapAsMove(
MI))
1319 return MI.isAsCheapAsAMove();
1322 switch (
MI.getOpcode()) {
1324 return MI.isAsCheapAsAMove();
1326 case TargetOpcode::COPY:
1329 case AArch64::ADDWrs:
1330 case AArch64::ADDXrs:
1331 case AArch64::SUBWrs:
1332 case AArch64::SUBXrs:
1333 return Subtarget.hasALULSLFast() &&
MI.getOperand(3).getImm() <= 4;
1338 case AArch64::MOVi32imm:
1340 case AArch64::MOVi64imm:
1345bool AArch64InstrInfo::isFalkorShiftExtFast(
const MachineInstr &
MI) {
1346 switch (
MI.getOpcode()) {
1350 case AArch64::ADDWrs:
1351 case AArch64::ADDXrs:
1352 case AArch64::ADDSWrs:
1353 case AArch64::ADDSXrs: {
1354 unsigned Imm =
MI.getOperand(3).getImm();
1361 case AArch64::ADDWrx:
1362 case AArch64::ADDXrx:
1363 case AArch64::ADDXrx64:
1364 case AArch64::ADDSWrx:
1365 case AArch64::ADDSXrx:
1366 case AArch64::ADDSXrx64: {
1367 unsigned Imm =
MI.getOperand(3).getImm();
1379 case AArch64::SUBWrs:
1380 case AArch64::SUBSWrs: {
1381 unsigned Imm =
MI.getOperand(3).getImm();
1383 return ShiftVal == 0 ||
1387 case AArch64::SUBXrs:
1388 case AArch64::SUBSXrs: {
1389 unsigned Imm =
MI.getOperand(3).getImm();
1391 return ShiftVal == 0 ||
1395 case AArch64::SUBWrx:
1396 case AArch64::SUBXrx:
1397 case AArch64::SUBXrx64:
1398 case AArch64::SUBSWrx:
1399 case AArch64::SUBSXrx:
1400 case AArch64::SUBSXrx64: {
1401 unsigned Imm =
MI.getOperand(3).getImm();
1413 case AArch64::LDRBBroW:
1414 case AArch64::LDRBBroX:
1415 case AArch64::LDRBroW:
1416 case AArch64::LDRBroX:
1417 case AArch64::LDRDroW:
1418 case AArch64::LDRDroX:
1419 case AArch64::LDRHHroW:
1420 case AArch64::LDRHHroX:
1421 case AArch64::LDRHroW:
1422 case AArch64::LDRHroX:
1423 case AArch64::LDRQroW:
1424 case AArch64::LDRQroX:
1425 case AArch64::LDRSBWroW:
1426 case AArch64::LDRSBWroX:
1427 case AArch64::LDRSBXroW:
1428 case AArch64::LDRSBXroX:
1429 case AArch64::LDRSHWroW:
1430 case AArch64::LDRSHWroX:
1431 case AArch64::LDRSHXroW:
1432 case AArch64::LDRSHXroX:
1433 case AArch64::LDRSWroW:
1434 case AArch64::LDRSWroX:
1435 case AArch64::LDRSroW:
1436 case AArch64::LDRSroX:
1437 case AArch64::LDRWroW:
1438 case AArch64::LDRWroX:
1439 case AArch64::LDRXroW:
1440 case AArch64::LDRXroX:
1441 case AArch64::PRFMroW:
1442 case AArch64::PRFMroX:
1443 case AArch64::STRBBroW:
1444 case AArch64::STRBBroX:
1445 case AArch64::STRBroW:
1446 case AArch64::STRBroX:
1447 case AArch64::STRDroW:
1448 case AArch64::STRDroX:
1449 case AArch64::STRHHroW:
1450 case AArch64::STRHHroX:
1451 case AArch64::STRHroW:
1452 case AArch64::STRHroX:
1453 case AArch64::STRQroW:
1454 case AArch64::STRQroX:
1455 case AArch64::STRSroW:
1456 case AArch64::STRSroX:
1457 case AArch64::STRWroW:
1458 case AArch64::STRWroX:
1459 case AArch64::STRXroW:
1460 case AArch64::STRXroX: {
1461 unsigned IsSigned =
MI.getOperand(3).getImm();
1468 unsigned Opc =
MI.getOpcode();
1472 case AArch64::SEH_StackAlloc:
1473 case AArch64::SEH_SaveFPLR:
1474 case AArch64::SEH_SaveFPLR_X:
1475 case AArch64::SEH_SaveReg:
1476 case AArch64::SEH_SaveReg_X:
1477 case AArch64::SEH_SaveRegP:
1478 case AArch64::SEH_SaveRegP_X:
1479 case AArch64::SEH_SaveFReg:
1480 case AArch64::SEH_SaveFReg_X:
1481 case AArch64::SEH_SaveFRegP:
1482 case AArch64::SEH_SaveFRegP_X:
1483 case AArch64::SEH_SetFP:
1484 case AArch64::SEH_AddFP:
1485 case AArch64::SEH_Nop:
1486 case AArch64::SEH_PrologEnd:
1487 case AArch64::SEH_EpilogStart:
1488 case AArch64::SEH_EpilogEnd:
1489 case AArch64::SEH_PACSignLR:
1490 case AArch64::SEH_SaveAnyRegI:
1491 case AArch64::SEH_SaveAnyRegIP:
1492 case AArch64::SEH_SaveAnyRegQP:
1493 case AArch64::SEH_SaveAnyRegQPX:
1494 case AArch64::SEH_AllocZ:
1495 case AArch64::SEH_SaveZReg:
1496 case AArch64::SEH_SavePReg:
1503 unsigned &SubIdx)
const {
1504 switch (
MI.getOpcode()) {
1507 case AArch64::SBFMXri:
1508 case AArch64::UBFMXri:
1511 if (
MI.getOperand(2).getImm() != 0 ||
MI.getOperand(3).getImm() != 31)
1514 SrcReg =
MI.getOperand(1).getReg();
1515 DstReg =
MI.getOperand(0).getReg();
1516 SubIdx = AArch64::sub_32;
1525 int64_t OffsetA = 0, OffsetB = 0;
1526 TypeSize WidthA(0,
false), WidthB(0,
false);
1527 bool OffsetAIsScalable =
false, OffsetBIsScalable =
false;
1548 OffsetAIsScalable == OffsetBIsScalable) {
1549 int LowOffset = OffsetA < OffsetB ? OffsetA : OffsetB;
1550 int HighOffset = OffsetA < OffsetB ? OffsetB : OffsetA;
1551 TypeSize LowWidth = (LowOffset == OffsetA) ? WidthA : WidthB;
1552 if (LowWidth.
isScalable() == OffsetAIsScalable &&
1570 switch (
MI.getOpcode()) {
1573 if (
MI.getOperand(0).getImm() == 0x14)
1580 case AArch64::MSRpstatesvcrImm1:
1587 auto Next = std::next(
MI.getIterator());
1588 return Next !=
MBB->end() &&
Next->isCFIInstruction();
1595 Register &SrcReg2, int64_t &CmpMask,
1596 int64_t &CmpValue)
const {
1600 assert(
MI.getNumOperands() >= 2 &&
"All AArch64 cmps should have 2 operands");
1601 if (!
MI.getOperand(1).isReg() ||
MI.getOperand(1).getSubReg())
1604 switch (
MI.getOpcode()) {
1607 case AArch64::PTEST_PP:
1608 case AArch64::PTEST_PP_ANY:
1609 case AArch64::PTEST_PP_FIRST:
1610 SrcReg =
MI.getOperand(0).getReg();
1611 SrcReg2 =
MI.getOperand(1).getReg();
1612 if (
MI.getOperand(2).getSubReg())
1619 case AArch64::SUBSWrr:
1620 case AArch64::SUBSWrs:
1621 case AArch64::SUBSWrx:
1622 case AArch64::SUBSXrr:
1623 case AArch64::SUBSXrs:
1624 case AArch64::SUBSXrx:
1625 case AArch64::ADDSWrr:
1626 case AArch64::ADDSWrs:
1627 case AArch64::ADDSWrx:
1628 case AArch64::ADDSXrr:
1629 case AArch64::ADDSXrs:
1630 case AArch64::ADDSXrx:
1632 SrcReg =
MI.getOperand(1).getReg();
1633 SrcReg2 =
MI.getOperand(2).getReg();
1636 if (
MI.getOperand(2).getSubReg())
1642 case AArch64::SUBSWri:
1643 case AArch64::ADDSWri:
1644 case AArch64::SUBSXri:
1645 case AArch64::ADDSXri:
1646 SrcReg =
MI.getOperand(1).getReg();
1649 CmpValue =
MI.getOperand(2).getImm();
1651 case AArch64::ANDSWri:
1652 case AArch64::ANDSXri:
1655 SrcReg =
MI.getOperand(1).getReg();
1659 MI.getOperand(2).getImm(),
1660 MI.getOpcode() == AArch64::ANDSWri ? 32 : 64);
1669 assert(
MBB &&
"Can't get MachineBasicBlock here");
1671 assert(MF &&
"Can't get MachineFunction here");
1676 for (
unsigned OpIdx = 0, EndIdx = Instr.getNumOperands();
OpIdx < EndIdx;
1683 if (!OpRegCstraints)
1691 "Operand has register constraints without being a register!");
1694 if (
Reg.isPhysical()) {
1711 bool MIDefinesZeroReg =
false;
1712 if (
MI.definesRegister(AArch64::WZR,
nullptr) ||
1713 MI.definesRegister(AArch64::XZR,
nullptr))
1714 MIDefinesZeroReg =
true;
1716 switch (
MI.getOpcode()) {
1718 return MI.getOpcode();
1719 case AArch64::ADDSWrr:
1720 return AArch64::ADDWrr;
1721 case AArch64::ADDSWri:
1722 return MIDefinesZeroReg ? AArch64::ADDSWri : AArch64::ADDWri;
1723 case AArch64::ADDSWrs:
1724 return MIDefinesZeroReg ? AArch64::ADDSWrs : AArch64::ADDWrs;
1725 case AArch64::ADDSWrx:
1726 return AArch64::ADDWrx;
1727 case AArch64::ADDSXrr:
1728 return AArch64::ADDXrr;
1729 case AArch64::ADDSXri:
1730 return MIDefinesZeroReg ? AArch64::ADDSXri : AArch64::ADDXri;
1731 case AArch64::ADDSXrs:
1732 return MIDefinesZeroReg ? AArch64::ADDSXrs : AArch64::ADDXrs;
1733 case AArch64::ADDSXrx:
1734 return AArch64::ADDXrx;
1735 case AArch64::SUBSWrr:
1736 return AArch64::SUBWrr;
1737 case AArch64::SUBSWri:
1738 return MIDefinesZeroReg ? AArch64::SUBSWri : AArch64::SUBWri;
1739 case AArch64::SUBSWrs:
1740 return MIDefinesZeroReg ? AArch64::SUBSWrs : AArch64::SUBWrs;
1741 case AArch64::SUBSWrx:
1742 return AArch64::SUBWrx;
1743 case AArch64::SUBSXrr:
1744 return AArch64::SUBXrr;
1745 case AArch64::SUBSXri:
1746 return MIDefinesZeroReg ? AArch64::SUBSXri : AArch64::SUBXri;
1747 case AArch64::SUBSXrs:
1748 return MIDefinesZeroReg ? AArch64::SUBSXrs : AArch64::SUBXrs;
1749 case AArch64::SUBSXrx:
1750 return AArch64::SUBXrx;
1765 if (To == To->getParent()->begin())
1770 if (To->getParent() != From->getParent())
1782 Instr.modifiesRegister(AArch64::NZCV,
TRI)) ||
1783 ((AccessToCheck &
AK_Read) && Instr.readsRegister(AArch64::NZCV,
TRI)))
1789std::optional<unsigned>
1793 unsigned MaskOpcode =
Mask->getOpcode();
1794 unsigned PredOpcode = Pred->
getOpcode();
1795 bool PredIsPTestLike = isPTestLikeOpcode(PredOpcode);
1796 bool PredIsWhileLike = isWhileOpcode(PredOpcode);
1798 if (PredIsWhileLike) {
1802 if ((Mask == Pred) && PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1809 getElementSizeForOpcode(MaskOpcode) ==
1810 getElementSizeForOpcode(PredOpcode))
1816 if (PTest->
getOpcode() == AArch64::PTEST_PP_FIRST &&
1823 if (PredIsPTestLike) {
1828 if ((Mask == Pred) && PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1836 if (Mask != PTestLikeMask && PTestLikeMask->isFullCopy() &&
1837 PTestLikeMask->getOperand(1).getReg().isVirtual())
1845 getElementSizeForOpcode(MaskOpcode) ==
1846 getElementSizeForOpcode(PredOpcode)) {
1847 if (Mask == PTestLikeMask || PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1873 uint64_t PredElementSize = getElementSizeForOpcode(PredOpcode);
1875 PTest->
getOpcode() == AArch64::PTEST_PP_ANY))
1883 switch (PredOpcode) {
1884 case AArch64::AND_PPzPP:
1885 case AArch64::BIC_PPzPP:
1886 case AArch64::EOR_PPzPP:
1887 case AArch64::NAND_PPzPP:
1888 case AArch64::NOR_PPzPP:
1889 case AArch64::ORN_PPzPP:
1890 case AArch64::ORR_PPzPP:
1891 case AArch64::BRKA_PPzP:
1892 case AArch64::BRKPA_PPzPP:
1893 case AArch64::BRKB_PPzP:
1894 case AArch64::BRKPB_PPzPP:
1895 case AArch64::RDFFR_PPz: {
1899 if (Mask != PredMask)
1903 case AArch64::BRKN_PPzP: {
1907 if ((MaskOpcode != AArch64::PTRUE_B) ||
1908 (
Mask->getOperand(1).getImm() != 31))
1912 case AArch64::PTRUE_B:
1925bool AArch64InstrInfo::optimizePTestInstr(
1926 MachineInstr *PTest,
unsigned MaskReg,
unsigned PredReg,
1931 if (Pred->
isCopy() && PTest->
getOpcode() == AArch64::PTEST_PP_FIRST) {
1935 if (
Op.isReg() &&
Op.getReg().isVirtual() &&
1936 Op.getSubReg() == AArch64::psub0)
1940 unsigned PredOpcode = Pred->
getOpcode();
1941 auto NewOp = canRemovePTestInstr(PTest, Mask, Pred, MRI);
1957 if (*NewOp != PredOpcode) {
1968 for (; i !=
e; ++i) {
1999 if (DeadNZCVIdx != -1) {
2018 if (CmpInstr.
getOpcode() == AArch64::PTEST_PP ||
2019 CmpInstr.
getOpcode() == AArch64::PTEST_PP_ANY ||
2020 CmpInstr.
getOpcode() == AArch64::PTEST_PP_FIRST)
2021 return optimizePTestInstr(&CmpInstr, SrcReg, SrcReg2, MRI);
2030 if (CmpValue == 0 && substituteCmpToZero(CmpInstr, SrcReg, *MRI))
2032 return (CmpValue == 0 || CmpValue == 1) &&
2033 removeCmpToZeroOrOne(CmpInstr, SrcReg, CmpValue, *MRI);
2041 switch (Instr.getOpcode()) {
2043 return AArch64::INSTRUCTION_LIST_END;
2045 case AArch64::ADDSWrr:
2046 case AArch64::ADDSWri:
2047 case AArch64::ADDSXrr:
2048 case AArch64::ADDSXri:
2049 case AArch64::ADDSWrx:
2050 case AArch64::ADDSXrx:
2051 case AArch64::SUBSWrr:
2052 case AArch64::SUBSWri:
2053 case AArch64::SUBSWrx:
2054 case AArch64::SUBSXrr:
2055 case AArch64::SUBSXri:
2056 case AArch64::SUBSXrx:
2057 case AArch64::ANDSWri:
2058 case AArch64::ANDSWrr:
2059 case AArch64::ANDSWrs:
2060 case AArch64::ANDSXri:
2061 case AArch64::ANDSXrr:
2062 case AArch64::ANDSXrs:
2063 case AArch64::BICSWrr:
2064 case AArch64::BICSXrr:
2065 case AArch64::BICSWrs:
2066 case AArch64::BICSXrs:
2067 return Instr.getOpcode();
2069 case AArch64::ADDWrr:
2070 return AArch64::ADDSWrr;
2071 case AArch64::ADDWri:
2072 return AArch64::ADDSWri;
2073 case AArch64::ADDXrr:
2074 return AArch64::ADDSXrr;
2075 case AArch64::ADDXri:
2076 return AArch64::ADDSXri;
2077 case AArch64::ADDWrx:
2078 return AArch64::ADDSWrx;
2079 case AArch64::ADDXrx:
2080 return AArch64::ADDSXrx;
2081 case AArch64::ADCWr:
2082 return AArch64::ADCSWr;
2083 case AArch64::ADCXr:
2084 return AArch64::ADCSXr;
2085 case AArch64::SUBWrr:
2086 return AArch64::SUBSWrr;
2087 case AArch64::SUBWri:
2088 return AArch64::SUBSWri;
2089 case AArch64::SUBXrr:
2090 return AArch64::SUBSXrr;
2091 case AArch64::SUBXri:
2092 return AArch64::SUBSXri;
2093 case AArch64::SUBWrx:
2094 return AArch64::SUBSWrx;
2095 case AArch64::SUBXrx:
2096 return AArch64::SUBSXrx;
2097 case AArch64::SBCWr:
2098 return AArch64::SBCSWr;
2099 case AArch64::SBCXr:
2100 return AArch64::SBCSXr;
2101 case AArch64::ANDWri:
2102 return AArch64::ANDSWri;
2103 case AArch64::ANDXri:
2104 return AArch64::ANDSXri;
2105 case AArch64::ANDWrr:
2106 return AArch64::ANDSWrr;
2107 case AArch64::ANDWrs:
2108 return AArch64::ANDSWrs;
2109 case AArch64::ANDXrr:
2110 return AArch64::ANDSXrr;
2111 case AArch64::ANDXrs:
2112 return AArch64::ANDSXrs;
2113 case AArch64::BICWrr:
2114 return AArch64::BICSWrr;
2115 case AArch64::BICXrr:
2116 return AArch64::BICSXrr;
2117 case AArch64::BICWrs:
2118 return AArch64::BICSWrs;
2119 case AArch64::BICXrs:
2120 return AArch64::BICSXrs;
2126 for (
auto *BB :
MBB->successors())
2127 if (BB->isLiveIn(AArch64::NZCV))
2134int AArch64InstrInfo::findCondCodeUseOperandIdxForBranchOrSelect(
2136 switch (
Instr.getOpcode()) {
2140 case AArch64::Bcc: {
2141 int Idx =
Instr.findRegisterUseOperandIdx(AArch64::NZCV,
nullptr);
2146 case AArch64::CSINVWr:
2147 case AArch64::CSINVXr:
2148 case AArch64::CSINCWr:
2149 case AArch64::CSINCXr:
2150 case AArch64::CSELWr:
2151 case AArch64::CSELXr:
2152 case AArch64::CSNEGWr:
2153 case AArch64::CSNEGXr:
2154 case AArch64::FCSELSrrr:
2155 case AArch64::FCSELDrrr: {
2156 int Idx =
Instr.findRegisterUseOperandIdx(AArch64::NZCV,
nullptr);
2168 AArch64InstrInfo::findCondCodeUseOperandIdxForBranchOrSelect(Instr);
2170 Instr.getOperand(CCIdx).
getImm())
2223std::optional<UsedNZCV>
2228 if (
MI.getParent() != CmpParent)
2229 return std::nullopt;
2232 return std::nullopt;
2237 if (Instr.readsRegister(AArch64::NZCV, &
TRI)) {
2240 return std::nullopt;
2245 if (Instr.modifiesRegister(AArch64::NZCV, &
TRI))
2248 return NZCVUsedAfterCmp;
2252 return Opcode == AArch64::ADDSWri || Opcode == AArch64::ADDSXri;
2256 return Opcode == AArch64::SUBSWri || Opcode == AArch64::SUBSXri;
2262 case AArch64::ANDSWri:
2263 case AArch64::ANDSWrr:
2264 case AArch64::ANDSWrs:
2265 case AArch64::ANDSXri:
2266 case AArch64::ANDSXrr:
2267 case AArch64::ANDSXrs:
2268 case AArch64::BICSWrr:
2269 case AArch64::BICSXrr:
2270 case AArch64::BICSWrs:
2271 case AArch64::BICSXrs:
2297 const unsigned CmpOpcode = CmpInstr.
getOpcode();
2303 "Caller guarantees that CmpInstr compares with constant 0");
2306 if (!NZVCUsed || NZVCUsed->C)
2329bool AArch64InstrInfo::substituteCmpToZero(
2340 if (NewOpc == AArch64::INSTRUCTION_LIST_END)
2347 MI->setDesc(
get(NewOpc));
2352 MI->addRegisterDefined(AArch64::NZCV, &
TRI);
2364 assert((CmpValue == 0 || CmpValue == 1) &&
2365 "Only comparisons to 0 or 1 considered for removal!");
2368 unsigned MIOpc =
MI.getOpcode();
2369 if (MIOpc == AArch64::CSINCWr) {
2370 if (
MI.getOperand(1).getReg() != AArch64::WZR ||
2371 MI.getOperand(2).getReg() != AArch64::WZR)
2373 }
else if (MIOpc == AArch64::CSINCXr) {
2374 if (
MI.getOperand(1).getReg() != AArch64::XZR ||
2375 MI.getOperand(2).getReg() != AArch64::XZR)
2385 if (
MI.findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
true) != -1)
2389 const unsigned CmpOpcode = CmpInstr.
getOpcode();
2391 if (CmpValue && !IsSubsRegImm)
2393 if (!CmpValue && !IsSubsRegImm && !
isADDSRegImm(CmpOpcode))
2398 if (MIUsedNZCV.
C || MIUsedNZCV.
V)
2401 std::optional<UsedNZCV> NZCVUsedAfterCmp =
2405 if (!NZCVUsedAfterCmp || NZCVUsedAfterCmp->C || NZCVUsedAfterCmp->V)
2408 if ((MIUsedNZCV.
Z && NZCVUsedAfterCmp->N) ||
2409 (MIUsedNZCV.
N && NZCVUsedAfterCmp->Z))
2412 if (MIUsedNZCV.
N && !CmpValue)
2454bool AArch64InstrInfo::removeCmpToZeroOrOne(
2461 SmallVector<MachineInstr *, 4> CCUseInstrs;
2462 bool IsInvertCC =
false;
2470 for (MachineInstr *CCUseInstr : CCUseInstrs) {
2471 int Idx = findCondCodeUseOperandIdxForBranchOrSelect(*CCUseInstr);
2472 assert(Idx >= 0 &&
"Unexpected instruction using CC.");
2473 MachineOperand &CCOperand = CCUseInstr->getOperand(Idx);
2482bool AArch64InstrInfo::expandPostRAPseudo(
MachineInstr &
MI)
const {
2483 if (
MI.getOpcode() != TargetOpcode::LOAD_STACK_GUARD &&
2484 MI.getOpcode() != AArch64::CATCHRET)
2487 MachineBasicBlock &
MBB = *
MI.getParent();
2489 auto TRI = Subtarget.getRegisterInfo();
2492 if (
MI.getOpcode() == AArch64::CATCHRET) {
2494 const TargetInstrInfo *
TII =
2496 MachineBasicBlock *TargetMBB =
MI.getOperand(0).getMBB();
2501 FirstEpilogSEH = std::prev(FirstEpilogSEH);
2503 FirstEpilogSEH = std::next(FirstEpilogSEH);
2518 if (
M.getStackProtectorGuard() ==
"sysreg") {
2519 const AArch64SysReg::SysReg *SrcReg =
2520 AArch64SysReg::lookupSysRegByName(
M.getStackProtectorGuardReg());
2528 int Offset =
M.getStackProtectorGuardOffset();
2579 const GlobalValue *GV =
2582 unsigned OpFlags = Subtarget.ClassifyGlobalReference(GV, TM);
2585 unsigned GuardWidth =
M.getStackProtectorGuardValueWidth().value_or(
2586 Subtarget.isTargetILP32() ? 4 : 8);
2587 if (GuardWidth != 4 && GuardWidth != 8)
2592 if (GuardWidth == 4) {
2593 unsigned Reg32 =
TRI->getSubReg(
Reg, AArch64::sub_32);
2607 if (GuardWidth == 4)
2641 if (GuardWidth == 4) {
2642 unsigned Reg32 =
TRI->getSubReg(
Reg, AArch64::sub_32);
2665 switch (
MI.getOpcode()) {
2668 case AArch64::MOVZWi:
2669 case AArch64::MOVZXi:
2670 if (
MI.getOperand(1).isImm() &&
MI.getOperand(1).getImm() == 0) {
2671 assert(
MI.getDesc().getNumOperands() == 3 &&
2672 MI.getOperand(2).getImm() == 0 &&
"invalid MOVZi operands");
2676 case AArch64::ANDWri:
2677 return MI.getOperand(1).getReg() == AArch64::WZR;
2678 case AArch64::ANDXri:
2679 return MI.getOperand(1).getReg() == AArch64::XZR;
2680 case TargetOpcode::COPY:
2681 return MI.getOperand(1).getReg() == AArch64::WZR;
2689 switch (
MI.getOpcode()) {
2692 case TargetOpcode::COPY: {
2695 return (AArch64::GPR32RegClass.
contains(DstReg) ||
2696 AArch64::GPR64RegClass.
contains(DstReg));
2698 case AArch64::ORRXrs:
2699 if (
MI.getOperand(1).getReg() == AArch64::XZR) {
2700 assert(
MI.getDesc().getNumOperands() == 4 &&
2701 MI.getOperand(3).getImm() == 0 &&
"invalid ORRrs operands");
2705 case AArch64::ADDXri:
2706 if (
MI.getOperand(2).getImm() == 0) {
2707 assert(
MI.getDesc().getNumOperands() == 4 &&
2708 MI.getOperand(3).getImm() == 0 &&
"invalid ADDXri operands");
2719 switch (
MI.getOpcode()) {
2722 case TargetOpcode::COPY: {
2724 return AArch64::FPR128RegClass.contains(DstReg);
2726 case AArch64::ORRv16i8:
2727 if (
MI.getOperand(1).getReg() ==
MI.getOperand(2).getReg()) {
2728 assert(
MI.getDesc().getNumOperands() == 3 &&
MI.getOperand(0).isReg() &&
2729 "invalid ORRv16i8 operands");
2741 case AArch64::LDRWui:
2742 case AArch64::LDRXui:
2743 case AArch64::LDRBui:
2744 case AArch64::LDRHui:
2745 case AArch64::LDRSui:
2746 case AArch64::LDRDui:
2747 case AArch64::LDRQui:
2748 case AArch64::LDR_PXI:
2754 int &FrameIndex)
const {
2758 if (
MI.getOperand(0).getSubReg() == 0 &&
MI.getOperand(1).isFI() &&
2759 MI.getOperand(2).isImm() &&
MI.getOperand(2).getImm() == 0) {
2760 FrameIndex =
MI.getOperand(1).getIndex();
2761 return MI.getOperand(0).getReg();
2770 case AArch64::STRWui:
2771 case AArch64::STRXui:
2772 case AArch64::STRBui:
2773 case AArch64::STRHui:
2774 case AArch64::STRSui:
2775 case AArch64::STRDui:
2776 case AArch64::STRQui:
2777 case AArch64::STR_PXI:
2783 int &FrameIndex)
const {
2787 if (
MI.getOperand(0).getSubReg() == 0 &&
MI.getOperand(1).isFI() &&
2788 MI.getOperand(2).isImm() &&
MI.getOperand(2).getImm() == 0) {
2789 FrameIndex =
MI.getOperand(1).getIndex();
2790 return MI.getOperand(0).getReg();
2796 int &FrameIndex)
const {
2811 return MI.getOperand(0).getReg();
2817 int &FrameIndex)
const {
2832 return MI.getOperand(0).getReg();
2840 return MMO->getFlags() & MOSuppressPair;
2846 if (
MI.memoperands_empty())
2854 return MMO->getFlags() & MOStridedAccess;
2862 case AArch64::STURSi:
2863 case AArch64::STRSpre:
2864 case AArch64::STURDi:
2865 case AArch64::STRDpre:
2866 case AArch64::STURQi:
2867 case AArch64::STRQpre:
2868 case AArch64::STURBBi:
2869 case AArch64::STURHHi:
2870 case AArch64::STURWi:
2871 case AArch64::STRWpre:
2872 case AArch64::STURXi:
2873 case AArch64::STRXpre:
2874 case AArch64::LDURSi:
2875 case AArch64::LDRSpre:
2876 case AArch64::LDURDi:
2877 case AArch64::LDRDpre:
2878 case AArch64::LDURQi:
2879 case AArch64::LDRQpre:
2880 case AArch64::LDURWi:
2881 case AArch64::LDRWpre:
2882 case AArch64::LDURXi:
2883 case AArch64::LDRXpre:
2884 case AArch64::LDRSWpre:
2885 case AArch64::LDURSWi:
2886 case AArch64::LDURHHi:
2887 case AArch64::LDURBBi:
2888 case AArch64::LDURSBWi:
2889 case AArch64::LDURSHWi:
2897 case AArch64::PRFMui:
return AArch64::PRFUMi;
2898 case AArch64::LDRXui:
return AArch64::LDURXi;
2899 case AArch64::LDRWui:
return AArch64::LDURWi;
2900 case AArch64::LDRBui:
return AArch64::LDURBi;
2901 case AArch64::LDRHui:
return AArch64::LDURHi;
2902 case AArch64::LDRSui:
return AArch64::LDURSi;
2903 case AArch64::LDRDui:
return AArch64::LDURDi;
2904 case AArch64::LDRQui:
return AArch64::LDURQi;
2905 case AArch64::LDRBBui:
return AArch64::LDURBBi;
2906 case AArch64::LDRHHui:
return AArch64::LDURHHi;
2907 case AArch64::LDRSBXui:
return AArch64::LDURSBXi;
2908 case AArch64::LDRSBWui:
return AArch64::LDURSBWi;
2909 case AArch64::LDRSHXui:
return AArch64::LDURSHXi;
2910 case AArch64::LDRSHWui:
return AArch64::LDURSHWi;
2911 case AArch64::LDRSWui:
return AArch64::LDURSWi;
2912 case AArch64::STRXui:
return AArch64::STURXi;
2913 case AArch64::STRWui:
return AArch64::STURWi;
2914 case AArch64::STRBui:
return AArch64::STURBi;
2915 case AArch64::STRHui:
return AArch64::STURHi;
2916 case AArch64::STRSui:
return AArch64::STURSi;
2917 case AArch64::STRDui:
return AArch64::STURDi;
2918 case AArch64::STRQui:
return AArch64::STURQi;
2919 case AArch64::STRBBui:
return AArch64::STURBBi;
2920 case AArch64::STRHHui:
return AArch64::STURHHi;
2929 case AArch64::LDAPURBi:
2930 case AArch64::LDAPURHi:
2931 case AArch64::LDAPURi:
2932 case AArch64::LDAPURSBWi:
2933 case AArch64::LDAPURSBXi:
2934 case AArch64::LDAPURSHWi:
2935 case AArch64::LDAPURSHXi:
2936 case AArch64::LDAPURSWi:
2937 case AArch64::LDAPURXi:
2938 case AArch64::LDR_PPXI:
2939 case AArch64::LDR_PXI:
2940 case AArch64::LDR_ZXI:
2941 case AArch64::LDR_ZZXI:
2942 case AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS:
2943 case AArch64::LDR_ZZZXI:
2944 case AArch64::LDR_ZZZZXI:
2945 case AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS:
2946 case AArch64::LDRBBui:
2947 case AArch64::LDRBui:
2948 case AArch64::LDRDui:
2949 case AArch64::LDRHHui:
2950 case AArch64::LDRHui:
2951 case AArch64::LDRQui:
2952 case AArch64::LDRSBWui:
2953 case AArch64::LDRSBXui:
2954 case AArch64::LDRSHWui:
2955 case AArch64::LDRSHXui:
2956 case AArch64::LDRSui:
2957 case AArch64::LDRSWui:
2958 case AArch64::LDRWui:
2959 case AArch64::LDRXui:
2960 case AArch64::LDURBBi:
2961 case AArch64::LDURBi:
2962 case AArch64::LDURDi:
2963 case AArch64::LDURHHi:
2964 case AArch64::LDURHi:
2965 case AArch64::LDURQi:
2966 case AArch64::LDURSBWi:
2967 case AArch64::LDURSBXi:
2968 case AArch64::LDURSHWi:
2969 case AArch64::LDURSHXi:
2970 case AArch64::LDURSi:
2971 case AArch64::LDURSWi:
2972 case AArch64::LDURWi:
2973 case AArch64::LDURXi:
2974 case AArch64::PRFMui:
2975 case AArch64::PRFUMi:
2976 case AArch64::ST2Gi:
2978 case AArch64::STLURBi:
2979 case AArch64::STLURHi:
2980 case AArch64::STLURWi:
2981 case AArch64::STLURXi:
2982 case AArch64::StoreSwiftAsyncContext:
2983 case AArch64::STR_PPXI:
2984 case AArch64::STR_PXI:
2985 case AArch64::STR_ZXI:
2986 case AArch64::STR_ZZXI:
2987 case AArch64::STR_ZZXI_STRIDED_CONTIGUOUS:
2988 case AArch64::STR_ZZZXI:
2989 case AArch64::STR_ZZZZXI:
2990 case AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS:
2991 case AArch64::STRBBui:
2992 case AArch64::STRBui:
2993 case AArch64::STRDui:
2994 case AArch64::STRHHui:
2995 case AArch64::STRHui:
2996 case AArch64::STRQui:
2997 case AArch64::STRSui:
2998 case AArch64::STRWui:
2999 case AArch64::STRXui:
3000 case AArch64::STURBBi:
3001 case AArch64::STURBi:
3002 case AArch64::STURDi:
3003 case AArch64::STURHHi:
3004 case AArch64::STURHi:
3005 case AArch64::STURQi:
3006 case AArch64::STURSi:
3007 case AArch64::STURWi:
3008 case AArch64::STURXi:
3009 case AArch64::STZ2Gi:
3010 case AArch64::STZGi:
3011 case AArch64::TAGPstack:
3013 case AArch64::LD1B_D_IMM:
3014 case AArch64::LD1B_H_IMM:
3015 case AArch64::LD1B_IMM:
3016 case AArch64::LD1B_S_IMM:
3017 case AArch64::LD1D_IMM:
3018 case AArch64::LD1H_D_IMM:
3019 case AArch64::LD1H_IMM:
3020 case AArch64::LD1H_S_IMM:
3021 case AArch64::LD1RB_D_IMM:
3022 case AArch64::LD1RB_H_IMM:
3023 case AArch64::LD1RB_IMM:
3024 case AArch64::LD1RB_S_IMM:
3025 case AArch64::LD1RD_IMM:
3026 case AArch64::LD1RH_D_IMM:
3027 case AArch64::LD1RH_IMM:
3028 case AArch64::LD1RH_S_IMM:
3029 case AArch64::LD1RSB_D_IMM:
3030 case AArch64::LD1RSB_H_IMM:
3031 case AArch64::LD1RSB_S_IMM:
3032 case AArch64::LD1RSH_D_IMM:
3033 case AArch64::LD1RSH_S_IMM:
3034 case AArch64::LD1RSW_IMM:
3035 case AArch64::LD1RW_D_IMM:
3036 case AArch64::LD1RW_IMM:
3037 case AArch64::LD1SB_D_IMM:
3038 case AArch64::LD1SB_H_IMM:
3039 case AArch64::LD1SB_S_IMM:
3040 case AArch64::LD1SH_D_IMM:
3041 case AArch64::LD1SH_S_IMM:
3042 case AArch64::LD1SW_D_IMM:
3043 case AArch64::LD1W_D_IMM:
3044 case AArch64::LD1W_IMM:
3045 case AArch64::LD2B_IMM:
3046 case AArch64::LD2D_IMM:
3047 case AArch64::LD2H_IMM:
3048 case AArch64::LD2W_IMM:
3049 case AArch64::LD3B_IMM:
3050 case AArch64::LD3D_IMM:
3051 case AArch64::LD3H_IMM:
3052 case AArch64::LD3W_IMM:
3053 case AArch64::LD4B_IMM:
3054 case AArch64::LD4D_IMM:
3055 case AArch64::LD4H_IMM:
3056 case AArch64::LD4W_IMM:
3058 case AArch64::LDNF1B_D_IMM:
3059 case AArch64::LDNF1B_H_IMM:
3060 case AArch64::LDNF1B_IMM:
3061 case AArch64::LDNF1B_S_IMM:
3062 case AArch64::LDNF1D_IMM:
3063 case AArch64::LDNF1H_D_IMM:
3064 case AArch64::LDNF1H_IMM:
3065 case AArch64::LDNF1H_S_IMM:
3066 case AArch64::LDNF1SB_D_IMM:
3067 case AArch64::LDNF1SB_H_IMM:
3068 case AArch64::LDNF1SB_S_IMM:
3069 case AArch64::LDNF1SH_D_IMM:
3070 case AArch64::LDNF1SH_S_IMM:
3071 case AArch64::LDNF1SW_D_IMM:
3072 case AArch64::LDNF1W_D_IMM:
3073 case AArch64::LDNF1W_IMM:
3074 case AArch64::LDNPDi:
3075 case AArch64::LDNPQi:
3076 case AArch64::LDNPSi:
3077 case AArch64::LDNPWi:
3078 case AArch64::LDNPXi:
3079 case AArch64::LDNT1B_ZRI:
3080 case AArch64::LDNT1D_ZRI:
3081 case AArch64::LDNT1H_ZRI:
3082 case AArch64::LDNT1W_ZRI:
3083 case AArch64::LDPDi:
3084 case AArch64::LDPQi:
3085 case AArch64::LDPSi:
3086 case AArch64::LDPWi:
3087 case AArch64::LDPXi:
3088 case AArch64::LDRBBpost:
3089 case AArch64::LDRBBpre:
3090 case AArch64::LDRBpost:
3091 case AArch64::LDRBpre:
3092 case AArch64::LDRDpost:
3093 case AArch64::LDRDpre:
3094 case AArch64::LDRHHpost:
3095 case AArch64::LDRHHpre:
3096 case AArch64::LDRHpost:
3097 case AArch64::LDRHpre:
3098 case AArch64::LDRQpost:
3099 case AArch64::LDRQpre:
3100 case AArch64::LDRSpost:
3101 case AArch64::LDRSpre:
3102 case AArch64::LDRWpost:
3103 case AArch64::LDRWpre:
3104 case AArch64::LDRXpost:
3105 case AArch64::LDRXpre:
3106 case AArch64::ST1B_D_IMM:
3107 case AArch64::ST1B_H_IMM:
3108 case AArch64::ST1B_IMM:
3109 case AArch64::ST1B_S_IMM:
3110 case AArch64::ST1D_IMM:
3111 case AArch64::ST1H_D_IMM:
3112 case AArch64::ST1H_IMM:
3113 case AArch64::ST1H_S_IMM:
3114 case AArch64::ST1W_D_IMM:
3115 case AArch64::ST1W_IMM:
3116 case AArch64::ST2B_IMM:
3117 case AArch64::ST2D_IMM:
3118 case AArch64::ST2H_IMM:
3119 case AArch64::ST2W_IMM:
3120 case AArch64::ST3B_IMM:
3121 case AArch64::ST3D_IMM:
3122 case AArch64::ST3H_IMM:
3123 case AArch64::ST3W_IMM:
3124 case AArch64::ST4B_IMM:
3125 case AArch64::ST4D_IMM:
3126 case AArch64::ST4H_IMM:
3127 case AArch64::ST4W_IMM:
3128 case AArch64::STGPi:
3129 case AArch64::STGPreIndex:
3130 case AArch64::STZGPreIndex:
3131 case AArch64::ST2GPreIndex:
3132 case AArch64::STZ2GPreIndex:
3133 case AArch64::STGPostIndex:
3134 case AArch64::STZGPostIndex:
3135 case AArch64::ST2GPostIndex:
3136 case AArch64::STZ2GPostIndex:
3137 case AArch64::STNPDi:
3138 case AArch64::STNPQi:
3139 case AArch64::STNPSi:
3140 case AArch64::STNPWi:
3141 case AArch64::STNPXi:
3142 case AArch64::STNT1B_ZRI:
3143 case AArch64::STNT1D_ZRI:
3144 case AArch64::STNT1H_ZRI:
3145 case AArch64::STNT1W_ZRI:
3146 case AArch64::STPDi:
3147 case AArch64::STPQi:
3148 case AArch64::STPSi:
3149 case AArch64::STPWi:
3150 case AArch64::STPXi:
3151 case AArch64::STRBBpost:
3152 case AArch64::STRBBpre:
3153 case AArch64::STRBpost:
3154 case AArch64::STRBpre:
3155 case AArch64::STRDpost:
3156 case AArch64::STRDpre:
3157 case AArch64::STRHHpost:
3158 case AArch64::STRHHpre:
3159 case AArch64::STRHpost:
3160 case AArch64::STRHpre:
3161 case AArch64::STRQpost:
3162 case AArch64::STRQpre:
3163 case AArch64::STRSpost:
3164 case AArch64::STRSpre:
3165 case AArch64::STRWpost:
3166 case AArch64::STRWpre:
3167 case AArch64::STRXpost:
3168 case AArch64::STRXpre:
3170 case AArch64::LDPDpost:
3171 case AArch64::LDPDpre:
3172 case AArch64::LDPQpost:
3173 case AArch64::LDPQpre:
3174 case AArch64::LDPSpost:
3175 case AArch64::LDPSpre:
3176 case AArch64::LDPWpost:
3177 case AArch64::LDPWpre:
3178 case AArch64::LDPXpost:
3179 case AArch64::LDPXpre:
3180 case AArch64::STGPpre:
3181 case AArch64::STGPpost:
3182 case AArch64::STPDpost:
3183 case AArch64::STPDpre:
3184 case AArch64::STPQpost:
3185 case AArch64::STPQpre:
3186 case AArch64::STPSpost:
3187 case AArch64::STPSpre:
3188 case AArch64::STPWpost:
3189 case AArch64::STPWpre:
3190 case AArch64::STPXpost:
3191 case AArch64::STPXpre:
3197 switch (
MI.getOpcode()) {
3201 case AArch64::STRSui:
3202 case AArch64::STRDui:
3203 case AArch64::STRQui:
3204 case AArch64::STRXui:
3205 case AArch64::STRWui:
3206 case AArch64::LDRSui:
3207 case AArch64::LDRDui:
3208 case AArch64::LDRQui:
3209 case AArch64::LDRXui:
3210 case AArch64::LDRWui:
3211 case AArch64::LDRSWui:
3213 case AArch64::STURSi:
3214 case AArch64::STRSpre:
3215 case AArch64::STURDi:
3216 case AArch64::STRDpre:
3217 case AArch64::STURQi:
3218 case AArch64::STRQpre:
3219 case AArch64::STURWi:
3220 case AArch64::STRWpre:
3221 case AArch64::STURXi:
3222 case AArch64::STRXpre:
3223 case AArch64::LDURSi:
3224 case AArch64::LDRSpre:
3225 case AArch64::LDURDi:
3226 case AArch64::LDRDpre:
3227 case AArch64::LDURQi:
3228 case AArch64::LDRQpre:
3229 case AArch64::LDURWi:
3230 case AArch64::LDRWpre:
3231 case AArch64::LDURXi:
3232 case AArch64::LDRXpre:
3233 case AArch64::LDURSWi:
3234 case AArch64::LDRSWpre:
3236 case AArch64::LDR_ZXI:
3237 case AArch64::STR_ZXI:
3243 switch (
MI.getOpcode()) {
3246 "Unexpected instruction - was a new tail call opcode introduced?");
3248 case AArch64::TCRETURNdi:
3249 case AArch64::TCRETURNri:
3250 case AArch64::TCRETURNrix16x17:
3251 case AArch64::TCRETURNrix17:
3252 case AArch64::TCRETURNrinotx16:
3253 case AArch64::TCRETURNriALL:
3254 case AArch64::AUTH_TCRETURN:
3255 case AArch64::AUTH_TCRETURN_BTI:
3265 case AArch64::ADDWri:
3266 return AArch64::ADDSWri;
3267 case AArch64::ADDWrr:
3268 return AArch64::ADDSWrr;
3269 case AArch64::ADDWrs:
3270 return AArch64::ADDSWrs;
3271 case AArch64::ADDWrx:
3272 return AArch64::ADDSWrx;
3273 case AArch64::ANDWri:
3274 return AArch64::ANDSWri;
3275 case AArch64::ANDWrr:
3276 return AArch64::ANDSWrr;
3277 case AArch64::ANDWrs:
3278 return AArch64::ANDSWrs;
3279 case AArch64::BICWrr:
3280 return AArch64::BICSWrr;
3281 case AArch64::BICWrs:
3282 return AArch64::BICSWrs;
3283 case AArch64::SUBWri:
3284 return AArch64::SUBSWri;
3285 case AArch64::SUBWrr:
3286 return AArch64::SUBSWrr;
3287 case AArch64::SUBWrs:
3288 return AArch64::SUBSWrs;
3289 case AArch64::SUBWrx:
3290 return AArch64::SUBSWrx;
3292 case AArch64::ADDXri:
3293 return AArch64::ADDSXri;
3294 case AArch64::ADDXrr:
3295 return AArch64::ADDSXrr;
3296 case AArch64::ADDXrs:
3297 return AArch64::ADDSXrs;
3298 case AArch64::ADDXrx:
3299 return AArch64::ADDSXrx;
3300 case AArch64::ANDXri:
3301 return AArch64::ANDSXri;
3302 case AArch64::ANDXrr:
3303 return AArch64::ANDSXrr;
3304 case AArch64::ANDXrs:
3305 return AArch64::ANDSXrs;
3306 case AArch64::BICXrr:
3307 return AArch64::BICSXrr;
3308 case AArch64::BICXrs:
3309 return AArch64::BICSXrs;
3310 case AArch64::SUBXri:
3311 return AArch64::SUBSXri;
3312 case AArch64::SUBXrr:
3313 return AArch64::SUBSXrr;
3314 case AArch64::SUBXrs:
3315 return AArch64::SUBSXrs;
3316 case AArch64::SUBXrx:
3317 return AArch64::SUBSXrx;
3319 case AArch64::AND_PPzPP:
3320 return AArch64::ANDS_PPzPP;
3321 case AArch64::BIC_PPzPP:
3322 return AArch64::BICS_PPzPP;
3323 case AArch64::EOR_PPzPP:
3324 return AArch64::EORS_PPzPP;
3325 case AArch64::NAND_PPzPP:
3326 return AArch64::NANDS_PPzPP;
3327 case AArch64::NOR_PPzPP:
3328 return AArch64::NORS_PPzPP;
3329 case AArch64::ORN_PPzPP:
3330 return AArch64::ORNS_PPzPP;
3331 case AArch64::ORR_PPzPP:
3332 return AArch64::ORRS_PPzPP;
3333 case AArch64::BRKA_PPzP:
3334 return AArch64::BRKAS_PPzP;
3335 case AArch64::BRKPA_PPzPP:
3336 return AArch64::BRKPAS_PPzPP;
3337 case AArch64::BRKB_PPzP:
3338 return AArch64::BRKBS_PPzP;
3339 case AArch64::BRKPB_PPzPP:
3340 return AArch64::BRKPBS_PPzPP;
3341 case AArch64::BRKN_PPzP:
3342 return AArch64::BRKNS_PPzP;
3343 case AArch64::RDFFR_PPz:
3344 return AArch64::RDFFRS_PPz;
3345 case AArch64::PTRUE_B:
3346 return AArch64::PTRUES_B;
3357 if (
MI.hasOrderedMemoryRef())
3362 assert((
MI.getOperand(IsPreLdSt ? 2 : 1).isReg() ||
3363 MI.getOperand(IsPreLdSt ? 2 : 1).isFI()) &&
3364 "Expected a reg or frame index operand.");
3368 bool IsImmPreLdSt = IsPreLdSt &&
MI.getOperand(3).isImm();
3370 if (!
MI.getOperand(2).isImm() && !IsImmPreLdSt)
3383 if (
MI.getOperand(1).isReg() && !IsPreLdSt) {
3384 Register BaseReg =
MI.getOperand(1).getReg();
3386 if (
MI.modifiesRegister(BaseReg,
TRI))
3392 switch (
MI.getOpcode()) {
3395 case AArch64::LDR_ZXI:
3396 case AArch64::STR_ZXI:
3397 if (!Subtarget.isLittleEndian() ||
3398 Subtarget.getSVEVectorSizeInBits() != 128)
3411 const MCAsmInfo &MAI =
MI.getMF()->getTarget().getMCAsmInfo();
3419 if (Subtarget.isPaired128Slow()) {
3420 switch (
MI.getOpcode()) {
3423 case AArch64::LDURQi:
3424 case AArch64::STURQi:
3425 case AArch64::LDRQui:
3426 case AArch64::STRQui:
3453std::optional<ExtAddrMode>
3458 bool OffsetIsScalable;
3459 if (!getMemOperandWithOffset(MemI,
Base,
Offset, OffsetIsScalable,
TRI))
3460 return std::nullopt;
3463 return std::nullopt;
3478 int64_t OffsetScale = 1;
3483 case AArch64::LDURQi:
3484 case AArch64::STURQi:
3488 case AArch64::LDURDi:
3489 case AArch64::STURDi:
3490 case AArch64::LDURXi:
3491 case AArch64::STURXi:
3495 case AArch64::LDURWi:
3496 case AArch64::LDURSWi:
3497 case AArch64::STURWi:
3501 case AArch64::LDURHi:
3502 case AArch64::STURHi:
3503 case AArch64::LDURHHi:
3504 case AArch64::STURHHi:
3505 case AArch64::LDURSHXi:
3506 case AArch64::LDURSHWi:
3510 case AArch64::LDRBroX:
3511 case AArch64::LDRBBroX:
3512 case AArch64::LDRSBXroX:
3513 case AArch64::LDRSBWroX:
3514 case AArch64::STRBroX:
3515 case AArch64::STRBBroX:
3516 case AArch64::LDURBi:
3517 case AArch64::LDURBBi:
3518 case AArch64::LDURSBXi:
3519 case AArch64::LDURSBWi:
3520 case AArch64::STURBi:
3521 case AArch64::STURBBi:
3522 case AArch64::LDRBui:
3523 case AArch64::LDRBBui:
3524 case AArch64::LDRSBXui:
3525 case AArch64::LDRSBWui:
3526 case AArch64::STRBui:
3527 case AArch64::STRBBui:
3531 case AArch64::LDRQroX:
3532 case AArch64::STRQroX:
3533 case AArch64::LDRQui:
3534 case AArch64::STRQui:
3539 case AArch64::LDRDroX:
3540 case AArch64::STRDroX:
3541 case AArch64::LDRXroX:
3542 case AArch64::STRXroX:
3543 case AArch64::LDRDui:
3544 case AArch64::STRDui:
3545 case AArch64::LDRXui:
3546 case AArch64::STRXui:
3551 case AArch64::LDRWroX:
3552 case AArch64::LDRSWroX:
3553 case AArch64::STRWroX:
3554 case AArch64::LDRWui:
3555 case AArch64::LDRSWui:
3556 case AArch64::STRWui:
3561 case AArch64::LDRHroX:
3562 case AArch64::STRHroX:
3563 case AArch64::LDRHHroX:
3564 case AArch64::STRHHroX:
3565 case AArch64::LDRSHXroX:
3566 case AArch64::LDRSHWroX:
3567 case AArch64::LDRHui:
3568 case AArch64::STRHui:
3569 case AArch64::LDRHHui:
3570 case AArch64::STRHHui:
3571 case AArch64::LDRSHXui:
3572 case AArch64::LDRSHWui:
3580 if (BaseRegOp.
isReg() && BaseRegOp.
getReg() == Reg)
3604 case AArch64::SBFMXri:
3617 AM.
Scale = OffsetScale;
3622 case TargetOpcode::SUBREG_TO_REG: {
3638 if (
DefMI.getOpcode() != AArch64::ORRWrs ||
3639 DefMI.getOperand(1).getReg() != AArch64::WZR ||
3640 DefMI.getOperand(3).getImm() != 0)
3647 AM.
Scale = OffsetScale;
3658 auto validateOffsetForLDP = [](
unsigned NumBytes, int64_t OldOffset,
3659 int64_t NewOffset) ->
bool {
3660 int64_t MinOffset, MaxOffset;
3677 return OldOffset < MinOffset || OldOffset > MaxOffset ||
3678 (NewOffset >= MinOffset && NewOffset <= MaxOffset);
3680 auto canFoldAddSubImmIntoAddrMode = [&](int64_t Disp) ->
bool {
3682 int64_t NewOffset = OldOffset + Disp;
3683 if (!isLegalAddressingMode(NumBytes, NewOffset, 0))
3687 if (!validateOffsetForLDP(NumBytes, OldOffset, NewOffset))
3697 auto canFoldAddRegIntoAddrMode =
3702 if ((
unsigned)Scale != Scale)
3704 if (!isLegalAddressingMode(NumBytes, 0, Scale))
3716 return (Opcode == AArch64::STURQi || Opcode == AArch64::STRQui) &&
3717 Subtarget.isSTRQroSlow();
3726 case AArch64::ADDXri:
3732 return canFoldAddSubImmIntoAddrMode(Disp);
3734 case AArch64::SUBXri:
3740 return canFoldAddSubImmIntoAddrMode(-Disp);
3742 case AArch64::ADDXrs: {
3755 if (Shift != 2 && Shift != 3 && Subtarget.hasAddrLSLSlow14())
3757 if (avoidSlowSTRQ(MemI))
3760 return canFoldAddRegIntoAddrMode(1ULL << Shift);
3763 case AArch64::ADDXrr:
3771 if (!OptSize && avoidSlowSTRQ(MemI))
3773 return canFoldAddRegIntoAddrMode(1);
3775 case AArch64::ADDXrx:
3783 if (!OptSize && avoidSlowSTRQ(MemI))
3792 return canFoldAddRegIntoAddrMode(
3807 case AArch64::LDURQi:
3808 case AArch64::LDRQui:
3809 return AArch64::LDRQroX;
3810 case AArch64::STURQi:
3811 case AArch64::STRQui:
3812 return AArch64::STRQroX;
3813 case AArch64::LDURDi:
3814 case AArch64::LDRDui:
3815 return AArch64::LDRDroX;
3816 case AArch64::STURDi:
3817 case AArch64::STRDui:
3818 return AArch64::STRDroX;
3819 case AArch64::LDURXi:
3820 case AArch64::LDRXui:
3821 return AArch64::LDRXroX;
3822 case AArch64::STURXi:
3823 case AArch64::STRXui:
3824 return AArch64::STRXroX;
3825 case AArch64::LDURWi:
3826 case AArch64::LDRWui:
3827 return AArch64::LDRWroX;
3828 case AArch64::LDURSWi:
3829 case AArch64::LDRSWui:
3830 return AArch64::LDRSWroX;
3831 case AArch64::STURWi:
3832 case AArch64::STRWui:
3833 return AArch64::STRWroX;
3834 case AArch64::LDURHi:
3835 case AArch64::LDRHui:
3836 return AArch64::LDRHroX;
3837 case AArch64::STURHi:
3838 case AArch64::STRHui:
3839 return AArch64::STRHroX;
3840 case AArch64::LDURHHi:
3841 case AArch64::LDRHHui:
3842 return AArch64::LDRHHroX;
3843 case AArch64::STURHHi:
3844 case AArch64::STRHHui:
3845 return AArch64::STRHHroX;
3846 case AArch64::LDURSHXi:
3847 case AArch64::LDRSHXui:
3848 return AArch64::LDRSHXroX;
3849 case AArch64::LDURSHWi:
3850 case AArch64::LDRSHWui:
3851 return AArch64::LDRSHWroX;
3852 case AArch64::LDURBi:
3853 case AArch64::LDRBui:
3854 return AArch64::LDRBroX;
3855 case AArch64::LDURBBi:
3856 case AArch64::LDRBBui:
3857 return AArch64::LDRBBroX;
3858 case AArch64::LDURSBXi:
3859 case AArch64::LDRSBXui:
3860 return AArch64::LDRSBXroX;
3861 case AArch64::LDURSBWi:
3862 case AArch64::LDRSBWui:
3863 return AArch64::LDRSBWroX;
3864 case AArch64::STURBi:
3865 case AArch64::STRBui:
3866 return AArch64::STRBroX;
3867 case AArch64::STURBBi:
3868 case AArch64::STRBBui:
3869 return AArch64::STRBBroX;
3881 case AArch64::LDURQi:
3883 return AArch64::LDRQui;
3884 case AArch64::STURQi:
3886 return AArch64::STRQui;
3887 case AArch64::LDURDi:
3889 return AArch64::LDRDui;
3890 case AArch64::STURDi:
3892 return AArch64::STRDui;
3893 case AArch64::LDURXi:
3895 return AArch64::LDRXui;
3896 case AArch64::STURXi:
3898 return AArch64::STRXui;
3899 case AArch64::LDURWi:
3901 return AArch64::LDRWui;
3902 case AArch64::LDURSWi:
3904 return AArch64::LDRSWui;
3905 case AArch64::STURWi:
3907 return AArch64::STRWui;
3908 case AArch64::LDURHi:
3910 return AArch64::LDRHui;
3911 case AArch64::STURHi:
3913 return AArch64::STRHui;
3914 case AArch64::LDURHHi:
3916 return AArch64::LDRHHui;
3917 case AArch64::STURHHi:
3919 return AArch64::STRHHui;
3920 case AArch64::LDURSHXi:
3922 return AArch64::LDRSHXui;
3923 case AArch64::LDURSHWi:
3925 return AArch64::LDRSHWui;
3926 case AArch64::LDURBi:
3928 return AArch64::LDRBui;
3929 case AArch64::LDURBBi:
3931 return AArch64::LDRBBui;
3932 case AArch64::LDURSBXi:
3934 return AArch64::LDRSBXui;
3935 case AArch64::LDURSBWi:
3937 return AArch64::LDRSBWui;
3938 case AArch64::STURBi:
3940 return AArch64::STRBui;
3941 case AArch64::STURBBi:
3943 return AArch64::STRBBui;
3944 case AArch64::LDRQui:
3945 case AArch64::STRQui:
3948 case AArch64::LDRDui:
3949 case AArch64::STRDui:
3950 case AArch64::LDRXui:
3951 case AArch64::STRXui:
3954 case AArch64::LDRWui:
3955 case AArch64::LDRSWui:
3956 case AArch64::STRWui:
3959 case AArch64::LDRHui:
3960 case AArch64::STRHui:
3961 case AArch64::LDRHHui:
3962 case AArch64::STRHHui:
3963 case AArch64::LDRSHXui:
3964 case AArch64::LDRSHWui:
3967 case AArch64::LDRBui:
3968 case AArch64::LDRBBui:
3969 case AArch64::LDRSBXui:
3970 case AArch64::LDRSBWui:
3971 case AArch64::STRBui:
3972 case AArch64::STRBBui:
3986 case AArch64::LDURQi:
3987 case AArch64::STURQi:
3988 case AArch64::LDURDi:
3989 case AArch64::STURDi:
3990 case AArch64::LDURXi:
3991 case AArch64::STURXi:
3992 case AArch64::LDURWi:
3993 case AArch64::LDURSWi:
3994 case AArch64::STURWi:
3995 case AArch64::LDURHi:
3996 case AArch64::STURHi:
3997 case AArch64::LDURHHi:
3998 case AArch64::STURHHi:
3999 case AArch64::LDURSHXi:
4000 case AArch64::LDURSHWi:
4001 case AArch64::LDURBi:
4002 case AArch64::STURBi:
4003 case AArch64::LDURBBi:
4004 case AArch64::STURBBi:
4005 case AArch64::LDURSBWi:
4006 case AArch64::LDURSBXi:
4008 case AArch64::LDRQui:
4009 return AArch64::LDURQi;
4010 case AArch64::STRQui:
4011 return AArch64::STURQi;
4012 case AArch64::LDRDui:
4013 return AArch64::LDURDi;
4014 case AArch64::STRDui:
4015 return AArch64::STURDi;
4016 case AArch64::LDRXui:
4017 return AArch64::LDURXi;
4018 case AArch64::STRXui:
4019 return AArch64::STURXi;
4020 case AArch64::LDRWui:
4021 return AArch64::LDURWi;
4022 case AArch64::LDRSWui:
4023 return AArch64::LDURSWi;
4024 case AArch64::STRWui:
4025 return AArch64::STURWi;
4026 case AArch64::LDRHui:
4027 return AArch64::LDURHi;
4028 case AArch64::STRHui:
4029 return AArch64::STURHi;
4030 case AArch64::LDRHHui:
4031 return AArch64::LDURHHi;
4032 case AArch64::STRHHui:
4033 return AArch64::STURHHi;
4034 case AArch64::LDRSHXui:
4035 return AArch64::LDURSHXi;
4036 case AArch64::LDRSHWui:
4037 return AArch64::LDURSHWi;
4038 case AArch64::LDRBBui:
4039 return AArch64::LDURBBi;
4040 case AArch64::LDRBui:
4041 return AArch64::LDURBi;
4042 case AArch64::STRBBui:
4043 return AArch64::STURBBi;
4044 case AArch64::STRBui:
4045 return AArch64::STURBi;
4046 case AArch64::LDRSBWui:
4047 return AArch64::LDURSBWi;
4048 case AArch64::LDRSBXui:
4049 return AArch64::LDURSBXi;
4062 case AArch64::LDRQroX:
4063 case AArch64::LDURQi:
4064 case AArch64::LDRQui:
4065 return AArch64::LDRQroW;
4066 case AArch64::STRQroX:
4067 case AArch64::STURQi:
4068 case AArch64::STRQui:
4069 return AArch64::STRQroW;
4070 case AArch64::LDRDroX:
4071 case AArch64::LDURDi:
4072 case AArch64::LDRDui:
4073 return AArch64::LDRDroW;
4074 case AArch64::STRDroX:
4075 case AArch64::STURDi:
4076 case AArch64::STRDui:
4077 return AArch64::STRDroW;
4078 case AArch64::LDRXroX:
4079 case AArch64::LDURXi:
4080 case AArch64::LDRXui:
4081 return AArch64::LDRXroW;
4082 case AArch64::STRXroX:
4083 case AArch64::STURXi:
4084 case AArch64::STRXui:
4085 return AArch64::STRXroW;
4086 case AArch64::LDRWroX:
4087 case AArch64::LDURWi:
4088 case AArch64::LDRWui:
4089 return AArch64::LDRWroW;
4090 case AArch64::LDRSWroX:
4091 case AArch64::LDURSWi:
4092 case AArch64::LDRSWui:
4093 return AArch64::LDRSWroW;
4094 case AArch64::STRWroX:
4095 case AArch64::STURWi:
4096 case AArch64::STRWui:
4097 return AArch64::STRWroW;
4098 case AArch64::LDRHroX:
4099 case AArch64::LDURHi:
4100 case AArch64::LDRHui:
4101 return AArch64::LDRHroW;
4102 case AArch64::STRHroX:
4103 case AArch64::STURHi:
4104 case AArch64::STRHui:
4105 return AArch64::STRHroW;
4106 case AArch64::LDRHHroX:
4107 case AArch64::LDURHHi:
4108 case AArch64::LDRHHui:
4109 return AArch64::LDRHHroW;
4110 case AArch64::STRHHroX:
4111 case AArch64::STURHHi:
4112 case AArch64::STRHHui:
4113 return AArch64::STRHHroW;
4114 case AArch64::LDRSHXroX:
4115 case AArch64::LDURSHXi:
4116 case AArch64::LDRSHXui:
4117 return AArch64::LDRSHXroW;
4118 case AArch64::LDRSHWroX:
4119 case AArch64::LDURSHWi:
4120 case AArch64::LDRSHWui:
4121 return AArch64::LDRSHWroW;
4122 case AArch64::LDRBroX:
4123 case AArch64::LDURBi:
4124 case AArch64::LDRBui:
4125 return AArch64::LDRBroW;
4126 case AArch64::LDRBBroX:
4127 case AArch64::LDURBBi:
4128 case AArch64::LDRBBui:
4129 return AArch64::LDRBBroW;
4130 case AArch64::LDRSBXroX:
4131 case AArch64::LDURSBXi:
4132 case AArch64::LDRSBXui:
4133 return AArch64::LDRSBXroW;
4134 case AArch64::LDRSBWroX:
4135 case AArch64::LDURSBWi:
4136 case AArch64::LDRSBWui:
4137 return AArch64::LDRSBWroW;
4138 case AArch64::STRBroX:
4139 case AArch64::STURBi:
4140 case AArch64::STRBui:
4141 return AArch64::STRBroW;
4142 case AArch64::STRBBroX:
4143 case AArch64::STURBBi:
4144 case AArch64::STRBBui:
4145 return AArch64::STRBBroW;
4170 return B.getInstr();
4174 "Addressing mode not supported for folding");
4191 return B.getInstr();
4198 "Address offset can be a register or an immediate, but not both");
4219 return B.getInstr();
4223 "Function must not be called with an addressing mode it can't handle");
4232 case AArch64::LD1Fourv16b_POST:
4233 case AArch64::LD1Fourv1d_POST:
4234 case AArch64::LD1Fourv2d_POST:
4235 case AArch64::LD1Fourv2s_POST:
4236 case AArch64::LD1Fourv4h_POST:
4237 case AArch64::LD1Fourv4s_POST:
4238 case AArch64::LD1Fourv8b_POST:
4239 case AArch64::LD1Fourv8h_POST:
4240 case AArch64::LD1Onev16b_POST:
4241 case AArch64::LD1Onev1d_POST:
4242 case AArch64::LD1Onev2d_POST:
4243 case AArch64::LD1Onev2s_POST:
4244 case AArch64::LD1Onev4h_POST:
4245 case AArch64::LD1Onev4s_POST:
4246 case AArch64::LD1Onev8b_POST:
4247 case AArch64::LD1Onev8h_POST:
4248 case AArch64::LD1Rv16b_POST:
4249 case AArch64::LD1Rv1d_POST:
4250 case AArch64::LD1Rv2d_POST:
4251 case AArch64::LD1Rv2s_POST:
4252 case AArch64::LD1Rv4h_POST:
4253 case AArch64::LD1Rv4s_POST:
4254 case AArch64::LD1Rv8b_POST:
4255 case AArch64::LD1Rv8h_POST:
4256 case AArch64::LD1Threev16b_POST:
4257 case AArch64::LD1Threev1d_POST:
4258 case AArch64::LD1Threev2d_POST:
4259 case AArch64::LD1Threev2s_POST:
4260 case AArch64::LD1Threev4h_POST:
4261 case AArch64::LD1Threev4s_POST:
4262 case AArch64::LD1Threev8b_POST:
4263 case AArch64::LD1Threev8h_POST:
4264 case AArch64::LD1Twov16b_POST:
4265 case AArch64::LD1Twov1d_POST:
4266 case AArch64::LD1Twov2d_POST:
4267 case AArch64::LD1Twov2s_POST:
4268 case AArch64::LD1Twov4h_POST:
4269 case AArch64::LD1Twov4s_POST:
4270 case AArch64::LD1Twov8b_POST:
4271 case AArch64::LD1Twov8h_POST:
4272 case AArch64::LD1i16_POST:
4273 case AArch64::LD1i32_POST:
4274 case AArch64::LD1i64_POST:
4275 case AArch64::LD1i8_POST:
4276 case AArch64::LD2Rv16b_POST:
4277 case AArch64::LD2Rv1d_POST:
4278 case AArch64::LD2Rv2d_POST:
4279 case AArch64::LD2Rv2s_POST:
4280 case AArch64::LD2Rv4h_POST:
4281 case AArch64::LD2Rv4s_POST:
4282 case AArch64::LD2Rv8b_POST:
4283 case AArch64::LD2Rv8h_POST:
4284 case AArch64::LD2Twov16b_POST:
4285 case AArch64::LD2Twov2d_POST:
4286 case AArch64::LD2Twov2s_POST:
4287 case AArch64::LD2Twov4h_POST:
4288 case AArch64::LD2Twov4s_POST:
4289 case AArch64::LD2Twov8b_POST:
4290 case AArch64::LD2Twov8h_POST:
4291 case AArch64::LD2i16_POST:
4292 case AArch64::LD2i32_POST:
4293 case AArch64::LD2i64_POST:
4294 case AArch64::LD2i8_POST:
4295 case AArch64::LD3Rv16b_POST:
4296 case AArch64::LD3Rv1d_POST:
4297 case AArch64::LD3Rv2d_POST:
4298 case AArch64::LD3Rv2s_POST:
4299 case AArch64::LD3Rv4h_POST:
4300 case AArch64::LD3Rv4s_POST:
4301 case AArch64::LD3Rv8b_POST:
4302 case AArch64::LD3Rv8h_POST:
4303 case AArch64::LD3Threev16b_POST:
4304 case AArch64::LD3Threev2d_POST:
4305 case AArch64::LD3Threev2s_POST:
4306 case AArch64::LD3Threev4h_POST:
4307 case AArch64::LD3Threev4s_POST:
4308 case AArch64::LD3Threev8b_POST:
4309 case AArch64::LD3Threev8h_POST:
4310 case AArch64::LD3i16_POST:
4311 case AArch64::LD3i32_POST:
4312 case AArch64::LD3i64_POST:
4313 case AArch64::LD3i8_POST:
4314 case AArch64::LD4Fourv16b_POST:
4315 case AArch64::LD4Fourv2d_POST:
4316 case AArch64::LD4Fourv2s_POST:
4317 case AArch64::LD4Fourv4h_POST:
4318 case AArch64::LD4Fourv4s_POST:
4319 case AArch64::LD4Fourv8b_POST:
4320 case AArch64::LD4Fourv8h_POST:
4321 case AArch64::LD4Rv16b_POST:
4322 case AArch64::LD4Rv1d_POST:
4323 case AArch64::LD4Rv2d_POST:
4324 case AArch64::LD4Rv2s_POST:
4325 case AArch64::LD4Rv4h_POST:
4326 case AArch64::LD4Rv4s_POST:
4327 case AArch64::LD4Rv8b_POST:
4328 case AArch64::LD4Rv8h_POST:
4329 case AArch64::LD4i16_POST:
4330 case AArch64::LD4i32_POST:
4331 case AArch64::LD4i64_POST:
4332 case AArch64::LD4i8_POST:
4333 case AArch64::LDAPRWpost:
4334 case AArch64::LDAPRXpost:
4335 case AArch64::LDIAPPWpost:
4336 case AArch64::LDIAPPXpost:
4337 case AArch64::LDPDpost:
4338 case AArch64::LDPQpost:
4339 case AArch64::LDPSWpost:
4340 case AArch64::LDPSpost:
4341 case AArch64::LDPWpost:
4342 case AArch64::LDPXpost:
4343 case AArch64::LDRBBpost:
4344 case AArch64::LDRBpost:
4345 case AArch64::LDRDpost:
4346 case AArch64::LDRHHpost:
4347 case AArch64::LDRHpost:
4348 case AArch64::LDRQpost:
4349 case AArch64::LDRSBWpost:
4350 case AArch64::LDRSBXpost:
4351 case AArch64::LDRSHWpost:
4352 case AArch64::LDRSHXpost:
4353 case AArch64::LDRSWpost:
4354 case AArch64::LDRSpost:
4355 case AArch64::LDRWpost:
4356 case AArch64::LDRXpost:
4357 case AArch64::ST1Fourv16b_POST:
4358 case AArch64::ST1Fourv1d_POST:
4359 case AArch64::ST1Fourv2d_POST:
4360 case AArch64::ST1Fourv2s_POST:
4361 case AArch64::ST1Fourv4h_POST:
4362 case AArch64::ST1Fourv4s_POST:
4363 case AArch64::ST1Fourv8b_POST:
4364 case AArch64::ST1Fourv8h_POST:
4365 case AArch64::ST1Onev16b_POST:
4366 case AArch64::ST1Onev1d_POST:
4367 case AArch64::ST1Onev2d_POST:
4368 case AArch64::ST1Onev2s_POST:
4369 case AArch64::ST1Onev4h_POST:
4370 case AArch64::ST1Onev4s_POST:
4371 case AArch64::ST1Onev8b_POST:
4372 case AArch64::ST1Onev8h_POST:
4373 case AArch64::ST1Threev16b_POST:
4374 case AArch64::ST1Threev1d_POST:
4375 case AArch64::ST1Threev2d_POST:
4376 case AArch64::ST1Threev2s_POST:
4377 case AArch64::ST1Threev4h_POST:
4378 case AArch64::ST1Threev4s_POST:
4379 case AArch64::ST1Threev8b_POST:
4380 case AArch64::ST1Threev8h_POST:
4381 case AArch64::ST1Twov16b_POST:
4382 case AArch64::ST1Twov1d_POST:
4383 case AArch64::ST1Twov2d_POST:
4384 case AArch64::ST1Twov2s_POST:
4385 case AArch64::ST1Twov4h_POST:
4386 case AArch64::ST1Twov4s_POST:
4387 case AArch64::ST1Twov8b_POST:
4388 case AArch64::ST1Twov8h_POST:
4389 case AArch64::ST1i16_POST:
4390 case AArch64::ST1i32_POST:
4391 case AArch64::ST1i64_POST:
4392 case AArch64::ST1i8_POST:
4393 case AArch64::ST2GPostIndex:
4394 case AArch64::ST2Twov16b_POST:
4395 case AArch64::ST2Twov2d_POST:
4396 case AArch64::ST2Twov2s_POST:
4397 case AArch64::ST2Twov4h_POST:
4398 case AArch64::ST2Twov4s_POST:
4399 case AArch64::ST2Twov8b_POST:
4400 case AArch64::ST2Twov8h_POST:
4401 case AArch64::ST2i16_POST:
4402 case AArch64::ST2i32_POST:
4403 case AArch64::ST2i64_POST:
4404 case AArch64::ST2i8_POST:
4405 case AArch64::ST3Threev16b_POST:
4406 case AArch64::ST3Threev2d_POST:
4407 case AArch64::ST3Threev2s_POST:
4408 case AArch64::ST3Threev4h_POST:
4409 case AArch64::ST3Threev4s_POST:
4410 case AArch64::ST3Threev8b_POST:
4411 case AArch64::ST3Threev8h_POST:
4412 case AArch64::ST3i16_POST:
4413 case AArch64::ST3i32_POST:
4414 case AArch64::ST3i64_POST:
4415 case AArch64::ST3i8_POST:
4416 case AArch64::ST4Fourv16b_POST:
4417 case AArch64::ST4Fourv2d_POST:
4418 case AArch64::ST4Fourv2s_POST:
4419 case AArch64::ST4Fourv4h_POST:
4420 case AArch64::ST4Fourv4s_POST:
4421 case AArch64::ST4Fourv8b_POST:
4422 case AArch64::ST4Fourv8h_POST:
4423 case AArch64::ST4i16_POST:
4424 case AArch64::ST4i32_POST:
4425 case AArch64::ST4i64_POST:
4426 case AArch64::ST4i8_POST:
4427 case AArch64::STGPostIndex:
4428 case AArch64::STGPpost:
4429 case AArch64::STPDpost:
4430 case AArch64::STPQpost:
4431 case AArch64::STPSpost:
4432 case AArch64::STPWpost:
4433 case AArch64::STPXpost:
4434 case AArch64::STRBBpost:
4435 case AArch64::STRBpost:
4436 case AArch64::STRDpost:
4437 case AArch64::STRHHpost:
4438 case AArch64::STRHpost:
4439 case AArch64::STRQpost:
4440 case AArch64::STRSpost:
4441 case AArch64::STRWpost:
4442 case AArch64::STRXpost:
4443 case AArch64::STZ2GPostIndex:
4444 case AArch64::STZGPostIndex:
4451 bool &OffsetIsScalable,
TypeSize &Width,
4472 int64_t Dummy1, Dummy2;
4494 return BaseOp->
isReg() || BaseOp->
isFI();
4501 assert(OfsOp.
isImm() &&
"Offset operand wasn't immediate.");
4506 TypeSize &Width, int64_t &MinOffset,
4507 int64_t &MaxOffset) {
4513 MinOffset = MaxOffset = 0;
4516 case AArch64::LDRQui:
4517 case AArch64::STRQui:
4523 case AArch64::LDRXui:
4524 case AArch64::LDRDui:
4525 case AArch64::STRXui:
4526 case AArch64::STRDui:
4527 case AArch64::PRFMui:
4533 case AArch64::LDRWui:
4534 case AArch64::LDRSui:
4535 case AArch64::LDRSWui:
4536 case AArch64::STRWui:
4537 case AArch64::STRSui:
4543 case AArch64::LDRHui:
4544 case AArch64::LDRHHui:
4545 case AArch64::LDRSHWui:
4546 case AArch64::LDRSHXui:
4547 case AArch64::STRHui:
4548 case AArch64::STRHHui:
4554 case AArch64::LDRBui:
4555 case AArch64::LDRBBui:
4556 case AArch64::LDRSBWui:
4557 case AArch64::LDRSBXui:
4558 case AArch64::STRBui:
4559 case AArch64::STRBBui:
4566 case AArch64::STRQpre:
4567 case AArch64::LDRQpost:
4573 case AArch64::LDRDpost:
4574 case AArch64::LDRDpre:
4575 case AArch64::LDRXpost:
4576 case AArch64::LDRXpre:
4577 case AArch64::STRDpost:
4578 case AArch64::STRDpre:
4579 case AArch64::STRXpost:
4580 case AArch64::STRXpre:
4586 case AArch64::STRWpost:
4587 case AArch64::STRWpre:
4588 case AArch64::LDRWpost:
4589 case AArch64::LDRWpre:
4590 case AArch64::STRSpost:
4591 case AArch64::STRSpre:
4592 case AArch64::LDRSpost:
4593 case AArch64::LDRSpre:
4599 case AArch64::LDRHpost:
4600 case AArch64::LDRHpre:
4601 case AArch64::STRHpost:
4602 case AArch64::STRHpre:
4603 case AArch64::LDRHHpost:
4604 case AArch64::LDRHHpre:
4605 case AArch64::STRHHpost:
4606 case AArch64::STRHHpre:
4612 case AArch64::LDRBpost:
4613 case AArch64::LDRBpre:
4614 case AArch64::STRBpost:
4615 case AArch64::STRBpre:
4616 case AArch64::LDRBBpost:
4617 case AArch64::LDRBBpre:
4618 case AArch64::STRBBpost:
4619 case AArch64::STRBBpre:
4626 case AArch64::LDURQi:
4627 case AArch64::STURQi:
4633 case AArch64::LDURXi:
4634 case AArch64::LDURDi:
4635 case AArch64::LDAPURXi:
4636 case AArch64::STURXi:
4637 case AArch64::STURDi:
4638 case AArch64::STLURXi:
4639 case AArch64::PRFUMi:
4645 case AArch64::LDURWi:
4646 case AArch64::LDURSi:
4647 case AArch64::LDURSWi:
4648 case AArch64::LDAPURi:
4649 case AArch64::LDAPURSWi:
4650 case AArch64::STURWi:
4651 case AArch64::STURSi:
4652 case AArch64::STLURWi:
4658 case AArch64::LDURHi:
4659 case AArch64::LDURHHi:
4660 case AArch64::LDURSHXi:
4661 case AArch64::LDURSHWi:
4662 case AArch64::LDAPURHi:
4663 case AArch64::LDAPURSHWi:
4664 case AArch64::LDAPURSHXi:
4665 case AArch64::STURHi:
4666 case AArch64::STURHHi:
4667 case AArch64::STLURHi:
4673 case AArch64::LDURBi:
4674 case AArch64::LDURBBi:
4675 case AArch64::LDURSBXi:
4676 case AArch64::LDURSBWi:
4677 case AArch64::LDAPURBi:
4678 case AArch64::LDAPURSBWi:
4679 case AArch64::LDAPURSBXi:
4680 case AArch64::STURBi:
4681 case AArch64::STURBBi:
4682 case AArch64::STLURBi:
4689 case AArch64::LDPQi:
4690 case AArch64::LDNPQi:
4691 case AArch64::STPQi:
4692 case AArch64::STNPQi:
4693 case AArch64::LDPQpost:
4694 case AArch64::LDPQpre:
4695 case AArch64::STPQpost:
4696 case AArch64::STPQpre:
4702 case AArch64::LDPXi:
4703 case AArch64::LDPDi:
4704 case AArch64::LDNPXi:
4705 case AArch64::LDNPDi:
4706 case AArch64::STPXi:
4707 case AArch64::STPDi:
4708 case AArch64::STNPXi:
4709 case AArch64::STNPDi:
4710 case AArch64::LDPDpost:
4711 case AArch64::LDPDpre:
4712 case AArch64::LDPXpost:
4713 case AArch64::LDPXpre:
4714 case AArch64::STPDpost:
4715 case AArch64::STPDpre:
4716 case AArch64::STPXpost:
4717 case AArch64::STPXpre:
4723 case AArch64::LDPWi:
4724 case AArch64::LDPSi:
4725 case AArch64::LDNPWi:
4726 case AArch64::LDNPSi:
4727 case AArch64::STPWi:
4728 case AArch64::STPSi:
4729 case AArch64::STNPWi:
4730 case AArch64::STNPSi:
4731 case AArch64::LDPSpost:
4732 case AArch64::LDPSpre:
4733 case AArch64::LDPWpost:
4734 case AArch64::LDPWpre:
4735 case AArch64::STPSpost:
4736 case AArch64::STPSpre:
4737 case AArch64::STPWpost:
4738 case AArch64::STPWpre:
4744 case AArch64::StoreSwiftAsyncContext:
4757 case AArch64::TAGPstack:
4767 case AArch64::STGPreIndex:
4768 case AArch64::STGPostIndex:
4769 case AArch64::STZGi:
4770 case AArch64::STZGPreIndex:
4771 case AArch64::STZGPostIndex:
4778 case AArch64::STR_ZZZZXI:
4779 case AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS:
4780 case AArch64::LDR_ZZZZXI:
4781 case AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS:
4787 case AArch64::STR_ZZZXI:
4788 case AArch64::LDR_ZZZXI:
4794 case AArch64::STR_ZZXI:
4795 case AArch64::STR_ZZXI_STRIDED_CONTIGUOUS:
4796 case AArch64::LDR_ZZXI:
4797 case AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS:
4803 case AArch64::LDR_PXI:
4804 case AArch64::STR_PXI:
4810 case AArch64::LDR_PPXI:
4811 case AArch64::STR_PPXI:
4817 case AArch64::LDR_ZXI:
4818 case AArch64::STR_ZXI:
4824 case AArch64::LD1B_IMM:
4825 case AArch64::LD1H_IMM:
4826 case AArch64::LD1W_IMM:
4827 case AArch64::LD1D_IMM:
4828 case AArch64::LDNT1B_ZRI:
4829 case AArch64::LDNT1H_ZRI:
4830 case AArch64::LDNT1W_ZRI:
4831 case AArch64::LDNT1D_ZRI:
4832 case AArch64::ST1B_IMM:
4833 case AArch64::ST1H_IMM:
4834 case AArch64::ST1W_IMM:
4835 case AArch64::ST1D_IMM:
4836 case AArch64::STNT1B_ZRI:
4837 case AArch64::STNT1H_ZRI:
4838 case AArch64::STNT1W_ZRI:
4839 case AArch64::STNT1D_ZRI:
4840 case AArch64::LDNF1B_IMM:
4841 case AArch64::LDNF1H_IMM:
4842 case AArch64::LDNF1W_IMM:
4843 case AArch64::LDNF1D_IMM:
4851 case AArch64::LD2B_IMM:
4852 case AArch64::LD2H_IMM:
4853 case AArch64::LD2W_IMM:
4854 case AArch64::LD2D_IMM:
4855 case AArch64::ST2B_IMM:
4856 case AArch64::ST2H_IMM:
4857 case AArch64::ST2W_IMM:
4858 case AArch64::ST2D_IMM:
4864 case AArch64::LD3B_IMM:
4865 case AArch64::LD3H_IMM:
4866 case AArch64::LD3W_IMM:
4867 case AArch64::LD3D_IMM:
4868 case AArch64::ST3B_IMM:
4869 case AArch64::ST3H_IMM:
4870 case AArch64::ST3W_IMM:
4871 case AArch64::ST3D_IMM:
4877 case AArch64::LD4B_IMM:
4878 case AArch64::LD4H_IMM:
4879 case AArch64::LD4W_IMM:
4880 case AArch64::LD4D_IMM:
4881 case AArch64::ST4B_IMM:
4882 case AArch64::ST4H_IMM:
4883 case AArch64::ST4W_IMM:
4884 case AArch64::ST4D_IMM:
4890 case AArch64::LD1B_H_IMM:
4891 case AArch64::LD1SB_H_IMM:
4892 case AArch64::LD1H_S_IMM:
4893 case AArch64::LD1SH_S_IMM:
4894 case AArch64::LD1W_D_IMM:
4895 case AArch64::LD1SW_D_IMM:
4896 case AArch64::ST1B_H_IMM:
4897 case AArch64::ST1H_S_IMM:
4898 case AArch64::ST1W_D_IMM:
4899 case AArch64::LDNF1B_H_IMM:
4900 case AArch64::LDNF1SB_H_IMM:
4901 case AArch64::LDNF1H_S_IMM:
4902 case AArch64::LDNF1SH_S_IMM:
4903 case AArch64::LDNF1W_D_IMM:
4904 case AArch64::LDNF1SW_D_IMM:
4912 case AArch64::LD1B_S_IMM:
4913 case AArch64::LD1SB_S_IMM:
4914 case AArch64::LD1H_D_IMM:
4915 case AArch64::LD1SH_D_IMM:
4916 case AArch64::ST1B_S_IMM:
4917 case AArch64::ST1H_D_IMM:
4918 case AArch64::LDNF1B_S_IMM:
4919 case AArch64::LDNF1SB_S_IMM:
4920 case AArch64::LDNF1H_D_IMM:
4921 case AArch64::LDNF1SH_D_IMM:
4929 case AArch64::LD1B_D_IMM:
4930 case AArch64::LD1SB_D_IMM:
4931 case AArch64::ST1B_D_IMM:
4932 case AArch64::LDNF1B_D_IMM:
4933 case AArch64::LDNF1SB_D_IMM:
4941 case AArch64::ST2Gi:
4942 case AArch64::ST2GPreIndex:
4943 case AArch64::ST2GPostIndex:
4944 case AArch64::STZ2Gi:
4945 case AArch64::STZ2GPreIndex:
4946 case AArch64::STZ2GPostIndex:
4952 case AArch64::STGPi:
4953 case AArch64::STGPpost:
4954 case AArch64::STGPpre:
4960 case AArch64::LD1RB_IMM:
4961 case AArch64::LD1RB_H_IMM:
4962 case AArch64::LD1RB_S_IMM:
4963 case AArch64::LD1RB_D_IMM:
4964 case AArch64::LD1RSB_H_IMM:
4965 case AArch64::LD1RSB_S_IMM:
4966 case AArch64::LD1RSB_D_IMM:
4972 case AArch64::LD1RH_IMM:
4973 case AArch64::LD1RH_S_IMM:
4974 case AArch64::LD1RH_D_IMM:
4975 case AArch64::LD1RSH_S_IMM:
4976 case AArch64::LD1RSH_D_IMM:
4982 case AArch64::LD1RW_IMM:
4983 case AArch64::LD1RW_D_IMM:
4984 case AArch64::LD1RSW_IMM:
4990 case AArch64::LD1RD_IMM:
5006 case AArch64::LDRBui:
5007 case AArch64::LDRBBui:
5008 case AArch64::LDURBBi:
5009 case AArch64::LDRSBWui:
5010 case AArch64::LDURSBWi:
5011 case AArch64::STRBui:
5012 case AArch64::STRBBui:
5013 case AArch64::STURBBi:
5015 case AArch64::LDRHui:
5016 case AArch64::LDRHHui:
5017 case AArch64::LDURHHi:
5018 case AArch64::LDRSHWui:
5019 case AArch64::LDURSHWi:
5020 case AArch64::STRHui:
5021 case AArch64::STRHHui:
5022 case AArch64::STURHHi:
5024 case AArch64::LDRSui:
5025 case AArch64::LDURSi:
5026 case AArch64::LDRSpre:
5027 case AArch64::LDRSWui:
5028 case AArch64::LDURSWi:
5029 case AArch64::LDRSWpre:
5030 case AArch64::LDRWpre:
5031 case AArch64::LDRWui:
5032 case AArch64::LDURWi:
5033 case AArch64::STRSui:
5034 case AArch64::STURSi:
5035 case AArch64::STRSpre:
5036 case AArch64::STRWui:
5037 case AArch64::STURWi:
5038 case AArch64::STRWpre:
5039 case AArch64::LDPSi:
5040 case AArch64::LDPSWi:
5041 case AArch64::LDPWi:
5042 case AArch64::STPSi:
5043 case AArch64::STPWi:
5045 case AArch64::LDRDui:
5046 case AArch64::LDURDi:
5047 case AArch64::LDRDpre:
5048 case AArch64::LDRXui:
5049 case AArch64::LDURXi:
5050 case AArch64::LDRXpre:
5051 case AArch64::STRDui:
5052 case AArch64::STURDi:
5053 case AArch64::STRDpre:
5054 case AArch64::STRXui:
5055 case AArch64::STURXi:
5056 case AArch64::STRXpre:
5057 case AArch64::LDPDi:
5058 case AArch64::LDPXi:
5059 case AArch64::STPDi:
5060 case AArch64::STPXi:
5062 case AArch64::LDRQui:
5063 case AArch64::LDURQi:
5064 case AArch64::STRQui:
5065 case AArch64::STURQi:
5066 case AArch64::STRQpre:
5067 case AArch64::LDPQi:
5068 case AArch64::LDRQpre:
5069 case AArch64::STPQi:
5071 case AArch64::STZGi:
5072 case AArch64::ST2Gi:
5073 case AArch64::STZ2Gi:
5074 case AArch64::STGPi:
5080 switch (
MI.getOpcode()) {
5083 case AArch64::LDRWpre:
5084 case AArch64::LDRXpre:
5085 case AArch64::LDRSWpre:
5086 case AArch64::LDRSpre:
5087 case AArch64::LDRDpre:
5088 case AArch64::LDRQpre:
5094 switch (
MI.getOpcode()) {
5097 case AArch64::STRWpre:
5098 case AArch64::STRXpre:
5099 case AArch64::STRSpre:
5100 case AArch64::STRDpre:
5101 case AArch64::STRQpre:
5111 switch (
MI.getOpcode()) {
5114 case AArch64::LDURBBi:
5115 case AArch64::LDURHHi:
5116 case AArch64::LDURWi:
5117 case AArch64::LDRBBui:
5118 case AArch64::LDRHHui:
5119 case AArch64::LDRWui:
5120 case AArch64::LDRBBroX:
5121 case AArch64::LDRHHroX:
5122 case AArch64::LDRWroX:
5123 case AArch64::LDRBBroW:
5124 case AArch64::LDRHHroW:
5125 case AArch64::LDRWroW:
5131 switch (
MI.getOpcode()) {
5134 case AArch64::LDURSBWi:
5135 case AArch64::LDURSHWi:
5136 case AArch64::LDURSBXi:
5137 case AArch64::LDURSHXi:
5138 case AArch64::LDURSWi:
5139 case AArch64::LDRSBWui:
5140 case AArch64::LDRSHWui:
5141 case AArch64::LDRSBXui:
5142 case AArch64::LDRSHXui:
5143 case AArch64::LDRSWui:
5144 case AArch64::LDRSBWroX:
5145 case AArch64::LDRSHWroX:
5146 case AArch64::LDRSBXroX:
5147 case AArch64::LDRSHXroX:
5148 case AArch64::LDRSWroX:
5149 case AArch64::LDRSBWroW:
5150 case AArch64::LDRSHWroW:
5151 case AArch64::LDRSBXroW:
5152 case AArch64::LDRSHXroW:
5153 case AArch64::LDRSWroW:
5159 switch (
MI.getOpcode()) {
5162 case AArch64::LDPSi:
5163 case AArch64::LDPSWi:
5164 case AArch64::LDPDi:
5165 case AArch64::LDPQi:
5166 case AArch64::LDPWi:
5167 case AArch64::LDPXi:
5168 case AArch64::STPSi:
5169 case AArch64::STPDi:
5170 case AArch64::STPQi:
5171 case AArch64::STPWi:
5172 case AArch64::STPXi:
5173 case AArch64::STGPi:
5179 assert(
MI.mayLoadOrStore() &&
"Load or store instruction expected");
5183 return MI.getOperand(Idx);
5188 assert(
MI.mayLoadOrStore() &&
"Load or store instruction expected");
5192 return MI.getOperand(Idx);
5197 switch (
MI.getOpcode()) {
5200 case AArch64::LDRBroX:
5201 case AArch64::LDRBBroX:
5202 case AArch64::LDRSBXroX:
5203 case AArch64::LDRSBWroX:
5204 case AArch64::LDRHroX:
5205 case AArch64::LDRHHroX:
5206 case AArch64::LDRSHXroX:
5207 case AArch64::LDRSHWroX:
5208 case AArch64::LDRWroX:
5209 case AArch64::LDRSroX:
5210 case AArch64::LDRSWroX:
5211 case AArch64::LDRDroX:
5212 case AArch64::LDRXroX:
5213 case AArch64::LDRQroX:
5214 return MI.getOperand(4);
5220 if (
MI.getParent() ==
nullptr)
5230 auto Reg =
Op.getReg();
5231 if (Reg.isPhysical())
5232 return AArch64::FPR16RegClass.contains(Reg);
5234 return TRC == &AArch64::FPR16RegClass ||
5235 TRC == &AArch64::FPR16_loRegClass;
5244 auto Reg =
Op.getReg();
5245 if (Reg.isPhysical())
5246 return AArch64::FPR128RegClass.contains(Reg);
5248 return TRC == &AArch64::FPR128RegClass ||
5249 TRC == &AArch64::FPR128_loRegClass;
5255 switch (
MI.getOpcode()) {
5258 case AArch64::PACIASP:
5259 case AArch64::PACIBSP:
5262 case AArch64::PAUTH_PROLOGUE:
5265 case AArch64::HINT: {
5266 unsigned Imm =
MI.getOperand(0).getImm();
5268 if (Imm == 32 || Imm == 34 || Imm == 36 || Imm == 38)
5271 if (Imm == 25 || Imm == 27)
5283 assert(Reg.isPhysical() &&
"Expected physical register in isFpOrNEON");
5284 return AArch64::FPR128RegClass.contains(Reg) ||
5285 AArch64::FPR64RegClass.contains(Reg) ||
5286 AArch64::FPR32RegClass.contains(Reg) ||
5287 AArch64::FPR16RegClass.contains(Reg) ||
5288 AArch64::FPR8RegClass.contains(Reg);
5295 auto Reg =
Op.getReg();
5296 if (Reg.isPhysical())
5300 return TRC == &AArch64::FPR128RegClass ||
5301 TRC == &AArch64::FPR128_loRegClass ||
5302 TRC == &AArch64::FPR64RegClass ||
5303 TRC == &AArch64::FPR64_loRegClass ||
5304 TRC == &AArch64::FPR32RegClass || TRC == &AArch64::FPR16RegClass ||
5305 TRC == &AArch64::FPR8RegClass;
5327 if (FirstOpc == SecondOpc)
5333 case AArch64::STRSui:
5334 case AArch64::STURSi:
5335 return SecondOpc == AArch64::STRSui || SecondOpc == AArch64::STURSi;
5336 case AArch64::STRDui:
5337 case AArch64::STURDi:
5338 return SecondOpc == AArch64::STRDui || SecondOpc == AArch64::STURDi;
5339 case AArch64::STRQui:
5340 case AArch64::STURQi:
5341 return SecondOpc == AArch64::STRQui || SecondOpc == AArch64::STURQi;
5342 case AArch64::STRWui:
5343 case AArch64::STURWi:
5344 return SecondOpc == AArch64::STRWui || SecondOpc == AArch64::STURWi;
5345 case AArch64::STRXui:
5346 case AArch64::STURXi:
5347 return SecondOpc == AArch64::STRXui || SecondOpc == AArch64::STURXi;
5348 case AArch64::LDRSui:
5349 case AArch64::LDURSi:
5350 return SecondOpc == AArch64::LDRSui || SecondOpc == AArch64::LDURSi;
5351 case AArch64::LDRDui:
5352 case AArch64::LDURDi:
5353 return SecondOpc == AArch64::LDRDui || SecondOpc == AArch64::LDURDi;
5354 case AArch64::LDRQui:
5355 case AArch64::LDURQi:
5356 return SecondOpc == AArch64::LDRQui || SecondOpc == AArch64::LDURQi;
5357 case AArch64::LDRWui:
5358 case AArch64::LDURWi:
5359 return SecondOpc == AArch64::LDRSWui || SecondOpc == AArch64::LDURSWi;
5360 case AArch64::LDRSWui:
5361 case AArch64::LDURSWi:
5362 return SecondOpc == AArch64::LDRWui || SecondOpc == AArch64::LDURWi;
5363 case AArch64::LDRXui:
5364 case AArch64::LDURXi:
5365 return SecondOpc == AArch64::LDRXui || SecondOpc == AArch64::LDURXi;
5372 int64_t Offset1,
unsigned Opcode1,
int FI2,
5373 int64_t Offset2,
unsigned Opcode2) {
5379 assert(ObjectOffset1 <= ObjectOffset2 &&
"Object offsets are not ordered.");
5382 if (ObjectOffset1 % Scale1 != 0)
5384 ObjectOffset1 /= Scale1;
5386 if (ObjectOffset2 % Scale2 != 0)
5388 ObjectOffset2 /= Scale2;
5389 ObjectOffset1 += Offset1;
5390 ObjectOffset2 += Offset2;
5391 return ObjectOffset1 + 1 == ObjectOffset2;
5403 int64_t OpOffset2,
bool OffsetIsScalable2,
unsigned ClusterSize,
5404 unsigned NumBytes)
const {
5414 "Only base registers and frame indices are supported.");
5421 if (ClusterSize > 2)
5428 unsigned FirstOpc = FirstLdSt.
getOpcode();
5429 unsigned SecondOpc = SecondLdSt.
getOpcode();
5449 if (Offset1 > 63 || Offset1 < -64)
5454 if (BaseOp1.
isFI()) {
5456 "Caller should have ordered offsets.");
5461 BaseOp2.
getIndex(), Offset2, SecondOpc);
5464 assert(Offset1 <= Offset2 &&
"Caller should have ordered offsets.");
5466 return Offset1 + 1 == Offset2;
5476 if (
Reg.isPhysical())
5485 return ((DestReg - SrcReg) & 0x1f) < NumRegs;
5494 assert(Subtarget.hasNEON() &&
"Unexpected register copy without NEON");
5496 uint16_t DestEncoding =
TRI->getEncodingValue(DestReg);
5497 uint16_t SrcEncoding =
TRI->getEncodingValue(SrcReg);
5498 unsigned NumRegs = Indices.
size();
5500 int SubReg = 0, End = NumRegs, Incr = 1;
5502 SubReg = NumRegs - 1;
5507 for (; SubReg != End; SubReg += Incr) {
5519 unsigned Opcode,
unsigned ZeroReg,
5522 unsigned NumRegs = Indices.
size();
5525 uint16_t DestEncoding =
TRI->getEncodingValue(DestReg);
5526 uint16_t SrcEncoding =
TRI->getEncodingValue(SrcReg);
5527 assert(DestEncoding % NumRegs == 0 && SrcEncoding % NumRegs == 0 &&
5528 "GPR reg sequences should not be able to overlap");
5531 for (
unsigned SubReg = 0; SubReg != NumRegs; ++SubReg) {
5552 unsigned Opc =
MI.getOpcode();
5553 if (
Opc == AArch64::MSRpstatesvcrImm1 ||
Opc == AArch64::MSRpstatePseudo) {
5555 int64_t PState =
MI.getOperand(0).getImm();
5556 if (PState == AArch64SVCR::SVCRSM || PState == AArch64SVCR::SVCRSMZA) {
5558 return MI.getOperand(1).getImm() == 1;
5577 bool RenamableSrc)
const {
5579 if (AArch64::GPR32spRegClass.
contains(DestReg) &&
5580 AArch64::GPR32spRegClass.
contains(SrcReg)) {
5581 if (DestReg == AArch64::WSP || SrcReg == AArch64::WSP) {
5583 if (Subtarget.hasZeroCycleRegMoveGPR64() &&
5584 !Subtarget.hasZeroCycleRegMoveGPR32()) {
5586 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5587 &AArch64::GPR64spRegClass);
5588 MCRegister SrcRegX = RI.getMatchingSuperReg(SrcReg, AArch64::sub_32,
5589 &AArch64::GPR64spRegClass);
5599 ++NumZCRegMoveInstrsGPR;
5605 if (Subtarget.hasZeroCycleRegMoveGPR32())
5606 ++NumZCRegMoveInstrsGPR;
5608 }
else if (Subtarget.hasZeroCycleRegMoveGPR64() &&
5609 !Subtarget.hasZeroCycleRegMoveGPR32()) {
5611 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5612 &AArch64::GPR64spRegClass);
5613 assert(DestRegX.
isValid() &&
"Destination super-reg not valid");
5614 MCRegister SrcRegX = RI.getMatchingSuperReg(SrcReg, AArch64::sub_32,
5615 &AArch64::GPR64spRegClass);
5625 ++NumZCRegMoveInstrsGPR;
5631 if (Subtarget.hasZeroCycleRegMoveGPR32())
5632 ++NumZCRegMoveInstrsGPR;
5638 if (AArch64::GPR32spRegClass.
contains(DestReg) && SrcReg == AArch64::WZR) {
5639 if (Subtarget.hasZeroCycleZeroingGPR64() &&
5640 !Subtarget.hasZeroCycleZeroingGPR32()) {
5641 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5642 &AArch64::GPR64spRegClass);
5643 assert(DestRegX.
isValid() &&
"Destination super-reg not valid");
5647 ++NumZCZeroingInstrsGPR;
5648 }
else if (Subtarget.hasZeroCycleZeroingGPR32()) {
5652 ++NumZCZeroingInstrsGPR;
5661 if (AArch64::GPR64spRegClass.
contains(DestReg) &&
5662 AArch64::GPR64spRegClass.
contains(SrcReg)) {
5663 if (DestReg == AArch64::SP || SrcReg == AArch64::SP) {
5669 if (Subtarget.hasZeroCycleRegMoveGPR64())
5670 ++NumZCRegMoveInstrsGPR;
5676 if (Subtarget.hasZeroCycleRegMoveGPR64())
5677 ++NumZCRegMoveInstrsGPR;
5683 if (AArch64::GPR64spRegClass.
contains(DestReg) && SrcReg == AArch64::XZR) {
5684 if (Subtarget.hasZeroCycleZeroingGPR64()) {
5688 ++NumZCZeroingInstrsGPR;
5698 if (AArch64::PPRRegClass.
contains(DestReg) &&
5699 AArch64::PPRRegClass.
contains(SrcReg)) {
5700 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
5701 "Unexpected SVE register.");
5711 bool DestIsPNR = AArch64::PNRRegClass.contains(DestReg);
5712 bool SrcIsPNR = AArch64::PNRRegClass.contains(SrcReg);
5713 if (DestIsPNR || SrcIsPNR) {
5715 return (R - AArch64::PN0) + AArch64::P0;
5720 if (PPRSrcReg != PPRDestReg) {
5732 if (AArch64::ZPRRegClass.
contains(DestReg) &&
5733 AArch64::ZPRRegClass.
contains(SrcReg)) {
5734 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
5735 "Unexpected SVE register.");
5743 if ((AArch64::ZPR2RegClass.
contains(DestReg) ||
5744 AArch64::ZPR2StridedOrContiguousRegClass.
contains(DestReg)) &&
5745 (AArch64::ZPR2RegClass.
contains(SrcReg) ||
5746 AArch64::ZPR2StridedOrContiguousRegClass.
contains(SrcReg))) {
5747 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
5748 "Unexpected SVE register.");
5749 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1};
5756 if (AArch64::ZPR3RegClass.
contains(DestReg) &&
5757 AArch64::ZPR3RegClass.
contains(SrcReg)) {
5758 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
5759 "Unexpected SVE register.");
5760 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1,
5768 if ((AArch64::ZPR4RegClass.
contains(DestReg) ||
5769 AArch64::ZPR4StridedOrContiguousRegClass.
contains(DestReg)) &&
5770 (AArch64::ZPR4RegClass.
contains(SrcReg) ||
5771 AArch64::ZPR4StridedOrContiguousRegClass.
contains(SrcReg))) {
5772 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
5773 "Unexpected SVE register.");
5774 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1,
5775 AArch64::zsub2, AArch64::zsub3};
5782 if (AArch64::DDDDRegClass.
contains(DestReg) &&
5783 AArch64::DDDDRegClass.
contains(SrcReg)) {
5784 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1,
5785 AArch64::dsub2, AArch64::dsub3};
5792 if (AArch64::DDDRegClass.
contains(DestReg) &&
5793 AArch64::DDDRegClass.
contains(SrcReg)) {
5794 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1,
5802 if (AArch64::DDRegClass.
contains(DestReg) &&
5803 AArch64::DDRegClass.
contains(SrcReg)) {
5804 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1};
5811 if (AArch64::QQQQRegClass.
contains(DestReg) &&
5812 AArch64::QQQQRegClass.
contains(SrcReg)) {
5813 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1,
5814 AArch64::qsub2, AArch64::qsub3};
5821 if (AArch64::QQQRegClass.
contains(DestReg) &&
5822 AArch64::QQQRegClass.
contains(SrcReg)) {
5823 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1,
5831 if (AArch64::QQRegClass.
contains(DestReg) &&
5832 AArch64::QQRegClass.
contains(SrcReg)) {
5833 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1};
5839 if (AArch64::XSeqPairsClassRegClass.
contains(DestReg) &&
5840 AArch64::XSeqPairsClassRegClass.
contains(SrcReg)) {
5841 static const unsigned Indices[] = {AArch64::sube64, AArch64::subo64};
5843 AArch64::XZR, Indices);
5847 if (AArch64::WSeqPairsClassRegClass.
contains(DestReg) &&
5848 AArch64::WSeqPairsClassRegClass.
contains(SrcReg)) {
5849 static const unsigned Indices[] = {AArch64::sube32, AArch64::subo32};
5851 AArch64::WZR, Indices);
5855 if (AArch64::FPR128RegClass.
contains(DestReg) &&
5856 AArch64::FPR128RegClass.
contains(SrcReg)) {
5860 if ((Subtarget.isSVEorStreamingSVEAvailable() &&
5861 !Subtarget.isNeonAvailable()) ||
5865 .
addReg(AArch64::Z0 + (SrcReg - AArch64::Q0))
5866 .
addReg(AArch64::Z0 + (SrcReg - AArch64::Q0));
5867 }
else if (Subtarget.isNeonAvailable()) {
5871 if (Subtarget.hasZeroCycleRegMoveFPR128())
5872 ++NumZCRegMoveInstrsFPR;
5888 if (AArch64::FPR64RegClass.
contains(DestReg) &&
5889 AArch64::FPR64RegClass.
contains(SrcReg)) {
5890 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
5891 !Subtarget.hasZeroCycleRegMoveFPR64() &&
5892 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
5894 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::dsub,
5895 &AArch64::FPR128RegClass);
5896 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::dsub,
5897 &AArch64::FPR128RegClass);
5906 ++NumZCRegMoveInstrsFPR;
5910 if (Subtarget.hasZeroCycleRegMoveFPR64())
5911 ++NumZCRegMoveInstrsFPR;
5916 if (AArch64::FPR32RegClass.
contains(DestReg) &&
5917 AArch64::FPR32RegClass.
contains(SrcReg)) {
5918 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
5919 !Subtarget.hasZeroCycleRegMoveFPR64() &&
5920 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
5922 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::ssub,
5923 &AArch64::FPR128RegClass);
5924 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::ssub,
5925 &AArch64::FPR128RegClass);
5934 ++NumZCRegMoveInstrsFPR;
5935 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
5936 !Subtarget.hasZeroCycleRegMoveFPR32()) {
5937 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::ssub,
5938 &AArch64::FPR64RegClass);
5939 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::ssub,
5940 &AArch64::FPR64RegClass);
5948 ++NumZCRegMoveInstrsFPR;
5952 if (Subtarget.hasZeroCycleRegMoveFPR32())
5953 ++NumZCRegMoveInstrsFPR;
5958 if (AArch64::FPR16RegClass.
contains(DestReg) &&
5959 AArch64::FPR16RegClass.
contains(SrcReg)) {
5960 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
5961 !Subtarget.hasZeroCycleRegMoveFPR64() &&
5962 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
5964 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
5965 &AArch64::FPR128RegClass);
5966 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
5967 &AArch64::FPR128RegClass);
5976 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
5977 !Subtarget.hasZeroCycleRegMoveFPR32()) {
5978 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
5979 &AArch64::FPR64RegClass);
5980 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
5981 &AArch64::FPR64RegClass);
5990 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
5991 &AArch64::FPR32RegClass);
5992 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
5993 &AArch64::FPR32RegClass);
6000 if (AArch64::FPR8RegClass.
contains(DestReg) &&
6001 AArch64::FPR8RegClass.
contains(SrcReg)) {
6002 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
6003 !Subtarget.hasZeroCycleRegMoveFPR64() &&
6004 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
6006 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
6007 &AArch64::FPR128RegClass);
6008 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
6009 &AArch64::FPR128RegClass);
6018 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
6019 !Subtarget.hasZeroCycleRegMoveFPR32()) {
6020 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
6021 &AArch64::FPR64RegClass);
6022 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
6023 &AArch64::FPR64RegClass);
6032 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
6033 &AArch64::FPR32RegClass);
6034 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
6035 &AArch64::FPR32RegClass);
6043 if (AArch64::FPR64RegClass.
contains(DestReg) &&
6044 AArch64::GPR64RegClass.
contains(SrcReg)) {
6045 if (AArch64::XZR == SrcReg) {
6053 if (AArch64::GPR64RegClass.
contains(DestReg) &&
6054 AArch64::FPR64RegClass.
contains(SrcReg)) {
6060 if (AArch64::FPR32RegClass.
contains(DestReg) &&
6061 AArch64::GPR32RegClass.
contains(SrcReg)) {
6062 if (AArch64::WZR == SrcReg) {
6070 if (AArch64::GPR32RegClass.
contains(DestReg) &&
6071 AArch64::FPR32RegClass.
contains(SrcReg)) {
6077 if (DestReg == AArch64::NZCV) {
6078 assert(AArch64::GPR64RegClass.
contains(SrcReg) &&
"Invalid NZCV copy");
6080 .
addImm(AArch64SysReg::NZCV)
6086 if (SrcReg == AArch64::NZCV) {
6087 assert(AArch64::GPR64RegClass.
contains(DestReg) &&
"Invalid NZCV copy");
6089 .
addImm(AArch64SysReg::NZCV)
6095 errs() << RI.getRegAsmName(DestReg) <<
" = COPY " << RI.getRegAsmName(SrcReg)
6106 unsigned SubIdx0,
unsigned SubIdx1,
int FI,
6111 SrcReg0 =
TRI.getSubReg(SrcReg, SubIdx0);
6113 SrcReg1 =
TRI.getSubReg(SrcReg, SubIdx1);
6126 Register SrcReg,
bool isKill,
int FI,
6141 switch (RI.getSpillSize(*RC)) {
6143 if (AArch64::FPR8RegClass.hasSubClassEq(RC))
6144 Opc = AArch64::STRBui;
6147 if (AArch64::FPR16RegClass.hasSubClassEq(RC))
6148 Opc = AArch64::STRHui;
6149 else if (AArch64::PNRRegClass.hasSubClassEq(RC) ||
6150 AArch64::PPRRegClass.hasSubClassEq(RC)) {
6151 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6152 "Unexpected register store without SVE store instructions");
6153 Opc = AArch64::STR_PXI;
6159 if (AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
6160 Opc = AArch64::STRWui;
6164 assert(SrcReg != AArch64::WSP);
6165 }
else if (AArch64::FPR32RegClass.hasSubClassEq(RC))
6166 Opc = AArch64::STRSui;
6167 else if (AArch64::PPR2RegClass.hasSubClassEq(RC)) {
6168 Opc = AArch64::STR_PPXI;
6173 if (AArch64::GPR64allRegClass.hasSubClassEq(RC)) {
6174 Opc = AArch64::STRXui;
6178 assert(SrcReg != AArch64::SP);
6179 }
else if (AArch64::FPR64RegClass.hasSubClassEq(RC)) {
6180 Opc = AArch64::STRDui;
6181 }
else if (AArch64::WSeqPairsClassRegClass.hasSubClassEq(RC)) {
6183 get(AArch64::STPWi), SrcReg, isKill,
6184 AArch64::sube32, AArch64::subo32, FI, MMO);
6189 if (AArch64::FPR128RegClass.hasSubClassEq(RC))
6190 Opc = AArch64::STRQui;
6191 else if (AArch64::DDRegClass.hasSubClassEq(RC)) {
6192 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6193 Opc = AArch64::ST1Twov1d;
6195 }
else if (AArch64::XSeqPairsClassRegClass.hasSubClassEq(RC)) {
6197 get(AArch64::STPXi), SrcReg, isKill,
6198 AArch64::sube64, AArch64::subo64, FI, MMO);
6200 }
else if (AArch64::ZPRRegClass.hasSubClassEq(RC)) {
6201 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6202 "Unexpected register store without SVE store instructions");
6203 Opc = AArch64::STR_ZXI;
6208 if (AArch64::DDDRegClass.hasSubClassEq(RC)) {
6209 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6210 Opc = AArch64::ST1Threev1d;
6215 if (AArch64::DDDDRegClass.hasSubClassEq(RC)) {
6216 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6217 Opc = AArch64::ST1Fourv1d;
6219 }
else if (AArch64::QQRegClass.hasSubClassEq(RC)) {
6220 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6221 Opc = AArch64::ST1Twov2d;
6223 }
else if (AArch64::ZPR2StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6224 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6225 "Unexpected register store without SVE store instructions");
6226 Opc = AArch64::STR_ZZXI_STRIDED_CONTIGUOUS;
6228 }
else if (AArch64::ZPR2RegClass.hasSubClassEq(RC)) {
6229 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6230 "Unexpected register store without SVE store instructions");
6231 Opc = AArch64::STR_ZZXI;
6236 if (AArch64::QQQRegClass.hasSubClassEq(RC)) {
6237 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6238 Opc = AArch64::ST1Threev2d;
6240 }
else if (AArch64::ZPR3RegClass.hasSubClassEq(RC)) {
6241 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6242 "Unexpected register store without SVE store instructions");
6243 Opc = AArch64::STR_ZZZXI;
6248 if (AArch64::QQQQRegClass.hasSubClassEq(RC)) {
6249 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6250 Opc = AArch64::ST1Fourv2d;
6252 }
else if (AArch64::ZPR4StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6253 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6254 "Unexpected register store without SVE store instructions");
6255 Opc = AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS;
6257 }
else if (AArch64::ZPR4RegClass.hasSubClassEq(RC)) {
6258 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6259 "Unexpected register store without SVE store instructions");
6260 Opc = AArch64::STR_ZZZZXI;
6265 assert(
Opc &&
"Unknown register class");
6276 MI.addMemOperand(MMO);
6283 Register DestReg,
unsigned SubIdx0,
6284 unsigned SubIdx1,
int FI,
6288 bool IsUndef =
true;
6290 DestReg0 =
TRI.getSubReg(DestReg, SubIdx0);
6292 DestReg1 =
TRI.getSubReg(DestReg, SubIdx1);
6321 switch (
TRI.getSpillSize(*RC)) {
6323 if (AArch64::FPR8RegClass.hasSubClassEq(RC))
6324 Opc = AArch64::LDRBui;
6327 bool IsPNR = AArch64::PNRRegClass.hasSubClassEq(RC);
6328 if (AArch64::FPR16RegClass.hasSubClassEq(RC))
6329 Opc = AArch64::LDRHui;
6330 else if (IsPNR || AArch64::PPRRegClass.hasSubClassEq(RC)) {
6331 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6332 "Unexpected register load without SVE load instructions");
6335 Opc = AArch64::LDR_PXI;
6341 if (AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
6342 Opc = AArch64::LDRWui;
6346 assert(DestReg != AArch64::WSP);
6347 }
else if (AArch64::FPR32RegClass.hasSubClassEq(RC))
6348 Opc = AArch64::LDRSui;
6349 else if (AArch64::PPR2RegClass.hasSubClassEq(RC)) {
6350 Opc = AArch64::LDR_PPXI;
6355 if (AArch64::GPR64allRegClass.hasSubClassEq(RC)) {
6356 Opc = AArch64::LDRXui;
6360 assert(DestReg != AArch64::SP);
6361 }
else if (AArch64::FPR64RegClass.hasSubClassEq(RC)) {
6362 Opc = AArch64::LDRDui;
6363 }
else if (AArch64::WSeqPairsClassRegClass.hasSubClassEq(RC)) {
6365 get(AArch64::LDPWi), DestReg, AArch64::sube32,
6366 AArch64::subo32, FI, MMO);
6371 if (AArch64::FPR128RegClass.hasSubClassEq(RC))
6372 Opc = AArch64::LDRQui;
6373 else if (AArch64::DDRegClass.hasSubClassEq(RC)) {
6374 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6375 Opc = AArch64::LD1Twov1d;
6377 }
else if (AArch64::XSeqPairsClassRegClass.hasSubClassEq(RC)) {
6379 get(AArch64::LDPXi), DestReg, AArch64::sube64,
6380 AArch64::subo64, FI, MMO);
6382 }
else if (AArch64::ZPRRegClass.hasSubClassEq(RC)) {
6383 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6384 "Unexpected register load without SVE load instructions");
6385 Opc = AArch64::LDR_ZXI;
6390 if (AArch64::DDDRegClass.hasSubClassEq(RC)) {
6391 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6392 Opc = AArch64::LD1Threev1d;
6397 if (AArch64::DDDDRegClass.hasSubClassEq(RC)) {
6398 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6399 Opc = AArch64::LD1Fourv1d;
6401 }
else if (AArch64::QQRegClass.hasSubClassEq(RC)) {
6402 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6403 Opc = AArch64::LD1Twov2d;
6405 }
else if (AArch64::ZPR2StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6406 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6407 "Unexpected register load without SVE load instructions");
6408 Opc = AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS;
6410 }
else if (AArch64::ZPR2RegClass.hasSubClassEq(RC)) {
6411 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6412 "Unexpected register load without SVE load instructions");
6413 Opc = AArch64::LDR_ZZXI;
6418 if (AArch64::QQQRegClass.hasSubClassEq(RC)) {
6419 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6420 Opc = AArch64::LD1Threev2d;
6422 }
else if (AArch64::ZPR3RegClass.hasSubClassEq(RC)) {
6423 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6424 "Unexpected register load without SVE load instructions");
6425 Opc = AArch64::LDR_ZZZXI;
6430 if (AArch64::QQQQRegClass.hasSubClassEq(RC)) {
6431 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6432 Opc = AArch64::LD1Fourv2d;
6434 }
else if (AArch64::ZPR4StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6435 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6436 "Unexpected register load without SVE load instructions");
6437 Opc = AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS;
6439 }
else if (AArch64::ZPR4RegClass.hasSubClassEq(RC)) {
6440 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6441 "Unexpected register load without SVE load instructions");
6442 Opc = AArch64::LDR_ZZZZXI;
6448 assert(
Opc &&
"Unknown register class");
6458 MI.addMemOperand(MMO);
6465 UseMI.getIterator()),
6467 return I.modifiesRegister(AArch64::NZCV, TRI) ||
6468 I.readsRegister(AArch64::NZCV, TRI);
6472void AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
6477 assert(
Offset.getScalable() % 2 == 0 &&
"Invalid frame offset");
6484 ByteSized =
Offset.getFixed();
6485 VGSized =
Offset.getScalable() / 2;
6491void AArch64InstrInfo::decomposeStackOffsetForFrameOffsets(
6493 int64_t &NumDataVectors) {
6497 assert(
Offset.getScalable() % 2 == 0 &&
"Invalid frame offset");
6499 NumBytes =
Offset.getFixed();
6501 NumPredicateVectors =
Offset.getScalable() / 2;
6506 if (NumPredicateVectors % 8 == 0 || NumPredicateVectors < -64 ||
6507 NumPredicateVectors > 62) {
6508 NumDataVectors = NumPredicateVectors / 8;
6509 NumPredicateVectors -= NumDataVectors * 8;
6535 Expr.
push_back((
char)dwarf::DW_OP_bregx);
6543 int64_t OffsetFromDefCFA) {
6557 Comment << (NumBytes < 0 ?
" - " :
" + ") << std::abs(NumBytes);
6558 if (!RegScale.empty())
6568 int64_t NumBytes, NumVGScaledBytes;
6569 AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
Offset, NumBytes,
6571 std::string CommentBuffer;
6574 if (
Reg == AArch64::SP)
6576 else if (
Reg == AArch64::FP)
6583 unsigned DwarfReg =
TRI.getDwarfRegNum(
Reg,
true);
6584 assert(DwarfReg <= 31 &&
"DwarfReg out of bounds (0..31)");
6586 Expr.
push_back(dwarf::DW_OP_breg0 + DwarfReg);
6589 if (NumVGScaledBytes) {
6599 DefCfaExpr.
push_back(dwarf::DW_CFA_def_cfa_expression);
6607 unsigned FrameReg,
unsigned Reg,
6609 bool LastAdjustmentWasScalable) {
6610 if (
Offset.getScalable())
6613 if (FrameReg == Reg && !LastAdjustmentWasScalable)
6616 unsigned DwarfReg =
TRI.getDwarfRegNum(Reg,
true);
6623 std::optional<int64_t> IncomingVGOffsetFromDefCFA) {
6624 int64_t NumBytes, NumVGScaledBytes;
6625 AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
6626 OffsetFromDefCFA, NumBytes, NumVGScaledBytes);
6628 unsigned DwarfReg =
TRI.getDwarfRegNum(Reg,
true);
6631 if (!NumVGScaledBytes)
6634 std::string CommentBuffer;
6639 assert(NumVGScaledBytes &&
"Expected scalable offset");
6643 if (IncomingVGOffsetFromDefCFA) {
6645 VGRegScale =
"* IncomingVG";
6648 VGRegScale =
"* VG";
6652 OffsetExpr.
push_back(dwarf::DW_OP_plus);
6661 CfaExpr.
push_back(dwarf::DW_CFA_expression);
6676 unsigned SrcReg, int64_t
Offset,
unsigned Opc,
6679 bool *HasWinCFI,
bool EmitCFAOffset,
6682 unsigned MaxEncoding, ShiftSize;
6684 case AArch64::ADDXri:
6685 case AArch64::ADDSXri:
6686 case AArch64::SUBXri:
6687 case AArch64::SUBSXri:
6688 MaxEncoding = 0xfff;
6691 case AArch64::ADDVL_XXI:
6692 case AArch64::ADDPL_XXI:
6693 case AArch64::ADDSVL_XXI:
6694 case AArch64::ADDSPL_XXI:
6709 if (
Opc == AArch64::ADDVL_XXI ||
Opc == AArch64::ADDSVL_XXI)
6711 else if (
Opc == AArch64::ADDPL_XXI ||
Opc == AArch64::ADDSPL_XXI)
6725 const unsigned MaxEncodableValue = MaxEncoding << ShiftSize;
6727 if (TmpReg == AArch64::XZR)
6728 TmpReg =
MBB.getParent()->getRegInfo().createVirtualRegister(
6729 &AArch64::GPR64RegClass);
6731 uint64_t ThisVal = std::min<uint64_t>(
Offset, MaxEncodableValue);
6732 unsigned LocalShiftSize = 0;
6733 if (ThisVal > MaxEncoding) {
6734 ThisVal = ThisVal >> ShiftSize;
6735 LocalShiftSize = ShiftSize;
6737 assert((ThisVal >> ShiftSize) <= MaxEncoding &&
6738 "Encoding cannot handle value that big");
6740 Offset -= ThisVal << LocalShiftSize;
6745 .
addImm(Sign * (
int)ThisVal);
6755 if (Sign == -1 ||
Opc == AArch64::SUBXri ||
Opc == AArch64::SUBSXri)
6756 CFAOffset += Change;
6758 CFAOffset -= Change;
6759 if (EmitCFAOffset && DestReg == TmpReg) {
6772 int Imm = (int)(ThisVal << LocalShiftSize);
6773 if (VScale != 1 && DestReg == AArch64::SP) {
6779 }
else if ((DestReg == AArch64::FP && SrcReg == AArch64::SP) ||
6780 (SrcReg == AArch64::FP && DestReg == AArch64::SP)) {
6781 assert(VScale == 1 &&
"Expected non-scalable operation");
6790 assert(
Offset == 0 &&
"Expected remaining offset to be zero to "
6791 "emit a single SEH directive");
6792 }
else if (DestReg == AArch64::SP) {
6793 assert(VScale == 1 &&
"Expected non-scalable operation");
6796 assert(SrcReg == AArch64::SP &&
"Unexpected SrcReg for SEH_StackAlloc");
6809 unsigned DestReg,
unsigned SrcReg,
6812 bool NeedsWinCFI,
bool *HasWinCFI,
6814 unsigned FrameReg) {
6821 bool UseSVL =
F.hasFnAttribute(
"aarch64_pstate_sm_body");
6823 int64_t Bytes, NumPredicateVectors, NumDataVectors;
6824 AArch64InstrInfo::decomposeStackOffsetForFrameOffsets(
6825 Offset, Bytes, NumPredicateVectors, NumDataVectors);
6828 bool NeedsFinalDefNZCV = SetNZCV && (NumPredicateVectors || NumDataVectors);
6829 if (NeedsFinalDefNZCV)
6833 if (Bytes || (!
Offset && SrcReg != DestReg)) {
6834 assert((DestReg != AArch64::SP || Bytes % 8 == 0) &&
6835 "SP increment/decrement not 8-byte aligned");
6836 unsigned Opc = SetNZCV ? AArch64::ADDSXri : AArch64::ADDXri;
6839 Opc = SetNZCV ? AArch64::SUBSXri : AArch64::SUBXri;
6842 NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
6844 CFAOffset += (
Opc == AArch64::ADDXri ||
Opc == AArch64::ADDSXri)
6851 assert(!(NeedsWinCFI && NumPredicateVectors) &&
6852 "WinCFI can't allocate fractions of an SVE data vector");
6854 if (NumDataVectors) {
6856 UseSVL ? AArch64::ADDSVL_XXI : AArch64::ADDVL_XXI,
TII,
6857 Flag, NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
6863 if (NumPredicateVectors) {
6864 assert(DestReg != AArch64::SP &&
"Unaligned access to SP");
6866 UseSVL ? AArch64::ADDSPL_XXI : AArch64::ADDPL_XXI,
TII,
6867 Flag, NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
6871 if (NeedsFinalDefNZCV)
6893 if (
MI.isFullCopy()) {
6896 if (SrcReg == AArch64::SP && DstReg.
isVirtual()) {
6900 if (DstReg == AArch64::SP && SrcReg.
isVirtual()) {
6905 if (SrcReg == AArch64::NZCV || DstReg == AArch64::NZCV)
6933 if (
MI.isCopy() &&
Ops.size() == 1 &&
6935 (
Ops[0] == 0 ||
Ops[0] == 1)) {
6936 bool IsSpill =
Ops[0] == 0;
6937 bool IsFill = !IsSpill;
6949 :
TRI.getMinimalPhysRegClass(Reg);
6955 "Mismatched register size in non subreg COPY");
6962 return &*--InsertPt;
6974 if (IsSpill && DstMO.
isUndef() && SrcReg == AArch64::WZR &&
6977 "Unexpected subreg on physical register");
6979 FrameIndex, &AArch64::GPR64RegClass,
Register());
6980 return &*--InsertPt;
6997 case AArch64::sub_32:
6998 if (AArch64::GPR64RegClass.hasSubClassEq(
getRegClass(DstReg)))
6999 FillRC = &AArch64::GPR32RegClass;
7002 FillRC = &AArch64::FPR32RegClass;
7005 FillRC = &AArch64::FPR64RegClass;
7011 TRI.getRegSizeInBits(*FillRC) &&
7012 "Mismatched regclass size on folded subreg COPY");
7031 bool *OutUseUnscaledOp,
7032 unsigned *OutUnscaledOp,
7033 int64_t *EmittableOffset) {
7035 if (EmittableOffset)
7036 *EmittableOffset = 0;
7037 if (OutUseUnscaledOp)
7038 *OutUseUnscaledOp =
false;
7044 switch (
MI.getOpcode()) {
7047 case AArch64::LD1Rv1d:
7048 case AArch64::LD1Rv2s:
7049 case AArch64::LD1Rv2d:
7050 case AArch64::LD1Rv4h:
7051 case AArch64::LD1Rv4s:
7052 case AArch64::LD1Rv8b:
7053 case AArch64::LD1Rv8h:
7054 case AArch64::LD1Rv16b:
7055 case AArch64::LD1Twov2d:
7056 case AArch64::LD1Threev2d:
7057 case AArch64::LD1Fourv2d:
7058 case AArch64::LD1Twov1d:
7059 case AArch64::LD1Threev1d:
7060 case AArch64::LD1Fourv1d:
7061 case AArch64::ST1Twov2d:
7062 case AArch64::ST1Threev2d:
7063 case AArch64::ST1Fourv2d:
7064 case AArch64::ST1Twov1d:
7065 case AArch64::ST1Threev1d:
7066 case AArch64::ST1Fourv1d:
7067 case AArch64::ST1i8:
7068 case AArch64::ST1i16:
7069 case AArch64::ST1i32:
7070 case AArch64::ST1i64:
7072 case AArch64::IRGstack:
7073 case AArch64::STGloop:
7074 case AArch64::STZGloop:
7079 TypeSize ScaleValue(0U,
false), Width(0U,
false);
7080 int64_t MinOff, MaxOff;
7086 bool IsMulVL = ScaleValue.isScalable();
7087 unsigned Scale = ScaleValue.getKnownMinValue();
7097 std::optional<unsigned> UnscaledOp =
7099 bool useUnscaledOp = UnscaledOp && (
Offset % Scale ||
Offset < 0);
7100 if (useUnscaledOp &&
7105 Scale = ScaleValue.getKnownMinValue();
7106 assert(IsMulVL == ScaleValue.isScalable() &&
7107 "Unscaled opcode has different value for scalable");
7109 int64_t Remainder =
Offset % Scale;
7110 assert(!(Remainder && useUnscaledOp) &&
7111 "Cannot have remainder when using unscaled op");
7113 assert(MinOff < MaxOff &&
"Unexpected Min/Max offsets");
7114 int64_t NewOffset =
Offset / Scale;
7115 if (MinOff <= NewOffset && NewOffset <= MaxOff)
7118 NewOffset = NewOffset < 0 ? MinOff : MaxOff;
7122 if (EmittableOffset)
7123 *EmittableOffset = NewOffset;
7124 if (OutUseUnscaledOp)
7125 *OutUseUnscaledOp = useUnscaledOp;
7126 if (OutUnscaledOp && UnscaledOp)
7127 *OutUnscaledOp = *UnscaledOp;
7140 unsigned Opcode =
MI.getOpcode();
7141 unsigned ImmIdx = FrameRegIdx + 1;
7143 if (Opcode == AArch64::ADDSXri || Opcode == AArch64::ADDXri) {
7148 MI.eraseFromParent();
7154 unsigned UnscaledOp;
7157 &UnscaledOp, &NewOffset);
7161 MI.getOperand(FrameRegIdx).ChangeToRegister(FrameReg,
false);
7163 MI.setDesc(
TII->get(UnscaledOp));
7165 MI.getOperand(ImmIdx).ChangeToImmediate(NewOffset);
7181bool AArch64InstrInfo::useMachineCombiner()
const {
return true; }
7186 case AArch64::ADDSWrr:
7187 case AArch64::ADDSWri:
7188 case AArch64::ADDSXrr:
7189 case AArch64::ADDSXri:
7190 case AArch64::SUBSWrr:
7191 case AArch64::SUBSXrr:
7193 case AArch64::SUBSWri:
7194 case AArch64::SUBSXri:
7205 case AArch64::ADDWrr:
7206 case AArch64::ADDWri:
7207 case AArch64::SUBWrr:
7208 case AArch64::ADDSWrr:
7209 case AArch64::ADDSWri:
7210 case AArch64::SUBSWrr:
7212 case AArch64::SUBWri:
7213 case AArch64::SUBSWri:
7224 case AArch64::ADDXrr:
7225 case AArch64::ADDXri:
7226 case AArch64::SUBXrr:
7227 case AArch64::ADDSXrr:
7228 case AArch64::ADDSXri:
7229 case AArch64::SUBSXrr:
7231 case AArch64::SUBXri:
7232 case AArch64::SUBSXri:
7233 case AArch64::ADDv8i8:
7234 case AArch64::ADDv16i8:
7235 case AArch64::ADDv4i16:
7236 case AArch64::ADDv8i16:
7237 case AArch64::ADDv2i32:
7238 case AArch64::ADDv4i32:
7239 case AArch64::SUBv8i8:
7240 case AArch64::SUBv16i8:
7241 case AArch64::SUBv4i16:
7242 case AArch64::SUBv8i16:
7243 case AArch64::SUBv2i32:
7244 case AArch64::SUBv4i32:
7257 case AArch64::FADDHrr:
7258 case AArch64::FADDSrr:
7259 case AArch64::FADDDrr:
7260 case AArch64::FADDv4f16:
7261 case AArch64::FADDv8f16:
7262 case AArch64::FADDv2f32:
7263 case AArch64::FADDv2f64:
7264 case AArch64::FADDv4f32:
7265 case AArch64::FSUBHrr:
7266 case AArch64::FSUBSrr:
7267 case AArch64::FSUBDrr:
7268 case AArch64::FSUBv4f16:
7269 case AArch64::FSUBv8f16:
7270 case AArch64::FSUBv2f32:
7271 case AArch64::FSUBv2f64:
7272 case AArch64::FSUBv4f32:
7291 unsigned CombineOpc,
unsigned ZeroReg = 0,
7292 bool CheckZeroReg =
false) {
7299 if (!
MI ||
MI->getParent() != &
MBB ||
MI->getOpcode() != CombineOpc)
7306 assert(
MI->getNumOperands() >= 4 &&
MI->getOperand(0).isReg() &&
7307 MI->getOperand(1).isReg() &&
MI->getOperand(2).isReg() &&
7308 MI->getOperand(3).isReg() &&
"MAdd/MSub must have a least 4 regs");
7310 if (
MI->getOperand(3).getReg() != ZeroReg)
7315 MI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
true) == -1)
7324 unsigned MulOpc,
unsigned ZeroReg) {
7339bool AArch64InstrInfo::isAssociativeAndCommutative(
const MachineInstr &Inst,
7340 bool Invert)
const {
7346 case AArch64::FADDHrr:
7347 case AArch64::FADDSrr:
7348 case AArch64::FADDDrr:
7349 case AArch64::FMULHrr:
7350 case AArch64::FMULSrr:
7351 case AArch64::FMULDrr:
7352 case AArch64::FMULX16:
7353 case AArch64::FMULX32:
7354 case AArch64::FMULX64:
7356 case AArch64::FADDv4f16:
7357 case AArch64::FADDv8f16:
7358 case AArch64::FADDv2f32:
7359 case AArch64::FADDv4f32:
7360 case AArch64::FADDv2f64:
7361 case AArch64::FMULv4f16:
7362 case AArch64::FMULv8f16:
7363 case AArch64::FMULv2f32:
7364 case AArch64::FMULv4f32:
7365 case AArch64::FMULv2f64:
7366 case AArch64::FMULXv4f16:
7367 case AArch64::FMULXv8f16:
7368 case AArch64::FMULXv2f32:
7369 case AArch64::FMULXv4f32:
7370 case AArch64::FMULXv2f64:
7374 case AArch64::FADD_ZZZ_H:
7375 case AArch64::FADD_ZZZ_S:
7376 case AArch64::FADD_ZZZ_D:
7377 case AArch64::FMUL_ZZZ_H:
7378 case AArch64::FMUL_ZZZ_S:
7379 case AArch64::FMUL_ZZZ_D:
7390 case AArch64::ADDWrr:
7391 case AArch64::ADDXrr:
7392 case AArch64::ANDWrr:
7393 case AArch64::ANDXrr:
7394 case AArch64::ORRWrr:
7395 case AArch64::ORRXrr:
7396 case AArch64::EORWrr:
7397 case AArch64::EORXrr:
7398 case AArch64::EONWrr:
7399 case AArch64::EONXrr:
7403 case AArch64::ADDv8i8:
7404 case AArch64::ADDv16i8:
7405 case AArch64::ADDv4i16:
7406 case AArch64::ADDv8i16:
7407 case AArch64::ADDv2i32:
7408 case AArch64::ADDv4i32:
7409 case AArch64::ADDv1i64:
7410 case AArch64::ADDv2i64:
7411 case AArch64::MULv8i8:
7412 case AArch64::MULv16i8:
7413 case AArch64::MULv4i16:
7414 case AArch64::MULv8i16:
7415 case AArch64::MULv2i32:
7416 case AArch64::MULv4i32:
7417 case AArch64::ANDv8i8:
7418 case AArch64::ANDv16i8:
7419 case AArch64::ORRv8i8:
7420 case AArch64::ORRv16i8:
7421 case AArch64::EORv8i8:
7422 case AArch64::EORv16i8:
7424 case AArch64::ADD_ZZZ_B:
7425 case AArch64::ADD_ZZZ_H:
7426 case AArch64::ADD_ZZZ_S:
7427 case AArch64::ADD_ZZZ_D:
7428 case AArch64::MUL_ZZZ_B:
7429 case AArch64::MUL_ZZZ_H:
7430 case AArch64::MUL_ZZZ_S:
7431 case AArch64::MUL_ZZZ_D:
7432 case AArch64::AND_ZZZ:
7433 case AArch64::ORR_ZZZ:
7434 case AArch64::EOR_ZZZ:
7465 auto setFound = [&](
int Opcode,
int Operand,
unsigned ZeroReg,
7473 auto setVFound = [&](
int Opcode,
int Operand,
unsigned Pattern) {
7485 case AArch64::ADDWrr:
7487 "ADDWrr does not have register operands");
7488 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULADDW_OP1);
7489 setFound(AArch64::MADDWrrr, 2, AArch64::WZR, MCP::MULADDW_OP2);
7491 case AArch64::ADDXrr:
7492 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULADDX_OP1);
7493 setFound(AArch64::MADDXrrr, 2, AArch64::XZR, MCP::MULADDX_OP2);
7495 case AArch64::SUBWrr:
7496 setFound(AArch64::MADDWrrr, 2, AArch64::WZR, MCP::MULSUBW_OP2);
7497 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULSUBW_OP1);
7499 case AArch64::SUBXrr:
7500 setFound(AArch64::MADDXrrr, 2, AArch64::XZR, MCP::MULSUBX_OP2);
7501 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULSUBX_OP1);
7503 case AArch64::ADDWri:
7504 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULADDWI_OP1);
7506 case AArch64::ADDXri:
7507 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULADDXI_OP1);
7509 case AArch64::SUBWri:
7510 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULSUBWI_OP1);
7512 case AArch64::SUBXri:
7513 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULSUBXI_OP1);
7515 case AArch64::ADDv8i8:
7516 setVFound(AArch64::MULv8i8, 1, MCP::MULADDv8i8_OP1);
7517 setVFound(AArch64::MULv8i8, 2, MCP::MULADDv8i8_OP2);
7519 case AArch64::ADDv16i8:
7520 setVFound(AArch64::MULv16i8, 1, MCP::MULADDv16i8_OP1);
7521 setVFound(AArch64::MULv16i8, 2, MCP::MULADDv16i8_OP2);
7523 case AArch64::ADDv4i16:
7524 setVFound(AArch64::MULv4i16, 1, MCP::MULADDv4i16_OP1);
7525 setVFound(AArch64::MULv4i16, 2, MCP::MULADDv4i16_OP2);
7526 setVFound(AArch64::MULv4i16_indexed, 1, MCP::MULADDv4i16_indexed_OP1);
7527 setVFound(AArch64::MULv4i16_indexed, 2, MCP::MULADDv4i16_indexed_OP2);
7529 case AArch64::ADDv8i16:
7530 setVFound(AArch64::MULv8i16, 1, MCP::MULADDv8i16_OP1);
7531 setVFound(AArch64::MULv8i16, 2, MCP::MULADDv8i16_OP2);
7532 setVFound(AArch64::MULv8i16_indexed, 1, MCP::MULADDv8i16_indexed_OP1);
7533 setVFound(AArch64::MULv8i16_indexed, 2, MCP::MULADDv8i16_indexed_OP2);
7535 case AArch64::ADDv2i32:
7536 setVFound(AArch64::MULv2i32, 1, MCP::MULADDv2i32_OP1);
7537 setVFound(AArch64::MULv2i32, 2, MCP::MULADDv2i32_OP2);
7538 setVFound(AArch64::MULv2i32_indexed, 1, MCP::MULADDv2i32_indexed_OP1);
7539 setVFound(AArch64::MULv2i32_indexed, 2, MCP::MULADDv2i32_indexed_OP2);
7541 case AArch64::ADDv4i32:
7542 setVFound(AArch64::MULv4i32, 1, MCP::MULADDv4i32_OP1);
7543 setVFound(AArch64::MULv4i32, 2, MCP::MULADDv4i32_OP2);
7544 setVFound(AArch64::MULv4i32_indexed, 1, MCP::MULADDv4i32_indexed_OP1);
7545 setVFound(AArch64::MULv4i32_indexed, 2, MCP::MULADDv4i32_indexed_OP2);
7547 case AArch64::SUBv8i8:
7548 setVFound(AArch64::MULv8i8, 1, MCP::MULSUBv8i8_OP1);
7549 setVFound(AArch64::MULv8i8, 2, MCP::MULSUBv8i8_OP2);
7551 case AArch64::SUBv16i8:
7552 setVFound(AArch64::MULv16i8, 1, MCP::MULSUBv16i8_OP1);
7553 setVFound(AArch64::MULv16i8, 2, MCP::MULSUBv16i8_OP2);
7555 case AArch64::SUBv4i16:
7556 setVFound(AArch64::MULv4i16, 1, MCP::MULSUBv4i16_OP1);
7557 setVFound(AArch64::MULv4i16, 2, MCP::MULSUBv4i16_OP2);
7558 setVFound(AArch64::MULv4i16_indexed, 1, MCP::MULSUBv4i16_indexed_OP1);
7559 setVFound(AArch64::MULv4i16_indexed, 2, MCP::MULSUBv4i16_indexed_OP2);
7561 case AArch64::SUBv8i16:
7562 setVFound(AArch64::MULv8i16, 1, MCP::MULSUBv8i16_OP1);
7563 setVFound(AArch64::MULv8i16, 2, MCP::MULSUBv8i16_OP2);
7564 setVFound(AArch64::MULv8i16_indexed, 1, MCP::MULSUBv8i16_indexed_OP1);
7565 setVFound(AArch64::MULv8i16_indexed, 2, MCP::MULSUBv8i16_indexed_OP2);
7567 case AArch64::SUBv2i32:
7568 setVFound(AArch64::MULv2i32, 1, MCP::MULSUBv2i32_OP1);
7569 setVFound(AArch64::MULv2i32, 2, MCP::MULSUBv2i32_OP2);
7570 setVFound(AArch64::MULv2i32_indexed, 1, MCP::MULSUBv2i32_indexed_OP1);
7571 setVFound(AArch64::MULv2i32_indexed, 2, MCP::MULSUBv2i32_indexed_OP2);
7573 case AArch64::SUBv4i32:
7574 setVFound(AArch64::MULv4i32, 1, MCP::MULSUBv4i32_OP1);
7575 setVFound(AArch64::MULv4i32, 2, MCP::MULSUBv4i32_OP2);
7576 setVFound(AArch64::MULv4i32_indexed, 1, MCP::MULSUBv4i32_indexed_OP1);
7577 setVFound(AArch64::MULv4i32_indexed, 2, MCP::MULSUBv4i32_indexed_OP2);
7583bool AArch64InstrInfo::isAccumulationOpcode(
unsigned Opcode)
const {
7587 case AArch64::UABALB_ZZZ_D:
7588 case AArch64::UABALB_ZZZ_H:
7589 case AArch64::UABALB_ZZZ_S:
7590 case AArch64::UABALT_ZZZ_D:
7591 case AArch64::UABALT_ZZZ_H:
7592 case AArch64::UABALT_ZZZ_S:
7593 case AArch64::SABALB_ZZZ_D:
7594 case AArch64::SABALB_ZZZ_S:
7595 case AArch64::SABALB_ZZZ_H:
7596 case AArch64::SABALT_ZZZ_D:
7597 case AArch64::SABALT_ZZZ_S:
7598 case AArch64::SABALT_ZZZ_H:
7599 case AArch64::UABALv16i8_v8i16:
7600 case AArch64::UABALv2i32_v2i64:
7601 case AArch64::UABALv4i16_v4i32:
7602 case AArch64::UABALv4i32_v2i64:
7603 case AArch64::UABALv8i16_v4i32:
7604 case AArch64::UABALv8i8_v8i16:
7605 case AArch64::UABAv16i8:
7606 case AArch64::UABAv2i32:
7607 case AArch64::UABAv4i16:
7608 case AArch64::UABAv4i32:
7609 case AArch64::UABAv8i16:
7610 case AArch64::UABAv8i8:
7611 case AArch64::SABALv16i8_v8i16:
7612 case AArch64::SABALv2i32_v2i64:
7613 case AArch64::SABALv4i16_v4i32:
7614 case AArch64::SABALv4i32_v2i64:
7615 case AArch64::SABALv8i16_v4i32:
7616 case AArch64::SABALv8i8_v8i16:
7617 case AArch64::SABAv16i8:
7618 case AArch64::SABAv2i32:
7619 case AArch64::SABAv4i16:
7620 case AArch64::SABAv4i32:
7621 case AArch64::SABAv8i16:
7622 case AArch64::SABAv8i8:
7629unsigned AArch64InstrInfo::getAccumulationStartOpcode(
7630 unsigned AccumulationOpcode)
const {
7631 switch (AccumulationOpcode) {
7634 case AArch64::UABALB_ZZZ_D:
7635 return AArch64::UABDLB_ZZZ_D;
7636 case AArch64::UABALB_ZZZ_H:
7637 return AArch64::UABDLB_ZZZ_H;
7638 case AArch64::UABALB_ZZZ_S:
7639 return AArch64::UABDLB_ZZZ_S;
7640 case AArch64::UABALT_ZZZ_D:
7641 return AArch64::UABDLT_ZZZ_D;
7642 case AArch64::UABALT_ZZZ_H:
7643 return AArch64::UABDLT_ZZZ_H;
7644 case AArch64::UABALT_ZZZ_S:
7645 return AArch64::UABDLT_ZZZ_S;
7646 case AArch64::UABALv16i8_v8i16:
7647 return AArch64::UABDLv16i8_v8i16;
7648 case AArch64::UABALv2i32_v2i64:
7649 return AArch64::UABDLv2i32_v2i64;
7650 case AArch64::UABALv4i16_v4i32:
7651 return AArch64::UABDLv4i16_v4i32;
7652 case AArch64::UABALv4i32_v2i64:
7653 return AArch64::UABDLv4i32_v2i64;
7654 case AArch64::UABALv8i16_v4i32:
7655 return AArch64::UABDLv8i16_v4i32;
7656 case AArch64::UABALv8i8_v8i16:
7657 return AArch64::UABDLv8i8_v8i16;
7658 case AArch64::UABAv16i8:
7659 return AArch64::UABDv16i8;
7660 case AArch64::UABAv2i32:
7661 return AArch64::UABDv2i32;
7662 case AArch64::UABAv4i16:
7663 return AArch64::UABDv4i16;
7664 case AArch64::UABAv4i32:
7665 return AArch64::UABDv4i32;
7666 case AArch64::UABAv8i16:
7667 return AArch64::UABDv8i16;
7668 case AArch64::UABAv8i8:
7669 return AArch64::UABDv8i8;
7670 case AArch64::SABALB_ZZZ_D:
7671 return AArch64::SABDLB_ZZZ_D;
7672 case AArch64::SABALB_ZZZ_S:
7673 return AArch64::SABDLB_ZZZ_S;
7674 case AArch64::SABALB_ZZZ_H:
7675 return AArch64::SABDLB_ZZZ_H;
7676 case AArch64::SABALT_ZZZ_D:
7677 return AArch64::SABDLT_ZZZ_D;
7678 case AArch64::SABALT_ZZZ_S:
7679 return AArch64::SABDLT_ZZZ_S;
7680 case AArch64::SABALT_ZZZ_H:
7681 return AArch64::SABDLT_ZZZ_H;
7682 case AArch64::SABALv16i8_v8i16:
7683 return AArch64::SABDLv16i8_v8i16;
7684 case AArch64::SABALv2i32_v2i64:
7685 return AArch64::SABDLv2i32_v2i64;
7686 case AArch64::SABALv4i16_v4i32:
7687 return AArch64::SABDLv4i16_v4i32;
7688 case AArch64::SABALv4i32_v2i64:
7689 return AArch64::SABDLv4i32_v2i64;
7690 case AArch64::SABALv8i16_v4i32:
7691 return AArch64::SABDLv8i16_v4i32;
7692 case AArch64::SABALv8i8_v8i16:
7693 return AArch64::SABDLv8i8_v8i16;
7694 case AArch64::SABAv16i8:
7695 return AArch64::SABDv16i8;
7696 case AArch64::SABAv2i32:
7697 return AArch64::SABAv2i32;
7698 case AArch64::SABAv4i16:
7699 return AArch64::SABDv4i16;
7700 case AArch64::SABAv4i32:
7701 return AArch64::SABDv4i32;
7702 case AArch64::SABAv8i16:
7703 return AArch64::SABDv8i16;
7704 case AArch64::SABAv8i8:
7705 return AArch64::SABDv8i8;
7721 auto Match = [&](
int Opcode,
int Operand,
unsigned Pattern) ->
bool {
7733 assert(
false &&
"Unsupported FP instruction in combiner\n");
7735 case AArch64::FADDHrr:
7737 "FADDHrr does not have register operands");
7739 Found = Match(AArch64::FMULHrr, 1, MCP::FMULADDH_OP1);
7740 Found |= Match(AArch64::FMULHrr, 2, MCP::FMULADDH_OP2);
7742 case AArch64::FADDSrr:
7744 "FADDSrr does not have register operands");
7746 Found |= Match(AArch64::FMULSrr, 1, MCP::FMULADDS_OP1) ||
7747 Match(AArch64::FMULv1i32_indexed, 1, MCP::FMLAv1i32_indexed_OP1);
7749 Found |= Match(AArch64::FMULSrr, 2, MCP::FMULADDS_OP2) ||
7750 Match(AArch64::FMULv1i32_indexed, 2, MCP::FMLAv1i32_indexed_OP2);
7752 case AArch64::FADDDrr:
7753 Found |= Match(AArch64::FMULDrr, 1, MCP::FMULADDD_OP1) ||
7754 Match(AArch64::FMULv1i64_indexed, 1, MCP::FMLAv1i64_indexed_OP1);
7756 Found |= Match(AArch64::FMULDrr, 2, MCP::FMULADDD_OP2) ||
7757 Match(AArch64::FMULv1i64_indexed, 2, MCP::FMLAv1i64_indexed_OP2);
7759 case AArch64::FADDv4f16:
7760 Found |= Match(AArch64::FMULv4i16_indexed, 1, MCP::FMLAv4i16_indexed_OP1) ||
7761 Match(AArch64::FMULv4f16, 1, MCP::FMLAv4f16_OP1);
7763 Found |= Match(AArch64::FMULv4i16_indexed, 2, MCP::FMLAv4i16_indexed_OP2) ||
7764 Match(AArch64::FMULv4f16, 2, MCP::FMLAv4f16_OP2);
7766 case AArch64::FADDv8f16:
7767 Found |= Match(AArch64::FMULv8i16_indexed, 1, MCP::FMLAv8i16_indexed_OP1) ||
7768 Match(AArch64::FMULv8f16, 1, MCP::FMLAv8f16_OP1);
7770 Found |= Match(AArch64::FMULv8i16_indexed, 2, MCP::FMLAv8i16_indexed_OP2) ||
7771 Match(AArch64::FMULv8f16, 2, MCP::FMLAv8f16_OP2);
7773 case AArch64::FADDv2f32:
7774 Found |= Match(AArch64::FMULv2i32_indexed, 1, MCP::FMLAv2i32_indexed_OP1) ||
7775 Match(AArch64::FMULv2f32, 1, MCP::FMLAv2f32_OP1);
7777 Found |= Match(AArch64::FMULv2i32_indexed, 2, MCP::FMLAv2i32_indexed_OP2) ||
7778 Match(AArch64::FMULv2f32, 2, MCP::FMLAv2f32_OP2);
7780 case AArch64::FADDv2f64:
7781 Found |= Match(AArch64::FMULv2i64_indexed, 1, MCP::FMLAv2i64_indexed_OP1) ||
7782 Match(AArch64::FMULv2f64, 1, MCP::FMLAv2f64_OP1);
7784 Found |= Match(AArch64::FMULv2i64_indexed, 2, MCP::FMLAv2i64_indexed_OP2) ||
7785 Match(AArch64::FMULv2f64, 2, MCP::FMLAv2f64_OP2);
7787 case AArch64::FADDv4f32:
7788 Found |= Match(AArch64::FMULv4i32_indexed, 1, MCP::FMLAv4i32_indexed_OP1) ||
7789 Match(AArch64::FMULv4f32, 1, MCP::FMLAv4f32_OP1);
7791 Found |= Match(AArch64::FMULv4i32_indexed, 2, MCP::FMLAv4i32_indexed_OP2) ||
7792 Match(AArch64::FMULv4f32, 2, MCP::FMLAv4f32_OP2);
7794 case AArch64::FSUBHrr:
7795 Found = Match(AArch64::FMULHrr, 1, MCP::FMULSUBH_OP1);
7796 Found |= Match(AArch64::FMULHrr, 2, MCP::FMULSUBH_OP2);
7797 Found |= Match(AArch64::FNMULHrr, 1, MCP::FNMULSUBH_OP1);
7799 case AArch64::FSUBSrr:
7800 Found = Match(AArch64::FMULSrr, 1, MCP::FMULSUBS_OP1);
7802 Found |= Match(AArch64::FMULSrr, 2, MCP::FMULSUBS_OP2) ||
7803 Match(AArch64::FMULv1i32_indexed, 2, MCP::FMLSv1i32_indexed_OP2);
7805 Found |= Match(AArch64::FNMULSrr, 1, MCP::FNMULSUBS_OP1);
7807 case AArch64::FSUBDrr:
7808 Found = Match(AArch64::FMULDrr, 1, MCP::FMULSUBD_OP1);
7810 Found |= Match(AArch64::FMULDrr, 2, MCP::FMULSUBD_OP2) ||
7811 Match(AArch64::FMULv1i64_indexed, 2, MCP::FMLSv1i64_indexed_OP2);
7813 Found |= Match(AArch64::FNMULDrr, 1, MCP::FNMULSUBD_OP1);
7815 case AArch64::FSUBv4f16:
7816 Found |= Match(AArch64::FMULv4i16_indexed, 2, MCP::FMLSv4i16_indexed_OP2) ||
7817 Match(AArch64::FMULv4f16, 2, MCP::FMLSv4f16_OP2);
7819 Found |= Match(AArch64::FMULv4i16_indexed, 1, MCP::FMLSv4i16_indexed_OP1) ||
7820 Match(AArch64::FMULv4f16, 1, MCP::FMLSv4f16_OP1);
7822 case AArch64::FSUBv8f16:
7823 Found |= Match(AArch64::FMULv8i16_indexed, 2, MCP::FMLSv8i16_indexed_OP2) ||
7824 Match(AArch64::FMULv8f16, 2, MCP::FMLSv8f16_OP2);
7826 Found |= Match(AArch64::FMULv8i16_indexed, 1, MCP::FMLSv8i16_indexed_OP1) ||
7827 Match(AArch64::FMULv8f16, 1, MCP::FMLSv8f16_OP1);
7829 case AArch64::FSUBv2f32:
7830 Found |= Match(AArch64::FMULv2i32_indexed, 2, MCP::FMLSv2i32_indexed_OP2) ||
7831 Match(AArch64::FMULv2f32, 2, MCP::FMLSv2f32_OP2);
7833 Found |= Match(AArch64::FMULv2i32_indexed, 1, MCP::FMLSv2i32_indexed_OP1) ||
7834 Match(AArch64::FMULv2f32, 1, MCP::FMLSv2f32_OP1);
7836 case AArch64::FSUBv2f64:
7837 Found |= Match(AArch64::FMULv2i64_indexed, 2, MCP::FMLSv2i64_indexed_OP2) ||
7838 Match(AArch64::FMULv2f64, 2, MCP::FMLSv2f64_OP2);
7840 Found |= Match(AArch64::FMULv2i64_indexed, 1, MCP::FMLSv2i64_indexed_OP1) ||
7841 Match(AArch64::FMULv2f64, 1, MCP::FMLSv2f64_OP1);
7843 case AArch64::FSUBv4f32:
7844 Found |= Match(AArch64::FMULv4i32_indexed, 2, MCP::FMLSv4i32_indexed_OP2) ||
7845 Match(AArch64::FMULv4f32, 2, MCP::FMLSv4f32_OP2);
7847 Found |= Match(AArch64::FMULv4i32_indexed, 1, MCP::FMLSv4i32_indexed_OP1) ||
7848 Match(AArch64::FMULv4f32, 1, MCP::FMLSv4f32_OP1);
7859 auto Match = [&](
unsigned Opcode,
int Operand,
unsigned Pattern) ->
bool {
7866 if (
MI &&
MI->getOpcode() == TargetOpcode::COPY &&
7867 MI->getOperand(1).getReg().isVirtual())
7869 if (
MI &&
MI->getOpcode() == Opcode) {
7881 case AArch64::FMULv2f32:
7882 Found = Match(AArch64::DUPv2i32lane, 1, MCP::FMULv2i32_indexed_OP1);
7883 Found |= Match(AArch64::DUPv2i32lane, 2, MCP::FMULv2i32_indexed_OP2);
7885 case AArch64::FMULv2f64:
7886 Found = Match(AArch64::DUPv2i64lane, 1, MCP::FMULv2i64_indexed_OP1);
7887 Found |= Match(AArch64::DUPv2i64lane, 2, MCP::FMULv2i64_indexed_OP2);
7889 case AArch64::FMULv4f16:
7890 Found = Match(AArch64::DUPv4i16lane, 1, MCP::FMULv4i16_indexed_OP1);
7891 Found |= Match(AArch64::DUPv4i16lane, 2, MCP::FMULv4i16_indexed_OP2);
7893 case AArch64::FMULv4f32:
7894 Found = Match(AArch64::DUPv4i32lane, 1, MCP::FMULv4i32_indexed_OP1);
7895 Found |= Match(AArch64::DUPv4i32lane, 2, MCP::FMULv4i32_indexed_OP2);
7897 case AArch64::FMULv8f16:
7898 Found = Match(AArch64::DUPv8i16lane, 1, MCP::FMULv8i16_indexed_OP1);
7899 Found |= Match(AArch64::DUPv8i16lane, 2, MCP::FMULv8i16_indexed_OP2);
7912 auto Match = [&](
unsigned Opcode,
unsigned Pattern) ->
bool {
7915 if (
MI !=
nullptr && (
MI->getOpcode() == Opcode) &&
7930 case AArch64::FNEGDr:
7932 case AArch64::FNEGSr:
8064 case AArch64::SUBWrr:
8065 case AArch64::SUBSWrr:
8066 case AArch64::SUBXrr:
8067 case AArch64::SUBSXrr:
8112 unsigned LoadLaneOpCode,
unsigned NumLanes) {
8135 while (!RemainingLanes.
empty() && CurrInstr &&
8136 CurrInstr->getOpcode() == LoadLaneOpCode &&
8138 CurrInstr->getNumOperands() == 4) {
8139 RemainingLanes.
erase(CurrInstr->getOperand(2).getImm());
8145 if (!RemainingLanes.
empty())
8149 if (CurrInstr->getOpcode() != TargetOpcode::SUBREG_TO_REG)
8153 auto Lane0LoadReg = CurrInstr->getOperand(1).getReg();
8154 unsigned SingleLaneSizeInBits = 128 / NumLanes;
8155 if (
TRI->getRegSizeInBits(Lane0LoadReg, MRI) != SingleLaneSizeInBits)
8171 RemainingLoadInstrs.
insert(LoadInstrs.
begin(), LoadInstrs.
end());
8174 for (; MBBItr !=
MBB->begin() && RemainingSteps > 0 &&
8175 !RemainingLoadInstrs.
empty();
8176 --MBBItr, --RemainingSteps) {
8180 RemainingLoadInstrs.
erase(&CurrInstr);
8190 if (RemainingSteps == 0 && !RemainingLoadInstrs.
empty())
8216 case AArch64::LD1i32:
8218 case AArch64::LD1i16:
8220 case AArch64::LD1i8:
8236 unsigned Pattern,
unsigned NumLanes) {
8244 for (
unsigned i = 0; i < NumLanes - 1; ++i) {
8252 return A->getOperand(2).getImm() >
B->getOperand(2).getImm();
8258 auto LoadToLaneInstrsAscending =
llvm::reverse(LoadToLaneInstrs);
8264 auto CreateLD1Instruction = [&](
MachineInstr *OriginalInstr,
8265 Register SrcRegister,
unsigned Lane,
8267 bool OffsetRegisterKillState) {
8276 InstrIdxForVirtReg.
insert(std::make_pair(NewRegister, InsInstrs.
size()));
8277 InsInstrs.
push_back(LoadIndexIntoRegister);
8283 auto CreateLDRInstruction =
8289 Opcode = AArch64::LDRSui;
8292 Opcode = AArch64::LDRHui;
8295 Opcode = AArch64::LDRBui;
8299 "Got unsupported number of lanes in machine-combiner gather pattern");
8309 auto LanesToLoadToReg0 =
8311 LoadToLaneInstrsAscending.begin() + NumLanes / 2);
8312 Register PrevReg = SubregToReg->getOperand(0).getReg();
8314 const MachineOperand &OffsetRegOperand = LoadInstr->getOperand(3);
8315 PrevReg = CreateLD1Instruction(LoadInstr, PrevReg, Index + 1,
8316 OffsetRegOperand.
getReg(),
8317 OffsetRegOperand.
isKill());
8324 MachineInstr *Lane0Load = *LoadToLaneInstrsAscending.begin();
8326 *std::next(LoadToLaneInstrsAscending.begin(), NumLanes / 2);
8333 CreateLDRInstruction(NumLanes, DestRegForMiddleIndex,
8334 OriginalSplitToLoadOffsetOperand.
getReg(),
8337 InstrIdxForVirtReg.
insert(
8338 std::make_pair(DestRegForMiddleIndex, InsInstrs.
size()));
8339 InsInstrs.
push_back(MiddleIndexLoadInstr);
8344 unsigned SubregType;
8347 SubregType = AArch64::ssub;
8350 SubregType = AArch64::hsub;
8353 SubregType = AArch64::bsub;
8357 "Got invalid NumLanes for machine-combiner gather pattern");
8360 auto SubRegToRegInstr =
8362 DestRegForSubregToReg)
8365 InstrIdxForVirtReg.
insert(
8366 std::make_pair(DestRegForSubregToReg, InsInstrs.
size()));
8370 auto LanesToLoadToReg1 =
8372 LoadToLaneInstrsAscending.end());
8373 PrevReg = SubRegToRegInstr->getOperand(0).getReg();
8375 const MachineOperand &OffsetRegOperand = LoadInstr->getOperand(3);
8376 PrevReg = CreateLD1Instruction(LoadInstr, PrevReg, Index + 1,
8377 OffsetRegOperand.
getReg(),
8378 OffsetRegOperand.
isKill());
8381 if (Index == NumLanes / 2 - 2) {
8416bool AArch64InstrInfo::getMachineCombinerPatterns(
8418 bool DoRegPressureReduce)
const {
8439 DoRegPressureReduce);
8468 const Register *ReplacedAddend =
nullptr) {
8469 assert(IdxMulOpd == 1 || IdxMulOpd == 2);
8471 unsigned IdxOtherOpd = IdxMulOpd == 1 ? 2 : 1;
8474 Register SrcReg0 = MUL->getOperand(1).getReg();
8475 bool Src0IsKill = MUL->getOperand(1).isKill();
8476 Register SrcReg1 = MUL->getOperand(2).getReg();
8477 bool Src1IsKill = MUL->getOperand(2).isKill();
8481 if (ReplacedAddend) {
8483 SrcReg2 = *ReplacedAddend;
8510 .
addImm(MUL->getOperand(3).getImm());
8517 assert(
false &&
"Invalid FMA instruction kind \n");
8531 if (AArch64::FPR32RegClass.hasSubClassEq(RC))
8532 Opc = AArch64::FNMADDSrrr;
8533 else if (AArch64::FPR64RegClass.hasSubClassEq(RC))
8534 Opc = AArch64::FNMADDDrrr;
8568 unsigned IdxDupOp,
unsigned MulOpc,
8570 assert(((IdxDupOp == 1) || (IdxDupOp == 2)) &&
8571 "Invalid index of FMUL operand");
8579 if (Dup->
getOpcode() == TargetOpcode::COPY)
8588 unsigned IdxMulOp = IdxDupOp == 1 ? 2 : 1;
8629 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
8644 genNeg(MF, MRI,
TII, Root, InsInstrs, InstrIdxForVirtReg, MnegOpc, RC);
8671 genNeg(MF, MRI,
TII, Root, InsInstrs, InstrIdxForVirtReg, MnegOpc, RC);
8699 unsigned IdxMulOpd,
unsigned MaddOpc,
unsigned VR,
8701 assert(IdxMulOpd == 1 || IdxMulOpd == 2);
8705 Register SrcReg0 = MUL->getOperand(1).getReg();
8706 bool Src0IsKill = MUL->getOperand(1).isKill();
8707 Register SrcReg1 = MUL->getOperand(2).getReg();
8708 bool Src1IsKill = MUL->getOperand(2).isKill();
8738 assert(IdxOpd1 == 1 || IdxOpd1 == 2);
8739 unsigned IdxOtherOpd = IdxOpd1 == 1 ? 2 : 1;
8753 if (Opcode == AArch64::SUBSWrr)
8754 Opcode = AArch64::SUBWrr;
8755 else if (Opcode == AArch64::SUBSXrr)
8756 Opcode = AArch64::SUBXrr;
8758 assert((Opcode == AArch64::SUBWrr || Opcode == AArch64::SUBXrr) &&
8759 "Unexpected instruction opcode.");
8776 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
8783unsigned AArch64InstrInfo::getReduceOpcodeForAccumulator(
8784 unsigned int AccumulatorOpCode)
const {
8785 switch (AccumulatorOpCode) {
8786 case AArch64::UABALB_ZZZ_D:
8787 case AArch64::SABALB_ZZZ_D:
8788 case AArch64::UABALT_ZZZ_D:
8789 case AArch64::SABALT_ZZZ_D:
8790 return AArch64::ADD_ZZZ_D;
8791 case AArch64::UABALB_ZZZ_H:
8792 case AArch64::SABALB_ZZZ_H:
8793 case AArch64::UABALT_ZZZ_H:
8794 case AArch64::SABALT_ZZZ_H:
8795 return AArch64::ADD_ZZZ_H;
8796 case AArch64::UABALB_ZZZ_S:
8797 case AArch64::SABALB_ZZZ_S:
8798 case AArch64::UABALT_ZZZ_S:
8799 case AArch64::SABALT_ZZZ_S:
8800 return AArch64::ADD_ZZZ_S;
8801 case AArch64::UABALv16i8_v8i16:
8802 case AArch64::SABALv8i8_v8i16:
8803 case AArch64::SABAv8i16:
8804 case AArch64::UABAv8i16:
8805 return AArch64::ADDv8i16;
8806 case AArch64::SABALv2i32_v2i64:
8807 case AArch64::UABALv2i32_v2i64:
8808 case AArch64::SABALv4i32_v2i64:
8809 return AArch64::ADDv2i64;
8810 case AArch64::UABALv4i16_v4i32:
8811 case AArch64::SABALv4i16_v4i32:
8812 case AArch64::SABALv8i16_v4i32:
8813 case AArch64::SABAv4i32:
8814 case AArch64::UABAv4i32:
8815 return AArch64::ADDv4i32;
8816 case AArch64::UABALv4i32_v2i64:
8817 return AArch64::ADDv2i64;
8818 case AArch64::UABALv8i16_v4i32:
8819 return AArch64::ADDv4i32;
8820 case AArch64::UABALv8i8_v8i16:
8821 case AArch64::SABALv16i8_v8i16:
8822 return AArch64::ADDv8i16;
8823 case AArch64::UABAv16i8:
8824 case AArch64::SABAv16i8:
8825 return AArch64::ADDv16i8;
8826 case AArch64::UABAv4i16:
8827 case AArch64::SABAv4i16:
8828 return AArch64::ADDv4i16;
8829 case AArch64::UABAv2i32:
8830 case AArch64::SABAv2i32:
8831 return AArch64::ADDv2i32;
8832 case AArch64::UABAv8i8:
8833 case AArch64::SABAv8i8:
8834 return AArch64::ADDv8i8;
8843void AArch64InstrInfo::genAlternativeCodeSequence(
8853 MachineInstr *
MUL =
nullptr;
8854 const TargetRegisterClass *RC;
8860 DelInstrs, InstrIdxForVirtReg);
8866 InstrIdxForVirtReg);
8872 InstrIdxForVirtReg);
8881 Opc = AArch64::MADDWrrr;
8882 RC = &AArch64::GPR32RegClass;
8884 Opc = AArch64::MADDXrrr;
8885 RC = &AArch64::GPR64RegClass;
8896 Opc = AArch64::MADDWrrr;
8897 RC = &AArch64::GPR32RegClass;
8899 Opc = AArch64::MADDXrrr;
8900 RC = &AArch64::GPR64RegClass;
8913 const TargetRegisterClass *RC;
8914 unsigned BitSize, MovImm;
8917 MovImm = AArch64::MOVi32imm;
8918 RC = &AArch64::GPR32spRegClass;
8920 Opc = AArch64::MADDWrrr;
8921 RC = &AArch64::GPR32RegClass;
8923 MovImm = AArch64::MOVi64imm;
8924 RC = &AArch64::GPR64spRegClass;
8926 Opc = AArch64::MADDXrrr;
8927 RC = &AArch64::GPR64RegClass;
8938 uint64_t UImm =
SignExtend64(IsSub ? -Imm : Imm, BitSize);
8942 if (Insn.
size() != 1)
8944 MachineInstrBuilder MIB1 =
8945 BuildMI(MF, MIMetadata(Root),
TII->get(MovImm), NewVR)
8946 .
addImm(IsSub ? -Imm : Imm);
8948 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
8959 const TargetRegisterClass *SubRC;
8960 unsigned SubOpc, ZeroReg;
8962 SubOpc = AArch64::SUBWrr;
8963 SubRC = &AArch64::GPR32spRegClass;
8964 ZeroReg = AArch64::WZR;
8965 Opc = AArch64::MADDWrrr;
8966 RC = &AArch64::GPR32RegClass;
8968 SubOpc = AArch64::SUBXrr;
8969 SubRC = &AArch64::GPR64spRegClass;
8970 ZeroReg = AArch64::XZR;
8971 Opc = AArch64::MADDXrrr;
8972 RC = &AArch64::GPR64RegClass;
8976 MachineInstrBuilder MIB1 =
8977 BuildMI(MF, MIMetadata(Root),
TII->get(SubOpc), NewVR)
8981 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
8992 Opc = AArch64::MSUBWrrr;
8993 RC = &AArch64::GPR32RegClass;
8995 Opc = AArch64::MSUBXrrr;
8996 RC = &AArch64::GPR64RegClass;
9001 Opc = AArch64::MLAv8i8;
9002 RC = &AArch64::FPR64RegClass;
9006 Opc = AArch64::MLAv8i8;
9007 RC = &AArch64::FPR64RegClass;
9011 Opc = AArch64::MLAv16i8;
9012 RC = &AArch64::FPR128RegClass;
9016 Opc = AArch64::MLAv16i8;
9017 RC = &AArch64::FPR128RegClass;
9021 Opc = AArch64::MLAv4i16;
9022 RC = &AArch64::FPR64RegClass;
9026 Opc = AArch64::MLAv4i16;
9027 RC = &AArch64::FPR64RegClass;
9031 Opc = AArch64::MLAv8i16;
9032 RC = &AArch64::FPR128RegClass;
9036 Opc = AArch64::MLAv8i16;
9037 RC = &AArch64::FPR128RegClass;
9041 Opc = AArch64::MLAv2i32;
9042 RC = &AArch64::FPR64RegClass;
9046 Opc = AArch64::MLAv2i32;
9047 RC = &AArch64::FPR64RegClass;
9051 Opc = AArch64::MLAv4i32;
9052 RC = &AArch64::FPR128RegClass;
9056 Opc = AArch64::MLAv4i32;
9057 RC = &AArch64::FPR128RegClass;
9062 Opc = AArch64::MLAv8i8;
9063 RC = &AArch64::FPR64RegClass;
9065 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i8,
9069 Opc = AArch64::MLSv8i8;
9070 RC = &AArch64::FPR64RegClass;
9074 Opc = AArch64::MLAv16i8;
9075 RC = &AArch64::FPR128RegClass;
9077 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv16i8,
9081 Opc = AArch64::MLSv16i8;
9082 RC = &AArch64::FPR128RegClass;
9086 Opc = AArch64::MLAv4i16;
9087 RC = &AArch64::FPR64RegClass;
9089 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i16,
9093 Opc = AArch64::MLSv4i16;
9094 RC = &AArch64::FPR64RegClass;
9098 Opc = AArch64::MLAv8i16;
9099 RC = &AArch64::FPR128RegClass;
9101 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i16,
9105 Opc = AArch64::MLSv8i16;
9106 RC = &AArch64::FPR128RegClass;
9110 Opc = AArch64::MLAv2i32;
9111 RC = &AArch64::FPR64RegClass;
9113 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv2i32,
9117 Opc = AArch64::MLSv2i32;
9118 RC = &AArch64::FPR64RegClass;
9122 Opc = AArch64::MLAv4i32;
9123 RC = &AArch64::FPR128RegClass;
9125 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i32,
9129 Opc = AArch64::MLSv4i32;
9130 RC = &AArch64::FPR128RegClass;
9135 Opc = AArch64::MLAv4i16_indexed;
9136 RC = &AArch64::FPR64RegClass;
9140 Opc = AArch64::MLAv4i16_indexed;
9141 RC = &AArch64::FPR64RegClass;
9145 Opc = AArch64::MLAv8i16_indexed;
9146 RC = &AArch64::FPR128RegClass;
9150 Opc = AArch64::MLAv8i16_indexed;
9151 RC = &AArch64::FPR128RegClass;
9155 Opc = AArch64::MLAv2i32_indexed;
9156 RC = &AArch64::FPR64RegClass;
9160 Opc = AArch64::MLAv2i32_indexed;
9161 RC = &AArch64::FPR64RegClass;
9165 Opc = AArch64::MLAv4i32_indexed;
9166 RC = &AArch64::FPR128RegClass;
9170 Opc = AArch64::MLAv4i32_indexed;
9171 RC = &AArch64::FPR128RegClass;
9176 Opc = AArch64::MLAv4i16_indexed;
9177 RC = &AArch64::FPR64RegClass;
9179 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i16,
9183 Opc = AArch64::MLSv4i16_indexed;
9184 RC = &AArch64::FPR64RegClass;
9188 Opc = AArch64::MLAv8i16_indexed;
9189 RC = &AArch64::FPR128RegClass;
9191 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i16,
9195 Opc = AArch64::MLSv8i16_indexed;
9196 RC = &AArch64::FPR128RegClass;
9200 Opc = AArch64::MLAv2i32_indexed;
9201 RC = &AArch64::FPR64RegClass;
9203 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv2i32,
9207 Opc = AArch64::MLSv2i32_indexed;
9208 RC = &AArch64::FPR64RegClass;
9212 Opc = AArch64::MLAv4i32_indexed;
9213 RC = &AArch64::FPR128RegClass;
9215 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i32,
9219 Opc = AArch64::MLSv4i32_indexed;
9220 RC = &AArch64::FPR128RegClass;
9226 Opc = AArch64::FMADDHrrr;
9227 RC = &AArch64::FPR16RegClass;
9231 Opc = AArch64::FMADDSrrr;
9232 RC = &AArch64::FPR32RegClass;
9236 Opc = AArch64::FMADDDrrr;
9237 RC = &AArch64::FPR64RegClass;
9242 Opc = AArch64::FMADDHrrr;
9243 RC = &AArch64::FPR16RegClass;
9247 Opc = AArch64::FMADDSrrr;
9248 RC = &AArch64::FPR32RegClass;
9252 Opc = AArch64::FMADDDrrr;
9253 RC = &AArch64::FPR64RegClass;
9258 Opc = AArch64::FMLAv1i32_indexed;
9259 RC = &AArch64::FPR32RegClass;
9264 Opc = AArch64::FMLAv1i32_indexed;
9265 RC = &AArch64::FPR32RegClass;
9271 Opc = AArch64::FMLAv1i64_indexed;
9272 RC = &AArch64::FPR64RegClass;
9277 Opc = AArch64::FMLAv1i64_indexed;
9278 RC = &AArch64::FPR64RegClass;
9284 RC = &AArch64::FPR64RegClass;
9285 Opc = AArch64::FMLAv4i16_indexed;
9290 RC = &AArch64::FPR64RegClass;
9291 Opc = AArch64::FMLAv4f16;
9296 RC = &AArch64::FPR64RegClass;
9297 Opc = AArch64::FMLAv4i16_indexed;
9302 RC = &AArch64::FPR64RegClass;
9303 Opc = AArch64::FMLAv4f16;
9310 RC = &AArch64::FPR64RegClass;
9312 Opc = AArch64::FMLAv2i32_indexed;
9316 Opc = AArch64::FMLAv2f32;
9323 RC = &AArch64::FPR64RegClass;
9325 Opc = AArch64::FMLAv2i32_indexed;
9329 Opc = AArch64::FMLAv2f32;
9336 RC = &AArch64::FPR128RegClass;
9337 Opc = AArch64::FMLAv8i16_indexed;
9342 RC = &AArch64::FPR128RegClass;
9343 Opc = AArch64::FMLAv8f16;
9348 RC = &AArch64::FPR128RegClass;
9349 Opc = AArch64::FMLAv8i16_indexed;
9354 RC = &AArch64::FPR128RegClass;
9355 Opc = AArch64::FMLAv8f16;
9362 RC = &AArch64::FPR128RegClass;
9364 Opc = AArch64::FMLAv2i64_indexed;
9368 Opc = AArch64::FMLAv2f64;
9375 RC = &AArch64::FPR128RegClass;
9377 Opc = AArch64::FMLAv2i64_indexed;
9381 Opc = AArch64::FMLAv2f64;
9389 RC = &AArch64::FPR128RegClass;
9391 Opc = AArch64::FMLAv4i32_indexed;
9395 Opc = AArch64::FMLAv4f32;
9403 RC = &AArch64::FPR128RegClass;
9405 Opc = AArch64::FMLAv4i32_indexed;
9409 Opc = AArch64::FMLAv4f32;
9416 Opc = AArch64::FNMSUBHrrr;
9417 RC = &AArch64::FPR16RegClass;
9421 Opc = AArch64::FNMSUBSrrr;
9422 RC = &AArch64::FPR32RegClass;
9426 Opc = AArch64::FNMSUBDrrr;
9427 RC = &AArch64::FPR64RegClass;
9432 Opc = AArch64::FNMADDHrrr;
9433 RC = &AArch64::FPR16RegClass;
9437 Opc = AArch64::FNMADDSrrr;
9438 RC = &AArch64::FPR32RegClass;
9442 Opc = AArch64::FNMADDDrrr;
9443 RC = &AArch64::FPR64RegClass;
9448 Opc = AArch64::FMSUBHrrr;
9449 RC = &AArch64::FPR16RegClass;
9453 Opc = AArch64::FMSUBSrrr;
9454 RC = &AArch64::FPR32RegClass;
9458 Opc = AArch64::FMSUBDrrr;
9459 RC = &AArch64::FPR64RegClass;
9464 Opc = AArch64::FMLSv1i32_indexed;
9465 RC = &AArch64::FPR32RegClass;
9471 Opc = AArch64::FMLSv1i64_indexed;
9472 RC = &AArch64::FPR64RegClass;
9479 RC = &AArch64::FPR64RegClass;
9481 MachineInstrBuilder MIB1 =
9482 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv4f16), NewVR)
9485 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9487 Opc = AArch64::FMLAv4f16;
9491 Opc = AArch64::FMLAv4i16_indexed;
9498 RC = &AArch64::FPR64RegClass;
9499 Opc = AArch64::FMLSv4f16;
9504 RC = &AArch64::FPR64RegClass;
9505 Opc = AArch64::FMLSv4i16_indexed;
9512 RC = &AArch64::FPR64RegClass;
9514 Opc = AArch64::FMLSv2i32_indexed;
9518 Opc = AArch64::FMLSv2f32;
9526 RC = &AArch64::FPR128RegClass;
9528 MachineInstrBuilder MIB1 =
9529 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv8f16), NewVR)
9532 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9534 Opc = AArch64::FMLAv8f16;
9538 Opc = AArch64::FMLAv8i16_indexed;
9545 RC = &AArch64::FPR128RegClass;
9546 Opc = AArch64::FMLSv8f16;
9551 RC = &AArch64::FPR128RegClass;
9552 Opc = AArch64::FMLSv8i16_indexed;
9559 RC = &AArch64::FPR128RegClass;
9561 Opc = AArch64::FMLSv2i64_indexed;
9565 Opc = AArch64::FMLSv2f64;
9573 RC = &AArch64::FPR128RegClass;
9575 Opc = AArch64::FMLSv4i32_indexed;
9579 Opc = AArch64::FMLSv4f32;
9586 RC = &AArch64::FPR64RegClass;
9588 MachineInstrBuilder MIB1 =
9589 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv2f32), NewVR)
9592 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9594 Opc = AArch64::FMLAv2i32_indexed;
9598 Opc = AArch64::FMLAv2f32;
9606 RC = &AArch64::FPR128RegClass;
9608 MachineInstrBuilder MIB1 =
9609 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv4f32), NewVR)
9612 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9614 Opc = AArch64::FMLAv4i32_indexed;
9618 Opc = AArch64::FMLAv4f32;
9626 RC = &AArch64::FPR128RegClass;
9628 MachineInstrBuilder MIB1 =
9629 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv2f64), NewVR)
9632 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9634 Opc = AArch64::FMLAv2i64_indexed;
9638 Opc = AArch64::FMLAv2f64;
9650 &AArch64::FPR128RegClass, MRI);
9659 &AArch64::FPR128RegClass, MRI);
9668 &AArch64::FPR128_loRegClass, MRI);
9677 &AArch64::FPR128RegClass, MRI);
9686 &AArch64::FPR128_loRegClass, MRI);
9720 for (
auto *
MI : InsInstrs)
9721 MI->setFlags(Flags);
9762 bool IsNegativeBranch =
false;
9763 bool IsTestAndBranch =
false;
9764 unsigned TargetBBInMI = 0;
9765 switch (
MI.getOpcode()) {
9769 case AArch64::CBWPri:
9770 case AArch64::CBXPri:
9771 case AArch64::CBBAssertExt:
9772 case AArch64::CBHAssertExt:
9773 case AArch64::CBWPrr:
9774 case AArch64::CBXPrr:
9780 case AArch64::CBNZW:
9781 case AArch64::CBNZX:
9783 IsNegativeBranch =
true;
9788 IsTestAndBranch =
true;
9790 case AArch64::TBNZW:
9791 case AArch64::TBNZX:
9793 IsNegativeBranch =
true;
9794 IsTestAndBranch =
true;
9800 if (IsTestAndBranch &&
MI.getOperand(1).getImm())
9804 assert(
MI.getParent() &&
"Incomplete machine instruction\n");
9815 while (
DefMI->isCopy()) {
9824 switch (
DefMI->getOpcode()) {
9828 case AArch64::ANDWri:
9829 case AArch64::ANDXri: {
9830 if (IsTestAndBranch)
9837 bool Is32Bit = (
DefMI->getOpcode() == AArch64::ANDWri);
9839 DefMI->getOperand(2).getImm(), Is32Bit ? 32 : 64);
9854 unsigned Opc = (Imm < 32)
9855 ? (IsNegativeBranch ? AArch64::TBNZW : AArch64::TBZW)
9856 : (IsNegativeBranch ? AArch64::TBNZX : AArch64::TBZX);
9869 if (!Is32Bit && Imm < 32)
9871 MI.eraseFromParent();
9875 case AArch64::CSINCWr:
9876 case AArch64::CSINCXr: {
9877 if (!(
DefMI->getOperand(1).getReg() == AArch64::WZR &&
9878 DefMI->getOperand(2).getReg() == AArch64::WZR) &&
9879 !(
DefMI->getOperand(1).getReg() == AArch64::XZR &&
9880 DefMI->getOperand(2).getReg() == AArch64::XZR))
9883 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
9896 if (IsNegativeBranch)
9899 MI.eraseFromParent();
9905std::pair<unsigned, unsigned>
9906AArch64InstrInfo::decomposeMachineOperandsTargetFlags(
unsigned TF)
const {
9908 return std::make_pair(TF & Mask, TF & ~Mask);
9912AArch64InstrInfo::getSerializableDirectMachineOperandTargetFlags()
const {
9915 static const std::pair<unsigned, const char *> TargetFlags[] = {
9916 {MO_PAGE,
"aarch64-page"}, {
MO_PAGEOFF,
"aarch64-pageoff"},
9917 {
MO_G3,
"aarch64-g3"}, {
MO_G2,
"aarch64-g2"},
9918 {
MO_G1,
"aarch64-g1"}, {
MO_G0,
"aarch64-g0"},
9924AArch64InstrInfo::getSerializableBitmaskMachineOperandTargetFlags()
const {
9925 using namespace AArch64II;
9927 static const std::pair<unsigned, const char *> TargetFlags[] = {
9930 {
MO_NC,
"aarch64-nc"},
9931 {
MO_S,
"aarch64-s"},
9942AArch64InstrInfo::getSerializableMachineMemOperandTargetFlags()
const {
9943 static const std::pair<MachineMemOperand::Flags, const char *> TargetFlags[] =
10045 MachineFunction *MF =
C.getMF();
10047 const AArch64RegisterInfo *ARI =
10048 static_cast<const AArch64RegisterInfo *
>(&
TRI);
10051 for (
unsigned Reg : AArch64::GPR64RegClass) {
10053 Reg != AArch64::LR &&
10054 Reg != AArch64::X16 &&
10055 Reg != AArch64::X17 &&
10056 C.isAvailableAcrossAndOutOfSeq(
Reg,
TRI) &&
10057 C.isAvailableInsideSeq(
Reg,
TRI))
10088 return SubtargetA.hasV8_3aOps() == SubtargetB.hasV8_3aOps();
10091std::optional<std::unique_ptr<outliner::OutlinedFunction>>
10092AArch64InstrInfo::getOutliningCandidateInfo(
10094 std::vector<outliner::Candidate> &RepeatedSequenceLocs,
10095 unsigned MinRepeats)
const {
10096 unsigned SequenceSize = 0;
10097 for (
auto &
MI : RepeatedSequenceLocs[0])
10100 unsigned NumBytesToCreateFrame = 0;
10106 MachineInstr &LastMI = RepeatedSequenceLocs[0].back();
10107 MachineInstr &FirstMI = RepeatedSequenceLocs[0].front();
10108 if (LastMI.
getOpcode() == AArch64::ADRP &&
10111 return std::nullopt;
10116 if ((FirstMI.
getOpcode() == AArch64::ADDXri ||
10117 FirstMI.
getOpcode() == AArch64::LDRXui) &&
10120 return std::nullopt;
10131 if (std::adjacent_find(
10132 RepeatedSequenceLocs.begin(), RepeatedSequenceLocs.end(),
10133 [](
const outliner::Candidate &a,
const outliner::Candidate &b) {
10136 if (outliningCandidatesSigningScopeConsensus(a, b) &&
10137 outliningCandidatesSigningKeyConsensus(a, b) &&
10138 outliningCandidatesV8_3OpsConsensus(a, b)) {
10142 }) != RepeatedSequenceLocs.end()) {
10143 return std::nullopt;
10160 unsigned NumBytesToCheckLRInTCEpilogue = 0;
10161 const auto RASignCondition = RepeatedSequenceLocs[0]
10164 ->getSignReturnAddressCondition();
10167 NumBytesToCreateFrame += 8;
10170 auto LRCheckMethod = Subtarget.getAuthenticatedLRCheckMethod(
10171 *RepeatedSequenceLocs[0].getMF());
10172 NumBytesToCheckLRInTCEpilogue =
10176 if (isTailCallReturnInst(RepeatedSequenceLocs[0].
back()))
10177 SequenceSize += NumBytesToCheckLRInTCEpilogue;
10185 for (
auto &
MI :
C) {
10186 if (
MI.modifiesRegister(AArch64::SP, &
TRI)) {
10187 switch (
MI.getOpcode()) {
10188 case AArch64::ADDXri:
10189 case AArch64::ADDWri:
10190 assert(
MI.getNumOperands() == 4 &&
"Wrong number of operands");
10191 assert(
MI.getOperand(2).isImm() &&
10192 "Expected operand to be immediate");
10193 assert(
MI.getOperand(1).isReg() &&
10194 "Expected operand to be a register");
10198 if (
MI.getOperand(1).getReg() == AArch64::SP)
10199 SPValue +=
MI.getOperand(2).getImm();
10203 case AArch64::SUBXri:
10204 case AArch64::SUBWri:
10205 assert(
MI.getNumOperands() == 4 &&
"Wrong number of operands");
10206 assert(
MI.getOperand(2).isImm() &&
10207 "Expected operand to be immediate");
10208 assert(
MI.getOperand(1).isReg() &&
10209 "Expected operand to be a register");
10213 if (
MI.getOperand(1).getReg() == AArch64::SP)
10214 SPValue -=
MI.getOperand(2).getImm();
10231 if (RepeatedSequenceLocs.size() < MinRepeats)
10232 return std::nullopt;
10236 unsigned FlagsSetInAll = 0xF;
10240 FlagsSetInAll &=
C.Flags;
10242 unsigned LastInstrOpcode = RepeatedSequenceLocs[0].back().getOpcode();
10245 auto SetCandidateCallInfo =
10246 [&RepeatedSequenceLocs](
unsigned CallID,
unsigned NumBytesForCall) {
10248 C.setCallInfo(CallID, NumBytesForCall);
10252 NumBytesToCreateFrame += 4;
10260 unsigned CFICount = 0;
10261 for (
auto &
I : RepeatedSequenceLocs[0]) {
10262 if (
I.isCFIInstruction())
10272 std::vector<MCCFIInstruction> CFIInstructions =
10273 C.getMF()->getFrameInstructions();
10275 if (CFICount > 0 && CFICount != CFIInstructions.size())
10276 return std::nullopt;
10284 if (!
MI.modifiesRegister(AArch64::SP, &
TRI) &&
10285 !
MI.readsRegister(AArch64::SP, &
TRI))
10291 if (
MI.modifiesRegister(AArch64::SP, &
TRI))
10296 if (
MI.mayLoadOrStore()) {
10299 bool OffsetIsScalable;
10303 if (!getMemOperandWithOffset(
MI,
Base,
Offset, OffsetIsScalable, &
TRI) ||
10304 !
Base->isReg() ||
Base->getReg() != AArch64::SP)
10308 if (OffsetIsScalable)
10316 TypeSize Scale(0U,
false), DummyWidth(0U,
false);
10317 getMemOpInfo(
MI.getOpcode(), Scale, DummyWidth, MinOffset, MaxOffset);
10320 if (
Offset < MinOffset * (int64_t)Scale.getFixedValue() ||
10321 Offset > MaxOffset * (int64_t)Scale.getFixedValue())
10336 bool AllStackInstrsSafe =
10341 if (RepeatedSequenceLocs[0].
back().isTerminator()) {
10343 NumBytesToCreateFrame = 0;
10344 unsigned NumBytesForCall = 4 + NumBytesToCheckLRInTCEpilogue;
10348 else if (LastInstrOpcode == AArch64::BL ||
10349 ((LastInstrOpcode == AArch64::BLR ||
10350 LastInstrOpcode == AArch64::BLRNoIP) &&
10354 NumBytesToCreateFrame = NumBytesToCheckLRInTCEpilogue;
10362 unsigned NumBytesNoStackCalls = 0;
10363 std::vector<outliner::Candidate> CandidatesWithoutStackFixups;
10369 ?
C.isAvailableAcrossAndOutOfSeq(AArch64::LR,
TRI)
10378 C.getMF()->getFunction().hasFnAttribute(Attribute::NoReturn);
10381 if (LRAvailable && !IsNoReturn) {
10382 NumBytesNoStackCalls += 4;
10384 CandidatesWithoutStackFixups.push_back(
C);
10389 else if (findRegisterToSaveLRTo(
C)) {
10390 NumBytesNoStackCalls += 12;
10392 CandidatesWithoutStackFixups.push_back(
C);
10397 else if (
C.isAvailableInsideSeq(AArch64::SP,
TRI)) {
10398 NumBytesNoStackCalls += 12;
10400 CandidatesWithoutStackFixups.push_back(
C);
10406 NumBytesNoStackCalls += SequenceSize;
10413 if (!AllStackInstrsSafe ||
10414 NumBytesNoStackCalls <= RepeatedSequenceLocs.size() * 12) {
10415 RepeatedSequenceLocs = CandidatesWithoutStackFixups;
10417 if (RepeatedSequenceLocs.size() < MinRepeats)
10418 return std::nullopt;
10471 (!
C.isAvailableAcrossAndOutOfSeq(AArch64::LR,
TRI) ||
10472 !findRegisterToSaveLRTo(
C));
10478 if (RepeatedSequenceLocs.size() < MinRepeats)
10479 return std::nullopt;
10488 bool ModStackToSaveLR =
false;
10491 ModStackToSaveLR =
true;
10500 ModStackToSaveLR =
true;
10502 if (ModStackToSaveLR) {
10504 if (!AllStackInstrsSafe)
10505 return std::nullopt;
10508 NumBytesToCreateFrame += 8;
10515 return std::nullopt;
10517 return std::make_unique<outliner::OutlinedFunction>(
10518 RepeatedSequenceLocs, SequenceSize, NumBytesToCreateFrame, FrameID);
10521void AArch64InstrInfo::mergeOutliningCandidateAttributes(
10522 Function &
F, std::vector<outliner::Candidate> &Candidates)
const {
10526 const auto &CFn = Candidates.front().getMF()->getFunction();
10528 if (CFn.hasFnAttribute(
"ptrauth-returns"))
10529 F.addFnAttr(CFn.getFnAttribute(
"ptrauth-returns"));
10530 if (CFn.hasFnAttribute(
"ptrauth-auth-traps"))
10531 F.addFnAttr(CFn.getFnAttribute(
"ptrauth-auth-traps"));
10534 if (CFn.hasFnAttribute(
"sign-return-address"))
10535 F.addFnAttr(CFn.getFnAttribute(
"sign-return-address"));
10536 if (CFn.hasFnAttribute(
"sign-return-address-key"))
10537 F.addFnAttr(CFn.getFnAttribute(
"sign-return-address-key"));
10539 AArch64GenInstrInfo::mergeOutliningCandidateAttributes(
F, Candidates);
10542bool AArch64InstrInfo::isFunctionSafeToOutlineFrom(
10547 if (!OutlineFromLinkOnceODRs &&
F.hasLinkOnceODRLinkage())
10554 if (
F.hasSection())
10560 AArch64FunctionInfo *AFI = MF.
getInfo<AArch64FunctionInfo>();
10561 if (!AFI || AFI->
hasRedZone().value_or(
true))
10581 unsigned &Flags)
const {
10583 "Must track liveness!");
10585 std::pair<MachineBasicBlock::iterator, MachineBasicBlock::iterator>>
10600 auto AreAllUnsafeRegsDead = [&LRU]() {
10601 return LRU.available(AArch64::W16) && LRU.available(AArch64::W17) &&
10602 LRU.available(AArch64::NZCV);
10617 bool LRAvailableEverywhere =
true;
10619 LRU.addLiveOuts(
MBB);
10621 auto UpdateWholeMBBFlags = [&
Flags](
const MachineInstr &
MI) {
10622 if (
MI.isCall() && !
MI.isTerminator())
10628 auto CreateNewRangeStartingAt =
10629 [&RangeBegin, &RangeEnd,
10631 RangeBegin = NewBegin;
10632 RangeEnd = std::next(RangeBegin);
10635 auto SaveRangeIfNonEmpty = [&RangeLen, &
Ranges, &RangeBegin, &RangeEnd]() {
10641 if (!RangeBegin.isEnd() && RangeBegin->isBundledWithPred())
10643 if (!RangeEnd.isEnd() && RangeEnd->isBundledWithPred())
10645 Ranges.emplace_back(RangeBegin, RangeEnd);
10653 for (; FirstPossibleEndPt !=
MBB.
instr_rend(); ++FirstPossibleEndPt) {
10654 if (!FirstPossibleEndPt->isDebugInstr())
10655 LRU.stepBackward(*FirstPossibleEndPt);
10658 UpdateWholeMBBFlags(*FirstPossibleEndPt);
10659 if (AreAllUnsafeRegsDead())
10666 CreateNewRangeStartingAt(FirstPossibleEndPt->getIterator());
10671 if (!
MI.isDebugInstr())
10672 LRU.stepBackward(
MI);
10673 UpdateWholeMBBFlags(
MI);
10674 if (!AreAllUnsafeRegsDead()) {
10675 SaveRangeIfNonEmpty();
10676 CreateNewRangeStartingAt(
MI.getIterator());
10679 LRAvailableEverywhere &= LRU.available(AArch64::LR);
10680 RangeBegin =
MI.getIterator();
10685 if (AreAllUnsafeRegsDead())
10686 SaveRangeIfNonEmpty();
10694 if (!LRAvailableEverywhere)
10702 unsigned Flags)
const {
10703 MachineInstr &
MI = *MIT;
10707 switch (
MI.getOpcode()) {
10708 case AArch64::PACM:
10709 case AArch64::PACIASP:
10710 case AArch64::PACIBSP:
10711 case AArch64::PACIASPPC:
10712 case AArch64::PACIBSPPC:
10713 case AArch64::AUTIASP:
10714 case AArch64::AUTIBSP:
10715 case AArch64::AUTIASPPCi:
10716 case AArch64::AUTIASPPCr:
10717 case AArch64::AUTIBSPPCi:
10718 case AArch64::AUTIBSPPCr:
10719 case AArch64::RETAA:
10720 case AArch64::RETAB:
10721 case AArch64::RETAASPPCi:
10722 case AArch64::RETAASPPCr:
10723 case AArch64::RETABSPPCi:
10724 case AArch64::RETABSPPCr:
10725 case AArch64::EMITBKEY:
10726 case AArch64::PAUTH_PROLOGUE:
10727 case AArch64::PAUTH_EPILOGUE:
10737 if (
MI.isCFIInstruction())
10741 if (
MI.isTerminator())
10747 for (
const MachineOperand &MOP :
MI.operands()) {
10750 assert(!MOP.isCFIIndex());
10753 if (MOP.isReg() && !MOP.isImplicit() &&
10754 (MOP.getReg() == AArch64::LR || MOP.getReg() == AArch64::W30))
10761 if (
MI.getOpcode() == AArch64::ADRP)
10781 for (
const MachineOperand &MOP :
MI.operands()) {
10782 if (MOP.isGlobal()) {
10790 if (Callee &&
Callee->getName() ==
"\01_mcount")
10798 if (
MI.getOpcode() == AArch64::BLR ||
10799 MI.getOpcode() == AArch64::BLRNoIP ||
MI.getOpcode() == AArch64::BL)
10803 return UnknownCallOutlineType;
10811 return UnknownCallOutlineType;
10819 return UnknownCallOutlineType;
10840 for (MachineInstr &
MI :
MBB) {
10841 const MachineOperand *
Base;
10842 TypeSize Width(0,
false);
10844 bool OffsetIsScalable;
10847 if (!
MI.mayLoadOrStore() ||
10850 (
Base->isReg() &&
Base->getReg() != AArch64::SP))
10854 TypeSize Scale(0U,
false);
10855 int64_t Dummy1, Dummy2;
10858 assert(StackOffsetOperand.
isImm() &&
"Stack offset wasn't immediate!");
10860 assert(Scale != 0 &&
"Unexpected opcode!");
10861 assert(!OffsetIsScalable &&
"Expected offset to be a byte offset");
10866 int64_t NewImm = (
Offset + 16) / (int64_t)Scale.getFixedValue();
10867 StackOffsetOperand.
setImm(NewImm);
10873 bool ShouldSignReturnAddr) {
10874 if (!ShouldSignReturnAddr)
10882void AArch64InstrInfo::buildOutlinedFrame(
10886 AArch64FunctionInfo *FI = MF.
getInfo<AArch64FunctionInfo>();
10894 unsigned TailOpcode;
10896 TailOpcode = AArch64::TCRETURNdi;
10900 TailOpcode = AArch64::TCRETURNriALL;
10911 bool IsLeafFunction =
true;
10914 auto IsNonTailCall = [](
const MachineInstr &
MI) {
10915 return MI.isCall() && !
MI.isReturn();
10925 "Can only fix up stack references once");
10926 fixupPostOutline(
MBB);
10928 IsLeafFunction =
false;
10939 Et = std::prev(
MBB.
end());
10949 if (MF.
getInfo<AArch64FunctionInfo>()->needsDwarfUnwindInfo(MF)) {
10953 CFIBuilder.buildDefCFAOffset(16);
10957 CFIBuilder.buildOffset(AArch64::LR, -16);
10971 RASignCondition, !IsLeafFunction);
11000 fixupPostOutline(
MBB);
11011 .addGlobalAddress(
M.getNamedValue(MF.
getName()))
11021 .addGlobalAddress(
M.getNamedValue(MF.
getName())));
11030 MachineInstr *Save;
11031 MachineInstr *Restore;
11037 assert(
Reg &&
"No callee-saved register available?");
11071 .addGlobalAddress(
M.getNamedValue(MF.
getName())));
11079bool AArch64InstrInfo::shouldOutlineFromFunctionByDefault(
11087 bool AllowSideEffects)
const {
11089 const AArch64Subtarget &STI = MF.
getSubtarget<AArch64Subtarget>();
11092 if (
TRI.isGeneralPurposeRegister(MF,
Reg)) {
11105 assert(STI.hasNEON() &&
"Expected to have NEON.");
11111std::optional<DestSourcePair>
11116 if (((
MI.getOpcode() == AArch64::ORRWrs &&
11117 MI.getOperand(1).getReg() == AArch64::WZR &&
11118 MI.getOperand(3).getImm() == 0x0) ||
11119 (
MI.getOpcode() == AArch64::ORRWrr &&
11120 MI.getOperand(1).getReg() == AArch64::WZR)) &&
11122 (!
MI.getOperand(0).getReg().isVirtual() ||
11123 MI.getOperand(0).getSubReg() == 0) &&
11124 (!
MI.getOperand(0).getReg().isPhysical() ||
11129 if (
MI.getOpcode() == AArch64::ORRXrs &&
11130 MI.getOperand(1).getReg() == AArch64::XZR &&
11131 MI.getOperand(3).getImm() == 0x0)
11134 return std::nullopt;
11137std::optional<DestSourcePair>
11139 if ((
MI.getOpcode() == AArch64::ORRWrs &&
11140 MI.getOperand(1).getReg() == AArch64::WZR &&
11141 MI.getOperand(3).getImm() == 0x0) ||
11142 (
MI.getOpcode() == AArch64::ORRWrr &&
11143 MI.getOperand(1).getReg() == AArch64::WZR))
11145 return std::nullopt;
11148std::optional<RegImmPair>
11157 return std::nullopt;
11159 switch (
MI.getOpcode()) {
11161 return std::nullopt;
11162 case AArch64::SUBWri:
11163 case AArch64::SUBXri:
11164 case AArch64::SUBSWri:
11165 case AArch64::SUBSXri:
11168 case AArch64::ADDSWri:
11169 case AArch64::ADDSXri:
11170 case AArch64::ADDWri:
11171 case AArch64::ADDXri: {
11173 if (!
MI.getOperand(0).isReg() || !
MI.getOperand(1).isReg() ||
11174 !
MI.getOperand(2).isImm())
11175 return std::nullopt;
11176 int Shift =
MI.getOperand(3).getImm();
11177 assert((Shift == 0 || Shift == 12) &&
"Shift can be either 0 or 12");
11181 return RegImmPair{
MI.getOperand(1).getReg(),
Offset};
11187static std::optional<ParamLoadedValue>
11191 auto DestSrc =
TII->isCopyLikeInstr(
MI);
11193 return std::nullopt;
11195 Register DestReg = DestSrc->Destination->getReg();
11196 Register SrcReg = DestSrc->Source->getReg();
11199 return std::nullopt;
11204 if (DestReg == DescribedReg)
11208 if (
MI.getOpcode() == AArch64::ORRWrs &&
11209 TRI->isSuperRegister(DestReg, DescribedReg))
11213 if (
MI.getOpcode() == AArch64::ORRXrs &&
11214 TRI->isSubRegister(DestReg, DescribedReg)) {
11215 Register SrcSubReg =
TRI->getSubReg(SrcReg, AArch64::sub_32);
11219 assert(!
TRI->isSuperOrSubRegisterEq(DestReg, DescribedReg) &&
11220 "Unhandled ORR[XW]rs copy case");
11222 return std::nullopt;
11225bool AArch64InstrInfo::isFunctionSafeToSplit(
const MachineFunction &MF)
const {
11230 if (MF.
getInfo<AArch64FunctionInfo>()->hasRedZone().value_or(
true))
11236bool AArch64InstrInfo::isMBBSafeToSplitToCold(
11240 auto isAsmGoto = [](
const MachineInstr &
MI) {
11241 return MI.getOpcode() == AArch64::INLINEASM_BR;
11251 auto containsMBB = [&
MBB](
const MachineJumpTableEntry &JTE) {
11258 for (
const MachineInstr &
MI :
MBB) {
11259 switch (
MI.getOpcode()) {
11260 case TargetOpcode::G_BRJT:
11261 case AArch64::JumpTableDest32:
11262 case AArch64::JumpTableDest16:
11263 case AArch64::JumpTableDest8:
11274std::optional<ParamLoadedValue>
11277 const MachineFunction *MF =
MI.getMF();
11279 switch (
MI.getOpcode()) {
11280 case AArch64::MOVZWi:
11281 case AArch64::MOVZXi: {
11284 if (!
TRI->isSuperRegisterEq(
MI.getOperand(0).getReg(),
Reg))
11285 return std::nullopt;
11287 if (!
MI.getOperand(1).isImm())
11288 return std::nullopt;
11289 int64_t Immediate =
MI.getOperand(1).getImm();
11290 int Shift =
MI.getOperand(2).getImm();
11294 case AArch64::ORRWrs:
11295 case AArch64::ORRXrs:
11302bool AArch64InstrInfo::isExtendLikelyToBeFolded(
11305 ExtMI.
getOpcode() == TargetOpcode::G_ZEXT ||
11306 ExtMI.
getOpcode() == TargetOpcode::G_ANYEXT);
11309 if (ExtMI.
getOpcode() == TargetOpcode::G_ANYEXT)
11319 return UserMI->
getOpcode() == TargetOpcode::G_PTR_ADD;
11322uint64_t AArch64InstrInfo::getElementSizeForOpcode(
unsigned Opc)
const {
11326bool AArch64InstrInfo::isPTestLikeOpcode(
unsigned Opc)
const {
11330bool AArch64InstrInfo::isWhileOpcode(
unsigned Opc)
const {
11335AArch64InstrInfo::getTailDuplicateSize(
CodeGenOptLevel OptLevel)
const {
11339bool AArch64InstrInfo::isLegalAddressingMode(
unsigned NumBytes, int64_t
Offset,
11340 unsigned Scale)
const {
11351 unsigned Shift =
Log2_64(NumBytes);
11352 if (NumBytes &&
Offset > 0 && (
Offset / NumBytes) <= (1LL << 12) - 1 &&
11360 return Scale == 1 || (Scale > 0 && Scale == NumBytes);
11365 return AArch64::BLRNoIP;
11367 return AArch64::BLR;
11373 auto Builder =
BuildMI(
MBB, InsertPt,
DL,
get(AArch64::PAUTH_EPILOGUE))
11383 Register TargetReg,
bool FrameSetup)
const {
11384 assert(TargetReg != AArch64::SP &&
"New top of stack cannot already be in SP");
11396 MF.
insert(MBBInsertPoint, LoopTestMBB);
11399 MF.
insert(MBBInsertPoint, LoopBodyMBB);
11401 MF.
insert(MBBInsertPoint, ExitMBB);
11411 BuildMI(*LoopTestMBB, LoopTestMBB->
end(),
DL,
TII->get(AArch64::SUBSXrx64),
11419 BuildMI(*LoopTestMBB, LoopTestMBB->
end(),
DL,
TII->get(AArch64::Bcc))
11425 BuildMI(*LoopBodyMBB, LoopBodyMBB->
end(),
DL,
TII->get(AArch64::LDRXui))
11442 BuildMI(*ExitMBB, ExitMBB->
end(),
DL,
TII->get(AArch64::ADDXri), AArch64::SP)
11461 MBB.addSuccessor(LoopTestMBB);
11467 return ExitMBB->
begin();
11472 MachineFunction *MF;
11473 const TargetInstrInfo *
TII;
11474 const TargetRegisterInfo *
TRI;
11475 MachineRegisterInfo &MRI;
11478 MachineBasicBlock *LoopBB;
11480 MachineInstr *CondBranch;
11482 MachineInstr *Comp;
11484 unsigned CompCounterOprNum;
11486 MachineInstr *Update;
11488 unsigned UpdateCounterOprNum;
11492 bool IsUpdatePriorComp;
11498 AArch64PipelinerLoopInfo(MachineBasicBlock *LoopBB, MachineInstr *CondBranch,
11499 MachineInstr *Comp,
unsigned CompCounterOprNum,
11500 MachineInstr *Update,
unsigned UpdateCounterOprNum,
11501 Register Init,
bool IsUpdatePriorComp,
11502 const SmallVectorImpl<MachineOperand> &
Cond)
11504 TII(MF->getSubtarget().getInstrInfo()),
11505 TRI(MF->getSubtarget().getRegisterInfo()), MRI(MF->getRegInfo()),
11506 LoopBB(LoopBB), CondBranch(CondBranch), Comp(Comp),
11507 CompCounterOprNum(CompCounterOprNum), Update(Update),
11508 UpdateCounterOprNum(UpdateCounterOprNum), Init(Init),
11511 bool shouldIgnoreForPipelining(
const MachineInstr *
MI)
const override {
11517 std::optional<bool> createTripCountGreaterCondition(
11518 int TC, MachineBasicBlock &
MBB,
11519 SmallVectorImpl<MachineOperand> &CondParam)
override {
11527 void createRemainingIterationsGreaterCondition(
11528 int TC, MachineBasicBlock &
MBB, SmallVectorImpl<MachineOperand> &
Cond,
11529 DenseMap<MachineInstr *, MachineInstr *> &LastStage0Insts)
override;
11531 void setPreheader(MachineBasicBlock *NewPreheader)
override {}
11533 void adjustTripCount(
int TripCountAdjust)
override {}
11535 bool isMVEExpanderSupported()
override {
return true; }
11554 }
else if (
I == ReplaceOprNum) {
11559 MBB.insert(InsertTo, NewMI);
11563void AArch64PipelinerLoopInfo::createRemainingIterationsGreaterCondition(
11579 assert(CondBranch->getOpcode() == AArch64::Bcc);
11583 if (CondBranch->getOperand(1).getMBB() == LoopBB)
11590 auto AccumulateCond = [&](
Register CurCond,
11601 if (!LastStage0Insts.
empty() && LastStage0Insts[Comp]->getParent() == &
MBB) {
11605 for (
int I = 0;
I <= TC; ++
I) {
11611 AccCond = AccumulateCond(AccCond, CC);
11615 if (Update != Comp && IsUpdatePriorComp) {
11617 LastStage0Insts[Comp]->getOperand(CompCounterOprNum).getReg();
11618 NextCounter =
cloneInstr(Update, UpdateCounterOprNum, Counter,
MBB,
11622 NextCounter = LastStage0Insts[Update]->getOperand(0).getReg();
11624 }
else if (Update != Comp) {
11629 Counter = NextCounter;
11633 if (LastStage0Insts.
empty()) {
11637 if (IsUpdatePriorComp)
11642 Counter = LastStage0Insts[Comp]->getOperand(CompCounterOprNum).getReg();
11645 for (
int I = 0;
I <= TC; ++
I) {
11649 AccCond = AccumulateCond(AccCond, CC);
11650 if (
I != TC && Update != Comp)
11653 Counter = NextCounter;
11669 assert(Phi.getNumOperands() == 5);
11670 if (Phi.getOperand(2).getMBB() ==
MBB) {
11671 RegMBB = Phi.getOperand(1).getReg();
11672 RegOther = Phi.getOperand(3).getReg();
11674 assert(Phi.getOperand(4).getMBB() ==
MBB);
11675 RegMBB = Phi.getOperand(3).getReg();
11676 RegOther = Phi.getOperand(1).getReg();
11681 if (!
Reg.isVirtual())
11690 unsigned &UpdateCounterOprNum,
Register &InitReg,
11691 bool &IsUpdatePriorComp) {
11705 if (!
Reg.isVirtual())
11708 UpdateInst =
nullptr;
11709 UpdateCounterOprNum = 0;
11711 IsUpdatePriorComp =
true;
11715 if (Def->getParent() != LoopBB)
11717 if (Def->isCopy()) {
11719 if (Def->getOperand(0).getSubReg() || Def->getOperand(1).getSubReg())
11721 CurReg = Def->getOperand(1).getReg();
11722 }
else if (Def->isPHI()) {
11726 IsUpdatePriorComp =
false;
11731 switch (Def->getOpcode()) {
11732 case AArch64::ADDSXri:
11733 case AArch64::ADDSWri:
11734 case AArch64::SUBSXri:
11735 case AArch64::SUBSWri:
11736 case AArch64::ADDXri:
11737 case AArch64::ADDWri:
11738 case AArch64::SUBXri:
11739 case AArch64::SUBWri:
11741 UpdateCounterOprNum = 1;
11743 case AArch64::ADDSXrr:
11744 case AArch64::ADDSWrr:
11745 case AArch64::SUBSXrr:
11746 case AArch64::SUBSWrr:
11747 case AArch64::ADDXrr:
11748 case AArch64::ADDWrr:
11749 case AArch64::SUBXrr:
11750 case AArch64::SUBWrr:
11753 UpdateCounterOprNum = 1;
11755 UpdateCounterOprNum = 2;
11762 CurReg = Def->getOperand(UpdateCounterOprNum).getReg();
11777std::unique_ptr<TargetInstrInfo::PipelinerLoopInfo>
11788 if (
MI.isCall() ||
MI.hasUnmodeledSideEffects())
11799 if (
TBB == LoopBB && FBB == LoopBB)
11803 if (
TBB != LoopBB && FBB ==
nullptr)
11806 assert((
TBB == LoopBB || FBB == LoopBB) &&
11807 "The Loop must be a single-basic-block loop");
11812 if (CondBranch->
getOpcode() != AArch64::Bcc)
11820 unsigned CompCounterOprNum = 0;
11822 if (
MI.modifiesRegister(AArch64::NZCV, &
TRI)) {
11826 switch (
MI.getOpcode()) {
11827 case AArch64::SUBSXri:
11828 case AArch64::SUBSWri:
11829 case AArch64::ADDSXri:
11830 case AArch64::ADDSWri:
11832 CompCounterOprNum = 1;
11834 case AArch64::ADDSWrr:
11835 case AArch64::ADDSXrr:
11836 case AArch64::SUBSWrr:
11837 case AArch64::SUBSXrr:
11841 if (isWhileOpcode(
MI.getOpcode())) {
11848 if (CompCounterOprNum == 0) {
11850 CompCounterOprNum = 2;
11852 CompCounterOprNum = 1;
11864 bool IsUpdatePriorComp;
11865 unsigned UpdateCounterOprNum;
11867 Update, UpdateCounterOprNum,
Init, IsUpdatePriorComp))
11870 return std::make_unique<AArch64PipelinerLoopInfo>(
11871 LoopBB, CondBranch, Comp, CompCounterOprNum, Update, UpdateCounterOprNum,
11881 TypeSize Scale(0U,
false), Width(0U,
false);
11882 int64_t MinOffset, MaxOffset;
11883 if (
getMemOpInfo(
MI.getOpcode(), Scale, Width, MinOffset, MaxOffset)) {
11885 if (
MI.getOperand(ImmIdx).isImm() && !
MI.getOperand(ImmIdx - 1).isFI()) {
11886 int64_t Imm =
MI.getOperand(ImmIdx).getImm();
11887 if (Imm < MinOffset || Imm > MaxOffset) {
11888 ErrInfo =
"Unexpected immediate on load/store instruction";
11894 const MCInstrDesc &MCID =
MI.getDesc();
11896 const MachineOperand &MO =
MI.getOperand(
Op);
11900 ErrInfo =
"OPERAND_IMPLICIT_IMM_0 should be 0";
11909 ErrInfo =
"OPERAND_SHIFT_MSL should be msl shift of 8 or 16";
11920#define GET_INSTRINFO_HELPERS
11921#define GET_INSTRMAP_INFO
11922#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 std::optional< unsigned > getLFIInstSizeInBytes(const MachineInstr &MI)
Return the maximum number of bytes of code the specified instruction may be after LFI rewriting.
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...
bool branchTargetEnforcement() const
SignReturnAddress getSignReturnAddressCondition() const
bool hasStreamingModeChanges() const
void setOutliningStyle(const std::string &Style)
bool branchProtectionPAuthLR() const
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 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.
void createPauthEpilogueInstr(MachineBasicBlock &MBB, DebugLoc DL) const
Return true when there is potentially a faster code sequence for an instruction chain ending in Root.
bool isBranchOffsetInRange(unsigned BranchOpc, int64_t BrOffset) const override
bool canInsertSelect(const MachineBasicBlock &, ArrayRef< MachineOperand > Cond, Register, Register, Register, int &, int &, int &) const override
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.
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.
MachineInstr * foldMemoryOperandImpl(MachineFunction &MF, MachineInstr &MI, ArrayRef< unsigned > Ops, int FrameIndex, MachineInstr *&CopyMI, LiveIntervals *LIS=nullptr, VirtRegMap *VRM=nullptr) const override
bool getMemOperandWithOffsetWidth(const MachineInstr &MI, const MachineOperand *&BaseOp, int64_t &Offset, bool &OffsetIsScalable, TypeSize &Width, const TargetRegisterInfo *TRI) const
If OffsetIsScalable is set to 'true', the offset is scaled by vscale.
Register isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
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
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,...
Represent a constant reference to an array (0 or more elements consecutively in memory),...
const T & front() const
Get the first element.
size_t size() const
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()
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.
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.
const MCAsmInfo & getMCAsmInfo() const
Return target specific asm information.
CodeModel::Model getCodeModel() const
Returns the code model.
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 expandMOVAddr(unsigned Opcode, unsigned TargetFlags, bool IsTargetMachO, SmallVectorImpl< AddrInsnModel > &Insn)
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.
NodeAddr< InstrNode * > Instr
LLVM_ABI Instruction & back() const
LLVM_ABI iterator begin() 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.