16 #ifndef LLVM_CODEGEN_SCHEDULEDAG_H
17 #define LLVM_CODEGEN_SCHEDULEDAG_H
29 class MachineConstantPool;
30 class MachineFunction;
31 class MachineRegisterInfo;
33 struct MCSchedClassDesc;
34 class TargetRegisterInfo;
37 class TargetInstrInfo;
40 class TargetRegisterClass;
102 : Dep(S, kind), Contents() {
109 "SDep::Anti and SDep::Output must use a non-zero Reg!");
120 : Dep(S,
Order), Contents(), Latency(0) {
121 Contents.OrdKind = kind;
126 if (Dep != Other.Dep)
return false;
127 switch (Dep.getInt()) {
131 return Contents.Reg == Other.Contents.
Reg;
133 return Contents.OrdKind == Other.Contents.
OrdKind;
139 return overlaps(Other) && Latency == Other.Latency;
161 return Dep.getPointer();
225 "getReg called on non-register dependence edge!");
236 "setReg called on non-register dependence edge!");
238 "SDep::Anti edge cannot use the zero register!");
240 "SDep::Output edge cannot use the zero register!");
251 enum LLVM_ENUM_INT_TYPE(
unsigned) { BoundaryID = ~0u };
298 bool isDepthCurrent : 1;
299 bool isHeightCurrent : 1;
320 isDepthCurrent(
false), isHeightCurrent(
false), Depth(0), Height(0),
334 isDepthCurrent(
false), isHeightCurrent(
false), Depth(0), Height(0),
347 isDepthCurrent(
false), isHeightCurrent(
false), Depth(0), Height(0),
362 assert(!Instr &&
"Setting SDNode of SUnit with MachineInstr!");
369 assert(!Instr &&
"Reading SDNode of SUnit with MachineInstr!");
380 assert(!Node &&
"Setting MachineInstr of SUnit with SDNode!");
387 assert(!Node &&
"Reading MachineInstr of SUnit with SDNode!");
405 const_cast<SUnit *
>(
this)->ComputeDepth();
412 if (!isHeightCurrent)
413 const_cast<SUnit *
>(
this)->ComputeHeight();
439 for (
unsigned i = 0, e = (
unsigned)
Preds.size(); i != e; ++i)
440 if (
Preds[i].getSUnit() ==
N)
447 for (
unsigned i = 0, e = (
unsigned)
Succs.size(); i != e; ++i)
448 if (
Succs[i].getSUnit() ==
N)
470 void ComputeHeight();
482 virtual void anchor();
487 CurCycle(0), HasReadyFilter(rf) {}
492 virtual void initNodes(std::vector<SUnit> &SUnits) = 0;
497 virtual bool empty()
const = 0;
504 assert(!HasReadyFilter &&
"The ready filter must override isReady()");
510 for (std::vector<SUnit *>::const_iterator
I = Nodes.begin(),
511 E = Nodes.end();
I != E; ++
I)
517 virtual void remove(
SUnit *SU) = 0;
566 return getNodeDesc(SU->
getNode());
607 return Operand == x.Operand;
612 assert(I.Node==Node &&
"Cannot assign iterators to two different nodes!");
618 return Node->
Preds[Operand].getSUnit();
645 return Node->
Preds[Operand];
679 std::vector<SUnit> &SUnits;
683 std::vector<int> Index2Node;
685 std::vector<int> Node2Index;
692 void DFS(
const SUnit *SU,
int UpperBound,
bool& HasLoop);
696 void Shift(
BitVector& Visited,
int LowerBound,
int UpperBound);
699 void Allocate(
int n,
int index);
static nodes_iterator nodes_begin(ScheduleDAG *G)
Weak DAG edge linking a chain of clustered instrs.
bool isCtrl() const
isCtrl - 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
const SUnitIterator & operator=(const SUnitIterator &I)
unsigned OrdKind
Order - Additional information about Order dependencies.
bool isSucc(SUnit *N)
isSucc - Test if node N is a successor of this node.
virtual void updateNode(const SUnit *SU)=0
const_iterator end() const
MachineInstr * getInstr() const
void print(raw_ostream &O, const ScheduleDAG *G) const
virtual void push(SUnit *U)=0
const MCInstrDesc & getDesc() const
bool operator!=(const SUnitIterator &x) const
virtual std::string getGraphNodeLabel(const SUnit *SU) const =0
std::vector< int >::iterator iterator
void removePred(const SDep &D)
Kind
Kind - These are the different kinds of scheduling dependencies.
bool overlaps(const SDep &Other) const
Return true if the specified SDep is equivalent except for latency.
bool isAssignedRegDep() const
SmallVectorImpl< SDep >::iterator succ_iterator
const TargetRegisterClass * CopyDstRC
SUnit()
SUnit - Construct a placeholder SUnit.
bool isArtificial() const
SmallVector< SDep, 4 > Preds
virtual void viewGraph()
Out-of-line implementation with no arguments is handy for gdb.
std::vector< SUnit >::iterator nodes_iterator
A register anti-dependedence (aka WAR).
void dumpAll(const ScheduleDAG *G) const
unsigned getHeight() const
const SUnit * getNode() const
SmallVectorImpl< SDep >::iterator pred_iterator
virtual void unscheduledNode(SUnit *)
virtual void releaseState()=0
void setInstr(MachineInstr *MI)
#define llvm_unreachable(msg)
SmallVectorImpl< SDep >::const_iterator const_pred_iterator
Regular data dependence (aka true-dependence).
unsigned getCurCycle() const
virtual std::string getDAGName() const =0
getDAGLabel - Return a label for the region of code covered by the DAG.
void setCurCycle(unsigned Cycle)
void InitDAGTopologicalSorting()
SchedulingPriorityQueue(bool rf=false)
pointer operator*() const
A register output-dependence (aka WAW).
bool isPred(SUnit *N)
isPred - Test if node N is a predecessor of this node.
virtual bool isReady(SUnit *) const
bool isNormalMemory() const
bool operator==(const SDep &Other) const
void setDepthToAtLeast(unsigned NewDepth)
bool operator==(const SUnitIterator &x) const
void setHeightToAtLeast(unsigned NewHeight)
virtual void dump(ScheduleDAG *) const
reverse_iterator rbegin()
bool WillCreateCycle(SUnit *TargetSU, SUnit *SU)
WillCreateCycle - Return true if addPred(TargetSU, SU) creates a cycle.
void clearDAG()
clearDAG - clear the DAG state (between regions).
virtual void addCustomGraphFeatures(GraphWriter< ScheduleDAG * > &) const
virtual void addNode(const SUnit *SU)=0
virtual bool empty() const =0
pointer operator->() const
static SUnitIterator begin(SUnit *N)
unsigned getLatency() const
SUnitIterator operator++(int)
const MCSchedClassDesc * SchedClass
void RemovePred(SUnit *M, SUnit *N)
void push_all(const std::vector< SUnit * > &Nodes)
Sched::Preference SchedulingPref
Any other ordering dependency.
static SUnitIterator end(SUnit *N)
const SDep & getSDep() const
const_reverse_iterator rbegin() const
SUnitIterator ChildIteratorType
SUnitIterator & operator++()
SDep(SUnit *S, OrderKind kind)
An unknown scheduling barrier.
virtual bool isBottomUp() const =0
bool isCtrlDep() const
isCtrlDep - Test if this is not an SDep::Data dependence.
static NodeType * getEntryNode(SUnit *N)
Nonvolatile load/Store instructions that may alias.
const TargetRegisterClass * CopySrcRC
void setReg(unsigned Reg)
std::vector< int >::const_iterator const_iterator
bool IsReachable(const SUnit *SU, const SUnit *TargetSU)
IsReachable - Checks if SU is reachable from TargetSU.
void biasCriticalPath()
Order this node's predecessor edges such that the critical path edge occurs first.
virtual void scheduledNode(SUnit *)
ScheduleDAG(MachineFunction &mf)
SmallVectorImpl< SDep >::const_iterator const_succ_iterator
bool isBoundaryNode() const
Boundary nodes are placeholders for the boundary of the scheduling region.
unsigned getDepth() const
void setLatency(unsigned Lat)
setLatency - Set the latency for this edge.
unsigned VerifyScheduledDAG(bool isBottomUp)
unsigned getOperand() const
const TargetRegisterInfo * TRI
SUnit(SDNode *node, unsigned nodenum)
bool operator!=(const SDep &Other) const
std::reverse_iterator< const_iterator > reverse_iterator
bool hasReadyFilter() const
unsigned short NumRegDefsLeft
virtual ~SchedulingPriorityQueue()
Kind getKind() const
getKind - Return an enum value representing the kind of the dependence.
const TargetInstrInfo * TII
virtual bool tracksRegPressure() const
const_iterator begin() const
virtual void dumpNode(const SUnit *SU) const =0
bool addPred(const SDep &D, bool Required=true)
SUnit(MachineInstr *instr, unsigned nodenum)
SmallVector< SDep, 4 > Succs
bool isBottomReady() const
Arbitrary strong DAG edge (no real dependence).
void AddPred(SUnit *Y, SUnit *X)
static nodes_iterator nodes_end(ScheduleDAG *G)
static ChildIteratorType child_begin(NodeType *N)
static ChildIteratorType child_end(NodeType *N)
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml","ocaml 3.10-compatible collector")
const MCInstrDesc * getInstrDesc(const SUnit *SU) const
MachineRegisterInfo & MRI
std::vector< SUnit > SUnits
SDep(SUnit *S, Kind kind, unsigned Reg)
SDep - Construct an SDep with the specified values.
const_reverse_iterator rend() const
ScheduleDAGTopologicalSort(std::vector< SUnit > &SUnits, SUnit *ExitSU)
static RegisterPass< NVPTXAllocaHoisting > X("alloca-hoisting","Hoisting alloca instructions in non-entry ""blocks to the entry block")
void dump(const ScheduleDAG *G) const
SUnit - Scheduling unit. This is a node in the scheduling DAG.
Nonvolatile load/Store instructions that must alias.