33 #ifndef LLVM_ADT_DEPTHFIRSTITERATOR_H
34 #define LLVM_ADT_DEPTHFIRSTITERATOR_H
47 template<
class SetType,
bool External>
53 template<
class SetType>
63 template<
class GraphT,
66 class df_iterator :
public std::iterator<std::forward_iterator_tag,
67 typename GT::NodeType, ptrdiff_t>,
69 typedef std::iterator<std::forward_iterator_tag,
73 typedef typename GT::ChildIteratorType ChildItTy;
79 std::vector<std::pair<PointerIntTy, ChildItTy> > VisitStack;
83 VisitStack.push_back(std::make_pair(
PointerIntTy(Node, 0),
84 GT::child_begin(Node)));
92 VisitStack.push_back(std::make_pair(
PointerIntTy(Node, 0),
93 GT::child_begin(Node)));
102 inline void toNext() {
104 std::pair<PointerIntTy, ChildItTy> &Top = VisitStack.back();
105 NodeType *Node = Top.first.getPointer();
106 ChildItTy &It = Top.second;
107 if (!Top.first.getInt()) {
109 It = GT::child_begin(Node);
113 while (It != GT::child_end(Node)) {
114 NodeType *Next = *It++;
116 if (Next && this->
Visited.insert(Next).second) {
118 VisitStack.push_back(std::make_pair(
PointerIntTy(Next, 0),
119 GT::child_begin(Next)));
125 VisitStack.pop_back();
126 }
while (!VisitStack.empty());
145 return VisitStack == x.VisitStack;
167 VisitStack.pop_back();
168 if (!VisitStack.empty())
184 return this->
Visited.count(Node) != 0;
194 return VisitStack[n].first.getPointer();
224 template <
class T,
class SetTy>
229 template <
class T,
class SetTy>
234 template <
class T,
class SetTy>
244 bool External =
false>
275 template <
class T,
class SetTy>
280 template <
class T,
class SetTy>
285 template <
class T,
class SetTy>
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
pointer operator*() const
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
iterator_range< idf_ext_iterator< T, SetTy > > inverse_depth_first_ext(const T &G, SetTy &S)
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
df_iterator & skipChildren()
Skips all children of the current node and traverses to next node.
static df_iterator end(const GraphT &G)
idf_iterator(const df_iterator< Inverse< T >, SetTy, External > &V)
idf_iterator< T > idf_begin(const T &G)
idf_iterator< T > idf_end(const T &G)
bool operator!=(const df_iterator &x) const
PointerIntPair - This class implements a pair of a pointer and small integer.
NodeType * operator->() const
df_ext_iterator< T, SetTy > df_ext_end(const T &G, SetTy &S)
df_iterator< T > df_end(const T &G)
idf_ext_iterator< T, SetTy > idf_ext_end(const T &G, SetTy &S)
iterator_range< df_ext_iterator< T, SetTy > > depth_first_ext(const T &G, SetTy &S)
df_ext_iterator< T, SetTy > df_ext_begin(const T &G, SetTy &S)
idf_ext_iterator(const idf_iterator< T, SetTy, true > &V)
static df_iterator begin(const GraphT &G)
idf_ext_iterator< T, SetTy > idf_ext_begin(const T &G, SetTy &S)
static df_iterator end(const GraphT &G, SetType &S)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
df_ext_iterator(const df_iterator< T, SetTy, true > &V)
iterator_range< idf_iterator< T > > inverse_depth_first(const T &G)
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
df_iterator operator++(int)
df_iterator_storage(const df_iterator_storage &S)
df_iterator< T > df_begin(const T &G)
A range adaptor for a pair of iterators.
df_iterator_storage(SetType &VSet)
iterator_range< df_iterator< T > > depth_first(const T &G)
df_iterator & operator++()
idf_ext_iterator(const df_iterator< Inverse< T >, SetTy, true > &V)
NodeType * getPath(unsigned n) const
getPath - Return the n'th node in the path from the entry node to the current node.
static df_iterator begin(const GraphT &G, SetType &S)
bool operator==(const df_iterator &x) const
unsigned getPathLength() const
getPathLength - Return the length of the path from the entry node to the current node, counting both nodes.
bool nodeVisited(NodeType *Node) const