LLVM  6.0.0svn
Public Types | Public Member Functions | Public Attributes | List of all members
llvm::SchedBoundary Class Reference

Each Scheduling boundary is associated with ready queues. More...

#include "llvm/CodeGen/MachineScheduler.h"

Collaboration diagram for llvm::SchedBoundary:
Collaboration graph
[legend]

Public Types

enum  { TopQID = 1, BotQID = 2, LogMaxQID = 2 }
 SUnit::NodeQueueId: 0 (none), 1 (top), 2 (bot), 3 (both) More...
 

Public Member Functions

 SchedBoundary (unsigned ID, const Twine &Name)
 Pending queues extend the ready queues with the same ID and the PendingFlag set. More...
 
 ~SchedBoundary ()
 
void reset ()
 
void init (ScheduleDAGMI *dag, const TargetSchedModel *smodel, SchedRemainder *rem)
 
bool isTop () const
 
unsigned getCurrCycle () const
 Number of cycles to issue the instructions scheduled in this zone. More...
 
unsigned getCurrMOps () const
 Micro-ops issued in the current cycle. More...
 
unsigned getDependentLatency () const
 
unsigned getScheduledLatency () const
 Get the number of latency cycles "covered" by the scheduled instructions. More...
 
unsigned getUnscheduledLatency (SUnit *SU) const
 
unsigned getResourceCount (unsigned ResIdx) const
 
unsigned getCriticalCount () const
 Get the scaled count of scheduled micro-ops and resources, including executed resources. More...
 
unsigned getExecutedCount () const
 Get a scaled count for the minimum execution time of the scheduled micro-ops that are ready to execute by getExecutedCount. More...
 
unsigned getZoneCritResIdx () const
 
bool isResourceLimited () const
 
unsigned getLatencyStallCycles (SUnit *SU)
 Get the difference between the given SUnit's ready time and the current cycle. More...
 
unsigned getNextResourceCycle (unsigned PIdx, unsigned Cycles)
 Compute the next cycle at which the given processor resource can be scheduled. More...
 
bool checkHazard (SUnit *SU)
 Does this SU have a hazard within the current instruction group. More...
 
unsigned findMaxLatency (ArrayRef< SUnit *> ReadySUs)
 
unsigned getOtherResourceCount (unsigned &OtherCritIdx)
 
void releaseNode (SUnit *SU, unsigned ReadyCycle)
 
void bumpCycle (unsigned NextCycle)
 Move the boundary of scheduled code by one cycle. More...
 
void incExecutedResources (unsigned PIdx, unsigned Count)
 
unsigned countResource (unsigned PIdx, unsigned Cycles, unsigned ReadyCycle)
 Add the given processor resource to this scheduled zone. More...
 
void bumpNode (SUnit *SU)
 Move the boundary of scheduled code by one SUnit. More...
 
void releasePending ()
 Release pending ready nodes in to the available queue. More...
 
void removeReady (SUnit *SU)
 Remove SU from the ready set for this boundary. More...
 
SUnitpickOnlyChoice ()
 Call this before applying any other heuristics to the Available queue. More...
 
void dumpScheduledState () const
 

Public Attributes

ScheduleDAGMIDAG = nullptr
 
const TargetSchedModelSchedModel = nullptr
 
SchedRemainderRem = nullptr
 
ReadyQueue Available
 
ReadyQueue Pending
 
ScheduleHazardRecognizerHazardRec = nullptr
 

Detailed Description

Each Scheduling boundary is associated with ready queues.

It tracks the current cycle in the direction of movement, and maintains the state of "hazards" and other interlocks at the current cycle.

Definition at line 612 of file MachineScheduler.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

SUnit::NodeQueueId: 0 (none), 1 (top), 2 (bot), 3 (both)

Enumerator
TopQID 
BotQID 
LogMaxQID 

Definition at line 615 of file MachineScheduler.h.

Constructor & Destructor Documentation

◆ SchedBoundary()

llvm::SchedBoundary::SchedBoundary ( unsigned  ID,
const Twine Name 
)
inline

Pending queues extend the ready queues with the same ID and the PendingFlag set.

Definition at line 687 of file MachineScheduler.h.

References llvm::cl::init().

◆ ~SchedBoundary()

SchedBoundary::~SchedBoundary ( )

Definition at line 1832 of file MachineScheduler.cpp.

Member Function Documentation

◆ bumpCycle()

void SchedBoundary::bumpCycle ( unsigned  NextCycle)

Move the boundary of scheduled code by one cycle.

Definition at line 2065 of file MachineScheduler.cpp.

References assert(), checkResourceLimit(), llvm::dbgs(), DEBUG, and llvm::max().

