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!");
248 enum :
unsigned { BoundaryID = ~0u };
268 unsigned NodeNum = BoundaryID;
269 unsigned NodeQueueId = 0;
270 unsigned NumPreds = 0;
271 unsigned NumSuccs = 0;
272 unsigned NumPredsLeft = 0;
273 unsigned NumSuccsLeft = 0;
274 unsigned WeakPredsLeft = 0;
275 unsigned WeakSuccsLeft = 0;
276 unsigned short NumRegDefsLeft = 0;
297 bool isDepthCurrent : 1;
298 bool isHeightCurrent : 1;
303 unsigned TopReadyCycle = 0;
304 unsigned BotReadyCycle = 0;
313 : Node(node), NodeNum(nodenum), isVRegCycle(
false), isCall(
false),
315 hasPhysRegUses(
false), hasPhysRegDefs(
false), hasPhysRegClobbers(
false),
318 isUnbuffered(
false), hasReservedResource(
false), isDepthCurrent(
false),
319 isHeightCurrent(
false) {}
324 : Instr(instr), NodeNum(nodenum), isVRegCycle(
false), isCall(
false),
326 hasPhysRegUses(
false), hasPhysRegDefs(
false), hasPhysRegClobbers(
false),
329 isUnbuffered(
false), hasReservedResource(
false), isDepthCurrent(
false),
330 isHeightCurrent(
false) {}
339 isDepthCurrent(
false), isHeightCurrent(
false) {}
353 assert(!Instr &&
"Setting SDNode of SUnit with MachineInstr!");
360 assert(!Instr &&
"Reading SDNode of SUnit with MachineInstr!");
371 assert(!Node &&
"Setting MachineInstr of SUnit with SDNode!");
378 assert(!Node &&
"Reading MachineInstr of SUnit with SDNode!");
390 unsigned TrueMemOrderLatency =
398 void removePred(
const SDep &D);
404 const_cast<SUnit *
>(
this)->ComputeDepth();
411 if (!isHeightCurrent)
412 const_cast<SUnit *
>(
this)->ComputeHeight();
419 void setDepthToAtLeast(
unsigned NewDepth);
424 void setHeightToAtLeast(
unsigned NewHeight);
428 void setDepthDirty();
432 void setHeightDirty();
436 for (
const SDep &Pred : Preds)
437 if (Pred.getSUnit() ==
N)
444 for (
const SDep &Succ : Succs)
445 if (Succ.getSUnit() ==
N)
451 return NumPredsLeft == 0;
454 return NumSuccsLeft == 0;
459 void biasCriticalPath();
461 void dumpAttributes()
const;
465 void ComputeHeight();
470 if (Dep != Other.Dep)
472 switch (Dep.getInt()) {
476 return Contents.Reg == Other.Contents.
Reg;
478 return Contents.OrdKind == Other.Contents.
OrdKind;
501 virtual void anchor();
503 unsigned CurCycle = 0;
511 virtual bool isBottomUp()
const = 0;
513 virtual void initNodes(std::vector<SUnit> &SUnits) = 0;
514 virtual void addNode(
const SUnit *SU) = 0;
515 virtual void updateNode(
const SUnit *SU) = 0;
516 virtual void releaseState() = 0;
518 virtual bool empty()
const = 0;
525 assert(!HasReadyFilter &&
"The ready filter must override isReady()");
529 virtual void push(
SUnit *U) = 0;
532 for (std::vector<SUnit *>::const_iterator
I = Nodes.begin(),
533 E = Nodes.end();
I !=
E; ++
I)
537 virtual SUnit *pop() = 0;
539 virtual void remove(
SUnit *SU) = 0;
571 static const bool StressSched =
false;
587 return getNodeDesc(SU->
getNode());
592 virtual void viewGraph();
594 virtual void dumpNode(
const SUnit &SU)
const = 0;
595 virtual void dump()
const = 0;
596 void dumpNodeName(
const SUnit &SU)
const;
599 virtual std::string getGraphNodeLabel(
const SUnit *SU)
const = 0;
602 virtual std::string getDAGName()
const = 0;
610 unsigned VerifyScheduledDAG(
bool isBottomUp);
614 void dumpNodeAll(
const SUnit &SU)
const;
630 return Operand == x.Operand;
635 return Node->
Preds[Operand].getSUnit();
657 return getSDep().isCtrl();
660 return getSDep().isArtificial();
663 return Node->
Preds[Operand];
682 return nodes_iterator(G->
SUnits.begin());
685 return nodes_iterator(G->
SUnits.end());
695 std::vector<SUnit> &SUnits;
699 std::vector<int> Index2Node;
701 std::vector<int> Node2Index;
708 void DFS(
const SUnit *SU,
int UpperBound,
bool& HasLoop);
712 void Shift(
BitVector& Visited,
int LowerBound,
int UpperBound);
715 void Allocate(
int n,
int index);
721 void InitDAGTopologicalSorting();
728 std::vector<int> GetSubGraph(
const SUnit &StartSU,
const SUnit &TargetSU,
732 bool IsReachable(
const SUnit *SU,
const SUnit *TargetSU);
735 bool WillCreateCycle(
SUnit *TargetSU,
SUnit *SU);
748 iterator
begin() {
return Index2Node.begin(); }
749 const_iterator
begin()
const {
return Index2Node.begin(); }
750 iterator
end() {
return Index2Node.end(); }
751 const_iterator
end()
const {
return Index2Node.end(); }
755 reverse_iterator
rbegin() {
return Index2Node.rbegin(); }
756 const_reverse_iterator
rbegin()
const {
return Index2Node.rbegin(); }
757 reverse_iterator
rend() {
return Index2Node.rend(); }
758 const_reverse_iterator
rend()
const {
return Index2Node.rend(); }
763 #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.
This class represents lattice values for constants.
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...
amdgpu Simplify well known AMD library false Value Value const Twine & Name
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()
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
This class describes a target machine that is implemented with the LLVM target-independent code gener...
SUnitIterator operator++(int)
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
void dump(const TargetRegisterInfo *TRI=nullptr) const
SUnitIterator ChildIteratorType
SUnitIterator & operator++()
SDep(SUnit *S, OrderKind kind)
const_iterator end() const
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
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.
static nodes_iterator nodes_end(ScheduleDAG *G)
bool isScheduleLow
True if preferable to schedule low.
const LLVMTargetMachine & TM
Target processor.
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.