42 template <
class Ptr,
class USE_iterator>
43 class PredIterator :
public std::iterator<std::forward_iterator_tag,
44 Ptr, ptrdiff_t, Ptr*, Ptr*> {
46 std::iterator<std::forward_iterator_tag, Ptr, ptrdiff_t, Ptr*, Ptr*>;
50 inline void advancePastNonTerminators() {
53 if (
auto *Inst = dyn_cast<Instruction>(*It))
54 if (Inst->isTerminator())
67 advancePastNonTerminators();
75 assert(!It.atEnd() &&
"pred_iterator out of range!");
76 return cast<Instruction>(*It)->getParent();
81 assert(!It.atEnd() &&
"pred_iterator out of range!");
82 ++It; advancePastNonTerminators();
87 Self tmp = *
this; ++*
this;
return tmp;
93 return It.getOperandNo();
136 template <
class InstructionT,
class BlockT>
139 std::random_access_iterator_tag, BlockT, int,
140 BlockT *, BlockT *> {
151 inline bool index_is_valid(
int Idx) {
154 return Idx >= 0 && (Idx == 0 || Idx <= (int)Inst->getNumSuccessors());
158 class SuccessorProxy {
162 explicit SuccessorProxy(
const Self &It) : It(It) {}
164 SuccessorProxy(
const SuccessorProxy &) =
default;
166 SuccessorProxy &operator=(SuccessorProxy RHS) {
171 SuccessorProxy &operator=(
reference RHS) {
172 It.Inst->setSuccessor(It.Idx, RHS);
176 operator reference()
const {
return *It; }
181 explicit inline SuccIterator(InstructionT *Inst) : Inst(Inst), Idx(0) {}
185 Idx = Inst->getNumSuccessors();
200 inline bool operator==(
const Self &x)
const {
return Idx == x.Idx; }
202 inline BlockT *
operator*()
const {
return Inst->getSuccessor(Idx); }
208 assert(Inst == RHS.Inst &&
"Cannot compare iterators of different blocks!");
209 return Idx < RHS.Idx;
213 assert(Inst == RHS.Inst &&
"Cannot compare iterators of different blocks!");
214 return Idx - RHS.Idx;
218 int NewIdx = Idx + RHS;
219 assert(index_is_valid(NewIdx) &&
"Iterator index out of bound");
231 return SuccessorProxy(TmpIt);
236 assert(Inst &&
"Source not available, if basic block was malformed");
237 return Inst->getParent();
395 return &G.
Graph->getEntryBlock();
401 return &G.
Graph->getEntryBlock();
407 #endif // LLVM_IR_CFG_H
std::string & operator+=(std::string &buffer, StringRef string)
static NodeRef getEntryNode(const BasicBlock *BB)
This class represents lattice values for constants.
iterator_range< succ_iterator > succ_range
static NodeRef getEntryNode(Inverse< BasicBlock *> G)
int operator-(const Self &RHS) const
PredIterator< BasicBlock, Value::user_iterator > pred_iterator
static NodeRef getEntryNode(BasicBlock *BB)
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
static ChildIteratorType child_begin(NodeRef N)
int getSuccessorIndex() const
This is used to interface between code that wants to operate on terminator instructions directly...
static ChildIteratorType child_end(NodeRef N)
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
SuccIterator< const Instruction, const BasicBlock > succ_const_iterator
static NodeRef getEntryNode(Inverse< const Function *> G)
SuccIterator(InstructionT *Inst)
PredIterator(Ptr *bb, bool)
static ChildIteratorType child_end(NodeRef N)
iterator_range< const_pred_iterator > pred_const_range
A Use represents the edge between a Value definition and its users.
SuccIterator(InstructionT *Inst, bool)
pointer * operator->() const
bool operator==(const Self &x) const
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...
reference operator*() const
static ChildIteratorType child_begin(NodeRef N)
BlockT * operator*() const
iterator_range< succ_const_iterator > succ_const_range
static ChildIteratorType child_end(NodeRef N)
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
static ChildIteratorType child_begin(NodeRef N)
Interval::succ_iterator succ_end(Interval *I)
Use & getUse() const
getUse - Return the operand Use in the predecessor's terminator of the successor. ...
static nodes_iterator nodes_begin(const Function *F)
const BasicBlock & getEntryBlock() const
typename super::reference reference
typename BasicBlock *::UnknownGraphTypeError NodeRef
static NodeRef getEntryNode(Inverse< Function *> G)
LLVM Basic Block Representation.
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...
iterator_range< pred_iterator > pred_range
Interval::pred_iterator pred_end(Interval *I)
static ChildIteratorType child_end(NodeRef N)
bool pred_empty(const BasicBlock *BB)
static NodeRef getEntryNode(Inverse< const BasicBlock *> G)
bool succ_empty(const Instruction *I)
unsigned getOperandNo() const
getOperandNo - Return the operand number in the predecessor's terminator of the successor.
static nodes_iterator nodes_end(const Function *F)
BlockT * getSource()
Get the source BlockT of this iterator.
Self & operator-=(int RHS)
isPodLike - This is a type trait that is used to determine whether a given type can be copied around ...
bool operator<(const Self &RHS) const
static NodeRef getEntryNode(Function *F)
pred_range predecessors(BasicBlock *BB)
A range adaptor for a pair of iterators.
static size_t size(const Function *F)
static NodeRef getEntryNode(const Function *F)
unsigned succ_size(const Instruction *I)
Self & operator+=(int RHS)
BlockT * operator->() const
static ChildIteratorType child_begin(NodeRef N)
SuccIterator< Instruction, BasicBlock > succ_iterator
PredIterator< const BasicBlock, Value::const_user_iterator > const_pred_iterator
typename super::pointer pointer
unsigned pred_size(const BasicBlock *BB)
Get the number of predecessors of BB.
static nodes_iterator nodes_end(Function *F)
bool operator!=(const Self &x) const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool operator==(const Self &x) const
static nodes_iterator nodes_begin(Function *F)
succ_range successors(Instruction *I)
static size_t size(Function *F)
SuccessorProxy operator[](int Offset)