LLVM API Documentation
#include <MachineScheduler.h>
Public Member Functions | |
ScheduleDAGMILive (MachineSchedContext *C, std::unique_ptr< MachineSchedStrategy > S) | |
virtual | ~ScheduleDAGMILive () |
bool | hasVRegLiveness () const override |
Return true if this DAG supports VReg liveness and RegPressure. | |
bool | isTrackingPressure () const |
Return true if register pressure tracking is enabled. | |
const IntervalPressure & | getTopPressure () const |
Get current register pressure for the top scheduled instructions. | |
const RegPressureTracker & | getTopRPTracker () const |
const IntervalPressure & | getBotPressure () const |
Get current register pressure for the bottom scheduled instructions. | |
const RegPressureTracker & | getBotRPTracker () const |
const IntervalPressure & | getRegPressure () const |
Get register pressure for the entire scheduling region before scheduling. | |
const std::vector < PressureChange > & | getRegionCriticalPSets () const |
PressureDiff & | getPressureDiff (const SUnit *SU) |
void | computeDFSResult () |
const SchedDFSResult * | getDFSResult () const |
Return a non-null DFS result if the scheduling strategy initialized it. | |
BitVector & | getScheduledTrees () |
void | enterRegion (MachineBasicBlock *bb, MachineBasicBlock::iterator begin, MachineBasicBlock::iterator end, unsigned regioninstrs) override |
void | schedule () override |
unsigned | computeCyclicCriticalPath () |
Compute the cyclic critical path through the DAG. | |
Protected Member Functions | |
void | buildDAGWithRegPressure () |
Build the DAG and setup three register pressure trackers. | |
void | scheduleMI (SUnit *SU, bool IsTopNode) |
Move an instruction and update register pressure. | |
void | initRegPressure () |
void | updatePressureDiffs (ArrayRef< unsigned > LiveUses) |
void | updateScheduledPressure (const SUnit *SU, const std::vector< unsigned > &NewMaxPressure) |
Protected Attributes | |
RegisterClassInfo * | RegClassInfo |
SchedDFSResult * | DFSResult |
BitVector | ScheduledTrees |
MachineBasicBlock::iterator | LiveRegionEnd |
PressureDiffs | SUPressureDiffs |
bool | ShouldTrackPressure |
Register pressure in this region computed by initRegPressure. | |
IntervalPressure | RegPressure |
RegPressureTracker | RPTracker |
std::vector< PressureChange > | RegionCriticalPSets |
IntervalPressure | TopPressure |
The top of the unscheduled zone. | |
RegPressureTracker | TopRPTracker |
IntervalPressure | BotPressure |
The bottom of the unscheduled zone. | |
RegPressureTracker | BotRPTracker |
ScheduleDAGMILive is an implementation of ScheduleDAGInstrs that schedules machine instructions while updating LiveIntervals and tracking regpressure.
Definition at line 347 of file MachineScheduler.h.
llvm::ScheduleDAGMILive::ScheduleDAGMILive | ( | MachineSchedContext * | C, |
std::unique_ptr< MachineSchedStrategy > | S | ||
) | [inline] |
Definition at line 382 of file MachineScheduler.h.
ScheduleDAGMILive::~ScheduleDAGMILive | ( | ) | [virtual] |
Definition at line 829 of file MachineScheduler.cpp.
References DFSResult.
void ScheduleDAGMILive::buildDAGWithRegPressure | ( | ) | [protected] |
Build the DAG and setup three register pressure trackers.
Call ScheduleDAGInstrs::buildSchedGraph with register pressure tracking enabled. This sets up three trackers. RPTracker will cover the entire DAG region, TopTracker and BottomTracker will be initialized to the top and bottom of the DAG region without covereing any unscheduled instruction.
Definition at line 1055 of file MachineScheduler.cpp.
References llvm::ScheduleDAGInstrs::BB, llvm::ScheduleDAGInstrs::buildSchedGraph(), llvm::RegPressureTracker::init(), initRegPressure(), LiveRegionEnd, llvm::RegPressureTracker::recede(), RegClassInfo, RegionCriticalPSets, llvm::ScheduleDAGInstrs::RegionEnd, llvm::RegPressureTracker::reset(), RPTracker, ShouldTrackPressure, and SUPressureDiffs.
Referenced by llvm::VLIWMachineScheduler::schedule(), and schedule().
Compute the cyclic critical path through the DAG.
Compute the max cyclic critical path through the DAG. The scheduling DAG only provides the critical path for single block loops. To handle loops that span blocks, we could use the vreg path latencies provided by MachineTraceMetrics instead. However, MachineTraceMetrics is not currently available for use in the scheduler.
The cyclic path estimation identifies a def-use pair that crosses the back edge and considers the depth and height of the nodes. For example, consider the following instruction sequence where each instruction has unit latency and defines an epomymous virtual register:
a->b(a,c)->c(b)->d(c)->exit
The cyclic critical path is a two cycles: b->c->b The acyclic critical path is four cycles: a->b->c->d->exit LiveOutHeight = height(c) = len(c->d->exit) = 2 LiveOutDepth = depth(c) + 1 = len(a->b->c) + 1 = 3 LiveInHeight = height(b) + 1 = len(b->c->d->exit) + 1 = 4 LiveInDepth = depth(b) = len(a->b) = 1
LiveOutDepth - LiveInDepth = 3 - 1 = 2 LiveInHeight - LiveOutHeight = 4 - 2 = 2 CyclicCriticalPath = min(2, 2) = 2
This could be relevant to PostRA scheduling, but is currently implemented assuming LiveIntervals.
Definition at line 1114 of file MachineScheduler.cpp.
References llvm::ScheduleDAGInstrs::BB, llvm::ArrayRef< T >::begin(), llvm::dbgs(), DEBUG, llvm::VNInfo::def, llvm::ArrayRef< T >::end(), llvm::SparseMultiSet< ValueT, KeyFunctorT, SparseT >::end(), llvm::ScheduleDAG::ExitSU, llvm::SparseMultiSet< ValueT, KeyFunctorT, SparseT >::find(), llvm::SUnit::getDepth(), llvm::SUnit::getHeight(), llvm::RegPressureTracker::getPressure(), llvm::ScheduleDAGInstrs::getSUnit(), llvm::LiveRange::getVNInfoBefore(), llvm::VNInfo::isPHIDef(), llvm::MachineBasicBlock::isSuccessor(), llvm::TargetRegisterInfo::isVirtualRegister(), llvm::SUnit::Latency, LI, llvm::RegisterPressure::LiveOutRegs, llvm::SUnit::NodeNum, llvm::LiveRange::Query(), RPTracker, llvm::ScheduleDAG::TRI, llvm::LiveQueryResult::valueIn(), and llvm::ScheduleDAGInstrs::VRegUses.
void ScheduleDAGMILive::computeDFSResult | ( | ) |
Compute a DFSResult after DAG building is complete, and before any queue comparisons.
Definition at line 1078 of file MachineScheduler.cpp.
References llvm::SchedDFSResult::clear(), llvm::BitVector::clear(), llvm::SchedDFSResult::compute(), DFSResult, llvm::SchedDFSResult::getNumSubtrees(), MinSubtreeSize, llvm::SchedDFSResult::resize(), llvm::BitVector::resize(), ScheduledTrees, and llvm::ScheduleDAG::SUnits.
void ScheduleDAGMILive::enterRegion | ( | MachineBasicBlock * | bb, |
MachineBasicBlock::iterator | begin, | ||
MachineBasicBlock::iterator | end, | ||
unsigned | regioninstrs | ||
) | [override, virtual] |
Implement the ScheduleDAGInstrs interface for handling the next scheduling region. This covers all instructions in a block, while schedule() may only cover a subset.
enterRegion - Called back from MachineScheduler::runOnMachineFunction after crossing a scheduling boundary. [begin, end) includes all instructions in the region, including the boundary itself and single-instruction regions that don't get scheduled.
Reimplemented from llvm::ScheduleDAGMI.
Definition at line 837 of file MachineScheduler.cpp.
References llvm::PressureDiffs::clear(), llvm::MachineBasicBlock::end(), LiveRegionEnd, llvm::ScheduleDAGInstrs::RegionEnd, llvm::ScheduleDAGMI::SchedImpl, ShouldTrackPressure, and SUPressureDiffs.
const IntervalPressure& llvm::ScheduleDAGMILive::getBotPressure | ( | ) | const [inline] |
Get current register pressure for the bottom scheduled instructions.
Definition at line 402 of file MachineScheduler.h.
References BotPressure.
const RegPressureTracker& llvm::ScheduleDAGMILive::getBotRPTracker | ( | ) | const [inline] |
Definition at line 403 of file MachineScheduler.h.
References BotRPTracker.
Referenced by llvm::ConvergingVLIWScheduler::pickNode(), and llvm::ConvergingVLIWScheduler::pickNodeBidrectional().
const SchedDFSResult* llvm::ScheduleDAGMILive::getDFSResult | ( | ) | const [inline] |
Return a non-null DFS result if the scheduling strategy initialized it.
Definition at line 421 of file MachineScheduler.h.
References DFSResult.
PressureDiff& llvm::ScheduleDAGMILive::getPressureDiff | ( | const SUnit * | SU | ) | [inline] |
Definition at line 412 of file MachineScheduler.h.
References llvm::SUnit::NodeNum, and SUPressureDiffs.
Referenced by updatePressureDiffs(), and updateScheduledPressure().
const std::vector<PressureChange>& llvm::ScheduleDAGMILive::getRegionCriticalPSets | ( | ) | const [inline] |
Definition at line 408 of file MachineScheduler.h.
References RegionCriticalPSets.
Referenced by llvm::ConvergingVLIWScheduler::pickNodeFromQueue().
const IntervalPressure& llvm::ScheduleDAGMILive::getRegPressure | ( | ) | const [inline] |
Get register pressure for the entire scheduling region before scheduling.
Definition at line 406 of file MachineScheduler.h.
References RegPressure.
Referenced by llvm::ConvergingVLIWScheduler::pickNodeFromQueue().
BitVector& llvm::ScheduleDAGMILive::getScheduledTrees | ( | ) | [inline] |
Definition at line 423 of file MachineScheduler.h.
References ScheduledTrees.
const IntervalPressure& llvm::ScheduleDAGMILive::getTopPressure | ( | ) | const [inline] |
Get current register pressure for the top scheduled instructions.
Definition at line 398 of file MachineScheduler.h.
References TopPressure.
const RegPressureTracker& llvm::ScheduleDAGMILive::getTopRPTracker | ( | ) | const [inline] |
Definition at line 399 of file MachineScheduler.h.
References TopRPTracker.
Referenced by llvm::ConvergingVLIWScheduler::pickNode(), and llvm::ConvergingVLIWScheduler::pickNodeBidrectional().
bool llvm::ScheduleDAGMILive::hasVRegLiveness | ( | ) | const [inline, override, virtual] |
Return true if this DAG supports VReg liveness and RegPressure.
Reimplemented from llvm::ScheduleDAGMI.
Definition at line 392 of file MachineScheduler.h.
void ScheduleDAGMILive::initRegPressure | ( | ) | [protected] |
Definition at line 855 of file MachineScheduler.cpp.
References llvm::RegPressureTracker::addLiveRegs(), llvm::ScheduleDAGInstrs::BB, BotRPTracker, llvm::RegPressureTracker::closeBottom(), llvm::RegPressureTracker::closeRegion(), llvm::RegPressureTracker::closeTop(), llvm::dbgs(), DEBUG, llvm::RegPressureTracker::dump(), llvm::dumpRegSetPressure(), llvm::ArrayRef< T >::empty(), llvm::RegPressureTracker::getLiveThru(), llvm::RegPressureTracker::getPos(), llvm::RegPressureTracker::getPressure(), llvm::RegisterClassInfo::getRegPressureSetLimit(), llvm::TargetRegisterInfo::getRegPressureSetName(), llvm::RegPressureTracker::init(), llvm::RegPressureTracker::initLiveThru(), llvm::RegisterPressure::LiveInRegs, llvm::RegisterPressure::LiveOutRegs, LiveRegionEnd, llvm::RegisterPressure::MaxSetPressure, llvm::RegPressureTracker::recede(), RegClassInfo, llvm::ScheduleDAGInstrs::RegionBegin, RegionCriticalPSets, llvm::ScheduleDAGInstrs::RegionEnd, RPTracker, TopRPTracker, llvm::ScheduleDAG::TRI, and updatePressureDiffs().
Referenced by buildDAGWithRegPressure().
bool llvm::ScheduleDAGMILive::isTrackingPressure | ( | ) | const [inline] |
Return true if register pressure tracking is enabled.
Definition at line 395 of file MachineScheduler.h.
References ShouldTrackPressure.
void ScheduleDAGMILive::schedule | ( | ) | [override, virtual] |
Implement ScheduleDAGInstrs interface for scheduling a sequence of reorderable instructions.
schedule - Called back from MachineScheduler::runOnMachineFunction after setting up the current scheduling region. [RegionBegin, RegionEnd) only includes instructions that have DAG nodes, not scheduling boundaries.
This is a skeletal driver, with all the functionality pushed into helpers, so that it can be easilly extended by experimental schedulers. Generally, implementing MachineSchedStrategy should be sufficient to implement a new scheduling algorithm. However, if a scheduler further subclasses ScheduleDAGMILive then it will want to override this virtual method in order to update any specialized state.
Reimplemented from llvm::ScheduleDAGMI.
Reimplemented in llvm::VLIWMachineScheduler.
Definition at line 994 of file MachineScheduler.cpp.
References llvm::ScheduleDAGInstrs::begin(), buildDAGWithRegPressure(), llvm::ScheduleDAGMI::checkSchedLimit(), llvm::ScheduleDAGMI::CurrentBottom, llvm::ScheduleDAGMI::CurrentTop, llvm::dbgs(), DEBUG, DFSResult, llvm::ScheduleDAGMI::dumpSchedule(), llvm::ScheduleDAGMI::findRootsAndBiasEdges(), llvm::RegPressureTracker::getPos(), llvm::SchedDFSResult::getSubtreeID(), llvm::ScheduleDAGTopologicalSort::InitDAGTopologicalSorting(), llvm::ScheduleDAGMI::initQueues(), llvm::ScheduleDAGMI::placeDebugValues(), llvm::ScheduleDAGMI::postprocessDAG(), llvm::ScheduleDAGInstrs::RegionBegin, llvm::ScheduleDAGMI::SchedImpl, ScheduledTrees, scheduleMI(), llvm::SchedDFSResult::scheduleTree(), llvm::BitVector::set(), llvm::RegPressureTracker::setPos(), ShouldTrackPressure, llvm::ScheduleDAG::SUnits, llvm::BitVector::test(), llvm::ScheduleDAGMI::Topo, TopRPTracker, llvm::ScheduleDAGMI::updateQueues(), llvm::ScheduleDAGMI::viewGraph(), and ViewMISchedDAGs.
void ScheduleDAGMILive::scheduleMI | ( | SUnit * | SU, |
bool | IsTopNode | ||
) | [protected] |
Move an instruction and update register pressure.
Definition at line 1177 of file MachineScheduler.cpp.
References llvm::RegPressureTracker::advance(), BotRPTracker, llvm::ScheduleDAGMI::CurrentBottom, llvm::ScheduleDAGMI::CurrentTop, llvm::SUnit::getInstr(), llvm::RegPressureTracker::getPos(), llvm::RegPressureTracker::getPressure(), llvm::SUnit::isBottomReady(), llvm::SUnit::isTopReady(), llvm::RegisterPressure::MaxSetPressure, llvm::AArch64CC::MI, llvm::ScheduleDAGMI::moveInstruction(), nextIfDebug(), priorNonDebug(), llvm::RegPressureTracker::recede(), llvm::RegPressureTracker::setPos(), ShouldTrackPressure, TopRPTracker, updatePressureDiffs(), and updateScheduledPressure().
Referenced by llvm::VLIWMachineScheduler::schedule(), and schedule().
void ScheduleDAGMILive::updatePressureDiffs | ( | ArrayRef< unsigned > | LiveUses | ) | [protected] |
Update the PressureDiff array for liveness after scheduling this instruction.
FIXME: Currently assuming single-use physregs.
Definition at line 943 of file MachineScheduler.cpp.
References llvm::PressureDiff::addPressureChange(), llvm::ScheduleDAGInstrs::BB, BotRPTracker, llvm::dbgs(), DEBUG, llvm::MachineBasicBlock::end(), llvm::SparseMultiSet< ValueT, KeyFunctorT, SparseT >::end(), llvm::ScheduleDAG::ExitSU, llvm::SparseMultiSet< ValueT, KeyFunctorT, SparseT >::find(), llvm::SUnit::getInstr(), llvm::RegPressureTracker::getPos(), getPressureDiff(), llvm::LiveRange::getVNInfoBefore(), llvm::SUnit::isScheduled, llvm::TargetRegisterInfo::isVirtualRegister(), LI, llvm::ScheduleDAG::MRI, nextIfDebug(), llvm::SUnit::NodeNum, llvm::LiveRange::Query(), llvm::ArrayRef< T >::size(), llvm::ScheduleDAG::TRI, llvm::LiveQueryResult::valueIn(), and llvm::ScheduleDAGInstrs::VRegUses.
Referenced by initRegPressure(), and scheduleMI().
void ScheduleDAGMILive::updateScheduledPressure | ( | const SUnit * | SU, |
const std::vector< unsigned > & | NewMaxPressure | ||
) | [protected] |
Definition at line 916 of file MachineScheduler.cpp.
References llvm::PressureDiff::begin(), BotRPTracker, llvm::dbgs(), DEBUG, llvm::PressureDiff::end(), llvm::RegPressureTracker::getLiveThru(), getPressureDiff(), llvm::RegisterClassInfo::getRegPressureSetLimit(), llvm::TargetRegisterInfo::getRegPressureSetName(), I, RegClassInfo, RegionCriticalPSets, and llvm::ScheduleDAG::TRI.
Referenced by scheduleMI().
IntervalPressure llvm::ScheduleDAGMILive::BotPressure [protected] |
The bottom of the unscheduled zone.
Definition at line 378 of file MachineScheduler.h.
Referenced by getBotPressure().
Definition at line 379 of file MachineScheduler.h.
Referenced by getBotRPTracker(), initRegPressure(), scheduleMI(), updatePressureDiffs(), and updateScheduledPressure().
SchedDFSResult* llvm::ScheduleDAGMILive::DFSResult [protected] |
Information about DAG subtrees. If DFSResult is NULL, then SchedulerTrees will be empty.
Definition at line 353 of file MachineScheduler.h.
Referenced by computeDFSResult(), getDFSResult(), schedule(), and ~ScheduleDAGMILive().
Definition at line 356 of file MachineScheduler.h.
Referenced by buildDAGWithRegPressure(), enterRegion(), and initRegPressure().
RegisterClassInfo* llvm::ScheduleDAGMILive::RegClassInfo [protected] |
Definition at line 349 of file MachineScheduler.h.
Referenced by buildDAGWithRegPressure(), initRegPressure(), and updateScheduledPressure().
std::vector<PressureChange> llvm::ScheduleDAGMILive::RegionCriticalPSets [protected] |
List of pressure sets that exceed the target's pressure limit before scheduling, listed in increasing set ID order. Each pressure set is paired with its max pressure in the currently scheduled regions.
Definition at line 371 of file MachineScheduler.h.
Referenced by buildDAGWithRegPressure(), getRegionCriticalPSets(), initRegPressure(), and updateScheduledPressure().
IntervalPressure llvm::ScheduleDAGMILive::RegPressure [protected] |
Definition at line 365 of file MachineScheduler.h.
Referenced by getRegPressure().
RegPressureTracker llvm::ScheduleDAGMILive::RPTracker [protected] |
Definition at line 366 of file MachineScheduler.h.
Referenced by buildDAGWithRegPressure(), computeCyclicCriticalPath(), and initRegPressure().
BitVector llvm::ScheduleDAGMILive::ScheduledTrees [protected] |
Definition at line 354 of file MachineScheduler.h.
Referenced by computeDFSResult(), getScheduledTrees(), and schedule().
bool llvm::ScheduleDAGMILive::ShouldTrackPressure [protected] |
Register pressure in this region computed by initRegPressure.
Definition at line 364 of file MachineScheduler.h.
Referenced by buildDAGWithRegPressure(), enterRegion(), isTrackingPressure(), schedule(), and scheduleMI().
Definition at line 361 of file MachineScheduler.h.
Referenced by buildDAGWithRegPressure(), enterRegion(), and getPressureDiff().
IntervalPressure llvm::ScheduleDAGMILive::TopPressure [protected] |
The top of the unscheduled zone.
Definition at line 374 of file MachineScheduler.h.
Referenced by getTopPressure().
Definition at line 375 of file MachineScheduler.h.
Referenced by getTopRPTracker(), initRegPressure(), schedule(), and scheduleMI().