LLVM: include/llvm/SandboxIR/BasicBlock.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9#ifndef LLVM_SANDBOXIR_BASICBLOCK_H
10#define LLVM_SANDBOXIR_BASICBLOCK_H
11
15
17
21
22
23
24class BBIterator {
25public:
26 using difference_type = std::ptrdiff_t;
28 using pointer = value_type *;
29 using reference = value_type &;
30 using iterator_category = std::bidirectional_iterator_tag;
31
32private:
33 llvm::BasicBlock *BB;
37
38public:
39 BBIterator() : BB(nullptr), Ctx(nullptr) {}
41 : BB(BB), It(It), Ctx(Ctx) {}
42 reference operator*() const { return *getInstr(It); }
43 LLVM_ABI BBIterator &operator++();
44 BBIterator operator++(int) {
45 auto Copy = *this;
46 ++*this;
48 }
51 auto Copy = *this;
52 --*this;
54 }
55 bool operator==(const BBIterator &Other) const {
56 assert(Ctx == Other.Ctx && "BBIterators in different context!");
57 return It == Other.It;
58 }
59 bool operator!=(const BBIterator &Other) const { return !(*this == Other); }
60
61
62 pointer get() const { return getInstr(It); }
63
65};
66
67
69
70
71 LLVM_ABI void buildBasicBlockFromLLVMIR(llvm::BasicBlock *LLVMBB);
72 friend class Context;
74
77 buildBasicBlockFromLLVMIR(BB);
78 }
79
80public:
82
91 return iterator(BB, BB->end(), &Ctx);
92 }
93 std::reverse_iterator rbegin() const {
94 return std::make_reverse_iterator(end());
95 }
96 std::reverse_iterator rend() const {
97 return std::make_reverse_iterator(begin());
98 }
104
105#ifndef NDEBUG
108#endif
109};
110
111}
112
113#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_ABI_FOR_TEST
bool operator==(const MergedFunctionsInfo &LHS, const MergedFunctionsInfo &RHS)
LLVM Basic Block Representation.
InstListType::iterator iterator
Instruction iterators...
This class implements an extremely fast bulk output stream that can only output to a stream.
A sandboxir::User with operands, opcode and linked with previous/next instructions in an instruction ...
A SandboxIR Value has users. This is the base class.
ClassID getSubclassID() const
ArchKind & operator--(ArchKind &Kind)
@ BasicBlock
Various leaf nodes.
LLVM_ABI Function * getParent() const
bool empty() const
Definition BasicBlock.h:101
LLVM_ABI_FOR_TEST void dumpOS(raw_ostream &OS) const final
Context & getContext() const
Definition BasicBlock.h:99
std::reverse_iterator< iterator > rbegin() const
Definition BasicBlock.h:93
BasicBlock(llvm::BasicBlock *BB, Context &SBCtx)
Definition BasicBlock.h:75
iterator end() const
Definition BasicBlock.h:89
static bool classof(const Value *From)
For isa/dyn_cast.
Definition BasicBlock.h:83
friend class Instruction
Iterator for Instructions in a `BasicBlock.
Definition BasicBlock.h:73
LLVM_ABI Instruction & back() const
BBIterator iterator
Definition BasicBlock.h:87
std::reverse_iterator< iterator > rend() const
Definition BasicBlock.h:96
void verify() const final
LLVM_ABI iterator begin() const
~BasicBlock() override=default
LLVM_ABI Instruction * getTerminator() const
LLVM_ABI Instruction & front() const
APInt operator*(APInt a, uint64_t RHS)
bool operator!=(uint64_t V1, const APInt &V2)
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
decltype(auto) cast(const From &Val)
cast - Return the argument parameter cast to the specified type.