9#ifndef LLVM_SANDBOXIR_INSTRUCTION_H
10#define LLVM_SANDBOXIR_INSTRUCTION_H
30 assert(InsertAtEnd !=
nullptr &&
"Expected non-null!");
31 InsertAt = InsertAtEnd->
end();
46#define OPCODES(...) __VA_ARGS__
47#define DEF_INSTR(ID, OPC, CLASS) OPC
48#include "llvm/SandboxIR/Values.def"
106 auto &
Ctx = WhereBB->getContext();
108 if (WhereIt != WhereBB->end())
109 Builder.SetInsertPoint((*Pos).getTopmostLLVMInstruction());
111 Builder.SetInsertPoint(cast<llvm::BasicBlock>(WhereBB->Val));
134 return cast<llvm::Instruction>(
Val)->getModule()->getDataLayout();
143 return cast<llvm::Instruction>(
Val)->isTerminator();
145 bool isUnaryOp()
const {
return cast<llvm::Instruction>(
Val)->isUnaryOp(); }
146 bool isBinaryOp()
const {
return cast<llvm::Instruction>(
Val)->isBinaryOp(); }
148 return cast<llvm::Instruction>(
Val)->isIntDivRem();
150 bool isShift()
const {
return cast<llvm::Instruction>(
Val)->isShift(); }
151 bool isCast()
const {
return cast<llvm::Instruction>(
Val)->isCast(); }
153 return cast<llvm::Instruction>(
Val)->isFuncletPad();
156 return cast<llvm::Instruction>(
Val)->isSpecialTerminator();
159 return cast<llvm::Instruction>(
Val)->isOnlyUserOfAnyOperand();
162 return cast<llvm::Instruction>(
Val)->isLogicalShift();
171 return cast<llvm::Instruction>(
Val)->hasMetadata();
177 return cast<llvm::Instruction>(
Val)->hasMetadataOtherThanDebugLoc();
182 return cast<llvm::Instruction>(
Val)->hasMetadata(KindID);
215 return cast<llvm::Instruction>(
Val)->comesBefore(
216 cast<llvm::Instruction>(
Other->Val));
226 return cast<llvm::Instruction>(
Val)->hasNoUnsignedWrap();
233 return cast<llvm::Instruction>(
Val)->hasNoSignedWrap();
239 bool isFast()
const {
return cast<llvm::Instruction>(
Val)->isFast(); }
246 return cast<llvm::Instruction>(
Val)->hasAllowReassoc();
253 bool isExact()
const {
return cast<llvm::Instruction>(
Val)->isExact(); }
258 bool hasNoNaNs()
const {
return cast<llvm::Instruction>(
Val)->hasNoNaNs(); }
264 bool hasNoInfs()
const {
return cast<llvm::Instruction>(
Val)->hasNoInfs(); }
271 return cast<llvm::Instruction>(
Val)->hasNoSignedZeros();
279 return cast<llvm::Instruction>(
Val)->hasAllowReciprocal();
287 return cast<llvm::Instruction>(
Val)->hasAllowContract();
295 return cast<llvm::Instruction>(
Val)->hasApproxFunc();
305 return cast<llvm::Instruction>(
Val)->getFastMathFlags();
317 return cast<llvm::Instruction>(
Val)->isAssociative();
321 return cast<llvm::Instruction>(
Val)->isCommutative();
325 return cast<llvm::Instruction>(
Val)->isIdempotent();
329 return cast<llvm::Instruction>(
Val)->isNilpotent();
333 return cast<llvm::Instruction>(
Val)->mayWriteToMemory();
337 return cast<llvm::Instruction>(
Val)->mayReadFromMemory();
340 return cast<llvm::Instruction>(
Val)->mayReadOrWriteMemory();
343 bool isAtomic()
const {
return cast<llvm::Instruction>(
Val)->isAtomic(); }
346 return cast<llvm::Instruction>(
Val)->hasAtomicLoad();
350 return cast<llvm::Instruction>(
Val)->hasAtomicStore();
353 bool isVolatile()
const {
return cast<llvm::Instruction>(
Val)->isVolatile(); }
357 bool mayThrow(
bool IncludePhaseOneUnwind =
false)
const {
358 return cast<llvm::Instruction>(
Val)->mayThrow(IncludePhaseOneUnwind);
362 return cast<llvm::Instruction>(
Val)->isFenceLike();
366 return cast<llvm::Instruction>(
Val)->mayHaveSideEffects();
383#define DEF_INSTR(ID, OPC, CLASS) friend class CLASS;
384#include "llvm/SandboxIR/Values.def"
390 Use getOperandUseInternal(
unsigned OpIdx,
bool Verify)
const final {
394 return {cast<llvm::Instruction>(
Val)};
422 return cast<llvm::FenceInst>(
Val)->getOrdering();
429 return cast<llvm::FenceInst>(
Val)->getSyncScopeID();
434 return From->getSubclassID() == ClassID::Fence;
487 return From->getSubclassID() == ClassID::InsertElement;
501 Opcode::ExtractElement,
I,
Ctx) {}
509 return From->getSubclassID() == ClassID::ExtractElement;
537 return From->getSubclassID() == ClassID::ShuffleVector;
562 return cast<llvm::ShuffleVectorInst>(
Val)->getMaskValue(Elt);
576 cast<llvm::ShuffleVectorInst>(
Val)->getShuffleMask(Result);
588 return cast<llvm::ShuffleVectorInst>(
Val)->getShuffleMask();
596 return cast<llvm::ShuffleVectorInst>(
Val)->changesLength();
603 return cast<llvm::ShuffleVectorInst>(
Val)->increasesLength();
616 cast<llvm::Constant>(Mask->Val), NumSrcElts);
623 return cast<llvm::ShuffleVectorInst>(
Val)->isSingleSource();
636 cast<llvm::Constant>(Mask->Val), NumSrcElts);
644 return cast<llvm::ShuffleVectorInst>(
Val)->isIdentity();
650 return cast<llvm::ShuffleVectorInst>(
Val)->isIdentityWithPadding();
656 return cast<llvm::ShuffleVectorInst>(
Val)->isIdentityWithExtract();
663 return cast<llvm::ShuffleVectorInst>(
Val)->isConcat();
679 cast<llvm::Constant>(Mask->Val), NumSrcElts);
690 return cast<llvm::ShuffleVectorInst>(
Val)->isSelect();
703 cast<llvm::Constant>(Mask->Val), NumSrcElts);
710 return cast<llvm::ShuffleVectorInst>(
Val)->isReverse();
723 cast<llvm::Constant>(Mask->Val), NumSrcElts);
731 return cast<llvm::ShuffleVectorInst>(
Val)->isZeroEltSplat();
771 cast<llvm::Constant>(Mask->Val), NumSrcElts);
780 return cast<llvm::ShuffleVectorInst>(
Val)->isTranspose();
794 cast<llvm::Constant>(Mask->Val), NumSrcElts,
Index);
802 return cast<llvm::ShuffleVectorInst>(
Val)->isSplice(
Index);
816 cast<llvm::Constant>(Mask->Val), NumSrcElts,
Index);
821 return cast<llvm::ShuffleVectorInst>(
Val)->isExtractSubvectorMask(
Index);
829 int &NumSubElts,
int &
Index) {
834 int &NumSubElts,
int &
Index) {
836 cast<llvm::Constant>(Mask->Val), NumSrcElts, NumSubElts,
Index);
841 return cast<llvm::ShuffleVectorInst>(
Val)->isInsertSubvectorMask(NumSubElts,
857 cast<llvm::Constant>(Mask->Val), ReplicationFactor, VF);
862 return cast<llvm::ShuffleVectorInst>(
Val)->isReplicationMask(
863 ReplicationFactor, VF);
882 return cast<llvm::ShuffleVectorInst>(
Val)->isOneUseSingleSourceMask(VF);
888 unsigned InVecNumElts) {
894 return cast<llvm::ShuffleVectorInst>(
Val)->isInterleave(Factor);
917 unsigned NumInputElts,
923 unsigned NumInputElts) {
952 unsigned MinSubElts,
unsigned MaxSubElts,
953 unsigned &NumSubElts,
unsigned &RotateAmt) {
955 Mask, EltSizeInBits, MinSubElts, MaxSubElts, NumSubElts, RotateAmt);
973 return From->getSubclassID() == ClassID::InsertValue;
978 return cast<llvm::InsertValueInst>(
Val)->idx_begin();
981 return cast<llvm::InsertValueInst>(
Val)->idx_end();
984 return cast<llvm::InsertValueInst>(
Val)->indices();
1008 return cast<llvm::InsertValueInst>(
Val)->getIndices();
1012 return cast<llvm::InsertValueInst>(
Val)->getNumIndices();
1016 return cast<llvm::InsertValueInst>(
Val)->hasIndices();
1034 return cast<llvm::BranchInst>(
Val)->isUnconditional();
1037 return cast<llvm::BranchInst>(
Val)->isConditional();
1047 struct LLVMBBToSBBB {
1049 LLVMBBToSBBB(
Context &Ctx) : Ctx(Ctx) {}
1053 struct ConstLLVMBBToSBBB {
1055 ConstLLVMBBToSBBB(Context &Ctx) : Ctx(Ctx) {}
1064 cast<llvm::BranchInst>(
Val)->successors();
1065 LLVMBBToSBBB BBMap(
Ctx);
1078 ConstLLVMBBToSBBB ConstBBMap(
Ctx);
1083 return make_range(ConstMappedBegin, ConstMappedEnd);
1097 return isa<LoadInst>(
I) || isa<CastInst>(
I) || isa<FreezeInst>(
I);
1100 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
1116 return From->getSubclassID() == ClassID::ExtractValue;
1128 return cast<llvm::ExtractValueInst>(
Val)->idx_begin();
1131 return cast<llvm::ExtractValueInst>(
Val)->idx_end();
1134 return cast<llvm::ExtractValueInst>(
Val)->indices();
1148 return cast<llvm::ExtractValueInst>(
Val)->getIndices();
1152 return cast<llvm::ExtractValueInst>(
Val)->getNumIndices();
1156 return cast<llvm::ExtractValueInst>(
Val)->hasIndices();
1176 return From->getSubclassID() == ClassID::VAArg;
1189 return From->getSubclassID() == ClassID::Freeze;
1219 bool isSimple()
const {
return cast<llvm::LoadInst>(
Val)->isSimple(); }
1246 bool isSimple()
const {
return cast<llvm::StoreInst>(
Val)->isSimple(); }
1255 Use getOperandUseInternal(
unsigned OpIdx,
bool Verify)
const final {
1259 return {cast<llvm::Instruction>(
Val)};
1285 return From->getSubclassID() == ClassID::Ret;
1300 auto Opc =
From->getSubclassID();
1301 return Opc == Instruction::ClassID::Call ||
1302 Opc == Instruction::ClassID::Invoke ||
1303 Opc == Instruction::ClassID::CallBr;
1313 auto *LLVMCB = cast<llvm::CallBase>(
Val);
1314 auto Dist = LLVMCB->data_operands_end() - LLVMCB->data_operands_begin();
1318 auto *LLVMCB = cast<llvm::CallBase>(
Val);
1319 auto Dist = LLVMCB->data_operands_end() - LLVMCB->data_operands_begin();
1335 assert(
this == U.getUser() &&
1336 "Only valid to query with a use of this instruction!");
1337 return cast<llvm::CallBase>(
Val)->isDataOperand(U.LLVMUse);
1341 return cast<llvm::CallBase>(
Val)->getDataOperandNo(U.LLVMUse);
1347 return cast<llvm::CallBase>(
Val)->getNumTotalBundleOperands();
1386 return cast<llvm::CallBase>(
Val)->isArgOperand(U.LLVMUse);
1389 return cast<llvm::CallBase>(
Val)->getArgOperandNo(U.LLVMUse);
1398 return cast<llvm::CallBase>(
Val)->isIndirectCall();
1401 return cast<llvm::CallBase>(
Val)->isCallee(U.LLVMUse);
1408 return cast<llvm::CallBase>(
Val)->isMustTailCall();
1412 return cast<llvm::CallBase>(
Val)->getIntrinsicID();
1417 return cast<llvm::CallBase>(
Val)->getCallingConv();
1436 return From->getSubclassID() == ClassID::Call;
1455 return From->getSubclassID() == ClassID::Invoke;
1464 assert(SuccIdx < 2 &&
"Successor # out of range for invoke!");
1471 return cast<llvm::InvokeInst>(
Val)->getNumSuccessors();
1490 return From->getSubclassID() == ClassID::CallBr;
1493 return cast<llvm::CallBrInst>(
Val)->getNumIndirectDests();
1504 return cast<llvm::CallBrInst>(
Val)->getNumSuccessors();
1522 return cast<llvm::LandingPadInst>(
Val)->isCleanup();
1536 return cast<llvm::LandingPadInst>(
Val)->isCatch(
Idx);
1540 return cast<llvm::LandingPadInst>(
Val)->isFilter(
Idx);
1544 return cast<llvm::LandingPadInst>(
Val)->getNumOperands();
1548 return From->getSubclassID() == ClassID::LandingPad;
1562 return cast<llvm::FuncletPadInst>(
Val)->arg_size();
1577 return From->getSubclassID() == ClassID::CatchPad ||
1578 From->getSubclassID() == ClassID::CleanupPad;
1596 return From->getSubclassID() == ClassID::CatchPad;
1610 return From->getSubclassID() == ClassID::CleanupPad;
1629 return cast<llvm::CatchReturnInst>(
Val)->getNumSuccessors();
1633 return From->getSubclassID() == ClassID::CatchRet;
1649 return cast<llvm::CleanupReturnInst>(
Val)->hasUnwindDest();
1652 return cast<llvm::CleanupReturnInst>(
Val)->unwindsToCaller();
1657 return cast<llvm::CleanupReturnInst>(
Val)->getNumSuccessors();
1663 return From->getSubclassID() == ClassID::CleanupRet;
1682 const Twine &NameStr =
"");
1685 return From->getSubclassID() == ClassID::GetElementPtr;
1691 return cast<llvm::GetElementPtrInst>(
Val)->getAddressSpace();
1715 return cast<llvm::GetElementPtrInst>(
Val)->getPointerAddressSpace();
1718 return cast<llvm::GetElementPtrInst>(
Val)->getNumIndices();
1721 return cast<llvm::GetElementPtrInst>(
Val)->hasIndices();
1724 return cast<llvm::GetElementPtrInst>(
Val)->hasAllConstantIndices();
1727 return cast<llvm::GetElementPtrInst>(
Val)->getNoWrapFlags();
1730 return cast<llvm::GetElementPtrInst>(
Val)->isInBounds();
1733 return cast<llvm::GetElementPtrInst>(
Val)->hasNoUnsignedSignedWrap();
1736 return cast<llvm::GetElementPtrInst>(
Val)->hasNoUnsignedWrap();
1739 return cast<llvm::GetElementPtrInst>(
Val)->accumulateConstantOffset(
DL,
1761 return cast<llvm::CatchSwitchInst>(
Val)->hasUnwindDest();
1764 return cast<llvm::CatchSwitchInst>(
Val)->unwindsToCaller();
1770 return cast<llvm::CatchSwitchInst>(
Val)->getNumHandlers();
1774 static BasicBlock *handler_helper(
Value *V) {
return cast<BasicBlock>(V); }
1776 return cast<BasicBlock>(V);
1822 "Successor # out of range for catchswitch!");
1827 "Successor # out of range for catchswitch!");
1832 return From->getSubclassID() == ClassID::CatchSwitch;
1845 return cast<llvm::ResumeInst>(
Val)->getNumSuccessors();
1848 return From->getSubclassID() == ClassID::Resume;
1869 return cast<llvm::SwitchInst>(
Val)->defaultDestUndefined();
1873 return cast<llvm::SwitchInst>(
Val)->getNumCases();
1929 return cast<llvm::SwitchInst>(
Val)->getNumSuccessors();
1934 return From->getSubclassID() == ClassID::Switch;
1941 case llvm::Instruction::FNeg:
1942 return Opcode::FNeg;
1943 case llvm::Instruction::UnaryOpsEnd:
1960 return From->getSubclassID() == ClassID::UnOp;
1968 case llvm::Instruction::Add:
1970 case llvm::Instruction::FAdd:
1971 return Opcode::FAdd;
1972 case llvm::Instruction::Sub:
1974 case llvm::Instruction::FSub:
1975 return Opcode::FSub;
1976 case llvm::Instruction::Mul:
1978 case llvm::Instruction::FMul:
1979 return Opcode::FMul;
1980 case llvm::Instruction::UDiv:
1981 return Opcode::UDiv;
1982 case llvm::Instruction::SDiv:
1983 return Opcode::SDiv;
1984 case llvm::Instruction::FDiv:
1985 return Opcode::FDiv;
1986 case llvm::Instruction::URem:
1987 return Opcode::URem;
1988 case llvm::Instruction::SRem:
1989 return Opcode::SRem;
1990 case llvm::Instruction::FRem:
1991 return Opcode::FRem;
1992 case llvm::Instruction::Shl:
1994 case llvm::Instruction::LShr:
1995 return Opcode::LShr;
1996 case llvm::Instruction::AShr:
1997 return Opcode::AShr;
1998 case llvm::Instruction::And:
2000 case llvm::Instruction::Or:
2002 case llvm::Instruction::Xor:
2004 case llvm::Instruction::BinaryOpsEnd:
2026 return From->getSubclassID() == ClassID::BinaryOperator;
2038 return cast<llvm::PossiblyDisjointInst>(
Val)->isDisjoint();
2042 return isa<Instruction>(
From) &&
2043 cast<Instruction>(
From)->getOpcode() == Opcode::Or;
2050 Instruction::Opcode::AtomicRMW, Atomic,
Ctx) {
2057 return cast<llvm::AtomicRMWInst>(
Val)->getOperation();
2066 cast<llvm::AtomicRMWInst>(
Val)->setOperation(
Op);
2071 return cast<llvm::AtomicRMWInst>(
Val)->isVolatile();
2075 return cast<llvm::AtomicRMWInst>(
Val)->getOrdering();
2079 return cast<llvm::AtomicRMWInst>(
Val)->getSyncScopeID();
2091 return cast<llvm::AtomicRMWInst>(
Val)->getPointerAddressSpace();
2094 return cast<llvm::AtomicRMWInst>(
Val)->isFloatingPointOperation();
2097 return From->getSubclassID() == ClassID::AtomicRMW;
2111 Instruction::Opcode::AtomicCmpXchg, Atomic,
2119 return cast<llvm::AtomicCmpXchgInst>(
Val)->getAlign();
2126 return cast<llvm::AtomicCmpXchgInst>(
Val)->isVolatile();
2131 bool isWeak()
const {
return cast<llvm::AtomicCmpXchgInst>(
Val)->isWeak(); }
2140 return cast<llvm::AtomicCmpXchgInst>(
Val)->getSuccessOrdering();
2145 return cast<llvm::AtomicCmpXchgInst>(
Val)->getFailureOrdering();
2149 return cast<llvm::AtomicCmpXchgInst>(
Val)->getMergedOrdering();
2152 return cast<llvm::AtomicCmpXchgInst>(
Val)->getSyncScopeID();
2172 return cast<llvm::AtomicCmpXchgInst>(
Val)->getPointerAddressSpace();
2182 return From->getSubclassID() == ClassID::AtomicCmpXchg;
2200 return cast<llvm::AllocaInst>(
Val)->isArrayAllocation();
2212 return cast<llvm::AllocaInst>(
Val)->getAddressSpace();
2217 return cast<llvm::AllocaInst>(
Val)->getAllocationSize(
DL);
2222 return cast<llvm::AllocaInst>(
Val)->getAllocationSizeInBits(
DL);
2237 return cast<llvm::AllocaInst>(
Val)->isStaticAlloca();
2242 return cast<llvm::AllocaInst>(
Val)->isUsedWithInAlloca();
2248 if (
auto *
I = dyn_cast<Instruction>(
From))
2249 return I->getSubclassID() == Instruction::ClassID::Alloca;
2257 case llvm::Instruction::ZExt:
2258 return Opcode::ZExt;
2259 case llvm::Instruction::SExt:
2260 return Opcode::SExt;
2261 case llvm::Instruction::FPToUI:
2262 return Opcode::FPToUI;
2263 case llvm::Instruction::FPToSI:
2264 return Opcode::FPToSI;
2265 case llvm::Instruction::FPExt:
2266 return Opcode::FPExt;
2267 case llvm::Instruction::PtrToInt:
2268 return Opcode::PtrToInt;
2269 case llvm::Instruction::IntToPtr:
2270 return Opcode::IntToPtr;
2271 case llvm::Instruction::SIToFP:
2272 return Opcode::SIToFP;
2273 case llvm::Instruction::UIToFP:
2274 return Opcode::UIToFP;
2275 case llvm::Instruction::Trunc:
2276 return Opcode::Trunc;
2277 case llvm::Instruction::FPTrunc:
2278 return Opcode::FPTrunc;
2279 case llvm::Instruction::BitCast:
2280 return Opcode::BitCast;
2281 case llvm::Instruction::AddrSpaceCast:
2282 return Opcode::AddrSpaceCast;
2283 case llvm::Instruction::CastOpsEnd:
2309 return cast<llvm::PossiblyNonNegInst>(
Val)->hasNonNeg();
2314 if (
auto *
I = dyn_cast<Instruction>(
From)) {
2315 switch (
I->getOpcode()) {
2317 case Opcode::UIToFP:
2336 if (
auto *
I = dyn_cast<Instruction>(
From))
2337 return I->getOpcode() ==
Op;
2357 :
public CastInstImpl<Instruction::Opcode::AddrSpaceCast> {
2385 LLVMBBToBB(
Context &Ctx) : Ctx(Ctx) {}
2400 LLVMBBToBB BBGetter(
Ctx);
2405 LLVMBBToBB BBGetter(
Ctx);
2418 return cast<llvm::PHINode>(
Val)->getNumIncomingValues();
2444 return cast<llvm::PHINode>(
Val)->hasConstantOrUndefValue();
2456#define WRAP_STATIC_PREDICATE(FunctionName) \
2457 static auto FunctionName(Predicate P) { return LLVMValType::FunctionName(P); }
2460#define WRAP_MEMBER(FunctionName) \
2461 auto FunctionName() const { return cast<LLVMValType>(Val)->FunctionName(); }
2463#define WRAP_BOTH(FunctionName) \
2464 WRAP_STATIC_PREDICATE(FunctionName) \
2465 WRAP_MEMBER(FunctionName)
2523 return From->getSubclassID() == ClassID::ICmp ||
2524 From->getSubclassID() == ClassID::FCmp;
2539 :
CmpInst(CI,
Ctx, ClassID::ICmp, Opcode::ICmp) {}
2564 return From->getSubclassID() == ClassID::ICmp;
2571 :
CmpInst(CI,
Ctx, ClassID::FCmp, Opcode::FCmp) {}
2589 return From->getSubclassID() == ClassID::FCmp;
2593#undef WRAP_STATIC_PREDICATE
2608 return From->getSubclassID() == ClassID::Opaque;
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
BlockVerifier::State From
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
static bool isSigned(unsigned int Opcode)
Module.h This file contains the declarations for the Module class.
ppc ctr loops PowerPC CTR Loops Verify
const SmallVectorImpl< MachineOperand > & Cond
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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 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.
static bool isImpliedTrueByMatchingCmp(Predicate Pred1, Predicate Pred2)
Determine if Pred1 implies Pred2 is true when two compares have matching operands.
static bool isImpliedFalseByMatchingCmp(Predicate Pred1, Predicate Pred2)
Determine if Pred1 implies Pred2 is false when two compares have matching operands.
This class represents an Operation in the Expression.
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 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 bool compare(const APInt &LHS, const APInt &RHS, ICmpInst::Predicate Pred)
Return result of LHS Pred RHS comparison.
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 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 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 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 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 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(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask chooses elements from its source vectors without lane crossings.
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,...
static bool isOneUseSingleSourceMask(ArrayRef< int > Mask, int VF)
Return true if this shuffle mask represents "clustered" mask of size VF, i.e.
static bool isSingleSourceMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask chooses elements from exactly one source vector.
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,...
static bool isIdentityMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask chooses elements from exactly one source vector without lane crossin...
static bool isExtractSubvectorMask(ArrayRef< int > Mask, int NumSrcElts, int &Index)
Return true if this shuffle mask is an extract subvector 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 void commuteShuffleMask(MutableArrayRef< int > Mask, unsigned InVecNumElts)
Change values in a shuffle permute mask assuming the two vector operands of length InVecNumElts have ...
static bool isTransposeMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask is a transpose mask.
static bool isInsertSubvectorMask(ArrayRef< int > Mask, int NumSrcElts, int &NumSubElts, int &Index)
Return true if this shuffle mask is an insert subvector mask.
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 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.
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.
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.
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.
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.
PointerType * getType() const
Overload to return most specific pointer type.
void setUsedWithInAlloca(bool V)
Specify whether this alloca is used to represent the arguments to a call.
static bool classof(const Value *From)
std::optional< TypeSize > getAllocationSize(const DataLayout &DL) const
Get allocation size in bytes.
void setAlignment(Align Align)
const Value * getArraySize() const
static AllocaInst * create(Type *Ty, unsigned AddrSpace, InsertPosition Pos, Context &Ctx, Value *ArraySize=nullptr, const Twine &Name="")
Value * getPointerOperand()
const Value * getNewValOperand() const
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
AtomicOrdering getMergedOrdering() const
void setSuccessOrdering(AtomicOrdering Ordering)
const Value * getCompareOperand() const
void setWeak(bool IsWeak)
void setVolatile(bool V)
Specify whether this is a volatile cmpxchg.
const Value * getPointerOperand() const
void setFailureOrdering(AtomicOrdering Ordering)
static bool classof(const Value *From)
AtomicOrdering getFailureOrdering() const
void setAlignment(Align Align)
Value * getCompareOperand()
static 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)
void setSyncScopeID(SyncScope::ID SSID)
AtomicOrdering getSuccessOrdering() const
SyncScope::ID getSyncScopeID() const
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.
static 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
void setSyncScopeID(SyncScope::ID SSID)
unsigned getPointerAddressSpace() const
llvm::AtomicRMWInst::BinOp BinOp
void setOrdering(AtomicOrdering Ordering)
SyncScope::ID getSyncScopeID() const
const Value * getValOperand() const
static StringRef getOperationName(BinOp Op)
AtomicOrdering getOrdering() const
void setOperation(BinOp Op)
Value * getPointerOperand()
static bool classof(const Value *From)
bool isFloatingPointOperation() const
static bool isFPOperation(BinOp Op)
void setAlignment(Align Align)
Iterator for Instructions in a `BasicBlock.
BasicBlock * getNodeParent() const
\Returns the parent BB.
Contains a list of sandboxir::Instruction's.
static 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 Value * createWithCopiedFlags(Instruction::Opcode Op, Value *LHS, Value *RHS, Value *CopyFrom, InsertPosition Pos, Context &Ctx, const Twine &Name="")
BasicBlock * getSuccessor(unsigned SuccIdx) const
Value * getCondition() const
void setSuccessor(unsigned Idx, BasicBlock *NewSucc)
unsigned getNumSuccessors() const
iterator_range< sb_succ_op_iterator > successors()
static BranchInst * create(BasicBlock *IfTrue, InsertPosition Pos, Context &Ctx)
static bool classof(const Value *From)
For isa/dyn_cast.
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
Function * getCalledFunction() const
Use getCalledOperandUse() const
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
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()
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
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
Value * getIndirectDestLabelUse(unsigned Idx) const
static CallBrInst * create(FunctionType *FTy, Value *Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, InsertPosition Pos, Context &Ctx, const Twine &NameStr="")
Value * getIndirectDestLabel(unsigned Idx) const
BasicBlock * getSuccessor(unsigned Idx) const
static bool classof(const Value *From)
void setIndirectDest(unsigned Idx, BasicBlock *BB)
BasicBlock * getDefaultDest() const
unsigned getNumIndirectDests() const
BasicBlock * getIndirectDest(unsigned Idx) const
SmallVector< BasicBlock *, 16 > getIndirectDests() const
unsigned getNumSuccessors() const
void setDefaultDest(BasicBlock *BB)
static CallInst * create(FunctionType *FTy, Value *Func, ArrayRef< Value * > Args, InsertPosition Pos, Context &Ctx, const Twine &NameStr="")
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="")
static Value * create(Type *DestTy, Opcode Op, Value *Operand, InsertPosition Pos, Context &Ctx, const Twine &Name="")
static bool classof(const Value *From)
For isa/dyn_cast.
static bool classof(const Value *From)
static CatchPadInst * create(Value *ParentPad, ArrayRef< Value * > Args, InsertPosition Pos, Context &Ctx, const Twine &Name="")
CatchSwitchInst * getCatchSwitch() const
CatchPadInst * getCatchPad() const
BasicBlock * getSuccessor() const
static bool classof(const Value *From)
void setSuccessor(BasicBlock *NewSucc)
void setCatchPad(CatchPadInst *CatchPad)
unsigned getNumSuccessors()
Value * getCatchSwitchParentPad() const
static CatchReturnInst * create(CatchPadInst *CatchPad, BasicBlock *BB, InsertPosition Pos, Context &Ctx)
void addHandler(BasicBlock *Dest)
const_handler_iterator handler_begin() const
const_handler_iterator handler_end() const
const BasicBlock *(*)(const Value *) ConstDerefFnTy
BasicBlock *(*)(Value *) DerefFnTy
unsigned getNumSuccessors() const
void setParentPad(Value *ParentPad)
bool hasUnwindDest() const
bool unwindsToCaller() const
void setUnwindDest(BasicBlock *UnwindDest)
handler_iterator handler_begin()
static 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)
BasicBlock * getUnwindDest() const
Value * getParentPad() const
BasicBlock * getSuccessor(unsigned Idx) const
const_handler_range handlers() const
static CleanupPadInst * create(Value *ParentPad, ArrayRef< Value * > Args, InsertPosition Pos, Context &Ctx, const Twine &Name="")
static bool classof(const Value *From)
CleanupPadInst * getCleanupPad() const
bool hasUnwindDest() const
void setUnwindDest(BasicBlock *NewDest)
bool unwindsToCaller() const
static CleanupReturnInst * create(CleanupPadInst *CleanupPad, BasicBlock *UnwindBB, InsertPosition Pos, Context &Ctx)
unsigned getNumSuccessors() const
BasicBlock * getUnwindDest() const
void setCleanupPad(CleanupPadInst *CleanupPad)
static bool classof(const Value *From)
WRAP_STATIC_PREDICATE(isUnordered)
static bool isImpliedFalseByMatchingCmp(Predicate Pred1, Predicate Pred2)
WRAP_BOTH(isTrueWhenEqual)
static CmpInst * create(Predicate Pred, Value *S1, Value *S2, InsertPosition Pos, Context &Ctx, const Twine &Name="")
static CmpInst * createWithCopiedFlags(Predicate Pred, Value *S1, Value *S2, const Instruction *FlagsSource, InsertPosition Pos, Context &Ctx, const Twine &Name="")
WRAP_BOTH(getInversePredicate)
void dumpOS(raw_ostream &OS) const override
LLVM_DUMP_METHOD void dump() const
WRAP_BOTH(getNonStrictPredicate)
static Type * makeCmpResultType(Type *OpndType)
Create a result type for fcmp/icmp.
void setPredicate(Predicate P)
static Value * createCommon(Value *Cond, Value *True, Value *False, const Twine &Name, IRBuilder<> &Builder, Context &Ctx)
WRAP_BOTH(isIntPredicate)
WRAP_STATIC_PREDICATE(isOrdered)
WRAP_BOTH(isNonStrictPredicate)
WRAP_BOTH(getSwappedPredicate)
static bool isImpliedTrueByMatchingCmp(Predicate Pred1, Predicate Pred2)
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)
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:
auto & getLLVMIRBuilder()
const Value * getVectorOperand() const
const Value * getIndexOperand() const
Value * getVectorOperand()
static Value * create(Value *Vec, Value *Idx, InsertPosition Pos, Context &Ctx, const Twine &Name="")
VectorType * getVectorOperandType() const
Value * getIndexOperand()
static bool classof(const Value *From)
static bool isValidOperands(const Value *Vec, const Value *Idx)
unsigned getNumIndices() const
static 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 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
static bool classof(const Value *From)
iterator_range< idx_iterator > indices() const
idx_iterator idx_end() const
WRAP_MEMBER(isRelational)
WRAP_MEMBER(isCommutative)
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 FenceInst * create(AtomicOrdering Ordering, InsertPosition Pos, Context &Ctx, SyncScope::ID SSID=SyncScope::System)
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)
void setSyncScopeID(SyncScope::ID SSID)
Sets the synchronization scope ID of this fence instruction.
static FreezeInst * create(Value *V, InsertPosition Pos, Context &Ctx, const Twine &Name="")
static bool classof(const Value *From)
static bool classof(const Value *From)
Value * getArgOperand(unsigned Idx) const
Return the Idx-th funcletpad argument.
Value * getParentPad() const
Return the outer EH-pad this funclet is nested within.
unsigned arg_size() const
Return the number of funcletpad arguments.
void setParentPad(Value *ParentPad)
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
Type * getResultElementType() const
unsigned getNumIndices() const
Type * getPointerOperandType() const
static unsigned getPointerOperandIndex()
Type * getSourceElementType() const
bool hasNoUnsignedSignedWrap() const
static bool classof(const Value *From)
const_op_iterator idx_end() const
Value * getPointerOperand() const
bool accumulateConstantOffset(const DataLayout &DL, APInt &Offset) const
iterator_range< const_op_iterator > indices() const
static Value * create(Type *Ty, Value *Ptr, ArrayRef< Value * > IdxList, InsertPosition Pos, Context &Ctx, const Twine &NameStr="")
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)
WRAP_STATIC_PREDICATE(isLT)
WRAP_BOTH(getUnsignedPredicate)
WRAP_MEMBER(isCommutative)
WRAP_MEMBER(isRelational)
WRAP_BOTH(getFlippedSignednessPredicate)
static bool classof(const Value *From)
static 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
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 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
bool hasNoUnsignedWrap() const
Determine whether the no signed wrap flag is set.
static IRBuilder & setInsertPos(InsertPosition Pos)
Helper function for create().
bool isAssociative() const
void setFastMathFlags(FastMathFlags FMF)
Convenience function for setting multiple fast-math flags on this instruction, which must be an opera...
friend class UnreachableInst
bool isSpecialTerminator() const
const DataLayout & getDataLayout() const
bool hasAllowReassoc() const
Determine whether the allow-reassociation flag is set.
void setHasAllowReassoc(bool B)
Set or clear the reassociation flag on this instruction, which must be an operator which supports thi...
bool mayWriteToMemory() const
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
void setHasNoSignedWrap(bool B=true)
Set or clear the nsw flag on this instruction, which must be an operator which supports this flag.
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.
void moveAfter(Instruction *After)
Move this instruction after After.
void moveBefore(BasicBlock &BB, const BBIterator &WhereIt)
Move this instruction to WhereIt.
bool hasAllowContract() const
Determine whether the allow-contract flag is set.
void setIsExact(bool B=true)
Set or clear the exact flag on this instruction, which must be an operator which supports this flag.
bool hasApproxFunc() const
Determine whether the approximate-math-functions flag is set.
bool hasNoSignedWrap() const
Determine whether the no signed wrap flag is set.
void 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.
BBIterator getIterator() const
\Returns a BasicBlock::iterator for this Instruction.
void setFast(bool B)
Set or clear all fast-math-flags on this instruction, which must be an operator which supports this f...
void setHasApproxFunc(bool B)
Set or clear the approximate-math-functions flag on this instruction, which must be an operator which...
void setHasNoNaNs(bool B)
Set or clear the no-nans flag on this instruction, which must be an operator which supports this flag...
void copyFastMathFlags(FastMathFlags FMF)
Convenience function for transferring all fast-math flag values to this instruction,...
bool isFuncletPad() const
bool hasAtomicStore() const
void setHasNoSignedZeros(bool B)
Set or clear the no-signed-zeros flag on this instruction, which must be an operator which supports t...
void insertInto(BasicBlock *BB, const BBIterator &WhereIt)
Insert this detached instruction into BB at WhereIt.
bool mayThrow(bool IncludePhaseOneUnwind=false) const
llvm::Instruction * getTopmostLLVMInstruction() const
A SandboxIR Instruction may map to multiple LLVM IR Instruction.
bool isIdempotent() const
bool hasMetadata() const
Return true if the instruction has any metadata attached to it.
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
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)
FastMathFlags getFastMathFlags() const
Convenience function for getting all the fast-math flags, which must be an operator which supports th...
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...
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.
void removeFromParent()
Detach this from its parent BasicBlock without deleting it.
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.
bool hasAllowReciprocal() const
Determine whether the allow-reciprocal flag is set.
void insertBefore(Instruction *BeforeI)
Insert this detached instruction before BeforeI.
void eraseFromParent()
Detach this Value from its parent and delete it.
void setHasAllowReciprocal(bool B)
Set or clear the allow-reciprocal flag on this instruction, which must be an operator which supports ...
void setHasNoInfs(bool B)
Set or clear the no-infs flag on this instruction, which must be an operator which supports this flag...
BasicBlock * getParent() const
\Returns the BasicBlock containing this Instruction, or null if it is detached.
static bool classof(const sandboxir::Value *From)
For isa/dyn_cast.
bool isTerminator() const
BasicBlock * getUnwindDest() const
static InvokeInst * create(FunctionType *FTy, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, InsertPosition Pos, Context &Ctx, const Twine &NameStr="")
void setNormalDest(BasicBlock *BB)
unsigned getNumSuccessors() const
void setUnwindDest(BasicBlock *BB)
BasicBlock * getSuccessor(unsigned SuccIdx) const
static bool classof(const Value *From)
BasicBlock * getNormalDest() const
void setSuccessor(unsigned SuccIdx, BasicBlock *NewSucc)
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.
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.
Constant * getClause(unsigned Idx) const
Get the value of the clause at index Idx.
static bool classof(const Value *From)
static LandingPadInst * create(Type *RetTy, unsigned NumReservedClauses, InsertPosition Pos, Context &Ctx, const Twine &Name="")
static 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="")
void setVolatile(bool V)
Specify whether this is a volatile load or not.
Value * getPointerOperand() const
bool isVolatile() const
Return true if this is a load from a volatile memory location.
static bool classof(const Value *From)
For isa/dyn_cast.
An LLLVM Instruction that has no SandboxIR equivalent class gets mapped to an OpaqueInstr.
static bool classof(const sandboxir::Value *From)
Iterator for the Use edges of a User's operands.
Value * hasConstantValue() const
iterator_range< const_block_iterator > blocks() const
int getBasicBlockIndex(const BasicBlock *BB) const
const_block_iterator block_end() const
const_op_range incoming_values() const
bool hasConstantOrUndefValue() const
unsigned getNumIncomingValues() const
Value * getIncomingValue(unsigned Idx) const
void setIncomingBlock(unsigned Idx, BasicBlock *BB)
void removeIncomingValueIf(function_ref< bool(unsigned)> Predicate)
static bool classof(const Value *From)
For isa/dyn_cast.
const_block_iterator block_begin() const
static PHINode * create(Type *Ty, unsigned NumReservedValues, InsertPosition Pos, Context &Ctx, const Twine &Name="")
Value * removeIncomingValue(unsigned Idx)
mapped_iterator< llvm::PHINode::const_block_iterator, LLVMBBToBB > const_block_iterator
void setIncomingValue(unsigned Idx, Value *V)
BasicBlock * getIncomingBlock(unsigned Idx) const
op_range incoming_values()
static unsigned getIncomingValueNumForOperand(unsigned Idx)
void replaceIncomingBlockWith(const BasicBlock *Old, BasicBlock *New)
Value * getIncomingValueForBlock(const BasicBlock *BB) const
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.
void setIsDisjoint(bool B)
Instruction that can have a nneg flag (zext/uitofp).
static bool classof(const Value *From)
For isa/dyn_cast.
static ResumeInst * create(Value *Exn, InsertPosition Pos, Context &Ctx)
unsigned getNumSuccessors() const
static bool classof(const Value *From)
static ReturnInst * create(Value *RetVal, InsertPosition Pos, Context &Ctx)
static bool classof(const Value *From)
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 bool classof(const Value *From)
For isa/dyn_cast.
const Value * getFalseValue() const
const Value * getTrueValue() const
void setTrueValue(Value *New)
static 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.
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)
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)
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 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 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)
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)
Instructions that contain a single LLVM Instruction can inherit from this.
void dumpOS(raw_ostream &OS) const override
void verify() const final
Should crash if there is something wrong with the instruction.
friend class FuncletPadInst
unsigned getUseOperandNo(const Use &Use) const final
\Returns the operand index of Use.
unsigned getNumOfIRInstrs() const final
This is used by BasicBlock::iterator.
void setVolatile(bool V)
Specify whether this is a volatile store or not.
static bool classof(const Value *From)
For isa/dyn_cast.
static StoreInst * create(Value *V, Value *Ptr, MaybeAlign Align, InsertPosition Pos, Context &Ctx)
static StoreInst * create(Value *V, Value *Ptr, MaybeAlign Align, InsertPosition Pos, bool IsVolatile, Context &Ctx)
Value * getPointerOperand() const
bool isVolatile() const
Return true if this is a store from a volatile memory location.
Value * getValueOperand() const
CaseIt findCaseValue(const ConstantInt *C)
iterator_range< ConstCaseIt > cases() const
static SwitchInst * create(Value *V, BasicBlock *Dest, unsigned NumCases, InsertPosition Pos, Context &Ctx, const Twine &Name="")
bool defaultDestUndefined() const
void addCase(ConstantInt *OnVal, BasicBlock *Dest)
BasicBlock * getSuccessor(unsigned Idx) const
CaseIt case_begin()
Returns a read/write iterator that points to the first case in the SwitchInst.
void setDefaultDest(BasicBlock *DefaultCase)
iterator_range< CaseIt > cases()
Iteration adapter for range-for loops.
llvm::SwitchInst::CaseIteratorImpl< CaseHandle > CaseIt
ConstCaseIt case_begin() const
BasicBlock * getDefaultDest() const
ConstCaseIt case_end() const
llvm::SwitchInst::CaseIteratorImpl< ConstCaseHandle > ConstCaseIt
ConstCaseIt case_default() const
static bool classof(const Value *From)
Value * getCondition() const
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.
void setCondition(Value *V)
ConstCaseIt findCaseValue(const ConstantInt *C) const
ConstantInt * findCaseDest(BasicBlock *BB)
static constexpr const unsigned DefaultPseudoIndex
CaseIt removeCase(CaseIt It)
This method removes the specified case and its successor from the switch instruction.
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.
An abstract class, parent of unary instructions.
static bool classof(const Instruction *I)
UnaryInstruction(ClassID ID, Opcode Opc, llvm::Instruction *LLVMI, Context &Ctx)
static bool classof(const Value *V)
static bool classof(const Value *From)
For isa/dyn_cast.
static Value * createWithCopiedFlags(Instruction::Opcode Op, Value *OpV, Value *CopyFrom, InsertPosition Pos, Context &Ctx, const Twine &Name="")
static Value * create(Instruction::Opcode Op, Value *OpV, InsertPosition Pos, Context &Ctx, const Twine &Name="")
static 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 bool classof(const Value *From)
Represents a Def-use/Use-def edge in SandboxIR.
A sandboxir::User has operands.
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...
virtual void setOperand(unsigned OperandIdx, Value *Operand)
Use getOperandUseDefault(unsigned OpIdx, bool Verify) const
\Returns the Use edge that corresponds to OpIdx.
void swapOperandsInternal(unsigned OpIdxA, unsigned OpIdxB)
virtual unsigned getNumOperands() const
Use getOperandUse(unsigned OpIdx) const
\Returns the operand edge for OpIdx.
virtual op_iterator op_end()
Value * getPointerOperand()
static 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.
void dumpCommonSuffix(raw_ostream &OS) const
Context & Ctx
All values point to the context.
ClassID SubclassID
For isa/dyn_cast.
void dumpCommonPrefix(raw_ostream &OS) const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
@ BasicBlock
Various leaf nodes.
@ System
Synchronized with respect to all concurrently executing threads.
static bool isOrdered(Instruction *I)
static SmallVector< Value *, 4 > getOperand(ArrayRef< Value * > Bndl, unsigned OpIdx)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
mapped_iterator< ItTy, FuncTy > map_iterator(ItTy I, FuncTy F)
AtomicOrdering
Atomic ordering for LLVM's memory model.
DWARFExpression::Operation Op
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
This struct is a compact representation of a valid (non-zero power of two) alignment.
The const version of succ_op_iterator.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.