92#ifndef LLVM_SANDBOXIR_SANDBOXIR_H
93#define LLVM_SANDBOXIR_SANDBOXIR_H
148#define DEF_INSTR(ID, OPC, CLASS) friend class CLASS;
149#include "llvm/SandboxIR/SandboxIRValues.def"
170 return !(*
this ==
Other);
199 return !(*
this ==
Other);
208#define DEF_VALUE(ID, CLASS) ID,
209#define DEF_USER(ID, CLASS) ID,
210#define DEF_INSTR(ID, OPC, CLASS) ID,
211#include "llvm/SandboxIR/SandboxIRValues.def"
217#define DEF_VALUE(ID, CLASS) \
220#define DEF_USER(ID, CLASS) \
223#define DEF_INSTR(ID, OPC, CLASS) \
226#include "llvm/SandboxIR/SandboxIRValues.def"
368 std::string
getUid()
const;
391 return From->getSubclassID() == ClassID::Argument;
395 assert(isa<llvm::Argument>(
Val) &&
"Expected Argument!");
421 return Use.LLVMUse->getOperandNo();
448 assert(isa<llvm::User>(
Val) &&
"Expect User value!");
452 assert(isa<llvm::User>(
Val) &&
"Expect User value!");
474 return isa<llvm::User>(
Val) ? cast<llvm::User>(
Val)->getNumOperands() : 0;
484 assert(isa<llvm::User>(
Val) &&
"Expected User!");
501 Use getOperandUseInternal(
unsigned OpIdx,
bool Verify)
const override {
508 return From->getSubclassID() == ClassID::Constant ||
509 From->getSubclassID() == ClassID::ConstantInt ||
510 From->getSubclassID() == ClassID::Function;
518 assert(isa<llvm::Constant>(
Val) &&
"Expected Constant!");
529 Use getOperandUseInternal(
unsigned OpIdx,
bool Verify)
const final {
537 bool IsSigned =
false);
543 return From->getSubclassID() == ClassID::ConstantInt;
550 assert(isa<llvm::ConstantInt>(
Val) &&
"Expected a ConstantInst!");
578 : BB(BB), It(It), Ctx(Ctx) {}
593 assert(Ctx ==
Other.Ctx &&
"BBIterators in different context!");
594 return It ==
Other.It;
612 buildBasicBlockFromLLVMIR(BB);
619 return From->getSubclassID() == Value::ClassID::Block;
625 auto *BB = cast<llvm::BasicBlock>(
Val);
628 std::reverse_iterator<iterator>
rbegin()
const {
629 return std::make_reverse_iterator(
end());
631 std::reverse_iterator<iterator>
rend()
const {
632 return std::make_reverse_iterator(
begin());
642 assert(isa<llvm::BasicBlock>(
Val) &&
"Expected BasicBlock!");
654#define OPCODES(...) __VA_ARGS__
655#define DEF_INSTR(ID, OPC, CLASS) OPC
656#include "llvm/SandboxIR/SandboxIRValues.def"
739 return cast<llvm::Instruction>(
Val)->hasNoUnsignedWrap();
746 return cast<llvm::Instruction>(
Val)->hasNoSignedWrap();
752 bool isFast()
const {
return cast<llvm::Instruction>(
Val)->isFast(); }
759 return cast<llvm::Instruction>(
Val)->hasAllowReassoc();
766 bool isExact()
const {
return cast<llvm::Instruction>(
Val)->isExact(); }
771 bool hasNoNaNs()
const {
return cast<llvm::Instruction>(
Val)->hasNoNaNs(); }
777 bool hasNoInfs()
const {
return cast<llvm::Instruction>(
Val)->hasNoInfs(); }
784 return cast<llvm::Instruction>(
Val)->hasNoSignedZeros();
792 return cast<llvm::Instruction>(
Val)->hasAllowReciprocal();
800 return cast<llvm::Instruction>(
Val)->hasAllowContract();
808 return cast<llvm::Instruction>(
Val)->hasApproxFunc();
818 return cast<llvm::Instruction>(
Val)->getFastMathFlags();
841#define DEF_INSTR(ID, OPC, CLASS) friend class CLASS;
842#include "llvm/SandboxIR/SandboxIRValues.def"
846 Use getOperandUseInternal(
unsigned OpIdx,
bool Verify)
const final {
850 return {cast<llvm::Instruction>(
Val)};
912 return From->getSubclassID() == ClassID::InsertElement;
926 Opcode::ExtractElement,
I,
Ctx) {}
936 return From->getSubclassID() == ClassID::ExtractElement;
971 return cast<llvm::BranchInst>(
Val)->isUnconditional();
974 return cast<llvm::BranchInst>(
Val)->isConditional();
984 struct LLVMBBToSBBB {
986 LLVMBBToSBBB(
Context &Ctx) : Ctx(Ctx) {}
990 struct ConstLLVMBBToSBBB {
992 ConstLLVMBBToSBBB(Context &Ctx) : Ctx(Ctx) {}
1001 cast<llvm::BranchInst>(
Val)->successors();
1002 LLVMBBToSBBB BBMap(
Ctx);
1015 ConstLLVMBBToSBBB ConstBBMap(
Ctx);
1020 return make_range(ConstMappedBegin, ConstMappedEnd);
1034 return isa<LoadInst>(
I) || isa<CastInst>(
I);
1037 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
1071 bool isSimple()
const {
return cast<llvm::LoadInst>(
Val)->isSimple(); }
1101 bool isSimple()
const {
return cast<llvm::StoreInst>(
Val)->isSimple(); }
1110 Use getOperandUseInternal(
unsigned OpIdx,
bool Verify)
const final {
1114 return {cast<llvm::Instruction>(
Val)};
1144 return From->getSubclassID() == ClassID::Ret;
1159 auto Opc =
From->getSubclassID();
1160 return Opc == Instruction::ClassID::Call ||
1161 Opc == Instruction::ClassID::Invoke ||
1162 Opc == Instruction::ClassID::CallBr;
1166 return cast<llvm::CallBase>(
Val)->getFunctionType();
1174 auto *LLVMCB = cast<llvm::CallBase>(
Val);
1175 auto Dist = LLVMCB->data_operands_end() - LLVMCB->data_operands_begin();
1179 auto *LLVMCB = cast<llvm::CallBase>(
Val);
1180 auto Dist = LLVMCB->data_operands_end() - LLVMCB->data_operands_begin();
1196 assert(
this == U.getUser() &&
1197 "Only valid to query with a use of this instruction!");
1198 return cast<llvm::CallBase>(
Val)->isDataOperand(U.LLVMUse);
1202 return cast<llvm::CallBase>(
Val)->getDataOperandNo(U.LLVMUse);
1208 return cast<llvm::CallBase>(
Val)->getNumTotalBundleOperands();
1247 return cast<llvm::CallBase>(
Val)->isArgOperand(U.LLVMUse);
1250 return cast<llvm::CallBase>(
Val)->getArgOperandNo(U.LLVMUse);
1259 return cast<llvm::CallBase>(
Val)->isIndirectCall();
1262 return cast<llvm::CallBase>(
Val)->isCallee(U.LLVMUse);
1269 return cast<llvm::CallBase>(
Val)->isMustTailCall();
1273 return cast<llvm::CallBase>(
Val)->getIntrinsicID();
1278 return cast<llvm::CallBase>(
Val)->getCallingConv();
1295 const Twine &NameStr =
"");
1304 return From->getSubclassID() == ClassID::Call;
1321 const Twine &NameStr =
"");
1332 return From->getSubclassID() == ClassID::Invoke;
1342 assert(SuccIdx < 2 &&
"Successor # out of range for invoke!");
1349 return cast<llvm::InvokeInst>(
Val)->getNumSuccessors();
1367 const Twine &NameStr =
"");
1379 return From->getSubclassID() == ClassID::CallBr;
1382 return cast<llvm::CallBrInst>(
Val)->getNumIndirectDests();
1393 return cast<llvm::CallBrInst>(
Val)->getNumSuccessors();
1412 const Twine &NameStr =
"");
1415 const Twine &NameStr =
"");
1418 const Twine &NameStr =
"");
1421 return From->getSubclassID() == ClassID::GetElementPtr;
1425 return cast<llvm::GetElementPtrInst>(
Val)->getSourceElementType();
1428 return cast<llvm::GetElementPtrInst>(
Val)->getResultElementType();
1431 return cast<llvm::GetElementPtrInst>(
Val)->getAddressSpace();
1454 return cast<llvm::GetElementPtrInst>(
Val)->getPointerOperandType();
1457 return cast<llvm::GetElementPtrInst>(
Val)->getPointerAddressSpace();
1460 return cast<llvm::GetElementPtrInst>(
Val)->getNumIndices();
1463 return cast<llvm::GetElementPtrInst>(
Val)->hasIndices();
1466 return cast<llvm::GetElementPtrInst>(
Val)->hasAllConstantIndices();
1469 return cast<llvm::GetElementPtrInst>(
Val)->getNoWrapFlags();
1472 return cast<llvm::GetElementPtrInst>(
Val)->isInBounds();
1475 return cast<llvm::GetElementPtrInst>(
Val)->hasNoUnsignedSignedWrap();
1478 return cast<llvm::GetElementPtrInst>(
Val)->hasNoUnsignedWrap();
1481 return cast<llvm::GetElementPtrInst>(
Val)->accumulateConstantOffset(
DL,
1503 return cast<llvm::CatchSwitchInst>(
Val)->hasUnwindDest();
1506 return cast<llvm::CatchSwitchInst>(
Val)->unwindsToCaller();
1512 return cast<llvm::CatchSwitchInst>(
Val)->getNumHandlers();
1516 static BasicBlock *handler_helper(
Value *V) {
return cast<BasicBlock>(V); }
1518 return cast<BasicBlock>(V);
1564 "Successor # out of range for catchswitch!");
1569 "Successor # out of range for catchswitch!");
1574 return From->getSubclassID() == ClassID::CatchSwitch;
1594 return cast<llvm::SwitchInst>(
Val)->defaultDestUndefined();
1598 return cast<llvm::SwitchInst>(
Val)->getNumCases();
1654 return cast<llvm::SwitchInst>(
Val)->getNumSuccessors();
1659 return From->getSubclassID() == ClassID::Switch;
1666 case llvm::Instruction::FNeg:
1667 return Opcode::FNeg;
1668 case llvm::Instruction::UnaryOpsEnd:
1700 return From->getSubclassID() == ClassID::UnOp;
1707 case llvm::Instruction::Add:
1709 case llvm::Instruction::FAdd:
1710 return Opcode::FAdd;
1711 case llvm::Instruction::Sub:
1713 case llvm::Instruction::FSub:
1714 return Opcode::FSub;
1715 case llvm::Instruction::Mul:
1717 case llvm::Instruction::FMul:
1718 return Opcode::FMul;
1719 case llvm::Instruction::UDiv:
1720 return Opcode::UDiv;
1721 case llvm::Instruction::SDiv:
1722 return Opcode::SDiv;
1723 case llvm::Instruction::FDiv:
1724 return Opcode::FDiv;
1725 case llvm::Instruction::URem:
1726 return Opcode::URem;
1727 case llvm::Instruction::SRem:
1728 return Opcode::SRem;
1729 case llvm::Instruction::FRem:
1730 return Opcode::FRem;
1731 case llvm::Instruction::Shl:
1733 case llvm::Instruction::LShr:
1734 return Opcode::LShr;
1735 case llvm::Instruction::AShr:
1736 return Opcode::AShr;
1737 case llvm::Instruction::And:
1739 case llvm::Instruction::Or:
1741 case llvm::Instruction::Xor:
1743 case llvm::Instruction::BinaryOpsEnd:
1750 getBinOpOpcode(BinOp->getOpcode()), BinOp,
1779 return From->getSubclassID() == ClassID::BinaryOperator;
1787 Instruction::Opcode::AtomicRMW, Atomic,
Ctx) {
1794 return cast<llvm::AtomicRMWInst>(
Val)->getOperation();
1803 cast<llvm::AtomicRMWInst>(
Val)->setOperation(
Op);
1808 return cast<llvm::AtomicRMWInst>(
Val)->isVolatile();
1812 return cast<llvm::AtomicRMWInst>(
Val)->getOrdering();
1816 return cast<llvm::AtomicRMWInst>(
Val)->getSyncScopeID();
1828 return cast<llvm::AtomicRMWInst>(
Val)->getPointerAddressSpace();
1831 return cast<llvm::AtomicRMWInst>(
Val)->isFloatingPointOperation();
1834 return From->getSubclassID() == ClassID::AtomicRMW;
1859 Instruction::Opcode::AtomicCmpXchg, Atomic,
1867 return cast<llvm::AtomicCmpXchgInst>(
Val)->getAlign();
1874 return cast<llvm::AtomicCmpXchgInst>(
Val)->isVolatile();
1879 bool isWeak()
const {
return cast<llvm::AtomicCmpXchgInst>(
Val)->isWeak(); }
1888 return cast<llvm::AtomicCmpXchgInst>(
Val)->getSuccessOrdering();
1893 return cast<llvm::AtomicCmpXchgInst>(
Val)->getFailureOrdering();
1897 return cast<llvm::AtomicCmpXchgInst>(
Val)->getMergedOrdering();
1900 return cast<llvm::AtomicCmpXchgInst>(
Val)->getSyncScopeID();
1920 return cast<llvm::AtomicCmpXchgInst>(
Val)->getPointerAddressSpace();
1960 return cast<llvm::AllocaInst>(
Val)->isArrayAllocation();
1970 return cast<llvm::AllocaInst>(
Val)->getType();
1974 return cast<llvm::AllocaInst>(
Val)->getAddressSpace();
1979 return cast<llvm::AllocaInst>(
Val)->getAllocationSize(
DL);
1984 return cast<llvm::AllocaInst>(
Val)->getAllocationSizeInBits(
DL);
1988 return cast<llvm::AllocaInst>(
Val)->getAllocatedType();
2001 return cast<llvm::AllocaInst>(
Val)->isStaticAlloca();
2006 return cast<llvm::AllocaInst>(
Val)->isUsedWithInAlloca();
2012 if (
auto *
I = dyn_cast<Instruction>(
From))
2013 return I->getSubclassID() == Instruction::ClassID::Alloca;
2021 case llvm::Instruction::ZExt:
2022 return Opcode::ZExt;
2023 case llvm::Instruction::SExt:
2024 return Opcode::SExt;
2025 case llvm::Instruction::FPToUI:
2026 return Opcode::FPToUI;
2027 case llvm::Instruction::FPToSI:
2028 return Opcode::FPToSI;
2029 case llvm::Instruction::FPExt:
2030 return Opcode::FPExt;
2031 case llvm::Instruction::PtrToInt:
2032 return Opcode::PtrToInt;
2033 case llvm::Instruction::IntToPtr:
2034 return Opcode::IntToPtr;
2035 case llvm::Instruction::SIToFP:
2036 return Opcode::SIToFP;
2037 case llvm::Instruction::UIToFP:
2038 return Opcode::UIToFP;
2039 case llvm::Instruction::Trunc:
2040 return Opcode::Trunc;
2041 case llvm::Instruction::FPTrunc:
2042 return Opcode::FPTrunc;
2043 case llvm::Instruction::BitCast:
2044 return Opcode::BitCast;
2045 case llvm::Instruction::AddrSpaceCast:
2046 return Opcode::AddrSpaceCast;
2047 case llvm::Instruction::CastOpsEnd:
2094 if (
auto *
I = dyn_cast<Instruction>(
From))
2095 return I->getOpcode() ==
Op;
2115 :
public CastInstImpl<Instruction::Opcode::AddrSpaceCast> {
2143 LLVMBBToBB(
Context &Ctx) : Ctx(Ctx) {}
2158 LLVMBBToBB BBGetter(
Ctx);
2163 LLVMBBToBB BBGetter(
Ctx);
2176 return cast<llvm::PHINode>(
Val)->getNumIncomingValues();
2202 return cast<llvm::PHINode>(
Val)->hasConstantOrUndefValue();
2223 return From->getSubclassID() == ClassID::Opaque;
2252 auto It = Pair.first;
2254 It->second = std::unique_ptr<Argument>(
new Argument(LLVMArg, *
this));
2255 return cast<Argument>(It->second.get());
2257 return cast<Argument>(It->second.get());
2350 LLVMBBToBB(
Context &Ctx) : Ctx(Ctx) {}
2352 return *cast<BasicBlock>(Ctx.
getValue(&LLVMBB));
2363 return From->getSubclassID() == ClassID::Function;
2371 size_t arg_size()
const {
return cast<llvm::Function>(
Val)->arg_size(); }
2376 LLVMBBToBB BBGetter(
Ctx);
2380 LLVMBBToBB BBGetter(
Ctx);
2384 return cast<llvm::Function>(
Val)->getFunctionType();
2389 assert(isa<llvm::Function>(
Val) &&
"Expected Function!");
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
BlockVerifier::State From
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
ppc ctr loops PowerPC CTR Loops Verify
StandardInstrumentations SI(Mod->getContext(), Debug, VerifyEach)
const SmallVectorImpl< MachineOperand > & Cond
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Class for arbitrary precision integers.
an instruction to allocate memory on the stack
This class represents an incoming formal argument to a Function.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
An instruction that atomically checks whether a specified value is in a memory location,...
static bool isValidFailureOrdering(AtomicOrdering Ordering)
static bool isValidSuccessOrdering(AtomicOrdering Ordering)
an instruction that atomically reads a memory location, combines it with another value,...
static bool isFPOperation(BinOp Op)
BinOp
This enumeration lists the possible modifications atomicrmw can make.
static StringRef getOperationName(BinOp Op)
LLVM Basic Block Representation.
InstListType::iterator iterator
Instruction iterators...
Conditional or Unconditional Branch instruction.
CallBr instruction, tracking function calls that may not return control but instead transfer it to a ...
This class represents a function call, abstracting a target machine's calling convention.
This is the base class for all instructions that perform data casts.
Instruction::CastOps getOpcode() const
Return the opcode of this CastInst.
ConstantFolder - Create constants with minimum, target independent, folding.
This is the shared class of boolean and integer constants.
This is an important base class in LLVM.
This class represents an Operation in the Expression.
A parsed version of the target data layout string in and methods for querying it.
Convenience struct for specifying and reasoning about fast-math flags.
Class to represent function types.
Represents flags for the getelementptr instruction/expression.
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
static unsigned getPointerOperandIndex()
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
This instruction inserts a single (scalar) element into a VectorType value.
static bool isValidOperands(const Value *Vec, const Value *NewElt, const Value *Idx)
Return true if an insertelement instruction can be formed with the specified operands.
This is an important class for using LLVM in a threaded context.
An instruction for reading from memory.
static unsigned getOperandNumForIncomingValue(unsigned i)
static unsigned getIncomingValueNumForOperand(unsigned i)
Class to represent pointers.
Return a value (possibly void), from a function.
This class represents the LLVM 'select' instruction.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
StringRef - Represent a constant reference to a string, i.e.
ConstantIntT * getCaseValue() const
Resolves case value for current case.
static const unsigned DefaultPseudoIndex
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
UnaryOps getOpcode() const
This function has undefined behavior.
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
StringRef getName() const
Return a constant reference to the value's name.
Base class of all SIMD vector types.
An efficient, type-erasing, non-owning reference to a callable.
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
unsigned getSrcAddressSpace() const
\Returns the address space of the pointer operand.
Value * getPointerOperand()
\Returns the pointer operand.
unsigned getDestAddressSpace() const
\Returns the address space of the result.
const Value * getPointerOperand() const
\Returns the pointer operand.
static unsigned getPointerOperandIndex()
\Returns the operand index of the pointer operand.
bool isUsedWithInAlloca() const
Return true if this alloca is used as an inalloca argument to a call.
Value * getArraySize()
Get the number of elements allocated.
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
bool isStaticAlloca() const
Return true if this alloca is in the entry block of the function and is a constant size.
bool isArrayAllocation() const
Return true if there is an allocation size parameter to the allocation instruction that is not 1.
std::optional< TypeSize > getAllocationSizeInBits(const DataLayout &DL) const
Get allocation size in bits.
void setAlignment(Align Align)
unsigned getAddressSpace() const
Return the address space for the allocation.
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
PointerType * getType() const
Overload to return most specific pointer type.
void setUsedWithInAlloca(bool V)
Specify whether this alloca is used to represent the arguments to a call.
static AllocaInst * create(Type *Ty, unsigned AddrSpace, BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx, Value *ArraySize=nullptr, const Twine &Name="")
static bool classof(const Value *From)
std::optional< TypeSize > getAllocationSize(const DataLayout &DL) const
Get allocation size in bytes.
const Value * getArraySize() const
void setAllocatedType(Type *Ty)
for use only in special circumstances that need to generically transform a whole instruction (eg: IR ...
Argument of a sandboxir::Function.
void dumpOS(raw_ostream &OS) const final
void printAsOperand(raw_ostream &OS) const
void verify() const final
Should crash if there is something wrong with the instruction.
static bool classof(const sandboxir::Value *From)
void setSyncScopeID(SyncScope::ID SSID)
void setVolatile(bool V)
Specify whether this is a volatile cmpxchg.
Value * getCompareOperand()
void setAlignment(Align Align)
Value * getPointerOperand()
const Value * getNewValOperand() const
void setSuccessOrdering(AtomicOrdering Ordering)
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
AtomicOrdering getMergedOrdering() const
Value * getNewValOperand()
const Value * getCompareOperand() const
static AtomicCmpXchgInst * create(Value *Ptr, Value *Cmp, Value *New, MaybeAlign Align, AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering, BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx, SyncScope::ID SSID=SyncScope::System, const Twine &Name="")
const Value * getPointerOperand() const
AtomicOrdering getFailureOrdering() const
static bool isValidFailureOrdering(AtomicOrdering Ordering)
void setWeak(bool IsWeak)
bool isVolatile() const
Return true if this is a cmpxchg from a volatile memory location.
static bool isValidSuccessOrdering(AtomicOrdering Ordering)
AtomicOrdering getSuccessOrdering() const
void setFailureOrdering(AtomicOrdering Ordering)
SyncScope::ID getSyncScopeID() const
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
bool isWeak() const
Return true if this cmpxchg may spuriously fail.
Value * getPointerOperand()
static AtomicRMWInst * create(BinOp Op, Value *Ptr, Value *Val, MaybeAlign Align, AtomicOrdering Ordering, BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx, SyncScope::ID SSID=SyncScope::System, const Twine &Name="")
BinOp getOperation() const
const Value * getPointerOperand() const
unsigned getPointerAddressSpace() const
llvm::AtomicRMWInst::BinOp BinOp
SyncScope::ID getSyncScopeID() const
void setAlignment(Align Align)
const Value * getValOperand() const
void setSyncScopeID(SyncScope::ID SSID)
static StringRef getOperationName(BinOp Op)
void setOrdering(AtomicOrdering Ordering)
AtomicOrdering getOrdering() const
void setOperation(BinOp Op)
static bool classof(const Value *From)
bool isFloatingPointOperation() const
static bool isFPOperation(BinOp Op)
Iterator for Instructions in a `BasicBlock.
BBIterator & operator++()
BBIterator operator++(int)
bool operator!=(const BBIterator &Other) const
BBIterator operator--(int)
pointer get() const
\Returns the SBInstruction that corresponds to this iterator, or null if the instruction is not found...
reference operator*() const
BBIterator & operator--()
std::bidirectional_iterator_tag iterator_category
std::ptrdiff_t difference_type
BBIterator(llvm::BasicBlock *BB, llvm::BasicBlock::iterator It, Context *Ctx)
bool operator==(const BBIterator &Other) const
Contains a list of sandboxir::Instruction's.
void dumpOS(raw_ostream &OS) const final
std::reverse_iterator< iterator > rbegin() const
static bool classof(const Value *From)
For isa/dyn_cast.
void verify() const final
Should crash if there is something wrong with the instruction.
std::reverse_iterator< iterator > rend() const
Function * getParent() const
Instruction & front() const
Instruction * getTerminator() const
Context & getContext() const
Instruction & back() const
static Value * create(Instruction::Opcode Op, Value *LHS, Value *RHS, BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx, const Twine &Name="")
static bool classof(const Value *From)
For isa/dyn_cast.
static Value * createWithCopiedFlags(Instruction::Opcode Op, Value *LHS, Value *RHS, Value *CopyFrom, BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx, const Twine &Name="")
unsigned getNumSuccessors() const
iterator_range< sb_succ_op_iterator > successors()
iterator_range< const_sb_succ_op_iterator > successors() const
static bool classof(const Value *From)
For isa/dyn_cast.
void setCondition(Value *V)
bool isConditional() const
void setSuccessor(unsigned Idx, BasicBlock *NewSucc)
bool isUnconditional() const
BasicBlock * getSuccessor(unsigned SuccIdx) const
static BranchInst * create(BasicBlock *IfTrue, Instruction *InsertBefore, Context &Ctx)
Value * getCondition() const
iterator_range< const_op_iterator > args() const
CallingConv::ID getCallingConv() const
bool isMustTailCall() const
const Function * getCaller() const
FunctionType * getFunctionType() const
void setCalledFunction(Function *F)
const_op_iterator arg_end() const
iterator_range< op_iterator > args()
static bool classof(const Value *From)
Value * getArgOperand(unsigned OpIdx) const
Function * getCalledFunction() const
Use getArgOperandUse(unsigned Idx)
bool isDataOperand(Use U) const
unsigned getArgOperandNo(Use U) const
const_op_iterator data_operands_end() const
op_iterator data_operands_end()
unsigned getDataOperandNo(Use U) const
unsigned getNumTotalBundleOperands() const
Return the total number operands (not operand bundles) used by every operand bundle in this OperandBu...
iterator_range< op_iterator > data_ops()
const_op_iterator data_operands_begin() const
bool data_operands_empty() const
bool hasArgument(const Value *V) const
void setCalledOperand(Value *V)
unsigned arg_size() const
unsigned data_operands_size() const
const_op_iterator arg_begin() const
Intrinsic::ID getIntrinsicID() const
Use getArgOperandUse(unsigned Idx) const
Value * getCalledOperand() const
op_iterator data_operands_begin()
bool isArgOperand(Use U) const
void setArgOperand(unsigned OpIdx, Value *NewOp)
iterator_range< const_op_iterator > data_ops() const
Use getCalledOperandUse() const
bool isCallee(Use U) const
bool isIndirectCall() const
static CallBrInst * create(FunctionType *FTy, Value *Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx, const Twine &NameStr="")
BasicBlock * getIndirectDest(unsigned Idx) const
static bool classof(const Value *From)
void setDefaultDest(BasicBlock *BB)
Value * getIndirectDestLabel(unsigned Idx) const
Value * getIndirectDestLabelUse(unsigned Idx) const
unsigned getNumIndirectDests() const
SmallVector< BasicBlock *, 16 > getIndirectDests() const
BasicBlock * getDefaultDest() const
BasicBlock * getSuccessor(unsigned Idx) const
void setIndirectDest(unsigned Idx, BasicBlock *BB)
unsigned getNumSuccessors() const
static CallInst * create(FunctionType *FTy, Value *Func, ArrayRef< Value * > Args, BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx, const Twine &NameStr="")
static bool classof(const Value *From)
static Value * create(Value *Src, Type *DestTy, Instruction *InsertBefore, Context &Ctx, const Twine &Name="")
static bool classof(const Value *From)
static Value * create(Value *Src, Type *DestTy, BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx, const Twine &Name="")
static Value * create(Value *Src, Type *DestTy, BasicBlock *InsertAtEnd, Context &Ctx, const Twine &Name="")
static Value * create(Type *DestTy, Opcode Op, Value *Operand, BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx, const Twine &Name="")
static bool classof(const Value *From)
For isa/dyn_cast.
const_handler_iterator handler_begin() const
void setParentPad(Value *ParentPad)
const_handler_iterator handler_end() const
static CatchSwitchInst * create(Value *ParentPad, BasicBlock *UnwindBB, unsigned NumHandlers, BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx, const Twine &Name="")
const BasicBlock *(*)(const Value *) ConstDerefFnTy
BasicBlock *(*)(Value *) DerefFnTy
unsigned getNumSuccessors() const
void addHandler(BasicBlock *Dest)
Value * getParentPad() const
bool hasUnwindDest() const
bool unwindsToCaller() const
handler_iterator handler_begin()
mapped_iterator< const_op_iterator, ConstDerefFnTy > const_handler_iterator
void setUnwindDest(BasicBlock *UnwindDest)
mapped_iterator< op_iterator, DerefFnTy > handler_iterator
static bool classof(const Value *From)
BasicBlock * getUnwindDest() const
CatchSwitchInst(llvm::CatchSwitchInst *CSI, Context &Ctx)
handler_iterator handler_end()
unsigned getNumHandlers() const
void setSuccessor(unsigned Idx, BasicBlock *NewSucc)
BasicBlock * getSuccessor(unsigned Idx) const
const_handler_range handlers() const
static ConstantInt * get(Type *Ty, uint64_t V, Context &Ctx, bool IsSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
void verify() const override
Should crash if there is something wrong with the instruction.
unsigned getUseOperandNo(const Use &Use) const override
\Returns the operand index of Use.
void dumpOS(raw_ostream &OS) const override
static bool classof(const sandboxir::Value *From)
For isa/dyn_cast.
sandboxir::Context & getParent() const
void verify() const override
Should crash if there is something wrong with the instruction.
static bool classof(const sandboxir::Value *From)
For isa/dyn_cast.
void dumpOS(raw_ostream &OS) const override
unsigned getUseOperandNo(const Use &Use) const override
\Returns the operand index of Use.
CallBrInst * createCallBrInst(llvm::CallBrInst *I)
GetElementPtrInst * createGetElementPtrInst(llvm::GetElementPtrInst *I)
DenseMap< llvm::Value *, std::unique_ptr< sandboxir::Value > > LLVMValueToValueMap
Maps LLVM Value to the corresponding sandboxir::Value.
Value * registerValue(std::unique_ptr< Value > &&VPtr)
Take ownership of VPtr and store it in LLVMValueToValueMap.
sandboxir::Value * getValue(llvm::Value *V) const
IRBuilder< ConstantFolder > LLVMIRBuilder
Argument * getOrCreateArgument(llvm::Argument *LLVMArg)
Get or create a sandboxir::Argument for an existing LLVM IR LLVMArg.
Function * createFunction(llvm::Function *F)
Create a sandboxir::Function for an existing LLVM IR F, including all blocks and instructions.
Value * getOrCreateValueInternal(llvm::Value *V, llvm::User *U=nullptr)
This is the actual function that creates sandboxir values for V, and among others handles all instruc...
friend ExtractElementInst
auto & getLLVMIRBuilder()
std::unique_ptr< Value > detach(Value *V)
Remove SBV from all SandboxIR maps and stop owning it.
SwitchInst * createSwitchInst(llvm::SwitchInst *I)
UnreachableInst * createUnreachableInst(llvm::UnreachableInst *UI)
const sandboxir::Value * getValue(const llvm::Value *V) const
void accept()
Convenience function for getTracker().accept()
BranchInst * createBranchInst(llvm::BranchInst *I)
Constant * getOrCreateConstant(llvm::Constant *LLVMC)
Get or create a sandboxir::Constant from an existing LLVM IR LLVMC.
BasicBlock * createBasicBlock(llvm::BasicBlock *BB)
Create a sandboxir::BasicBlock for an existing LLVM IR BB.
UnaryOperator * createUnaryOperator(llvm::UnaryOperator *I)
ExtractElementInst * createExtractElementInst(llvm::ExtractElementInst *EEI)
LoadInst * createLoadInst(llvm::LoadInst *LI)
AllocaInst * createAllocaInst(llvm::AllocaInst *I)
Context(LLVMContext &LLVMCtx)
void revert()
Convenience function for getTracker().revert()
CallInst * createCallInst(llvm::CallInst *I)
AtomicRMWInst * createAtomicRMWInst(llvm::AtomicRMWInst *I)
std::unique_ptr< Value > detachLLVMValue(llvm::Value *V)
Remove V from the maps and returns the unique_ptr.
StoreInst * createStoreInst(llvm::StoreInst *SI)
void save()
Convenience function for getTracker().save()
Value * getOrCreateValue(llvm::Value *LLVMV)
Get or create a sandboxir::Value for an existing LLVM IR LLVMV.
InsertElementInst * createInsertElementInst(llvm::InsertElementInst *IEI)
AtomicCmpXchgInst * createAtomicCmpXchgInst(llvm::AtomicCmpXchgInst *I)
CatchSwitchInst * createCatchSwitchInst(llvm::CatchSwitchInst *I)
ReturnInst * createReturnInst(llvm::ReturnInst *I)
PHINode * createPHINode(llvm::PHINode *I)
SelectInst * createSelectInst(llvm::SelectInst *SI)
CastInst * createCastInst(llvm::CastInst *I)
BinaryOperator * createBinaryOperator(llvm::BinaryOperator *I)
InvokeInst * createInvokeInst(llvm::InvokeInst *I)
size_t getNumValues() const
\Returns the number of values registered with Context.
static Value * create(Value *Vec, Value *Idx, Instruction *InsertBefore, Context &Ctx, const Twine &Name="")
const Value * getVectorOperand() const
const Value * getIndexOperand() const
Value * getVectorOperand()
VectorType * getVectorOperandType() const
Value * getIndexOperand()
static bool classof(const Value *From)
static bool isValidOperands(const Value *Vec, const Value *Idx)
Argument * getArg(unsigned Idx) const
FunctionType * getFunctionType() const
void dumpNameAndArgs(raw_ostream &OS) const
void dumpOS(raw_ostream &OS) const final
void verify() const final
Should crash if there is something wrong with the instruction.
static bool classof(const sandboxir::Value *From)
For isa/dyn_cast.
mapped_iterator< llvm::Function::iterator, LLVMBBToBB > iterator
unsigned getAddressSpace() const
bool hasAllConstantIndices() const
bool hasNoUnsignedWrap() const
Value * getPointerOperand() const
iterator_range< op_iterator > indices()
const_op_iterator idx_begin() const
unsigned getPointerAddressSpace() const
GEPNoWrapFlags getNoWrapFlags() const
static Value * create(Type *Ty, Value *Ptr, ArrayRef< Value * > IdxList, BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx, const Twine &NameStr="")
Type * getResultElementType() const
unsigned getNumIndices() const
Type * getPointerOperandType() const
static unsigned getPointerOperandIndex()
Type * getSourceElementType() const
bool hasNoUnsignedSignedWrap() const
static bool classof(const Value *From)
const_op_iterator idx_end() const
bool accumulateConstantOffset(const DataLayout &DL, APInt &Offset) const
iterator_range< const_op_iterator > indices() const
static Value * create(Value *Vec, Value *NewElt, Value *Idx, Instruction *InsertBefore, Context &Ctx, const Twine &Name="")
static bool isValidOperands(const Value *Vec, const Value *NewElt, const Value *Idx)
static bool classof(const Value *From)
A sandboxir::User with operands, opcode and linked with previous/next instructions in an instruction ...
bool hasNoUnsignedWrap() const
Determine whether the no signed wrap flag is set.
friend class UnreachableInst
BBIterator getIterator() const
\Returns a BasicBlock::iterator for this Instruction.
void removeFromParent()
Detach this from its parent BasicBlock without deleting it.
bool hasAllowReassoc() const
Determine whether the allow-reassociation flag is set.
virtual unsigned getNumOfIRInstrs() const =0
This is used by BasicBlock::iterator.
bool hasNoSignedZeros() const
Determine whether the no-signed-zeros flag is set.
void copyFastMathFlags(FastMathFlags FMF)
Convenience function for transferring all fast-math flag values to this instruction,...
void setHasNoSignedZeros(bool B)
Set or clear the no-signed-zeros flag on this instruction, which must be an operator which supports t...
static bool classof(const sandboxir::Value *From)
For isa/dyn_cast.
void moveAfter(Instruction *After)
Move this instruction after After.
bool hasAllowContract() const
Determine whether the allow-contract flag is set.
void setHasAllowContract(bool B)
Set or clear the allow-contract flag on this instruction, which must be an operator which supports th...
void setIsExact(bool B=true)
Set or clear the exact flag on this instruction, which must be an operator which supports this flag.
bool hasApproxFunc() const
Determine whether the approximate-math-functions flag is set.
bool hasNoSignedWrap() const
Determine whether the no signed wrap flag is set.
void setHasNoNaNs(bool B)
Set or clear the no-nans flag on this instruction, which must be an operator which supports this flag...
void insertInto(BasicBlock *BB, const BBIterator &WhereIt)
Insert this detached instruction into BB at WhereIt.
Opcode getOpcode() const
\Returns this Instruction's opcode.
void setHasApproxFunc(bool B)
Set or clear the approximate-math-functions flag on this instruction, which must be an operator which...
bool isFast() const
Determine whether all fast-math-flags are set.
static const char * getOpcodeName(Opcode Opc)
void setHasAllowReassoc(bool B)
Set or clear the reassociation flag on this instruction, which must be an operator which supports thi...
void setFastMathFlags(FastMathFlags FMF)
Convenience function for setting multiple fast-math flags on this instruction, which must be an opera...
void eraseFromParent()
Detach this Value from its parent and delete it.
Instruction * getNextNode() const
\Returns the next sandboxir::Instruction in the block, or nullptr if at the end of the block.
void moveBefore(BasicBlock &BB, const BBIterator &WhereIt)
Move this instruction to WhereIt.
llvm::Instruction * getTopmostLLVMInstruction() const
A SandboxIR Instruction may map to multiple LLVM IR Instruction.
void setHasNoInfs(bool B)
Set or clear the no-infs flag on this instruction, which must be an operator which supports this flag...
void insertAfter(Instruction *AfterI)
Insert this detached instruction after AfterI.
virtual SmallVector< llvm::Instruction *, 1 > getLLVMInstrs() const =0
\Returns the LLVM IR Instructions that this SandboxIR maps to in program order.
void moveBefore(Instruction *Before)
Move this instruction before Before.
void dumpOS(raw_ostream &OS) const override
bool isExact() const
Determine whether the exact flag is set.
Instruction * getPrevNode() const
\Returns the previous sandboxir::Instruction in the block, or nullptr if at the beginning of the bloc...
Instruction(ClassID ID, Opcode Opc, llvm::Instruction *I, sandboxir::Context &SBCtx)
FastMathFlags getFastMathFlags() const
Convenience function for getting all the fast-math flags, which must be an operator which supports th...
void setHasNoSignedWrap(bool B=true)
Set or clear the nsw flag on this instruction, which must be an operator which supports this flag.
void setHasAllowReciprocal(bool B)
Set or clear the allow-reciprocal flag on this instruction, which must be an operator which supports ...
bool hasNoInfs() const
Determine whether the no-infs flag is set.
bool hasNoNaNs() const
Determine whether the no-NaNs flag is set.
bool hasAllowReciprocal() const
Determine whether the allow-reciprocal flag is set.
void setFast(bool B)
Set or clear all fast-math-flags on this instruction, which must be an operator which supports this f...
void setHasNoUnsignedWrap(bool B=true)
Set or clear the nuw flag on this instruction, which must be an operator which supports this flag.
void insertBefore(Instruction *BeforeI)
Insert this detached instruction before BeforeI.
BasicBlock * getParent() const
\Returns the BasicBlock containing this Instruction, or null if it is detached.
Instruction * getLandingPadInst() const
BasicBlock * getSuccessor(unsigned SuccIdx) const
void setNormalDest(BasicBlock *BB)
unsigned getNumSuccessors() const
static InvokeInst * create(FunctionType *FTy, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx, const Twine &NameStr="")
static bool classof(const Value *From)
void setUnwindDest(BasicBlock *BB)
void setSuccessor(unsigned SuccIdx, BasicBlock *NewSucc)
BasicBlock * getNormalDest() const
BasicBlock * getUnwindDest() const
static bool classof(const Value *From)
For isa/dyn_cast.
static LoadInst * create(Type *Ty, Value *Ptr, MaybeAlign Align, Instruction *InsertBefore, Context &Ctx, const Twine &Name="")
void setVolatile(bool V)
Specify whether this is a volatile load or not.
bool isVolatile() const
Return true if this is a load from a volatile memory location.
Value * getPointerOperand() const
An LLLVM Instruction that has no SandboxIR equivalent class gets mapped to an OpaqueInstr.
static bool classof(const sandboxir::Value *From)
Iterator for the Use edges of a User's operands.
OperandUseIterator()=default
std::ptrdiff_t difference_type
value_type operator*() const
std::input_iterator_tag iterator_category
OperandUseIterator operator++(int)
OperandUseIterator operator+(unsigned Num) const
bool operator!=(const OperandUseIterator &Other) const
bool operator==(const OperandUseIterator &Other) const
OperandUseIterator operator-(unsigned Num) const
OperandUseIterator & operator++()
iterator_range< const_block_iterator > blocks() const
const_block_iterator block_end() const
static bool classof(const Value *From)
For isa/dyn_cast.
const_op_range incoming_values() const
void setIncomingBlock(unsigned Idx, BasicBlock *BB)
bool hasConstantOrUndefValue() const
void replaceIncomingBlockWith(const BasicBlock *Old, BasicBlock *New)
void setIncomingValue(unsigned Idx, Value *V)
unsigned getNumIncomingValues() const
void addIncoming(Value *V, BasicBlock *BB)
const_block_iterator block_begin() const
int getBasicBlockIndex(const BasicBlock *BB) const
mapped_iterator< llvm::PHINode::const_block_iterator, LLVMBBToBB > const_block_iterator
Value * removeIncomingValue(unsigned Idx)
void removeIncomingValueIf(function_ref< bool(unsigned)> Predicate)
Value * hasConstantValue() const
op_range incoming_values()
static unsigned getIncomingValueNumForOperand(unsigned Idx)
Value * getIncomingValueForBlock(const BasicBlock *BB) const
BasicBlock * getIncomingBlock(unsigned Idx) const
static unsigned getOperandNumForIncomingValue(unsigned Idx)
static PHINode * create(Type *Ty, unsigned NumReservedValues, Instruction *InsertBefore, Context &Ctx, const Twine &Name="")
Value * getIncomingValue(unsigned Idx) const
static bool classof(const Value *From)
Value * getReturnValue() const
\Returns null if there is no return value.
static ReturnInst * create(Value *RetVal, Instruction *InsertBefore, Context &Ctx)
static Value * create(Value *Cond, Value *True, Value *False, Instruction *InsertBefore, Context &Ctx, const Twine &Name="")
void setTrueValue(Value *New)
static bool classof(const Value *From)
For isa/dyn_cast.
void setCondition(Value *New)
void setFalseValue(Value *New)
Instructions that contain a single LLVM Instruction can inherit from this.
void dumpOS(raw_ostream &OS) const override
void verify() const final
Should crash if there is something wrong with the instruction.
unsigned getUseOperandNo(const Use &Use) const final
\Returns the operand index of Use.
unsigned getNumOfIRInstrs() const final
This is used by BasicBlock::iterator.
static bool classof(const Value *From)
For isa/dyn_cast.
void setVolatile(bool V)
Specify whether this is a volatile store or not.
static StoreInst * create(Value *V, Value *Ptr, MaybeAlign Align, Instruction *InsertBefore, Context &Ctx)
bool isVolatile() const
Return true if this is a store from a volatile memory location.
Value * getPointerOperand() const
Value * getValueOperand() const
BasicBlock * getSuccessor(unsigned Idx) const
CaseIt findCaseValue(const ConstantInt *C)
iterator_range< ConstCaseIt > cases() const
bool defaultDestUndefined() const
void setSuccessor(unsigned Idx, BasicBlock *NewSucc)
void setDefaultDest(BasicBlock *DefaultCase)
CaseIt case_begin()
Returns a read/write iterator that points to the first case in the SwitchInst.
iterator_range< CaseIt > cases()
Iteration adapter for range-for loops.
void addCase(ConstantInt *OnVal, BasicBlock *Dest)
llvm::SwitchInst::CaseIteratorImpl< CaseHandle > CaseIt
SwitchInst(llvm::SwitchInst *SI, Context &Ctx)
ConstCaseIt case_begin() const
ConstCaseIt case_end() const
llvm::SwitchInst::CaseIteratorImpl< ConstCaseHandle > ConstCaseIt
ConstCaseIt case_default() const
static bool classof(const Value *From)
BasicBlock * getDefaultDest() const
void setCondition(Value *V)
static SwitchInst * create(Value *V, BasicBlock *Dest, unsigned NumCases, BasicBlock::iterator WhereIt, BasicBlock *WhereBB, Context &Ctx, const Twine &Name="")
Value * getCondition() const
unsigned getNumCases() const
unsigned getNumSuccessors() const
CaseIt case_end()
Returns a read/write iterator that points one past the last in the SwitchInst.
ConstCaseIt findCaseValue(const ConstantInt *C) const
ConstantInt * findCaseDest(BasicBlock *BB)
static constexpr const unsigned DefaultPseudoIndex
CaseIt removeCase(CaseIt It)
This method removes the specified case and its successor from the switch instruction.
The tracker collects all the change objects and implements the main API for saving / reverting / acce...
void revert()
Stops tracking and reverts to saved state.
void save()
Turns on IR tracking.
void accept()
Stops tracking and accept changes.
An abstract class, parent of unary instructions.
static bool classof(const Instruction *I)
UnaryInstruction(ClassID ID, Opcode Opc, llvm::Instruction *LLVMI, Context &Ctx)
static bool classof(const Value *V)
static bool classof(const Value *From)
For isa/dyn_cast.
static Value * create(Instruction::Opcode Op, Value *OpV, BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx, const Twine &Name="")
static Value * createWithCopiedFlags(Instruction::Opcode Op, Value *OpV, Value *CopyFrom, BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx, const Twine &Name="")
static bool classof(const Value *From)
static UnreachableInst * create(Instruction *InsertBefore, Context &Ctx)
unsigned getNumOfIRInstrs() const final
This is used by BasicBlock::iterator.
unsigned getUseOperandNo(const Use &Use) const final
\Returns the operand index of Use.
unsigned getNumSuccessors() const
Represents a Def-use/Use-def edge in SandboxIR.
unsigned getOperandNo() const
class User * getUser() const
Iterator for the Use edges of a Value's users.
const sandboxir::Use & getUse() const
std::input_iterator_tag iterator_category
std::ptrdiff_t difference_type
bool operator!=(const UserUseIterator &Other) const
UserUseIterator & operator++()
value_type operator*() const
bool operator==(const UserUseIterator &Other) const
UserUseIterator()=default
A sandboxir::User has operands.
virtual op_iterator op_begin()
void dumpOS(raw_ostream &OS) const override
friend class OperandUseIterator
Value * getOperand(unsigned OpIdx) const
virtual unsigned getUseOperandNo(const Use &Use) const =0
\Returns the operand index of Use.
unsigned getUseOperandNoDefault(const Use &Use) const
The default implementation works only for single-LLVMIR-instruction Users and only if they match exac...
virtual const_op_iterator op_end() const
static bool classof(const Value *From)
For isa/dyn_cast.
bool replaceUsesOfWith(Value *FromV, Value *ToV)
Replaces any operands that match FromV with ToV.
void verifyUserOfLLVMUse(const llvm::Use &Use) const
void verify() const override
Should crash if there is something wrong with the instruction.
Use getOperandUseDefault(unsigned OpIdx, bool Verify) const
\Returns the Use edge that corresponds to OpIdx.
OperandUseIterator op_iterator
const_op_range operands() const
virtual void setOperand(unsigned OperandIdx, Value *Operand)
virtual Use getOperandUseInternal(unsigned OpIdx, bool Verify) const =0
\Returns the Use for the OpIdx'th operand.
void swapOperandsInternal(unsigned OpIdxA, unsigned OpIdxB)
virtual unsigned getNumOperands() const
virtual const_op_iterator op_begin() const
Use getOperandUse(unsigned OpIdx) const
\Returns the operand edge for OpIdx.
virtual op_iterator op_end()
User(ClassID ID, llvm::Value *V, Context &Ctx)
void dumpCommonHeader(raw_ostream &OS) const final
A SandboxIR Value has users. This is the base class.
mapped_iterator< sandboxir::UserUseIterator, UseToUser > user_iterator
LLVM_DUMP_METHOD void dump() const
llvm::Value * Val
The LLVM Value that corresponds to this SandboxIR Value.
std::string getUid() const
Returns the unique id in the form 'SB<number>.' like 'SB1.'.
const_use_iterator use_end() const
user_iterator user_begin()
void replaceAllUsesWith(Value *Other)
ClassID getSubclassID() const
StringRef getName() const
\Returns the LLVM IR name of the bottom-most LLVM value.
virtual void verify() const =0
Should crash if there is something wrong with the instruction.
void dumpCommonFooter(raw_ostream &OS) const
virtual void dumpCommonHeader(raw_ostream &OS) const
UserUseIterator use_iterator
Context & Ctx
All values point to the context.
ClassID SubclassID
For isa/dyn_cast.
void dumpCommonSuffix(raw_ostream &OS) const
friend class LLVMOpUserItToSBTy
const_use_iterator use_begin() const
Context & getContext() const
const_user_iterator user_begin() const
bool hasNUsesOrMore(unsigned Num) const
Return true if this value has N uses or more.
Value & operator=(const Value &)=delete
iterator_range< const_user_iterator > users() const
iterator_range< user_iterator > users()
void replaceUsesWithIf(Value *OtherV, llvm::function_ref< bool(const Use &)> ShouldReplace)
unsigned getNumUses() const
\Returns the number of user edges (not necessarily to unique users).
bool hasNUses(unsigned Num) const
Return true if this Value has exactly N uses.
unsigned UID
A unique ID used for forming the name (used for debugging).
virtual void dumpOS(raw_ostream &OS) const =0
iterator_range< use_iterator > uses()
const_user_iterator user_end() const
void dumpCommonPrefix(raw_ostream &OS) const
void printAsOperandCommon(raw_ostream &OS) const
static const char * getSubclassIDStr(ClassID ID)
Value(const Value &)=delete
Disable copies.
friend raw_ostream & operator<<(raw_ostream &OS, const sandboxir::Value &V)
iterator_range< const_use_iterator > uses() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
@ BasicBlock
Various leaf nodes.
@ System
Synchronized with respect to all concurrently executing threads.
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
mapped_iterator< ItTy, FuncTy > map_iterator(ItTy I, FuncTy F)
AtomicOrdering
Atomic ordering for LLVM's memory model.
DWARFExpression::Operation Op
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
This struct is a compact representation of a valid (non-zero power of two) alignment.
The const version of succ_op_iterator.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Helper for mapped_iterator.
User * operator()(const Use &Use) const