32 #ifndef LLVM_ADT_DEPTHFIRSTITERATOR_H 33 #define LLVM_ADT_DEPTHFIRSTITERATOR_H 49 template<
class SetType,
bool External>
55 template<
class SetType>
68 template <
typename NodeRef,
unsigned SmallSize=8>
73 std::pair<iterator,bool>
insert(NodeRef
N) {
return BaseSet::insert(N); }
74 template <
typename IterT>
75 void insert(IterT Begin, IterT End) { BaseSet::insert(Begin,End); }
81 template <
class GraphT,
86 :
public std::iterator<std::forward_iterator_tag, typename GT::NodeRef>,
88 using super = std::iterator<std::forward_iterator_tag, typename GT::NodeRef>;
89 using NodeRef =
typename GT::NodeRef;
90 using ChildItTy =
typename GT::ChildIteratorType;
95 using StackElement = std::pair<NodeRef, Optional<ChildItTy>>;
98 std::vector<StackElement> VisitStack;
103 VisitStack.push_back(StackElement(Node,
None));
110 if (this->
Visited.insert(Node).second)
111 VisitStack.push_back(StackElement(Node,
None));
119 inline void toNext() {
121 NodeRef Node = VisitStack.back().first;
125 Opt.
emplace(GT::child_begin(Node));
130 while (*Opt != GT::child_end(Node)) {
131 NodeRef Next = *(*Opt)++;
133 if (this->
Visited.insert(Next).second) {
135 VisitStack.push_back(StackElement(Next,
None));
142 VisitStack.pop_back();
143 }
while (!VisitStack.empty());
162 return VisitStack == x.VisitStack;
166 const NodeRef &
operator*()
const {
return VisitStack.back().first; }
184 VisitStack.pop_back();
185 if (!VisitStack.empty())
201 return this->
Visited.count(Node) != 0;
210 NodeRef
getPath(
unsigned n)
const {
return VisitStack[n].first; }
232 template <class T, class SetTy = std::set<typename GraphTraits<T>::NodeRef>>
238 template <
class T,
class SetTy>
243 template <
class T,
class SetTy>
248 template <
class T,
class SetTy>
258 bool External =
false>
281 template <class T, class SetTy = std::set<typename GraphTraits<T>::NodeRef>>
289 template <
class T,
class SetTy>
294 template <
class T,
class SetTy>
299 template <
class T,
class SetTy>
307 #endif // LLVM_ADT_DEPTHFIRSTITERATOR_H NodeRef operator->() const
bool operator==(const df_iterator &x) const
This class represents lattice values for constants.
const NodeRef & operator*() const
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
void emplace(ArgTypes &&... Args)
Create a new object by constructing it in place with the given arguments.
void insert(IterT Begin, IterT End)
iterator_range< idf_ext_iterator< T, SetTy > > inverse_depth_first_ext(const T &G, SetTy &S)
block Block Frequency true
bool operator!=(const df_iterator &x) const
df_iterator & skipChildren()
Skips all children of the current node and traverses to next node.
NodeRef getPath(unsigned n) const
getPath - Return the n'th node in the path from the entry node to the current node.
static df_iterator end(const GraphT &G)
unsigned getPathLength() const
getPathLength - Return the length of the path from the entry node to the current node, counting both nodes.
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)
typename BaseSet::iterator iterator
SmallPtrSet< typename GraphTraits< std::conditional< IsConst, const BlockT, BlockT >::type * >::NodeRef, 8 > BaseSet
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)
typename super::pointer pointer
df_iterator_storage(const df_iterator_storage &S)
std::pair< iterator, bool > insert(NodeRef N)
df_iterator< T > df_begin(const T &G)
bool nodeVisited(NodeRef Node) const
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)
static df_iterator begin(const GraphT &G, SetType &S)