25#define DEBUG_TYPE "post-RA-sched"
29 Resources->clearResources();
34 PrefVectorStoreNew =
nullptr;
44 if (!
MI || TII->isZeroCost(
MI->getOpcode()) ||
MI->isMetaInstruction())
47 if (!Resources->canReserveResources(*
MI)) {
50 if (isNewStore(*
MI)) {
55 MF->CreateMachineInstr(TII->get(TII->getDotNewOp(*
MI)),
57 if (Resources->canReserveResources(*NewMI))
61 MF->deleteMachineInstr(NewMI);
66 if (SU == UsesDotCur && DotCurPNum != (
int)PacketNum) {
67 LLVM_DEBUG(
dbgs() <<
"*** .cur Hazard in cycle " << PacketNum <<
", "
72 if (mustWaitForHMXPartner(SU)) {
73 LLVM_DEBUG(
dbgs() <<
"*** HMX pair hazard in cycle " << PacketNum <<
", "
81SUnit *HexagonHazardRecognizer::findHMXPartner(
SUnit *SU)
const {
83 bool IsActivate =
TII->isHMXActivateInstr(
MI);
84 SUnit *Partner =
nullptr;
94 IsActivate ?
TII->isHMXWeightInstr(
SI) :
TII->isHMXActivateInstr(
SI);
101bool HexagonHazardRecognizer::mustWaitForHMXPartner(
SUnit *SU)
const {
103 if (!!Activate == !!Weight)
105 if (SU == HMXPartner)
116 Resources->clearResources();
117 if (DotCurPNum != -1 && DotCurPNum != (
int)PacketNum) {
118 UsesDotCur =
nullptr;
122 PrefVectorStoreNew =
nullptr;
123 if (Weight !=
nullptr && Activate !=
nullptr) {
126 HMXPartner =
nullptr;
146 if (Weight ==
nullptr && Activate ==
nullptr)
147 if (TII->isHMXWeightInstr(*SU->
getInstr()) ||
148 TII->isHMXActivateInstr(*SU->
getInstr()))
151 if (PrefVectorStoreNew !=
nullptr && PrefVectorStoreNew != SU)
155 return UsesDotCur && ((SU == UsesDotCur) ^ (DotCurPNum == (int)PacketNum));
161 if (!
TII->mayBeNewStore(
MI))
178 if (TII->isZeroCost(
MI->getOpcode()) ||
MI->isMetaInstruction())
181 if (!Resources->canReserveResources(*
MI) || isNewStore(*
MI)) {
184 assert(TII->mayBeNewStore(*
MI) &&
"Expecting .new store");
187 MF->CreateMachineInstr(TII->get(TII->getDotNewOp(*
MI)),
189 if (Resources->canReserveResources(*NewMI))
190 Resources->reserveResources(*NewMI);
192 Resources->reserveResources(*
MI);
193 MF->deleteMachineInstr(NewMI);
195 Resources->reserveResources(*
MI);
202 if (TII->mayBeCurLoad(*
MI))
203 for (
auto &S : SU->
Succs)
204 if (S.isAssignedRegDep() && S.getLatency() == 0 &&
206 UsesDotCur = S.getSUnit();
207 DotCurPNum = PacketNum;
210 if (SU == UsesDotCur) {
211 UsesDotCur =
nullptr;
215 UsesLoad =
MI->mayLoad();
217 if (TII->isHVXVec(*
MI) && !
MI->mayLoad() && !
MI->mayStore())
218 for (
auto &S : SU->
Succs)
219 if (S.isAssignedRegDep() && S.getLatency() == 0 &&
220 TII->mayBeNewStore(*S.getSUnit()->
getInstr()) &&
221 Resources->canReserveResources(*S.getSUnit()->
getInstr())) {
222 PrefVectorStoreNew = S.getSUnit();
225 bool IsWeight = TII->isHMXWeightInstr(*
MI);
226 bool IsActivate = TII->isHMXActivateInstr(*
MI);
227 if (IsWeight || IsActivate) {
228 bool IsFirstHalf = !Weight && !Activate;
233 HMXPartner = IsFirstHalf ? findHMXPartner(SU) :
nullptr;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
const HexagonInstrInfo * TII
void Reset() override
This callback is invoked when a new block of instructions is about to be scheduled.
void AdvanceCycle() override
This callback is invoked whenever the next top-down instruction to be scheduled cannot issue in the c...
bool ShouldPreferAnother(SUnit *) const override
This callback may be invoked if getHazardType returns NoHazard.
HazardType getHazardType(SUnit *SU, int stalls) override
Return the hazard type of emitting this node.
void EmitInstruction(SUnit *) override
This callback is invoked when an instruction is emitted to be scheduled, to advance the hazard state.
Representation of each machine instruction.
bool mayLoad(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read memory.
LLVM_ABI void insert(mop_iterator InsertBefore, ArrayRef< MachineOperand > Ops)
Inserts Ops BEFORE It. Can untie/retie tied operands.
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.
Scheduling unit. This is a node in the scheduling DAG.
bool isInstr() const
Returns true if this SUnit refers to a machine instruction as opposed to an SDNode.
unsigned NodeNum
Entry # of node in the node vector.
SmallVector< SDep, 4 > Succs
All sunit successors.
MachineInstr * getInstr() const
Returns the representative MachineInstr for this SUnit.
bool contains(const T &V) const
Check if the SmallSet contains the given element.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.