16 #ifndef LLVM_ADT_POSTORDERITERATOR_H
17 #define LLVM_ADT_POSTORDERITERATOR_H
53 template<
class SetType,
bool External>
58 template<
typename NodeType>
60 return Visited.insert(To);
64 template<
typename NodeType>
69 template<
class SetType>
79 template<
class NodeType>
83 template<
class NodeType>
87 template<
class GraphT,
89 bool ExtStorage =
false,
90 class GT = GraphTraits<GraphT> >
91 class po_iterator :
public std::iterator<std::forward_iterator_tag,
92 typename GT::NodeType, ptrdiff_t>,
94 typedef std::iterator<std::forward_iterator_tag,
97 typedef typename GT::ChildIteratorType ChildItTy;
101 std::vector<std::pair<NodeType *, ChildItTy> > VisitStack;
103 void traverseChild() {
104 while (VisitStack.back().second != GT::child_end(VisitStack.back().first)) {
105 NodeType *BB = *VisitStack.back().second++;
106 if (this->
insertEdge(VisitStack.back().first, BB)) {
108 VisitStack.push_back(std::make_pair(BB, GT::child_begin(BB)));
115 VisitStack.push_back(std::make_pair(BB, GT::child_begin(BB)));
123 VisitStack.push_back(std::make_pair(BB, GT::child_begin(BB)));
140 return _Self(GT::getEntryNode(G), S);
145 return VisitStack == x.VisitStack;
150 return VisitStack.back().first;
161 VisitStack.pop_back();
162 if (!VisitStack.empty())
168 _Self tmp = *
this; ++*
this;
return tmp;
186 template<
class T,
class SetType>
191 template<
class T,
class SetType>
199 bool External =
false>
225 template <
class T,
class SetType>
230 template <
class T,
class SetType>
258 template<
class GraphT,
class GT = GraphTraits<GraphT> >
261 std::vector<NodeType*> Blocks;
262 inline void Initialize(NodeType *BB) {
269 Initialize(GT::getEntryNode(G));
po_ext_iterator< T, SetType > po_ext_end(T G, SetType &S)
bool operator!=(const _Self &x) const
void finishPostorder(NodeType *BB)
static _Self begin(GraphT G)
ipo_ext_iterator(const ipo_iterator< T, SetType, true > &V)
ipo_ext_iterator(const po_iterator< Inverse< T >, SetType, true > &V)
po_ext_iterator(const po_iterator< T, SetType, true > &V)
ipo_iterator< T > ipo_begin(T G, bool Reverse=false)
ReversePostOrderTraversal(GraphT G)
po_iterator< T > po_begin(T G)
ipo_iterator< T > ipo_end(T G)
po_iterator_storage(const po_iterator_storage &S)
static _Self begin(GraphT G, SetType &S)
Default po_iterator_storage implementation with an internal set object.
po_iterator< GraphT, SetType, ExtStorage, GT > _Self
std::vector< NodeType * >::reverse_iterator rpo_iterator
NodeType * operator->() const
bool insertEdge(NodeType *From, NodeType *To)
bool operator==(const _Self &x) const
static _Self end(GraphT G, SetType &S)
bool insertEdge(NodeType *From, NodeType *To)
ipo_ext_iterator< T, SetType > ipo_ext_begin(T G, SetType &S)
po_iterator< T > po_end(T G)
ipo_ext_iterator< T, SetType > ipo_ext_end(T G, SetType &S)
std::reverse_iterator< const_iterator > reverse_iterator
po_iterator_storage(SetType &VSet)
po_ext_iterator< T, SetType > po_ext_begin(T G, SetType &S)
ipo_iterator(const po_iterator< Inverse< T >, SetType, External > &V)
static _Self end(GraphT G)
void finishPostorder(NodeType *BB)
pointer operator*() const