16#ifndef LLVM_ADT_POSTORDERITERATOR_H
17#define LLVM_ADT_POSTORDERITERATOR_H
35 if (
Size < Data.size())
36 Data.resize(
Size,
false);
41 if (Idx >= Data.size())
43 bool Inserted = !Data[Idx];
45 return {std::nullopt, Inserted};
49template <
typename GraphT>
51 std::conditional_t<GraphHasNodeNumbers<GraphT>,
70template <
typename DerivedT,
typename GraphTraits>
73 using ChildItTy =
typename GraphTraits::ChildIteratorType;
86 :
Node(
Node), It(Children.begin()), End(Children.end()) {}
102 DerivedT *POT =
nullptr;
133 DerivedT *
derived() {
return static_cast<DerivedT *
>(
this); }
138 VisitStack.emplace_back(Start,
make_range(GraphTraits::child_begin(Start),
139 GraphTraits::child_end(Start)));
145 void traverseChild() {
147 auto &Entry = VisitStack.
back();
148 if (Entry.It == Entry.End)
150 NodeRef BB = *Entry.It++;
154 GraphTraits::child_end(BB)));
159 derived()->finishPostorder(VisitStack.back().Node);
160 VisitStack.pop_back();
161 if (VisitStack.empty())
164 return VisitStack.back().Node;
169 if (VisitStack.empty())
202template <
typename GraphT,
typename SetType = po_detail::DefaultSet<GraphT>>
205 GraphTraits<GraphT>> {
221 return Visited.insert(To).second;
229template <
typename GraphT,
typename SetType>
232 GraphTraits<GraphT>> {
243 return Visited.insert(To).second;
257template <
class T,
class SetType>
289template<
class GraphT,
class GT = GraphTraits<GraphT>>
291 using NodeRef =
typename GT::NodeRef;
296 void Initialize(
const GraphT &
G) {
This file defines the little GraphTraits<X> template class that should be specialized by classes that...
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
Post-order traversal of the graph starting at the root node using an external storage.
bool insertEdge(std::optional< NodeRef > From, NodeRef To)
PostOrderExtTraversal(const GraphT &G, SetType &S)
bool operator!=(const iterator &X) const
pointer operator->() const
bool operator==(const iterator &X) const
std::input_iterator_tag iterator_category
reference operator*() const
std::ptrdiff_t difference_type
friend class PostOrderTraversalBase
PostOrderTraversalBase()=default
bool insertEdge(std::optional< NodeRef > From, NodeRef To)
Add edge and return whether To should be visited.
void init(NodeRef Start)
Initialize post-order traversal at given start node.
void finishPostorder(NodeRef)
Callback just before the iterator moves to the next block.
Post-order traversal of a graph.
PostOrderTraversal()=default
Default constructor for an empty traversal.
bool insertEdge(std::optional< NodeRef > From, NodeRef To)
PostOrderTraversal(const GraphT &G)
Post-order traversal of the graph starting at the root node using an internal storage.
const_rpo_iterator end() const
const_rpo_iterator begin() const
ReversePostOrderTraversal(const GraphT &G)
typename VecTy::reverse_iterator rpo_iterator
typename VecTy::const_reverse_iterator const_rpo_iterator
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
reference emplace_back(ArgTypes &&... Args)
std::reverse_iterator< const_iterator > const_reverse_iterator
std::reverse_iterator< iterator > reverse_iterator
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A range adaptor for a pair of iterators.
std::pair< std::nullopt_t, bool > insert(NodeRef Node)
void reserve(size_t Size)
std::conditional_t< GraphHasNodeNumbers< GraphT >, NumberSet< typename GraphTraits< GraphT >::NodeRef >, SmallPtrSet< typename GraphTraits< GraphT >::NodeRef, 8 > > DefaultSet
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
auto inverse_post_order_ext(const T &G, SetType &S)
auto post_order_ext(const T &G, SetType &S)
auto post_order(const T &G)
Post-order traversal of a graph.
OutputIt copy(R &&Range, OutputIt Out)
typename GraphType::UnknownGraphTypeError NodeRef