16 #ifndef LLVM_ADT_POSTORDERITERATOR_H
17 #define LLVM_ADT_POSTORDERITERATOR_H
54 template<
class SetType,
bool External>
59 template<
typename NodeType>
61 return Visited.insert(To).second;
65 template<
typename NodeType>
70 template<
class SetType>
81 return Visited.insert(To).second;
85 template<
class NodeType>
89 template<
class GraphT,
91 bool ExtStorage =
false,
92 class GT = GraphTraits<GraphT> >
93 class po_iterator :
public std::iterator<std::forward_iterator_tag,
94 typename GT::NodeType, ptrdiff_t>,
96 typedef std::iterator<std::forward_iterator_tag,
99 typedef typename GT::ChildIteratorType ChildItTy;
103 std::vector<std::pair<NodeType *, ChildItTy> > VisitStack;
105 void traverseChild() {
106 while (VisitStack.back().second != GT::child_end(VisitStack.back().first)) {
107 NodeType *BB = *VisitStack.back().second++;
108 if (this->
insertEdge(VisitStack.back().first, BB)) {
110 VisitStack.push_back(std::make_pair(BB, GT::child_begin(BB)));
117 VisitStack.push_back(std::make_pair(BB, GT::child_begin(BB)));
124 if (this->
insertEdge((NodeType*)
nullptr, BB)) {
125 VisitStack.push_back(std::make_pair(BB, GT::child_begin(BB)));
148 return VisitStack == x.VisitStack;
162 VisitStack.pop_back();
163 if (!VisitStack.empty())
193 template<
class T,
class SetType>
198 template<
class T,
class SetType>
203 template <
class T,
class SetType>
211 bool External =
false>
242 template <
class T,
class SetType>
247 template <
class T,
class SetType>
252 template <
class T,
class SetType>
253 iterator_range<ipo_ext_iterator<T, SetType>>
281 template<
class GraphT,
class GT = GraphTraits<GraphT> >
284 std::vector<NodeType*> Blocks;
285 void Initialize(NodeType *BB) {
289 typedef typename std::vector<NodeType*>::reverse_iterator
rpo_iterator;
po_iterator & operator++()
po_ext_iterator< T, SetType > po_ext_end(T G, SetType &S)
void finishPostorder(NodeType *BB)
static po_iterator end(GraphT G, SetType &S)
ipo_ext_iterator(const ipo_iterator< T, SetType, true > &V)
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
static po_iterator begin(GraphT G)
ipo_ext_iterator(const po_iterator< Inverse< T >, SetType, true > &V)
po_iterator operator++(int)
po_ext_iterator(const po_iterator< T, SetType, true > &V)
bool operator!=(const po_iterator &x) const
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
static po_iterator begin(GraphT G, SetType &S)
bool operator==(const po_iterator &x) const
ipo_iterator< T > ipo_end(const T &G)
ReversePostOrderTraversal(GraphT G)
ipo_ext_iterator< T, SetType > ipo_ext_begin(const T &G, SetType &S)
ipo_iterator< T > ipo_begin(const T &G, bool Reverse=false)
ipo_ext_iterator< T, SetType > ipo_ext_end(const T &G, SetType &S)
static po_iterator end(GraphT G)
po_iterator_storage(const po_iterator_storage &S)
Default po_iterator_storage implementation with an internal set object.
po_iterator< T > po_end(const T &G)
iterator_range< po_iterator< T > > post_order(const T &G)
std::vector< NodeType * >::reverse_iterator rpo_iterator
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
NodeType * operator->() const
bool insertEdge(NodeType *From, NodeType *To)
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
iterator_range< po_ext_iterator< T, SetType > > post_order_ext(const T &G, SetType &S)
bool insertEdge(NodeType *From, NodeType *To)
A range adaptor for a pair of iterators.
iterator_range< ipo_ext_iterator< T, SetType > > inverse_post_order_ext(const T &G, SetType &S)
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)
iterator_range< ipo_iterator< T > > inverse_post_order(const T &G, bool Reverse=false)
void finishPostorder(NodeType *BB)
pointer operator*() const
po_iterator< T > po_begin(const T &G)