◆ bumpNode()

void SchedBoundary::bumpNode ( SUnit SU)

◆ checkHazard()

bool SchedBoundary::checkHazard ( SUnit SU)

Does this SU have a hazard within the current instruction group.

The scheduler supports two modes of hazard recognition. The first is the ScheduleHazardRecognizer API. It is a fully general hazard recognizer that supports highly complicated in-order reservation tables (ScoreboardHazardRecognizer) and arbitraty target-specific logic.

The second is a streamlined mechanism that checks for hazards based on simple counters that the scheduler itself maintains. It explicitly checks for instruction dispatch limitations, including the number of micro-ops that can dispatch per cycle.

TODO: Also check whether the SU must start a new group.

Definition at line 1949 of file MachineScheduler.cpp.

References llvm::dbgs(), DEBUG, findMaxLatency(), llvm::SUnit::getInstr(), llvm::ScheduleDAGInstrs::getSchedClass(), llvm::SUnit::hasReservedResource, llvm::make_range(), llvm::max(), llvm::SUnit::NodeNum, llvm::ScheduleHazardRecognizer::NoHazard, and llvm::PPCISD::SC.

◆ countResource()

unsigned SchedBoundary::countResource ( unsigned  PIdx,
unsigned  Cycles,
unsigned  NextCycle 
)

Add the given processor resource to this scheduled zone.

Parameters
Cyclesindicates the number of consecutive (non-pipelined) cycles during which this resource is consumed.
Returns
the next cycle at which the instruction may execute without oversubscribing resources.

Definition at line 2116 of file MachineScheduler.cpp.

References assert(), llvm::dbgs(), and DEBUG.

Referenced by incExecutedResources().

◆ dumpScheduledState()

LLVM_DUMP_METHOD void SchedBoundary::dumpScheduledState ( ) const

◆ findMaxLatency()

unsigned SchedBoundary::findMaxLatency ( ArrayRef< SUnit *>  ReadySUs)

◆ getCriticalCount()

unsigned llvm::SchedBoundary::getCriticalCount ( ) const
inline

Get the scaled count of scheduled micro-ops and resources, including executed resources.

Definition at line 729 of file MachineScheduler.h.

References llvm::TargetSchedModel::getMicroOpFactor().

◆ getCurrCycle()

unsigned llvm::SchedBoundary::getCurrCycle ( ) const
inline

Number of cycles to issue the instructions scheduled in this zone.

Definition at line 704 of file MachineScheduler.h.

Referenced by llvm::GenericSchedulerBase::setPolicy().

◆ getCurrMOps()

unsigned llvm::SchedBoundary::getCurrMOps ( ) const
inline

Micro-ops issued in the current cycle.

Definition at line 707 of file MachineScheduler.h.

Referenced by llvm::GenericScheduler::tryCandidate().

◆ getDependentLatency()

unsigned llvm::SchedBoundary::getDependentLatency ( ) const
inline

Definition at line 710 of file MachineScheduler.h.

Referenced by llvm::GenericSchedulerBase::setPolicy().

◆ getExecutedCount()

unsigned llvm::SchedBoundary::getExecutedCount ( ) const
inline

Get a scaled count for the minimum execution time of the scheduled micro-ops that are ready to execute by getExecutedCount.

Notice the feedback loop.

Definition at line 738 of file MachineScheduler.h.

References llvm::TargetSchedModel::getLatencyFactor(), and llvm::max().

◆ getLatencyStallCycles()

unsigned SchedBoundary::getLatencyStallCycles ( SUnit SU)

Get the difference between the given SUnit's ready time and the current cycle.

Compute the stall cycles based on this SUnit's ready time.

Heuristics treat these "soft stalls" differently than the hard stall cycles based on CPU resources and computed by checkHazard(). A fully in-order model (MicroOpBufferSize==0) will not make use of this since instructions are not available for scheduling until they are ready. However, a weaker in-order model may use this for heuristics. For example, if a processor has in-order behavior when reading certain resources, this may come into play.

Definition at line 1912 of file MachineScheduler.cpp.

References llvm::SUnit::BotReadyCycle, getNextResourceCycle(), llvm::SUnit::isUnbuffered, and llvm::SUnit::TopReadyCycle.

Referenced by llvm::GenericScheduler::tryCandidate().

◆ getNextResourceCycle()

unsigned SchedBoundary::getNextResourceCycle ( unsigned  PIdx,
unsigned  Cycles 
)

Compute the next cycle at which the given processor resource can be scheduled.

Definition at line 1925 of file MachineScheduler.cpp.

Referenced by getLatencyStallCycles().

◆ getOtherResourceCount()

