LLVM API Documentation
#include <MachineScheduler.h>
Public Member Functions | |
GenericScheduler (const MachineSchedContext *C) | |
void | initPolicy (MachineBasicBlock::iterator Begin, MachineBasicBlock::iterator End, unsigned NumRegionInstrs) override |
Initialize the per-region scheduling policy. | |
bool | shouldTrackPressure () const override |
void | initialize (ScheduleDAGMI *dag) override |
Initialize the strategy after building the DAG for a new region. | |
SUnit * | pickNode (bool &IsTopNode) override |
Pick the best node to balance the schedule. Implements MachineSchedStrategy. | |
void | schedNode (SUnit *SU, bool IsTopNode) override |
void | releaseTopNode (SUnit *SU) override |
void | releaseBottomNode (SUnit *SU) override |
void | registerRoots () override |
Protected Member Functions | |
void | checkAcyclicLatency () |
void | tryCandidate (SchedCandidate &Cand, SchedCandidate &TryCand, SchedBoundary &Zone, const RegPressureTracker &RPTracker, RegPressureTracker &TempTracker) |
SUnit * | pickNodeBidirectional (bool &IsTopNode) |
Pick the best candidate node from either the top or bottom queue. | |
void | pickNodeFromQueue (SchedBoundary &Zone, const RegPressureTracker &RPTracker, SchedCandidate &Candidate) |
void | reschedulePhysRegCopies (SUnit *SU, bool isTop) |
GenericScheduler shrinks the unscheduled zone using heuristics to balance the schedule.
Definition at line 845 of file MachineScheduler.h.
llvm::GenericScheduler::GenericScheduler | ( | const MachineSchedContext * | C | ) | [inline] |
Definition at line 854 of file MachineScheduler.h.
void GenericScheduler::checkAcyclicLatency | ( | ) | [protected] |
Set IsAcyclicLatencyLimited if the acyclic path is longer than the cyclic critical path by more cycles than it takes to drain the instruction buffer. We estimate an upper bounds on in-flight instructions as:
CyclesPerIteration = max( CyclicPath, Loop-Resource-Height ) InFlightIterations = AcyclicPath / CyclesPerIteration InFlightResources = InFlightIterations * LoopResources
TODO: Check execution resources in addition to IssueCount.
Definition at line 2436 of file MachineScheduler.cpp.
References llvm::SchedRemainder::CriticalPath, llvm::SchedRemainder::CyclicCritPath, llvm::dbgs(), DEBUG, llvm::TargetSchedModel::getLatencyFactor(), llvm::TargetSchedModel::getMicroOpBufferSize(), llvm::TargetSchedModel::getMicroOpFactor(), llvm::SchedRemainder::IsAcyclicLatencyLimited, llvm::GenericSchedulerBase::Rem, llvm::SchedRemainder::RemIssueCount, and llvm::GenericSchedulerBase::SchedModel.
void GenericScheduler::initialize | ( | ScheduleDAGMI * | DAG | ) | [override, virtual] |
Initialize the strategy after building the DAG for a new region.
Implements llvm::MachineSchedStrategy.
Definition at line 2350 of file MachineScheduler.cpp.
References llvm::TargetInstrInfo::CreateTargetMIHazardRecognizer(), llvm::TargetSubtargetInfo::getInstrInfo(), llvm::TargetSchedModel::getInstrItineraries(), llvm::TargetMachine::getSubtargetImpl(), llvm::ScheduleDAGMI::hasVRegLiveness(), llvm::SchedRemainder::init(), llvm::GenericSchedulerBase::Rem, llvm::GenericSchedulerBase::SchedModel, llvm::SystemZISD::TM, and llvm::GenericSchedulerBase::TRI.
void GenericScheduler::initPolicy | ( | MachineBasicBlock::iterator | Begin, |
MachineBasicBlock::iterator | End, | ||
unsigned | NumRegionInstrs | ||
) | [override, virtual] |
Initialize the per-region scheduling policy.
Reimplemented from llvm::MachineSchedStrategy.
Definition at line 2380 of file MachineScheduler.cpp.
References llvm::GenericSchedulerBase::Context, EnableRegPressure, llvm::ForceBottomUp, llvm::ForceTopDown, llvm::RegisterClassInfo::getNumAllocatableRegs(), llvm::TargetLoweringBase::getRegClassFor(), llvm::TargetMachine::getSubtarget(), llvm::TargetMachine::getSubtargetImpl(), llvm::MachineFunction::getTarget(), llvm::TargetSubtargetInfo::getTargetLowering(), llvm::MVT::i1, llvm::MVT::i32, llvm::TargetLoweringBase::isTypeLegal(), llvm::MachineSchedContext::MF, llvm::TargetSubtargetInfo::overrideSchedPolicy(), llvm::MachineSchedContext::RegClassInfo, and llvm::SystemZISD::TM.
SUnit * GenericScheduler::pickNode | ( | bool & | IsTopNode | ) | [override, virtual] |
Pick the best node to balance the schedule. Implements MachineSchedStrategy.
Implements llvm::MachineSchedStrategy.
Definition at line 2771 of file MachineScheduler.cpp.
References llvm::ScheduleDAGMI::bottom(), llvm::dbgs(), DEBUG, llvm::SUnit::getInstr(), llvm::SUnit::isBottomReady(), llvm::SUnit::isScheduled, llvm::SUnit::isTopReady(), llvm::GenericSchedulerBase::NoCand, llvm::SUnit::NodeNum, llvm::GenericSchedulerBase::SchedCandidate::Reason, llvm::GenericSchedulerBase::SchedCandidate::SU, llvm::ScheduleDAGMI::top(), and tracePick().
SUnit * GenericScheduler::pickNodeBidirectional | ( | bool & | IsTopNode | ) | [protected] |
Pick the best candidate node from either the top or bottom queue.
Definition at line 2712 of file MachineScheduler.cpp.
References llvm::dbgs(), DEBUG, llvm::GenericSchedulerBase::SchedCandidate::isRepeat(), llvm::GenericSchedulerBase::NoCand, llvm::GenericSchedulerBase::SchedCandidate::Policy, llvm::GenericSchedulerBase::SchedCandidate::Reason, llvm::GenericSchedulerBase::RegCritical, llvm::GenericSchedulerBase::RegExcess, llvm::GenericSchedulerBase::setPolicy(), llvm::GenericSchedulerBase::SchedCandidate::SU, and tracePick().
void GenericScheduler::pickNodeFromQueue | ( | SchedBoundary & | Zone, |
const RegPressureTracker & | RPTracker, | ||
SchedCandidate & | Cand | ||
) | [protected] |
Pick the best candidate from the queue.
TODO: getMaxPressureDelta results can be mostly cached for each SUnit during DAG building. To adjust for the current scheduling location we need to maintain the number of vreg uses remaining to be top-scheduled.
Definition at line 2686 of file MachineScheduler.cpp.
References llvm::SchedBoundary::Available, llvm::ReadyQueue::begin(), DEBUG, llvm::ReadyQueue::dump(), llvm::ReadyQueue::end(), I, llvm::GenericSchedulerBase::SchedCandidate::initResourceDelta(), llvm::GenericSchedulerBase::NoCand, llvm::GenericSchedulerBase::SchedCandidate::Policy, llvm::GenericSchedulerBase::SchedCandidate::Reason, llvm::GenericSchedulerBase::SchedCandidate::ResDelta, llvm::GenericSchedulerBase::SchedModel, llvm::GenericSchedulerBase::SchedCandidate::setBest(), llvm::GenericSchedulerBase::SchedCandidate::SU, and llvm::GenericSchedulerBase::traceCandidate().
void GenericScheduler::registerRoots | ( | ) | [override, virtual] |
Notify this strategy that all roots have been released (including those that depend on EntrySU or ExitSU).
Reimplemented from llvm::MachineSchedStrategy.
Definition at line 2464 of file MachineScheduler.cpp.
References llvm::SchedRemainder::CriticalPath, llvm::SchedRemainder::CyclicCritPath, llvm::dbgs(), DEBUG, llvm::DumpCriticalPathLength, EnableCyclicPath, llvm::errs(), llvm::ScheduleDAG::ExitSU, llvm::SUnit::getDepth(), I, and llvm::GenericSchedulerBase::Rem.
void llvm::GenericScheduler::releaseBottomNode | ( | SUnit * | SU | ) | [inline, override, virtual] |
When all successor dependencies have been resolved, free this node for bottom-up scheduling.
Implements llvm::MachineSchedStrategy.
Definition at line 876 of file MachineScheduler.h.
References llvm::SchedBoundary::releaseBottomNode().
void llvm::GenericScheduler::releaseTopNode | ( | SUnit * | SU | ) | [inline, override, virtual] |
When all predecessor dependencies have been resolved, free this node for top-down scheduling.
Implements llvm::MachineSchedStrategy.
Definition at line 872 of file MachineScheduler.h.
References llvm::SchedBoundary::releaseTopNode().
void GenericScheduler::reschedulePhysRegCopies | ( | SUnit * | SU, |
bool | isTop | ||
) | [protected] |
Definition at line 2817 of file MachineScheduler.cpp.
References llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::SDep::Data, llvm::dbgs(), DEBUG, llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::SUnit::getInstr(), I, llvm::MachineInstr::isCopy(), llvm::TargetRegisterInfo::isPhysicalRegister(), llvm::ScheduleDAGMI::moveInstruction(), llvm::SUnit::Preds, llvm::SmallVectorTemplateCommon< T, typename >::size(), llvm::SUnit::Succs, and llvm::GenericSchedulerBase::TRI.
void GenericScheduler::schedNode | ( | SUnit * | SU, |
bool | IsTopNode | ||
) | [override, virtual] |
Update the scheduler's state after scheduling a node. This is the same node that was just returned by pickNode(). However, ScheduleDAGMILive needs to update it's state based on the current cycle before MachineSchedStrategy does.
FIXME: Eventually, we may bundle physreg copies rather than rescheduling them here. See comments in biasPhysRegCopy.
Implements llvm::MachineSchedStrategy.
Definition at line 2849 of file MachineScheduler.cpp.
References llvm::SUnit::BotReadyCycle, llvm::SUnit::hasPhysRegDefs, llvm::SUnit::hasPhysRegUses, and llvm::SUnit::TopReadyCycle.
bool llvm::GenericScheduler::shouldTrackPressure | ( | ) | const [inline, override, virtual] |
Check if pressure tracking is needed before building the DAG and initializing this strategy. Called after initPolicy.
Reimplemented from llvm::MachineSchedStrategy.
Definition at line 862 of file MachineScheduler.h.
References llvm::MachineSchedPolicy::ShouldTrackPressure.
void GenericScheduler::tryCandidate | ( | SchedCandidate & | Cand, |
SchedCandidate & | TryCand, | ||
SchedBoundary & | Zone, | ||
const RegPressureTracker & | RPTracker, | ||
RegPressureTracker & | TempTracker | ||
) | [protected] |
Apply a set of heursitics to a new candidate. Heuristics are currently hierarchical. This may be more efficient than a graduated cost model because we don't need to evaluate all aspects of the model for each node in the queue. But it's really done to make the heuristics easier to debug and statistically analyze.
Cand | provides the policy and current best candidate. |
TryCand | refers to the next SUnit candidate, otherwise uninitialized. |
Zone | describes the scheduled zone that we are extending. |
RPTracker | describes reg pressure within the scheduled zone. |
TempTracker | is a scratch pressure tracker to reuse in queries. |
Definition at line 2551 of file MachineScheduler.cpp.
References biasPhysRegCopy(), llvm::GenericSchedulerBase::Cluster, llvm::RegPressureDelta::CriticalMax, llvm::GenericSchedulerBase::SchedResourceDelta::CritResources, llvm::RegPressureDelta::CurrentMax, llvm::dbgs(), DEBUG, llvm::GenericSchedulerBase::SchedResourceDelta::DemandedResources, llvm::RegPressureDelta::Excess, llvm::SchedBoundary::getCurrMOps(), llvm::SUnit::getInstr(), llvm::SchedBoundary::getLatencyStallCycles(), llvm::RegPressureTracker::getMaxDownwardPressureDelta(), llvm::RegPressureTracker::getMaxUpwardPressureDelta(), llvm::ScheduleDAGMI::getNextClusterPred(), llvm::ScheduleDAGMI::getNextClusterSucc(), llvm::PressureChange::getPSet(), llvm::TargetRegisterInfo::getRegPressureSetName(), llvm::PressureChange::getUnitInc(), llvm::RegPressureTracker::getUpwardPressureDelta(), getWeakLeft(), llvm::GenericSchedulerBase::SchedCandidate::initResourceDelta(), llvm::SchedRemainder::IsAcyclicLatencyLimited, llvm::SchedBoundary::isNextSU(), llvm::SchedBoundary::isTop(), llvm::PressureChange::isValid(), llvm::GenericSchedulerBase::SchedCandidate::isValid(), llvm::GenericSchedulerBase::NextDefUse, llvm::SUnit::NodeNum, llvm::GenericSchedulerBase::NodeOrder, llvm::GenericSchedulerBase::PhysRegCopy, llvm::GenericSchedulerBase::SchedCandidate::Reason, llvm::GenericSchedulerBase::RegCritical, llvm::GenericSchedulerBase::RegExcess, llvm::GenericSchedulerBase::RegMax, llvm::GenericSchedulerBase::Rem, llvm::GenericSchedulerBase::SchedCandidate::ResDelta, llvm::GenericSchedulerBase::ResourceDemand, llvm::GenericSchedulerBase::ResourceReduce, llvm::GenericSchedulerBase::SchedCandidate::RPDelta, llvm::GenericSchedulerBase::SchedModel, llvm::GenericSchedulerBase::Stall, llvm::GenericSchedulerBase::SchedCandidate::SU, llvm::GenericSchedulerBase::TRI, tryGreater(), tryLatency(), tryLess(), tryPressure(), VerifyScheduling, and llvm::GenericSchedulerBase::Weak.