18 assert(It != ItE &&
"Already at end!");
24 assert(Num > 0 &&
"Bad getNumOfIRInstrs()");
25 It = std::next(It, Num - 1);
31 if (It == BB->
end()) {
36 unsigned Num = CurrI.getNumOfIRInstrs();
37 assert(Num > 0 &&
"Bad getNumOfIRInstrs()");
38 assert(std::prev(It, Num - 1) != BB->
begin() &&
"Already at begin!");
39 It = std::prev(It, Num);
45 return cast<BasicBlock>(Ctx->
getValue(Parent));
50 return cast_or_null<Instruction>(Ctx->
getValue(&*It));
54 auto *BB = cast<llvm::BasicBlock>(
Val);
55 auto *
F = BB->getParent();
68 if (isa<llvm::BasicBlock>(
Op))
83 assert(V !=
nullptr &&
"No SandboxIR for BB->begin()!");
84 auto *
I = cast<Instruction>(V);
85 unsigned Num =
I->getNumOfIRInstrs();
86 assert(Num >= 1u &&
"Bad getNumOfIRInstrs()");
87 It = std::next(It, Num - 1);
95 return cast_or_null<Instruction>(TerminatorV);
99 auto *BB = cast<llvm::BasicBlock>(
Val);
100 assert(!BB->empty() &&
"Empty block!");
101 auto *SBI = cast<Instruction>(
getContext().getValue(&*BB->begin()));
102 assert(SBI !=
nullptr &&
"Expected Instr!");
107 auto *BB = cast<llvm::BasicBlock>(
Val);
108 assert(!BB->empty() &&
"Empty block!");
109 auto *SBI = cast<Instruction>(
getContext().getValue(&*BB->rbegin()));
110 assert(SBI !=
nullptr &&
"Expected Instr!");
126 OS <<
"<Crash-proof mode!>\n";
131 OS << IRef <<
" *** No SandboxIR ***\n";
133 auto *SBI = dyn_cast<Instruction>(SBV);
134 if (SBI ==
nullptr) {
135 OS << IRef <<
" *** Not a SBInstruction!!! ***\n";
137 if (Visited.
insert(SBI).second)
143 for (
auto &SBI : *
this) {
151 assert(isa<llvm::BasicBlock>(
Val) &&
"Expected BasicBlock!");
152 for (
const auto &
I : *
this) {
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineInstr unsigned OpIdx
LLVM Basic Block Representation.
iterator begin()
Instruction iterator methods.
InstListType::iterator iterator
Instruction iterators...
This class represents an Operation in the Expression.
Implements a dense probed hash-table based set.
LLVM Value Representation.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
std::pair< iterator, bool > insert(const ValueT &V)
This class implements an extremely fast bulk output stream that can only output to a stream.
Iterator for Instructions in a `BasicBlock.
LLVM_ABI BasicBlock * getNodeParent() const
\Returns the parent BB.
LLVM_ABI BBIterator & operator++()
LLVM_ABI BBIterator & operator--()
Contains a list of sandboxir::Instruction's.
LLVM_ABI Function * getParent() const
void verify() const final
Should crash if there is something wrong with the instruction.
LLVM_ABI Instruction & back() const
LLVM_ABI Instruction * getTerminator() const
LLVM_ABI Instruction & front() const
LLVM_ABI iterator begin() const
Context & getContext() const
void dumpOS(raw_ostream &OS) const final
LLVM_ABI sandboxir::Value * getValue(llvm::Value *V) const
Value * getOrCreateValue(llvm::Value *LLVMV)
Get or create a sandboxir::Value for an existing LLVM IR LLVMV.
A sandboxir::User with operands, opcode and linked with previous/next instructions in an instruction ...
virtual unsigned getNumOfIRInstrs() const =0
This is used by BasicBlock::iterator.
llvm::Value * Val
The LLVM Value that corresponds to this SandboxIR Value.
Context & Ctx
All values point to the context.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
auto reverse(ContainerTy &&C)