unsigned SchedBoundary::getOtherResourceCount ( unsigned OtherCritIdx)

Definition at line 2015 of file MachineScheduler.cpp.

References llvm::dbgs(), and DEBUG.

Referenced by findMaxLatency(), and llvm::GenericSchedulerBase::setPolicy().

◆ getResourceCount()

unsigned llvm::SchedBoundary::getResourceCount ( unsigned  ResIdx) const
inline

Definition at line 723 of file MachineScheduler.h.

◆ getScheduledLatency()

unsigned llvm::SchedBoundary::getScheduledLatency ( ) const
inline

Get the number of latency cycles "covered" by the scheduled instructions.

This is the larger of the critical path within the zone and the number of cycles required to issue the instructions.

Definition at line 715 of file MachineScheduler.h.

References llvm::max().

Referenced by tryLatency().

◆ getUnscheduledLatency()

unsigned llvm::SchedBoundary::getUnscheduledLatency ( SUnit SU) const
inline

Definition at line 719 of file MachineScheduler.h.

References llvm::SUnit::getDepth(), and llvm::SUnit::getHeight().

◆ getZoneCritResIdx()

unsigned llvm::SchedBoundary::getZoneCritResIdx ( ) const
inline

Definition at line 743 of file MachineScheduler.h.

Referenced by llvm::GenericSchedulerBase::setPolicy().

◆ incExecutedResources()

void SchedBoundary::incExecutedResources ( unsigned  PIdx,
unsigned  Count 
)

Definition at line 2102 of file MachineScheduler.cpp.

References countResource().

◆ init()

void SchedBoundary::init ( ScheduleDAGMI dag,
const TargetSchedModel smodel,
SchedRemainder rem 
)

Definition at line 1894 of file MachineScheduler.cpp.

References InvalidCycle.

Referenced by llvm::SchedRemainder::init().

◆ isResourceLimited()

bool llvm::SchedBoundary::isResourceLimited ( ) const
inline

Definition at line 746 of file MachineScheduler.h.

Referenced by llvm::GenericSchedulerBase::setPolicy().

◆ isTop()

bool llvm::SchedBoundary::isTop ( ) const
inline

◆ pickOnlyChoice()

SUnit * SchedBoundary::pickOnlyChoice ( )

Call this before applying any other heuristics to the Available queue.

If this queue only has one ready candidate, return it.

Updates the Available/Pending Q's if necessary and returns the single available instruction, or NULL if there are multiple candidates.

As a side effect, defer any nodes that now hit a hazard, and advance the cycle until at least one node is ready. If multiple instructions are ready, return NULL.

Definition at line 2330 of file MachineScheduler.cpp.

References DEBUG, and I.

Referenced by llvm::GCNMaxOccupancySchedStrategy::initialize(), and llvm::GCNMaxOccupancySchedStrategy::pickNode().

◆ releaseNode()

void SchedBoundary::releaseNode ( SUnit SU,
unsigned  ReadyCycle 
)

◆ releasePending()

void SchedBoundary::releasePending ( )

Release pending ready nodes in to the available queue.

This makes them visible to heuristics.

Definition at line 2286 of file MachineScheduler.cpp.

References llvm::SUnit::BotReadyCycle, llvm::max(), ReadyListLimit, and llvm::SUnit::TopReadyCycle.

◆ removeReady()

void SchedBoundary::removeReady ( SUnit SU)

Remove SU from the ready set for this boundary.

Definition at line 2318 of file MachineScheduler.cpp.

References assert().

Referenced by llvm::GCNMaxOccupancySchedStrategy::pickNode().

◆ reset()

void SchedBoundary::reset ( )

Definition at line 1841 of file MachineScheduler.cpp.

References assert(), llvm::SchedRemainder::init(), and llvm::max().

Member Data Documentation

◆ Available

ReadyQueue llvm::SchedBoundary::Available

◆ DAG

ScheduleDAGMI* llvm::SchedBoundary::DAG = nullptr

Definition at line 621 of file MachineScheduler.h.

Referenced by llvm::GCNMaxOccupancySchedStrategy::initialize().

◆ HazardRec

ScheduleHazardRecognizer* llvm::SchedBoundary::HazardRec = nullptr

Definition at line 628 of file MachineScheduler.h.

◆ Pending

ReadyQueue llvm::SchedBoundary::Pending

◆ Rem

SchedRemainder* llvm::SchedBoundary::Rem = nullptr

Definition at line 623 of file MachineScheduler.h.

◆ SchedModel

const TargetSchedModel* llvm::SchedBoundary::SchedModel = nullptr

Definition at line 622 of file MachineScheduler.h.


The documentation for this class was generated from the following files: