10b57cec5SDimitry Andric //===- RegionIterator.h - Iterators to iteratate over Regions ---*- C++ -*-===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric // This file defines the iterators to iterate over the elements of a Region.
90b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
100b57cec5SDimitry Andric
110b57cec5SDimitry Andric #ifndef LLVM_ANALYSIS_REGIONITERATOR_H
120b57cec5SDimitry Andric #define LLVM_ANALYSIS_REGIONITERATOR_H
130b57cec5SDimitry Andric
140b57cec5SDimitry Andric #include "llvm/ADT/DepthFirstIterator.h"
150b57cec5SDimitry Andric #include "llvm/ADT/GraphTraits.h"
160b57cec5SDimitry Andric #include "llvm/ADT/PointerIntPair.h"
170b57cec5SDimitry Andric #include "llvm/Analysis/RegionInfo.h"
180b57cec5SDimitry Andric #include <cassert>
190b57cec5SDimitry Andric #include <iterator>
200b57cec5SDimitry Andric #include <type_traits>
210b57cec5SDimitry Andric
220b57cec5SDimitry Andric namespace llvm {
230b57cec5SDimitry Andric
240b57cec5SDimitry Andric class BasicBlock;
25*81ad6265SDimitry Andric class RegionInfo;
260b57cec5SDimitry Andric
270b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
280b57cec5SDimitry Andric /// Hierarchical RegionNode successor iterator.
290b57cec5SDimitry Andric ///
300b57cec5SDimitry Andric /// This iterator iterates over all successors of a RegionNode.
310b57cec5SDimitry Andric ///
320b57cec5SDimitry Andric /// For a BasicBlock RegionNode it skips all BasicBlocks that are not part of
330b57cec5SDimitry Andric /// the parent Region. Furthermore for BasicBlocks that start a subregion, a
340b57cec5SDimitry Andric /// RegionNode representing the subregion is returned.
350b57cec5SDimitry Andric ///
360b57cec5SDimitry Andric /// For a subregion RegionNode there is just one successor. The RegionNode
370b57cec5SDimitry Andric /// representing the exit of the subregion.
38fe6060f1SDimitry Andric template <class NodeRef, class BlockT, class RegionT> class RNSuccIterator {
39fe6060f1SDimitry Andric public:
40fe6060f1SDimitry Andric using iterator_category = std::forward_iterator_tag;
41fe6060f1SDimitry Andric using value_type = NodeRef;
42fe6060f1SDimitry Andric using difference_type = std::ptrdiff_t;
43fe6060f1SDimitry Andric using pointer = value_type *;
44fe6060f1SDimitry Andric using reference = value_type &;
45fe6060f1SDimitry Andric
46fe6060f1SDimitry Andric private:
470b57cec5SDimitry Andric using BlockTraits = GraphTraits<BlockT *>;
480b57cec5SDimitry Andric using SuccIterTy = typename BlockTraits::ChildIteratorType;
490b57cec5SDimitry Andric
500b57cec5SDimitry Andric // The iterator works in two modes, bb mode or region mode.
510b57cec5SDimitry Andric enum ItMode {
520b57cec5SDimitry Andric // In BB mode it returns all successors of this BasicBlock as its
530b57cec5SDimitry Andric // successors.
540b57cec5SDimitry Andric ItBB,
550b57cec5SDimitry Andric // In region mode there is only one successor, thats the regionnode mapping
560b57cec5SDimitry Andric // to the exit block of the regionnode
570b57cec5SDimitry Andric ItRgBegin, // At the beginning of the regionnode successor.
580b57cec5SDimitry Andric ItRgEnd // At the end of the regionnode successor.
590b57cec5SDimitry Andric };
600b57cec5SDimitry Andric
610b57cec5SDimitry Andric static_assert(std::is_pointer<NodeRef>::value,
620b57cec5SDimitry Andric "FIXME: Currently RNSuccIterator only supports NodeRef as "
630b57cec5SDimitry Andric "pointers due to the use of pointer-specific data structures "
640b57cec5SDimitry Andric "(e.g. PointerIntPair and SmallPtrSet) internally. Generalize "
650b57cec5SDimitry Andric "it to support non-pointer types");
660b57cec5SDimitry Andric
670b57cec5SDimitry Andric // Use two bit to represent the mode iterator.
680b57cec5SDimitry Andric PointerIntPair<NodeRef, 2, ItMode> Node;
690b57cec5SDimitry Andric
700b57cec5SDimitry Andric // The block successor iterator.
710b57cec5SDimitry Andric SuccIterTy BItor;
720b57cec5SDimitry Andric
730b57cec5SDimitry Andric // advanceRegionSucc - A region node has only one successor. It reaches end
740b57cec5SDimitry Andric // once we advance it.
advanceRegionSucc()750b57cec5SDimitry Andric void advanceRegionSucc() {
760b57cec5SDimitry Andric assert(Node.getInt() == ItRgBegin && "Cannot advance region successor!");
770b57cec5SDimitry Andric Node.setInt(ItRgEnd);
780b57cec5SDimitry Andric }
790b57cec5SDimitry Andric
getNode()800b57cec5SDimitry Andric NodeRef getNode() const { return Node.getPointer(); }
810b57cec5SDimitry Andric
820b57cec5SDimitry Andric // isRegionMode - Is the current iterator in region mode?
isRegionMode()830b57cec5SDimitry Andric bool isRegionMode() const { return Node.getInt() != ItBB; }
840b57cec5SDimitry Andric
850b57cec5SDimitry Andric // Get the immediate successor. This function may return a Basic Block
860b57cec5SDimitry Andric // RegionNode or a subregion RegionNode.
getISucc(BlockT * BB)870b57cec5SDimitry Andric NodeRef getISucc(BlockT *BB) const {
880b57cec5SDimitry Andric NodeRef succ;
890b57cec5SDimitry Andric succ = getNode()->getParent()->getNode(BB);
900b57cec5SDimitry Andric assert(succ && "BB not in Region or entered subregion!");
910b57cec5SDimitry Andric return succ;
920b57cec5SDimitry Andric }
930b57cec5SDimitry Andric
940b57cec5SDimitry Andric // getRegionSucc - Return the successor basic block of a SubRegion RegionNode.
getRegionSucc()950b57cec5SDimitry Andric inline BlockT* getRegionSucc() const {
960b57cec5SDimitry Andric assert(Node.getInt() == ItRgBegin && "Cannot get the region successor!");
970b57cec5SDimitry Andric return getNode()->template getNodeAs<RegionT>()->getExit();
980b57cec5SDimitry Andric }
990b57cec5SDimitry Andric
1000b57cec5SDimitry Andric // isExit - Is this the exit BB of the Region?
isExit(BlockT * BB)1010b57cec5SDimitry Andric inline bool isExit(BlockT* BB) const {
1020b57cec5SDimitry Andric return getNode()->getParent()->getExit() == BB;
1030b57cec5SDimitry Andric }
1040b57cec5SDimitry Andric
1050b57cec5SDimitry Andric public:
1060b57cec5SDimitry Andric using Self = RNSuccIterator<NodeRef, BlockT, RegionT>;
1070b57cec5SDimitry Andric
1080b57cec5SDimitry Andric /// Create begin iterator of a RegionNode.
RNSuccIterator(NodeRef node)1090b57cec5SDimitry Andric inline RNSuccIterator(NodeRef node)
1100b57cec5SDimitry Andric : Node(node, node->isSubRegion() ? ItRgBegin : ItBB),
1110b57cec5SDimitry Andric BItor(BlockTraits::child_begin(node->getEntry())) {
1120b57cec5SDimitry Andric // Skip the exit block
1130b57cec5SDimitry Andric if (!isRegionMode())
1140b57cec5SDimitry Andric while (BlockTraits::child_end(node->getEntry()) != BItor && isExit(*BItor))
1150b57cec5SDimitry Andric ++BItor;
1160b57cec5SDimitry Andric
1170b57cec5SDimitry Andric if (isRegionMode() && isExit(getRegionSucc()))
1180b57cec5SDimitry Andric advanceRegionSucc();
1190b57cec5SDimitry Andric }
1200b57cec5SDimitry Andric
1210b57cec5SDimitry Andric /// Create an end iterator.
RNSuccIterator(NodeRef node,bool)1220b57cec5SDimitry Andric inline RNSuccIterator(NodeRef node, bool)
1230b57cec5SDimitry Andric : Node(node, node->isSubRegion() ? ItRgEnd : ItBB),
1240b57cec5SDimitry Andric BItor(BlockTraits::child_end(node->getEntry())) {}
1250b57cec5SDimitry Andric
1260b57cec5SDimitry Andric inline bool operator==(const Self& x) const {
1270b57cec5SDimitry Andric assert(isRegionMode() == x.isRegionMode() && "Broken iterator!");
1280b57cec5SDimitry Andric if (isRegionMode())
1290b57cec5SDimitry Andric return Node.getInt() == x.Node.getInt();
1300b57cec5SDimitry Andric else
1310b57cec5SDimitry Andric return BItor == x.BItor;
1320b57cec5SDimitry Andric }
1330b57cec5SDimitry Andric
1340b57cec5SDimitry Andric inline bool operator!=(const Self& x) const { return !operator==(x); }
1350b57cec5SDimitry Andric
1360b57cec5SDimitry Andric inline value_type operator*() const {
1370b57cec5SDimitry Andric BlockT *BB = isRegionMode() ? getRegionSucc() : *BItor;
1380b57cec5SDimitry Andric assert(!isExit(BB) && "Iterator out of range!");
1390b57cec5SDimitry Andric return getISucc(BB);
1400b57cec5SDimitry Andric }
1410b57cec5SDimitry Andric
1420b57cec5SDimitry Andric inline Self& operator++() {
1430b57cec5SDimitry Andric if(isRegionMode()) {
1440b57cec5SDimitry Andric // The Region only has 1 successor.
1450b57cec5SDimitry Andric advanceRegionSucc();
1460b57cec5SDimitry Andric } else {
1470b57cec5SDimitry Andric // Skip the exit.
1480b57cec5SDimitry Andric do
1490b57cec5SDimitry Andric ++BItor;
1500b57cec5SDimitry Andric while (BItor != BlockTraits::child_end(getNode()->getEntry())
1510b57cec5SDimitry Andric && isExit(*BItor));
1520b57cec5SDimitry Andric }
1530b57cec5SDimitry Andric return *this;
1540b57cec5SDimitry Andric }
1550b57cec5SDimitry Andric
1560b57cec5SDimitry Andric inline Self operator++(int) {
1570b57cec5SDimitry Andric Self tmp = *this;
1580b57cec5SDimitry Andric ++*this;
1590b57cec5SDimitry Andric return tmp;
1600b57cec5SDimitry Andric }
1610b57cec5SDimitry Andric };
1620b57cec5SDimitry Andric
1630b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
1640b57cec5SDimitry Andric /// Flat RegionNode iterator.
1650b57cec5SDimitry Andric ///
1660b57cec5SDimitry Andric /// The Flat Region iterator will iterate over all BasicBlock RegionNodes that
1670b57cec5SDimitry Andric /// are contained in the Region and its subregions. This is close to a virtual
1680b57cec5SDimitry Andric /// control flow graph of the Region.
1690b57cec5SDimitry Andric template <class NodeRef, class BlockT, class RegionT>
170fe6060f1SDimitry Andric class RNSuccIterator<FlatIt<NodeRef>, BlockT, RegionT> {
1710b57cec5SDimitry Andric using BlockTraits = GraphTraits<BlockT *>;
1720b57cec5SDimitry Andric using SuccIterTy = typename BlockTraits::ChildIteratorType;
1730b57cec5SDimitry Andric
1740b57cec5SDimitry Andric NodeRef Node;
1750b57cec5SDimitry Andric SuccIterTy Itor;
1760b57cec5SDimitry Andric
1770b57cec5SDimitry Andric public:
178fe6060f1SDimitry Andric using iterator_category = std::forward_iterator_tag;
179fe6060f1SDimitry Andric using value_type = NodeRef;
180fe6060f1SDimitry Andric using difference_type = std::ptrdiff_t;
181fe6060f1SDimitry Andric using pointer = value_type *;
182fe6060f1SDimitry Andric using reference = value_type &;
183fe6060f1SDimitry Andric
1840b57cec5SDimitry Andric using Self = RNSuccIterator<FlatIt<NodeRef>, BlockT, RegionT>;
1850b57cec5SDimitry Andric
1860b57cec5SDimitry Andric /// Create the iterator from a RegionNode.
1870b57cec5SDimitry Andric ///
1880b57cec5SDimitry Andric /// Note that the incoming node must be a bb node, otherwise it will trigger
1890b57cec5SDimitry Andric /// an assertion when we try to get a BasicBlock.
RNSuccIterator(NodeRef node)1900b57cec5SDimitry Andric inline RNSuccIterator(NodeRef node)
1910b57cec5SDimitry Andric : Node(node), Itor(BlockTraits::child_begin(node->getEntry())) {
1920b57cec5SDimitry Andric assert(!Node->isSubRegion() &&
1930b57cec5SDimitry Andric "Subregion node not allowed in flat iterating mode!");
1940b57cec5SDimitry Andric assert(Node->getParent() && "A BB node must have a parent!");
1950b57cec5SDimitry Andric
1960b57cec5SDimitry Andric // Skip the exit block of the iterating region.
1970b57cec5SDimitry Andric while (BlockTraits::child_end(Node->getEntry()) != Itor &&
1980b57cec5SDimitry Andric Node->getParent()->getExit() == *Itor)
1990b57cec5SDimitry Andric ++Itor;
2000b57cec5SDimitry Andric }
2010b57cec5SDimitry Andric
2020b57cec5SDimitry Andric /// Create an end iterator
RNSuccIterator(NodeRef node,bool)2030b57cec5SDimitry Andric inline RNSuccIterator(NodeRef node, bool)
2040b57cec5SDimitry Andric : Node(node), Itor(BlockTraits::child_end(node->getEntry())) {
2050b57cec5SDimitry Andric assert(!Node->isSubRegion() &&
2060b57cec5SDimitry Andric "Subregion node not allowed in flat iterating mode!");
2070b57cec5SDimitry Andric }
2080b57cec5SDimitry Andric
2090b57cec5SDimitry Andric inline bool operator==(const Self& x) const {
2100b57cec5SDimitry Andric assert(Node->getParent() == x.Node->getParent()
2110b57cec5SDimitry Andric && "Cannot compare iterators of different regions!");
2120b57cec5SDimitry Andric
2130b57cec5SDimitry Andric return Itor == x.Itor && Node == x.Node;
2140b57cec5SDimitry Andric }
2150b57cec5SDimitry Andric
2160b57cec5SDimitry Andric inline bool operator!=(const Self& x) const { return !operator==(x); }
2170b57cec5SDimitry Andric
2180b57cec5SDimitry Andric inline value_type operator*() const {
2190b57cec5SDimitry Andric BlockT *BB = *Itor;
2200b57cec5SDimitry Andric
2210b57cec5SDimitry Andric // Get the iterating region.
2220b57cec5SDimitry Andric RegionT *Parent = Node->getParent();
2230b57cec5SDimitry Andric
2240b57cec5SDimitry Andric // The only case that the successor reaches out of the region is it reaches
2250b57cec5SDimitry Andric // the exit of the region.
2260b57cec5SDimitry Andric assert(Parent->getExit() != BB && "iterator out of range!");
2270b57cec5SDimitry Andric
2280b57cec5SDimitry Andric return Parent->getBBNode(BB);
2290b57cec5SDimitry Andric }
2300b57cec5SDimitry Andric
2310b57cec5SDimitry Andric inline Self& operator++() {
2320b57cec5SDimitry Andric // Skip the exit block of the iterating region.
2330b57cec5SDimitry Andric do
2340b57cec5SDimitry Andric ++Itor;
2350b57cec5SDimitry Andric while (Itor != succ_end(Node->getEntry())
2360b57cec5SDimitry Andric && Node->getParent()->getExit() == *Itor);
2370b57cec5SDimitry Andric
2380b57cec5SDimitry Andric return *this;
2390b57cec5SDimitry Andric }
2400b57cec5SDimitry Andric
2410b57cec5SDimitry Andric inline Self operator++(int) {
2420b57cec5SDimitry Andric Self tmp = *this;
2430b57cec5SDimitry Andric ++*this;
2440b57cec5SDimitry Andric return tmp;
2450b57cec5SDimitry Andric }
2460b57cec5SDimitry Andric };
2470b57cec5SDimitry Andric
2480b57cec5SDimitry Andric template <class NodeRef, class BlockT, class RegionT>
succ_begin(NodeRef Node)2490b57cec5SDimitry Andric inline RNSuccIterator<NodeRef, BlockT, RegionT> succ_begin(NodeRef Node) {
2500b57cec5SDimitry Andric return RNSuccIterator<NodeRef, BlockT, RegionT>(Node);
2510b57cec5SDimitry Andric }
2520b57cec5SDimitry Andric
2530b57cec5SDimitry Andric template <class NodeRef, class BlockT, class RegionT>
succ_end(NodeRef Node)2540b57cec5SDimitry Andric inline RNSuccIterator<NodeRef, BlockT, RegionT> succ_end(NodeRef Node) {
2550b57cec5SDimitry Andric return RNSuccIterator<NodeRef, BlockT, RegionT>(Node, true);
2560b57cec5SDimitry Andric }
2570b57cec5SDimitry Andric
2580b57cec5SDimitry Andric //===--------------------------------------------------------------------===//
2590b57cec5SDimitry Andric // RegionNode GraphTraits specialization so the bbs in the region can be
2600b57cec5SDimitry Andric // iterate by generic graph iterators.
2610b57cec5SDimitry Andric //
2620b57cec5SDimitry Andric // NodeT can either be region node or const region node, otherwise child_begin
2630b57cec5SDimitry Andric // and child_end fail.
2640b57cec5SDimitry Andric
2650b57cec5SDimitry Andric #define RegionNodeGraphTraits(NodeT, BlockT, RegionT) \
2660b57cec5SDimitry Andric template <> struct GraphTraits<NodeT *> { \
2670b57cec5SDimitry Andric using NodeRef = NodeT *; \
2680b57cec5SDimitry Andric using ChildIteratorType = RNSuccIterator<NodeRef, BlockT, RegionT>; \
2690b57cec5SDimitry Andric static NodeRef getEntryNode(NodeRef N) { return N; } \
2700b57cec5SDimitry Andric static inline ChildIteratorType child_begin(NodeRef N) { \
2710b57cec5SDimitry Andric return RNSuccIterator<NodeRef, BlockT, RegionT>(N); \
2720b57cec5SDimitry Andric } \
2730b57cec5SDimitry Andric static inline ChildIteratorType child_end(NodeRef N) { \
2740b57cec5SDimitry Andric return RNSuccIterator<NodeRef, BlockT, RegionT>(N, true); \
2750b57cec5SDimitry Andric } \
2760b57cec5SDimitry Andric }; \
2770b57cec5SDimitry Andric template <> struct GraphTraits<FlatIt<NodeT *>> { \
2780b57cec5SDimitry Andric using NodeRef = NodeT *; \
2790b57cec5SDimitry Andric using ChildIteratorType = \
2800b57cec5SDimitry Andric RNSuccIterator<FlatIt<NodeRef>, BlockT, RegionT>; \
2810b57cec5SDimitry Andric static NodeRef getEntryNode(NodeRef N) { return N; } \
2820b57cec5SDimitry Andric static inline ChildIteratorType child_begin(NodeRef N) { \
2830b57cec5SDimitry Andric return RNSuccIterator<FlatIt<NodeRef>, BlockT, RegionT>(N); \
2840b57cec5SDimitry Andric } \
2850b57cec5SDimitry Andric static inline ChildIteratorType child_end(NodeRef N) { \
2860b57cec5SDimitry Andric return RNSuccIterator<FlatIt<NodeRef>, BlockT, RegionT>(N, true); \
2870b57cec5SDimitry Andric } \
2880b57cec5SDimitry Andric }
2890b57cec5SDimitry Andric
2900b57cec5SDimitry Andric #define RegionGraphTraits(RegionT, NodeT) \
2910b57cec5SDimitry Andric template <> struct GraphTraits<RegionT *> : public GraphTraits<NodeT *> { \
2920b57cec5SDimitry Andric using nodes_iterator = df_iterator<NodeRef>; \
2930b57cec5SDimitry Andric static NodeRef getEntryNode(RegionT *R) { \
2940b57cec5SDimitry Andric return R->getNode(R->getEntry()); \
2950b57cec5SDimitry Andric } \
2960b57cec5SDimitry Andric static nodes_iterator nodes_begin(RegionT *R) { \
2970b57cec5SDimitry Andric return nodes_iterator::begin(getEntryNode(R)); \
2980b57cec5SDimitry Andric } \
2990b57cec5SDimitry Andric static nodes_iterator nodes_end(RegionT *R) { \
3000b57cec5SDimitry Andric return nodes_iterator::end(getEntryNode(R)); \
3010b57cec5SDimitry Andric } \
3020b57cec5SDimitry Andric }; \
3030b57cec5SDimitry Andric template <> \
3040b57cec5SDimitry Andric struct GraphTraits<FlatIt<RegionT *>> \
3050b57cec5SDimitry Andric : public GraphTraits<FlatIt<NodeT *>> { \
3060b57cec5SDimitry Andric using nodes_iterator = \
3070b57cec5SDimitry Andric df_iterator<NodeRef, df_iterator_default_set<NodeRef>, false, \
3080b57cec5SDimitry Andric GraphTraits<FlatIt<NodeRef>>>; \
3090b57cec5SDimitry Andric static NodeRef getEntryNode(RegionT *R) { \
3100b57cec5SDimitry Andric return R->getBBNode(R->getEntry()); \
3110b57cec5SDimitry Andric } \
3120b57cec5SDimitry Andric static nodes_iterator nodes_begin(RegionT *R) { \
3130b57cec5SDimitry Andric return nodes_iterator::begin(getEntryNode(R)); \
3140b57cec5SDimitry Andric } \
3150b57cec5SDimitry Andric static nodes_iterator nodes_end(RegionT *R) { \
3160b57cec5SDimitry Andric return nodes_iterator::end(getEntryNode(R)); \
3170b57cec5SDimitry Andric } \
3180b57cec5SDimitry Andric }
3190b57cec5SDimitry Andric
3200b57cec5SDimitry Andric RegionNodeGraphTraits(RegionNode, BasicBlock, Region);
3210b57cec5SDimitry Andric RegionNodeGraphTraits(const RegionNode, BasicBlock, Region);
3220b57cec5SDimitry Andric
3230b57cec5SDimitry Andric RegionGraphTraits(Region, RegionNode);
3240b57cec5SDimitry Andric RegionGraphTraits(const Region, const RegionNode);
3250b57cec5SDimitry Andric
3260b57cec5SDimitry Andric template <> struct GraphTraits<RegionInfo*>
3270b57cec5SDimitry Andric : public GraphTraits<FlatIt<RegionNode*>> {
3280b57cec5SDimitry Andric using nodes_iterator =
3290b57cec5SDimitry Andric df_iterator<NodeRef, df_iterator_default_set<NodeRef>, false,
3300b57cec5SDimitry Andric GraphTraits<FlatIt<NodeRef>>>;
3310b57cec5SDimitry Andric
3320b57cec5SDimitry Andric static NodeRef getEntryNode(RegionInfo *RI) {
3330b57cec5SDimitry Andric return GraphTraits<FlatIt<Region*>>::getEntryNode(RI->getTopLevelRegion());
3340b57cec5SDimitry Andric }
3350b57cec5SDimitry Andric
3360b57cec5SDimitry Andric static nodes_iterator nodes_begin(RegionInfo* RI) {
3370b57cec5SDimitry Andric return nodes_iterator::begin(getEntryNode(RI));
3380b57cec5SDimitry Andric }
3390b57cec5SDimitry Andric
3400b57cec5SDimitry Andric static nodes_iterator nodes_end(RegionInfo *RI) {
3410b57cec5SDimitry Andric return nodes_iterator::end(getEntryNode(RI));
3420b57cec5SDimitry Andric }
3430b57cec5SDimitry Andric };
3440b57cec5SDimitry Andric
3450b57cec5SDimitry Andric template <> struct GraphTraits<RegionInfoPass*>
3460b57cec5SDimitry Andric : public GraphTraits<RegionInfo *> {
3470b57cec5SDimitry Andric using nodes_iterator =
3480b57cec5SDimitry Andric df_iterator<NodeRef, df_iterator_default_set<NodeRef>, false,
3490b57cec5SDimitry Andric GraphTraits<FlatIt<NodeRef>>>;
3500b57cec5SDimitry Andric
3510b57cec5SDimitry Andric static NodeRef getEntryNode(RegionInfoPass *RI) {
3520b57cec5SDimitry Andric return GraphTraits<RegionInfo*>::getEntryNode(&RI->getRegionInfo());
3530b57cec5SDimitry Andric }
3540b57cec5SDimitry Andric
3550b57cec5SDimitry Andric static nodes_iterator nodes_begin(RegionInfoPass* RI) {
3560b57cec5SDimitry Andric return GraphTraits<RegionInfo*>::nodes_begin(&RI->getRegionInfo());
3570b57cec5SDimitry Andric }
3580b57cec5SDimitry Andric
3590b57cec5SDimitry Andric static nodes_iterator nodes_end(RegionInfoPass *RI) {
3600b57cec5SDimitry Andric return GraphTraits<RegionInfo*>::nodes_end(&RI->getRegionInfo());
3610b57cec5SDimitry Andric }
3620b57cec5SDimitry Andric };
3630b57cec5SDimitry Andric
3640b57cec5SDimitry Andric } // end namespace llvm
3650b57cec5SDimitry Andric
3660b57cec5SDimitry Andric #endif // LLVM_ANALYSIS_REGIONITERATOR_H
367