70 #define DEBUG_TYPE "arm-ldst-opt" 72 STATISTIC(NumLDMGened ,
"Number of ldm instructions generated");
73 STATISTIC(NumSTMGened ,
"Number of stm instructions generated");
74 STATISTIC(NumVLDMGened,
"Number of vldm instructions generated");
75 STATISTIC(NumVSTMGened,
"Number of vstm instructions generated");
76 STATISTIC(NumLdStMoved,
"Number of load / store instructions moved");
77 STATISTIC(NumLDRDFormed,
"Number of ldrd created before allocation");
78 STATISTIC(NumSTRDFormed,
"Number of strd created before allocation");
79 STATISTIC(NumLDRD2LDM,
"Number of ldrd instructions turned back into ldm");
80 STATISTIC(NumSTRD2STM,
"Number of strd instructions turned back into stm");
81 STATISTIC(NumLDRD2LDR,
"Number of ldrd instructions turned back into ldr's");
82 STATISTIC(NumSTRD2STR,
"Number of strd instructions turned back into str's");
93 #define ARM_LOAD_STORE_OPT_NAME "ARM load / store optimization pass" 112 bool RegClassInfoValid;
113 bool isThumb1, isThumb2;
129 struct MemOpQueueEntry {
134 MemOpQueueEntry(
MachineInstr &MI,
int Offset,
unsigned Position)
141 struct MergeCandidate {
146 unsigned LatestMIIdx;
149 unsigned EarliestMIIdx;
156 bool CanMergeToLSMulti;
159 bool CanMergeToLSDouble;
170 unsigned Base,
unsigned WordOffset,
174 int Offset,
unsigned Base,
bool BaseKill,
unsigned Opcode,
176 ArrayRef<std::pair<unsigned, bool>> Regs,
180 int Offset,
unsigned Base,
bool BaseKill,
unsigned Opcode,
182 ArrayRef<std::pair<unsigned, bool>> Regs,
184 void FormCandidates(
const MemOpQueue &MemOps);
185 MachineInstr *MergeOpsUpdate(
const MergeCandidate &Cand);
204 for (
const auto &MO : MI.operands()) {
207 if (MO.isDef() && MO.getReg() == ARM::CPSR && !MO.isDead())
218 bool isAM3 = Opcode == ARM::LDRD || Opcode == ARM::STRD;
222 if (Opcode == ARM::t2LDRi12 || Opcode == ARM::t2LDRi8 ||
223 Opcode == ARM::t2STRi12 || Opcode == ARM::t2STRi8 ||
224 Opcode == ARM::t2LDRDi8 || Opcode == ARM::t2STRDi8 ||
225 Opcode == ARM::LDRi12 || Opcode == ARM::STRi12)
229 if (Opcode == ARM::tLDRi || Opcode == ARM::tSTRi ||
230 Opcode == ARM::tLDRspi || Opcode == ARM::tSTRspi)
346 case ARM::tLDMIA_UPD:
347 case ARM::tSTMIA_UPD:
348 case ARM::t2LDMIA_RET:
350 case ARM::t2LDMIA_UPD:
352 case ARM::t2STMIA_UPD:
354 case ARM::VLDMSIA_UPD:
356 case ARM::VSTMSIA_UPD:
358 case ARM::VLDMDIA_UPD:
360 case ARM::VSTMDIA_UPD:
374 case ARM::t2LDMDB_UPD:
376 case ARM::t2STMDB_UPD:
377 case ARM::VLDMSDB_UPD:
378 case ARM::VSTMSDB_UPD:
379 case ARM::VLDMDDB_UPD:
380 case ARM::VSTMDDB_UPD:
392 return Opc == ARM::tLDRi || Opc == ARM::tLDRspi;
396 return Opc == ARM::t2LDRi12 || Opc == ARM::t2LDRi8;
404 return Opc == ARM::tSTRi || Opc == ARM::tSTRspi;
408 return Opc == ARM::t2STRi12 || Opc == ARM::t2STRi8;
416 return isi32Load(Opc) || Opc == ARM::VLDRS || Opc == ARM::VLDRD;
464 case ARM::tLDMIA_UPD:
465 case ARM::tSTMIA_UPD:
487 assert(isThumb1 &&
"Can only update base register uses for Thumb1!");
490 for (; MBBI != MBB.
end(); ++MBBI) {
491 bool InsertSub =
false;
492 unsigned Opc = MBBI->getOpcode();
494 if (MBBI->readsRegister(Base)) {
497 Opc == ARM::tLDRi || Opc == ARM::tLDRHi || Opc == ARM::tLDRBi;
499 Opc == ARM::tSTRi || Opc == ARM::tSTRHi || Opc == ARM::tSTRBi;
501 if (IsLoad || IsStore) {
507 MBBI->getOperand(MBBI->getDesc().getNumOperands() - 3);
514 if (Offset >= 0 && !(IsStore && InstrSrcReg == Base))
518 }
else if ((Opc == ARM::tSUBi8 || Opc == ARM::tADDi8) &&
519 !definesCPSR(*MBBI)) {
524 MBBI->getOperand(MBBI->getDesc().getNumOperands() - 3);
525 Offset = (Opc == ARM::tSUBi8) ?
526 MO.
getImm() + WordOffset * 4 :
527 MO.
getImm() - WordOffset * 4 ;
528 if (Offset >= 0 && TL->isLegalAddImmediate(Offset)) {
541 }
else if (definesCPSR(*MBBI) || MBBI->isCall() || MBBI->isBranch()) {
550 BuildMI(MBB, MBBI, DL,
TII->get(ARM::tSUBi8), Base)
553 .addImm(WordOffset * 4)
559 if (MBBI->killsRegister(Base) || MBBI->definesRegister(Base))
570 if (MBBI != MBB.
end()) --MBBI;
571 BuildMI(MBB, MBBI, DL,
TII->get(ARM::tSUBi8), Base)
574 .addImm(WordOffset * 4)
582 if (!RegClassInfoValid) {
583 RegClassInfo.runOnMachineFunction(*MF);
584 RegClassInfoValid =
true;
587 for (
unsigned Reg : RegClassInfo.getOrder(&RegClass))
588 if (!LiveRegs.contains(
Reg))
599 if (!LiveRegsValid) {
601 LiveRegs.addLiveOuts(MBB);
602 LiveRegPos = MBB.
end();
603 LiveRegsValid =
true;
606 while (LiveRegPos != Before) {
608 LiveRegs.stepBackward(*LiveRegPos);
614 for (
const std::pair<unsigned, bool> &R : Regs)
625 int Offset,
unsigned Base,
bool BaseKill,
unsigned Opcode,
627 ArrayRef<std::pair<unsigned, bool>> Regs,
629 unsigned NumRegs = Regs.size();
634 bool SafeToClobberCPSR = !isThumb1 ||
638 bool Writeback = isThumb1;
644 assert(Base != ARM::SP &&
"Thumb1 does not allow SP in register list");
645 if (Opcode == ARM::tLDRi)
647 else if (Opcode == ARM::tSTRi)
654 bool haveIBAndDA = isNotVFP && !isThumb2 && !isThumb1;
656 if (Offset == 4 && haveIBAndDA) {
658 }
else if (Offset == -4 * (
int)NumRegs + 4 && haveIBAndDA) {
660 }
else if (Offset == -4 * (
int)NumRegs && isNotVFP && !isThumb1) {
663 }
else if (Offset != 0 || Opcode == ARM::tLDRspi || Opcode == ARM::tSTRspi) {
676 if (!SafeToClobberCPSR)
683 NewBase = Regs[NumRegs-1].first;
687 moveLiveRegsBefore(MBB, InsertBefore);
691 for (
const std::pair<unsigned, bool> &R : Regs)
692 LiveRegs.addReg(R.first);
694 NewBase = findFreeReg(isThumb1 ? ARM::tGPRRegClass : ARM::GPRRegClass);
699 int BaseOpc = isThumb2 ? (BaseKill && Base == ARM::SP ? ARM::t2ADDspImm
701 : (isThumb1 && Base == ARM::SP)
703 : (isThumb1 && Offset < 8)
705 : isThumb1 ? ARM::tADDi8 : ARM::ADDri;
711 BaseOpc = isThumb2 ? (BaseKill && Base == ARM::SP ? ARM::t2SUBspImm
713 : (isThumb1 && Offset < 8 && Base != ARM::SP)
715 : isThumb1 ? ARM::tSUBi8 : ARM::SUBri;
718 if (!TL->isLegalAddImmediate(Offset))
724 bool KillOldBase = BaseKill &&
733 if (Base != NewBase &&
734 (BaseOpc == ARM::tADDi8 || BaseOpc == ARM::tSUBi8)) {
741 BuildMI(MBB, InsertBefore, DL,
TII->get(ARM::tMOVSr), NewBase)
744 BuildMI(MBB, InsertBefore, DL,
TII->get(ARM::tMOVr), NewBase)
752 if (BaseOpc == ARM::tADDrSPi) {
753 assert(Offset % 4 == 0 &&
"tADDrSPi offset is scaled by 4");
754 BuildMI(MBB, InsertBefore, DL,
TII->get(BaseOpc), NewBase)
759 BuildMI(MBB, InsertBefore, DL,
TII->get(BaseOpc), NewBase)
765 BuildMI(MBB, InsertBefore, DL,
TII->get(BaseOpc), NewBase)
791 if (isThumb1 && !SafeToClobberCPSR && Writeback && !BaseKill)
797 assert(isThumb1 &&
"expected Writeback only inThumb1");
798 if (Opcode == ARM::tLDMIA) {
801 Opcode = ARM::tLDMIA_UPD;
804 MIB =
BuildMI(MBB, InsertBefore, DL,
TII->get(Opcode));
813 UpdateBaseRegUses(MBB, InsertBefore, DL, Base, NumRegs, Pred, PredReg);
816 MIB =
BuildMI(MBB, InsertBefore, DL,
TII->get(Opcode));
822 for (
const std::pair<unsigned, bool> &R : Regs)
832 int Offset,
unsigned Base,
bool BaseKill,
unsigned Opcode,
834 ArrayRef<std::pair<unsigned, bool>> Regs,
837 assert((IsLoad ||
isi32Store(Opcode)) &&
"Must have integer load or store");
838 unsigned LoadStoreOpcode = IsLoad ? ARM::t2LDRDi8 : ARM::t2STRDi8;
842 TII->get(LoadStoreOpcode));
856 MachineInstr *ARMLoadStoreOpt::MergeOpsUpdate(
const MergeCandidate &Cand) {
868 bool IsKill = MO.
isKill();
871 Regs.
push_back(std::make_pair(Reg, IsKill));
898 iterator InsertBefore = std::next(iterator(LatestMI));
903 unsigned PredReg = 0;
907 if (Cand.CanMergeToLSDouble)
908 Merged = CreateLoadStoreDouble(MBB, InsertBefore, Offset, Base, BaseKill,
909 Opcode, Pred, PredReg, DL, Regs,
911 if (!Merged && Cand.CanMergeToLSMulti)
912 Merged = CreateLoadStoreMulti(MBB, InsertBefore, Offset, Base, BaseKill,
913 Opcode, Pred, PredReg, DL, Regs, Cand.Instrs);
919 iterator EarliestI(Cand.Instrs[Cand.EarliestMIIdx]);
920 bool EarliestAtBegin =
false;
921 if (EarliestI == MBB.
begin()) {
922 EarliestAtBegin =
true;
924 EarliestI = std::prev(EarliestI);
933 EarliestI = MBB.
begin();
935 EarliestI = std::next(EarliestI);
936 auto FixupRange =
make_range(EarliestI, iterator(Merged));
942 for (
unsigned &ImpDefReg : ImpDefs) {
944 if (!MO.isReg() || MO.getReg() != ImpDefReg)
955 for (
unsigned ImpDef : ImpDefs)
962 if (!MO.isReg() || !MO.isKill())
964 if (UsedRegs.
count(MO.getReg()))
978 return (Value % 4) == 0 && Value < 1024;
1000 void ARMLoadStoreOpt::FormCandidates(
const MemOpQueue &MemOps) {
1006 unsigned SIndex = 0;
1007 unsigned EIndex = MemOps.size();
1011 int Offset = MemOps[SIndex].Offset;
1015 :
TRI->getEncodingValue(PReg);
1016 unsigned Latest = SIndex;
1017 unsigned Earliest = SIndex;
1019 bool CanMergeToLSDouble =
1023 if (STI->isCortexM3() &&
isi32Load(Opcode) &&
1025 CanMergeToLSDouble =
false;
1027 bool CanMergeToLSMulti =
true;
1030 if (STI->hasSlowOddRegister() && !isNotVFP && (PRegNum % 2) == 1)
1031 CanMergeToLSMulti =
false;
1035 if (PReg == ARM::SP || PReg == ARM::PC)
1036 CanMergeToLSMulti = CanMergeToLSDouble =
false;
1040 CanMergeToLSMulti = CanMergeToLSDouble =
false;
1055 for (
unsigned I = SIndex+1;
I < EIndex; ++
I, ++Count) {
1056 int NewOffset = MemOps[
I].Offset;
1057 if (NewOffset != Offset + (
int)
Size)
1061 if (Reg == ARM::SP || Reg == ARM::PC)
1068 :
TRI->getEncodingValue(Reg);
1069 bool PartOfLSMulti = CanMergeToLSMulti;
1070 if (PartOfLSMulti) {
1072 if (RegNum <= PRegNum)
1073 PartOfLSMulti =
false;
1077 else if (!isNotVFP && RegNum != PRegNum+1)
1078 PartOfLSMulti =
false;
1081 bool PartOfLSDouble = CanMergeToLSDouble && Count <= 1;
1083 if (!PartOfLSMulti && !PartOfLSDouble)
1085 CanMergeToLSMulti &= PartOfLSMulti;
1086 CanMergeToLSDouble &= PartOfLSDouble;
1090 if (Position < MemOps[Latest].Position)
1092 else if (Position > MemOps[Earliest].Position)
1100 MergeCandidate *Candidate =
new(
Allocator.Allocate()) MergeCandidate;
1101 for (
unsigned C = SIndex, CE = SIndex + Count;
C < CE; ++
C)
1102 Candidate->Instrs.push_back(MemOps[
C].MI);
1103 Candidate->LatestMIIdx = Latest - SIndex;
1104 Candidate->EarliestMIIdx = Earliest - SIndex;
1105 Candidate->InsertPos = MemOps[Latest].Position;
1107 CanMergeToLSMulti = CanMergeToLSDouble =
false;
1108 Candidate->CanMergeToLSMulti = CanMergeToLSMulti;
1109 Candidate->CanMergeToLSDouble = CanMergeToLSDouble;
1110 Candidates.push_back(Candidate);
1113 }
while (SIndex < EIndex);
1191 case ARM::tADDi8: Scale = 4; CheckCPSRDef =
true;
break;
1192 case ARM::tSUBi8: Scale = -4; CheckCPSRDef =
true;
break;
1194 case ARM::t2SUBspImm:
1195 case ARM::SUBri: Scale = -1; CheckCPSRDef =
true;
break;
1197 case ARM::t2ADDspImm:
1198 case ARM::ADDri: Scale = 1; CheckCPSRDef =
true;
break;
1199 case ARM::tADDspi: Scale = 4; CheckCPSRDef =
false;
break;
1200 case ARM::tSUBspi: Scale = -4; CheckCPSRDef =
false;
break;
1208 MIPredReg != PredReg)
1211 if (CheckCPSRDef && definesCPSR(MI))
1224 if (MBBI == BeginMBBI)
1229 while (PrevMBBI->isDebugInstr() && PrevMBBI != BeginMBBI)
1233 return Offset == 0 ? EndMBBI : PrevMBBI;
1245 while (NextMBBI != EndMBBI && NextMBBI->isDebugInstr())
1247 if (NextMBBI == EndMBBI)
1251 return Offset == 0 ? EndMBBI : NextMBBI;
1266 bool ARMLoadStoreOpt::MergeBaseUpdateLSMultiple(
MachineInstr *
MI) {
1268 if (isThumb1)
return false;
1272 bool BaseKill = BaseOP.
isKill();
1273 unsigned PredReg = 0;
1291 if (Mode ==
ARM_AM::ia && Offset == -Bytes) {
1293 }
else if (Mode ==
ARM_AM::ib && Offset == -Bytes) {
1304 if (!STI->hasMinSize() || !BaseKill)
1307 bool HighRegsUsed =
false;
1310 HighRegsUsed =
true;
1315 MergeInstr = MBB.
end();
1320 if (MergeInstr != MBB.
end())
1321 MBB.
erase(MergeInstr);
1327 .addImm(Pred).
addReg(PredReg);
1344 return ARM::LDR_PRE_IMM;
1346 return ARM::STR_PRE_IMM;
1348 return Mode ==
ARM_AM::add ? ARM::VLDMSIA_UPD : ARM::VLDMSDB_UPD;
1350 return Mode ==
ARM_AM::add ? ARM::VLDMDIA_UPD : ARM::VLDMDDB_UPD;
1352 return Mode ==
ARM_AM::add ? ARM::VSTMSIA_UPD : ARM::VSTMSDB_UPD;
1354 return Mode ==
ARM_AM::add ? ARM::VSTMDIA_UPD : ARM::VSTMDDB_UPD;
1357 return ARM::t2LDR_PRE;
1360 return ARM::t2STR_PRE;
1369 return ARM::LDR_POST_IMM;
1371 return ARM::STR_POST_IMM;
1373 return Mode ==
ARM_AM::add ? ARM::VLDMSIA_UPD : ARM::VLDMSDB_UPD;
1375 return Mode ==
ARM_AM::add ? ARM::VLDMDIA_UPD : ARM::VLDMDDB_UPD;
1377 return Mode ==
ARM_AM::add ? ARM::VSTMSIA_UPD : ARM::VSTMSDB_UPD;
1379 return Mode ==
ARM_AM::add ? ARM::VSTMDIA_UPD : ARM::VSTMDDB_UPD;
1382 return ARM::t2LDR_POST;
1385 return ARM::t2STR_POST;
1392 bool ARMLoadStoreOpt::MergeBaseUpdateLoadStore(
MachineInstr *MI) {
1395 if (isThumb1)
return false;
1401 bool isAM5 = (Opcode == ARM::VLDRD || Opcode == ARM::VLDRS ||
1402 Opcode == ARM::VSTRD || Opcode == ARM::VSTRS);
1403 bool isAM2 = (Opcode == ARM::LDRi12 || Opcode == ARM::STRi12);
1415 unsigned PredReg = 0;
1424 if (!isAM5 && Offset == Bytes) {
1426 }
else if (Offset == -Bytes) {
1430 if (Offset == Bytes) {
1432 }
else if (!isAM5 && Offset == -Bytes) {
1437 MBB.
erase(MergeInstr);
1451 .addImm(Pred).
addReg(PredReg)
1458 if (NewOpc == ARM::LDR_PRE_IMM || NewOpc == ARM::LDRB_PRE_IMM) {
1487 if (isAM2 && NewOpc == ARM::STR_POST_IMM) {
1490 BuildMI(MBB, MBBI, DL,
TII->get(NewOpc), Base)
1499 BuildMI(MBB, MBBI, DL,
TII->get(NewOpc), Base)
1512 bool ARMLoadStoreOpt::MergeBaseUpdateLSDouble(
MachineInstr &MI)
const {
1514 assert((Opcode == ARM::t2LDRDi8 || Opcode == ARM::t2STRDi8) &&
1515 "Must have t2STRDi8 or t2LDRDi8");
1525 if (Reg0Op.
getReg() == Base || Reg1Op.
getReg() == Base)
1536 if (Offset == 8 || Offset == -8) {
1537 NewOpc = Opcode == ARM::t2LDRDi8 ? ARM::t2LDRD_PRE : ARM::t2STRD_PRE;
1540 if (Offset == 8 || Offset == -8) {
1541 NewOpc = Opcode == ARM::t2LDRDi8 ? ARM::t2LDRD_POST : ARM::t2STRD_POST;
1545 MBB.
erase(MergeInstr);
1549 if (NewOpc == ARM::t2LDRD_PRE || NewOpc == ARM::t2LDRD_POST) {
1552 assert(NewOpc == ARM::t2STRD_PRE || NewOpc == ARM::t2STRD_POST);
1557 assert(
TII->get(Opcode).getNumOperands() == 6 &&
1558 TII->get(NewOpc).getNumOperands() == 7 &&
1559 "Unexpected number of operands in Opcode specification.");
1629 bool isDef,
unsigned NewOpc,
unsigned Reg,
1630 bool RegDeadKill,
bool RegUndef,
unsigned BaseReg,
1661 if (Opcode != ARM::LDRD && Opcode != ARM::STRD && Opcode != ARM::t2LDRDi8)
1668 unsigned EvenRegNum =
TRI->getDwarfRegNum(EvenReg,
false);
1669 unsigned OddRegNum =
TRI->getDwarfRegNum(OddReg,
false);
1673 bool Errata602117 = EvenReg == BaseReg &&
1674 (Opcode == ARM::LDRD || Opcode == ARM::t2LDRDi8) && STI->isCortexM3();
1676 bool NonConsecutiveRegs = (Opcode == ARM::LDRD || Opcode == ARM::STRD) &&
1677 (EvenRegNum % 2 != 0 || EvenRegNum + 1 != OddRegNum);
1679 if (!Errata602117 && !NonConsecutiveRegs)
1682 bool isT2 = Opcode == ARM::t2LDRDi8 || Opcode == ARM::t2STRDi8;
1683 bool isLd = Opcode == ARM::LDRD || Opcode == ARM::t2LDRDi8;
1684 bool EvenDeadKill = isLd ?
1687 bool OddDeadKill = isLd ?
1690 bool BaseKill = BaseOp.
isKill();
1691 bool BaseUndef = BaseOp.
isUndef();
1693 "register offset not handled below");
1695 unsigned PredReg = 0;
1698 if (OddRegNum > EvenRegNum && OffImm == 0) {
1701 unsigned NewOpc = (isLd)
1702 ? (isT2 ? ARM::t2LDMIA : ARM::LDMIA)
1703 : (isT2 ? ARM::t2STMIA : ARM::STMIA);
1705 BuildMI(MBB, MBBI, MBBI->getDebugLoc(),
TII->get(NewOpc))
1707 .addImm(Pred).
addReg(PredReg)
1713 BuildMI(MBB, MBBI, MBBI->getDebugLoc(),
TII->get(NewOpc))
1715 .addImm(Pred).
addReg(PredReg)
1725 unsigned NewOpc = (isLd)
1726 ? (isT2 ? (OffImm < 0 ? ARM::t2LDRi8 : ARM::t2LDRi12) : ARM::LDRi12)
1727 : (isT2 ? (OffImm < 0 ? ARM::t2STRi8 : ARM::t2STRi12) : ARM::STRi12);
1730 unsigned NewOpc2 = (isLd)
1731 ? (isT2 ? (OffImm+4 < 0 ? ARM::t2LDRi8 : ARM::t2LDRi12) : ARM::LDRi12)
1732 : (isT2 ? (OffImm+4 < 0 ? ARM::t2STRi8 : ARM::t2STRi12) : ARM::STRi12);
1735 if (isLd &&
TRI->regsOverlap(EvenReg, BaseReg)) {
1736 assert(!
TRI->regsOverlap(OddReg, BaseReg));
1737 InsertLDR_STR(MBB, MBBI, OffImm + 4, isLd, NewOpc2, OddReg, OddDeadKill,
1738 false, BaseReg,
false, BaseUndef, Pred, PredReg,
TII, MI);
1739 InsertLDR_STR(MBB, MBBI, OffImm, isLd, NewOpc, EvenReg, EvenDeadKill,
1740 false, BaseReg, BaseKill, BaseUndef, Pred, PredReg,
TII,
1743 if (OddReg == EvenReg && EvenDeadKill) {
1747 EvenDeadKill =
false;
1751 if (EvenReg == BaseReg)
1752 EvenDeadKill =
false;
1753 InsertLDR_STR(MBB, MBBI, OffImm, isLd, NewOpc, EvenReg, EvenDeadKill,
1754 EvenUndef, BaseReg,
false, BaseUndef, Pred, PredReg,
TII,
1756 InsertLDR_STR(MBB, MBBI, OffImm + 4, isLd, NewOpc2, OddReg, OddDeadKill,
1757 OddUndef, BaseReg, BaseKill, BaseUndef, Pred, PredReg,
TII,
1766 MBBI = MBB.
erase(MBBI);
1774 unsigned CurrBase = 0;
1775 unsigned CurrOpc = ~0u;
1778 assert(Candidates.size() == 0);
1779 assert(MergeBaseCandidates.size() == 0);
1780 LiveRegsValid =
false;
1785 MBBI = std::prev(
I);
1786 if (FixInvalidRegPairOp(MBB, MBBI))
1791 unsigned Opcode = MBBI->getOpcode();
1795 unsigned PredReg = 0;
1798 if (CurrBase == 0) {
1803 MemOps.push_back(MemOpQueueEntry(*MBBI, Offset, Position));
1807 if (CurrOpc == Opcode && CurrBase == Base && CurrPred == Pred) {
1815 bool Overlap =
false;
1817 Overlap = (Base ==
Reg);
1819 for (
const MemOpQueueEntry &
E : MemOps) {
1820 if (
TRI->regsOverlap(Reg,
E.MI->getOperand(0).getReg())) {
1830 if (Offset > MemOps.back().Offset) {
1831 MemOps.push_back(MemOpQueueEntry(*MBBI, Offset, Position));
1834 MemOpQueue::iterator
MI, ME;
1835 for (MI = MemOps.begin(), ME = MemOps.end(); MI != ME; ++
MI) {
1836 if (Offset < MI->Offset) {
1840 if (Offset == MI->Offset) {
1846 if (MI != MemOps.end()) {
1847 MemOps.insert(MI, MemOpQueueEntry(*MBBI, Offset, Position));
1858 }
else if (MBBI->isDebugInstr()) {
1860 }
else if (MBBI->getOpcode() == ARM::t2LDRDi8 ||
1861 MBBI->getOpcode() == ARM::t2STRDi8) {
1864 MergeBaseCandidates.push_back(&*MBBI);
1868 if (MemOps.size() > 0) {
1869 FormCandidates(MemOps);
1877 if (MemOps.size() > 0)
1878 FormCandidates(MemOps);
1882 auto LessThan = [](
const MergeCandidate* M0,
const MergeCandidate *M1) {
1883 return M0->InsertPos < M1->InsertPos;
1888 bool Changed =
false;
1889 for (
const MergeCandidate *Candidate : Candidates) {
1890 if (Candidate->CanMergeToLSMulti || Candidate->CanMergeToLSDouble) {
1896 if (Opcode == ARM::t2STRDi8 || Opcode == ARM::t2LDRDi8)
1897 MergeBaseUpdateLSDouble(*Merged);
1899 MergeBaseUpdateLSMultiple(Merged);
1902 if (MergeBaseUpdateLoadStore(MI))
1907 assert(Candidate->Instrs.size() == 1);
1908 if (MergeBaseUpdateLoadStore(Candidate->Instrs.front()))
1915 MergeBaseUpdateLSDouble(*MI);
1916 MergeBaseCandidates.clear();
1933 if (isThumb1)
return false;
1934 if (MBB.
empty())
return false;
1937 if (MBBI != MBB.
begin() && MBBI != MBB.
end() &&
1938 (MBBI->getOpcode() == ARM::BX_RET ||
1939 MBBI->getOpcode() == ARM::tBX_RET ||
1940 MBBI->getOpcode() == ARM::MOVPCLR)) {
1943 while (PrevI->isDebugInstr() && PrevI != MBB.
begin())
1947 if (Opcode == ARM::LDMIA_UPD || Opcode == ARM::LDMDA_UPD ||
1948 Opcode == ARM::LDMDB_UPD || Opcode == ARM::LDMIB_UPD ||
1949 Opcode == ARM::t2LDMIA_UPD || Opcode == ARM::t2LDMDB_UPD) {
1951 if (MO.
getReg() != ARM::LR)
1953 unsigned NewOpc = (isThumb2 ? ARM::t2LDMIA_RET : ARM::LDMIA_RET);
1954 assert(((isThumb2 && Opcode == ARM::t2LDMIA_UPD) ||
1955 Opcode == ARM::LDMIA_UPD) &&
"Unsupported multiple load-return!");
1966 if (
Info.getReg() == ARM::LR) {
1967 Info.setRestored(
false);
1979 if (MBBI == MBB.
begin() || MBBI == MBB.
end() ||
1980 MBBI->getOpcode() != ARM::tBX_RET)
1985 if (Prev->getOpcode() != ARM::tMOVr || !Prev->definesRegister(ARM::LR))
1988 for (
auto Use : Prev->uses())
1990 assert(STI->hasV4TOps());
1991 BuildMI(MBB, MBBI, MBBI->getDebugLoc(),
TII->get(ARM::tBX))
1994 .copyImplicitOps(*MBBI);
2011 TII = STI->getInstrInfo();
2012 TRI = STI->getRegisterInfo();
2014 RegClassInfoValid =
false;
2015 isThumb2 = AFI->isThumb2Function();
2016 isThumb1 = AFI->isThumbFunction() && !isThumb2;
2022 Modified |= LoadStoreMultipleOpti(MBB);
2023 if (STI->hasV5TOps())
2024 Modified |= MergeReturnIntoLDM(MBB);
2026 Modified |= CombineMovBx(MBB);
2033 #define ARM_PREALLOC_LOAD_STORE_OPT_NAME \ 2034 "ARM pre- register allocation load / store optimization pass" 2055 StringRef getPassName()
const override {
2066 unsigned &NewOpc,
unsigned &EvenReg,
2067 unsigned &OddReg,
unsigned &BaseReg,
2073 unsigned Base,
bool isLd,
2090 bool ARMPreAllocLoadStoreOpt::runOnMachineFunction(
MachineFunction &Fn) {
2096 TII = STI->getInstrInfo();
2097 TRI = STI->getRegisterInfo();
2100 AA = &getAnalysis<AAResultsWrapperPass>().getAAResults();
2104 Modified |= RescheduleLoadStoreInstrs(&MFI);
2119 if (I->isDebugInstr() || MemOps.
count(&*I))
2121 if (I->isCall() || I->isTerminator() || I->hasUnmodeledSideEffects())
2123 if (I->mayStore() || (!isLd && I->mayLoad()))
2125 if (I->mayAlias(AA, *MemOp,
false))
2127 for (
unsigned j = 0, NumOps = I->getNumOperands(); j != NumOps; ++j) {
2134 if (Reg != Base && !MemRegs.
count(Reg))
2135 AddedRegPressure.
insert(Reg);
2140 if (MemRegs.
size() <= 4)
2143 return AddedRegPressure.
size() <= MemRegs.
size() * 2;
2150 unsigned &SecondReg,
2151 unsigned &BaseReg,
int &Offset,
2156 if (!STI->hasV5TEOps())
2162 if (Opcode == ARM::LDRi12) {
2164 }
else if (Opcode == ARM::STRi12) {
2166 }
else if (Opcode == ARM::t2LDRi8 || Opcode == ARM::t2LDRi12) {
2167 NewOpc = ARM::t2LDRDi8;
2170 }
else if (Opcode == ARM::t2STRi8 || Opcode == ARM::t2STRi12) {
2171 NewOpc = ARM::t2STRDi8;
2187 const Function &Func = MF->getFunction();
2188 unsigned ReqAlign = STI->hasV6Ops()
2191 if (Align < ReqAlign)
2197 int Limit = (1 << 8) * Scale;
2198 if (OffImm >= Limit || (OffImm <= -Limit) || (OffImm & (Scale-1)))
2207 int Limit = (1 << 8) * Scale;
2208 if (OffImm >= Limit || (OffImm & (Scale-1)))
2214 if (FirstReg == SecondReg)
2224 unsigned Base,
bool isLd,
2226 bool RetVal =
false;
2232 assert(LHS == RHS || LOffset != ROffset);
2233 return LOffset > ROffset;
2240 while (Ops.
size() > 1) {
2241 unsigned FirstLoc = ~0U;
2242 unsigned LastLoc = 0;
2246 unsigned LastOpcode = 0;
2247 unsigned LastBytes = 0;
2248 unsigned NumMove = 0;
2249 for (
int i = Ops.
size() - 1; i >= 0; --i) {
2254 if (LastOpcode && LSMOpcode != LastOpcode)
2261 if (Bytes != LastBytes || Offset != (LastOffset + (
int)Bytes))
2266 if (NumMove == InstReorderLimit)
2273 LastOpcode = LSMOpcode;
2275 unsigned Loc = MI2LocMap[
Op];
2276 if (Loc <= FirstLoc) {
2280 if (Loc >= LastLoc) {
2291 for (
size_t i = Ops.
size() - NumMove,
e = Ops.
size(); i !=
e; ++i) {
2298 bool DoMove = (LastLoc - FirstLoc) <= NumMove*4;
2301 MemOps, MemRegs,
TRI, AA);
2303 for (
unsigned i = 0; i != NumMove; ++i)
2308 while (InsertPos != MBB->
end() &&
2309 (MemOps.
count(&*InsertPos) || InsertPos->isDebugInstr()))
2316 unsigned FirstReg = 0, SecondReg = 0;
2317 unsigned BaseReg = 0, PredReg = 0;
2320 unsigned NewOpc = 0;
2323 if (NumMove == 2 && CanFormLdStDWord(Op0, Op1, dl, NewOpc,
2324 FirstReg, SecondReg, BaseReg,
2325 Offset, PredReg, Pred, isT2)) {
2331 MRI->constrainRegClass(FirstReg, TRC);
2332 MRI->constrainRegClass(SecondReg, TRC);
2373 for (
unsigned i = 0; i != NumMove; ++i) {
2376 MBB->
splice(InsertPos, MBB, Op);
2380 NumLdStMoved += NumMove;
2391 bool RetVal =
false;
2397 Base2InstMap Base2LdsMap;
2398 Base2InstMap Base2StsMap;
2406 for (; MBBI !=
E; ++MBBI) {
2415 MI2LocMap[&MI] = ++Loc;
2419 unsigned PredReg = 0;
2427 bool StopHere =
false;
2428 auto FindBases = [&] (Base2InstMap &Base2Ops, BaseVec &Bases) {
2429 MapIt BI = Base2Ops.find(Base);
2430 if (BI == Base2Ops.end()) {
2431 Base2Ops[Base].push_back(&MI);
2432 Bases.push_back(Base);
2435 for (
unsigned i = 0,
e = BI->second.size(); i !=
e; ++i) {
2442 BI->second.push_back(&MI);
2446 FindBases(Base2LdsMap, LdBases);
2448 FindBases(Base2StsMap, StBases);
2459 for (
unsigned i = 0,
e = LdBases.size(); i !=
e; ++i) {
2460 unsigned Base = LdBases[i];
2463 RetVal |= RescheduleOps(MBB, Lds, Base,
true, MI2LocMap);
2467 for (
unsigned i = 0,
e = StBases.size(); i !=
e; ++i) {
2468 unsigned Base = StBases[i];
2471 RetVal |= RescheduleOps(MBB, Sts, Base,
false, MI2LocMap);
2475 Base2LdsMap.clear();
2476 Base2StsMap.clear();
2488 return new ARMPreAllocLoadStoreOpt();
2489 return new ARMLoadStoreOpt();
static unsigned getPreIndexedLoadStoreOpcode(unsigned Opc, ARM_AM::AddrOpc Mode)
const MachineInstrBuilder & setMemRefs(ArrayRef< MachineMemOperand *> MMOs) const
const MachineInstrBuilder & add(const MachineOperand &MO) const
A parsed version of the target data layout string in and methods for querying it. ...
bool isCalleeSavedInfoValid() const
Has the callee saved info been calculated yet?
static bool isT1i32Load(unsigned Opc)
bool isCall(QueryType Type=AnyInBundle) const
This class represents lattice values for constants.
iterator_range< mop_iterator > uses()
Returns a range that includes all operands that are register uses.
LivenessQueryResult computeRegisterLiveness(const TargetRegisterInfo *TRI, unsigned Reg, const_iterator Before, unsigned Neighborhood=10) const
Return whether (physical) register Reg has been defined and not killed as of just before Before...
static unsigned getImmScale(unsigned Opc)
void push_back(const T &Elt)
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
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.
const ARMTargetLowering * getTargetLowering() const override
STATISTIC(NumFunctions, "Total number of functions")
unsigned const TargetRegisterInfo * TRI
unsigned getAM3Opc(AddrOpc Opc, unsigned char Offset, unsigned IdxMode=0)
getAM3Opc - This function encodes the addrmode3 opc field.
static IntegerType * getInt64Ty(LLVMContext &C)
static int isIncrementOrDecrement(const MachineInstr &MI, unsigned Reg, ARMCC::CondCodes Pred, unsigned PredReg)
Check if the given instruction increments or decrements a register and return the amount it is increm...
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
bool isAtomic() const
Returns true if this operation has an atomic ordering requirement of unordered or higher...
AnalysisUsage & addRequired()
static uint32_t getAlignment(const MCSectionCOFF &Sec)
A description of a memory reference used in the backend.
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
const HexagonInstrInfo * TII
unsigned getNumOperands() const
Retuns the total number of operands.
static bool IsSafeAndProfitableToMove(bool isLd, unsigned Base, MachineBasicBlock::iterator I, MachineBasicBlock::iterator E, SmallPtrSetImpl< MachineInstr *> &MemOps, SmallSet< unsigned, 4 > &MemRegs, const TargetRegisterInfo *TRI, AliasAnalysis *AA)
A Use represents the edge between a Value definition and its users.
bool isTerminator(QueryType Type=AnyInBundle) const
Returns true if this instruction part of the terminator for a basic block.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
Position
Position to insert a new instruction relative to an existing instruction.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
bool regsOverlap(Register regA, Register regB) const
Returns true if the two registers are equal or alias each other.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
void copyImplicitOps(MachineFunction &MF, const MachineInstr &MI)
Copy implicit register operands from specified instruction to this instruction.
static std::array< MachineOperand, 2 > predOps(ARMCC::CondCodes Pred, unsigned PredReg=0)
Get the operands corresponding to the given Pred value.
static ARM_AM::AMSubMode getLoadStoreMultipleSubMode(unsigned Opcode)
unsigned char getAM3Offset(unsigned AM3Opc)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
iterator getLastNonDebugInstr()
Returns an iterator to the last non-debug instruction in the basic block, or end().
void setReg(Register Reg)
Change the register this operand corresponds to.
unsigned getUndefRegState(bool B)
Analysis containing CSE Info
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
unsigned getKillRegState(bool B)
static unsigned getPostIndexedLoadStoreOpcode(unsigned Opc, ARM_AM::AddrOpc Mode)
TargetInstrInfo - Interface to description of machine instruction set.
#define ARM_PREALLOC_LOAD_STORE_OPT_NAME
unsigned getDeadRegState(bool B)
unsigned getDefRegState(bool B)
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
initializer< Ty > init(const Ty &Val)
MachineInstrBundleIterator< MachineInstr > iterator
unsigned char getAM5Offset(unsigned AM5Opc)
AddrOpc getAM3Op(unsigned AM3Opc)
unsigned const MachineRegisterInfo * MRI
ArrayRef< MachineMemOperand * > memoperands() const
Access to memory operands of the instruction.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
bool killsRegister(Register Reg, const TargetRegisterInfo *TRI=nullptr) const
Return true if the MachineInstr kills the specified register.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static bool isT2i32Load(unsigned Opc)
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
std::pair< iterator, bool > insert(const ValueT &V)
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Register is known to be fully dead.
Represent the analysis usage information of a pass.
bool hasOneMemOperand() const
Return true if this instruction has exactly one MachineMemOperand.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
void setImm(int64_t immVal)
FunctionPass class - This class is used to implement most global optimizations.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
ARMCC::CondCodes getInstrPredicate(const MachineInstr &MI, unsigned &PredReg)
getInstrPredicate - If instruction is predicated, returns its predicate condition, otherwise returns AL.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
static bool isAtomic(Instruction *I)
static bool isMemoryOp(const MachineInstr &MI)
Returns true if instruction is a memory operation that this pass is capable of operating on...
bool isDebugInstr() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
uint64_t getAlignment() const
Return the minimum known alignment in bytes of the actual memory reference.
This struct is a compact representation of a valid (non-zero power of two) alignment.
static cl::opt< bool > AssumeMisalignedLoadStores("arm-assume-misaligned-load-store", cl::Hidden, cl::init(false), cl::desc("Be more conservative in ARM load/store opt"))
This switch disables formation of double/multi instructions that could potentially lead to (new) alig...
FunctionPass * createARMLoadStoreOptimizationPass(bool PreAlloc=false)
Returns an instance of the load / store optimization pass.
void sort(IteratorTy Start, IteratorTy End)
static bool mayCombineMisaligned(const TargetSubtargetInfo &STI, const MachineInstr &MI)
Return true for loads/stores that can be combined to a double/multi operation without increasing the ...
static MachineBasicBlock::iterator findIncDecBefore(MachineBasicBlock::iterator MBBI, unsigned Reg, ARMCC::CondCodes Pred, unsigned PredReg, int &Offset)
Searches for an increment or decrement of Reg before MBBI.
static bool isi32Store(unsigned Opc)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
bool readsRegister(Register Reg, const TargetRegisterInfo *TRI=nullptr) const
Return true if the MachineInstr reads the specified register.
Iterator for intrusive lists based on ilist_node.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
void setDesc(const MCInstrDesc &tid)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one...
static MachineOperand t1CondCodeOp(bool isDead=false)
Get the operand corresponding to the conditional code result for Thumb1.
Align max(MaybeAlign Lhs, Align Rhs)
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
unsigned getAM2Opc(AddrOpc Opc, unsigned Imm12, ShiftOpc SO, unsigned IdxMode=0)
static uint64_t add(uint64_t LeftOp, uint64_t RightOp)
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
MachineInstr * getInstr() const
If conversion operators fail, use this method to get the MachineInstr explicitly. ...
INITIALIZE_PASS(ARMLoadStoreOpt, "arm-ldst-opt", ARM_LOAD_STORE_OPT_NAME, false, false) static bool definesCPSR(const MachineInstr &MI)
A BumpPtrAllocator that allows only elements of a specific type to be allocated.
const Function & getFunction() const
Return the LLVM function that this machine code represents.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
The CalleeSavedInfo class tracks the information need to locate where a callee saved register is in t...
#define ARM_LOAD_STORE_OPT_NAME
unsigned getTransientStackAlignment() const
getTransientStackAlignment - This method returns the number of bytes to which the stack pointer must ...
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
iterator_range< mop_iterator > implicit_operands()
static const MachineOperand & getLoadStoreBaseOp(const MachineInstr &MI)
unsigned succ_size() const
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
MachineFunctionProperties & set(Property P)
TargetSubtargetInfo - Generic base class for all target subtargets.
static bool isARMLowRegister(unsigned Reg)
isARMLowRegister - Returns true if the register is a low register (r0-r7).
Representation of each machine instruction.
static bool isT2i32Store(unsigned Opc)
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
static bool isValidLSDoubleOffset(int Offset)
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
static MachineOperand condCodeOp(unsigned CCReg=0)
Get the operand corresponding to the conditional code result.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
A set of physical registers with utility functions to track liveness when walking backward/forward th...
LLVM_NODISCARD bool empty() const
const std::vector< CalleeSavedInfo > & getCalleeSavedInfo() const
Returns a reference to call saved info vector for the current function.
ARMFunctionInfo - This class is derived from MachineFunctionInfo and contains private ARM-specific in...
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
APFloat abs(APFloat X)
Returns the absolute value of the argument.
const MachineInstrBuilder & cloneMemRefs(const MachineInstr &OtherMI) const
virtual const TargetFrameLowering * getFrameLowering() const
const MachineInstrBuilder & cloneMergedMemRefs(ArrayRef< const MachineInstr *> OtherMIs) const
static bool isLoadSingle(unsigned Opc)
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
static unsigned getUpdatingLSMultipleOpcode(unsigned Opc, ARM_AM::AMSubMode Mode)
static bool isi32Load(unsigned Opc)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static unsigned getLSMultipleTransferSize(const MachineInstr *MI)
LLVM Value Representation.
static int getLoadStoreMultipleOpcode(unsigned Opcode, ARM_AM::AMSubMode Mode)
static const MachineOperand & getLoadStoreRegOp(const MachineInstr &MI)
static MachineBasicBlock::iterator findIncDecAfter(MachineBasicBlock::iterator MBBI, unsigned Reg, ARMCC::CondCodes Pred, unsigned PredReg, int &Offset)
Searches for a increment or decrement of Reg after MBBI.
StringRef - Represent a constant reference to a string, i.e.
static void InsertLDR_STR(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, int Offset, bool isDef, unsigned NewOpc, unsigned Reg, bool RegDeadKill, bool RegUndef, unsigned BaseReg, bool BaseKill, bool BaseUndef, ARMCC::CondCodes Pred, unsigned PredReg, const TargetInstrInfo *TII, MachineInstr *MI)
AddrOpc getAM5Op(unsigned AM5Opc)
Register getReg() const
getReg - Returns the register number.
static bool isVolatile(Instruction *Inst)
static bool isT1i32Store(unsigned Opc)
static int getMemoryOpOffset(const MachineInstr &MI)
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object...
const MachineOperand & getOperand(unsigned i) const
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
static bool ContainsReg(const ArrayRef< std::pair< unsigned, bool >> &Regs, unsigned Reg)
Properties which a MachineFunction may have at a given point in time.
Wrapper class representing virtual and physical registers.
This file describes how to lower LLVM code to machine code.
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.