67#define GET_INSTRINFO_CTOR_DTOR
68#include "AArch64GenInstrInfo.inc"
70#define DEBUG_TYPE "AArch64InstrInfo"
72STATISTIC(NumCopyInstrs,
"Number of COPY instructions expanded");
73STATISTIC(NumZCRegMoveInstrsGPR,
"Number of zero-cycle GPR register move "
74 "instructions expanded from canonical COPY");
75STATISTIC(NumZCRegMoveInstrsFPR,
"Number of zero-cycle FPR register move "
76 "instructions expanded from canonical COPY");
77STATISTIC(NumZCZeroingInstrsGPR,
"Number of zero-cycle GPR zeroing "
78 "instructions expanded from canonical COPY");
83 cl::desc(
"Restrict range of CB instructions (DEBUG)"));
87 cl::desc(
"Restrict range of TB[N]Z instructions (DEBUG)"));
91 cl::desc(
"Restrict range of CB[N]Z instructions (DEBUG)"));
95 cl::desc(
"Restrict range of Bcc instructions (DEBUG)"));
99 cl::desc(
"Restrict range of B instructions (DEBUG)"));
103 cl::desc(
"Restrict range of instructions to search for the "
104 "machine-combiner gather pattern optimization"));
108 cl::desc(
"Use a frame record for Mach-O non-leaf outlined functions"));
113 RI(STI.getTargetTriple(), STI.getHwMode()), Subtarget(STI) {}
123 switch (
MI.getOpcode()) {
146 case AArch64::BLRAAZ:
148 case AArch64::BLRABZ:
152 case AArch64::AUTIASP:
153 case AArch64::AUTIBSP:
154 case AArch64::AUTIAZ:
155 case AArch64::AUTIBZ:
156 case AArch64::XPACLRI:
161 if (
MI.getOperand(0).getImm() == 3 &&
MI.getOperand(1).getImm() == 7 &&
162 MI.getOperand(3).getImm() == 1)
170 bool ModifiesLR =
false;
171 bool ModifiesSP =
false;
175 if (MO.getReg() == AArch64::LR)
177 else if (MO.getReg() == AArch64::SP)
186 if (
MI.mayLoadOrStore()) {
194 if (ModifiesSP || ModifiesLR)
207 if (!
Desc.isPseudo() && !Subtarget.isLFI()) {
208 assert(
Desc.getSize() == 4 &&
"Unexpected instruction size");
218 auto Op =
MI.getOpcode();
219 if (
Op == AArch64::INLINEASM ||
Op == AArch64::INLINEASM_BR)
220 return getInlineAsmLength(
MI.getOperand(0).getSymbolName(), MAI);
224 if (
MI.isMetaInstruction())
229 unsigned NumBytes = 0;
238 NumBytes =
Desc.getSize() ?
Desc.getSize() : 4;
241 if (!MFI->shouldSignReturnAddress(*MF))
244 auto Method = STI.getAuthenticatedLRCheckMethod(*MF);
252 switch (
Desc.getOpcode()) {
255 return Desc.getSize();
262 case TargetOpcode::STACKMAP:
265 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
267 case TargetOpcode::PATCHPOINT:
270 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
272 case TargetOpcode::STATEPOINT:
274 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
279 case TargetOpcode::PATCHABLE_FUNCTION_ENTER:
284 F.getFnAttributeAsParsedInteger(
"patchable-function-entry", 9) * 4;
286 case TargetOpcode::PATCHABLE_FUNCTION_EXIT:
287 case TargetOpcode::PATCHABLE_TAIL_CALL:
288 case TargetOpcode::PATCHABLE_TYPED_EVENT_CALL:
292 case TargetOpcode::PATCHABLE_EVENT_CALL:
298 NumBytes =
MI.getOperand(1).getImm();
300 case AArch64::MOVaddr:
301 case AArch64::MOVaddrJT:
302 case AArch64::MOVaddrCP:
303 case AArch64::MOVaddrBA:
304 case AArch64::MOVaddrTLS:
305 case AArch64::MOVaddrEXT: {
309 MI.getOperand(1).getTargetFlags(),
310 Subtarget.isTargetMachO(), Insn);
311 NumBytes = Insn.
size() * 4;
315 case AArch64::MOVi32imm:
316 case AArch64::MOVi64imm: {
318 unsigned BitSize =
Desc.getOpcode() == AArch64::MOVi32imm ? 32 : 64;
321 NumBytes = Insn.
size() * 4;
325 case TargetOpcode::BUNDLE:
326 NumBytes = getInstBundleSize(
MI);
362 case AArch64::CBWPri:
363 case AArch64::CBXPri:
364 case AArch64::CBWPrr:
365 case AArch64::CBXPrr:
373 case AArch64::CBBAssertExt:
374 case AArch64::CBHAssertExt:
405 case AArch64::CBWPri:
406 case AArch64::CBXPri:
407 case AArch64::CBBAssertExt:
408 case AArch64::CBHAssertExt:
409 case AArch64::CBWPrr:
410 case AArch64::CBXPrr:
416 int64_t BrOffset)
const {
418 assert(Bits >= 3 &&
"max branch displacement must be enough to jump"
419 "over conditional branch expansion");
420 return isIntN(Bits, BrOffset / 4);
425 switch (
MI.getOpcode()) {
429 return MI.getOperand(0).getMBB();
434 return MI.getOperand(2).getMBB();
440 return MI.getOperand(1).getMBB();
441 case AArch64::CBWPri:
442 case AArch64::CBXPri:
443 case AArch64::CBBAssertExt:
444 case AArch64::CBHAssertExt:
445 case AArch64::CBWPrr:
446 case AArch64::CBXPrr:
447 return MI.getOperand(3).getMBB();
457 assert(RS &&
"RegScavenger required for long branching");
459 "new block should be inserted for expanding unconditional branch");
462 "restore block should be inserted for restoring clobbered registers");
469 "Branch offsets outside of the signed 33-bit range not supported");
480 RS->enterBasicBlockEnd(
MBB);
483 constexpr Register Reg = AArch64::X16;
484 if (!RS->isRegUsed(Reg)) {
485 insertUnconditionalBranch(
MBB, &NewDestBB,
DL);
496 Register Scavenged = RS->FindUnusedReg(&AArch64::GPR64RegClass);
498 buildIndirectBranch(Scavenged, NewDestBB);
499 RS->setRegUsed(Scavenged);
508 "Unable to insert indirect branch inside function that has red zone");
531 bool AllowModify)
const {
538 if (
I->getOpcode() == AArch64::SpeculationBarrierISBDSBEndBB ||
539 I->getOpcode() == AArch64::SpeculationBarrierSBEndBB) {
543 if (!isUnpredicatedTerminator(*
I))
550 unsigned LastOpc = LastInst->
getOpcode();
551 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
566 unsigned SecondLastOpc = SecondLastInst->
getOpcode();
573 LastInst = SecondLastInst;
575 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
580 SecondLastInst = &*
I;
581 SecondLastOpc = SecondLastInst->
getOpcode();
592 LastInst = SecondLastInst;
594 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
596 "unreachable unconditional branches removed above");
605 SecondLastInst = &*
I;
606 SecondLastOpc = SecondLastInst->
getOpcode();
610 if (SecondLastInst &&
I !=
MBB.begin() && isUnpredicatedTerminator(*--
I))
626 I->eraseFromParent();
635 I->eraseFromParent();
644 MachineBranchPredicate &MBP,
645 bool AllowModify)
const {
657 assert(MBP.TrueDest &&
"expected!");
658 MBP.FalseDest = FBB ? FBB :
MBB.getNextNode();
660 MBP.ConditionDef =
nullptr;
661 MBP.SingleUseCondition =
false;
671 if (
I ==
MBB.begin())
687 if (
MI.modifiesRegister(AArch64::NZCV,
nullptr)) {
688 MBP.ConditionDef = &
MI;
697 case AArch64::CBNZX: {
701 MBP.Predicate = (
Opc == AArch64::CBNZX ||
Opc == AArch64::CBNZW)
702 ? MachineBranchPredicate::PRED_NE
703 : MachineBranchPredicate::PRED_EQ;
704 Register CondReg = MBP.LHS.getReg();
713 case AArch64::TBNZX: {
734 Cond[1].setImm(AArch64::CBNZW);
737 Cond[1].setImm(AArch64::CBZW);
740 Cond[1].setImm(AArch64::CBNZX);
743 Cond[1].setImm(AArch64::CBZX);
746 Cond[1].setImm(AArch64::TBNZW);
749 Cond[1].setImm(AArch64::TBZW);
752 Cond[1].setImm(AArch64::TBNZX);
755 Cond[1].setImm(AArch64::TBZX);
759 case AArch64::CBWPri:
760 case AArch64::CBXPri:
761 case AArch64::CBBAssertExt:
762 case AArch64::CBHAssertExt:
763 case AArch64::CBWPrr:
764 case AArch64::CBXPrr: {
777 int *BytesRemoved)
const {
787 I->eraseFromParent();
791 if (
I ==
MBB.begin()) {
804 I->eraseFromParent();
811void AArch64InstrInfo::instantiateCondBranch(
836 if (
Cond.size() > 5) {
847 assert(
TBB &&
"insertBranch must not be told to insert a fallthrough");
878 return Opc == AArch64::CBBAssertExt;
881 return Opc == AArch64::CBHAssertExt;
893 switch (
Cond.size()) {
968 unsigned SubsOpc, SubsDestReg;
974 case AArch64::CBWPri:
975 SubsOpc = AArch64::SUBSWri;
976 SubsDestReg = AArch64::WZR;
979 case AArch64::CBXPri:
980 SubsOpc = AArch64::SUBSXri;
981 SubsDestReg = AArch64::XZR;
984 case AArch64::CBWPrr:
985 SubsOpc = AArch64::SUBSWrr;
986 SubsDestReg = AArch64::WZR;
989 case AArch64::CBXPrr:
990 SubsOpc = AArch64::SUBSXrr;
991 SubsDestReg = AArch64::XZR;
1025 "Unexpected compare-and-branch instruction for extend type");
1026 switch (ExtendType) {
1030 ExtOpc = AArch64::SBFMWri;
1034 ExtOpc = AArch64::SBFMWri;
1038 ExtOpc = AArch64::ANDWri;
1042 ExtOpc = AArch64::ANDWri;
1051 if (ExtOpc != AArch64::ANDWri)
1053 MBBI.addImm(ExtBits);
1062 "Unexpected compare-and-branch instruction for extend type");
1083 unsigned Opc =
MI.getOpcode();
1090 if (
MI.getOperand(0).getReg() == AArch64::WZR ||
1091 MI.getOperand(0).getReg() == AArch64::XZR) {
1093 dbgs() <<
"Removing always taken branch: " <<
MI);
1096 for (
auto *S : Succs)
1098 MBB->removeSuccessor(S);
1100 while (
MBB->rbegin() != &
MI)
1101 MBB->rbegin()->eraseFromParent();
1102 MI.eraseFromParent();
1107 case AArch64::CBNZW:
1108 case AArch64::CBNZX:
1109 case AArch64::TBNZW:
1110 case AArch64::TBNZX:
1112 if (
MI.getOperand(0).getReg() == AArch64::WZR ||
1113 MI.getOperand(0).getReg() == AArch64::XZR) {
1115 dbgs() <<
"Removing never taken branch: " <<
MI);
1117 MI.getParent()->removeSuccessor(
Target);
1118 MI.eraseFromParent();
1133 VReg =
DefMI->getOperand(1).getReg();
1142 unsigned *NewReg =
nullptr) {
1147 bool Is64Bit = AArch64::GPR64allRegClass.hasSubClassEq(MRI.
getRegClass(VReg));
1152 unsigned SrcReg = 0;
1153 switch (
DefMI->getOpcode()) {
1154 case AArch64::SUBREG_TO_REG:
1158 if (!
DefMI->getOperand(1).isReg())
1160 if (!
DefMI->getOperand(2).isImm() ||
1161 DefMI->getOperand(2).getImm() != AArch64::sub_32)
1164 if (
DefMI->getOpcode() != AArch64::MOVi32imm)
1166 if (!
DefMI->getOperand(1).isImm() ||
DefMI->getOperand(1).getImm() != 1)
1169 SrcReg = AArch64::XZR;
1170 Opc = AArch64::CSINCXr;
1173 case AArch64::MOVi32imm:
1174 case AArch64::MOVi64imm:
1175 if (!
DefMI->getOperand(1).isImm() ||
DefMI->getOperand(1).getImm() != 1)
1177 SrcReg = Is64Bit ? AArch64::XZR : AArch64::WZR;
1178 Opc = Is64Bit ? AArch64::CSINCXr : AArch64::CSINCWr;
1181 case AArch64::ADDSXri:
1182 case AArch64::ADDSWri:
1184 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
1189 case AArch64::ADDXri:
1190 case AArch64::ADDWri:
1192 if (!
DefMI->getOperand(2).isImm() ||
DefMI->getOperand(2).getImm() != 1 ||
1193 DefMI->getOperand(3).getImm() != 0)
1195 SrcReg =
DefMI->getOperand(1).getReg();
1196 Opc = Is64Bit ? AArch64::CSINCXr : AArch64::CSINCWr;
1199 case AArch64::ORNXrr:
1200 case AArch64::ORNWrr: {
1203 if (ZReg != AArch64::XZR && ZReg != AArch64::WZR)
1205 SrcReg =
DefMI->getOperand(2).getReg();
1206 Opc = Is64Bit ? AArch64::CSINVXr : AArch64::CSINVWr;
1210 case AArch64::SUBSXrr:
1211 case AArch64::SUBSWrr:
1213 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
1218 case AArch64::SUBXrr:
1219 case AArch64::SUBWrr: {
1222 if (ZReg != AArch64::XZR && ZReg != AArch64::WZR)
1224 SrcReg =
DefMI->getOperand(2).getReg();
1225 Opc = Is64Bit ? AArch64::CSNEGXr : AArch64::CSNEGWr;
1231 assert(
Opc && SrcReg &&
"Missing parameters");
1241 Register FalseReg,
int &CondCycles,
1243 int &FalseCycles)
const {
1254 if (!RI.getCommonSubClass(RC, MRI.
getRegClass(DstReg)))
1258 unsigned ExtraCondLat =
Cond.size() != 1;
1262 if (AArch64::GPR64allRegClass.hasSubClassEq(RC) ||
1263 AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
1265 CondCycles = 1 + ExtraCondLat;
1266 TrueCycles = FalseCycles = 1;
1276 if (AArch64::FPR64RegClass.hasSubClassEq(RC) ||
1277 AArch64::FPR32RegClass.hasSubClassEq(RC)) {
1278 CondCycles = 5 + ExtraCondLat;
1279 TrueCycles = FalseCycles = 2;
1285 if (AArch64::FPR128RegClass.hasSubClassEq(RC) &&
1286 Subtarget.isNeonAvailable() &&
1287 !
MBB.getParent()->getFunction().hasMinSize()) {
1288 CondCycles = 8 + ExtraCondLat;
1289 TrueCycles = FalseCycles = 2;
1308 assert(Subtarget.isNeonAvailable() &&
"Expected NEON for a vector select");
1327 bool TryFold =
false;
1329 RC = &AArch64::GPR64RegClass;
1330 Opc = AArch64::CSELXr;
1333 RC = &AArch64::GPR32RegClass;
1334 Opc = AArch64::CSELWr;
1337 RC = &AArch64::FPR64RegClass;
1338 Opc = AArch64::FCSELDrrr;
1340 RC = &AArch64::FPR32RegClass;
1341 Opc = AArch64::FCSELSrrr;
1343 assert(RC &&
"Unsupported regclass");
1347 unsigned NewReg = 0;
1370 (FalseReg.
isVirtual() || FalseReg == AArch64::WZR ||
1371 FalseReg == AArch64::XZR) &&
1372 "FalseReg was folded into a non-virtual register other than WZR or XZR");
1389 assert(BitSize == 64 &&
"Only bit sizes of 32 or 64 allowed");
1394 return Is.
size() <= 2;
1399 assert(
MI.isCopy() &&
"Expected COPY instruction");
1405 if (
Reg.isVirtual())
1407 if (
Reg.isPhysical())
1408 return RI.getMinimalPhysRegClass(
Reg);
1413 if (DstRC && SrcRC && !RI.getCommonSubClass(DstRC, SrcRC))
1416 return MI.isAsCheapAsAMove();
1422 if (Subtarget.hasExynosCheapAsMoveHandling()) {
1423 if (isExynosCheapAsMove(
MI))
1425 return MI.isAsCheapAsAMove();
1428 switch (
MI.getOpcode()) {
1430 return MI.isAsCheapAsAMove();
1432 case TargetOpcode::COPY:
1435 case AArch64::ADDWrs:
1436 case AArch64::ADDXrs:
1437 case AArch64::SUBWrs:
1438 case AArch64::SUBXrs:
1439 return Subtarget.hasALULSLFast() &&
MI.getOperand(3).getImm() <= 4;
1444 case AArch64::MOVi32imm:
1446 case AArch64::MOVi64imm:
1451bool AArch64InstrInfo::isFalkorShiftExtFast(
const MachineInstr &
MI) {
1452 switch (
MI.getOpcode()) {
1456 case AArch64::ADDWrs:
1457 case AArch64::ADDXrs:
1458 case AArch64::ADDSWrs:
1459 case AArch64::ADDSXrs: {
1460 unsigned Imm =
MI.getOperand(3).getImm();
1467 case AArch64::ADDWrx:
1468 case AArch64::ADDXrx:
1469 case AArch64::ADDXrx64:
1470 case AArch64::ADDSWrx:
1471 case AArch64::ADDSXrx:
1472 case AArch64::ADDSXrx64: {
1473 unsigned Imm =
MI.getOperand(3).getImm();
1485 case AArch64::SUBWrs:
1486 case AArch64::SUBSWrs: {
1487 unsigned Imm =
MI.getOperand(3).getImm();
1489 return ShiftVal == 0 ||
1493 case AArch64::SUBXrs:
1494 case AArch64::SUBSXrs: {
1495 unsigned Imm =
MI.getOperand(3).getImm();
1497 return ShiftVal == 0 ||
1501 case AArch64::SUBWrx:
1502 case AArch64::SUBXrx:
1503 case AArch64::SUBXrx64:
1504 case AArch64::SUBSWrx:
1505 case AArch64::SUBSXrx:
1506 case AArch64::SUBSXrx64: {
1507 unsigned Imm =
MI.getOperand(3).getImm();
1519 case AArch64::LDRBBroW:
1520 case AArch64::LDRBBroX:
1521 case AArch64::LDRBroW:
1522 case AArch64::LDRBroX:
1523 case AArch64::LDRDroW:
1524 case AArch64::LDRDroX:
1525 case AArch64::LDRHHroW:
1526 case AArch64::LDRHHroX:
1527 case AArch64::LDRHroW:
1528 case AArch64::LDRHroX:
1529 case AArch64::LDRQroW:
1530 case AArch64::LDRQroX:
1531 case AArch64::LDRSBWroW:
1532 case AArch64::LDRSBWroX:
1533 case AArch64::LDRSBXroW:
1534 case AArch64::LDRSBXroX:
1535 case AArch64::LDRSHWroW:
1536 case AArch64::LDRSHWroX:
1537 case AArch64::LDRSHXroW:
1538 case AArch64::LDRSHXroX:
1539 case AArch64::LDRSWroW:
1540 case AArch64::LDRSWroX:
1541 case AArch64::LDRSroW:
1542 case AArch64::LDRSroX:
1543 case AArch64::LDRWroW:
1544 case AArch64::LDRWroX:
1545 case AArch64::LDRXroW:
1546 case AArch64::LDRXroX:
1547 case AArch64::PRFMroW:
1548 case AArch64::PRFMroX:
1549 case AArch64::STRBBroW:
1550 case AArch64::STRBBroX:
1551 case AArch64::STRBroW:
1552 case AArch64::STRBroX:
1553 case AArch64::STRDroW:
1554 case AArch64::STRDroX:
1555 case AArch64::STRHHroW:
1556 case AArch64::STRHHroX:
1557 case AArch64::STRHroW:
1558 case AArch64::STRHroX:
1559 case AArch64::STRQroW:
1560 case AArch64::STRQroX:
1561 case AArch64::STRSroW:
1562 case AArch64::STRSroX:
1563 case AArch64::STRWroW:
1564 case AArch64::STRWroX:
1565 case AArch64::STRXroW:
1566 case AArch64::STRXroX: {
1567 unsigned IsSigned =
MI.getOperand(3).getImm();
1574 unsigned Opc =
MI.getOpcode();
1578 case AArch64::SEH_StackAlloc:
1579 case AArch64::SEH_SaveFPLR:
1580 case AArch64::SEH_SaveFPLR_X:
1581 case AArch64::SEH_SaveReg:
1582 case AArch64::SEH_SaveReg_X:
1583 case AArch64::SEH_SaveRegP:
1584 case AArch64::SEH_SaveRegP_X:
1585 case AArch64::SEH_SaveFReg:
1586 case AArch64::SEH_SaveFReg_X:
1587 case AArch64::SEH_SaveFRegP:
1588 case AArch64::SEH_SaveFRegP_X:
1589 case AArch64::SEH_SetFP:
1590 case AArch64::SEH_AddFP:
1591 case AArch64::SEH_Nop:
1592 case AArch64::SEH_PrologEnd:
1593 case AArch64::SEH_EpilogStart:
1594 case AArch64::SEH_EpilogEnd:
1595 case AArch64::SEH_PACSignLR:
1596 case AArch64::SEH_SaveAnyRegI:
1597 case AArch64::SEH_SaveAnyRegIP:
1598 case AArch64::SEH_SaveAnyRegQP:
1599 case AArch64::SEH_SaveAnyRegQPX:
1600 case AArch64::SEH_AllocZ:
1601 case AArch64::SEH_SaveZReg:
1602 case AArch64::SEH_SavePReg:
1609 unsigned &SubIdx)
const {
1610 switch (
MI.getOpcode()) {
1613 case AArch64::SBFMXri:
1614 case AArch64::UBFMXri:
1617 if (
MI.getOperand(2).getImm() != 0 ||
MI.getOperand(3).getImm() != 31)
1620 SrcReg =
MI.getOperand(1).getReg();
1621 DstReg =
MI.getOperand(0).getReg();
1622 SubIdx = AArch64::sub_32;
1630 int64_t OffsetA = 0, OffsetB = 0;
1631 TypeSize WidthA(0,
false), WidthB(0,
false);
1632 bool OffsetAIsScalable =
false, OffsetBIsScalable =
false;
1653 OffsetAIsScalable == OffsetBIsScalable) {
1654 int LowOffset = OffsetA < OffsetB ? OffsetA : OffsetB;
1655 int HighOffset = OffsetA < OffsetB ? OffsetB : OffsetA;
1656 TypeSize LowWidth = (LowOffset == OffsetA) ? WidthA : WidthB;
1657 if (LowWidth.
isScalable() == OffsetAIsScalable &&
1675 switch (
MI.getOpcode()) {
1678 if (
MI.getOperand(0).getImm() == 0x14)
1685 case AArch64::MSRpstatesvcrImm1:
1692 auto Next = std::next(
MI.getIterator());
1693 return Next !=
MBB->end() &&
Next->isCFIInstruction();
1700 Register &SrcReg2, int64_t &CmpMask,
1701 int64_t &CmpValue)
const {
1705 assert(
MI.getNumOperands() >= 2 &&
"All AArch64 cmps should have 2 operands");
1706 if (!
MI.getOperand(1).isReg() ||
MI.getOperand(1).getSubReg())
1709 switch (
MI.getOpcode()) {
1712 case AArch64::PTEST_PP:
1713 case AArch64::PTEST_PP_ANY:
1714 case AArch64::PTEST_PP_FIRST:
1715 SrcReg =
MI.getOperand(0).getReg();
1716 SrcReg2 =
MI.getOperand(1).getReg();
1717 if (
MI.getOperand(2).getSubReg())
1724 case AArch64::SUBSWrr:
1725 case AArch64::SUBSWrs:
1726 case AArch64::SUBSWrx:
1727 case AArch64::SUBSXrr:
1728 case AArch64::SUBSXrs:
1729 case AArch64::SUBSXrx:
1730 case AArch64::ADDSWrr:
1731 case AArch64::ADDSWrs:
1732 case AArch64::ADDSWrx:
1733 case AArch64::ADDSXrr:
1734 case AArch64::ADDSXrs:
1735 case AArch64::ADDSXrx:
1737 SrcReg =
MI.getOperand(1).getReg();
1738 SrcReg2 =
MI.getOperand(2).getReg();
1741 if (
MI.getOperand(2).getSubReg())
1747 case AArch64::SUBSWri:
1748 case AArch64::ADDSWri:
1749 case AArch64::SUBSXri:
1750 case AArch64::ADDSXri:
1751 SrcReg =
MI.getOperand(1).getReg();
1754 CmpValue =
MI.getOperand(2).getImm();
1756 case AArch64::ANDSWri:
1757 case AArch64::ANDSXri:
1760 SrcReg =
MI.getOperand(1).getReg();
1764 MI.getOperand(2).getImm(),
1765 MI.getOpcode() == AArch64::ANDSWri ? 32 : 64);
1774 assert(
MBB &&
"Can't get MachineBasicBlock here");
1776 assert(MF &&
"Can't get MachineFunction here");
1781 for (
unsigned OpIdx = 0, EndIdx = Instr.getNumOperands(); OpIdx < EndIdx;
1785 Instr.getRegClassConstraint(OpIdx,
TII,
TRI);
1788 if (!OpRegCstraints)
1796 "Operand has register constraints without being a register!");
1799 if (
Reg.isPhysical()) {
1816 bool MIDefinesZeroReg =
false;
1817 if (
MI.definesRegister(AArch64::WZR,
nullptr) ||
1818 MI.definesRegister(AArch64::XZR,
nullptr))
1819 MIDefinesZeroReg =
true;
1821 switch (
MI.getOpcode()) {
1823 return MI.getOpcode();
1824 case AArch64::ADDSWrr:
1825 return AArch64::ADDWrr;
1826 case AArch64::ADDSWri:
1827 return MIDefinesZeroReg ? AArch64::ADDSWri : AArch64::ADDWri;
1828 case AArch64::ADDSWrs:
1829 return MIDefinesZeroReg ? AArch64::ADDSWrs : AArch64::ADDWrs;
1830 case AArch64::ADDSWrx:
1831 return AArch64::ADDWrx;
1832 case AArch64::ADDSXrr:
1833 return AArch64::ADDXrr;
1834 case AArch64::ADDSXri:
1835 return MIDefinesZeroReg ? AArch64::ADDSXri : AArch64::ADDXri;
1836 case AArch64::ADDSXrs:
1837 return MIDefinesZeroReg ? AArch64::ADDSXrs : AArch64::ADDXrs;
1838 case AArch64::ADDSXrx:
1839 return AArch64::ADDXrx;
1840 case AArch64::SUBSWrr:
1841 return AArch64::SUBWrr;
1842 case AArch64::SUBSWri:
1843 return MIDefinesZeroReg ? AArch64::SUBSWri : AArch64::SUBWri;
1844 case AArch64::SUBSWrs:
1845 return MIDefinesZeroReg ? AArch64::SUBSWrs : AArch64::SUBWrs;
1846 case AArch64::SUBSWrx:
1847 return AArch64::SUBWrx;
1848 case AArch64::SUBSXrr:
1849 return AArch64::SUBXrr;
1850 case AArch64::SUBSXri:
1851 return MIDefinesZeroReg ? AArch64::SUBSXri : AArch64::SUBXri;
1852 case AArch64::SUBSXrs:
1853 return MIDefinesZeroReg ? AArch64::SUBSXrs : AArch64::SUBXrs;
1854 case AArch64::SUBSXrx:
1855 return AArch64::SUBXrx;
1870 if (To == To->getParent()->begin())
1875 if (To->getParent() != From->getParent())
1887 Instr.modifiesRegister(AArch64::NZCV,
TRI)) ||
1888 ((AccessToCheck &
AK_Read) && Instr.readsRegister(AArch64::NZCV,
TRI)))
1894std::optional<unsigned>
1898 unsigned MaskOpcode =
Mask->getOpcode();
1899 unsigned PredOpcode = Pred->
getOpcode();
1900 bool PredIsPTestLike = isPTestLikeOpcode(PredOpcode);
1901 bool PredIsWhileLike = isWhileOpcode(PredOpcode);
1903 if (PredIsWhileLike) {
1907 if ((Mask == Pred) && PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1914 getElementSizeForOpcode(MaskOpcode) ==
1915 getElementSizeForOpcode(PredOpcode))
1921 if (PTest->
getOpcode() == AArch64::PTEST_PP_FIRST &&
1928 if (PredIsPTestLike) {
1933 if ((Mask == Pred) && PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1941 if (Mask != PTestLikeMask && PTestLikeMask->isFullCopy() &&
1942 PTestLikeMask->getOperand(1).getReg().isVirtual())
1950 getElementSizeForOpcode(MaskOpcode) ==
1951 getElementSizeForOpcode(PredOpcode)) {
1952 if (Mask == PTestLikeMask || PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1978 uint64_t PredElementSize = getElementSizeForOpcode(PredOpcode);
1980 PTest->
getOpcode() == AArch64::PTEST_PP_ANY))
1988 switch (PredOpcode) {
1989 case AArch64::AND_PPzPP:
1990 case AArch64::BIC_PPzPP:
1991 case AArch64::EOR_PPzPP:
1992 case AArch64::NAND_PPzPP:
1993 case AArch64::NOR_PPzPP:
1994 case AArch64::ORN_PPzPP:
1995 case AArch64::ORR_PPzPP:
1996 case AArch64::BRKA_PPzP:
1997 case AArch64::BRKPA_PPzPP:
1998 case AArch64::BRKB_PPzP:
1999 case AArch64::BRKPB_PPzPP:
2000 case AArch64::RDFFR_PPz: {
2004 if (Mask != PredMask)
2008 case AArch64::BRKN_PPzP: {
2012 if ((MaskOpcode != AArch64::PTRUE_B) ||
2013 (
Mask->getOperand(1).getImm() != 31))
2017 case AArch64::PTRUE_B:
2030bool AArch64InstrInfo::optimizePTestInstr(
2031 MachineInstr *PTest,
unsigned MaskReg,
unsigned PredReg,
2036 if (Pred->
isCopy() && PTest->
getOpcode() == AArch64::PTEST_PP_FIRST) {
2040 if (
Op.isReg() &&
Op.getReg().isVirtual() &&
2041 Op.getSubReg() == AArch64::psub0)
2045 unsigned PredOpcode = Pred->
getOpcode();
2046 auto NewOp = canRemovePTestInstr(PTest, Mask, Pred, MRI);
2062 if (*NewOp != PredOpcode) {
2073 for (; i !=
e; ++i) {
2104 if (DeadNZCVIdx != -1) {
2123 if (CmpInstr.
getOpcode() == AArch64::PTEST_PP ||
2124 CmpInstr.
getOpcode() == AArch64::PTEST_PP_ANY ||
2125 CmpInstr.
getOpcode() == AArch64::PTEST_PP_FIRST)
2126 return optimizePTestInstr(&CmpInstr, SrcReg, SrcReg2, MRI);
2135 if (CmpValue == 0 && substituteCmpToZero(CmpInstr, SrcReg, *MRI))
2137 return (CmpValue == 0 || CmpValue == 1) &&
2138 removeCmpToZeroOrOne(CmpInstr, SrcReg, CmpValue, *MRI);
2146 switch (Instr.getOpcode()) {
2148 return AArch64::INSTRUCTION_LIST_END;
2150 case AArch64::ADDSWrr:
2151 case AArch64::ADDSWri:
2152 case AArch64::ADDSXrr:
2153 case AArch64::ADDSXri:
2154 case AArch64::ADDSWrx:
2155 case AArch64::ADDSXrx:
2156 case AArch64::ADDSWrs:
2157 case AArch64::ADDSXrs:
2158 case AArch64::SUBSWrr:
2159 case AArch64::SUBSWri:
2160 case AArch64::SUBSWrx:
2161 case AArch64::SUBSWrs:
2162 case AArch64::SUBSXrr:
2163 case AArch64::SUBSXri:
2164 case AArch64::SUBSXrx:
2165 case AArch64::SUBSXrs:
2166 case AArch64::ANDSWri:
2167 case AArch64::ANDSWrr:
2168 case AArch64::ANDSWrs:
2169 case AArch64::ANDSXri:
2170 case AArch64::ANDSXrr:
2171 case AArch64::ANDSXrs:
2172 case AArch64::BICSWrr:
2173 case AArch64::BICSXrr:
2174 case AArch64::BICSWrs:
2175 case AArch64::BICSXrs:
2176 case AArch64::ADCSWr:
2177 case AArch64::ADCSXr:
2178 case AArch64::SBCSWr:
2179 case AArch64::SBCSXr:
2180 return Instr.getOpcode();
2182 case AArch64::ADDWrr:
2183 return AArch64::ADDSWrr;
2184 case AArch64::ADDWri:
2185 return AArch64::ADDSWri;
2186 case AArch64::ADDXrr:
2187 return AArch64::ADDSXrr;
2188 case AArch64::ADDXri:
2189 return AArch64::ADDSXri;
2190 case AArch64::ADDWrx:
2191 return AArch64::ADDSWrx;
2192 case AArch64::ADDXrx:
2193 return AArch64::ADDSXrx;
2194 case AArch64::ADDWrs:
2195 return AArch64::ADDSWrs;
2196 case AArch64::ADDXrs:
2197 return AArch64::ADDSXrs;
2198 case AArch64::ADCWr:
2199 return AArch64::ADCSWr;
2200 case AArch64::ADCXr:
2201 return AArch64::ADCSXr;
2202 case AArch64::SUBWrr:
2203 return AArch64::SUBSWrr;
2204 case AArch64::SUBWri:
2205 return AArch64::SUBSWri;
2206 case AArch64::SUBXrr:
2207 return AArch64::SUBSXrr;
2208 case AArch64::SUBXri:
2209 return AArch64::SUBSXri;
2210 case AArch64::SUBWrx:
2211 return AArch64::SUBSWrx;
2212 case AArch64::SUBXrx:
2213 return AArch64::SUBSXrx;
2214 case AArch64::SUBWrs:
2215 return AArch64::SUBSWrs;
2216 case AArch64::SUBXrs:
2217 return AArch64::SUBSXrs;
2218 case AArch64::SBCWr:
2219 return AArch64::SBCSWr;
2220 case AArch64::SBCXr:
2221 return AArch64::SBCSXr;
2222 case AArch64::ANDWri:
2223 return AArch64::ANDSWri;
2224 case AArch64::ANDXri:
2225 return AArch64::ANDSXri;
2226 case AArch64::ANDWrr:
2227 return AArch64::ANDSWrr;
2228 case AArch64::ANDWrs:
2229 return AArch64::ANDSWrs;
2230 case AArch64::ANDXrr:
2231 return AArch64::ANDSXrr;
2232 case AArch64::ANDXrs:
2233 return AArch64::ANDSXrs;
2234 case AArch64::BICWrr:
2235 return AArch64::BICSWrr;
2236 case AArch64::BICXrr:
2237 return AArch64::BICSXrr;
2238 case AArch64::BICWrs:
2239 return AArch64::BICSWrs;
2240 case AArch64::BICXrs:
2241 return AArch64::BICSXrs;
2247 for (
auto *BB :
MBB->successors())
2248 if (BB->isLiveIn(AArch64::NZCV))
2255int AArch64InstrInfo::findCondCodeUseOperandIdxForBranchOrSelect(
2257 switch (
Instr.getOpcode()) {
2261 case AArch64::Bcc: {
2262 int Idx =
Instr.findRegisterUseOperandIdx(AArch64::NZCV,
nullptr);
2267 case AArch64::CSINVWr:
2268 case AArch64::CSINVXr:
2269 case AArch64::CSINCWr:
2270 case AArch64::CSINCXr:
2271 case AArch64::CSELWr:
2272 case AArch64::CSELXr:
2273 case AArch64::CSNEGWr:
2274 case AArch64::CSNEGXr:
2275 case AArch64::FCSELSrrr:
2276 case AArch64::FCSELDrrr: {
2277 int Idx =
Instr.findRegisterUseOperandIdx(AArch64::NZCV,
nullptr);
2289 AArch64InstrInfo::findCondCodeUseOperandIdxForBranchOrSelect(Instr);
2291 Instr.getOperand(CCIdx).
getImm())
2344std::optional<UsedNZCV>
2349 if (
MI.getParent() != CmpParent)
2350 return std::nullopt;
2353 return std::nullopt;
2358 if (Instr.readsRegister(AArch64::NZCV, &
TRI)) {
2361 return std::nullopt;
2366 if (Instr.modifiesRegister(AArch64::NZCV, &
TRI))
2369 return NZCVUsedAfterCmp;
2373 return Opcode == AArch64::ADDSWri || Opcode == AArch64::ADDSXri;
2377 return Opcode == AArch64::SUBSWri || Opcode == AArch64::SUBSXri;
2383 case AArch64::ANDSWri:
2384 case AArch64::ANDSWrr:
2385 case AArch64::ANDSWrs:
2386 case AArch64::ANDSXri:
2387 case AArch64::ANDSXrr:
2388 case AArch64::ANDSXrs:
2389 case AArch64::BICSWrr:
2390 case AArch64::BICSXrr:
2391 case AArch64::BICSWrs:
2392 case AArch64::BICSXrs:
2418 const unsigned CmpOpcode = CmpInstr.
getOpcode();
2424 "Caller guarantees that CmpInstr compares with constant 0");
2427 if (!NZVCUsed || NZVCUsed->C)
2448bool AArch64InstrInfo::substituteCmpToZero(
2459 if (NewOpc == AArch64::INSTRUCTION_LIST_END)
2466 MI->setDesc(
get(NewOpc));
2471 MI->addRegisterDefined(AArch64::NZCV, &
TRI);
2483 assert((CmpValue == 0 || CmpValue == 1) &&
2484 "Only comparisons to 0 or 1 considered for removal!");
2487 unsigned MIOpc =
MI.getOpcode();
2488 if (MIOpc == AArch64::CSINCWr) {
2489 if (
MI.getOperand(1).getReg() != AArch64::WZR ||
2490 MI.getOperand(2).getReg() != AArch64::WZR)
2492 }
else if (MIOpc == AArch64::CSINCXr) {
2493 if (
MI.getOperand(1).getReg() != AArch64::XZR ||
2494 MI.getOperand(2).getReg() != AArch64::XZR)
2504 if (
MI.findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
true) != -1)
2508 const unsigned CmpOpcode = CmpInstr.
getOpcode();
2510 if (CmpValue && !IsSubsRegImm)
2512 if (!CmpValue && !IsSubsRegImm && !
isADDSRegImm(CmpOpcode))
2517 if (MIUsedNZCV.
C || MIUsedNZCV.
V)
2520 std::optional<UsedNZCV> NZCVUsedAfterCmp =
2524 if (!NZCVUsedAfterCmp || NZCVUsedAfterCmp->C || NZCVUsedAfterCmp->V)
2527 if ((MIUsedNZCV.
Z && NZCVUsedAfterCmp->N) ||
2528 (MIUsedNZCV.
N && NZCVUsedAfterCmp->Z))
2531 if (MIUsedNZCV.
N && !CmpValue)
2573bool AArch64InstrInfo::removeCmpToZeroOrOne(
2580 SmallVector<MachineInstr *, 4> CCUseInstrs;
2581 bool IsInvertCC =
false;
2589 for (MachineInstr *CCUseInstr : CCUseInstrs) {
2590 int Idx = findCondCodeUseOperandIdxForBranchOrSelect(*CCUseInstr);
2591 assert(Idx >= 0 &&
"Unexpected instruction using CC.");
2592 MachineOperand &CCOperand = CCUseInstr->getOperand(Idx);
2601bool AArch64InstrInfo::expandPostRAPseudo(
MachineInstr &
MI)
const {
2602 if (
MI.getOpcode() != TargetOpcode::LOAD_STACK_GUARD &&
2603 MI.getOpcode() != AArch64::CATCHRET &&
2604 MI.getOpcode() != AArch64::STACK_GUARD_UNMIX)
2609 auto TRI = Subtarget.getRegisterInfo();
2612 if (
MI.getOpcode() == AArch64::STACK_GUARD_UNMIX) {
2626 if (
MI.getOpcode() == AArch64::CATCHRET) {
2628 const TargetInstrInfo *
TII =
2630 MachineBasicBlock *TargetMBB =
MI.getOperand(0).getMBB();
2635 FirstEpilogSEH = std::prev(FirstEpilogSEH);
2637 FirstEpilogSEH = std::next(FirstEpilogSEH);
2652 if (
M.getStackProtectorGuard() ==
"sysreg") {
2653 const AArch64SysReg::SysReg *SrcReg =
2654 AArch64SysReg::lookupSysRegByName(
M.getStackProtectorGuardReg());
2662 int Offset =
M.getStackProtectorGuardOffset();
2713 const GlobalValue *GV =
2716 unsigned OpFlags = Subtarget.ClassifyGlobalReference(GV, TM);
2719 unsigned GuardWidth =
M.getStackProtectorGuardValueWidth().value_or(
2720 Subtarget.isTargetILP32() ? 4 : 8);
2721 if (GuardWidth != 4 && GuardWidth != 8)
2726 if (GuardWidth == 4) {
2727 unsigned Reg32 =
TRI->getSubReg(
Reg, AArch64::sub_32);
2756 if (GuardWidth == 4) {
2757 unsigned Reg32 =
TRI->getSubReg(
Reg, AArch64::sub_32);
2774 if (GuardWidth == 4) {
2775 unsigned Reg32 =
TRI->getSubReg(
Reg, AArch64::sub_32);
2793 if (Subtarget.getTargetTriple().isOSMSVCRT())
2806 switch (
MI.getOpcode()) {
2809 case AArch64::MOVZWi:
2810 case AArch64::MOVZXi:
2811 if (
MI.getOperand(1).isImm() &&
MI.getOperand(1).getImm() == 0) {
2812 assert(
MI.getDesc().getNumOperands() == 3 &&
2813 MI.getOperand(2).getImm() == 0 &&
"invalid MOVZi operands");
2817 case AArch64::ANDWri:
2818 return MI.getOperand(1).getReg() == AArch64::WZR;
2819 case AArch64::ANDXri:
2820 return MI.getOperand(1).getReg() == AArch64::XZR;
2821 case TargetOpcode::COPY:
2822 return MI.getOperand(1).getReg() == AArch64::WZR;
2830 switch (
MI.getOpcode()) {
2833 case TargetOpcode::COPY: {
2836 return (AArch64::GPR32RegClass.
contains(DstReg) ||
2837 AArch64::GPR64RegClass.
contains(DstReg));
2839 case AArch64::ORRXrs:
2840 if (
MI.getOperand(1).getReg() == AArch64::XZR) {
2841 assert(
MI.getDesc().getNumOperands() == 4 &&
2842 MI.getOperand(3).getImm() == 0 &&
"invalid ORRrs operands");
2846 case AArch64::ADDXri:
2847 if (
MI.getOperand(2).getImm() == 0) {
2848 assert(
MI.getDesc().getNumOperands() == 4 &&
2849 MI.getOperand(3).getImm() == 0 &&
"invalid ADDXri operands");
2860 switch (
MI.getOpcode()) {
2863 case TargetOpcode::COPY: {
2865 return AArch64::FPR128RegClass.contains(DstReg);
2867 case AArch64::ORRv16i8:
2868 if (
MI.getOperand(1).getReg() ==
MI.getOperand(2).getReg()) {
2869 assert(
MI.getDesc().getNumOperands() == 3 &&
MI.getOperand(0).isReg() &&
2870 "invalid ORRv16i8 operands");
2882 case AArch64::LDRWui:
2883 case AArch64::LDRXui:
2884 case AArch64::LDRBui:
2885 case AArch64::LDRHui:
2886 case AArch64::LDRSui:
2887 case AArch64::LDRDui:
2888 case AArch64::LDRQui:
2889 case AArch64::LDR_PXI:
2895 int &FrameIndex)
const {
2899 if (
MI.getOperand(0).getSubReg() == 0 &&
MI.getOperand(1).isFI() &&
2900 MI.getOperand(2).isImm() &&
MI.getOperand(2).getImm() == 0) {
2901 FrameIndex =
MI.getOperand(1).getIndex();
2902 return MI.getOperand(0).getReg();
2911 case AArch64::STRWui:
2912 case AArch64::STRXui:
2913 case AArch64::STRBui:
2914 case AArch64::STRHui:
2915 case AArch64::STRSui:
2916 case AArch64::STRDui:
2917 case AArch64::STRQui:
2918 case AArch64::STR_PXI:
2924 int &FrameIndex)
const {
2928 if (
MI.getOperand(0).getSubReg() == 0 &&
MI.getOperand(1).isFI() &&
2929 MI.getOperand(2).isImm() &&
MI.getOperand(2).getImm() == 0) {
2930 FrameIndex =
MI.getOperand(1).getIndex();
2931 return MI.getOperand(0).getReg();
2937 int &FrameIndex)
const {
2952 return MI.getOperand(0).getReg();
2958 int &FrameIndex)
const {
2973 return MI.getOperand(0).getReg();
2981 return MMO->getFlags() & MOSuppressPair;
2987 if (
MI.memoperands_empty())
2995 return MMO->getFlags() & MOStridedAccess;
3003 case AArch64::STURSi:
3004 case AArch64::STRSpre:
3005 case AArch64::STURDi:
3006 case AArch64::STRDpre:
3007 case AArch64::STURQi:
3008 case AArch64::STRQpre:
3009 case AArch64::STURBBi:
3010 case AArch64::STURHHi:
3011 case AArch64::STURWi:
3012 case AArch64::STRWpre:
3013 case AArch64::STURXi:
3014 case AArch64::STRXpre:
3015 case AArch64::LDURSi:
3016 case AArch64::LDRSpre:
3017 case AArch64::LDURDi:
3018 case AArch64::LDRDpre:
3019 case AArch64::LDURQi:
3020 case AArch64::LDRQpre:
3021 case AArch64::LDURWi:
3022 case AArch64::LDRWpre:
3023 case AArch64::LDURXi:
3024 case AArch64::LDRXpre:
3025 case AArch64::LDRSWpre:
3026 case AArch64::LDURSWi:
3027 case AArch64::LDURHHi:
3028 case AArch64::LDURBBi:
3029 case AArch64::LDURSBWi:
3030 case AArch64::LDURSHWi:
3038 case AArch64::PRFMui:
return AArch64::PRFUMi;
3039 case AArch64::LDRXui:
return AArch64::LDURXi;
3040 case AArch64::LDRWui:
return AArch64::LDURWi;
3041 case AArch64::LDRBui:
return AArch64::LDURBi;
3042 case AArch64::LDRHui:
return AArch64::LDURHi;
3043 case AArch64::LDRSui:
return AArch64::LDURSi;
3044 case AArch64::LDRDui:
return AArch64::LDURDi;
3045 case AArch64::LDRQui:
return AArch64::LDURQi;
3046 case AArch64::LDRBBui:
return AArch64::LDURBBi;
3047 case AArch64::LDRHHui:
return AArch64::LDURHHi;
3048 case AArch64::LDRSBXui:
return AArch64::LDURSBXi;
3049 case AArch64::LDRSBWui:
return AArch64::LDURSBWi;
3050 case AArch64::LDRSHXui:
return AArch64::LDURSHXi;
3051 case AArch64::LDRSHWui:
return AArch64::LDURSHWi;
3052 case AArch64::LDRSWui:
return AArch64::LDURSWi;
3053 case AArch64::STRXui:
return AArch64::STURXi;
3054 case AArch64::STRWui:
return AArch64::STURWi;
3055 case AArch64::STRBui:
return AArch64::STURBi;
3056 case AArch64::STRHui:
return AArch64::STURHi;
3057 case AArch64::STRSui:
return AArch64::STURSi;
3058 case AArch64::STRDui:
return AArch64::STURDi;
3059 case AArch64::STRQui:
return AArch64::STURQi;
3060 case AArch64::STRBBui:
return AArch64::STURBBi;
3061 case AArch64::STRHHui:
return AArch64::STURHHi;
3070 case AArch64::LDAPURBi:
3071 case AArch64::LDAPURHi:
3072 case AArch64::LDAPURi:
3073 case AArch64::LDAPURSBWi:
3074 case AArch64::LDAPURSBXi:
3075 case AArch64::LDAPURSHWi:
3076 case AArch64::LDAPURSHXi:
3077 case AArch64::LDAPURSWi:
3078 case AArch64::LDAPURXi:
3079 case AArch64::LDR_PPXI:
3080 case AArch64::LDR_PXI:
3081 case AArch64::LDR_ZXI:
3082 case AArch64::LDR_ZZXI:
3083 case AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS:
3084 case AArch64::LDR_ZZZXI:
3085 case AArch64::LDR_ZZZZXI:
3086 case AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS:
3087 case AArch64::LDRBBui:
3088 case AArch64::LDRBui:
3089 case AArch64::LDRDui:
3090 case AArch64::LDRHHui:
3091 case AArch64::LDRHui:
3092 case AArch64::LDRQui:
3093 case AArch64::LDRSBWui:
3094 case AArch64::LDRSBXui:
3095 case AArch64::LDRSHWui:
3096 case AArch64::LDRSHXui:
3097 case AArch64::LDRSui:
3098 case AArch64::LDRSWui:
3099 case AArch64::LDRWui:
3100 case AArch64::LDRXui:
3101 case AArch64::LDURBBi:
3102 case AArch64::LDURBi:
3103 case AArch64::LDURDi:
3104 case AArch64::LDURHHi:
3105 case AArch64::LDURHi:
3106 case AArch64::LDURQi:
3107 case AArch64::LDURSBWi:
3108 case AArch64::LDURSBXi:
3109 case AArch64::LDURSHWi:
3110 case AArch64::LDURSHXi:
3111 case AArch64::LDURSi:
3112 case AArch64::LDURSWi:
3113 case AArch64::LDURWi:
3114 case AArch64::LDURXi:
3115 case AArch64::PRFMui:
3116 case AArch64::PRFUMi:
3117 case AArch64::ST2Gi:
3119 case AArch64::STLURBi:
3120 case AArch64::STLURHi:
3121 case AArch64::STLURWi:
3122 case AArch64::STLURXi:
3123 case AArch64::StoreSwiftAsyncContext:
3124 case AArch64::STR_PPXI:
3125 case AArch64::STR_PXI:
3126 case AArch64::STR_ZXI:
3127 case AArch64::STR_ZZXI:
3128 case AArch64::STR_ZZXI_STRIDED_CONTIGUOUS:
3129 case AArch64::STR_ZZZXI:
3130 case AArch64::STR_ZZZZXI:
3131 case AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS:
3132 case AArch64::STRBBui:
3133 case AArch64::STRBui:
3134 case AArch64::STRDui:
3135 case AArch64::STRHHui:
3136 case AArch64::STRHui:
3137 case AArch64::STRQui:
3138 case AArch64::STRSui:
3139 case AArch64::STRWui:
3140 case AArch64::STRXui:
3141 case AArch64::STURBBi:
3142 case AArch64::STURBi:
3143 case AArch64::STURDi:
3144 case AArch64::STURHHi:
3145 case AArch64::STURHi:
3146 case AArch64::STURQi:
3147 case AArch64::STURSi:
3148 case AArch64::STURWi:
3149 case AArch64::STURXi:
3150 case AArch64::STZ2Gi:
3151 case AArch64::STZGi:
3152 case AArch64::TAGPstack:
3153 case AArch64::ATOMIC_STORE_HINT_Bi:
3154 case AArch64::ATOMIC_STORE_HINT_Hi:
3155 case AArch64::ATOMIC_STORE_HINT_Wi:
3156 case AArch64::ATOMIC_STORE_HINT_Si:
3157 case AArch64::ATOMIC_STORE_HINT_Xi:
3158 case AArch64::ATOMIC_STORE_HINT_Di:
3159 case AArch64::ATOMIC_STORE_HINT_Bui:
3160 case AArch64::ATOMIC_STORE_HINT_Hui:
3161 case AArch64::ATOMIC_STORE_HINT_Wui:
3162 case AArch64::ATOMIC_STORE_HINT_Sui:
3163 case AArch64::ATOMIC_STORE_HINT_Xui:
3164 case AArch64::ATOMIC_STORE_HINT_Dui:
3166 case AArch64::LD1B_D_IMM:
3167 case AArch64::LD1B_H_IMM:
3168 case AArch64::LD1B_IMM:
3169 case AArch64::LD1B_S_IMM:
3170 case AArch64::LD1D_IMM:
3171 case AArch64::LD1H_D_IMM:
3172 case AArch64::LD1H_IMM:
3173 case AArch64::LD1H_S_IMM:
3174 case AArch64::LD1RB_D_IMM:
3175 case AArch64::LD1RB_H_IMM:
3176 case AArch64::LD1RB_IMM:
3177 case AArch64::LD1RB_S_IMM:
3178 case AArch64::LD1RD_IMM:
3179 case AArch64::LD1RH_D_IMM:
3180 case AArch64::LD1RH_IMM:
3181 case AArch64::LD1RH_S_IMM:
3182 case AArch64::LD1RSB_D_IMM:
3183 case AArch64::LD1RSB_H_IMM:
3184 case AArch64::LD1RSB_S_IMM:
3185 case AArch64::LD1RSH_D_IMM:
3186 case AArch64::LD1RSH_S_IMM:
3187 case AArch64::LD1RSW_IMM:
3188 case AArch64::LD1RW_D_IMM:
3189 case AArch64::LD1RW_IMM:
3190 case AArch64::LD1SB_D_IMM:
3191 case AArch64::LD1SB_H_IMM:
3192 case AArch64::LD1SB_S_IMM:
3193 case AArch64::LD1SH_D_IMM:
3194 case AArch64::LD1SH_S_IMM:
3195 case AArch64::LD1SW_D_IMM:
3196 case AArch64::LD1W_D_IMM:
3197 case AArch64::LD1W_IMM:
3198 case AArch64::LD2B_IMM:
3199 case AArch64::LD2D_IMM:
3200 case AArch64::LD2H_IMM:
3201 case AArch64::LD2W_IMM:
3202 case AArch64::LD3B_IMM:
3203 case AArch64::LD3D_IMM:
3204 case AArch64::LD3H_IMM:
3205 case AArch64::LD3W_IMM:
3206 case AArch64::LD4B_IMM:
3207 case AArch64::LD4D_IMM:
3208 case AArch64::LD4H_IMM:
3209 case AArch64::LD4W_IMM:
3211 case AArch64::LDNF1B_D_IMM:
3212 case AArch64::LDNF1B_H_IMM:
3213 case AArch64::LDNF1B_IMM:
3214 case AArch64::LDNF1B_S_IMM:
3215 case AArch64::LDNF1D_IMM:
3216 case AArch64::LDNF1H_D_IMM:
3217 case AArch64::LDNF1H_IMM:
3218 case AArch64::LDNF1H_S_IMM:
3219 case AArch64::LDNF1SB_D_IMM:
3220 case AArch64::LDNF1SB_H_IMM:
3221 case AArch64::LDNF1SB_S_IMM:
3222 case AArch64::LDNF1SH_D_IMM:
3223 case AArch64::LDNF1SH_S_IMM:
3224 case AArch64::LDNF1SW_D_IMM:
3225 case AArch64::LDNF1W_D_IMM:
3226 case AArch64::LDNF1W_IMM:
3227 case AArch64::LDNPDi:
3228 case AArch64::LDNPQi:
3229 case AArch64::LDNPSi:
3230 case AArch64::LDNPWi:
3231 case AArch64::LDNPXi:
3232 case AArch64::LDNT1B_ZRI:
3233 case AArch64::LDNT1D_ZRI:
3234 case AArch64::LDNT1H_ZRI:
3235 case AArch64::LDNT1W_ZRI:
3236 case AArch64::LDPDi:
3237 case AArch64::LDPQi:
3238 case AArch64::LDPSi:
3239 case AArch64::LDPWi:
3240 case AArch64::LDPXi:
3241 case AArch64::LDRBBpost:
3242 case AArch64::LDRBBpre:
3243 case AArch64::LDRBpost:
3244 case AArch64::LDRBpre:
3245 case AArch64::LDRDpost:
3246 case AArch64::LDRDpre:
3247 case AArch64::LDRHHpost:
3248 case AArch64::LDRHHpre:
3249 case AArch64::LDRHpost:
3250 case AArch64::LDRHpre:
3251 case AArch64::LDRQpost:
3252 case AArch64::LDRQpre:
3253 case AArch64::LDRSpost:
3254 case AArch64::LDRSpre:
3255 case AArch64::LDRWpost:
3256 case AArch64::LDRWpre:
3257 case AArch64::LDRXpost:
3258 case AArch64::LDRXpre:
3259 case AArch64::ST1B_D_IMM:
3260 case AArch64::ST1B_H_IMM:
3261 case AArch64::ST1B_IMM:
3262 case AArch64::ST1B_S_IMM:
3263 case AArch64::ST1D_IMM:
3264 case AArch64::ST1H_D_IMM:
3265 case AArch64::ST1H_IMM:
3266 case AArch64::ST1H_S_IMM:
3267 case AArch64::ST1W_D_IMM:
3268 case AArch64::ST1W_IMM:
3269 case AArch64::ST2B_IMM:
3270 case AArch64::ST2D_IMM:
3271 case AArch64::ST2H_IMM:
3272 case AArch64::ST2W_IMM:
3273 case AArch64::ST3B_IMM:
3274 case AArch64::ST3D_IMM:
3275 case AArch64::ST3H_IMM:
3276 case AArch64::ST3W_IMM:
3277 case AArch64::ST4B_IMM:
3278 case AArch64::ST4D_IMM:
3279 case AArch64::ST4H_IMM:
3280 case AArch64::ST4W_IMM:
3281 case AArch64::STGPi:
3282 case AArch64::STGPreIndex:
3283 case AArch64::STZGPreIndex:
3284 case AArch64::ST2GPreIndex:
3285 case AArch64::STZ2GPreIndex:
3286 case AArch64::STGPostIndex:
3287 case AArch64::STZGPostIndex:
3288 case AArch64::ST2GPostIndex:
3289 case AArch64::STZ2GPostIndex:
3290 case AArch64::STNPDi:
3291 case AArch64::STNPQi:
3292 case AArch64::STNPSi:
3293 case AArch64::STNPWi:
3294 case AArch64::STNPXi:
3295 case AArch64::STNT1B_ZRI:
3296 case AArch64::STNT1D_ZRI:
3297 case AArch64::STNT1H_ZRI:
3298 case AArch64::STNT1W_ZRI:
3299 case AArch64::STPDi:
3300 case AArch64::STPQi:
3301 case AArch64::STPSi:
3302 case AArch64::STPWi:
3303 case AArch64::STPXi:
3304 case AArch64::STRBBpost:
3305 case AArch64::STRBBpre:
3306 case AArch64::STRBpost:
3307 case AArch64::STRBpre:
3308 case AArch64::STRDpost:
3309 case AArch64::STRDpre:
3310 case AArch64::STRHHpost:
3311 case AArch64::STRHHpre:
3312 case AArch64::STRHpost:
3313 case AArch64::STRHpre:
3314 case AArch64::STRQpost:
3315 case AArch64::STRQpre:
3316 case AArch64::STRSpost:
3317 case AArch64::STRSpre:
3318 case AArch64::STRWpost:
3319 case AArch64::STRWpre:
3320 case AArch64::STRXpost:
3321 case AArch64::STRXpre:
3322 case AArch64::LD1B_2Z_IMM:
3323 case AArch64::LD1B_2Z_STRIDED_IMM:
3324 case AArch64::LD1H_2Z_IMM:
3325 case AArch64::LD1H_2Z_STRIDED_IMM:
3326 case AArch64::LD1W_2Z_IMM:
3327 case AArch64::LD1W_2Z_STRIDED_IMM:
3328 case AArch64::LD1D_2Z_IMM:
3329 case AArch64::LD1D_2Z_STRIDED_IMM:
3330 case AArch64::LD1B_4Z_IMM:
3331 case AArch64::LD1B_4Z_STRIDED_IMM:
3332 case AArch64::LD1H_4Z_IMM:
3333 case AArch64::LD1H_4Z_STRIDED_IMM:
3334 case AArch64::LD1W_4Z_IMM:
3335 case AArch64::LD1W_4Z_STRIDED_IMM:
3336 case AArch64::LD1D_4Z_IMM:
3337 case AArch64::LD1D_4Z_STRIDED_IMM:
3338 case AArch64::LD1B_2Z_IMM_PSEUDO:
3339 case AArch64::LD1H_2Z_IMM_PSEUDO:
3340 case AArch64::LD1W_2Z_IMM_PSEUDO:
3341 case AArch64::LD1D_2Z_IMM_PSEUDO:
3342 case AArch64::LD1B_4Z_IMM_PSEUDO:
3343 case AArch64::LD1H_4Z_IMM_PSEUDO:
3344 case AArch64::LD1W_4Z_IMM_PSEUDO:
3345 case AArch64::LD1D_4Z_IMM_PSEUDO:
3346 case AArch64::ST1B_2Z_IMM:
3347 case AArch64::ST1B_2Z_STRIDED_IMM:
3348 case AArch64::ST1H_2Z_IMM:
3349 case AArch64::ST1H_2Z_STRIDED_IMM:
3350 case AArch64::ST1W_2Z_IMM:
3351 case AArch64::ST1W_2Z_STRIDED_IMM:
3352 case AArch64::ST1D_2Z_IMM:
3353 case AArch64::ST1D_2Z_STRIDED_IMM:
3354 case AArch64::LDNT1B_2Z_IMM_PSEUDO:
3355 case AArch64::LDNT1B_2Z_IMM:
3356 case AArch64::LDNT1B_2Z_STRIDED_IMM:
3357 case AArch64::LDNT1H_2Z_IMM_PSEUDO:
3358 case AArch64::LDNT1H_2Z_IMM:
3359 case AArch64::LDNT1H_2Z_STRIDED_IMM:
3360 case AArch64::LDNT1W_2Z_IMM_PSEUDO:
3361 case AArch64::LDNT1W_2Z_IMM:
3362 case AArch64::LDNT1W_2Z_STRIDED_IMM:
3363 case AArch64::LDNT1D_2Z_IMM_PSEUDO:
3364 case AArch64::LDNT1D_2Z_IMM:
3365 case AArch64::LDNT1D_2Z_STRIDED_IMM:
3366 case AArch64::STNT1B_2Z_IMM:
3367 case AArch64::STNT1B_2Z_STRIDED_IMM:
3368 case AArch64::STNT1H_2Z_IMM:
3369 case AArch64::STNT1H_2Z_STRIDED_IMM:
3370 case AArch64::STNT1W_2Z_IMM:
3371 case AArch64::STNT1W_2Z_STRIDED_IMM:
3372 case AArch64::STNT1D_2Z_IMM:
3373 case AArch64::STNT1D_2Z_STRIDED_IMM:
3374 case AArch64::ST1B_2Z_IMM_PSEUDO:
3375 case AArch64::ST1H_2Z_IMM_PSEUDO:
3376 case AArch64::ST1W_2Z_IMM_PSEUDO:
3377 case AArch64::ST1D_2Z_IMM_PSEUDO:
3378 case AArch64::STNT1B_2Z_IMM_PSEUDO:
3379 case AArch64::STNT1H_2Z_IMM_PSEUDO:
3380 case AArch64::STNT1W_2Z_IMM_PSEUDO:
3381 case AArch64::STNT1D_2Z_IMM_PSEUDO:
3382 case AArch64::ST1B_4Z_IMM:
3383 case AArch64::ST1B_4Z_STRIDED_IMM:
3384 case AArch64::ST1H_4Z_IMM:
3385 case AArch64::ST1H_4Z_STRIDED_IMM:
3386 case AArch64::ST1W_4Z_IMM:
3387 case AArch64::ST1W_4Z_STRIDED_IMM:
3388 case AArch64::ST1D_4Z_IMM:
3389 case AArch64::ST1D_4Z_STRIDED_IMM:
3390 case AArch64::LDNT1B_4Z_IMM_PSEUDO:
3391 case AArch64::LDNT1B_4Z_IMM:
3392 case AArch64::LDNT1B_4Z_STRIDED_IMM:
3393 case AArch64::LDNT1H_4Z_IMM_PSEUDO:
3394 case AArch64::LDNT1H_4Z_IMM:
3395 case AArch64::LDNT1H_4Z_STRIDED_IMM:
3396 case AArch64::LDNT1W_4Z_IMM_PSEUDO:
3397 case AArch64::LDNT1W_4Z_IMM:
3398 case AArch64::LDNT1W_4Z_STRIDED_IMM:
3399 case AArch64::LDNT1D_4Z_IMM_PSEUDO:
3400 case AArch64::LDNT1D_4Z_IMM:
3401 case AArch64::LDNT1D_4Z_STRIDED_IMM:
3402 case AArch64::STNT1B_4Z_IMM:
3403 case AArch64::STNT1B_4Z_STRIDED_IMM:
3404 case AArch64::STNT1H_4Z_IMM:
3405 case AArch64::STNT1H_4Z_STRIDED_IMM:
3406 case AArch64::STNT1W_4Z_IMM:
3407 case AArch64::STNT1W_4Z_STRIDED_IMM:
3408 case AArch64::STNT1D_4Z_IMM:
3409 case AArch64::STNT1D_4Z_STRIDED_IMM:
3410 case AArch64::ST1B_4Z_IMM_PSEUDO:
3411 case AArch64::ST1H_4Z_IMM_PSEUDO:
3412 case AArch64::ST1W_4Z_IMM_PSEUDO:
3413 case AArch64::ST1D_4Z_IMM_PSEUDO:
3414 case AArch64::STNT1B_4Z_IMM_PSEUDO:
3415 case AArch64::STNT1H_4Z_IMM_PSEUDO:
3416 case AArch64::STNT1W_4Z_IMM_PSEUDO:
3417 case AArch64::STNT1D_4Z_IMM_PSEUDO:
3419 case AArch64::LDPDpost:
3420 case AArch64::LDPDpre:
3421 case AArch64::LDPQpost:
3422 case AArch64::LDPQpre:
3423 case AArch64::LDPSpost:
3424 case AArch64::LDPSpre:
3425 case AArch64::LDPWpost:
3426 case AArch64::LDPWpre:
3427 case AArch64::LDPXpost:
3428 case AArch64::LDPXpre:
3429 case AArch64::STGPpre:
3430 case AArch64::STGPpost:
3431 case AArch64::STPDpost:
3432 case AArch64::STPDpre:
3433 case AArch64::STPQpost:
3434 case AArch64::STPQpre:
3435 case AArch64::STPSpost:
3436 case AArch64::STPSpre:
3437 case AArch64::STPWpost:
3438 case AArch64::STPWpre:
3439 case AArch64::STPXpost:
3440 case AArch64::STPXpre:
3446 switch (
MI.getOpcode()) {
3450 case AArch64::STRSui:
3451 case AArch64::STRDui:
3452 case AArch64::STRQui:
3453 case AArch64::STRXui:
3454 case AArch64::STRWui:
3455 case AArch64::LDRSui:
3456 case AArch64::LDRDui:
3457 case AArch64::LDRQui:
3458 case AArch64::LDRXui:
3459 case AArch64::LDRWui:
3460 case AArch64::LDRSWui:
3462 case AArch64::STURSi:
3463 case AArch64::STRSpre:
3464 case AArch64::STURDi:
3465 case AArch64::STRDpre:
3466 case AArch64::STURQi:
3467 case AArch64::STRQpre:
3468 case AArch64::STURWi:
3469 case AArch64::STRWpre:
3470 case AArch64::STURXi:
3471 case AArch64::STRXpre:
3472 case AArch64::LDURSi:
3473 case AArch64::LDRSpre:
3474 case AArch64::LDURDi:
3475 case AArch64::LDRDpre:
3476 case AArch64::LDURQi:
3477 case AArch64::LDRQpre:
3478 case AArch64::LDURWi:
3479 case AArch64::LDRWpre:
3480 case AArch64::LDURXi:
3481 case AArch64::LDRXpre:
3482 case AArch64::LDURSWi:
3483 case AArch64::LDRSWpre:
3485 case AArch64::LDR_ZXI:
3486 case AArch64::STR_ZXI:
3492 switch (
MI.getOpcode()) {
3495 "Unexpected instruction - was a new tail call opcode introduced?");
3497 case AArch64::TCRETURNdi:
3498 case AArch64::TCRETURNri:
3499 case AArch64::TCRETURNrix16x17:
3500 case AArch64::TCRETURNrix17:
3501 case AArch64::TCRETURNrinotx16:
3502 case AArch64::TCRETURNriALL:
3503 case AArch64::AUTH_TCRETURN:
3504 case AArch64::AUTH_TCRETURN_BTI:
3514 case AArch64::ADDWri:
3515 return AArch64::ADDSWri;
3516 case AArch64::ADDWrr:
3517 return AArch64::ADDSWrr;
3518 case AArch64::ADDWrs:
3519 return AArch64::ADDSWrs;
3520 case AArch64::ADDWrx:
3521 return AArch64::ADDSWrx;
3522 case AArch64::ANDWri:
3523 return AArch64::ANDSWri;
3524 case AArch64::ANDWrr:
3525 return AArch64::ANDSWrr;
3526 case AArch64::ANDWrs:
3527 return AArch64::ANDSWrs;
3528 case AArch64::BICWrr:
3529 return AArch64::BICSWrr;
3530 case AArch64::BICWrs:
3531 return AArch64::BICSWrs;
3532 case AArch64::SUBWri:
3533 return AArch64::SUBSWri;
3534 case AArch64::SUBWrr:
3535 return AArch64::SUBSWrr;
3536 case AArch64::SUBWrs:
3537 return AArch64::SUBSWrs;
3538 case AArch64::SUBWrx:
3539 return AArch64::SUBSWrx;
3541 case AArch64::ADDXri:
3542 return AArch64::ADDSXri;
3543 case AArch64::ADDXrr:
3544 return AArch64::ADDSXrr;
3545 case AArch64::ADDXrs:
3546 return AArch64::ADDSXrs;
3547 case AArch64::ADDXrx:
3548 return AArch64::ADDSXrx;
3549 case AArch64::ANDXri:
3550 return AArch64::ANDSXri;
3551 case AArch64::ANDXrr:
3552 return AArch64::ANDSXrr;
3553 case AArch64::ANDXrs:
3554 return AArch64::ANDSXrs;
3555 case AArch64::BICXrr:
3556 return AArch64::BICSXrr;
3557 case AArch64::BICXrs:
3558 return AArch64::BICSXrs;
3559 case AArch64::SUBXri:
3560 return AArch64::SUBSXri;
3561 case AArch64::SUBXrr:
3562 return AArch64::SUBSXrr;
3563 case AArch64::SUBXrs:
3564 return AArch64::SUBSXrs;
3565 case AArch64::SUBXrx:
3566 return AArch64::SUBSXrx;
3568 case AArch64::AND_PPzPP:
3569 return AArch64::ANDS_PPzPP;
3570 case AArch64::BIC_PPzPP:
3571 return AArch64::BICS_PPzPP;
3572 case AArch64::EOR_PPzPP:
3573 return AArch64::EORS_PPzPP;
3574 case AArch64::NAND_PPzPP:
3575 return AArch64::NANDS_PPzPP;
3576 case AArch64::NOR_PPzPP:
3577 return AArch64::NORS_PPzPP;
3578 case AArch64::ORN_PPzPP:
3579 return AArch64::ORNS_PPzPP;
3580 case AArch64::ORR_PPzPP:
3581 return AArch64::ORRS_PPzPP;
3582 case AArch64::BRKA_PPzP:
3583 return AArch64::BRKAS_PPzP;
3584 case AArch64::BRKPA_PPzPP:
3585 return AArch64::BRKPAS_PPzPP;
3586 case AArch64::BRKB_PPzP:
3587 return AArch64::BRKBS_PPzP;
3588 case AArch64::BRKPB_PPzPP:
3589 return AArch64::BRKPBS_PPzPP;
3590 case AArch64::BRKN_PPzP:
3591 return AArch64::BRKNS_PPzP;
3592 case AArch64::RDFFR_PPz:
3593 return AArch64::RDFFRS_PPz;
3594 case AArch64::PTRUE_B:
3595 return AArch64::PTRUES_B;
3606 if (
MI.hasOrderedMemoryRef())
3611 assert((
MI.getOperand(IsPreLdSt ? 2 : 1).isReg() ||
3612 MI.getOperand(IsPreLdSt ? 2 : 1).isFI()) &&
3613 "Expected a reg or frame index operand.");
3617 bool IsImmPreLdSt = IsPreLdSt &&
MI.getOperand(3).isImm();
3619 if (!
MI.getOperand(2).isImm() && !IsImmPreLdSt)
3632 if (
MI.getOperand(1).isReg() && !IsPreLdSt) {
3633 Register BaseReg =
MI.getOperand(1).getReg();
3635 if (
MI.modifiesRegister(BaseReg,
TRI))
3641 switch (
MI.getOpcode()) {
3644 case AArch64::LDR_ZXI:
3645 case AArch64::STR_ZXI:
3646 if (!Subtarget.isLittleEndian() ||
3647 Subtarget.getSVEVectorSizeInBits() != 128)
3660 const MCAsmInfo &MAI =
MI.getMF()->getTarget().getMCAsmInfo();
3668 if (Subtarget.isPaired128Slow()) {
3669 switch (
MI.getOpcode()) {
3672 case AArch64::LDURQi:
3673 case AArch64::STURQi:
3674 case AArch64::LDRQui:
3675 case AArch64::STRQui:
3701std::optional<ExtAddrMode>
3705 bool OffsetIsScalable;
3706 if (!getMemOperandWithOffset(MemI,
Base,
Offset, OffsetIsScalable))
3707 return std::nullopt;
3710 return std::nullopt;
3725 int64_t OffsetScale = 1;
3730 case AArch64::LDURQi:
3731 case AArch64::STURQi:
3735 case AArch64::LDURDi:
3736 case AArch64::STURDi:
3737 case AArch64::LDURXi:
3738 case AArch64::STURXi:
3742 case AArch64::LDURWi:
3743 case AArch64::LDURSWi:
3744 case AArch64::STURWi:
3748 case AArch64::LDURHi:
3749 case AArch64::STURHi:
3750 case AArch64::LDURHHi:
3751 case AArch64::STURHHi:
3752 case AArch64::LDURSHXi:
3753 case AArch64::LDURSHWi:
3757 case AArch64::LDRBroX:
3758 case AArch64::LDRBBroX:
3759 case AArch64::LDRSBXroX:
3760 case AArch64::LDRSBWroX:
3761 case AArch64::STRBroX:
3762 case AArch64::STRBBroX:
3763 case AArch64::LDURBi:
3764 case AArch64::LDURBBi:
3765 case AArch64::LDURSBXi:
3766 case AArch64::LDURSBWi:
3767 case AArch64::STURBi:
3768 case AArch64::STURBBi:
3769 case AArch64::LDRBui:
3770 case AArch64::LDRBBui:
3771 case AArch64::LDRSBXui:
3772 case AArch64::LDRSBWui:
3773 case AArch64::STRBui:
3774 case AArch64::STRBBui:
3778 case AArch64::LDRQroX:
3779 case AArch64::STRQroX:
3780 case AArch64::LDRQui:
3781 case AArch64::STRQui:
3786 case AArch64::LDRDroX:
3787 case AArch64::STRDroX:
3788 case AArch64::LDRXroX:
3789 case AArch64::STRXroX:
3790 case AArch64::LDRDui:
3791 case AArch64::STRDui:
3792 case AArch64::LDRXui:
3793 case AArch64::STRXui:
3798 case AArch64::LDRWroX:
3799 case AArch64::LDRSWroX:
3800 case AArch64::STRWroX:
3801 case AArch64::LDRWui:
3802 case AArch64::LDRSWui:
3803 case AArch64::STRWui:
3808 case AArch64::LDRHroX:
3809 case AArch64::STRHroX:
3810 case AArch64::LDRHHroX:
3811 case AArch64::STRHHroX:
3812 case AArch64::LDRSHXroX:
3813 case AArch64::LDRSHWroX:
3814 case AArch64::LDRHui:
3815 case AArch64::STRHui:
3816 case AArch64::LDRHHui:
3817 case AArch64::STRHHui:
3818 case AArch64::LDRSHXui:
3819 case AArch64::LDRSHWui:
3827 if (BaseRegOp.
isReg() && BaseRegOp.
getReg() == Reg)
3851 case AArch64::SBFMXri:
3864 AM.
Scale = OffsetScale;
3869 case TargetOpcode::SUBREG_TO_REG: {
3885 if (
DefMI.getOpcode() != AArch64::ORRWrs ||
3886 DefMI.getOperand(1).getReg() != AArch64::WZR ||
3887 DefMI.getOperand(3).getImm() != 0)
3894 AM.
Scale = OffsetScale;
3905 auto validateOffsetForLDP = [](
unsigned NumBytes, int64_t OldOffset,
3906 int64_t NewOffset) ->
bool {
3907 int64_t MinOffset, MaxOffset;
3924 return OldOffset < MinOffset || OldOffset > MaxOffset ||
3925 (NewOffset >= MinOffset && NewOffset <= MaxOffset);
3927 auto canFoldAddSubImmIntoAddrMode = [&](int64_t Disp) ->
bool {
3929 int64_t NewOffset = OldOffset + Disp;
3930 if (!isLegalAddressingMode(NumBytes, NewOffset, 0))
3934 if (!validateOffsetForLDP(NumBytes, OldOffset, NewOffset))
3944 auto canFoldAddRegIntoAddrMode =
3949 if ((
unsigned)Scale != Scale)
3951 if (!isLegalAddressingMode(NumBytes, 0, Scale))
3963 return (Opcode == AArch64::STURQi || Opcode == AArch64::STRQui) &&
3964 Subtarget.isSTRQroSlow();
3973 case AArch64::ADDXri:
3979 return canFoldAddSubImmIntoAddrMode(Disp);
3981 case AArch64::SUBXri:
3987 return canFoldAddSubImmIntoAddrMode(-Disp);
3989 case AArch64::ADDXrs: {
4002 if (Shift != 2 && Shift != 3 && Subtarget.hasAddrLSLSlow14())
4004 if (avoidSlowSTRQ(MemI))
4007 return canFoldAddRegIntoAddrMode(1ULL << Shift);
4010 case AArch64::ADDXrr:
4018 if (!OptSize && avoidSlowSTRQ(MemI))
4020 return canFoldAddRegIntoAddrMode(1);
4022 case AArch64::ADDXrx:
4030 if (!OptSize && avoidSlowSTRQ(MemI))
4039 return canFoldAddRegIntoAddrMode(
4054 case AArch64::LDURQi:
4055 case AArch64::LDRQui:
4056 return AArch64::LDRQroX;
4057 case AArch64::STURQi:
4058 case AArch64::STRQui:
4059 return AArch64::STRQroX;
4060 case AArch64::LDURDi:
4061 case AArch64::LDRDui:
4062 return AArch64::LDRDroX;
4063 case AArch64::STURDi:
4064 case AArch64::STRDui:
4065 return AArch64::STRDroX;
4066 case AArch64::LDURXi:
4067 case AArch64::LDRXui:
4068 return AArch64::LDRXroX;
4069 case AArch64::STURXi:
4070 case AArch64::STRXui:
4071 return AArch64::STRXroX;
4072 case AArch64::LDURWi:
4073 case AArch64::LDRWui:
4074 return AArch64::LDRWroX;
4075 case AArch64::LDURSWi:
4076 case AArch64::LDRSWui:
4077 return AArch64::LDRSWroX;
4078 case AArch64::STURWi:
4079 case AArch64::STRWui:
4080 return AArch64::STRWroX;
4081 case AArch64::LDURHi:
4082 case AArch64::LDRHui:
4083 return AArch64::LDRHroX;
4084 case AArch64::STURHi:
4085 case AArch64::STRHui:
4086 return AArch64::STRHroX;
4087 case AArch64::LDURHHi:
4088 case AArch64::LDRHHui:
4089 return AArch64::LDRHHroX;
4090 case AArch64::STURHHi:
4091 case AArch64::STRHHui:
4092 return AArch64::STRHHroX;
4093 case AArch64::LDURSHXi:
4094 case AArch64::LDRSHXui:
4095 return AArch64::LDRSHXroX;
4096 case AArch64::LDURSHWi:
4097 case AArch64::LDRSHWui:
4098 return AArch64::LDRSHWroX;
4099 case AArch64::LDURBi:
4100 case AArch64::LDRBui:
4101 return AArch64::LDRBroX;
4102 case AArch64::LDURBBi:
4103 case AArch64::LDRBBui:
4104 return AArch64::LDRBBroX;
4105 case AArch64::LDURSBXi:
4106 case AArch64::LDRSBXui:
4107 return AArch64::LDRSBXroX;
4108 case AArch64::LDURSBWi:
4109 case AArch64::LDRSBWui:
4110 return AArch64::LDRSBWroX;
4111 case AArch64::STURBi:
4112 case AArch64::STRBui:
4113 return AArch64::STRBroX;
4114 case AArch64::STURBBi:
4115 case AArch64::STRBBui:
4116 return AArch64::STRBBroX;
4128 case AArch64::LDURQi:
4130 return AArch64::LDRQui;
4131 case AArch64::STURQi:
4133 return AArch64::STRQui;
4134 case AArch64::LDURDi:
4136 return AArch64::LDRDui;
4137 case AArch64::STURDi:
4139 return AArch64::STRDui;
4140 case AArch64::LDURXi:
4142 return AArch64::LDRXui;
4143 case AArch64::STURXi:
4145 return AArch64::STRXui;
4146 case AArch64::LDURWi:
4148 return AArch64::LDRWui;
4149 case AArch64::LDURSWi:
4151 return AArch64::LDRSWui;
4152 case AArch64::STURWi:
4154 return AArch64::STRWui;
4155 case AArch64::LDURHi:
4157 return AArch64::LDRHui;
4158 case AArch64::STURHi:
4160 return AArch64::STRHui;
4161 case AArch64::LDURHHi:
4163 return AArch64::LDRHHui;
4164 case AArch64::STURHHi:
4166 return AArch64::STRHHui;
4167 case AArch64::LDURSHXi:
4169 return AArch64::LDRSHXui;
4170 case AArch64::LDURSHWi:
4172 return AArch64::LDRSHWui;
4173 case AArch64::LDURBi:
4175 return AArch64::LDRBui;
4176 case AArch64::LDURBBi:
4178 return AArch64::LDRBBui;
4179 case AArch64::LDURSBXi:
4181 return AArch64::LDRSBXui;
4182 case AArch64::LDURSBWi:
4184 return AArch64::LDRSBWui;
4185 case AArch64::STURBi:
4187 return AArch64::STRBui;
4188 case AArch64::STURBBi:
4190 return AArch64::STRBBui;
4191 case AArch64::LDRQui:
4192 case AArch64::STRQui:
4195 case AArch64::LDRDui:
4196 case AArch64::STRDui:
4197 case AArch64::LDRXui:
4198 case AArch64::STRXui:
4201 case AArch64::LDRWui:
4202 case AArch64::LDRSWui:
4203 case AArch64::STRWui:
4206 case AArch64::LDRHui:
4207 case AArch64::STRHui:
4208 case AArch64::LDRHHui:
4209 case AArch64::STRHHui:
4210 case AArch64::LDRSHXui:
4211 case AArch64::LDRSHWui:
4214 case AArch64::LDRBui:
4215 case AArch64::LDRBBui:
4216 case AArch64::LDRSBXui:
4217 case AArch64::LDRSBWui:
4218 case AArch64::STRBui:
4219 case AArch64::STRBBui:
4233 case AArch64::LDURQi:
4234 case AArch64::STURQi:
4235 case AArch64::LDURDi:
4236 case AArch64::STURDi:
4237 case AArch64::LDURXi:
4238 case AArch64::STURXi:
4239 case AArch64::LDURWi:
4240 case AArch64::LDURSWi:
4241 case AArch64::STURWi:
4242 case AArch64::LDURHi:
4243 case AArch64::STURHi:
4244 case AArch64::LDURHHi:
4245 case AArch64::STURHHi:
4246 case AArch64::LDURSHXi:
4247 case AArch64::LDURSHWi:
4248 case AArch64::LDURBi:
4249 case AArch64::STURBi:
4250 case AArch64::LDURBBi:
4251 case AArch64::STURBBi:
4252 case AArch64::LDURSBWi:
4253 case AArch64::LDURSBXi:
4255 case AArch64::LDRQui:
4256 return AArch64::LDURQi;
4257 case AArch64::STRQui:
4258 return AArch64::STURQi;
4259 case AArch64::LDRDui:
4260 return AArch64::LDURDi;
4261 case AArch64::STRDui:
4262 return AArch64::STURDi;
4263 case AArch64::LDRXui:
4264 return AArch64::LDURXi;
4265 case AArch64::STRXui:
4266 return AArch64::STURXi;
4267 case AArch64::LDRWui:
4268 return AArch64::LDURWi;
4269 case AArch64::LDRSWui:
4270 return AArch64::LDURSWi;
4271 case AArch64::STRWui:
4272 return AArch64::STURWi;
4273 case AArch64::LDRHui:
4274 return AArch64::LDURHi;
4275 case AArch64::STRHui:
4276 return AArch64::STURHi;
4277 case AArch64::LDRHHui:
4278 return AArch64::LDURHHi;
4279 case AArch64::STRHHui:
4280 return AArch64::STURHHi;
4281 case AArch64::LDRSHXui:
4282 return AArch64::LDURSHXi;
4283 case AArch64::LDRSHWui:
4284 return AArch64::LDURSHWi;
4285 case AArch64::LDRBBui:
4286 return AArch64::LDURBBi;
4287 case AArch64::LDRBui:
4288 return AArch64::LDURBi;
4289 case AArch64::STRBBui:
4290 return AArch64::STURBBi;
4291 case AArch64::STRBui:
4292 return AArch64::STURBi;
4293 case AArch64::LDRSBWui:
4294 return AArch64::LDURSBWi;
4295 case AArch64::LDRSBXui:
4296 return AArch64::LDURSBXi;
4309 case AArch64::LDRQroX:
4310 case AArch64::LDURQi:
4311 case AArch64::LDRQui:
4312 return AArch64::LDRQroW;
4313 case AArch64::STRQroX:
4314 case AArch64::STURQi:
4315 case AArch64::STRQui:
4316 return AArch64::STRQroW;
4317 case AArch64::LDRDroX:
4318 case AArch64::LDURDi:
4319 case AArch64::LDRDui:
4320 return AArch64::LDRDroW;
4321 case AArch64::STRDroX:
4322 case AArch64::STURDi:
4323 case AArch64::STRDui:
4324 return AArch64::STRDroW;
4325 case AArch64::LDRXroX:
4326 case AArch64::LDURXi:
4327 case AArch64::LDRXui:
4328 return AArch64::LDRXroW;
4329 case AArch64::STRXroX:
4330 case AArch64::STURXi:
4331 case AArch64::STRXui:
4332 return AArch64::STRXroW;
4333 case AArch64::LDRWroX:
4334 case AArch64::LDURWi:
4335 case AArch64::LDRWui:
4336 return AArch64::LDRWroW;
4337 case AArch64::LDRSWroX:
4338 case AArch64::LDURSWi:
4339 case AArch64::LDRSWui:
4340 return AArch64::LDRSWroW;
4341 case AArch64::STRWroX:
4342 case AArch64::STURWi:
4343 case AArch64::STRWui:
4344 return AArch64::STRWroW;
4345 case AArch64::LDRHroX:
4346 case AArch64::LDURHi:
4347 case AArch64::LDRHui:
4348 return AArch64::LDRHroW;
4349 case AArch64::STRHroX:
4350 case AArch64::STURHi:
4351 case AArch64::STRHui:
4352 return AArch64::STRHroW;
4353 case AArch64::LDRHHroX:
4354 case AArch64::LDURHHi:
4355 case AArch64::LDRHHui:
4356 return AArch64::LDRHHroW;
4357 case AArch64::STRHHroX:
4358 case AArch64::STURHHi:
4359 case AArch64::STRHHui:
4360 return AArch64::STRHHroW;
4361 case AArch64::LDRSHXroX:
4362 case AArch64::LDURSHXi:
4363 case AArch64::LDRSHXui:
4364 return AArch64::LDRSHXroW;
4365 case AArch64::LDRSHWroX:
4366 case AArch64::LDURSHWi:
4367 case AArch64::LDRSHWui:
4368 return AArch64::LDRSHWroW;
4369 case AArch64::LDRBroX:
4370 case AArch64::LDURBi:
4371 case AArch64::LDRBui:
4372 return AArch64::LDRBroW;
4373 case AArch64::LDRBBroX:
4374 case AArch64::LDURBBi:
4375 case AArch64::LDRBBui:
4376 return AArch64::LDRBBroW;
4377 case AArch64::LDRSBXroX:
4378 case AArch64::LDURSBXi:
4379 case AArch64::LDRSBXui:
4380 return AArch64::LDRSBXroW;
4381 case AArch64::LDRSBWroX:
4382 case AArch64::LDURSBWi:
4383 case AArch64::LDRSBWui:
4384 return AArch64::LDRSBWroW;
4385 case AArch64::STRBroX:
4386 case AArch64::STURBi:
4387 case AArch64::STRBui:
4388 return AArch64::STRBroW;
4389 case AArch64::STRBBroX:
4390 case AArch64::STURBBi:
4391 case AArch64::STRBBui:
4392 return AArch64::STRBBroW;
4417 return B.getInstr();
4421 "Addressing mode not supported for folding");
4438 return B.getInstr();
4445 "Address offset can be a register or an immediate, but not both");
4466 return B.getInstr();
4470 "Function must not be called with an addressing mode it can't handle");
4479 case AArch64::LD1Fourv16b_POST:
4480 case AArch64::LD1Fourv1d_POST:
4481 case AArch64::LD1Fourv2d_POST:
4482 case AArch64::LD1Fourv2s_POST:
4483 case AArch64::LD1Fourv4h_POST:
4484 case AArch64::LD1Fourv4s_POST:
4485 case AArch64::LD1Fourv8b_POST:
4486 case AArch64::LD1Fourv8h_POST:
4487 case AArch64::LD1Onev16b_POST:
4488 case AArch64::LD1Onev1d_POST:
4489 case AArch64::LD1Onev2d_POST:
4490 case AArch64::LD1Onev2s_POST:
4491 case AArch64::LD1Onev4h_POST:
4492 case AArch64::LD1Onev4s_POST:
4493 case AArch64::LD1Onev8b_POST:
4494 case AArch64::LD1Onev8h_POST:
4495 case AArch64::LD1Rv16b_POST:
4496 case AArch64::LD1Rv1d_POST:
4497 case AArch64::LD1Rv2d_POST:
4498 case AArch64::LD1Rv2s_POST:
4499 case AArch64::LD1Rv4h_POST:
4500 case AArch64::LD1Rv4s_POST:
4501 case AArch64::LD1Rv8b_POST:
4502 case AArch64::LD1Rv8h_POST:
4503 case AArch64::LD1Threev16b_POST:
4504 case AArch64::LD1Threev1d_POST:
4505 case AArch64::LD1Threev2d_POST:
4506 case AArch64::LD1Threev2s_POST:
4507 case AArch64::LD1Threev4h_POST:
4508 case AArch64::LD1Threev4s_POST:
4509 case AArch64::LD1Threev8b_POST:
4510 case AArch64::LD1Threev8h_POST:
4511 case AArch64::LD1Twov16b_POST:
4512 case AArch64::LD1Twov1d_POST:
4513 case AArch64::LD1Twov2d_POST:
4514 case AArch64::LD1Twov2s_POST:
4515 case AArch64::LD1Twov4h_POST:
4516 case AArch64::LD1Twov4s_POST:
4517 case AArch64::LD1Twov8b_POST:
4518 case AArch64::LD1Twov8h_POST:
4519 case AArch64::LD1i16_POST:
4520 case AArch64::LD1i32_POST:
4521 case AArch64::LD1i64_POST:
4522 case AArch64::LD1i8_POST:
4523 case AArch64::LD2Rv16b_POST:
4524 case AArch64::LD2Rv1d_POST:
4525 case AArch64::LD2Rv2d_POST:
4526 case AArch64::LD2Rv2s_POST:
4527 case AArch64::LD2Rv4h_POST:
4528 case AArch64::LD2Rv4s_POST:
4529 case AArch64::LD2Rv8b_POST:
4530 case AArch64::LD2Rv8h_POST:
4531 case AArch64::LD2Twov16b_POST:
4532 case AArch64::LD2Twov2d_POST:
4533 case AArch64::LD2Twov2s_POST:
4534 case AArch64::LD2Twov4h_POST:
4535 case AArch64::LD2Twov4s_POST:
4536 case AArch64::LD2Twov8b_POST:
4537 case AArch64::LD2Twov8h_POST:
4538 case AArch64::LD2i16_POST:
4539 case AArch64::LD2i32_POST:
4540 case AArch64::LD2i64_POST:
4541 case AArch64::LD2i8_POST:
4542 case AArch64::LD3Rv16b_POST:
4543 case AArch64::LD3Rv1d_POST:
4544 case AArch64::LD3Rv2d_POST:
4545 case AArch64::LD3Rv2s_POST:
4546 case AArch64::LD3Rv4h_POST:
4547 case AArch64::LD3Rv4s_POST:
4548 case AArch64::LD3Rv8b_POST:
4549 case AArch64::LD3Rv8h_POST:
4550 case AArch64::LD3Threev16b_POST:
4551 case AArch64::LD3Threev2d_POST:
4552 case AArch64::LD3Threev2s_POST:
4553 case AArch64::LD3Threev4h_POST:
4554 case AArch64::LD3Threev4s_POST:
4555 case AArch64::LD3Threev8b_POST:
4556 case AArch64::LD3Threev8h_POST:
4557 case AArch64::LD3i16_POST:
4558 case AArch64::LD3i32_POST:
4559 case AArch64::LD3i64_POST:
4560 case AArch64::LD3i8_POST:
4561 case AArch64::LD4Fourv16b_POST:
4562 case AArch64::LD4Fourv2d_POST:
4563 case AArch64::LD4Fourv2s_POST:
4564 case AArch64::LD4Fourv4h_POST:
4565 case AArch64::LD4Fourv4s_POST:
4566 case AArch64::LD4Fourv8b_POST:
4567 case AArch64::LD4Fourv8h_POST:
4568 case AArch64::LD4Rv16b_POST:
4569 case AArch64::LD4Rv1d_POST:
4570 case AArch64::LD4Rv2d_POST:
4571 case AArch64::LD4Rv2s_POST:
4572 case AArch64::LD4Rv4h_POST:
4573 case AArch64::LD4Rv4s_POST:
4574 case AArch64::LD4Rv8b_POST:
4575 case AArch64::LD4Rv8h_POST:
4576 case AArch64::LD4i16_POST:
4577 case AArch64::LD4i32_POST:
4578 case AArch64::LD4i64_POST:
4579 case AArch64::LD4i8_POST:
4580 case AArch64::LDAPRWpost:
4581 case AArch64::LDAPRXpost:
4582 case AArch64::LDIAPPWpost:
4583 case AArch64::LDIAPPXpost:
4584 case AArch64::LDPDpost:
4585 case AArch64::LDPQpost:
4586 case AArch64::LDPSWpost:
4587 case AArch64::LDPSpost:
4588 case AArch64::LDPWpost:
4589 case AArch64::LDPXpost:
4590 case AArch64::LDRBBpost:
4591 case AArch64::LDRBpost:
4592 case AArch64::LDRDpost:
4593 case AArch64::LDRHHpost:
4594 case AArch64::LDRHpost:
4595 case AArch64::LDRQpost:
4596 case AArch64::LDRSBWpost:
4597 case AArch64::LDRSBXpost:
4598 case AArch64::LDRSHWpost:
4599 case AArch64::LDRSHXpost:
4600 case AArch64::LDRSWpost:
4601 case AArch64::LDRSpost:
4602 case AArch64::LDRWpost:
4603 case AArch64::LDRXpost:
4604 case AArch64::ST1Fourv16b_POST:
4605 case AArch64::ST1Fourv1d_POST:
4606 case AArch64::ST1Fourv2d_POST:
4607 case AArch64::ST1Fourv2s_POST:
4608 case AArch64::ST1Fourv4h_POST:
4609 case AArch64::ST1Fourv4s_POST:
4610 case AArch64::ST1Fourv8b_POST:
4611 case AArch64::ST1Fourv8h_POST:
4612 case AArch64::ST1Onev16b_POST:
4613 case AArch64::ST1Onev1d_POST:
4614 case AArch64::ST1Onev2d_POST:
4615 case AArch64::ST1Onev2s_POST:
4616 case AArch64::ST1Onev4h_POST:
4617 case AArch64::ST1Onev4s_POST:
4618 case AArch64::ST1Onev8b_POST:
4619 case AArch64::ST1Onev8h_POST:
4620 case AArch64::ST1Threev16b_POST:
4621 case AArch64::ST1Threev1d_POST:
4622 case AArch64::ST1Threev2d_POST:
4623 case AArch64::ST1Threev2s_POST:
4624 case AArch64::ST1Threev4h_POST:
4625 case AArch64::ST1Threev4s_POST:
4626 case AArch64::ST1Threev8b_POST:
4627 case AArch64::ST1Threev8h_POST:
4628 case AArch64::ST1Twov16b_POST:
4629 case AArch64::ST1Twov1d_POST:
4630 case AArch64::ST1Twov2d_POST:
4631 case AArch64::ST1Twov2s_POST:
4632 case AArch64::ST1Twov4h_POST:
4633 case AArch64::ST1Twov4s_POST:
4634 case AArch64::ST1Twov8b_POST:
4635 case AArch64::ST1Twov8h_POST:
4636 case AArch64::ST1i16_POST:
4637 case AArch64::ST1i32_POST:
4638 case AArch64::ST1i64_POST:
4639 case AArch64::ST1i8_POST:
4640 case AArch64::ST2GPostIndex:
4641 case AArch64::ST2Twov16b_POST:
4642 case AArch64::ST2Twov2d_POST:
4643 case AArch64::ST2Twov2s_POST:
4644 case AArch64::ST2Twov4h_POST:
4645 case AArch64::ST2Twov4s_POST:
4646 case AArch64::ST2Twov8b_POST:
4647 case AArch64::ST2Twov8h_POST:
4648 case AArch64::ST2i16_POST:
4649 case AArch64::ST2i32_POST:
4650 case AArch64::ST2i64_POST:
4651 case AArch64::ST2i8_POST:
4652 case AArch64::ST3Threev16b_POST:
4653 case AArch64::ST3Threev2d_POST:
4654 case AArch64::ST3Threev2s_POST:
4655 case AArch64::ST3Threev4h_POST:
4656 case AArch64::ST3Threev4s_POST:
4657 case AArch64::ST3Threev8b_POST:
4658 case AArch64::ST3Threev8h_POST:
4659 case AArch64::ST3i16_POST:
4660 case AArch64::ST3i32_POST:
4661 case AArch64::ST3i64_POST:
4662 case AArch64::ST3i8_POST:
4663 case AArch64::ST4Fourv16b_POST:
4664 case AArch64::ST4Fourv2d_POST:
4665 case AArch64::ST4Fourv2s_POST:
4666 case AArch64::ST4Fourv4h_POST:
4667 case AArch64::ST4Fourv4s_POST:
4668 case AArch64::ST4Fourv8b_POST:
4669 case AArch64::ST4Fourv8h_POST:
4670 case AArch64::ST4i16_POST:
4671 case AArch64::ST4i32_POST:
4672 case AArch64::ST4i64_POST:
4673 case AArch64::ST4i8_POST:
4674 case AArch64::STGPostIndex:
4675 case AArch64::STGPpost:
4676 case AArch64::STPDpost:
4677 case AArch64::STPQpost:
4678 case AArch64::STPSpost:
4679 case AArch64::STPWpost:
4680 case AArch64::STPXpost:
4681 case AArch64::STRBBpost:
4682 case AArch64::STRBpost:
4683 case AArch64::STRDpost:
4684 case AArch64::STRHHpost:
4685 case AArch64::STRHpost:
4686 case AArch64::STRQpost:
4687 case AArch64::STRSpost:
4688 case AArch64::STRWpost:
4689 case AArch64::STRXpost:
4690 case AArch64::STZ2GPostIndex:
4691 case AArch64::STZGPostIndex:
4698 bool &OffsetIsScalable,
TypeSize &Width)
const {
4718 int64_t Dummy1, Dummy2;
4740 return BaseOp->
isReg() || BaseOp->
isFI();
4747 assert(OfsOp.
isImm() &&
"Offset operand wasn't immediate.");
4752 TypeSize &Width, int64_t &MinOffset,
4753 int64_t &MaxOffset) {
4758 MinOffset = MaxOffset = 0;
4761 case AArch64::LDRQui:
4762 case AArch64::STRQui:
4767 case AArch64::LDRXui:
4768 case AArch64::LDRDui:
4769 case AArch64::STRXui:
4770 case AArch64::STRDui:
4771 case AArch64::PRFMui:
4772 case AArch64::ATOMIC_STORE_HINT_Xui:
4773 case AArch64::ATOMIC_STORE_HINT_Dui:
4778 case AArch64::LDRWui:
4779 case AArch64::LDRSui:
4780 case AArch64::LDRSWui:
4781 case AArch64::STRWui:
4782 case AArch64::STRSui:
4783 case AArch64::ATOMIC_STORE_HINT_Wui:
4784 case AArch64::ATOMIC_STORE_HINT_Sui:
4789 case AArch64::LDRHui:
4790 case AArch64::LDRHHui:
4791 case AArch64::LDRSHWui:
4792 case AArch64::LDRSHXui:
4793 case AArch64::STRHui:
4794 case AArch64::STRHHui:
4795 case AArch64::ATOMIC_STORE_HINT_Hui:
4800 case AArch64::LDRBui:
4801 case AArch64::LDRBBui:
4802 case AArch64::LDRSBWui:
4803 case AArch64::LDRSBXui:
4804 case AArch64::STRBui:
4805 case AArch64::STRBBui:
4806 case AArch64::ATOMIC_STORE_HINT_Bui:
4812 case AArch64::STRQpre:
4813 case AArch64::LDRQpost:
4819 case AArch64::LDRDpost:
4820 case AArch64::LDRDpre:
4821 case AArch64::LDRXpost:
4822 case AArch64::LDRXpre:
4823 case AArch64::STRDpost:
4824 case AArch64::STRDpre:
4825 case AArch64::STRXpost:
4826 case AArch64::STRXpre:
4832 case AArch64::STRWpost:
4833 case AArch64::STRWpre:
4834 case AArch64::LDRWpost:
4835 case AArch64::LDRWpre:
4836 case AArch64::STRSpost:
4837 case AArch64::STRSpre:
4838 case AArch64::LDRSpost:
4839 case AArch64::LDRSpre:
4845 case AArch64::LDRHpost:
4846 case AArch64::LDRHpre:
4847 case AArch64::STRHpost:
4848 case AArch64::STRHpre:
4849 case AArch64::LDRHHpost:
4850 case AArch64::LDRHHpre:
4851 case AArch64::STRHHpost:
4852 case AArch64::STRHHpre:
4858 case AArch64::LDRBpost:
4859 case AArch64::LDRBpre:
4860 case AArch64::STRBpost:
4861 case AArch64::STRBpre:
4862 case AArch64::LDRBBpost:
4863 case AArch64::LDRBBpre:
4864 case AArch64::STRBBpost:
4865 case AArch64::STRBBpre:
4871 case AArch64::LDURQi:
4872 case AArch64::STURQi:
4878 case AArch64::LDURXi:
4879 case AArch64::LDURDi:
4880 case AArch64::LDAPURXi:
4881 case AArch64::STURXi:
4882 case AArch64::STURDi:
4883 case AArch64::STLURXi:
4884 case AArch64::PRFUMi:
4885 case AArch64::ATOMIC_STORE_HINT_Xi:
4886 case AArch64::ATOMIC_STORE_HINT_Di:
4892 case AArch64::LDURWi:
4893 case AArch64::LDURSi:
4894 case AArch64::LDURSWi:
4895 case AArch64::LDAPURi:
4896 case AArch64::LDAPURSWi:
4897 case AArch64::STURWi:
4898 case AArch64::STURSi:
4899 case AArch64::STLURWi:
4900 case AArch64::ATOMIC_STORE_HINT_Wi:
4901 case AArch64::ATOMIC_STORE_HINT_Si:
4907 case AArch64::LDURHi:
4908 case AArch64::LDURHHi:
4909 case AArch64::LDURSHXi:
4910 case AArch64::LDURSHWi:
4911 case AArch64::LDAPURHi:
4912 case AArch64::LDAPURSHWi:
4913 case AArch64::LDAPURSHXi:
4914 case AArch64::STURHi:
4915 case AArch64::STURHHi:
4916 case AArch64::STLURHi:
4917 case AArch64::ATOMIC_STORE_HINT_Hi:
4923 case AArch64::LDURBi:
4924 case AArch64::LDURBBi:
4925 case AArch64::LDURSBXi:
4926 case AArch64::LDURSBWi:
4927 case AArch64::LDAPURBi:
4928 case AArch64::LDAPURSBWi:
4929 case AArch64::LDAPURSBXi:
4930 case AArch64::STURBi:
4931 case AArch64::STURBBi:
4932 case AArch64::STLURBi:
4933 case AArch64::ATOMIC_STORE_HINT_Bi:
4939 case AArch64::LDPQi:
4940 case AArch64::LDNPQi:
4941 case AArch64::STPQi:
4942 case AArch64::STNPQi:
4943 case AArch64::LDPQpost:
4944 case AArch64::LDPQpre:
4945 case AArch64::STPQpost:
4946 case AArch64::STPQpre:
4952 case AArch64::LDPXi:
4953 case AArch64::LDPDi:
4954 case AArch64::LDNPXi:
4955 case AArch64::LDNPDi:
4956 case AArch64::STPXi:
4957 case AArch64::STPDi:
4958 case AArch64::STNPXi:
4959 case AArch64::STNPDi:
4960 case AArch64::LDPDpost:
4961 case AArch64::LDPDpre:
4962 case AArch64::LDPXpost:
4963 case AArch64::LDPXpre:
4964 case AArch64::STPDpost:
4965 case AArch64::STPDpre:
4966 case AArch64::STPXpost:
4967 case AArch64::STPXpre:
4973 case AArch64::LDPWi:
4974 case AArch64::LDPSi:
4975 case AArch64::LDNPWi:
4976 case AArch64::LDNPSi:
4977 case AArch64::STPWi:
4978 case AArch64::STPSi:
4979 case AArch64::STNPWi:
4980 case AArch64::STNPSi:
4981 case AArch64::LDPSpost:
4982 case AArch64::LDPSpre:
4983 case AArch64::LDPWpost:
4984 case AArch64::LDPWpre:
4985 case AArch64::STPSpost:
4986 case AArch64::STPSpre:
4987 case AArch64::STPWpost:
4988 case AArch64::STPWpre:
4994 case AArch64::StoreSwiftAsyncContext:
5007 case AArch64::TAGPstack:
5017 case AArch64::STGPreIndex:
5018 case AArch64::STGPostIndex:
5019 case AArch64::STZGi:
5020 case AArch64::STZGPreIndex:
5021 case AArch64::STZGPostIndex:
5027 case AArch64::STR_ZZZZXI:
5028 case AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS:
5029 case AArch64::LDR_ZZZZXI:
5030 case AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS:
5036 case AArch64::STR_ZZZXI:
5037 case AArch64::LDR_ZZZXI:
5043 case AArch64::STR_ZZXI:
5044 case AArch64::STR_ZZXI_STRIDED_CONTIGUOUS:
5045 case AArch64::LDR_ZZXI:
5046 case AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS:
5052 case AArch64::LDR_PXI:
5053 case AArch64::STR_PXI:
5058 case AArch64::LDR_PPXI:
5059 case AArch64::STR_PPXI:
5065 case AArch64::LDR_ZXI:
5066 case AArch64::STR_ZXI:
5071 case AArch64::LD1B_IMM:
5072 case AArch64::LD1H_IMM:
5073 case AArch64::LD1W_IMM:
5074 case AArch64::LD1D_IMM:
5075 case AArch64::LDNT1B_ZRI:
5076 case AArch64::LDNT1H_ZRI:
5077 case AArch64::LDNT1W_ZRI:
5078 case AArch64::LDNT1D_ZRI:
5079 case AArch64::ST1B_IMM:
5080 case AArch64::ST1H_IMM:
5081 case AArch64::ST1W_IMM:
5082 case AArch64::ST1D_IMM:
5083 case AArch64::STNT1B_ZRI:
5084 case AArch64::STNT1H_ZRI:
5085 case AArch64::STNT1W_ZRI:
5086 case AArch64::STNT1D_ZRI:
5087 case AArch64::LDNF1B_IMM:
5088 case AArch64::LDNF1H_IMM:
5089 case AArch64::LDNF1W_IMM:
5090 case AArch64::LDNF1D_IMM:
5097 case AArch64::LD2B_IMM:
5098 case AArch64::LD2H_IMM:
5099 case AArch64::LD2W_IMM:
5100 case AArch64::LD2D_IMM:
5101 case AArch64::ST2B_IMM:
5102 case AArch64::ST2H_IMM:
5103 case AArch64::ST2W_IMM:
5104 case AArch64::ST2D_IMM:
5105 case AArch64::LD1B_2Z_IMM:
5106 case AArch64::LD1B_2Z_STRIDED_IMM:
5107 case AArch64::LD1H_2Z_IMM:
5108 case AArch64::LD1H_2Z_STRIDED_IMM:
5109 case AArch64::LD1W_2Z_IMM:
5110 case AArch64::LD1W_2Z_STRIDED_IMM:
5111 case AArch64::LD1D_2Z_IMM:
5112 case AArch64::LD1D_2Z_STRIDED_IMM:
5113 case AArch64::LD1B_2Z_IMM_PSEUDO:
5114 case AArch64::LD1H_2Z_IMM_PSEUDO:
5115 case AArch64::LD1W_2Z_IMM_PSEUDO:
5116 case AArch64::LD1D_2Z_IMM_PSEUDO:
5117 case AArch64::ST1B_2Z_IMM:
5118 case AArch64::ST1B_2Z_STRIDED_IMM:
5119 case AArch64::ST1H_2Z_IMM:
5120 case AArch64::ST1H_2Z_STRIDED_IMM:
5121 case AArch64::ST1W_2Z_IMM:
5122 case AArch64::ST1W_2Z_STRIDED_IMM:
5123 case AArch64::ST1D_2Z_IMM:
5124 case AArch64::ST1D_2Z_STRIDED_IMM:
5125 case AArch64::LDNT1B_2Z_IMM_PSEUDO:
5126 case AArch64::LDNT1B_2Z_IMM:
5127 case AArch64::LDNT1B_2Z_STRIDED_IMM:
5128 case AArch64::LDNT1H_2Z_IMM_PSEUDO:
5129 case AArch64::LDNT1H_2Z_IMM:
5130 case AArch64::LDNT1H_2Z_STRIDED_IMM:
5131 case AArch64::LDNT1W_2Z_IMM_PSEUDO:
5132 case AArch64::LDNT1W_2Z_IMM:
5133 case AArch64::LDNT1W_2Z_STRIDED_IMM:
5134 case AArch64::LDNT1D_2Z_IMM_PSEUDO:
5135 case AArch64::LDNT1D_2Z_IMM:
5136 case AArch64::LDNT1D_2Z_STRIDED_IMM:
5137 case AArch64::STNT1B_2Z_IMM:
5138 case AArch64::STNT1B_2Z_STRIDED_IMM:
5139 case AArch64::STNT1H_2Z_IMM:
5140 case AArch64::STNT1H_2Z_STRIDED_IMM:
5141 case AArch64::STNT1W_2Z_IMM:
5142 case AArch64::STNT1W_2Z_STRIDED_IMM:
5143 case AArch64::STNT1D_2Z_IMM:
5144 case AArch64::STNT1D_2Z_STRIDED_IMM:
5145 case AArch64::ST1B_2Z_IMM_PSEUDO:
5146 case AArch64::ST1H_2Z_IMM_PSEUDO:
5147 case AArch64::ST1W_2Z_IMM_PSEUDO:
5148 case AArch64::ST1D_2Z_IMM_PSEUDO:
5149 case AArch64::STNT1B_2Z_IMM_PSEUDO:
5150 case AArch64::STNT1H_2Z_IMM_PSEUDO:
5151 case AArch64::STNT1W_2Z_IMM_PSEUDO:
5152 case AArch64::STNT1D_2Z_IMM_PSEUDO:
5157 case AArch64::LD3B_IMM:
5158 case AArch64::LD3H_IMM:
5159 case AArch64::LD3W_IMM:
5160 case AArch64::LD3D_IMM:
5161 case AArch64::ST3B_IMM:
5162 case AArch64::ST3H_IMM:
5163 case AArch64::ST3W_IMM:
5164 case AArch64::ST3D_IMM:
5169 case AArch64::LD4B_IMM:
5170 case AArch64::LD4H_IMM:
5171 case AArch64::LD4W_IMM:
5172 case AArch64::LD4D_IMM:
5173 case AArch64::ST4B_IMM:
5174 case AArch64::ST4H_IMM:
5175 case AArch64::ST4W_IMM:
5176 case AArch64::ST4D_IMM:
5177 case AArch64::LD1B_4Z_IMM:
5178 case AArch64::LD1B_4Z_STRIDED_IMM:
5179 case AArch64::LD1H_4Z_IMM:
5180 case AArch64::LD1H_4Z_STRIDED_IMM:
5181 case AArch64::LD1W_4Z_IMM:
5182 case AArch64::LD1W_4Z_STRIDED_IMM:
5183 case AArch64::LD1D_4Z_IMM:
5184 case AArch64::LD1D_4Z_STRIDED_IMM:
5185 case AArch64::LD1B_4Z_IMM_PSEUDO:
5186 case AArch64::LD1H_4Z_IMM_PSEUDO:
5187 case AArch64::LD1W_4Z_IMM_PSEUDO:
5188 case AArch64::LD1D_4Z_IMM_PSEUDO:
5189 case AArch64::ST1B_4Z_IMM:
5190 case AArch64::ST1B_4Z_STRIDED_IMM:
5191 case AArch64::ST1H_4Z_IMM:
5192 case AArch64::ST1H_4Z_STRIDED_IMM:
5193 case AArch64::ST1W_4Z_IMM:
5194 case AArch64::ST1W_4Z_STRIDED_IMM:
5195 case AArch64::ST1D_4Z_IMM:
5196 case AArch64::ST1D_4Z_STRIDED_IMM:
5197 case AArch64::LDNT1B_4Z_IMM_PSEUDO:
5198 case AArch64::LDNT1B_4Z_IMM:
5199 case AArch64::LDNT1B_4Z_STRIDED_IMM:
5200 case AArch64::LDNT1H_4Z_IMM_PSEUDO:
5201 case AArch64::LDNT1H_4Z_IMM:
5202 case AArch64::LDNT1H_4Z_STRIDED_IMM:
5203 case AArch64::LDNT1W_4Z_IMM_PSEUDO:
5204 case AArch64::LDNT1W_4Z_IMM:
5205 case AArch64::LDNT1W_4Z_STRIDED_IMM:
5206 case AArch64::LDNT1D_4Z_IMM_PSEUDO:
5207 case AArch64::LDNT1D_4Z_IMM:
5208 case AArch64::LDNT1D_4Z_STRIDED_IMM:
5209 case AArch64::STNT1B_4Z_IMM:
5210 case AArch64::STNT1B_4Z_STRIDED_IMM:
5211 case AArch64::STNT1H_4Z_IMM:
5212 case AArch64::STNT1H_4Z_STRIDED_IMM:
5213 case AArch64::STNT1W_4Z_IMM:
5214 case AArch64::STNT1W_4Z_STRIDED_IMM:
5215 case AArch64::STNT1D_4Z_IMM:
5216 case AArch64::STNT1D_4Z_STRIDED_IMM:
5217 case AArch64::ST1B_4Z_IMM_PSEUDO:
5218 case AArch64::ST1H_4Z_IMM_PSEUDO:
5219 case AArch64::ST1W_4Z_IMM_PSEUDO:
5220 case AArch64::ST1D_4Z_IMM_PSEUDO:
5221 case AArch64::STNT1B_4Z_IMM_PSEUDO:
5222 case AArch64::STNT1H_4Z_IMM_PSEUDO:
5223 case AArch64::STNT1W_4Z_IMM_PSEUDO:
5224 case AArch64::STNT1D_4Z_IMM_PSEUDO:
5229 case AArch64::LD1B_H_IMM:
5230 case AArch64::LD1SB_H_IMM:
5231 case AArch64::LD1H_S_IMM:
5232 case AArch64::LD1SH_S_IMM:
5233 case AArch64::LD1W_D_IMM:
5234 case AArch64::LD1SW_D_IMM:
5235 case AArch64::ST1B_H_IMM:
5236 case AArch64::ST1H_S_IMM:
5237 case AArch64::ST1W_D_IMM:
5238 case AArch64::LDNF1B_H_IMM:
5239 case AArch64::LDNF1SB_H_IMM:
5240 case AArch64::LDNF1H_S_IMM:
5241 case AArch64::LDNF1SH_S_IMM:
5242 case AArch64::LDNF1W_D_IMM:
5243 case AArch64::LDNF1SW_D_IMM:
5250 case AArch64::LD1B_S_IMM:
5251 case AArch64::LD1SB_S_IMM:
5252 case AArch64::LD1H_D_IMM:
5253 case AArch64::LD1SH_D_IMM:
5254 case AArch64::ST1B_S_IMM:
5255 case AArch64::ST1H_D_IMM:
5256 case AArch64::LDNF1B_S_IMM:
5257 case AArch64::LDNF1SB_S_IMM:
5258 case AArch64::LDNF1H_D_IMM:
5259 case AArch64::LDNF1SH_D_IMM:
5266 case AArch64::LD1B_D_IMM:
5267 case AArch64::LD1SB_D_IMM:
5268 case AArch64::ST1B_D_IMM:
5269 case AArch64::LDNF1B_D_IMM:
5270 case AArch64::LDNF1SB_D_IMM:
5277 case AArch64::ST2Gi:
5278 case AArch64::ST2GPreIndex:
5279 case AArch64::ST2GPostIndex:
5280 case AArch64::STZ2Gi:
5281 case AArch64::STZ2GPreIndex:
5282 case AArch64::STZ2GPostIndex:
5288 case AArch64::STGPi:
5289 case AArch64::STGPpost:
5290 case AArch64::STGPpre:
5295 case AArch64::LD1RB_IMM:
5296 case AArch64::LD1RB_H_IMM:
5297 case AArch64::LD1RB_S_IMM:
5298 case AArch64::LD1RB_D_IMM:
5299 case AArch64::LD1RSB_H_IMM:
5300 case AArch64::LD1RSB_S_IMM:
5301 case AArch64::LD1RSB_D_IMM:
5306 case AArch64::LD1RH_IMM:
5307 case AArch64::LD1RH_S_IMM:
5308 case AArch64::LD1RH_D_IMM:
5309 case AArch64::LD1RSH_S_IMM:
5310 case AArch64::LD1RSH_D_IMM:
5315 case AArch64::LD1RW_IMM:
5316 case AArch64::LD1RW_D_IMM:
5317 case AArch64::LD1RSW_IMM:
5322 case AArch64::LD1RD_IMM:
5337 case AArch64::LDRBui:
5338 case AArch64::LDRBBui:
5339 case AArch64::LDURBBi:
5340 case AArch64::LDRSBWui:
5341 case AArch64::LDURSBWi:
5342 case AArch64::STRBui:
5343 case AArch64::STRBBui:
5344 case AArch64::STURBBi:
5346 case AArch64::LDRHui:
5347 case AArch64::LDRHHui:
5348 case AArch64::LDURHHi:
5349 case AArch64::LDRSHWui:
5350 case AArch64::LDURSHWi:
5351 case AArch64::STRHui:
5352 case AArch64::STRHHui:
5353 case AArch64::STURHHi:
5355 case AArch64::LDRSui:
5356 case AArch64::LDURSi:
5357 case AArch64::LDRSpre:
5358 case AArch64::LDRSWui:
5359 case AArch64::LDURSWi:
5360 case AArch64::LDRSWpre:
5361 case AArch64::LDRWpre:
5362 case AArch64::LDRWui:
5363 case AArch64::LDURWi:
5364 case AArch64::STRSui:
5365 case AArch64::STURSi:
5366 case AArch64::STRSpre:
5367 case AArch64::STRWui:
5368 case AArch64::STURWi:
5369 case AArch64::STRWpre:
5370 case AArch64::LDPSi:
5371 case AArch64::LDPSWi:
5372 case AArch64::LDPWi:
5373 case AArch64::STPSi:
5374 case AArch64::STPWi:
5376 case AArch64::LDRDui:
5377 case AArch64::LDURDi:
5378 case AArch64::LDRDpre:
5379 case AArch64::LDRXui:
5380 case AArch64::LDURXi:
5381 case AArch64::LDRXpre:
5382 case AArch64::STRDui:
5383 case AArch64::STURDi:
5384 case AArch64::STRDpre:
5385 case AArch64::STRXui:
5386 case AArch64::STURXi:
5387 case AArch64::STRXpre:
5388 case AArch64::LDPDi:
5389 case AArch64::LDPXi:
5390 case AArch64::STPDi:
5391 case AArch64::STPXi:
5393 case AArch64::LDRQui:
5394 case AArch64::LDURQi:
5395 case AArch64::STRQui:
5396 case AArch64::STURQi:
5397 case AArch64::STRQpre:
5398 case AArch64::LDPQi:
5399 case AArch64::LDRQpre:
5400 case AArch64::STPQi:
5402 case AArch64::STZGi:
5403 case AArch64::ST2Gi:
5404 case AArch64::STZ2Gi:
5405 case AArch64::STGPi:
5411 switch (
MI.getOpcode()) {
5414 case AArch64::LDRWpre:
5415 case AArch64::LDRXpre:
5416 case AArch64::LDRSWpre:
5417 case AArch64::LDRSpre:
5418 case AArch64::LDRDpre:
5419 case AArch64::LDRQpre:
5425 switch (
MI.getOpcode()) {
5428 case AArch64::STRWpre:
5429 case AArch64::STRXpre:
5430 case AArch64::STRSpre:
5431 case AArch64::STRDpre:
5432 case AArch64::STRQpre:
5442 switch (
MI.getOpcode()) {
5445 case AArch64::LDURBBi:
5446 case AArch64::LDURHHi:
5447 case AArch64::LDURWi:
5448 case AArch64::LDRBBui:
5449 case AArch64::LDRHHui:
5450 case AArch64::LDRWui:
5451 case AArch64::LDRBBroX:
5452 case AArch64::LDRHHroX:
5453 case AArch64::LDRWroX:
5454 case AArch64::LDRBBroW:
5455 case AArch64::LDRHHroW:
5456 case AArch64::LDRWroW:
5462 switch (
MI.getOpcode()) {
5465 case AArch64::LDURSBWi:
5466 case AArch64::LDURSHWi:
5467 case AArch64::LDURSBXi:
5468 case AArch64::LDURSHXi:
5469 case AArch64::LDURSWi:
5470 case AArch64::LDRSBWui:
5471 case AArch64::LDRSHWui:
5472 case AArch64::LDRSBXui:
5473 case AArch64::LDRSHXui:
5474 case AArch64::LDRSWui:
5475 case AArch64::LDRSBWroX:
5476 case AArch64::LDRSHWroX:
5477 case AArch64::LDRSBXroX:
5478 case AArch64::LDRSHXroX:
5479 case AArch64::LDRSWroX:
5480 case AArch64::LDRSBWroW:
5481 case AArch64::LDRSHWroW:
5482 case AArch64::LDRSBXroW:
5483 case AArch64::LDRSHXroW:
5484 case AArch64::LDRSWroW:
5490 switch (
MI.getOpcode()) {
5493 case AArch64::LDPSi:
5494 case AArch64::LDPSWi:
5495 case AArch64::LDPDi:
5496 case AArch64::LDPQi:
5497 case AArch64::LDPWi:
5498 case AArch64::LDPXi:
5499 case AArch64::STPSi:
5500 case AArch64::STPDi:
5501 case AArch64::STPQi:
5502 case AArch64::STPWi:
5503 case AArch64::STPXi:
5504 case AArch64::STGPi:
5510 assert(
MI.mayLoadOrStore() &&
"Load or store instruction expected");
5514 return MI.getOperand(Idx);
5519 assert(
MI.mayLoadOrStore() &&
"Load or store instruction expected");
5523 return MI.getOperand(Idx);
5528 switch (
MI.getOpcode()) {
5531 case AArch64::LDRBroX:
5532 case AArch64::LDRBBroX:
5533 case AArch64::LDRSBXroX:
5534 case AArch64::LDRSBWroX:
5535 case AArch64::LDRHroX:
5536 case AArch64::LDRHHroX:
5537 case AArch64::LDRSHXroX:
5538 case AArch64::LDRSHWroX:
5539 case AArch64::LDRWroX:
5540 case AArch64::LDRSroX:
5541 case AArch64::LDRSWroX:
5542 case AArch64::LDRDroX:
5543 case AArch64::LDRXroX:
5544 case AArch64::LDRQroX:
5545 return MI.getOperand(4);
5551 if (
MI.getParent() ==
nullptr)
5561 auto Reg =
Op.getReg();
5562 if (Reg.isPhysical())
5563 return AArch64::FPR16RegClass.contains(Reg);
5565 return TRC == &AArch64::FPR16RegClass ||
5566 TRC == &AArch64::FPR16_loRegClass;
5575 auto Reg =
Op.getReg();
5576 if (Reg.isPhysical())
5577 return AArch64::FPR128RegClass.contains(Reg);
5579 return TRC == &AArch64::FPR128RegClass ||
5580 TRC == &AArch64::FPR128_loRegClass;
5586 switch (
MI.getOpcode()) {
5589 case AArch64::PACIASP:
5590 case AArch64::PACIBSP:
5593 case AArch64::PAUTH_PROLOGUE:
5596 case AArch64::HINT: {
5597 unsigned Imm =
MI.getOperand(0).getImm();
5602 if (
Imm == 25 ||
Imm == 27)
5614 assert(Reg.isPhysical() &&
"Expected physical register in isFpOrNEON");
5615 return AArch64::FPR128RegClass.contains(Reg) ||
5616 AArch64::FPR64RegClass.contains(Reg) ||
5617 AArch64::FPR32RegClass.contains(Reg) ||
5618 AArch64::FPR16RegClass.contains(Reg) ||
5619 AArch64::FPR8RegClass.contains(Reg);
5626 auto Reg =
Op.getReg();
5627 if (Reg.isPhysical())
5631 return TRC == &AArch64::FPR128RegClass ||
5632 TRC == &AArch64::FPR128_loRegClass ||
5633 TRC == &AArch64::FPR64RegClass ||
5634 TRC == &AArch64::FPR64_loRegClass ||
5635 TRC == &AArch64::FPR32RegClass || TRC == &AArch64::FPR16RegClass ||
5636 TRC == &AArch64::FPR8RegClass;
5658 if (FirstOpc == SecondOpc)
5664 case AArch64::STRSui:
5665 case AArch64::STURSi:
5666 return SecondOpc == AArch64::STRSui || SecondOpc == AArch64::STURSi;
5667 case AArch64::STRDui:
5668 case AArch64::STURDi:
5669 return SecondOpc == AArch64::STRDui || SecondOpc == AArch64::STURDi;
5670 case AArch64::STRQui:
5671 case AArch64::STURQi:
5672 return SecondOpc == AArch64::STRQui || SecondOpc == AArch64::STURQi;
5673 case AArch64::STRWui:
5674 case AArch64::STURWi:
5675 return SecondOpc == AArch64::STRWui || SecondOpc == AArch64::STURWi;
5676 case AArch64::STRXui:
5677 case AArch64::STURXi:
5678 return SecondOpc == AArch64::STRXui || SecondOpc == AArch64::STURXi;
5679 case AArch64::LDRSui:
5680 case AArch64::LDURSi:
5681 return SecondOpc == AArch64::LDRSui || SecondOpc == AArch64::LDURSi;
5682 case AArch64::LDRDui:
5683 case AArch64::LDURDi:
5684 return SecondOpc == AArch64::LDRDui || SecondOpc == AArch64::LDURDi;
5685 case AArch64::LDRQui:
5686 case AArch64::LDURQi:
5687 return SecondOpc == AArch64::LDRQui || SecondOpc == AArch64::LDURQi;
5688 case AArch64::LDRWui:
5689 case AArch64::LDURWi:
5690 return SecondOpc == AArch64::LDRSWui || SecondOpc == AArch64::LDURSWi;
5691 case AArch64::LDRSWui:
5692 case AArch64::LDURSWi:
5693 return SecondOpc == AArch64::LDRWui || SecondOpc == AArch64::LDURWi;
5694 case AArch64::LDRXui:
5695 case AArch64::LDURXi:
5696 return SecondOpc == AArch64::LDRXui || SecondOpc == AArch64::LDURXi;
5703 int64_t Offset1,
unsigned Opcode1,
int FI2,
5704 int64_t Offset2,
unsigned Opcode2) {
5710 assert(ObjectOffset1 <= ObjectOffset2 &&
"Object offsets are not ordered.");
5713 if (ObjectOffset1 % Scale1 != 0)
5715 ObjectOffset1 /= Scale1;
5717 if (ObjectOffset2 % Scale2 != 0)
5719 ObjectOffset2 /= Scale2;
5720 ObjectOffset1 += Offset1;
5721 ObjectOffset2 += Offset2;
5722 return ObjectOffset1 + 1 == ObjectOffset2;
5734 int64_t OpOffset2,
bool OffsetIsScalable2,
unsigned ClusterSize,
5735 unsigned NumBytes)
const {
5745 "Only base registers and frame indices are supported.");
5752 if (ClusterSize > 2)
5759 unsigned FirstOpc = FirstLdSt.
getOpcode();
5760 unsigned SecondOpc = SecondLdSt.
getOpcode();
5780 if (Offset1 > 63 || Offset1 < -64)
5785 if (BaseOp1.
isFI()) {
5787 "Caller should have ordered offsets.");
5792 BaseOp2.
getIndex(), Offset2, SecondOpc);
5795 assert(Offset1 <= Offset2 &&
"Caller should have ordered offsets.");
5797 return Offset1 + 1 == Offset2;
5807 if (
Reg.isPhysical())
5817 assert(Subtarget.hasNEON() &&
"Unexpected register copy without NEON");
5819 uint16_t DestEncoding =
TRI->getEncodingValue(DestReg);
5820 uint16_t SrcEncoding =
TRI->getEncodingValue(SrcReg);
5821 unsigned NumRegs = Indices.
size();
5822 MCRegister DestSubReg =
TRI->getSubReg(DestReg, Indices[0]);
5824 "Unexpected predicate tuple copy");
5825 unsigned MaxRegs = AArch64::PPRRegClass.contains(DestSubReg) ? 15 : 31;
5827 int SubReg = 0, End = NumRegs, Incr = 1;
5829 if (((DestEncoding - SrcEncoding) & MaxRegs) < NumRegs) {
5830 SubReg = NumRegs - 1;
5835 for (; SubReg != End; SubReg += Incr) {
5836 DestSubReg =
TRI->getSubReg(DestReg, Indices[SubReg]);
5837 MCRegister SrcSubReg =
TRI->getSubReg(SrcReg, Indices[SubReg]);
5846 unsigned Opcode,
unsigned ZeroReg,
5849 unsigned NumRegs = Indices.
size();
5852 uint16_t DestEncoding =
TRI->getEncodingValue(DestReg);
5853 uint16_t SrcEncoding =
TRI->getEncodingValue(SrcReg);
5854 assert(DestEncoding % NumRegs == 0 && SrcEncoding % NumRegs == 0 &&
5855 "GPR reg sequences should not be able to overlap");
5858 for (
unsigned SubReg = 0; SubReg != NumRegs; ++SubReg) {
5879 unsigned Opc =
MI.getOpcode();
5880 if (
Opc == AArch64::MSRpstatesvcrImm1 ||
Opc == AArch64::MSRpstatePseudo) {
5882 int64_t PState =
MI.getOperand(0).getImm();
5883 if (PState == AArch64SVCR::SVCRSM || PState == AArch64SVCR::SVCRSMZA) {
5885 return MI.getOperand(1).getImm() == 1;
5904 bool RenamableSrc)
const {
5905 if (AArch64::GPR32spRegClass.
contains(DestReg) &&
5906 AArch64::GPR32spRegClass.
contains(SrcReg)) {
5907 if (DestReg == AArch64::WSP || SrcReg == AArch64::WSP) {
5909 if (Subtarget.hasZeroCycleRegMoveGPR64() &&
5910 !Subtarget.hasZeroCycleRegMoveGPR32()) {
5912 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5913 &AArch64::GPR64spRegClass);
5914 MCRegister SrcRegX = RI.getMatchingSuperReg(SrcReg, AArch64::sub_32,
5915 &AArch64::GPR64spRegClass);
5925 ++NumZCRegMoveInstrsGPR;
5931 if (Subtarget.hasZeroCycleRegMoveGPR32())
5932 ++NumZCRegMoveInstrsGPR;
5934 }
else if (Subtarget.hasZeroCycleRegMoveGPR64() &&
5935 !Subtarget.hasZeroCycleRegMoveGPR32()) {
5937 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5938 &AArch64::GPR64spRegClass);
5939 assert(DestRegX.
isValid() &&
"Destination super-reg not valid");
5940 MCRegister SrcRegX = RI.getMatchingSuperReg(SrcReg, AArch64::sub_32,
5941 &AArch64::GPR64spRegClass);
5951 ++NumZCRegMoveInstrsGPR;
5957 if (Subtarget.hasZeroCycleRegMoveGPR32())
5958 ++NumZCRegMoveInstrsGPR;
5964 if (AArch64::GPR32spRegClass.
contains(DestReg) && SrcReg == AArch64::WZR) {
5965 if (Subtarget.hasZeroCycleZeroingGPR64() &&
5966 !Subtarget.hasZeroCycleZeroingGPR32()) {
5967 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5968 &AArch64::GPR64spRegClass);
5969 assert(DestRegX.
isValid() &&
"Destination super-reg not valid");
5973 ++NumZCZeroingInstrsGPR;
5974 }
else if (Subtarget.hasZeroCycleZeroingGPR32()) {
5978 ++NumZCZeroingInstrsGPR;
5987 if (AArch64::GPR64spRegClass.
contains(DestReg) &&
5988 AArch64::GPR64spRegClass.
contains(SrcReg)) {
5989 if (DestReg == AArch64::SP || SrcReg == AArch64::SP) {
5995 if (Subtarget.hasZeroCycleRegMoveGPR64())
5996 ++NumZCRegMoveInstrsGPR;
6002 if (Subtarget.hasZeroCycleRegMoveGPR64())
6003 ++NumZCRegMoveInstrsGPR;
6009 if (AArch64::GPR64spRegClass.
contains(DestReg) && SrcReg == AArch64::XZR) {
6010 if (Subtarget.hasZeroCycleZeroingGPR64()) {
6014 ++NumZCZeroingInstrsGPR;
6024 if (AArch64::PPRRegClass.
contains(DestReg) &&
6025 AArch64::PPRRegClass.
contains(SrcReg)) {
6026 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6027 "Unexpected SVE register.");
6037 bool DestIsPNR = AArch64::PNRRegClass.contains(DestReg);
6038 bool SrcIsPNR = AArch64::PNRRegClass.contains(SrcReg);
6039 if (DestIsPNR || SrcIsPNR) {
6041 return (R - AArch64::PN0) + AArch64::P0;
6046 if (PPRSrcReg != PPRDestReg) {
6058 if (AArch64::PPR2RegClass.
contains(DestReg) &&
6059 AArch64::PPR2RegClass.
contains(SrcReg)) {
6060 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6061 "Unexpected SVE predicate register.");
6062 static const unsigned Indices[] = {AArch64::psub0, AArch64::psub1};
6068 if (AArch64::ZPRRegClass.
contains(DestReg) &&
6069 AArch64::ZPRRegClass.
contains(SrcReg)) {
6070 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6071 "Unexpected SVE register.");
6079 if ((AArch64::ZPR2RegClass.
contains(DestReg) ||
6080 AArch64::ZPR2StridedOrContiguousRegClass.
contains(DestReg)) &&
6081 (AArch64::ZPR2RegClass.
contains(SrcReg) ||
6082 AArch64::ZPR2StridedOrContiguousRegClass.
contains(SrcReg))) {
6083 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6084 "Unexpected SVE register.");
6085 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1};
6091 if (AArch64::ZPR3RegClass.
contains(DestReg) &&
6092 AArch64::ZPR3RegClass.
contains(SrcReg)) {
6093 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6094 "Unexpected SVE register.");
6095 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1,
6102 if ((AArch64::ZPR4RegClass.
contains(DestReg) ||
6103 AArch64::ZPR4StridedOrContiguousRegClass.
contains(DestReg)) &&
6104 (AArch64::ZPR4RegClass.
contains(SrcReg) ||
6105 AArch64::ZPR4StridedOrContiguousRegClass.
contains(SrcReg))) {
6106 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6107 "Unexpected SVE register.");
6108 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1,
6109 AArch64::zsub2, AArch64::zsub3};
6115 if (AArch64::DDDDRegClass.
contains(DestReg) &&
6116 AArch64::DDDDRegClass.
contains(SrcReg)) {
6117 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1,
6118 AArch64::dsub2, AArch64::dsub3};
6124 if (AArch64::DDDRegClass.
contains(DestReg) &&
6125 AArch64::DDDRegClass.
contains(SrcReg)) {
6126 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1,
6133 if (AArch64::DDRegClass.
contains(DestReg) &&
6134 AArch64::DDRegClass.
contains(SrcReg)) {
6135 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1};
6141 if (AArch64::QQQQRegClass.
contains(DestReg) &&
6142 AArch64::QQQQRegClass.
contains(SrcReg)) {
6143 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1,
6144 AArch64::qsub2, AArch64::qsub3};
6150 if (AArch64::QQQRegClass.
contains(DestReg) &&
6151 AArch64::QQQRegClass.
contains(SrcReg)) {
6152 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1,
6159 if (AArch64::QQRegClass.
contains(DestReg) &&
6160 AArch64::QQRegClass.
contains(SrcReg)) {
6161 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1};
6166 if (AArch64::XSeqPairsClassRegClass.
contains(DestReg) &&
6167 AArch64::XSeqPairsClassRegClass.
contains(SrcReg)) {
6168 static const unsigned Indices[] = {AArch64::sube64, AArch64::subo64};
6170 AArch64::XZR, Indices);
6174 if (AArch64::WSeqPairsClassRegClass.
contains(DestReg) &&
6175 AArch64::WSeqPairsClassRegClass.
contains(SrcReg)) {
6176 static const unsigned Indices[] = {AArch64::sube32, AArch64::subo32};
6178 AArch64::WZR, Indices);
6182 if (AArch64::FPR128RegClass.
contains(DestReg) &&
6183 AArch64::FPR128RegClass.
contains(SrcReg)) {
6187 if ((Subtarget.isSVEorStreamingSVEAvailable() &&
6188 !Subtarget.isNeonAvailable()) ||
6192 .
addReg(AArch64::Z0 + (SrcReg - AArch64::Q0))
6193 .
addReg(AArch64::Z0 + (SrcReg - AArch64::Q0));
6194 }
else if (Subtarget.isNeonAvailable()) {
6198 if (Subtarget.hasZeroCycleRegMoveFPR128())
6199 ++NumZCRegMoveInstrsFPR;
6215 if (AArch64::FPR64RegClass.
contains(DestReg) &&
6216 AArch64::FPR64RegClass.
contains(SrcReg)) {
6217 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
6218 !Subtarget.hasZeroCycleRegMoveFPR64() &&
6219 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
6221 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::dsub,
6222 &AArch64::FPR128RegClass);
6223 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::dsub,
6224 &AArch64::FPR128RegClass);
6233 ++NumZCRegMoveInstrsFPR;
6237 if (Subtarget.hasZeroCycleRegMoveFPR64())
6238 ++NumZCRegMoveInstrsFPR;
6243 if (AArch64::FPR32RegClass.
contains(DestReg) &&
6244 AArch64::FPR32RegClass.
contains(SrcReg)) {
6245 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
6246 !Subtarget.hasZeroCycleRegMoveFPR64() &&
6247 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
6249 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::ssub,
6250 &AArch64::FPR128RegClass);
6251 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::ssub,
6252 &AArch64::FPR128RegClass);
6261 ++NumZCRegMoveInstrsFPR;
6262 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
6263 !Subtarget.hasZeroCycleRegMoveFPR32()) {
6264 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::ssub,
6265 &AArch64::FPR64RegClass);
6266 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::ssub,
6267 &AArch64::FPR64RegClass);
6275 ++NumZCRegMoveInstrsFPR;
6279 if (Subtarget.hasZeroCycleRegMoveFPR32())
6280 ++NumZCRegMoveInstrsFPR;
6285 if (AArch64::FPR16RegClass.
contains(DestReg) &&
6286 AArch64::FPR16RegClass.
contains(SrcReg)) {
6287 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
6288 !Subtarget.hasZeroCycleRegMoveFPR64() &&
6289 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
6291 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
6292 &AArch64::FPR128RegClass);
6293 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
6294 &AArch64::FPR128RegClass);
6303 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
6304 !Subtarget.hasZeroCycleRegMoveFPR32()) {
6305 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
6306 &AArch64::FPR64RegClass);
6307 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
6308 &AArch64::FPR64RegClass);
6317 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
6318 &AArch64::FPR32RegClass);
6319 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
6320 &AArch64::FPR32RegClass);
6327 if (AArch64::FPR8RegClass.
contains(DestReg) &&
6328 AArch64::FPR8RegClass.
contains(SrcReg)) {
6329 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
6330 !Subtarget.hasZeroCycleRegMoveFPR64() &&
6331 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
6333 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
6334 &AArch64::FPR128RegClass);
6335 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
6336 &AArch64::FPR128RegClass);
6345 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
6346 !Subtarget.hasZeroCycleRegMoveFPR32()) {
6347 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
6348 &AArch64::FPR64RegClass);
6349 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
6350 &AArch64::FPR64RegClass);
6359 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
6360 &AArch64::FPR32RegClass);
6361 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
6362 &AArch64::FPR32RegClass);
6370 if (AArch64::FPR64RegClass.
contains(DestReg) &&
6371 AArch64::GPR64RegClass.
contains(SrcReg)) {
6372 if (AArch64::XZR == SrcReg) {
6380 if (AArch64::GPR64RegClass.
contains(DestReg) &&
6381 AArch64::FPR64RegClass.
contains(SrcReg)) {
6387 if (AArch64::FPR32RegClass.
contains(DestReg) &&
6388 AArch64::GPR32RegClass.
contains(SrcReg)) {
6389 if (AArch64::WZR == SrcReg) {
6397 if (AArch64::GPR32RegClass.
contains(DestReg) &&
6398 AArch64::FPR32RegClass.
contains(SrcReg)) {
6404 if (DestReg == AArch64::NZCV) {
6405 assert(AArch64::GPR64RegClass.
contains(SrcReg) &&
"Invalid NZCV copy");
6407 .
addImm(AArch64SysReg::NZCV)
6413 if (SrcReg == AArch64::NZCV) {
6414 assert(AArch64::GPR64RegClass.
contains(DestReg) &&
"Invalid NZCV copy");
6416 .
addImm(AArch64SysReg::NZCV)
6422 errs() << RI.getRegAsmName(DestReg) <<
" = COPY " << RI.getRegAsmName(SrcReg)
6433 bool RenamableSrc)
const {
6445 unsigned SubIdx0,
unsigned SubIdx1,
int FI,
6450 SrcReg0 =
TRI.getSubReg(SrcReg, SubIdx0);
6452 SrcReg1 =
TRI.getSubReg(SrcReg, SubIdx1);
6465 Register SrcReg,
bool isKill,
int FI,
6480 switch (RI.getSpillSize(*RC)) {
6482 if (AArch64::FPR8RegClass.hasSubClassEq(RC))
6483 Opc = AArch64::STRBui;
6486 if (AArch64::FPR16RegClass.hasSubClassEq(RC))
6487 Opc = AArch64::STRHui;
6488 else if (AArch64::PNRRegClass.hasSubClassEq(RC) ||
6489 AArch64::PPRRegClass.hasSubClassEq(RC)) {
6490 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6491 "Unexpected register store without SVE store instructions");
6492 Opc = AArch64::STR_PXI;
6498 if (AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
6499 Opc = AArch64::STRWui;
6503 assert(SrcReg != AArch64::WSP);
6504 }
else if (AArch64::FPR32RegClass.hasSubClassEq(RC))
6505 Opc = AArch64::STRSui;
6506 else if (AArch64::PPR2RegClass.hasSubClassEq(RC)) {
6507 Opc = AArch64::STR_PPXI;
6512 if (AArch64::GPR64allRegClass.hasSubClassEq(RC)) {
6513 Opc = AArch64::STRXui;
6517 assert(SrcReg != AArch64::SP);
6518 }
else if (AArch64::FPR64RegClass.hasSubClassEq(RC)) {
6519 Opc = AArch64::STRDui;
6520 }
else if (AArch64::WSeqPairsClassRegClass.hasSubClassEq(RC)) {
6522 get(AArch64::STPWi), SrcReg, isKill,
6523 AArch64::sube32, AArch64::subo32, FI, MMO);
6528 if (AArch64::FPR128RegClass.hasSubClassEq(RC))
6529 Opc = AArch64::STRQui;
6530 else if (AArch64::DDRegClass.hasSubClassEq(RC)) {
6531 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6532 Opc = AArch64::ST1Twov1d;
6534 }
else if (AArch64::XSeqPairsClassRegClass.hasSubClassEq(RC)) {
6536 get(AArch64::STPXi), SrcReg, isKill,
6537 AArch64::sube64, AArch64::subo64, FI, MMO);
6539 }
else if (AArch64::ZPRRegClass.hasSubClassEq(RC)) {
6540 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6541 "Unexpected register store without SVE store instructions");
6542 Opc = AArch64::STR_ZXI;
6547 if (AArch64::DDDRegClass.hasSubClassEq(RC)) {
6548 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6549 Opc = AArch64::ST1Threev1d;
6554 if (AArch64::DDDDRegClass.hasSubClassEq(RC)) {
6555 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6556 Opc = AArch64::ST1Fourv1d;
6558 }
else if (AArch64::QQRegClass.hasSubClassEq(RC)) {
6559 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6560 Opc = AArch64::ST1Twov2d;
6562 }
else if (AArch64::ZPR2StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6563 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6564 "Unexpected register store without SVE store instructions");
6565 Opc = AArch64::STR_ZZXI_STRIDED_CONTIGUOUS;
6567 }
else if (AArch64::ZPR2RegClass.hasSubClassEq(RC)) {
6568 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6569 "Unexpected register store without SVE store instructions");
6570 Opc = AArch64::STR_ZZXI;
6575 if (AArch64::QQQRegClass.hasSubClassEq(RC)) {
6576 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6577 Opc = AArch64::ST1Threev2d;
6579 }
else if (AArch64::ZPR3RegClass.hasSubClassEq(RC)) {
6580 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6581 "Unexpected register store without SVE store instructions");
6582 Opc = AArch64::STR_ZZZXI;
6587 if (AArch64::QQQQRegClass.hasSubClassEq(RC)) {
6588 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6589 Opc = AArch64::ST1Fourv2d;
6591 }
else if (AArch64::ZPR4StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6592 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6593 "Unexpected register store without SVE store instructions");
6594 Opc = AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS;
6596 }
else if (AArch64::ZPR4RegClass.hasSubClassEq(RC)) {
6597 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6598 "Unexpected register store without SVE store instructions");
6599 Opc = AArch64::STR_ZZZZXI;
6604 assert(
Opc &&
"Unknown register class");
6615 MI.addMemOperand(MMO);
6622 Register DestReg,
unsigned SubIdx0,
6623 unsigned SubIdx1,
int FI,
6627 bool IsUndef =
true;
6629 DestReg0 =
TRI.getSubReg(DestReg, SubIdx0);
6631 DestReg1 =
TRI.getSubReg(DestReg, SubIdx1);
6660 switch (
TRI.getSpillSize(*RC)) {
6662 if (AArch64::FPR8RegClass.hasSubClassEq(RC))
6663 Opc = AArch64::LDRBui;
6666 bool IsPNR = AArch64::PNRRegClass.hasSubClassEq(RC);
6667 if (AArch64::FPR16RegClass.hasSubClassEq(RC))
6668 Opc = AArch64::LDRHui;
6669 else if (IsPNR || AArch64::PPRRegClass.hasSubClassEq(RC)) {
6670 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6671 "Unexpected register load without SVE load instructions");
6674 Opc = AArch64::LDR_PXI;
6680 if (AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
6681 Opc = AArch64::LDRWui;
6685 assert(DestReg != AArch64::WSP);
6686 }
else if (AArch64::FPR32RegClass.hasSubClassEq(RC))
6687 Opc = AArch64::LDRSui;
6688 else if (AArch64::PPR2RegClass.hasSubClassEq(RC)) {
6689 Opc = AArch64::LDR_PPXI;
6694 if (AArch64::GPR64allRegClass.hasSubClassEq(RC)) {
6695 Opc = AArch64::LDRXui;
6699 assert(DestReg != AArch64::SP);
6700 }
else if (AArch64::FPR64RegClass.hasSubClassEq(RC)) {
6701 Opc = AArch64::LDRDui;
6702 }
else if (AArch64::WSeqPairsClassRegClass.hasSubClassEq(RC)) {
6704 get(AArch64::LDPWi), DestReg, AArch64::sube32,
6705 AArch64::subo32, FI, MMO);
6710 if (AArch64::FPR128RegClass.hasSubClassEq(RC))
6711 Opc = AArch64::LDRQui;
6712 else if (AArch64::DDRegClass.hasSubClassEq(RC)) {
6713 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6714 Opc = AArch64::LD1Twov1d;
6716 }
else if (AArch64::XSeqPairsClassRegClass.hasSubClassEq(RC)) {
6718 get(AArch64::LDPXi), DestReg, AArch64::sube64,
6719 AArch64::subo64, FI, MMO);
6721 }
else if (AArch64::ZPRRegClass.hasSubClassEq(RC)) {
6722 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6723 "Unexpected register load without SVE load instructions");
6724 Opc = AArch64::LDR_ZXI;
6729 if (AArch64::DDDRegClass.hasSubClassEq(RC)) {
6730 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6731 Opc = AArch64::LD1Threev1d;
6736 if (AArch64::DDDDRegClass.hasSubClassEq(RC)) {
6737 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6738 Opc = AArch64::LD1Fourv1d;
6740 }
else if (AArch64::QQRegClass.hasSubClassEq(RC)) {
6741 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6742 Opc = AArch64::LD1Twov2d;
6744 }
else if (AArch64::ZPR2StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6745 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6746 "Unexpected register load without SVE load instructions");
6747 Opc = AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS;
6749 }
else if (AArch64::ZPR2RegClass.hasSubClassEq(RC)) {
6750 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6751 "Unexpected register load without SVE load instructions");
6752 Opc = AArch64::LDR_ZZXI;
6757 if (AArch64::QQQRegClass.hasSubClassEq(RC)) {
6758 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6759 Opc = AArch64::LD1Threev2d;
6761 }
else if (AArch64::ZPR3RegClass.hasSubClassEq(RC)) {
6762 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6763 "Unexpected register load without SVE load instructions");
6764 Opc = AArch64::LDR_ZZZXI;
6769 if (AArch64::QQQQRegClass.hasSubClassEq(RC)) {
6770 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6771 Opc = AArch64::LD1Fourv2d;
6773 }
else if (AArch64::ZPR4StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6774 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6775 "Unexpected register load without SVE load instructions");
6776 Opc = AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS;
6778 }
else if (AArch64::ZPR4RegClass.hasSubClassEq(RC)) {
6779 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6780 "Unexpected register load without SVE load instructions");
6781 Opc = AArch64::LDR_ZZZZXI;
6787 assert(
Opc &&
"Unknown register class");
6797 MI.addMemOperand(MMO);
6804 UseMI.getIterator()),
6806 return I.modifiesRegister(AArch64::NZCV, TRI) ||
6807 I.readsRegister(AArch64::NZCV, TRI);
6811void AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
6816 assert(
Offset.getScalable() % 2 == 0 &&
"Invalid frame offset");
6823 ByteSized =
Offset.getFixed();
6824 VGSized =
Offset.getScalable() / 2;
6830void AArch64InstrInfo::decomposeStackOffsetForFrameOffsets(
6832 int64_t &NumDataVectors) {
6836 assert(
Offset.getScalable() % 2 == 0 &&
"Invalid frame offset");
6838 NumBytes =
Offset.getFixed();
6840 NumPredicateVectors =
Offset.getScalable() / 2;
6845 if (NumPredicateVectors % 8 == 0 || NumPredicateVectors < -64 ||
6846 NumPredicateVectors > 62) {
6847 NumDataVectors = NumPredicateVectors / 8;
6848 NumPredicateVectors -= NumDataVectors * 8;
6874 Expr.
push_back((
char)dwarf::DW_OP_bregx);
6882 int64_t OffsetFromDefCFA) {
6896 Comment << (NumBytes < 0 ?
" - " :
" + ") << std::abs(NumBytes);
6897 if (!RegScale.empty())
6907 int64_t NumBytes, NumVGScaledBytes;
6908 AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
Offset, NumBytes,
6910 std::string CommentBuffer;
6913 if (
Reg == AArch64::SP)
6915 else if (
Reg == AArch64::FP)
6922 unsigned DwarfReg =
TRI.getDwarfRegNum(
Reg,
true);
6923 assert(DwarfReg <= 31 &&
"DwarfReg out of bounds (0..31)");
6925 Expr.
push_back(dwarf::DW_OP_breg0 + DwarfReg);
6928 if (NumVGScaledBytes) {
6938 DefCfaExpr.
push_back(dwarf::DW_CFA_def_cfa_expression);
6946 unsigned FrameReg,
unsigned Reg,
6948 bool LastAdjustmentWasScalable) {
6949 if (
Offset.getScalable())
6952 if (FrameReg == Reg && !LastAdjustmentWasScalable)
6955 unsigned DwarfReg =
TRI.getDwarfRegNum(Reg,
true);
6962 std::optional<int64_t> IncomingVGOffsetFromDefCFA) {
6963 int64_t NumBytes, NumVGScaledBytes;
6964 AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
6965 OffsetFromDefCFA, NumBytes, NumVGScaledBytes);
6967 unsigned DwarfReg =
TRI.getDwarfRegNum(Reg,
true);
6970 if (!NumVGScaledBytes)
6973 std::string CommentBuffer;
6978 assert(NumVGScaledBytes &&
"Expected scalable offset");
6982 if (IncomingVGOffsetFromDefCFA) {
6984 VGRegScale =
"* IncomingVG";
6987 VGRegScale =
"* VG";
6991 OffsetExpr.
push_back(dwarf::DW_OP_plus);
7000 CfaExpr.
push_back(dwarf::DW_CFA_expression);
7015 unsigned SrcReg, int64_t
Offset,
unsigned Opc,
7018 bool *HasWinCFI,
bool EmitCFAOffset,
7021 unsigned MaxEncoding, ShiftSize;
7023 case AArch64::ADDXri:
7024 case AArch64::ADDSXri:
7025 case AArch64::SUBXri:
7026 case AArch64::SUBSXri:
7027 MaxEncoding = 0xfff;
7030 case AArch64::ADDVL_XXI:
7031 case AArch64::ADDPL_XXI:
7032 case AArch64::ADDSVL_XXI:
7033 case AArch64::ADDSPL_XXI:
7048 if (
Opc == AArch64::ADDVL_XXI ||
Opc == AArch64::ADDSVL_XXI)
7050 else if (
Opc == AArch64::ADDPL_XXI ||
Opc == AArch64::ADDSPL_XXI)
7064 const unsigned MaxEncodableValue = MaxEncoding << ShiftSize;
7066 if (TmpReg == AArch64::XZR)
7067 TmpReg =
MBB.getParent()->getRegInfo().createVirtualRegister(
7068 &AArch64::GPR64RegClass);
7070 uint64_t ThisVal = std::min<uint64_t>(
Offset, MaxEncodableValue);
7071 unsigned LocalShiftSize = 0;
7072 if (ThisVal > MaxEncoding) {
7073 ThisVal = ThisVal >> ShiftSize;
7074 LocalShiftSize = ShiftSize;
7076 assert((ThisVal >> ShiftSize) <= MaxEncoding &&
7077 "Encoding cannot handle value that big");
7079 Offset -= ThisVal << LocalShiftSize;
7084 .
addImm(Sign * (
int)ThisVal);
7094 if (Sign == -1 ||
Opc == AArch64::SUBXri ||
Opc == AArch64::SUBSXri)
7095 CFAOffset += Change;
7097 CFAOffset -= Change;
7098 if (EmitCFAOffset && DestReg == TmpReg) {
7111 int Imm = (int)(ThisVal << LocalShiftSize);
7112 if (VScale != 1 && DestReg == AArch64::SP) {
7118 }
else if ((DestReg == AArch64::FP && SrcReg == AArch64::SP) ||
7119 (SrcReg == AArch64::FP && DestReg == AArch64::SP)) {
7120 assert(VScale == 1 &&
"Expected non-scalable operation");
7129 assert(
Offset == 0 &&
"Expected remaining offset to be zero to "
7130 "emit a single SEH directive");
7131 }
else if (DestReg == AArch64::SP) {
7132 assert(VScale == 1 &&
"Expected non-scalable operation");
7135 assert(SrcReg == AArch64::SP &&
"Unexpected SrcReg for SEH_StackAlloc");
7148 unsigned DestReg,
unsigned SrcReg,
7151 bool NeedsWinCFI,
bool *HasWinCFI,
7153 unsigned FrameReg) {
7160 bool UseSVL =
F.hasFnAttribute(
"aarch64_pstate_sm_body");
7162 int64_t Bytes, NumPredicateVectors, NumDataVectors;
7163 AArch64InstrInfo::decomposeStackOffsetForFrameOffsets(
7164 Offset, Bytes, NumPredicateVectors, NumDataVectors);
7167 bool NeedsFinalDefNZCV = SetNZCV && (NumPredicateVectors || NumDataVectors);
7168 if (NeedsFinalDefNZCV)
7172 if (Bytes || (!
Offset && SrcReg != DestReg)) {
7173 assert((DestReg != AArch64::SP || Bytes % 8 == 0) &&
7174 "SP increment/decrement not 8-byte aligned");
7175 unsigned Opc = SetNZCV ? AArch64::ADDSXri : AArch64::ADDXri;
7178 Opc = SetNZCV ? AArch64::SUBSXri : AArch64::SUBXri;
7181 NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
7183 CFAOffset += (
Opc == AArch64::ADDXri ||
Opc == AArch64::ADDSXri)
7190 assert(!(NeedsWinCFI && NumPredicateVectors) &&
7191 "WinCFI can't allocate fractions of an SVE data vector");
7193 if (NumDataVectors) {
7195 UseSVL ? AArch64::ADDSVL_XXI : AArch64::ADDVL_XXI,
TII,
7196 Flag, NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
7202 if (NumPredicateVectors) {
7203 assert(DestReg != AArch64::SP &&
"Unaligned access to SP");
7205 UseSVL ? AArch64::ADDSPL_XXI : AArch64::ADDPL_XXI,
TII,
7206 Flag, NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
7210 if (NeedsFinalDefNZCV)
7232 if (
MI.isFullCopy()) {
7235 if (SrcReg == AArch64::SP && DstReg.
isVirtual()) {
7239 if (DstReg == AArch64::SP && SrcReg.
isVirtual()) {
7244 if (SrcReg == AArch64::NZCV || DstReg == AArch64::NZCV)
7272 if (
MI.isCopy() &&
Ops.size() == 1 &&
7274 (
Ops[0] == 0 ||
Ops[0] == 1)) {
7275 bool IsSpill =
Ops[0] == 0;
7276 bool IsFill = !IsSpill;
7288 :
TRI.getMinimalPhysRegClass(Reg);
7294 "Mismatched register size in non subreg COPY");
7301 return &*--InsertPt;
7313 if (IsSpill && DstMO.
isUndef() && SrcReg == AArch64::WZR &&
7316 "Unexpected subreg on physical register");
7318 FrameIndex, &AArch64::GPR64RegClass,
Register());
7319 return &*--InsertPt;
7336 case AArch64::sub_32:
7337 if (AArch64::GPR64RegClass.hasSubClassEq(
getRegClass(DstReg)))
7338 FillRC = &AArch64::GPR32RegClass;
7341 FillRC = &AArch64::FPR32RegClass;
7344 FillRC = &AArch64::FPR64RegClass;
7350 TRI.getRegSizeInBits(*FillRC) &&
7351 "Mismatched regclass size on folded subreg COPY");
7370 bool *OutUseUnscaledOp,
7371 unsigned *OutUnscaledOp,
7372 int64_t *EmittableOffset) {
7374 if (EmittableOffset)
7375 *EmittableOffset = 0;
7376 if (OutUseUnscaledOp)
7377 *OutUseUnscaledOp =
false;
7383 switch (
MI.getOpcode()) {
7386 case AArch64::LD1Rv1d:
7387 case AArch64::LD1Rv2s:
7388 case AArch64::LD1Rv2d:
7389 case AArch64::LD1Rv4h:
7390 case AArch64::LD1Rv4s:
7391 case AArch64::LD1Rv8b:
7392 case AArch64::LD1Rv8h:
7393 case AArch64::LD1Rv16b:
7394 case AArch64::LD1Twov2d:
7395 case AArch64::LD1Threev2d:
7396 case AArch64::LD1Fourv2d:
7397 case AArch64::LD1Twov1d:
7398 case AArch64::LD1Threev1d:
7399 case AArch64::LD1Fourv1d:
7400 case AArch64::ST1Twov2d:
7401 case AArch64::ST1Threev2d:
7402 case AArch64::ST1Fourv2d:
7403 case AArch64::ST1Twov1d:
7404 case AArch64::ST1Threev1d:
7405 case AArch64::ST1Fourv1d:
7406 case AArch64::ST1i8:
7407 case AArch64::ST1i16:
7408 case AArch64::ST1i32:
7409 case AArch64::ST1i64:
7411 case AArch64::IRGstack:
7412 case AArch64::STGloop:
7413 case AArch64::STZGloop:
7418 TypeSize ScaleValue(0U,
false), Width(0U,
false);
7419 int64_t MinOff, MaxOff;
7425 bool IsMulVL = ScaleValue.isScalable();
7426 unsigned Scale = ScaleValue.getKnownMinValue();
7436 std::optional<unsigned> UnscaledOp =
7438 bool useUnscaledOp = UnscaledOp && (
Offset % Scale ||
Offset < 0);
7439 if (useUnscaledOp &&
7444 Scale = ScaleValue.getKnownMinValue();
7445 assert(IsMulVL == ScaleValue.isScalable() &&
7446 "Unscaled opcode has different value for scalable");
7448 int64_t Remainder =
Offset % Scale;
7449 assert(!(Remainder && useUnscaledOp) &&
7450 "Cannot have remainder when using unscaled op");
7452 assert(MinOff < MaxOff &&
"Unexpected Min/Max offsets");
7453 int64_t NewOffset =
Offset / Scale;
7454 if (MinOff <= NewOffset && NewOffset <= MaxOff)
7462 int64_t HighPart =
Offset & ~0xFFF;
7463 int64_t LowPart =
Offset & 0xFFF;
7464 int64_t LowScaled = LowPart / Scale;
7465 if (!IsMulVL && NewOffset >= 0 && LowPart % Scale == 0 &&
7466 MinOff <= LowScaled && LowScaled <= MaxOff &&
7468 NewOffset = LowScaled;
7473 NewOffset = NewOffset < 0 ? MinOff : MaxOff;
7478 if (EmittableOffset)
7479 *EmittableOffset = NewOffset;
7480 if (OutUseUnscaledOp)
7481 *OutUseUnscaledOp = useUnscaledOp;
7482 if (OutUnscaledOp && UnscaledOp)
7483 *OutUnscaledOp = *UnscaledOp;
7496 unsigned Opcode =
MI.getOpcode();
7497 unsigned ImmIdx = FrameRegIdx + 1;
7499 if (Opcode == AArch64::ADDSXri || Opcode == AArch64::ADDXri) {
7504 MI.eraseFromParent();
7510 unsigned UnscaledOp;
7513 &UnscaledOp, &NewOffset);
7517 MI.getOperand(FrameRegIdx).ChangeToRegister(FrameReg,
false);
7519 MI.setDesc(
TII->get(UnscaledOp));
7521 MI.getOperand(ImmIdx).ChangeToImmediate(NewOffset);
7537bool AArch64InstrInfo::useMachineCombiner()
const {
return true; }
7542 case AArch64::ADDSWrr:
7543 case AArch64::ADDSWri:
7544 case AArch64::ADDSXrr:
7545 case AArch64::ADDSXri:
7546 case AArch64::SUBSWrr:
7547 case AArch64::SUBSXrr:
7549 case AArch64::SUBSWri:
7550 case AArch64::SUBSXri:
7561 case AArch64::ADDWrr:
7562 case AArch64::ADDWri:
7563 case AArch64::SUBWrr:
7564 case AArch64::ADDSWrr:
7565 case AArch64::ADDSWri:
7566 case AArch64::SUBSWrr:
7568 case AArch64::SUBWri:
7569 case AArch64::SUBSWri:
7580 case AArch64::ADDXrr:
7581 case AArch64::ADDXri:
7582 case AArch64::SUBXrr:
7583 case AArch64::ADDSXrr:
7584 case AArch64::ADDSXri:
7585 case AArch64::SUBSXrr:
7587 case AArch64::SUBXri:
7588 case AArch64::SUBSXri:
7589 case AArch64::ADDv8i8:
7590 case AArch64::ADDv16i8:
7591 case AArch64::ADDv4i16:
7592 case AArch64::ADDv8i16:
7593 case AArch64::ADDv2i32:
7594 case AArch64::ADDv4i32:
7595 case AArch64::SUBv8i8:
7596 case AArch64::SUBv16i8:
7597 case AArch64::SUBv4i16:
7598 case AArch64::SUBv8i16:
7599 case AArch64::SUBv2i32:
7600 case AArch64::SUBv4i32:
7613 case AArch64::FADDHrr:
7614 case AArch64::FADDSrr:
7615 case AArch64::FADDDrr:
7616 case AArch64::FADDv4f16:
7617 case AArch64::FADDv8f16:
7618 case AArch64::FADDv2f32:
7619 case AArch64::FADDv2f64:
7620 case AArch64::FADDv4f32:
7621 case AArch64::FSUBHrr:
7622 case AArch64::FSUBSrr:
7623 case AArch64::FSUBDrr:
7624 case AArch64::FSUBv4f16:
7625 case AArch64::FSUBv8f16:
7626 case AArch64::FSUBv2f32:
7627 case AArch64::FSUBv2f64:
7628 case AArch64::FSUBv4f32:
7645 unsigned CombineOpc,
unsigned ZeroReg = 0,
7646 bool CheckZeroReg =
false) {
7653 if (!
MI ||
MI->getParent() != &
MBB ||
MI->getOpcode() != CombineOpc)
7660 assert(
MI->getNumOperands() >= 4 &&
MI->getOperand(0).isReg() &&
7661 MI->getOperand(1).isReg() &&
MI->getOperand(2).isReg() &&
7662 MI->getOperand(3).isReg() &&
"MAdd/MSub must have a least 4 regs");
7664 if (
MI->getOperand(3).getReg() != ZeroReg)
7669 MI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
true) == -1)
7678 unsigned MulOpc,
unsigned ZeroReg) {
7693bool AArch64InstrInfo::isAssociativeAndCommutative(
const MachineInstr &Inst,
7694 bool Invert)
const {
7700 case AArch64::FADDHrr:
7701 case AArch64::FADDSrr:
7702 case AArch64::FADDDrr:
7703 case AArch64::FMULHrr:
7704 case AArch64::FMULSrr:
7705 case AArch64::FMULDrr:
7706 case AArch64::FMULX16:
7707 case AArch64::FMULX32:
7708 case AArch64::FMULX64:
7710 case AArch64::FADDv4f16:
7711 case AArch64::FADDv8f16:
7712 case AArch64::FADDv2f32:
7713 case AArch64::FADDv4f32:
7714 case AArch64::FADDv2f64:
7715 case AArch64::FMULv4f16:
7716 case AArch64::FMULv8f16:
7717 case AArch64::FMULv2f32:
7718 case AArch64::FMULv4f32:
7719 case AArch64::FMULv2f64:
7720 case AArch64::FMULXv4f16:
7721 case AArch64::FMULXv8f16:
7722 case AArch64::FMULXv2f32:
7723 case AArch64::FMULXv4f32:
7724 case AArch64::FMULXv2f64:
7728 case AArch64::FADD_ZZZ_H:
7729 case AArch64::FADD_ZZZ_S:
7730 case AArch64::FADD_ZZZ_D:
7731 case AArch64::FMUL_ZZZ_H:
7732 case AArch64::FMUL_ZZZ_S:
7733 case AArch64::FMUL_ZZZ_D:
7744 case AArch64::ADDWrr:
7745 case AArch64::ADDXrr:
7746 case AArch64::ANDWrr:
7747 case AArch64::ANDXrr:
7748 case AArch64::ORRWrr:
7749 case AArch64::ORRXrr:
7750 case AArch64::EORWrr:
7751 case AArch64::EORXrr:
7752 case AArch64::EONWrr:
7753 case AArch64::EONXrr:
7757 case AArch64::ADDv8i8:
7758 case AArch64::ADDv16i8:
7759 case AArch64::ADDv4i16:
7760 case AArch64::ADDv8i16:
7761 case AArch64::ADDv2i32:
7762 case AArch64::ADDv4i32:
7763 case AArch64::ADDv1i64:
7764 case AArch64::ADDv2i64:
7765 case AArch64::MULv8i8:
7766 case AArch64::MULv16i8:
7767 case AArch64::MULv4i16:
7768 case AArch64::MULv8i16:
7769 case AArch64::MULv2i32:
7770 case AArch64::MULv4i32:
7771 case AArch64::ANDv8i8:
7772 case AArch64::ANDv16i8:
7773 case AArch64::ORRv8i8:
7774 case AArch64::ORRv16i8:
7775 case AArch64::EORv8i8:
7776 case AArch64::EORv16i8:
7778 case AArch64::ADD_ZZZ_B:
7779 case AArch64::ADD_ZZZ_H:
7780 case AArch64::ADD_ZZZ_S:
7781 case AArch64::ADD_ZZZ_D:
7782 case AArch64::MUL_ZZZ_B:
7783 case AArch64::MUL_ZZZ_H:
7784 case AArch64::MUL_ZZZ_S:
7785 case AArch64::MUL_ZZZ_D:
7786 case AArch64::AND_ZZZ:
7787 case AArch64::ORR_ZZZ:
7788 case AArch64::EOR_ZZZ:
7819 auto setFound = [&](
int Opcode,
int Operand,
unsigned ZeroReg,
7827 auto setVFound = [&](
int Opcode,
int Operand,
unsigned Pattern) {
7839 case AArch64::ADDWrr:
7841 "ADDWrr does not have register operands");
7842 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULADDW_OP1);
7843 setFound(AArch64::MADDWrrr, 2, AArch64::WZR, MCP::MULADDW_OP2);
7845 case AArch64::ADDXrr:
7846 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULADDX_OP1);
7847 setFound(AArch64::MADDXrrr, 2, AArch64::XZR, MCP::MULADDX_OP2);
7849 case AArch64::SUBWrr:
7850 setFound(AArch64::MADDWrrr, 2, AArch64::WZR, MCP::MULSUBW_OP2);
7851 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULSUBW_OP1);
7853 case AArch64::SUBXrr:
7854 setFound(AArch64::MADDXrrr, 2, AArch64::XZR, MCP::MULSUBX_OP2);
7855 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULSUBX_OP1);
7857 case AArch64::ADDWri:
7858 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULADDWI_OP1);
7860 case AArch64::ADDXri:
7861 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULADDXI_OP1);
7863 case AArch64::SUBWri:
7864 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULSUBWI_OP1);
7866 case AArch64::SUBXri:
7867 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULSUBXI_OP1);
7869 case AArch64::ADDv8i8:
7870 setVFound(AArch64::MULv8i8, 1, MCP::MULADDv8i8_OP1);
7871 setVFound(AArch64::MULv8i8, 2, MCP::MULADDv8i8_OP2);
7873 case AArch64::ADDv16i8:
7874 setVFound(AArch64::MULv16i8, 1, MCP::MULADDv16i8_OP1);
7875 setVFound(AArch64::MULv16i8, 2, MCP::MULADDv16i8_OP2);
7877 case AArch64::ADDv4i16:
7878 setVFound(AArch64::MULv4i16, 1, MCP::MULADDv4i16_OP1);
7879 setVFound(AArch64::MULv4i16, 2, MCP::MULADDv4i16_OP2);
7880 setVFound(AArch64::MULv4i16_indexed, 1, MCP::MULADDv4i16_indexed_OP1);
7881 setVFound(AArch64::MULv4i16_indexed, 2, MCP::MULADDv4i16_indexed_OP2);
7883 case AArch64::ADDv8i16:
7884 setVFound(AArch64::MULv8i16, 1, MCP::MULADDv8i16_OP1);
7885 setVFound(AArch64::MULv8i16, 2, MCP::MULADDv8i16_OP2);
7886 setVFound(AArch64::MULv8i16_indexed, 1, MCP::MULADDv8i16_indexed_OP1);
7887 setVFound(AArch64::MULv8i16_indexed, 2, MCP::MULADDv8i16_indexed_OP2);
7889 case AArch64::ADDv2i32:
7890 setVFound(AArch64::MULv2i32, 1, MCP::MULADDv2i32_OP1);
7891 setVFound(AArch64::MULv2i32, 2, MCP::MULADDv2i32_OP2);
7892 setVFound(AArch64::MULv2i32_indexed, 1, MCP::MULADDv2i32_indexed_OP1);
7893 setVFound(AArch64::MULv2i32_indexed, 2, MCP::MULADDv2i32_indexed_OP2);
7895 case AArch64::ADDv4i32:
7896 setVFound(AArch64::MULv4i32, 1, MCP::MULADDv4i32_OP1);
7897 setVFound(AArch64::MULv4i32, 2, MCP::MULADDv4i32_OP2);
7898 setVFound(AArch64::MULv4i32_indexed, 1, MCP::MULADDv4i32_indexed_OP1);
7899 setVFound(AArch64::MULv4i32_indexed, 2, MCP::MULADDv4i32_indexed_OP2);
7901 case AArch64::SUBv8i8:
7902 setVFound(AArch64::MULv8i8, 1, MCP::MULSUBv8i8_OP1);
7903 setVFound(AArch64::MULv8i8, 2, MCP::MULSUBv8i8_OP2);
7905 case AArch64::SUBv16i8:
7906 setVFound(AArch64::MULv16i8, 1, MCP::MULSUBv16i8_OP1);
7907 setVFound(AArch64::MULv16i8, 2, MCP::MULSUBv16i8_OP2);
7909 case AArch64::SUBv4i16:
7910 setVFound(AArch64::MULv4i16, 1, MCP::MULSUBv4i16_OP1);
7911 setVFound(AArch64::MULv4i16, 2, MCP::MULSUBv4i16_OP2);
7912 setVFound(AArch64::MULv4i16_indexed, 1, MCP::MULSUBv4i16_indexed_OP1);
7913 setVFound(AArch64::MULv4i16_indexed, 2, MCP::MULSUBv4i16_indexed_OP2);
7915 case AArch64::SUBv8i16:
7916 setVFound(AArch64::MULv8i16, 1, MCP::MULSUBv8i16_OP1);
7917 setVFound(AArch64::MULv8i16, 2, MCP::MULSUBv8i16_OP2);
7918 setVFound(AArch64::MULv8i16_indexed, 1, MCP::MULSUBv8i16_indexed_OP1);
7919 setVFound(AArch64::MULv8i16_indexed, 2, MCP::MULSUBv8i16_indexed_OP2);
7921 case AArch64::SUBv2i32:
7922 setVFound(AArch64::MULv2i32, 1, MCP::MULSUBv2i32_OP1);
7923 setVFound(AArch64::MULv2i32, 2, MCP::MULSUBv2i32_OP2);
7924 setVFound(AArch64::MULv2i32_indexed, 1, MCP::MULSUBv2i32_indexed_OP1);
7925 setVFound(AArch64::MULv2i32_indexed, 2, MCP::MULSUBv2i32_indexed_OP2);
7927 case AArch64::SUBv4i32:
7928 setVFound(AArch64::MULv4i32, 1, MCP::MULSUBv4i32_OP1);
7929 setVFound(AArch64::MULv4i32, 2, MCP::MULSUBv4i32_OP2);
7930 setVFound(AArch64::MULv4i32_indexed, 1, MCP::MULSUBv4i32_indexed_OP1);
7931 setVFound(AArch64::MULv4i32_indexed, 2, MCP::MULSUBv4i32_indexed_OP2);
7937bool AArch64InstrInfo::isAccumulationOpcode(
unsigned Opcode)
const {
7941 case AArch64::UABALB_ZZZ_D:
7942 case AArch64::UABALB_ZZZ_H:
7943 case AArch64::UABALB_ZZZ_S:
7944 case AArch64::UABALT_ZZZ_D:
7945 case AArch64::UABALT_ZZZ_H:
7946 case AArch64::UABALT_ZZZ_S:
7947 case AArch64::SABALB_ZZZ_D:
7948 case AArch64::SABALB_ZZZ_S:
7949 case AArch64::SABALB_ZZZ_H:
7950 case AArch64::SABALT_ZZZ_D:
7951 case AArch64::SABALT_ZZZ_S:
7952 case AArch64::SABALT_ZZZ_H:
7953 case AArch64::UABALv16i8_v8i16:
7954 case AArch64::UABALv2i32_v2i64:
7955 case AArch64::UABALv4i16_v4i32:
7956 case AArch64::UABALv4i32_v2i64:
7957 case AArch64::UABALv8i16_v4i32:
7958 case AArch64::UABALv8i8_v8i16:
7959 case AArch64::UABAv16i8:
7960 case AArch64::UABAv2i32:
7961 case AArch64::UABAv4i16:
7962 case AArch64::UABAv4i32:
7963 case AArch64::UABAv8i16:
7964 case AArch64::UABAv8i8:
7965 case AArch64::SABALv16i8_v8i16:
7966 case AArch64::SABALv2i32_v2i64:
7967 case AArch64::SABALv4i16_v4i32:
7968 case AArch64::SABALv4i32_v2i64:
7969 case AArch64::SABALv8i16_v4i32:
7970 case AArch64::SABALv8i8_v8i16:
7971 case AArch64::SABAv16i8:
7972 case AArch64::SABAv2i32:
7973 case AArch64::SABAv4i16:
7974 case AArch64::SABAv4i32:
7975 case AArch64::SABAv8i16:
7976 case AArch64::SABAv8i8:
7983unsigned AArch64InstrInfo::getAccumulationStartOpcode(
7984 unsigned AccumulationOpcode)
const {
7985 switch (AccumulationOpcode) {
7988 case AArch64::UABALB_ZZZ_D:
7989 return AArch64::UABDLB_ZZZ_D;
7990 case AArch64::UABALB_ZZZ_H:
7991 return AArch64::UABDLB_ZZZ_H;
7992 case AArch64::UABALB_ZZZ_S:
7993 return AArch64::UABDLB_ZZZ_S;
7994 case AArch64::UABALT_ZZZ_D:
7995 return AArch64::UABDLT_ZZZ_D;
7996 case AArch64::UABALT_ZZZ_H:
7997 return AArch64::UABDLT_ZZZ_H;
7998 case AArch64::UABALT_ZZZ_S:
7999 return AArch64::UABDLT_ZZZ_S;
8000 case AArch64::UABALv16i8_v8i16:
8001 return AArch64::UABDLv16i8_v8i16;
8002 case AArch64::UABALv2i32_v2i64:
8003 return AArch64::UABDLv2i32_v2i64;
8004 case AArch64::UABALv4i16_v4i32:
8005 return AArch64::UABDLv4i16_v4i32;
8006 case AArch64::UABALv4i32_v2i64:
8007 return AArch64::UABDLv4i32_v2i64;
8008 case AArch64::UABALv8i16_v4i32:
8009 return AArch64::UABDLv8i16_v4i32;
8010 case AArch64::UABALv8i8_v8i16:
8011 return AArch64::UABDLv8i8_v8i16;
8012 case AArch64::UABAv16i8:
8013 return AArch64::UABDv16i8;
8014 case AArch64::UABAv2i32:
8015 return AArch64::UABDv2i32;
8016 case AArch64::UABAv4i16:
8017 return AArch64::UABDv4i16;
8018 case AArch64::UABAv4i32:
8019 return AArch64::UABDv4i32;
8020 case AArch64::UABAv8i16:
8021 return AArch64::UABDv8i16;
8022 case AArch64::UABAv8i8:
8023 return AArch64::UABDv8i8;
8024 case AArch64::SABALB_ZZZ_D:
8025 return AArch64::SABDLB_ZZZ_D;
8026 case AArch64::SABALB_ZZZ_S:
8027 return AArch64::SABDLB_ZZZ_S;
8028 case AArch64::SABALB_ZZZ_H:
8029 return AArch64::SABDLB_ZZZ_H;
8030 case AArch64::SABALT_ZZZ_D:
8031 return AArch64::SABDLT_ZZZ_D;
8032 case AArch64::SABALT_ZZZ_S:
8033 return AArch64::SABDLT_ZZZ_S;
8034 case AArch64::SABALT_ZZZ_H:
8035 return AArch64::SABDLT_ZZZ_H;
8036 case AArch64::SABALv16i8_v8i16:
8037 return AArch64::SABDLv16i8_v8i16;
8038 case AArch64::SABALv2i32_v2i64:
8039 return AArch64::SABDLv2i32_v2i64;
8040 case AArch64::SABALv4i16_v4i32:
8041 return AArch64::SABDLv4i16_v4i32;
8042 case AArch64::SABALv4i32_v2i64:
8043 return AArch64::SABDLv4i32_v2i64;
8044 case AArch64::SABALv8i16_v4i32:
8045 return AArch64::SABDLv8i16_v4i32;
8046 case AArch64::SABALv8i8_v8i16:
8047 return AArch64::SABDLv8i8_v8i16;
8048 case AArch64::SABAv16i8:
8049 return AArch64::SABDv16i8;
8050 case AArch64::SABAv2i32:
8051 return AArch64::SABDv2i32;
8052 case AArch64::SABAv4i16:
8053 return AArch64::SABDv4i16;
8054 case AArch64::SABAv4i32:
8055 return AArch64::SABDv4i32;
8056 case AArch64::SABAv8i16:
8057 return AArch64::SABDv8i16;
8058 case AArch64::SABAv8i8:
8059 return AArch64::SABDv8i8;
8075 auto Match = [&](
int Opcode,
int Operand,
unsigned Pattern) ->
bool {
8087 assert(
false &&
"Unsupported FP instruction in combiner\n");
8089 case AArch64::FADDHrr:
8091 "FADDHrr does not have register operands");
8093 Found = Match(AArch64::FMULHrr, 1, MCP::FMULADDH_OP1);
8094 Found |= Match(AArch64::FMULHrr, 2, MCP::FMULADDH_OP2);
8096 case AArch64::FADDSrr:
8098 "FADDSrr does not have register operands");
8100 Found |= Match(AArch64::FMULSrr, 1, MCP::FMULADDS_OP1) ||
8101 Match(AArch64::FMULv1i32_indexed, 1, MCP::FMLAv1i32_indexed_OP1);
8103 Found |= Match(AArch64::FMULSrr, 2, MCP::FMULADDS_OP2) ||
8104 Match(AArch64::FMULv1i32_indexed, 2, MCP::FMLAv1i32_indexed_OP2);
8106 case AArch64::FADDDrr:
8107 Found |= Match(AArch64::FMULDrr, 1, MCP::FMULADDD_OP1) ||
8108 Match(AArch64::FMULv1i64_indexed, 1, MCP::FMLAv1i64_indexed_OP1);
8110 Found |= Match(AArch64::FMULDrr, 2, MCP::FMULADDD_OP2) ||
8111 Match(AArch64::FMULv1i64_indexed, 2, MCP::FMLAv1i64_indexed_OP2);
8113 case AArch64::FADDv4f16:
8114 Found |= Match(AArch64::FMULv4i16_indexed, 1, MCP::FMLAv4i16_indexed_OP1) ||
8115 Match(AArch64::FMULv4f16, 1, MCP::FMLAv4f16_OP1);
8117 Found |= Match(AArch64::FMULv4i16_indexed, 2, MCP::FMLAv4i16_indexed_OP2) ||
8118 Match(AArch64::FMULv4f16, 2, MCP::FMLAv4f16_OP2);
8120 case AArch64::FADDv8f16:
8121 Found |= Match(AArch64::FMULv8i16_indexed, 1, MCP::FMLAv8i16_indexed_OP1) ||
8122 Match(AArch64::FMULv8f16, 1, MCP::FMLAv8f16_OP1);
8124 Found |= Match(AArch64::FMULv8i16_indexed, 2, MCP::FMLAv8i16_indexed_OP2) ||
8125 Match(AArch64::FMULv8f16, 2, MCP::FMLAv8f16_OP2);
8127 case AArch64::FADDv2f32:
8128 Found |= Match(AArch64::FMULv2i32_indexed, 1, MCP::FMLAv2i32_indexed_OP1) ||
8129 Match(AArch64::FMULv2f32, 1, MCP::FMLAv2f32_OP1);
8131 Found |= Match(AArch64::FMULv2i32_indexed, 2, MCP::FMLAv2i32_indexed_OP2) ||
8132 Match(AArch64::FMULv2f32, 2, MCP::FMLAv2f32_OP2);
8134 case AArch64::FADDv2f64:
8135 Found |= Match(AArch64::FMULv2i64_indexed, 1, MCP::FMLAv2i64_indexed_OP1) ||
8136 Match(AArch64::FMULv2f64, 1, MCP::FMLAv2f64_OP1);
8138 Found |= Match(AArch64::FMULv2i64_indexed, 2, MCP::FMLAv2i64_indexed_OP2) ||
8139 Match(AArch64::FMULv2f64, 2, MCP::FMLAv2f64_OP2);
8141 case AArch64::FADDv4f32:
8142 Found |= Match(AArch64::FMULv4i32_indexed, 1, MCP::FMLAv4i32_indexed_OP1) ||
8143 Match(AArch64::FMULv4f32, 1, MCP::FMLAv4f32_OP1);
8145 Found |= Match(AArch64::FMULv4i32_indexed, 2, MCP::FMLAv4i32_indexed_OP2) ||
8146 Match(AArch64::FMULv4f32, 2, MCP::FMLAv4f32_OP2);
8148 case AArch64::FSUBHrr:
8149 Found = Match(AArch64::FMULHrr, 1, MCP::FMULSUBH_OP1);
8150 Found |= Match(AArch64::FMULHrr, 2, MCP::FMULSUBH_OP2);
8151 Found |= Match(AArch64::FNMULHrr, 1, MCP::FNMULSUBH_OP1);
8153 case AArch64::FSUBSrr:
8154 Found = Match(AArch64::FMULSrr, 1, MCP::FMULSUBS_OP1);
8156 Found |= Match(AArch64::FMULSrr, 2, MCP::FMULSUBS_OP2) ||
8157 Match(AArch64::FMULv1i32_indexed, 2, MCP::FMLSv1i32_indexed_OP2);
8159 Found |= Match(AArch64::FNMULSrr, 1, MCP::FNMULSUBS_OP1);
8161 case AArch64::FSUBDrr:
8162 Found = Match(AArch64::FMULDrr, 1, MCP::FMULSUBD_OP1);
8164 Found |= Match(AArch64::FMULDrr, 2, MCP::FMULSUBD_OP2) ||
8165 Match(AArch64::FMULv1i64_indexed, 2, MCP::FMLSv1i64_indexed_OP2);
8167 Found |= Match(AArch64::FNMULDrr, 1, MCP::FNMULSUBD_OP1);
8169 case AArch64::FSUBv4f16:
8170 Found |= Match(AArch64::FMULv4i16_indexed, 2, MCP::FMLSv4i16_indexed_OP2) ||
8171 Match(AArch64::FMULv4f16, 2, MCP::FMLSv4f16_OP2);
8173 Found |= Match(AArch64::FMULv4i16_indexed, 1, MCP::FMLSv4i16_indexed_OP1) ||
8174 Match(AArch64::FMULv4f16, 1, MCP::FMLSv4f16_OP1);
8176 case AArch64::FSUBv8f16:
8177 Found |= Match(AArch64::FMULv8i16_indexed, 2, MCP::FMLSv8i16_indexed_OP2) ||
8178 Match(AArch64::FMULv8f16, 2, MCP::FMLSv8f16_OP2);
8180 Found |= Match(AArch64::FMULv8i16_indexed, 1, MCP::FMLSv8i16_indexed_OP1) ||
8181 Match(AArch64::FMULv8f16, 1, MCP::FMLSv8f16_OP1);
8183 case AArch64::FSUBv2f32:
8184 Found |= Match(AArch64::FMULv2i32_indexed, 2, MCP::FMLSv2i32_indexed_OP2) ||
8185 Match(AArch64::FMULv2f32, 2, MCP::FMLSv2f32_OP2);
8187 Found |= Match(AArch64::FMULv2i32_indexed, 1, MCP::FMLSv2i32_indexed_OP1) ||
8188 Match(AArch64::FMULv2f32, 1, MCP::FMLSv2f32_OP1);
8190 case AArch64::FSUBv2f64:
8191 Found |= Match(AArch64::FMULv2i64_indexed, 2, MCP::FMLSv2i64_indexed_OP2) ||
8192 Match(AArch64::FMULv2f64, 2, MCP::FMLSv2f64_OP2);
8194 Found |= Match(AArch64::FMULv2i64_indexed, 1, MCP::FMLSv2i64_indexed_OP1) ||
8195 Match(AArch64::FMULv2f64, 1, MCP::FMLSv2f64_OP1);
8197 case AArch64::FSUBv4f32:
8198 Found |= Match(AArch64::FMULv4i32_indexed, 2, MCP::FMLSv4i32_indexed_OP2) ||
8199 Match(AArch64::FMULv4f32, 2, MCP::FMLSv4f32_OP2);
8201 Found |= Match(AArch64::FMULv4i32_indexed, 1, MCP::FMLSv4i32_indexed_OP1) ||
8202 Match(AArch64::FMULv4f32, 1, MCP::FMLSv4f32_OP1);
8213 auto Match = [&](
unsigned Opcode,
int Operand,
unsigned Pattern) ->
bool {
8220 if (
MI &&
MI->getOpcode() == TargetOpcode::COPY &&
8221 MI->getOperand(1).getReg().isVirtual())
8223 if (
MI &&
MI->getOpcode() == Opcode) {
8235 case AArch64::FMULv2f32:
8236 Found = Match(AArch64::DUPv2i32lane, 1, MCP::FMULv2i32_indexed_OP1);
8237 Found |= Match(AArch64::DUPv2i32lane, 2, MCP::FMULv2i32_indexed_OP2);
8239 case AArch64::FMULv2f64:
8240 Found = Match(AArch64::DUPv2i64lane, 1, MCP::FMULv2i64_indexed_OP1);
8241 Found |= Match(AArch64::DUPv2i64lane, 2, MCP::FMULv2i64_indexed_OP2);
8243 case AArch64::FMULv4f16:
8244 Found = Match(AArch64::DUPv4i16lane, 1, MCP::FMULv4i16_indexed_OP1);
8245 Found |= Match(AArch64::DUPv4i16lane, 2, MCP::FMULv4i16_indexed_OP2);
8247 case AArch64::FMULv4f32:
8248 Found = Match(AArch64::DUPv4i32lane, 1, MCP::FMULv4i32_indexed_OP1);
8249 Found |= Match(AArch64::DUPv4i32lane, 2, MCP::FMULv4i32_indexed_OP2);
8251 case AArch64::FMULv8f16:
8252 Found = Match(AArch64::DUPv8i16lane, 1, MCP::FMULv8i16_indexed_OP1);
8253 Found |= Match(AArch64::DUPv8i16lane, 2, MCP::FMULv8i16_indexed_OP2);
8266 auto Match = [&](
unsigned Opcode,
unsigned Pattern) ->
bool {
8269 if (
MI !=
nullptr && (
MI->getOpcode() == Opcode) &&
8284 case AArch64::FNEGDr:
8286 case AArch64::FNEGSr:
8418 case AArch64::SUBWrr:
8419 case AArch64::SUBSWrr:
8420 case AArch64::SUBXrr:
8421 case AArch64::SUBSXrr:
8466 unsigned LoadLaneOpCode,
unsigned NumLanes) {
8489 while (!RemainingLanes.
empty() && CurrInstr &&
8490 CurrInstr->getOpcode() == LoadLaneOpCode &&
8492 CurrInstr->getNumOperands() == 4) {
8493 RemainingLanes.
erase(CurrInstr->getOperand(2).getImm());
8499 if (!RemainingLanes.
empty())
8503 if (CurrInstr->getOpcode() != TargetOpcode::SUBREG_TO_REG)
8507 auto Lane0LoadReg = CurrInstr->getOperand(1).getReg();
8508 unsigned SingleLaneSizeInBits = 128 / NumLanes;
8509 if (
TRI->getRegSizeInBits(Lane0LoadReg, MRI) != SingleLaneSizeInBits)
8525 RemainingLoadInstrs.
insert(LoadInstrs.
begin(), LoadInstrs.
end());
8528 for (; MBBItr !=
MBB->begin() && RemainingSteps > 0 &&
8529 !RemainingLoadInstrs.
empty();
8530 --MBBItr, --RemainingSteps) {
8534 RemainingLoadInstrs.
erase(&CurrInstr);
8544 if (RemainingSteps == 0 && !RemainingLoadInstrs.
empty())
8570 case AArch64::LD1i32:
8572 case AArch64::LD1i16:
8574 case AArch64::LD1i8:
8590 unsigned Pattern,
unsigned NumLanes) {
8598 for (
unsigned i = 0; i < NumLanes - 1; ++i) {
8606 return A->getOperand(2).getImm() >
B->getOperand(2).getImm();
8612 auto LoadToLaneInstrsAscending =
llvm::reverse(LoadToLaneInstrs);
8618 auto CreateLD1Instruction = [&](
MachineInstr *OriginalInstr,
8619 Register SrcRegister,
unsigned Lane,
8621 bool OffsetRegisterKillState) {
8630 InstrIdxForVirtReg.
insert(std::make_pair(NewRegister, InsInstrs.
size()));
8631 InsInstrs.
push_back(LoadIndexIntoRegister);
8637 auto CreateLDRInstruction =
8643 Opcode = AArch64::LDRSui;
8646 Opcode = AArch64::LDRHui;
8649 Opcode = AArch64::LDRBui;
8653 "Got unsupported number of lanes in machine-combiner gather pattern");
8663 auto LanesToLoadToReg0 =
8665 LoadToLaneInstrsAscending.begin() + NumLanes / 2);
8666 Register PrevReg = SubregToReg->getOperand(0).getReg();
8668 const MachineOperand &OffsetRegOperand = LoadInstr->getOperand(3);
8669 PrevReg = CreateLD1Instruction(LoadInstr, PrevReg, Index + 1,
8670 OffsetRegOperand.
getReg(),
8671 OffsetRegOperand.
isKill());
8678 MachineInstr *Lane0Load = *LoadToLaneInstrsAscending.begin();
8680 *std::next(LoadToLaneInstrsAscending.begin(), NumLanes / 2);
8687 CreateLDRInstruction(NumLanes, DestRegForMiddleIndex,
8688 OriginalSplitToLoadOffsetOperand.
getReg(),
8691 InstrIdxForVirtReg.
insert(
8692 std::make_pair(DestRegForMiddleIndex, InsInstrs.
size()));
8693 InsInstrs.
push_back(MiddleIndexLoadInstr);
8698 unsigned SubregType;
8701 SubregType = AArch64::ssub;
8704 SubregType = AArch64::hsub;
8707 SubregType = AArch64::bsub;
8711 "Got invalid NumLanes for machine-combiner gather pattern");
8714 auto SubRegToRegInstr =
8716 DestRegForSubregToReg)
8719 InstrIdxForVirtReg.
insert(
8720 std::make_pair(DestRegForSubregToReg, InsInstrs.
size()));
8724 auto LanesToLoadToReg1 =
8726 LoadToLaneInstrsAscending.end());
8727 PrevReg = SubRegToRegInstr->getOperand(0).getReg();
8729 const MachineOperand &OffsetRegOperand = LoadInstr->getOperand(3);
8730 PrevReg = CreateLD1Instruction(LoadInstr, PrevReg, Index + 1,
8731 OffsetRegOperand.
getReg(),
8732 OffsetRegOperand.
isKill());
8735 if (Index == NumLanes / 2 - 2) {
8770bool AArch64InstrInfo::getMachineCombinerPatterns(
8772 bool DoRegPressureReduce)
const {
8793 DoRegPressureReduce);
8822 const Register *ReplacedAddend =
nullptr) {
8823 assert(IdxMulOpd == 1 || IdxMulOpd == 2);
8825 unsigned IdxOtherOpd = IdxMulOpd == 1 ? 2 : 1;
8828 Register SrcReg0 = MUL->getOperand(1).getReg();
8829 bool Src0IsKill = MUL->getOperand(1).isKill();
8830 Register SrcReg1 = MUL->getOperand(2).getReg();
8831 bool Src1IsKill = MUL->getOperand(2).isKill();
8835 if (ReplacedAddend) {
8837 SrcReg2 = *ReplacedAddend;
8864 .
addImm(MUL->getOperand(3).getImm());
8871 assert(
false &&
"Invalid FMA instruction kind \n");
8885 if (AArch64::FPR32RegClass.hasSubClassEq(RC))
8886 Opc = AArch64::FNMADDSrrr;
8887 else if (AArch64::FPR64RegClass.hasSubClassEq(RC))
8888 Opc = AArch64::FNMADDDrrr;
8922 unsigned IdxDupOp,
unsigned MulOpc,
8924 assert(((IdxDupOp == 1) || (IdxDupOp == 2)) &&
8925 "Invalid index of FMUL operand");
8933 if (Dup->
getOpcode() == TargetOpcode::COPY)
8942 unsigned IdxMulOp = IdxDupOp == 1 ? 2 : 1;
8983 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
8998 genNeg(MF, MRI,
TII, Root, InsInstrs, InstrIdxForVirtReg, MnegOpc, RC);
9025 genNeg(MF, MRI,
TII, Root, InsInstrs, InstrIdxForVirtReg, MnegOpc, RC);
9053 unsigned IdxMulOpd,
unsigned MaddOpc,
unsigned VR,
9055 assert(IdxMulOpd == 1 || IdxMulOpd == 2);
9059 Register SrcReg0 = MUL->getOperand(1).getReg();
9060 bool Src0IsKill = MUL->getOperand(1).isKill();
9061 Register SrcReg1 = MUL->getOperand(2).getReg();
9062 bool Src1IsKill = MUL->getOperand(2).isKill();
9092 assert(IdxOpd1 == 1 || IdxOpd1 == 2);
9093 unsigned IdxOtherOpd = IdxOpd1 == 1 ? 2 : 1;
9107 if (Opcode == AArch64::SUBSWrr)
9108 Opcode = AArch64::SUBWrr;
9109 else if (Opcode == AArch64::SUBSXrr)
9110 Opcode = AArch64::SUBXrr;
9112 assert((Opcode == AArch64::SUBWrr || Opcode == AArch64::SUBXrr) &&
9113 "Unexpected instruction opcode.");
9130 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9137unsigned AArch64InstrInfo::getReduceOpcodeForAccumulator(
9138 unsigned int AccumulatorOpCode)
const {
9139 switch (AccumulatorOpCode) {
9140 case AArch64::UABALB_ZZZ_D:
9141 case AArch64::SABALB_ZZZ_D:
9142 case AArch64::UABALT_ZZZ_D:
9143 case AArch64::SABALT_ZZZ_D:
9144 return AArch64::ADD_ZZZ_D;
9145 case AArch64::UABALB_ZZZ_H:
9146 case AArch64::SABALB_ZZZ_H:
9147 case AArch64::UABALT_ZZZ_H:
9148 case AArch64::SABALT_ZZZ_H:
9149 return AArch64::ADD_ZZZ_H;
9150 case AArch64::UABALB_ZZZ_S:
9151 case AArch64::SABALB_ZZZ_S:
9152 case AArch64::UABALT_ZZZ_S:
9153 case AArch64::SABALT_ZZZ_S:
9154 return AArch64::ADD_ZZZ_S;
9155 case AArch64::UABALv16i8_v8i16:
9156 case AArch64::SABALv8i8_v8i16:
9157 case AArch64::SABAv8i16:
9158 case AArch64::UABAv8i16:
9159 return AArch64::ADDv8i16;
9160 case AArch64::SABALv2i32_v2i64:
9161 case AArch64::UABALv2i32_v2i64:
9162 case AArch64::SABALv4i32_v2i64:
9163 return AArch64::ADDv2i64;
9164 case AArch64::UABALv4i16_v4i32:
9165 case AArch64::SABALv4i16_v4i32:
9166 case AArch64::SABALv8i16_v4i32:
9167 case AArch64::SABAv4i32:
9168 case AArch64::UABAv4i32:
9169 return AArch64::ADDv4i32;
9170 case AArch64::UABALv4i32_v2i64:
9171 return AArch64::ADDv2i64;
9172 case AArch64::UABALv8i16_v4i32:
9173 return AArch64::ADDv4i32;
9174 case AArch64::UABALv8i8_v8i16:
9175 case AArch64::SABALv16i8_v8i16:
9176 return AArch64::ADDv8i16;
9177 case AArch64::UABAv16i8:
9178 case AArch64::SABAv16i8:
9179 return AArch64::ADDv16i8;
9180 case AArch64::UABAv4i16:
9181 case AArch64::SABAv4i16:
9182 return AArch64::ADDv4i16;
9183 case AArch64::UABAv2i32:
9184 case AArch64::SABAv2i32:
9185 return AArch64::ADDv2i32;
9186 case AArch64::UABAv8i8:
9187 case AArch64::SABAv8i8:
9188 return AArch64::ADDv8i8;
9197void AArch64InstrInfo::genAlternativeCodeSequence(
9207 MachineInstr *
MUL =
nullptr;
9214 DelInstrs, InstrIdxForVirtReg);
9220 InstrIdxForVirtReg);
9226 InstrIdxForVirtReg);
9235 Opc = AArch64::MADDWrrr;
9236 RC = &AArch64::GPR32RegClass;
9238 Opc = AArch64::MADDXrrr;
9239 RC = &AArch64::GPR64RegClass;
9250 Opc = AArch64::MADDWrrr;
9251 RC = &AArch64::GPR32RegClass;
9253 Opc = AArch64::MADDXrrr;
9254 RC = &AArch64::GPR64RegClass;
9268 unsigned BitSize, MovImm;
9271 MovImm = AArch64::MOVi32imm;
9272 RC = &AArch64::GPR32spRegClass;
9274 Opc = AArch64::MADDWrrr;
9275 RC = &AArch64::GPR32RegClass;
9277 MovImm = AArch64::MOVi64imm;
9278 RC = &AArch64::GPR64spRegClass;
9280 Opc = AArch64::MADDXrrr;
9281 RC = &AArch64::GPR64RegClass;
9296 if (Insn.
size() != 1)
9298 MachineInstrBuilder MIB1 =
9299 BuildMI(MF, MIMetadata(Root),
TII->get(MovImm), NewVR)
9302 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9314 unsigned SubOpc, ZeroReg;
9316 SubOpc = AArch64::SUBWrr;
9317 SubRC = &AArch64::GPR32spRegClass;
9318 ZeroReg = AArch64::WZR;
9319 Opc = AArch64::MADDWrrr;
9320 RC = &AArch64::GPR32RegClass;
9322 SubOpc = AArch64::SUBXrr;
9323 SubRC = &AArch64::GPR64spRegClass;
9324 ZeroReg = AArch64::XZR;
9325 Opc = AArch64::MADDXrrr;
9326 RC = &AArch64::GPR64RegClass;
9330 MachineInstrBuilder MIB1 =
9331 BuildMI(MF, MIMetadata(Root),
TII->get(SubOpc), NewVR)
9335 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9346 Opc = AArch64::MSUBWrrr;
9347 RC = &AArch64::GPR32RegClass;
9349 Opc = AArch64::MSUBXrrr;
9350 RC = &AArch64::GPR64RegClass;
9355 Opc = AArch64::MLAv8i8;
9356 RC = &AArch64::FPR64RegClass;
9360 Opc = AArch64::MLAv8i8;
9361 RC = &AArch64::FPR64RegClass;
9365 Opc = AArch64::MLAv16i8;
9366 RC = &AArch64::FPR128RegClass;
9370 Opc = AArch64::MLAv16i8;
9371 RC = &AArch64::FPR128RegClass;
9375 Opc = AArch64::MLAv4i16;
9376 RC = &AArch64::FPR64RegClass;
9380 Opc = AArch64::MLAv4i16;
9381 RC = &AArch64::FPR64RegClass;
9385 Opc = AArch64::MLAv8i16;
9386 RC = &AArch64::FPR128RegClass;
9390 Opc = AArch64::MLAv8i16;
9391 RC = &AArch64::FPR128RegClass;
9395 Opc = AArch64::MLAv2i32;
9396 RC = &AArch64::FPR64RegClass;
9400 Opc = AArch64::MLAv2i32;
9401 RC = &AArch64::FPR64RegClass;
9405 Opc = AArch64::MLAv4i32;
9406 RC = &AArch64::FPR128RegClass;
9410 Opc = AArch64::MLAv4i32;
9411 RC = &AArch64::FPR128RegClass;
9416 Opc = AArch64::MLAv8i8;
9417 RC = &AArch64::FPR64RegClass;
9419 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i8,
9423 Opc = AArch64::MLSv8i8;
9424 RC = &AArch64::FPR64RegClass;
9428 Opc = AArch64::MLAv16i8;
9429 RC = &AArch64::FPR128RegClass;
9431 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv16i8,
9435 Opc = AArch64::MLSv16i8;
9436 RC = &AArch64::FPR128RegClass;
9440 Opc = AArch64::MLAv4i16;
9441 RC = &AArch64::FPR64RegClass;
9443 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i16,
9447 Opc = AArch64::MLSv4i16;
9448 RC = &AArch64::FPR64RegClass;
9452 Opc = AArch64::MLAv8i16;
9453 RC = &AArch64::FPR128RegClass;
9455 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i16,
9459 Opc = AArch64::MLSv8i16;
9460 RC = &AArch64::FPR128RegClass;
9464 Opc = AArch64::MLAv2i32;
9465 RC = &AArch64::FPR64RegClass;
9467 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv2i32,
9471 Opc = AArch64::MLSv2i32;
9472 RC = &AArch64::FPR64RegClass;
9476 Opc = AArch64::MLAv4i32;
9477 RC = &AArch64::FPR128RegClass;
9479 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i32,
9483 Opc = AArch64::MLSv4i32;
9484 RC = &AArch64::FPR128RegClass;
9489 Opc = AArch64::MLAv4i16_indexed;
9490 RC = &AArch64::FPR64RegClass;
9494 Opc = AArch64::MLAv4i16_indexed;
9495 RC = &AArch64::FPR64RegClass;
9499 Opc = AArch64::MLAv8i16_indexed;
9500 RC = &AArch64::FPR128RegClass;
9504 Opc = AArch64::MLAv8i16_indexed;
9505 RC = &AArch64::FPR128RegClass;
9509 Opc = AArch64::MLAv2i32_indexed;
9510 RC = &AArch64::FPR64RegClass;
9514 Opc = AArch64::MLAv2i32_indexed;
9515 RC = &AArch64::FPR64RegClass;
9519 Opc = AArch64::MLAv4i32_indexed;
9520 RC = &AArch64::FPR128RegClass;
9524 Opc = AArch64::MLAv4i32_indexed;
9525 RC = &AArch64::FPR128RegClass;
9530 Opc = AArch64::MLAv4i16_indexed;
9531 RC = &AArch64::FPR64RegClass;
9533 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i16,
9537 Opc = AArch64::MLSv4i16_indexed;
9538 RC = &AArch64::FPR64RegClass;
9542 Opc = AArch64::MLAv8i16_indexed;
9543 RC = &AArch64::FPR128RegClass;
9545 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i16,
9549 Opc = AArch64::MLSv8i16_indexed;
9550 RC = &AArch64::FPR128RegClass;
9554 Opc = AArch64::MLAv2i32_indexed;
9555 RC = &AArch64::FPR64RegClass;
9557 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv2i32,
9561 Opc = AArch64::MLSv2i32_indexed;
9562 RC = &AArch64::FPR64RegClass;
9566 Opc = AArch64::MLAv4i32_indexed;
9567 RC = &AArch64::FPR128RegClass;
9569 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i32,
9573 Opc = AArch64::MLSv4i32_indexed;
9574 RC = &AArch64::FPR128RegClass;
9580 Opc = AArch64::FMADDHrrr;
9581 RC = &AArch64::FPR16RegClass;
9585 Opc = AArch64::FMADDSrrr;
9586 RC = &AArch64::FPR32RegClass;
9590 Opc = AArch64::FMADDDrrr;
9591 RC = &AArch64::FPR64RegClass;
9596 Opc = AArch64::FMADDHrrr;
9597 RC = &AArch64::FPR16RegClass;
9601 Opc = AArch64::FMADDSrrr;
9602 RC = &AArch64::FPR32RegClass;
9606 Opc = AArch64::FMADDDrrr;
9607 RC = &AArch64::FPR64RegClass;
9612 Opc = AArch64::FMLAv1i32_indexed;
9613 RC = &AArch64::FPR32RegClass;
9618 Opc = AArch64::FMLAv1i32_indexed;
9619 RC = &AArch64::FPR32RegClass;
9625 Opc = AArch64::FMLAv1i64_indexed;
9626 RC = &AArch64::FPR64RegClass;
9631 Opc = AArch64::FMLAv1i64_indexed;
9632 RC = &AArch64::FPR64RegClass;
9638 RC = &AArch64::FPR64RegClass;
9639 Opc = AArch64::FMLAv4i16_indexed;
9644 RC = &AArch64::FPR64RegClass;
9645 Opc = AArch64::FMLAv4f16;
9650 RC = &AArch64::FPR64RegClass;
9651 Opc = AArch64::FMLAv4i16_indexed;
9656 RC = &AArch64::FPR64RegClass;
9657 Opc = AArch64::FMLAv4f16;
9664 RC = &AArch64::FPR64RegClass;
9666 Opc = AArch64::FMLAv2i32_indexed;
9670 Opc = AArch64::FMLAv2f32;
9677 RC = &AArch64::FPR64RegClass;
9679 Opc = AArch64::FMLAv2i32_indexed;
9683 Opc = AArch64::FMLAv2f32;
9690 RC = &AArch64::FPR128RegClass;
9691 Opc = AArch64::FMLAv8i16_indexed;
9696 RC = &AArch64::FPR128RegClass;
9697 Opc = AArch64::FMLAv8f16;
9702 RC = &AArch64::FPR128RegClass;
9703 Opc = AArch64::FMLAv8i16_indexed;
9708 RC = &AArch64::FPR128RegClass;
9709 Opc = AArch64::FMLAv8f16;
9716 RC = &AArch64::FPR128RegClass;
9718 Opc = AArch64::FMLAv2i64_indexed;
9722 Opc = AArch64::FMLAv2f64;
9729 RC = &AArch64::FPR128RegClass;
9731 Opc = AArch64::FMLAv2i64_indexed;
9735 Opc = AArch64::FMLAv2f64;
9743 RC = &AArch64::FPR128RegClass;
9745 Opc = AArch64::FMLAv4i32_indexed;
9749 Opc = AArch64::FMLAv4f32;
9757 RC = &AArch64::FPR128RegClass;
9759 Opc = AArch64::FMLAv4i32_indexed;
9763 Opc = AArch64::FMLAv4f32;
9770 Opc = AArch64::FNMSUBHrrr;
9771 RC = &AArch64::FPR16RegClass;
9775 Opc = AArch64::FNMSUBSrrr;
9776 RC = &AArch64::FPR32RegClass;
9780 Opc = AArch64::FNMSUBDrrr;
9781 RC = &AArch64::FPR64RegClass;
9786 Opc = AArch64::FNMADDHrrr;
9787 RC = &AArch64::FPR16RegClass;
9791 Opc = AArch64::FNMADDSrrr;
9792 RC = &AArch64::FPR32RegClass;
9796 Opc = AArch64::FNMADDDrrr;
9797 RC = &AArch64::FPR64RegClass;
9802 Opc = AArch64::FMSUBHrrr;
9803 RC = &AArch64::FPR16RegClass;
9807 Opc = AArch64::FMSUBSrrr;
9808 RC = &AArch64::FPR32RegClass;
9812 Opc = AArch64::FMSUBDrrr;
9813 RC = &AArch64::FPR64RegClass;
9818 Opc = AArch64::FMLSv1i32_indexed;
9819 RC = &AArch64::FPR32RegClass;
9825 Opc = AArch64::FMLSv1i64_indexed;
9826 RC = &AArch64::FPR64RegClass;
9833 RC = &AArch64::FPR64RegClass;
9835 MachineInstrBuilder MIB1 =
9836 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv4f16), NewVR)
9839 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9841 Opc = AArch64::FMLAv4f16;
9845 Opc = AArch64::FMLAv4i16_indexed;
9852 RC = &AArch64::FPR64RegClass;
9853 Opc = AArch64::FMLSv4f16;
9858 RC = &AArch64::FPR64RegClass;
9859 Opc = AArch64::FMLSv4i16_indexed;
9866 RC = &AArch64::FPR64RegClass;
9868 Opc = AArch64::FMLSv2i32_indexed;
9872 Opc = AArch64::FMLSv2f32;
9880 RC = &AArch64::FPR128RegClass;
9882 MachineInstrBuilder MIB1 =
9883 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv8f16), NewVR)
9886 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9888 Opc = AArch64::FMLAv8f16;
9892 Opc = AArch64::FMLAv8i16_indexed;
9899 RC = &AArch64::FPR128RegClass;
9900 Opc = AArch64::FMLSv8f16;
9905 RC = &AArch64::FPR128RegClass;
9906 Opc = AArch64::FMLSv8i16_indexed;
9913 RC = &AArch64::FPR128RegClass;
9915 Opc = AArch64::FMLSv2i64_indexed;
9919 Opc = AArch64::FMLSv2f64;
9927 RC = &AArch64::FPR128RegClass;
9929 Opc = AArch64::FMLSv4i32_indexed;
9933 Opc = AArch64::FMLSv4f32;
9940 RC = &AArch64::FPR64RegClass;
9942 MachineInstrBuilder MIB1 =
9943 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv2f32), NewVR)
9946 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9948 Opc = AArch64::FMLAv2i32_indexed;
9952 Opc = AArch64::FMLAv2f32;
9960 RC = &AArch64::FPR128RegClass;
9962 MachineInstrBuilder MIB1 =
9963 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv4f32), NewVR)
9966 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9968 Opc = AArch64::FMLAv4i32_indexed;
9972 Opc = AArch64::FMLAv4f32;
9980 RC = &AArch64::FPR128RegClass;
9982 MachineInstrBuilder MIB1 =
9983 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv2f64), NewVR)
9986 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9988 Opc = AArch64::FMLAv2i64_indexed;
9992 Opc = AArch64::FMLAv2f64;
10000 unsigned IdxDupOp =
10004 &AArch64::FPR128RegClass, MRI);
10009 unsigned IdxDupOp =
10013 &AArch64::FPR128RegClass, MRI);
10018 unsigned IdxDupOp =
10022 &AArch64::FPR128_loRegClass, MRI);
10027 unsigned IdxDupOp =
10031 &AArch64::FPR128RegClass, MRI);
10036 unsigned IdxDupOp =
10040 &AArch64::FPR128_loRegClass, MRI);
10074 for (
auto *
MI : InsInstrs)
10075 MI->setFlags(Flags);
10116 bool IsNegativeBranch =
false;
10117 bool IsTestAndBranch =
false;
10118 unsigned TargetBBInMI = 0;
10119 switch (
MI.getOpcode()) {
10123 case AArch64::CBWPri:
10124 case AArch64::CBXPri:
10125 case AArch64::CBBAssertExt:
10126 case AArch64::CBHAssertExt:
10127 case AArch64::CBWPrr:
10128 case AArch64::CBXPrr:
10130 case AArch64::CBZW:
10131 case AArch64::CBZX:
10134 case AArch64::CBNZW:
10135 case AArch64::CBNZX:
10137 IsNegativeBranch =
true;
10139 case AArch64::TBZW:
10140 case AArch64::TBZX:
10142 IsTestAndBranch =
true;
10144 case AArch64::TBNZW:
10145 case AArch64::TBNZX:
10147 IsNegativeBranch =
true;
10148 IsTestAndBranch =
true;
10154 if (IsTestAndBranch &&
MI.getOperand(1).getImm())
10158 assert(
MI.getParent() &&
"Incomplete machine instruction\n");
10171 while (
DefMI->isCopy()) {
10182 switch (
DefMI->getOpcode()) {
10186 case AArch64::ANDWri:
10187 case AArch64::ANDXri: {
10188 if (IsTestAndBranch)
10195 bool Is32Bit = (
DefMI->getOpcode() == AArch64::ANDWri);
10197 DefMI->getOperand(2).getImm(), Is32Bit ? 32 : 64);
10213 unsigned Opc = (
Imm < 32)
10214 ? (IsNegativeBranch ? AArch64::TBNZW : AArch64::TBZW)
10215 : (IsNegativeBranch ? AArch64::TBNZX : AArch64::TBZX);
10228 if (!Is32Bit &&
Imm < 32)
10230 MI.eraseFromParent();
10234 case AArch64::CSINCWr:
10235 case AArch64::CSINCXr: {
10236 if (!(
DefMI->getOperand(1).getReg() == AArch64::WZR &&
10237 DefMI->getOperand(2).getReg() == AArch64::WZR) &&
10238 !(
DefMI->getOperand(1).getReg() == AArch64::XZR &&
10239 DefMI->getOperand(2).getReg() == AArch64::XZR))
10242 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
10255 if (IsNegativeBranch)
10258 MI.eraseFromParent();
10264std::pair<unsigned, unsigned>
10265AArch64InstrInfo::decomposeMachineOperandsTargetFlags(
unsigned TF)
const {
10267 return std::make_pair(TF & Mask, TF & ~Mask);
10271AArch64InstrInfo::getSerializableDirectMachineOperandTargetFlags()
const {
10274 static const std::pair<unsigned, const char *> TargetFlags[] = {
10275 {MO_PAGE,
"aarch64-page"}, {
MO_PAGEOFF,
"aarch64-pageoff"},
10276 {
MO_G3,
"aarch64-g3"}, {
MO_G2,
"aarch64-g2"},
10277 {
MO_G1,
"aarch64-g1"}, {
MO_G0,
"aarch64-g0"},
10283AArch64InstrInfo::getSerializableBitmaskMachineOperandTargetFlags()
const {
10284 using namespace AArch64II;
10286 static const std::pair<unsigned, const char *> TargetFlags[] = {
10288 {
MO_GOT,
"aarch64-got"},
10289 {
MO_NC,
"aarch64-nc"},
10290 {
MO_S,
"aarch64-s"},
10291 {
MO_TLS,
"aarch64-tls"},
10301AArch64InstrInfo::getSerializableMachineMemOperandTargetFlags()
const {
10302 static const std::pair<MachineMemOperand::Flags, const char *> TargetFlags[] =
10436 std::vector<outliner::Candidate> &RepeatedSequenceLocs,
10451 return C.isAvailableInsideSeq(AArch64::FP,
TRI);
10459 const AArch64RegisterInfo *ARI =
10460 static_cast<const AArch64RegisterInfo *
>(&
TRI);
10463 for (
unsigned Reg : AArch64::GPR64RegClass) {
10465 Reg != AArch64::LR &&
10466 Reg != AArch64::X16 &&
10467 Reg != AArch64::X17 &&
10468 C.isAvailableAcrossAndOutOfSeq(
Reg,
TRI) &&
10469 C.isAvailableInsideSeq(
Reg,
TRI))
10500 return SubtargetA.hasV8_3aOps() == SubtargetB.hasV8_3aOps();
10503std::optional<std::unique_ptr<outliner::OutlinedFunction>>
10504AArch64InstrInfo::getOutliningCandidateInfo(
10506 std::vector<outliner::Candidate> &RepeatedSequenceLocs,
10507 unsigned MinRepeats)
const {
10508 unsigned SequenceSize = 0;
10509 for (
auto &
MI : RepeatedSequenceLocs[0])
10512 unsigned NumBytesToCreateFrame = 0;
10518 MachineInstr &LastMI = RepeatedSequenceLocs[0].back();
10519 MachineInstr &FirstMI = RepeatedSequenceLocs[0].front();
10520 if (LastMI.
getOpcode() == AArch64::ADRP &&
10523 return std::nullopt;
10528 if ((FirstMI.
getOpcode() == AArch64::ADDXri ||
10529 FirstMI.
getOpcode() == AArch64::LDRXui) &&
10532 return std::nullopt;
10543 if (std::adjacent_find(
10544 RepeatedSequenceLocs.begin(), RepeatedSequenceLocs.end(),
10545 [](
const outliner::Candidate &a,
const outliner::Candidate &b) {
10548 if (outliningCandidatesSigningScopeConsensus(a, b) &&
10549 outliningCandidatesSigningKeyConsensus(a, b) &&
10550 outliningCandidatesV8_3OpsConsensus(a, b)) {
10554 }) != RepeatedSequenceLocs.end()) {
10555 return std::nullopt;
10572 unsigned NumBytesToCheckLRInTCEpilogue = 0;
10573 const auto RASignCondition = RepeatedSequenceLocs[0]
10576 ->getSignReturnAddressCondition();
10579 NumBytesToCreateFrame += 8;
10582 auto LRCheckMethod = Subtarget.getAuthenticatedLRCheckMethod(
10583 *RepeatedSequenceLocs[0].getMF());
10584 NumBytesToCheckLRInTCEpilogue =
10588 if (isTailCallReturnInst(RepeatedSequenceLocs[0].
back()))
10589 SequenceSize += NumBytesToCheckLRInTCEpilogue;
10597 for (
auto &
MI :
C) {
10598 if (
MI.modifiesRegister(AArch64::SP, &
TRI)) {
10599 switch (
MI.getOpcode()) {
10600 case AArch64::ADDXri:
10601 case AArch64::ADDWri:
10602 assert(
MI.getNumOperands() == 4 &&
"Wrong number of operands");
10603 assert(
MI.getOperand(2).isImm() &&
10604 "Expected operand to be immediate");
10605 assert(
MI.getOperand(1).isReg() &&
10606 "Expected operand to be a register");
10610 if (
MI.getOperand(1).getReg() == AArch64::SP)
10611 SPValue +=
MI.getOperand(2).getImm();
10615 case AArch64::SUBXri:
10616 case AArch64::SUBWri:
10617 assert(
MI.getNumOperands() == 4 &&
"Wrong number of operands");
10618 assert(
MI.getOperand(2).isImm() &&
10619 "Expected operand to be immediate");
10620 assert(
MI.getOperand(1).isReg() &&
10621 "Expected operand to be a register");
10625 if (
MI.getOperand(1).getReg() == AArch64::SP)
10626 SPValue -=
MI.getOperand(2).getImm();
10643 if (RepeatedSequenceLocs.size() < MinRepeats)
10644 return std::nullopt;
10648 unsigned FlagsSetInAll = 0xF;
10652 FlagsSetInAll &=
C.Flags;
10654 unsigned LastInstrOpcode = RepeatedSequenceLocs[0].back().getOpcode();
10657 auto SetCandidateCallInfo =
10658 [&RepeatedSequenceLocs](
unsigned CallID,
unsigned NumBytesForCall) {
10660 C.setCallInfo(CallID, NumBytesForCall);
10664 NumBytesToCreateFrame += 4;
10672 unsigned CFICount = 0;
10673 for (
auto &
I : RepeatedSequenceLocs[0]) {
10674 if (
I.isCFIInstruction())
10684 std::vector<MCCFIInstruction> CFIInstructions =
10685 C.getMF()->getFrameInstructions();
10687 if (CFICount > 0 && CFICount != CFIInstructions.size())
10688 return std::nullopt;
10696 if (!
MI.modifiesRegister(AArch64::SP, &
TRI) &&
10697 !
MI.readsRegister(AArch64::SP, &
TRI))
10703 if (
MI.modifiesRegister(AArch64::SP, &
TRI))
10708 if (
MI.mayLoadOrStore()) {
10711 bool OffsetIsScalable;
10715 if (!getMemOperandWithOffset(
MI,
Base,
Offset, OffsetIsScalable) ||
10716 !
Base->isReg() ||
Base->getReg() != AArch64::SP)
10720 if (OffsetIsScalable)
10728 TypeSize Scale(0U,
false), DummyWidth(0U,
false);
10729 getMemOpInfo(
MI.getOpcode(), Scale, DummyWidth, MinOffset, MaxOffset);
10732 if (
Offset < MinOffset * (int64_t)Scale.getFixedValue() ||
10733 Offset > MaxOffset * (int64_t)Scale.getFixedValue())
10748 bool AllStackInstrsSafe =
10753 if (RepeatedSequenceLocs[0].
back().isTerminator()) {
10755 NumBytesToCreateFrame = 0;
10756 unsigned NumBytesForCall = 4 + NumBytesToCheckLRInTCEpilogue;
10760 else if (LastInstrOpcode == AArch64::BL ||
10761 ((LastInstrOpcode == AArch64::BLR ||
10762 LastInstrOpcode == AArch64::BLRNoIP) &&
10766 NumBytesToCreateFrame = NumBytesToCheckLRInTCEpilogue;
10774 unsigned NumBytesNoStackCalls = 0;
10775 std::vector<outliner::Candidate> CandidatesWithoutStackFixups;
10781 ?
C.isAvailableAcrossAndOutOfSeq(AArch64::LR,
TRI)
10790 C.getMF()->getFunction().hasFnAttribute(Attribute::NoReturn);
10793 if (LRAvailable && !IsNoReturn) {
10794 NumBytesNoStackCalls += 4;
10796 CandidatesWithoutStackFixups.push_back(
C);
10801 else if (findRegisterToSaveLRTo(
C)) {
10802 NumBytesNoStackCalls += 12;
10804 CandidatesWithoutStackFixups.push_back(
C);
10809 else if (
C.isAvailableInsideSeq(AArch64::SP,
TRI)) {
10810 NumBytesNoStackCalls += 12;
10812 CandidatesWithoutStackFixups.push_back(
C);
10818 NumBytesNoStackCalls += SequenceSize;
10825 if (!AllStackInstrsSafe ||
10826 NumBytesNoStackCalls <= RepeatedSequenceLocs.size() * 12) {
10827 RepeatedSequenceLocs = CandidatesWithoutStackFixups;
10829 if (RepeatedSequenceLocs.size() < MinRepeats)
10830 return std::nullopt;
10883 (!
C.isAvailableAcrossAndOutOfSeq(AArch64::LR,
TRI) ||
10884 !findRegisterToSaveLRTo(
C));
10890 if (RepeatedSequenceLocs.size() < MinRepeats)
10891 return std::nullopt;
10900 bool ModStackToSaveLR =
false;
10903 ModStackToSaveLR =
true;
10912 ModStackToSaveLR =
true;
10914 if (ModStackToSaveLR) {
10916 if (!AllStackInstrsSafe)
10917 return std::nullopt;
10920 NumBytesToCreateFrame += 8;
10924 RepeatedSequenceLocs,
TRI))
10925 NumBytesToCreateFrame += 4;
10932 return std::nullopt;
10934 return std::make_unique<outliner::OutlinedFunction>(
10935 RepeatedSequenceLocs, SequenceSize, NumBytesToCreateFrame, FrameID);
10938void AArch64InstrInfo::mergeOutliningCandidateAttributes(
10939 Function &
F, std::vector<outliner::Candidate> &Candidates)
const {
10943 const auto &CFn = Candidates.front().getMF()->getFunction();
10945 if (CFn.hasFnAttribute(
"ptrauth-returns"))
10946 F.addFnAttr(CFn.getFnAttribute(
"ptrauth-returns"));
10947 if (CFn.hasFnAttribute(
"ptrauth-auth-traps"))
10948 F.addFnAttr(CFn.getFnAttribute(
"ptrauth-auth-traps"));
10951 if (CFn.hasFnAttribute(
"sign-return-address"))
10952 F.addFnAttr(CFn.getFnAttribute(
"sign-return-address"));
10953 if (CFn.hasFnAttribute(
"sign-return-address-key"))
10954 F.addFnAttr(CFn.getFnAttribute(
"sign-return-address-key"));
10956 AArch64GenInstrInfo::mergeOutliningCandidateAttributes(
F, Candidates);
10959bool AArch64InstrInfo::isFunctionSafeToOutlineFrom(
10964 if (!OutlineFromLinkOnceODRs &&
F.hasLinkOnceODRLinkage())
10971 if (
F.hasSection())
10977 AArch64FunctionInfo *AFI = MF.
getInfo<AArch64FunctionInfo>();
10978 if (!AFI || AFI->
hasRedZone().value_or(
true))
10998 unsigned &Flags)
const {
11000 "Must track liveness!");
11002 std::pair<MachineBasicBlock::iterator, MachineBasicBlock::iterator>>
11017 auto AreAllUnsafeRegsDead = [&LRU]() {
11018 return LRU.available(AArch64::W16) && LRU.available(AArch64::W17) &&
11019 LRU.available(AArch64::NZCV);
11034 bool LRAvailableEverywhere =
true;
11036 LRU.addLiveOuts(
MBB);
11038 auto UpdateWholeMBBFlags = [&
Flags](
const MachineInstr &
MI) {
11039 if (
MI.isCall() && !
MI.isTerminator())
11045 auto CreateNewRangeStartingAt =
11046 [&RangeBegin, &RangeEnd,
11048 RangeBegin = NewBegin;
11049 RangeEnd = std::next(RangeBegin);
11052 auto SaveRangeIfNonEmpty = [&RangeLen, &
Ranges, &RangeBegin, &RangeEnd]() {
11058 if (!RangeBegin.isEnd() && RangeBegin->isBundledWithPred())
11060 if (!RangeEnd.isEnd() && RangeEnd->isBundledWithPred())
11062 Ranges.emplace_back(RangeBegin, RangeEnd);
11070 for (; FirstPossibleEndPt !=
MBB.
instr_rend(); ++FirstPossibleEndPt) {
11071 if (!FirstPossibleEndPt->isDebugInstr())
11072 LRU.stepBackward(*FirstPossibleEndPt);
11075 UpdateWholeMBBFlags(*FirstPossibleEndPt);
11076 if (AreAllUnsafeRegsDead())
11083 CreateNewRangeStartingAt(FirstPossibleEndPt->getIterator());
11088 if (!
MI.isDebugInstr())
11089 LRU.stepBackward(
MI);
11090 UpdateWholeMBBFlags(
MI);
11091 if (!AreAllUnsafeRegsDead()) {
11092 SaveRangeIfNonEmpty();
11093 CreateNewRangeStartingAt(
MI.getIterator());
11096 LRAvailableEverywhere &= LRU.available(AArch64::LR);
11100 RangeBegin =
MI.getIterator();
11101 if (!
MI.isDebugInstr())
11106 if (AreAllUnsafeRegsDead())
11107 SaveRangeIfNonEmpty();
11115 if (!LRAvailableEverywhere)
11123 unsigned Flags)
const {
11124 MachineInstr &
MI = *MIT;
11128 switch (
MI.getOpcode()) {
11129 case AArch64::PACM:
11130 case AArch64::PACIASP:
11131 case AArch64::PACIBSP:
11132 case AArch64::PACIASPPC:
11133 case AArch64::PACIBSPPC:
11134 case AArch64::AUTIASP:
11135 case AArch64::AUTIBSP:
11136 case AArch64::AUTIASPPCi:
11137 case AArch64::AUTIASPPCr:
11138 case AArch64::AUTIBSPPCi:
11139 case AArch64::AUTIBSPPCr:
11140 case AArch64::RETAA:
11141 case AArch64::RETAB:
11142 case AArch64::RETAASPPCi:
11143 case AArch64::RETAASPPCr:
11144 case AArch64::RETABSPPCi:
11145 case AArch64::RETABSPPCr:
11146 case AArch64::EMITBKEY:
11147 case AArch64::PAUTH_PROLOGUE:
11148 case AArch64::PAUTH_EPILOGUE:
11158 if (
MI.isCFIInstruction())
11162 if (
MI.isTerminator())
11168 for (
const MachineOperand &MOP :
MI.operands()) {
11171 assert(!MOP.isCFIIndex());
11174 if (MOP.isReg() && !MOP.isImplicit() &&
11175 (MOP.getReg() == AArch64::LR || MOP.getReg() == AArch64::W30))
11182 if (
MI.getOpcode() == AArch64::ADRP)
11202 for (
const MachineOperand &MOP :
MI.operands()) {
11203 if (MOP.isGlobal()) {
11211 if (Callee &&
Callee->getName() ==
"\01_mcount")
11219 if (
MI.getOpcode() == AArch64::BLR ||
11220 MI.getOpcode() == AArch64::BLRNoIP ||
MI.getOpcode() == AArch64::BL)
11224 return UnknownCallOutlineType;
11232 return UnknownCallOutlineType;
11240 return UnknownCallOutlineType;
11261 for (MachineInstr &
MI :
MBB) {
11262 const MachineOperand *
Base;
11263 TypeSize Width(0,
false);
11265 bool OffsetIsScalable;
11268 if (!
MI.mayLoadOrStore() ||
11271 (
Base->isReg() &&
Base->getReg() != AArch64::SP))
11275 TypeSize Scale(0U,
false);
11276 int64_t Dummy1, Dummy2;
11279 assert(StackOffsetOperand.
isImm() &&
"Stack offset wasn't immediate!");
11281 assert(Scale != 0 &&
"Unexpected opcode!");
11282 assert(!OffsetIsScalable &&
"Expected offset to be a byte offset");
11287 int64_t NewImm = (
Offset + 16) / (int64_t)Scale.getFixedValue();
11288 StackOffsetOperand.
setImm(NewImm);
11294 bool ShouldSignReturnAddr) {
11295 if (!ShouldSignReturnAddr)
11303void AArch64InstrInfo::buildOutlinedFrame(
11307 AArch64FunctionInfo *FI = MF.
getInfo<AArch64FunctionInfo>();
11315 unsigned TailOpcode;
11317 TailOpcode = AArch64::TCRETURNdi;
11321 TailOpcode = AArch64::TCRETURNriALL;
11332 bool IsLeafFunction =
true;
11335 auto IsNonTailCall = [](
const MachineInstr &
MI) {
11336 return MI.isCall() && !
MI.isReturn();
11346 "Can only fix up stack references once");
11347 fixupPostOutline(
MBB);
11349 IsLeafFunction =
false;
11360 Et = std::prev(
MBB.
end());
11391 CFIBuilder.buildDefCFA(AArch64::FP, 16);
11392 CFIBuilder.buildOffset(AArch64::LR, -8);
11393 CFIBuilder.buildOffset(AArch64::FP, -16);
11412 if (MF.
getInfo<AArch64FunctionInfo>()->needsDwarfUnwindInfo(MF)) {
11416 CFIBuilder.buildDefCFAOffset(16);
11420 CFIBuilder.buildOffset(AArch64::LR, -16);
11435 RASignCondition, !IsLeafFunction);
11464 fixupPostOutline(
MBB);
11475 .addGlobalAddress(
M.getNamedValue(MF.
getName()))
11485 .addGlobalAddress(
M.getNamedValue(MF.
getName())));
11494 MachineInstr *Save;
11495 MachineInstr *Restore;
11501 assert(
Reg &&
"No callee-saved register available?");
11535 .addGlobalAddress(
M.getNamedValue(MF.
getName())));
11543bool AArch64InstrInfo::shouldOutlineFromFunctionByDefault(
11551 bool AllowSideEffects)
const {
11553 const AArch64Subtarget &STI = MF.
getSubtarget<AArch64Subtarget>();
11556 if (
TRI.isGeneralPurposeRegister(MF,
Reg)) {
11569 assert(STI.hasFPARMv8() &&
"Expected FP to be available.");
11575std::optional<DestSourcePair>
11580 if ((
MI.getOpcode() == AArch64::ORRWrs &&
11581 MI.getOperand(1).getReg() == AArch64::WZR &&
11582 MI.getOperand(3).getImm() == 0x0) ||
11583 (
MI.getOpcode() == AArch64::ORRWrr &&
11584 MI.getOperand(1).getReg() == AArch64::WZR)) {
11586 if ((
MI.getOperand(0).getReg().isPhysical() &&
11587 MI.findRegisterDefOperandIdx(
11590 (
MI.getOperand(0).getReg().isVirtual() &&
11591 !
MI.getOperand(0).getSubReg()))
11595 if (
MI.getOpcode() == AArch64::ORRXrs &&
11596 MI.getOperand(1).getReg() == AArch64::XZR &&
11597 MI.getOperand(3).getImm() == 0x0)
11600 return std::nullopt;
11603std::optional<DestSourcePair>
11605 if ((
MI.getOpcode() == AArch64::ORRWrs &&
11606 MI.getOperand(1).getReg() == AArch64::WZR &&
11607 MI.getOperand(3).getImm() == 0x0) ||
11608 (
MI.getOpcode() == AArch64::ORRWrr &&
11609 MI.getOperand(1).getReg() == AArch64::WZR))
11611 return std::nullopt;
11614std::optional<RegImmPair>
11623 return std::nullopt;
11625 switch (
MI.getOpcode()) {
11627 return std::nullopt;
11628 case AArch64::SUBWri:
11629 case AArch64::SUBXri:
11630 case AArch64::SUBSWri:
11631 case AArch64::SUBSXri:
11634 case AArch64::ADDSWri:
11635 case AArch64::ADDSXri:
11636 case AArch64::ADDWri:
11637 case AArch64::ADDXri: {
11639 if (!
MI.getOperand(0).isReg() || !
MI.getOperand(1).isReg() ||
11640 !
MI.getOperand(2).isImm())
11641 return std::nullopt;
11642 int Shift =
MI.getOperand(3).getImm();
11643 assert((Shift == 0 || Shift == 12) &&
"Shift can be either 0 or 12");
11647 return RegImmPair{
MI.getOperand(1).getReg(),
Offset};
11653static std::optional<ParamLoadedValue>
11657 auto DestSrc =
TII->isCopyLikeInstr(
MI);
11659 return std::nullopt;
11661 Register DestReg = DestSrc->Destination->getReg();
11662 Register SrcReg = DestSrc->Source->getReg();
11665 return std::nullopt;
11670 if (DestReg == DescribedReg)
11674 if (
MI.getOpcode() == AArch64::ORRWrs &&
11675 TRI->isSuperRegister(DestReg, DescribedReg))
11679 if (
MI.getOpcode() == AArch64::ORRXrs &&
11680 TRI->isSubRegister(DestReg, DescribedReg)) {
11681 Register SrcSubReg =
TRI->getSubReg(SrcReg, AArch64::sub_32);
11685 assert(!
TRI->isSuperOrSubRegisterEq(DestReg, DescribedReg) &&
11686 "Unhandled ORR[XW]rs copy case");
11688 return std::nullopt;
11691bool AArch64InstrInfo::isFunctionSafeToSplit(
const MachineFunction &MF)
const {
11696 if (MF.
getInfo<AArch64FunctionInfo>()->hasRedZone().value_or(
true))
11702bool AArch64InstrInfo::isMBBSafeToSplitToCold(
11706 auto isAsmGoto = [](
const MachineInstr &
MI) {
11707 return MI.getOpcode() == AArch64::INLINEASM_BR;
11717 auto containsMBB = [&
MBB](
const MachineJumpTableEntry &JTE) {
11724 for (
const MachineInstr &
MI :
MBB) {
11725 switch (
MI.getOpcode()) {
11726 case TargetOpcode::G_BRJT:
11727 case AArch64::JumpTableDest32:
11728 case AArch64::JumpTableDest16:
11729 case AArch64::JumpTableDest8:
11740std::optional<ParamLoadedValue>
11745 switch (
MI.getOpcode()) {
11746 case AArch64::MOVZWi:
11747 case AArch64::MOVZXi: {
11750 if (!
TRI->isSuperRegisterEq(
MI.getOperand(0).getReg(),
Reg))
11751 return std::nullopt;
11753 if (!
MI.getOperand(1).isImm())
11754 return std::nullopt;
11755 int64_t Immediate =
MI.getOperand(1).getImm();
11756 int Shift =
MI.getOperand(2).getImm();
11760 case AArch64::ORRWrs:
11761 case AArch64::ORRXrs:
11768bool AArch64InstrInfo::isExtendLikelyToBeFolded(
11771 ExtMI.
getOpcode() == TargetOpcode::G_ZEXT ||
11772 ExtMI.
getOpcode() == TargetOpcode::G_ANYEXT);
11775 if (ExtMI.
getOpcode() == TargetOpcode::G_ANYEXT)
11785 return UserMI->
getOpcode() == TargetOpcode::G_PTR_ADD;
11788uint64_t AArch64InstrInfo::getElementSizeForOpcode(
unsigned Opc)
const {
11792bool AArch64InstrInfo::isPTestLikeOpcode(
unsigned Opc)
const {
11796bool AArch64InstrInfo::isWhileOpcode(
unsigned Opc)
const {
11801AArch64InstrInfo::getTailDuplicateSize(
CodeGenOptLevel OptLevel)
const {
11805bool AArch64InstrInfo::isLegalAddressingMode(
unsigned NumBytes, int64_t
Offset,
11806 unsigned Scale)
const {
11817 unsigned Shift =
Log2_64(NumBytes);
11818 if (NumBytes &&
Offset > 0 && (
Offset / NumBytes) <= (1LL << 12) - 1 &&
11826 return Scale == 1 || (Scale > 0 && Scale == NumBytes);
11831 return AArch64::BLRNoIP;
11833 return AArch64::BLR;
11839 auto Builder =
BuildMI(
MBB, InsertPt,
DL,
get(AArch64::PAUTH_EPILOGUE))
11860 Register TargetReg,
bool FrameSetup)
const {
11861 assert(TargetReg != AArch64::SP &&
"New top of stack cannot already be in SP");
11873 MF.
insert(MBBInsertPoint, LoopTestMBB);
11876 MF.
insert(MBBInsertPoint, LoopBodyMBB);
11878 MF.
insert(MBBInsertPoint, ExitMBB);
11888 BuildMI(*LoopTestMBB, LoopTestMBB->
end(),
DL,
TII->get(AArch64::SUBSXrx64),
11896 BuildMI(*LoopTestMBB, LoopTestMBB->
end(),
DL,
TII->get(AArch64::Bcc))
11902 BuildMI(*LoopBodyMBB, LoopBodyMBB->
end(),
DL,
TII->get(AArch64::LDRXui))
11919 BuildMI(*ExitMBB, ExitMBB->
end(),
DL,
TII->get(AArch64::ADDXri), AArch64::SP)
11938 MBB.addSuccessor(LoopTestMBB);
11944 return ExitMBB->
begin();
11950 const TargetInstrInfo *
TII;
11951 const TargetRegisterInfo *
TRI;
11952 MachineRegisterInfo &MRI;
11955 MachineBasicBlock *LoopBB;
11957 MachineInstr *CondBranch;
11959 MachineInstr *Comp;
11961 unsigned CompCounterOprNum;
11963 MachineInstr *Update;
11965 unsigned UpdateCounterOprNum;
11969 bool IsUpdatePriorComp;
11972 SmallVector<MachineOperand, 4>
Cond;
11975 AArch64PipelinerLoopInfo(MachineBasicBlock *LoopBB, MachineInstr *CondBranch,
11976 MachineInstr *Comp,
unsigned CompCounterOprNum,
11977 MachineInstr *Update,
unsigned UpdateCounterOprNum,
11978 Register Init,
bool IsUpdatePriorComp,
11979 const SmallVectorImpl<MachineOperand> &
Cond)
11981 TII(MF->getSubtarget().getInstrInfo()),
11982 TRI(MF->getSubtarget().getRegisterInfo()), MRI(MF->getRegInfo()),
11983 LoopBB(LoopBB), CondBranch(CondBranch), Comp(Comp),
11984 CompCounterOprNum(CompCounterOprNum), Update(Update),
11985 UpdateCounterOprNum(UpdateCounterOprNum), Init(Init),
11988 bool shouldIgnoreForPipelining(
const MachineInstr *
MI)
const override {
11994 std::optional<bool> createTripCountGreaterCondition(
11995 int TC, MachineBasicBlock &
MBB,
11996 SmallVectorImpl<MachineOperand> &CondParam)
override {
12004 void createRemainingIterationsGreaterCondition(
12005 int TC, MachineBasicBlock &
MBB, SmallVectorImpl<MachineOperand> &
Cond,
12006 DenseMap<MachineInstr *, MachineInstr *> &LastStage0Insts)
override;
12008 void setPreheader(MachineBasicBlock *NewPreheader)
override {}
12010 void adjustTripCount(
int TripCountAdjust)
override {}
12012 bool isMVEExpanderSupported()
override {
return true; }
12031 }
else if (
I == ReplaceOprNum) {
12036 MBB.insert(InsertTo, NewMI);
12040void AArch64PipelinerLoopInfo::createRemainingIterationsGreaterCondition(
12056 assert(CondBranch->getOpcode() == AArch64::Bcc);
12060 if (CondBranch->getOperand(1).getMBB() == LoopBB)
12067 auto AccumulateCond = [&](
Register CurCond,
12078 if (!LastStage0Insts.
empty() && LastStage0Insts[Comp]->getParent() == &
MBB) {
12082 for (
int I = 0;
I <= TC; ++
I) {
12088 AccCond = AccumulateCond(AccCond, CC);
12092 if (Update != Comp && IsUpdatePriorComp) {
12094 LastStage0Insts[Comp]->getOperand(CompCounterOprNum).getReg();
12095 NextCounter =
cloneInstr(Update, UpdateCounterOprNum, Counter,
MBB,
12099 NextCounter = LastStage0Insts[Update]->getOperand(0).getReg();
12101 }
else if (Update != Comp) {
12106 Counter = NextCounter;
12110 if (LastStage0Insts.
empty()) {
12114 if (IsUpdatePriorComp)
12119 Counter = LastStage0Insts[Comp]->getOperand(CompCounterOprNum).getReg();
12122 for (
int I = 0;
I <= TC; ++
I) {
12126 AccCond = AccumulateCond(AccCond, CC);
12127 if (
I != TC && Update != Comp)
12130 Counter = NextCounter;
12146 assert(Phi.getNumOperands() == 5);
12147 if (Phi.getOperand(2).getMBB() ==
MBB) {
12148 RegMBB = Phi.getOperand(1).getReg();
12149 RegOther = Phi.getOperand(3).getReg();
12151 assert(Phi.getOperand(4).getMBB() ==
MBB);
12152 RegMBB = Phi.getOperand(3).getReg();
12153 RegOther = Phi.getOperand(1).getReg();
12158 if (!
Reg.isVirtual())
12167 unsigned &UpdateCounterOprNum,
Register &InitReg,
12168 bool &IsUpdatePriorComp) {
12182 if (!
Reg.isVirtual())
12185 UpdateInst =
nullptr;
12186 UpdateCounterOprNum = 0;
12188 IsUpdatePriorComp =
true;
12192 if (Def->getParent() != LoopBB)
12194 if (Def->isCopy()) {
12196 if (Def->getOperand(0).getSubReg() || Def->getOperand(1).getSubReg())
12198 CurReg = Def->getOperand(1).getReg();
12199 }
else if (Def->isPHI()) {
12203 IsUpdatePriorComp =
false;
12208 switch (Def->getOpcode()) {
12209 case AArch64::ADDSXri:
12210 case AArch64::ADDSWri:
12211 case AArch64::SUBSXri:
12212 case AArch64::SUBSWri:
12213 case AArch64::ADDXri:
12214 case AArch64::ADDWri:
12215 case AArch64::SUBXri:
12216 case AArch64::SUBWri:
12218 UpdateCounterOprNum = 1;
12220 case AArch64::ADDSXrr:
12221 case AArch64::ADDSWrr:
12222 case AArch64::SUBSXrr:
12223 case AArch64::SUBSWrr:
12224 case AArch64::ADDXrr:
12225 case AArch64::ADDWrr:
12226 case AArch64::SUBXrr:
12227 case AArch64::SUBWrr:
12230 UpdateCounterOprNum = 1;
12232 UpdateCounterOprNum = 2;
12239 CurReg = Def->getOperand(UpdateCounterOprNum).getReg();
12254std::unique_ptr<TargetInstrInfo::PipelinerLoopInfo>
12265 if (
MI.isCall() ||
MI.hasUnmodeledSideEffects())
12276 if (
TBB == LoopBB && FBB == LoopBB)
12280 if (
TBB != LoopBB && FBB ==
nullptr)
12283 assert((
TBB == LoopBB || FBB == LoopBB) &&
12284 "The Loop must be a single-basic-block loop");
12289 if (CondBranch->
getOpcode() != AArch64::Bcc)
12297 unsigned CompCounterOprNum = 0;
12299 if (
MI.modifiesRegister(AArch64::NZCV, &
TRI)) {
12303 switch (
MI.getOpcode()) {
12304 case AArch64::SUBSXri:
12305 case AArch64::SUBSWri:
12306 case AArch64::ADDSXri:
12307 case AArch64::ADDSWri:
12309 CompCounterOprNum = 1;
12311 case AArch64::ADDSWrr:
12312 case AArch64::ADDSXrr:
12313 case AArch64::SUBSWrr:
12314 case AArch64::SUBSXrr:
12318 if (isWhileOpcode(
MI.getOpcode())) {
12325 if (CompCounterOprNum == 0) {
12327 CompCounterOprNum = 2;
12329 CompCounterOprNum = 1;
12341 bool IsUpdatePriorComp;
12342 unsigned UpdateCounterOprNum;
12344 Update, UpdateCounterOprNum,
Init, IsUpdatePriorComp))
12347 return std::make_unique<AArch64PipelinerLoopInfo>(
12348 LoopBB, CondBranch, Comp, CompCounterOprNum, Update, UpdateCounterOprNum,
12358 TypeSize Scale(0U,
false), Width(0U,
false);
12359 int64_t MinOffset, MaxOffset;
12360 if (
getMemOpInfo(
MI.getOpcode(), Scale, Width, MinOffset, MaxOffset)) {
12362 if (
MI.getOperand(ImmIdx).isImm() && !
MI.getOperand(ImmIdx - 1).isFI()) {
12363 int64_t
Imm =
MI.getOperand(ImmIdx).getImm();
12365 ErrInfo =
"Unexpected immediate on load/store instruction";
12371 const MCInstrDesc &MCID =
MI.getDesc();
12373 const MachineOperand &MO =
MI.getOperand(
Op);
12377 ErrInfo =
"OPERAND_IMPLICIT_IMM_0 should be 0";
12386 ErrInfo =
"OPERAND_SHIFT_MSL should be msl shift of 8 or 16";
12392 ErrInfo =
"OPERAND_IMM_UINT1 should be 0 or 1";
12398 ErrInfo =
"OPERAND_IMM_UINT4plus1 should be in the range 1 to 16";
12404 ErrInfo =
"OPERAND_IMM_UINT5 should be in the range 0 to 31";
12410 ErrInfo =
"OPERAND_IMM_UINT8 should be in the range 0 to 255";
12421#define GET_INSTRINFO_HELPERS
12422#define GET_INSTRMAP_INFO
12423#include "AArch64GenInstrInfo.inc"
MachineInstrBuilder & UseMI
MachineInstrBuilder MachineInstrBuilder & DefMI
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 bool predictCompactUnwindFrameRecordForOutlinedFunction(std::vector< outliner::Candidate > &RepeatedSequenceLocs, const TargetRegisterInfo &TRI)
Predict what the above will answer, for use while costing candidates.
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 cl::opt< bool > UseCompactUnwindFrameRecordForOutlinedFunctions("aarch64-outliner-compact-unwind-frame", cl::Hidden, cl::init(true), cl::desc("Use a frame record for Mach-O non-leaf outlined functions"))
static bool shouldUseCompactUnwindFrameRecordForOutlinedFunction(const MachineBasicBlock &MBB)
Return true if the outlined function in MBB should save FP and LR as a frame record instead of saving...
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 bool isCompactUnwindFrameRecordEnabled(const MachineFunction &MF)
Return true if the frame-record form of the outlined prologue is enabled for the target of MF.
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 bool isValidCBExtend(int64_t Opc, AArch64_AM::ShiftExtendType Ext)
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< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
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.
Register const TargetRegisterInfo * TRI
Promote Memory to Register
static MCRegister getReg(const MCDisassembler *D, unsigned RC, unsigned RegNo)
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
unsigned getArgumentStackToRestore() const
SignReturnAddress getSignReturnAddressCondition() const
bool hasStreamingModeChanges() const
void setOutliningStyle(const std::string &Style)
bool branchProtectionPAuthLR() const
bool needsDwarfUnwindInfo(const MachineFunction &MF) 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 copyPhysRegImpl(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, Register DestReg, Register SrcReg, bool KillSrc, bool RenamableDest=false, bool RenamableSrc=false) const
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.
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
Register isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
bool getMemOperandsWithOffsetWidth(const MachineInstr &MI, SmallVectorImpl< const MachineOperand * > &BaseOps, int64_t &Offset, bool &OffsetIsScalable, LocationSize &Width) 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.
std::optional< ExtAddrMode > getAddrModeFromMemoryOp(const MachineInstr &MemI) const override
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
void copyPhysRegTuple(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, bool KillSrc, llvm::ArrayRef< unsigned > Indices) const
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
AArch64CC::CondCode insertCmpForCondBr(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, ArrayRef< MachineOperand > Cond) const
Inserts the compare instruction needed to un-fuse a fused conditional branch instruction and returns ...
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 getMemOperandWithOffsetWidth(const MachineInstr &MI, const MachineOperand *&BaseOp, int64_t &Offset, bool &OffsetIsScalable, TypeSize &Width) const
If OffsetIsScalable is set to 'true', the offset is scaled by vscale.
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.
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.
A set of register units used to track register liveness.
bool available(MCRegister Reg) const
Returns true if no part of physical register Reg is live.
LLVM_ABI void accumulate(const MachineInstr &MI)
Adds all register units used, defined or clobbered in MI.
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
bool hasSuperClassEq(const MCRegisterClass *RC) const
Returns true if RC is a super-class of or equal to this class.
bool contains(MCRegister Reg) const
contains - Return true if the specified register is included in this register class.
bool hasSubClassEq(const MCRegisterClass *RC) const
Returns true if RC is a sub-class of or equal to this class.
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.
iterator insertAfter(iterator I, MachineInstr *MI)
Insert MI into the instruction list after I.
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.
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...
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags F, LLT MemTy, Align BaseAlignment, const MMOMetadata &Metadata=MMOMetadata(), SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
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 LLVM_READONLY 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.
MachineBasicBlock * getDefBlock(Register Reg) const
Return the machine basic block in which the specified virtual register is defined,...
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...
use_instr_nodbg_iterator use_instr_nodbg_begin(Register RegNo) const
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 LLVM_READONLY 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.
const Triple & getTargetTriple() const
Get the target triple which is a string describing the target host.
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.
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.
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
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...
constexpr bool isLegalArithImmed(const uint64_t C)
isLegalArithImmed -
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.
@ 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 isLFIPrePostMemAccess(unsigned Opcode)
Returns true if Opcode is a pre- or post-indexed memory access that the LFI rewriter expands with a b...
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.
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly.
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.
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
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)
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.
constexpr auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.
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)
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Next
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 ...
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.
MCRegisterClass TargetRegisterClass
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.