29 template <
class Ptr,
class USE_iterator>
30 class PredIterator :
public std::iterator<std::forward_iterator_tag,
31 Ptr, ptrdiff_t, Ptr*, Ptr*> {
32 typedef std::iterator<std::forward_iterator_tag, Ptr, ptrdiff_t, Ptr*,
37 inline void advancePastNonTerminators() {
39 while (!It.atEnd() && !isa<TerminatorInst>(*It))
49 advancePastNonTerminators();
57 assert(!It.atEnd() &&
"pred_iterator out of range!");
58 return cast<TerminatorInst>(*It)->getParent();
63 assert(!It.atEnd() &&
"pred_iterator out of range!");
64 ++It; advancePastNonTerminators();
69 Self tmp = *
this; ++*
this;
return tmp;
75 return It.getOperandNo();
113 template <
class Term_,
class BB_>
114 class SuccIterator :
public std::iterator<std::random_access_iterator_tag, BB_,
116 typedef std::iterator<std::random_access_iterator_tag, BB_, int, BB_ *, BB_ *>
128 inline bool index_is_valid(
int idx) {
129 return idx >= 0 && (
unsigned) idx < Term->getNumSuccessors();
133 class SuccessorProxy {
137 explicit SuccessorProxy(
const Self &it) : it(it) {}
139 SuccessorProxy(
const SuccessorProxy&) =
default;
141 SuccessorProxy &operator=(SuccessorProxy r) {
147 it.Term->setSuccessor(it.idx, r);
151 operator reference()
const {
return *it; }
160 idx = Term->getNumSuccessors();
174 inline bool operator==(
const Self& x)
const {
return idx == x.idx; }
183 Self tmp = *
this; ++*
this;
return tmp;
188 Self tmp = *
this; --*
this;
return tmp;
192 assert(Term == x.Term &&
"Cannot compare iterators of different blocks!");
197 assert(Term == x.Term &&
"Cannot compare iterators of different blocks!");
201 assert(Term == x.Term &&
"Cannot compare iterators of different blocks!");
206 assert(Term == x.Term &&
"Cannot compare iterators of different blocks!");
211 unsigned new_idx = idx + Right;
212 assert(index_is_valid(new_idx) &&
"Iterator index out of bound");
232 assert(Term == x.Term &&
"Cannot work on iterators of different blocks!");
233 int distance = idx - x.idx;
240 return SuccessorProxy(tmp);
245 assert(Term &&
"Source not available, if basic block was malformed");
246 return Term->getParent();
static NodeType * getEntryNode(Inverse< Function * > G)
SuccIterator< const TerminatorInst *, const BasicBlock > succ_const_iterator
PredIterator< const BasicBlock, Value::const_user_iterator > const_pred_iterator
bool operator==(const Self &x) const
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
bool operator==(const Self &x) const
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
static ChildIteratorType child_begin(NodeType *N)
bool operator!=(const Self &x) const
static ChildIteratorType child_end(NodeType *N)
llvm::iterator_range< pred_iterator > pred_range
PredIterator(Ptr *bb, bool)
Use & getUse() const
getUse - Return the operand Use in the predecessor's terminator of the successor. ...
llvm::iterator_range< succ_const_iterator > succ_const_range
static ChildIteratorType child_begin(NodeType *N)
static ChildIteratorType child_end(NodeType *N)
A Use represents the edge between a Value definition and its users.
static NodeType * getEntryNode(const BasicBlock *BB)
bool operator>=(const Self &x) const
succ_const_iterator ChildIteratorType
super::reference reference
Interval::succ_iterator succ_begin(Interval *I)
succ_begin/succ_end - define methods so that Intervals may be used just like BasicBlocks can with the...
succ_iterator ChildIteratorType
static NodeType * getEntryNode(BasicBlock *BB)
bool operator<(const Self &x) const
unsigned getOperandNo() const
getOperandNo - Return the operand number in the predecessor's terminator of the successor.
bool operator>(const Self &x) const
llvm::iterator_range< succ_iterator > succ_range
Interval::succ_iterator succ_end(Interval *I)
static nodes_iterator nodes_begin(const Function *F)
reference operator*() const
Subclasses of this class are all able to terminate a basic block.
SuccIterator< TerminatorInst *, BasicBlock > succ_iterator
LLVM Basic Block Representation.
bool succ_empty(const BasicBlock *BB)
Interval::pred_iterator pred_begin(Interval *I)
pred_begin/pred_end - define methods so that Intervals may be used just like BasicBlocks can with the...
Interval::pred_iterator pred_end(Interval *I)
bool pred_empty(const BasicBlock *BB)
bool operator<=(const Self &x) const
int operator-(const Self &x) const
static nodes_iterator nodes_end(const Function *F)
isPodLike - This is a type trait that is used to determine whether a given type can be copied around ...
static ChildIteratorType child_end(NodeType *N)
static ChildIteratorType child_begin(NodeType *N)
unsigned getSuccessorIndex() const
getSuccessorIndex - This is used to interface between code that wants to operate on terminator instru...
pred_range predecessors(BasicBlock *BB)
static NodeType * getEntryNode(Function *F)
const BasicBlock & getEntryBlock() const
reference operator*() const
BB_ * getSource()
Get the source BB of this iterator.
static ChildIteratorType child_begin(NodeType *N)
A range adaptor for a pair of iterators.
super::reference reference
static size_t size(const Function *F)
llvm::iterator_range< const_pred_iterator > pred_const_range
pointer operator->() const
pred_iterator ChildIteratorType
user_iterator_impl< const User > const_user_iterator
SuccIterator(Term_ T, bool)
bool operator!=(const Self &x) const
Function::iterator nodes_iterator
static NodeType * getEntryNode(const Function *F)
TerminatorInst * getTerminator()
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
SuccessorProxy operator[](int offset)
PredIterator< BasicBlock, Value::user_iterator > pred_iterator
const BasicBlock NodeType
static NodeType * getEntryNode(Inverse< BasicBlock * > G)
static nodes_iterator nodes_end(Function *F)
static ChildIteratorType child_end(NodeType *N)
Self operator-(int Right) const
Self & operator+=(int Right)
const BasicBlock NodeType
static nodes_iterator nodes_begin(Function *F)
succ_range successors(BasicBlock *BB)
const_pred_iterator ChildIteratorType
static NodeType * getEntryNode(Inverse< const BasicBlock * > G)
static NodeType * getEntryNode(Inverse< const Function * > G)
Self & operator-=(int Right)
Function::const_iterator nodes_iterator
static size_t size(Function *F)
pointer * operator->() const
Self operator+(int Right) const