17 if (Prev ==
nullptr) {
39 assert(LLVMI->getParent() !=
nullptr &&
"LLVM IR instr is detached!");
40 auto *NextLLVMI = LLVMI->getNextNode();
60 I->removeFromParent();
66 Ctx.runEraseInstrCallbacks(
this);
67 std::unique_ptr<Value> Detached =
Ctx.detach(
this);
72 Tracker.
track(std::make_unique<EraseFromParent>(std::move(Detached)));
77 I->removeFromParent();
81 I->dropAllReferences();
94 Ctx.runMoveInstrCallbacks(
this, WhereIt);
95 Ctx.getTracker().emplaceIfTracking<MoveInstr>(
this);
99 if (WhereIt == BB.
end()) {
103 It = WhereI->getTopmostLLVMInstruction()->
getIterator();
107 [](
auto *I1,
auto *I2) {
return I1->comesBefore(I2); }) &&
108 "Expected program order!");
111 I->moveBefore(*LLVMBB, It);
117 Ctx.getTracker().emplaceIfTracking<InsertIntoBB>(
this);
133 if (WhereIt != BB->
end()) {
135 LLVMBeforeI = BeforeI->getTopmostLLVMInstruction();
139 LLVMBeforeI =
nullptr;
140 LLVMBeforeIt = LLVMBB->
end();
143 Ctx.getTracker().emplaceIfTracking<InsertIntoBB>(
this);
147 I->insertInto(LLVMBB, LLVMBeforeIt);
162 auto &Builder = WhereBB->getParent()->getParent()->getLLVMIRBuilder();
163 if (WhereIt != WhereBB->end())
164 Builder.SetInsertPoint((*Pos).getTopmostLLVMInstruction());
172#define DEF_INSTR(ID, OPC, CLASS) \
175#define DEF_DISABLE_AUTO_UNDEF
176#include "llvm/SandboxIR/ValuesDefFilesList.def"
200 GenericSetter<&Instruction::isFast, &Instruction::setFast>>(
this);
207 GenericSetter<&Instruction::isExact, &Instruction::setIsExact>>(
this);
285 OS <<
"Unimplemented! Please override dump().";
294 return Ctx.createVAArgInst(LLVMI);
305 return Ctx.createFreezeInst(LLVMI);
312 return Ctx.createFenceInst(LLVMI);
334 Builder.CreateSelect(
Cond->Val,
True->Val,
False->Val, Name);
336 return Ctx.createSelectInst(NewSI);
355BrInstCommon::ConstLLVMBBToSBBB::operator()(
const llvm::BasicBlock *BB)
const {
364 return Ctx.createUncondBrInst(NewUBr);
387 auto &Builder = setInsertPos(InsertBefore);
391 return Ctx.createCondBrInst(NewCBr);
396 "Cannot get condition of an uncond branch!");
410 "Successor # out of range for Branch!");
441 Builder.CreateAlignedLoad(Ty->LLVMTy, Ptr->
Val,
Align, IsVolatile, Name);
442 auto *NewSBI =
Ctx.createLoadInst(NewLI);
465 auto *NewSI = Builder.CreateAlignedStore(V->Val, Ptr->
Val,
Align, IsVolatile);
466 auto *NewSBI =
Ctx.createStoreInst(NewSI);
485 return Ctx.createUnreachableInst(NewUI);
495 if (RetVal !=
nullptr)
496 NewRI = Builder.CreateRet(RetVal->Val);
498 NewRI = Builder.CreateRetVoid();
499 return Ctx.createReturnInst(NewRI);
505 return createCommon(RetVal, Builder,
Ctx);
510 return LLVMRetVal !=
nullptr ?
Ctx.getValue(LLVMRetVal) :
nullptr;
554 for (
Value *Arg : Args)
558 return Ctx.createCallInst(NewCI);
568 for (
Value *Arg : Args)
574 return Ctx.createInvokeInst(Invoke);
616 for (
Value *Arg : Args)
622 LLVMIndirectDests, LLVMArgs, NameStr);
623 return Ctx.createCallBrInst(CallBr);
670 auto &Builder = setInsertPos(Pos);
672 Builder.CreateLandingPad(RetTy->
LLVMTy, NumReservedClauses, Name);
673 return Ctx.createLandingPadInst(LLVMI);
719 auto &Builder = setInsertPos(Pos);
722 for (
auto *Arg : Args)
725 Builder.CreateCatchPad(ParentPad->
Val, LLVMArgs, Name);
726 return Ctx.createCatchPadInst(LLVMI);
735 for (
auto *Arg : Args)
738 Builder.CreateCleanupPad(ParentPad->
Val, LLVMArgs, Name);
739 return Ctx.createCleanupPadInst(LLVMI);
747 return Ctx.createCatchReturnInst(LLVMI);
789 return Ctx.createCleanupReturnInst(LLVMI);
823 auto &Builder = setInsertPos(Pos);
826 for (
Value *Idx : IdxList)
829 Builder.CreateGEP(Ty->LLVMTy, Ptr->
Val, LLVMIdxList, NameStr);
831 return Ctx.createGetElementPtrInst(NewGEP);
863 Builder.CreatePHI(Ty->LLVMTy, NumReservedValues, Name);
864 return Ctx.createPHINode(NewPHI);
892 constexpr BasicBlock *(PHINode::*GetIncomingBlockFn)(
unsigned)
const =
914 return Ctx.getValue(LLVMV);
917 auto &Tracker = Ctx.getTracker();
918 Tracker.emplaceIfTracking<PHIRemoveIncoming>(
this, getBasicBlockIndex(BB));
924 return Ctx.getValue(LLVMV);
934 return Ctx.getValue(LLVMV);
938 return LLVMV !=
nullptr ?
Ctx.getValue(LLVMV) :
nullptr;
941 assert(New && Old &&
"Sandbox IR PHI node got a null basic block!");
956 if (Predicate(Idx - 1))
965 auto *LLVMV = Builder.CreateCmp(
P,
S1->Val, S2->
Val, Name);
968 return Ctx.getOrCreateConstant(LLVMC);
1033 case Instruction::Opcode::ZExt:
1035 case Instruction::Opcode::SExt:
1037 case Instruction::Opcode::FPToUI:
1039 case Instruction::Opcode::FPToSI:
1041 case Instruction::Opcode::FPExt:
1043 case Instruction::Opcode::PtrToAddr:
1045 llvm::Instruction::PtrToAddr);
1046 case Instruction::Opcode::PtrToInt:
1048 case Instruction::Opcode::IntToPtr:
1050 case Instruction::Opcode::SIToFP:
1052 case Instruction::Opcode::UIToFP:
1054 case Instruction::Opcode::Trunc:
1056 case Instruction::Opcode::FPTrunc:
1058 case Instruction::Opcode::BitCast:
1060 case Instruction::Opcode::AddrSpaceCast:
1062 llvm::Instruction::AddrSpaceCast);
1071 case Instruction::Opcode::FNeg:
1079 unsigned NumHandlers,
1081 const Twine &Name) {
1085 return Ctx.createCatchSwitchInst(LLVMCSI);
1121 return Ctx.createResumeInst(LLVMI);
1130 const Twine &Name) {
1131 auto &Builder = setInsertPos(Pos);
1144 GenericSetter<&SwitchInst::getCondition, &SwitchInst::setCondition>>(
1162template <
typename LLVMCaseItT,
typename BlockT,
typename ConstT>
1165 const auto &LLVMCaseHandle = *LLVMCaseIt;
1166 auto *LLVMC = Ctx.getValue(LLVMCaseHandle.getCaseValue());
1170template <
typename LLVMCaseItT,
typename BlockT,
typename ConstT>
1174 const auto &LLVMCaseHandle = *LLVMCaseIt;
1175 auto *LLVMBB = LLVMCaseHandle.getCaseSuccessor();
1207 auto LLVMCaseIt =
LLVMSwitch->removeCase(LLVMIt);
1209 return CaseIt(
this, Num);
1228 const Twine &Name) {
1232 return Ctx.createUnaryOperator(NewUnOpV);
1243 UnI->copyIRFlags(CopyFrom->
Val);
1250 case Instruction::Opcode::Add:
1252 case Instruction::Opcode::FAdd:
1254 case Instruction::Opcode::Sub:
1256 case Instruction::Opcode::FSub:
1258 case Instruction::Opcode::Mul:
1260 case Instruction::Opcode::FMul:
1262 case Instruction::Opcode::UDiv:
1264 case Instruction::Opcode::SDiv:
1266 case Instruction::Opcode::FDiv:
1268 case Instruction::Opcode::URem:
1270 case Instruction::Opcode::SRem:
1272 case Instruction::Opcode::FRem:
1274 case Instruction::Opcode::Shl:
1276 case Instruction::Opcode::LShr:
1278 case Instruction::Opcode::AShr:
1280 case Instruction::Opcode::And:
1282 case Instruction::Opcode::Or:
1284 case Instruction::Opcode::Xor:
1292 const Twine &Name) {
1297 return Ctx.createBinaryOperator(NewBinOp);
1305 const Twine &Name) {
1393 auto &Builder = setInsertPos(Pos);
1395 Builder.CreateAtomicCmpXchg(Ptr->
Val, Cmp->Val, New->Val,
Align,
1396 SuccessOrdering, FailureOrdering, SSID);
1440 const Twine &Name) {
1443 Builder.CreateAlloca(Ty->LLVMTy, AddrSpace, ArraySize->
Val, Name);
1444 return Ctx.createAllocaInst(NewAlloca);
1488 return Ctx.createCastInst(NewCI);
1514 const Twine &Name) {
1517 Builder.CreateInsertElement(Vec->
Val, NewElt->
Val, Idx->Val, Name);
1519 return Ctx.createInsertElementInst(NewInsert);
1527 llvm::Value *NewV = Builder.CreateExtractElement(Vec->
Val, Idx->Val, Name);
1529 return Ctx.createExtractElementInst(NewExtract);
1536 const Twine &Name) {
1539 Builder.CreateShuffleVector(
V1->Val, V2->
Val, Mask->Val, Name);
1541 return Ctx.createShuffleVectorInst(NewShuffle);
1548 const Twine &Name) {
1550 llvm::Value *NewV = Builder.CreateShuffleVector(
V1->Val, V2->
Val, Mask, Name);
1552 return Ctx.createShuffleVectorInst(NewShuffle);
1575 return Ctx.getOrCreateConstant(
1592 const Twine &Name) {
1594 llvm::Value *NewV = Builder.CreateExtractValue(Agg->
Val, Idxs, Name);
1596 return Ctx.createExtractValueInst(NewExtractValueInst);
1608 const Twine &Name) {
1612 return Ctx.createInsertValueInst(NewInsertValueInst);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_EXPORT_TEMPLATE
static Value * getCondition(Instruction *I)
static constexpr Value * getValue(Ty &ValueOrUse)
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
const SmallVectorImpl< MachineOperand > & Cond
static SymbolRef::Type getType(const Symbol *Sym)
static Value * getParentPad(Value *EHPad)
void setAllocatedType(Type *Ty)
for use only in special circumstances that need to generically transform a whole instruction (eg: IR ...
void setUsedWithInAlloca(bool V)
Specify whether this alloca is used to represent the arguments to a call.
bool isUsedWithInAlloca() const
Return true if this alloca is used as an inalloca argument to a call.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
void setWeak(bool IsWeak)
void setFailureOrdering(AtomicOrdering Ordering)
Sets the failure ordering constraint of this cmpxchg instruction.
AtomicOrdering getFailureOrdering() const
Returns the failure ordering constraint of this cmpxchg instruction.
void setSuccessOrdering(AtomicOrdering Ordering)
Sets the success ordering constraint of this cmpxchg instruction.
bool isWeak() const
Return true if this cmpxchg may spuriously fail.
AtomicOrdering getSuccessOrdering() const
Returns the success ordering constraint of this cmpxchg instruction.
void setOrdering(AtomicOrdering Ordering)
Sets the ordering constraint of this rmw instruction.
AtomicOrdering getOrdering() const
Returns the ordering constraint of this rmw instruction.
LLVM Basic Block Representation.
const Function * getParent() const
Return the enclosing method, or null if none.
InstListType::iterator iterator
Instruction iterators...
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.
BasicBlock * getSuccessor() const
void setSuccessor(BasicBlock *NewSucc)
Conditional Branch instruction.
void setSuccessor(unsigned idx, BasicBlock *NewSucc)
BasicBlock * getSuccessor(unsigned i) const
This is the shared class of boolean and integer constants.
static LLVM_ABI ConstantTokenNone * get(LLVMContext &Context)
Return the ConstantTokenNone.
Convenience struct for specifying and reasoning about fast-math flags.
An instruction for ordering other memory operations.
void setSyncScopeID(SyncScope::ID SSID)
Sets the synchronization scope ID of this fence instruction.
void setArgOperand(unsigned i, Value *v)
void setParentPad(Value *ParentPad)
Value * getParentPad() const
Convenience accessors.
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th funcletpad argument.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
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.
LLVM_ABI void copyFastMathFlags(FastMathFlags FMF)
Convenience function for transferring all fast-math flag values to this instruction,...
LLVM_ABI void setHasAllowReassoc(bool B)
Set or clear the reassociation flag on this instruction, which must be an operator which supports thi...
Instruction(const Instruction &)=delete
LLVM_ABI bool hasAllowReassoc() const LLVM_READONLY
Determine whether the allow-reassociation flag is set.
friend class BasicBlock
Various leaf nodes.
The landingpad instruction holds all of the information necessary to generate correct exception handl...
bool isCleanup() const
Return 'true' if this landingpad instruction is a cleanup.
void setCleanup(bool V)
Indicate that this landingpad instruction is a cleanup.
void setIsDisjoint(bool B)
Return a value (possibly void), from a function.
static LLVM_ABI Constant * convertShuffleMaskForBitcode(ArrayRef< int > Mask, Type *ResultTy)
void reserve(size_type N)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A handle to a particular switch case.
CaseIteratorImpl< ConstCaseHandle > ConstCaseIt
CaseIteratorImpl< CaseHandle > CaseIt
void setSuccessor(unsigned idx, BasicBlock *NewSucc)
Target - Wrapper for Target specific information.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)
Unconditional Branch instruction.
This function has undefined behavior.
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
static LLVM_ABI VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
An efficient, type-erasing, non-owning reference to a callable.
self_iterator getIterator()
NodeTy * getNextNode()
Get the next node, or nullptr for the list tail.
This class implements an extremely fast bulk output stream that can only output to a stream.
LLVM_ABI Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
LLVM_ABI void setAllocatedType(Type *Ty)
for use only in special circumstances that need to generically transform a whole instruction (eg: IR ...
LLVM_ABI Value * getArraySize()
Get the number of elements allocated.
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.
LLVM_ABI void setAlignment(Align Align)
static LLVM_ABI AllocaInst * create(Type *Ty, unsigned AddrSpace, InsertPosition Pos, Context &Ctx, Value *ArraySize=nullptr, const Twine &Name="")
LLVM_ABI Value * getPointerOperand()
LLVM_ABI void setSuccessOrdering(AtomicOrdering Ordering)
LLVM_ABI void setWeak(bool IsWeak)
LLVM_ABI void setVolatile(bool V)
Specify whether this is a volatile cmpxchg.
LLVM_ABI void setFailureOrdering(AtomicOrdering Ordering)
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="")
bool isVolatile() const
Return true if this is a cmpxchg from a volatile memory location.
LLVM_ABI void setSyncScopeID(SyncScope::ID SSID)
SyncScope::ID getSyncScopeID() const
LLVM_ABI Value * getNewValOperand()
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
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="")
LLVM_ABI void setSyncScopeID(SyncScope::ID SSID)
llvm::AtomicRMWInst::BinOp BinOp
LLVM_ABI void setOrdering(AtomicOrdering Ordering)
SyncScope::ID getSyncScopeID() const
LLVM_ABI void setVolatile(bool V)
LLVM_ABI Value * getPointerOperand()
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 LLVM_ABI Value * createWithCopiedFlags(Instruction::Opcode Op, Value *LHS, Value *RHS, Value *CopyFrom, InsertPosition Pos, Context &Ctx, const Twine &Name="")
LLVM_ABI Function * getCalledFunction() const
LLVM_ABI Use getCalledOperandUse() const
LLVM_ABI FunctionType * getFunctionType() const
LLVM_ABI void setCalledFunction(Function *F)
LLVM_ABI Function * getCaller()
LLVM_ABI Value * getCalledOperand() 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
LLVM_ABI void setIndirectDest(unsigned Idx, BasicBlock *BB)
LLVM_ABI BasicBlock * getDefaultDest() const
LLVM_ABI BasicBlock * getIndirectDest(unsigned Idx) const
LLVM_ABI SmallVector< BasicBlock *, 16 > getIndirectDests() 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="")
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 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
LLVM_ABI void setSuccessor(BasicBlock *NewSucc)
LLVM_ABI void setCatchPad(CatchPadInst *CatchPad)
LLVM_ABI Value * getCatchSwitchParentPad() const
static LLVM_ABI CatchReturnInst * create(CatchPadInst *CatchPad, BasicBlock *BB, InsertPosition Pos, Context &Ctx)
LLVM_ABI void addHandler(BasicBlock *Dest)
LLVM_ABI void setParentPad(Value *ParentPad)
LLVM_ABI void setUnwindDest(BasicBlock *UnwindDest)
static LLVM_ABI CatchSwitchInst * create(Value *ParentPad, BasicBlock *UnwindBB, unsigned NumHandlers, InsertPosition Pos, Context &Ctx, const Twine &Name="")
LLVM_ABI BasicBlock * getUnwindDest() const
LLVM_ABI Value * getParentPad() const
static LLVM_ABI CleanupPadInst * create(Value *ParentPad, ArrayRef< Value * > Args, InsertPosition Pos, Context &Ctx, const Twine &Name="")
LLVM_ABI CleanupPadInst * getCleanupPad() const
LLVM_ABI void setUnwindDest(BasicBlock *NewDest)
static LLVM_ABI CleanupReturnInst * create(CleanupPadInst *CleanupPad, BasicBlock *UnwindBB, InsertPosition Pos, Context &Ctx)
LLVM_ABI BasicBlock * getUnwindDest() const
LLVM_ABI void setCleanupPad(CleanupPadInst *CleanupPad)
llvm::CmpInst::Predicate Predicate
void dumpOS(raw_ostream &OS) const override
LLVM_DUMP_METHOD void dump() const
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)
LLVM_ABI void swapOperands()
static LLVM_ABI CondBrInst * create(Value *Cond, BasicBlock *IfTrue, BasicBlock *IfFalse, InsertPosition InsertBefore, Context &Ctx)
LLVM_ABI BasicBlock * getSuccessor(unsigned SuccIdx) const
static LLVM_ABI bool classof(const Value *From)
For isa/dyn_cast.
LLVM_ABI void setSuccessor(unsigned Idx, BasicBlock *NewSucc)
unsigned getNumSuccessors() const
LLVM_ABI Value * getCondition() const
LLVM_ABI void setCondition(Value *V)
static LLVM_ABI ConstantTokenNone * get(Context &Ctx)
Return the ConstantTokenNone.
Type * getType(llvm::Type *LLVMTy)
Constant * getOrCreateConstant(llvm::Constant *LLVMC)
Get or create a sandboxir::Constant from an existing LLVM IR LLVMC.
Value * getVectorOperand()
static LLVM_ABI Value * create(Value *Vec, Value *Idx, InsertPosition Pos, Context &Ctx, const Twine &Name="")
LLVM_ABI VectorType * getVectorOperandType() const
static LLVM_ABI Value * create(Value *Agg, ArrayRef< unsigned > Idxs, InsertPosition Pos, Context &Ctx, const Twine &Name="")
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...
LLVM_ABI void swapOperands()
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.
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="")
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.
LLVM_ABI void setParentPad(Value *ParentPad)
LLVM_ABI void setArgOperand(unsigned Idx, Value *V)
Set the Idx-th funcletpad argument.
Similar to GenericSetter but the setters/getters have an index as their first argument.
This class can be used for tracking most instruction setters.
LLVM_ABI Type * getResultElementType() const
LLVM_ABI Type * getPointerOperandType() const
LLVM_ABI Type * getSourceElementType() const
LLVM_ABI Value * getPointerOperand() const
static LLVM_ABI Value * create(Type *Ty, Value *Ptr, ArrayRef< Value * > IdxList, InsertPosition Pos, Context &Ctx, const Twine &NameStr="")
LLVM_ABI void swapOperands()
static LLVM_ABI Value * create(Value *Vec, Value *NewElt, Value *Idx, InsertPosition Pos, Context &Ctx, const Twine &Name="")
const BBIterator & getIterator() const
BasicBlock * getBasicBlock() const
static LLVM_ABI Value * create(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, InsertPosition Pos, Context &Ctx, const Twine &Name="")
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.
LLVM_ABI void setFastMathFlags(FastMathFlags FMF)
Convenience function for setting multiple fast-math flags on this instruction, which must be an opera...
LLVM_ABI void setHasAllowReassoc(bool B)
Set or clear the reassociation flag on this instruction, which must be an operator which supports thi...
bool hasNoSignedZeros() const
Determine whether the no-signed-zeros flag is set.
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.
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.
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.
void dumpOS(raw_ostream &OS) const override
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...
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,...
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.
LLVM_ABI llvm::Instruction * getTopmostLLVMInstruction() const
A SandboxIR Instruction may map to multiple LLVM IR Instruction.
LLVM_ABI void setHasAllowContract(bool B)
Set or clear the allow-contract flag on this instruction, which must be an operator which supports th...
virtual SmallVector< llvm::Instruction *, 1 > getLLVMInstrs() const =0
\Returns the LLVM IR Instructions that this SandboxIR maps to in program order.
LLVM_ABI Type * getAccessType() const
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...
LLVM_ABI Instruction * getNextNode() const
\Returns the next sandboxir::Instruction in the block, or nullptr if at the end of the block.
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...
static LLVM_ABI IRBuilder & setInsertPos(InsertPosition Pos)
Helper function for create().
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.
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)
LLVM_ABI void setUnwindDest(BasicBlock *BB)
LLVM_ABI BasicBlock * getSuccessor(unsigned SuccIdx) const
LLVM_ABI BasicBlock * getNormalDest() const
LLVM_ABI LandingPadInst * getLandingPadInst() const
LLVM_ABI void setCleanup(bool V)
Indicate that this landingpad instruction is a cleanup.
LLVM_ABI Constant * getClause(unsigned Idx) const
Get the value of the clause at index Idx.
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="")
LLVM_ABI void setVolatile(bool V)
Specify whether this is a volatile load or not.
LLVM_ABI Value * getPointerOperand() const
static LLVM_ABI bool classof(const Value *From)
For isa/dyn_cast.
LLVM_ABI Value * hasConstantValue() const
LLVM_ABI int getBasicBlockIndex(const BasicBlock *BB) 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.
static LLVM_ABI PHINode * create(Type *Ty, unsigned NumReservedValues, InsertPosition Pos, Context &Ctx, const Twine &Name="")
LLVM_ABI Value * removeIncomingValue(unsigned Idx)
LLVM_ABI void setIncomingValue(unsigned Idx, Value *V)
LLVM_ABI BasicBlock * getIncomingBlock(unsigned Idx) const
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)
LLVM_ABI void setIsDisjoint(bool B)
LLVM_ABI void setNonNeg(bool B)
static LLVM_ABI ResumeInst * create(Value *Exn, InsertPosition Pos, Context &Ctx)
LLVM_ABI Value * getValue() const
static LLVM_ABI ReturnInst * create(Value *RetVal, InsertPosition Pos, Context &Ctx)
LLVM_ABI Value * getReturnValue() const
\Returns null if there is no return value.
static LLVM_ABI bool classof(const Value *From)
For isa/dyn_cast.
LLVM_ABI void swapValues()
static LLVM_ABI Value * create(Value *Cond, Value *True, Value *False, InsertPosition Pos, Context &Ctx, const Twine &Name="")
LLVM_ABI VectorType * getType() const
Overload to return most specific vector type.
LLVM_ABI Constant * getShuffleMaskForBitcode() const
Return the mask for this instruction, for use in bitcode.
LLVM_ABI void commute()
Swap the operands and adjust the mask to preserve the semantics of the instruction.
static LLVM_ABI Value * create(Value *V1, Value *V2, Value *Mask, InsertPosition Pos, Context &Ctx, const Twine &Name="")
static LLVM_ABI Constant * convertShuffleMaskForBitcode(ArrayRef< int > Mask, Type *ResultTy)
LLVM_ABI void setShuffleMask(ArrayRef< int > Mask)
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 LLVM_ABI StoreInst * create(Value *V, Value *Ptr, MaybeAlign Align, InsertPosition Pos, bool IsVolatile, Context &Ctx)
LLVM_ABI Value * getPointerOperand() const
LLVM_ABI Value * getValueOperand() const
BlockT * getCaseSuccessor() const
ConstT * getCaseValue() 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_ABI BasicBlock * getDefaultDest() const
CaseItImpl< llvm::SwitchInst::CaseIt, BasicBlock, ConstantInt > CaseIt
LLVM_ABI Value * getCondition() const
LLVM_ABI void setSuccessor(unsigned Idx, BasicBlock *NewSucc)
LLVM_ABI void setCondition(Value *V)
LLVM_ABI ConstantInt * findCaseDest(BasicBlock *BB)
LLVM_ABI 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...
bool isTracking() const
\Returns true if the tracker is recording changes.
void track(std::unique_ptr< IRChangeBase > &&Change)
Record Change and take ownership.
bool emplaceIfTracking(ArgsT... Args)
A convenience wrapper for track() that constructs and tracks the Change object if tracking is enabled...
Just like llvm::Type these are immutable, unique, never get freed and can only be created via static ...
static LLVM_ABI IntegerType * getInt1Ty(Context &Ctx)
Context & getContext() const
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 UncondBrInst * create(BasicBlock *Target, InsertPosition InsertBefore, Context &Ctx)
LLVM_ABI BasicBlock * getSuccessor() const
static LLVM_ABI bool classof(const Value *From)
For isa/dyn_cast.
LLVM_ABI void setSuccessor(BasicBlock *NewSucc)
static LLVM_ABI UnreachableInst * create(InsertPosition Pos, Context &Ctx)
static LLVM_ABI bool classof(const Value *From)
Tracks swapping a Use with another Use.
Represents a Def-use/Use-def edge in SandboxIR.
virtual void setOperand(unsigned OperandIdx, Value *Operand)
virtual unsigned getNumOperands() const
Use getOperandUse(unsigned OpIdx) const
\Returns the operand edge for OpIdx.
LLVM_ABI Value * getPointerOperand()
static LLVM_ABI VAArgInst * create(Value *List, Type *Ty, InsertPosition Pos, Context &Ctx, const Twine &Name="")
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.
iterator_range< user_iterator > users()
void dumpCommonPrefix(raw_ostream &OS) const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static llvm::Instruction::CastOps getLLVMCastOp(Instruction::Opcode Opc)
BasicBlock(llvm::BasicBlock *BB, Context &SBCtx)
static llvm::Instruction::UnaryOps getLLVMUnaryOp(Instruction::Opcode Opc)
\Returns the LLVM opcode that corresponds to Opc.
LLVM_ABI void dumpOS(raw_ostream &OS) const final
LLVM_ABI iterator begin() const
static llvm::Instruction::BinaryOps getLLVMBinaryOp(Instruction::Opcode Opc)
\Returns the LLVM opcode that corresponds to Opc.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
auto cast_or_null(const Y &Val)
const Value * getPointerOperand(const Value *V)
A helper function that returns the pointer operand of a load, store or GEP instruction.
auto reverse(ContainerTy &&C)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool is_sorted(R &&Range, Compare C)
Wrapper function around std::is_sorted to check if elements in a range R are sorted with respect to a...
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.
This struct is a compact representation of a valid (non-zero power of two) alignment.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.