14 #ifndef LLVM_CODEGEN_SCHEDULEDFS_H
15 #define LLVM_CODEGEN_SCHEDULEDFS_H
18 #include "llvm/Support/DataTypes.h"
25 class ScheduleDAGInstrs;
60 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
71 static const unsigned InvalidSubtreeID = ~0u;
83 NodeData(): InstrCount(0), SubtreeID(InvalidSubtreeID) {}
88 unsigned ParentTreeID;
89 unsigned SubInstrCount;
91 TreeData(): ParentTreeID(InvalidSubtreeID), SubInstrCount(0) {}
99 Connection(
unsigned tree,
unsigned level): TreeID(tree),
Level(level) {}
103 unsigned SubtreeLimit;
105 std::vector<NodeData> DFSNodeData;
108 SmallVector<TreeData, 16> DFSTreeData;
112 std::vector<SmallVector<Connection, 4> > SubtreeConnections;
116 std::vector<unsigned> SubtreeConnectLevels;
120 : IsBottomUp(IsBU), SubtreeLimit(lim) {}
128 bool empty()
const {
return DFSNodeData.empty(); }
134 SubtreeConnections.clear();
135 SubtreeConnectLevels.clear();
140 DFSNodeData.resize(NumSUnits);
149 return DFSNodeData[SU->
NodeNum].InstrCount;
155 return DFSTreeData[SubtreeID].SubInstrCount;
175 assert(SU->
NodeNum < DFSNodeData.size() &&
"New Node");
176 return DFSNodeData[SU->
NodeNum].SubtreeID;
184 return SubtreeConnectLevels[SubtreeID];
192 raw_ostream &
operator<<(raw_ostream &OS,
const ILPValue &Val);
unsigned getSubtreeLimit() const
Get the node cutoff before subtrees are considered significant.
void clear()
Clear the results.
unsigned getSubtreeLevel(unsigned SubtreeID) const
Get the connection level of a subtree.
Represent the ILP of the subDAG rooted at a DAG node.
unsigned getNumSubInstrs(unsigned SubtreeID) const
Get the number of instructions in the given subtree not including children.
bool operator>(ILPValue RHS) const
unsigned getNumSubtrees() const
The number of subtrees detected in this DAG.
Compute the values of each DAG node for various metrics during DFS.
bool operator<=(ILPValue RHS) const
ILPValue(unsigned count, unsigned length)
void resize(unsigned NumSUnits)
Initialize the result data with the size of the DAG.
bool operator>=(ILPValue RHS) const
bool operator<(ILPValue RHS) const
Internal state used to compute SchedDFSResult.
bool empty() const
Return true if this DFSResult is uninitialized.
void compute(ArrayRef< SUnit > SUnits)
Compute various metrics for the DAG with given roots.
ILPValue getILP(const SUnit *SU) const
Get the ILP value for a DAG node.
unsigned getDepth() const
unsigned getSubtreeID(const SUnit *SU) const
Get the ID of the subtree the given DAG node belongs to.
void print(raw_ostream &OS) const
unsigned getNumInstrs(const SUnit *SU) const
Get the number of instructions in the given subtree and its children.
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
SchedDFSResult(bool IsBU, unsigned lim)
void scheduleTree(unsigned SubtreeID)
Scheduler callback to update SubtreeConnectLevels when a tree is initially scheduled.
SUnit - Scheduling unit. This is a node in the scheduling DAG.