33 #ifndef LLVM_ADT_DEPTHFIRSTITERATOR_H 34 #define LLVM_ADT_DEPTHFIRSTITERATOR_H 50 template<
class SetType,
bool External>
56 template<
class SetType>
69 template <
typename NodeRef,
unsigned SmallSize=8>
74 std::pair<iterator,bool>
insert(NodeRef
N) {
return BaseSet::insert(N); }
75 template <
typename IterT>
76 void insert(IterT Begin, IterT End) { BaseSet::insert(Begin,End); }
82 template <
class GraphT,
87 :
public std::iterator<std::forward_iterator_tag, typename GT::NodeRef>,
89 using super = std::iterator<std::forward_iterator_tag, typename GT::NodeRef>;
90 using NodeRef =
typename GT::NodeRef;
91 using ChildItTy =
typename GT::ChildIteratorType;
96 using StackElement = std::pair<NodeRef, Optional<ChildItTy>>;
99 std::vector<StackElement> VisitStack;
104 VisitStack.push_back(StackElement(Node,
None));
111 if (this->
Visited.insert(Node).second)
112 VisitStack.push_back(StackElement(Node,
None));
120 inline void toNext() {
122 NodeRef Node = VisitStack.back().first;
126 Opt.
emplace(GT::child_begin(Node));
131 while (*Opt != GT::child_end(Node)) {
132 NodeRef Next = *(*Opt)++;
134 if (this->
Visited.insert(Next).second) {
136 VisitStack.push_back(StackElement(Next,
None));
143 VisitStack.pop_back();
144 }
while (!VisitStack.empty());
163 return VisitStack == x.VisitStack;
167 const NodeRef &
operator*()
const {
return VisitStack.back().first; }
185 VisitStack.pop_back();
186 if (!VisitStack.empty())
202 return this->
Visited.count(Node) != 0;
211 NodeRef
getPath(
unsigned n)
const {
return VisitStack[n].first; }
233 template <class T, class SetTy = std::set<typename GraphTraits<T>::NodeRef>>
239 template <
class T,
class SetTy>
244 template <
class T,
class SetTy>
249 template <
class T,
class SetTy>
259 bool External =
false>
282 template <class T, class SetTy = std::set<typename GraphTraits<T>::NodeRef>>
290 template <
class T,
class SetTy>
295 template <
class T,
class SetTy>
300 template <
class T,
class SetTy>
308 #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)