9#ifndef LLVM_SANDBOXIR_INSTRUCTION_H
10#define LLVM_SANDBOXIR_INSTRUCTION_H
31 assert(InsertAtEnd !=
nullptr &&
"Expected non-null!");
32 InsertAt = InsertAtEnd->
end();
35 operator BBIterator() {
return InsertAt; }
47#define OPCODES(...) __VA_ARGS__
48#define DEF_INSTR(ID, OPC, CLASS) OPC
49#include "llvm/SandboxIR/Values.def"
107 auto &
Ctx = WhereBB->getContext();
108 auto &Builder =
Ctx.getLLVMIRBuilder();
109 if (WhereIt != WhereBB->end())
110 Builder.SetInsertPoint((*Pos).getTopmostLLVMInstruction());
358 bool mayThrow(
bool IncludePhaseOneUnwind =
false)
const {
378template <
typename LLVMT>
class SingleLLVMInstructionImpl :
public Instruction {
384#define DEF_INSTR(ID, OPC, CLASS) friend class CLASS;
385#include "llvm/SandboxIR/Values.def"
391 Use getOperandUseInternal(
unsigned OpIdx,
bool Verify)
const final {
412class FenceInst :
public SingleLLVMInstructionImpl<llvm::FenceInst> {
414 : SingleLLVMInstructionImpl(ClassID::Fence, Opcode::Fence, FI,
Ctx) {}
439class SelectInst :
public SingleLLVMInstructionImpl<llvm::SelectInst> {
443 : SingleLLVMInstructionImpl(ClassID::Select, Opcode::Select, CI,
Ctx) {}
449 const Twine &Name =
"");
475class InsertElementInst final
476 :
public SingleLLVMInstructionImpl<llvm::InsertElementInst> {
479 : SingleLLVMInstructionImpl(ClassID::InsertElement, Opcode::InsertElement,
486 const Twine &Name =
"");
497class ExtractElementInst final
498 :
public SingleLLVMInstructionImpl<llvm::ExtractElementInst> {
501 : SingleLLVMInstructionImpl(ClassID::ExtractElement,
502 Opcode::ExtractElement,
I,
Ctx) {}
523class ShuffleVectorInst final
524 :
public SingleLLVMInstructionImpl<llvm::ShuffleVectorInst> {
527 : SingleLLVMInstructionImpl(ClassID::ShuffleVector, Opcode::ShuffleVector,
534 const Twine &Name =
"");
537 const Twine &Name =
"");
831 int &NumSubElts,
int &Index) {
836 int &NumSubElts,
int &Index) {
865 ReplicationFactor, VF);
890 unsigned InVecNumElts) {
919 unsigned NumInputElts,
925 unsigned NumInputElts) {
954 unsigned MinSubElts,
unsigned MaxSubElts,
955 unsigned &NumSubElts,
unsigned &RotateAmt) {
957 Mask, EltSizeInBits, MinSubElts, MaxSubElts, NumSubElts, RotateAmt);
962 :
public SingleLLVMInstructionImpl<llvm::InsertValueInst> {
965 : SingleLLVMInstructionImpl(ClassID::InsertValue, Opcode::InsertValue,
972 const Twine &Name =
"");
1022class BranchInst :
public SingleLLVMInstructionImpl<llvm::BranchInst> {
1025 : SingleLLVMInstructionImpl(ClassID::Br, Opcode::Br, BI,
Ctx) {}
1050 struct LLVMBBToSBBB {
1052 LLVMBBToSBBB(
Context &Ctx) : Ctx(Ctx) {}
1056 struct ConstLLVMBBToSBBB {
1058 ConstLLVMBBToSBBB(Context &Ctx) : Ctx(Ctx) {}
1068 LLVMBBToSBBB BBMap(
Ctx);
1081 ConstLLVMBBToSBBB ConstBBMap(
Ctx);
1086 return make_range(ConstMappedBegin, ConstMappedEnd);
1092 :
public SingleLLVMInstructionImpl<llvm::UnaryInstruction> {
1096 : SingleLLVMInstructionImpl(
ID,
Opc, LLVMI,
Ctx) {}
1117 const Twine &Name =
"");
1171 Context &
Ctx,
const Twine &Name =
"");
1191 const Twine &Name =
"");
1214 const Twine &Name =
"") {
1226class StoreInst final :
public SingleLLVMInstructionImpl<llvm::StoreInst> {
1229 : SingleLLVMInstructionImpl(ClassID::Store, Opcode::Store,
SI,
Ctx) {}
1260 Use getOperandUseInternal(
unsigned OpIdx,
bool Verify)
const final {
1277class ReturnInst final :
public SingleLLVMInstructionImpl<llvm::ReturnInst> {
1280 : SingleLLVMInstructionImpl(ClassID::Ret, Opcode::Ret,
I,
Ctx) {}
1297class CallBase :
public SingleLLVMInstructionImpl<llvm::CallBase> {
1299 : SingleLLVMInstructionImpl(
ID,
Opc,
I,
Ctx) {}
1307 return Opc == Instruction::ClassID::Call ||
1308 Opc == Instruction::ClassID::Invoke ||
1309 Opc == Instruction::ClassID::CallBr;
1320 auto Dist = LLVMCB->data_operands_end() - LLVMCB->data_operands_begin();
1325 auto Dist = LLVMCB->data_operands_end() - LLVMCB->data_operands_begin();
1341 assert(
this == U.getUser() &&
1342 "Only valid to query with a use of this instruction!");
1362 return const_cast<CallBase *
>(
this)->
arg_end();
1411 return const_cast<CallBase *
>(
this)->
getCaller();
1428class CallInst :
public CallBase {
1446class InvokeInst final :
public CallBase {
1471 assert(SuccIdx < 2 &&
"Successor # out of range for invoke!");
1482class CallBrInst final :
public CallBase {
1515class LandingPadInst :
public SingleLLVMInstructionImpl<llvm::LandingPadInst> {
1517 : SingleLLVMInstructionImpl(ClassID::LandingPad, Opcode::LandingPad, LP,
1523 unsigned NumReservedClauses,
1525 const Twine &Name =
"");
1560class FuncletPadInst :
public SingleLLVMInstructionImpl<llvm::FuncletPadInst> {
1590class CatchPadInst :
public FuncletPadInst {
1602 const Twine &Name =
"");
1608class CleanupPadInst :
public FuncletPadInst {
1617 const Twine &Name =
"");
1623class CatchReturnInst
1624 :
public SingleLLVMInstructionImpl<llvm::CatchReturnInst> {
1626 : SingleLLVMInstructionImpl(ClassID::CatchRet, Opcode::CatchRet, CRI,
1647class CleanupReturnInst
1648 :
public SingleLLVMInstructionImpl<llvm::CleanupReturnInst> {
1650 : SingleLLVMInstructionImpl(ClassID::CleanupRet, Opcode::CleanupRet, CRI,
1677class GetElementPtrInst final
1678 :
public SingleLLVMInstructionImpl<llvm::GetElementPtrInst> {
1682 : SingleLLVMInstructionImpl(ClassID::GetElementPtr, Opcode::GetElementPtr,
1685 : SingleLLVMInstructionImpl(
SubclassID, Opcode::GetElementPtr,
I,
Ctx) {}
1692 const Twine &NameStr =
"");
1706 return const_cast<GetElementPtrInst *
>(
this)->
idx_begin();
1710 return const_cast<GetElementPtrInst *
>(
this)->
idx_end();
1716 return const_cast<GetElementPtrInst *
>(
this)->
indices();
1755class CatchSwitchInst
1756 :
public SingleLLVMInstructionImpl<llvm::CatchSwitchInst> {
1758 : SingleLLVMInstructionImpl(ClassID::CatchSwitch, Opcode::CatchSwitch,
1832 "Successor # out of range for catchswitch!");
1837 "Successor # out of range for catchswitch!");
1846class ResumeInst :
public SingleLLVMInstructionImpl<llvm::ResumeInst> {
1848 : SingleLLVMInstructionImpl(ClassID::Resume, Opcode::Resume, CSI,
Ctx) {}
1863class SwitchInst :
public SingleLLVMInstructionImpl<llvm::SwitchInst> {
1865 : SingleLLVMInstructionImpl(ClassID::Switch, Opcode::Switch,
SI,
Ctx) {}
1917 const_cast<const SwitchInst *
>(
this)->
findCaseValue(
C)->getCaseIndex());
1952 case llvm::Instruction::FNeg:
1953 return Opcode::FNeg;
1954 case llvm::Instruction::UnaryOpsEnd:
1966 const Twine &Name =
"");
1970 const Twine &Name =
"");
1981 case llvm::Instruction::Add:
1983 case llvm::Instruction::FAdd:
1984 return Opcode::FAdd;
1985 case llvm::Instruction::Sub:
1987 case llvm::Instruction::FSub:
1988 return Opcode::FSub;
1989 case llvm::Instruction::Mul:
1991 case llvm::Instruction::FMul:
1992 return Opcode::FMul;
1993 case llvm::Instruction::UDiv:
1994 return Opcode::UDiv;
1995 case llvm::Instruction::SDiv:
1996 return Opcode::SDiv;
1997 case llvm::Instruction::FDiv:
1998 return Opcode::FDiv;
1999 case llvm::Instruction::URem:
2000 return Opcode::URem;
2001 case llvm::Instruction::SRem:
2002 return Opcode::SRem;
2003 case llvm::Instruction::FRem:
2004 return Opcode::FRem;
2005 case llvm::Instruction::Shl:
2007 case llvm::Instruction::LShr:
2008 return Opcode::LShr;
2009 case llvm::Instruction::AShr:
2010 return Opcode::AShr;
2011 case llvm::Instruction::And:
2013 case llvm::Instruction::Or:
2015 case llvm::Instruction::Xor:
2017 case llvm::Instruction::BinaryOpsEnd:
2031 const Twine &Name =
"");
2037 const Twine &Name =
"");
2061class AtomicRMWInst :
public SingleLLVMInstructionImpl<llvm::AtomicRMWInst> {
2063 : SingleLLVMInstructionImpl(ClassID::AtomicRMW,
2064 Instruction::Opcode::AtomicRMW, Atomic,
Ctx) {
2120class AtomicCmpXchgInst
2121 :
public SingleLLVMInstructionImpl<llvm::AtomicCmpXchgInst> {
2123 : SingleLLVMInstructionImpl(ClassID::AtomicCmpXchg,
2124 Instruction::Opcode::AtomicCmpXchg, Atomic,
2208 Value *ArraySize =
nullptr,
2209 const Twine &Name =
"");
2263 return I->getSubclassID() == Instruction::ClassID::Alloca;
2271 case llvm::Instruction::ZExt:
2272 return Opcode::ZExt;
2273 case llvm::Instruction::SExt:
2274 return Opcode::SExt;
2275 case llvm::Instruction::FPToUI:
2276 return Opcode::FPToUI;
2277 case llvm::Instruction::FPToSI:
2278 return Opcode::FPToSI;
2279 case llvm::Instruction::FPExt:
2280 return Opcode::FPExt;
2281 case llvm::Instruction::PtrToAddr:
2282 return Opcode::PtrToAddr;
2283 case llvm::Instruction::PtrToInt:
2284 return Opcode::PtrToInt;
2285 case llvm::Instruction::IntToPtr:
2286 return Opcode::IntToPtr;
2287 case llvm::Instruction::SIToFP:
2288 return Opcode::SIToFP;
2289 case llvm::Instruction::UIToFP:
2290 return Opcode::UIToFP;
2291 case llvm::Instruction::Trunc:
2292 return Opcode::Trunc;
2293 case llvm::Instruction::FPTrunc:
2294 return Opcode::FPTrunc;
2295 case llvm::Instruction::BitCast:
2296 return Opcode::BitCast;
2297 case llvm::Instruction::AddrSpaceCast:
2298 return Opcode::AddrSpaceCast;
2299 case llvm::Instruction::CastOpsEnd:
2314 const Twine &Name =
"");
2331 switch (
I->getOpcode()) {
2333 case Opcode::UIToFP:
2347 Context &
Ctx,
const Twine &Name =
"") {
2353 return I->getOpcode() ==
Op;
2370 :
public CastInstImpl<Instruction::Opcode::PtrToAddr> {};
2375 :
public CastInstImpl<Instruction::Opcode::AddrSpaceCast> {
2395class PHINode final :
public SingleLLVMInstructionImpl<llvm::PHINode> {
2398 : SingleLLVMInstructionImpl(ClassID::PHI, Opcode::PHI,
PHI,
Ctx) {}
2410 const Twine &Name =
"");
2418 LLVMBBToBB BBGetter(
Ctx);
2423 LLVMBBToBB BBGetter(
Ctx);
2475#define WRAP_STATIC_PREDICATE(FunctionName) \
2476 static auto FunctionName(Predicate P) { return LLVMValType::FunctionName(P); }
2479#define WRAP_MEMBER(FunctionName) \
2480 auto FunctionName() const { return cast<LLVMValType>(Val)->FunctionName(); }
2482#define WRAP_BOTH(FunctionName) \
2483 WRAP_STATIC_PREDICATE(FunctionName) \
2484 WRAP_MEMBER(FunctionName)
2486class CmpInst :
public SingleLLVMInstructionImpl<llvm::CmpInst> {
2491 : SingleLLVMInstructionImpl(Id,
Opc, CI,
Ctx) {}
2502 const Twine &Name =
"");
2507 const Twine &Name =
"");
2552 :
CmpInst(CI,
Ctx, ClassID::ICmp, Opcode::ICmp) {}
2589 :
CmpInst(CI,
Ctx, ClassID::FCmp, Opcode::FCmp) {}
2611#undef WRAP_STATIC_PREDICATE
2617class OpaqueInst :
public SingleLLVMInstructionImpl<llvm::Instruction> {
2619 : SingleLLVMInstructionImpl(ClassID::Opaque, Opcode::Opaque,
I,
Ctx) {}
2621 : SingleLLVMInstructionImpl(
SubclassID, Opcode::Opaque,
I,
Ctx) {}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
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.
static bool isSigned(unsigned int Opcode)
Module.h This file contains the declarations for the Module class.
MachineInstr unsigned OpIdx
ppc ctr loops PowerPC CTR Loops Verify
const SmallVectorImpl< MachineOperand > & Cond
Class for arbitrary precision integers.
an instruction to allocate memory on the stack
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 LLVM_ABI StringRef getOperationName(BinOp Op)
LLVM Basic Block Representation.
Conditional or Unconditional Branch instruction.
This is the base class for all instructions that perform data casts.
Instruction::CastOps getOpcode() const
Return the opcode of this CastInst.
This class is the base class for the comparison instructions.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
An abstraction over a floating-point predicate, and a pack of an integer predicate with samesign info...
A parsed version of the target data layout string in and methods for querying it.
This instruction compares its operands according to the predicate given to the constructor.
static LLVM_ABI bool compare(const APFloat &LHS, const APFloat &RHS, FCmpInst::Predicate Pred)
Return result of LHS Pred RHS comparison.
static auto predicates()
Returns the sequence of all FCmp predicates.
Convenience struct for specifying and reasoning about fast-math flags.
An instruction for ordering other memory operations.
This class represents a freeze function that returns random concrete value if an operand is either a ...
Represents flags for the getelementptr instruction/expression.
static unsigned getPointerOperandIndex()
This instruction compares its operands according to the predicate given to the constructor.
static LLVM_ABI bool compare(const APInt &LHS, const APInt &RHS, ICmpInst::Predicate Pred)
Return result of LHS Pred RHS comparison.
static LLVM_ABI std::optional< bool > isImpliedByMatchingCmp(CmpPredicate Pred1, CmpPredicate Pred2)
Determine if Pred1 implies Pred2 is true, false, or if nothing can be inferred about the implication,...
static auto predicates()
Returns the sequence of all ICmp predicates.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
static LLVM_ABI 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 instruction inserts a struct field of array element value into an aggregate value.
static unsigned getAggregateOperandIndex()
const unsigned * idx_iterator
static unsigned getInsertedValueOperandIndex()
The landingpad instruction holds all of the information necessary to generate correct exception handl...
An instruction for reading from memory.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
static unsigned getOperandNumForIncomingValue(unsigned i)
static unsigned getIncomingValueNumForOperand(unsigned i)
Resume the propagation of an exception.
This class represents the LLVM 'select' instruction.
static LLVM_ABI const char * areInvalidOperands(Value *Cond, Value *True, Value *False)
Return a string if the specified operands are invalid for a select operation, otherwise return null.
static LLVM_ABI bool isZeroEltSplatMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask chooses all elements with the same value as the first element of exa...
ArrayRef< int > getShuffleMask() const
static LLVM_ABI bool isSpliceMask(ArrayRef< int > Mask, int NumSrcElts, int &Index)
Return true if this shuffle mask is a splice mask, concatenating the two inputs together and then ext...
static LLVM_ABI bool isValidOperands(const Value *V1, const Value *V2, const Value *Mask)
Return true if a shufflevector instruction can be formed with the specified operands.
static LLVM_ABI bool isSelectMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask chooses elements from its source vectors without lane crossings.
static LLVM_ABI bool isBitRotateMask(ArrayRef< int > Mask, unsigned EltSizeInBits, unsigned MinSubElts, unsigned MaxSubElts, unsigned &NumSubElts, unsigned &RotateAmt)
Checks if the shuffle is a bit rotation of the first operand across multiple subelements,...
static LLVM_ABI bool isOneUseSingleSourceMask(ArrayRef< int > Mask, int VF)
Return true if this shuffle mask represents "clustered" mask of size VF, i.e.
static LLVM_ABI bool isSingleSourceMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask chooses elements from exactly one source vector.
static LLVM_ABI bool isDeInterleaveMaskOfFactor(ArrayRef< int > Mask, unsigned Factor, unsigned &Index)
Check if the mask is a DE-interleave mask of the given factor Factor like: <Index,...
static LLVM_ABI bool isIdentityMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask chooses elements from exactly one source vector without lane crossin...
static LLVM_ABI bool isExtractSubvectorMask(ArrayRef< int > Mask, int NumSrcElts, int &Index)
Return true if this shuffle mask is an extract subvector mask.
static LLVM_ABI bool isReverseMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask swaps the order of elements from exactly one source vector.
static void commuteShuffleMask(MutableArrayRef< int > Mask, unsigned InVecNumElts)
Change values in a shuffle permute mask assuming the two vector operands of length InVecNumElts have ...
static LLVM_ABI bool isTransposeMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask is a transpose mask.
static LLVM_ABI bool isInsertSubvectorMask(ArrayRef< int > Mask, int NumSrcElts, int &NumSubElts, int &Index)
Return true if this shuffle mask is an insert subvector mask.
static LLVM_ABI bool isReplicationMask(ArrayRef< int > Mask, int &ReplicationFactor, int &VF)
Return true if this shuffle mask replicates each of the VF elements in a vector ReplicationFactor tim...
static LLVM_ABI bool isInterleaveMask(ArrayRef< int > Mask, unsigned Factor, unsigned NumInputElts, SmallVectorImpl< unsigned > &StartIndexes)
Return true if the mask interleaves one or more input vectors together.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
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.
A handle to a particular switch case.
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...
UnaryOps getOpcode() const
This function has undefined behavior.
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
static unsigned getPointerOperandIndex()
LLVM Value Representation.
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.
LLVM_ABI 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.
LLVM_ABI void setAllocatedType(Type *Ty)
for use only in special circumstances that need to generically transform a whole instruction (eg: IR ...
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.
LLVM_ABI Value * getArraySize()
Get the number of elements allocated.
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.
LLVM_ABI PointerType * getType() const
Overload to return most specific pointer type.
LLVM_ABI void setUsedWithInAlloca(bool V)
Specify whether this alloca is used to represent the arguments to a call.
static bool classof(const Value *From)
std::optional< TypeSize > getAllocationSize(const DataLayout &DL) const
Get allocation size in bytes.
LLVM_ABI void setAlignment(Align Align)
const Value * getArraySize() const
static LLVM_ABI AllocaInst * create(Type *Ty, unsigned AddrSpace, InsertPosition Pos, Context &Ctx, Value *ArraySize=nullptr, const Twine &Name="")
LLVM_ABI Value * getPointerOperand()
const Value * getNewValOperand() const
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
AtomicOrdering getMergedOrdering() const
LLVM_ABI void setSuccessOrdering(AtomicOrdering Ordering)
const Value * getCompareOperand() const
LLVM_ABI void setWeak(bool IsWeak)
LLVM_ABI void setVolatile(bool V)
Specify whether this is a volatile cmpxchg.
const Value * getPointerOperand() const
LLVM_ABI void setFailureOrdering(AtomicOrdering Ordering)
static bool classof(const Value *From)
AtomicOrdering getFailureOrdering() const
LLVM_ABI void setAlignment(Align Align)
LLVM_ABI Value * getCompareOperand()
static LLVM_ABI AtomicCmpXchgInst * create(Value *Ptr, Value *Cmp, Value *New, MaybeAlign Align, AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering, InsertPosition Pos, Context &Ctx, SyncScope::ID SSID=SyncScope::System, const Twine &Name="")
static bool isValidFailureOrdering(AtomicOrdering Ordering)
bool isVolatile() const
Return true if this is a cmpxchg from a volatile memory location.
static bool isValidSuccessOrdering(AtomicOrdering Ordering)
LLVM_ABI void setSyncScopeID(SyncScope::ID SSID)
AtomicOrdering getSuccessOrdering() const
SyncScope::ID getSyncScopeID() const
LLVM_ABI Value * getNewValOperand()
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.
LLVM_ABI Value * getValOperand()
static LLVM_ABI AtomicRMWInst * create(BinOp Op, Value *Ptr, Value *Val, MaybeAlign Align, AtomicOrdering Ordering, InsertPosition Pos, Context &Ctx, SyncScope::ID SSID=SyncScope::System, const Twine &Name="")
BinOp getOperation() const
const Value * getPointerOperand() const
LLVM_ABI void setSyncScopeID(SyncScope::ID SSID)
unsigned getPointerAddressSpace() const
llvm::AtomicRMWInst::BinOp BinOp
LLVM_ABI void setOrdering(AtomicOrdering Ordering)
SyncScope::ID getSyncScopeID() const
LLVM_ABI void setVolatile(bool V)
const Value * getValOperand() const
static StringRef getOperationName(BinOp Op)
AtomicOrdering getOrdering() const
void setOperation(BinOp Op)
LLVM_ABI Value * getPointerOperand()
static bool classof(const Value *From)
bool isFloatingPointOperation() const
static bool isFPOperation(BinOp Op)
LLVM_ABI void setAlignment(Align Align)
static LLVM_ABI Value * create(Instruction::Opcode Op, Value *LHS, Value *RHS, InsertPosition Pos, Context &Ctx, const Twine &Name="")
static Opcode getBinOpOpcode(llvm::Instruction::BinaryOps BinOp)
static bool classof(const Value *From)
For isa/dyn_cast.
BinaryOperator(llvm::BinaryOperator *BinOp, Context &Ctx)
static LLVM_ABI Value * createWithCopiedFlags(Instruction::Opcode Op, Value *LHS, Value *RHS, Value *CopyFrom, InsertPosition Pos, Context &Ctx, const Twine &Name="")
LLVM_ABI BasicBlock * getSuccessor(unsigned SuccIdx) const
LLVM_ABI Value * getCondition() const
mapped_iterator< llvm::BranchInst::const_succ_op_iterator, ConstLLVMBBToSBBB > const_sb_succ_op_iterator
LLVM_ABI void setSuccessor(unsigned Idx, BasicBlock *NewSucc)
unsigned getNumSuccessors() const
iterator_range< sb_succ_op_iterator > successors()
static LLVM_ABI BranchInst * create(BasicBlock *IfTrue, InsertPosition Pos, Context &Ctx)
static LLVM_ABI bool classof(const Value *From)
For isa/dyn_cast.
mapped_iterator< llvm::BranchInst::succ_op_iterator, LLVMBBToSBBB > sb_succ_op_iterator
iterator_range< const_sb_succ_op_iterator > successors() const
void setCondition(Value *V)
bool isConditional() const
bool isUnconditional() const
iterator_range< const_op_iterator > args() const
CallingConv::ID getCallingConv() const
bool isMustTailCall() const
const Function * getCaller() const
LLVM_ABI Function * getCalledFunction() const
LLVM_ABI Use getCalledOperandUse() const
LLVM_ABI FunctionType * getFunctionType() const
const_op_iterator arg_end() const
iterator_range< op_iterator > args()
static bool classof(const Value *From)
Value * getArgOperand(unsigned OpIdx) const
LLVM_ABI void setCalledFunction(Function *F)
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()
LLVM_ABI Function * getCaller()
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
LLVM_ABI Value * getCalledOperand() 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
op_iterator data_operands_begin()
bool isArgOperand(Use U) const
void setArgOperand(unsigned OpIdx, Value *NewOp)
iterator_range< const_op_iterator > data_ops() const
bool isCallee(Use U) const
bool isIndirectCall() const
LLVM_ABI Value * getIndirectDestLabelUse(unsigned Idx) const
static LLVM_ABI CallBrInst * create(FunctionType *FTy, Value *Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, InsertPosition Pos, Context &Ctx, const Twine &NameStr="")
LLVM_ABI Value * getIndirectDestLabel(unsigned Idx) const
LLVM_ABI BasicBlock * getSuccessor(unsigned Idx) const
static bool classof(const Value *From)
LLVM_ABI void setIndirectDest(unsigned Idx, BasicBlock *BB)
LLVM_ABI BasicBlock * getDefaultDest() const
unsigned getNumIndirectDests() const
LLVM_ABI BasicBlock * getIndirectDest(unsigned Idx) const
LLVM_ABI SmallVector< BasicBlock *, 16 > getIndirectDests() const
unsigned getNumSuccessors() const
LLVM_ABI void setDefaultDest(BasicBlock *BB)
static LLVM_ABI CallInst * create(FunctionType *FTy, Value *Func, ArrayRef< Value * > Args, InsertPosition Pos, Context &Ctx, const Twine &NameStr="")
friend class IntrinsicInst
static bool classof(const Value *From)
static bool classof(const Value *From)
static Value * create(Value *Src, Type *DestTy, InsertPosition Pos, Context &Ctx, const Twine &Name="")
LLVM_ABI Type * getSrcTy() const
static LLVM_ABI Value * create(Type *DestTy, Opcode Op, Value *Operand, InsertPosition Pos, Context &Ctx, const Twine &Name="")
LLVM_ABI Type * getDestTy() const
static LLVM_ABI bool classof(const Value *From)
For isa/dyn_cast.
static bool classof(const Value *From)
static LLVM_ABI CatchPadInst * create(Value *ParentPad, ArrayRef< Value * > Args, InsertPosition Pos, Context &Ctx, const Twine &Name="")
LLVM_ABI CatchSwitchInst * getCatchSwitch() const
LLVM_ABI CatchPadInst * getCatchPad() const
LLVM_ABI BasicBlock * getSuccessor() const
static bool classof(const Value *From)
LLVM_ABI void setSuccessor(BasicBlock *NewSucc)
LLVM_ABI void setCatchPad(CatchPadInst *CatchPad)
unsigned getNumSuccessors()
LLVM_ABI Value * getCatchSwitchParentPad() const
static LLVM_ABI CatchReturnInst * create(CatchPadInst *CatchPad, BasicBlock *BB, InsertPosition Pos, Context &Ctx)
LLVM_ABI void addHandler(BasicBlock *Dest)
const_handler_iterator handler_begin() const
const_handler_iterator handler_end() const
const BasicBlock *(*)(const Value *) ConstDerefFnTy
iterator_range< const_handler_iterator > const_handler_range
BasicBlock *(*)(Value *) DerefFnTy
iterator_range< handler_iterator > handler_range
unsigned getNumSuccessors() const
LLVM_ABI void setParentPad(Value *ParentPad)
bool hasUnwindDest() const
bool unwindsToCaller() const
LLVM_ABI void setUnwindDest(BasicBlock *UnwindDest)
handler_iterator handler_begin()
static LLVM_ABI CatchSwitchInst * create(Value *ParentPad, BasicBlock *UnwindBB, unsigned NumHandlers, InsertPosition Pos, Context &Ctx, const Twine &Name="")
mapped_iterator< const_op_iterator, ConstDerefFnTy > const_handler_iterator
mapped_iterator< op_iterator, DerefFnTy > handler_iterator
static bool classof(const Value *From)
handler_iterator handler_end()
unsigned getNumHandlers() const
void setSuccessor(unsigned Idx, BasicBlock *NewSucc)
LLVM_ABI BasicBlock * getUnwindDest() const
LLVM_ABI Value * getParentPad() const
BasicBlock * getSuccessor(unsigned Idx) const
const_handler_range handlers() const
static LLVM_ABI CleanupPadInst * create(Value *ParentPad, ArrayRef< Value * > Args, InsertPosition Pos, Context &Ctx, const Twine &Name="")
static bool classof(const Value *From)
LLVM_ABI CleanupPadInst * getCleanupPad() const
bool hasUnwindDest() const
LLVM_ABI void setUnwindDest(BasicBlock *NewDest)
bool unwindsToCaller() const
static LLVM_ABI CleanupReturnInst * create(CleanupPadInst *CleanupPad, BasicBlock *UnwindBB, InsertPosition Pos, Context &Ctx)
unsigned getNumSuccessors() const
LLVM_ABI BasicBlock * getUnwindDest() const
LLVM_ABI void setCleanupPad(CleanupPadInst *CleanupPad)
static bool classof(const Value *From)
llvm::CmpInst::Predicate Predicate
WRAP_STATIC_PREDICATE(isUnordered)
llvm::CmpInst LLVMValType
WRAP_BOTH(isTrueWhenEqual)
WRAP_BOTH(getInversePredicate)
static LLVM_ABI Value * createCommon(Value *Cond, Value *True, Value *False, const Twine &Name, IRBuilder<> &Builder, Context &Ctx)
void dumpOS(raw_ostream &OS) const override
LLVM_DUMP_METHOD void dump() const
WRAP_BOTH(getNonStrictPredicate)
static LLVM_ABI Value * createWithCopiedFlags(Predicate Pred, Value *S1, Value *S2, const Instruction *FlagsSource, InsertPosition Pos, Context &Ctx, const Twine &Name="")
static LLVM_ABI Type * makeCmpResultType(Type *OpndType)
Create a result type for fcmp/icmp.
static LLVM_ABI Value * create(Predicate Pred, Value *S1, Value *S2, InsertPosition Pos, Context &Ctx, const Twine &Name="")
LLVM_ABI void setPredicate(Predicate P)
WRAP_BOTH(isIntPredicate)
WRAP_STATIC_PREDICATE(isOrdered)
WRAP_BOTH(isNonStrictPredicate)
WRAP_BOTH(getSwappedPredicate)
WRAP_BOTH(getStrictPredicate)
WRAP_BOTH(isStrictPredicate)
WRAP_STATIC_PREDICATE(getPredicateName)
CmpInst(llvm::CmpInst *CI, Context &Ctx, ClassID Id, Opcode Opc)
Use Context::createCmpInst(). Don't call the constructor directly.
WRAP_BOTH(isFalseWhenEqual)
WRAP_MEMBER(getPredicate)
LLVM_ABI void swapOperands()
WRAP_BOTH(getUnorderedPredicate)
WRAP_BOTH(getFlippedStrictnessPredicate)
WRAP_BOTH(getOrderedPredicate)
WRAP_MEMBER(isCommutative)
static bool classof(const Value *From)
Method for support type inquiry through isa, cast, and dyn_cast:
const Value * getVectorOperand() const
const Value * getIndexOperand() const
Value * getVectorOperand()
static LLVM_ABI Value * create(Value *Vec, Value *Idx, InsertPosition Pos, Context &Ctx, const Twine &Name="")
LLVM_ABI VectorType * getVectorOperandType() const
Value * getIndexOperand()
static bool classof(const Value *From)
static bool isValidOperands(const Value *Vec, const Value *Idx)
unsigned getNumIndices() const
static LLVM_ABI Value * create(Value *Agg, ArrayRef< unsigned > Idxs, InsertPosition Pos, Context &Ctx, const Twine &Name="")
const Value * getAggregateOperand() const
static unsigned getAggregateOperandIndex()
idx_iterator idx_begin() const
ArrayRef< unsigned > getIndices() const
static LLVM_ABI Type * getIndexedType(Type *Agg, ArrayRef< unsigned > Idxs)
Returns the type of the element that would be extracted with an extractvalue instruction with the spe...
Value * getAggregateOperand()
unsigned hasIndices() const
llvm::ExtractValueInst::idx_iterator idx_iterator
static bool classof(const Value *From)
iterator_range< idx_iterator > indices() const
idx_iterator idx_end() const
WRAP_MEMBER(isRelational)
WRAP_MEMBER(isCommutative)
LLVM_ABI void swapOperands()
static bool compare(const APFloat &LHS, const APFloat &RHS, FCmpInst::Predicate Pred)
static bool classof(const Value *From)
AtomicOrdering getOrdering() const
Returns the ordering constraint of this fence instruction.
static LLVM_ABI FenceInst * create(AtomicOrdering Ordering, InsertPosition Pos, Context &Ctx, SyncScope::ID SSID=SyncScope::System)
LLVM_ABI void setOrdering(AtomicOrdering Ordering)
Sets the ordering constraint of this fence instruction.
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this fence instruction.
static bool classof(const Value *From)
LLVM_ABI void setSyncScopeID(SyncScope::ID SSID)
Sets the synchronization scope ID of this fence instruction.
static LLVM_ABI FreezeInst * create(Value *V, InsertPosition Pos, Context &Ctx, const Twine &Name="")
static bool classof(const Value *From)
static bool classof(const Value *From)
LLVM_ABI Value * getArgOperand(unsigned Idx) const
Return the Idx-th funcletpad argument.
LLVM_ABI Value * getParentPad() const
Return the outer EH-pad this funclet is nested within.
unsigned arg_size() const
Return the number of funcletpad arguments.
LLVM_ABI void setParentPad(Value *ParentPad)
LLVM_ABI void setArgOperand(unsigned Idx, Value *V)
Set the Idx-th funcletpad argument.
friend class CatchPadInst
friend class CleanupPadInst
unsigned getAddressSpace() const
bool hasAllConstantIndices() const
bool hasNoUnsignedWrap() const
iterator_range< op_iterator > indices()
const_op_iterator idx_begin() const
unsigned getPointerAddressSpace() const
GEPNoWrapFlags getNoWrapFlags() const
LLVM_ABI Type * getResultElementType() const
unsigned getNumIndices() const
LLVM_ABI Type * getPointerOperandType() const
static unsigned getPointerOperandIndex()
LLVM_ABI Type * getSourceElementType() const
bool hasNoUnsignedSignedWrap() const
static bool classof(const Value *From)
const_op_iterator idx_end() const
LLVM_ABI Value * getPointerOperand() const
bool accumulateConstantOffset(const DataLayout &DL, APInt &Offset) const
iterator_range< const_op_iterator > indices() const
static LLVM_ABI Value * create(Type *Ty, Value *Ptr, ArrayRef< Value * > IdxList, InsertPosition Pos, Context &Ctx, const Twine &NameStr="")
static std::optional< bool > isImpliedByMatchingCmp(CmpPredicate Pred1, CmpPredicate Pred2)
WRAP_BOTH(getSignedPredicate)
WRAP_STATIC_PREDICATE(isLE)
WRAP_STATIC_PREDICATE(isGE)
static bool compare(const APInt &LHS, const APInt &RHS, ICmpInst::Predicate Pred)
WRAP_STATIC_PREDICATE(isGT)
LLVM_ABI void swapOperands()
WRAP_STATIC_PREDICATE(isLT)
WRAP_BOTH(getUnsignedPredicate)
WRAP_MEMBER(isCommutative)
WRAP_MEMBER(isRelational)
WRAP_BOTH(getFlippedSignednessPredicate)
static bool classof(const Value *From)
static LLVM_ABI Value * create(Value *Vec, Value *NewElt, Value *Idx, InsertPosition Pos, Context &Ctx, const Twine &Name="")
static bool isValidOperands(const Value *Vec, const Value *NewElt, const Value *Idx)
static bool classof(const Value *From)
InsertPosition(BBIterator InsertAt)
InsertPosition(BasicBlock *InsertAtEnd)
const BBIterator & getIterator() const
Instruction & operator*()
BasicBlock * getBasicBlock() const
llvm::InsertValueInst::idx_iterator idx_iterator
Value * getAggregateOperand()
Value * getInsertedValueOperand()
idx_iterator idx_end() const
iterator_range< idx_iterator > indices() const
static bool classof(const Value *From)
const Value * getInsertedValueOperand() const
unsigned hasIndices() const
const Value * getAggregateOperand() const
static unsigned getInsertedValueOperandIndex()
unsigned getNumIndices() const
ArrayRef< unsigned > getIndices() const
static LLVM_ABI Value * create(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, InsertPosition Pos, Context &Ctx, const Twine &Name="")
idx_iterator idx_begin() const
static unsigned getAggregateOperandIndex()
A sandboxir::User with operands, opcode and linked with previous/next instructions in an instruction ...
bool hasAtomicLoad() const
friend class InsertElementInst
bool hasNoUnsignedWrap() const
Determine whether the no signed wrap flag is set.
static IRBuilder & setInsertPos(InsertPosition Pos)
Helper function for create().
friend class CatchReturnInst
bool isAssociative() const
LLVM_ABI void setFastMathFlags(FastMathFlags FMF)
Convenience function for setting multiple fast-math flags on this instruction, which must be an opera...
friend class UnreachableInst
friend class UnaryOperator
bool isSpecialTerminator() const
const DataLayout & getDataLayout() const
bool hasAllowReassoc() const
Determine whether the allow-reassociation flag is set.
LLVM_ABI void setHasAllowReassoc(bool B)
Set or clear the reassociation flag on this instruction, which must be an operator which supports thi...
bool mayWriteToMemory() const
friend class EraseFromParent
virtual unsigned getNumOfIRInstrs() const =0
This is used by BasicBlock::iterator.
bool hasNoSignedZeros() const
Determine whether the no-signed-zeros flag is set.
const char * getOpcodeName() const
bool isLogicalShift() const
LLVM_ABI void setHasNoSignedWrap(bool B=true)
Set or clear the nsw flag on this instruction, which must be an operator which supports this flag.
LLVM_ABI void insertAfter(Instruction *AfterI)
Insert this detached instruction after AfterI.
bool hasMetadata(unsigned KindID) const
Return true if this instruction has the given type of metadata attached.
bool hasMetadataOtherThanDebugLoc() const
Return true if this instruction has metadata attached to it other than a debug location.
friend class ExtractElementInst
void moveAfter(Instruction *After)
Move this instruction after After.
LLVM_ABI void moveBefore(BasicBlock &BB, const BBIterator &WhereIt)
Move this instruction to WhereIt.
bool hasAllowContract() const
Determine whether the allow-contract flag is set.
LLVM_ABI 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.
friend class ShuffleVectorInst
friend class ExtractValueInst
LLVM_ABI void setHasNoUnsignedWrap(bool B=true)
Set or clear the nuw flag on this instruction, which must be an operator which supports this flag.
Opcode getOpcode() const
\Returns this Instruction's opcode.
void dumpOS(raw_ostream &OS) const override
bool isFast() const
Determine whether all fast-math-flags are set.
LLVM_ABI BBIterator getIterator() const
\Returns a BasicBlock::iterator for this Instruction.
LLVM_ABI void setFast(bool B)
Set or clear all fast-math-flags on this instruction, which must be an operator which supports this f...
friend class InsertValueInst
LLVM_ABI void setHasApproxFunc(bool B)
Set or clear the approximate-math-functions flag on this instruction, which must be an operator which...
LLVM_ABI void setHasNoNaNs(bool B)
Set or clear the no-nans flag on this instruction, which must be an operator which supports this flag...
LLVM_ABI void copyFastMathFlags(FastMathFlags FMF)
Convenience function for transferring all fast-math flag values to this instruction,...
friend class CatchSwitchInst
friend class BinaryOperator
bool isFuncletPad() const
bool hasAtomicStore() const
friend class CatchPadInst
LLVM_ABI void setHasNoSignedZeros(bool B)
Set or clear the no-signed-zeros flag on this instruction, which must be an operator which supports t...
LLVM_ABI void insertInto(BasicBlock *BB, const BBIterator &WhereIt)
Insert this detached instruction into BB at WhereIt.
bool mayThrow(bool IncludePhaseOneUnwind=false) const
LLVM_ABI llvm::Instruction * getTopmostLLVMInstruction() const
A SandboxIR Instruction may map to multiple LLVM IR Instruction.
friend class AtomicRMWInst
bool isIdempotent() const
bool hasMetadata() const
Return true if the instruction has any metadata attached to it.
LLVM_ABI void setHasAllowContract(bool B)
Set or clear the allow-contract flag on this instruction, which must be an operator which supports th...
bool isOnlyUserOfAnyOperand() const
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.
bool mayHaveSideEffects() const
LLVM_ABI Type * getAccessType() const
bool mayReadOrWriteMemory() const
bool isExact() const
Determine whether the exact flag is set.
bool mayReadFromMemory() const
Instruction(ClassID ID, Opcode Opc, llvm::Instruction *I, sandboxir::Context &SBCtx)
friend class GetElementPtrInst
FastMathFlags getFastMathFlags() const
Convenience function for getting all the fast-math flags, which must be an operator which supports th...
friend class CleanupPadInst
bool isCommutative() const
bool comesBefore(const Instruction *Other) const
Given an instruction Other in the same basic block as this instruction, return true if this instructi...
friend class AtomicCmpXchgInst
LLVM_ABI Instruction * getNextNode() const
\Returns the next sandboxir::Instruction in the block, or nullptr if at the end of the block.
bool hasNoInfs() const
Determine whether the no-infs flag is set.
friend class LandingPadInst
LLVM_ABI void removeFromParent()
Detach this from its parent BasicBlock without deleting it.
LLVM_ABI Instruction * getPrevNode() const
\Returns the previous sandboxir::Instruction in the block, or nullptr if at the beginning of the bloc...
bool hasNoNaNs() const
Determine whether the no-NaNs flag is set.
friend class CleanupReturnInst
bool hasAllowReciprocal() const
Determine whether the allow-reciprocal flag is set.
LLVM_ABI void insertBefore(Instruction *BeforeI)
Insert this detached instruction before BeforeI.
LLVM_ABI void eraseFromParent()
Detach this Value from its parent and delete it.
LLVM_ABI void setHasAllowReciprocal(bool B)
Set or clear the allow-reciprocal flag on this instruction, which must be an operator which supports ...
LLVM_ABI void setHasNoInfs(bool B)
Set or clear the no-infs flag on this instruction, which must be an operator which supports this flag...
LLVM_ABI BasicBlock * getParent() const
\Returns the BasicBlock containing this Instruction, or null if it is detached.
static LLVM_ABI bool classof(const sandboxir::Value *From)
For isa/dyn_cast.
bool isTerminator() const
LLVM_ABI BasicBlock * getUnwindDest() const
static LLVM_ABI InvokeInst * create(FunctionType *FTy, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, InsertPosition Pos, Context &Ctx, const Twine &NameStr="")
LLVM_ABI void setNormalDest(BasicBlock *BB)
unsigned getNumSuccessors() const
LLVM_ABI void setUnwindDest(BasicBlock *BB)
LLVM_ABI BasicBlock * getSuccessor(unsigned SuccIdx) const
static bool classof(const Value *From)
LLVM_ABI BasicBlock * getNormalDest() const
void setSuccessor(unsigned SuccIdx, BasicBlock *NewSucc)
LLVM_ABI LandingPadInst * getLandingPadInst() const
bool isFilter(unsigned Idx) const
Return 'true' if the clause and index Idx is a filter clause.
bool isCleanup() const
Return 'true' if this landingpad instruction is a cleanup.
LLVM_ABI void setCleanup(bool V)
Indicate that this landingpad instruction is a cleanup.
unsigned getNumClauses() const
Get the number of clauses for this landing pad.
bool isCatch(unsigned Idx) const
Return 'true' if the clause and index Idx is a catch clause.
LLVM_ABI Constant * getClause(unsigned Idx) const
Get the value of the clause at index Idx.
static bool classof(const Value *From)
static LLVM_ABI LandingPadInst * create(Type *RetTy, unsigned NumReservedClauses, InsertPosition Pos, Context &Ctx, const Twine &Name="")
static LLVM_ABI LoadInst * create(Type *Ty, Value *Ptr, MaybeAlign Align, InsertPosition Pos, bool IsVolatile, Context &Ctx, const Twine &Name="")
static LoadInst * create(Type *Ty, Value *Ptr, MaybeAlign Align, InsertPosition Pos, Context &Ctx, const Twine &Name="")
LLVM_ABI void setVolatile(bool V)
Specify whether this is a volatile load or not.
LLVM_ABI Value * getPointerOperand() const
bool isVolatile() const
Return true if this is a load from a volatile memory location.
static LLVM_ABI bool classof(const Value *From)
For isa/dyn_cast.
static bool classof(const sandboxir::Value *From)
LLVM_ABI Value * hasConstantValue() const
iterator_range< const_block_iterator > blocks() const
LLVM_ABI int getBasicBlockIndex(const BasicBlock *BB) const
const_block_iterator block_end() const
const_op_range incoming_values() const
bool hasConstantOrUndefValue() const
unsigned getNumIncomingValues() const
LLVM_ABI Value * getIncomingValue(unsigned Idx) const
LLVM_ABI void setIncomingBlock(unsigned Idx, BasicBlock *BB)
LLVM_ABI void removeIncomingValueIf(function_ref< bool(unsigned)> Predicate)
static LLVM_ABI bool classof(const Value *From)
For isa/dyn_cast.
const_block_iterator block_begin() const
static LLVM_ABI PHINode * create(Type *Ty, unsigned NumReservedValues, InsertPosition Pos, Context &Ctx, const Twine &Name="")
mapped_iterator< llvm::PHINode::const_block_iterator, LLVMBBToBB > const_block_iterator
LLVM_ABI Value * removeIncomingValue(unsigned Idx)
LLVM_ABI void setIncomingValue(unsigned Idx, Value *V)
LLVM_ABI BasicBlock * getIncomingBlock(unsigned Idx) const
op_range incoming_values()
static unsigned getIncomingValueNumForOperand(unsigned Idx)
LLVM_ABI void replaceIncomingBlockWith(const BasicBlock *Old, BasicBlock *New)
LLVM_ABI Value * getIncomingValueForBlock(const BasicBlock *BB) const
LLVM_ABI void addIncoming(Value *V, BasicBlock *BB)
static unsigned getOperandNumForIncomingValue(unsigned Idx)
An or instruction, which can be marked as "disjoint", indicating that the inputs don't have a 1 in th...
static bool classof(const Value *From)
For isa/dyn_cast.
LLVM_ABI void setIsDisjoint(bool B)
Instruction that can have a nneg flag (zext/uitofp).
LLVM_ABI void setNonNeg(bool B)
static bool classof(const Value *From)
For isa/dyn_cast.
static LLVM_ABI ResumeInst * create(Value *Exn, InsertPosition Pos, Context &Ctx)
unsigned getNumSuccessors() const
static bool classof(const Value *From)
LLVM_ABI Value * getValue() const
static LLVM_ABI ReturnInst * create(Value *RetVal, InsertPosition Pos, Context &Ctx)
static bool classof(const Value *From)
LLVM_ABI Value * getReturnValue() const
\Returns null if there is no return value.
static const char * areInvalidOperands(Value *Cond, Value *True, Value *False)
Return a string if the specified operands are invalid for a select operation, otherwise return null.
static LLVM_ABI bool classof(const Value *From)
For isa/dyn_cast.
const Value * getFalseValue() const
const Value * getTrueValue() const
LLVM_ABI void swapValues()
void setTrueValue(Value *New)
static LLVM_ABI Value * create(Value *Cond, Value *True, Value *False, InsertPosition Pos, Context &Ctx, const Twine &Name="")
void setCondition(Value *New)
const Value * getCondition() const
void setFalseValue(Value *New)
void getShuffleMask(SmallVectorImpl< int > &Result) const
Return the mask for this instruction as a vector of integers.
static bool isZeroEltSplatMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask chooses all elements with the same value as the first element of exa...
bool isExtractSubvectorMask(int &Index) const
Return true if this shuffle mask is an extract subvector mask.
bool changesLength() const
Return true if this shuffle returns a vector with a different number of elements than its source vect...
bool isReverse() const
Return true if this shuffle swaps the order of elements from exactly one source vector.
LLVM_ABI VectorType * getType() const
Overload to return most specific vector type.
bool isIdentityWithPadding() const
Return true if this shuffle lengthens exactly one source vector with undefs in the high elements.
static bool isSingleSourceMask(const Constant *Mask, int NumSrcElts)
bool isIdentityWithExtract() const
Return true if this shuffle extracts the first N elements of exactly one source vector.
static bool isIdentityMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask chooses elements from exactly one source vector without lane crossin...
ArrayRef< int > getShuffleMask() const
static bool isReverseMask(const Constant *Mask, int NumSrcElts)
LLVM_ABI Constant * getShuffleMaskForBitcode() const
Return the mask for this instruction, for use in bitcode.
static bool isExtractSubvectorMask(const Constant *Mask, int NumSrcElts, int &Index)
bool isInterleave(unsigned Factor) const
Return if this shuffle interleaves its two input vectors together.
static bool isInterleaveMask(ArrayRef< int > Mask, unsigned Factor, unsigned NumInputElts, SmallVectorImpl< unsigned > &StartIndexes)
Return true if the mask interleaves one or more input vectors together.
static bool isOneUseSingleSourceMask(ArrayRef< int > Mask, int VF)
Return true if this shuffle mask represents "clustered" mask of size VF, i.e.
static bool isTransposeMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask is a transpose mask.
static bool isTransposeMask(const Constant *Mask, int NumSrcElts)
static bool isInterleaveMask(ArrayRef< int > Mask, unsigned Factor, unsigned NumInputElts)
LLVM_ABI void commute()
Swap the operands and adjust the mask to preserve the semantics of the instruction.
static bool isReplicationMask(ArrayRef< int > Mask, int &ReplicationFactor, int &VF)
Return true if this shuffle mask replicates each of the VF elements in a vector ReplicationFactor tim...
static LLVM_ABI Value * create(Value *V1, Value *V2, Value *Mask, InsertPosition Pos, Context &Ctx, const Twine &Name="")
bool isIdentity() const
Return true if this shuffle chooses elements from exactly one source vector without lane crossings an...
static bool isReplicationMask(const Constant *Mask, int &ReplicationFactor, int &VF)
static bool isIdentityMask(const Constant *Mask, int NumSrcElts)
static bool isDeInterleaveMaskOfFactor(ArrayRef< int > Mask, unsigned Factor)
static LLVM_ABI Constant * convertShuffleMaskForBitcode(ArrayRef< int > Mask, Type *ResultTy)
bool isSingleSource() const
Return true if this shuffle chooses elements from exactly one source vector without changing the leng...
static bool isExtractSubvectorMask(ArrayRef< int > Mask, int NumSrcElts, int &Index)
Return true if this shuffle mask is an extract subvector mask.
bool isSplice(int &Index) const
Return true if this shuffle splices two inputs without changing the length of the vectors.
static bool isValidOperands(const Value *V1, const Value *V2, const Value *Mask)
Return true if a shufflevector instruction can be formed with the specified operands.
static bool isSelectMask(const Constant *Mask, int NumSrcElts)
static bool isSpliceMask(const Constant *Mask, int NumSrcElts, int &Index)
static bool isBitRotateMask(ArrayRef< int > Mask, unsigned EltSizeInBits, unsigned MinSubElts, unsigned MaxSubElts, unsigned &NumSubElts, unsigned &RotateAmt)
Checks if the shuffle is a bit rotation of the first operand across multiple subelements,...
bool isReplicationMask(int &ReplicationFactor, int &VF) const
Return true if this shuffle mask is a replication mask.
bool isConcat() const
Return true if this shuffle concatenates its 2 source vectors.
static bool isValidOperands(const Value *V1, const Value *V2, ArrayRef< int > Mask)
static bool isInsertSubvectorMask(const Constant *Mask, int NumSrcElts, int &NumSubElts, int &Index)
static bool isSpliceMask(ArrayRef< int > Mask, int NumSrcElts, int &Index)
Return true if this shuffle mask is a splice mask, concatenating the two inputs together and then ext...
static bool isSelectMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask chooses elements from its source vectors without lane crossings.
static void commuteShuffleMask(MutableArrayRef< int > Mask, unsigned InVecNumElts)
Change values in a shuffle permute mask assuming the two vector operands of length InVecNumElts have ...
bool increasesLength() const
Return true if this shuffle returns a vector with a greater number of elements than its source vector...
bool isZeroEltSplat() const
Return true if all elements of this shuffle are the same value as the first element of exactly one so...
static bool isInsertSubvectorMask(ArrayRef< int > Mask, int NumSrcElts, int &NumSubElts, int &Index)
Return true if this shuffle mask is an insert subvector mask.
static void getShuffleMask(const Constant *Mask, SmallVectorImpl< int > &Result)
Convert the input shuffle mask operand to a vector of integers.
static bool isZeroEltSplatMask(const Constant *Mask, int NumSrcElts)
LLVM_ABI void setShuffleMask(ArrayRef< int > Mask)
static bool isReverseMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask swaps the order of elements from exactly one source vector.
static bool isSingleSourceMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask chooses elements from exactly one source vector.
bool isOneUseSingleSourceMask(int VF) const
Return true if this shuffle mask is a one-use-single-source("clustered") mask.
static bool isDeInterleaveMaskOfFactor(ArrayRef< int > Mask, unsigned Factor, unsigned &Index)
Check if the mask is a DE-interleave mask of the given factor Factor like: <Index,...
int getMaskValue(unsigned Elt) const
Return the shuffle mask value of this instruction for the given element index.
bool isInsertSubvectorMask(int &NumSubElts, int &Index) const
Return true if this shuffle mask is an insert subvector mask.
bool isSelect() const
Return true if this shuffle chooses elements from its source vectors without lane crossings and all o...
bool isTranspose() const
Return true if this shuffle transposes the elements of its inputs without changing the length of the ...
static bool classof(const Value *From)
void dumpOS(raw_ostream &OS) const override
void verify() const final
Should crash if there is something wrong with the instruction.
friend class FuncletPadInst
friend class UnaryInstruction
unsigned getUseOperandNo(const Use &Use) const final
\Returns the operand index of Use.
unsigned getNumOfIRInstrs() const final
This is used by BasicBlock::iterator.
LLVM_ABI void setVolatile(bool V)
Specify whether this is a volatile store or not.
static LLVM_ABI bool classof(const Value *From)
For isa/dyn_cast.
static StoreInst * create(Value *V, Value *Ptr, MaybeAlign Align, InsertPosition Pos, Context &Ctx)
static LLVM_ABI StoreInst * create(Value *V, Value *Ptr, MaybeAlign Align, InsertPosition Pos, bool IsVolatile, Context &Ctx)
LLVM_ABI Value * getPointerOperand() const
bool isVolatile() const
Return true if this is a store from a volatile memory location.
LLVM_ABI Value * getValueOperand() const
CaseIt findCaseValue(const ConstantInt *C)
iterator_range< ConstCaseIt > cases() const
static LLVM_ABI SwitchInst * create(Value *V, BasicBlock *Dest, unsigned NumCases, InsertPosition Pos, Context &Ctx, const Twine &Name="")
LLVM_ABI void addCase(ConstantInt *OnVal, BasicBlock *Dest)
LLVM_ABI BasicBlock * getSuccessor(unsigned Idx) const
CaseIt case_begin()
Returns a read/write iterator that points to the first case in the SwitchInst.
LLVM_ABI void setDefaultDest(BasicBlock *DefaultCase)
llvm::SwitchInst::CaseHandleImpl< SwitchInst, ConstantInt, BasicBlock > CaseHandle
iterator_range< CaseIt > cases()
Iteration adapter for range-for loops.
llvm::SwitchInst::CaseIteratorImpl< CaseHandle > CaseIt
ConstCaseIt case_begin() const
bool defaultDestUnreachable() const
LLVM_ABI BasicBlock * getDefaultDest() const
ConstCaseIt case_end() const
llvm::SwitchInst::CaseIteratorImpl< ConstCaseHandle > ConstCaseIt
ConstCaseIt case_default() const
static bool classof(const Value *From)
LLVM_ABI Value * getCondition() const
LLVM_ABI void setSuccessor(unsigned Idx, BasicBlock *NewSucc)
unsigned getNumCases() const
unsigned getNumSuccessors() const
CaseIt case_end()
Returns a read/write iterator that points one past the last in the SwitchInst.
LLVM_ABI void setCondition(Value *V)
ConstCaseIt findCaseValue(const ConstantInt *C) const
LLVM_ABI ConstantInt * findCaseDest(BasicBlock *BB)
static constexpr const unsigned DefaultPseudoIndex
LLVM_ABI CaseIt removeCase(CaseIt It)
This method removes the specified case and its successor from the switch instruction.
llvm::SwitchInst::CaseHandleImpl< const SwitchInst, const ConstantInt, const BasicBlock > ConstCaseHandle
Just like llvm::Type these are immutable, unique, never get freed and can only be created via static ...
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
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 LLVM_ABI Value * createWithCopiedFlags(Instruction::Opcode Op, Value *OpV, Value *CopyFrom, InsertPosition Pos, Context &Ctx, const Twine &Name="")
static LLVM_ABI Value * create(Instruction::Opcode Op, Value *OpV, InsertPosition Pos, Context &Ctx, const Twine &Name="")
static LLVM_ABI UnreachableInst * create(InsertPosition Pos, 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
static LLVM_ABI bool classof(const Value *From)
Represents a Def-use/Use-def edge in SandboxIR.
LLVM_ABI void set(Value *V)
virtual op_iterator op_begin()
unsigned getUseOperandNoDefault(const Use &Use) const
The default implementation works only for single-LLVMIR-instruction Users and only if they match exac...
OperandUseIterator const_op_iterator
virtual void setOperand(unsigned OperandIdx, Value *Operand)
Use getOperandUseDefault(unsigned OpIdx, bool Verify) const
\Returns the Use edge that corresponds to OpIdx.
OperandUseIterator op_iterator
void swapOperandsInternal(unsigned OpIdxA, unsigned OpIdxB)
virtual unsigned getNumOperands() const
Use getOperandUse(unsigned OpIdx) const
\Returns the operand edge for OpIdx.
iterator_range< const_op_iterator > const_op_range
virtual op_iterator op_end()
iterator_range< op_iterator > op_range
User(ClassID ID, llvm::Value *V, Context &Ctx)
LLVM_ABI Value * getPointerOperand()
static LLVM_ABI VAArgInst * create(Value *List, Type *Ty, InsertPosition Pos, Context &Ctx, const Twine &Name="")
const Value * getPointerOperand() const
static bool classof(const Value *From)
static unsigned getPointerOperandIndex()
A SandboxIR Value has users. This is the base class.
llvm::Value * Val
The LLVM Value that corresponds to this SandboxIR Value.
ClassID getSubclassID() const
void dumpCommonSuffix(raw_ostream &OS) const
Context & Ctx
All values point to the context.
ClassID SubclassID
For isa/dyn_cast.
LLVM_ABI Type * getType() const
void dumpCommonPrefix(raw_ostream &OS) const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
@ System
Synchronized with respect to all concurrently executing threads.
static bool isOrdered(Instruction *I)
BasicBlock(llvm::BasicBlock *BB, Context &SBCtx)
friend class Instruction
Iterator for Instructions in a `BasicBlock.
static SmallVector< Value *, 4 > getOperand(ArrayRef< Value * > Bndl, unsigned OpIdx)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
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)
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
AtomicOrdering
Atomic ordering for LLVM's memory model.
DWARFExpression::Operation Op
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
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.