92#ifndef LLVM_SANDBOXIR_SANDBOXIR_H
93#define LLVM_SANDBOXIR_SANDBOXIR_H
152#define DEF_INSTR(ID, OPC, CLASS) friend class CLASS;
153#include "llvm/SandboxIR/SandboxIRValues.def"
174 return !(*
this ==
Other);
203 return !(*
this ==
Other);
212#define DEF_VALUE(ID, CLASS) ID,
213#define DEF_USER(ID, CLASS) ID,
214#define DEF_INSTR(ID, OPC, CLASS) ID,
215#include "llvm/SandboxIR/SandboxIRValues.def"
221#define DEF_VALUE(ID, CLASS) \
224#define DEF_USER(ID, CLASS) \
227#define DEF_INSTR(ID, OPC, CLASS) \
230#include "llvm/SandboxIR/SandboxIRValues.def"
376 std::string
getUid()
const;
399 return From->getSubclassID() == ClassID::Argument;
403 assert(isa<llvm::Argument>(
Val) &&
"Expected Argument!");
429 return Use.LLVMUse->getOperandNo();
456 assert(isa<llvm::User>(
Val) &&
"Expect User value!");
460 assert(isa<llvm::User>(
Val) &&
"Expect User value!");
482 return isa<llvm::User>(
Val) ? cast<llvm::User>(
Val)->getNumOperands() : 0;
492 assert(isa<llvm::User>(
Val) &&
"Expected User!");
509 Use getOperandUseInternal(
unsigned OpIdx,
bool Verify)
const override {
516 return From->getSubclassID() == ClassID::Constant ||
517 From->getSubclassID() == ClassID::ConstantInt ||
518 From->getSubclassID() == ClassID::Function;
526 assert(isa<llvm::Constant>(
Val) &&
"Expected Constant!");
537 Use getOperandUseInternal(
unsigned OpIdx,
bool Verify)
const final {
545 bool IsSigned =
false);
551 return From->getSubclassID() == ClassID::ConstantInt;
558 assert(isa<llvm::ConstantInt>(
Val) &&
"Expected a ConstantInst!");
586 : BB(BB), It(It), Ctx(Ctx) {}
601 assert(Ctx ==
Other.Ctx &&
"BBIterators in different context!");
602 return It ==
Other.It;
620 buildBasicBlockFromLLVMIR(BB);
627 return From->getSubclassID() == Value::ClassID::Block;
633 auto *BB = cast<llvm::BasicBlock>(
Val);
636 std::reverse_iterator<iterator>
rbegin()
const {
637 return std::make_reverse_iterator(
end());
639 std::reverse_iterator<iterator>
rend()
const {
640 return std::make_reverse_iterator(
begin());
650 assert(isa<llvm::BasicBlock>(
Val) &&
"Expected BasicBlock!");
662#define OPCODES(...) __VA_ARGS__
663#define DEF_INSTR(ID, OPC, CLASS) OPC
664#include "llvm/SandboxIR/SandboxIRValues.def"
750 return cast<llvm::Instruction>(
Val)->hasNoUnsignedWrap();
757 return cast<llvm::Instruction>(
Val)->hasNoSignedWrap();
763 bool isFast()
const {
return cast<llvm::Instruction>(
Val)->isFast(); }
770 return cast<llvm::Instruction>(
Val)->hasAllowReassoc();
777 bool isExact()
const {
return cast<llvm::Instruction>(
Val)->isExact(); }
782 bool hasNoNaNs()
const {
return cast<llvm::Instruction>(
Val)->hasNoNaNs(); }
788 bool hasNoInfs()
const {
return cast<llvm::Instruction>(
Val)->hasNoInfs(); }
795 return cast<llvm::Instruction>(
Val)->hasNoSignedZeros();
803 return cast<llvm::Instruction>(
Val)->hasAllowReciprocal();
811 return cast<llvm::Instruction>(
Val)->hasAllowContract();
819 return cast<llvm::Instruction>(
Val)->hasApproxFunc();
829 return cast<llvm::Instruction>(
Val)->getFastMathFlags();
852#define DEF_INSTR(ID, OPC, CLASS) friend class CLASS;
853#include "llvm/SandboxIR/SandboxIRValues.def"
858 Use getOperandUseInternal(
unsigned OpIdx,
bool Verify)
const final {
862 return {cast<llvm::Instruction>(
Val)};
924 return From->getSubclassID() == ClassID::InsertElement;
938 Opcode::ExtractElement,
I,
Ctx) {}
948 return From->getSubclassID() == ClassID::ExtractElement;
986 return From->getSubclassID() == ClassID::ShuffleVector;
991 void commute() { cast<llvm::ShuffleVectorInst>(
Val)->commute(); }
1007 return cast<llvm::ShuffleVectorInst>(
Val)->getType();
1013 return cast<llvm::ShuffleVectorInst>(
Val)->getMaskValue(Elt);
1027 cast<llvm::ShuffleVectorInst>(
Val)->getShuffleMask(Result);
1039 return cast<llvm::ShuffleVectorInst>(
Val)->getShuffleMask();
1047 return cast<llvm::ShuffleVectorInst>(
Val)->changesLength();
1054 return cast<llvm::ShuffleVectorInst>(
Val)->increasesLength();
1067 cast<llvm::Constant>(Mask->Val), NumSrcElts);
1074 return cast<llvm::ShuffleVectorInst>(
Val)->isSingleSource();
1087 cast<llvm::Constant>(Mask->Val), NumSrcElts);
1095 return cast<llvm::ShuffleVectorInst>(
Val)->isIdentity();
1101 return cast<llvm::ShuffleVectorInst>(
Val)->isIdentityWithPadding();
1107 return cast<llvm::ShuffleVectorInst>(
Val)->isIdentityWithExtract();
1114 return cast<llvm::ShuffleVectorInst>(
Val)->isConcat();
1130 cast<llvm::Constant>(Mask->Val), NumSrcElts);
1141 return cast<llvm::ShuffleVectorInst>(
Val)->isSelect();
1154 cast<llvm::Constant>(Mask->Val), NumSrcElts);
1161 return cast<llvm::ShuffleVectorInst>(
Val)->isReverse();
1174 cast<llvm::Constant>(Mask->Val), NumSrcElts);
1182 return cast<llvm::ShuffleVectorInst>(
Val)->isZeroEltSplat();
1222 cast<llvm::Constant>(Mask->Val), NumSrcElts);
1231 return cast<llvm::ShuffleVectorInst>(
Val)->isTranspose();
1245 cast<llvm::Constant>(Mask->Val), NumSrcElts,
Index);
1253 return cast<llvm::ShuffleVectorInst>(
Val)->isSplice(
Index);
1267 cast<llvm::Constant>(Mask->Val), NumSrcElts,
Index);
1272 return cast<llvm::ShuffleVectorInst>(
Val)->isExtractSubvectorMask(
Index);
1280 int &NumSubElts,
int &
Index) {
1285 int &NumSubElts,
int &
Index) {
1287 cast<llvm::Constant>(Mask->Val), NumSrcElts, NumSubElts,
Index);
1292 return cast<llvm::ShuffleVectorInst>(
Val)->isInsertSubvectorMask(NumSubElts,
1308 cast<llvm::Constant>(Mask->Val), ReplicationFactor, VF);
1313 return cast<llvm::ShuffleVectorInst>(
Val)->isReplicationMask(
1314 ReplicationFactor, VF);
1333 return cast<llvm::ShuffleVectorInst>(
Val)->isOneUseSingleSourceMask(VF);
1339 unsigned InVecNumElts) {
1345 return cast<llvm::ShuffleVectorInst>(
Val)->isInterleave(Factor);
1368 unsigned NumInputElts,
1374 unsigned NumInputElts) {
1403 unsigned MinSubElts,
unsigned MaxSubElts,
1404 unsigned &NumSubElts,
unsigned &RotateAmt) {
1406 Mask, EltSizeInBits, MinSubElts, MaxSubElts, NumSubElts, RotateAmt);
1429 return cast<llvm::BranchInst>(
Val)->isUnconditional();
1432 return cast<llvm::BranchInst>(
Val)->isConditional();
1442 struct LLVMBBToSBBB {
1444 LLVMBBToSBBB(
Context &Ctx) : Ctx(Ctx) {}
1448 struct ConstLLVMBBToSBBB {
1450 ConstLLVMBBToSBBB(Context &Ctx) : Ctx(Ctx) {}
1459 cast<llvm::BranchInst>(
Val)->successors();
1460 LLVMBBToSBBB BBMap(
Ctx);
1473 ConstLLVMBBToSBBB ConstBBMap(
Ctx);
1478 return make_range(ConstMappedBegin, ConstMappedEnd);
1492 return isa<LoadInst>(
I) || isa<CastInst>(
I);
1495 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
1529 bool isSimple()
const {
return cast<llvm::LoadInst>(
Val)->isSimple(); }
1559 bool isSimple()
const {
return cast<llvm::StoreInst>(
Val)->isSimple(); }
1568 Use getOperandUseInternal(
unsigned OpIdx,
bool Verify)
const final {
1572 return {cast<llvm::Instruction>(
Val)};
1602 return From->getSubclassID() == ClassID::Ret;
1617 auto Opc =
From->getSubclassID();
1618 return Opc == Instruction::ClassID::Call ||
1619 Opc == Instruction::ClassID::Invoke ||
1620 Opc == Instruction::ClassID::CallBr;
1624 return cast<llvm::CallBase>(
Val)->getFunctionType();
1632 auto *LLVMCB = cast<llvm::CallBase>(
Val);
1633 auto Dist = LLVMCB->data_operands_end() - LLVMCB->data_operands_begin();
1637 auto *LLVMCB = cast<llvm::CallBase>(
Val);
1638 auto Dist = LLVMCB->data_operands_end() - LLVMCB->data_operands_begin();
1654 assert(
this == U.getUser() &&
1655 "Only valid to query with a use of this instruction!");
1656 return cast<llvm::CallBase>(
Val)->isDataOperand(U.LLVMUse);
1660 return cast<llvm::CallBase>(
Val)->getDataOperandNo(U.LLVMUse);
1666 return cast<llvm::CallBase>(
Val)->getNumTotalBundleOperands();
1705 return cast<llvm::CallBase>(
Val)->isArgOperand(U.LLVMUse);
1708 return cast<llvm::CallBase>(
Val)->getArgOperandNo(U.LLVMUse);
1717 return cast<llvm::CallBase>(
Val)->isIndirectCall();
1720 return cast<llvm::CallBase>(
Val)->isCallee(U.LLVMUse);
1727 return cast<llvm::CallBase>(
Val)->isMustTailCall();
1731 return cast<llvm::CallBase>(
Val)->getIntrinsicID();
1736 return cast<llvm::CallBase>(
Val)->getCallingConv();
1753 const Twine &NameStr =
"");
1762 return From->getSubclassID() == ClassID::Call;
1779 const Twine &NameStr =
"");
1790 return From->getSubclassID() == ClassID::Invoke;
1800 assert(SuccIdx < 2 &&
"Successor # out of range for invoke!");
1807 return cast<llvm::InvokeInst>(
Val)->getNumSuccessors();
1825 const Twine &NameStr =
"");
1837 return From->getSubclassID() == ClassID::CallBr;
1840 return cast<llvm::CallBrInst>(
Val)->getNumIndirectDests();
1851 return cast<llvm::CallBrInst>(
Val)->getNumSuccessors();
1865 return cast<llvm::FuncletPadInst>(
Val)->arg_size();
1880 return From->getSubclassID() == ClassID::CatchPad ||
1881 From->getSubclassID() == ClassID::CleanupPad;
1899 return From->getSubclassID() == ClassID::CatchPad;
1913 return From->getSubclassID() == ClassID::CleanupPad;
1932 const Twine &NameStr =
"");
1935 const Twine &NameStr =
"");
1938 const Twine &NameStr =
"");
1941 return From->getSubclassID() == ClassID::GetElementPtr;
1945 return cast<llvm::GetElementPtrInst>(
Val)->getSourceElementType();
1948 return cast<llvm::GetElementPtrInst>(
Val)->getResultElementType();
1951 return cast<llvm::GetElementPtrInst>(
Val)->getAddressSpace();
1974 return cast<llvm::GetElementPtrInst>(
Val)->getPointerOperandType();
1977 return cast<llvm::GetElementPtrInst>(
Val)->getPointerAddressSpace();
1980 return cast<llvm::GetElementPtrInst>(
Val)->getNumIndices();
1983 return cast<llvm::GetElementPtrInst>(
Val)->hasIndices();
1986 return cast<llvm::GetElementPtrInst>(
Val)->hasAllConstantIndices();
1989 return cast<llvm::GetElementPtrInst>(
Val)->getNoWrapFlags();
1992 return cast<llvm::GetElementPtrInst>(
Val)->isInBounds();
1995 return cast<llvm::GetElementPtrInst>(
Val)->hasNoUnsignedSignedWrap();
1998 return cast<llvm::GetElementPtrInst>(
Val)->hasNoUnsignedWrap();
2001 return cast<llvm::GetElementPtrInst>(
Val)->accumulateConstantOffset(
DL,
2023 return cast<llvm::CatchSwitchInst>(
Val)->hasUnwindDest();
2026 return cast<llvm::CatchSwitchInst>(
Val)->unwindsToCaller();
2032 return cast<llvm::CatchSwitchInst>(
Val)->getNumHandlers();
2036 static BasicBlock *handler_helper(
Value *V) {
return cast<BasicBlock>(V); }
2038 return cast<BasicBlock>(V);
2084 "Successor # out of range for catchswitch!");
2089 "Successor # out of range for catchswitch!");
2094 return From->getSubclassID() == ClassID::CatchSwitch;
2114 return cast<llvm::SwitchInst>(
Val)->defaultDestUndefined();
2118 return cast<llvm::SwitchInst>(
Val)->getNumCases();
2174 return cast<llvm::SwitchInst>(
Val)->getNumSuccessors();
2179 return From->getSubclassID() == ClassID::Switch;
2186 case llvm::Instruction::FNeg:
2187 return Opcode::FNeg;
2188 case llvm::Instruction::UnaryOpsEnd:
2220 return From->getSubclassID() == ClassID::UnOp;
2227 case llvm::Instruction::Add:
2229 case llvm::Instruction::FAdd:
2230 return Opcode::FAdd;
2231 case llvm::Instruction::Sub:
2233 case llvm::Instruction::FSub:
2234 return Opcode::FSub;
2235 case llvm::Instruction::Mul:
2237 case llvm::Instruction::FMul:
2238 return Opcode::FMul;
2239 case llvm::Instruction::UDiv:
2240 return Opcode::UDiv;
2241 case llvm::Instruction::SDiv:
2242 return Opcode::SDiv;
2243 case llvm::Instruction::FDiv:
2244 return Opcode::FDiv;
2245 case llvm::Instruction::URem:
2246 return Opcode::URem;
2247 case llvm::Instruction::SRem:
2248 return Opcode::SRem;
2249 case llvm::Instruction::FRem:
2250 return Opcode::FRem;
2251 case llvm::Instruction::Shl:
2253 case llvm::Instruction::LShr:
2254 return Opcode::LShr;
2255 case llvm::Instruction::AShr:
2256 return Opcode::AShr;
2257 case llvm::Instruction::And:
2259 case llvm::Instruction::Or:
2261 case llvm::Instruction::Xor:
2263 case llvm::Instruction::BinaryOpsEnd:
2270 getBinOpOpcode(BinOp->getOpcode()), BinOp,
2299 return From->getSubclassID() == ClassID::BinaryOperator;
2307 Instruction::Opcode::AtomicRMW, Atomic,
Ctx) {
2314 return cast<llvm::AtomicRMWInst>(
Val)->getOperation();
2323 cast<llvm::AtomicRMWInst>(
Val)->setOperation(
Op);
2328 return cast<llvm::AtomicRMWInst>(
Val)->isVolatile();
2332 return cast<llvm::AtomicRMWInst>(
Val)->getOrdering();
2336 return cast<llvm::AtomicRMWInst>(
Val)->getSyncScopeID();
2348 return cast<llvm::AtomicRMWInst>(
Val)->getPointerAddressSpace();
2351 return cast<llvm::AtomicRMWInst>(
Val)->isFloatingPointOperation();
2354 return From->getSubclassID() == ClassID::AtomicRMW;
2379 Instruction::Opcode::AtomicCmpXchg, Atomic,
2387 return cast<llvm::AtomicCmpXchgInst>(
Val)->getAlign();
2394 return cast<llvm::AtomicCmpXchgInst>(
Val)->isVolatile();
2399 bool isWeak()
const {
return cast<llvm::AtomicCmpXchgInst>(
Val)->isWeak(); }
2408 return cast<llvm::AtomicCmpXchgInst>(
Val)->getSuccessOrdering();
2413 return cast<llvm::AtomicCmpXchgInst>(
Val)->getFailureOrdering();
2417 return cast<llvm::AtomicCmpXchgInst>(
Val)->getMergedOrdering();
2420 return cast<llvm::AtomicCmpXchgInst>(
Val)->getSyncScopeID();
2440 return cast<llvm::AtomicCmpXchgInst>(
Val)->getPointerAddressSpace();
2480 return cast<llvm::AllocaInst>(
Val)->isArrayAllocation();
2490 return cast<llvm::AllocaInst>(
Val)->getType();
2494 return cast<llvm::AllocaInst>(
Val)->getAddressSpace();
2499 return cast<llvm::AllocaInst>(
Val)->getAllocationSize(
DL);
2504 return cast<llvm::AllocaInst>(
Val)->getAllocationSizeInBits(
DL);
2508 return cast<llvm::AllocaInst>(
Val)->getAllocatedType();
2521 return cast<llvm::AllocaInst>(
Val)->isStaticAlloca();
2526 return cast<llvm::AllocaInst>(
Val)->isUsedWithInAlloca();
2532 if (
auto *
I = dyn_cast<Instruction>(
From))
2533 return I->getSubclassID() == Instruction::ClassID::Alloca;
2541 case llvm::Instruction::ZExt:
2542 return Opcode::ZExt;
2543 case llvm::Instruction::SExt:
2544 return Opcode::SExt;
2545 case llvm::Instruction::FPToUI:
2546 return Opcode::FPToUI;
2547 case llvm::Instruction::FPToSI:
2548 return Opcode::FPToSI;
2549 case llvm::Instruction::FPExt:
2550 return Opcode::FPExt;
2551 case llvm::Instruction::PtrToInt:
2552 return Opcode::PtrToInt;
2553 case llvm::Instruction::IntToPtr:
2554 return Opcode::IntToPtr;
2555 case llvm::Instruction::SIToFP:
2556 return Opcode::SIToFP;
2557 case llvm::Instruction::UIToFP:
2558 return Opcode::UIToFP;
2559 case llvm::Instruction::Trunc:
2560 return Opcode::Trunc;
2561 case llvm::Instruction::FPTrunc:
2562 return Opcode::FPTrunc;
2563 case llvm::Instruction::BitCast:
2564 return Opcode::BitCast;
2565 case llvm::Instruction::AddrSpaceCast:
2566 return Opcode::AddrSpaceCast;
2567 case llvm::Instruction::CastOpsEnd:
2614 if (
auto *
I = dyn_cast<Instruction>(
From))
2615 return I->getOpcode() ==
Op;
2635 :
public CastInstImpl<Instruction::Opcode::AddrSpaceCast> {
2663 LLVMBBToBB(
Context &Ctx) : Ctx(Ctx) {}
2678 LLVMBBToBB BBGetter(
Ctx);
2683 LLVMBBToBB BBGetter(
Ctx);
2696 return cast<llvm::PHINode>(
Val)->getNumIncomingValues();
2722 return cast<llvm::PHINode>(
Val)->hasConstantOrUndefValue();
2743 return From->getSubclassID() == ClassID::Opaque;
2772 auto It = Pair.first;
2774 It->second = std::unique_ptr<Argument>(
new Argument(LLVMArg, *
this));
2775 return cast<Argument>(It->second.get());
2777 return cast<Argument>(It->second.get());
2876 LLVMBBToBB(
Context &Ctx) : Ctx(Ctx) {}
2878 return *cast<BasicBlock>(Ctx.
getValue(&LLVMBB));
2889 return From->getSubclassID() == ClassID::Function;
2897 size_t arg_size()
const {
return cast<llvm::Function>(
Val)->arg_size(); }
2902 LLVMBBToBB BBGetter(
Ctx);
2906 LLVMBBToBB BBGetter(
Ctx);
2910 return cast<llvm::Function>(
Val)->getFunctionType();
2915 assert(isa<llvm::Function>(
Val) &&
"Expected Function!");
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
BlockVerifier::State From
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
ppc ctr loops PowerPC CTR Loops Verify
StandardInstrumentations SI(Mod->getContext(), Debug, VerifyEach)
const SmallVectorImpl< MachineOperand > & Cond
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Class for arbitrary precision integers.
an instruction to allocate memory on the stack
This class represents an incoming formal argument to a Function.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
An instruction that atomically checks whether a specified value is in a memory location,...
static bool isValidFailureOrdering(AtomicOrdering Ordering)
static bool isValidSuccessOrdering(AtomicOrdering Ordering)
an instruction that atomically reads a memory location, combines it with another value,...
static bool isFPOperation(BinOp Op)
BinOp
This enumeration lists the possible modifications atomicrmw can make.
static StringRef getOperationName(BinOp Op)
LLVM Basic Block Representation.
InstListType::iterator iterator
Instruction iterators...
Conditional or Unconditional Branch instruction.
CallBr instruction, tracking function calls that may not return control but instead transfer it to a ...
This class represents a function call, abstracting a target machine's calling convention.
This is the base class for all instructions that perform data casts.
Instruction::CastOps getOpcode() const
Return the opcode of this CastInst.
ConstantFolder - Create constants with minimum, target independent, folding.
This is the shared class of boolean and integer constants.
This is an important base class in LLVM.
This class represents an Operation in the Expression.
A parsed version of the target data layout string in and methods for querying it.
Convenience struct for specifying and reasoning about fast-math flags.
Class to represent function types.
Represents flags for the getelementptr instruction/expression.
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
static unsigned getPointerOperandIndex()
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
This instruction inserts a single (scalar) element into a VectorType value.
static bool isValidOperands(const Value *Vec, const Value *NewElt, const Value *Idx)
Return true if an insertelement instruction can be formed with the specified operands.
This is an important class for using LLVM in a threaded context.
An instruction for reading from memory.
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)
Class to represent pointers.
Return a value (possibly void), from a function.
This class represents the LLVM 'select' instruction.
This instruction constructs a fixed permutation of two input vectors.
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...
The instances of the Type class are immutable: once they are created, they are never changed.
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
UnaryOps getOpcode() const
This function has undefined behavior.
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
StringRef getName() const
Return a constant reference to the value's name.
Base class of all SIMD vector types.
An efficient, type-erasing, non-owning reference to a callable.
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
unsigned getSrcAddressSpace() const
\Returns the address space of the pointer operand.
Value * getPointerOperand()
\Returns the pointer operand.
unsigned getDestAddressSpace() const
\Returns the address space of the result.
const Value * getPointerOperand() const
\Returns the pointer operand.
static unsigned getPointerOperandIndex()
\Returns the operand index of the pointer operand.
bool isUsedWithInAlloca() const
Return true if this alloca is used as an inalloca argument to a call.
Value * getArraySize()
Get the number of elements allocated.
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
bool isStaticAlloca() const
Return true if this alloca is in the entry block of the function and is a constant size.
bool isArrayAllocation() const
Return true if there is an allocation size parameter to the allocation instruction that is not 1.
std::optional< TypeSize > getAllocationSizeInBits(const DataLayout &DL) const
Get allocation size in bits.
void setAlignment(Align Align)
unsigned getAddressSpace() const
Return the address space for the allocation.
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
PointerType * getType() const
Overload to return most specific pointer type.
void setUsedWithInAlloca(bool V)
Specify whether this alloca is used to represent the arguments to a call.
static AllocaInst * create(Type *Ty, unsigned AddrSpace, BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx, Value *ArraySize=nullptr, const Twine &Name="")
static bool classof(const Value *From)
std::optional< TypeSize > getAllocationSize(const DataLayout &DL) const
Get allocation size in bytes.
const Value * getArraySize() const
void setAllocatedType(Type *Ty)
for use only in special circumstances that need to generically transform a whole instruction (eg: IR ...
Argument of a sandboxir::Function.
void dumpOS(raw_ostream &OS) const final
void printAsOperand(raw_ostream &OS) const
void verify() const final
Should crash if there is something wrong with the instruction.
static bool classof(const sandboxir::Value *From)
void setSyncScopeID(SyncScope::ID SSID)
void setVolatile(bool V)
Specify whether this is a volatile cmpxchg.
Value * getCompareOperand()
void setAlignment(Align Align)
Value * getPointerOperand()
const Value * getNewValOperand() const
void setSuccessOrdering(AtomicOrdering Ordering)
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
AtomicOrdering getMergedOrdering() const
Value * getNewValOperand()
const Value * getCompareOperand() const
static AtomicCmpXchgInst * create(Value *Ptr, Value *Cmp, Value *New, MaybeAlign Align, AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering, BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx, SyncScope::ID SSID=SyncScope::System, const Twine &Name="")
const Value * getPointerOperand() const
AtomicOrdering getFailureOrdering() const
static bool isValidFailureOrdering(AtomicOrdering Ordering)
void setWeak(bool IsWeak)
bool isVolatile() const
Return true if this is a cmpxchg from a volatile memory location.
static bool isValidSuccessOrdering(AtomicOrdering Ordering)
AtomicOrdering getSuccessOrdering() const
void setFailureOrdering(AtomicOrdering Ordering)
SyncScope::ID getSyncScopeID() const
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
bool isWeak() const
Return true if this cmpxchg may spuriously fail.
Value * getPointerOperand()
static AtomicRMWInst * create(BinOp Op, Value *Ptr, Value *Val, MaybeAlign Align, AtomicOrdering Ordering, BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx, SyncScope::ID SSID=SyncScope::System, const Twine &Name="")
BinOp getOperation() const
const Value * getPointerOperand() const
unsigned getPointerAddressSpace() const
llvm::AtomicRMWInst::BinOp BinOp
SyncScope::ID getSyncScopeID() const
void setAlignment(Align Align)
const Value * getValOperand() const
void setSyncScopeID(SyncScope::ID SSID)
static StringRef getOperationName(BinOp Op)
void setOrdering(AtomicOrdering Ordering)
AtomicOrdering getOrdering() const
void setOperation(BinOp Op)
static bool classof(const Value *From)
bool isFloatingPointOperation() const
static bool isFPOperation(BinOp Op)
Iterator for Instructions in a `BasicBlock.
BBIterator & operator++()
BBIterator operator++(int)
bool operator!=(const BBIterator &Other) const
BBIterator operator--(int)
pointer get() const
\Returns the SBInstruction that corresponds to this iterator, or null if the instruction is not found...
reference operator*() const
BBIterator & operator--()
std::bidirectional_iterator_tag iterator_category
std::ptrdiff_t difference_type
BBIterator(llvm::BasicBlock *BB, llvm::BasicBlock::iterator It, Context *Ctx)
bool operator==(const BBIterator &Other) const
Contains a list of sandboxir::Instruction's.
void dumpOS(raw_ostream &OS) const final
std::reverse_iterator< iterator > rbegin() const
static bool classof(const Value *From)
For isa/dyn_cast.
void verify() const final
Should crash if there is something wrong with the instruction.
std::reverse_iterator< iterator > rend() const
Function * getParent() const
Instruction & front() const
Instruction * getTerminator() const
Context & getContext() const
Instruction & back() const
static Value * create(Instruction::Opcode Op, Value *LHS, Value *RHS, BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx, const Twine &Name="")
static bool classof(const Value *From)
For isa/dyn_cast.
static Value * createWithCopiedFlags(Instruction::Opcode Op, Value *LHS, Value *RHS, Value *CopyFrom, BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx, const Twine &Name="")
unsigned getNumSuccessors() const
iterator_range< sb_succ_op_iterator > successors()
iterator_range< const_sb_succ_op_iterator > successors() const
static bool classof(const Value *From)
For isa/dyn_cast.
void setCondition(Value *V)
bool isConditional() const
void setSuccessor(unsigned Idx, BasicBlock *NewSucc)
bool isUnconditional() const
BasicBlock * getSuccessor(unsigned SuccIdx) const
static BranchInst * create(BasicBlock *IfTrue, Instruction *InsertBefore, Context &Ctx)
Value * getCondition() const
iterator_range< const_op_iterator > args() const
CallingConv::ID getCallingConv() const
bool isMustTailCall() const
const Function * getCaller() const
FunctionType * getFunctionType() const
void setCalledFunction(Function *F)
const_op_iterator arg_end() const
iterator_range< op_iterator > args()
static bool classof(const Value *From)
Value * getArgOperand(unsigned OpIdx) const
Function * getCalledFunction() const
Use getArgOperandUse(unsigned Idx)
bool isDataOperand(Use U) const
unsigned getArgOperandNo(Use U) const
const_op_iterator data_operands_end() const
op_iterator data_operands_end()
unsigned getDataOperandNo(Use U) const
unsigned getNumTotalBundleOperands() const
Return the total number operands (not operand bundles) used by every operand bundle in this OperandBu...
iterator_range< op_iterator > data_ops()
const_op_iterator data_operands_begin() const
bool data_operands_empty() const
bool hasArgument(const Value *V) const
void setCalledOperand(Value *V)
unsigned arg_size() const
unsigned data_operands_size() const
const_op_iterator arg_begin() const
Intrinsic::ID getIntrinsicID() const
Use getArgOperandUse(unsigned Idx) const
Value * getCalledOperand() const
op_iterator data_operands_begin()
bool isArgOperand(Use U) const
void setArgOperand(unsigned OpIdx, Value *NewOp)
iterator_range< const_op_iterator > data_ops() const
Use getCalledOperandUse() const
bool isCallee(Use U) const
bool isIndirectCall() const
static CallBrInst * create(FunctionType *FTy, Value *Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx, const Twine &NameStr="")
BasicBlock * getIndirectDest(unsigned Idx) const
static bool classof(const Value *From)
void setDefaultDest(BasicBlock *BB)
Value * getIndirectDestLabel(unsigned Idx) const
Value * getIndirectDestLabelUse(unsigned Idx) const
unsigned getNumIndirectDests() const
SmallVector< BasicBlock *, 16 > getIndirectDests() const
BasicBlock * getDefaultDest() const
BasicBlock * getSuccessor(unsigned Idx) const
void setIndirectDest(unsigned Idx, BasicBlock *BB)
unsigned getNumSuccessors() const
static CallInst * create(FunctionType *FTy, Value *Func, ArrayRef< Value * > Args, BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx, const Twine &NameStr="")
static bool classof(const Value *From)
static Value * create(Value *Src, Type *DestTy, Instruction *InsertBefore, Context &Ctx, const Twine &Name="")
static bool classof(const Value *From)
static Value * create(Value *Src, Type *DestTy, BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx, const Twine &Name="")
static Value * create(Value *Src, Type *DestTy, BasicBlock *InsertAtEnd, Context &Ctx, const Twine &Name="")
static Value * create(Type *DestTy, Opcode Op, Value *Operand, BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx, const Twine &Name="")
static bool classof(const Value *From)
For isa/dyn_cast.
static bool classof(const Value *From)
CatchSwitchInst * getCatchSwitch() const
static CatchPadInst * create(Value *ParentPad, ArrayRef< Value * > Args, BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx, const Twine &Name="")
const_handler_iterator handler_begin() const
void setParentPad(Value *ParentPad)
const_handler_iterator handler_end() const
static CatchSwitchInst * create(Value *ParentPad, BasicBlock *UnwindBB, unsigned NumHandlers, BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx, const Twine &Name="")
const BasicBlock *(*)(const Value *) ConstDerefFnTy
BasicBlock *(*)(Value *) DerefFnTy
unsigned getNumSuccessors() const
void addHandler(BasicBlock *Dest)
Value * getParentPad() const
bool hasUnwindDest() const
bool unwindsToCaller() const
handler_iterator handler_begin()
mapped_iterator< const_op_iterator, ConstDerefFnTy > const_handler_iterator
void setUnwindDest(BasicBlock *UnwindDest)
mapped_iterator< op_iterator, DerefFnTy > handler_iterator
static bool classof(const Value *From)
BasicBlock * getUnwindDest() const
CatchSwitchInst(llvm::CatchSwitchInst *CSI, Context &Ctx)
handler_iterator handler_end()
unsigned getNumHandlers() const
void setSuccessor(unsigned Idx, BasicBlock *NewSucc)
BasicBlock * getSuccessor(unsigned Idx) const
const_handler_range handlers() const
static CleanupPadInst * create(Value *ParentPad, ArrayRef< Value * > Args, BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx, const Twine &Name="")
static bool classof(const Value *From)
static ConstantInt * get(Type *Ty, uint64_t V, Context &Ctx, bool IsSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
void verify() const override
Should crash if there is something wrong with the instruction.
unsigned getUseOperandNo(const Use &Use) const override
\Returns the operand index of Use.
void dumpOS(raw_ostream &OS) const override
static bool classof(const sandboxir::Value *From)
For isa/dyn_cast.
sandboxir::Context & getParent() const
void verify() const override
Should crash if there is something wrong with the instruction.
static bool classof(const sandboxir::Value *From)
For isa/dyn_cast.
void dumpOS(raw_ostream &OS) const override
unsigned getUseOperandNo(const Use &Use) const override
\Returns the operand index of Use.
CallBrInst * createCallBrInst(llvm::CallBrInst *I)
GetElementPtrInst * createGetElementPtrInst(llvm::GetElementPtrInst *I)
DenseMap< llvm::Value *, std::unique_ptr< sandboxir::Value > > LLVMValueToValueMap
Maps LLVM Value to the corresponding sandboxir::Value.
Value * registerValue(std::unique_ptr< Value > &&VPtr)
Take ownership of VPtr and store it in LLVMValueToValueMap.
CatchPadInst * createCatchPadInst(llvm::CatchPadInst *I)
sandboxir::Value * getValue(llvm::Value *V) const
IRBuilder< ConstantFolder > LLVMIRBuilder
Argument * getOrCreateArgument(llvm::Argument *LLVMArg)
Get or create a sandboxir::Argument for an existing LLVM IR LLVMArg.
Function * createFunction(llvm::Function *F)
Create a sandboxir::Function for an existing LLVM IR F, including all blocks and instructions.
Value * getOrCreateValueInternal(llvm::Value *V, llvm::User *U=nullptr)
This is the actual function that creates sandboxir values for V, and among others handles all instruc...
friend ExtractElementInst
auto & getLLVMIRBuilder()
std::unique_ptr< Value > detach(Value *V)
Remove SBV from all SandboxIR maps and stop owning it.
SwitchInst * createSwitchInst(llvm::SwitchInst *I)
UnreachableInst * createUnreachableInst(llvm::UnreachableInst *UI)
const sandboxir::Value * getValue(const llvm::Value *V) const
void accept()
Convenience function for getTracker().accept()
ShuffleVectorInst * createShuffleVectorInst(llvm::ShuffleVectorInst *SVI)
BranchInst * createBranchInst(llvm::BranchInst *I)
Constant * getOrCreateConstant(llvm::Constant *LLVMC)
Get or create a sandboxir::Constant from an existing LLVM IR LLVMC.
BasicBlock * createBasicBlock(llvm::BasicBlock *BB)
Create a sandboxir::BasicBlock for an existing LLVM IR BB.
UnaryOperator * createUnaryOperator(llvm::UnaryOperator *I)
ExtractElementInst * createExtractElementInst(llvm::ExtractElementInst *EEI)
LoadInst * createLoadInst(llvm::LoadInst *LI)
AllocaInst * createAllocaInst(llvm::AllocaInst *I)
Context(LLVMContext &LLVMCtx)
void revert()
Convenience function for getTracker().revert()
CallInst * createCallInst(llvm::CallInst *I)
AtomicRMWInst * createAtomicRMWInst(llvm::AtomicRMWInst *I)
std::unique_ptr< Value > detachLLVMValue(llvm::Value *V)
Remove V from the maps and returns the unique_ptr.
StoreInst * createStoreInst(llvm::StoreInst *SI)
void save()
Convenience function for getTracker().save()
Value * getOrCreateValue(llvm::Value *LLVMV)
Get or create a sandboxir::Value for an existing LLVM IR LLVMV.
InsertElementInst * createInsertElementInst(llvm::InsertElementInst *IEI)
AtomicCmpXchgInst * createAtomicCmpXchgInst(llvm::AtomicCmpXchgInst *I)
CatchSwitchInst * createCatchSwitchInst(llvm::CatchSwitchInst *I)
ReturnInst * createReturnInst(llvm::ReturnInst *I)
CleanupPadInst * createCleanupPadInst(llvm::CleanupPadInst *I)
PHINode * createPHINode(llvm::PHINode *I)
SelectInst * createSelectInst(llvm::SelectInst *SI)
CastInst * createCastInst(llvm::CastInst *I)