56#define DEBUG_TYPE "packets"
59 cl::desc(
"Disable Hexagon packetizer pass"));
63 cl::desc(
"Allow only one single floating point instruction in a packet"));
67 cl::desc(
"Allow only one complex instruction in a packet"));
71 cl::desc(
"Allow slot1 store and slot0 load"));
75 cl::desc(
"Allow non-solo packetization of volatile memory references"));
79 cl::desc(
"Generate all instruction with TC"));
83 cl::desc(
"Disable vector double new-value-stores"));
93 HexagonPacketizer(
bool Min =
false)
96 void getAnalysisUsage(AnalysisUsage &AU)
const override {
99 AU.
addRequired<MachineBranchProbabilityInfoWrapperPass>();
104 StringRef getPassName()
const override {
return "Hexagon Packetizer"; }
107 MachineFunctionProperties getRequiredProperties()
const override {
108 return MachineFunctionProperties().setNoVRegs();
112 const HexagonInstrInfo *HII =
nullptr;
113 const bool Minimal =
false;
118char HexagonPacketizer::ID = 0;
121 "Hexagon Packetizer",
false,
false)
137 addMutation(std::make_unique<HexagonSubtarget::UsrOverflowMutation>());
138 addMutation(std::make_unique<HexagonSubtarget::HVXMemLatencyMutation>());
139 addMutation(std::make_unique<HexagonSubtarget::HMXActivateWeightMutation>());
140 addMutation(std::make_unique<HexagonSubtarget::BankConflictMutation>());
141 addMutation(std::make_unique<HexagonSubtarget::HLXPseudoMutation>());
148 for (
auto &MO : FirstI.
operands()) {
149 if (!MO.isReg() || !MO.isDef())
165 InsertPt = std::next(BundleIt).getInstrIterator();
171 if (
MI.isBundledWithSucc()) {
178 MI.unbundleFromPred();
180 B.splice(InsertPt, &
B,
MI.getIterator());
186 for (++
I;
I !=
E &&
I->isBundledWithPred(); ++
I)
199 BundleIt->eraseFromParent();
208 HII = HST.getInstrInfo();
209 auto &MLI = getAnalysis<MachineLoopInfoWrapperPass>().getLI();
210 auto *AA = &getAnalysis<AAResultsWrapperPass>().getAAResults();
212 &getAnalysis<MachineBranchProbabilityInfoWrapperPass>().getMBPI();
215 HII->genAllInsnTimingClasses(MF);
220 HexagonPacketizerList
Packetizer(MF, MLI, AA, MBPI, MinOnly);
233 for (MachineBasicBlock &MB : MF) {
240 if (HST.isTinyCoreWithDuplex())
241 HII->translateInstrsForDup(MF,
true);
244 for (
auto &MB : MF) {
245 auto Begin = MB.begin(),
End = MB.end();
246 while (Begin !=
End) {
250 while (RB !=
End && HII->isSchedulingBoundary(*RB, &MB, MF))
255 while (RE !=
End && !HII->isSchedulingBoundary(*RE, &MB, MF))
269 if (HST.isTinyCoreWithDuplex())
270 HII->translateInstrsForDup(MF,
false);
290 auto *ExtMI =
MF.CreateMachineInstr(HII->get(Hexagon::A4_ext),
DebugLoc());
292 if (Reserve && Avail)
294 MF.deleteMachineInstr(ExtMI);
301 if (DepReg == HRI->getRARegister())
304 if (HII->isDeallocRet(
MI))
305 if (DepReg == HRI->getFrameRegister() || DepReg == HRI->getStackRegister())
315 if (MO.isReg() && MO.getReg() == DepReg && !MO.isImplicit())
328 return MI.getOpcode() == Hexagon::J2_jump;
332 switch (
MI.getOpcode()) {
333 case Hexagon::Y2_barrier:
340 return MI.getDesc().isTerminator() ||
MI.getDesc().isCall();
347 for (
auto *CSR =
TRI->getCalleeSavedRegs(&MF); CSR && *CSR; ++CSR)
348 if (
MI.modifiesRegister(*CSR,
TRI))
359 if (NewRC == &Hexagon::PredRegsRegClass) {
360 if (HII->isHVXVec(
MI) &&
MI.mayStore())
362 return HII->isPredicated(
MI) && HII->getDotNewPredOp(
MI,
nullptr) > 0;
365 return HII->mayBeNewStore(
MI);
375 int CurOpcode = HII->getDotCurOp(
MI);
376 MI.setDesc(HII->get(CurOpcode));
384 if (HII->isDotCurInst(*BI)) {
389 for (
auto &MO : BI->operands())
390 if (MO.isReg() && MO.getReg() ==
MI->getOperand(0).getReg())
397 MI->setDesc(HII->get(HII->getNonDotCurOp(*
MI)));
405 if (!HII->isHVXVec(
MI))
407 if (!HII->isHVXVec(*MII))
411 if (HII->isDotCurInst(
MI) && !HII->mayBeCurLoad(
MI))
414 if (!HII->mayBeCurLoad(
MI))
423 dbgs() <<
"in packet\n";);
426 dbgs() <<
"Checking CUR against ";
430 bool FoundMatch =
false;
431 for (
auto &MO : MJ.operands())
432 if (MO.isReg() && MO.getReg() == DestReg)
441 if (BI->readsRegister(DepReg,
MF.getSubtarget().getRegisterInfo()))
458 if (RC == &Hexagon::PredRegsRegClass)
459 NewOpcode = HII->getDotNewPredOp(
MI,
MBPI);
461 NewOpcode = HII->getDotNewOp(
MI);
462 MI.setDesc(HII->get(NewOpcode));
467 int NewOpcode = HII->getDotOldOp(
MI);
468 MI.setDesc(HII->get(NewOpcode));
473 unsigned Opc =
MI.getOpcode();
475 case Hexagon::S2_storerd_io:
476 case Hexagon::S2_storeri_io:
477 case Hexagon::S2_storerh_io:
478 case Hexagon::S2_storerb_io:
483 unsigned FrameSize =
MF.getFrameInfo().getStackSize();
486 if (HII->isValidOffset(
Opc, NewOff)) {
494 unsigned Opc =
MI.getOpcode();
496 case Hexagon::S2_storerd_io:
497 case Hexagon::S2_storeri_io:
498 case Hexagon::S2_storerh_io:
499 case Hexagon::S2_storerb_io:
504 unsigned FrameSize =
MF.getFrameInfo().getStackSize();
517 if (!HII->getBaseAndOffsetPosition(
MI, BPI, OPI))
520 if (!HII->getBaseAndOffsetPosition(MJ, BPJ, OPJ))
528 for (
const auto &PI : SUI->
Preds)
530 (PI.getKind() !=
SDep::Data || PI.getReg() != Reg))
533 if (!HII->getIncrementValue(MJ, Incr))
536 int64_t
Offset =
MI.getOperand(OPI).getImm();
537 if (!HII->isValidOffset(
MI.getOpcode(),
Offset + Incr))
540 MI.getOperand(OPI).setImm(
Offset + Incr);
549 if (!HII->getBaseAndOffsetPosition(
MI, BP,
OP))
551 MI.getOperand(
OP).setImm(ChangedOffset);
579 for (
auto &MO :
MI.operands())
580 if (MO.isReg() && MO.isDef())
581 DefRegsSet.
insert(MO.getReg());
583 for (
auto &MO :
MI.operands())
584 if (MO.isReg() && MO.isUse() && DefRegsSet.
count(MO.getReg()))
590 assert(Op1.
isReg() &&
"Post increment operand has be to a register.");
593 if (
MI.getDesc().mayStore()) {
596 assert(Op0.
isReg() &&
"Post increment operand has be to a register.");
601 llvm_unreachable(
"mayLoad or mayStore not set for Post Increment operation");
607 return MI.getOperand(
MI.getNumOperands()-1);
611 unsigned Opc =
MI.getOpcode();
613 case Hexagon::L4_loadrd_ap:
614 case Hexagon::L4_loadrb_ap:
615 case Hexagon::L4_loadrh_ap:
616 case Hexagon::L4_loadrub_ap:
617 case Hexagon::L4_loadruh_ap:
618 case Hexagon::L4_loadri_ap:
626 return MI.getOperand(1);
649 if (!HII->mayBeNewStore(
MI))
662 if (PacketRC == &Hexagon::DoubleRegsRegClass)
675 if (HII->isPostIncrement(
MI) &&
680 if (HII->isPostIncrement(PacketMI) && PacketMI.
mayLoad() &&
695 if (HII->isPredicated(PacketMI)) {
696 if (!HII->isPredicated(
MI))
701 unsigned predRegNumSrc = 0;
702 unsigned predRegNumDst = 0;
706 for (
auto &MO : PacketMI.
operands()) {
709 predRegNumSrc = MO.getReg();
710 predRegClass = HRI->getMinimalPhysRegClass(predRegNumSrc);
711 if (predRegClass == &Hexagon::PredRegsRegClass)
714 assert((predRegClass == &Hexagon::PredRegsRegClass) &&
715 "predicate register not found in a predicated PacketMI instruction");
718 for (
auto &MO :
MI.operands()) {
721 predRegNumDst = MO.getReg();
722 predRegClass = HRI->getMinimalPhysRegClass(predRegNumDst);
723 if (predRegClass == &Hexagon::PredRegsRegClass)
726 assert((predRegClass == &Hexagon::PredRegsRegClass) &&
727 "predicate register not found in a predicated MI instruction");
737 if (predRegNumDst != predRegNumSrc ||
738 HII->isDotNewInst(PacketMI) != HII->isDotNewInst(
MI) ||
751 unsigned StartCheck = 0;
760 if (&TempMI != &PacketMI && !StartCheck)
764 if (&TempMI == &PacketMI)
767 for (
auto &MO :
MI.operands())
778 if (!HII->isPostIncrement(
MI)) {
779 for (
unsigned opNum = 0; opNum <
MI.getNumOperands()-1; opNum++) {
790 for (
auto &MO : PacketMI.
operands()) {
791 if (MO.isRegMask() && MO.clobbersPhysReg(DepReg))
793 if (!MO.isReg() || !MO.isDef() || !MO.isImplicit())
796 if (R == DepReg || HRI->isSuperRegister(DepReg, R))
805 for (
auto &MO :
MI.operands()) {
806 if (MO.isReg() && MO.isUse() && MO.isImplicit() && MO.getReg() == DepReg)
816 const SUnit *PacketSU,
unsigned DepReg,
818 if (!HII->mayBeNewStore(
MI))
833 for (
auto &MO :
I.operands()) {
834 if (CheckDef && MO.isRegMask() && MO.clobbersPhysReg(DepReg))
836 if (!MO.isReg() || MO.getReg() != DepReg || !MO.isImplicit())
838 if (CheckDef == MO.isDef())
849 if (HII->isDotNewInst(
MI) && !HII->mayBeNewStore(
MI))
878 if (RC == &Hexagon::PredRegsRegClass)
879 return HII->predCanBeUsedAsDotNew(PI, DepReg);
881 if (RC != &Hexagon::PredRegsRegClass && !HII->mayBeNewStore(
MI))
886 int NewOpcode = (RC != &Hexagon::PredRegsRegClass) ? HII->getDotNewOp(
MI) :
887 HII->getDotNewPredOp(
MI,
MBPI);
890 bool ResourcesAvailable =
ResourceTracker->canReserveResources(*NewMI);
891 MF.deleteMachineInstr(NewMI);
892 if (!ResourcesAvailable)
921 if (!HII->isPredicated(*
I))
930 if (PacketSU->
isSucc(PacketSUDep)) {
931 for (
unsigned i = 0; i < PacketSU->
Succs.size(); ++i) {
932 auto &Dep = PacketSU->
Succs[i];
933 if (Dep.getSUnit() == PacketSUDep && Dep.getKind() ==
SDep::Anti &&
934 Dep.getReg() == DepReg)
950 for (
auto &
Op :
MI.operands()) {
951 if (
Op.isReg() &&
Op.getReg() &&
Op.isUse() &&
952 Hexagon::PredRegsRegClass.contains(
Op.getReg()))
994 if (PacketSU->
isSucc(SU)) {
995 for (
unsigned i = 0; i < PacketSU->
Succs.size(); ++i) {
996 auto Dep = PacketSU->
Succs[i];
1001 if (Dep.getSUnit() == SU && Dep.getKind() ==
SDep::Data &&
1002 Hexagon::PredRegsRegClass.contains(Dep.getReg())) {
1021 return PReg1 == PReg2 &&
1022 Hexagon::PredRegsRegClass.contains(PReg1) &&
1023 Hexagon::PredRegsRegClass.contains(PReg2) &&
1025 HII->isDotNewInst(MI1) == HII->isDotNewInst(MI2);
1031 PromotedToDotNew =
false;
1032 GlueToNewValueJump =
false;
1033 GlueAllocframeStore =
false;
1034 FoundSequentialDependence =
false;
1041 if (
MI.isDebugInstr())
1044 if (
MI.isCFIInstruction())
1048 if (
MI.isInlineAsm())
1051 if (
MI.isImplicitDef() ||
MI.getOpcode() == TargetOpcode::FREEZE)
1058 return !IS->getUnits();
1066 if (
MI.isEHLabel() ||
MI.isCFIInstruction())
1080 if (HII->isSolo(
MI))
1083 if (
MI.getOpcode() == Hexagon::PATCHABLE_FUNCTION_ENTER ||
1084 MI.getOpcode() == Hexagon::PATCHABLE_FUNCTION_EXIT ||
1085 MI.getOpcode() == Hexagon::PATCHABLE_TAIL_CALL ||
1086 MI.getOpcode() == Hexagon::PATCHABLE_EVENT_CALL ||
1087 MI.getOpcode() == Hexagon::PATCHABLE_TYPED_EVENT_CALL)
1090 if (
MI.getOpcode() == Hexagon::A2_nop)
1124 if (
MI.isInlineAsm())
1132 const auto &MID =
MI.getDesc();
1133 const auto &MJD = MJ.
getDesc();
1154 else if (MO.isReg() && Hexagon::IntRegsRegClass.contains(MO.getReg()))
1156 else if (MO.isReg() &&
1157 Hexagon::DoubleRegsRegClass.contains(MO.getReg()))
1163 if ((getScalarUses(
MI) & 4) && getScalarUses(MJ))
1167 switch (
MI.getOpcode()) {
1168 case Hexagon::S2_storew_locked:
1169 case Hexagon::S4_stored_locked:
1170 case Hexagon::L2_loadw_locked:
1171 case Hexagon::L4_loadd_locked:
1172 case Hexagon::Y2_dccleana:
1173 case Hexagon::Y2_dccleaninva:
1174 case Hexagon::Y2_dcinva:
1175 case Hexagon::Y2_dczeroa:
1176 case Hexagon::Y4_l2fetch:
1177 case Hexagon::Y5_l2fetch: {
1181 unsigned TJ = HII.
getType(MJ);
1188 case Hexagon::LX_S16b_pseudo: {
1195 return HRI.isSuperRegisterEq(StReg, Def.getReg());
1216 for (
auto &
B :
MF) {
1220 BundleIt =
MI.getIterator();
1221 if (!
MI.isInsideBundle())
1230 bool InsertBeforeBundle;
1231 if (
MI.isInlineAsm())
1233 else if (
MI.isDebugInstr())
1234 InsertBeforeBundle =
true;
1245 unsigned Opc =
MI.getOpcode();
1247 case Hexagon::Y2_barrier:
1248 case Hexagon::Y2_dcfetchbo:
1249 case Hexagon::Y4_l2fetch:
1250 case Hexagon::Y5_l2fetch:
1263 if (HII->isPredicated(
I) || HII->isPredicated(J))
1266 BitVector DeadDefs(Hexagon::NUM_TARGET_REGS);
1267 for (
auto &MO :
I.operands()) {
1268 if (!MO.isReg() || !MO.isDef() || !MO.isDead())
1270 DeadDefs[MO.getReg()] =
true;
1274 if (!MO.isReg() || !MO.isDef() || !MO.isDead())
1277 if (R != Hexagon::USR_OVF && DeadDefs[R])
1287 if ((HII->isSaveCalleeSavedRegsCall(
I) &&
1289 (HII->isSaveCalleeSavedRegsCall(J) &&
1301 if (
MI.isCall() || HII->isDeallocRet(
MI) || HII->isNewValueJump(
MI))
1303 if (HII->isPredicated(
MI) && HII->isPredicatedNew(
MI) && HII->isJumpR(
MI))
1308 if (HII->isLoopN(
I) && isBadForLoopN(J))
1310 if (HII->isLoopN(J) && isBadForLoopN(
I))
1315 return HII->isDeallocRet(
I) &&
1333 if (!OpJ.isRegMask())
1335 assert((J.
isCall() || HII->isTailCall(J)) &&
"Regmask on a non-call");
1338 if (OpJ.clobbersPhysReg(OpI.getReg()))
1340 }
else if (OpI.isRegMask()) {
1352 bool StoreI =
I.mayStore(), StoreJ = J.
mayStore();
1353 if ((SysI && StoreJ) || (SysJ && StoreI))
1356 if (StoreI && StoreJ) {
1357 if (HII->isNewValueInst(J) || HII->isMemOp(J) || HII->isMemOp(
I))
1362 bool MopStI = HII->isMemOp(
I) || StoreI;
1363 bool MopStJ = HII->isMemOp(J) || StoreJ;
1364 if (MopStI && MopStJ)
1368 return (StoreJ && HII->isDeallocRet(
I)) || (StoreI && HII->isDeallocRet(J));
1381 IgnoreDepMIs.clear();
1413 if (NextMII !=
I.getParent()->end() && HII->isNewValueJump(*NextMII)) {
1416 bool secondRegMatch =
false;
1420 if (NOp1.
isReg() &&
I.getOperand(0).getReg() == NOp1.
getReg())
1421 secondRegMatch =
true;
1437 if (PI->getOpcode() == Hexagon::S2_allocframe || PI->mayStore() ||
1438 HII->isLoopN(*PI)) {
1444 if (OpR.
isReg() && PI->modifiesRegister(OpR.
getReg(), HRI)) {
1450 GlueToNewValueJump =
true;
1459 for (
unsigned i = 0; i < SUJ->
Succs.size(); ++i) {
1460 if (FoundSequentialDependence)
1463 if (SUJ->
Succs[i].getSUnit() != SUI)
1482 unsigned DepReg = 0;
1485 DepReg = SUJ->
Succs[i].getReg();
1486 RC = HRI->getMinimalPhysRegClass(DepReg);
1489 if (
I.isCall() || HII->isJumpR(
I) ||
I.isReturn() || HII->isTailCall(
I)) {
1503 if (DepType ==
SDep::Data && HII->isDotCurInst(J)) {
1504 if (HII->isHVXVec(
I))
1512 PromotedToDotNew =
true;
1514 FoundSequentialDependence =
true;
1518 if (HII->isNewValueJump(
I))
1524 if (HII->isPredicated(
I) && HII->isPredicated(J) &&
1538 auto Itr =
find(IgnoreDepMIs, &J);
1539 if (Itr != IgnoreDepMIs.end()) {
1543 IgnoreDepMIs.push_back(&
I);
1555 if (
I.isConditionalBranch() && DepType !=
SDep::Data &&
1560 FoundSequentialDependence =
true;
1574 FoundSequentialDependence =
true;
1580 bool LoadI =
I.mayLoad(), StoreI =
I.mayStore();
1581 bool NVStoreJ = HII->isNewValueStore(J);
1582 bool NVStoreI = HII->isNewValueStore(
I);
1583 bool IsVecJ = HII->isHVXVec(J) || HII->isHLXVec(J);
1584 bool IsVecI = HII->isHVXVec(
I) || HII->isHLXVec(
I);
1588 if (LoadJ && LoadI && HII->isPureSlot0(J)) {
1589 FoundSequentialDependence =
true;
1594 ((LoadJ && StoreI && !NVStoreI) ||
1595 (StoreJ && LoadI && !NVStoreJ)) &&
1596 (J.
getOpcode() != Hexagon::S2_allocframe &&
1597 I.getOpcode() != Hexagon::S2_allocframe) &&
1598 (J.
getOpcode() != Hexagon::L2_deallocframe &&
1599 I.getOpcode() != Hexagon::L2_deallocframe) &&
1600 (!HII->isMemOp(J) && !HII->isMemOp(
I)) && (!IsVecJ && !IsVecI))
1603 if (StoreJ && LoadI &&
alias(J,
I)) {
1604 FoundSequentialDependence =
true;
1609 if (!LoadJ || (!LoadI && !StoreI)) {
1612 FoundSequentialDependence =
true;
1627 unsigned Opc =
I.getOpcode();
1629 case Hexagon::S2_storerd_io:
1630 case Hexagon::S2_storeri_io:
1631 case Hexagon::S2_storerh_io:
1632 case Hexagon::S2_storerb_io:
1633 if (
I.getOperand(0).getReg() == HRI->getStackRegister()) {
1639 if (GlueAllocframeStore)
1659 if (
Op.isReg() &&
Op.isDef()) {
1663 }
else if (!
Op.isRegMask()) {
1667 FoundSequentialDependence =
true;
1681 if (DepType !=
SDep::Anti ||
I.getOpcode() == Hexagon::LX_L16b_pseudo) {
1682 FoundSequentialDependence =
true;
1687 if (FoundSequentialDependence) {
1702 if (Coexist && !Dependence)
1707 if (PromotedToDotNew)
1714 if (GlueAllocframeStore) {
1716 GlueAllocframeStore =
false;
1722 if (GlueToNewValueJump) {
1725 GlueToNewValueJump =
false;
1733 FoundSequentialDependence =
false;
1743 bool FoundLoad =
false;
1744 bool FoundStore =
false;
1747 unsigned Opc = MJ->getOpcode();
1748 if (
Opc == Hexagon::S2_allocframe ||
Opc == Hexagon::L2_deallocframe)
1750 if (HII->isMemOp(*MJ))
1754 if (MJ->mayStore() && !HII->isNewValueStore(*MJ))
1757 return FoundLoad && FoundStore;
1767 PacketStalls =
false;
1768 PacketStallCycles = 0;
1771 PacketStallCycles = std::max(PacketStallCycles,
calcStall(
MI));
1773 if (
MI.isImplicitDef() ||
MI.getOpcode() == TargetOpcode::FREEZE) {
1782 if (std::next(MII) !=
MI.getParent()->end()) {
1784 if (HII->isActivateWeightPair(
MI, nextMI)) {
1787 if (HII->isDependent(JMI,
MI) || HII->isDependent(JMI, nextMI)) {
1808 bool ExtMI = HII->isExtended(
MI) || HII->isConstExtended(
MI);
1811 if (GlueToNewValueJump) {
1821 bool ExtNvjMI = HII->isExtended(NvjMI) || HII->isConstExtended(NvjMI);
1828 if (Good && ExtNvjMI)
1854 if (PromotedToDotNew)
1856 if (GlueAllocframeStore) {
1858 GlueAllocframeStore =
false;
1873 dbgs() <<
"Finalizing packet:\n";
1889 OldPacketMIs.clear();
1892 for (
auto &
I :
make_range(HII->expandVGatherPseudo(*
MI), NextMI))
1893 OldPacketMIs.push_back(&
I);
1897 if (OldPacketMIs.size() > 1) {
1901 auto BundleMII = std::prev(FirstMI);
1902 if (memShufDisabled)
1903 HII->setBundleNoShuf(BundleMII);
1908 PacketHasDuplex =
false;
1909 PacketHasSLOT0OnlyInsn =
false;
1935 PacketHasSLOT0OnlyInsn |= HII->isPureSlot0(*MJ);
1937 int Opcode = HII->getDuplexOpcode(
MI,
false);
1941 if (HII->isDuplexPair(
MI, *MJ) && !PacketHasSLOT0OnlyInsn) {
1942 PacketHasDuplex =
true;
1949 MIRef.
setDesc(HII->get(Opcode));
1960 return HII->isTmpLoadPseudo(
I) || HII->isNewStorePseudo(
I);
1962 bool HasConstExt = HII->isConstExtended(
MI);
1963 bool HasPseudo = IsHLXLdStPseudo(
MI);
1965 HasConstExt |= HII->isConstExtended(*MJ);
1966 HasPseudo |= IsHLXLdStPseudo(*MJ);
1968 if (HasConstExt && HasPseudo)
1984 if (!OldPacketMIs.empty()) {
1985 auto *OldBB = OldPacketMIs.front()->getParent();
1986 auto *ThisBB =
I.getParent();
1987 if (
MLI->getLoopFor(OldBB) !=
MLI->getLoopFor(ThisBB))
2018 for (
auto &Pred : SUI->
Preds)
2019 if (Pred.getSUnit() == SUJ)
2020 if ((Pred.getLatency() == 0 && Pred.isAssignedRegDep()) ||
2021 HII->isNewValueJump(
I) || HII->isToBeScheduledASAP(*J,
I))
2027 for (
auto *J : OldPacketMIs) {
2029 for (
auto &Pred : SUI->
Preds)
2030 if (Pred.getSUnit() == SUJ && Pred.getLatency() > 1)
2031 return Pred.getLatency();
2043 return Latency > PacketStallCycles;
2052 return new HexagonPacketizer(Minimal);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file implements the BitVector class.
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file defines the DenseSet and SmallDenseSet classes.
cl::opt< bool > OneComplexPerPacket
cl::opt< bool > OneFloatPerPacket
cl::opt< bool > ScheduleInlineAsm("hexagon-sched-inline-asm", cl::Hidden, cl::init(false), cl::desc("Do not consider inline-asm a scheduling/" "packetization boundary."))
#define HEXAGON_LRFP_SIZE
cl::opt< bool > DisablePacketizer
static bool cannotCoexistAsymm(const MachineInstr &MI, const MachineInstr &MJ, const HexagonInstrInfo &HII)
static bool isDirectJump(const MachineInstr &MI)
static MachineBasicBlock::iterator moveInstrOut(MachineInstr &MI, MachineBasicBlock::iterator BundleIt, bool Before)
static bool isRegDependence(const SDep::Kind DepType)
cl::opt< bool > OneComplexPerPacket("single-complex-packet", cl::Hidden, cl::desc("Allow only one complex instruction in a packet"))
static const MachineOperand & getStoreValueOperand(const MachineInstr &MI)
static cl::opt< bool > EnableGenAllInsnClass("enable-gen-insn", cl::Hidden, cl::desc("Generate all instruction with TC"))
static bool isControlFlow(const MachineInstr &MI)
static cl::opt< bool > DisableVecDblNVStores("disable-vecdbl-nv-stores", cl::Hidden, cl::desc("Disable vector double new-value-stores"))
static PredicateKind getPredicateSense(const MachineInstr &MI, const HexagonInstrInfo *HII)
Returns true if an instruction is predicated on p0 and false if it's predicated on !...
static unsigned getPredicatedRegister(MachineInstr &MI, const HexagonInstrInfo *QII)
Gets the predicate register of a predicated instruction.
cl::opt< bool > DisablePacketizer("disable-packetizer", cl::Hidden, cl::desc("Disable Hexagon packetizer pass"))
static cl::opt< bool > Slot1Store("slot1-store-slot0-load", cl::Hidden, cl::init(true), cl::desc("Allow slot1 store and slot0 load"))
static cl::opt< bool > PacketizeVolatiles("hexagon-packetize-volatiles", cl::Hidden, cl::init(true), cl::desc("Allow non-solo packetization of volatile memory references"))
static bool hasWriteToReadDep(const MachineInstr &FirstI, const MachineInstr &SecondI, const TargetRegisterInfo *TRI)
static bool doesModifyCalleeSavedReg(const MachineInstr &MI, const TargetRegisterInfo *TRI)
Returns true if the instruction modifies a callee-saved register.
static bool isLoadAbsSet(const MachineInstr &MI)
static const MachineOperand & getAbsSetOperand(const MachineInstr &MI)
static const MachineOperand & getPostIncrementOperand(const MachineInstr &MI, const HexagonInstrInfo *HII)
cl::opt< bool > OneFloatPerPacket("single-float-packet", cl::Hidden, cl::desc("Allow only one single floating point instruction in a packet"))
static bool isImplicitDependency(const MachineInstr &I, bool CheckDef, unsigned DepReg)
static bool isSchedBarrier(const MachineInstr &MI)
static bool isSystemInstr(const MachineInstr &MI)
Register const TargetRegisterInfo * TRI
static MCRegister getReg(const MCDisassembler *D, unsigned RC, unsigned RegNo)
uint64_t IntrinsicInst * II
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Remove Loads Into Fake Uses
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object.
AnalysisUsage & addRequired()
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
Implements a dense probed hash-table based set.
FunctionPass class - This class is used to implement most global optimizations.
bool isHLXVec(const MachineInstr &MI) const
bool isPredicated(const MachineInstr &MI) const override
Returns true if the instruction is already predicated.
bool isHVXMemWithAIndirect(const MachineInstr &I, const MachineInstr &J) const
bool isRestrictNoSlot1Store(const MachineInstr &MI) const
bool isPureSlot0(const MachineInstr &MI) const
const HexagonRegisterInfo & getRegisterInfo() const
bool isComplex(const MachineInstr &MI) const
bool isPostIncrement(const MachineInstr &MI) const override
Return true for post-incremented instructions.
bool isFloat(const MachineInstr &MI) const
uint64_t getType(const MachineInstr &MI) const
bool isPredicatedTrue(const MachineInstr &MI) const
bool isNewValueStore(const MachineInstr &MI) const
bool arePredicatesComplements(MachineInstr &MI1, MachineInstr &MI2)
bool updateOffset(SUnit *SUI, SUnit *SUJ)
Return true if we can update the offset in MI so that MI and MJ can be packetized together.
void endPacket(MachineBasicBlock *MBB, MachineBasicBlock::iterator MI) override
bool getmemShufDisabled()
HexagonPacketizerList(MachineFunction &MF, MachineLoopInfo &MLI, AAResults *AA, const MachineBranchProbabilityInfo *MBPI, bool Minimal)
bool isCallDependent(const MachineInstr &MI, SDep::Kind DepType, unsigned DepReg)
bool promoteToDotCur(MachineInstr &MI, SDep::Kind DepType, MachineBasicBlock::iterator &MII, const TargetRegisterClass *RC)
bool promoteToDotNew(MachineInstr &MI, SDep::Kind DepType, MachineBasicBlock::iterator &MII, const TargetRegisterClass *RC)
bool isLegalToPacketizeTogether(SUnit *SUI, SUnit *SUJ) override
bool canPromoteToDotCur(const MachineInstr &MI, const SUnit *PacketSU, unsigned DepReg, MachineBasicBlock::iterator &MII, const TargetRegisterClass *RC)
void useCalleesSP(MachineInstr &MI)
bool demoteToDotOld(MachineInstr &MI)
bool cannotCoexist(const MachineInstr &MI, const MachineInstr &MJ)
const MachineLoopInfo * MLI
bool isSoloInstruction(const MachineInstr &MI) override
bool isLegalToPruneDependencies(SUnit *SUI, SUnit *SUJ) override
void initPacketizerState() override
bool hasControlDependence(const MachineInstr &I, const MachineInstr &J)
bool restrictingDepExistInPacket(MachineInstr &, unsigned)
bool producesStall(const MachineInstr &MI)
void undoChangedOffset(MachineInstr &MI)
Undo the changed offset.
bool hasDualStoreDependence(const MachineInstr &I, const MachineInstr &J)
unsigned int calcStall(const MachineInstr &MI)
bool canPromoteToDotNew(const MachineInstr &MI, const SUnit *PacketSU, unsigned DepReg, MachineBasicBlock::iterator &MII, const TargetRegisterClass *RC)
bool canPromoteToNewValue(const MachineInstr &MI, const SUnit *PacketSU, unsigned DepReg, MachineBasicBlock::iterator &MII)
bool ignorePseudoInstruction(const MachineInstr &MI, const MachineBasicBlock *MBB) override
void unpacketizeSoloInstrs(MachineFunction &MF)
const MachineBranchProbabilityInfo * MBPI
A handle to the branch probability pass.
bool shouldAddToPacket(const MachineInstr &MI) override
bool canReserveResourcesForConstExt()
bool useCallersSP(MachineInstr &MI)
bool canPromoteToNewValueStore(const MachineInstr &MI, const MachineInstr &PacketMI, unsigned DepReg)
bool tryAllocateResourcesForConstExt(bool Reserve)
void setmemShufDisabled(bool val)
void reserveResourcesForConstExt()
MachineBasicBlock::iterator addToPacket(MachineInstr &MI) override
bool hasDeadDependence(const MachineInstr &I, const MachineInstr &J)
bool isNewifiable(const MachineInstr &MI, const TargetRegisterClass *NewRC)
bool hasRegMaskDependence(const MachineInstr &I, const MachineInstr &J)
const HexagonInstrInfo * getInstrInfo() const override
const HexagonRegisterInfo * getRegisterInfo() const override
bool hasV60OpsOnly() const
Describe properties that are true of each instruction in the target description file.
unsigned getSchedClass() const
Return the scheduling class for this instruction.
Instructions::iterator instr_iterator
Instructions::const_iterator const_instr_iterator
MachineInstrBundleIterator< MachineInstr > iterator
Analysis pass which computes a MachineDominatorTree.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Function & getFunction()
Return the LLVM function that this machine code represents.
const MachineFunctionProperties & getProperties() const
Get the function properties.
instr_iterator getInstrIterator() const
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
bool isTerminator(QueryType Type=AnyInBundle) const
Returns true if this instruction part of the terminator for a basic block.
bool isImplicitDef() const
bool readsRegister(Register Reg, const TargetRegisterInfo *TRI) const
Return true if the MachineInstr reads the specified register.
bool isBarrier(QueryType Type=AnyInBundle) const
Returns true if the specified instruction stops control flow from executing the instruction immediate...
filtered_mop_range all_defs()
Returns an iterator range over all operands that are (explicit or implicit) register defs.
bool isCall(QueryType Type=AnyInBundle) const
bool isBranch(QueryType Type=AnyInBundle) const
Returns true if this is a conditional, unconditional, or indirect branch.
bool modifiesRegister(Register Reg, const TargetRegisterInfo *TRI) const
Return true if the MachineInstr modifies (fully define or partially define) the specified register.
LLVM_ABI void unbundleFromPred()
Break bundle above this instruction.
bool mayLoad(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read memory.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
LLVM_ABI void setDesc(const MCInstrDesc &TID)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one.
LLVM_ABI bool hasOrderedMemoryRef() const
Return true if this instruction may have an ordered or volatile memory reference, or if the informati...
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
bool isBundledWithSucc() const
Return true if this instruction is part of a bundle, and it is not the last instruction in the bundle...
const MachineOperand & getOperand(unsigned i) const
MachineOperand class - Representation of each machine instruction operand.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Register getReg() const
getReg - Returns the register number.
Wrapper class representing virtual and physical registers.
Kind
These are the different kinds of scheduling dependencies.
@ Output
A register output-dependence (aka WAW).
@ Order
Any other ordering dependency.
@ Anti
A register anti-dependence (aka WAR).
@ Data
Regular data dependence (aka true-dependence).
Scheduling unit. This is a node in the scheduling DAG.
bool isSucc(const SUnit *N) const
Tests if node N is a successor of this node.
SmallVector< SDep, 4 > Succs
All sunit successors.
SmallVector< SDep, 4 > Preds
All sunit predecessors.
MachineInstr * getInstr() const
Returns the representative MachineInstr for this SUnit.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
VLIWPacketizerList(MachineFunction &MF, MachineLoopInfo &MLI, AAResults *AA)
void addMutation(std::unique_ptr< ScheduleDAGMutation > Mutation)
bool alias(const MachineInstr &MI1, const MachineInstr &MI2, bool UseTBAA=true) const
std::vector< MachineInstr * > CurrentPacketMIs
std::map< MachineInstr *, SUnit * > MIToSUnit
DFAPacketizer * ResourceTracker
std::pair< iterator, bool > insert(const ValueT &V)
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool getTSFlag(const MCInstrDesc &MID, HexagonTSFlagsVal Pos)
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void finalizeBundle(MachineBasicBlock &MBB, MachineBasicBlock::instr_iterator FirstMI, MachineBasicBlock::instr_iterator LastMI)
finalizeBundle - Finalize a machine instruction bundle which includes a sequence of instructions star...
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
std::string utohexstr(uint64_t X, bool LowerCase=false, unsigned Width=0)
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
FunctionPass * createHexagonPacketizer(bool Minimal)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
DWARFExpression::Operation Op
@ End
Run the machine verifier once, at the end of the pipeline.
MCRegisterClass TargetRegisterClass