LLVM 20.0.0git
|
A ScheduleDAG for scheduling lists of MachineInstr. More...
#include "llvm/CodeGen/ScheduleDAGInstrs.h"
Classes | |
class | Value2SUsMap |
Public Types | |
enum | DumpDirection { TopDown , BottomUp , Bidirectional , NotSet } |
The direction that should be used to dump the scheduled Sequence. More... | |
using | SUList = std::list< SUnit * > |
A list of SUnits, used in Value2SUsMap, during DAG construction. | |
Public Member Functions | |
void | setDumpDirection (DumpDirection D) |
ScheduleDAGInstrs (MachineFunction &mf, const MachineLoopInfo *mli, bool RemoveKillFlags=false) | |
~ScheduleDAGInstrs () override=default | |
const TargetSchedModel * | getSchedModel () const |
Gets the machine model for instruction scheduling. | |
const MCSchedClassDesc * | getSchedClass (SUnit *SU) const |
Resolves and cache a resolved scheduling class for an SUnit. | |
bool | IsReachable (SUnit *SU, SUnit *TargetSU) |
IsReachable - Checks if SU is reachable from TargetSU. | |
MachineBasicBlock::iterator | begin () const |
Returns an iterator to the top of the current scheduling region. | |
MachineBasicBlock::iterator | end () const |
Returns an iterator to the bottom of the current scheduling region. | |
SUnit * | newSUnit (MachineInstr *MI) |
Creates a new SUnit and return a ptr to it. | |
SUnit * | getSUnit (MachineInstr *MI) const |
Returns an existing SUnit for this MI, or nullptr. | |
virtual bool | doMBBSchedRegionsTopDown () const |
If this method returns true, handling of the scheduling regions themselves (in case of a scheduling boundary in MBB) will be done beginning with the topmost region of MBB. | |
virtual void | startBlock (MachineBasicBlock *BB) |
Prepares to perform scheduling in the given block. | |
virtual void | finishBlock () |
Cleans up after scheduling in the given block. | |
virtual void | enterRegion (MachineBasicBlock *bb, MachineBasicBlock::iterator begin, MachineBasicBlock::iterator end, unsigned regioninstrs) |
Initialize the DAG and common scheduler state for a new scheduling region. | |
virtual void | exitRegion () |
Called when the scheduler has finished scheduling the current region. | |
void | buildSchedGraph (AAResults *AA, RegPressureTracker *RPTracker=nullptr, PressureDiffs *PDiffs=nullptr, LiveIntervals *LIS=nullptr, bool TrackLaneMasks=false) |
Builds SUnits for the current region. | |
void | addSchedBarrierDeps () |
Adds dependencies from instructions in the current list of instructions being scheduled to scheduling barrier. | |
virtual void | schedule ()=0 |
Orders nodes according to selected style. | |
virtual void | finalizeSchedule () |
Allow targets to perform final scheduling actions at the level of the whole MachineFunction. | |
void | dumpNode (const SUnit &SU) const override |
void | dump () const override |
std::string | getGraphNodeLabel (const SUnit *SU) const override |
Returns a label for a DAG node that points to an instruction. | |
std::string | getDAGName () const override |
Returns a label for the region of code covered by the DAG. | |
void | fixupKills (MachineBasicBlock &MBB) |
Fixes register kill flags that scheduling has made invalid. | |
bool | canAddEdge (SUnit *SuccSU, SUnit *PredSU) |
True if an edge can be added from PredSU to SuccSU without creating a cycle. | |
bool | addEdge (SUnit *SuccSU, const SDep &PredDep) |
Add a DAG edge to the given SU with the given predecessor dependence data. | |
Public Member Functions inherited from llvm::ScheduleDAG | |
ScheduleDAG (const ScheduleDAG &)=delete | |
ScheduleDAG & | operator= (const ScheduleDAG &)=delete |
ScheduleDAG (MachineFunction &mf) | |
virtual | ~ScheduleDAG () |
void | clearDAG () |
Clears the DAG state (between regions). | |
const MCInstrDesc * | getInstrDesc (const SUnit *SU) const |
Returns the MCInstrDesc of this SUnit. | |
virtual void | viewGraph (const Twine &Name, const Twine &Title) |
Pops up a GraphViz/gv window with the ScheduleDAG rendered using 'dot'. | |
virtual void | viewGraph () |
Out-of-line implementation with no arguments is handy for gdb. | |
virtual void | dumpNode (const SUnit &SU) const =0 |
virtual void | dump () const =0 |
void | dumpNodeName (const SUnit &SU) const |
virtual std::string | getGraphNodeLabel (const SUnit *SU) const =0 |
Returns a label for an SUnit node in a visualization of the ScheduleDAG. | |
virtual std::string | getDAGName () const =0 |
Returns a label for the region of code covered by the DAG. | |
virtual void | addCustomGraphFeatures (GraphWriter< ScheduleDAG * > &) const |
Adds custom features for a visualization of the ScheduleDAG. | |
unsigned | VerifyScheduledDAG (bool isBottomUp) |
Verifies that all SUnits were scheduled and that their state is consistent. | |
Protected Types | |
using | DbgValueVector = std::vector< std::pair< MachineInstr *, MachineInstr * > > |
Protected Member Functions | |
void | reduceHugeMemNodeMaps (Value2SUsMap &stores, Value2SUsMap &loads, unsigned N) |
Reduces maps in FIFO order, by N SUs. | |
void | addChainDependency (SUnit *SUa, SUnit *SUb, unsigned Latency=0) |
Adds a chain edge between SUa and SUb, but only if both AAResults and Target fail to deny the dependency. | |
void | addChainDependencies (SUnit *SU, SUList &SUs, unsigned Latency) |
Adds dependencies as needed from all SUs in list to SU. | |
void | addChainDependencies (SUnit *SU, Value2SUsMap &Val2SUsMap) |
Adds dependencies as needed from all SUs in map, to SU. | |
void | addChainDependencies (SUnit *SU, Value2SUsMap &Val2SUsMap, ValueType V) |
Adds dependencies as needed to SU, from all SUs mapped to V. | |
void | addBarrierChain (Value2SUsMap &map) |
Adds barrier chain edges from all SUs in map, and then clear the map. | |
void | insertBarrierChain (Value2SUsMap &map) |
Inserts a barrier chain in a huge region, far below current SU. | |
void | initSUnits () |
Creates an SUnit for each real instruction, numbered in top-down topological order. | |
void | addPhysRegDataDeps (SUnit *SU, unsigned OperIdx) |
MO is an operand of SU's instruction that defines a physical register. | |
void | addPhysRegDeps (SUnit *SU, unsigned OperIdx) |
Adds register dependencies (data, anti, and output) from this SUnit to following instructions in the same scheduling region that depend the physical register referenced at OperIdx. | |
void | addVRegDefDeps (SUnit *SU, unsigned OperIdx) |
Adds register output and data dependencies from this SUnit to instructions that occur later in the same scheduling region if they read from or write to the virtual register defined at OperIdx. | |
void | addVRegUseDeps (SUnit *SU, unsigned OperIdx) |
Adds a register data dependency if the instruction that defines the virtual register used at OperIdx is mapped to an SUnit. | |
LaneBitmask | getLaneMaskForMO (const MachineOperand &MO) const |
Returns a mask for which lanes get read/written by the given (register) machine operand. | |
bool | deadDefHasNoUse (const MachineOperand &MO) |
Returns true if the def register in MO has no uses. | |
Protected Member Functions inherited from llvm::ScheduleDAG | |
void | dumpNodeAll (const SUnit &SU) const |
Protected Attributes | |
const MachineLoopInfo * | MLI = nullptr |
const MachineFrameInfo & | MFI |
TargetSchedModel | SchedModel |
TargetSchedModel provides an interface to the machine model. | |
bool | RemoveKillFlags |
True if the DAG builder should remove kill flags (in preparation for rescheduling). | |
bool | CanHandleTerminators = false |
The standard DAG builder does not normally include terminators as DAG nodes because it does not create the necessary dependencies to prevent reordering. | |
bool | TrackLaneMasks = false |
Whether lane masks should get tracked. | |
MachineBasicBlock * | BB = nullptr |
The block in which to insert instructions. | |
MachineBasicBlock::iterator | RegionBegin |
The beginning of the range to be scheduled. | |
MachineBasicBlock::iterator | RegionEnd |
The end of the range to be scheduled. | |
unsigned | NumRegionInstrs = 0 |
Instructions in this region (distance(RegionBegin, RegionEnd)). | |
DenseMap< MachineInstr *, SUnit * > | MISUnitMap |
After calling BuildSchedGraph, each machine instruction in the current scheduling region is mapped to an SUnit. | |
RegUnit2SUnitsMap | Defs |
Defs, Uses - Remember where defs and uses of each register are as we iterate upward through the instructions. | |
RegUnit2SUnitsMap | Uses |
VReg2SUnitMultiMap | CurrentVRegDefs |
Tracks the last instruction(s) in this region defining each virtual register. | |
VReg2SUnitOperIdxMultiMap | CurrentVRegUses |
Tracks the last instructions in this region using each virtual register. | |
AAResults * | AAForDep = nullptr |
SUnit * | BarrierChain = nullptr |
Remember a generic side-effecting instruction as we proceed. | |
DumpDirection | DumpDir = NotSet |
UndefValue * | UnknownValue |
For an unanalyzable memory access, this Value is used in maps. | |
ScheduleDAGTopologicalSort | Topo |
Topo - A topological ordering for SUnits which permits fast IsReachable and similar queries. | |
DbgValueVector | DbgValues |
Remember instruction that precedes DBG_VALUE. | |
MachineInstr * | FirstDbgValue = nullptr |
LiveRegUnits | LiveRegs |
Set of live physical registers for updating kill flags. | |
Additional Inherited Members | |
Public Attributes inherited from llvm::ScheduleDAG | |
const LLVMTargetMachine & | TM |
Target processor. | |
const TargetInstrInfo * | TII |
Target instruction information. | |
const TargetRegisterInfo * | TRI |
Target processor register info. | |
MachineFunction & | MF |
Machine function. | |
MachineRegisterInfo & | MRI |
Virtual/real register map. | |
std::vector< SUnit > | SUnits |
The scheduling units. | |
SUnit | EntrySU |
Special node for the region entry. | |
SUnit | ExitSU |
Special node for the region exit. | |
bool | StressSched |
A ScheduleDAG for scheduling lists of MachineInstr.
Definition at line 114 of file ScheduleDAGInstrs.h.
|
protected |
Definition at line 250 of file ScheduleDAGInstrs.h.
using llvm::ScheduleDAGInstrs::SUList = std::list<SUnit *> |
A list of SUnits, used in Value2SUsMap, during DAG construction.
Note: to gain speed it might be worth investigating an optimized implementation of this data structure, such as a singly linked list with a memory pool (SmallVector was tried but slow and SparseSet is not applicable).
Definition at line 185 of file ScheduleDAGInstrs.h.
The direction that should be used to dump the scheduled Sequence.
Enumerator | |
---|---|
TopDown | |
BottomUp | |
Bidirectional | |
NotSet |
Definition at line 188 of file ScheduleDAGInstrs.h.
|
explicit |
Definition at line 113 of file ScheduleDAGInstrs.cpp.
References DbgValues, llvm::MachineFunction::getSubtarget(), llvm::TargetSchedModel::init(), and SchedModel.
|
overridedefault |
|
protected |
Adds barrier chain edges from all SUs in map, and then clear the map.
This is equivalent to insertBarrierChain(), but optimized for the common case where the new BarrierChain (a global memory object) has a higher NodeNum than all SUs in map. It is assumed BarrierChain has been set before calling this.
Definition at line 695 of file ScheduleDAGInstrs.cpp.
References assert(), BarrierChain, and llvm::ScheduleDAGInstrs::Value2SUsMap::clear().
Referenced by buildSchedGraph().
|
inlineprotected |
Adds dependencies as needed from all SUs in list to SU.
Definition at line 217 of file ScheduleDAGInstrs.h.
References addChainDependency(), and llvm::Latency.
Referenced by addChainDependencies(), and buildSchedGraph().
|
protected |
Adds dependencies as needed from all SUs in map, to SU.
Definition at line 679 of file ScheduleDAGInstrs.cpp.
References addChainDependencies(), llvm::ScheduleDAGInstrs::Value2SUsMap::getTrueMemOrderLatency(), and I.
|
protected |
Adds dependencies as needed to SU, from all SUs mapped to V.
Definition at line 686 of file ScheduleDAGInstrs.cpp.
References addChainDependencies(), llvm::MapVector< KeyT, ValueT, MapType, VectorType >::end(), llvm::MapVector< KeyT, ValueT, MapType, VectorType >::find(), and llvm::ScheduleDAGInstrs::Value2SUsMap::getTrueMemOrderLatency().
|
protected |
Adds a chain edge between SUa and SUb, but only if both AAResults and Target fail to deny the dependency.
Definition at line 557 of file ScheduleDAGInstrs.cpp.
References AAForDep, llvm::SUnit::addPred(), llvm::SUnit::getInstr(), llvm::Latency, llvm::MachineInstr::mayAlias(), llvm::SDep::MayAliasMem, llvm::SDep::setLatency(), and UseTBAA.
Referenced by addChainDependencies().
Add a DAG edge to the given SU with the given predecessor dependence data.
Definition at line 1222 of file ScheduleDAGInstrs.cpp.
References llvm::SUnit::addPred(), llvm::ScheduleDAGTopologicalSort::AddPredQueued(), llvm::ScheduleDAG::ExitSU, llvm::SDep::getSUnit(), llvm::SDep::isArtificial(), llvm::ScheduleDAGTopologicalSort::IsReachable(), and Topo.
Referenced by llvm::HexagonSubtarget::CallMutation::apply(), and llvm::fuseInstructionPair().
MO is an operand of SU's instruction that defines a physical register.
Adds data dependencies from SU to any uses of the physical register.
Definition at line 238 of file ScheduleDAGInstrs.cpp.
References llvm::SUnit::addPred(), llvm::SDep::Artificial, assert(), llvm::TargetSchedModel::computeOperandLatency(), llvm::SDep::Data, llvm::SparseMultiSet< ValueT, KeyFunctorT, SparseT >::end(), llvm::SparseMultiSet< ValueT, KeyFunctorT, SparseT >::find(), llvm::MachineInstr::getDesc(), llvm::SUnit::getInstr(), llvm::MCInstrDesc::getNumOperands(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), llvm::MachineFunction::getSubtarget(), llvm::MCInstrDesc::hasImplicitDefOfPhysReg(), llvm::MCInstrDesc::hasImplicitUseOfPhysReg(), llvm::SUnit::hasPhysRegDefs, I, llvm::MachineOperand::isDef(), llvm::ScheduleDAG::MF, llvm::MCRegisterInfo::regunits(), SchedModel, llvm::SDep::setLatency(), llvm::ScheduleDAG::TRI, UseReg(), and Uses.
Referenced by addPhysRegDeps().
Adds register dependencies (data, anti, and output) from this SUnit to following instructions in the same scheduling region that depend the physical register referenced at OperIdx.
Definition at line 294 of file ScheduleDAGInstrs.cpp.
References addPhysRegDataDeps(), llvm::SUnit::addPred(), llvm::SDep::Anti, B, llvm::TargetSchedModel::computeOutputLatency(), Defs, llvm::SparseMultiSet< ValueT, KeyFunctorT, SparseT >::end(), llvm::SparseMultiSet< ValueT, KeyFunctorT, SparseT >::equal_range(), llvm::SparseMultiSet< ValueT, KeyFunctorT, SparseT >::erase(), llvm::SparseMultiSet< ValueT, KeyFunctorT, SparseT >::eraseAll(), llvm::ScheduleDAG::ExitSU, llvm::SparseMultiSet< ValueT, KeyFunctorT, SparseT >::find(), llvm::SUnit::getInstr(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), llvm::MachineFunction::getSubtarget(), llvm::SUnit::hasPhysRegUses, I, llvm::SparseMultiSet< ValueT, KeyFunctorT, SparseT >::insert(), llvm::SUnit::isCall, llvm::MachineRegisterInfo::isConstantPhysReg(), llvm::MachineOperand::isDead(), llvm::MachineOperand::isUse(), llvm::ScheduleDAG::MF, MI, llvm::ScheduleDAG::MRI, llvm::SDep::Output, P, llvm::MCRegisterInfo::regunits(), RemoveKillFlags, SchedModel, llvm::MachineOperand::setIsKill(), llvm::SDep::setLatency(), llvm::ScheduleDAG::TRI, and Uses.
Referenced by buildSchedGraph().
void ScheduleDAGInstrs::addSchedBarrierDeps | ( | ) |
Adds dependencies from instructions in the current list of instructions being scheduled to scheduling barrier.
We want to make sure instructions which define registers that are either used by the terminator or are live-out are properly scheduled. This is especially important when the definition latency of the return value(s) are too high to be hidden by the branch or when the liveout registers used by instructions in the fallthrough block.
Definition at line 203 of file ScheduleDAGInstrs.cpp.
References addVRegUseDeps(), llvm::MachineInstr::all_uses(), BB, llvm::SparseMultiSet< ValueT, KeyFunctorT, SparseT >::contains(), llvm::MachineBasicBlock::end(), llvm::ScheduleDAG::ExitSU, llvm::SparseMultiSet< ValueT, KeyFunctorT, SparseT >::insert(), llvm::MachineInstr::isBarrier(), llvm::MachineInstr::isCall(), RegionBegin, RegionEnd, llvm::MCRegisterInfo::regunits(), llvm::SUnit::setInstr(), llvm::skipDebugInstructionsBackward(), llvm::MachineBasicBlock::successors(), llvm::ScheduleDAG::TRI, and Uses.
Referenced by buildSchedGraph().
Adds register output and data dependencies from this SUnit to instructions that occur later in the same scheduling region if they read from or write to the virtual register defined at OperIdx.
TODO: Hoist loop induction variable increments. This has to be reevaluated. Generally, IV scheduling should be done before coalescing.
Definition at line 404 of file ScheduleDAGInstrs.cpp.
References llvm::SUnit::addPred(), llvm::LaneBitmask::any(), assert(), llvm::TargetSchedModel::computeOperandLatency(), llvm::TargetSchedModel::computeOutputLatency(), CurrentVRegDefs, CurrentVRegUses, llvm::SDep::Data, deadDefHasNoUse(), llvm::drop_begin(), llvm::SparseMultiSet< ValueT, KeyFunctorT, SparseT >::end(), llvm::SparseMultiSet< ValueT, KeyFunctorT, SparseT >::erase(), llvm::SparseMultiSet< ValueT, KeyFunctorT, SparseT >::find(), llvm::LaneBitmask::getAll(), llvm::SUnit::getInstr(), getLaneMaskForMO(), llvm::MachineOperand::getReg(), llvm::MachineOperand::getSubReg(), llvm::MachineFunction::getSubtarget(), llvm::MachineRegisterInfo::hasOneDef(), I, llvm::SparseMultiSet< ValueT, KeyFunctorT, SparseT >::insert(), llvm::MachineOperand::isDead(), llvm::MachineOperand::isUndef(), llvm::make_range(), llvm::ScheduleDAG::MF, MI, llvm::ScheduleDAG::MRI, none, llvm::SDep::Output, SchedModel, llvm::MachineOperand::setIsUndef(), llvm::SDep::setLatency(), and TrackLaneMasks.
Referenced by buildSchedGraph().
Adds a register data dependency if the instruction that defines the virtual register used at OperIdx is mapped to an SUnit.
Add a register antidependency from this SUnit to instructions that occur later in the same scheduling region if they write the virtual register.
TODO: Handle ExitSU "uses" properly.
Definition at line 524 of file ScheduleDAGInstrs.cpp.
References llvm::SDep::Anti, assert(), CurrentVRegDefs, CurrentVRegUses, llvm::SparseMultiSet< ValueT, KeyFunctorT, SparseT >::end(), llvm::SparseMultiSet< ValueT, KeyFunctorT, SparseT >::find(), llvm::LaneBitmask::getAll(), llvm::SUnit::getInstr(), getLaneMaskForMO(), llvm::MachineOperand::getReg(), llvm::SparseMultiSet< ValueT, KeyFunctorT, SparseT >::insert(), llvm::make_range(), MI, none, and TrackLaneMasks.
Referenced by addSchedBarrierDeps(), and buildSchedGraph().
|
inline |
Returns an iterator to the top of the current scheduling region.
Definition at line 284 of file ScheduleDAGInstrs.h.
References RegionBegin.
Referenced by enterRegion(), llvm::ScheduleDAGMI::enterRegion(), llvm::ScheduleDAGMILive::enterRegion(), llvm::GCNSchedStage::initGCNRegion(), llvm::ScheduleDAGMI::schedule(), llvm::ScheduleDAGMILive::schedule(), llvm::VLIWMachineScheduler::schedule(), and llvm::SIScheduleDAGMI::schedule().
void ScheduleDAGInstrs::buildSchedGraph | ( | AAResults * | AA, |
RegPressureTracker * | RPTracker = nullptr , |
||
PressureDiffs * | PDiffs = nullptr , |
||
LiveIntervals * | LIS = nullptr , |
||
bool | TrackLaneMasks = false |
||
) |
Builds SUnits for the current region.
If RPTracker
is non-null, compute register pressure as a side effect. The DAG builder is an efficient place to do it because it already visits operands.
Definition at line 739 of file ScheduleDAGInstrs.cpp.
References AAForDep, addBarrierChain(), addChainDependencies(), llvm::PressureDiffs::addInstruction(), addPhysRegDeps(), llvm::SUnit::addPred(), llvm::SUnit::addPredBarrier(), addSchedBarrierDeps(), addVRegDefDeps(), addVRegUseDeps(), llvm::RegisterOperands::adjustLaneLiveness(), llvm::SDep::Artificial, assert(), BarrierChain, CanHandleTerminators, llvm::SparseMultiSet< ValueT, KeyFunctorT, SparseT >::clear(), llvm::ScheduleDAG::clearDAG(), llvm::RegisterOperands::collect(), CurrentVRegDefs, CurrentVRegUses, llvm::dbgs(), DbgValues, Defs, llvm::SparseMultiSet< ValueT, KeyFunctorT, SparseT >::empty(), EnableAASchedMI, llvm::ScheduleDAG::ExitSU, FirstDbgValue, llvm::MachineFunction::getDataLayout(), llvm::LiveIntervals::getInstructionIndex(), llvm::MCRegisterInfo::getNumRegs(), llvm::MachineRegisterInfo::getNumVirtRegs(), llvm::RegPressureTracker::getPos(), getReductionSize(), llvm::MachineOperand::getReg(), llvm::MachineFunction::getSubtarget(), getUnderlyingObjectsForInstr(), HugeRegion, llvm::PressureDiffs::init(), initSUnits(), llvm::ScheduleDAGInstrs::Value2SUsMap::insert(), llvm::MachineOperand::isDef(), isGlobalMemoryObject(), llvm::MachineOperand::isReg(), llvm::MachineOperand::isUse(), llvm::SUnit::Latency, LLVM_DEBUG, llvm::ScheduleDAGTopologicalSort::MarkDirty(), llvm::ScheduleDAG::MF, MFI, MI, MISUnitMap, llvm::ScheduleDAG::MRI, llvm::SUnit::NodeNum, llvm::SUnit::NumSuccs, llvm::MachineOperand::readsReg(), llvm::RegPressureTracker::recede(), llvm::RegPressureTracker::recedeSkipDebugValues(), reduceHugeMemNodeMaps(), RegionBegin, RegionEnd, llvm::SDep::setLatency(), llvm::SparseMultiSet< ValueT, KeyFunctorT, SparseT >::setUniverse(), llvm::ScheduleDAGInstrs::Value2SUsMap::size(), llvm::ScheduleDAG::SUnits, Topo, TrackLaneMasks, llvm::ScheduleDAG::TRI, UnknownValue, UseAA, and Uses.
Referenced by llvm::GCNIterativeScheduler::BuildDAG::BuildDAG(), llvm::ScheduleDAGMILive::buildDAGWithRegPressure(), llvm::DefaultVLIWScheduler::schedule(), llvm::SwingSchedulerDAG::schedule(), and llvm::ScheduleDAGMI::schedule().
True if an edge can be added from PredSU to SuccSU without creating a cycle.
Definition at line 1218 of file ScheduleDAGInstrs.cpp.
References llvm::ScheduleDAG::ExitSU, llvm::ScheduleDAGTopologicalSort::IsReachable(), and Topo.
|
protected |
Returns true if the def register in MO
has no uses.
Definition at line 391 of file ScheduleDAGInstrs.cpp.
References CurrentVRegUses, llvm::SparseMultiSet< ValueT, KeyFunctorT, SparseT >::end(), llvm::SparseMultiSet< ValueT, KeyFunctorT, SparseT >::find(), getLaneMaskForMO(), and llvm::MachineOperand::getReg().
Referenced by addVRegDefDeps().
|
inlinevirtual |
If this method returns true, handling of the scheduling regions themselves (in case of a scheduling boundary in MBB) will be done beginning with the topmost region of MBB.
Reimplemented in llvm::ScheduleDAGMI.
Definition at line 298 of file ScheduleDAGInstrs.h.
|
overridevirtual |
Implements llvm::ScheduleDAG.
Definition at line 1189 of file ScheduleDAGInstrs.cpp.
References llvm::ScheduleDAG::dumpNodeAll(), llvm::ScheduleDAG::EntrySU, llvm::ScheduleDAG::ExitSU, llvm::SUnit::getInstr(), and llvm::ScheduleDAG::SUnits.
Referenced by llvm::VLIWPacketizerList::PacketizeMIs(), llvm::SwingSchedulerDAG::schedule(), and llvm::ScheduleDAGMI::schedule().
Implements llvm::ScheduleDAG.
Definition at line 1178 of file ScheduleDAGInstrs.cpp.
References llvm::SUnit::BotReadyCycle, llvm::dbgs(), llvm::MachineInstr::dump(), llvm::ScheduleDAG::dumpNodeName(), llvm::SUnit::getInstr(), SchedPrintCycles, and llvm::SUnit::TopReadyCycle.
Referenced by llvm::ResourceManager::calculateResMII(), llvm::ScheduleDAGMI::dumpSchedule(), llvm::ConvergingVLIWScheduler::pickNode(), llvm::R600SchedStrategy::pickNode(), llvm::SIScheduleBlock::printDebug(), llvm::R600SchedStrategy::releaseBottomNode(), llvm::ScheduleDAGMI::releasePred(), llvm::ScheduleDAGMI::releaseSucc(), llvm::R600SchedStrategy::releaseTopNode(), llvm::GenericScheduler::reschedulePhysReg(), and llvm::ConvergingVLIWScheduler::traceCandidate().
|
inline |
Returns an iterator to the bottom of the current scheduling region.
Definition at line 287 of file ScheduleDAGInstrs.h.
References RegionEnd.
Referenced by enterRegion(), llvm::ScheduleDAGMI::enterRegion(), llvm::ScheduleDAGMILive::enterRegion(), and llvm::GCNSchedStage::initGCNRegion().
|
virtual |
Initialize the DAG and common scheduler state for a new scheduling region.
This does not actually create the DAG, only clears it. The scheduling driver may call BuildSchedGraph multiple times per scheduling region.
Reimplemented in llvm::ScheduleDAGMI, llvm::ScheduleDAGMILive, and llvm::GCNIterativeScheduler.
Definition at line 189 of file ScheduleDAGInstrs.cpp.
References assert(), BB, begin(), end(), NumRegionInstrs, RegionBegin, and RegionEnd.
Referenced by llvm::ScheduleDAGMI::enterRegion(), and llvm::VLIWPacketizerList::PacketizeMIs().
|
virtual |
Called when the scheduler has finished scheduling the current region.
Definition at line 199 of file ScheduleDAGInstrs.cpp.
Referenced by llvm::GCNSchedStage::finalizeGCNRegion(), and llvm::VLIWPacketizerList::PacketizeMIs().
|
inlinevirtual |
Allow targets to perform final scheduling actions at the level of the whole MachineFunction.
By default does nothing.
Reimplemented in llvm::GCNIterativeScheduler, llvm::GCNScheduleDAGMILive, and llvm::GCNPostScheduleDAGMILive.
Definition at line 345 of file ScheduleDAGInstrs.h.
Referenced by llvm::GCNPostScheduleDAGMILive::finalizeSchedule().
|
virtual |
Cleans up after scheduling in the given block.
Reimplemented in llvm::SwingSchedulerDAG, and llvm::ScheduleDAGMI.
Definition at line 184 of file ScheduleDAGInstrs.cpp.
References BB.
Referenced by llvm::SwingSchedulerDAG::finishBlock(), llvm::ScheduleDAGMI::finishBlock(), and llvm::VLIWPacketizerList::PacketizeMIs().
void ScheduleDAGInstrs::fixupKills | ( | MachineBasicBlock & | MBB | ) |
Fixes register kill flags that scheduling has made invalid.
Definition at line 1127 of file ScheduleDAGInstrs.cpp.
References llvm::LiveRegUnits::addLiveOuts(), llvm::dbgs(), llvm::MachineOperand::getReg(), llvm::MachineOperand::getRegMask(), I, llvm::LiveRegUnits::init(), llvm::MachineOperand::isDef(), llvm::MachineOperand::isReg(), llvm::MachineOperand::isRegMask(), LiveRegs, LLVM_DEBUG, MBB, MI, llvm::ScheduleDAG::MRI, llvm::printMBBReference(), llvm::LiveRegUnits::removeReg(), llvm::LiveRegUnits::removeRegsNotPreserved(), llvm::reverse(), toggleKills(), and llvm::ScheduleDAG::TRI.
|
overridevirtual |
Returns a label for the region of code covered by the DAG.
Return the basic block label.
It is not necessarilly unique because a block contains multiple scheduling regions. But it is fine for visualization.
Implements llvm::ScheduleDAG.
Definition at line 1214 of file ScheduleDAGInstrs.cpp.
References BB, and llvm::MachineBasicBlock::getFullName().
Returns a label for a DAG node that points to an instruction.
Implements llvm::ScheduleDAG.
Definition at line 1200 of file ScheduleDAGInstrs.cpp.
References llvm::ScheduleDAG::EntrySU, llvm::ScheduleDAG::ExitSU, llvm::SUnit::getInstr(), and llvm::MachineInstr::print().
|
protected |
Returns a mask for which lanes get read/written by the given (register) machine operand.
Definition at line 377 of file ScheduleDAGInstrs.cpp.
References llvm::LaneBitmask::getAll(), llvm::TargetRegisterClass::getLaneMask(), llvm::MachineOperand::getReg(), llvm::MachineRegisterInfo::getRegClass(), llvm::MachineOperand::getSubReg(), llvm::TargetRegisterInfo::getSubRegIndexLaneMask(), llvm::TargetRegisterClass::HasDisjunctSubRegs, llvm::ScheduleDAG::MRI, SubReg, and llvm::ScheduleDAG::TRI.
Referenced by addVRegDefDeps(), addVRegUseDeps(), and deadDefHasNoUse().
|
inline |
Resolves and cache a resolved scheduling class for an SUnit.
Definition at line 272 of file ScheduleDAGInstrs.h.
References llvm::SUnit::getInstr(), llvm::TargetSchedModel::hasInstrSchedModel(), llvm::TargetSchedModel::resolveSchedClass(), llvm::SUnit::SchedClass, and SchedModel.
Referenced by llvm::SchedBoundary::bumpNode(), llvm::ResourceManager::calculateResMII(), llvm::ResourceManager::canReserveResources(), llvm::SchedBoundary::checkHazard(), llvm::ScheduleDAGMI::dumpScheduleTraceBottomUp(), llvm::ScheduleDAGMI::dumpScheduleTraceTopDown(), llvm::SchedRemainder::init(), llvm::GenericSchedulerBase::SchedCandidate::initResourceDelta(), initSUnits(), and llvm::ResourceManager::reserveResources().
|
inline |
Gets the machine model for instruction scheduling.
Definition at line 269 of file ScheduleDAGInstrs.h.
References SchedModel.
Referenced by llvm::GenericScheduler::initialize(), llvm::PostGenericScheduler::initialize(), and llvm::ConvergingVLIWScheduler::initialize().
|
inline |
Returns an existing SUnit for this MI, or nullptr.
Definition at line 397 of file ScheduleDAGInstrs.h.
References MI, and MISUnitMap.
Referenced by llvm::SwingSchedulerDAG::applyInstrChange(), llvm::WindowScheduler::calculateMaxCycle(), llvm::ScheduleDAGMILive::computeCyclicCriticalPath(), llvm::GCNSchedStage::computeSUnitReadyCycle(), llvm::ScheduleDAGMI::dumpSchedule(), llvm::ScheduleDAGMI::dumpScheduleTraceBottomUp(), llvm::ScheduleDAGMI::dumpScheduleTraceTopDown(), llvm::GCNSchedStage::getScheduleMetrics(), llvm::SMSchedule::isLoopCarried(), and llvm::SwingSchedulerDAG::schedule().
|
protected |
Creates an SUnit for each real instruction, numbered in top-down topological order.
The instruction order A < B, implies that no edge exists from B to A.
Map each real instruction to its SUnit.
After initSUnits, the SUnits vector cannot be resized and the scheduler may hang onto SUnit pointers. We may relax this in the future by using SUnit IDs instead of pointers.
MachineScheduler relies on initSUnits numbering the nodes by their order in the original instruction list.
Definition at line 578 of file ScheduleDAGInstrs.cpp.
References llvm::MCProcResourceDesc::BufferSize, llvm::SUnit::getInstr(), llvm::TargetSchedModel::getProcResource(), getSchedClass(), llvm::TargetSchedModel::getWriteProcResBegin(), llvm::TargetSchedModel::getWriteProcResEnd(), llvm::TargetSchedModel::hasInstrSchedModel(), llvm::SUnit::hasReservedResource, llvm::SUnit::isCall, llvm::SUnit::isCommutable, llvm::SUnit::isUnbuffered, llvm::SUnit::Latency, llvm::make_range(), MI, MISUnitMap, newSUnit(), NumRegionInstrs, RegionBegin, RegionEnd, SchedModel, and llvm::ScheduleDAG::SUnits.
Referenced by buildSchedGraph().
|
protected |
Inserts a barrier chain in a huge region, far below current SU.
Adds barrier chain edges from all SUs in map with higher NodeNums than this new BarrierChain, and remove them from map. It is assumed BarrierChain has been set before calling this.
Definition at line 706 of file ScheduleDAGInstrs.cpp.
References assert(), BarrierChain, llvm::MapVector< KeyT, ValueT, MapType, VectorType >::begin(), llvm::MapVector< KeyT, ValueT, MapType, VectorType >::end(), I, llvm::SUnit::NodeNum, llvm::ScheduleDAGInstrs::Value2SUsMap::reComputeSize(), and llvm::MapVector< KeyT, ValueT, MapType, VectorType >::remove_if().
Referenced by reduceHugeMemNodeMaps().
IsReachable - Checks if SU is reachable from TargetSU.
Definition at line 279 of file ScheduleDAGInstrs.h.
References llvm::ScheduleDAGTopologicalSort::IsReachable(), and Topo.
|
inline |
Creates a new SUnit and return a ptr to it.
Definition at line 386 of file ScheduleDAGInstrs.h.
References Addr, assert(), MI, and llvm::ScheduleDAG::SUnits.
Referenced by initSUnits().
|
protected |
Reduces maps in FIFO order, by N SUs.
This is better than turning every Nth memory SU into BarrierChain in buildSchedGraph(), since it avoids unnecessary edges between seen SUs above the new BarrierChain, and those below it.
Definition at line 1058 of file ScheduleDAGInstrs.cpp.
References llvm::SUnit::addPredBarrier(), assert(), BarrierChain, llvm::dbgs(), llvm::ScheduleDAGInstrs::Value2SUsMap::dump(), insertBarrierChain(), LLVM_DEBUG, N, llvm::SUnit::NodeNum, llvm::ScheduleDAGInstrs::Value2SUsMap::size(), llvm::sort(), stores, and llvm::ScheduleDAG::SUnits.
Referenced by buildSchedGraph().
|
pure virtual |
Orders nodes according to selected style.
Typically, a scheduling algorithm will implement schedule() without overriding enterRegion() or exitRegion().
Implemented in llvm::DefaultVLIWScheduler, llvm::SwingSchedulerDAG, llvm::ScheduleDAGMI, llvm::ScheduleDAGMILive, llvm::VLIWMachineScheduler, llvm::GCNIterativeScheduler, llvm::GCNScheduleDAGMILive, llvm::GCNPostScheduleDAGMILive, and llvm::SIScheduleDAGMI.
|
inline |
Definition at line 195 of file ScheduleDAGInstrs.h.
|
virtual |
Prepares to perform scheduling in the given block.
Reimplemented in llvm::ScheduleDAGMI.
Definition at line 180 of file ScheduleDAGInstrs.cpp.
References BB.
Referenced by llvm::VLIWPacketizerList::PacketizeMIs(), and llvm::ScheduleDAGMI::startBlock().
|
protected |
Definition at line 172 of file ScheduleDAGInstrs.h.
Referenced by addChainDependency(), and buildSchedGraph().
|
protected |
Remember a generic side-effecting instruction as we proceed.
No other SU ever gets scheduled around it (except in the special case of a huge region that gets reduced).
Definition at line 177 of file ScheduleDAGInstrs.h.
Referenced by addBarrierChain(), buildSchedGraph(), insertBarrierChain(), and reduceHugeMemNodeMaps().
|
protected |
The block in which to insert instructions.
Definition at line 140 of file ScheduleDAGInstrs.h.
Referenced by addSchedBarrierDeps(), llvm::GCNIterativeScheduler::BuildDAG::BuildDAG(), llvm::ScheduleDAGMILive::buildDAGWithRegPressure(), llvm::ScheduleDAGMILive::computeCyclicCriticalPath(), llvm::ScheduleDAGMI::dumpScheduleTraceBottomUp(), llvm::ScheduleDAGMI::dumpScheduleTraceTopDown(), enterRegion(), llvm::GCNIterativeScheduler::enterRegion(), finishBlock(), llvm::SIScheduleDAGMI::getBB(), llvm::VLIWMachineScheduler::getBBSize(), getDAGName(), llvm::ScheduleDAGMILive::initRegPressure(), llvm::SIScheduleDAGMI::initRPTracker(), llvm::SwingSchedulerDAG::isLoopCarriedDep(), llvm::ScheduleDAGMI::moveInstruction(), llvm::GCNIterativeScheduler::OverrideLegacyStrategy::OverrideLegacyStrategy(), llvm::ScheduleDAGMI::placeDebugValues(), llvm::GCNSchedStage::revertScheduling(), llvm::VLIWMachineScheduler::schedule(), llvm::GCNIterativeScheduler::scheduleRegion(), startBlock(), and llvm::ScheduleDAGMILive::updatePressureDiffs().
|
protected |
The standard DAG builder does not normally include terminators as DAG nodes because it does not create the necessary dependencies to prevent reordering.
A specialized scheduler can override TargetInstrInfo::isSchedulingBoundary then enable this flag to indicate it has taken responsibility for scheduling the terminator correctly.
Definition at line 131 of file ScheduleDAGInstrs.h.
Referenced by buildSchedGraph(), and llvm::DefaultVLIWScheduler::DefaultVLIWScheduler().
|
protected |
Tracks the last instruction(s) in this region defining each virtual register.
There may be multiple current definitions for a register with disjunct lanemasks.
Definition at line 168 of file ScheduleDAGInstrs.h.
Referenced by addVRegDefDeps(), addVRegUseDeps(), and buildSchedGraph().
|
protected |
Tracks the last instructions in this region using each virtual register.
Definition at line 170 of file ScheduleDAGInstrs.h.
Referenced by addVRegDefDeps(), addVRegUseDeps(), buildSchedGraph(), and deadDefHasNoUse().
|
protected |
Remember instruction that precedes DBG_VALUE.
These are generated by buildSchedGraph but persist so they can be referenced when emitting the final schedule.
Definition at line 255 of file ScheduleDAGInstrs.h.
Referenced by buildSchedGraph(), llvm::GCNIterativeScheduler::detachSchedule(), llvm::ScheduleDAGMI::placeDebugValues(), and ScheduleDAGInstrs().
|
protected |
Defs, Uses - Remember where defs and uses of each register are as we iterate upward through the instructions.
This is allocated here instead of inside BuildSchedGraph to avoid the need for it to be initialized and destructed for each block.
Definition at line 162 of file ScheduleDAGInstrs.h.
Referenced by addPhysRegDeps(), and buildSchedGraph().
|
protected |
Definition at line 198 of file ScheduleDAGInstrs.h.
Referenced by llvm::ScheduleDAGMI::dumpSchedule(), and setDumpDirection().
|
protected |
Definition at line 256 of file ScheduleDAGInstrs.h.
Referenced by buildSchedGraph(), llvm::GCNIterativeScheduler::detachSchedule(), and llvm::ScheduleDAGMI::placeDebugValues().
|
protected |
Set of live physical registers for updating kill flags.
Definition at line 259 of file ScheduleDAGInstrs.h.
Referenced by fixupKills(), and toggleKills().
|
protected |
|
protected |
After calling BuildSchedGraph, each machine instruction in the current scheduling region is mapped to an SUnit.
Definition at line 153 of file ScheduleDAGInstrs.h.
Referenced by llvm::SwingSchedulerDAG::applyInstrChange(), buildSchedGraph(), llvm::SwingSchedulerDAG::fixupRegisterOverlaps(), getSUnit(), and initSUnits().
|
protected |
Definition at line 116 of file ScheduleDAGInstrs.h.
Referenced by llvm::VLIWMachineScheduler::schedule().
|
protected |
Instructions in this region (distance(RegionBegin, RegionEnd)).
Definition at line 149 of file ScheduleDAGInstrs.h.
Referenced by enterRegion(), llvm::GCNIterativeScheduler::enterRegion(), llvm::GCNSchedStage::initGCNRegion(), and initSUnits().
|
protected |
The beginning of the range to be scheduled.
Definition at line 143 of file ScheduleDAGInstrs.h.
Referenced by addSchedBarrierDeps(), begin(), buildSchedGraph(), enterRegion(), llvm::GCNSchedStage::finalizeGCNRegion(), llvm::GCNSchedStage::initGCNRegion(), llvm::ScheduleDAGMI::initQueues(), llvm::ScheduleDAGMILive::initQueues(), llvm::ScheduleDAGMILive::initRegPressure(), llvm::SIScheduleDAGMI::initRPTracker(), initSUnits(), llvm::ScheduleDAGMI::moveInstruction(), llvm::ScheduleDAGMI::placeDebugValues(), llvm::GCNIterativeScheduler::OverrideLegacyStrategy::restoreOrder(), llvm::GCNSchedStage::revertScheduling(), llvm::GCNIterativeScheduler::OverrideLegacyStrategy::schedule(), llvm::GCNIterativeScheduler::schedule(), llvm::GCNScheduleDAGMILive::schedule(), llvm::SIScheduleDAGMI::schedule(), llvm::GCNIterativeScheduler::scheduleRegion(), and llvm::GCNSchedStage::setupNewBlock().
|
protected |
The end of the range to be scheduled.
Definition at line 146 of file ScheduleDAGInstrs.h.
Referenced by addSchedBarrierDeps(), llvm::ScheduleDAGMILive::buildDAGWithRegPressure(), buildSchedGraph(), end(), enterRegion(), llvm::ScheduleDAGMILive::enterRegion(), llvm::GCNSchedStage::finalizeGCNRegion(), llvm::GCNSchedStage::initGCNRegion(), llvm::ScheduleDAGMI::initQueues(), llvm::ScheduleDAGMILive::initRegPressure(), initSUnits(), llvm::ScheduleDAGMI::placeDebugValues(), llvm::GCNIterativeScheduler::OverrideLegacyStrategy::restoreOrder(), llvm::GCNSchedStage::revertScheduling(), llvm::GCNIterativeScheduler::OverrideLegacyStrategy::schedule(), llvm::GCNIterativeScheduler::schedule(), llvm::GCNScheduleDAGMILive::schedule(), and llvm::GCNIterativeScheduler::scheduleRegion().
|
protected |
True if the DAG builder should remove kill flags (in preparation for rescheduling).
Definition at line 124 of file ScheduleDAGInstrs.h.
Referenced by addPhysRegDeps().
|
protected |
TargetSchedModel provides an interface to the machine model.
Definition at line 120 of file ScheduleDAGInstrs.h.
Referenced by addPhysRegDataDeps(), addPhysRegDeps(), addVRegDefDeps(), llvm::ScheduleDAGMILive::dump(), llvm::ScheduleDAGMI::dumpScheduleTraceBottomUp(), llvm::ScheduleDAGMI::dumpScheduleTraceTopDown(), getSchedClass(), getSchedModel(), initSUnits(), and ScheduleDAGInstrs().
|
protected |
Topo - A topological ordering for SUnits which permits fast IsReachable and similar queries.
Definition at line 248 of file ScheduleDAGInstrs.h.
Referenced by addEdge(), llvm::GCNIterativeScheduler::BuildDAG::BuildDAG(), buildSchedGraph(), canAddEdge(), llvm::SIScheduleDAGMI::GetTopo(), IsReachable(), and llvm::VLIWMachineScheduler::schedule().
|
protected |
Whether lane masks should get tracked.
Definition at line 134 of file ScheduleDAGInstrs.h.
Referenced by addVRegDefDeps(), addVRegUseDeps(), buildSchedGraph(), and llvm::ScheduleDAGMILive::collectVRegUses().
|
protected |
For an unanalyzable memory access, this Value is used in maps.
Definition at line 243 of file ScheduleDAGInstrs.h.
Referenced by buildSchedGraph().
|
protected |
Definition at line 163 of file ScheduleDAGInstrs.h.
Referenced by addPhysRegDataDeps(), addPhysRegDeps(), addSchedBarrierDeps(), and buildSchedGraph().