54 #define GET_INSTRINFO_CTOR_DTOR 55 #include "AArch64GenInstrInfo.inc" 59 cl::desc(
"Restrict range of TB[N]Z instructions (DEBUG)"));
63 cl::desc(
"Restrict range of CB[N]Z instructions (DEBUG)"));
67 cl::desc(
"Restrict range of Bcc instructions (DEBUG)"));
72 RI(STI.getTargetTriple()), Subtarget(STI) {}
93 unsigned NumBytes = 0;
100 case TargetOpcode::STACKMAP:
103 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
105 case TargetOpcode::PATCHPOINT:
108 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
114 case AArch64::JumpTableDest32:
115 case AArch64::JumpTableDest16:
116 case AArch64::JumpTableDest8:
180 int64_t BrOffset)
const {
182 assert(Bits >= 3 &&
"max branch displacement must be enough to jump" 183 "over conditional branch expansion");
184 return isIntN(Bits, BrOffset / 4);
213 bool AllowModify)
const {
219 if (!isUnpredicatedTerminator(*I))
226 unsigned LastOpc = LastInst->
getOpcode();
227 if (I == MBB.
begin() || !isUnpredicatedTerminator(*--I)) {
242 unsigned SecondLastOpc = SecondLastInst->
getOpcode();
249 LastInst = SecondLastInst;
251 if (I == MBB.
begin() || !isUnpredicatedTerminator(*--I)) {
256 SecondLastInst = &*
I;
257 SecondLastOpc = SecondLastInst->
getOpcode();
263 if (SecondLastInst && I != MBB.
begin() && isUnpredicatedTerminator(*--I))
279 I->eraseFromParent();
288 I->eraseFromParent();
298 if (Cond[0].getImm() != -1) {
304 switch (Cond[1].getImm()) {
308 Cond[1].setImm(AArch64::CBNZW);
311 Cond[1].setImm(AArch64::CBZW);
314 Cond[1].setImm(AArch64::CBNZX);
317 Cond[1].setImm(AArch64::CBZX);
320 Cond[1].setImm(AArch64::TBNZW);
323 Cond[1].setImm(AArch64::TBZW);
326 Cond[1].setImm(AArch64::TBNZX);
329 Cond[1].setImm(AArch64::TBZX);
338 int *BytesRemoved)
const {
348 I->eraseFromParent();
352 if (I == MBB.
begin()) {
365 I->eraseFromParent();
372 void AArch64InstrInfo::instantiateCondBranch(
375 if (Cond[0].getImm() != -1) {
382 BuildMI(&MBB, DL,
get(Cond[1].getImm())).
add(Cond[2]);
384 MIB.
addImm(Cond[3].getImm());
393 assert(TBB &&
"insertBranch must not be told to insert a fallthrough");
399 instantiateCondBranch(MBB, DL, TBB, Cond);
408 instantiateCondBranch(MBB, DL, TBB, Cond);
432 unsigned *NewVReg =
nullptr) {
437 bool Is64Bit = AArch64::GPR64allRegClass.hasSubClassEq(MRI.
getRegClass(VReg));
440 unsigned SrcOpNum = 0;
442 case AArch64::ADDSXri:
443 case AArch64::ADDSWri:
449 case AArch64::ADDXri:
450 case AArch64::ADDWri:
456 Opc = Is64Bit ? AArch64::CSINCXr : AArch64::CSINCWr;
459 case AArch64::ORNXrr:
460 case AArch64::ORNWrr: {
463 if (ZReg != AArch64::XZR && ZReg != AArch64::WZR)
466 Opc = Is64Bit ? AArch64::CSINVXr : AArch64::CSINVWr;
470 case AArch64::SUBSXrr:
471 case AArch64::SUBSWrr:
477 case AArch64::SUBXrr:
478 case AArch64::SUBWrr: {
481 if (ZReg != AArch64::XZR && ZReg != AArch64::WZR)
484 Opc = Is64Bit ? AArch64::CSNEGXr : AArch64::CSNEGWr;
490 assert(Opc && SrcOpNum &&
"Missing parameters");
499 unsigned TrueReg,
unsigned FalseReg,
500 int &CondCycles,
int &TrueCycles,
501 int &FalseCycles)
const {
510 unsigned ExtraCondLat = Cond.
size() != 1;
514 if (AArch64::GPR64allRegClass.hasSubClassEq(RC) ||
515 AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
517 CondCycles = 1 + ExtraCondLat;
518 TrueCycles = FalseCycles = 1;
528 if (AArch64::FPR64RegClass.hasSubClassEq(RC) ||
529 AArch64::FPR32RegClass.hasSubClassEq(RC)) {
530 CondCycles = 5 + ExtraCondLat;
531 TrueCycles = FalseCycles = 2;
541 const DebugLoc &DL,
unsigned DstReg,
543 unsigned TrueReg,
unsigned FalseReg)
const {
548 switch (Cond.
size()) {
557 switch (Cond[1].getImm()) {
581 BuildMI(MBB, I, DL,
get(AArch64::SUBSXri), AArch64::XZR)
587 BuildMI(MBB, I, DL,
get(AArch64::SUBSWri), AArch64::WZR)
596 switch (Cond[1].getImm()) {
609 if (Cond[1].getImm() == AArch64::TBZW || Cond[1].getImm() == AArch64::TBNZW)
610 BuildMI(MBB, I, DL,
get(AArch64::ANDSWri), AArch64::WZR)
615 BuildMI(MBB, I, DL,
get(AArch64::ANDSXri), AArch64::XZR)
625 bool TryFold =
false;
627 RC = &AArch64::GPR64RegClass;
628 Opc = AArch64::CSELXr;
631 RC = &AArch64::GPR32RegClass;
632 Opc = AArch64::CSELWr;
635 RC = &AArch64::FPR64RegClass;
636 Opc = AArch64::FCSELDrrr;
638 RC = &AArch64::FPR32RegClass;
639 Opc = AArch64::FCSELSrrr;
641 assert(RC &&
"Unsupported regclass");
645 unsigned NewVReg = 0;
669 BuildMI(MBB, I, DL,
get(Opc), DstReg)
678 uint64_t UImm = Imm << (64 - BitSize) >> (64 - BitSize);
694 if (Opcode == AArch64::FMOVH0 ||
695 Opcode == AArch64::FMOVS0 ||
696 Opcode == AArch64::FMOVD0)
701 if (Opcode == TargetOpcode::COPY &&
710 if (isExynosCheapAsMove(MI))
723 case AArch64::ADDWri:
724 case AArch64::ADDXri:
725 case AArch64::SUBWri:
726 case AArch64::SUBXri:
730 case AArch64::ANDWri:
731 case AArch64::ANDXri:
732 case AArch64::EORWri:
733 case AArch64::EORXri:
734 case AArch64::ORRWri:
735 case AArch64::ORRXri:
739 case AArch64::ANDWrr:
740 case AArch64::ANDXrr:
741 case AArch64::BICWrr:
742 case AArch64::BICXrr:
743 case AArch64::EONWrr:
744 case AArch64::EONXrr:
745 case AArch64::EORWrr:
746 case AArch64::EORXrr:
747 case AArch64::ORNWrr:
748 case AArch64::ORNXrr:
749 case AArch64::ORRWrr:
750 case AArch64::ORRXrr:
755 case AArch64::MOVi32imm:
757 case AArch64::MOVi64imm:
769 case AArch64::ADDWrs:
770 case AArch64::ADDXrs:
771 case AArch64::ADDSWrs:
772 case AArch64::ADDSXrs: {
780 case AArch64::ADDWrx:
781 case AArch64::ADDXrx:
782 case AArch64::ADDXrx64:
783 case AArch64::ADDSWrx:
784 case AArch64::ADDSXrx:
785 case AArch64::ADDSXrx64: {
798 case AArch64::SUBWrs:
799 case AArch64::SUBSWrs: {
802 return ShiftVal == 0 ||
806 case AArch64::SUBXrs:
807 case AArch64::SUBSXrs: {
810 return ShiftVal == 0 ||
814 case AArch64::SUBWrx:
815 case AArch64::SUBXrx:
816 case AArch64::SUBXrx64:
817 case AArch64::SUBSWrx:
818 case AArch64::SUBSXrx:
819 case AArch64::SUBSXrx64: {
832 case AArch64::LDRBBroW:
833 case AArch64::LDRBBroX:
834 case AArch64::LDRBroW:
835 case AArch64::LDRBroX:
836 case AArch64::LDRDroW:
837 case AArch64::LDRDroX:
838 case AArch64::LDRHHroW:
839 case AArch64::LDRHHroX:
840 case AArch64::LDRHroW:
841 case AArch64::LDRHroX:
842 case AArch64::LDRQroW:
843 case AArch64::LDRQroX:
844 case AArch64::LDRSBWroW:
845 case AArch64::LDRSBWroX:
846 case AArch64::LDRSBXroW:
847 case AArch64::LDRSBXroX:
848 case AArch64::LDRSHWroW:
849 case AArch64::LDRSHWroX:
850 case AArch64::LDRSHXroW:
851 case AArch64::LDRSHXroX:
852 case AArch64::LDRSWroW:
853 case AArch64::LDRSWroX:
854 case AArch64::LDRSroW:
855 case AArch64::LDRSroX:
856 case AArch64::LDRWroW:
857 case AArch64::LDRWroX:
858 case AArch64::LDRXroW:
859 case AArch64::LDRXroX:
860 case AArch64::PRFMroW:
861 case AArch64::PRFMroX:
862 case AArch64::STRBBroW:
863 case AArch64::STRBBroX:
864 case AArch64::STRBroW:
865 case AArch64::STRBroX:
866 case AArch64::STRDroW:
867 case AArch64::STRDroX:
868 case AArch64::STRHHroW:
869 case AArch64::STRHHroX:
870 case AArch64::STRHroW:
871 case AArch64::STRHroX:
872 case AArch64::STRQroW:
873 case AArch64::STRQroX:
874 case AArch64::STRSroW:
875 case AArch64::STRSroX:
876 case AArch64::STRWroW:
877 case AArch64::STRWroX:
878 case AArch64::STRXroW:
879 case AArch64::STRXroX: {
891 case AArch64::SEH_StackAlloc:
892 case AArch64::SEH_SaveFPLR:
893 case AArch64::SEH_SaveFPLR_X:
894 case AArch64::SEH_SaveReg:
895 case AArch64::SEH_SaveReg_X:
896 case AArch64::SEH_SaveRegP:
897 case AArch64::SEH_SaveRegP_X:
898 case AArch64::SEH_SaveFReg:
899 case AArch64::SEH_SaveFReg_X:
900 case AArch64::SEH_SaveFRegP:
901 case AArch64::SEH_SaveFRegP_X:
902 case AArch64::SEH_SetFP:
903 case AArch64::SEH_AddFP:
904 case AArch64::SEH_Nop:
905 case AArch64::SEH_PrologEnd:
906 case AArch64::SEH_EpilogStart:
907 case AArch64::SEH_EpilogEnd:
913 unsigned &SrcReg,
unsigned &DstReg,
914 unsigned &SubIdx)
const {
918 case AArch64::SBFMXri:
919 case AArch64::UBFMXri:
927 SubIdx = AArch64::sub_32;
936 int64_t OffsetA = 0, OffsetB = 0;
937 unsigned WidthA = 0, WidthB = 0;
954 int LowOffset = OffsetA < OffsetB ? OffsetA : OffsetB;
955 int HighOffset = OffsetA < OffsetB ? OffsetB : OffsetA;
956 int LowWidth = (LowOffset == OffsetA) ? WidthA : WidthB;
957 if (LowOffset + LowWidth <= HighOffset)
988 unsigned &SrcReg2,
int &CmpMask,
989 int &CmpValue)
const {
999 case AArch64::SUBSWrr:
1000 case AArch64::SUBSWrs:
1001 case AArch64::SUBSWrx:
1002 case AArch64::SUBSXrr:
1003 case AArch64::SUBSXrs:
1004 case AArch64::SUBSXrx:
1005 case AArch64::ADDSWrr:
1006 case AArch64::ADDSWrs:
1007 case AArch64::ADDSWrx:
1008 case AArch64::ADDSXrr:
1009 case AArch64::ADDSXrs:
1010 case AArch64::ADDSXrx:
1017 case AArch64::SUBSWri:
1018 case AArch64::ADDSWri:
1019 case AArch64::SUBSXri:
1020 case AArch64::ADDSXri:
1027 case AArch64::ANDSWri:
1028 case AArch64::ANDSXri:
1041 MI.
getOpcode() == AArch64::ANDSWri ? 32 : 64) != 0;
1050 assert(MBB &&
"Can't get MachineBasicBlock here");
1052 assert(MF &&
"Can't get MachineFunction here");
1057 for (
unsigned OpIdx = 0, EndIdx = Instr.
getNumOperands(); OpIdx < EndIdx;
1064 if (!OpRegCstraints)
1072 "Operand has register constraints without being a register!");
1076 if (!OpRegCstraints->
contains(Reg))
1092 bool MIDefinesZeroReg =
false;
1094 MIDefinesZeroReg =
true;
1099 case AArch64::ADDSWrr:
1100 return AArch64::ADDWrr;
1101 case AArch64::ADDSWri:
1102 return MIDefinesZeroReg ? AArch64::ADDSWri : AArch64::ADDWri;
1103 case AArch64::ADDSWrs:
1104 return MIDefinesZeroReg ? AArch64::ADDSWrs : AArch64::ADDWrs;
1105 case AArch64::ADDSWrx:
1106 return AArch64::ADDWrx;
1107 case AArch64::ADDSXrr:
1108 return AArch64::ADDXrr;
1109 case AArch64::ADDSXri:
1110 return MIDefinesZeroReg ? AArch64::ADDSXri : AArch64::ADDXri;
1111 case AArch64::ADDSXrs:
1112 return MIDefinesZeroReg ? AArch64::ADDSXrs : AArch64::ADDXrs;
1113 case AArch64::ADDSXrx:
1114 return AArch64::ADDXrx;
1115 case AArch64::SUBSWrr:
1116 return AArch64::SUBWrr;
1117 case AArch64::SUBSWri:
1118 return MIDefinesZeroReg ? AArch64::SUBSWri : AArch64::SUBWri;
1119 case AArch64::SUBSWrs:
1120 return MIDefinesZeroReg ? AArch64::SUBSWrs : AArch64::SUBWrs;
1121 case AArch64::SUBSWrx:
1122 return AArch64::SUBWrx;
1123 case AArch64::SUBSXrr:
1124 return AArch64::SUBXrr;
1125 case AArch64::SUBSXri:
1126 return MIDefinesZeroReg ? AArch64::SUBSXri : AArch64::SUBXri;
1127 case AArch64::SUBSXrs:
1128 return MIDefinesZeroReg ? AArch64::SUBSXrs : AArch64::SUBXrs;
1129 case AArch64::SUBSXrx:
1130 return AArch64::SUBXrx;
1145 if (To == To->getParent()->begin())
1150 if (To->getParent() != From->getParent())
1156 return MI.getIterator() ==
From;
1157 }) != To->getParent()->rend());
1160 for (--To; To !=
From; --To) {
1183 MachineInstr &CmpInstr,
unsigned SrcReg,
unsigned SrcReg2,
int CmpMask,
1190 if (DeadNZCVIdx != -1) {
1205 assert(succeeded &&
"Some operands reg class are incompatible!");
1212 assert((CmpValue == 0 || CmpValue == 1) &&
"CmpValue must be 0 or 1!");
1213 if (CmpValue != 0 || SrcReg2 != 0)
1220 return substituteCmpToZero(CmpInstr, SrcReg, MRI);
1230 return AArch64::INSTRUCTION_LIST_END;
1232 case AArch64::ADDSWrr:
1233 case AArch64::ADDSWri:
1234 case AArch64::ADDSXrr:
1235 case AArch64::ADDSXri:
1236 case AArch64::SUBSWrr:
1237 case AArch64::SUBSWri:
1238 case AArch64::SUBSXrr:
1239 case AArch64::SUBSXri:
1242 case AArch64::ADDWrr:
1243 return AArch64::ADDSWrr;
1244 case AArch64::ADDWri:
1245 return AArch64::ADDSWri;
1246 case AArch64::ADDXrr:
1247 return AArch64::ADDSXrr;
1248 case AArch64::ADDXri:
1249 return AArch64::ADDSXri;
1250 case AArch64::ADCWr:
1251 return AArch64::ADCSWr;
1252 case AArch64::ADCXr:
1253 return AArch64::ADCSXr;
1254 case AArch64::SUBWrr:
1255 return AArch64::SUBSWrr;
1256 case AArch64::SUBWri:
1257 return AArch64::SUBSWri;
1258 case AArch64::SUBXrr:
1259 return AArch64::SUBSXrr;
1260 case AArch64::SUBXri:
1261 return AArch64::SUBSXri;
1262 case AArch64::SBCWr:
1263 return AArch64::SBCSWr;
1264 case AArch64::SBCXr:
1265 return AArch64::SBCSXr;
1266 case AArch64::ANDWri:
1267 return AArch64::ANDSWri;
1268 case AArch64::ANDXri:
1269 return AArch64::ANDSXri;
1276 if (BB->isLiveIn(AArch64::NZCV))
1289 UsedNZCV() =
default;
1291 UsedNZCV &
operator|=(
const UsedNZCV &UsedFlags) {
1292 this->N |= UsedFlags.N;
1293 this->Z |= UsedFlags.Z;
1294 this->C |= UsedFlags.C;
1295 this->V |= UsedFlags.V;
1310 case AArch64::Bcc: {
1316 case AArch64::CSINVWr:
1317 case AArch64::CSINVXr:
1318 case AArch64::CSINCWr:
1319 case AArch64::CSINCXr:
1320 case AArch64::CSELWr:
1321 case AArch64::CSELXr:
1322 case AArch64::CSNEGWr:
1323 case AArch64::CSNEGXr:
1324 case AArch64::FCSELSrrr:
1325 case AArch64::FCSELDrrr: {
1378 return Opcode == AArch64::ADDSWri || Opcode == AArch64::ADDSXri;
1382 return Opcode == AArch64::SUBSWri || Opcode == AArch64::SUBSXri;
1399 assert(
sForm(*MI) != AArch64::INSTRUCTION_LIST_END);
1402 const unsigned CmpOpcode = CmpInstr->
getOpcode();
1418 UsedNZCV NZCVUsedAfterCmp;
1434 return !NZCVUsedAfterCmp.C && !NZCVUsedAfterCmp.V;
1441 bool AArch64InstrInfo::substituteCmpToZero(
1452 unsigned NewOpc =
sForm(*MI);
1453 if (NewOpc == AArch64::INSTRUCTION_LIST_END)
1464 assert(succeeded &&
"Some operands reg class are incompatible!");
1470 if (MI.
getOpcode() != TargetOpcode::LOAD_STACK_GUARD &&
1476 auto TRI = Subtarget.getRegisterInfo();
1487 FirstEpilogSEH != MBB.
begin())
1488 FirstEpilogSEH = std::prev(FirstEpilogSEH);
1489 if (FirstEpilogSEH != MBB.
begin())
1490 FirstEpilogSEH = std::next(FirstEpilogSEH);
1494 BuildMI(MBB, FirstEpilogSEH, DL, TII->
get(AArch64::ADDXri))
1506 unsigned OpFlags = Subtarget.ClassifyGlobalReference(GV, TM);
1512 if (Subtarget.isTargetILP32()) {
1513 unsigned Reg32 = TRI->getSubReg(Reg, AArch64::sub_32);
1514 BuildMI(MBB, MI, DL,
get(AArch64::LDRWui))
1521 BuildMI(MBB, MI, DL,
get(AArch64::LDRXui), Reg)
1527 assert(!Subtarget.isTargetILP32() &&
"how can large exist in ILP32?");
1528 BuildMI(MBB, MI, DL,
get(AArch64::MOVZXi), Reg)
1531 BuildMI(MBB, MI, DL,
get(AArch64::MOVKXi), Reg)
1535 BuildMI(MBB, MI, DL,
get(AArch64::MOVKXi), Reg)
1539 BuildMI(MBB, MI, DL,
get(AArch64::MOVKXi), Reg)
1543 BuildMI(MBB, MI, DL,
get(AArch64::LDRXui), Reg)
1554 if (Subtarget.isTargetILP32()) {
1555 unsigned Reg32 = TRI->getSubReg(Reg, AArch64::sub_32);
1556 BuildMI(MBB, MI, DL,
get(AArch64::LDRWui))
1563 BuildMI(MBB, MI, DL,
get(AArch64::LDRXui), Reg)
1581 case AArch64::MOVZWi:
1582 case AArch64::MOVZXi:
1589 case AArch64::ANDWri:
1591 case AArch64::ANDXri:
1593 case TargetOpcode::COPY:
1605 case TargetOpcode::COPY: {
1608 return (AArch64::GPR32RegClass.
contains(DstReg) ||
1609 AArch64::GPR64RegClass.
contains(DstReg));
1611 case AArch64::ORRXrs:
1618 case AArch64::ADDXri:
1635 case TargetOpcode::COPY: {
1638 return (AArch64::FPR64RegClass.
contains(DstReg) ||
1639 AArch64::FPR128RegClass.
contains(DstReg));
1641 case AArch64::ORRv16i8:
1644 "invalid ORRv16i8 operands");
1657 case AArch64::LDRWui:
1658 case AArch64::LDRXui:
1659 case AArch64::LDRBui:
1660 case AArch64::LDRHui:
1661 case AArch64::LDRSui:
1662 case AArch64::LDRDui:
1663 case AArch64::LDRQui:
1680 case AArch64::STRWui:
1681 case AArch64::STRXui:
1682 case AArch64::STRBui:
1683 case AArch64::STRHui:
1684 case AArch64::STRSui:
1685 case AArch64::STRDui:
1686 case AArch64::STRQui:
1722 case AArch64::STURSi:
1723 case AArch64::STURDi:
1724 case AArch64::STURQi:
1725 case AArch64::STURBBi:
1726 case AArch64::STURHHi:
1727 case AArch64::STURWi:
1728 case AArch64::STURXi:
1729 case AArch64::LDURSi:
1730 case AArch64::LDURDi:
1731 case AArch64::LDURQi:
1732 case AArch64::LDURWi:
1733 case AArch64::LDURXi:
1734 case AArch64::LDURSWi:
1735 case AArch64::LDURHHi:
1736 case AArch64::LDURBBi:
1737 case AArch64::LDURSBWi:
1738 case AArch64::LDURSHWi:
1746 case AArch64::PRFMui:
return AArch64::PRFUMi;
1747 case AArch64::LDRXui:
return AArch64::LDURXi;
1748 case AArch64::LDRWui:
return AArch64::LDURWi;
1749 case AArch64::LDRBui:
return AArch64::LDURBi;
1750 case AArch64::LDRHui:
return AArch64::LDURHi;
1751 case AArch64::LDRSui:
return AArch64::LDURSi;
1752 case AArch64::LDRDui:
return AArch64::LDURDi;
1753 case AArch64::LDRQui:
return AArch64::LDURQi;
1754 case AArch64::LDRBBui:
return AArch64::LDURBBi;
1755 case AArch64::LDRHHui:
return AArch64::LDURHHi;
1756 case AArch64::LDRSBXui:
return AArch64::LDURSBXi;
1757 case AArch64::LDRSBWui:
return AArch64::LDURSBWi;
1758 case AArch64::LDRSHXui:
return AArch64::LDURSHXi;
1759 case AArch64::LDRSHWui:
return AArch64::LDURSHWi;
1760 case AArch64::LDRSWui:
return AArch64::LDURSWi;
1761 case AArch64::STRXui:
return AArch64::STURXi;
1762 case AArch64::STRWui:
return AArch64::STURWi;
1763 case AArch64::STRBui:
return AArch64::STURBi;
1764 case AArch64::STRHui:
return AArch64::STURHi;
1765 case AArch64::STRSui:
return AArch64::STURSi;
1766 case AArch64::STRDui:
return AArch64::STURDi;
1767 case AArch64::STRQui:
return AArch64::STURQi;
1768 case AArch64::STRBBui:
return AArch64::STURBBi;
1769 case AArch64::STRHHui:
return AArch64::STURHHi;
1777 case AArch64::LDPXi:
1778 case AArch64::LDPDi:
1779 case AArch64::STPXi:
1780 case AArch64::STPDi:
1781 case AArch64::LDNPXi:
1782 case AArch64::LDNPDi:
1783 case AArch64::STNPXi:
1784 case AArch64::STNPDi:
1785 case AArch64::LDPQi:
1786 case AArch64::STPQi:
1787 case AArch64::LDNPQi:
1788 case AArch64::STNPQi:
1789 case AArch64::LDPWi:
1790 case AArch64::LDPSi:
1791 case AArch64::STPWi:
1792 case AArch64::STPSi:
1793 case AArch64::LDNPWi:
1794 case AArch64::LDNPSi:
1795 case AArch64::STNPWi:
1796 case AArch64::STNPSi:
1798 case AArch64::STGPi:
1801 case AArch64::STGOffset:
1811 case AArch64::STRSui:
1812 case AArch64::STRDui:
1813 case AArch64::STRQui:
1814 case AArch64::STRXui:
1815 case AArch64::STRWui:
1816 case AArch64::LDRSui:
1817 case AArch64::LDRDui:
1818 case AArch64::LDRQui:
1819 case AArch64::LDRXui:
1820 case AArch64::LDRWui:
1821 case AArch64::LDRSWui:
1823 case AArch64::STURSi:
1824 case AArch64::STURDi:
1825 case AArch64::STURQi:
1826 case AArch64::STURWi:
1827 case AArch64::STURXi:
1828 case AArch64::LDURSi:
1829 case AArch64::LDURDi:
1830 case AArch64::LDURQi:
1831 case AArch64::LDURWi:
1832 case AArch64::LDURXi:
1833 case AArch64::LDURSWi:
1844 case AArch64::ADDWri:
1846 return AArch64::ADDSWri;
1847 case AArch64::ADDWrr:
1849 return AArch64::ADDSWrr;
1850 case AArch64::ADDWrs:
1852 return AArch64::ADDSWrs;
1853 case AArch64::ADDWrx:
1855 return AArch64::ADDSWrx;
1856 case AArch64::ANDWri:
1858 return AArch64::ANDSWri;
1859 case AArch64::ANDWrr:
1861 return AArch64::ANDSWrr;
1862 case AArch64::ANDWrs:
1864 return AArch64::ANDSWrs;
1865 case AArch64::BICWrr:
1867 return AArch64::BICSWrr;
1868 case AArch64::BICWrs:
1870 return AArch64::BICSWrs;
1871 case AArch64::SUBWri:
1873 return AArch64::SUBSWri;
1874 case AArch64::SUBWrr:
1876 return AArch64::SUBSWrr;
1877 case AArch64::SUBWrs:
1879 return AArch64::SUBSWrs;
1880 case AArch64::SUBWrx:
1882 return AArch64::SUBSWrx;
1884 case AArch64::ADDXri:
1886 return AArch64::ADDSXri;
1887 case AArch64::ADDXrr:
1889 return AArch64::ADDSXrr;
1890 case AArch64::ADDXrs:
1892 return AArch64::ADDSXrs;
1893 case AArch64::ADDXrx:
1895 return AArch64::ADDSXrx;
1896 case AArch64::ANDXri:
1898 return AArch64::ANDSXri;
1899 case AArch64::ANDXrr:
1901 return AArch64::ANDSXrr;
1902 case AArch64::ANDXrs:
1904 return AArch64::ANDSXrs;
1905 case AArch64::BICXrr:
1907 return AArch64::BICSXrr;
1908 case AArch64::BICXrs:
1910 return AArch64::BICSXrs;
1911 case AArch64::SUBXri:
1913 return AArch64::SUBSXri;
1914 case AArch64::SUBXrr:
1916 return AArch64::SUBSXrr;
1917 case AArch64::SUBXrs:
1919 return AArch64::SUBSXrs;
1920 case AArch64::SUBXrx:
1922 return AArch64::SUBSXrx;
1935 "Expected a reg or frame index operand.");
1966 if (Subtarget.isPaired128Slow()) {
1970 case AArch64::LDURQi:
1971 case AArch64::STURQi:
1972 case AArch64::LDRQui:
1973 case AArch64::STRQui:
2014 int64_t Dummy1, Dummy2;
2032 if (!BaseOp->
isReg() && !BaseOp->
isFI())
2042 assert(OfsOp.isImm() &&
"Offset operand wasn't immediate.");
2047 unsigned &
Width, int64_t &MinOffset,
2048 int64_t &MaxOffset) {
2053 MinOffset = MaxOffset = 0;
2055 case AArch64::STRWpost:
2056 case AArch64::LDRWpost:
2062 case AArch64::LDURQi:
2063 case AArch64::STURQi:
2069 case AArch64::PRFUMi:
2070 case AArch64::LDURXi:
2071 case AArch64::LDURDi:
2072 case AArch64::STURXi:
2073 case AArch64::STURDi:
2079 case AArch64::LDURWi:
2080 case AArch64::LDURSi:
2081 case AArch64::LDURSWi:
2082 case AArch64::STURWi:
2083 case AArch64::STURSi:
2089 case AArch64::LDURHi:
2090 case AArch64::LDURHHi:
2091 case AArch64::LDURSHXi:
2092 case AArch64::LDURSHWi:
2093 case AArch64::STURHi:
2094 case AArch64::STURHHi:
2100 case AArch64::LDURBi:
2101 case AArch64::LDURBBi:
2102 case AArch64::LDURSBXi:
2103 case AArch64::LDURSBWi:
2104 case AArch64::STURBi:
2105 case AArch64::STURBBi:
2111 case AArch64::LDPQi:
2112 case AArch64::LDNPQi:
2113 case AArch64::STPQi:
2114 case AArch64::STNPQi:
2120 case AArch64::LDRQui:
2121 case AArch64::STRQui:
2126 case AArch64::LDPXi:
2127 case AArch64::LDPDi:
2128 case AArch64::LDNPXi:
2129 case AArch64::LDNPDi:
2130 case AArch64::STPXi:
2131 case AArch64::STPDi:
2132 case AArch64::STNPXi:
2133 case AArch64::STNPDi:
2139 case AArch64::PRFMui:
2140 case AArch64::LDRXui:
2141 case AArch64::LDRDui:
2142 case AArch64::STRXui:
2143 case AArch64::STRDui:
2148 case AArch64::LDPWi:
2149 case AArch64::LDPSi:
2150 case AArch64::LDNPWi:
2151 case AArch64::LDNPSi:
2152 case AArch64::STPWi:
2153 case AArch64::STPSi:
2154 case AArch64::STNPWi:
2155 case AArch64::STNPSi:
2161 case AArch64::LDRWui:
2162 case AArch64::LDRSui:
2163 case AArch64::LDRSWui:
2164 case AArch64::STRWui:
2165 case AArch64::STRSui:
2170 case AArch64::LDRHui:
2171 case AArch64::LDRHHui:
2172 case AArch64::LDRSHWui:
2173 case AArch64::LDRSHXui:
2174 case AArch64::STRHui:
2175 case AArch64::STRHHui:
2180 case AArch64::LDRBui:
2181 case AArch64::LDRBBui:
2182 case AArch64::LDRSBWui:
2183 case AArch64::LDRSBXui:
2184 case AArch64::STRBui:
2185 case AArch64::STRBBui:
2196 case AArch64::TAGPstack:
2205 case AArch64::STGOffset:
2206 case AArch64::STZGOffset:
2211 case AArch64::LDR_PXI:
2212 case AArch64::STR_PXI:
2217 case AArch64::LDR_ZXI:
2218 case AArch64::STR_ZXI:
2223 case AArch64::ST2GOffset:
2224 case AArch64::STZ2GOffset:
2230 case AArch64::STGPi:
2245 case AArch64::LDRBBui:
2246 case AArch64::LDURBBi:
2247 case AArch64::LDRSBWui:
2248 case AArch64::LDURSBWi:
2249 case AArch64::STRBBui:
2250 case AArch64::STURBBi:
2252 case AArch64::LDRHHui:
2253 case AArch64::LDURHHi:
2254 case AArch64::LDRSHWui:
2255 case AArch64::LDURSHWi:
2256 case AArch64::STRHHui:
2257 case AArch64::STURHHi:
2259 case AArch64::LDRSui:
2260 case AArch64::LDURSi:
2261 case AArch64::LDRSWui:
2262 case AArch64::LDURSWi:
2263 case AArch64::LDRWui:
2264 case AArch64::LDURWi:
2265 case AArch64::STRSui:
2266 case AArch64::STURSi:
2267 case AArch64::STRWui:
2268 case AArch64::STURWi:
2269 case AArch64::LDPSi:
2270 case AArch64::LDPSWi:
2271 case AArch64::LDPWi:
2272 case AArch64::STPSi:
2273 case AArch64::STPWi:
2275 case AArch64::LDRDui:
2276 case AArch64::LDURDi:
2277 case AArch64::LDRXui:
2278 case AArch64::LDURXi:
2279 case AArch64::STRDui:
2280 case AArch64::STURDi:
2281 case AArch64::STRXui:
2282 case AArch64::STURXi:
2283 case AArch64::LDPDi:
2284 case AArch64::LDPXi:
2285 case AArch64::STPDi:
2286 case AArch64::STPXi:
2288 case AArch64::LDRQui:
2289 case AArch64::LDURQi:
2290 case AArch64::STRQui:
2291 case AArch64::STURQi:
2292 case AArch64::LDPQi:
2293 case AArch64::STPQi:
2294 case AArch64::STGOffset:
2295 case AArch64::STZGOffset:
2296 case AArch64::ST2GOffset:
2297 case AArch64::STZ2GOffset:
2298 case AArch64::STGPi:
2310 if (Offset % Scale != 0)
2320 if (FirstOpc == SecondOpc)
2326 case AArch64::LDRWui:
2327 case AArch64::LDURWi:
2328 return SecondOpc == AArch64::LDRSWui || SecondOpc == AArch64::LDURSWi;
2329 case AArch64::LDRSWui:
2330 case AArch64::LDURSWi:
2331 return SecondOpc == AArch64::LDRWui || SecondOpc == AArch64::LDURWi;
2338 int64_t Offset1,
unsigned Opcode1,
int FI2,
2339 int64_t Offset2,
unsigned Opcode2) {
2345 assert(ObjectOffset1 <= ObjectOffset2 &&
"Object offsets are not ordered.");
2348 if (ObjectOffset1 % Scale1 != 0)
2350 ObjectOffset1 /= Scale1;
2352 if (ObjectOffset2 % Scale2 != 0)
2354 ObjectOffset2 /= Scale2;
2355 ObjectOffset1 += Offset1;
2356 ObjectOffset2 += Offset2;
2357 return ObjectOffset1 + 1 == ObjectOffset2;
2368 unsigned NumLoads)
const {
2375 "Only base registers and frame indices are supported.");
2389 unsigned FirstOpc = FirstLdSt.
getOpcode();
2390 unsigned SecondOpc = SecondLdSt.
getOpcode();
2410 if (Offset1 > 63 || Offset1 < -64)
2415 if (BaseOp1.
isFI()) {
2417 "Caller should have ordered offsets.");
2422 BaseOp2.
getIndex(), Offset2, SecondOpc);
2425 assert(Offset1 <= Offset2 &&
"Caller should have ordered offsets.");
2427 return Offset1 + 1 == Offset2;
2431 unsigned Reg,
unsigned SubIdx,
2435 return MIB.
addReg(Reg, State);
2439 return MIB.
addReg(Reg, State, SubIdx);
2446 return ((DestReg - SrcReg) & 0x1f) < NumRegs;
2455 assert(Subtarget.hasNEON() &&
"Unexpected register copy without NEON");
2457 uint16_t DestEncoding = TRI->getEncodingValue(DestReg);
2458 uint16_t SrcEncoding = TRI->getEncodingValue(SrcReg);
2459 unsigned NumRegs = Indices.
size();
2461 int SubReg = 0, End = NumRegs, Incr = 1;
2463 SubReg = NumRegs - 1;
2468 for (; SubReg != End; SubReg += Incr) {
2471 AddSubReg(MIB, SrcReg, Indices[SubReg], 0, TRI);
2479 unsigned SrcReg,
bool KillSrc,
2480 unsigned Opcode,
unsigned ZeroReg,
2483 unsigned NumRegs = Indices.
size();
2488 assert(DestEncoding % NumRegs == 0 && SrcEncoding % NumRegs == 0 &&
2489 "GPR reg sequences should not be able to overlap");
2505 if (AArch64::GPR32spRegClass.
contains(DestReg) &&
2506 (AArch64::GPR32spRegClass.
contains(SrcReg) || SrcReg == AArch64::WZR)) {
2509 if (DestReg == AArch64::WSP || SrcReg == AArch64::WSP) {
2511 if (Subtarget.hasZeroCycleRegMove()) {
2514 DestReg, AArch64::sub_32, &AArch64::GPR64spRegClass);
2516 SrcReg, AArch64::sub_32, &AArch64::GPR64spRegClass);
2521 BuildMI(MBB, I, DL,
get(AArch64::ADDXri), DestRegX)
2527 BuildMI(MBB, I, DL,
get(AArch64::ADDWri), DestReg)
2532 }
else if (SrcReg == AArch64::WZR && Subtarget.hasZeroCycleZeroingGP()) {
2533 BuildMI(MBB, I, DL,
get(AArch64::MOVZWi), DestReg)
2537 if (Subtarget.hasZeroCycleRegMove()) {
2540 DestReg, AArch64::sub_32, &AArch64::GPR64spRegClass);
2542 SrcReg, AArch64::sub_32, &AArch64::GPR64spRegClass);
2547 BuildMI(MBB, I, DL,
get(AArch64::ORRXrr), DestRegX)
2553 BuildMI(MBB, I, DL,
get(AArch64::ORRWrr), DestReg)
2562 if (AArch64::PPRRegClass.
contains(DestReg) &&
2563 AArch64::PPRRegClass.
contains(SrcReg)) {
2564 assert(Subtarget.hasSVE() &&
"Unexpected SVE register.");
2565 BuildMI(MBB, I, DL,
get(AArch64::ORR_PPzPP), DestReg)
2573 if (AArch64::ZPRRegClass.
contains(DestReg) &&
2574 AArch64::ZPRRegClass.
contains(SrcReg)) {
2575 assert(Subtarget.hasSVE() &&
"Unexpected SVE register.");
2576 BuildMI(MBB, I, DL,
get(AArch64::ORR_ZZZ), DestReg)
2582 if (AArch64::GPR64spRegClass.
contains(DestReg) &&
2583 (AArch64::GPR64spRegClass.
contains(SrcReg) || SrcReg == AArch64::XZR)) {
2584 if (DestReg == AArch64::SP || SrcReg == AArch64::SP) {
2586 BuildMI(MBB, I, DL,
get(AArch64::ADDXri), DestReg)
2590 }
else if (SrcReg == AArch64::XZR && Subtarget.hasZeroCycleZeroingGP()) {
2591 BuildMI(MBB, I, DL,
get(AArch64::MOVZXi), DestReg)
2596 BuildMI(MBB, I, DL,
get(AArch64::ORRXrr), DestReg)
2604 if (AArch64::DDDDRegClass.
contains(DestReg) &&
2605 AArch64::DDDDRegClass.
contains(SrcReg)) {
2606 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1,
2607 AArch64::dsub2, AArch64::dsub3};
2614 if (AArch64::DDDRegClass.
contains(DestReg) &&
2615 AArch64::DDDRegClass.
contains(SrcReg)) {
2616 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1,
2624 if (AArch64::DDRegClass.
contains(DestReg) &&
2625 AArch64::DDRegClass.
contains(SrcReg)) {
2626 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1};
2633 if (AArch64::QQQQRegClass.
contains(DestReg) &&
2634 AArch64::QQQQRegClass.
contains(SrcReg)) {
2635 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1,
2636 AArch64::qsub2, AArch64::qsub3};
2643 if (AArch64::QQQRegClass.
contains(DestReg) &&
2644 AArch64::QQQRegClass.
contains(SrcReg)) {
2645 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1,
2653 if (AArch64::QQRegClass.
contains(DestReg) &&
2654 AArch64::QQRegClass.
contains(SrcReg)) {
2655 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1};
2661 if (AArch64::XSeqPairsClassRegClass.
contains(DestReg) &&
2662 AArch64::XSeqPairsClassRegClass.
contains(SrcReg)) {
2663 static const unsigned Indices[] = {AArch64::sube64, AArch64::subo64};
2664 copyGPRRegTuple(MBB, I, DL, DestReg, SrcReg, KillSrc, AArch64::ORRXrs,
2665 AArch64::XZR, Indices);
2669 if (AArch64::WSeqPairsClassRegClass.
contains(DestReg) &&
2670 AArch64::WSeqPairsClassRegClass.
contains(SrcReg)) {
2671 static const unsigned Indices[] = {AArch64::sube32, AArch64::subo32};
2672 copyGPRRegTuple(MBB, I, DL, DestReg, SrcReg, KillSrc, AArch64::ORRWrs,
2673 AArch64::WZR, Indices);
2677 if (AArch64::FPR128RegClass.
contains(DestReg) &&
2678 AArch64::FPR128RegClass.
contains(SrcReg)) {
2679 if (Subtarget.hasNEON()) {
2680 BuildMI(MBB, I, DL,
get(AArch64::ORRv16i8), DestReg)
2684 BuildMI(MBB, I, DL,
get(AArch64::STRQpre))
2689 BuildMI(MBB, I, DL,
get(AArch64::LDRQpre))
2698 if (AArch64::FPR64RegClass.
contains(DestReg) &&
2699 AArch64::FPR64RegClass.
contains(SrcReg)) {
2700 if (Subtarget.hasNEON()) {
2701 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::dsub,
2702 &AArch64::FPR128RegClass);
2703 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::dsub,
2704 &AArch64::FPR128RegClass);
2705 BuildMI(MBB, I, DL,
get(AArch64::ORRv16i8), DestReg)
2709 BuildMI(MBB, I, DL,
get(AArch64::FMOVDr), DestReg)
2715 if (AArch64::FPR32RegClass.
contains(DestReg) &&
2716 AArch64::FPR32RegClass.
contains(SrcReg)) {
2717 if (Subtarget.hasNEON()) {
2718 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::ssub,
2719 &AArch64::FPR128RegClass);
2720 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::ssub,
2721 &AArch64::FPR128RegClass);
2722 BuildMI(MBB, I, DL,
get(AArch64::ORRv16i8), DestReg)
2726 BuildMI(MBB, I, DL,
get(AArch64::FMOVSr), DestReg)
2732 if (AArch64::FPR16RegClass.
contains(DestReg) &&
2733 AArch64::FPR16RegClass.
contains(SrcReg)) {
2734 if (Subtarget.hasNEON()) {
2735 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
2736 &AArch64::FPR128RegClass);
2737 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
2738 &AArch64::FPR128RegClass);
2739 BuildMI(MBB, I, DL,
get(AArch64::ORRv16i8), DestReg)
2743 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
2744 &AArch64::FPR32RegClass);
2745 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
2746 &AArch64::FPR32RegClass);
2747 BuildMI(MBB, I, DL,
get(AArch64::FMOVSr), DestReg)
2753 if (AArch64::FPR8RegClass.
contains(DestReg) &&
2754 AArch64::FPR8RegClass.
contains(SrcReg)) {
2755 if (Subtarget.hasNEON()) {
2756 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
2757 &AArch64::FPR128RegClass);
2758 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
2759 &AArch64::FPR128RegClass);
2760 BuildMI(MBB, I, DL,
get(AArch64::ORRv16i8), DestReg)
2764 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
2765 &AArch64::FPR32RegClass);
2766 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
2767 &AArch64::FPR32RegClass);
2768 BuildMI(MBB, I, DL,
get(AArch64::FMOVSr), DestReg)
2775 if (AArch64::FPR64RegClass.
contains(DestReg) &&
2776 AArch64::GPR64RegClass.
contains(SrcReg)) {
2777 BuildMI(MBB, I, DL,
get(AArch64::FMOVXDr), DestReg)
2781 if (AArch64::GPR64RegClass.
contains(DestReg) &&
2782 AArch64::FPR64RegClass.
contains(SrcReg)) {
2783 BuildMI(MBB, I, DL,
get(AArch64::FMOVDXr), DestReg)
2788 if (AArch64::FPR32RegClass.
contains(DestReg) &&
2789 AArch64::GPR32RegClass.
contains(SrcReg)) {
2790 BuildMI(MBB, I, DL,
get(AArch64::FMOVWSr), DestReg)
2794 if (AArch64::GPR32RegClass.
contains(DestReg) &&
2795 AArch64::FPR32RegClass.
contains(SrcReg)) {
2796 BuildMI(MBB, I, DL,
get(AArch64::FMOVSWr), DestReg)
2801 if (DestReg == AArch64::NZCV) {
2802 assert(AArch64::GPR64RegClass.
contains(SrcReg) &&
"Invalid NZCV copy");
2803 BuildMI(MBB, I, DL,
get(AArch64::MSR))
2804 .
addImm(AArch64SysReg::NZCV)
2810 if (SrcReg == AArch64::NZCV) {
2811 assert(AArch64::GPR64RegClass.
contains(DestReg) &&
"Invalid NZCV copy");
2812 BuildMI(MBB, I, DL,
get(AArch64::MRS), DestReg)
2813 .
addImm(AArch64SysReg::NZCV)
2825 unsigned SrcReg,
bool IsKill,
2826 unsigned SubIdx0,
unsigned SubIdx1,
int FI,
2828 unsigned SrcReg0 = SrcReg;
2829 unsigned SrcReg1 = SrcReg;
2831 SrcReg0 = TRI.
getSubReg(SrcReg, SubIdx0);
2833 SrcReg1 = TRI.
getSubReg(SrcReg, SubIdx1);
2859 if (AArch64::FPR8RegClass.hasSubClassEq(RC))
2860 Opc = AArch64::STRBui;
2863 if (AArch64::FPR16RegClass.hasSubClassEq(RC))
2864 Opc = AArch64::STRHui;
2867 if (AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
2868 Opc = AArch64::STRWui;
2872 assert(SrcReg != AArch64::WSP);
2873 }
else if (AArch64::FPR32RegClass.hasSubClassEq(RC))
2874 Opc = AArch64::STRSui;
2877 if (AArch64::GPR64allRegClass.hasSubClassEq(RC)) {
2878 Opc = AArch64::STRXui;
2882 assert(SrcReg != AArch64::SP);
2883 }
else if (AArch64::FPR64RegClass.hasSubClassEq(RC)) {
2884 Opc = AArch64::STRDui;
2885 }
else if (AArch64::WSeqPairsClassRegClass.hasSubClassEq(RC)) {
2887 get(AArch64::STPWi), SrcReg, isKill,
2888 AArch64::sube32, AArch64::subo32, FI, MMO);
2893 if (AArch64::FPR128RegClass.hasSubClassEq(RC))
2894 Opc = AArch64::STRQui;
2895 else if (AArch64::DDRegClass.hasSubClassEq(RC)) {
2896 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
2897 Opc = AArch64::ST1Twov1d;
2899 }
else if (AArch64::XSeqPairsClassRegClass.hasSubClassEq(RC)) {
2901 get(AArch64::STPXi), SrcReg, isKill,
2902 AArch64::sube64, AArch64::subo64, FI, MMO);
2907 if (AArch64::DDDRegClass.hasSubClassEq(RC)) {
2908 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
2909 Opc = AArch64::ST1Threev1d;
2914 if (AArch64::DDDDRegClass.hasSubClassEq(RC)) {
2915 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
2916 Opc = AArch64::ST1Fourv1d;
2918 }
else if (AArch64::QQRegClass.hasSubClassEq(RC)) {
2919 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
2920 Opc = AArch64::ST1Twov2d;
2925 if (AArch64::QQQRegClass.hasSubClassEq(RC)) {
2926 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
2927 Opc = AArch64::ST1Threev2d;
2932 if (AArch64::QQQQRegClass.hasSubClassEq(RC)) {
2933 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
2934 Opc = AArch64::ST1Fourv2d;
2940 if (AArch64::PPRRegClass.hasSubClassEq(RC)) {
2941 assert(Subtarget.hasSVE() &&
"Unexpected register store without SVE");
2942 Opc = AArch64::STR_PXI;
2944 }
else if (AArch64::ZPRRegClass.hasSubClassEq(RC)) {
2945 assert(Subtarget.hasSVE() &&
"Unexpected register store without SVE");
2946 Opc = AArch64::STR_ZXI;
2949 assert(Opc &&
"Unknown register class");
2965 unsigned DestReg,
unsigned SubIdx0,
2966 unsigned SubIdx1,
int FI,
2968 unsigned DestReg0 = DestReg;
2969 unsigned DestReg1 = DestReg;
2970 bool IsUndef =
true;
2972 DestReg0 = TRI.
getSubReg(DestReg, SubIdx0);
2974 DestReg1 = TRI.
getSubReg(DestReg, SubIdx1);
3001 if (AArch64::FPR8RegClass.hasSubClassEq(RC))
3002 Opc = AArch64::LDRBui;
3005 if (AArch64::FPR16RegClass.hasSubClassEq(RC))
3006 Opc = AArch64::LDRHui;
3009 if (AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
3010 Opc = AArch64::LDRWui;
3014 assert(DestReg != AArch64::WSP);
3015 }
else if (AArch64::FPR32RegClass.hasSubClassEq(RC))
3016 Opc = AArch64::LDRSui;
3019 if (AArch64::GPR64allRegClass.hasSubClassEq(RC)) {
3020 Opc = AArch64::LDRXui;
3024 assert(DestReg != AArch64::SP);
3025 }
else if (AArch64::FPR64RegClass.hasSubClassEq(RC)) {
3026 Opc = AArch64::LDRDui;
3027 }
else if (AArch64::WSeqPairsClassRegClass.hasSubClassEq(RC)) {
3029 get(AArch64::LDPWi), DestReg, AArch64::sube32,
3030 AArch64::subo32, FI, MMO);
3035 if (AArch64::FPR128RegClass.hasSubClassEq(RC))
3036 Opc = AArch64::LDRQui;
3037 else if (AArch64::DDRegClass.hasSubClassEq(RC)) {
3038 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
3039 Opc = AArch64::LD1Twov1d;
3041 }
else if (AArch64::XSeqPairsClassRegClass.hasSubClassEq(RC)) {
3043 get(AArch64::LDPXi), DestReg, AArch64::sube64,
3044 AArch64::subo64, FI, MMO);
3049 if (AArch64::DDDRegClass.hasSubClassEq(RC)) {
3050 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
3051 Opc = AArch64::LD1Threev1d;
3056 if (AArch64::DDDDRegClass.hasSubClassEq(RC)) {
3057 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
3058 Opc = AArch64::LD1Fourv1d;
3060 }
else if (AArch64::QQRegClass.hasSubClassEq(RC)) {
3061 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
3062 Opc = AArch64::LD1Twov2d;
3067 if (AArch64::QQQRegClass.hasSubClassEq(RC)) {
3068 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
3069 Opc = AArch64::LD1Threev2d;
3074 if (AArch64::QQQQRegClass.hasSubClassEq(RC)) {
3075 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
3076 Opc = AArch64::LD1Fourv2d;
3083 if (AArch64::PPRRegClass.hasSubClassEq(RC)) {
3084 assert(Subtarget.hasSVE() &&
"Unexpected register load without SVE");
3085 Opc = AArch64::LDR_PXI;
3087 }
else if (AArch64::ZPRRegClass.hasSubClassEq(RC)) {
3088 assert(Subtarget.hasSVE() &&
"Unexpected register load without SVE");
3089 Opc = AArch64::LDR_ZXI;
3092 assert(Opc &&
"Unknown register class");
3108 const DebugLoc &DL,
unsigned DestReg,
3109 unsigned SrcReg, int64_t
Offset,
unsigned Opc,
3114 unsigned MaxEncoding, ShiftSize;
3116 case AArch64::ADDXri:
3117 case AArch64::ADDSXri:
3118 case AArch64::SUBXri:
3119 case AArch64::SUBSXri:
3120 MaxEncoding = 0xfff;
3123 case AArch64::ADDVL_XXI:
3124 case AArch64::ADDPL_XXI:
3148 const unsigned MaxEncodableValue = MaxEncoding << ShiftSize;
3150 uint64_t ThisVal = std::min<uint64_t>(
Offset, MaxEncodableValue);
3151 unsigned LocalShiftSize = 0;
3152 if (ThisVal > MaxEncoding) {
3153 ThisVal = ThisVal >> ShiftSize;
3154 LocalShiftSize = ShiftSize;
3156 assert((ThisVal >> ShiftSize) <= MaxEncoding &&
3157 "Encoding cannot handle value that big");
3158 auto MBI =
BuildMI(MBB, MBBI, DL, TII->
get(Opc), DestReg)
3160 .
addImm(Sign * (
int)ThisVal);
3167 assert(Sign == 1 &&
"SEH directives should always have a positive sign");
3168 int Imm = (int)(ThisVal << LocalShiftSize);
3169 if ((DestReg == AArch64::FP && SrcReg == AArch64::SP) ||
3170 (SrcReg == AArch64::FP && DestReg == AArch64::SP)) {
3174 BuildMI(MBB, MBBI, DL, TII->
get(AArch64::SEH_SetFP)).setMIFlag(Flag);
3176 BuildMI(MBB, MBBI, DL, TII->
get(AArch64::SEH_AddFP))
3179 assert((Offset - Imm) == 0 &&
"Expected remaining offset to be zero to " 3180 "emit a single SEH directive");
3181 }
else if (DestReg == AArch64::SP) {
3184 assert(SrcReg == AArch64::SP &&
"Unexpected SrcReg for SEH_StackAlloc");
3185 BuildMI(MBB, MBBI, DL, TII->
get(AArch64::SEH_StackAlloc))
3194 Offset -= ThisVal << LocalShiftSize;
3200 unsigned DestReg,
unsigned SrcReg,
3203 bool NeedsWinCFI,
bool *HasWinCFI) {
3204 int64_t Bytes, NumPredicateVectors, NumDataVectors;
3208 if (Bytes || (!Offset && SrcReg != DestReg)) {
3209 assert((DestReg != AArch64::SP || Bytes % 16 == 0) &&
3210 "SP increment/decrement not 16-byte aligned");
3211 unsigned Opc = SetNZCV ? AArch64::ADDSXri : AArch64::ADDXri;
3214 Opc = SetNZCV ? AArch64::SUBSXri : AArch64::SUBXri;
3217 NeedsWinCFI, HasWinCFI);
3221 assert(!(SetNZCV && (NumPredicateVectors || NumDataVectors)) &&
3222 "SetNZCV not supported with SVE vectors");
3223 assert(!(NeedsWinCFI && (NumPredicateVectors || NumDataVectors)) &&
3224 "WinCFI not supported with SVE vectors");
3226 if (NumDataVectors) {
3228 AArch64::ADDVL_XXI, TII, Flag, NeedsWinCFI,
nullptr);
3232 if (NumPredicateVectors) {
3233 assert(DestReg != AArch64::SP &&
"Unaligned access to SP");
3235 AArch64::ADDPL_XXI, TII, Flag, NeedsWinCFI,
nullptr);
3295 (Ops[0] == 0 || Ops[0] == 1)) {
3296 bool IsSpill = Ops[0] == 0;
3297 bool IsFill = !IsSpill;
3315 "Mismatched register size in non subreg COPY");
3322 return &*--InsertPt;
3336 "Unexpected subreg on physical register");
3338 unsigned SpillSubreg;
3343 case AArch64::sub_32:
3345 if (AArch64::GPR32RegClass.
contains(SrcReg)) {
3346 SpillRC = &AArch64::GPR64RegClass;
3347 SpillSubreg = AArch64::sub_32;
3348 }
else if (AArch64::FPR32RegClass.
contains(SrcReg)) {
3349 SpillRC = &AArch64::FPR64RegClass;
3350 SpillSubreg = AArch64::ssub;
3355 if (AArch64::FPR64RegClass.
contains(SrcReg)) {
3356 SpillRC = &AArch64::FPR128RegClass;
3357 SpillSubreg = AArch64::dsub;
3364 if (
unsigned WidenedSrcReg =
3368 return &*--InsertPt;
3387 case AArch64::sub_32:
3388 FillRC = &AArch64::GPR32RegClass;
3391 FillRC = &AArch64::FPR32RegClass;
3394 FillRC = &AArch64::FPR64RegClass;
3401 "Mismatched regclass size on folded subreg COPY");
3419 case AArch64::LDR_ZXI:
3420 case AArch64::STR_ZXI:
3421 case AArch64::LDR_PXI:
3422 case AArch64::STR_PXI:
3431 bool *OutUseUnscaledOp,
3432 unsigned *OutUnscaledOp,
3433 int64_t *EmittableOffset) {
3435 if (EmittableOffset)
3436 *EmittableOffset = 0;
3437 if (OutUseUnscaledOp)
3438 *OutUseUnscaledOp =
false;
3447 case AArch64::LD1Twov2d:
3448 case AArch64::LD1Threev2d:
3449 case AArch64::LD1Fourv2d:
3450 case AArch64::LD1Twov1d:
3451 case AArch64::LD1Threev1d:
3452 case AArch64::LD1Fourv1d:
3453 case AArch64::ST1Twov2d:
3454 case AArch64::ST1Threev2d:
3455 case AArch64::ST1Fourv2d:
3456 case AArch64::ST1Twov1d:
3457 case AArch64::ST1Threev1d:
3458 case AArch64::ST1Fourv1d:
3460 case AArch64::IRGstack:
3465 unsigned Scale,
Width;
3466 int64_t MinOff, MaxOff;
3478 Offset += ImmOpnd.
getImm() * Scale;
3485 bool useUnscaledOp = UnscaledOp && (Offset % Scale || Offset < 0);
3486 if (useUnscaledOp &&
3490 int64_t Remainder = Offset % Scale;
3491 assert(!(Remainder && useUnscaledOp) &&
3492 "Cannot have remainder when using unscaled op");
3494 assert(MinOff < MaxOff &&
"Unexpected Min/Max offsets");
3495 int64_t NewOffset = Offset / Scale;
3496 if (MinOff <= NewOffset && NewOffset <= MaxOff)
3499 NewOffset = NewOffset < 0 ? MinOff : MaxOff;
3500 Offset = Offset - NewOffset * Scale + Remainder;
3503 if (EmittableOffset)
3504 *EmittableOffset = NewOffset;
3505 if (OutUseUnscaledOp)
3506 *OutUseUnscaledOp = useUnscaledOp;
3507 if (OutUnscaledOp && UnscaledOp)
3508 *OutUnscaledOp = *UnscaledOp;
3524 unsigned ImmIdx = FrameRegIdx + 1;
3526 if (Opcode == AArch64::ADDSXri || Opcode == AArch64::ADDXri) {
3537 unsigned UnscaledOp;
3540 &UnscaledOp, &NewOffset);
3546 MI.
setDesc(TII->get(UnscaledOp));
3566 case AArch64::ADDSWrr:
3567 case AArch64::ADDSWri:
3568 case AArch64::ADDSXrr:
3569 case AArch64::ADDSXri:
3570 case AArch64::SUBSWrr:
3571 case AArch64::SUBSXrr:
3573 case AArch64::SUBSWri:
3574 case AArch64::SUBSXri:
3585 case AArch64::ADDWrr:
3586 case AArch64::ADDWri:
3587 case AArch64::SUBWrr:
3588 case AArch64::ADDSWrr:
3589 case AArch64::ADDSWri:
3590 case AArch64::SUBSWrr:
3592 case AArch64::SUBWri:
3593 case AArch64::SUBSWri:
3604 case AArch64::ADDXrr:
3605 case AArch64::ADDXri:
3606 case AArch64::SUBXrr:
3607 case AArch64::ADDSXrr:
3608 case AArch64::ADDSXri:
3609 case AArch64::SUBSXrr:
3611 case AArch64::SUBXri:
3612 case AArch64::SUBSXri:
3613 case AArch64::ADDv8i8:
3614 case AArch64::ADDv16i8:
3615 case AArch64::ADDv4i16:
3616 case AArch64::ADDv8i16:
3617 case AArch64::ADDv2i32:
3618 case AArch64::ADDv4i32:
3619 case AArch64::SUBv8i8:
3620 case AArch64::SUBv16i8:
3621 case AArch64::SUBv4i16:
3622 case AArch64::SUBv8i16:
3623 case AArch64::SUBv2i32:
3624 case AArch64::SUBv4i32:
3637 case AArch64::FADDHrr:
3638 case AArch64::FADDSrr:
3639 case AArch64::FADDDrr:
3640 case AArch64::FADDv4f16:
3641 case AArch64::FADDv8f16:
3642 case AArch64::FADDv2f32:
3643 case AArch64::FADDv2f64:
3644 case AArch64::FADDv4f32:
3645 case AArch64::FSUBHrr:
3646 case AArch64::FSUBSrr:
3647 case AArch64::FSUBDrr:
3648 case AArch64::FSUBv4f16:
3649 case AArch64::FSUBv8f16:
3650 case AArch64::FSUBv2f32:
3651 case AArch64::FSUBv2f64:
3652 case AArch64::FSUBv4f32:
3669 unsigned CombineOpc,
unsigned ZeroReg = 0,
3670 bool CheckZeroReg =
false) {
3698 unsigned MulOpc,
unsigned ZeroReg) {
3699 return canCombine(MBB, MO, MulOpc, ZeroReg,
true);
3716 case AArch64::FADDDrr:
3717 case AArch64::FADDSrr:
3718 case AArch64::FADDv2f32:
3719 case AArch64::FADDv2f64:
3720 case AArch64::FADDv4f32:
3721 case AArch64::FMULDrr:
3722 case AArch64::FMULSrr:
3723 case AArch64::FMULX32:
3724 case AArch64::FMULX64:
3725 case AArch64::FMULXv2f32:
3726 case AArch64::FMULXv2f64:
3727 case AArch64::FMULXv4f32:
3728 case AArch64::FMULv2f32:
3729 case AArch64::FMULv2f64:
3730 case AArch64::FMULv4f32:
3759 auto setFound = [&](
int Opcode,
int Operand,
unsigned ZeroReg,
3779 case AArch64::ADDWrr:
3781 "ADDWrr does not have register operands");
3785 case AArch64::ADDXrr:
3789 case AArch64::SUBWrr:
3793 case AArch64::SUBXrr:
3797 case AArch64::ADDWri:
3800 case AArch64::ADDXri:
3803 case AArch64::SUBWri:
3806 case AArch64::SUBXri:
3809 case AArch64::ADDv8i8:
3813 case AArch64::ADDv16i8:
3817 case AArch64::ADDv4i16:
3823 case AArch64::ADDv8i16:
3829 case AArch64::ADDv2i32:
3835 case AArch64::ADDv4i32:
3841 case AArch64::SUBv8i8:
3845 case AArch64::SUBv16i8:
3849 case AArch64::SUBv4i16:
3855 case AArch64::SUBv8i16:
3861 case AArch64::SUBv2i32:
3867 case AArch64::SUBv4i32:
3888 auto Match = [&](
int Opcode,
int Operand,
3901 assert(
false &&
"Unsupported FP instruction in combiner\n");
3903 case AArch64::FADDHrr:
3905 "FADDHrr does not have register operands");
3910 case AArch64::FADDSrr:
3912 "FADDSrr does not have register operands");
3920 case AArch64::FADDDrr:
3927 case AArch64::FADDv4f16:
3934 case AArch64::FADDv8f16:
3941 case AArch64::FADDv2f32:
3948 case AArch64::FADDv2f64:
3955 case AArch64::FADDv4f32:
3962 case AArch64::FSUBHrr:
3967 case AArch64::FSUBSrr:
3975 case AArch64::FSUBDrr:
3983 case AArch64::FSUBv4f16:
3990 case AArch64::FSUBv8f16:
3997 case AArch64::FSUBv2f32:
4004 case AArch64::FSUBv2f64:
4011 case AArch64::FSUBv4f32:
4173 const Register *ReplacedAddend =
nullptr) {
4174 assert(IdxMulOpd == 1 || IdxMulOpd == 2);
4176 unsigned IdxOtherOpd = IdxMulOpd == 1 ? 2 : 1;
4186 if (ReplacedAddend) {
4188 SrcReg2 = *ReplacedAddend;
4222 assert(
false &&
"Invalid FMA instruction kind \n");
4236 return genFusedMultiply(MF, MRI, TII, Root, InsInstrs, IdxMulOpd, MaddOpc, RC,
4254 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
4269 genNeg(MF, MRI, TII, Root, InsInstrs, InstrIdxForVirtReg, MnegOpc, RC);
4270 return genFusedMultiply(MF, MRI, TII, Root, InsInstrs, IdxMulOpd, MaddOpc, RC,
4282 return genFusedMultiply(MF, MRI, TII, Root, InsInstrs, IdxMulOpd, MaddOpc, RC,
4296 genNeg(MF, MRI, TII, Root, InsInstrs, InstrIdxForVirtReg, MnegOpc, RC);
4298 return genFusedMultiply(MF, MRI, TII, Root, InsInstrs, IdxMulOpd, MaddOpc, RC,
4324 unsigned IdxMulOpd,
unsigned MaddOpc,
unsigned VR,
4326 assert(IdxMulOpd == 1 || IdxMulOpd == 2);
4374 DelInstrs, InstrIdxForVirtReg);
4383 Opc = AArch64::MADDWrrr;
4384 RC = &AArch64::GPR32RegClass;
4386 Opc = AArch64::MADDXrrr;
4387 RC = &AArch64::GPR64RegClass;
4398 Opc = AArch64::MADDWrrr;
4399 RC = &AArch64::GPR32RegClass;
4401 Opc = AArch64::MADDXrrr;
4402 RC = &AArch64::GPR64RegClass;
4414 unsigned BitSize, OrrOpc, ZeroReg;
4416 OrrOpc = AArch64::ORRWri;
4417 OrrRC = &AArch64::GPR32spRegClass;
4419 ZeroReg = AArch64::WZR;
4420 Opc = AArch64::MADDWrrr;
4421 RC = &AArch64::GPR32RegClass;
4423 OrrOpc = AArch64::ORRXri;
4424 OrrRC = &AArch64::GPR64spRegClass;
4426 ZeroReg = AArch64::XZR;
4427 Opc = AArch64::MADDXrrr;
4428 RC = &AArch64::GPR64RegClass;
4445 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
4446 MUL =
genMaddR(MF, MRI, TII, Root, InsInstrs, 1, Opc, NewVR, RC);
4458 unsigned SubOpc, ZeroReg;
4460 SubOpc = AArch64::SUBWrr;
4461 SubRC = &AArch64::GPR32spRegClass;
4462 ZeroReg = AArch64::WZR;
4463 Opc = AArch64::MADDWrrr;
4464 RC = &AArch64::GPR32RegClass;
4466 SubOpc = AArch64::SUBXrr;
4467 SubRC = &AArch64::GPR64spRegClass;
4468 ZeroReg = AArch64::XZR;
4469 Opc = AArch64::MADDXrrr;
4470 RC = &AArch64::GPR64RegClass;
4479 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
4480 MUL =
genMaddR(MF, MRI, TII, Root, InsInstrs, 1, Opc, NewVR, RC);
4490 Opc = AArch64::MSUBWrrr;
4491 RC = &AArch64::GPR32RegClass;
4493 Opc = AArch64::MSUBXrrr;
4494 RC = &AArch64::GPR64RegClass;
4506 unsigned BitSize, OrrOpc, ZeroReg;
4508 OrrOpc = AArch64::ORRWri;
4509 OrrRC = &AArch64::GPR32spRegClass;
4511 ZeroReg = AArch64::WZR;
4512 Opc = AArch64::MADDWrrr;
4513 RC = &AArch64::GPR32RegClass;
4515 OrrOpc = AArch64::ORRXri;
4516 OrrRC = &AArch64::GPR64spRegClass;
4518 ZeroReg = AArch64::XZR;
4519 Opc = AArch64::MADDXrrr;
4520 RC = &AArch64::GPR64RegClass;
4536 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
4537 MUL =
genMaddR(MF, MRI, TII, Root, InsInstrs, 1, Opc, NewVR, RC);
4543 Opc = AArch64::MLAv8i8;
4544 RC = &AArch64::FPR64RegClass;
4548 Opc = AArch64::MLAv8i8;
4549 RC = &AArch64::FPR64RegClass;
4553 Opc = AArch64::MLAv16i8;
4554 RC = &AArch64::FPR128RegClass;
4558 Opc = AArch64::MLAv16i8;
4559 RC = &AArch64::FPR128RegClass;
4563 Opc = AArch64::MLAv4i16;
4564 RC = &AArch64::FPR64RegClass;
4568 Opc = AArch64::MLAv4i16;
4569 RC = &AArch64::FPR64RegClass;
4573 Opc = AArch64::MLAv8i16;
4574 RC = &AArch64::FPR128RegClass;
4578 Opc = AArch64::MLAv8i16;
4579 RC = &AArch64::FPR128RegClass;
4583 Opc = AArch64::MLAv2i32;
4584 RC = &AArch64::FPR64RegClass;
4588 Opc = AArch64::MLAv2i32;
4589 RC = &AArch64::FPR64RegClass;
4593 Opc = AArch64::MLAv4i32;
4594 RC = &AArch64::FPR128RegClass;
4598 Opc = AArch64::MLAv4i32;
4599 RC = &AArch64::FPR128RegClass;
4604 Opc = AArch64::MLAv8i8;
4605 RC = &AArch64::FPR64RegClass;
4607 InstrIdxForVirtReg, 1, Opc, AArch64::NEGv8i8,
4611 Opc = AArch64::MLSv8i8;
4612 RC = &AArch64::FPR64RegClass;
4616 Opc = AArch64::MLAv16i8;
4617 RC = &AArch64::FPR128RegClass;
4619 InstrIdxForVirtReg, 1, Opc, AArch64::NEGv16i8,
4623 Opc = AArch64::MLSv16i8;
4624 RC = &AArch64::FPR128RegClass;
4628 Opc = AArch64::MLAv4i16;
4629 RC = &AArch64::FPR64RegClass;
4631 InstrIdxForVirtReg, 1, Opc, AArch64::NEGv4i16,
4635 Opc = AArch64::MLSv4i16;
4636 RC = &AArch64::FPR64RegClass;
4640 Opc = AArch64::MLAv8i16;
4641 RC = &AArch64::FPR128RegClass;
4643 InstrIdxForVirtReg, 1, Opc, AArch64::NEGv8i16,
4647 Opc = AArch64::MLSv8i16;
4648 RC = &AArch64::FPR128RegClass;
4652 Opc = AArch64::MLAv2i32;
4653 RC = &AArch64::FPR64RegClass;
4655 InstrIdxForVirtReg, 1, Opc, AArch64::NEGv2i32,
4659 Opc = AArch64::MLSv2i32;
4660 RC = &AArch64::FPR64RegClass;
4664 Opc = AArch64::MLAv4i32;
4665 RC = &AArch64::FPR128RegClass;
4667 InstrIdxForVirtReg, 1, Opc, AArch64::NEGv4i32,
4671 Opc = AArch64::MLSv4i32;
4672 RC = &AArch64::FPR128RegClass;
4677 Opc = AArch64::MLAv4i16_indexed;
4678 RC = &AArch64::FPR64RegClass;
4682 Opc = AArch64::MLAv4i16_indexed;
4683 RC = &AArch64::FPR64RegClass;
4687 Opc = AArch64::MLAv8i16_indexed;
4688 RC = &AArch64::FPR128RegClass;
4692 Opc = AArch64::MLAv8i16_indexed;
4693 RC = &AArch64::FPR128RegClass;
4697 Opc = AArch64::MLAv2i32_indexed;
4698 RC = &AArch64::FPR64RegClass;
4702 Opc = AArch64::MLAv2i32_indexed;
4703 RC = &AArch64::FPR64RegClass;
4707 Opc = AArch64::MLAv4i32_indexed;
4708 RC = &AArch64::FPR128RegClass;
4712 Opc = AArch64::MLAv4i32_indexed;
4713 RC = &AArch64::FPR128RegClass;
4718 Opc = AArch64::MLAv4i16_indexed;
4719 RC = &AArch64::FPR64RegClass;
4721 InstrIdxForVirtReg, 1, Opc, AArch64::NEGv4i16,
4725 Opc = AArch64::MLSv4i16_indexed;
4726 RC = &AArch64::FPR64RegClass;
4730 Opc = AArch64::MLAv8i16_indexed;
4731 RC = &AArch64::FPR128RegClass;
4733 InstrIdxForVirtReg, 1, Opc, AArch64::NEGv8i16,
4737 Opc = AArch64::MLSv8i16_indexed;
4738 RC = &AArch64::FPR128RegClass;
4742 Opc = AArch64::MLAv2i32_indexed;
4743 RC = &AArch64::FPR64RegClass;
4745 InstrIdxForVirtReg, 1, Opc, AArch64::NEGv2i32,
4749 Opc = AArch64::MLSv2i32_indexed;
4750 RC = &AArch64::FPR64RegClass;
4754 Opc = AArch64::MLAv4i32_indexed;
4755 RC = &AArch64::FPR128RegClass;
4757 InstrIdxForVirtReg, 1, Opc, AArch64::NEGv4i32,
4761 Opc = AArch64::MLSv4i32_indexed;
4762 RC = &AArch64::FPR128RegClass;
4768 Opc = AArch64::FMADDHrrr;
4769 RC = &AArch64::FPR16RegClass;
4773 Opc = AArch64::FMADDSrrr;
4774 RC = &AArch64::FPR32RegClass;
4778 Opc = AArch64::FMADDDrrr;
4779 RC = &AArch64::FPR64RegClass;
4784 Opc = AArch64::FMADDHrrr;
4785 RC = &AArch64::FPR16RegClass;
4789 Opc = AArch64::FMADDSrrr;
4790 RC = &AArch64::FPR32RegClass;
4794 Opc = AArch64::FMADDDrrr;
4795 RC = &AArch64::FPR64RegClass;
4800 Opc = AArch64::FMLAv1i32_indexed;
4801 RC = &AArch64::FPR32RegClass;
4806 Opc = AArch64::FMLAv1i32_indexed;
4807 RC = &AArch64::FPR32RegClass;
4813 Opc = AArch64::FMLAv1i64_indexed;
4814 RC = &AArch64::FPR64RegClass;
4819 Opc = AArch64::FMLAv1i64_indexed;
4820 RC = &AArch64::FPR64RegClass;
4826 RC = &AArch64::FPR64RegClass;
4827 Opc = AArch64::FMLAv4i16_indexed;
4832 RC = &AArch64::FPR64RegClass;
4833 Opc = AArch64::FMLAv4f16;
4838 RC = &AArch64::FPR64RegClass;
4839 Opc = AArch64::FMLAv4i16_indexed;
4844 RC = &AArch64::FPR64RegClass;
4845 Opc = AArch64::FMLAv4f16;
4852 RC = &AArch64::FPR64RegClass;
4854 Opc = AArch64::FMLAv2i32_indexed;
4858 Opc = AArch64::FMLAv2f32;
4865 RC = &AArch64::FPR64RegClass;
4867 Opc = AArch64::FMLAv2i32_indexed;
4871 Opc = AArch64::FMLAv2f32;
4878 RC = &AArch64::FPR128RegClass;
4879 Opc = AArch64::FMLAv8i16_indexed;
4884 RC = &AArch64::FPR128RegClass;
4885 Opc = AArch64::FMLAv8f16;
4890 RC = &AArch64::FPR128RegClass;
4891 Opc = AArch64::FMLAv8i16_indexed;
4896 RC = &AArch64::FPR128RegClass;
4897 Opc = AArch64::FMLAv8f16;
4904 RC = &AArch64::FPR128RegClass;
4906 Opc = AArch64::FMLAv2i64_indexed;
4910 Opc = AArch64::FMLAv2f64;
4917 RC = &AArch64::FPR128RegClass;
4919 Opc = AArch64::FMLAv2i64_indexed;
4923 Opc = AArch64::FMLAv2f64;
4931 RC = &AArch64::FPR128RegClass;
4933 Opc = AArch64::FMLAv4i32_indexed;
4937 Opc = AArch64::FMLAv4f32;
4945 RC = &AArch64::FPR128RegClass;
4947 Opc = AArch64::FMLAv4i32_indexed;
4951 Opc = AArch64::FMLAv4f32;
4958 Opc = AArch64::FNMSUBHrrr;
4959 RC = &AArch64::FPR16RegClass;
4963 Opc = AArch64::FNMSUBSrrr;
4964 RC = &AArch64::FPR32RegClass;
4968 Opc = AArch64::FNMSUBDrrr;
4969 RC = &AArch64::FPR64RegClass;
4974 Opc = AArch64::FNMADDHrrr;
4975 RC = &AArch64::FPR16RegClass;
4979 Opc = AArch64::FNMADDSrrr;
4980 RC = &AArch64::FPR32RegClass;
4984 Opc = AArch64::FNMADDDrrr;
4985 RC = &AArch64::FPR64RegClass;
4990 Opc = AArch64::FMSUBHrrr;
4991 RC = &AArch64::FPR16RegClass;
4995 Opc = AArch64::FMSUBSrrr;
4996 RC = &AArch64::FPR32RegClass;
5000 Opc = AArch64::FMSUBDrrr;
5001 RC = &AArch64::FPR64RegClass;
5006 Opc = AArch64::FMLSv1i32_indexed;
5007 RC = &AArch64::FPR32RegClass;
5013 Opc = AArch64::FMLSv1i64_indexed;
5014 RC = &AArch64::FPR64RegClass;
5021 RC = &AArch64::FPR64RegClass;
5027 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
5029 Opc = AArch64::FMLAv4f16;
5033 Opc = AArch64::FMLAv4i16_indexed;
5040 RC = &AArch64::FPR64RegClass;
5041 Opc = AArch64::FMLSv4f16;
5046 RC = &AArch64::FPR64RegClass;
5047 Opc = AArch64::FMLSv4i16_indexed;
5054 RC = &AArch64::FPR64RegClass;
5056 Opc = AArch64::FMLSv2i32_indexed;
5060 Opc = AArch64::FMLSv2f32;
5068 RC = &AArch64::FPR128RegClass;
5074 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
5076 Opc = AArch64::FMLAv8f16;
5080 Opc = AArch64::FMLAv8i16_indexed;
5087 RC = &AArch64::FPR128RegClass;
5088 Opc = AArch64::FMLSv8f16;
5093 RC = &AArch64::FPR128RegClass;
5094 Opc = AArch64::FMLSv8i16_indexed;
5101 RC = &AArch64::FPR128RegClass;
5103 Opc = AArch64::FMLSv2i64_indexed;
5107 Opc = AArch64::FMLSv2f64;
5115 RC = &AArch64::FPR128RegClass;
5117 Opc = AArch64::FMLSv4i32_indexed;
5121 Opc = AArch64::FMLSv4f32;
5128 RC = &AArch64::FPR64RegClass;
5134 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
5136 Opc = AArch64::FMLAv2i32_indexed;
5140 Opc = AArch64::FMLAv2f32;
5148 RC = &AArch64::FPR128RegClass;
5154 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
5156 Opc = AArch64::FMLAv4i32_indexed;
5160 Opc = AArch64::FMLAv4f32;
5168 RC = &AArch64::FPR128RegClass;
5174 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
5176 Opc = AArch64::FMLAv2i64_indexed;
5180 Opc = AArch64::FMLAv2f64;
5230 bool IsNegativeBranch =
false;
5231 bool IsTestAndBranch =
false;
5232 unsigned TargetBBInMI = 0;
5242 case AArch64::CBNZW:
5243 case AArch64::CBNZX:
5245 IsNegativeBranch =
true;
5250 IsTestAndBranch =
true;
5252 case AArch64::TBNZW:
5253 case AArch64::TBNZX:
5255 IsNegativeBranch =
true;
5256 IsTestAndBranch =
true;
5277 while (DefMI->
isCopy()) {
5290 case AArch64::ANDWri:
5291 case AArch64::ANDXri: {
5292 if (IsTestAndBranch)
5299 bool Is32Bit = (DefMI->
getOpcode() == AArch64::ANDWri);
5316 unsigned Opc = (Imm < 32)
5317 ? (IsNegativeBranch ? AArch64::TBNZW : AArch64::TBZW)
5318 : (IsNegativeBranch ? AArch64::TBNZX : AArch64::TBZX);
5331 if (!Is32Bit && Imm < 32)
5337 case AArch64::CSINCWr:
5338 case AArch64::CSINCXr: {
5357 if (IsNegativeBranch)
5366 std::pair<unsigned, unsigned>
5369 return std::make_pair(TF & Mask, TF & ~Mask);
5374 using namespace AArch64II;
5376 static const std::pair<unsigned, const char *> TargetFlags[] = {
5378 {
MO_G3,
"aarch64-g3"}, {
MO_G2,
"aarch64-g2"},
5379 {
MO_G1,
"aarch64-g1"}, {
MO_G0,
"aarch64-g0"},
5386 using namespace AArch64II;
5388 static const std::pair<unsigned, const char *> TargetFlags[] = {
5391 {
MO_NC,
"aarch64-nc"},
5392 {
MO_S,
"aarch64-s"},
5402 static const std::pair<MachineMemOperand::Flags, const char *> TargetFlags[] =
5511 for (
unsigned Reg : AArch64::GPR64RegClass) {
5513 Reg != AArch64::LR &&
5514 Reg != AArch64::X16 &&
5515 Reg != AArch64::X17 &&
5545 return ScopeA.
equals(ScopeB);
5554 return ScopeA.
equals(
"none");
5560 return ScopeB.
equals(
"none");
5587 return KeyA.
equals(KeyB);
5604 llvm_unreachable(
"Unkown combination of sign-return-address-key attributes");
5613 return SubtargetA.
hasV8_3aOps() == SubtargetB.hasV8_3aOps();
5617 std::vector<outliner::Candidate> &RepeatedSequenceLocs)
const {
5619 unsigned SequenceSize =
5620 std::accumulate(FirstCand.
front(), std::next(FirstCand.
back()), 0,
5624 unsigned NumBytesToCreateFrame = 0;
5634 if (std::adjacent_find(
5635 RepeatedSequenceLocs.begin(), RepeatedSequenceLocs.end(),
5645 }) != RepeatedSequenceLocs.end()) {
5664 NumBytesToCreateFrame += 8;
5674 if (MBBI->modifiesRegister(AArch64::SP, &TRI)) {
5675 switch (MBBI->getOpcode()) {
5676 case AArch64::ADDXri:
5677 case AArch64::ADDWri:
5678 assert(MBBI->getNumOperands() == 4 &&
"Wrong number of operands");
5679 assert(MBBI->getOperand(2).isImm() &&
5680 "Expected operand to be immediate");
5681 assert(MBBI->getOperand(1).isReg() &&
5682 "Expected operand to be a register");
5686 if (MBBI->getOperand(1).getReg() == AArch64::SP)
5687 SPValue += MBBI->getOperand(2).getImm();
5691 case AArch64::SUBXri:
5692 case AArch64::SUBWri:
5693 assert(MBBI->getNumOperands() == 4 &&
"Wrong number of operands");
5694 assert(MBBI->getOperand(2).isImm() &&
5695 "Expected operand to be immediate");
5696 assert(MBBI->getOperand(1).isReg() &&
5697 "Expected operand to be a register");
5701 if (MBBI->getOperand(1).getReg() == AArch64::SP)
5702 SPValue -= MBBI->getOperand(2).getImm();
5710 if (MBBI ==
C.back())
5719 RepeatedSequenceLocs.erase(
std::remove_if(RepeatedSequenceLocs.begin(),
5720 RepeatedSequenceLocs.end(),
5721 hasIllegalSPModification),
5722 RepeatedSequenceLocs.end());
5725 if (RepeatedSequenceLocs.size() < 2)
5730 unsigned FlagsSetInAll = 0xF;
5733 std::for_each(RepeatedSequenceLocs.begin(), RepeatedSequenceLocs.end(),
5735 FlagsSetInAll &=
C.Flags;
5765 RepeatedSequenceLocs.erase(
std::remove_if(RepeatedSequenceLocs.begin(),
5766 RepeatedSequenceLocs.end(),
5767 CantGuaranteeValueAcrossCall),
5768 RepeatedSequenceLocs.end());
5771 if (RepeatedSequenceLocs.size() < 2)
5778 unsigned LastInstrOpcode = RepeatedSequenceLocs[0].back()->getOpcode();
5781 auto SetCandidateCallInfo =
5782 [&RepeatedSequenceLocs](
unsigned CallID,
unsigned NumBytesForCall) {
5784 C.setCallInfo(CallID, NumBytesForCall);
5788 NumBytesToCreateFrame += 4;
5818 Base->
getReg() != AArch64::SP)
5826 unsigned DummyWidth;
5830 if (Offset < MinOffset * Scale || Offset > MaxOffset * Scale)
5846 FirstCand.
front(), std::next(FirstCand.
back()), IsSafeToFixup);
5850 if (RepeatedSequenceLocs[0].back()->isTerminator()) {
5852 NumBytesToCreateFrame = 0;
5857 (LastInstrOpcode == AArch64::BLR && !HasBTI)) {
5860 NumBytesToCreateFrame = 0;
5868 unsigned NumBytesNoStackCalls = 0;
5869 std::vector<outliner::Candidate> CandidatesWithoutStackFixups;
5886 NumBytesNoStackCalls += 4;
5888 CandidatesWithoutStackFixups.push_back(C);
5893 else if (findRegisterToSaveLRTo(C)) {
5894 NumBytesNoStackCalls += 12;
5896 CandidatesWithoutStackFixups.push_back(C);
5902 NumBytesNoStackCalls += 12;
5904 CandidatesWithoutStackFixups.push_back(C);
5910 NumBytesNoStackCalls += SequenceSize;
5917 if (!AllStackInstrsSafe ||
5918 NumBytesNoStackCalls <= RepeatedSequenceLocs.size() * 12) {
5919 RepeatedSequenceLocs = CandidatesWithoutStackFixups;
5926 if (RepeatedSequenceLocs.size() < 2) {
5927 RepeatedSequenceLocs.clear();
5937 bool ModStackToSaveLR =
false;
5940 ModStackToSaveLR =
true;
5949 ModStackToSaveLR =
true;
5951 if (ModStackToSaveLR) {
5953 if (!AllStackInstrsSafe) {
5954 RepeatedSequenceLocs.clear();
5959 NumBytesToCreateFrame += 8;
5964 NumBytesToCreateFrame, FrameID);
5994 unsigned &Flags)
const {
5998 "Suitable Machine Function for outlining must track liveness");
6005 bool W16AvailableInBlock = LRU.available(AArch64::W16);
6006 bool W17AvailableInBlock = LRU.available(AArch64::W17);
6007 bool NZCVAvailableInBlock = LRU.available(AArch64::NZCV);
6011 if (W16AvailableInBlock && W17AvailableInBlock && NZCVAvailableInBlock)
6015 LRU.addLiveOuts(MBB);
6019 if (W16AvailableInBlock && !LRU.available(AArch64::W16))
6021 if (W17AvailableInBlock && !LRU.available(AArch64::W17))
6023 if (NZCVAvailableInBlock && !LRU.available(AArch64::NZCV))
6036 bool CanSaveLR =
false;
6042 for (
unsigned Reg : AArch64::GPR64RegClass) {
6044 Reg != AArch64::X16 &&
Reg != AArch64::X17 && LRU.available(
Reg)) {
6053 if (!CanSaveLR && !LRU.available(AArch64::LR))
6061 unsigned Flags)
const {
6070 case AArch64::PACIASP:
6071 case AArch64::PACIBSP:
6072 case AArch64::AUTIASP:
6073 case AArch64::AUTIBSP:
6074 case AArch64::RETAA:
6075 case AArch64::RETAB:
6076 case AArch64::EMITBKEY:
6106 if (MOP.isCPI() || MOP.isJTI() || MOP.isCFIIndex() || MOP.isFI() ||
6107 MOP.isTargetIndex())
6111 if (MOP.isReg() && !MOP.isImplicit() &&
6112 (MOP.getReg() == AArch64::LR || MOP.getReg() == AArch64::W30))
6140 if (MOP.isGlobal()) {
6148 if (Callee && Callee->
getName() ==
"\01_mcount")
6160 return UnknownCallOutlineType;
6168 return UnknownCallOutlineType;
6176 return UnknownCallOutlineType;
6196 if (Imm == 32 || Imm == 34 || Imm == 36 || Imm == 38)
6210 if (!
MI.mayLoadOrStore() ||
6217 int64_t Dummy1, Dummy2;
6220 assert(StackOffsetOperand.
isImm() &&
"Stack offset wasn't immediate!");
6222 assert(Scale != 0 &&
"Unexpected opcode!");
6227 int64_t NewImm = (Offset + 16) / Scale;
6228 StackOffsetOperand.
setImm(NewImm);
6233 bool ShouldSignReturnAddr,
6234 bool ShouldSignReturnAddrWithAKey) {
6235 if (ShouldSignReturnAddr) {
6242 if (MBBAUT != MBB.
end())
6243 DL = MBBAUT->getDebugLoc();
6252 if (ShouldSignReturnAddrWithAKey) {
6264 .addCFIIndex(CFIIndex)
6272 TII->
get(ShouldSignReturnAddrWithAKey ? AArch64::RETAA
6274 .copyImplicitOps(*MBBAUT);
6278 TII->
get(ShouldSignReturnAddrWithAKey ? AArch64::AUTIASP
6279 : AArch64::AUTIBSP))
6292 unsigned TailOpcode;
6294 TailOpcode = AArch64::TCRETURNdi;
6297 TailOpcode = AArch64::TCRETURNriALL;
6306 bool IsLeafFunction =
true;
6310 return MI.isCall() && !
MI.isReturn();
6317 "Can only fix up stack references once");
6318 fixupPostOutline(MBB);
6320 IsLeafFunction =
false;
6330 Et = std::prev(MBB.
end());
6338 It = MBB.
insert(It, STRXpre);
6345 int64_t StackPosEntry =
6353 int64_t LRPosEntry =
6365 Et = MBB.
insert(Et, LDRXpost);
6372 bool ShouldSignReturnAddr =
false;
6377 ShouldSignReturnAddr =
true;
6378 else if (Scope.
equals(
"non-leaf") && !IsLeafFunction)
6379 ShouldSignReturnAddr =
true;
6383 bool ShouldSignReturnAddrWithAKey =
true;
6389 "Return address signing key must be either a_key or b_key");
6390 ShouldSignReturnAddrWithAKey = Key.
equals_lower(
"a_key");
6397 ShouldSignReturnAddrWithAKey);
6407 ShouldSignReturnAddrWithAKey);
6415 fixupPostOutline(MBB);
6451 unsigned Reg = findRegisterToSaveLRTo(C);
6452 assert(Reg != 0 &&
"No callee-saved register available?");
6477 It = MBB.
insert(It, Save);
6486 It = MBB.
insert(It, Restore);
6500 if (MI.
getOpcode() == AArch64::ORRWrs &&
6506 if (MI.
getOpcode() == AArch64::ORRXrs &&
6528 case AArch64::SUBWri:
6529 case AArch64::SUBXri:
6530 case AArch64::SUBSWri:
6531 case AArch64::SUBSXri:
6534 case AArch64::ADDSWri:
6535 case AArch64::ADDSXri:
6536 case AArch64::ADDWri:
6537 case AArch64::ADDXri: {
6544 assert((Shift == 0 || Shift == 12) &&
"Shift can be either 0 or 12");
6545 Offset = Offset << Shift;
6562 Register DestReg = DestSrc->Destination->getReg();
6563 Register SrcReg = DestSrc->Source->getReg();
6568 if (DestReg == DescribedReg)
6572 if (MI.
getOpcode() == AArch64::ORRWrs &&
6577 if (MI.
getOpcode() == AArch64::ORRXrs &&
6584 "Unhandled ORR[XW]rs copy case");
6595 case AArch64::MOVZWi:
6596 case AArch64::MOVZXi: {
6609 case AArch64::ORRWrs:
6610 case AArch64::ORRXrs:
6617 #define GET_INSTRINFO_HELPERS 6618 #include "AArch64GenInstrInfo.inc" Scope
Defines the scope in which this symbol should be visible: Default – Visible in the public interface ...
static bool isStridedAccess(const MachineInstr &MI)
Return true if the given load or store is a strided memory access.
ArrayRef< std::pair< unsigned, const char * > > getSerializableBitmaskMachineOperandTargetFlags() const override
MO_PREL - Indicates that the bits of the symbol operand represented by MO_G0 etc are PC relative...
const MachineInstrBuilder & add(const MachineOperand &MO) const
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
bool usesWindowsCFI() const
bool isCalleeSavedInfoValid() const
Has the callee saved info been calculated yet?
Optional< DestSourcePair > isCopyInstr(const MachineInstr &MI) const
If the specific machine instruction is a instruction that moves/copies value from one register to ano...
MO_G3 - A symbol operand with this flag (granule 3) represents the high 16-bits of a 64-bit address...
static bool isFPRCopy(const MachineInstr &MI)
Does this instruction rename an FPR without modifying bits?
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
instr_iterator instr_begin()
bool use_nodbg_empty(unsigned RegNo) const
use_nodbg_empty - Return true if there are no non-Debug instructions using the specified register...
AArch64FunctionInfo - This class is derived from MachineFunctionInfo and contains private AArch64-spe...
Optional< ParamLoadedValue > describeLoadedValue(const MachineInstr &MI, Register Reg) const override
static unsigned getArithShiftValue(unsigned Imm)
getArithShiftValue - get the arithmetic shift value.
bool contains(unsigned Reg) const
Return true if the specified register is included in this register class.
StackOffset is a wrapper around scalable and non-scalable offsets and is used in several functions su...
bool isCall(QueryType Type=AnyInBundle) const
Wrapper class representing physical registers. Should be passed by value.
instr_iterator instr_end()
MachineBasicBlock * getMBB() const
const MachineFunction * getMF() const
Return the function that contains the basic block that this instruction belongs to.
This class represents lattice values for constants.
unsigned getNumObjects() const
Return the number of objects.
MO_PAGE - A symbol operand with this flag represents the pc-relative offset of the 4K page containing...
LLVM_NODISCARD bool equals_lower(StringRef RHS) const
equals_lower - Check for string equality, ignoring case.
A Module instance is used to store all the information related to an LLVM module. ...
static bool isGPRCopy(const MachineInstr &MI)
Does this instruction rename a GPR without modifying bits?
static bool getFMAPatterns(MachineInstr &Root, SmallVectorImpl< MachineCombinerPattern > &Patterns)
Floating-Point Support.
static unsigned sForm(MachineInstr &Instr)
Get opcode of S version of Instr.
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
const MachineInstrBuilder & addCFIIndex(unsigned CFIIndex) const
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
MO_TAGGED - With MO_PAGE, indicates that the page includes a memory tag in bits 56-63.
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)
emitFrameOffset - Emit instructions as needed to set DestReg to SrcReg plus Offset.
void initLRU(const TargetRegisterInfo &TRI)
Compute the registers that are live across this Candidate.
static bool outliningCandidatesSigningKeyConsensus(const outliner::Candidate &a, const outliner::Candidate &b)
void push_back(const T &Elt)
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
static CondCode getInvertedCondCode(CondCode Code)
LLVM_NODISCARD unsigned addFrameInst(const MCCFIInstruction &Inst)
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
Describe properties that are true of each instruction in the target description file.
void setIsUndef(bool Val=true)
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int Offset)
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
constexpr T getValueOr(U &&value) const LLVM_LVALUE_FUNCTION
static bool isSUBSRegImm(unsigned Opcode)
static bool processLogicalImmediate(uint64_t Imm, unsigned RegSize, uint64_t &Encoding)
processLogicalImmediate - Determine if an immediate value can be encoded as the immediate operand of ...
int findRegisterDefOperandIdx(Register Reg, bool isDead=false, bool Overlap=false, const TargetRegisterInfo *TRI=nullptr) const
Returns the operand index that is a def of the specified register or -1 if it is not found...
bool shouldClusterMemOps(const MachineOperand &BaseOp1, const MachineOperand &BaseOp2, unsigned NumLoads) const override
Detect opportunities for ldp/stp formation.
unsigned getSubReg() const
LiveRegUnits LRU
Contains physical register liveness information for the MBB containing this Candidate.
Offset can apply, at least partly.
const SetOfInstructions & getLOHRelated() const
Emit a save, restore, call, and return.
bool mayLoadOrStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read or modify memory.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
unsigned const TargetRegisterInfo * TRI
MO_G0 - A symbol operand with this flag (granule 0) represents the bits 0-15 of a 64-bit address...
MachineModuleInfo & getMMI() const
bool hasOneDef(unsigned RegNo) const
Return true if there is exactly one operand defining the specified register.
bool isMetaInstruction() const
Return true if this instruction doesn't produce any output in the form of executable instructions...
iterator_range< mop_iterator > operands()
static MCCFIInstruction createDefCfaOffset(MCSymbol *L, int Offset)
.cfi_def_cfa_offset modifies a rule for computing CFA.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
static unsigned convertToNonFlagSettingOpc(const MachineInstr &MI)
Return the opcode that does not set flags when possible - otherwise return the original opcode...
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
bool hasCustomCheapAsMoveHandling() const
unsigned getSpillSize(const TargetRegisterClass &RC) const
Return the size in bytes of the stack slot allocated to hold a spilled copy of a register from class ...
An individual sequence of instructions to be replaced with a call to an outlined function.
static bool isLdStPairSuppressed(const MachineInstr &MI)
Return true if pairing the given load or store is hinted to be unprofitable.
const MachineInstrBuilder & setMIFlag(MachineInstr::MIFlag Flag) const
static bool isUnscaledLdSt(unsigned Opc)
Return true if this is an unscaled load/store.
return AArch64::GPR64RegClass contains(Reg)
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
iterator_range< succ_iterator > successors()
static const MachineInstrBuilder & AddSubReg(const MachineInstrBuilder &MIB, unsigned Reg, unsigned SubIdx, unsigned State, const TargetRegisterInfo *TRI)
MO_G2 - A symbol operand with this flag (granule 2) represents the bits 32-47 of a 64-bit address...
std::vector< Candidate > Candidates
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
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)
std::pair< MachineOperand, DIExpression * > ParamLoadedValue
A description of a memory reference used in the backend.
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.
bool isAssociativeAndCommutative(const MachineInstr &Inst) const override
Return true when Inst is associative and commutative so that it can be reassociated.
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
static bool isSEHInstruction(const MachineInstr &MI)
Return true if the instructions is a SEH instruciton used for unwinding on Windows.
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
static void suppressLdStPair(MachineInstr &MI)
Hint that pairing the given load or store is unprofitable.
const HexagonInstrInfo * TII
static bool isPairableLdStInst(const MachineInstr &MI)
Return true if pairing the given load or store may be paired with another.
static AArch64CC::CondCode findCondCodeUsedByInstr(const MachineInstr &Instr)
Find a condition code used by the instruction.
static bool canBeExpandedToORR(const MachineInstr &MI, unsigned BitSize)
Returns true if a MOVi32imm or MOVi64imm can be expanded to an ORRxx.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
const TargetRegisterClass * getRegClassConstraint(unsigned OpIdx, const TargetInstrInfo *TII, const TargetRegisterInfo *TRI) const
Compute the static register class constraint for operand OpIdx.
unsigned getNumOperands() const
Retuns the total number of operands.
static bool isSVEScaledImmInstruction(unsigned Opcode)
MachineBasicBlock::iterator insertOutlinedCall(Module &M, MachineBasicBlock &MBB, MachineBasicBlock::iterator &It, MachineFunction &MF, const outliner::Candidate &C) const override
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
MachineOutlinerClass
Constants defining how certain sequences should be outlined.
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
bool useMachineCombiner() const override
AArch64 supports MachineCombiner.
bool isTerminator(QueryType Type=AnyInBundle) const
Returns true if this instruction part of the terminator for a basic block.
static int getRegClass(RegisterKind Is, unsigned RegWidth)
unsigned FrameConstructionID
Target-defined identifier for constructing a frame for this function.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
static UsedNZCV getUsedNZCV(AArch64CC::CondCode CC)
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
static bool isFalkorShiftExtFast(const MachineInstr &MI)
Returns true if the instruction has a shift by immediate that can be executed in one cycle less...
static bool canCombineWithMUL(MachineBasicBlock &MBB, MachineOperand &MO, unsigned MulOpc, unsigned ZeroReg)
static 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...
const char * getSymbolName() const
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...
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, unsigned base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
static Register genNeg(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr *> &InsInstrs, DenseMap< unsigned, unsigned > &InstrIdxForVirtReg, unsigned MnegOpc, const TargetRegisterClass *RC)
genNeg - Helper to generate an intermediate negation of the second operand of Root ...
static void signOutlinedFunction(MachineFunction &MF, MachineBasicBlock &MBB, bool ShouldSignReturnAddr, bool ShouldSignReturnAddrWithAKey)
const MachineInstrBuilder & addDef(Register RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register definition operand.
INLINEASM - Represents an inline asm block.
static bool isCombineInstrCandidate64(unsigned Opc)
MachineInstr * getVRegDef(unsigned Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
int64_t getScalableBytes() const
Returns the scalable part of the offset in bytes.
Used to describe a register and immediate addition.
int getDwarfRegNum(MCRegister RegNum, bool isEH) const
Map a target register to an equivalent dwarf register number.
static bool shouldClusterFI(const MachineFrameInfo &MFI, int FI1, int64_t Offset1, unsigned Opcode1, int FI2, int64_t Offset2, unsigned Opcode2)
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
AArch64InstrInfo(const AArch64Subtarget &STI)
void clearKillFlags(unsigned Reg) const
clearKillFlags - Iterate over all the uses of the given register and clear the kill flag from the Mac...
MO_GOT - This flag indicates that a symbol operand represents the address of the GOT entry for the sy...
bool available(MCPhysReg Reg) const
Returns true if no part of physical register Reg is live.
virtual Optional< ParamLoadedValue > describeLoadedValue(const MachineInstr &MI, Register Reg) const
Produce the expression describing the MI loading a value into the physical register Reg...
unsigned getInstSizeInBytes(const MachineInstr &MI) const override
GetInstSize - Return the number of bytes of code the specified instruction may be.
Register getSubReg(MCRegister Reg, unsigned Idx) const
Returns the physical register number of sub-register "Index" for physical register RegNo...
static bool canCombineWithFMUL(MachineBasicBlock &MBB, MachineOperand &MO, unsigned MulOpc)
GlobalValue * getNamedValue(StringRef Name) const
Return the global value in the module with the specified name, of arbitrary type. ...
virtual bool getMachineCombinerPatterns(MachineInstr &Root, SmallVectorImpl< MachineCombinerPattern > &Patterns) const
Return true when there is potentially a faster code sequence for an instruction chain ending in Root...
const MachineInstrBuilder & addGlobalAddress(const GlobalValue *GV, int64_t Offset=0, unsigned TargetFlags=0) const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
reverse_iterator getReverse() const
Get a reverse iterator to the same node.
iterator getLastNonDebugInstr()
Returns an iterator to the last non-debug instruction in the basic block, or end().
bool canInsertSelect(const MachineBasicBlock &, ArrayRef< MachineOperand > Cond, unsigned, unsigned, int &, int &, int &) const override
static bool canCombine(MachineBasicBlock &MBB, MachineOperand &MO, unsigned CombineOpc, unsigned ZeroReg=0, bool CheckZeroReg=false)
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
virtual const TargetInstrInfo * getInstrInfo() const
static const MachineMemOperand::Flags MOSuppressPair
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
bool isMBBSafeToOutlineFrom(MachineBasicBlock &MBB, unsigned &Flags) const override
unsigned getUndefRegState(bool B)
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
static bool canPairLdStOpc(unsigned FirstOpc, unsigned SecondOpc)
const TargetRegisterClass * constrainRegClass(unsigned Reg, const TargetRegisterClass *RC, unsigned MinNumRegs=0)
constrainRegClass - Constrain the register class of the specified virtual register to be a common sub...
reverse_iterator rbegin()
int64_t getBytes() const
Returns the non-scalable part of the offset in bytes.
Instances of this class represent a single low-level machine instruction.
unsigned getKillRegState(bool B)
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
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 ChangeToImmediate(int64_t ImmVal)
ChangeToImmediate - Replace this operand with a new immediate operand of the specified value...
void copyGPRRegTuple(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, DebugLoc DL, unsigned DestReg, unsigned SrcReg, bool KillSrc, unsigned Opcode, unsigned ZeroReg, llvm::ArrayRef< unsigned > Indices) const
Flag
These should be considered private to the implementation of the MCInstrDesc class.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
TargetInstrInfo - Interface to description of machine instruction set.
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
static bool isCondBranchOpcode(int Opc)
bool isIdenticalTo(const MachineOperand &Other) const
Returns true if this operand is identical to the specified operand except for liveness related flags ...
This class is intended to be used as a base class for asm properties and features specific to the tar...
unsigned getDefRegState(bool B)
MachineBasicBlock::iterator & back()
static bool isCombineInstrCandidateFP(const MachineInstr &Inst)
static unsigned getShiftValue(unsigned Imm)
getShiftValue - Extract the shift value.
bool operator|=(SparseBitVector< ElementSize > &LHS, const SparseBitVector< ElementSize > *RHS)
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
unsigned getObjectAlignment(int ObjectIdx) const
Return the alignment of the specified stack object.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata *> MDs)
bool hasLinkOnceODRLinkage() const
initializer< Ty > init(const Ty &Val)
const MachineInstrBuilder & addUse(Register RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register use operand.
MachineInstrBundleIterator< MachineInstr > iterator
static MCCFIInstruction createNegateRAState(MCSymbol *L)
.cfi_negate_ra_state AArch64 negate RA state.
unsigned UnsafeFPMath
UnsafeFPMath - This flag is enabled when the -enable-unsafe-fp-math flag is specified on the command ...
FPOpFusion::FPOpFusionMode AllowFPOpFusion
AllowFPOpFusion - This flag is set by the -fuse-fp-ops=xxx option.
const AArch64RegisterInfo & getRegisterInfo() const
getRegisterInfo - TargetInstrInfo is a superset of MRegister info.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
bool LRUWasSet
True if initLRU has been called on this Candidate.
MO_G1 - A symbol operand with this flag (granule 1) represents the bits 16-31 of a 64-bit address...
unsigned const MachineRegisterInfo * MRI
ArrayRef< MachineMemOperand * > memoperands() const
Access to memory operands of the instruction.
InstrType
Represents how an instruction should be mapped by the outliner.
LiveRegUnits UsedInSequence
Contains the accumulated register liveness information for the instructions in this Candidate...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void genAlternativeCodeSequence(MachineInstr &Root, MachineCombinerPattern Pattern, SmallVectorImpl< MachineInstr *> &InsInstrs, SmallVectorImpl< MachineInstr *> &DelInstrs, DenseMap< unsigned, unsigned > &InstrIdxForVirtReg) const override
When getMachineCombinerPatterns() finds patterns, this function generates the instructions that could...
bool hasExynosCheapAsMoveHandling() const
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, bool KillSrc) const override
unsigned CallConstructionID
Identifier denoting the instructions to emit to call an outlined function from this point...
static cl::opt< unsigned > BCCDisplacementBits("aarch64-bcc-offset-bits", cl::Hidden, cl::init(19), cl::desc("Restrict range of Bcc instructions (DEBUG)"))
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
size_t size() const
size - Get the array size.
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static AArch64_AM::ShiftExtendType getArithExtendType(unsigned Imm)
The information necessary to create an outlined function for some class of candidate.
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.
void setCallInfo(unsigned CID, unsigned CO)
Set the CallConstructionID and CallOverhead of this candidate to CID and CO respectively.
bool isFixedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a fixed stack object.
void getForFrameOffset(int64_t &NumBytes, int64_t &NumPredicateVectors, int64_t &NumDataVectors) const
Returns the offset in parts to which this frame offset can be decomposed for the purpose of describin...
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...
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
bool getMemOperandWithOffset(const MachineInstr &MI, const MachineOperand *&BaseOp, int64_t &Offset, const TargetRegisterInfo *TRI) const override
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 bool canInstrSubstituteCmpInstr(MachineInstr *MI, MachineInstr *CmpInstr, const TargetRegisterInfo *TRI)
Check if CmpInstr can be substituted by MI.
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
bool definesRegister(Register Reg, const TargetRegisterInfo *TRI=nullptr) const
Return true if the MachineInstr fully defines the specified register.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
void setImm(int64_t immVal)
bool def_empty(unsigned RegNo) const
def_empty - Return true if there are no instructions defining the specified register (it may be live-...
bool isSuperRegister(MCRegister RegA, MCRegister RegB) const
Returns true if RegB is a super-register of RegA.
MI-level patchpoint operands.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
self_iterator getIterator()
bool isBranchOffsetInRange(unsigned BranchOpc, int64_t BrOffset) const override
bool isAsCheapAsAMove(const MachineInstr &MI) const override
bool expandPostRAPseudo(MachineInstr &MI) const override
auto find_if(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly...
auto remove_if(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::remove_if which take ranges instead of having to pass begin/end explicitly...
uint16_t getEncodingValue(MCRegister RegNo) const
Returns the encoding for RegNo.
const MachineInstrBuilder & addFrameIndex(int Idx) const
bool isThroughputPattern(MachineCombinerPattern Pattern) const override
Return true when a code sequence can improve throughput.
void setStackID(int ObjectIdx, uint8_t ID)
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
MachineCombinerPattern
These are instruction patterns matched by the machine combiner pass.
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)
bool isSuperRegisterEq(MCRegister RegA, MCRegister RegB) const
Returns true if RegB is a super-register of RegA or if RegB == RegA.
bool getMachineCombinerPatterns(MachineInstr &Root, SmallVectorImpl< MachineCombinerPattern > &Patterns) const override
Return true when there is potentially a faster code sequence for an instruction chain ending in Root...
bool isSchedulingBoundary(const MachineInstr &MI, const MachineBasicBlock *MBB, const MachineFunction &MF) const override
MO_HI12 - This flag indicates that a symbol operand represents the bits 13-24 of a 64-bit address...
bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
ArrayRef< std::pair< unsigned, const char * > > getSerializableDirectMachineOperandTargetFlags() const override
MachineBasicBlock::iterator & front()
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
static unsigned getLoadStoreImmIdx(unsigned Opc)
Returns the index for the immediate for a given instruction.
void insertSelect(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, unsigned DstReg, ArrayRef< MachineOperand > Cond, unsigned TrueReg, unsigned FalseReg) const override
Emit a call and tail-call.
bool isDebugInstr() const
This class contains a discriminated union of information about pointers in memory operands...
MO_TLS - Indicates that the operand being accessed is some kind of thread-local symbol.
bool isCoalescableExtInstr(const MachineInstr &MI, unsigned &SrcReg, unsigned &DstReg, unsigned &SubIdx) const override
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
unsigned getNumExplicitOperands() const
Returns the number of non-implicit operands.
This struct is a compact representation of a valid (non-zero power of two) alignment.
bool hasSubClassEq(const TargetRegisterClass *RC) const
Returns true if RC is a sub-class of or equal to this class.
bool getMemOperandWithOffsetWidth(const MachineInstr &MI, const MachineOperand *&BaseOp, int64_t &Offset, unsigned &Width, const TargetRegisterInfo *TRI) const
void setIsKill(bool Val=true)
static MachineInstr * genFusedMultiplyAccNeg(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr *> &InsInstrs, DenseMap< unsigned, unsigned > &InstrIdxForVirtReg, unsigned IdxMulOpd, unsigned MaddOpc, unsigned MnegOpc, const TargetRegisterClass *RC)
genFusedMultiplyAccNeg - Helper to generate fused multiply accumulate instructions with an additional...
ArrayRef< std::pair< MachineMemOperand::Flags, const char * > > getSerializableMachineMemOperandTargetFlags() const override
The memory access writes data.
static unsigned canFoldIntoCSel(const MachineRegisterInfo &MRI, unsigned VReg, unsigned *NewVReg=nullptr)
static uint64_t encodeLogicalImmediate(uint64_t imm, unsigned regSize)
encodeLogicalImmediate - Return the encoded immediate value for a logical immediate instruction of th...
uint32_t getNumPatchBytes() const
Return the number of patchable bytes the given stackmap should emit.
static bool isIndirectBranchOpcode(int Opc)
bool readsRegister(Register Reg, const TargetRegisterInfo *TRI=nullptr) const
Return true if the MachineInstr reads the specified register.
virtual bool isSchedulingBoundary(const MachineInstr &MI, const MachineBasicBlock *MBB, const MachineFunction &MF) const
Test if the given instruction should be considered a scheduling boundary.
void setOpcode(unsigned Op)
static bool isUncondBranchOpcode(int Opc)
void getNoop(MCInst &NopInst) const override
bool shouldOutlineFromFunctionByDefault(MachineFunction &MF) const override
void setDesc(const MCInstrDesc &tid)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one...
static bool getMemOpInfo(unsigned Opcode, unsigned &Scale, unsigned &Width, int64_t &MinOffset, int64_t &MaxOffset)
Returns true if opcode Opc is a memory operation.
BlockVerifier::State From
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
bool isCandidateToMergeOrPair(const MachineInstr &MI) const
Return true if this is a load/store that can be potentially paired/merged.
static uint64_t add(uint64_t LeftOp, uint64_t RightOp)
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.
bool hasSection() const
Check if this global has a custom object file section.
static void parseCondBranch(MachineInstr *LastInst, MachineBasicBlock *&Target, SmallVectorImpl< MachineOperand > &Cond)
MachineInstrBuilder MachineInstrBuilder & DefMI
bool modifiesRegister(Register Reg, const TargetRegisterInfo *TRI) const
Return true if the MachineInstr modifies (fully define or partially define) the specified register...
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
bool hasOrderedMemoryRef() const
Return true if this instruction may have an ordered or volatile memory reference, or if the informati...
static bool isCombineInstrCandidate(unsigned Opc)
outliner::InstrType getOutliningType(MachineBasicBlock::iterator &MIT, unsigned Flags) const override
bool optimizeCondBranch(MachineInstr &MI) const override
Replace csincr-branch sequence by simple conditional branch.
MachineInstr * getUniqueVRegDef(unsigned Reg) const
getUniqueVRegDef - Return the unique machine instr that defines the specified virtual register or nul...
const Function & getFunction() const
Return the LLVM function that this machine code represents.
bool areMemAccessesTriviallyDisjoint(const MachineInstr &MIa, const MachineInstr &MIb) const override
bool needsUnwindTableEntry() const
True if this function needs an unwind table.
unsigned isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
bool isSubRegister(MCRegister RegA, MCRegister RegB) const
Returns true if RegB is a sub-register of RegA.
Target - Wrapper for Target specific information.
amdgpu Simplify well known AMD library false FunctionCallee Callee
static bool getMaddPatterns(MachineInstr &Root, SmallVectorImpl< MachineCombinerPattern > &Patterns)
Find instructions that can be turned into madd.
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
static unsigned convertToFlagSettingOpc(unsigned Opc, bool &Is64Bit)
Return the opcode that set flags when possible.
int findRegisterUseOperandIdx(Register Reg, bool isKill=false, const TargetRegisterInfo *TRI=nullptr) const
Returns the operand index that is a use of the specific register or -1 if it is not found...
static cl::opt< unsigned > TBZDisplacementBits("aarch64-tbz-offset-bits", cl::Hidden, cl::init(14), cl::desc("Restrict range of TB[N]Z instructions (DEBUG)"))
Optional< bool > hasRedZone() const
MO_S - Indicates that the bits of the symbol operand represented by MO_G0 etc are signed...
CATCHRET - Represents a return from a catch block funclet.
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
The memory access reads data.
TargetSubtargetInfo - Generic base class for all target subtargets.
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 ...
LLVM_NODISCARD bool equals(StringRef RHS) const
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
bool isReservedReg(const MachineFunction &MF, unsigned Reg) const
Representation of each machine instruction.
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify=false) const override
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
static bool isGPRZero(const MachineInstr &MI)
Does this instruction set its full destination register to zero?
void copyPhysRegTuple(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, bool KillSrc, unsigned Opcode, llvm::ArrayRef< unsigned > Indices) const
bool optimizeCompareInstr(MachineInstr &CmpInstr, unsigned SrcReg, unsigned SrcReg2, int CmpMask, int CmpValue, const MachineRegisterInfo *MRI) const override
optimizeCompareInstr - Convert the instruction supplying the argument to the comparison into one that...
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
bool analyzeCompare(const MachineInstr &MI, unsigned &SrcReg, unsigned &SrcReg2, int &CmpMask, int &CmpValue) const override
analyzeCompare - For a comparison instruction, return the source registers in SrcReg and SrcReg2...
static AArch64_AM::ShiftExtendType getShiftType(unsigned Imm)
getShiftType - Extract the shift type.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
const MachineInstrBuilder & setMIFlags(unsigned Flags) const
MI-level stackmap operands.
virtual void genAlternativeCodeSequence(MachineInstr &Root, MachineCombinerPattern Pattern, SmallVectorImpl< MachineInstr *> &InsInstrs, SmallVectorImpl< MachineInstr *> &DelInstrs, DenseMap< unsigned, unsigned > &InstIdxForVirtReg) const
When getMachineCombinerPatterns() finds patterns, this function generates the instructions that could...
MO_COFFSTUB - On a symbol operand "FOO", this indicates that the reference is actually to the "...
unsigned getMatchingSuperReg(unsigned Reg, unsigned SubIdx, const TargetRegisterClass *RC) const
Return a super-register of the specified register Reg so its sub-register of index SubIdx is Reg...
StringRef getValueAsString() const
Return the attribute's value as a string.
static bool areCFlagsAliveInSuccessors(MachineBasicBlock *MBB)
Check if AArch64::NZCV should be alive in successors of MBB.
MO_DLLIMPORT - On a symbol operand, this represents that the reference to the symbol is for an import...
Optional< RegImmPair > isAddImmediate(const MachineInstr &MI, Register Reg) const override
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
StringRef getName() const
Return a constant reference to the value's name.
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
static Optional< unsigned > getUnscaledLdSt(unsigned Opc)
Returns the unscaled load/store for the scaled load/store opcode, if there is a corresponding unscale...
static MachineOperand CreateImm(int64_t Val)
void ChangeToRegister(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isDebug=false)
ChangeToRegister - Replace this operand with a new register operand of the specified value...
MO_PAGEOFF - A symbol operand with this flag represents the offset of that symbol within a 4K page...
void setSubReg(unsigned subReg)
bool hasMinSize() const
Optimize this function for minimum size (-Oz).
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
static MachineInstr * genFusedMultiplyIdxNeg(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr *> &InsInstrs, DenseMap< unsigned, unsigned > &InstrIdxForVirtReg, unsigned IdxMulOpd, unsigned MaddOpc, unsigned MnegOpc, const TargetRegisterClass *RC)
genFusedMultiplyAccNeg - Helper to generate fused multiply accumulate instructions with an additional...
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.
bool tracksLiveness() const
tracksLiveness - Returns true when tracking register liveness accurately.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
bool isFunctionSafeToOutlineFrom(MachineFunction &MF, bool OutlineFromLinkOnceODRs) const override
bool isSuperOrSubRegisterEq(MCRegister RegA, MCRegister RegB) const
Returns true if RegB is a super-register or sub-register of RegA or if RegB == RegA.
uint32_t getNumPatchBytes() const
Return the number of patchable bytes the given patchpoint should emit.
static unsigned getBranchDisplacementBits(unsigned Opc)
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
bool hasOneNonDBGUse(unsigned RegNo) const
hasOneNonDBGUse - Return true if there is exactly one non-Debug use of the specified register...
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
static void storeRegPairToStackSlot(const TargetRegisterInfo &TRI, MachineBasicBlock &MBB, MachineBasicBlock::iterator InsertBefore, const MCInstrDesc &MCID, unsigned SrcReg, bool IsKill, unsigned SubIdx0, unsigned SubIdx1, int FI, MachineMemOperand *MMO)
A set of register units used to track register liveness.
constexpr int64_t SignExtend64(uint64_t x)
Sign-extend the number in the bottom B bits of X to a 64-bit integer.
LLVM_NODISCARD bool empty() const
const TargetRegisterClass * getMinimalPhysRegClass(unsigned Reg, MVT VT=MVT::Other) const
Returns the Register Class of a physical register of the given type, picking the most sub register cl...
bool isReg() const
isReg - Tests if this is a MO_Register operand.
static unsigned removeCopies(const MachineRegisterInfo &MRI, unsigned VReg)
static bool isCombineInstrCandidate32(unsigned Opc)
static bool outliningCandidatesSigningScopeConsensus(const outliner::Candidate &a, const outliner::Candidate &b)
bool hasZeroCycleZeroingFP() const
static bool scaleOffset(unsigned Opc, int64_t &Offset)
bool memoperands_empty() const
Return true if we don't have any memory operands which described the memory access done by this instr...
static bool outliningCandidatesV8_3OpsConsensus(const outliner::Candidate &a, const outliner::Candidate &b)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MachineBasicBlock * getBranchDestBlock(const MachineInstr &MI) const override
INLINEASM_BR - Terminator version of inline asm. Used by asm-goto.
bool hasZeroCycleZeroingGP() const
void addRegisterDefined(Register Reg, const TargetRegisterInfo *RegInfo=nullptr)
We have determined MI defines a register.
static void loadRegPairFromStackSlot(const TargetRegisterInfo &TRI, MachineBasicBlock &MBB, MachineBasicBlock::iterator InsertBefore, const MCInstrDesc &MCID, unsigned DestReg, unsigned SubIdx0, unsigned SubIdx1, int FI, MachineMemOperand *MMO)
std::pair< unsigned, unsigned > decomposeMachineOperandsTargetFlags(unsigned TF) const override
const AArch64InstrInfo * getInstrInfo() const override
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
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...
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
unsigned getOpcode() const
Return the opcode number for this descriptor.
Primary interface to the complete machine description for the target machine.
bool hasUnmodeledSideEffects() const
Return true if this instruction has side effects that are not modeled by mayLoad / mayStore...
void addOperand(const MCOperand &Op)
StringRef - Represent a constant reference to a string, i.e.
MO_NC - Indicates whether the linker is expected to check the symbol reference for overflow...
void RemoveOperand(unsigned OpNo)
Erase an operand from an instruction, leaving it with one fewer operand than it started with...
unsigned getRegSizeInBits(const TargetRegisterClass &RC) const
Return the size in bits of a register from class RC.
MachineOperand & getMemOpBaseRegImmOfsOffsetOperand(MachineInstr &LdSt) const
Return the immediate offset of the base register in a load/store LdSt.
Register getReg() const
getReg - Returns the register number.
UnaryPredicate for_each(R &&Range, UnaryPredicate P)
Provide wrappers to std::for_each which take ranges instead of having to pass begin/end explicitly...
MachineInstr * foldMemoryOperandImpl(MachineFunction &MF, MachineInstr &MI, ArrayRef< unsigned > Ops, MachineBasicBlock::iterator InsertPt, int FrameIndex, LiveIntervals *LIS=nullptr, VirtRegMap *VRM=nullptr) const override
static bool isCombineInstrSettingFlag(unsigned Opc)
const MachineOperand & getOperand(unsigned i) const
outliner::OutlinedFunction getOutliningCandidateInfo(std::vector< outliner::Candidate > &RepeatedSequenceLocs) const override
bool isIndirectDebugValue() const
A DBG_VALUE is indirect iff the first operand is a register and the second operand is an immediate...
bool rewriteAArch64FrameIndex(MachineInstr &MI, unsigned FrameRegIdx, unsigned FrameReg, StackOffset &Offset, const AArch64InstrInfo *TII)
rewriteAArch64FrameIndex - Rewrite MI to access 'Offset' bytes from the FP.
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects...
static MCOperand createImm(int64_t Val)
MachineFunction * getMF() const
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.
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
The operation is expected to be selectable directly by the target, and no transformation is necessary...
bool getFlag(MIFlag Flag) const
Return whether an MI flag is set.
unsigned Log2_64(uint64_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
static const MachineMemOperand::Flags MOStridedAccess
static bool forwardCopyWillClobberTuple(unsigned DestReg, unsigned SrcReg, unsigned NumRegs)
bool isAsCheapAsAMove(QueryType Type=AllInBundle) const
Returns true if this instruction has the same cost (or less) than a move instruction.
static bool UpdateOperandRegClass(MachineInstr &Instr)
Wrapper class representing virtual and physical registers.
bool empty() const
empty - Check if the array is empty.
void buildOutlinedFrame(MachineBasicBlock &MBB, MachineFunction &MF, const outliner::OutlinedFunction &OF) const override
static int getMemScale(unsigned Opc)
Scaling factor for (scaled or unscaled) load or store.
static bool isADDSRegImm(unsigned Opcode)