15 #ifndef LLVM_CODEGEN_SCHEDULEDAG_H 16 #define LLVM_CODEGEN_SCHEDULEDAG_H 105 : Dep(S, kind), Contents() {
112 "SDep::Anti and SDep::Output must use a non-zero Reg!");
124 : Dep(S,
Order), Contents(), Latency(0) {
125 Contents.OrdKind = kind;
132 return overlaps(Other) && Latency == Other.Latency;
220 "getReg called on non-register dependence edge!");
230 "setReg called on non-register dependence edge!");
232 "SDep::Anti edge cannot use the zero register!");
234 "SDep::Output edge cannot use the zero register!");
244 enum :
unsigned { BoundaryID = ~0u };
264 unsigned NodeNum = BoundaryID;
265 unsigned NodeQueueId = 0;
266 unsigned NumPreds = 0;
267 unsigned NumSuccs = 0;
268 unsigned NumPredsLeft = 0;
269 unsigned NumSuccsLeft = 0;
270 unsigned WeakPredsLeft = 0;
271 unsigned WeakSuccsLeft = 0;
272 unsigned short NumRegDefsLeft = 0;
293 bool isDepthCurrent : 1;
294 bool isHeightCurrent : 1;
299 unsigned TopReadyCycle = 0;
300 unsigned BotReadyCycle = 0;
309 : Node(node), NodeNum(nodenum), isVRegCycle(
false), isCall(
false),
311 hasPhysRegUses(
false), hasPhysRegDefs(
false), hasPhysRegClobbers(
false),
314 isUnbuffered(
false), hasReservedResource(
false), isDepthCurrent(
false),
315 isHeightCurrent(
false) {}
320 : Instr(instr), NodeNum(nodenum), isVRegCycle(
false), isCall(
false),
322 hasPhysRegUses(
false), hasPhysRegDefs(
false), hasPhysRegClobbers(
false),
325 isUnbuffered(
false), hasReservedResource(
false), isDepthCurrent(
false),
326 isHeightCurrent(
false) {}
335 isDepthCurrent(
false), isHeightCurrent(
false) {}
349 assert(!Instr &&
"Setting SDNode of SUnit with MachineInstr!");
356 assert(!Instr &&
"Reading SDNode of SUnit with MachineInstr!");
367 assert(!Node &&
"Setting MachineInstr of SUnit with SDNode!");
374 assert(!Node &&
"Reading MachineInstr of SUnit with SDNode!");
386 unsigned TrueMemOrderLatency =
394 void removePred(
const SDep &D);
400 const_cast<SUnit *
>(
this)->ComputeDepth();
407 if (!isHeightCurrent)
408 const_cast<SUnit *
>(
this)->ComputeHeight();
415 void setDepthToAtLeast(
unsigned NewDepth);
420 void setHeightToAtLeast(
unsigned NewHeight);
424 void setDepthDirty();
428 void setHeightDirty();
432 for (
const SDep &Pred : Preds)
433 if (Pred.getSUnit() ==
N)
440 for (
const SDep &Succ : Succs)
441 if (Succ.getSUnit() ==
N)
447 return NumPredsLeft == 0;
450 return NumSuccsLeft == 0;
455 void biasCriticalPath();
457 void dumpAttributes()
const;
461 void ComputeHeight();
466 if (Dep != Other.Dep)
468 switch (Dep.getInt()) {
472 return Contents.Reg == Other.Contents.
Reg;
474 return Contents.OrdKind == Other.Contents.
OrdKind;
497 virtual void anchor();
499 unsigned CurCycle = 0;
507 virtual bool isBottomUp()
const = 0;
509 virtual void initNodes(std::vector<SUnit> &SUnits) = 0;
510 virtual void addNode(
const SUnit *SU) = 0;
511 virtual void updateNode(
const SUnit *SU) = 0;
512 virtual void releaseState() = 0;
514 virtual bool empty()
const = 0;
521 assert(!HasReadyFilter &&
"The ready filter must override isReady()");
528 for (std::vector<SUnit *>::const_iterator
I = Nodes.begin(),
529 E = Nodes.end();
I !=
E; ++
I)
533 virtual SUnit *pop() = 0;
535 virtual void remove(
SUnit *SU) = 0;
567 static const bool StressSched =
false;
583 return getNodeDesc(SU->
getNode());
588 virtual void viewGraph();
590 virtual void dumpNode(
const SUnit &SU)
const = 0;
591 virtual void dump()
const = 0;
592 void dumpNodeName(
const SUnit &SU)
const;
595 virtual std::string getGraphNodeLabel(
const SUnit *SU)
const = 0;
598 virtual std::string getDAGName()
const = 0;
606 unsigned VerifyScheduledDAG(
bool isBottomUp);
610 void dumpNodeAll(
const SUnit &SU)
const;
626 return Operand == x.Operand;
631 return Node->
Preds[Operand].getSUnit();
653 return getSDep().isCtrl();
656 return getSDep().isArtificial();
659 return Node->
Preds[Operand];
678 return nodes_iterator(G->
SUnits.begin());
681 return nodes_iterator(G->
SUnits.end());
691 std::vector<SUnit> &SUnits;
701 std::vector<int> Index2Node;
703 std::vector<int> Node2Index;
710 void DFS(
const SUnit *SU,
int UpperBound,
bool& HasLoop);
714 void Shift(
BitVector& Visited,
int LowerBound,
int UpperBound);
717 void Allocate(
int n,
int index);
728 void InitDAGTopologicalSorting();
735 std::vector<int> GetSubGraph(
const SUnit &StartSU,
const SUnit &TargetSU,
739 bool IsReachable(
const SUnit *SU,
const SUnit *TargetSU);
742 bool WillCreateCycle(
SUnit *TargetSU,
SUnit *SU);
763 iterator
begin() {
return Index2Node.begin(); }
764 const_iterator
begin()
const {
return Index2Node.begin(); }
765 iterator
end() {
return Index2Node.end(); }
766 const_iterator
end()
const {
return Index2Node.end(); }
770 reverse_iterator
rbegin() {
return Index2Node.rbegin(); }
771 const_reverse_iterator
rbegin()
const {
return Index2Node.rbegin(); }
772 reverse_iterator
rend() {
return Index2Node.rend(); }
773 const_reverse_iterator
rend()
const {
return Index2Node.rend(); }
778 #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.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
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...
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.
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 MarkDirty()
Mark the ordering as temporarily broken, after a new node has been added.
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.