41template <
class Ptr,
class USE_iterator>
58 assert(Inst->isTerminator() &&
"BasicBlock used in non-terminator");
77 assert(!
It.atEnd() &&
"pred_iterator out of range!");
83 assert(!
It.atEnd() &&
"pred_iterator out of range!");
89 Self tmp = *
this; ++*
this;
return tmp;
95 return It.getOperandNo();
138template <
class InstructionT,
class BlockT>
141 std::random_access_iterator_tag, BlockT, int,
142 BlockT *, BlockT *> {
153 inline bool index_is_valid(
int Idx) {
156 return Idx >= 0 && (Idx == 0 || Idx <= (int)Inst->getNumSuccessors());
160 class SuccessorProxy {
164 explicit SuccessorProxy(
const Self &It) : It(It) {}
166 SuccessorProxy(
const SuccessorProxy &) =
default;
168 SuccessorProxy &operator=(SuccessorProxy
RHS) {
174 It.Inst->setSuccessor(It.Idx,
RHS);
178 operator reference()
const {
return *It; }
183 explicit inline SuccIterator(InstructionT *Inst) : Inst(Inst), Idx(0) {}
187 Idx = Inst->getNumSuccessors();
202 inline bool operator==(
const Self &x)
const {
return Idx == x.Idx; }
204 inline BlockT *
operator*()
const {
return Inst->getSuccessor(Idx); }
210 assert(Inst ==
RHS.Inst &&
"Cannot compare iterators of different blocks!");
211 return Idx <
RHS.Idx;
215 assert(Inst ==
RHS.Inst &&
"Cannot compare iterators of different blocks!");
216 return Idx -
RHS.Idx;
220 int NewIdx = Idx +
RHS;
221 assert(index_is_valid(NewIdx) &&
"Iterator index out of bound");
233 return SuccessorProxy(TmpIt);
238 assert(Inst &&
"Source not available, if basic block was malformed");
239 return Inst->getParent();
313 "GraphTraits getNumber() not detected");
328 "GraphTraits getNumber() not detected");
347 "GraphTraits getNumber() not detected");
361 "GraphTraits getNumber() not detected");
388 return F->getMaxBlockNumber();
391 return F->getBlockNumberEpoch();
412 return F->getMaxBlockNumber();
415 return F->getBlockNumberEpoch();
427 return &
G.Graph->getEntryBlock();
431 return F->getMaxBlockNumber();
434 return F->getBlockNumberEpoch();
440 return &
G.Graph->getEntryBlock();
444 return F->getMaxBlockNumber();
447 return F->getBlockNumberEpoch();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the little GraphTraits<X> template class that should be specialized by classes that...
LLVM Basic Block Representation.
unsigned getNumber() const
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...
bool operator==(const Self &x) const
void advancePastNonTerminators()
PredIterator(Ptr *bb, bool)
bool operator!=(const Self &x) const
std::forward_iterator_tag iterator_category
reference operator*() const
PredIterator< Ptr, USE_iterator > Self
std::ptrdiff_t difference_type
pointer * operator->() const
unsigned getOperandNo() const
getOperandNo - Return the operand number in the predecessor's terminator of the successor.
Use & getUse() const
getUse - Return the operand Use in the predecessor's terminator of the successor.
bool operator==(const Self &x) const
SuccIterator(InstructionT *Inst, bool)
Self & operator-=(int RHS)
int getSuccessorIndex() const
This is used to interface between code that wants to operate on terminator instructions directly.
BlockT * operator->() const
bool operator<(const Self &RHS) const
BlockT * operator*() const
BlockT * getSource()
Get the source BlockT of this iterator.
SuccessorProxy operator[](int Offset)
Self & operator+=(int RHS)
int operator-(const Self &RHS) const
SuccIterator(InstructionT *Inst)
A Use represents the edge between a Value definition and its users.
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
A range adaptor for a pair of iterators.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
This is an optimization pass for GlobalISel generic memory operations.
bool succ_empty(const Instruction *I)
iterator_range< pred_iterator > pred_range
iterator_range< succ_iterator > succ_range
auto pred_end(const MachineBasicBlock *BB)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
auto successors(const MachineBasicBlock *BB)
constexpr bool GraphHasNodeNumbers
Indicate whether a GraphTraits<NodeT>::getNumber() is supported.
iterator_range< const_pred_iterator > const_pred_range
auto pred_size(const MachineBasicBlock *BB)
PredIterator< const BasicBlock, Value::const_user_iterator > const_pred_iterator
auto succ_size(const MachineBasicBlock *BB)
RNSuccIterator< NodeRef, BlockT, RegionT > succ_begin(NodeRef Node)
RNSuccIterator< NodeRef, BlockT, RegionT > succ_end(NodeRef Node)
PredIterator< BasicBlock, Value::user_iterator > pred_iterator
auto pred_begin(const MachineBasicBlock *BB)
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
auto predecessors(const MachineBasicBlock *BB)
SuccIterator< Instruction, BasicBlock > succ_iterator
bool pred_empty(const BasicBlock *BB)
SuccIterator< const Instruction, const BasicBlock > const_succ_iterator
iterator_range< const_succ_iterator > const_succ_range
static NodeRef getEntryNode(BasicBlock *BB)
succ_iterator ChildIteratorType
static ChildIteratorType child_begin(NodeRef N)
static unsigned getNumber(const BasicBlock *BB)
static ChildIteratorType child_end(NodeRef N)
static unsigned getMaxNumber(const Function *F)
static nodes_iterator nodes_begin(Function *F)
static unsigned getNumberEpoch(const Function *F)
static nodes_iterator nodes_end(Function *F)
static size_t size(Function *F)
static NodeRef getEntryNode(Function *F)
pointer_iterator< Function::iterator > nodes_iterator
static ChildIteratorType child_begin(NodeRef N)
static unsigned getNumber(const BasicBlock *BB)
static ChildIteratorType child_end(NodeRef N)
pred_iterator ChildIteratorType
static NodeRef getEntryNode(Inverse< BasicBlock * > G)
static unsigned getNumberEpoch(const Function *F)
static unsigned getMaxNumber(const Function *F)
static NodeRef getEntryNode(Inverse< Function * > G)
static ChildIteratorType child_end(NodeRef N)
const_pred_iterator ChildIteratorType
const BasicBlock * NodeRef
static NodeRef getEntryNode(Inverse< const BasicBlock * > G)
static ChildIteratorType child_begin(NodeRef N)
static unsigned getNumber(const BasicBlock *BB)
static unsigned getMaxNumber(const Function *F)
static NodeRef getEntryNode(Inverse< const Function * > G)
static unsigned getNumberEpoch(const Function *F)
const BasicBlock * NodeRef
static ChildIteratorType child_begin(NodeRef N)
static unsigned getNumber(const BasicBlock *BB)
static NodeRef getEntryNode(const BasicBlock *BB)
const_succ_iterator ChildIteratorType
static ChildIteratorType child_end(NodeRef N)
static size_t size(const Function *F)
static nodes_iterator nodes_begin(const Function *F)
static NodeRef getEntryNode(const Function *F)
static unsigned getNumberEpoch(const Function *F)
static unsigned getMaxNumber(const Function *F)
static nodes_iterator nodes_end(const Function *F)
pointer_iterator< Function::const_iterator > nodes_iterator
typename Function *::UnknownGraphTypeError NodeRef