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))
71 if (isa<llvm::MetadataAsValue>(
Op))
74 if (isa<llvm::InlineAsm>(
Op))
89 assert(V !=
nullptr &&
"No SandboxIR for BB->begin()!");
90 auto *
I = cast<Instruction>(V);
91 unsigned Num =
I->getNumOfIRInstrs();
92 assert(Num >= 1u &&
"Bad getNumOfIRInstrs()");
93 It = std::next(It, Num - 1);
101 return cast_or_null<Instruction>(TerminatorV);
105 auto *BB = cast<llvm::BasicBlock>(
Val);
106 assert(!BB->empty() &&
"Empty block!");
107 auto *SBI = cast<Instruction>(
getContext().getValue(&*BB->begin()));
108 assert(SBI !=
nullptr &&
"Expected Instr!");
113 auto *BB = cast<llvm::BasicBlock>(
Val);
114 assert(!BB->empty() &&
"Empty block!");
115 auto *SBI = cast<Instruction>(
getContext().getValue(&*BB->rbegin()));
116 assert(SBI !=
nullptr &&
"Expected Instr!");
132 OS <<
"<Crash-proof mode!>\n";
137 OS << IRef <<
" *** No SandboxIR ***\n";
139 auto *SBI = dyn_cast<Instruction>(SBV);
140 if (SBI ==
nullptr) {
141 OS << IRef <<
" *** Not a SBInstruction!!! ***\n";
143 if (Visited.
insert(SBI).second)
149 for (
auto &SBI : *
this) {
157 assert(isa<llvm::BasicBlock>(
Val) &&
"Expected BasicBlock!");
158 for (
const auto &
I : *
this) {
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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.
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.
BasicBlock * getNodeParent() const
\Returns the parent BB.
BBIterator & operator++()
BBIterator & operator--()
Contains a list of sandboxir::Instruction's.
Function * getParent() const
void verify() const final
Should crash if there is something wrong with the instruction.
Instruction & back() const
Instruction * getTerminator() const
Instruction & front() const
Context & getContext() const
void dumpOS(raw_ostream &OS) const final
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.
A SandboxIR Value has users. This is the base class.
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)