16 #ifndef LLVM_CODEGEN_SCHEDULEDAG_H
17 #define LLVM_CODEGEN_SCHEDULEDAG_H
106 : Dep(S, kind), Contents() {
113 "SDep::Anti and SDep::Output must use a non-zero Reg!");
125 : Dep(S,
Order), Contents(), Latency(0) {
126 Contents.OrdKind = kind;
133 return overlaps(Other) && Latency == Other.Latency;
221 "getReg called on non-register dependence edge!");
231 "setReg called on non-register dependence edge!");
233 "SDep::Anti edge cannot use the zero register!");
235 "SDep::Output edge cannot use the zero register!");
249 enum :
unsigned { BoundaryID = ~0u };
298 bool isDepthCurrent : 1;
299 bool isHeightCurrent : 1;
320 isHeightCurrent(
false) {}
331 isHeightCurrent(
false) {}
340 isDepthCurrent(
false), isHeightCurrent(
false) {}
354 assert(!Instr &&
"Setting SDNode of SUnit with MachineInstr!");
361 assert(!Instr &&
"Reading SDNode of SUnit with MachineInstr!");
372 assert(!Node &&
"Setting MachineInstr of SUnit with SDNode!");
379 assert(!Node &&
"Reading MachineInstr of SUnit with SDNode!");
391 unsigned TrueMemOrderLatency =
405 const_cast<SUnit *
>(
this)->ComputeDepth();
412 if (!isHeightCurrent)
413 const_cast<SUnit *
>(
this)->ComputeHeight();
438 if (Pred.getSUnit() ==
N)
446 if (Succ.getSUnit() ==
N)
466 const SUnit *
X =
nullptr)
const;
471 void ComputeHeight();
476 if (Dep != Other.Dep)
478 switch (Dep.getInt()) {
482 return Contents.Reg == Other.Contents.
Reg;
484 return Contents.OrdKind == Other.Contents.
OrdKind;
507 virtual void anchor();
509 unsigned CurCycle = 0;
519 virtual void initNodes(std::vector<SUnit> &SUnits) = 0;
524 virtual bool empty()
const = 0;
531 assert(!HasReadyFilter &&
"The ready filter must override isReady()");
538 for (std::vector<SUnit *>::const_iterator
I = Nodes.begin(),
539 E = Nodes.end();
I !=
E; ++
I)
545 virtual void remove(
SUnit *SU) = 0;
593 return getNodeDesc(SU->
getNode());
631 return Operand == x.Operand;
636 return Node->
Preds[Operand].getSUnit();
664 return Node->
Preds[Operand];
683 return nodes_iterator(G->
SUnits.begin());
686 return nodes_iterator(G->
SUnits.end());
696 std::vector<SUnit> &SUnits;
700 std::vector<int> Index2Node;
702 std::vector<int> Node2Index;
709 void DFS(
const SUnit *SU,
int UpperBound,
bool& HasLoop);
713 void Shift(
BitVector& Visited,
int LowerBound,
int UpperBound);
716 void Allocate(
int n,
int index);
764 #endif // LLVM_CODEGEN_SCHEDULEDAG_H
static nodes_iterator nodes_begin(ScheduleDAG *G)
Weak DAG edge linking a chain of clustered instrs.
bool isCtrl() const
Shorthand for getKind() != SDep::Data.
std::vector< int >::const_reverse_iterator const_reverse_iterator
std::vector< int >::reverse_iterator reverse_iterator
virtual void initNodes(std::vector< SUnit > &SUnits)=0
bool isArtificialDep() const
typename SuperClass::const_iterator const_iterator
unsigned OrdKind
Additional information about Order dependencies.
unsigned NumPreds
of SDep::Data preds.
void setNode(SDNode *N)
Assigns the representative SDNode for this SUnit.
virtual void updateNode(const SUnit *SU)=0
const_iterator end() const
bool isTwoAddress
Is a two-address instruction.
Describe properties that are true of each instruction in the target description file.
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
MachineInstr * getInstr() const
Returns the representative MachineInstr for this SUnit.
void dumpAll(const ScheduleDAG *G) const
virtual void push(SUnit *U)=0
bool isInstr() const
Returns true if this SUnit refers to a machine instruction as opposed to an SDNode.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
bool operator!=(const SUnitIterator &x) const
virtual std::string getGraphNodeLabel(const SUnit *SU) const =0
Returns a label for an SUnit node in a visualization of the ScheduleDAG.
std::vector< int >::iterator iterator
void removePred(const SDep &D)
Removes the specified edge as a pred of the current node if it exists.
Kind
These are the different kinds of scheduling dependencies.
virtual ~SchedulingPriorityQueue()=default
bool overlaps(const SDep &Other) const
Returns true if the specified SDep is equivalent except for latency.
bool isAssignedRegDep() const
Tests if this is a Data dependence that is associated with a register.
static NodeRef getEntryNode(SUnit *N)
unsigned BotReadyCycle
Cycle relative to end when node is ready.
SmallVectorImpl< SDep >::iterator succ_iterator
const TargetRegisterClass * CopyDstRC
Is a special copy node if != nullptr.
SUnit()
Constructs a placeholder SUnit.
bool isArtificial() const
Tests if this is an Order dependence that is marked as "artificial", meaning it isn't necessary for...
SmallVector< SDep, 4 > Preds
All sunit predecessors.
virtual void viewGraph()
Out-of-line implementation with no arguments is handy for gdb.
A register anti-dependence (aka WAR).
MachineFunction & MF
Machine function.
bool isScheduled
True once scheduled.
This interface is used to plug different priorities computation algorithms into the list scheduler...
unsigned getHeight() const
Returns the height of this node, which is the length of the maximum path down to any node which has n...
const SUnit * getNode() const
SmallVectorImpl< SDep >::iterator pred_iterator
unsigned NumSuccs
of SDep::Data sucss.
virtual void unscheduledNode(SUnit *)
unsigned NumSuccsLeft
of succs not scheduled.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
bool isWeak() const
Tests if this a weak dependence.
virtual void releaseState()=0
Kind getKind() const
Returns an enum value representing the kind of the dependence.
raw_ostream & print(raw_ostream &O, const TargetRegisterInfo *TRI=nullptr) const
void setInstr(MachineInstr *MI)
Assigns the instruction for the SUnit.
SmallVectorImpl< SDep >::const_iterator const_pred_iterator
Regular data dependence (aka true-dependence).
bool mayLoad(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read memory.
bool hasPhysRegUses
Has physreg uses.
unsigned getCurCycle() const
unsigned Reg
For Data, Anti, and Output dependencies, the associated register.
bool hasPhysRegDefs
Has physreg defs that are being used.
virtual std::string getDAGName() const =0
Returns a label for the region of code covered by the DAG.
void setCurCycle(unsigned Cycle)
bool isPred(const SUnit *N) const
Tests if node N is a predecessor of this node.
void InitDAGTopologicalSorting()
Creates the initial topological ordering from the DAG to be scheduled.
SchedulingPriorityQueue(bool rf=false)
unsigned TopReadyCycle
Cycle relative to start when node is ready.
SUnit * OrigNode
If not this, the node from which this node was cloned.
SDep()
Constructs a null SDep.
pointer operator*() const
A register output-dependence (aka WAW).
bool hasReservedResource
Uses a reserved resource.
std::vector< int > GetSubGraph(const SUnit &StartSU, const SUnit &TargetSU, bool &Success)
Returns an array of SUs that are both in the successor subtree of StartSU and in the predecessor subt...
unsigned WeakSuccsLeft
of weak succs not scheduled.
bool isMustAlias() const
Tests if this is an Order dependence that is marked as "must alias", meaning that the SUnits at eithe...
void dump(const ScheduleDAG *G) const
bool isPending
True once pending.
unsigned NumPredsLeft
of preds not scheduled.
virtual bool isReady(SUnit *) const
bool isNormalMemory() const
Tests if this is an Order dependence between two memory accesses where both sides of the dependence a...
TargetInstrInfo - Interface to description of machine instruction set.
bool operator==(const SDep &Other) const
void setDepthToAtLeast(unsigned NewDepth)
If NewDepth is greater than this node's depth value, sets it to be the new depth value.
bool operator==(const SUnitIterator &x) const
bool isUnbuffered
Uses an unbuffered resource.
void setHeightToAtLeast(unsigned NewHeight)
If NewDepth is greater than this node's depth value, set it to be the new height value.
Function Alias Analysis false
bool isCall
Is a function call.
virtual void dump(ScheduleDAG *) const
void setDepthDirty()
Sets a flag in this node to indicate that its stored Depth value will require recomputation the next ...
reverse_iterator rbegin()
bool WillCreateCycle(SUnit *TargetSU, SUnit *SU)
Returns true if addPred(TargetSU, SU) creates a cycle.
void clearDAG()
Clears the DAG state (between regions).
PointerIntPair - This class implements a pair of a pointer and small integer.
SDNode * getNode() const
Returns the representative SDNode for this SUnit.
unsigned short Latency
Node latency.
virtual void addCustomGraphFeatures(GraphWriter< ScheduleDAG * > &) const
Adds custom features for a visualization of the ScheduleDAG.
virtual void addNode(const SUnit *SU)=0
virtual bool empty() const =0
pointer operator->() const
Summarize the scheduling resources required for an instruction of a particular scheduling class...
static SUnitIterator begin(SUnit *N)
bool isVRegCycle
May use and def the same vreg.
unsigned getLatency() const
Returns the latency value for this edge, which roughly means the minimum number of cycles that must e...
static ChildIteratorType child_begin(NodeRef N)
bool isCloned
True if this node has been cloned.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
SUnitIterator operator++(int)
raw_ostream & print(raw_ostream &O, const SUnit *N=nullptr, const SUnit *X=nullptr) const
const MCSchedClassDesc * SchedClass
nullptr or resolved SchedClass.
void RemovePred(SUnit *M, SUnit *N)
Updates the topological ordering to accommodate an an edge to be removed from the specified node N fr...
const TargetMachine & TM
Target processor.
void push_all(const std::vector< SUnit * > &Nodes)
Sched::Preference SchedulingPref
Scheduling preference.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Any other ordering dependency.
static SUnitIterator end(SUnit *N)
const SDep & getSDep() const
pointer_iterator< std::vector< SUnit >::iterator > nodes_iterator
const_reverse_iterator rbegin() const
SUnitIterator ChildIteratorType
SUnitIterator & operator++()
SDep(SUnit *S, OrderKind kind)
unsigned WeakPredsLeft
of weak preds not scheduled.
An unknown scheduling barrier.
bool isScheduleHigh
True if preferable to schedule high.
bool isCommutable
Is a commutable instruction.
isPodLike - This is a type trait that is used to determine whether a given type can be copied around ...
virtual bool isBottomUp() const =0
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
bool isCtrlDep() const
Tests if this is not an SDep::Data dependence.
Nonvolatile load/Store instructions that may alias.
Represents one node in the SelectionDAG.
const TargetRegisterClass * CopySrcRC
bool addPredBarrier(SUnit *SU)
Adds a barrier edge to SU by calling addPred(), with latency 0 generally or latency 1 for a store fol...
void setReg(unsigned Reg)
Assigns the associated register for this edge.
std::vector< int >::const_iterator const_iterator
bool IsReachable(const SUnit *SU, const SUnit *TargetSU)
Checks if SU is reachable from TargetSU.
void biasCriticalPath()
Orders this node's predecessor edges such that the critical path edge occurs first.
virtual void scheduledNode(SUnit *)
As each node is scheduled, this method is invoked.
ScheduleDAG(MachineFunction &mf)
typename SuperClass::iterator iterator
SmallVectorImpl< SDep >::const_iterator const_succ_iterator
static ChildIteratorType child_end(NodeRef N)
bool isCallOp
Is a function call operand.
bool isBoundaryNode() const
Boundary nodes are placeholders for the boundary of the scheduling region.
unsigned getDepth() const
Returns the depth of this node, which is the length of the maximum path up to any node which has no p...
llvm_unreachable("Unknown RegBank!")
void setLatency(unsigned Lat)
Sets the latency for this edge.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
bool isAvailable
True once available.
bool isCluster() const
Tests if this is an Order dependence that is marked as "cluster", meaning it is artificial and wants ...
SUnit EntrySU
Special node for the region entry.
unsigned NodeQueueId
Queue id of node.
unsigned VerifyScheduledDAG(bool isBottomUp)
Verifies that all SUnits were scheduled and that their state is consistent.
Representation of each machine instruction.
SUnit ExitSU
Special node for the region exit.
unsigned getOperand() const
const TargetRegisterInfo * TRI
Target processor register info.
SUnit(SDNode *node, unsigned nodenum)
Constructs an SUnit for pre-regalloc scheduling to represent an SDNode and any nodes flagged to it...
bool operator!=(const SDep &Other) const
bool hasReadyFilter() const
unsigned short NumRegDefsLeft
of reg defs with no scheduled use.
const TargetInstrInfo * TII
Target instruction information.
bool isSucc(const SUnit *N) const
Tests if node N is a successor of this node.
unsigned NodeNum
Entry # of node in the node vector.
virtual bool tracksRegPressure() const
void setHeightDirty()
Sets a flag in this node to indicate that its stored Height value will require recomputation the next...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const_iterator begin() const
virtual void dumpNode(const SUnit *SU) const =0
bool isNormalMemoryOrBarrier() const
Tests if this is could be any kind of memory dependence.
bool addPred(const SDep &D, bool Required=true)
Adds the specified edge as a pred of the current node if not already.
SUnit(MachineInstr *instr, unsigned nodenum)
Constructs an SUnit for post-regalloc scheduling to represent a MachineInstr.
SmallVector< SDep, 4 > Succs
All sunit successors.
bool isBottomReady() const
Arbitrary strong DAG edge (no real dependence).
This class implements an extremely fast bulk output stream that can only output to a stream...
Primary interface to the complete machine description for the target machine.
void AddPred(SUnit *Y, SUnit *X)
Updates the topological ordering to accommodate an edge to be added from SUnit X to SUnit Y...
static nodes_iterator nodes_end(ScheduleDAG *G)
bool isScheduleLow
True if preferable to schedule low.
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml","ocaml 3.10-compatible collector")
const MCInstrDesc * getInstrDesc(const SUnit *SU) const
Returns the MCInstrDesc of this SUnit.
MachineRegisterInfo & MRI
Virtual/real register map.
std::vector< SUnit > SUnits
The scheduling units.
unsigned getReg() const
Returns the register associated with this edge.
This class can compute a topological ordering for SUnits and provides methods for dynamically updatin...
bool hasPhysRegClobbers
Has any physreg defs, used or not.
SDep(SUnit *S, Kind kind, unsigned Reg)
Constructs an SDep with the specified values.
const_reverse_iterator rend() const
ScheduleDAGTopologicalSort(std::vector< SUnit > &SUnits, SUnit *ExitSU)
Scheduling unit. This is a node in the scheduling DAG.
Nonvolatile load/Store instructions that must alias.
This file describes how to lower LLVM code to machine code.
bool isBarrier() const
Tests if this is an Order dependence that is marked as a barrier.