55 #define DEBUG_TYPE "packets" 59 cl::desc(
"Disable Hexagon packetizer pass"));
63 cl::desc(
"Allow slot1 store and slot0 load"));
67 cl::desc(
"Allow non-solo packetization of volatile memory references"));
74 cl::desc(
"Disable vector double new-value-stores"));
104 StringRef getPassName()
const override {
return "Hexagon Packetizer"; }
122 "Hexagon Packetizer",
false,
false)
137 addMutation(llvm::make_unique<HexagonSubtarget::UsrOverflowMutation>());
138 addMutation(llvm::make_unique<HexagonSubtarget::HVXMemLatencyMutation>());
139 addMutation(llvm::make_unique<HexagonSubtarget::BankConflictMutation>());
146 for (
auto &MO : FirstI.
operands()) {
147 if (!MO.isReg() || !MO.isDef())
149 unsigned R = MO.getReg();
163 InsertPt = std::next(BundleIt).getInstrIterator();
184 for (++I; I != E && I->isBundledWithPred(); ++
I)
197 BundleIt->eraseFromParent();
207 HRI = HST.getRegisterInfo();
208 auto &MLI = getAnalysis<MachineLoopInfo>();
209 auto *AA = &getAnalysis<AAResultsWrapperPass>().getAAResults();
210 auto *MBPI = &getAnalysis<MachineBranchProbabilityInfo>();
213 HII->genAllInsnTimingClasses(MF);
229 for (
auto &MB : MF) {
231 auto MI = MB.begin();
233 auto NextI = std::next(
MI);
243 for (
auto &MB : MF) {
244 auto Begin = MB.begin(), End = MB.end();
245 while (Begin != End) {
249 while (RB != End && HII->isSchedulingBoundary(*RB, &MB, MF))
254 while (RE != End && !HII->isSchedulingBoundary(*RE, &MB, MF))
274 if (!tryAllocateResourcesForConstExt(
true))
279 return tryAllocateResourcesForConstExt(
false);
286 bool Avail = ResourceTracker->canReserveResources(*ExtMI);
287 if (Reserve && Avail)
288 ResourceTracker->reserveResources(*ExtMI);
296 if (DepReg == HRI->getRARegister())
299 if (HII->isDeallocRet(MI))
300 if (DepReg == HRI->getFrameRegister() || DepReg == HRI->getStackRegister())
310 if (MO.isReg() && MO.getReg() == DepReg && !MO.isImplicit())
323 return MI.
getOpcode() == Hexagon::J2_jump;
328 case Hexagon::Y2_barrier:
354 if (NewRC == &Hexagon::PredRegsRegClass) {
355 if (HII->isHVXVec(MI) && MI.
mayStore())
357 return HII->isPredicated(MI) && HII->getDotNewPredOp(MI,
nullptr) > 0;
360 return HII->mayBeNewStore(MI);
370 int CurOpcode = HII->getDotCurOp(MI);
371 MI.
setDesc(HII->get(CurOpcode));
377 for (
auto BI : CurrentPacketMIs) {
379 if (HII->isDotCurInst(*BI)) {
384 for (
auto &MO : BI->operands())
392 MI->
setDesc(HII->get(HII->getNonDotCurOp(*MI)));
400 if (!HII->isHVXVec(MI))
402 if (!HII->isHVXVec(*MII))
406 if (HII->isDotCurInst(MI) && !HII->mayBeCurLoad(MI))
409 if (!HII->mayBeCurLoad(MI))
418 dbgs() <<
"in packet\n";);
421 dbgs() <<
"Checking CUR against ";
425 bool FoundMatch =
false;
426 for (
auto &MO : MJ.operands())
427 if (MO.isReg() && MO.getReg() == DestReg)
434 for (
auto BI : CurrentPacketMIs) {
453 if (RC == &Hexagon::PredRegsRegClass)
454 NewOpcode = HII->getDotNewPredOp(MI, MBPI);
456 NewOpcode = HII->getDotNewOp(MI);
457 MI.
setDesc(HII->get(NewOpcode));
462 int NewOpcode = HII->getDotOldOp(MI);
463 MI.
setDesc(HII->get(NewOpcode));
470 case Hexagon::S2_storerd_io:
471 case Hexagon::S2_storeri_io:
472 case Hexagon::S2_storerh_io:
473 case Hexagon::S2_storerb_io:
481 if (HII->isValidOffset(Opc, NewOff, HRI)) {
491 case Hexagon::S2_storerd_io:
492 case Hexagon::S2_storeri_io:
493 case Hexagon::S2_storerh_io:
494 case Hexagon::S2_storerb_io:
512 if (!HII->getBaseAndOffsetPosition(MI, BPI, OPI))
515 if (!HII->getBaseAndOffsetPosition(MJ, BPJ, OPJ))
517 unsigned Reg = MI.getOperand(BPI).getReg();
523 for (
const auto &PI : SUI->
Preds)
528 if (!HII->getIncrementValue(MJ, Incr))
531 int64_t
Offset = MI.getOperand(OPI).getImm();
532 if (!HII->isValidOffset(MI.getOpcode(), Offset+Incr, HRI))
535 MI.getOperand(OPI).setImm(Offset + Incr);
544 if (!HII->getBaseAndOffsetPosition(MI, BP, OP))
575 if (MO.isReg() && MO.isDef())
576 DefRegsSet.
insert(MO.getReg());
579 if (MO.isReg() && MO.isUse() && DefRegsSet.count(MO.getReg()))
585 assert(Op1.
isReg() &&
"Post increment operand has be to a register.");
591 assert(Op0.
isReg() &&
"Post increment operand has be to a register.");
596 llvm_unreachable(
"mayLoad or mayStore not set for Post Increment operation");
608 case Hexagon::L4_loadrd_ap:
609 case Hexagon::L4_loadrb_ap:
610 case Hexagon::L4_loadrh_ap:
611 case Hexagon::L4_loadrub_ap:
612 case Hexagon::L4_loadruh_ap:
613 case Hexagon::L4_loadri_ap:
644 if (!HII->mayBeNewStore(MI))
657 if (PacketRC == &Hexagon::DoubleRegsRegClass)
662 for (
auto I : CurrentPacketMIs) {
663 SUnit *PacketSU = MIToSUnit.find(
I)->second;
670 if (HII->isPostIncrement(MI) &&
675 if (HII->isPostIncrement(PacketMI) && PacketMI.
mayLoad() &&
690 if (HII->isPredicated(PacketMI)) {
691 if (!HII->isPredicated(MI))
696 unsigned predRegNumSrc = 0;
697 unsigned predRegNumDst = 0;
701 for (
auto &MO : PacketMI.
operands()) {
704 predRegNumSrc = MO.getReg();
705 predRegClass = HRI->getMinimalPhysRegClass(predRegNumSrc);
706 if (predRegClass == &Hexagon::PredRegsRegClass)
709 assert((predRegClass == &Hexagon::PredRegsRegClass) &&
710 "predicate register not found in a predicated PacketMI instruction");
716 predRegNumDst = MO.getReg();
717 predRegClass = HRI->getMinimalPhysRegClass(predRegNumDst);
718 if (predRegClass == &Hexagon::PredRegsRegClass)
721 assert((predRegClass == &Hexagon::PredRegsRegClass) &&
722 "predicate register not found in a predicated MI instruction");
732 if (predRegNumDst != predRegNumSrc ||
733 HII->isDotNewInst(PacketMI) != HII->isDotNewInst(MI) ||
746 unsigned StartCheck = 0;
748 for (
auto I : CurrentPacketMIs) {
749 SUnit *TempSU = MIToSUnit.find(
I)->second;
755 if (&TempMI != &PacketMI && !StartCheck)
759 if (&TempMI == &PacketMI)
773 if (!HII->isPostIncrement(MI)) {
774 for (
unsigned opNum = 0; opNum < MI.
getNumOperands()-1; opNum++) {
785 for (
auto &MO : PacketMI.
operands()) {
786 if (MO.isRegMask() && MO.clobbersPhysReg(DepReg))
788 if (!MO.isReg() || !MO.isDef() || !MO.isImplicit())
790 unsigned R = MO.getReg();
791 if (R == DepReg || HRI->isSuperRegister(DepReg, R))
801 if (MO.isReg() && MO.isUse() && MO.isImplicit() && MO.getReg() == DepReg)
811 const SUnit *PacketSU,
unsigned DepReg,
813 if (!HII->mayBeNewStore(MI))
818 if (canPromoteToNewValueStore(MI, PacketMI, DepReg))
829 if (CheckDef && MO.isRegMask() && MO.clobbersPhysReg(DepReg))
831 if (!MO.isReg() || MO.getReg() != DepReg || !MO.isImplicit())
833 if (CheckDef == MO.isDef())
848 if (HII->isDotNewInst(MI) && !HII->mayBeNewStore(MI))
851 if (!isNewifiable(MI, RC))
877 if (RC == &Hexagon::PredRegsRegClass)
878 return HII->predCanBeUsedAsDotNew(PI, DepReg);
880 if (RC != &Hexagon::PredRegsRegClass && !HII->mayBeNewStore(MI))
885 int NewOpcode = HII->getDotNewOp(MI);
888 bool ResourcesAvailable = ResourceTracker->canReserveResources(*NewMI);
890 if (!ResourcesAvailable)
894 if (!canPromoteToNewValue(MI, PacketSU, DepReg, MII))
915 SUnit *PacketSUDep = MIToSUnit.find(&MI)->second;
917 for (
auto I : CurrentPacketMIs) {
919 if (!HII->isPredicated(*
I))
923 SUnit *PacketSU = MIToSUnit.find(
I)->second;
928 if (PacketSU->
isSucc(PacketSUDep)) {
929 for (
unsigned i = 0; i < PacketSU->
Succs.size(); ++i) {
930 auto &Dep = PacketSU->
Succs[i];
931 if (Dep.getSUnit() == PacketSUDep && Dep.getKind() ==
SDep::Anti &&
932 Dep.getReg() == DepReg)
949 if (
Op.isReg() &&
Op.getReg() &&
Op.isUse() &&
950 Hexagon::PredRegsRegClass.contains(
Op.getReg()))
969 SUnit *SU = MIToSUnit[&MI1];
987 for (
auto I : CurrentPacketMIs) {
989 SUnit *PacketSU = MIToSUnit.find(
I)->second;
992 if (PacketSU->
isSucc(SU)) {
993 for (
unsigned i = 0; i < PacketSU->
Succs.size(); ++i) {
994 auto Dep = PacketSU->
Succs[i];
999 if (Dep.getSUnit() == SU && Dep.getKind() ==
SDep::Data &&
1000 Hexagon::PredRegsRegClass.contains(Dep.getReg())) {
1006 if (restrictingDepExistInPacket(*
I, Dep.getReg()))
1019 return PReg1 == PReg2 &&
1020 Hexagon::PredRegsRegClass.contains(PReg1) &&
1021 Hexagon::PredRegsRegClass.contains(PReg2) &&
1023 HII->isDotNewInst(MI1) == HII->isDotNewInst(MI2);
1029 PromotedToDotNew =
false;
1030 GlueToNewValueJump =
false;
1031 GlueAllocframeStore =
false;
1032 FoundSequentialDependence =
false;
1055 auto *IS = ResourceTracker->getInstrItins()->beginStage(TID.
getSchedClass());
1056 unsigned FuncUnits = IS->getUnits();
1082 if (HII->isSolo(MI))
1114 case Hexagon::S2_storew_locked:
1115 case Hexagon::S4_stored_locked:
1116 case Hexagon::L2_loadw_locked:
1117 case Hexagon::L4_loadd_locked:
1118 case Hexagon::Y2_dccleana:
1119 case Hexagon::Y2_dccleaninva:
1120 case Hexagon::Y2_dcinva:
1121 case Hexagon::Y2_dczeroa:
1122 case Hexagon::Y4_l2fetch:
1123 case Hexagon::Y5_l2fetch: {
1127 unsigned TJ = HII.
getType(MJ);
1150 for (
auto &
B : MF) {
1153 for (
auto I =
B.instr_begin(),
E =
B.instr_end();
I !=
E;
I = NextI) {
1154 NextI = std::next(
I);
1167 bool InsertBeforeBundle;
1171 InsertBeforeBundle =
true;
1175 BundleIt =
moveInstrOut(MI, BundleIt, InsertBeforeBundle);
1184 case Hexagon::Y2_barrier:
1185 case Hexagon::Y2_dcfetchbo:
1186 case Hexagon::Y4_l2fetch:
1187 case Hexagon::Y5_l2fetch:
1200 if (HII->isPredicated(I) || HII->isPredicated(J))
1203 BitVector DeadDefs(Hexagon::NUM_TARGET_REGS);
1205 if (!MO.isReg() || !MO.isDef() || !MO.isDead())
1207 DeadDefs[MO.getReg()] =
true;
1211 if (!MO.isReg() || !MO.isDef() || !MO.isDead())
1213 unsigned R = MO.getReg();
1214 if (R != Hexagon::USR_OVF && DeadDefs[R])
1224 if ((HII->isSaveCalleeSavedRegsCall(I) &&
1226 (HII->isSaveCalleeSavedRegsCall(J) &&
1238 if (
MI.isCall() || HII->isDeallocRet(
MI) || HII->isNewValueJump(
MI))
1240 if (HII->isPredicated(
MI) && HII->isPredicatedNew(
MI) && HII->isJumpR(
MI))
1245 if (HII->isLoopN(I) && isBadForLoopN(J))
1247 if (HII->isLoopN(J) && isBadForLoopN(I))
1252 return HII->isDeallocRet(I) &&
1270 if (!OpJ.isRegMask())
1272 assert((J.
isCall() || HII->isTailCall(J)) &&
"Regmask on a non-call");
1275 if (OpJ.clobbersPhysReg(OpI.getReg()))
1277 }
else if (OpI.isRegMask()) {
1290 if ((SysI && StoreJ) || (SysJ && StoreI))
1293 if (StoreI && StoreJ) {
1294 if (HII->isNewValueInst(J) || HII->isMemOp(J) || HII->isMemOp(I))
1299 bool MopStI = HII->isMemOp(I) || StoreI;
1300 bool MopStJ = HII->isMemOp(J) || StoreJ;
1301 if (MopStI && MopStJ)
1305 return (StoreJ && HII->isDeallocRet(I)) || (StoreI && HII->isDeallocRet(J));
1317 if (CurrentPacketMIs.size() == 1)
1318 IgnoreDepMIs.clear();
1323 assert(!isSoloInstruction(I) &&
"Unexpected solo instr!");
1325 if (cannotCoexist(I, J))
1328 Dependence = hasDeadDependence(I, J) || hasControlDependence(I, J);
1350 if (NextMII != I.getParent()->end() && HII->isNewValueJump(*NextMII)) {
1353 bool secondRegMatch =
false;
1357 if (NOp1.
isReg() && I.getOperand(0).getReg() == NOp1.
getReg())
1358 secondRegMatch =
true;
1374 if (PI->getOpcode() == Hexagon::S2_allocframe || PI->mayStore() ||
1375 HII->isLoopN(*PI)) {
1381 if (OpR.
isReg() && PI->modifiesRegister(OpR.
getReg(), HRI)) {
1387 GlueToNewValueJump =
true;
1396 for (
unsigned i = 0; i < SUJ->
Succs.size(); ++i) {
1397 if (FoundSequentialDependence)
1400 if (SUJ->
Succs[i].getSUnit() != SUI)
1419 unsigned DepReg = 0;
1422 DepReg = SUJ->
Succs[i].getReg();
1423 RC = HRI->getMinimalPhysRegClass(DepReg);
1426 if (I.isCall() || HII->isJumpR(I) || I.isReturn() || HII->isTailCall(I)) {
1429 if (!isCallDependent(I, DepType, SUJ->
Succs[i].getReg()))
1434 if (canPromoteToDotCur(J, SUJ, DepReg, II, RC))
1435 if (promoteToDotCur(J, DepType, II, RC))
1440 if (DepType ==
SDep::Data && HII->isDotCurInst(J)) {
1441 if (HII->isHVXVec(I))
1447 if (canPromoteToDotNew(I, SUJ, DepReg, II, RC)) {
1448 if (promoteToDotNew(I, DepType, II, RC)) {
1449 PromotedToDotNew =
true;
1450 if (cannotCoexist(I, J))
1451 FoundSequentialDependence =
true;
1455 if (HII->isNewValueJump(I))
1461 if (HII->isPredicated(I) && HII->isPredicated(J) &&
1462 arePredicatesComplements(I, J)) {
1475 auto Itr =
find(IgnoreDepMIs, &J);
1476 if (Itr != IgnoreDepMIs.end()) {
1480 IgnoreDepMIs.push_back(&I);
1492 if (I.isConditionalBranch() && DepType !=
SDep::Data &&
1497 FoundSequentialDependence =
true;
1511 FoundSequentialDependence =
true;
1517 bool LoadI = I.mayLoad(), StoreI = I.mayStore();
1518 bool NVStoreJ = HII->isNewValueStore(J);
1519 bool NVStoreI = HII->isNewValueStore(I);
1520 bool IsVecJ = HII->isHVXVec(J);
1521 bool IsVecI = HII->isHVXVec(I);
1524 ((LoadJ && StoreI && !NVStoreI) ||
1525 (StoreJ && LoadI && !NVStoreJ)) &&
1526 (J.
getOpcode() != Hexagon::S2_allocframe &&
1527 I.getOpcode() != Hexagon::S2_allocframe) &&
1528 (J.
getOpcode() != Hexagon::L2_deallocframe &&
1529 I.getOpcode() != Hexagon::L2_deallocframe) &&
1530 (!HII->isMemOp(J) && !HII->isMemOp(I)) && (!IsVecJ && !IsVecI))
1531 setmemShufDisabled(
true);
1533 if (StoreJ && LoadI && alias(J, I)) {
1534 FoundSequentialDependence =
true;
1539 if (!LoadJ || (!LoadI && !StoreI)) {
1542 FoundSequentialDependence =
true;
1557 unsigned Opc = I.getOpcode();
1559 case Hexagon::S2_storerd_io:
1560 case Hexagon::S2_storeri_io:
1561 case Hexagon::S2_storerh_io:
1562 case Hexagon::S2_storerb_io:
1563 if (I.getOperand(0).getReg() == HRI->getStackRegister()) {
1568 GlueAllocframeStore = useCallersSP(I);
1569 if (GlueAllocframeStore)
1588 if (
Op.isReg() &&
Op.isDef()) {
1589 unsigned R =
Op.getReg();
1592 }
else if (!
Op.isRegMask()) {
1596 FoundSequentialDependence =
true;
1608 FoundSequentialDependence =
true;
1613 if (FoundSequentialDependence) {
1626 bool Coexist = !cannotCoexist(I, J);
1633 if (PromotedToDotNew)
1640 if (GlueAllocframeStore) {
1642 GlueAllocframeStore =
false;
1646 undoChangedOffset(I);
1648 if (GlueToNewValueJump) {
1651 GlueToNewValueJump =
false;
1655 if (ChangedOffset ==
INT64_MAX && updateOffset(SUI, SUJ)) {
1656 FoundSequentialDependence =
false;
1666 bool FoundLoad =
false;
1667 bool FoundStore =
false;
1669 for (
auto MJ : CurrentPacketMIs) {
1670 unsigned Opc = MJ->getOpcode();
1671 if (Opc == Hexagon::S2_allocframe || Opc == Hexagon::L2_deallocframe)
1673 if (HII->isMemOp(*MJ))
1677 if (MJ->mayStore() && !HII->isNewValueStore(*MJ))
1680 return FoundLoad && FoundStore;
1689 if (CurrentPacketMIs.empty())
1690 PacketStalls =
false;
1691 PacketStalls |= producesStall(MI);
1696 CurrentPacketMIs.push_back(&MI);
1699 assert(ResourceTracker->canReserveResources(MI));
1701 bool ExtMI = HII->isExtended(MI) || HII->isConstExtended(MI);
1704 if (GlueToNewValueJump) {
1710 ResourceTracker->reserveResources(MI);
1712 Good = tryAllocateResourcesForConstExt(
true);
1714 bool ExtNvjMI = HII->isExtended(NvjMI) || HII->isConstExtended(NvjMI);
1716 if (ResourceTracker->canReserveResources(NvjMI))
1717 ResourceTracker->reserveResources(NvjMI);
1721 if (Good && ExtNvjMI)
1722 Good = tryAllocateResourcesForConstExt(
true);
1726 assert(ResourceTracker->canReserveResources(MI));
1727 ResourceTracker->reserveResources(MI);
1729 assert(canReserveResourcesForConstExt());
1730 tryAllocateResourcesForConstExt(
true);
1732 assert(ResourceTracker->canReserveResources(NvjMI));
1733 ResourceTracker->reserveResources(NvjMI);
1735 assert(canReserveResourcesForConstExt());
1736 reserveResourcesForConstExt();
1739 CurrentPacketMIs.push_back(&MI);
1740 CurrentPacketMIs.push_back(&NvjMI);
1744 ResourceTracker->reserveResources(MI);
1745 if (ExtMI && !tryAllocateResourcesForConstExt(
true)) {
1747 if (PromotedToDotNew)
1749 if (GlueAllocframeStore) {
1751 GlueAllocframeStore =
false;
1753 ResourceTracker->reserveResources(MI);
1754 reserveResourcesForConstExt();
1757 CurrentPacketMIs.push_back(&MI);
1765 bool memShufDisabled = getmemShufDisabled();
1766 if (memShufDisabled && !foundLSInPacket()) {
1767 setmemShufDisabled(
false);
1770 memShufDisabled = getmemShufDisabled();
1772 if (CurrentPacketMIs.size() > 1) {
1777 auto BundleMII = std::prev(FirstMI);
1778 if (memShufDisabled)
1779 HII->setBundleNoShuf(BundleMII);
1781 setmemShufDisabled(
false);
1783 OldPacketMIs = CurrentPacketMIs;
1784 CurrentPacketMIs.clear();
1786 ResourceTracker->clearResources();
1791 return !producesStall(MI);
1808 if (!OldPacketMIs.empty()) {
1809 auto *OldBB = OldPacketMIs.front()->getParent();
1811 if (MLI->getLoopFor(OldBB) != MLI->getLoopFor(ThisBB))
1838 for (
auto J : CurrentPacketMIs) {
1839 SUnit *SUJ = MIToSUnit[J];
1840 for (
auto &Pred : SUI->
Preds)
1841 if (Pred.getSUnit() == SUJ)
1842 if ((Pred.getLatency() == 0 && Pred.isAssignedRegDep()) ||
1843 HII->isNewValueJump(I) || HII->isToBeScheduledASAP(*J, I))
1849 for (
auto J : OldPacketMIs) {
1850 SUnit *SUJ = MIToSUnit[J];
1851 for (
auto &Pred : SUI->
Preds)
1852 if (Pred.getSUnit() == SUJ && Pred.getLatency() > 1)
1864 return new HexagonPacketizer();
bool canPromoteToNewValueStore(const MachineInstr &MI, const MachineInstr &PacketMI, unsigned DepReg)
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
static bool hasWriteToReadDep(const MachineInstr &FirstI, const MachineInstr &SecondI, const TargetRegisterInfo *TRI)
bool modifiesRegister(unsigned Reg, const TargetRegisterInfo *TRI) const
Return true if the MachineInstr modifies (fully define or partially define) the specified register...
bool isCall(QueryType Type=AnyInBundle) const
instr_iterator instr_end()
Compute iterated dominance frontiers using a linear time algorithm.
bool canPromoteToDotNew(const MachineInstr &MI, const SUnit *PacketSU, unsigned DepReg, MachineBasicBlock::iterator &MII, const TargetRegisterClass *RC)
static bool cannotCoexistAsymm(const MachineInstr &MI, const MachineInstr &MJ, const HexagonInstrInfo &HII)
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
bool isCFIInstruction() const
bool isBundledWithPred() const
Return true if this instruction is part of a bundle, and it is not the first instruction in the bundl...
Describe properties that are true of each instruction in the target description file.
unsigned getReg() const
getReg - Returns the register number.
static bool isImplicitDependency(const MachineInstr &I, bool CheckDef, unsigned DepReg)
bool demoteToDotOld(MachineInstr &MI)
static cl::opt< bool > PacketizeVolatiles("hexagon-packetize-volatiles", cl::ZeroOrMore, cl::Hidden, cl::init(true), cl::desc("Allow non-solo packetization of volatile memory references"))
void undoChangedOffset(MachineInstr &MI)
Undo the changed offset.
static cl::opt< bool > DisablePacketizer("disable-packetizer", cl::Hidden, cl::ZeroOrMore, cl::init(false), cl::desc("Disable Hexagon packetizer pass"))
INITIALIZE_PASS_BEGIN(HexagonPacketizer, "hexagon-packetizer", "Hexagon Packetizer", false, false) INITIALIZE_PASS_END(HexagonPacketizer
unsigned const TargetRegisterInfo * TRI
Kind
These are the different kinds of scheduling dependencies.
iterator_range< mop_iterator > operands()
MachineInstr * CreateMachineInstr(const MCInstrDesc &MCID, const DebugLoc &DL, bool NoImp=false)
CreateMachineInstr - Allocate a new MachineInstr.
SmallVector< SDep, 4 > Preds
All sunit predecessors.
A register anti-dependence (aka WAR).
bool restrictingDepExistInPacket(MachineInstr &, unsigned)
bool canPromoteToDotCur(const MachineInstr &MI, const SUnit *PacketSU, unsigned DepReg, MachineBasicBlock::iterator &MII, const TargetRegisterClass *RC)
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
static cl::opt< bool > EnableGenAllInsnClass("enable-gen-insn", cl::init(false), cl::Hidden, cl::ZeroOrMore, cl::desc("Generate all instruction with TC"))
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
unsigned getNumOperands() const
Access to explicit operands of the instruction.
cl::opt< bool > Slot1Store("slot1-store-slot0-load", cl::Hidden, cl::ZeroOrMore, cl::init(true), cl::desc("Allow slot1 store and slot0 load"))
bool isBundledWithSucc() const
Return true if this instruction is part of a bundle, and it is not the last instruction in the bundle...
bool shouldAddToPacket(const MachineInstr &MI) override
Regular data dependence (aka true-dependence).
bool isTerminator(QueryType Type=AnyInBundle) const
Returns true if this instruction part of the terminator for a basic block.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
void endPacket(MachineBasicBlock *MBB, MachineBasicBlock::iterator MI) override
bool arePredicatesComplements(MachineInstr &MI1, MachineInstr &MI2)
static bool doesModifyCalleeSavedReg(const MachineInstr &MI, const TargetRegisterInfo *TRI)
Returns true if the instruction modifies a callee-saved register.
void unbundleFromPred()
Break bundle above this instruction.
A register output-dependence (aka WAW).
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
static bool isControlFlow(const MachineInstr &MI)
void initializeHexagonPacketizerPass(PassRegistry &)
instr_iterator getInstrIterator() const
bool isInsideBundle() const
Return true if MI is in a bundle (but not the first MI in a bundle).
virtual const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const =0
Return a null-terminated list of all of the callee-saved registers on this target.
hexagon Hexagon Packetizer
bool isBranch(QueryType Type=AnyInBundle) const
Returns true if this is a conditional, unconditional, or indirect branch.
static MachineBasicBlock::iterator moveInstrOut(MachineInstr &MI, MachineBasicBlock::iterator BundleIt, bool Before)
static unsigned getPredicatedRegister(MachineInstr &MI, const HexagonInstrInfo *QII)
Gets the predicate register of a predicated instruction.
static const MachineOperand & getAbsSetOperand(const MachineInstr &MI)
bool isSoloInstruction(const MachineInstr &MI) override
unsigned getSchedClass() const
Return the scheduling class for this instruction.
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
initializer< Ty > init(const Ty &Val)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
MachineInstr * getInstr() const
Returns the representative MachineInstr for this SUnit.
static bool isSystemInstr(const MachineInstr &MI)
FunctionPass * createHexagonPacketizer()
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.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
std::pair< iterator, bool > insert(const ValueT &V)
Represent the analysis usage information of a pass.
void clearFlag(MIFlag Flag)
clearFlag - Clear a MI flag.
void setImm(int64_t immVal)
FunctionPass class - This class is used to implement most global optimizations.
self_iterator getIterator()
static bool isRegDependence(const SDep::Kind DepType)
bool tryAllocateResourcesForConstExt(bool Reserve)
void DeleteMachineInstr(MachineInstr *MI)
DeleteMachineInstr - Delete the given MachineInstr.
bool isImplicitDef() const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Any other ordering dependency.
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
bool isPostIncrement(const MachineInstr &MI) const override
Return true for post-incremented instructions.
bool isDebugInstr() const
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool isLegalToPacketizeTogether(SUnit *SUI, SUnit *SUJ) override
bool isPredicated(const MachineInstr &MI) const override
Returns true if the instruction is already predicated.
static const MachineOperand & getPostIncrementOperand(const MachineInstr &MI, const HexagonInstrInfo *HII)
#define HEXAGON_LRFP_SIZE
Iterator for intrusive lists based on ilist_node.
void setDesc(const MCInstrDesc &tid)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one...
bool hasV60OpsOnly() const
bool isDebugValue() const
MachineOperand class - Representation of each machine instruction operand.
uint64_t getType(const MachineInstr &MI) const
bool hasOrderedMemoryRef() const
Return true if this instruction may have an ordered or volatile memory reference, or if the informati...
static cl::opt< bool > DisableVecDblNVStores("disable-vecdbl-nv-stores", cl::init(false), cl::Hidden, cl::ZeroOrMore, cl::desc("Disable vector double new-value-stores"))
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
void setPreservesCFG()
This function should be called by the pass, iff they do not:
const Function & getFunction() const
Return the LLVM function that this machine code represents.
void initPacketizerState() override
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool canReserveResourcesForConstExt()
MachineBasicBlock::iterator addToPacket(MachineInstr &MI) override
bool readsRegister(unsigned Reg, const TargetRegisterInfo *TRI=nullptr) const
Return true if the MachineInstr reads the specified register.
bool mayStore() const
Return true if this instruction could possibly modify memory.
static const MachineOperand & getStoreValueOperand(const MachineInstr &MI)
static bool isLoadAbsSet(const MachineInstr &MI)
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 !p0...
const MachineBasicBlock * getParent() const
MachineFunctionProperties & set(Property P)
Representation of each machine instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
static bool isSchedBarrier(const MachineInstr &MI)
void reserveResourcesForConstExt()
bool promoteToDotCur(MachineInstr &MI, SDep::Kind DepType, MachineBasicBlock::iterator &MII, const TargetRegisterClass *RC)
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 '...
bool isCallDependent(const MachineInstr &MI, SDep::Kind DepType, unsigned DepReg)
bool ignorePseudoInstruction(const MachineInstr &MI, const MachineBasicBlock *MBB) override
bool isNewifiable(const MachineInstr &MI, const TargetRegisterClass *NewRC)
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...
cl::opt< bool > ScheduleInlineAsm
bool isCall() const
Return true if the instruction is a call.
bool isPredicatedTrue(const MachineInstr &MI) const
bool hasControlDependence(const MachineInstr &I, const MachineInstr &J)
DFAPacketizer * getResourceTracker()
bool useCallersSP(MachineInstr &MI)
bool isReg() const
isReg - Tests if this is a MO_Register operand.
bool mayLoad(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read memory.
bool promoteToDotNew(MachineInstr &MI, SDep::Kind DepType, MachineBasicBlock::iterator &MII, const TargetRegisterClass *RC)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool hasDeadDependence(const MachineInstr &I, const MachineInstr &J)
bool isHVXMemWithAIndirect(const MachineInstr &I, const MachineInstr &J) const
bool isTerminator() const
Returns true if this instruction part of the terminator for a basic block.
bool cannotCoexist(const MachineInstr &MI, const MachineInstr &MJ)
bool isLegalToPruneDependencies(SUnit *SUI, SUnit *SUJ) override
const HexagonInstrInfo * getInstrInfo() const override
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
SmallVector< SDep, 4 > Succs
All sunit successors.
void useCalleesSP(MachineInstr &MI)
bool hasRegMaskDependence(const MachineInstr &I, const MachineInstr &J)
bool isBarrier(QueryType Type=AnyInBundle) const
Returns true if the specified instruction stops control flow from executing the instruction immediate...
StringRef - Represent a constant reference to a string, i.e.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
void unpacketizeSoloInstrs(MachineFunction &MF)
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object...
Dependence - This class represents a dependence between two memory memory references in a function...
const MachineOperand & getOperand(unsigned i) const
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...
bool canPromoteToNewValue(const MachineInstr &MI, const SUnit *PacketSU, unsigned DepReg, MachineBasicBlock::iterator &MII)
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects...
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
bool isSucc(const SUnit *N) const
Tests if node N is a successor of this node.
void PacketizeMIs(MachineBasicBlock *MBB, MachineBasicBlock::iterator BeginItr, MachineBasicBlock::iterator EndItr)
static bool isDirectJump(const MachineInstr &MI)
bool producesStall(const MachineInstr &MI)
Properties which a MachineFunction may have at a given point in time.
Scheduling unit. This is a node in the scheduling DAG.
bool hasV4SpecificDependence(const MachineInstr &I, const MachineInstr &J)