22#define DEBUG_TYPE "machine-scheduler"
26void SystemZPostRASchedStrategy::SUSet::
29 for (
auto &SU : *
this) {
43 if (
MBB->pred_size() == 1)
44 PredMBB = *
MBB->pred_begin();
51 PredMBB = (Pred ==
MBB ? nullptr : Pred);
55 &&
"Loop MBB should not consider predecessor outside of loop.");
60void SystemZPostRASchedStrategy::
64 ((LastEmittedMI !=
nullptr && LastEmittedMI->getParent() == MBB) ?
65 std::next(LastEmittedMI) : MBB->begin());
67 for (;
I != NextBegin; ++
I) {
68 if (
I->isPosition() ||
I->isDebugInstr())
70 HazardRec->emitInstruction(&*
I);
80 assert ((SchedStates.find(NextMBB) == SchedStates.end()) &&
81 "Entering MBB twice?");
97 if (SinglePredMBB ==
nullptr)
99 auto It = SchedStates.find(SinglePredMBB);
100 if (It == SchedStates.end())
106 HazardRec->copyState(It->second);
113 bool TakenBranch = (
MI.isBranch() &&
114 (TII->getBranchInfo(
MI).isIndirect() ||
115 TII->getBranchInfo(
MI).getMBBTarget() == MBB));
116 HazardRec->emitInstruction(&
MI, TakenBranch);
127 advanceTo(MBB->getFirstTerminator());
134 (
C->MF->getSubtarget().getInstrInfo())),
135 MBB(nullptr), HazardRec(nullptr) {
142 for (
auto I : SchedStates) {
150 unsigned NumRegionInstrs) {
152 if (Begin->isTerminator())
164 if (Available.empty())
168 if (Available.size() == 1) {
170 HazardRec->dumpSU(*Available.begin(),
dbgs());
dbgs() <<
"\n";);
171 return *Available.begin();
175 LLVM_DEBUG(
dbgs() <<
"** Available: "; Available.dump(*HazardRec););
178 for (
auto *SU : Available) {
181 Candidate c(SU, *HazardRec);
184 if (Best.SU ==
nullptr || c < Best) {
194 if (!SU->isScheduleHigh && Best.noCost())
198 assert (Best.SU !=
nullptr);
202SystemZPostRASchedStrategy::Candidate::
215bool SystemZPostRASchedStrategy::Candidate::
216operator<(
const Candidate &other) {
219 if (GroupingCost < other.GroupingCost)
221 if (GroupingCost > other.GroupingCost)
225 if (ResourcesCost < other.ResourcesCost)
227 if (ResourcesCost > other.ResourcesCost)
231 if (SU->
getHeight() > other.SU->getHeight())
233 if (SU->
getHeight() < other.SU->getHeight())
237 if (SU->
NodeNum < other.SU->NodeNum)
245 if (Available.size() == 1)
dbgs() <<
"(only one) ";
246 Candidate c(SU, *HazardRec); c.dumpCosts();
dbgs() <<
"\n";);
250 HazardRec->EmitInstruction(SU);
261 Available.insert(SU);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static MachineBasicBlock * getSingleSchedPred(MachineBasicBlock *MBB, const MachineLoop *Loop)
bool contains(const LoopT *L) const
Return true if the specified loop is contained within in this loop.
BlockT * getHeader() const
Represents a single loop in the control flow graph.
MachineInstrBundleIterator< MachineInstr > iterator
Representation of each machine instruction.
Scheduling unit. This is a node in the scheduling DAG.
unsigned NodeNum
Entry # of node in the node vector.
bool isUnbuffered
Uses an unbuffered resource.
unsigned getHeight() const
Returns the height of this node, which is the length of the maximum path down to any node which has n...
bool isScheduleHigh
True if preferable to schedule high.
ScheduleDAGMI is an implementation of ScheduleDAGInstrs that simply schedules machine instructions ac...
SystemZHazardRecognizer maintains the state for one MBB during scheduling.
int groupingCost(SUnit *SU) const
Return the cost of decoder grouping for SU.
void dumpSU(SUnit *SU, raw_ostream &OS) const
int resourcesCost(SUnit *SU)
Return the cost of SU in regards to processor resources usage.
SUnit * pickNode(bool &IsTopNode) override
Pick the next node to schedule, or return NULL.
void leaveMBB() override
Tell the strategy that current MBB is done.
void initPolicy(MachineBasicBlock::iterator Begin, MachineBasicBlock::iterator End, unsigned NumRegionInstrs) override
Called for a region before scheduling.
void schedNode(SUnit *SU, bool IsTopNode) override
ScheduleDAGMI has scheduled an instruction - tell HazardRec about it.
void initialize(ScheduleDAGMI *dag) override
Initialize the strategy after building the DAG for a new region.
void enterMBB(MachineBasicBlock *NextMBB) override
Tell the strategy that MBB is about to be processed.
virtual ~SystemZPostRASchedStrategy()
SystemZPostRASchedStrategy(const MachineSchedContext *C)
void releaseTopNode(SUnit *SU) override
SU has had all predecessor dependencies resolved.
TargetSubtargetInfo - Generic base class for all target subtargets.
@ C
The default llvm calling convention, compatible with C.
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.
LLVM_ABI Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
Summarize the scheduling resources required for an instruction of a particular scheduling class.
MachineSchedContext provides enough context from the MachineScheduler pass for the target to instanti...