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()) {
134 if (
MI.getOperand(0).getReg() != AArch64::LR)
147 case AArch64::BLRAAZ:
149 case AArch64::BLRABZ:
153 case AArch64::AUTIASP:
154 case AArch64::AUTIBSP:
155 case AArch64::AUTIAZ:
156 case AArch64::AUTIBZ:
157 case AArch64::XPACLRI:
162 if (
MI.getOperand(0).getImm() == 3 &&
MI.getOperand(1).getImm() == 7 &&
163 MI.getOperand(3).getImm() == 1)
171 bool ModifiesLR =
false;
172 bool ModifiesSP =
false;
176 if (MO.getReg() == AArch64::LR)
178 else if (MO.getReg() == AArch64::SP)
187 if (
MI.mayLoadOrStore()) {
195 if (ModifiesSP || ModifiesLR)
208 if (!
Desc.isPseudo() && !Subtarget.isLFI()) {
209 assert(
Desc.getSize() == 4 &&
"Unexpected instruction size");
219 auto Op =
MI.getOpcode();
220 if (
Op == AArch64::INLINEASM ||
Op == AArch64::INLINEASM_BR)
221 return getInlineAsmLength(
MI.getOperand(0).getSymbolName(), MAI);
225 if (
MI.isMetaInstruction())
230 unsigned NumBytes = 0;
239 NumBytes =
Desc.getSize() ?
Desc.getSize() : 4;
242 if (!MFI->shouldSignReturnAddress(*MF))
245 auto Method = STI.getAuthenticatedLRCheckMethod(*MF);
253 switch (
Desc.getOpcode()) {
256 return Desc.getSize();
263 case TargetOpcode::STACKMAP:
266 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
268 case TargetOpcode::PATCHPOINT:
271 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
273 case TargetOpcode::STATEPOINT:
275 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
280 case TargetOpcode::PATCHABLE_FUNCTION_ENTER:
285 F.getFnAttributeAsParsedInteger(
"patchable-function-entry", 9) * 4;
287 case TargetOpcode::PATCHABLE_FUNCTION_EXIT:
288 case TargetOpcode::PATCHABLE_TAIL_CALL:
289 case TargetOpcode::PATCHABLE_TYPED_EVENT_CALL:
293 case TargetOpcode::PATCHABLE_EVENT_CALL:
299 NumBytes =
MI.getOperand(1).getImm();
301 case AArch64::MOVaddr:
302 case AArch64::MOVaddrJT:
303 case AArch64::MOVaddrCP:
304 case AArch64::MOVaddrBA:
305 case AArch64::MOVaddrTLS:
306 case AArch64::MOVaddrEXT: {
310 MI.getOperand(1).getTargetFlags(),
311 Subtarget.isTargetMachO(), Insn);
312 NumBytes = Insn.
size() * 4;
316 case AArch64::MOVi32imm:
317 case AArch64::MOVi64imm: {
319 unsigned BitSize =
Desc.getOpcode() == AArch64::MOVi32imm ? 32 : 64;
322 NumBytes = Insn.
size() * 4;
326 case TargetOpcode::BUNDLE:
327 NumBytes = getInstBundleSize(
MI);
363 case AArch64::CBWPri:
364 case AArch64::CBXPri:
365 case AArch64::CBWPrr:
366 case AArch64::CBXPrr:
374 case AArch64::CBBAssertExt:
375 case AArch64::CBHAssertExt:
406 case AArch64::CBWPri:
407 case AArch64::CBXPri:
408 case AArch64::CBBAssertExt:
409 case AArch64::CBHAssertExt:
410 case AArch64::CBWPrr:
411 case AArch64::CBXPrr:
417 int64_t BrOffset)
const {
419 assert(Bits >= 3 &&
"max branch displacement must be enough to jump"
420 "over conditional branch expansion");
421 return isIntN(Bits, BrOffset / 4);
426 switch (
MI.getOpcode()) {
430 return MI.getOperand(0).getMBB();
435 return MI.getOperand(2).getMBB();
441 return MI.getOperand(1).getMBB();
442 case AArch64::CBWPri:
443 case AArch64::CBXPri:
444 case AArch64::CBBAssertExt:
445 case AArch64::CBHAssertExt:
446 case AArch64::CBWPrr:
447 case AArch64::CBXPrr:
448 return MI.getOperand(3).getMBB();
458 assert(RS &&
"RegScavenger required for long branching");
460 "new block should be inserted for expanding unconditional branch");
463 "restore block should be inserted for restoring clobbered registers");
470 "Branch offsets outside of the signed 33-bit range not supported");
481 RS->enterBasicBlockEnd(
MBB);
484 constexpr Register Reg = AArch64::X16;
485 if (!RS->isRegUsed(Reg)) {
486 insertUnconditionalBranch(
MBB, &NewDestBB,
DL);
497 Register Scavenged = RS->FindUnusedReg(&AArch64::GPR64RegClass);
498 if (Scavenged != AArch64::NoRegister) {
499 buildIndirectBranch(Scavenged, NewDestBB);
500 RS->setRegUsed(Scavenged);
509 "Unable to insert indirect branch inside function that has red zone");
532 bool AllowModify)
const {
539 if (
I->getOpcode() == AArch64::SpeculationBarrierISBDSBEndBB ||
540 I->getOpcode() == AArch64::SpeculationBarrierSBEndBB) {
544 if (!isUnpredicatedTerminator(*
I))
551 unsigned LastOpc = LastInst->
getOpcode();
552 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
567 unsigned SecondLastOpc = SecondLastInst->
getOpcode();
574 LastInst = SecondLastInst;
576 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
581 SecondLastInst = &*
I;
582 SecondLastOpc = SecondLastInst->
getOpcode();
593 LastInst = SecondLastInst;
595 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
597 "unreachable unconditional branches removed above");
606 SecondLastInst = &*
I;
607 SecondLastOpc = SecondLastInst->
getOpcode();
611 if (SecondLastInst &&
I !=
MBB.begin() && isUnpredicatedTerminator(*--
I))
627 I->eraseFromParent();
636 I->eraseFromParent();
645 MachineBranchPredicate &MBP,
646 bool AllowModify)
const {
658 assert(MBP.TrueDest &&
"expected!");
659 MBP.FalseDest = FBB ? FBB :
MBB.getNextNode();
661 MBP.ConditionDef =
nullptr;
662 MBP.SingleUseCondition =
false;
672 if (
I ==
MBB.begin())
688 if (
MI.modifiesRegister(AArch64::NZCV,
nullptr)) {
689 MBP.ConditionDef = &
MI;
698 case AArch64::CBNZX: {
702 MBP.Predicate = (
Opc == AArch64::CBNZX ||
Opc == AArch64::CBNZW)
703 ? MachineBranchPredicate::PRED_NE
704 : MachineBranchPredicate::PRED_EQ;
705 Register CondReg = MBP.LHS.getReg();
714 case AArch64::TBNZX: {
735 Cond[1].setImm(AArch64::CBNZW);
738 Cond[1].setImm(AArch64::CBZW);
741 Cond[1].setImm(AArch64::CBNZX);
744 Cond[1].setImm(AArch64::CBZX);
747 Cond[1].setImm(AArch64::TBNZW);
750 Cond[1].setImm(AArch64::TBZW);
753 Cond[1].setImm(AArch64::TBNZX);
756 Cond[1].setImm(AArch64::TBZX);
760 case AArch64::CBWPri:
761 case AArch64::CBXPri:
762 case AArch64::CBBAssertExt:
763 case AArch64::CBHAssertExt:
764 case AArch64::CBWPrr:
765 case AArch64::CBXPrr: {
778 int *BytesRemoved)
const {
788 I->eraseFromParent();
792 if (
I ==
MBB.begin()) {
805 I->eraseFromParent();
812void AArch64InstrInfo::instantiateCondBranch(
837 if (
Cond.size() > 5) {
848 assert(
TBB &&
"insertBranch must not be told to insert a fallthrough");
879 return Opc == AArch64::CBBAssertExt;
882 return Opc == AArch64::CBHAssertExt;
894 switch (
Cond.size()) {
969 unsigned SubsOpc, SubsDestReg;
975 case AArch64::CBWPri:
976 SubsOpc = AArch64::SUBSWri;
977 SubsDestReg = AArch64::WZR;
980 case AArch64::CBXPri:
981 SubsOpc = AArch64::SUBSXri;
982 SubsDestReg = AArch64::XZR;
985 case AArch64::CBWPrr:
986 SubsOpc = AArch64::SUBSWrr;
987 SubsDestReg = AArch64::WZR;
990 case AArch64::CBXPrr:
991 SubsOpc = AArch64::SUBSXrr;
992 SubsDestReg = AArch64::XZR;
1026 "Unexpected compare-and-branch instruction for extend type");
1027 switch (ExtendType) {
1031 ExtOpc = AArch64::SBFMWri;
1035 ExtOpc = AArch64::SBFMWri;
1039 ExtOpc = AArch64::ANDWri;
1043 ExtOpc = AArch64::ANDWri;
1052 if (ExtOpc != AArch64::ANDWri)
1054 MBBI.addImm(ExtBits);
1063 "Unexpected compare-and-branch instruction for extend type");
1084 unsigned Opc =
MI.getOpcode();
1091 if (
MI.getOperand(0).getReg() == AArch64::WZR ||
1092 MI.getOperand(0).getReg() == AArch64::XZR) {
1094 dbgs() <<
"Removing always taken branch: " <<
MI);
1097 for (
auto *S : Succs)
1099 MBB->removeSuccessor(S);
1101 while (
MBB->rbegin() != &
MI)
1102 MBB->rbegin()->eraseFromParent();
1103 MI.eraseFromParent();
1108 case AArch64::CBNZW:
1109 case AArch64::CBNZX:
1110 case AArch64::TBNZW:
1111 case AArch64::TBNZX:
1113 if (
MI.getOperand(0).getReg() == AArch64::WZR ||
1114 MI.getOperand(0).getReg() == AArch64::XZR) {
1116 dbgs() <<
"Removing never taken branch: " <<
MI);
1118 MI.getParent()->removeSuccessor(
Target);
1119 MI.eraseFromParent();
1134 VReg =
DefMI->getOperand(1).getReg();
1143 unsigned *NewReg =
nullptr) {
1148 bool Is64Bit = AArch64::GPR64allRegClass.hasSubClassEq(MRI.
getRegClass(VReg));
1153 unsigned SrcReg = 0;
1154 switch (
DefMI->getOpcode()) {
1155 case AArch64::SUBREG_TO_REG:
1159 if (!
DefMI->getOperand(1).isReg())
1161 if (!
DefMI->getOperand(2).isImm() ||
1162 DefMI->getOperand(2).getImm() != AArch64::sub_32)
1165 if (
DefMI->getOpcode() != AArch64::MOVi32imm)
1167 if (!
DefMI->getOperand(1).isImm() ||
DefMI->getOperand(1).getImm() != 1)
1170 SrcReg = AArch64::XZR;
1171 Opc = AArch64::CSINCXr;
1174 case AArch64::MOVi32imm:
1175 case AArch64::MOVi64imm:
1176 if (!
DefMI->getOperand(1).isImm() ||
DefMI->getOperand(1).getImm() != 1)
1178 SrcReg = Is64Bit ? AArch64::XZR : AArch64::WZR;
1179 Opc = Is64Bit ? AArch64::CSINCXr : AArch64::CSINCWr;
1182 case AArch64::ADDSXri:
1183 case AArch64::ADDSWri:
1185 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
1190 case AArch64::ADDXri:
1191 case AArch64::ADDWri:
1193 if (!
DefMI->getOperand(2).isImm() ||
DefMI->getOperand(2).getImm() != 1 ||
1194 DefMI->getOperand(3).getImm() != 0)
1196 SrcReg =
DefMI->getOperand(1).getReg();
1197 Opc = Is64Bit ? AArch64::CSINCXr : AArch64::CSINCWr;
1200 case AArch64::ORNXrr:
1201 case AArch64::ORNWrr: {
1204 if (ZReg != AArch64::XZR && ZReg != AArch64::WZR)
1206 SrcReg =
DefMI->getOperand(2).getReg();
1207 Opc = Is64Bit ? AArch64::CSINVXr : AArch64::CSINVWr;
1211 case AArch64::SUBSXrr:
1212 case AArch64::SUBSWrr:
1214 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
1219 case AArch64::SUBXrr:
1220 case AArch64::SUBWrr: {
1223 if (ZReg != AArch64::XZR && ZReg != AArch64::WZR)
1225 SrcReg =
DefMI->getOperand(2).getReg();
1226 Opc = Is64Bit ? AArch64::CSNEGXr : AArch64::CSNEGWr;
1232 assert(
Opc && SrcReg &&
"Missing parameters");
1242 Register FalseReg,
int &CondCycles,
1244 int &FalseCycles)
const {
1255 if (!RI.getCommonSubClass(RC, MRI.
getRegClass(DstReg)))
1259 unsigned ExtraCondLat =
Cond.size() != 1;
1263 if (AArch64::GPR64allRegClass.hasSubClassEq(RC) ||
1264 AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
1266 CondCycles = 1 + ExtraCondLat;
1267 TrueCycles = FalseCycles = 1;
1277 if (AArch64::FPR64RegClass.hasSubClassEq(RC) ||
1278 AArch64::FPR32RegClass.hasSubClassEq(RC)) {
1279 CondCycles = 5 + ExtraCondLat;
1280 TrueCycles = FalseCycles = 2;
1299 bool TryFold =
false;
1301 RC = &AArch64::GPR64RegClass;
1302 Opc = AArch64::CSELXr;
1305 RC = &AArch64::GPR32RegClass;
1306 Opc = AArch64::CSELWr;
1309 RC = &AArch64::FPR64RegClass;
1310 Opc = AArch64::FCSELDrrr;
1312 RC = &AArch64::FPR32RegClass;
1313 Opc = AArch64::FCSELSrrr;
1315 assert(RC &&
"Unsupported regclass");
1319 unsigned NewReg = 0;
1342 (FalseReg.
isVirtual() || FalseReg == AArch64::WZR ||
1343 FalseReg == AArch64::XZR) &&
1344 "FalseReg was folded into a non-virtual register other than WZR or XZR");
1361 assert(BitSize == 64 &&
"Only bit sizes of 32 or 64 allowed");
1366 return Is.
size() <= 2;
1371 assert(
MI.isCopy() &&
"Expected COPY instruction");
1377 if (
Reg.isVirtual())
1379 if (
Reg.isPhysical())
1380 return RI.getMinimalPhysRegClass(
Reg);
1385 if (DstRC && SrcRC && !RI.getCommonSubClass(DstRC, SrcRC))
1388 return MI.isAsCheapAsAMove();
1394 if (Subtarget.hasExynosCheapAsMoveHandling()) {
1395 if (isExynosCheapAsMove(
MI))
1397 return MI.isAsCheapAsAMove();
1400 switch (
MI.getOpcode()) {
1402 return MI.isAsCheapAsAMove();
1404 case TargetOpcode::COPY:
1407 case AArch64::ADDWrs:
1408 case AArch64::ADDXrs:
1409 case AArch64::SUBWrs:
1410 case AArch64::SUBXrs:
1411 return Subtarget.hasALULSLFast() &&
MI.getOperand(3).getImm() <= 4;
1416 case AArch64::MOVi32imm:
1418 case AArch64::MOVi64imm:
1423bool AArch64InstrInfo::isFalkorShiftExtFast(
const MachineInstr &
MI) {
1424 switch (
MI.getOpcode()) {
1428 case AArch64::ADDWrs:
1429 case AArch64::ADDXrs:
1430 case AArch64::ADDSWrs:
1431 case AArch64::ADDSXrs: {
1432 unsigned Imm =
MI.getOperand(3).getImm();
1439 case AArch64::ADDWrx:
1440 case AArch64::ADDXrx:
1441 case AArch64::ADDXrx64:
1442 case AArch64::ADDSWrx:
1443 case AArch64::ADDSXrx:
1444 case AArch64::ADDSXrx64: {
1445 unsigned Imm =
MI.getOperand(3).getImm();
1457 case AArch64::SUBWrs:
1458 case AArch64::SUBSWrs: {
1459 unsigned Imm =
MI.getOperand(3).getImm();
1461 return ShiftVal == 0 ||
1465 case AArch64::SUBXrs:
1466 case AArch64::SUBSXrs: {
1467 unsigned Imm =
MI.getOperand(3).getImm();
1469 return ShiftVal == 0 ||
1473 case AArch64::SUBWrx:
1474 case AArch64::SUBXrx:
1475 case AArch64::SUBXrx64:
1476 case AArch64::SUBSWrx:
1477 case AArch64::SUBSXrx:
1478 case AArch64::SUBSXrx64: {
1479 unsigned Imm =
MI.getOperand(3).getImm();
1491 case AArch64::LDRBBroW:
1492 case AArch64::LDRBBroX:
1493 case AArch64::LDRBroW:
1494 case AArch64::LDRBroX:
1495 case AArch64::LDRDroW:
1496 case AArch64::LDRDroX:
1497 case AArch64::LDRHHroW:
1498 case AArch64::LDRHHroX:
1499 case AArch64::LDRHroW:
1500 case AArch64::LDRHroX:
1501 case AArch64::LDRQroW:
1502 case AArch64::LDRQroX:
1503 case AArch64::LDRSBWroW:
1504 case AArch64::LDRSBWroX:
1505 case AArch64::LDRSBXroW:
1506 case AArch64::LDRSBXroX:
1507 case AArch64::LDRSHWroW:
1508 case AArch64::LDRSHWroX:
1509 case AArch64::LDRSHXroW:
1510 case AArch64::LDRSHXroX:
1511 case AArch64::LDRSWroW:
1512 case AArch64::LDRSWroX:
1513 case AArch64::LDRSroW:
1514 case AArch64::LDRSroX:
1515 case AArch64::LDRWroW:
1516 case AArch64::LDRWroX:
1517 case AArch64::LDRXroW:
1518 case AArch64::LDRXroX:
1519 case AArch64::PRFMroW:
1520 case AArch64::PRFMroX:
1521 case AArch64::STRBBroW:
1522 case AArch64::STRBBroX:
1523 case AArch64::STRBroW:
1524 case AArch64::STRBroX:
1525 case AArch64::STRDroW:
1526 case AArch64::STRDroX:
1527 case AArch64::STRHHroW:
1528 case AArch64::STRHHroX:
1529 case AArch64::STRHroW:
1530 case AArch64::STRHroX:
1531 case AArch64::STRQroW:
1532 case AArch64::STRQroX:
1533 case AArch64::STRSroW:
1534 case AArch64::STRSroX:
1535 case AArch64::STRWroW:
1536 case AArch64::STRWroX:
1537 case AArch64::STRXroW:
1538 case AArch64::STRXroX: {
1539 unsigned IsSigned =
MI.getOperand(3).getImm();
1546 unsigned Opc =
MI.getOpcode();
1550 case AArch64::SEH_StackAlloc:
1551 case AArch64::SEH_SaveFPLR:
1552 case AArch64::SEH_SaveFPLR_X:
1553 case AArch64::SEH_SaveReg:
1554 case AArch64::SEH_SaveReg_X:
1555 case AArch64::SEH_SaveRegP:
1556 case AArch64::SEH_SaveRegP_X:
1557 case AArch64::SEH_SaveFReg:
1558 case AArch64::SEH_SaveFReg_X:
1559 case AArch64::SEH_SaveFRegP:
1560 case AArch64::SEH_SaveFRegP_X:
1561 case AArch64::SEH_SetFP:
1562 case AArch64::SEH_AddFP:
1563 case AArch64::SEH_Nop:
1564 case AArch64::SEH_PrologEnd:
1565 case AArch64::SEH_EpilogStart:
1566 case AArch64::SEH_EpilogEnd:
1567 case AArch64::SEH_PACSignLR:
1568 case AArch64::SEH_SaveAnyRegI:
1569 case AArch64::SEH_SaveAnyRegIP:
1570 case AArch64::SEH_SaveAnyRegQP:
1571 case AArch64::SEH_SaveAnyRegQPX:
1572 case AArch64::SEH_AllocZ:
1573 case AArch64::SEH_SaveZReg:
1574 case AArch64::SEH_SavePReg:
1581 unsigned &SubIdx)
const {
1582 switch (
MI.getOpcode()) {
1585 case AArch64::SBFMXri:
1586 case AArch64::UBFMXri:
1589 if (
MI.getOperand(2).getImm() != 0 ||
MI.getOperand(3).getImm() != 31)
1592 SrcReg =
MI.getOperand(1).getReg();
1593 DstReg =
MI.getOperand(0).getReg();
1594 SubIdx = AArch64::sub_32;
1603 int64_t OffsetA = 0, OffsetB = 0;
1604 TypeSize WidthA(0,
false), WidthB(0,
false);
1605 bool OffsetAIsScalable =
false, OffsetBIsScalable =
false;
1626 OffsetAIsScalable == OffsetBIsScalable) {
1627 int LowOffset = OffsetA < OffsetB ? OffsetA : OffsetB;
1628 int HighOffset = OffsetA < OffsetB ? OffsetB : OffsetA;
1629 TypeSize LowWidth = (LowOffset == OffsetA) ? WidthA : WidthB;
1630 if (LowWidth.
isScalable() == OffsetAIsScalable &&
1648 switch (
MI.getOpcode()) {
1651 if (
MI.getOperand(0).getImm() == 0x14)
1658 case AArch64::MSRpstatesvcrImm1:
1665 auto Next = std::next(
MI.getIterator());
1666 return Next !=
MBB->end() &&
Next->isCFIInstruction();
1673 Register &SrcReg2, int64_t &CmpMask,
1674 int64_t &CmpValue)
const {
1678 assert(
MI.getNumOperands() >= 2 &&
"All AArch64 cmps should have 2 operands");
1679 if (!
MI.getOperand(1).isReg() ||
MI.getOperand(1).getSubReg())
1682 switch (
MI.getOpcode()) {
1685 case AArch64::PTEST_PP:
1686 case AArch64::PTEST_PP_ANY:
1687 case AArch64::PTEST_PP_FIRST:
1688 SrcReg =
MI.getOperand(0).getReg();
1689 SrcReg2 =
MI.getOperand(1).getReg();
1690 if (
MI.getOperand(2).getSubReg())
1697 case AArch64::SUBSWrr:
1698 case AArch64::SUBSWrs:
1699 case AArch64::SUBSWrx:
1700 case AArch64::SUBSXrr:
1701 case AArch64::SUBSXrs:
1702 case AArch64::SUBSXrx:
1703 case AArch64::ADDSWrr:
1704 case AArch64::ADDSWrs:
1705 case AArch64::ADDSWrx:
1706 case AArch64::ADDSXrr:
1707 case AArch64::ADDSXrs:
1708 case AArch64::ADDSXrx:
1710 SrcReg =
MI.getOperand(1).getReg();
1711 SrcReg2 =
MI.getOperand(2).getReg();
1714 if (
MI.getOperand(2).getSubReg())
1720 case AArch64::SUBSWri:
1721 case AArch64::ADDSWri:
1722 case AArch64::SUBSXri:
1723 case AArch64::ADDSXri:
1724 SrcReg =
MI.getOperand(1).getReg();
1727 CmpValue =
MI.getOperand(2).getImm();
1729 case AArch64::ANDSWri:
1730 case AArch64::ANDSXri:
1733 SrcReg =
MI.getOperand(1).getReg();
1737 MI.getOperand(2).getImm(),
1738 MI.getOpcode() == AArch64::ANDSWri ? 32 : 64);
1747 assert(
MBB &&
"Can't get MachineBasicBlock here");
1749 assert(MF &&
"Can't get MachineFunction here");
1754 for (
unsigned OpIdx = 0, EndIdx = Instr.getNumOperands(); OpIdx < EndIdx;
1758 Instr.getRegClassConstraint(OpIdx,
TII,
TRI);
1761 if (!OpRegCstraints)
1769 "Operand has register constraints without being a register!");
1772 if (
Reg.isPhysical()) {
1789 bool MIDefinesZeroReg =
false;
1790 if (
MI.definesRegister(AArch64::WZR,
nullptr) ||
1791 MI.definesRegister(AArch64::XZR,
nullptr))
1792 MIDefinesZeroReg =
true;
1794 switch (
MI.getOpcode()) {
1796 return MI.getOpcode();
1797 case AArch64::ADDSWrr:
1798 return AArch64::ADDWrr;
1799 case AArch64::ADDSWri:
1800 return MIDefinesZeroReg ? AArch64::ADDSWri : AArch64::ADDWri;
1801 case AArch64::ADDSWrs:
1802 return MIDefinesZeroReg ? AArch64::ADDSWrs : AArch64::ADDWrs;
1803 case AArch64::ADDSWrx:
1804 return AArch64::ADDWrx;
1805 case AArch64::ADDSXrr:
1806 return AArch64::ADDXrr;
1807 case AArch64::ADDSXri:
1808 return MIDefinesZeroReg ? AArch64::ADDSXri : AArch64::ADDXri;
1809 case AArch64::ADDSXrs:
1810 return MIDefinesZeroReg ? AArch64::ADDSXrs : AArch64::ADDXrs;
1811 case AArch64::ADDSXrx:
1812 return AArch64::ADDXrx;
1813 case AArch64::SUBSWrr:
1814 return AArch64::SUBWrr;
1815 case AArch64::SUBSWri:
1816 return MIDefinesZeroReg ? AArch64::SUBSWri : AArch64::SUBWri;
1817 case AArch64::SUBSWrs:
1818 return MIDefinesZeroReg ? AArch64::SUBSWrs : AArch64::SUBWrs;
1819 case AArch64::SUBSWrx:
1820 return AArch64::SUBWrx;
1821 case AArch64::SUBSXrr:
1822 return AArch64::SUBXrr;
1823 case AArch64::SUBSXri:
1824 return MIDefinesZeroReg ? AArch64::SUBSXri : AArch64::SUBXri;
1825 case AArch64::SUBSXrs:
1826 return MIDefinesZeroReg ? AArch64::SUBSXrs : AArch64::SUBXrs;
1827 case AArch64::SUBSXrx:
1828 return AArch64::SUBXrx;
1843 if (To == To->getParent()->begin())
1848 if (To->getParent() != From->getParent())
1860 Instr.modifiesRegister(AArch64::NZCV,
TRI)) ||
1861 ((AccessToCheck &
AK_Read) && Instr.readsRegister(AArch64::NZCV,
TRI)))
1867std::optional<unsigned>
1871 unsigned MaskOpcode =
Mask->getOpcode();
1872 unsigned PredOpcode = Pred->
getOpcode();
1873 bool PredIsPTestLike = isPTestLikeOpcode(PredOpcode);
1874 bool PredIsWhileLike = isWhileOpcode(PredOpcode);
1876 if (PredIsWhileLike) {
1880 if ((Mask == Pred) && PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1887 getElementSizeForOpcode(MaskOpcode) ==
1888 getElementSizeForOpcode(PredOpcode))
1894 if (PTest->
getOpcode() == AArch64::PTEST_PP_FIRST &&
1901 if (PredIsPTestLike) {
1906 if ((Mask == Pred) && PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1914 if (Mask != PTestLikeMask && PTestLikeMask->isFullCopy() &&
1915 PTestLikeMask->getOperand(1).getReg().isVirtual())
1923 getElementSizeForOpcode(MaskOpcode) ==
1924 getElementSizeForOpcode(PredOpcode)) {
1925 if (Mask == PTestLikeMask || PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1951 uint64_t PredElementSize = getElementSizeForOpcode(PredOpcode);
1953 PTest->
getOpcode() == AArch64::PTEST_PP_ANY))
1961 switch (PredOpcode) {
1962 case AArch64::AND_PPzPP:
1963 case AArch64::BIC_PPzPP:
1964 case AArch64::EOR_PPzPP:
1965 case AArch64::NAND_PPzPP:
1966 case AArch64::NOR_PPzPP:
1967 case AArch64::ORN_PPzPP:
1968 case AArch64::ORR_PPzPP:
1969 case AArch64::BRKA_PPzP:
1970 case AArch64::BRKPA_PPzPP:
1971 case AArch64::BRKB_PPzP:
1972 case AArch64::BRKPB_PPzPP:
1973 case AArch64::RDFFR_PPz: {
1977 if (Mask != PredMask)
1981 case AArch64::BRKN_PPzP: {
1985 if ((MaskOpcode != AArch64::PTRUE_B) ||
1986 (
Mask->getOperand(1).getImm() != 31))
1990 case AArch64::PTRUE_B:
2003bool AArch64InstrInfo::optimizePTestInstr(
2004 MachineInstr *PTest,
unsigned MaskReg,
unsigned PredReg,
2009 if (Pred->
isCopy() && PTest->
getOpcode() == AArch64::PTEST_PP_FIRST) {
2013 if (
Op.isReg() &&
Op.getReg().isVirtual() &&
2014 Op.getSubReg() == AArch64::psub0)
2018 unsigned PredOpcode = Pred->
getOpcode();
2019 auto NewOp = canRemovePTestInstr(PTest, Mask, Pred, MRI);
2035 if (*NewOp != PredOpcode) {
2046 for (; i !=
e; ++i) {
2077 if (DeadNZCVIdx != -1) {
2096 if (CmpInstr.
getOpcode() == AArch64::PTEST_PP ||
2097 CmpInstr.
getOpcode() == AArch64::PTEST_PP_ANY ||
2098 CmpInstr.
getOpcode() == AArch64::PTEST_PP_FIRST)
2099 return optimizePTestInstr(&CmpInstr, SrcReg, SrcReg2, MRI);
2108 if (CmpValue == 0 && substituteCmpToZero(CmpInstr, SrcReg, *MRI))
2110 return (CmpValue == 0 || CmpValue == 1) &&
2111 removeCmpToZeroOrOne(CmpInstr, SrcReg, CmpValue, *MRI);
2119 switch (Instr.getOpcode()) {
2121 return AArch64::INSTRUCTION_LIST_END;
2123 case AArch64::ADDSWrr:
2124 case AArch64::ADDSWri:
2125 case AArch64::ADDSXrr:
2126 case AArch64::ADDSXri:
2127 case AArch64::ADDSWrx:
2128 case AArch64::ADDSXrx:
2129 case AArch64::ADDSWrs:
2130 case AArch64::ADDSXrs:
2131 case AArch64::SUBSWrr:
2132 case AArch64::SUBSWri:
2133 case AArch64::SUBSWrx:
2134 case AArch64::SUBSWrs:
2135 case AArch64::SUBSXrr:
2136 case AArch64::SUBSXri:
2137 case AArch64::SUBSXrx:
2138 case AArch64::SUBSXrs:
2139 case AArch64::ANDSWri:
2140 case AArch64::ANDSWrr:
2141 case AArch64::ANDSWrs:
2142 case AArch64::ANDSXri:
2143 case AArch64::ANDSXrr:
2144 case AArch64::ANDSXrs:
2145 case AArch64::BICSWrr:
2146 case AArch64::BICSXrr:
2147 case AArch64::BICSWrs:
2148 case AArch64::BICSXrs:
2149 case AArch64::ADCSWr:
2150 case AArch64::ADCSXr:
2151 case AArch64::SBCSWr:
2152 case AArch64::SBCSXr:
2153 return Instr.getOpcode();
2155 case AArch64::ADDWrr:
2156 return AArch64::ADDSWrr;
2157 case AArch64::ADDWri:
2158 return AArch64::ADDSWri;
2159 case AArch64::ADDXrr:
2160 return AArch64::ADDSXrr;
2161 case AArch64::ADDXri:
2162 return AArch64::ADDSXri;
2163 case AArch64::ADDWrx:
2164 return AArch64::ADDSWrx;
2165 case AArch64::ADDXrx:
2166 return AArch64::ADDSXrx;
2167 case AArch64::ADDWrs:
2168 return AArch64::ADDSWrs;
2169 case AArch64::ADDXrs:
2170 return AArch64::ADDSXrs;
2171 case AArch64::ADCWr:
2172 return AArch64::ADCSWr;
2173 case AArch64::ADCXr:
2174 return AArch64::ADCSXr;
2175 case AArch64::SUBWrr:
2176 return AArch64::SUBSWrr;
2177 case AArch64::SUBWri:
2178 return AArch64::SUBSWri;
2179 case AArch64::SUBXrr:
2180 return AArch64::SUBSXrr;
2181 case AArch64::SUBXri:
2182 return AArch64::SUBSXri;
2183 case AArch64::SUBWrx:
2184 return AArch64::SUBSWrx;
2185 case AArch64::SUBXrx:
2186 return AArch64::SUBSXrx;
2187 case AArch64::SUBWrs:
2188 return AArch64::SUBSWrs;
2189 case AArch64::SUBXrs:
2190 return AArch64::SUBSXrs;
2191 case AArch64::SBCWr:
2192 return AArch64::SBCSWr;
2193 case AArch64::SBCXr:
2194 return AArch64::SBCSXr;
2195 case AArch64::ANDWri:
2196 return AArch64::ANDSWri;
2197 case AArch64::ANDXri:
2198 return AArch64::ANDSXri;
2199 case AArch64::ANDWrr:
2200 return AArch64::ANDSWrr;
2201 case AArch64::ANDWrs:
2202 return AArch64::ANDSWrs;
2203 case AArch64::ANDXrr:
2204 return AArch64::ANDSXrr;
2205 case AArch64::ANDXrs:
2206 return AArch64::ANDSXrs;
2207 case AArch64::BICWrr:
2208 return AArch64::BICSWrr;
2209 case AArch64::BICXrr:
2210 return AArch64::BICSXrr;
2211 case AArch64::BICWrs:
2212 return AArch64::BICSWrs;
2213 case AArch64::BICXrs:
2214 return AArch64::BICSXrs;
2220 for (
auto *BB :
MBB->successors())
2221 if (BB->isLiveIn(AArch64::NZCV))
2228int AArch64InstrInfo::findCondCodeUseOperandIdxForBranchOrSelect(
2230 switch (
Instr.getOpcode()) {
2234 case AArch64::Bcc: {
2235 int Idx =
Instr.findRegisterUseOperandIdx(AArch64::NZCV,
nullptr);
2240 case AArch64::CSINVWr:
2241 case AArch64::CSINVXr:
2242 case AArch64::CSINCWr:
2243 case AArch64::CSINCXr:
2244 case AArch64::CSELWr:
2245 case AArch64::CSELXr:
2246 case AArch64::CSNEGWr:
2247 case AArch64::CSNEGXr:
2248 case AArch64::FCSELSrrr:
2249 case AArch64::FCSELDrrr: {
2250 int Idx =
Instr.findRegisterUseOperandIdx(AArch64::NZCV,
nullptr);
2262 AArch64InstrInfo::findCondCodeUseOperandIdxForBranchOrSelect(Instr);
2264 Instr.getOperand(CCIdx).
getImm())
2317std::optional<UsedNZCV>
2322 if (
MI.getParent() != CmpParent)
2323 return std::nullopt;
2326 return std::nullopt;
2331 if (Instr.readsRegister(AArch64::NZCV, &
TRI)) {
2334 return std::nullopt;
2339 if (Instr.modifiesRegister(AArch64::NZCV, &
TRI))
2342 return NZCVUsedAfterCmp;
2346 return Opcode == AArch64::ADDSWri || Opcode == AArch64::ADDSXri;
2350 return Opcode == AArch64::SUBSWri || Opcode == AArch64::SUBSXri;
2356 case AArch64::ANDSWri:
2357 case AArch64::ANDSWrr:
2358 case AArch64::ANDSWrs:
2359 case AArch64::ANDSXri:
2360 case AArch64::ANDSXrr:
2361 case AArch64::ANDSXrs:
2362 case AArch64::BICSWrr:
2363 case AArch64::BICSXrr:
2364 case AArch64::BICSWrs:
2365 case AArch64::BICSXrs:
2391 const unsigned CmpOpcode = CmpInstr.
getOpcode();
2397 "Caller guarantees that CmpInstr compares with constant 0");
2400 if (!NZVCUsed || NZVCUsed->C)
2421bool AArch64InstrInfo::substituteCmpToZero(
2432 if (NewOpc == AArch64::INSTRUCTION_LIST_END)
2439 MI->setDesc(
get(NewOpc));
2444 MI->addRegisterDefined(AArch64::NZCV, &
TRI);
2456 assert((CmpValue == 0 || CmpValue == 1) &&
2457 "Only comparisons to 0 or 1 considered for removal!");
2460 unsigned MIOpc =
MI.getOpcode();
2461 if (MIOpc == AArch64::CSINCWr) {
2462 if (
MI.getOperand(1).getReg() != AArch64::WZR ||
2463 MI.getOperand(2).getReg() != AArch64::WZR)
2465 }
else if (MIOpc == AArch64::CSINCXr) {
2466 if (
MI.getOperand(1).getReg() != AArch64::XZR ||
2467 MI.getOperand(2).getReg() != AArch64::XZR)
2477 if (
MI.findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
true) != -1)
2481 const unsigned CmpOpcode = CmpInstr.
getOpcode();
2483 if (CmpValue && !IsSubsRegImm)
2485 if (!CmpValue && !IsSubsRegImm && !
isADDSRegImm(CmpOpcode))
2490 if (MIUsedNZCV.
C || MIUsedNZCV.
V)
2493 std::optional<UsedNZCV> NZCVUsedAfterCmp =
2497 if (!NZCVUsedAfterCmp || NZCVUsedAfterCmp->C || NZCVUsedAfterCmp->V)
2500 if ((MIUsedNZCV.
Z && NZCVUsedAfterCmp->N) ||
2501 (MIUsedNZCV.
N && NZCVUsedAfterCmp->Z))
2504 if (MIUsedNZCV.
N && !CmpValue)
2546bool AArch64InstrInfo::removeCmpToZeroOrOne(
2553 SmallVector<MachineInstr *, 4> CCUseInstrs;
2554 bool IsInvertCC =
false;
2562 for (MachineInstr *CCUseInstr : CCUseInstrs) {
2563 int Idx = findCondCodeUseOperandIdxForBranchOrSelect(*CCUseInstr);
2564 assert(Idx >= 0 &&
"Unexpected instruction using CC.");
2565 MachineOperand &CCOperand = CCUseInstr->getOperand(Idx);
2574bool AArch64InstrInfo::expandPostRAPseudo(
MachineInstr &
MI)
const {
2575 if (
MI.getOpcode() != TargetOpcode::LOAD_STACK_GUARD &&
2576 MI.getOpcode() != AArch64::CATCHRET &&
2577 MI.getOpcode() != AArch64::STACK_GUARD_UNMIX)
2582 auto TRI = Subtarget.getRegisterInfo();
2585 if (
MI.getOpcode() == AArch64::STACK_GUARD_UNMIX) {
2599 if (
MI.getOpcode() == AArch64::CATCHRET) {
2601 const TargetInstrInfo *
TII =
2603 MachineBasicBlock *TargetMBB =
MI.getOperand(0).getMBB();
2608 FirstEpilogSEH = std::prev(FirstEpilogSEH);
2610 FirstEpilogSEH = std::next(FirstEpilogSEH);
2625 if (
M.getStackProtectorGuard() ==
"sysreg") {
2626 const AArch64SysReg::SysReg *SrcReg =
2627 AArch64SysReg::lookupSysRegByName(
M.getStackProtectorGuardReg());
2635 int Offset =
M.getStackProtectorGuardOffset();
2686 const GlobalValue *GV =
2689 unsigned OpFlags = Subtarget.ClassifyGlobalReference(GV, TM);
2692 unsigned GuardWidth =
M.getStackProtectorGuardValueWidth().value_or(
2693 Subtarget.isTargetILP32() ? 4 : 8);
2694 if (GuardWidth != 4 && GuardWidth != 8)
2699 if (GuardWidth == 4) {
2700 unsigned Reg32 =
TRI->getSubReg(
Reg, AArch64::sub_32);
2729 if (GuardWidth == 4) {
2730 unsigned Reg32 =
TRI->getSubReg(
Reg, AArch64::sub_32);
2747 if (GuardWidth == 4) {
2748 unsigned Reg32 =
TRI->getSubReg(
Reg, AArch64::sub_32);
2766 if (Subtarget.getTargetTriple().isOSMSVCRT())
2779 switch (
MI.getOpcode()) {
2782 case AArch64::MOVZWi:
2783 case AArch64::MOVZXi:
2784 if (
MI.getOperand(1).isImm() &&
MI.getOperand(1).getImm() == 0) {
2785 assert(
MI.getDesc().getNumOperands() == 3 &&
2786 MI.getOperand(2).getImm() == 0 &&
"invalid MOVZi operands");
2790 case AArch64::ANDWri:
2791 return MI.getOperand(1).getReg() == AArch64::WZR;
2792 case AArch64::ANDXri:
2793 return MI.getOperand(1).getReg() == AArch64::XZR;
2794 case TargetOpcode::COPY:
2795 return MI.getOperand(1).getReg() == AArch64::WZR;
2803 switch (
MI.getOpcode()) {
2806 case TargetOpcode::COPY: {
2809 return (AArch64::GPR32RegClass.
contains(DstReg) ||
2810 AArch64::GPR64RegClass.
contains(DstReg));
2812 case AArch64::ORRXrs:
2813 if (
MI.getOperand(1).getReg() == AArch64::XZR) {
2814 assert(
MI.getDesc().getNumOperands() == 4 &&
2815 MI.getOperand(3).getImm() == 0 &&
"invalid ORRrs operands");
2819 case AArch64::ADDXri:
2820 if (
MI.getOperand(2).getImm() == 0) {
2821 assert(
MI.getDesc().getNumOperands() == 4 &&
2822 MI.getOperand(3).getImm() == 0 &&
"invalid ADDXri operands");
2833 switch (
MI.getOpcode()) {
2836 case TargetOpcode::COPY: {
2838 return AArch64::FPR128RegClass.contains(DstReg);
2840 case AArch64::ORRv16i8:
2841 if (
MI.getOperand(1).getReg() ==
MI.getOperand(2).getReg()) {
2842 assert(
MI.getDesc().getNumOperands() == 3 &&
MI.getOperand(0).isReg() &&
2843 "invalid ORRv16i8 operands");
2855 case AArch64::LDRWui:
2856 case AArch64::LDRXui:
2857 case AArch64::LDRBui:
2858 case AArch64::LDRHui:
2859 case AArch64::LDRSui:
2860 case AArch64::LDRDui:
2861 case AArch64::LDRQui:
2862 case AArch64::LDR_PXI:
2868 int &FrameIndex)
const {
2872 if (
MI.getOperand(0).getSubReg() == 0 &&
MI.getOperand(1).isFI() &&
2873 MI.getOperand(2).isImm() &&
MI.getOperand(2).getImm() == 0) {
2874 FrameIndex =
MI.getOperand(1).getIndex();
2875 return MI.getOperand(0).getReg();
2884 case AArch64::STRWui:
2885 case AArch64::STRXui:
2886 case AArch64::STRBui:
2887 case AArch64::STRHui:
2888 case AArch64::STRSui:
2889 case AArch64::STRDui:
2890 case AArch64::STRQui:
2891 case AArch64::STR_PXI:
2897 int &FrameIndex)
const {
2901 if (
MI.getOperand(0).getSubReg() == 0 &&
MI.getOperand(1).isFI() &&
2902 MI.getOperand(2).isImm() &&
MI.getOperand(2).getImm() == 0) {
2903 FrameIndex =
MI.getOperand(1).getIndex();
2904 return MI.getOperand(0).getReg();
2910 int &FrameIndex)
const {
2925 return MI.getOperand(0).getReg();
2931 int &FrameIndex)
const {
2946 return MI.getOperand(0).getReg();
2954 return MMO->getFlags() & MOSuppressPair;
2960 if (
MI.memoperands_empty())
2968 return MMO->getFlags() & MOStridedAccess;
2976 case AArch64::STURSi:
2977 case AArch64::STRSpre:
2978 case AArch64::STURDi:
2979 case AArch64::STRDpre:
2980 case AArch64::STURQi:
2981 case AArch64::STRQpre:
2982 case AArch64::STURBBi:
2983 case AArch64::STURHHi:
2984 case AArch64::STURWi:
2985 case AArch64::STRWpre:
2986 case AArch64::STURXi:
2987 case AArch64::STRXpre:
2988 case AArch64::LDURSi:
2989 case AArch64::LDRSpre:
2990 case AArch64::LDURDi:
2991 case AArch64::LDRDpre:
2992 case AArch64::LDURQi:
2993 case AArch64::LDRQpre:
2994 case AArch64::LDURWi:
2995 case AArch64::LDRWpre:
2996 case AArch64::LDURXi:
2997 case AArch64::LDRXpre:
2998 case AArch64::LDRSWpre:
2999 case AArch64::LDURSWi:
3000 case AArch64::LDURHHi:
3001 case AArch64::LDURBBi:
3002 case AArch64::LDURSBWi:
3003 case AArch64::LDURSHWi:
3011 case AArch64::PRFMui:
return AArch64::PRFUMi;
3012 case AArch64::LDRXui:
return AArch64::LDURXi;
3013 case AArch64::LDRWui:
return AArch64::LDURWi;
3014 case AArch64::LDRBui:
return AArch64::LDURBi;
3015 case AArch64::LDRHui:
return AArch64::LDURHi;
3016 case AArch64::LDRSui:
return AArch64::LDURSi;
3017 case AArch64::LDRDui:
return AArch64::LDURDi;
3018 case AArch64::LDRQui:
return AArch64::LDURQi;
3019 case AArch64::LDRBBui:
return AArch64::LDURBBi;
3020 case AArch64::LDRHHui:
return AArch64::LDURHHi;
3021 case AArch64::LDRSBXui:
return AArch64::LDURSBXi;
3022 case AArch64::LDRSBWui:
return AArch64::LDURSBWi;
3023 case AArch64::LDRSHXui:
return AArch64::LDURSHXi;
3024 case AArch64::LDRSHWui:
return AArch64::LDURSHWi;
3025 case AArch64::LDRSWui:
return AArch64::LDURSWi;
3026 case AArch64::STRXui:
return AArch64::STURXi;
3027 case AArch64::STRWui:
return AArch64::STURWi;
3028 case AArch64::STRBui:
return AArch64::STURBi;
3029 case AArch64::STRHui:
return AArch64::STURHi;
3030 case AArch64::STRSui:
return AArch64::STURSi;
3031 case AArch64::STRDui:
return AArch64::STURDi;
3032 case AArch64::STRQui:
return AArch64::STURQi;
3033 case AArch64::STRBBui:
return AArch64::STURBBi;
3034 case AArch64::STRHHui:
return AArch64::STURHHi;
3043 case AArch64::LDAPURBi:
3044 case AArch64::LDAPURHi:
3045 case AArch64::LDAPURi:
3046 case AArch64::LDAPURSBWi:
3047 case AArch64::LDAPURSBXi:
3048 case AArch64::LDAPURSHWi:
3049 case AArch64::LDAPURSHXi:
3050 case AArch64::LDAPURSWi:
3051 case AArch64::LDAPURXi:
3052 case AArch64::LDR_PPXI:
3053 case AArch64::LDR_PXI:
3054 case AArch64::LDR_ZXI:
3055 case AArch64::LDR_ZZXI:
3056 case AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS:
3057 case AArch64::LDR_ZZZXI:
3058 case AArch64::LDR_ZZZZXI:
3059 case AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS:
3060 case AArch64::LDRBBui:
3061 case AArch64::LDRBui:
3062 case AArch64::LDRDui:
3063 case AArch64::LDRHHui:
3064 case AArch64::LDRHui:
3065 case AArch64::LDRQui:
3066 case AArch64::LDRSBWui:
3067 case AArch64::LDRSBXui:
3068 case AArch64::LDRSHWui:
3069 case AArch64::LDRSHXui:
3070 case AArch64::LDRSui:
3071 case AArch64::LDRSWui:
3072 case AArch64::LDRWui:
3073 case AArch64::LDRXui:
3074 case AArch64::LDURBBi:
3075 case AArch64::LDURBi:
3076 case AArch64::LDURDi:
3077 case AArch64::LDURHHi:
3078 case AArch64::LDURHi:
3079 case AArch64::LDURQi:
3080 case AArch64::LDURSBWi:
3081 case AArch64::LDURSBXi:
3082 case AArch64::LDURSHWi:
3083 case AArch64::LDURSHXi:
3084 case AArch64::LDURSi:
3085 case AArch64::LDURSWi:
3086 case AArch64::LDURWi:
3087 case AArch64::LDURXi:
3088 case AArch64::PRFMui:
3089 case AArch64::PRFUMi:
3090 case AArch64::ST2Gi:
3092 case AArch64::STLURBi:
3093 case AArch64::STLURHi:
3094 case AArch64::STLURWi:
3095 case AArch64::STLURXi:
3096 case AArch64::StoreSwiftAsyncContext:
3097 case AArch64::STR_PPXI:
3098 case AArch64::STR_PXI:
3099 case AArch64::STR_ZXI:
3100 case AArch64::STR_ZZXI:
3101 case AArch64::STR_ZZXI_STRIDED_CONTIGUOUS:
3102 case AArch64::STR_ZZZXI:
3103 case AArch64::STR_ZZZZXI:
3104 case AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS:
3105 case AArch64::STRBBui:
3106 case AArch64::STRBui:
3107 case AArch64::STRDui:
3108 case AArch64::STRHHui:
3109 case AArch64::STRHui:
3110 case AArch64::STRQui:
3111 case AArch64::STRSui:
3112 case AArch64::STRWui:
3113 case AArch64::STRXui:
3114 case AArch64::STURBBi:
3115 case AArch64::STURBi:
3116 case AArch64::STURDi:
3117 case AArch64::STURHHi:
3118 case AArch64::STURHi:
3119 case AArch64::STURQi:
3120 case AArch64::STURSi:
3121 case AArch64::STURWi:
3122 case AArch64::STURXi:
3123 case AArch64::STZ2Gi:
3124 case AArch64::STZGi:
3125 case AArch64::TAGPstack:
3127 case AArch64::LD1B_D_IMM:
3128 case AArch64::LD1B_H_IMM:
3129 case AArch64::LD1B_IMM:
3130 case AArch64::LD1B_S_IMM:
3131 case AArch64::LD1D_IMM:
3132 case AArch64::LD1H_D_IMM:
3133 case AArch64::LD1H_IMM:
3134 case AArch64::LD1H_S_IMM:
3135 case AArch64::LD1RB_D_IMM:
3136 case AArch64::LD1RB_H_IMM:
3137 case AArch64::LD1RB_IMM:
3138 case AArch64::LD1RB_S_IMM:
3139 case AArch64::LD1RD_IMM:
3140 case AArch64::LD1RH_D_IMM:
3141 case AArch64::LD1RH_IMM:
3142 case AArch64::LD1RH_S_IMM:
3143 case AArch64::LD1RSB_D_IMM:
3144 case AArch64::LD1RSB_H_IMM:
3145 case AArch64::LD1RSB_S_IMM:
3146 case AArch64::LD1RSH_D_IMM:
3147 case AArch64::LD1RSH_S_IMM:
3148 case AArch64::LD1RSW_IMM:
3149 case AArch64::LD1RW_D_IMM:
3150 case AArch64::LD1RW_IMM:
3151 case AArch64::LD1SB_D_IMM:
3152 case AArch64::LD1SB_H_IMM:
3153 case AArch64::LD1SB_S_IMM:
3154 case AArch64::LD1SH_D_IMM:
3155 case AArch64::LD1SH_S_IMM:
3156 case AArch64::LD1SW_D_IMM:
3157 case AArch64::LD1W_D_IMM:
3158 case AArch64::LD1W_IMM:
3159 case AArch64::LD2B_IMM:
3160 case AArch64::LD2D_IMM:
3161 case AArch64::LD2H_IMM:
3162 case AArch64::LD2W_IMM:
3163 case AArch64::LD3B_IMM:
3164 case AArch64::LD3D_IMM:
3165 case AArch64::LD3H_IMM:
3166 case AArch64::LD3W_IMM:
3167 case AArch64::LD4B_IMM:
3168 case AArch64::LD4D_IMM:
3169 case AArch64::LD4H_IMM:
3170 case AArch64::LD4W_IMM:
3172 case AArch64::LDNF1B_D_IMM:
3173 case AArch64::LDNF1B_H_IMM:
3174 case AArch64::LDNF1B_IMM:
3175 case AArch64::LDNF1B_S_IMM:
3176 case AArch64::LDNF1D_IMM:
3177 case AArch64::LDNF1H_D_IMM:
3178 case AArch64::LDNF1H_IMM:
3179 case AArch64::LDNF1H_S_IMM:
3180 case AArch64::LDNF1SB_D_IMM:
3181 case AArch64::LDNF1SB_H_IMM:
3182 case AArch64::LDNF1SB_S_IMM:
3183 case AArch64::LDNF1SH_D_IMM:
3184 case AArch64::LDNF1SH_S_IMM:
3185 case AArch64::LDNF1SW_D_IMM:
3186 case AArch64::LDNF1W_D_IMM:
3187 case AArch64::LDNF1W_IMM:
3188 case AArch64::LDNPDi:
3189 case AArch64::LDNPQi:
3190 case AArch64::LDNPSi:
3191 case AArch64::LDNPWi:
3192 case AArch64::LDNPXi:
3193 case AArch64::LDNT1B_ZRI:
3194 case AArch64::LDNT1D_ZRI:
3195 case AArch64::LDNT1H_ZRI:
3196 case AArch64::LDNT1W_ZRI:
3197 case AArch64::LDPDi:
3198 case AArch64::LDPQi:
3199 case AArch64::LDPSi:
3200 case AArch64::LDPWi:
3201 case AArch64::LDPXi:
3202 case AArch64::LDRBBpost:
3203 case AArch64::LDRBBpre:
3204 case AArch64::LDRBpost:
3205 case AArch64::LDRBpre:
3206 case AArch64::LDRDpost:
3207 case AArch64::LDRDpre:
3208 case AArch64::LDRHHpost:
3209 case AArch64::LDRHHpre:
3210 case AArch64::LDRHpost:
3211 case AArch64::LDRHpre:
3212 case AArch64::LDRQpost:
3213 case AArch64::LDRQpre:
3214 case AArch64::LDRSpost:
3215 case AArch64::LDRSpre:
3216 case AArch64::LDRWpost:
3217 case AArch64::LDRWpre:
3218 case AArch64::LDRXpost:
3219 case AArch64::LDRXpre:
3220 case AArch64::ST1B_D_IMM:
3221 case AArch64::ST1B_H_IMM:
3222 case AArch64::ST1B_IMM:
3223 case AArch64::ST1B_S_IMM:
3224 case AArch64::ST1D_IMM:
3225 case AArch64::ST1H_D_IMM:
3226 case AArch64::ST1H_IMM:
3227 case AArch64::ST1H_S_IMM:
3228 case AArch64::ST1W_D_IMM:
3229 case AArch64::ST1W_IMM:
3230 case AArch64::ST2B_IMM:
3231 case AArch64::ST2D_IMM:
3232 case AArch64::ST2H_IMM:
3233 case AArch64::ST2W_IMM:
3234 case AArch64::ST3B_IMM:
3235 case AArch64::ST3D_IMM:
3236 case AArch64::ST3H_IMM:
3237 case AArch64::ST3W_IMM:
3238 case AArch64::ST4B_IMM:
3239 case AArch64::ST4D_IMM:
3240 case AArch64::ST4H_IMM:
3241 case AArch64::ST4W_IMM:
3242 case AArch64::STGPi:
3243 case AArch64::STGPreIndex:
3244 case AArch64::STZGPreIndex:
3245 case AArch64::ST2GPreIndex:
3246 case AArch64::STZ2GPreIndex:
3247 case AArch64::STGPostIndex:
3248 case AArch64::STZGPostIndex:
3249 case AArch64::ST2GPostIndex:
3250 case AArch64::STZ2GPostIndex:
3251 case AArch64::STNPDi:
3252 case AArch64::STNPQi:
3253 case AArch64::STNPSi:
3254 case AArch64::STNPWi:
3255 case AArch64::STNPXi:
3256 case AArch64::STNT1B_ZRI:
3257 case AArch64::STNT1D_ZRI:
3258 case AArch64::STNT1H_ZRI:
3259 case AArch64::STNT1W_ZRI:
3260 case AArch64::STPDi:
3261 case AArch64::STPQi:
3262 case AArch64::STPSi:
3263 case AArch64::STPWi:
3264 case AArch64::STPXi:
3265 case AArch64::STRBBpost:
3266 case AArch64::STRBBpre:
3267 case AArch64::STRBpost:
3268 case AArch64::STRBpre:
3269 case AArch64::STRDpost:
3270 case AArch64::STRDpre:
3271 case AArch64::STRHHpost:
3272 case AArch64::STRHHpre:
3273 case AArch64::STRHpost:
3274 case AArch64::STRHpre:
3275 case AArch64::STRQpost:
3276 case AArch64::STRQpre:
3277 case AArch64::STRSpost:
3278 case AArch64::STRSpre:
3279 case AArch64::STRWpost:
3280 case AArch64::STRWpre:
3281 case AArch64::STRXpost:
3282 case AArch64::STRXpre:
3283 case AArch64::LD1B_2Z_IMM:
3284 case AArch64::LD1B_2Z_STRIDED_IMM:
3285 case AArch64::LD1H_2Z_IMM:
3286 case AArch64::LD1H_2Z_STRIDED_IMM:
3287 case AArch64::LD1W_2Z_IMM:
3288 case AArch64::LD1W_2Z_STRIDED_IMM:
3289 case AArch64::LD1D_2Z_IMM:
3290 case AArch64::LD1D_2Z_STRIDED_IMM:
3291 case AArch64::LD1B_4Z_IMM:
3292 case AArch64::LD1B_4Z_STRIDED_IMM:
3293 case AArch64::LD1H_4Z_IMM:
3294 case AArch64::LD1H_4Z_STRIDED_IMM:
3295 case AArch64::LD1W_4Z_IMM:
3296 case AArch64::LD1W_4Z_STRIDED_IMM:
3297 case AArch64::LD1D_4Z_IMM:
3298 case AArch64::LD1D_4Z_STRIDED_IMM:
3299 case AArch64::LD1B_2Z_IMM_PSEUDO:
3300 case AArch64::LD1H_2Z_IMM_PSEUDO:
3301 case AArch64::LD1W_2Z_IMM_PSEUDO:
3302 case AArch64::LD1D_2Z_IMM_PSEUDO:
3303 case AArch64::LD1B_4Z_IMM_PSEUDO:
3304 case AArch64::LD1H_4Z_IMM_PSEUDO:
3305 case AArch64::LD1W_4Z_IMM_PSEUDO:
3306 case AArch64::LD1D_4Z_IMM_PSEUDO:
3307 case AArch64::ST1B_2Z_IMM:
3308 case AArch64::ST1B_2Z_STRIDED_IMM:
3309 case AArch64::ST1H_2Z_IMM:
3310 case AArch64::ST1H_2Z_STRIDED_IMM:
3311 case AArch64::ST1W_2Z_IMM:
3312 case AArch64::ST1W_2Z_STRIDED_IMM:
3313 case AArch64::ST1D_2Z_IMM:
3314 case AArch64::ST1D_2Z_STRIDED_IMM:
3315 case AArch64::LDNT1B_2Z_IMM_PSEUDO:
3316 case AArch64::LDNT1B_2Z_IMM:
3317 case AArch64::LDNT1B_2Z_STRIDED_IMM:
3318 case AArch64::LDNT1H_2Z_IMM_PSEUDO:
3319 case AArch64::LDNT1H_2Z_IMM:
3320 case AArch64::LDNT1H_2Z_STRIDED_IMM:
3321 case AArch64::LDNT1W_2Z_IMM_PSEUDO:
3322 case AArch64::LDNT1W_2Z_IMM:
3323 case AArch64::LDNT1W_2Z_STRIDED_IMM:
3324 case AArch64::LDNT1D_2Z_IMM_PSEUDO:
3325 case AArch64::LDNT1D_2Z_IMM:
3326 case AArch64::LDNT1D_2Z_STRIDED_IMM:
3327 case AArch64::STNT1B_2Z_IMM:
3328 case AArch64::STNT1B_2Z_STRIDED_IMM:
3329 case AArch64::STNT1H_2Z_IMM:
3330 case AArch64::STNT1H_2Z_STRIDED_IMM:
3331 case AArch64::STNT1W_2Z_IMM:
3332 case AArch64::STNT1W_2Z_STRIDED_IMM:
3333 case AArch64::STNT1D_2Z_IMM:
3334 case AArch64::STNT1D_2Z_STRIDED_IMM:
3335 case AArch64::ST1B_2Z_IMM_PSEUDO:
3336 case AArch64::ST1H_2Z_IMM_PSEUDO:
3337 case AArch64::ST1W_2Z_IMM_PSEUDO:
3338 case AArch64::ST1D_2Z_IMM_PSEUDO:
3339 case AArch64::STNT1B_2Z_IMM_PSEUDO:
3340 case AArch64::STNT1H_2Z_IMM_PSEUDO:
3341 case AArch64::STNT1W_2Z_IMM_PSEUDO:
3342 case AArch64::STNT1D_2Z_IMM_PSEUDO:
3343 case AArch64::ST1B_4Z_IMM:
3344 case AArch64::ST1B_4Z_STRIDED_IMM:
3345 case AArch64::ST1H_4Z_IMM:
3346 case AArch64::ST1H_4Z_STRIDED_IMM:
3347 case AArch64::ST1W_4Z_IMM:
3348 case AArch64::ST1W_4Z_STRIDED_IMM:
3349 case AArch64::ST1D_4Z_IMM:
3350 case AArch64::ST1D_4Z_STRIDED_IMM:
3351 case AArch64::LDNT1B_4Z_IMM_PSEUDO:
3352 case AArch64::LDNT1B_4Z_IMM:
3353 case AArch64::LDNT1B_4Z_STRIDED_IMM:
3354 case AArch64::LDNT1H_4Z_IMM_PSEUDO:
3355 case AArch64::LDNT1H_4Z_IMM:
3356 case AArch64::LDNT1H_4Z_STRIDED_IMM:
3357 case AArch64::LDNT1W_4Z_IMM_PSEUDO:
3358 case AArch64::LDNT1W_4Z_IMM:
3359 case AArch64::LDNT1W_4Z_STRIDED_IMM:
3360 case AArch64::LDNT1D_4Z_IMM_PSEUDO:
3361 case AArch64::LDNT1D_4Z_IMM:
3362 case AArch64::LDNT1D_4Z_STRIDED_IMM:
3363 case AArch64::STNT1B_4Z_IMM:
3364 case AArch64::STNT1B_4Z_STRIDED_IMM:
3365 case AArch64::STNT1H_4Z_IMM:
3366 case AArch64::STNT1H_4Z_STRIDED_IMM:
3367 case AArch64::STNT1W_4Z_IMM:
3368 case AArch64::STNT1W_4Z_STRIDED_IMM:
3369 case AArch64::STNT1D_4Z_IMM:
3370 case AArch64::STNT1D_4Z_STRIDED_IMM:
3371 case AArch64::ST1B_4Z_IMM_PSEUDO:
3372 case AArch64::ST1H_4Z_IMM_PSEUDO:
3373 case AArch64::ST1W_4Z_IMM_PSEUDO:
3374 case AArch64::ST1D_4Z_IMM_PSEUDO:
3375 case AArch64::STNT1B_4Z_IMM_PSEUDO:
3376 case AArch64::STNT1H_4Z_IMM_PSEUDO:
3377 case AArch64::STNT1W_4Z_IMM_PSEUDO:
3378 case AArch64::STNT1D_4Z_IMM_PSEUDO:
3380 case AArch64::LDPDpost:
3381 case AArch64::LDPDpre:
3382 case AArch64::LDPQpost:
3383 case AArch64::LDPQpre:
3384 case AArch64::LDPSpost:
3385 case AArch64::LDPSpre:
3386 case AArch64::LDPWpost:
3387 case AArch64::LDPWpre:
3388 case AArch64::LDPXpost:
3389 case AArch64::LDPXpre:
3390 case AArch64::STGPpre:
3391 case AArch64::STGPpost:
3392 case AArch64::STPDpost:
3393 case AArch64::STPDpre:
3394 case AArch64::STPQpost:
3395 case AArch64::STPQpre:
3396 case AArch64::STPSpost:
3397 case AArch64::STPSpre:
3398 case AArch64::STPWpost:
3399 case AArch64::STPWpre:
3400 case AArch64::STPXpost:
3401 case AArch64::STPXpre:
3407 switch (
MI.getOpcode()) {
3411 case AArch64::STRSui:
3412 case AArch64::STRDui:
3413 case AArch64::STRQui:
3414 case AArch64::STRXui:
3415 case AArch64::STRWui:
3416 case AArch64::LDRSui:
3417 case AArch64::LDRDui:
3418 case AArch64::LDRQui:
3419 case AArch64::LDRXui:
3420 case AArch64::LDRWui:
3421 case AArch64::LDRSWui:
3423 case AArch64::STURSi:
3424 case AArch64::STRSpre:
3425 case AArch64::STURDi:
3426 case AArch64::STRDpre:
3427 case AArch64::STURQi:
3428 case AArch64::STRQpre:
3429 case AArch64::STURWi:
3430 case AArch64::STRWpre:
3431 case AArch64::STURXi:
3432 case AArch64::STRXpre:
3433 case AArch64::LDURSi:
3434 case AArch64::LDRSpre:
3435 case AArch64::LDURDi:
3436 case AArch64::LDRDpre:
3437 case AArch64::LDURQi:
3438 case AArch64::LDRQpre:
3439 case AArch64::LDURWi:
3440 case AArch64::LDRWpre:
3441 case AArch64::LDURXi:
3442 case AArch64::LDRXpre:
3443 case AArch64::LDURSWi:
3444 case AArch64::LDRSWpre:
3446 case AArch64::LDR_ZXI:
3447 case AArch64::STR_ZXI:
3453 switch (
MI.getOpcode()) {
3456 "Unexpected instruction - was a new tail call opcode introduced?");
3458 case AArch64::TCRETURNdi:
3459 case AArch64::TCRETURNri:
3460 case AArch64::TCRETURNrix16x17:
3461 case AArch64::TCRETURNrix17:
3462 case AArch64::TCRETURNrinotx16:
3463 case AArch64::TCRETURNriALL:
3464 case AArch64::AUTH_TCRETURN:
3465 case AArch64::AUTH_TCRETURN_BTI:
3475 case AArch64::ADDWri:
3476 return AArch64::ADDSWri;
3477 case AArch64::ADDWrr:
3478 return AArch64::ADDSWrr;
3479 case AArch64::ADDWrs:
3480 return AArch64::ADDSWrs;
3481 case AArch64::ADDWrx:
3482 return AArch64::ADDSWrx;
3483 case AArch64::ANDWri:
3484 return AArch64::ANDSWri;
3485 case AArch64::ANDWrr:
3486 return AArch64::ANDSWrr;
3487 case AArch64::ANDWrs:
3488 return AArch64::ANDSWrs;
3489 case AArch64::BICWrr:
3490 return AArch64::BICSWrr;
3491 case AArch64::BICWrs:
3492 return AArch64::BICSWrs;
3493 case AArch64::SUBWri:
3494 return AArch64::SUBSWri;
3495 case AArch64::SUBWrr:
3496 return AArch64::SUBSWrr;
3497 case AArch64::SUBWrs:
3498 return AArch64::SUBSWrs;
3499 case AArch64::SUBWrx:
3500 return AArch64::SUBSWrx;
3502 case AArch64::ADDXri:
3503 return AArch64::ADDSXri;
3504 case AArch64::ADDXrr:
3505 return AArch64::ADDSXrr;
3506 case AArch64::ADDXrs:
3507 return AArch64::ADDSXrs;
3508 case AArch64::ADDXrx:
3509 return AArch64::ADDSXrx;
3510 case AArch64::ANDXri:
3511 return AArch64::ANDSXri;
3512 case AArch64::ANDXrr:
3513 return AArch64::ANDSXrr;
3514 case AArch64::ANDXrs:
3515 return AArch64::ANDSXrs;
3516 case AArch64::BICXrr:
3517 return AArch64::BICSXrr;
3518 case AArch64::BICXrs:
3519 return AArch64::BICSXrs;
3520 case AArch64::SUBXri:
3521 return AArch64::SUBSXri;
3522 case AArch64::SUBXrr:
3523 return AArch64::SUBSXrr;
3524 case AArch64::SUBXrs:
3525 return AArch64::SUBSXrs;
3526 case AArch64::SUBXrx:
3527 return AArch64::SUBSXrx;
3529 case AArch64::AND_PPzPP:
3530 return AArch64::ANDS_PPzPP;
3531 case AArch64::BIC_PPzPP:
3532 return AArch64::BICS_PPzPP;
3533 case AArch64::EOR_PPzPP:
3534 return AArch64::EORS_PPzPP;
3535 case AArch64::NAND_PPzPP:
3536 return AArch64::NANDS_PPzPP;
3537 case AArch64::NOR_PPzPP:
3538 return AArch64::NORS_PPzPP;
3539 case AArch64::ORN_PPzPP:
3540 return AArch64::ORNS_PPzPP;
3541 case AArch64::ORR_PPzPP:
3542 return AArch64::ORRS_PPzPP;
3543 case AArch64::BRKA_PPzP:
3544 return AArch64::BRKAS_PPzP;
3545 case AArch64::BRKPA_PPzPP:
3546 return AArch64::BRKPAS_PPzPP;
3547 case AArch64::BRKB_PPzP:
3548 return AArch64::BRKBS_PPzP;
3549 case AArch64::BRKPB_PPzPP:
3550 return AArch64::BRKPBS_PPzPP;
3551 case AArch64::BRKN_PPzP:
3552 return AArch64::BRKNS_PPzP;
3553 case AArch64::RDFFR_PPz:
3554 return AArch64::RDFFRS_PPz;
3555 case AArch64::PTRUE_B:
3556 return AArch64::PTRUES_B;
3567 if (
MI.hasOrderedMemoryRef())
3572 assert((
MI.getOperand(IsPreLdSt ? 2 : 1).isReg() ||
3573 MI.getOperand(IsPreLdSt ? 2 : 1).isFI()) &&
3574 "Expected a reg or frame index operand.");
3578 bool IsImmPreLdSt = IsPreLdSt &&
MI.getOperand(3).isImm();
3580 if (!
MI.getOperand(2).isImm() && !IsImmPreLdSt)
3593 if (
MI.getOperand(1).isReg() && !IsPreLdSt) {
3594 Register BaseReg =
MI.getOperand(1).getReg();
3596 if (
MI.modifiesRegister(BaseReg,
TRI))
3602 switch (
MI.getOpcode()) {
3605 case AArch64::LDR_ZXI:
3606 case AArch64::STR_ZXI:
3607 if (!Subtarget.isLittleEndian() ||
3608 Subtarget.getSVEVectorSizeInBits() != 128)
3621 const MCAsmInfo &MAI =
MI.getMF()->getTarget().getMCAsmInfo();
3629 if (Subtarget.isPaired128Slow()) {
3630 switch (
MI.getOpcode()) {
3633 case AArch64::LDURQi:
3634 case AArch64::STURQi:
3635 case AArch64::LDRQui:
3636 case AArch64::STRQui:
3663std::optional<ExtAddrMode>
3668 bool OffsetIsScalable;
3669 if (!getMemOperandWithOffset(MemI,
Base,
Offset, OffsetIsScalable,
TRI))
3670 return std::nullopt;
3673 return std::nullopt;
3688 int64_t OffsetScale = 1;
3693 case AArch64::LDURQi:
3694 case AArch64::STURQi:
3698 case AArch64::LDURDi:
3699 case AArch64::STURDi:
3700 case AArch64::LDURXi:
3701 case AArch64::STURXi:
3705 case AArch64::LDURWi:
3706 case AArch64::LDURSWi:
3707 case AArch64::STURWi:
3711 case AArch64::LDURHi:
3712 case AArch64::STURHi:
3713 case AArch64::LDURHHi:
3714 case AArch64::STURHHi:
3715 case AArch64::LDURSHXi:
3716 case AArch64::LDURSHWi:
3720 case AArch64::LDRBroX:
3721 case AArch64::LDRBBroX:
3722 case AArch64::LDRSBXroX:
3723 case AArch64::LDRSBWroX:
3724 case AArch64::STRBroX:
3725 case AArch64::STRBBroX:
3726 case AArch64::LDURBi:
3727 case AArch64::LDURBBi:
3728 case AArch64::LDURSBXi:
3729 case AArch64::LDURSBWi:
3730 case AArch64::STURBi:
3731 case AArch64::STURBBi:
3732 case AArch64::LDRBui:
3733 case AArch64::LDRBBui:
3734 case AArch64::LDRSBXui:
3735 case AArch64::LDRSBWui:
3736 case AArch64::STRBui:
3737 case AArch64::STRBBui:
3741 case AArch64::LDRQroX:
3742 case AArch64::STRQroX:
3743 case AArch64::LDRQui:
3744 case AArch64::STRQui:
3749 case AArch64::LDRDroX:
3750 case AArch64::STRDroX:
3751 case AArch64::LDRXroX:
3752 case AArch64::STRXroX:
3753 case AArch64::LDRDui:
3754 case AArch64::STRDui:
3755 case AArch64::LDRXui:
3756 case AArch64::STRXui:
3761 case AArch64::LDRWroX:
3762 case AArch64::LDRSWroX:
3763 case AArch64::STRWroX:
3764 case AArch64::LDRWui:
3765 case AArch64::LDRSWui:
3766 case AArch64::STRWui:
3771 case AArch64::LDRHroX:
3772 case AArch64::STRHroX:
3773 case AArch64::LDRHHroX:
3774 case AArch64::STRHHroX:
3775 case AArch64::LDRSHXroX:
3776 case AArch64::LDRSHWroX:
3777 case AArch64::LDRHui:
3778 case AArch64::STRHui:
3779 case AArch64::LDRHHui:
3780 case AArch64::STRHHui:
3781 case AArch64::LDRSHXui:
3782 case AArch64::LDRSHWui:
3790 if (BaseRegOp.
isReg() && BaseRegOp.
getReg() == Reg)
3814 case AArch64::SBFMXri:
3827 AM.
Scale = OffsetScale;
3832 case TargetOpcode::SUBREG_TO_REG: {
3848 if (
DefMI.getOpcode() != AArch64::ORRWrs ||
3849 DefMI.getOperand(1).getReg() != AArch64::WZR ||
3850 DefMI.getOperand(3).getImm() != 0)
3857 AM.
Scale = OffsetScale;
3868 auto validateOffsetForLDP = [](
unsigned NumBytes, int64_t OldOffset,
3869 int64_t NewOffset) ->
bool {
3870 int64_t MinOffset, MaxOffset;
3887 return OldOffset < MinOffset || OldOffset > MaxOffset ||
3888 (NewOffset >= MinOffset && NewOffset <= MaxOffset);
3890 auto canFoldAddSubImmIntoAddrMode = [&](int64_t Disp) ->
bool {
3892 int64_t NewOffset = OldOffset + Disp;
3893 if (!isLegalAddressingMode(NumBytes, NewOffset, 0))
3897 if (!validateOffsetForLDP(NumBytes, OldOffset, NewOffset))
3907 auto canFoldAddRegIntoAddrMode =
3912 if ((
unsigned)Scale != Scale)
3914 if (!isLegalAddressingMode(NumBytes, 0, Scale))
3926 return (Opcode == AArch64::STURQi || Opcode == AArch64::STRQui) &&
3927 Subtarget.isSTRQroSlow();
3936 case AArch64::ADDXri:
3942 return canFoldAddSubImmIntoAddrMode(Disp);
3944 case AArch64::SUBXri:
3950 return canFoldAddSubImmIntoAddrMode(-Disp);
3952 case AArch64::ADDXrs: {
3965 if (Shift != 2 && Shift != 3 && Subtarget.hasAddrLSLSlow14())
3967 if (avoidSlowSTRQ(MemI))
3970 return canFoldAddRegIntoAddrMode(1ULL << Shift);
3973 case AArch64::ADDXrr:
3981 if (!OptSize && avoidSlowSTRQ(MemI))
3983 return canFoldAddRegIntoAddrMode(1);
3985 case AArch64::ADDXrx:
3993 if (!OptSize && avoidSlowSTRQ(MemI))
4002 return canFoldAddRegIntoAddrMode(
4017 case AArch64::LDURQi:
4018 case AArch64::LDRQui:
4019 return AArch64::LDRQroX;
4020 case AArch64::STURQi:
4021 case AArch64::STRQui:
4022 return AArch64::STRQroX;
4023 case AArch64::LDURDi:
4024 case AArch64::LDRDui:
4025 return AArch64::LDRDroX;
4026 case AArch64::STURDi:
4027 case AArch64::STRDui:
4028 return AArch64::STRDroX;
4029 case AArch64::LDURXi:
4030 case AArch64::LDRXui:
4031 return AArch64::LDRXroX;
4032 case AArch64::STURXi:
4033 case AArch64::STRXui:
4034 return AArch64::STRXroX;
4035 case AArch64::LDURWi:
4036 case AArch64::LDRWui:
4037 return AArch64::LDRWroX;
4038 case AArch64::LDURSWi:
4039 case AArch64::LDRSWui:
4040 return AArch64::LDRSWroX;
4041 case AArch64::STURWi:
4042 case AArch64::STRWui:
4043 return AArch64::STRWroX;
4044 case AArch64::LDURHi:
4045 case AArch64::LDRHui:
4046 return AArch64::LDRHroX;
4047 case AArch64::STURHi:
4048 case AArch64::STRHui:
4049 return AArch64::STRHroX;
4050 case AArch64::LDURHHi:
4051 case AArch64::LDRHHui:
4052 return AArch64::LDRHHroX;
4053 case AArch64::STURHHi:
4054 case AArch64::STRHHui:
4055 return AArch64::STRHHroX;
4056 case AArch64::LDURSHXi:
4057 case AArch64::LDRSHXui:
4058 return AArch64::LDRSHXroX;
4059 case AArch64::LDURSHWi:
4060 case AArch64::LDRSHWui:
4061 return AArch64::LDRSHWroX;
4062 case AArch64::LDURBi:
4063 case AArch64::LDRBui:
4064 return AArch64::LDRBroX;
4065 case AArch64::LDURBBi:
4066 case AArch64::LDRBBui:
4067 return AArch64::LDRBBroX;
4068 case AArch64::LDURSBXi:
4069 case AArch64::LDRSBXui:
4070 return AArch64::LDRSBXroX;
4071 case AArch64::LDURSBWi:
4072 case AArch64::LDRSBWui:
4073 return AArch64::LDRSBWroX;
4074 case AArch64::STURBi:
4075 case AArch64::STRBui:
4076 return AArch64::STRBroX;
4077 case AArch64::STURBBi:
4078 case AArch64::STRBBui:
4079 return AArch64::STRBBroX;
4091 case AArch64::LDURQi:
4093 return AArch64::LDRQui;
4094 case AArch64::STURQi:
4096 return AArch64::STRQui;
4097 case AArch64::LDURDi:
4099 return AArch64::LDRDui;
4100 case AArch64::STURDi:
4102 return AArch64::STRDui;
4103 case AArch64::LDURXi:
4105 return AArch64::LDRXui;
4106 case AArch64::STURXi:
4108 return AArch64::STRXui;
4109 case AArch64::LDURWi:
4111 return AArch64::LDRWui;
4112 case AArch64::LDURSWi:
4114 return AArch64::LDRSWui;
4115 case AArch64::STURWi:
4117 return AArch64::STRWui;
4118 case AArch64::LDURHi:
4120 return AArch64::LDRHui;
4121 case AArch64::STURHi:
4123 return AArch64::STRHui;
4124 case AArch64::LDURHHi:
4126 return AArch64::LDRHHui;
4127 case AArch64::STURHHi:
4129 return AArch64::STRHHui;
4130 case AArch64::LDURSHXi:
4132 return AArch64::LDRSHXui;
4133 case AArch64::LDURSHWi:
4135 return AArch64::LDRSHWui;
4136 case AArch64::LDURBi:
4138 return AArch64::LDRBui;
4139 case AArch64::LDURBBi:
4141 return AArch64::LDRBBui;
4142 case AArch64::LDURSBXi:
4144 return AArch64::LDRSBXui;
4145 case AArch64::LDURSBWi:
4147 return AArch64::LDRSBWui;
4148 case AArch64::STURBi:
4150 return AArch64::STRBui;
4151 case AArch64::STURBBi:
4153 return AArch64::STRBBui;
4154 case AArch64::LDRQui:
4155 case AArch64::STRQui:
4158 case AArch64::LDRDui:
4159 case AArch64::STRDui:
4160 case AArch64::LDRXui:
4161 case AArch64::STRXui:
4164 case AArch64::LDRWui:
4165 case AArch64::LDRSWui:
4166 case AArch64::STRWui:
4169 case AArch64::LDRHui:
4170 case AArch64::STRHui:
4171 case AArch64::LDRHHui:
4172 case AArch64::STRHHui:
4173 case AArch64::LDRSHXui:
4174 case AArch64::LDRSHWui:
4177 case AArch64::LDRBui:
4178 case AArch64::LDRBBui:
4179 case AArch64::LDRSBXui:
4180 case AArch64::LDRSBWui:
4181 case AArch64::STRBui:
4182 case AArch64::STRBBui:
4196 case AArch64::LDURQi:
4197 case AArch64::STURQi:
4198 case AArch64::LDURDi:
4199 case AArch64::STURDi:
4200 case AArch64::LDURXi:
4201 case AArch64::STURXi:
4202 case AArch64::LDURWi:
4203 case AArch64::LDURSWi:
4204 case AArch64::STURWi:
4205 case AArch64::LDURHi:
4206 case AArch64::STURHi:
4207 case AArch64::LDURHHi:
4208 case AArch64::STURHHi:
4209 case AArch64::LDURSHXi:
4210 case AArch64::LDURSHWi:
4211 case AArch64::LDURBi:
4212 case AArch64::STURBi:
4213 case AArch64::LDURBBi:
4214 case AArch64::STURBBi:
4215 case AArch64::LDURSBWi:
4216 case AArch64::LDURSBXi:
4218 case AArch64::LDRQui:
4219 return AArch64::LDURQi;
4220 case AArch64::STRQui:
4221 return AArch64::STURQi;
4222 case AArch64::LDRDui:
4223 return AArch64::LDURDi;
4224 case AArch64::STRDui:
4225 return AArch64::STURDi;
4226 case AArch64::LDRXui:
4227 return AArch64::LDURXi;
4228 case AArch64::STRXui:
4229 return AArch64::STURXi;
4230 case AArch64::LDRWui:
4231 return AArch64::LDURWi;
4232 case AArch64::LDRSWui:
4233 return AArch64::LDURSWi;
4234 case AArch64::STRWui:
4235 return AArch64::STURWi;
4236 case AArch64::LDRHui:
4237 return AArch64::LDURHi;
4238 case AArch64::STRHui:
4239 return AArch64::STURHi;
4240 case AArch64::LDRHHui:
4241 return AArch64::LDURHHi;
4242 case AArch64::STRHHui:
4243 return AArch64::STURHHi;
4244 case AArch64::LDRSHXui:
4245 return AArch64::LDURSHXi;
4246 case AArch64::LDRSHWui:
4247 return AArch64::LDURSHWi;
4248 case AArch64::LDRBBui:
4249 return AArch64::LDURBBi;
4250 case AArch64::LDRBui:
4251 return AArch64::LDURBi;
4252 case AArch64::STRBBui:
4253 return AArch64::STURBBi;
4254 case AArch64::STRBui:
4255 return AArch64::STURBi;
4256 case AArch64::LDRSBWui:
4257 return AArch64::LDURSBWi;
4258 case AArch64::LDRSBXui:
4259 return AArch64::LDURSBXi;
4272 case AArch64::LDRQroX:
4273 case AArch64::LDURQi:
4274 case AArch64::LDRQui:
4275 return AArch64::LDRQroW;
4276 case AArch64::STRQroX:
4277 case AArch64::STURQi:
4278 case AArch64::STRQui:
4279 return AArch64::STRQroW;
4280 case AArch64::LDRDroX:
4281 case AArch64::LDURDi:
4282 case AArch64::LDRDui:
4283 return AArch64::LDRDroW;
4284 case AArch64::STRDroX:
4285 case AArch64::STURDi:
4286 case AArch64::STRDui:
4287 return AArch64::STRDroW;
4288 case AArch64::LDRXroX:
4289 case AArch64::LDURXi:
4290 case AArch64::LDRXui:
4291 return AArch64::LDRXroW;
4292 case AArch64::STRXroX:
4293 case AArch64::STURXi:
4294 case AArch64::STRXui:
4295 return AArch64::STRXroW;
4296 case AArch64::LDRWroX:
4297 case AArch64::LDURWi:
4298 case AArch64::LDRWui:
4299 return AArch64::LDRWroW;
4300 case AArch64::LDRSWroX:
4301 case AArch64::LDURSWi:
4302 case AArch64::LDRSWui:
4303 return AArch64::LDRSWroW;
4304 case AArch64::STRWroX:
4305 case AArch64::STURWi:
4306 case AArch64::STRWui:
4307 return AArch64::STRWroW;
4308 case AArch64::LDRHroX:
4309 case AArch64::LDURHi:
4310 case AArch64::LDRHui:
4311 return AArch64::LDRHroW;
4312 case AArch64::STRHroX:
4313 case AArch64::STURHi:
4314 case AArch64::STRHui:
4315 return AArch64::STRHroW;
4316 case AArch64::LDRHHroX:
4317 case AArch64::LDURHHi:
4318 case AArch64::LDRHHui:
4319 return AArch64::LDRHHroW;
4320 case AArch64::STRHHroX:
4321 case AArch64::STURHHi:
4322 case AArch64::STRHHui:
4323 return AArch64::STRHHroW;
4324 case AArch64::LDRSHXroX:
4325 case AArch64::LDURSHXi:
4326 case AArch64::LDRSHXui:
4327 return AArch64::LDRSHXroW;
4328 case AArch64::LDRSHWroX:
4329 case AArch64::LDURSHWi:
4330 case AArch64::LDRSHWui:
4331 return AArch64::LDRSHWroW;
4332 case AArch64::LDRBroX:
4333 case AArch64::LDURBi:
4334 case AArch64::LDRBui:
4335 return AArch64::LDRBroW;
4336 case AArch64::LDRBBroX:
4337 case AArch64::LDURBBi:
4338 case AArch64::LDRBBui:
4339 return AArch64::LDRBBroW;
4340 case AArch64::LDRSBXroX:
4341 case AArch64::LDURSBXi:
4342 case AArch64::LDRSBXui:
4343 return AArch64::LDRSBXroW;
4344 case AArch64::LDRSBWroX:
4345 case AArch64::LDURSBWi:
4346 case AArch64::LDRSBWui:
4347 return AArch64::LDRSBWroW;
4348 case AArch64::STRBroX:
4349 case AArch64::STURBi:
4350 case AArch64::STRBui:
4351 return AArch64::STRBroW;
4352 case AArch64::STRBBroX:
4353 case AArch64::STURBBi:
4354 case AArch64::STRBBui:
4355 return AArch64::STRBBroW;
4380 return B.getInstr();
4384 "Addressing mode not supported for folding");
4401 return B.getInstr();
4408 "Address offset can be a register or an immediate, but not both");
4429 return B.getInstr();
4433 "Function must not be called with an addressing mode it can't handle");
4442 case AArch64::LD1Fourv16b_POST:
4443 case AArch64::LD1Fourv1d_POST:
4444 case AArch64::LD1Fourv2d_POST:
4445 case AArch64::LD1Fourv2s_POST:
4446 case AArch64::LD1Fourv4h_POST:
4447 case AArch64::LD1Fourv4s_POST:
4448 case AArch64::LD1Fourv8b_POST:
4449 case AArch64::LD1Fourv8h_POST:
4450 case AArch64::LD1Onev16b_POST:
4451 case AArch64::LD1Onev1d_POST:
4452 case AArch64::LD1Onev2d_POST:
4453 case AArch64::LD1Onev2s_POST:
4454 case AArch64::LD1Onev4h_POST:
4455 case AArch64::LD1Onev4s_POST:
4456 case AArch64::LD1Onev8b_POST:
4457 case AArch64::LD1Onev8h_POST:
4458 case AArch64::LD1Rv16b_POST:
4459 case AArch64::LD1Rv1d_POST:
4460 case AArch64::LD1Rv2d_POST:
4461 case AArch64::LD1Rv2s_POST:
4462 case AArch64::LD1Rv4h_POST:
4463 case AArch64::LD1Rv4s_POST:
4464 case AArch64::LD1Rv8b_POST:
4465 case AArch64::LD1Rv8h_POST:
4466 case AArch64::LD1Threev16b_POST:
4467 case AArch64::LD1Threev1d_POST:
4468 case AArch64::LD1Threev2d_POST:
4469 case AArch64::LD1Threev2s_POST:
4470 case AArch64::LD1Threev4h_POST:
4471 case AArch64::LD1Threev4s_POST:
4472 case AArch64::LD1Threev8b_POST:
4473 case AArch64::LD1Threev8h_POST:
4474 case AArch64::LD1Twov16b_POST:
4475 case AArch64::LD1Twov1d_POST:
4476 case AArch64::LD1Twov2d_POST:
4477 case AArch64::LD1Twov2s_POST:
4478 case AArch64::LD1Twov4h_POST:
4479 case AArch64::LD1Twov4s_POST:
4480 case AArch64::LD1Twov8b_POST:
4481 case AArch64::LD1Twov8h_POST:
4482 case AArch64::LD1i16_POST:
4483 case AArch64::LD1i32_POST:
4484 case AArch64::LD1i64_POST:
4485 case AArch64::LD1i8_POST:
4486 case AArch64::LD2Rv16b_POST:
4487 case AArch64::LD2Rv1d_POST:
4488 case AArch64::LD2Rv2d_POST:
4489 case AArch64::LD2Rv2s_POST:
4490 case AArch64::LD2Rv4h_POST:
4491 case AArch64::LD2Rv4s_POST:
4492 case AArch64::LD2Rv8b_POST:
4493 case AArch64::LD2Rv8h_POST:
4494 case AArch64::LD2Twov16b_POST:
4495 case AArch64::LD2Twov2d_POST:
4496 case AArch64::LD2Twov2s_POST:
4497 case AArch64::LD2Twov4h_POST:
4498 case AArch64::LD2Twov4s_POST:
4499 case AArch64::LD2Twov8b_POST:
4500 case AArch64::LD2Twov8h_POST:
4501 case AArch64::LD2i16_POST:
4502 case AArch64::LD2i32_POST:
4503 case AArch64::LD2i64_POST:
4504 case AArch64::LD2i8_POST:
4505 case AArch64::LD3Rv16b_POST:
4506 case AArch64::LD3Rv1d_POST:
4507 case AArch64::LD3Rv2d_POST:
4508 case AArch64::LD3Rv2s_POST:
4509 case AArch64::LD3Rv4h_POST:
4510 case AArch64::LD3Rv4s_POST:
4511 case AArch64::LD3Rv8b_POST:
4512 case AArch64::LD3Rv8h_POST:
4513 case AArch64::LD3Threev16b_POST:
4514 case AArch64::LD3Threev2d_POST:
4515 case AArch64::LD3Threev2s_POST:
4516 case AArch64::LD3Threev4h_POST:
4517 case AArch64::LD3Threev4s_POST:
4518 case AArch64::LD3Threev8b_POST:
4519 case AArch64::LD3Threev8h_POST:
4520 case AArch64::LD3i16_POST:
4521 case AArch64::LD3i32_POST:
4522 case AArch64::LD3i64_POST:
4523 case AArch64::LD3i8_POST:
4524 case AArch64::LD4Fourv16b_POST:
4525 case AArch64::LD4Fourv2d_POST:
4526 case AArch64::LD4Fourv2s_POST:
4527 case AArch64::LD4Fourv4h_POST:
4528 case AArch64::LD4Fourv4s_POST:
4529 case AArch64::LD4Fourv8b_POST:
4530 case AArch64::LD4Fourv8h_POST:
4531 case AArch64::LD4Rv16b_POST:
4532 case AArch64::LD4Rv1d_POST:
4533 case AArch64::LD4Rv2d_POST:
4534 case AArch64::LD4Rv2s_POST:
4535 case AArch64::LD4Rv4h_POST:
4536 case AArch64::LD4Rv4s_POST:
4537 case AArch64::LD4Rv8b_POST:
4538 case AArch64::LD4Rv8h_POST:
4539 case AArch64::LD4i16_POST:
4540 case AArch64::LD4i32_POST:
4541 case AArch64::LD4i64_POST:
4542 case AArch64::LD4i8_POST:
4543 case AArch64::LDAPRWpost:
4544 case AArch64::LDAPRXpost:
4545 case AArch64::LDIAPPWpost:
4546 case AArch64::LDIAPPXpost:
4547 case AArch64::LDPDpost:
4548 case AArch64::LDPQpost:
4549 case AArch64::LDPSWpost:
4550 case AArch64::LDPSpost:
4551 case AArch64::LDPWpost:
4552 case AArch64::LDPXpost:
4553 case AArch64::LDRBBpost:
4554 case AArch64::LDRBpost:
4555 case AArch64::LDRDpost:
4556 case AArch64::LDRHHpost:
4557 case AArch64::LDRHpost:
4558 case AArch64::LDRQpost:
4559 case AArch64::LDRSBWpost:
4560 case AArch64::LDRSBXpost:
4561 case AArch64::LDRSHWpost:
4562 case AArch64::LDRSHXpost:
4563 case AArch64::LDRSWpost:
4564 case AArch64::LDRSpost:
4565 case AArch64::LDRWpost:
4566 case AArch64::LDRXpost:
4567 case AArch64::ST1Fourv16b_POST:
4568 case AArch64::ST1Fourv1d_POST:
4569 case AArch64::ST1Fourv2d_POST:
4570 case AArch64::ST1Fourv2s_POST:
4571 case AArch64::ST1Fourv4h_POST:
4572 case AArch64::ST1Fourv4s_POST:
4573 case AArch64::ST1Fourv8b_POST:
4574 case AArch64::ST1Fourv8h_POST:
4575 case AArch64::ST1Onev16b_POST:
4576 case AArch64::ST1Onev1d_POST:
4577 case AArch64::ST1Onev2d_POST:
4578 case AArch64::ST1Onev2s_POST:
4579 case AArch64::ST1Onev4h_POST:
4580 case AArch64::ST1Onev4s_POST:
4581 case AArch64::ST1Onev8b_POST:
4582 case AArch64::ST1Onev8h_POST:
4583 case AArch64::ST1Threev16b_POST:
4584 case AArch64::ST1Threev1d_POST:
4585 case AArch64::ST1Threev2d_POST:
4586 case AArch64::ST1Threev2s_POST:
4587 case AArch64::ST1Threev4h_POST:
4588 case AArch64::ST1Threev4s_POST:
4589 case AArch64::ST1Threev8b_POST:
4590 case AArch64::ST1Threev8h_POST:
4591 case AArch64::ST1Twov16b_POST:
4592 case AArch64::ST1Twov1d_POST:
4593 case AArch64::ST1Twov2d_POST:
4594 case AArch64::ST1Twov2s_POST:
4595 case AArch64::ST1Twov4h_POST:
4596 case AArch64::ST1Twov4s_POST:
4597 case AArch64::ST1Twov8b_POST:
4598 case AArch64::ST1Twov8h_POST:
4599 case AArch64::ST1i16_POST:
4600 case AArch64::ST1i32_POST:
4601 case AArch64::ST1i64_POST:
4602 case AArch64::ST1i8_POST:
4603 case AArch64::ST2GPostIndex:
4604 case AArch64::ST2Twov16b_POST:
4605 case AArch64::ST2Twov2d_POST:
4606 case AArch64::ST2Twov2s_POST:
4607 case AArch64::ST2Twov4h_POST:
4608 case AArch64::ST2Twov4s_POST:
4609 case AArch64::ST2Twov8b_POST:
4610 case AArch64::ST2Twov8h_POST:
4611 case AArch64::ST2i16_POST:
4612 case AArch64::ST2i32_POST:
4613 case AArch64::ST2i64_POST:
4614 case AArch64::ST2i8_POST:
4615 case AArch64::ST3Threev16b_POST:
4616 case AArch64::ST3Threev2d_POST:
4617 case AArch64::ST3Threev2s_POST:
4618 case AArch64::ST3Threev4h_POST:
4619 case AArch64::ST3Threev4s_POST:
4620 case AArch64::ST3Threev8b_POST:
4621 case AArch64::ST3Threev8h_POST:
4622 case AArch64::ST3i16_POST:
4623 case AArch64::ST3i32_POST:
4624 case AArch64::ST3i64_POST:
4625 case AArch64::ST3i8_POST:
4626 case AArch64::ST4Fourv16b_POST:
4627 case AArch64::ST4Fourv2d_POST:
4628 case AArch64::ST4Fourv2s_POST:
4629 case AArch64::ST4Fourv4h_POST:
4630 case AArch64::ST4Fourv4s_POST:
4631 case AArch64::ST4Fourv8b_POST:
4632 case AArch64::ST4Fourv8h_POST:
4633 case AArch64::ST4i16_POST:
4634 case AArch64::ST4i32_POST:
4635 case AArch64::ST4i64_POST:
4636 case AArch64::ST4i8_POST:
4637 case AArch64::STGPostIndex:
4638 case AArch64::STGPpost:
4639 case AArch64::STPDpost:
4640 case AArch64::STPQpost:
4641 case AArch64::STPSpost:
4642 case AArch64::STPWpost:
4643 case AArch64::STPXpost:
4644 case AArch64::STRBBpost:
4645 case AArch64::STRBpost:
4646 case AArch64::STRDpost:
4647 case AArch64::STRHHpost:
4648 case AArch64::STRHpost:
4649 case AArch64::STRQpost:
4650 case AArch64::STRSpost:
4651 case AArch64::STRWpost:
4652 case AArch64::STRXpost:
4653 case AArch64::STZ2GPostIndex:
4654 case AArch64::STZGPostIndex:
4661 bool &OffsetIsScalable,
TypeSize &Width,
4682 int64_t Dummy1, Dummy2;
4704 return BaseOp->
isReg() || BaseOp->
isFI();
4711 assert(OfsOp.
isImm() &&
"Offset operand wasn't immediate.");
4716 TypeSize &Width, int64_t &MinOffset,
4717 int64_t &MaxOffset) {
4722 MinOffset = MaxOffset = 0;
4725 case AArch64::LDRQui:
4726 case AArch64::STRQui:
4731 case AArch64::LDRXui:
4732 case AArch64::LDRDui:
4733 case AArch64::STRXui:
4734 case AArch64::STRDui:
4735 case AArch64::PRFMui:
4740 case AArch64::LDRWui:
4741 case AArch64::LDRSui:
4742 case AArch64::LDRSWui:
4743 case AArch64::STRWui:
4744 case AArch64::STRSui:
4749 case AArch64::LDRHui:
4750 case AArch64::LDRHHui:
4751 case AArch64::LDRSHWui:
4752 case AArch64::LDRSHXui:
4753 case AArch64::STRHui:
4754 case AArch64::STRHHui:
4759 case AArch64::LDRBui:
4760 case AArch64::LDRBBui:
4761 case AArch64::LDRSBWui:
4762 case AArch64::LDRSBXui:
4763 case AArch64::STRBui:
4764 case AArch64::STRBBui:
4770 case AArch64::STRQpre:
4771 case AArch64::LDRQpost:
4777 case AArch64::LDRDpost:
4778 case AArch64::LDRDpre:
4779 case AArch64::LDRXpost:
4780 case AArch64::LDRXpre:
4781 case AArch64::STRDpost:
4782 case AArch64::STRDpre:
4783 case AArch64::STRXpost:
4784 case AArch64::STRXpre:
4790 case AArch64::STRWpost:
4791 case AArch64::STRWpre:
4792 case AArch64::LDRWpost:
4793 case AArch64::LDRWpre:
4794 case AArch64::STRSpost:
4795 case AArch64::STRSpre:
4796 case AArch64::LDRSpost:
4797 case AArch64::LDRSpre:
4803 case AArch64::LDRHpost:
4804 case AArch64::LDRHpre:
4805 case AArch64::STRHpost:
4806 case AArch64::STRHpre:
4807 case AArch64::LDRHHpost:
4808 case AArch64::LDRHHpre:
4809 case AArch64::STRHHpost:
4810 case AArch64::STRHHpre:
4816 case AArch64::LDRBpost:
4817 case AArch64::LDRBpre:
4818 case AArch64::STRBpost:
4819 case AArch64::STRBpre:
4820 case AArch64::LDRBBpost:
4821 case AArch64::LDRBBpre:
4822 case AArch64::STRBBpost:
4823 case AArch64::STRBBpre:
4829 case AArch64::LDURQi:
4830 case AArch64::STURQi:
4836 case AArch64::LDURXi:
4837 case AArch64::LDURDi:
4838 case AArch64::LDAPURXi:
4839 case AArch64::STURXi:
4840 case AArch64::STURDi:
4841 case AArch64::STLURXi:
4842 case AArch64::PRFUMi:
4848 case AArch64::LDURWi:
4849 case AArch64::LDURSi:
4850 case AArch64::LDURSWi:
4851 case AArch64::LDAPURi:
4852 case AArch64::LDAPURSWi:
4853 case AArch64::STURWi:
4854 case AArch64::STURSi:
4855 case AArch64::STLURWi:
4861 case AArch64::LDURHi:
4862 case AArch64::LDURHHi:
4863 case AArch64::LDURSHXi:
4864 case AArch64::LDURSHWi:
4865 case AArch64::LDAPURHi:
4866 case AArch64::LDAPURSHWi:
4867 case AArch64::LDAPURSHXi:
4868 case AArch64::STURHi:
4869 case AArch64::STURHHi:
4870 case AArch64::STLURHi:
4876 case AArch64::LDURBi:
4877 case AArch64::LDURBBi:
4878 case AArch64::LDURSBXi:
4879 case AArch64::LDURSBWi:
4880 case AArch64::LDAPURBi:
4881 case AArch64::LDAPURSBWi:
4882 case AArch64::LDAPURSBXi:
4883 case AArch64::STURBi:
4884 case AArch64::STURBBi:
4885 case AArch64::STLURBi:
4891 case AArch64::LDPQi:
4892 case AArch64::LDNPQi:
4893 case AArch64::STPQi:
4894 case AArch64::STNPQi:
4895 case AArch64::LDPQpost:
4896 case AArch64::LDPQpre:
4897 case AArch64::STPQpost:
4898 case AArch64::STPQpre:
4904 case AArch64::LDPXi:
4905 case AArch64::LDPDi:
4906 case AArch64::LDNPXi:
4907 case AArch64::LDNPDi:
4908 case AArch64::STPXi:
4909 case AArch64::STPDi:
4910 case AArch64::STNPXi:
4911 case AArch64::STNPDi:
4912 case AArch64::LDPDpost:
4913 case AArch64::LDPDpre:
4914 case AArch64::LDPXpost:
4915 case AArch64::LDPXpre:
4916 case AArch64::STPDpost:
4917 case AArch64::STPDpre:
4918 case AArch64::STPXpost:
4919 case AArch64::STPXpre:
4925 case AArch64::LDPWi:
4926 case AArch64::LDPSi:
4927 case AArch64::LDNPWi:
4928 case AArch64::LDNPSi:
4929 case AArch64::STPWi:
4930 case AArch64::STPSi:
4931 case AArch64::STNPWi:
4932 case AArch64::STNPSi:
4933 case AArch64::LDPSpost:
4934 case AArch64::LDPSpre:
4935 case AArch64::LDPWpost:
4936 case AArch64::LDPWpre:
4937 case AArch64::STPSpost:
4938 case AArch64::STPSpre:
4939 case AArch64::STPWpost:
4940 case AArch64::STPWpre:
4946 case AArch64::StoreSwiftAsyncContext:
4959 case AArch64::TAGPstack:
4969 case AArch64::STGPreIndex:
4970 case AArch64::STGPostIndex:
4971 case AArch64::STZGi:
4972 case AArch64::STZGPreIndex:
4973 case AArch64::STZGPostIndex:
4979 case AArch64::STR_ZZZZXI:
4980 case AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS:
4981 case AArch64::LDR_ZZZZXI:
4982 case AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS:
4988 case AArch64::STR_ZZZXI:
4989 case AArch64::LDR_ZZZXI:
4995 case AArch64::STR_ZZXI:
4996 case AArch64::STR_ZZXI_STRIDED_CONTIGUOUS:
4997 case AArch64::LDR_ZZXI:
4998 case AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS:
5004 case AArch64::LDR_PXI:
5005 case AArch64::STR_PXI:
5010 case AArch64::LDR_PPXI:
5011 case AArch64::STR_PPXI:
5017 case AArch64::LDR_ZXI:
5018 case AArch64::STR_ZXI:
5023 case AArch64::LD1B_IMM:
5024 case AArch64::LD1H_IMM:
5025 case AArch64::LD1W_IMM:
5026 case AArch64::LD1D_IMM:
5027 case AArch64::LDNT1B_ZRI:
5028 case AArch64::LDNT1H_ZRI:
5029 case AArch64::LDNT1W_ZRI:
5030 case AArch64::LDNT1D_ZRI:
5031 case AArch64::ST1B_IMM:
5032 case AArch64::ST1H_IMM:
5033 case AArch64::ST1W_IMM:
5034 case AArch64::ST1D_IMM:
5035 case AArch64::STNT1B_ZRI:
5036 case AArch64::STNT1H_ZRI:
5037 case AArch64::STNT1W_ZRI:
5038 case AArch64::STNT1D_ZRI:
5039 case AArch64::LDNF1B_IMM:
5040 case AArch64::LDNF1H_IMM:
5041 case AArch64::LDNF1W_IMM:
5042 case AArch64::LDNF1D_IMM:
5049 case AArch64::LD2B_IMM:
5050 case AArch64::LD2H_IMM:
5051 case AArch64::LD2W_IMM:
5052 case AArch64::LD2D_IMM:
5053 case AArch64::ST2B_IMM:
5054 case AArch64::ST2H_IMM:
5055 case AArch64::ST2W_IMM:
5056 case AArch64::ST2D_IMM:
5057 case AArch64::LD1B_2Z_IMM:
5058 case AArch64::LD1B_2Z_STRIDED_IMM:
5059 case AArch64::LD1H_2Z_IMM:
5060 case AArch64::LD1H_2Z_STRIDED_IMM:
5061 case AArch64::LD1W_2Z_IMM:
5062 case AArch64::LD1W_2Z_STRIDED_IMM:
5063 case AArch64::LD1D_2Z_IMM:
5064 case AArch64::LD1D_2Z_STRIDED_IMM:
5065 case AArch64::LD1B_2Z_IMM_PSEUDO:
5066 case AArch64::LD1H_2Z_IMM_PSEUDO:
5067 case AArch64::LD1W_2Z_IMM_PSEUDO:
5068 case AArch64::LD1D_2Z_IMM_PSEUDO:
5069 case AArch64::ST1B_2Z_IMM:
5070 case AArch64::ST1B_2Z_STRIDED_IMM:
5071 case AArch64::ST1H_2Z_IMM:
5072 case AArch64::ST1H_2Z_STRIDED_IMM:
5073 case AArch64::ST1W_2Z_IMM:
5074 case AArch64::ST1W_2Z_STRIDED_IMM:
5075 case AArch64::ST1D_2Z_IMM:
5076 case AArch64::ST1D_2Z_STRIDED_IMM:
5077 case AArch64::LDNT1B_2Z_IMM_PSEUDO:
5078 case AArch64::LDNT1B_2Z_IMM:
5079 case AArch64::LDNT1B_2Z_STRIDED_IMM:
5080 case AArch64::LDNT1H_2Z_IMM_PSEUDO:
5081 case AArch64::LDNT1H_2Z_IMM:
5082 case AArch64::LDNT1H_2Z_STRIDED_IMM:
5083 case AArch64::LDNT1W_2Z_IMM_PSEUDO:
5084 case AArch64::LDNT1W_2Z_IMM:
5085 case AArch64::LDNT1W_2Z_STRIDED_IMM:
5086 case AArch64::LDNT1D_2Z_IMM_PSEUDO:
5087 case AArch64::LDNT1D_2Z_IMM:
5088 case AArch64::LDNT1D_2Z_STRIDED_IMM:
5089 case AArch64::STNT1B_2Z_IMM:
5090 case AArch64::STNT1B_2Z_STRIDED_IMM:
5091 case AArch64::STNT1H_2Z_IMM:
5092 case AArch64::STNT1H_2Z_STRIDED_IMM:
5093 case AArch64::STNT1W_2Z_IMM:
5094 case AArch64::STNT1W_2Z_STRIDED_IMM:
5095 case AArch64::STNT1D_2Z_IMM:
5096 case AArch64::STNT1D_2Z_STRIDED_IMM:
5097 case AArch64::ST1B_2Z_IMM_PSEUDO:
5098 case AArch64::ST1H_2Z_IMM_PSEUDO:
5099 case AArch64::ST1W_2Z_IMM_PSEUDO:
5100 case AArch64::ST1D_2Z_IMM_PSEUDO:
5101 case AArch64::STNT1B_2Z_IMM_PSEUDO:
5102 case AArch64::STNT1H_2Z_IMM_PSEUDO:
5103 case AArch64::STNT1W_2Z_IMM_PSEUDO:
5104 case AArch64::STNT1D_2Z_IMM_PSEUDO:
5109 case AArch64::LD3B_IMM:
5110 case AArch64::LD3H_IMM:
5111 case AArch64::LD3W_IMM:
5112 case AArch64::LD3D_IMM:
5113 case AArch64::ST3B_IMM:
5114 case AArch64::ST3H_IMM:
5115 case AArch64::ST3W_IMM:
5116 case AArch64::ST3D_IMM:
5121 case AArch64::LD4B_IMM:
5122 case AArch64::LD4H_IMM:
5123 case AArch64::LD4W_IMM:
5124 case AArch64::LD4D_IMM:
5125 case AArch64::ST4B_IMM:
5126 case AArch64::ST4H_IMM:
5127 case AArch64::ST4W_IMM:
5128 case AArch64::ST4D_IMM:
5129 case AArch64::LD1B_4Z_IMM:
5130 case AArch64::LD1B_4Z_STRIDED_IMM:
5131 case AArch64::LD1H_4Z_IMM:
5132 case AArch64::LD1H_4Z_STRIDED_IMM:
5133 case AArch64::LD1W_4Z_IMM:
5134 case AArch64::LD1W_4Z_STRIDED_IMM:
5135 case AArch64::LD1D_4Z_IMM:
5136 case AArch64::LD1D_4Z_STRIDED_IMM:
5137 case AArch64::LD1B_4Z_IMM_PSEUDO:
5138 case AArch64::LD1H_4Z_IMM_PSEUDO:
5139 case AArch64::LD1W_4Z_IMM_PSEUDO:
5140 case AArch64::LD1D_4Z_IMM_PSEUDO:
5141 case AArch64::ST1B_4Z_IMM:
5142 case AArch64::ST1B_4Z_STRIDED_IMM:
5143 case AArch64::ST1H_4Z_IMM:
5144 case AArch64::ST1H_4Z_STRIDED_IMM:
5145 case AArch64::ST1W_4Z_IMM:
5146 case AArch64::ST1W_4Z_STRIDED_IMM:
5147 case AArch64::ST1D_4Z_IMM:
5148 case AArch64::ST1D_4Z_STRIDED_IMM:
5149 case AArch64::LDNT1B_4Z_IMM_PSEUDO:
5150 case AArch64::LDNT1B_4Z_IMM:
5151 case AArch64::LDNT1B_4Z_STRIDED_IMM:
5152 case AArch64::LDNT1H_4Z_IMM_PSEUDO:
5153 case AArch64::LDNT1H_4Z_IMM:
5154 case AArch64::LDNT1H_4Z_STRIDED_IMM:
5155 case AArch64::LDNT1W_4Z_IMM_PSEUDO:
5156 case AArch64::LDNT1W_4Z_IMM:
5157 case AArch64::LDNT1W_4Z_STRIDED_IMM:
5158 case AArch64::LDNT1D_4Z_IMM_PSEUDO:
5159 case AArch64::LDNT1D_4Z_IMM:
5160 case AArch64::LDNT1D_4Z_STRIDED_IMM:
5161 case AArch64::STNT1B_4Z_IMM:
5162 case AArch64::STNT1B_4Z_STRIDED_IMM:
5163 case AArch64::STNT1H_4Z_IMM:
5164 case AArch64::STNT1H_4Z_STRIDED_IMM:
5165 case AArch64::STNT1W_4Z_IMM:
5166 case AArch64::STNT1W_4Z_STRIDED_IMM:
5167 case AArch64::STNT1D_4Z_IMM:
5168 case AArch64::STNT1D_4Z_STRIDED_IMM:
5169 case AArch64::ST1B_4Z_IMM_PSEUDO:
5170 case AArch64::ST1H_4Z_IMM_PSEUDO:
5171 case AArch64::ST1W_4Z_IMM_PSEUDO:
5172 case AArch64::ST1D_4Z_IMM_PSEUDO:
5173 case AArch64::STNT1B_4Z_IMM_PSEUDO:
5174 case AArch64::STNT1H_4Z_IMM_PSEUDO:
5175 case AArch64::STNT1W_4Z_IMM_PSEUDO:
5176 case AArch64::STNT1D_4Z_IMM_PSEUDO:
5181 case AArch64::LD1B_H_IMM:
5182 case AArch64::LD1SB_H_IMM:
5183 case AArch64::LD1H_S_IMM:
5184 case AArch64::LD1SH_S_IMM:
5185 case AArch64::LD1W_D_IMM:
5186 case AArch64::LD1SW_D_IMM:
5187 case AArch64::ST1B_H_IMM:
5188 case AArch64::ST1H_S_IMM:
5189 case AArch64::ST1W_D_IMM:
5190 case AArch64::LDNF1B_H_IMM:
5191 case AArch64::LDNF1SB_H_IMM:
5192 case AArch64::LDNF1H_S_IMM:
5193 case AArch64::LDNF1SH_S_IMM:
5194 case AArch64::LDNF1W_D_IMM:
5195 case AArch64::LDNF1SW_D_IMM:
5202 case AArch64::LD1B_S_IMM:
5203 case AArch64::LD1SB_S_IMM:
5204 case AArch64::LD1H_D_IMM:
5205 case AArch64::LD1SH_D_IMM:
5206 case AArch64::ST1B_S_IMM:
5207 case AArch64::ST1H_D_IMM:
5208 case AArch64::LDNF1B_S_IMM:
5209 case AArch64::LDNF1SB_S_IMM:
5210 case AArch64::LDNF1H_D_IMM:
5211 case AArch64::LDNF1SH_D_IMM:
5218 case AArch64::LD1B_D_IMM:
5219 case AArch64::LD1SB_D_IMM:
5220 case AArch64::ST1B_D_IMM:
5221 case AArch64::LDNF1B_D_IMM:
5222 case AArch64::LDNF1SB_D_IMM:
5229 case AArch64::ST2Gi:
5230 case AArch64::ST2GPreIndex:
5231 case AArch64::ST2GPostIndex:
5232 case AArch64::STZ2Gi:
5233 case AArch64::STZ2GPreIndex:
5234 case AArch64::STZ2GPostIndex:
5240 case AArch64::STGPi:
5241 case AArch64::STGPpost:
5242 case AArch64::STGPpre:
5247 case AArch64::LD1RB_IMM:
5248 case AArch64::LD1RB_H_IMM:
5249 case AArch64::LD1RB_S_IMM:
5250 case AArch64::LD1RB_D_IMM:
5251 case AArch64::LD1RSB_H_IMM:
5252 case AArch64::LD1RSB_S_IMM:
5253 case AArch64::LD1RSB_D_IMM:
5258 case AArch64::LD1RH_IMM:
5259 case AArch64::LD1RH_S_IMM:
5260 case AArch64::LD1RH_D_IMM:
5261 case AArch64::LD1RSH_S_IMM:
5262 case AArch64::LD1RSH_D_IMM:
5267 case AArch64::LD1RW_IMM:
5268 case AArch64::LD1RW_D_IMM:
5269 case AArch64::LD1RSW_IMM:
5274 case AArch64::LD1RD_IMM:
5289 case AArch64::LDRBui:
5290 case AArch64::LDRBBui:
5291 case AArch64::LDURBBi:
5292 case AArch64::LDRSBWui:
5293 case AArch64::LDURSBWi:
5294 case AArch64::STRBui:
5295 case AArch64::STRBBui:
5296 case AArch64::STURBBi:
5298 case AArch64::LDRHui:
5299 case AArch64::LDRHHui:
5300 case AArch64::LDURHHi:
5301 case AArch64::LDRSHWui:
5302 case AArch64::LDURSHWi:
5303 case AArch64::STRHui:
5304 case AArch64::STRHHui:
5305 case AArch64::STURHHi:
5307 case AArch64::LDRSui:
5308 case AArch64::LDURSi:
5309 case AArch64::LDRSpre:
5310 case AArch64::LDRSWui:
5311 case AArch64::LDURSWi:
5312 case AArch64::LDRSWpre:
5313 case AArch64::LDRWpre:
5314 case AArch64::LDRWui:
5315 case AArch64::LDURWi:
5316 case AArch64::STRSui:
5317 case AArch64::STURSi:
5318 case AArch64::STRSpre:
5319 case AArch64::STRWui:
5320 case AArch64::STURWi:
5321 case AArch64::STRWpre:
5322 case AArch64::LDPSi:
5323 case AArch64::LDPSWi:
5324 case AArch64::LDPWi:
5325 case AArch64::STPSi:
5326 case AArch64::STPWi:
5328 case AArch64::LDRDui:
5329 case AArch64::LDURDi:
5330 case AArch64::LDRDpre:
5331 case AArch64::LDRXui:
5332 case AArch64::LDURXi:
5333 case AArch64::LDRXpre:
5334 case AArch64::STRDui:
5335 case AArch64::STURDi:
5336 case AArch64::STRDpre:
5337 case AArch64::STRXui:
5338 case AArch64::STURXi:
5339 case AArch64::STRXpre:
5340 case AArch64::LDPDi:
5341 case AArch64::LDPXi:
5342 case AArch64::STPDi:
5343 case AArch64::STPXi:
5345 case AArch64::LDRQui:
5346 case AArch64::LDURQi:
5347 case AArch64::STRQui:
5348 case AArch64::STURQi:
5349 case AArch64::STRQpre:
5350 case AArch64::LDPQi:
5351 case AArch64::LDRQpre:
5352 case AArch64::STPQi:
5354 case AArch64::STZGi:
5355 case AArch64::ST2Gi:
5356 case AArch64::STZ2Gi:
5357 case AArch64::STGPi:
5363 switch (
MI.getOpcode()) {
5366 case AArch64::LDRWpre:
5367 case AArch64::LDRXpre:
5368 case AArch64::LDRSWpre:
5369 case AArch64::LDRSpre:
5370 case AArch64::LDRDpre:
5371 case AArch64::LDRQpre:
5377 switch (
MI.getOpcode()) {
5380 case AArch64::STRWpre:
5381 case AArch64::STRXpre:
5382 case AArch64::STRSpre:
5383 case AArch64::STRDpre:
5384 case AArch64::STRQpre:
5394 switch (
MI.getOpcode()) {
5397 case AArch64::LDURBBi:
5398 case AArch64::LDURHHi:
5399 case AArch64::LDURWi:
5400 case AArch64::LDRBBui:
5401 case AArch64::LDRHHui:
5402 case AArch64::LDRWui:
5403 case AArch64::LDRBBroX:
5404 case AArch64::LDRHHroX:
5405 case AArch64::LDRWroX:
5406 case AArch64::LDRBBroW:
5407 case AArch64::LDRHHroW:
5408 case AArch64::LDRWroW:
5414 switch (
MI.getOpcode()) {
5417 case AArch64::LDURSBWi:
5418 case AArch64::LDURSHWi:
5419 case AArch64::LDURSBXi:
5420 case AArch64::LDURSHXi:
5421 case AArch64::LDURSWi:
5422 case AArch64::LDRSBWui:
5423 case AArch64::LDRSHWui:
5424 case AArch64::LDRSBXui:
5425 case AArch64::LDRSHXui:
5426 case AArch64::LDRSWui:
5427 case AArch64::LDRSBWroX:
5428 case AArch64::LDRSHWroX:
5429 case AArch64::LDRSBXroX:
5430 case AArch64::LDRSHXroX:
5431 case AArch64::LDRSWroX:
5432 case AArch64::LDRSBWroW:
5433 case AArch64::LDRSHWroW:
5434 case AArch64::LDRSBXroW:
5435 case AArch64::LDRSHXroW:
5436 case AArch64::LDRSWroW:
5442 switch (
MI.getOpcode()) {
5445 case AArch64::LDPSi:
5446 case AArch64::LDPSWi:
5447 case AArch64::LDPDi:
5448 case AArch64::LDPQi:
5449 case AArch64::LDPWi:
5450 case AArch64::LDPXi:
5451 case AArch64::STPSi:
5452 case AArch64::STPDi:
5453 case AArch64::STPQi:
5454 case AArch64::STPWi:
5455 case AArch64::STPXi:
5456 case AArch64::STGPi:
5462 assert(
MI.mayLoadOrStore() &&
"Load or store instruction expected");
5466 return MI.getOperand(Idx);
5471 assert(
MI.mayLoadOrStore() &&
"Load or store instruction expected");
5475 return MI.getOperand(Idx);
5480 switch (
MI.getOpcode()) {
5483 case AArch64::LDRBroX:
5484 case AArch64::LDRBBroX:
5485 case AArch64::LDRSBXroX:
5486 case AArch64::LDRSBWroX:
5487 case AArch64::LDRHroX:
5488 case AArch64::LDRHHroX:
5489 case AArch64::LDRSHXroX:
5490 case AArch64::LDRSHWroX:
5491 case AArch64::LDRWroX:
5492 case AArch64::LDRSroX:
5493 case AArch64::LDRSWroX:
5494 case AArch64::LDRDroX:
5495 case AArch64::LDRXroX:
5496 case AArch64::LDRQroX:
5497 return MI.getOperand(4);
5503 if (
MI.getParent() ==
nullptr)
5513 auto Reg =
Op.getReg();
5514 if (Reg.isPhysical())
5515 return AArch64::FPR16RegClass.contains(Reg);
5517 return TRC == &AArch64::FPR16RegClass ||
5518 TRC == &AArch64::FPR16_loRegClass;
5527 auto Reg =
Op.getReg();
5528 if (Reg.isPhysical())
5529 return AArch64::FPR128RegClass.contains(Reg);
5531 return TRC == &AArch64::FPR128RegClass ||
5532 TRC == &AArch64::FPR128_loRegClass;
5538 switch (
MI.getOpcode()) {
5541 case AArch64::PACIASP:
5542 case AArch64::PACIBSP:
5545 case AArch64::PAUTH_PROLOGUE:
5548 case AArch64::HINT: {
5549 unsigned Imm =
MI.getOperand(0).getImm();
5554 if (
Imm == 25 ||
Imm == 27)
5566 assert(Reg.isPhysical() &&
"Expected physical register in isFpOrNEON");
5567 return AArch64::FPR128RegClass.contains(Reg) ||
5568 AArch64::FPR64RegClass.contains(Reg) ||
5569 AArch64::FPR32RegClass.contains(Reg) ||
5570 AArch64::FPR16RegClass.contains(Reg) ||
5571 AArch64::FPR8RegClass.contains(Reg);
5578 auto Reg =
Op.getReg();
5579 if (Reg.isPhysical())
5583 return TRC == &AArch64::FPR128RegClass ||
5584 TRC == &AArch64::FPR128_loRegClass ||
5585 TRC == &AArch64::FPR64RegClass ||
5586 TRC == &AArch64::FPR64_loRegClass ||
5587 TRC == &AArch64::FPR32RegClass || TRC == &AArch64::FPR16RegClass ||
5588 TRC == &AArch64::FPR8RegClass;
5610 if (FirstOpc == SecondOpc)
5616 case AArch64::STRSui:
5617 case AArch64::STURSi:
5618 return SecondOpc == AArch64::STRSui || SecondOpc == AArch64::STURSi;
5619 case AArch64::STRDui:
5620 case AArch64::STURDi:
5621 return SecondOpc == AArch64::STRDui || SecondOpc == AArch64::STURDi;
5622 case AArch64::STRQui:
5623 case AArch64::STURQi:
5624 return SecondOpc == AArch64::STRQui || SecondOpc == AArch64::STURQi;
5625 case AArch64::STRWui:
5626 case AArch64::STURWi:
5627 return SecondOpc == AArch64::STRWui || SecondOpc == AArch64::STURWi;
5628 case AArch64::STRXui:
5629 case AArch64::STURXi:
5630 return SecondOpc == AArch64::STRXui || SecondOpc == AArch64::STURXi;
5631 case AArch64::LDRSui:
5632 case AArch64::LDURSi:
5633 return SecondOpc == AArch64::LDRSui || SecondOpc == AArch64::LDURSi;
5634 case AArch64::LDRDui:
5635 case AArch64::LDURDi:
5636 return SecondOpc == AArch64::LDRDui || SecondOpc == AArch64::LDURDi;
5637 case AArch64::LDRQui:
5638 case AArch64::LDURQi:
5639 return SecondOpc == AArch64::LDRQui || SecondOpc == AArch64::LDURQi;
5640 case AArch64::LDRWui:
5641 case AArch64::LDURWi:
5642 return SecondOpc == AArch64::LDRSWui || SecondOpc == AArch64::LDURSWi;
5643 case AArch64::LDRSWui:
5644 case AArch64::LDURSWi:
5645 return SecondOpc == AArch64::LDRWui || SecondOpc == AArch64::LDURWi;
5646 case AArch64::LDRXui:
5647 case AArch64::LDURXi:
5648 return SecondOpc == AArch64::LDRXui || SecondOpc == AArch64::LDURXi;
5655 int64_t Offset1,
unsigned Opcode1,
int FI2,
5656 int64_t Offset2,
unsigned Opcode2) {
5662 assert(ObjectOffset1 <= ObjectOffset2 &&
"Object offsets are not ordered.");
5665 if (ObjectOffset1 % Scale1 != 0)
5667 ObjectOffset1 /= Scale1;
5669 if (ObjectOffset2 % Scale2 != 0)
5671 ObjectOffset2 /= Scale2;
5672 ObjectOffset1 += Offset1;
5673 ObjectOffset2 += Offset2;
5674 return ObjectOffset1 + 1 == ObjectOffset2;
5686 int64_t OpOffset2,
bool OffsetIsScalable2,
unsigned ClusterSize,
5687 unsigned NumBytes)
const {
5697 "Only base registers and frame indices are supported.");
5704 if (ClusterSize > 2)
5711 unsigned FirstOpc = FirstLdSt.
getOpcode();
5712 unsigned SecondOpc = SecondLdSt.
getOpcode();
5732 if (Offset1 > 63 || Offset1 < -64)
5737 if (BaseOp1.
isFI()) {
5739 "Caller should have ordered offsets.");
5744 BaseOp2.
getIndex(), Offset2, SecondOpc);
5747 assert(Offset1 <= Offset2 &&
"Caller should have ordered offsets.");
5749 return Offset1 + 1 == Offset2;
5759 if (
Reg.isPhysical())
5769 assert(Subtarget.hasNEON() &&
"Unexpected register copy without NEON");
5771 uint16_t DestEncoding =
TRI->getEncodingValue(DestReg);
5772 uint16_t SrcEncoding =
TRI->getEncodingValue(SrcReg);
5773 unsigned NumRegs = Indices.
size();
5774 MCRegister DestSubReg =
TRI->getSubReg(DestReg, Indices[0]);
5776 "Unexpected predicate tuple copy");
5777 unsigned MaxRegs = AArch64::PPRRegClass.contains(DestSubReg) ? 15 : 31;
5779 int SubReg = 0, End = NumRegs, Incr = 1;
5781 if (((DestEncoding - SrcEncoding) & MaxRegs) < NumRegs) {
5782 SubReg = NumRegs - 1;
5787 for (; SubReg != End; SubReg += Incr) {
5788 DestSubReg =
TRI->getSubReg(DestReg, Indices[SubReg]);
5789 MCRegister SrcSubReg =
TRI->getSubReg(SrcReg, Indices[SubReg]);
5798 unsigned Opcode,
unsigned ZeroReg,
5801 unsigned NumRegs = Indices.
size();
5804 uint16_t DestEncoding =
TRI->getEncodingValue(DestReg);
5805 uint16_t SrcEncoding =
TRI->getEncodingValue(SrcReg);
5806 assert(DestEncoding % NumRegs == 0 && SrcEncoding % NumRegs == 0 &&
5807 "GPR reg sequences should not be able to overlap");
5810 for (
unsigned SubReg = 0; SubReg != NumRegs; ++SubReg) {
5831 unsigned Opc =
MI.getOpcode();
5832 if (
Opc == AArch64::MSRpstatesvcrImm1 ||
Opc == AArch64::MSRpstatePseudo) {
5834 int64_t PState =
MI.getOperand(0).getImm();
5835 if (PState == AArch64SVCR::SVCRSM || PState == AArch64SVCR::SVCRSMZA) {
5837 return MI.getOperand(1).getImm() == 1;
5856 bool RenamableSrc)
const {
5857 if (AArch64::GPR32spRegClass.
contains(DestReg) &&
5858 AArch64::GPR32spRegClass.
contains(SrcReg)) {
5859 if (DestReg == AArch64::WSP || SrcReg == AArch64::WSP) {
5861 if (Subtarget.hasZeroCycleRegMoveGPR64() &&
5862 !Subtarget.hasZeroCycleRegMoveGPR32()) {
5864 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5865 &AArch64::GPR64spRegClass);
5866 MCRegister SrcRegX = RI.getMatchingSuperReg(SrcReg, AArch64::sub_32,
5867 &AArch64::GPR64spRegClass);
5877 ++NumZCRegMoveInstrsGPR;
5883 if (Subtarget.hasZeroCycleRegMoveGPR32())
5884 ++NumZCRegMoveInstrsGPR;
5886 }
else if (Subtarget.hasZeroCycleRegMoveGPR64() &&
5887 !Subtarget.hasZeroCycleRegMoveGPR32()) {
5889 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5890 &AArch64::GPR64spRegClass);
5891 assert(DestRegX.
isValid() &&
"Destination super-reg not valid");
5892 MCRegister SrcRegX = RI.getMatchingSuperReg(SrcReg, AArch64::sub_32,
5893 &AArch64::GPR64spRegClass);
5903 ++NumZCRegMoveInstrsGPR;
5909 if (Subtarget.hasZeroCycleRegMoveGPR32())
5910 ++NumZCRegMoveInstrsGPR;
5916 if (AArch64::GPR32spRegClass.
contains(DestReg) && SrcReg == AArch64::WZR) {
5917 if (Subtarget.hasZeroCycleZeroingGPR64() &&
5918 !Subtarget.hasZeroCycleZeroingGPR32()) {
5919 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5920 &AArch64::GPR64spRegClass);
5921 assert(DestRegX.
isValid() &&
"Destination super-reg not valid");
5925 ++NumZCZeroingInstrsGPR;
5926 }
else if (Subtarget.hasZeroCycleZeroingGPR32()) {
5930 ++NumZCZeroingInstrsGPR;
5939 if (AArch64::GPR64spRegClass.
contains(DestReg) &&
5940 AArch64::GPR64spRegClass.
contains(SrcReg)) {
5941 if (DestReg == AArch64::SP || SrcReg == AArch64::SP) {
5947 if (Subtarget.hasZeroCycleRegMoveGPR64())
5948 ++NumZCRegMoveInstrsGPR;
5954 if (Subtarget.hasZeroCycleRegMoveGPR64())
5955 ++NumZCRegMoveInstrsGPR;
5961 if (AArch64::GPR64spRegClass.
contains(DestReg) && SrcReg == AArch64::XZR) {
5962 if (Subtarget.hasZeroCycleZeroingGPR64()) {
5966 ++NumZCZeroingInstrsGPR;
5976 if (AArch64::PPRRegClass.
contains(DestReg) &&
5977 AArch64::PPRRegClass.
contains(SrcReg)) {
5978 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
5979 "Unexpected SVE register.");
5989 bool DestIsPNR = AArch64::PNRRegClass.contains(DestReg);
5990 bool SrcIsPNR = AArch64::PNRRegClass.contains(SrcReg);
5991 if (DestIsPNR || SrcIsPNR) {
5993 return (R - AArch64::PN0) + AArch64::P0;
5998 if (PPRSrcReg != PPRDestReg) {
6010 if (AArch64::PPR2RegClass.
contains(DestReg) &&
6011 AArch64::PPR2RegClass.
contains(SrcReg)) {
6012 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6013 "Unexpected SVE predicate register.");
6014 static const unsigned Indices[] = {AArch64::psub0, AArch64::psub1};
6020 if (AArch64::ZPRRegClass.
contains(DestReg) &&
6021 AArch64::ZPRRegClass.
contains(SrcReg)) {
6022 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6023 "Unexpected SVE register.");
6031 if ((AArch64::ZPR2RegClass.
contains(DestReg) ||
6032 AArch64::ZPR2StridedOrContiguousRegClass.
contains(DestReg)) &&
6033 (AArch64::ZPR2RegClass.
contains(SrcReg) ||
6034 AArch64::ZPR2StridedOrContiguousRegClass.
contains(SrcReg))) {
6035 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6036 "Unexpected SVE register.");
6037 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1};
6043 if (AArch64::ZPR3RegClass.
contains(DestReg) &&
6044 AArch64::ZPR3RegClass.
contains(SrcReg)) {
6045 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6046 "Unexpected SVE register.");
6047 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1,
6054 if ((AArch64::ZPR4RegClass.
contains(DestReg) ||
6055 AArch64::ZPR4StridedOrContiguousRegClass.
contains(DestReg)) &&
6056 (AArch64::ZPR4RegClass.
contains(SrcReg) ||
6057 AArch64::ZPR4StridedOrContiguousRegClass.
contains(SrcReg))) {
6058 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6059 "Unexpected SVE register.");
6060 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1,
6061 AArch64::zsub2, AArch64::zsub3};
6067 if (AArch64::DDDDRegClass.
contains(DestReg) &&
6068 AArch64::DDDDRegClass.
contains(SrcReg)) {
6069 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1,
6070 AArch64::dsub2, AArch64::dsub3};
6076 if (AArch64::DDDRegClass.
contains(DestReg) &&
6077 AArch64::DDDRegClass.
contains(SrcReg)) {
6078 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1,
6085 if (AArch64::DDRegClass.
contains(DestReg) &&
6086 AArch64::DDRegClass.
contains(SrcReg)) {
6087 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1};
6093 if (AArch64::QQQQRegClass.
contains(DestReg) &&
6094 AArch64::QQQQRegClass.
contains(SrcReg)) {
6095 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1,
6096 AArch64::qsub2, AArch64::qsub3};
6102 if (AArch64::QQQRegClass.
contains(DestReg) &&
6103 AArch64::QQQRegClass.
contains(SrcReg)) {
6104 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1,
6111 if (AArch64::QQRegClass.
contains(DestReg) &&
6112 AArch64::QQRegClass.
contains(SrcReg)) {
6113 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1};
6118 if (AArch64::XSeqPairsClassRegClass.
contains(DestReg) &&
6119 AArch64::XSeqPairsClassRegClass.
contains(SrcReg)) {
6120 static const unsigned Indices[] = {AArch64::sube64, AArch64::subo64};
6122 AArch64::XZR, Indices);
6126 if (AArch64::WSeqPairsClassRegClass.
contains(DestReg) &&
6127 AArch64::WSeqPairsClassRegClass.
contains(SrcReg)) {
6128 static const unsigned Indices[] = {AArch64::sube32, AArch64::subo32};
6130 AArch64::WZR, Indices);
6134 if (AArch64::FPR128RegClass.
contains(DestReg) &&
6135 AArch64::FPR128RegClass.
contains(SrcReg)) {
6139 if ((Subtarget.isSVEorStreamingSVEAvailable() &&
6140 !Subtarget.isNeonAvailable()) ||
6144 .
addReg(AArch64::Z0 + (SrcReg - AArch64::Q0))
6145 .
addReg(AArch64::Z0 + (SrcReg - AArch64::Q0));
6146 }
else if (Subtarget.isNeonAvailable()) {
6150 if (Subtarget.hasZeroCycleRegMoveFPR128())
6151 ++NumZCRegMoveInstrsFPR;
6167 if (AArch64::FPR64RegClass.
contains(DestReg) &&
6168 AArch64::FPR64RegClass.
contains(SrcReg)) {
6169 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
6170 !Subtarget.hasZeroCycleRegMoveFPR64() &&
6171 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
6173 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::dsub,
6174 &AArch64::FPR128RegClass);
6175 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::dsub,
6176 &AArch64::FPR128RegClass);
6185 ++NumZCRegMoveInstrsFPR;
6189 if (Subtarget.hasZeroCycleRegMoveFPR64())
6190 ++NumZCRegMoveInstrsFPR;
6195 if (AArch64::FPR32RegClass.
contains(DestReg) &&
6196 AArch64::FPR32RegClass.
contains(SrcReg)) {
6197 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
6198 !Subtarget.hasZeroCycleRegMoveFPR64() &&
6199 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
6201 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::ssub,
6202 &AArch64::FPR128RegClass);
6203 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::ssub,
6204 &AArch64::FPR128RegClass);
6213 ++NumZCRegMoveInstrsFPR;
6214 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
6215 !Subtarget.hasZeroCycleRegMoveFPR32()) {
6216 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::ssub,
6217 &AArch64::FPR64RegClass);
6218 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::ssub,
6219 &AArch64::FPR64RegClass);
6227 ++NumZCRegMoveInstrsFPR;
6231 if (Subtarget.hasZeroCycleRegMoveFPR32())
6232 ++NumZCRegMoveInstrsFPR;
6237 if (AArch64::FPR16RegClass.
contains(DestReg) &&
6238 AArch64::FPR16RegClass.
contains(SrcReg)) {
6239 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
6240 !Subtarget.hasZeroCycleRegMoveFPR64() &&
6241 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
6243 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
6244 &AArch64::FPR128RegClass);
6245 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
6246 &AArch64::FPR128RegClass);
6255 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
6256 !Subtarget.hasZeroCycleRegMoveFPR32()) {
6257 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
6258 &AArch64::FPR64RegClass);
6259 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
6260 &AArch64::FPR64RegClass);
6269 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
6270 &AArch64::FPR32RegClass);
6271 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
6272 &AArch64::FPR32RegClass);
6279 if (AArch64::FPR8RegClass.
contains(DestReg) &&
6280 AArch64::FPR8RegClass.
contains(SrcReg)) {
6281 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
6282 !Subtarget.hasZeroCycleRegMoveFPR64() &&
6283 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
6285 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
6286 &AArch64::FPR128RegClass);
6287 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
6288 &AArch64::FPR128RegClass);
6297 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
6298 !Subtarget.hasZeroCycleRegMoveFPR32()) {
6299 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
6300 &AArch64::FPR64RegClass);
6301 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
6302 &AArch64::FPR64RegClass);
6311 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
6312 &AArch64::FPR32RegClass);
6313 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
6314 &AArch64::FPR32RegClass);
6322 if (AArch64::FPR64RegClass.
contains(DestReg) &&
6323 AArch64::GPR64RegClass.
contains(SrcReg)) {
6324 if (AArch64::XZR == SrcReg) {
6332 if (AArch64::GPR64RegClass.
contains(DestReg) &&
6333 AArch64::FPR64RegClass.
contains(SrcReg)) {
6339 if (AArch64::FPR32RegClass.
contains(DestReg) &&
6340 AArch64::GPR32RegClass.
contains(SrcReg)) {
6341 if (AArch64::WZR == SrcReg) {
6349 if (AArch64::GPR32RegClass.
contains(DestReg) &&
6350 AArch64::FPR32RegClass.
contains(SrcReg)) {
6356 if (DestReg == AArch64::NZCV) {
6357 assert(AArch64::GPR64RegClass.
contains(SrcReg) &&
"Invalid NZCV copy");
6359 .
addImm(AArch64SysReg::NZCV)
6365 if (SrcReg == AArch64::NZCV) {
6366 assert(AArch64::GPR64RegClass.
contains(DestReg) &&
"Invalid NZCV copy");
6368 .
addImm(AArch64SysReg::NZCV)
6374 errs() << RI.getRegAsmName(DestReg) <<
" = COPY " << RI.getRegAsmName(SrcReg)
6385 bool RenamableSrc)
const {
6397 unsigned SubIdx0,
unsigned SubIdx1,
int FI,
6402 SrcReg0 =
TRI.getSubReg(SrcReg, SubIdx0);
6404 SrcReg1 =
TRI.getSubReg(SrcReg, SubIdx1);
6417 Register SrcReg,
bool isKill,
int FI,
6432 switch (RI.getSpillSize(*RC)) {
6434 if (AArch64::FPR8RegClass.hasSubClassEq(RC))
6435 Opc = AArch64::STRBui;
6438 if (AArch64::FPR16RegClass.hasSubClassEq(RC))
6439 Opc = AArch64::STRHui;
6440 else if (AArch64::PNRRegClass.hasSubClassEq(RC) ||
6441 AArch64::PPRRegClass.hasSubClassEq(RC)) {
6442 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6443 "Unexpected register store without SVE store instructions");
6444 Opc = AArch64::STR_PXI;
6450 if (AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
6451 Opc = AArch64::STRWui;
6455 assert(SrcReg != AArch64::WSP);
6456 }
else if (AArch64::FPR32RegClass.hasSubClassEq(RC))
6457 Opc = AArch64::STRSui;
6458 else if (AArch64::PPR2RegClass.hasSubClassEq(RC)) {
6459 Opc = AArch64::STR_PPXI;
6464 if (AArch64::GPR64allRegClass.hasSubClassEq(RC)) {
6465 Opc = AArch64::STRXui;
6469 assert(SrcReg != AArch64::SP);
6470 }
else if (AArch64::FPR64RegClass.hasSubClassEq(RC)) {
6471 Opc = AArch64::STRDui;
6472 }
else if (AArch64::WSeqPairsClassRegClass.hasSubClassEq(RC)) {
6474 get(AArch64::STPWi), SrcReg, isKill,
6475 AArch64::sube32, AArch64::subo32, FI, MMO);
6480 if (AArch64::FPR128RegClass.hasSubClassEq(RC))
6481 Opc = AArch64::STRQui;
6482 else if (AArch64::DDRegClass.hasSubClassEq(RC)) {
6483 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6484 Opc = AArch64::ST1Twov1d;
6486 }
else if (AArch64::XSeqPairsClassRegClass.hasSubClassEq(RC)) {
6488 get(AArch64::STPXi), SrcReg, isKill,
6489 AArch64::sube64, AArch64::subo64, FI, MMO);
6491 }
else if (AArch64::ZPRRegClass.hasSubClassEq(RC)) {
6492 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6493 "Unexpected register store without SVE store instructions");
6494 Opc = AArch64::STR_ZXI;
6499 if (AArch64::DDDRegClass.hasSubClassEq(RC)) {
6500 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6501 Opc = AArch64::ST1Threev1d;
6506 if (AArch64::DDDDRegClass.hasSubClassEq(RC)) {
6507 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6508 Opc = AArch64::ST1Fourv1d;
6510 }
else if (AArch64::QQRegClass.hasSubClassEq(RC)) {
6511 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6512 Opc = AArch64::ST1Twov2d;
6514 }
else if (AArch64::ZPR2StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6515 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6516 "Unexpected register store without SVE store instructions");
6517 Opc = AArch64::STR_ZZXI_STRIDED_CONTIGUOUS;
6519 }
else if (AArch64::ZPR2RegClass.hasSubClassEq(RC)) {
6520 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6521 "Unexpected register store without SVE store instructions");
6522 Opc = AArch64::STR_ZZXI;
6527 if (AArch64::QQQRegClass.hasSubClassEq(RC)) {
6528 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6529 Opc = AArch64::ST1Threev2d;
6531 }
else if (AArch64::ZPR3RegClass.hasSubClassEq(RC)) {
6532 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6533 "Unexpected register store without SVE store instructions");
6534 Opc = AArch64::STR_ZZZXI;
6539 if (AArch64::QQQQRegClass.hasSubClassEq(RC)) {
6540 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6541 Opc = AArch64::ST1Fourv2d;
6543 }
else if (AArch64::ZPR4StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6544 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6545 "Unexpected register store without SVE store instructions");
6546 Opc = AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS;
6548 }
else if (AArch64::ZPR4RegClass.hasSubClassEq(RC)) {
6549 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6550 "Unexpected register store without SVE store instructions");
6551 Opc = AArch64::STR_ZZZZXI;
6556 assert(
Opc &&
"Unknown register class");
6567 MI.addMemOperand(MMO);
6574 Register DestReg,
unsigned SubIdx0,
6575 unsigned SubIdx1,
int FI,
6579 bool IsUndef =
true;
6581 DestReg0 =
TRI.getSubReg(DestReg, SubIdx0);
6583 DestReg1 =
TRI.getSubReg(DestReg, SubIdx1);
6612 switch (
TRI.getSpillSize(*RC)) {
6614 if (AArch64::FPR8RegClass.hasSubClassEq(RC))
6615 Opc = AArch64::LDRBui;
6618 bool IsPNR = AArch64::PNRRegClass.hasSubClassEq(RC);
6619 if (AArch64::FPR16RegClass.hasSubClassEq(RC))
6620 Opc = AArch64::LDRHui;
6621 else if (IsPNR || AArch64::PPRRegClass.hasSubClassEq(RC)) {
6622 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6623 "Unexpected register load without SVE load instructions");
6626 Opc = AArch64::LDR_PXI;
6632 if (AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
6633 Opc = AArch64::LDRWui;
6637 assert(DestReg != AArch64::WSP);
6638 }
else if (AArch64::FPR32RegClass.hasSubClassEq(RC))
6639 Opc = AArch64::LDRSui;
6640 else if (AArch64::PPR2RegClass.hasSubClassEq(RC)) {
6641 Opc = AArch64::LDR_PPXI;
6646 if (AArch64::GPR64allRegClass.hasSubClassEq(RC)) {
6647 Opc = AArch64::LDRXui;
6651 assert(DestReg != AArch64::SP);
6652 }
else if (AArch64::FPR64RegClass.hasSubClassEq(RC)) {
6653 Opc = AArch64::LDRDui;
6654 }
else if (AArch64::WSeqPairsClassRegClass.hasSubClassEq(RC)) {
6656 get(AArch64::LDPWi), DestReg, AArch64::sube32,
6657 AArch64::subo32, FI, MMO);
6662 if (AArch64::FPR128RegClass.hasSubClassEq(RC))
6663 Opc = AArch64::LDRQui;
6664 else if (AArch64::DDRegClass.hasSubClassEq(RC)) {
6665 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6666 Opc = AArch64::LD1Twov1d;
6668 }
else if (AArch64::XSeqPairsClassRegClass.hasSubClassEq(RC)) {
6670 get(AArch64::LDPXi), DestReg, AArch64::sube64,
6671 AArch64::subo64, FI, MMO);
6673 }
else if (AArch64::ZPRRegClass.hasSubClassEq(RC)) {
6674 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6675 "Unexpected register load without SVE load instructions");
6676 Opc = AArch64::LDR_ZXI;
6681 if (AArch64::DDDRegClass.hasSubClassEq(RC)) {
6682 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6683 Opc = AArch64::LD1Threev1d;
6688 if (AArch64::DDDDRegClass.hasSubClassEq(RC)) {
6689 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6690 Opc = AArch64::LD1Fourv1d;
6692 }
else if (AArch64::QQRegClass.hasSubClassEq(RC)) {
6693 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6694 Opc = AArch64::LD1Twov2d;
6696 }
else if (AArch64::ZPR2StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6697 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6698 "Unexpected register load without SVE load instructions");
6699 Opc = AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS;
6701 }
else if (AArch64::ZPR2RegClass.hasSubClassEq(RC)) {
6702 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6703 "Unexpected register load without SVE load instructions");
6704 Opc = AArch64::LDR_ZZXI;
6709 if (AArch64::QQQRegClass.hasSubClassEq(RC)) {
6710 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6711 Opc = AArch64::LD1Threev2d;
6713 }
else if (AArch64::ZPR3RegClass.hasSubClassEq(RC)) {
6714 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6715 "Unexpected register load without SVE load instructions");
6716 Opc = AArch64::LDR_ZZZXI;
6721 if (AArch64::QQQQRegClass.hasSubClassEq(RC)) {
6722 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6723 Opc = AArch64::LD1Fourv2d;
6725 }
else if (AArch64::ZPR4StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6726 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6727 "Unexpected register load without SVE load instructions");
6728 Opc = AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS;
6730 }
else if (AArch64::ZPR4RegClass.hasSubClassEq(RC)) {
6731 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6732 "Unexpected register load without SVE load instructions");
6733 Opc = AArch64::LDR_ZZZZXI;
6739 assert(
Opc &&
"Unknown register class");
6749 MI.addMemOperand(MMO);
6756 UseMI.getIterator()),
6758 return I.modifiesRegister(AArch64::NZCV, TRI) ||
6759 I.readsRegister(AArch64::NZCV, TRI);
6763void AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
6768 assert(
Offset.getScalable() % 2 == 0 &&
"Invalid frame offset");
6775 ByteSized =
Offset.getFixed();
6776 VGSized =
Offset.getScalable() / 2;
6782void AArch64InstrInfo::decomposeStackOffsetForFrameOffsets(
6784 int64_t &NumDataVectors) {
6788 assert(
Offset.getScalable() % 2 == 0 &&
"Invalid frame offset");
6790 NumBytes =
Offset.getFixed();
6792 NumPredicateVectors =
Offset.getScalable() / 2;
6797 if (NumPredicateVectors % 8 == 0 || NumPredicateVectors < -64 ||
6798 NumPredicateVectors > 62) {
6799 NumDataVectors = NumPredicateVectors / 8;
6800 NumPredicateVectors -= NumDataVectors * 8;
6826 Expr.
push_back((
char)dwarf::DW_OP_bregx);
6834 int64_t OffsetFromDefCFA) {
6848 Comment << (NumBytes < 0 ?
" - " :
" + ") << std::abs(NumBytes);
6849 if (!RegScale.empty())
6859 int64_t NumBytes, NumVGScaledBytes;
6860 AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
Offset, NumBytes,
6862 std::string CommentBuffer;
6865 if (
Reg == AArch64::SP)
6867 else if (
Reg == AArch64::FP)
6874 unsigned DwarfReg =
TRI.getDwarfRegNum(
Reg,
true);
6875 assert(DwarfReg <= 31 &&
"DwarfReg out of bounds (0..31)");
6877 Expr.
push_back(dwarf::DW_OP_breg0 + DwarfReg);
6880 if (NumVGScaledBytes) {
6890 DefCfaExpr.
push_back(dwarf::DW_CFA_def_cfa_expression);
6898 unsigned FrameReg,
unsigned Reg,
6900 bool LastAdjustmentWasScalable) {
6901 if (
Offset.getScalable())
6904 if (FrameReg == Reg && !LastAdjustmentWasScalable)
6907 unsigned DwarfReg =
TRI.getDwarfRegNum(Reg,
true);
6914 std::optional<int64_t> IncomingVGOffsetFromDefCFA) {
6915 int64_t NumBytes, NumVGScaledBytes;
6916 AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
6917 OffsetFromDefCFA, NumBytes, NumVGScaledBytes);
6919 unsigned DwarfReg =
TRI.getDwarfRegNum(Reg,
true);
6922 if (!NumVGScaledBytes)
6925 std::string CommentBuffer;
6930 assert(NumVGScaledBytes &&
"Expected scalable offset");
6934 if (IncomingVGOffsetFromDefCFA) {
6936 VGRegScale =
"* IncomingVG";
6939 VGRegScale =
"* VG";
6943 OffsetExpr.
push_back(dwarf::DW_OP_plus);
6952 CfaExpr.
push_back(dwarf::DW_CFA_expression);
6967 unsigned SrcReg, int64_t
Offset,
unsigned Opc,
6970 bool *HasWinCFI,
bool EmitCFAOffset,
6973 unsigned MaxEncoding, ShiftSize;
6975 case AArch64::ADDXri:
6976 case AArch64::ADDSXri:
6977 case AArch64::SUBXri:
6978 case AArch64::SUBSXri:
6979 MaxEncoding = 0xfff;
6982 case AArch64::ADDVL_XXI:
6983 case AArch64::ADDPL_XXI:
6984 case AArch64::ADDSVL_XXI:
6985 case AArch64::ADDSPL_XXI:
7000 if (
Opc == AArch64::ADDVL_XXI ||
Opc == AArch64::ADDSVL_XXI)
7002 else if (
Opc == AArch64::ADDPL_XXI ||
Opc == AArch64::ADDSPL_XXI)
7016 const unsigned MaxEncodableValue = MaxEncoding << ShiftSize;
7018 if (TmpReg == AArch64::XZR)
7019 TmpReg =
MBB.getParent()->getRegInfo().createVirtualRegister(
7020 &AArch64::GPR64RegClass);
7022 uint64_t ThisVal = std::min<uint64_t>(
Offset, MaxEncodableValue);
7023 unsigned LocalShiftSize = 0;
7024 if (ThisVal > MaxEncoding) {
7025 ThisVal = ThisVal >> ShiftSize;
7026 LocalShiftSize = ShiftSize;
7028 assert((ThisVal >> ShiftSize) <= MaxEncoding &&
7029 "Encoding cannot handle value that big");
7031 Offset -= ThisVal << LocalShiftSize;
7036 .
addImm(Sign * (
int)ThisVal);
7046 if (Sign == -1 ||
Opc == AArch64::SUBXri ||
Opc == AArch64::SUBSXri)
7047 CFAOffset += Change;
7049 CFAOffset -= Change;
7050 if (EmitCFAOffset && DestReg == TmpReg) {
7063 int Imm = (int)(ThisVal << LocalShiftSize);
7064 if (VScale != 1 && DestReg == AArch64::SP) {
7070 }
else if ((DestReg == AArch64::FP && SrcReg == AArch64::SP) ||
7071 (SrcReg == AArch64::FP && DestReg == AArch64::SP)) {
7072 assert(VScale == 1 &&
"Expected non-scalable operation");
7081 assert(
Offset == 0 &&
"Expected remaining offset to be zero to "
7082 "emit a single SEH directive");
7083 }
else if (DestReg == AArch64::SP) {
7084 assert(VScale == 1 &&
"Expected non-scalable operation");
7087 assert(SrcReg == AArch64::SP &&
"Unexpected SrcReg for SEH_StackAlloc");
7100 unsigned DestReg,
unsigned SrcReg,
7103 bool NeedsWinCFI,
bool *HasWinCFI,
7105 unsigned FrameReg) {
7112 bool UseSVL =
F.hasFnAttribute(
"aarch64_pstate_sm_body");
7114 int64_t Bytes, NumPredicateVectors, NumDataVectors;
7115 AArch64InstrInfo::decomposeStackOffsetForFrameOffsets(
7116 Offset, Bytes, NumPredicateVectors, NumDataVectors);
7119 bool NeedsFinalDefNZCV = SetNZCV && (NumPredicateVectors || NumDataVectors);
7120 if (NeedsFinalDefNZCV)
7124 if (Bytes || (!
Offset && SrcReg != DestReg)) {
7125 assert((DestReg != AArch64::SP || Bytes % 8 == 0) &&
7126 "SP increment/decrement not 8-byte aligned");
7127 unsigned Opc = SetNZCV ? AArch64::ADDSXri : AArch64::ADDXri;
7130 Opc = SetNZCV ? AArch64::SUBSXri : AArch64::SUBXri;
7133 NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
7135 CFAOffset += (
Opc == AArch64::ADDXri ||
Opc == AArch64::ADDSXri)
7142 assert(!(NeedsWinCFI && NumPredicateVectors) &&
7143 "WinCFI can't allocate fractions of an SVE data vector");
7145 if (NumDataVectors) {
7147 UseSVL ? AArch64::ADDSVL_XXI : AArch64::ADDVL_XXI,
TII,
7148 Flag, NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
7154 if (NumPredicateVectors) {
7155 assert(DestReg != AArch64::SP &&
"Unaligned access to SP");
7157 UseSVL ? AArch64::ADDSPL_XXI : AArch64::ADDPL_XXI,
TII,
7158 Flag, NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
7162 if (NeedsFinalDefNZCV)
7184 if (
MI.isFullCopy()) {
7187 if (SrcReg == AArch64::SP && DstReg.
isVirtual()) {
7191 if (DstReg == AArch64::SP && SrcReg.
isVirtual()) {
7196 if (SrcReg == AArch64::NZCV || DstReg == AArch64::NZCV)
7224 if (
MI.isCopy() &&
Ops.size() == 1 &&
7226 (
Ops[0] == 0 ||
Ops[0] == 1)) {
7227 bool IsSpill =
Ops[0] == 0;
7228 bool IsFill = !IsSpill;
7240 :
TRI.getMinimalPhysRegClass(Reg);
7246 "Mismatched register size in non subreg COPY");
7253 return &*--InsertPt;
7265 if (IsSpill && DstMO.
isUndef() && SrcReg == AArch64::WZR &&
7268 "Unexpected subreg on physical register");
7270 FrameIndex, &AArch64::GPR64RegClass,
Register());
7271 return &*--InsertPt;
7288 case AArch64::sub_32:
7289 if (AArch64::GPR64RegClass.hasSubClassEq(
getRegClass(DstReg)))
7290 FillRC = &AArch64::GPR32RegClass;
7293 FillRC = &AArch64::FPR32RegClass;
7296 FillRC = &AArch64::FPR64RegClass;
7302 TRI.getRegSizeInBits(*FillRC) &&
7303 "Mismatched regclass size on folded subreg COPY");
7322 bool *OutUseUnscaledOp,
7323 unsigned *OutUnscaledOp,
7324 int64_t *EmittableOffset) {
7326 if (EmittableOffset)
7327 *EmittableOffset = 0;
7328 if (OutUseUnscaledOp)
7329 *OutUseUnscaledOp =
false;
7335 switch (
MI.getOpcode()) {
7338 case AArch64::LD1Rv1d:
7339 case AArch64::LD1Rv2s:
7340 case AArch64::LD1Rv2d:
7341 case AArch64::LD1Rv4h:
7342 case AArch64::LD1Rv4s:
7343 case AArch64::LD1Rv8b:
7344 case AArch64::LD1Rv8h:
7345 case AArch64::LD1Rv16b:
7346 case AArch64::LD1Twov2d:
7347 case AArch64::LD1Threev2d:
7348 case AArch64::LD1Fourv2d:
7349 case AArch64::LD1Twov1d:
7350 case AArch64::LD1Threev1d:
7351 case AArch64::LD1Fourv1d:
7352 case AArch64::ST1Twov2d:
7353 case AArch64::ST1Threev2d:
7354 case AArch64::ST1Fourv2d:
7355 case AArch64::ST1Twov1d:
7356 case AArch64::ST1Threev1d:
7357 case AArch64::ST1Fourv1d:
7358 case AArch64::ST1i8:
7359 case AArch64::ST1i16:
7360 case AArch64::ST1i32:
7361 case AArch64::ST1i64:
7363 case AArch64::IRGstack:
7364 case AArch64::STGloop:
7365 case AArch64::STZGloop:
7370 TypeSize ScaleValue(0U,
false), Width(0U,
false);
7371 int64_t MinOff, MaxOff;
7377 bool IsMulVL = ScaleValue.isScalable();
7378 unsigned Scale = ScaleValue.getKnownMinValue();
7388 std::optional<unsigned> UnscaledOp =
7390 bool useUnscaledOp = UnscaledOp && (
Offset % Scale ||
Offset < 0);
7391 if (useUnscaledOp &&
7396 Scale = ScaleValue.getKnownMinValue();
7397 assert(IsMulVL == ScaleValue.isScalable() &&
7398 "Unscaled opcode has different value for scalable");
7400 int64_t Remainder =
Offset % Scale;
7401 assert(!(Remainder && useUnscaledOp) &&
7402 "Cannot have remainder when using unscaled op");
7404 assert(MinOff < MaxOff &&
"Unexpected Min/Max offsets");
7405 int64_t NewOffset =
Offset / Scale;
7406 if (MinOff <= NewOffset && NewOffset <= MaxOff)
7414 int64_t HighPart =
Offset & ~0xFFF;
7415 int64_t LowPart =
Offset & 0xFFF;
7416 int64_t LowScaled = LowPart / Scale;
7417 if (!IsMulVL && NewOffset >= 0 && LowPart % Scale == 0 &&
7418 MinOff <= LowScaled && LowScaled <= MaxOff &&
7420 NewOffset = LowScaled;
7425 NewOffset = NewOffset < 0 ? MinOff : MaxOff;
7430 if (EmittableOffset)
7431 *EmittableOffset = NewOffset;
7432 if (OutUseUnscaledOp)
7433 *OutUseUnscaledOp = useUnscaledOp;
7434 if (OutUnscaledOp && UnscaledOp)
7435 *OutUnscaledOp = *UnscaledOp;
7448 unsigned Opcode =
MI.getOpcode();
7449 unsigned ImmIdx = FrameRegIdx + 1;
7451 if (Opcode == AArch64::ADDSXri || Opcode == AArch64::ADDXri) {
7456 MI.eraseFromParent();
7462 unsigned UnscaledOp;
7465 &UnscaledOp, &NewOffset);
7469 MI.getOperand(FrameRegIdx).ChangeToRegister(FrameReg,
false);
7471 MI.setDesc(
TII->get(UnscaledOp));
7473 MI.getOperand(ImmIdx).ChangeToImmediate(NewOffset);
7489bool AArch64InstrInfo::useMachineCombiner()
const {
return true; }
7494 case AArch64::ADDSWrr:
7495 case AArch64::ADDSWri:
7496 case AArch64::ADDSXrr:
7497 case AArch64::ADDSXri:
7498 case AArch64::SUBSWrr:
7499 case AArch64::SUBSXrr:
7501 case AArch64::SUBSWri:
7502 case AArch64::SUBSXri:
7513 case AArch64::ADDWrr:
7514 case AArch64::ADDWri:
7515 case AArch64::SUBWrr:
7516 case AArch64::ADDSWrr:
7517 case AArch64::ADDSWri:
7518 case AArch64::SUBSWrr:
7520 case AArch64::SUBWri:
7521 case AArch64::SUBSWri:
7532 case AArch64::ADDXrr:
7533 case AArch64::ADDXri:
7534 case AArch64::SUBXrr:
7535 case AArch64::ADDSXrr:
7536 case AArch64::ADDSXri:
7537 case AArch64::SUBSXrr:
7539 case AArch64::SUBXri:
7540 case AArch64::SUBSXri:
7541 case AArch64::ADDv8i8:
7542 case AArch64::ADDv16i8:
7543 case AArch64::ADDv4i16:
7544 case AArch64::ADDv8i16:
7545 case AArch64::ADDv2i32:
7546 case AArch64::ADDv4i32:
7547 case AArch64::SUBv8i8:
7548 case AArch64::SUBv16i8:
7549 case AArch64::SUBv4i16:
7550 case AArch64::SUBv8i16:
7551 case AArch64::SUBv2i32:
7552 case AArch64::SUBv4i32:
7565 case AArch64::FADDHrr:
7566 case AArch64::FADDSrr:
7567 case AArch64::FADDDrr:
7568 case AArch64::FADDv4f16:
7569 case AArch64::FADDv8f16:
7570 case AArch64::FADDv2f32:
7571 case AArch64::FADDv2f64:
7572 case AArch64::FADDv4f32:
7573 case AArch64::FSUBHrr:
7574 case AArch64::FSUBSrr:
7575 case AArch64::FSUBDrr:
7576 case AArch64::FSUBv4f16:
7577 case AArch64::FSUBv8f16:
7578 case AArch64::FSUBv2f32:
7579 case AArch64::FSUBv2f64:
7580 case AArch64::FSUBv4f32:
7597 unsigned CombineOpc,
unsigned ZeroReg = 0,
7598 bool CheckZeroReg =
false) {
7605 if (!
MI ||
MI->getParent() != &
MBB ||
MI->getOpcode() != CombineOpc)
7612 assert(
MI->getNumOperands() >= 4 &&
MI->getOperand(0).isReg() &&
7613 MI->getOperand(1).isReg() &&
MI->getOperand(2).isReg() &&
7614 MI->getOperand(3).isReg() &&
"MAdd/MSub must have a least 4 regs");
7616 if (
MI->getOperand(3).getReg() != ZeroReg)
7621 MI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
true) == -1)
7630 unsigned MulOpc,
unsigned ZeroReg) {
7645bool AArch64InstrInfo::isAssociativeAndCommutative(
const MachineInstr &Inst,
7646 bool Invert)
const {
7652 case AArch64::FADDHrr:
7653 case AArch64::FADDSrr:
7654 case AArch64::FADDDrr:
7655 case AArch64::FMULHrr:
7656 case AArch64::FMULSrr:
7657 case AArch64::FMULDrr:
7658 case AArch64::FMULX16:
7659 case AArch64::FMULX32:
7660 case AArch64::FMULX64:
7662 case AArch64::FADDv4f16:
7663 case AArch64::FADDv8f16:
7664 case AArch64::FADDv2f32:
7665 case AArch64::FADDv4f32:
7666 case AArch64::FADDv2f64:
7667 case AArch64::FMULv4f16:
7668 case AArch64::FMULv8f16:
7669 case AArch64::FMULv2f32:
7670 case AArch64::FMULv4f32:
7671 case AArch64::FMULv2f64:
7672 case AArch64::FMULXv4f16:
7673 case AArch64::FMULXv8f16:
7674 case AArch64::FMULXv2f32:
7675 case AArch64::FMULXv4f32:
7676 case AArch64::FMULXv2f64:
7680 case AArch64::FADD_ZZZ_H:
7681 case AArch64::FADD_ZZZ_S:
7682 case AArch64::FADD_ZZZ_D:
7683 case AArch64::FMUL_ZZZ_H:
7684 case AArch64::FMUL_ZZZ_S:
7685 case AArch64::FMUL_ZZZ_D:
7696 case AArch64::ADDWrr:
7697 case AArch64::ADDXrr:
7698 case AArch64::ANDWrr:
7699 case AArch64::ANDXrr:
7700 case AArch64::ORRWrr:
7701 case AArch64::ORRXrr:
7702 case AArch64::EORWrr:
7703 case AArch64::EORXrr:
7704 case AArch64::EONWrr:
7705 case AArch64::EONXrr:
7709 case AArch64::ADDv8i8:
7710 case AArch64::ADDv16i8:
7711 case AArch64::ADDv4i16:
7712 case AArch64::ADDv8i16:
7713 case AArch64::ADDv2i32:
7714 case AArch64::ADDv4i32:
7715 case AArch64::ADDv1i64:
7716 case AArch64::ADDv2i64:
7717 case AArch64::MULv8i8:
7718 case AArch64::MULv16i8:
7719 case AArch64::MULv4i16:
7720 case AArch64::MULv8i16:
7721 case AArch64::MULv2i32:
7722 case AArch64::MULv4i32:
7723 case AArch64::ANDv8i8:
7724 case AArch64::ANDv16i8:
7725 case AArch64::ORRv8i8:
7726 case AArch64::ORRv16i8:
7727 case AArch64::EORv8i8:
7728 case AArch64::EORv16i8:
7730 case AArch64::ADD_ZZZ_B:
7731 case AArch64::ADD_ZZZ_H:
7732 case AArch64::ADD_ZZZ_S:
7733 case AArch64::ADD_ZZZ_D:
7734 case AArch64::MUL_ZZZ_B:
7735 case AArch64::MUL_ZZZ_H:
7736 case AArch64::MUL_ZZZ_S:
7737 case AArch64::MUL_ZZZ_D:
7738 case AArch64::AND_ZZZ:
7739 case AArch64::ORR_ZZZ:
7740 case AArch64::EOR_ZZZ:
7771 auto setFound = [&](
int Opcode,
int Operand,
unsigned ZeroReg,
7779 auto setVFound = [&](
int Opcode,
int Operand,
unsigned Pattern) {
7791 case AArch64::ADDWrr:
7793 "ADDWrr does not have register operands");
7794 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULADDW_OP1);
7795 setFound(AArch64::MADDWrrr, 2, AArch64::WZR, MCP::MULADDW_OP2);
7797 case AArch64::ADDXrr:
7798 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULADDX_OP1);
7799 setFound(AArch64::MADDXrrr, 2, AArch64::XZR, MCP::MULADDX_OP2);
7801 case AArch64::SUBWrr:
7802 setFound(AArch64::MADDWrrr, 2, AArch64::WZR, MCP::MULSUBW_OP2);
7803 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULSUBW_OP1);
7805 case AArch64::SUBXrr:
7806 setFound(AArch64::MADDXrrr, 2, AArch64::XZR, MCP::MULSUBX_OP2);
7807 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULSUBX_OP1);
7809 case AArch64::ADDWri:
7810 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULADDWI_OP1);
7812 case AArch64::ADDXri:
7813 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULADDXI_OP1);
7815 case AArch64::SUBWri:
7816 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULSUBWI_OP1);
7818 case AArch64::SUBXri:
7819 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULSUBXI_OP1);
7821 case AArch64::ADDv8i8:
7822 setVFound(AArch64::MULv8i8, 1, MCP::MULADDv8i8_OP1);
7823 setVFound(AArch64::MULv8i8, 2, MCP::MULADDv8i8_OP2);
7825 case AArch64::ADDv16i8:
7826 setVFound(AArch64::MULv16i8, 1, MCP::MULADDv16i8_OP1);
7827 setVFound(AArch64::MULv16i8, 2, MCP::MULADDv16i8_OP2);
7829 case AArch64::ADDv4i16:
7830 setVFound(AArch64::MULv4i16, 1, MCP::MULADDv4i16_OP1);
7831 setVFound(AArch64::MULv4i16, 2, MCP::MULADDv4i16_OP2);
7832 setVFound(AArch64::MULv4i16_indexed, 1, MCP::MULADDv4i16_indexed_OP1);
7833 setVFound(AArch64::MULv4i16_indexed, 2, MCP::MULADDv4i16_indexed_OP2);
7835 case AArch64::ADDv8i16:
7836 setVFound(AArch64::MULv8i16, 1, MCP::MULADDv8i16_OP1);
7837 setVFound(AArch64::MULv8i16, 2, MCP::MULADDv8i16_OP2);
7838 setVFound(AArch64::MULv8i16_indexed, 1, MCP::MULADDv8i16_indexed_OP1);
7839 setVFound(AArch64::MULv8i16_indexed, 2, MCP::MULADDv8i16_indexed_OP2);
7841 case AArch64::ADDv2i32:
7842 setVFound(AArch64::MULv2i32, 1, MCP::MULADDv2i32_OP1);
7843 setVFound(AArch64::MULv2i32, 2, MCP::MULADDv2i32_OP2);
7844 setVFound(AArch64::MULv2i32_indexed, 1, MCP::MULADDv2i32_indexed_OP1);
7845 setVFound(AArch64::MULv2i32_indexed, 2, MCP::MULADDv2i32_indexed_OP2);
7847 case AArch64::ADDv4i32:
7848 setVFound(AArch64::MULv4i32, 1, MCP::MULADDv4i32_OP1);
7849 setVFound(AArch64::MULv4i32, 2, MCP::MULADDv4i32_OP2);
7850 setVFound(AArch64::MULv4i32_indexed, 1, MCP::MULADDv4i32_indexed_OP1);
7851 setVFound(AArch64::MULv4i32_indexed, 2, MCP::MULADDv4i32_indexed_OP2);
7853 case AArch64::SUBv8i8:
7854 setVFound(AArch64::MULv8i8, 1, MCP::MULSUBv8i8_OP1);
7855 setVFound(AArch64::MULv8i8, 2, MCP::MULSUBv8i8_OP2);
7857 case AArch64::SUBv16i8:
7858 setVFound(AArch64::MULv16i8, 1, MCP::MULSUBv16i8_OP1);
7859 setVFound(AArch64::MULv16i8, 2, MCP::MULSUBv16i8_OP2);
7861 case AArch64::SUBv4i16:
7862 setVFound(AArch64::MULv4i16, 1, MCP::MULSUBv4i16_OP1);
7863 setVFound(AArch64::MULv4i16, 2, MCP::MULSUBv4i16_OP2);
7864 setVFound(AArch64::MULv4i16_indexed, 1, MCP::MULSUBv4i16_indexed_OP1);
7865 setVFound(AArch64::MULv4i16_indexed, 2, MCP::MULSUBv4i16_indexed_OP2);
7867 case AArch64::SUBv8i16:
7868 setVFound(AArch64::MULv8i16, 1, MCP::MULSUBv8i16_OP1);
7869 setVFound(AArch64::MULv8i16, 2, MCP::MULSUBv8i16_OP2);
7870 setVFound(AArch64::MULv8i16_indexed, 1, MCP::MULSUBv8i16_indexed_OP1);
7871 setVFound(AArch64::MULv8i16_indexed, 2, MCP::MULSUBv8i16_indexed_OP2);
7873 case AArch64::SUBv2i32:
7874 setVFound(AArch64::MULv2i32, 1, MCP::MULSUBv2i32_OP1);
7875 setVFound(AArch64::MULv2i32, 2, MCP::MULSUBv2i32_OP2);
7876 setVFound(AArch64::MULv2i32_indexed, 1, MCP::MULSUBv2i32_indexed_OP1);
7877 setVFound(AArch64::MULv2i32_indexed, 2, MCP::MULSUBv2i32_indexed_OP2);
7879 case AArch64::SUBv4i32:
7880 setVFound(AArch64::MULv4i32, 1, MCP::MULSUBv4i32_OP1);
7881 setVFound(AArch64::MULv4i32, 2, MCP::MULSUBv4i32_OP2);
7882 setVFound(AArch64::MULv4i32_indexed, 1, MCP::MULSUBv4i32_indexed_OP1);
7883 setVFound(AArch64::MULv4i32_indexed, 2, MCP::MULSUBv4i32_indexed_OP2);
7889bool AArch64InstrInfo::isAccumulationOpcode(
unsigned Opcode)
const {
7893 case AArch64::UABALB_ZZZ_D:
7894 case AArch64::UABALB_ZZZ_H:
7895 case AArch64::UABALB_ZZZ_S:
7896 case AArch64::UABALT_ZZZ_D:
7897 case AArch64::UABALT_ZZZ_H:
7898 case AArch64::UABALT_ZZZ_S:
7899 case AArch64::SABALB_ZZZ_D:
7900 case AArch64::SABALB_ZZZ_S:
7901 case AArch64::SABALB_ZZZ_H:
7902 case AArch64::SABALT_ZZZ_D:
7903 case AArch64::SABALT_ZZZ_S:
7904 case AArch64::SABALT_ZZZ_H:
7905 case AArch64::UABALv16i8_v8i16:
7906 case AArch64::UABALv2i32_v2i64:
7907 case AArch64::UABALv4i16_v4i32:
7908 case AArch64::UABALv4i32_v2i64:
7909 case AArch64::UABALv8i16_v4i32:
7910 case AArch64::UABALv8i8_v8i16:
7911 case AArch64::UABAv16i8:
7912 case AArch64::UABAv2i32:
7913 case AArch64::UABAv4i16:
7914 case AArch64::UABAv4i32:
7915 case AArch64::UABAv8i16:
7916 case AArch64::UABAv8i8:
7917 case AArch64::SABALv16i8_v8i16:
7918 case AArch64::SABALv2i32_v2i64:
7919 case AArch64::SABALv4i16_v4i32:
7920 case AArch64::SABALv4i32_v2i64:
7921 case AArch64::SABALv8i16_v4i32:
7922 case AArch64::SABALv8i8_v8i16:
7923 case AArch64::SABAv16i8:
7924 case AArch64::SABAv2i32:
7925 case AArch64::SABAv4i16:
7926 case AArch64::SABAv4i32:
7927 case AArch64::SABAv8i16:
7928 case AArch64::SABAv8i8:
7935unsigned AArch64InstrInfo::getAccumulationStartOpcode(
7936 unsigned AccumulationOpcode)
const {
7937 switch (AccumulationOpcode) {
7940 case AArch64::UABALB_ZZZ_D:
7941 return AArch64::UABDLB_ZZZ_D;
7942 case AArch64::UABALB_ZZZ_H:
7943 return AArch64::UABDLB_ZZZ_H;
7944 case AArch64::UABALB_ZZZ_S:
7945 return AArch64::UABDLB_ZZZ_S;
7946 case AArch64::UABALT_ZZZ_D:
7947 return AArch64::UABDLT_ZZZ_D;
7948 case AArch64::UABALT_ZZZ_H:
7949 return AArch64::UABDLT_ZZZ_H;
7950 case AArch64::UABALT_ZZZ_S:
7951 return AArch64::UABDLT_ZZZ_S;
7952 case AArch64::UABALv16i8_v8i16:
7953 return AArch64::UABDLv16i8_v8i16;
7954 case AArch64::UABALv2i32_v2i64:
7955 return AArch64::UABDLv2i32_v2i64;
7956 case AArch64::UABALv4i16_v4i32:
7957 return AArch64::UABDLv4i16_v4i32;
7958 case AArch64::UABALv4i32_v2i64:
7959 return AArch64::UABDLv4i32_v2i64;
7960 case AArch64::UABALv8i16_v4i32:
7961 return AArch64::UABDLv8i16_v4i32;
7962 case AArch64::UABALv8i8_v8i16:
7963 return AArch64::UABDLv8i8_v8i16;
7964 case AArch64::UABAv16i8:
7965 return AArch64::UABDv16i8;
7966 case AArch64::UABAv2i32:
7967 return AArch64::UABDv2i32;
7968 case AArch64::UABAv4i16:
7969 return AArch64::UABDv4i16;
7970 case AArch64::UABAv4i32:
7971 return AArch64::UABDv4i32;
7972 case AArch64::UABAv8i16:
7973 return AArch64::UABDv8i16;
7974 case AArch64::UABAv8i8:
7975 return AArch64::UABDv8i8;
7976 case AArch64::SABALB_ZZZ_D:
7977 return AArch64::SABDLB_ZZZ_D;
7978 case AArch64::SABALB_ZZZ_S:
7979 return AArch64::SABDLB_ZZZ_S;
7980 case AArch64::SABALB_ZZZ_H:
7981 return AArch64::SABDLB_ZZZ_H;
7982 case AArch64::SABALT_ZZZ_D:
7983 return AArch64::SABDLT_ZZZ_D;
7984 case AArch64::SABALT_ZZZ_S:
7985 return AArch64::SABDLT_ZZZ_S;
7986 case AArch64::SABALT_ZZZ_H:
7987 return AArch64::SABDLT_ZZZ_H;
7988 case AArch64::SABALv16i8_v8i16:
7989 return AArch64::SABDLv16i8_v8i16;
7990 case AArch64::SABALv2i32_v2i64:
7991 return AArch64::SABDLv2i32_v2i64;
7992 case AArch64::SABALv4i16_v4i32:
7993 return AArch64::SABDLv4i16_v4i32;
7994 case AArch64::SABALv4i32_v2i64:
7995 return AArch64::SABDLv4i32_v2i64;
7996 case AArch64::SABALv8i16_v4i32:
7997 return AArch64::SABDLv8i16_v4i32;
7998 case AArch64::SABALv8i8_v8i16:
7999 return AArch64::SABDLv8i8_v8i16;
8000 case AArch64::SABAv16i8:
8001 return AArch64::SABDv16i8;
8002 case AArch64::SABAv2i32:
8003 return AArch64::SABAv2i32;
8004 case AArch64::SABAv4i16:
8005 return AArch64::SABDv4i16;
8006 case AArch64::SABAv4i32:
8007 return AArch64::SABDv4i32;
8008 case AArch64::SABAv8i16:
8009 return AArch64::SABDv8i16;
8010 case AArch64::SABAv8i8:
8011 return AArch64::SABDv8i8;
8027 auto Match = [&](
int Opcode,
int Operand,
unsigned Pattern) ->
bool {
8039 assert(
false &&
"Unsupported FP instruction in combiner\n");
8041 case AArch64::FADDHrr:
8043 "FADDHrr does not have register operands");
8045 Found = Match(AArch64::FMULHrr, 1, MCP::FMULADDH_OP1);
8046 Found |= Match(AArch64::FMULHrr, 2, MCP::FMULADDH_OP2);
8048 case AArch64::FADDSrr:
8050 "FADDSrr does not have register operands");
8052 Found |= Match(AArch64::FMULSrr, 1, MCP::FMULADDS_OP1) ||
8053 Match(AArch64::FMULv1i32_indexed, 1, MCP::FMLAv1i32_indexed_OP1);
8055 Found |= Match(AArch64::FMULSrr, 2, MCP::FMULADDS_OP2) ||
8056 Match(AArch64::FMULv1i32_indexed, 2, MCP::FMLAv1i32_indexed_OP2);
8058 case AArch64::FADDDrr:
8059 Found |= Match(AArch64::FMULDrr, 1, MCP::FMULADDD_OP1) ||
8060 Match(AArch64::FMULv1i64_indexed, 1, MCP::FMLAv1i64_indexed_OP1);
8062 Found |= Match(AArch64::FMULDrr, 2, MCP::FMULADDD_OP2) ||
8063 Match(AArch64::FMULv1i64_indexed, 2, MCP::FMLAv1i64_indexed_OP2);
8065 case AArch64::FADDv4f16:
8066 Found |= Match(AArch64::FMULv4i16_indexed, 1, MCP::FMLAv4i16_indexed_OP1) ||
8067 Match(AArch64::FMULv4f16, 1, MCP::FMLAv4f16_OP1);
8069 Found |= Match(AArch64::FMULv4i16_indexed, 2, MCP::FMLAv4i16_indexed_OP2) ||
8070 Match(AArch64::FMULv4f16, 2, MCP::FMLAv4f16_OP2);
8072 case AArch64::FADDv8f16:
8073 Found |= Match(AArch64::FMULv8i16_indexed, 1, MCP::FMLAv8i16_indexed_OP1) ||
8074 Match(AArch64::FMULv8f16, 1, MCP::FMLAv8f16_OP1);
8076 Found |= Match(AArch64::FMULv8i16_indexed, 2, MCP::FMLAv8i16_indexed_OP2) ||
8077 Match(AArch64::FMULv8f16, 2, MCP::FMLAv8f16_OP2);
8079 case AArch64::FADDv2f32:
8080 Found |= Match(AArch64::FMULv2i32_indexed, 1, MCP::FMLAv2i32_indexed_OP1) ||
8081 Match(AArch64::FMULv2f32, 1, MCP::FMLAv2f32_OP1);
8083 Found |= Match(AArch64::FMULv2i32_indexed, 2, MCP::FMLAv2i32_indexed_OP2) ||
8084 Match(AArch64::FMULv2f32, 2, MCP::FMLAv2f32_OP2);
8086 case AArch64::FADDv2f64:
8087 Found |= Match(AArch64::FMULv2i64_indexed, 1, MCP::FMLAv2i64_indexed_OP1) ||
8088 Match(AArch64::FMULv2f64, 1, MCP::FMLAv2f64_OP1);
8090 Found |= Match(AArch64::FMULv2i64_indexed, 2, MCP::FMLAv2i64_indexed_OP2) ||
8091 Match(AArch64::FMULv2f64, 2, MCP::FMLAv2f64_OP2);
8093 case AArch64::FADDv4f32:
8094 Found |= Match(AArch64::FMULv4i32_indexed, 1, MCP::FMLAv4i32_indexed_OP1) ||
8095 Match(AArch64::FMULv4f32, 1, MCP::FMLAv4f32_OP1);
8097 Found |= Match(AArch64::FMULv4i32_indexed, 2, MCP::FMLAv4i32_indexed_OP2) ||
8098 Match(AArch64::FMULv4f32, 2, MCP::FMLAv4f32_OP2);
8100 case AArch64::FSUBHrr:
8101 Found = Match(AArch64::FMULHrr, 1, MCP::FMULSUBH_OP1);
8102 Found |= Match(AArch64::FMULHrr, 2, MCP::FMULSUBH_OP2);
8103 Found |= Match(AArch64::FNMULHrr, 1, MCP::FNMULSUBH_OP1);
8105 case AArch64::FSUBSrr:
8106 Found = Match(AArch64::FMULSrr, 1, MCP::FMULSUBS_OP1);
8108 Found |= Match(AArch64::FMULSrr, 2, MCP::FMULSUBS_OP2) ||
8109 Match(AArch64::FMULv1i32_indexed, 2, MCP::FMLSv1i32_indexed_OP2);
8111 Found |= Match(AArch64::FNMULSrr, 1, MCP::FNMULSUBS_OP1);
8113 case AArch64::FSUBDrr:
8114 Found = Match(AArch64::FMULDrr, 1, MCP::FMULSUBD_OP1);
8116 Found |= Match(AArch64::FMULDrr, 2, MCP::FMULSUBD_OP2) ||
8117 Match(AArch64::FMULv1i64_indexed, 2, MCP::FMLSv1i64_indexed_OP2);
8119 Found |= Match(AArch64::FNMULDrr, 1, MCP::FNMULSUBD_OP1);
8121 case AArch64::FSUBv4f16:
8122 Found |= Match(AArch64::FMULv4i16_indexed, 2, MCP::FMLSv4i16_indexed_OP2) ||
8123 Match(AArch64::FMULv4f16, 2, MCP::FMLSv4f16_OP2);
8125 Found |= Match(AArch64::FMULv4i16_indexed, 1, MCP::FMLSv4i16_indexed_OP1) ||
8126 Match(AArch64::FMULv4f16, 1, MCP::FMLSv4f16_OP1);
8128 case AArch64::FSUBv8f16:
8129 Found |= Match(AArch64::FMULv8i16_indexed, 2, MCP::FMLSv8i16_indexed_OP2) ||
8130 Match(AArch64::FMULv8f16, 2, MCP::FMLSv8f16_OP2);
8132 Found |= Match(AArch64::FMULv8i16_indexed, 1, MCP::FMLSv8i16_indexed_OP1) ||
8133 Match(AArch64::FMULv8f16, 1, MCP::FMLSv8f16_OP1);
8135 case AArch64::FSUBv2f32:
8136 Found |= Match(AArch64::FMULv2i32_indexed, 2, MCP::FMLSv2i32_indexed_OP2) ||
8137 Match(AArch64::FMULv2f32, 2, MCP::FMLSv2f32_OP2);
8139 Found |= Match(AArch64::FMULv2i32_indexed, 1, MCP::FMLSv2i32_indexed_OP1) ||
8140 Match(AArch64::FMULv2f32, 1, MCP::FMLSv2f32_OP1);
8142 case AArch64::FSUBv2f64:
8143 Found |= Match(AArch64::FMULv2i64_indexed, 2, MCP::FMLSv2i64_indexed_OP2) ||
8144 Match(AArch64::FMULv2f64, 2, MCP::FMLSv2f64_OP2);
8146 Found |= Match(AArch64::FMULv2i64_indexed, 1, MCP::FMLSv2i64_indexed_OP1) ||
8147 Match(AArch64::FMULv2f64, 1, MCP::FMLSv2f64_OP1);
8149 case AArch64::FSUBv4f32:
8150 Found |= Match(AArch64::FMULv4i32_indexed, 2, MCP::FMLSv4i32_indexed_OP2) ||
8151 Match(AArch64::FMULv4f32, 2, MCP::FMLSv4f32_OP2);
8153 Found |= Match(AArch64::FMULv4i32_indexed, 1, MCP::FMLSv4i32_indexed_OP1) ||
8154 Match(AArch64::FMULv4f32, 1, MCP::FMLSv4f32_OP1);
8165 auto Match = [&](
unsigned Opcode,
int Operand,
unsigned Pattern) ->
bool {
8172 if (
MI &&
MI->getOpcode() == TargetOpcode::COPY &&
8173 MI->getOperand(1).getReg().isVirtual())
8175 if (
MI &&
MI->getOpcode() == Opcode) {
8187 case AArch64::FMULv2f32:
8188 Found = Match(AArch64::DUPv2i32lane, 1, MCP::FMULv2i32_indexed_OP1);
8189 Found |= Match(AArch64::DUPv2i32lane, 2, MCP::FMULv2i32_indexed_OP2);
8191 case AArch64::FMULv2f64:
8192 Found = Match(AArch64::DUPv2i64lane, 1, MCP::FMULv2i64_indexed_OP1);
8193 Found |= Match(AArch64::DUPv2i64lane, 2, MCP::FMULv2i64_indexed_OP2);
8195 case AArch64::FMULv4f16:
8196 Found = Match(AArch64::DUPv4i16lane, 1, MCP::FMULv4i16_indexed_OP1);
8197 Found |= Match(AArch64::DUPv4i16lane, 2, MCP::FMULv4i16_indexed_OP2);
8199 case AArch64::FMULv4f32:
8200 Found = Match(AArch64::DUPv4i32lane, 1, MCP::FMULv4i32_indexed_OP1);
8201 Found |= Match(AArch64::DUPv4i32lane, 2, MCP::FMULv4i32_indexed_OP2);
8203 case AArch64::FMULv8f16:
8204 Found = Match(AArch64::DUPv8i16lane, 1, MCP::FMULv8i16_indexed_OP1);
8205 Found |= Match(AArch64::DUPv8i16lane, 2, MCP::FMULv8i16_indexed_OP2);
8218 auto Match = [&](
unsigned Opcode,
unsigned Pattern) ->
bool {
8221 if (
MI !=
nullptr && (
MI->getOpcode() == Opcode) &&
8236 case AArch64::FNEGDr:
8238 case AArch64::FNEGSr:
8370 case AArch64::SUBWrr:
8371 case AArch64::SUBSWrr:
8372 case AArch64::SUBXrr:
8373 case AArch64::SUBSXrr:
8418 unsigned LoadLaneOpCode,
unsigned NumLanes) {
8441 while (!RemainingLanes.
empty() && CurrInstr &&
8442 CurrInstr->getOpcode() == LoadLaneOpCode &&
8444 CurrInstr->getNumOperands() == 4) {
8445 RemainingLanes.
erase(CurrInstr->getOperand(2).getImm());
8451 if (!RemainingLanes.
empty())
8455 if (CurrInstr->getOpcode() != TargetOpcode::SUBREG_TO_REG)
8459 auto Lane0LoadReg = CurrInstr->getOperand(1).getReg();
8460 unsigned SingleLaneSizeInBits = 128 / NumLanes;
8461 if (
TRI->getRegSizeInBits(Lane0LoadReg, MRI) != SingleLaneSizeInBits)
8477 RemainingLoadInstrs.
insert(LoadInstrs.
begin(), LoadInstrs.
end());
8480 for (; MBBItr !=
MBB->begin() && RemainingSteps > 0 &&
8481 !RemainingLoadInstrs.
empty();
8482 --MBBItr, --RemainingSteps) {
8486 RemainingLoadInstrs.
erase(&CurrInstr);
8496 if (RemainingSteps == 0 && !RemainingLoadInstrs.
empty())
8522 case AArch64::LD1i32:
8524 case AArch64::LD1i16:
8526 case AArch64::LD1i8:
8542 unsigned Pattern,
unsigned NumLanes) {
8550 for (
unsigned i = 0; i < NumLanes - 1; ++i) {
8558 return A->getOperand(2).getImm() >
B->getOperand(2).getImm();
8564 auto LoadToLaneInstrsAscending =
llvm::reverse(LoadToLaneInstrs);
8570 auto CreateLD1Instruction = [&](
MachineInstr *OriginalInstr,
8571 Register SrcRegister,
unsigned Lane,
8573 bool OffsetRegisterKillState) {
8582 InstrIdxForVirtReg.
insert(std::make_pair(NewRegister, InsInstrs.
size()));
8583 InsInstrs.
push_back(LoadIndexIntoRegister);
8589 auto CreateLDRInstruction =
8595 Opcode = AArch64::LDRSui;
8598 Opcode = AArch64::LDRHui;
8601 Opcode = AArch64::LDRBui;
8605 "Got unsupported number of lanes in machine-combiner gather pattern");
8615 auto LanesToLoadToReg0 =
8617 LoadToLaneInstrsAscending.begin() + NumLanes / 2);
8618 Register PrevReg = SubregToReg->getOperand(0).getReg();
8620 const MachineOperand &OffsetRegOperand = LoadInstr->getOperand(3);
8621 PrevReg = CreateLD1Instruction(LoadInstr, PrevReg, Index + 1,
8622 OffsetRegOperand.
getReg(),
8623 OffsetRegOperand.
isKill());
8630 MachineInstr *Lane0Load = *LoadToLaneInstrsAscending.begin();
8632 *std::next(LoadToLaneInstrsAscending.begin(), NumLanes / 2);
8639 CreateLDRInstruction(NumLanes, DestRegForMiddleIndex,
8640 OriginalSplitToLoadOffsetOperand.
getReg(),
8643 InstrIdxForVirtReg.
insert(
8644 std::make_pair(DestRegForMiddleIndex, InsInstrs.
size()));
8645 InsInstrs.
push_back(MiddleIndexLoadInstr);
8650 unsigned SubregType;
8653 SubregType = AArch64::ssub;
8656 SubregType = AArch64::hsub;
8659 SubregType = AArch64::bsub;
8663 "Got invalid NumLanes for machine-combiner gather pattern");
8666 auto SubRegToRegInstr =
8668 DestRegForSubregToReg)
8671 InstrIdxForVirtReg.
insert(
8672 std::make_pair(DestRegForSubregToReg, InsInstrs.
size()));
8676 auto LanesToLoadToReg1 =
8678 LoadToLaneInstrsAscending.end());
8679 PrevReg = SubRegToRegInstr->getOperand(0).getReg();
8681 const MachineOperand &OffsetRegOperand = LoadInstr->getOperand(3);
8682 PrevReg = CreateLD1Instruction(LoadInstr, PrevReg, Index + 1,
8683 OffsetRegOperand.
getReg(),
8684 OffsetRegOperand.
isKill());
8687 if (Index == NumLanes / 2 - 2) {
8722bool AArch64InstrInfo::getMachineCombinerPatterns(
8724 bool DoRegPressureReduce)
const {
8745 DoRegPressureReduce);
8774 const Register *ReplacedAddend =
nullptr) {
8775 assert(IdxMulOpd == 1 || IdxMulOpd == 2);
8777 unsigned IdxOtherOpd = IdxMulOpd == 1 ? 2 : 1;
8780 Register SrcReg0 = MUL->getOperand(1).getReg();
8781 bool Src0IsKill = MUL->getOperand(1).isKill();
8782 Register SrcReg1 = MUL->getOperand(2).getReg();
8783 bool Src1IsKill = MUL->getOperand(2).isKill();
8787 if (ReplacedAddend) {
8789 SrcReg2 = *ReplacedAddend;
8816 .
addImm(MUL->getOperand(3).getImm());
8823 assert(
false &&
"Invalid FMA instruction kind \n");
8837 if (AArch64::FPR32RegClass.hasSubClassEq(RC))
8838 Opc = AArch64::FNMADDSrrr;
8839 else if (AArch64::FPR64RegClass.hasSubClassEq(RC))
8840 Opc = AArch64::FNMADDDrrr;
8874 unsigned IdxDupOp,
unsigned MulOpc,
8876 assert(((IdxDupOp == 1) || (IdxDupOp == 2)) &&
8877 "Invalid index of FMUL operand");
8885 if (Dup->
getOpcode() == TargetOpcode::COPY)
8894 unsigned IdxMulOp = IdxDupOp == 1 ? 2 : 1;
8935 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
8950 genNeg(MF, MRI,
TII, Root, InsInstrs, InstrIdxForVirtReg, MnegOpc, RC);
8977 genNeg(MF, MRI,
TII, Root, InsInstrs, InstrIdxForVirtReg, MnegOpc, RC);
9005 unsigned IdxMulOpd,
unsigned MaddOpc,
unsigned VR,
9007 assert(IdxMulOpd == 1 || IdxMulOpd == 2);
9011 Register SrcReg0 = MUL->getOperand(1).getReg();
9012 bool Src0IsKill = MUL->getOperand(1).isKill();
9013 Register SrcReg1 = MUL->getOperand(2).getReg();
9014 bool Src1IsKill = MUL->getOperand(2).isKill();
9044 assert(IdxOpd1 == 1 || IdxOpd1 == 2);
9045 unsigned IdxOtherOpd = IdxOpd1 == 1 ? 2 : 1;
9059 if (Opcode == AArch64::SUBSWrr)
9060 Opcode = AArch64::SUBWrr;
9061 else if (Opcode == AArch64::SUBSXrr)
9062 Opcode = AArch64::SUBXrr;
9064 assert((Opcode == AArch64::SUBWrr || Opcode == AArch64::SUBXrr) &&
9065 "Unexpected instruction opcode.");
9082 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9089unsigned AArch64InstrInfo::getReduceOpcodeForAccumulator(
9090 unsigned int AccumulatorOpCode)
const {
9091 switch (AccumulatorOpCode) {
9092 case AArch64::UABALB_ZZZ_D:
9093 case AArch64::SABALB_ZZZ_D:
9094 case AArch64::UABALT_ZZZ_D:
9095 case AArch64::SABALT_ZZZ_D:
9096 return AArch64::ADD_ZZZ_D;
9097 case AArch64::UABALB_ZZZ_H:
9098 case AArch64::SABALB_ZZZ_H:
9099 case AArch64::UABALT_ZZZ_H:
9100 case AArch64::SABALT_ZZZ_H:
9101 return AArch64::ADD_ZZZ_H;
9102 case AArch64::UABALB_ZZZ_S:
9103 case AArch64::SABALB_ZZZ_S:
9104 case AArch64::UABALT_ZZZ_S:
9105 case AArch64::SABALT_ZZZ_S:
9106 return AArch64::ADD_ZZZ_S;
9107 case AArch64::UABALv16i8_v8i16:
9108 case AArch64::SABALv8i8_v8i16:
9109 case AArch64::SABAv8i16:
9110 case AArch64::UABAv8i16:
9111 return AArch64::ADDv8i16;
9112 case AArch64::SABALv2i32_v2i64:
9113 case AArch64::UABALv2i32_v2i64:
9114 case AArch64::SABALv4i32_v2i64:
9115 return AArch64::ADDv2i64;
9116 case AArch64::UABALv4i16_v4i32:
9117 case AArch64::SABALv4i16_v4i32:
9118 case AArch64::SABALv8i16_v4i32:
9119 case AArch64::SABAv4i32:
9120 case AArch64::UABAv4i32:
9121 return AArch64::ADDv4i32;
9122 case AArch64::UABALv4i32_v2i64:
9123 return AArch64::ADDv2i64;
9124 case AArch64::UABALv8i16_v4i32:
9125 return AArch64::ADDv4i32;
9126 case AArch64::UABALv8i8_v8i16:
9127 case AArch64::SABALv16i8_v8i16:
9128 return AArch64::ADDv8i16;
9129 case AArch64::UABAv16i8:
9130 case AArch64::SABAv16i8:
9131 return AArch64::ADDv16i8;
9132 case AArch64::UABAv4i16:
9133 case AArch64::SABAv4i16:
9134 return AArch64::ADDv4i16;
9135 case AArch64::UABAv2i32:
9136 case AArch64::SABAv2i32:
9137 return AArch64::ADDv2i32;
9138 case AArch64::UABAv8i8:
9139 case AArch64::SABAv8i8:
9140 return AArch64::ADDv8i8;
9149void AArch64InstrInfo::genAlternativeCodeSequence(
9159 MachineInstr *
MUL =
nullptr;
9166 DelInstrs, InstrIdxForVirtReg);
9172 InstrIdxForVirtReg);
9178 InstrIdxForVirtReg);
9187 Opc = AArch64::MADDWrrr;
9188 RC = &AArch64::GPR32RegClass;
9190 Opc = AArch64::MADDXrrr;
9191 RC = &AArch64::GPR64RegClass;
9202 Opc = AArch64::MADDWrrr;
9203 RC = &AArch64::GPR32RegClass;
9205 Opc = AArch64::MADDXrrr;
9206 RC = &AArch64::GPR64RegClass;
9220 unsigned BitSize, MovImm;
9223 MovImm = AArch64::MOVi32imm;
9224 RC = &AArch64::GPR32spRegClass;
9226 Opc = AArch64::MADDWrrr;
9227 RC = &AArch64::GPR32RegClass;
9229 MovImm = AArch64::MOVi64imm;
9230 RC = &AArch64::GPR64spRegClass;
9232 Opc = AArch64::MADDXrrr;
9233 RC = &AArch64::GPR64RegClass;
9248 if (Insn.
size() != 1)
9250 MachineInstrBuilder MIB1 =
9251 BuildMI(MF, MIMetadata(Root),
TII->get(MovImm), NewVR)
9254 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9266 unsigned SubOpc, ZeroReg;
9268 SubOpc = AArch64::SUBWrr;
9269 SubRC = &AArch64::GPR32spRegClass;
9270 ZeroReg = AArch64::WZR;
9271 Opc = AArch64::MADDWrrr;
9272 RC = &AArch64::GPR32RegClass;
9274 SubOpc = AArch64::SUBXrr;
9275 SubRC = &AArch64::GPR64spRegClass;
9276 ZeroReg = AArch64::XZR;
9277 Opc = AArch64::MADDXrrr;
9278 RC = &AArch64::GPR64RegClass;
9282 MachineInstrBuilder MIB1 =
9283 BuildMI(MF, MIMetadata(Root),
TII->get(SubOpc), NewVR)
9287 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9298 Opc = AArch64::MSUBWrrr;
9299 RC = &AArch64::GPR32RegClass;
9301 Opc = AArch64::MSUBXrrr;
9302 RC = &AArch64::GPR64RegClass;
9307 Opc = AArch64::MLAv8i8;
9308 RC = &AArch64::FPR64RegClass;
9312 Opc = AArch64::MLAv8i8;
9313 RC = &AArch64::FPR64RegClass;
9317 Opc = AArch64::MLAv16i8;
9318 RC = &AArch64::FPR128RegClass;
9322 Opc = AArch64::MLAv16i8;
9323 RC = &AArch64::FPR128RegClass;
9327 Opc = AArch64::MLAv4i16;
9328 RC = &AArch64::FPR64RegClass;
9332 Opc = AArch64::MLAv4i16;
9333 RC = &AArch64::FPR64RegClass;
9337 Opc = AArch64::MLAv8i16;
9338 RC = &AArch64::FPR128RegClass;
9342 Opc = AArch64::MLAv8i16;
9343 RC = &AArch64::FPR128RegClass;
9347 Opc = AArch64::MLAv2i32;
9348 RC = &AArch64::FPR64RegClass;
9352 Opc = AArch64::MLAv2i32;
9353 RC = &AArch64::FPR64RegClass;
9357 Opc = AArch64::MLAv4i32;
9358 RC = &AArch64::FPR128RegClass;
9362 Opc = AArch64::MLAv4i32;
9363 RC = &AArch64::FPR128RegClass;
9368 Opc = AArch64::MLAv8i8;
9369 RC = &AArch64::FPR64RegClass;
9371 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i8,
9375 Opc = AArch64::MLSv8i8;
9376 RC = &AArch64::FPR64RegClass;
9380 Opc = AArch64::MLAv16i8;
9381 RC = &AArch64::FPR128RegClass;
9383 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv16i8,
9387 Opc = AArch64::MLSv16i8;
9388 RC = &AArch64::FPR128RegClass;
9392 Opc = AArch64::MLAv4i16;
9393 RC = &AArch64::FPR64RegClass;
9395 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i16,
9399 Opc = AArch64::MLSv4i16;
9400 RC = &AArch64::FPR64RegClass;
9404 Opc = AArch64::MLAv8i16;
9405 RC = &AArch64::FPR128RegClass;
9407 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i16,
9411 Opc = AArch64::MLSv8i16;
9412 RC = &AArch64::FPR128RegClass;
9416 Opc = AArch64::MLAv2i32;
9417 RC = &AArch64::FPR64RegClass;
9419 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv2i32,
9423 Opc = AArch64::MLSv2i32;
9424 RC = &AArch64::FPR64RegClass;
9428 Opc = AArch64::MLAv4i32;
9429 RC = &AArch64::FPR128RegClass;
9431 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i32,
9435 Opc = AArch64::MLSv4i32;
9436 RC = &AArch64::FPR128RegClass;
9441 Opc = AArch64::MLAv4i16_indexed;
9442 RC = &AArch64::FPR64RegClass;
9446 Opc = AArch64::MLAv4i16_indexed;
9447 RC = &AArch64::FPR64RegClass;
9451 Opc = AArch64::MLAv8i16_indexed;
9452 RC = &AArch64::FPR128RegClass;
9456 Opc = AArch64::MLAv8i16_indexed;
9457 RC = &AArch64::FPR128RegClass;
9461 Opc = AArch64::MLAv2i32_indexed;
9462 RC = &AArch64::FPR64RegClass;
9466 Opc = AArch64::MLAv2i32_indexed;
9467 RC = &AArch64::FPR64RegClass;
9471 Opc = AArch64::MLAv4i32_indexed;
9472 RC = &AArch64::FPR128RegClass;
9476 Opc = AArch64::MLAv4i32_indexed;
9477 RC = &AArch64::FPR128RegClass;
9482 Opc = AArch64::MLAv4i16_indexed;
9483 RC = &AArch64::FPR64RegClass;
9485 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i16,
9489 Opc = AArch64::MLSv4i16_indexed;
9490 RC = &AArch64::FPR64RegClass;
9494 Opc = AArch64::MLAv8i16_indexed;
9495 RC = &AArch64::FPR128RegClass;
9497 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i16,
9501 Opc = AArch64::MLSv8i16_indexed;
9502 RC = &AArch64::FPR128RegClass;
9506 Opc = AArch64::MLAv2i32_indexed;
9507 RC = &AArch64::FPR64RegClass;
9509 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv2i32,
9513 Opc = AArch64::MLSv2i32_indexed;
9514 RC = &AArch64::FPR64RegClass;
9518 Opc = AArch64::MLAv4i32_indexed;
9519 RC = &AArch64::FPR128RegClass;
9521 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i32,
9525 Opc = AArch64::MLSv4i32_indexed;
9526 RC = &AArch64::FPR128RegClass;
9532 Opc = AArch64::FMADDHrrr;
9533 RC = &AArch64::FPR16RegClass;
9537 Opc = AArch64::FMADDSrrr;
9538 RC = &AArch64::FPR32RegClass;
9542 Opc = AArch64::FMADDDrrr;
9543 RC = &AArch64::FPR64RegClass;
9548 Opc = AArch64::FMADDHrrr;
9549 RC = &AArch64::FPR16RegClass;
9553 Opc = AArch64::FMADDSrrr;
9554 RC = &AArch64::FPR32RegClass;
9558 Opc = AArch64::FMADDDrrr;
9559 RC = &AArch64::FPR64RegClass;
9564 Opc = AArch64::FMLAv1i32_indexed;
9565 RC = &AArch64::FPR32RegClass;
9570 Opc = AArch64::FMLAv1i32_indexed;
9571 RC = &AArch64::FPR32RegClass;
9577 Opc = AArch64::FMLAv1i64_indexed;
9578 RC = &AArch64::FPR64RegClass;
9583 Opc = AArch64::FMLAv1i64_indexed;
9584 RC = &AArch64::FPR64RegClass;
9590 RC = &AArch64::FPR64RegClass;
9591 Opc = AArch64::FMLAv4i16_indexed;
9596 RC = &AArch64::FPR64RegClass;
9597 Opc = AArch64::FMLAv4f16;
9602 RC = &AArch64::FPR64RegClass;
9603 Opc = AArch64::FMLAv4i16_indexed;
9608 RC = &AArch64::FPR64RegClass;
9609 Opc = AArch64::FMLAv4f16;
9616 RC = &AArch64::FPR64RegClass;
9618 Opc = AArch64::FMLAv2i32_indexed;
9622 Opc = AArch64::FMLAv2f32;
9629 RC = &AArch64::FPR64RegClass;
9631 Opc = AArch64::FMLAv2i32_indexed;
9635 Opc = AArch64::FMLAv2f32;
9642 RC = &AArch64::FPR128RegClass;
9643 Opc = AArch64::FMLAv8i16_indexed;
9648 RC = &AArch64::FPR128RegClass;
9649 Opc = AArch64::FMLAv8f16;
9654 RC = &AArch64::FPR128RegClass;
9655 Opc = AArch64::FMLAv8i16_indexed;
9660 RC = &AArch64::FPR128RegClass;
9661 Opc = AArch64::FMLAv8f16;
9668 RC = &AArch64::FPR128RegClass;
9670 Opc = AArch64::FMLAv2i64_indexed;
9674 Opc = AArch64::FMLAv2f64;
9681 RC = &AArch64::FPR128RegClass;
9683 Opc = AArch64::FMLAv2i64_indexed;
9687 Opc = AArch64::FMLAv2f64;
9695 RC = &AArch64::FPR128RegClass;
9697 Opc = AArch64::FMLAv4i32_indexed;
9701 Opc = AArch64::FMLAv4f32;
9709 RC = &AArch64::FPR128RegClass;
9711 Opc = AArch64::FMLAv4i32_indexed;
9715 Opc = AArch64::FMLAv4f32;
9722 Opc = AArch64::FNMSUBHrrr;
9723 RC = &AArch64::FPR16RegClass;
9727 Opc = AArch64::FNMSUBSrrr;
9728 RC = &AArch64::FPR32RegClass;
9732 Opc = AArch64::FNMSUBDrrr;
9733 RC = &AArch64::FPR64RegClass;
9738 Opc = AArch64::FNMADDHrrr;
9739 RC = &AArch64::FPR16RegClass;
9743 Opc = AArch64::FNMADDSrrr;
9744 RC = &AArch64::FPR32RegClass;
9748 Opc = AArch64::FNMADDDrrr;
9749 RC = &AArch64::FPR64RegClass;
9754 Opc = AArch64::FMSUBHrrr;
9755 RC = &AArch64::FPR16RegClass;
9759 Opc = AArch64::FMSUBSrrr;
9760 RC = &AArch64::FPR32RegClass;
9764 Opc = AArch64::FMSUBDrrr;
9765 RC = &AArch64::FPR64RegClass;
9770 Opc = AArch64::FMLSv1i32_indexed;
9771 RC = &AArch64::FPR32RegClass;
9777 Opc = AArch64::FMLSv1i64_indexed;
9778 RC = &AArch64::FPR64RegClass;
9785 RC = &AArch64::FPR64RegClass;
9787 MachineInstrBuilder MIB1 =
9788 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv4f16), NewVR)
9791 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9793 Opc = AArch64::FMLAv4f16;
9797 Opc = AArch64::FMLAv4i16_indexed;
9804 RC = &AArch64::FPR64RegClass;
9805 Opc = AArch64::FMLSv4f16;
9810 RC = &AArch64::FPR64RegClass;
9811 Opc = AArch64::FMLSv4i16_indexed;
9818 RC = &AArch64::FPR64RegClass;
9820 Opc = AArch64::FMLSv2i32_indexed;
9824 Opc = AArch64::FMLSv2f32;
9832 RC = &AArch64::FPR128RegClass;
9834 MachineInstrBuilder MIB1 =
9835 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv8f16), NewVR)
9838 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9840 Opc = AArch64::FMLAv8f16;
9844 Opc = AArch64::FMLAv8i16_indexed;
9851 RC = &AArch64::FPR128RegClass;
9852 Opc = AArch64::FMLSv8f16;
9857 RC = &AArch64::FPR128RegClass;
9858 Opc = AArch64::FMLSv8i16_indexed;
9865 RC = &AArch64::FPR128RegClass;
9867 Opc = AArch64::FMLSv2i64_indexed;
9871 Opc = AArch64::FMLSv2f64;
9879 RC = &AArch64::FPR128RegClass;
9881 Opc = AArch64::FMLSv4i32_indexed;
9885 Opc = AArch64::FMLSv4f32;
9892 RC = &AArch64::FPR64RegClass;
9894 MachineInstrBuilder MIB1 =
9895 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv2f32), NewVR)
9898 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9900 Opc = AArch64::FMLAv2i32_indexed;
9904 Opc = AArch64::FMLAv2f32;
9912 RC = &AArch64::FPR128RegClass;
9914 MachineInstrBuilder MIB1 =
9915 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv4f32), NewVR)
9918 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9920 Opc = AArch64::FMLAv4i32_indexed;
9924 Opc = AArch64::FMLAv4f32;
9932 RC = &AArch64::FPR128RegClass;
9934 MachineInstrBuilder MIB1 =
9935 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv2f64), NewVR)
9938 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9940 Opc = AArch64::FMLAv2i64_indexed;
9944 Opc = AArch64::FMLAv2f64;
9956 &AArch64::FPR128RegClass, MRI);
9965 &AArch64::FPR128RegClass, MRI);
9974 &AArch64::FPR128_loRegClass, MRI);
9983 &AArch64::FPR128RegClass, MRI);
9992 &AArch64::FPR128_loRegClass, MRI);
10026 for (
auto *
MI : InsInstrs)
10027 MI->setFlags(Flags);
10068 bool IsNegativeBranch =
false;
10069 bool IsTestAndBranch =
false;
10070 unsigned TargetBBInMI = 0;
10071 switch (
MI.getOpcode()) {
10075 case AArch64::CBWPri:
10076 case AArch64::CBXPri:
10077 case AArch64::CBBAssertExt:
10078 case AArch64::CBHAssertExt:
10079 case AArch64::CBWPrr:
10080 case AArch64::CBXPrr:
10082 case AArch64::CBZW:
10083 case AArch64::CBZX:
10086 case AArch64::CBNZW:
10087 case AArch64::CBNZX:
10089 IsNegativeBranch =
true;
10091 case AArch64::TBZW:
10092 case AArch64::TBZX:
10094 IsTestAndBranch =
true;
10096 case AArch64::TBNZW:
10097 case AArch64::TBNZX:
10099 IsNegativeBranch =
true;
10100 IsTestAndBranch =
true;
10106 if (IsTestAndBranch &&
MI.getOperand(1).getImm())
10110 assert(
MI.getParent() &&
"Incomplete machine instruction\n");
10123 while (
DefMI->isCopy()) {
10134 switch (
DefMI->getOpcode()) {
10138 case AArch64::ANDWri:
10139 case AArch64::ANDXri: {
10140 if (IsTestAndBranch)
10147 bool Is32Bit = (
DefMI->getOpcode() == AArch64::ANDWri);
10149 DefMI->getOperand(2).getImm(), Is32Bit ? 32 : 64);
10165 unsigned Opc = (
Imm < 32)
10166 ? (IsNegativeBranch ? AArch64::TBNZW : AArch64::TBZW)
10167 : (IsNegativeBranch ? AArch64::TBNZX : AArch64::TBZX);
10180 if (!Is32Bit &&
Imm < 32)
10182 MI.eraseFromParent();
10186 case AArch64::CSINCWr:
10187 case AArch64::CSINCXr: {
10188 if (!(
DefMI->getOperand(1).getReg() == AArch64::WZR &&
10189 DefMI->getOperand(2).getReg() == AArch64::WZR) &&
10190 !(
DefMI->getOperand(1).getReg() == AArch64::XZR &&
10191 DefMI->getOperand(2).getReg() == AArch64::XZR))
10194 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
10207 if (IsNegativeBranch)
10210 MI.eraseFromParent();
10216std::pair<unsigned, unsigned>
10217AArch64InstrInfo::decomposeMachineOperandsTargetFlags(
unsigned TF)
const {
10219 return std::make_pair(TF & Mask, TF & ~Mask);
10223AArch64InstrInfo::getSerializableDirectMachineOperandTargetFlags()
const {
10226 static const std::pair<unsigned, const char *> TargetFlags[] = {
10227 {MO_PAGE,
"aarch64-page"}, {
MO_PAGEOFF,
"aarch64-pageoff"},
10228 {
MO_G3,
"aarch64-g3"}, {
MO_G2,
"aarch64-g2"},
10229 {
MO_G1,
"aarch64-g1"}, {
MO_G0,
"aarch64-g0"},
10235AArch64InstrInfo::getSerializableBitmaskMachineOperandTargetFlags()
const {
10236 using namespace AArch64II;
10238 static const std::pair<unsigned, const char *> TargetFlags[] = {
10240 {
MO_GOT,
"aarch64-got"},
10241 {
MO_NC,
"aarch64-nc"},
10242 {
MO_S,
"aarch64-s"},
10243 {
MO_TLS,
"aarch64-tls"},
10253AArch64InstrInfo::getSerializableMachineMemOperandTargetFlags()
const {
10254 static const std::pair<MachineMemOperand::Flags, const char *> TargetFlags[] =
10388 std::vector<outliner::Candidate> &RepeatedSequenceLocs,
10403 return C.isAvailableInsideSeq(AArch64::FP,
TRI);
10411 const AArch64RegisterInfo *ARI =
10412 static_cast<const AArch64RegisterInfo *
>(&
TRI);
10415 for (
unsigned Reg : AArch64::GPR64RegClass) {
10417 Reg != AArch64::LR &&
10418 Reg != AArch64::X16 &&
10419 Reg != AArch64::X17 &&
10420 C.isAvailableAcrossAndOutOfSeq(
Reg,
TRI) &&
10421 C.isAvailableInsideSeq(
Reg,
TRI))
10452 return SubtargetA.hasV8_3aOps() == SubtargetB.hasV8_3aOps();
10455std::optional<std::unique_ptr<outliner::OutlinedFunction>>
10456AArch64InstrInfo::getOutliningCandidateInfo(
10458 std::vector<outliner::Candidate> &RepeatedSequenceLocs,
10459 unsigned MinRepeats)
const {
10460 unsigned SequenceSize = 0;
10461 for (
auto &
MI : RepeatedSequenceLocs[0])
10464 unsigned NumBytesToCreateFrame = 0;
10470 MachineInstr &LastMI = RepeatedSequenceLocs[0].back();
10471 MachineInstr &FirstMI = RepeatedSequenceLocs[0].front();
10472 if (LastMI.
getOpcode() == AArch64::ADRP &&
10475 return std::nullopt;
10480 if ((FirstMI.
getOpcode() == AArch64::ADDXri ||
10481 FirstMI.
getOpcode() == AArch64::LDRXui) &&
10484 return std::nullopt;
10495 if (std::adjacent_find(
10496 RepeatedSequenceLocs.begin(), RepeatedSequenceLocs.end(),
10497 [](
const outliner::Candidate &a,
const outliner::Candidate &b) {
10500 if (outliningCandidatesSigningScopeConsensus(a, b) &&
10501 outliningCandidatesSigningKeyConsensus(a, b) &&
10502 outliningCandidatesV8_3OpsConsensus(a, b)) {
10506 }) != RepeatedSequenceLocs.end()) {
10507 return std::nullopt;
10524 unsigned NumBytesToCheckLRInTCEpilogue = 0;
10525 const auto RASignCondition = RepeatedSequenceLocs[0]
10528 ->getSignReturnAddressCondition();
10531 NumBytesToCreateFrame += 8;
10534 auto LRCheckMethod = Subtarget.getAuthenticatedLRCheckMethod(
10535 *RepeatedSequenceLocs[0].getMF());
10536 NumBytesToCheckLRInTCEpilogue =
10540 if (isTailCallReturnInst(RepeatedSequenceLocs[0].
back()))
10541 SequenceSize += NumBytesToCheckLRInTCEpilogue;
10549 for (
auto &
MI :
C) {
10550 if (
MI.modifiesRegister(AArch64::SP, &
TRI)) {
10551 switch (
MI.getOpcode()) {
10552 case AArch64::ADDXri:
10553 case AArch64::ADDWri:
10554 assert(
MI.getNumOperands() == 4 &&
"Wrong number of operands");
10555 assert(
MI.getOperand(2).isImm() &&
10556 "Expected operand to be immediate");
10557 assert(
MI.getOperand(1).isReg() &&
10558 "Expected operand to be a register");
10562 if (
MI.getOperand(1).getReg() == AArch64::SP)
10563 SPValue +=
MI.getOperand(2).getImm();
10567 case AArch64::SUBXri:
10568 case AArch64::SUBWri:
10569 assert(
MI.getNumOperands() == 4 &&
"Wrong number of operands");
10570 assert(
MI.getOperand(2).isImm() &&
10571 "Expected operand to be immediate");
10572 assert(
MI.getOperand(1).isReg() &&
10573 "Expected operand to be a register");
10577 if (
MI.getOperand(1).getReg() == AArch64::SP)
10578 SPValue -=
MI.getOperand(2).getImm();
10595 if (RepeatedSequenceLocs.size() < MinRepeats)
10596 return std::nullopt;
10600 unsigned FlagsSetInAll = 0xF;
10604 FlagsSetInAll &=
C.Flags;
10606 unsigned LastInstrOpcode = RepeatedSequenceLocs[0].back().getOpcode();
10609 auto SetCandidateCallInfo =
10610 [&RepeatedSequenceLocs](
unsigned CallID,
unsigned NumBytesForCall) {
10612 C.setCallInfo(CallID, NumBytesForCall);
10616 NumBytesToCreateFrame += 4;
10624 unsigned CFICount = 0;
10625 for (
auto &
I : RepeatedSequenceLocs[0]) {
10626 if (
I.isCFIInstruction())
10636 std::vector<MCCFIInstruction> CFIInstructions =
10637 C.getMF()->getFrameInstructions();
10639 if (CFICount > 0 && CFICount != CFIInstructions.size())
10640 return std::nullopt;
10648 if (!
MI.modifiesRegister(AArch64::SP, &
TRI) &&
10649 !
MI.readsRegister(AArch64::SP, &
TRI))
10655 if (
MI.modifiesRegister(AArch64::SP, &
TRI))
10660 if (
MI.mayLoadOrStore()) {
10663 bool OffsetIsScalable;
10667 if (!getMemOperandWithOffset(
MI,
Base,
Offset, OffsetIsScalable, &
TRI) ||
10668 !
Base->isReg() ||
Base->getReg() != AArch64::SP)
10672 if (OffsetIsScalable)
10680 TypeSize Scale(0U,
false), DummyWidth(0U,
false);
10681 getMemOpInfo(
MI.getOpcode(), Scale, DummyWidth, MinOffset, MaxOffset);
10684 if (
Offset < MinOffset * (int64_t)Scale.getFixedValue() ||
10685 Offset > MaxOffset * (int64_t)Scale.getFixedValue())
10700 bool AllStackInstrsSafe =
10705 if (RepeatedSequenceLocs[0].
back().isTerminator()) {
10707 NumBytesToCreateFrame = 0;
10708 unsigned NumBytesForCall = 4 + NumBytesToCheckLRInTCEpilogue;
10712 else if (LastInstrOpcode == AArch64::BL ||
10713 ((LastInstrOpcode == AArch64::BLR ||
10714 LastInstrOpcode == AArch64::BLRNoIP) &&
10718 NumBytesToCreateFrame = NumBytesToCheckLRInTCEpilogue;
10726 unsigned NumBytesNoStackCalls = 0;
10727 std::vector<outliner::Candidate> CandidatesWithoutStackFixups;
10733 ?
C.isAvailableAcrossAndOutOfSeq(AArch64::LR,
TRI)
10742 C.getMF()->getFunction().hasFnAttribute(Attribute::NoReturn);
10745 if (LRAvailable && !IsNoReturn) {
10746 NumBytesNoStackCalls += 4;
10748 CandidatesWithoutStackFixups.push_back(
C);
10753 else if (findRegisterToSaveLRTo(
C)) {
10754 NumBytesNoStackCalls += 12;
10756 CandidatesWithoutStackFixups.push_back(
C);
10761 else if (
C.isAvailableInsideSeq(AArch64::SP,
TRI)) {
10762 NumBytesNoStackCalls += 12;
10764 CandidatesWithoutStackFixups.push_back(
C);
10770 NumBytesNoStackCalls += SequenceSize;
10777 if (!AllStackInstrsSafe ||
10778 NumBytesNoStackCalls <= RepeatedSequenceLocs.size() * 12) {
10779 RepeatedSequenceLocs = CandidatesWithoutStackFixups;
10781 if (RepeatedSequenceLocs.size() < MinRepeats)
10782 return std::nullopt;
10835 (!
C.isAvailableAcrossAndOutOfSeq(AArch64::LR,
TRI) ||
10836 !findRegisterToSaveLRTo(
C));
10842 if (RepeatedSequenceLocs.size() < MinRepeats)
10843 return std::nullopt;
10852 bool ModStackToSaveLR =
false;
10855 ModStackToSaveLR =
true;
10864 ModStackToSaveLR =
true;
10866 if (ModStackToSaveLR) {
10868 if (!AllStackInstrsSafe)
10869 return std::nullopt;
10872 NumBytesToCreateFrame += 8;
10876 RepeatedSequenceLocs,
TRI))
10877 NumBytesToCreateFrame += 4;
10884 return std::nullopt;
10886 return std::make_unique<outliner::OutlinedFunction>(
10887 RepeatedSequenceLocs, SequenceSize, NumBytesToCreateFrame, FrameID);
10890void AArch64InstrInfo::mergeOutliningCandidateAttributes(
10891 Function &
F, std::vector<outliner::Candidate> &Candidates)
const {
10895 const auto &CFn = Candidates.front().getMF()->getFunction();
10897 if (CFn.hasFnAttribute(
"ptrauth-returns"))
10898 F.addFnAttr(CFn.getFnAttribute(
"ptrauth-returns"));
10899 if (CFn.hasFnAttribute(
"ptrauth-auth-traps"))
10900 F.addFnAttr(CFn.getFnAttribute(
"ptrauth-auth-traps"));
10903 if (CFn.hasFnAttribute(
"sign-return-address"))
10904 F.addFnAttr(CFn.getFnAttribute(
"sign-return-address"));
10905 if (CFn.hasFnAttribute(
"sign-return-address-key"))
10906 F.addFnAttr(CFn.getFnAttribute(
"sign-return-address-key"));
10908 AArch64GenInstrInfo::mergeOutliningCandidateAttributes(
F, Candidates);
10911bool AArch64InstrInfo::isFunctionSafeToOutlineFrom(
10916 if (!OutlineFromLinkOnceODRs &&
F.hasLinkOnceODRLinkage())
10923 if (
F.hasSection())
10929 AArch64FunctionInfo *AFI = MF.
getInfo<AArch64FunctionInfo>();
10930 if (!AFI || AFI->
hasRedZone().value_or(
true))
10950 unsigned &Flags)
const {
10952 "Must track liveness!");
10954 std::pair<MachineBasicBlock::iterator, MachineBasicBlock::iterator>>
10969 auto AreAllUnsafeRegsDead = [&LRU]() {
10970 return LRU.available(AArch64::W16) && LRU.available(AArch64::W17) &&
10971 LRU.available(AArch64::NZCV);
10986 bool LRAvailableEverywhere =
true;
10988 LRU.addLiveOuts(
MBB);
10990 auto UpdateWholeMBBFlags = [&
Flags](
const MachineInstr &
MI) {
10991 if (
MI.isCall() && !
MI.isTerminator())
10997 auto CreateNewRangeStartingAt =
10998 [&RangeBegin, &RangeEnd,
11000 RangeBegin = NewBegin;
11001 RangeEnd = std::next(RangeBegin);
11004 auto SaveRangeIfNonEmpty = [&RangeLen, &
Ranges, &RangeBegin, &RangeEnd]() {
11010 if (!RangeBegin.isEnd() && RangeBegin->isBundledWithPred())
11012 if (!RangeEnd.isEnd() && RangeEnd->isBundledWithPred())
11014 Ranges.emplace_back(RangeBegin, RangeEnd);
11022 for (; FirstPossibleEndPt !=
MBB.
instr_rend(); ++FirstPossibleEndPt) {
11023 if (!FirstPossibleEndPt->isDebugInstr())
11024 LRU.stepBackward(*FirstPossibleEndPt);
11027 UpdateWholeMBBFlags(*FirstPossibleEndPt);
11028 if (AreAllUnsafeRegsDead())
11035 CreateNewRangeStartingAt(FirstPossibleEndPt->getIterator());
11040 if (!
MI.isDebugInstr())
11041 LRU.stepBackward(
MI);
11042 UpdateWholeMBBFlags(
MI);
11043 if (!AreAllUnsafeRegsDead()) {
11044 SaveRangeIfNonEmpty();
11045 CreateNewRangeStartingAt(
MI.getIterator());
11048 LRAvailableEverywhere &= LRU.available(AArch64::LR);
11052 RangeBegin =
MI.getIterator();
11053 if (!
MI.isDebugInstr())
11058 if (AreAllUnsafeRegsDead())
11059 SaveRangeIfNonEmpty();
11067 if (!LRAvailableEverywhere)
11075 unsigned Flags)
const {
11076 MachineInstr &
MI = *MIT;
11080 switch (
MI.getOpcode()) {
11081 case AArch64::PACM:
11082 case AArch64::PACIASP:
11083 case AArch64::PACIBSP:
11084 case AArch64::PACIASPPC:
11085 case AArch64::PACIBSPPC:
11086 case AArch64::AUTIASP:
11087 case AArch64::AUTIBSP:
11088 case AArch64::AUTIASPPCi:
11089 case AArch64::AUTIASPPCr:
11090 case AArch64::AUTIBSPPCi:
11091 case AArch64::AUTIBSPPCr:
11092 case AArch64::RETAA:
11093 case AArch64::RETAB:
11094 case AArch64::RETAASPPCi:
11095 case AArch64::RETAASPPCr:
11096 case AArch64::RETABSPPCi:
11097 case AArch64::RETABSPPCr:
11098 case AArch64::EMITBKEY:
11099 case AArch64::PAUTH_PROLOGUE:
11100 case AArch64::PAUTH_EPILOGUE:
11110 if (
MI.isCFIInstruction())
11114 if (
MI.isTerminator())
11120 for (
const MachineOperand &MOP :
MI.operands()) {
11123 assert(!MOP.isCFIIndex());
11126 if (MOP.isReg() && !MOP.isImplicit() &&
11127 (MOP.getReg() == AArch64::LR || MOP.getReg() == AArch64::W30))
11134 if (
MI.getOpcode() == AArch64::ADRP)
11154 for (
const MachineOperand &MOP :
MI.operands()) {
11155 if (MOP.isGlobal()) {
11163 if (Callee &&
Callee->getName() ==
"\01_mcount")
11171 if (
MI.getOpcode() == AArch64::BLR ||
11172 MI.getOpcode() == AArch64::BLRNoIP ||
MI.getOpcode() == AArch64::BL)
11176 return UnknownCallOutlineType;
11184 return UnknownCallOutlineType;
11192 return UnknownCallOutlineType;
11213 for (MachineInstr &
MI :
MBB) {
11214 const MachineOperand *
Base;
11215 TypeSize Width(0,
false);
11217 bool OffsetIsScalable;
11220 if (!
MI.mayLoadOrStore() ||
11223 (
Base->isReg() &&
Base->getReg() != AArch64::SP))
11227 TypeSize Scale(0U,
false);
11228 int64_t Dummy1, Dummy2;
11231 assert(StackOffsetOperand.
isImm() &&
"Stack offset wasn't immediate!");
11233 assert(Scale != 0 &&
"Unexpected opcode!");
11234 assert(!OffsetIsScalable &&
"Expected offset to be a byte offset");
11239 int64_t NewImm = (
Offset + 16) / (int64_t)Scale.getFixedValue();
11240 StackOffsetOperand.
setImm(NewImm);
11246 bool ShouldSignReturnAddr) {
11247 if (!ShouldSignReturnAddr)
11255void AArch64InstrInfo::buildOutlinedFrame(
11259 AArch64FunctionInfo *FI = MF.
getInfo<AArch64FunctionInfo>();
11267 unsigned TailOpcode;
11269 TailOpcode = AArch64::TCRETURNdi;
11273 TailOpcode = AArch64::TCRETURNriALL;
11284 bool IsLeafFunction =
true;
11287 auto IsNonTailCall = [](
const MachineInstr &
MI) {
11288 return MI.isCall() && !
MI.isReturn();
11298 "Can only fix up stack references once");
11299 fixupPostOutline(
MBB);
11301 IsLeafFunction =
false;
11312 Et = std::prev(
MBB.
end());
11343 CFIBuilder.buildDefCFA(AArch64::FP, 16);
11344 CFIBuilder.buildOffset(AArch64::LR, -8);
11345 CFIBuilder.buildOffset(AArch64::FP, -16);
11364 if (MF.
getInfo<AArch64FunctionInfo>()->needsDwarfUnwindInfo(MF)) {
11368 CFIBuilder.buildDefCFAOffset(16);
11372 CFIBuilder.buildOffset(AArch64::LR, -16);
11387 RASignCondition, !IsLeafFunction);
11416 fixupPostOutline(
MBB);
11427 .addGlobalAddress(
M.getNamedValue(MF.
getName()))
11437 .addGlobalAddress(
M.getNamedValue(MF.
getName())));
11446 MachineInstr *Save;
11447 MachineInstr *Restore;
11453 assert(
Reg &&
"No callee-saved register available?");
11487 .addGlobalAddress(
M.getNamedValue(MF.
getName())));
11495bool AArch64InstrInfo::shouldOutlineFromFunctionByDefault(
11503 bool AllowSideEffects)
const {
11505 const AArch64Subtarget &STI = MF.
getSubtarget<AArch64Subtarget>();
11508 if (
TRI.isGeneralPurposeRegister(MF,
Reg)) {
11521 assert(STI.hasFPARMv8() &&
"Expected FP to be available.");
11527std::optional<DestSourcePair>
11532 if ((
MI.getOpcode() == AArch64::ORRWrs &&
11533 MI.getOperand(1).getReg() == AArch64::WZR &&
11534 MI.getOperand(3).getImm() == 0x0) ||
11535 (
MI.getOpcode() == AArch64::ORRWrr &&
11536 MI.getOperand(1).getReg() == AArch64::WZR)) {
11538 if ((
MI.getOperand(0).getReg().isPhysical() &&
11539 MI.findRegisterDefOperandIdx(
11542 (
MI.getOperand(0).getReg().isVirtual() &&
11543 !
MI.getOperand(0).getSubReg()))
11547 if (
MI.getOpcode() == AArch64::ORRXrs &&
11548 MI.getOperand(1).getReg() == AArch64::XZR &&
11549 MI.getOperand(3).getImm() == 0x0)
11552 return std::nullopt;
11555std::optional<DestSourcePair>
11557 if ((
MI.getOpcode() == AArch64::ORRWrs &&
11558 MI.getOperand(1).getReg() == AArch64::WZR &&
11559 MI.getOperand(3).getImm() == 0x0) ||
11560 (
MI.getOpcode() == AArch64::ORRWrr &&
11561 MI.getOperand(1).getReg() == AArch64::WZR))
11563 return std::nullopt;
11566std::optional<RegImmPair>
11575 return std::nullopt;
11577 switch (
MI.getOpcode()) {
11579 return std::nullopt;
11580 case AArch64::SUBWri:
11581 case AArch64::SUBXri:
11582 case AArch64::SUBSWri:
11583 case AArch64::SUBSXri:
11586 case AArch64::ADDSWri:
11587 case AArch64::ADDSXri:
11588 case AArch64::ADDWri:
11589 case AArch64::ADDXri: {
11591 if (!
MI.getOperand(0).isReg() || !
MI.getOperand(1).isReg() ||
11592 !
MI.getOperand(2).isImm())
11593 return std::nullopt;
11594 int Shift =
MI.getOperand(3).getImm();
11595 assert((Shift == 0 || Shift == 12) &&
"Shift can be either 0 or 12");
11599 return RegImmPair{
MI.getOperand(1).getReg(),
Offset};
11605static std::optional<ParamLoadedValue>
11609 auto DestSrc =
TII->isCopyLikeInstr(
MI);
11611 return std::nullopt;
11613 Register DestReg = DestSrc->Destination->getReg();
11614 Register SrcReg = DestSrc->Source->getReg();
11617 return std::nullopt;
11622 if (DestReg == DescribedReg)
11626 if (
MI.getOpcode() == AArch64::ORRWrs &&
11627 TRI->isSuperRegister(DestReg, DescribedReg))
11631 if (
MI.getOpcode() == AArch64::ORRXrs &&
11632 TRI->isSubRegister(DestReg, DescribedReg)) {
11633 Register SrcSubReg =
TRI->getSubReg(SrcReg, AArch64::sub_32);
11637 assert(!
TRI->isSuperOrSubRegisterEq(DestReg, DescribedReg) &&
11638 "Unhandled ORR[XW]rs copy case");
11640 return std::nullopt;
11643bool AArch64InstrInfo::isFunctionSafeToSplit(
const MachineFunction &MF)
const {
11648 if (MF.
getInfo<AArch64FunctionInfo>()->hasRedZone().value_or(
true))
11654bool AArch64InstrInfo::isMBBSafeToSplitToCold(
11658 auto isAsmGoto = [](
const MachineInstr &
MI) {
11659 return MI.getOpcode() == AArch64::INLINEASM_BR;
11669 auto containsMBB = [&
MBB](
const MachineJumpTableEntry &JTE) {
11676 for (
const MachineInstr &
MI :
MBB) {
11677 switch (
MI.getOpcode()) {
11678 case TargetOpcode::G_BRJT:
11679 case AArch64::JumpTableDest32:
11680 case AArch64::JumpTableDest16:
11681 case AArch64::JumpTableDest8:
11692std::optional<ParamLoadedValue>
11697 switch (
MI.getOpcode()) {
11698 case AArch64::MOVZWi:
11699 case AArch64::MOVZXi: {
11702 if (!
TRI->isSuperRegisterEq(
MI.getOperand(0).getReg(),
Reg))
11703 return std::nullopt;
11705 if (!
MI.getOperand(1).isImm())
11706 return std::nullopt;
11707 int64_t Immediate =
MI.getOperand(1).getImm();
11708 int Shift =
MI.getOperand(2).getImm();
11712 case AArch64::ORRWrs:
11713 case AArch64::ORRXrs:
11720bool AArch64InstrInfo::isExtendLikelyToBeFolded(
11723 ExtMI.
getOpcode() == TargetOpcode::G_ZEXT ||
11724 ExtMI.
getOpcode() == TargetOpcode::G_ANYEXT);
11727 if (ExtMI.
getOpcode() == TargetOpcode::G_ANYEXT)
11737 return UserMI->
getOpcode() == TargetOpcode::G_PTR_ADD;
11740uint64_t AArch64InstrInfo::getElementSizeForOpcode(
unsigned Opc)
const {
11744bool AArch64InstrInfo::isPTestLikeOpcode(
unsigned Opc)
const {
11748bool AArch64InstrInfo::isWhileOpcode(
unsigned Opc)
const {
11753AArch64InstrInfo::getTailDuplicateSize(
CodeGenOptLevel OptLevel)
const {
11757bool AArch64InstrInfo::isLegalAddressingMode(
unsigned NumBytes, int64_t
Offset,
11758 unsigned Scale)
const {
11769 unsigned Shift =
Log2_64(NumBytes);
11770 if (NumBytes &&
Offset > 0 && (
Offset / NumBytes) <= (1LL << 12) - 1 &&
11778 return Scale == 1 || (Scale > 0 && Scale == NumBytes);
11783 return AArch64::BLRNoIP;
11785 return AArch64::BLR;
11791 auto Builder =
BuildMI(
MBB, InsertPt,
DL,
get(AArch64::PAUTH_EPILOGUE))
11812 Register TargetReg,
bool FrameSetup)
const {
11813 assert(TargetReg != AArch64::SP &&
"New top of stack cannot already be in SP");
11825 MF.
insert(MBBInsertPoint, LoopTestMBB);
11828 MF.
insert(MBBInsertPoint, LoopBodyMBB);
11830 MF.
insert(MBBInsertPoint, ExitMBB);
11840 BuildMI(*LoopTestMBB, LoopTestMBB->
end(),
DL,
TII->get(AArch64::SUBSXrx64),
11848 BuildMI(*LoopTestMBB, LoopTestMBB->
end(),
DL,
TII->get(AArch64::Bcc))
11854 BuildMI(*LoopBodyMBB, LoopBodyMBB->
end(),
DL,
TII->get(AArch64::LDRXui))
11871 BuildMI(*ExitMBB, ExitMBB->
end(),
DL,
TII->get(AArch64::ADDXri), AArch64::SP)
11890 MBB.addSuccessor(LoopTestMBB);
11896 return ExitMBB->
begin();
11902 const TargetInstrInfo *
TII;
11903 const TargetRegisterInfo *
TRI;
11904 MachineRegisterInfo &MRI;
11907 MachineBasicBlock *LoopBB;
11909 MachineInstr *CondBranch;
11911 MachineInstr *Comp;
11913 unsigned CompCounterOprNum;
11915 MachineInstr *Update;
11917 unsigned UpdateCounterOprNum;
11921 bool IsUpdatePriorComp;
11924 SmallVector<MachineOperand, 4>
Cond;
11927 AArch64PipelinerLoopInfo(MachineBasicBlock *LoopBB, MachineInstr *CondBranch,
11928 MachineInstr *Comp,
unsigned CompCounterOprNum,
11929 MachineInstr *Update,
unsigned UpdateCounterOprNum,
11930 Register Init,
bool IsUpdatePriorComp,
11931 const SmallVectorImpl<MachineOperand> &
Cond)
11933 TII(MF->getSubtarget().getInstrInfo()),
11934 TRI(MF->getSubtarget().getRegisterInfo()), MRI(MF->getRegInfo()),
11935 LoopBB(LoopBB), CondBranch(CondBranch), Comp(Comp),
11936 CompCounterOprNum(CompCounterOprNum), Update(Update),
11937 UpdateCounterOprNum(UpdateCounterOprNum), Init(Init),
11940 bool shouldIgnoreForPipelining(
const MachineInstr *
MI)
const override {
11946 std::optional<bool> createTripCountGreaterCondition(
11947 int TC, MachineBasicBlock &
MBB,
11948 SmallVectorImpl<MachineOperand> &CondParam)
override {
11956 void createRemainingIterationsGreaterCondition(
11957 int TC, MachineBasicBlock &
MBB, SmallVectorImpl<MachineOperand> &
Cond,
11958 DenseMap<MachineInstr *, MachineInstr *> &LastStage0Insts)
override;
11960 void setPreheader(MachineBasicBlock *NewPreheader)
override {}
11962 void adjustTripCount(
int TripCountAdjust)
override {}
11964 bool isMVEExpanderSupported()
override {
return true; }
11983 }
else if (
I == ReplaceOprNum) {
11988 MBB.insert(InsertTo, NewMI);
11992void AArch64PipelinerLoopInfo::createRemainingIterationsGreaterCondition(
12008 assert(CondBranch->getOpcode() == AArch64::Bcc);
12012 if (CondBranch->getOperand(1).getMBB() == LoopBB)
12019 auto AccumulateCond = [&](
Register CurCond,
12030 if (!LastStage0Insts.
empty() && LastStage0Insts[Comp]->getParent() == &
MBB) {
12034 for (
int I = 0;
I <= TC; ++
I) {
12040 AccCond = AccumulateCond(AccCond, CC);
12044 if (Update != Comp && IsUpdatePriorComp) {
12046 LastStage0Insts[Comp]->getOperand(CompCounterOprNum).getReg();
12047 NextCounter =
cloneInstr(Update, UpdateCounterOprNum, Counter,
MBB,
12051 NextCounter = LastStage0Insts[Update]->getOperand(0).getReg();
12053 }
else if (Update != Comp) {
12058 Counter = NextCounter;
12062 if (LastStage0Insts.
empty()) {
12066 if (IsUpdatePriorComp)
12071 Counter = LastStage0Insts[Comp]->getOperand(CompCounterOprNum).getReg();
12074 for (
int I = 0;
I <= TC; ++
I) {
12078 AccCond = AccumulateCond(AccCond, CC);
12079 if (
I != TC && Update != Comp)
12082 Counter = NextCounter;
12098 assert(Phi.getNumOperands() == 5);
12099 if (Phi.getOperand(2).getMBB() ==
MBB) {
12100 RegMBB = Phi.getOperand(1).getReg();
12101 RegOther = Phi.getOperand(3).getReg();
12103 assert(Phi.getOperand(4).getMBB() ==
MBB);
12104 RegMBB = Phi.getOperand(3).getReg();
12105 RegOther = Phi.getOperand(1).getReg();
12110 if (!
Reg.isVirtual())
12119 unsigned &UpdateCounterOprNum,
Register &InitReg,
12120 bool &IsUpdatePriorComp) {
12134 if (!
Reg.isVirtual())
12137 UpdateInst =
nullptr;
12138 UpdateCounterOprNum = 0;
12140 IsUpdatePriorComp =
true;
12144 if (Def->getParent() != LoopBB)
12146 if (Def->isCopy()) {
12148 if (Def->getOperand(0).getSubReg() || Def->getOperand(1).getSubReg())
12150 CurReg = Def->getOperand(1).getReg();
12151 }
else if (Def->isPHI()) {
12155 IsUpdatePriorComp =
false;
12160 switch (Def->getOpcode()) {
12161 case AArch64::ADDSXri:
12162 case AArch64::ADDSWri:
12163 case AArch64::SUBSXri:
12164 case AArch64::SUBSWri:
12165 case AArch64::ADDXri:
12166 case AArch64::ADDWri:
12167 case AArch64::SUBXri:
12168 case AArch64::SUBWri:
12170 UpdateCounterOprNum = 1;
12172 case AArch64::ADDSXrr:
12173 case AArch64::ADDSWrr:
12174 case AArch64::SUBSXrr:
12175 case AArch64::SUBSWrr:
12176 case AArch64::ADDXrr:
12177 case AArch64::ADDWrr:
12178 case AArch64::SUBXrr:
12179 case AArch64::SUBWrr:
12182 UpdateCounterOprNum = 1;
12184 UpdateCounterOprNum = 2;
12191 CurReg = Def->getOperand(UpdateCounterOprNum).getReg();
12206std::unique_ptr<TargetInstrInfo::PipelinerLoopInfo>
12217 if (
MI.isCall() ||
MI.hasUnmodeledSideEffects())
12228 if (
TBB == LoopBB && FBB == LoopBB)
12232 if (
TBB != LoopBB && FBB ==
nullptr)
12235 assert((
TBB == LoopBB || FBB == LoopBB) &&
12236 "The Loop must be a single-basic-block loop");
12241 if (CondBranch->
getOpcode() != AArch64::Bcc)
12249 unsigned CompCounterOprNum = 0;
12251 if (
MI.modifiesRegister(AArch64::NZCV, &
TRI)) {
12255 switch (
MI.getOpcode()) {
12256 case AArch64::SUBSXri:
12257 case AArch64::SUBSWri:
12258 case AArch64::ADDSXri:
12259 case AArch64::ADDSWri:
12261 CompCounterOprNum = 1;
12263 case AArch64::ADDSWrr:
12264 case AArch64::ADDSXrr:
12265 case AArch64::SUBSWrr:
12266 case AArch64::SUBSXrr:
12270 if (isWhileOpcode(
MI.getOpcode())) {
12277 if (CompCounterOprNum == 0) {
12279 CompCounterOprNum = 2;
12281 CompCounterOprNum = 1;
12293 bool IsUpdatePriorComp;
12294 unsigned UpdateCounterOprNum;
12296 Update, UpdateCounterOprNum,
Init, IsUpdatePriorComp))
12299 return std::make_unique<AArch64PipelinerLoopInfo>(
12300 LoopBB, CondBranch, Comp, CompCounterOprNum, Update, UpdateCounterOprNum,
12310 TypeSize Scale(0U,
false), Width(0U,
false);
12311 int64_t MinOffset, MaxOffset;
12312 if (
getMemOpInfo(
MI.getOpcode(), Scale, Width, MinOffset, MaxOffset)) {
12314 if (
MI.getOperand(ImmIdx).isImm() && !
MI.getOperand(ImmIdx - 1).isFI()) {
12315 int64_t
Imm =
MI.getOperand(ImmIdx).getImm();
12317 ErrInfo =
"Unexpected immediate on load/store instruction";
12323 const MCInstrDesc &MCID =
MI.getDesc();
12325 const MachineOperand &MO =
MI.getOperand(
Op);
12329 ErrInfo =
"OPERAND_IMPLICIT_IMM_0 should be 0";
12338 ErrInfo =
"OPERAND_SHIFT_MSL should be msl shift of 8 or 16";
12344 ErrInfo =
"OPERAND_IMM_UINT1 should be 0 or 1";
12350 ErrInfo =
"OPERAND_IMM_UINT4plus1 should be in the range 1 to 16";
12356 ErrInfo =
"OPERAND_IMM_UINT5 should be in the range 0 to 31";
12362 ErrInfo =
"OPERAND_IMM_UINT8 should be in the range 0 to 255";
12373#define GET_INSTRINFO_HELPERS
12374#define GET_INSTRMAP_INFO
12375#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.
std::optional< ExtAddrMode > getAddrModeFromMemoryOp(const MachineInstr &MemI, const TargetRegisterInfo *TRI) const override
bool getMemOperandsWithOffsetWidth(const MachineInstr &MI, SmallVectorImpl< const MachineOperand * > &BaseOps, int64_t &Offset, bool &OffsetIsScalable, LocationSize &Width, const TargetRegisterInfo *TRI) const override
bool analyzeBranchPredicate(MachineBasicBlock &MBB, MachineBranchPredicate &MBP, bool AllowModify) const override
void insertIndirectBranch(MachineBasicBlock &MBB, MachineBasicBlock &NewDestBB, MachineBasicBlock &RestoreBB, const DebugLoc &DL, int64_t BrOffset, RegScavenger *RS) const override
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register DestReg, int FrameIndex, const TargetRegisterClass *RC, Register VReg, unsigned SubReg=0, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
static bool isPairableLdStInst(const MachineInstr &MI)
Return true if pairing the given load or store may be paired with another.
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, Register VReg, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
static bool isSExtLoad(const MachineInstr &MI)
Returns whether the instruction is a sign-extending load.
const AArch64RegisterInfo & getRegisterInfo() const
getRegisterInfo - TargetInstrInfo is a superset of MRegister info.
static bool isPreSt(const MachineInstr &MI)
Returns whether the instruction is a pre-indexed store.
void insertNoop(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const override
AArch64InstrInfo(const AArch64Subtarget &STI)
static bool isPairedLdSt(const MachineInstr &MI)
Returns whether the instruction is a paired load/store.
MachineInstr * foldMemoryOperandImpl(MachineFunction &MF, MachineInstr &MI, ArrayRef< unsigned > Ops, int FrameIndex, MachineInstr *&CopyMI, LiveIntervals *LIS=nullptr, VirtRegMap *VRM=nullptr) const override
bool getMemOperandWithOffsetWidth(const MachineInstr &MI, const MachineOperand *&BaseOp, int64_t &Offset, bool &OffsetIsScalable, TypeSize &Width, const TargetRegisterInfo *TRI) const
If OffsetIsScalable is set to 'true', the offset is scaled by vscale.
Register isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
static bool isStridedAccess(const MachineInstr &MI)
Return true if the given load or store is a strided memory access.
bool shouldClusterMemOps(ArrayRef< const MachineOperand * > BaseOps1, int64_t Offset1, bool OffsetIsScalable1, ArrayRef< const MachineOperand * > BaseOps2, int64_t Offset2, bool OffsetIsScalable2, unsigned ClusterSize, unsigned NumBytes) const override
Detect opportunities for ldp/stp formation.
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
bool isThroughputPattern(unsigned Pattern) const override
Return true when a code sequence can improve throughput.
MachineOperand & getMemOpBaseRegImmOfsOffsetOperand(MachineInstr &LdSt) const
Return the immediate offset of the base register in a load/store LdSt.
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify=false) const override
bool canFoldIntoAddrMode(const MachineInstr &MemI, Register Reg, const MachineInstr &AddrI, ExtAddrMode &AM) const override
static bool isLdStPairSuppressed(const MachineInstr &MI)
Return true if pairing the given load or store is hinted to be unprofitable.
Register isStoreToStackSlotPostFE(const MachineInstr &MI, int &FrameIndex) const override
Check for post-frame ptr elimination stack locations as well.
std::unique_ptr< TargetInstrInfo::PipelinerLoopInfo > analyzeLoopForPipelining(MachineBasicBlock *LoopBB) const override
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 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.
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 Triple & getTargetTriple() const
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.