33#define DEBUG_TYPE "pre-RA-sched"
57 std::vector<SUnit*> PendingQueue;
66 HazardRec = STI.
getInstrInfo()->CreateTargetHazardRecognizer(&STI,
this);
69 ~ScheduleDAGVLIW()
override {
71 delete AvailableQueue;
74 void Schedule()
override;
77 void releaseSucc(SUnit *SU,
const SDep &
D);
78 void releaseSuccessors(SUnit *SU);
79 void scheduleNodeTopDown(SUnit *SU,
unsigned CurCycle);
80 void listScheduleTopDown();
85void ScheduleDAGVLIW::Schedule() {
87 <<
" '" << BB->getName() <<
"' **********\n");
89 assert(PendingQueue.empty() &&
"stale PendingQueue");
98 listScheduleTopDown();
109void ScheduleDAGVLIW::releaseSucc(SUnit *SU,
const SDep &
D) {
110 SUnit *SuccSU =
D.getSUnit();
114 dbgs() <<
"*** Scheduling failed! ***\n";
116 dbgs() <<
" has been released too many times!\n";
120 assert(!
D.isWeak() &&
"unexpected artificial DAG edge");
129 PendingQueue.push_back(SuccSU);
133void ScheduleDAGVLIW::releaseSuccessors(SUnit *SU) {
135 for (SDep &Succ : SU->
Succs) {
137 "The list-td scheduler doesn't yet support physreg dependencies!");
139 releaseSucc(SU, Succ);
146void ScheduleDAGVLIW::scheduleNodeTopDown(SUnit *SU,
unsigned CurCycle) {
151 assert(CurCycle >= SU->
getDepth() &&
"Node scheduled above its depth!");
154 releaseSuccessors(SU);
161void ScheduleDAGVLIW::listScheduleTopDown() {
162 unsigned CurCycle = 0;
165 releaseSuccessors(&EntrySU);
168 for (SUnit &SU : SUnits) {
170 if (SU.
Preds.empty()) {
171 AvailableQueue->
push(&SU);
178 std::vector<SUnit*> NotReady;
180 while (!AvailableQueue->
empty() || !PendingQueue.empty()) {
183 for (
unsigned i = 0, e = PendingQueue.size(); i != e; ++i) {
184 if (PendingQueue[i]->getDepth() == CurCycle) {
185 AvailableQueue->
push(PendingQueue[i]);
186 PendingQueue[i]->isAvailable =
true;
187 PendingQueue[i] = PendingQueue.back();
188 PendingQueue.pop_back();
192 assert(PendingQueue[i]->getDepth() > CurCycle &&
"Negative latency?");
198 if (AvailableQueue->
empty()) {
205 SUnit *FoundSUnit =
nullptr;
207 bool HasNoopHazards =
false;
208 while (!AvailableQueue->
empty()) {
209 SUnit *CurSUnit = AvailableQueue->
pop();
214 FoundSUnit = CurSUnit;
221 NotReady.push_back(CurSUnit);
225 if (!NotReady.empty()) {
232 scheduleNodeTopDown(FoundSUnit, CurCycle);
239 }
else if (!HasNoopHazards) {
259 VerifyScheduledSequence(
false);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static RegisterScheduler VLIWScheduler("vliw-td", "VLIW scheduler", createVLIWDAGScheduler)
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
bool isAssignedRegDep() const
Tests if this is a Data dependence that is associated with a register.
unsigned short Latency
Node latency.
unsigned getDepth() const
Returns the depth of this node, which is the length of the maximum path up to any node which has no p...
bool isScheduled
True once scheduled.
bool isAvailable
True once available.
SmallVector< SDep, 4 > Succs
All sunit successors.
SmallVector< SDep, 4 > Preds
All sunit predecessors.
LLVM_ABI void setDepthToAtLeast(unsigned NewDepth)
If NewDepth is greater than this node's depth value, sets it to be the new depth value.
ScheduleDAGSDNodes - A ScheduleDAG for scheduling SDNode-based DAGs.
HazardRecognizer - This determines whether or not an instruction can be issued this cycle,...
virtual void Reset()
Reset - This callback is invoked when a new block of instructions is about to be schedule.
virtual void EmitInstruction(SUnit *)
EmitInstruction - This callback is invoked when an instruction is emitted, to advance the hazard stat...
virtual void EmitNoop()
EmitNoop - This callback is invoked when a noop was added to the instruction stream.
virtual void AdvanceCycle()
AdvanceCycle - This callback is invoked whenever the next top-down instruction to be scheduled cannot...
virtual HazardType getHazardType(SUnit *, int Stalls=0)
getHazardType - Return the hazard type of emitting this node.
This interface is used to plug different priorities computation algorithms into the list scheduler.
virtual void releaseState()=0
virtual void scheduledNode(SUnit *)
As each node is scheduled, this method is invoked.
virtual void initNodes(std::vector< SUnit > &SUnits)=0
virtual bool empty() const =0
void push_all(const std::vector< SUnit * > &Nodes)
virtual void push(SUnit *U)=0
SelectionDAGISel - This is the common base class used for SelectionDAG-based pattern-matching instruc...
TargetSubtargetInfo - Generic base class for all target subtargets.
virtual const TargetInstrInfo * getInstrInfo() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Sequence
A sequence of states that a pointer may go through in which an objc_retain and objc_release are actua...
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.
CodeGenOptLevel
Code generation optimization level.
LLVM_ABI ScheduleDAGSDNodes * createVLIWDAGScheduler(SelectionDAGISel *IS, CodeGenOptLevel OptLevel)
createVLIWDAGScheduler - Scheduler for VLIW targets.
LLVM_ABI Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.