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 };
269 unsigned NodeNum = BoundaryID;
270 unsigned NodeQueueId = 0;
271 unsigned NumPreds = 0;
272 unsigned NumSuccs = 0;
273 unsigned NumPredsLeft = 0;
274 unsigned NumSuccsLeft = 0;
275 unsigned WeakPredsLeft = 0;
276 unsigned WeakSuccsLeft = 0;
277 unsigned short NumRegDefsLeft = 0;
298 bool isDepthCurrent : 1;
299 bool isHeightCurrent : 1;
304 unsigned TopReadyCycle = 0;
305 unsigned BotReadyCycle = 0;
314 : Node(node), NodeNum(nodenum), isVRegCycle(
false), isCall(
false),
316 hasPhysRegUses(
false), hasPhysRegDefs(
false), hasPhysRegClobbers(
false),
319 isUnbuffered(
false), hasReservedResource(
false), isDepthCurrent(
false),
320 isHeightCurrent(
false) {}
325 : Instr(instr), NodeNum(nodenum), isVRegCycle(
false), isCall(
false),
327 hasPhysRegUses(
false), hasPhysRegDefs(
false), hasPhysRegClobbers(
false),
330 isUnbuffered(
false), hasReservedResource(
false), isDepthCurrent(
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 =
399 void removePred(
const SDep &D);
405 const_cast<SUnit *
>(
this)->ComputeDepth();
412 if (!isHeightCurrent)
413 const_cast<SUnit *
>(
this)->ComputeHeight();
420 void setDepthToAtLeast(
unsigned NewDepth);
425 void setHeightToAtLeast(
unsigned NewHeight);
429 void setDepthDirty();
433 void setHeightDirty();
437 for (
const SDep &Pred : Preds)
438 if (Pred.getSUnit() ==
N)
445 for (
const SDep &Succ : Succs)
446 if (Succ.getSUnit() ==
N)
452 return NumPredsLeft == 0;
455 return NumSuccsLeft == 0;
460 void biasCriticalPath();
465 const SUnit *Entry =
nullptr,
466 const SUnit *Exit =
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;
517 virtual bool isBottomUp()
const = 0;
519 virtual void initNodes(std::vector<SUnit> &SUnits) = 0;
520 virtual void addNode(
const SUnit *SU) = 0;
521 virtual void updateNode(
const SUnit *SU) = 0;
522 virtual void releaseState() = 0;
524 virtual bool empty()
const = 0;
531 assert(!HasReadyFilter &&
"The ready filter must override isReady()");
535 virtual void push(
SUnit *U) = 0;
538 for (std::vector<SUnit *>::const_iterator
I = Nodes.begin(),
539 E = Nodes.end();
I !=
E; ++
I)
543 virtual SUnit *pop() = 0;
545 virtual void remove(
SUnit *SU) = 0;
577 static const bool StressSched =
false;
593 return getNodeDesc(SU->
getNode());
598 virtual void viewGraph();
600 virtual void dumpNode(
const SUnit *SU)
const = 0;
603 virtual std::string getGraphNodeLabel(
const SUnit *SU)
const = 0;
606 virtual std::string getDAGName()
const = 0;
614 unsigned VerifyScheduledDAG(
bool isBottomUp);
631 return Operand == x.Operand;
636 return Node->
Preds[Operand].getSUnit();
658 return getSDep().isCtrl();
661 return getSDep().isArtificial();
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);
722 void InitDAGTopologicalSorting();
729 std::vector<int> GetSubGraph(
const SUnit &StartSU,
const SUnit &TargetSU,
733 bool IsReachable(
const SUnit *SU,
const SUnit *TargetSU);
736 bool WillCreateCycle(
SUnit *TargetSU,
SUnit *SU);
749 iterator
begin() {
return Index2Node.begin(); }
750 const_iterator
begin()
const {
return Index2Node.begin(); }
751 iterator
end() {
return Index2Node.end(); }
752 const_iterator
end()
const {
return Index2Node.end(); }
756 reverse_iterator
rbegin() {
return Index2Node.rbegin(); }
757 const_reverse_iterator
rbegin()
const {
return Index2Node.rbegin(); }
758 reverse_iterator
rend() {
return Index2Node.rend(); }
759 const_reverse_iterator
rend()
const {
return Index2Node.rend(); }
764 #endif // LLVM_CODEGEN_SCHEDULEDAG_H static nodes_iterator nodes_begin(ScheduleDAG *G)
Weak DAG edge linking a chain of clustered instrs.
std::vector< int >::const_reverse_iterator const_reverse_iterator
unsigned getOperand() const
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
std::vector< int >::reverse_iterator reverse_iterator
typename SuperClass::const_iterator const_iterator
unsigned OrdKind
Additional information about Order dependencies.
void setNode(SDNode *N)
Assigns the representative SDNode for this SUnit.
Compute iterated dominance frontiers using a linear time algorithm.
SDNode * getNode() const
Returns the representative SDNode for this SUnit.
pointer operator*() const
virtual bool tracksRegPressure() const
bool isTwoAddress
Is a two-address instruction.
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...
Describe properties that are true of each instruction in the target description file.
bool isBarrier() const
Tests if this is an Order dependence that is marked as a barrier.
std::vector< int >::iterator iterator
unsigned const TargetRegisterInfo * TRI
unsigned getReg() const
Returns the register associated with this edge.
const_reverse_iterator rend() const
bool isBottomReady() const
Kind
These are the different kinds of scheduling dependencies.
bool operator==(const SDep &Other) const
bool isAssignedRegDep() const
Tests if this is a Data dependence that is associated with a register.
static NodeRef getEntryNode(SUnit *N)
SmallVectorImpl< SDep >::iterator succ_iterator
const_iterator begin() const
virtual void dump(ScheduleDAG *) const
SUnit()
Constructs a placeholder SUnit.
unsigned getCurCycle() const
SmallVector< SDep, 4 > Preds
All sunit predecessors.
A register anti-dependence (aka WAR).
MachineFunction & MF
Machine function.
bool isScheduled
True once scheduled.
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
This interface is used to plug different priorities computation algorithms into the list scheduler...
raw_ostream & print(raw_ostream &O, const TargetRegisterInfo *TRI=nullptr) const
SmallVectorImpl< SDep >::iterator pred_iterator
virtual void unscheduledNode(SUnit *)
unsigned getLatency() const
Returns the latency value for this edge, which roughly means the minimum number of cycles that must e...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
void setInstr(MachineInstr *MI)
Assigns the instruction for the SUnit.
SmallVectorImpl< SDep >::const_iterator const_pred_iterator
void push_all(const std::vector< SUnit *> &Nodes)
Regular data dependence (aka true-dependence).
bool hasPhysRegUses
Has physreg uses.
const MCInstrDesc * getInstrDesc(const SUnit *SU) const
Returns the MCInstrDesc of this SUnit.
unsigned Reg
For Data, Anti, and Output dependencies, the associated register.
bool hasPhysRegDefs
Has physreg defs that are being used.
void setCurCycle(unsigned Cycle)
APInt operator*(APInt a, uint64_t RHS)
SchedulingPriorityQueue(bool rf=false)
bool operator==(const SUnitIterator &x) const
const_reverse_iterator rbegin() const
pointer operator->() const
SDep()
Constructs a null SDep.
A register output-dependence (aka WAW).
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
bool hasReservedResource
Uses a reserved resource.
bool isPending
True once pending.
bool isCtrl() const
Shorthand for getKind() != SDep::Data.
bool isBoundaryNode() const
Boundary nodes are placeholders for the boundary of the scheduling region.
TargetInstrInfo - Interface to description of machine instruction set.
bool isUnbuffered
Uses an unbuffered resource.
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
bool isCall
Is a function call.
reverse_iterator rbegin()
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
MachineInstr * getInstr() const
Returns the representative MachineInstr for this SUnit.
bool isArtificial() const
Tests if this is an Order dependence that is marked as "artificial", meaning it isn't necessary for c...
bool isNormalMemoryOrBarrier() const
Tests if this is could be any kind of memory dependence.
PointerIntPair - This class implements a pair of a pointer and small integer.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Summarize the scheduling resources required for an instruction of a particular scheduling class...
const SUnit * getNode() const
static SUnitIterator begin(SUnit *N)
bool isVRegCycle
May use and def the same vreg.
static ChildIteratorType child_begin(NodeRef N)
bool isCloned
True if this node has been cloned.
bool operator!=(const SUnitIterator &x) const
SUnitIterator operator++(int)
const TargetMachine & TM
Target processor.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Any other ordering dependency.
static SUnitIterator end(SUnit *N)
bool isNormalMemory() const
Tests if this is an Order dependence between two memory accesses where both sides of the dependence a...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
pointer_iterator< std::vector< SUnit >::iterator > nodes_iterator
SUnitIterator ChildIteratorType
SUnitIterator & operator++()
SDep(SUnit *S, OrderKind kind)
const_iterator end() const
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 void addCustomGraphFeatures(GraphWriter< ScheduleDAG *> &) const
Adds custom features for a visualization of the ScheduleDAG.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
Nonvolatile load/Store instructions that may alias.
Represents one node in the SelectionDAG.
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 operator!=(const SDep &Other) const
virtual void scheduledNode(SUnit *)
As each node is scheduled, this method is invoked.
typename SuperClass::iterator iterator
SmallVectorImpl< SDep >::const_iterator const_succ_iterator
static ChildIteratorType child_end(NodeRef N)
bool isCallOp
Is a function call operand.
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.
SUnit EntrySU
Special node for the region entry.
unsigned getHeight() const
Returns the height of this node, which is the length of the maximum path down to any node which has n...
Representation of each machine instruction.
SUnit ExitSU
Special node for the region exit.
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 isMustAlias() const
Tests if this is an Order dependence that is marked as "must alias", meaning that the SUnits at eithe...
const TargetInstrInfo * TII
Target instruction information.
Kind getKind() const
Returns an enum value representing the kind of the dependence.
bool isCtrlDep() const
Tests if this is not an SDep::Data dependence.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const SDep & getSDep() const
virtual bool isReady(SUnit *) const
bool overlaps(const SDep &Other) const
Returns true if the specified SDep is equivalent except for latency.
bool hasReadyFilter() const
SUnit(MachineInstr *instr, unsigned nodenum)
Constructs an SUnit for post-regalloc scheduling to represent a MachineInstr.
SmallVector< SDep, 4 > Succs
All sunit successors.
bool isCluster() const
Tests if this is an Order dependence that is marked as "cluster", meaning it is artificial and wants ...
Arbitrary strong DAG edge (no real dependence).
bool isWeak() const
Tests if this a weak 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.
static nodes_iterator nodes_end(ScheduleDAG *G)
bool isScheduleLow
True if preferable to schedule low.
MachineRegisterInfo & MRI
Virtual/real register map.
std::vector< SUnit > SUnits
The scheduling units.
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.
bool isInstr() const
Returns true if this SUnit refers to a machine instruction as opposed to an SDNode.
bool isSucc(const SUnit *N) const
Tests if node N is a successor of this node.
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 isArtificialDep() const
bool isPred(const SUnit *N) const
Tests if node N is a predecessor of this node.