15#ifndef LLVM_IR_INSTRUCTIONS_H
16#define LLVM_IR_INSTRUCTIONS_H
71 "Bitfields must be contiguous");
125 return Align(1ULL << getSubclassData<AlignmentField>());
129 setSubclassData<AlignmentField>(
Log2(
Align));
140 return getSubclassData<UsedWithInAllocaField>();
145 setSubclassData<UsedWithInAllocaField>(V);
149 bool isSwiftError()
const {
return getSubclassData<SwiftErrorField>(); }
155 return (
I->getOpcode() == Instruction::Alloca);
158 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
164 template <
typename Bitfield>
165 void setSubclassData(
typename Bitfield::Type
Value) {
166 Instruction::setSubclassData<Bitfield>(
Value);
181 Bitfield::areContiguous<VolatileField, AlignmentField, OrderingField>(),
182 "Bitfields must be contiguous");
205 bool isVolatile()
const {
return getSubclassData<VolatileField>(); }
212 return Align(1ULL << (getSubclassData<AlignmentField>()));
216 setSubclassData<AlignmentField>(
Log2(
Align));
221 return getSubclassData<OrderingField>();
226 setSubclassData<OrderingField>(Ordering);
267 return I->getOpcode() == Instruction::Load;
270 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
276 template <
typename Bitfield>
277 void setSubclassData(
typename Bitfield::Type
Value) {
278 Instruction::setSubclassData<Bitfield>(
Value);
297 Bitfield::areContiguous<VolatileField, AlignmentField, OrderingField>(),
298 "Bitfields must be contiguous");
321 void *
operator new(
size_t S) {
return User::operator
new(S, AllocMarker); }
322 void operator delete(
void *
Ptr) { User::operator
delete(
Ptr); }
325 bool isVolatile()
const {
return getSubclassData<VolatileField>(); }
334 return Align(1ULL << (getSubclassData<AlignmentField>()));
338 setSubclassData<AlignmentField>(
Log2(
Align));
343 return getSubclassData<OrderingField>();
349 setSubclassData<OrderingField>(Ordering);
393 return I->getOpcode() == Instruction::Store;
396 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
402 template <
typename Bitfield>
403 void setSubclassData(
typename Bitfield::Type
Value) {
404 Instruction::setSubclassData<Bitfield>(
Value);
445 void *
operator new(
size_t S) {
return User::operator
new(S, AllocMarker); }
446 void operator delete(
void *
Ptr) { User::operator
delete(
Ptr); }
450 return getSubclassData<OrderingField>();
456 setSubclassData<OrderingField>(Ordering);
471 return I->getOpcode() == Instruction::Fence;
474 return isa<Instruction>(V) && classof(cast<Instruction>(V));
480 template <
typename Bitfield>
481 void setSubclassData(
typename Bitfield::Type
Value) {
482 Instruction::setSubclassData<Bitfield>(
Value);
506 template <
unsigned Offset>
507 using AtomicOrderingBitfieldElement =
526 void *
operator new(
size_t S) {
return User::operator
new(S, AllocMarker); }
527 void operator delete(
void *
Ptr) { User::operator
delete(
Ptr); }
540 "Bitfields must be contiguous");
545 return Align(1ULL << getSubclassData<AlignmentField>());
549 setSubclassData<AlignmentField>(
Log2(
Align));
555 bool isVolatile()
const {
return getSubclassData<VolatileField>(); }
562 bool isWeak()
const {
return getSubclassData<WeakField>(); }
564 void setWeak(
bool IsWeak) { setSubclassData<WeakField>(IsWeak); }
583 return getSubclassData<SuccessOrderingField>();
589 "invalid CmpXchg success ordering");
590 setSubclassData<SuccessOrderingField>(Ordering);
595 return getSubclassData<FailureOrderingField>();
601 "invalid CmpXchg failure ordering");
602 setSubclassData<FailureOrderingField>(Ordering);
653 switch (SuccessOrdering) {
669 return I->getOpcode() == Instruction::AtomicCmpXchg;
672 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
678 template <
typename Bitfield>
679 void setSubclassData(
typename Bitfield::Type
Value) {
680 Instruction::setSubclassData<Bitfield>(
Value);
771 LAST_BINOP = USubSat,
776 template <
unsigned Offset>
777 using AtomicOrderingBitfieldElement =
781 template <
unsigned Offset>
782 using BinOpBitfieldElement =
785 constexpr static IntrusiveOperandsAllocMarker AllocMarker{2};
790 InsertPosition InsertBefore =
nullptr);
793 void *
operator new(
size_t S) {
return User::operator
new(S, AllocMarker); }
794 void operator delete(
void *
Ptr) { User::operator
delete(
Ptr); }
803 "Bitfields must be contiguous");
822 setSubclassData<OperationField>(
Operation);
828 return Align(1ULL << getSubclassData<AlignmentField>());
832 setSubclassData<AlignmentField>(
Log2(
Align));
837 bool isVolatile()
const {
return getSubclassData<VolatileField>(); }
848 return getSubclassData<AtomicOrderingField>();
854 "atomicrmw instructions can only be atomic.");
856 "atomicrmw instructions cannot be unordered.");
857 setSubclassData<AtomicOrderingField>(Ordering);
883 return isFPOperation(getOperation());
888 return I->getOpcode() == Instruction::AtomicRMW;
891 return isa<Instruction>(V) && classof(cast<Instruction>(V));
900 template <
typename Bitfield>
901 void setSubclassData(
typename Bitfield::Type
Value) {
902 Instruction::setSubclassData<Bitfield>(
Value);
926 assert(Ty &&
"Invalid GetElementPtrInst indices for type!");
934 Type *SourceElementType;
935 Type *ResultElementType;
958 const Twine &NameStr =
"",
961 assert(PointeeType &&
"Must specify element type");
964 PointeeType,
Ptr, IdxList, AllocMarker, NameStr, InsertBefore);
969 const Twine &NameStr =
"",
972 Create(PointeeType,
Ptr, IdxList, NameStr, InsertBefore);
973 GEP->setNoWrapFlags(NW);
981 const Twine &NameStr =
"",
984 NameStr, InsertBefore);
996 return ResultElementType;
1066 if (
auto *IndexVTy = dyn_cast<VectorType>(
Index->getType())) {
1123 APInt &ConstantOffset)
const;
1126 return (
I->getOpcode() == Instruction::GetElementPtr);
1129 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
1137GetElementPtrInst::GetElementPtrInst(
Type *PointeeType,
Value *
Ptr,
1143 SourceElementType(PointeeType),
1144 ResultElementType(getIndexedType(PointeeType, IdxList)) {
1145 init(
Ptr, IdxList, NameStr);
1160 assert(isIntPredicate() &&
1161 "Invalid ICmp predicate value");
1163 "Both operands to ICmp instruction are not of the same type!");
1166 getOperand(0)->
getType()->isPtrOrPtrVectorTy()) &&
1167 "Invalid operand types for ICmp instruction");
1170 enum { SameSign = (1 << 0) };
1185 const Twine &NameStr =
""
1188 RHS, NameStr, InsertBefore) {
1199 const Twine &NameStr =
""
1209 return {getPredicate(), hasSameSign()};
1215 return {getInversePredicate(Pred), Pred.
hasSameSign()};
1220 return getInverseCmpPredicate(getCmpPredicate());
1226 return {getSwappedPredicate(Pred), Pred.
hasSameSign()};
1231 return getSwappedCmpPredicate(getCmpPredicate());
1237 return {getNonStrictPredicate(Pred), Pred.
hasSameSign()};
1243 return getNonStrictCmpPredicate(getCmpPredicate());
1251 return getSignedPredicate(getPredicate());
1262 return getUnsignedPredicate(getPredicate());
1278 return getFlippedSignednessPredicate(getPredicate());
1283 static std::optional<bool> isImpliedByMatchingCmp(
CmpPredicate Pred1,
1287 SubclassOptionalData = (SubclassOptionalData & ~SameSign) | (
B * SameSign);
1298 return P == ICMP_EQ ||
P == ICMP_NE;
1304 return isEquality(getPredicate());
1318 return !isEquality();
1324 return !isEquality(
P);
1330 return P == ICMP_SGT ||
P == ICMP_UGT;
1336 return P == ICMP_SLT ||
P == ICMP_ULT;
1342 return P == ICMP_SGE ||
P == ICMP_UGE;
1348 return P == ICMP_SLE ||
P == ICMP_ULE;
1361 setPredicate(getSwappedPredicate());
1376 return I->getOpcode() == Instruction::ICmp;
1379 return isa<Instruction>(V) && classof(cast<Instruction>(V));
1395 "Both operands to FCmp instruction are not of the same type!");
1398 "Invalid operand types for FCmp instruction");
1414 const Twine &NameStr =
""
1417 RHS, NameStr, InsertBefore) {
1425 const Twine &NameStr =
"",
1428 RHS, NameStr, nullptr, FlagsSource) {
1478 return I->getOpcode() == Instruction::FCmp;
1481 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
1512 static unsigned ComputeNumOperands(
unsigned NumArgs,
1513 unsigned NumBundleInputs = 0) {
1516 return 1 + NumArgs + NumBundleInputs;
1529 return new (AllocMarker)
1530 CallInst(Ty,
F, NameStr, AllocMarker, InsertBefore);
1534 const Twine &NameStr,
1537 return new (AllocMarker)
1538 CallInst(Ty, Func, Args, {}, NameStr, AllocMarker, InsertBefore);
1543 const Twine &NameStr =
"",
1545 IntrusiveOperandsAndDescriptorAllocMarker AllocMarker{
1549 return new (AllocMarker)
1550 CallInst(Ty, Func, Args, Bundles, NameStr, AllocMarker, InsertBefore);
1555 return Create(Func.getFunctionType(), Func.getCallee(), NameStr,
1561 const Twine &NameStr =
"",
1563 return Create(Func.getFunctionType(), Func.getCallee(), Args, Bundles,
1564 NameStr, InsertBefore);
1568 const Twine &NameStr,
1570 return Create(Func.getFunctionType(), Func.getCallee(), Args, NameStr,
1594 Bitfield::areContiguous<TailCallKindField, CallBase::CallingConvField>(),
1595 "Bitfields must be contiguous");
1598 return getSubclassData<TailCallKindField>();
1611 setSubclassData<TailCallKindField>(TCK);
1625 case Intrinsic::trap:
1626 case Intrinsic::ubsantrap:
1635 return I->getOpcode() == Instruction::Call;
1638 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
1647 template <
typename Bitfield>
1648 void setSubclassData(
typename Bitfield::Type
Value) {
1649 Instruction::setSubclassData<Bitfield>(
Value);
1653CallInst::CallInst(
FunctionType *Ty, Value *Func, ArrayRef<Value *> Args,
1654 ArrayRef<OperandBundleDef> Bundles,
const Twine &NameStr,
1655 AllocInfo AllocInfo, InsertPosition InsertBefore)
1656 : CallBase(Ty->getReturnType(), Instruction::
Call, AllocInfo,
1658 assert(AllocInfo.NumOps ==
1660 init(Ty, Func, Args, Bundles, NameStr);
1674 :
Instruction(
S1->getType(), Instruction::Select, AllocMarker,
1695 const Twine &NameStr =
"",
1699 new (AllocMarker)
SelectInst(
C,
S1, S2, NameStr, InsertBefore);
1733 return I->getOpcode() == Instruction::Select;
1736 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
1773 return I->getOpcode() == VAArg;
1776 return isa<Instruction>(V) && classof(cast<Instruction>(V));
1801 const Twine &NameStr =
"",
1803 return new (AllocMarker)
1825 return I->getOpcode() == Instruction::ExtractElement;
1828 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
1850 const Twine &NameStr =
"",
1861 const Twine &NameStr =
"",
1863 return new (AllocMarker)
1869 static bool isValidOperands(
const Value *Vec,
const Value *NewElt,
1883 return I->getOpcode() == Instruction::InsertElement;
1886 return isa<Instruction>(V) && classof(cast<Instruction>(V));
1931 const Twine &NameStr =
"",
1934 const Twine &NameStr =
"",
1937 void *
operator new(
size_t S) {
return User::operator
new(S, AllocMarker); }
1938 void operator delete(
void *
Ptr) {
return User::operator
delete(
Ptr); }
1946 static bool isValidOperands(
const Value *V1,
const Value *V2,
1948 static bool isValidOperands(
const Value *V1,
const Value *V2,
1966 static void getShuffleMask(
const Constant *Mask,
1972 Result.assign(ShuffleMask.
begin(), ShuffleMask.
end());
1993 unsigned NumSourceElts = cast<VectorType>(
Op<0>()->
getType())
1995 .getKnownMinValue();
1996 unsigned NumMaskElts = ShuffleMask.
size();
1997 return NumSourceElts != NumMaskElts;
2004 unsigned NumSourceElts = cast<VectorType>(
Op<0>()->
getType())
2006 .getKnownMinValue();
2007 unsigned NumMaskElts = ShuffleMask.
size();
2008 return NumSourceElts < NumMaskElts;
2016 static bool isSingleSourceMask(
ArrayRef<int> Mask,
int NumSrcElts);
2018 assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2020 getShuffleMask(Mask, MaskAsInts);
2021 return isSingleSourceMask(MaskAsInts, NumSrcElts);
2029 return !changesLength() &&
2030 isSingleSourceMask(ShuffleMask, ShuffleMask.
size());
2038 static bool isIdentityMask(
ArrayRef<int> Mask,
int NumSrcElts);
2040 assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2044 if (isa<ScalableVectorType>(Mask->getType()))
2048 getShuffleMask(Mask, MaskAsInts);
2049 return isIdentityMask(MaskAsInts, NumSrcElts);
2059 if (isa<ScalableVectorType>(
getType()))
2062 return !changesLength() && isIdentityMask(ShuffleMask, ShuffleMask.
size());
2067 bool isIdentityWithPadding()
const;
2071 bool isIdentityWithExtract()
const;
2076 bool isConcat()
const;
2086 static bool isSelectMask(
ArrayRef<int> Mask,
int NumSrcElts);
2088 assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2090 getShuffleMask(Mask, MaskAsInts);
2091 return isSelectMask(MaskAsInts, NumSrcElts);
2103 return !changesLength() && isSelectMask(ShuffleMask, ShuffleMask.
size());
2113 assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2115 getShuffleMask(Mask, MaskAsInts);
2132 static bool isZeroEltSplatMask(
ArrayRef<int> Mask,
int NumSrcElts);
2134 assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2136 getShuffleMask(Mask, MaskAsInts);
2137 return isZeroEltSplatMask(MaskAsInts, NumSrcElts);
2147 return !changesLength() &&
2148 isZeroEltSplatMask(ShuffleMask, ShuffleMask.
size());
2183 static bool isTransposeMask(
ArrayRef<int> Mask,
int NumSrcElts);
2185 assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2187 getShuffleMask(Mask, MaskAsInts);
2188 return isTransposeMask(MaskAsInts, NumSrcElts);
2197 return !changesLength() && isTransposeMask(ShuffleMask, ShuffleMask.
size());
2208 assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2210 getShuffleMask(Mask, MaskAsInts);
2211 return isSpliceMask(MaskAsInts, NumSrcElts,
Index);
2219 return !changesLength() &&
2220 isSpliceMask(ShuffleMask, ShuffleMask.
size(),
Index);
2226 static bool isExtractSubvectorMask(
ArrayRef<int> Mask,
int NumSrcElts,
2230 assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2233 if (isa<ScalableVectorType>(Mask->getType()))
2236 getShuffleMask(Mask, MaskAsInts);
2237 return isExtractSubvectorMask(MaskAsInts, NumSrcElts,
Index);
2244 if (isa<ScalableVectorType>(
getType()))
2248 cast<FixedVectorType>(
Op<0>()->
getType())->getNumElements();
2249 return isExtractSubvectorMask(ShuffleMask, NumSrcElts,
Index);
2256 static bool isInsertSubvectorMask(
ArrayRef<int> Mask,
int NumSrcElts,
2257 int &NumSubElts,
int &
Index);
2259 int &NumSubElts,
int &
Index) {
2260 assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2263 if (isa<ScalableVectorType>(Mask->getType()))
2266 getShuffleMask(Mask, MaskAsInts);
2267 return isInsertSubvectorMask(MaskAsInts, NumSrcElts, NumSubElts,
Index);
2274 if (isa<ScalableVectorType>(
getType()))
2278 cast<FixedVectorType>(
Op<0>()->
getType())->getNumElements();
2279 return isInsertSubvectorMask(ShuffleMask, NumSrcElts, NumSubElts,
Index);
2286 static bool isReplicationMask(
ArrayRef<int> Mask,
int &ReplicationFactor,
2290 assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2293 if (isa<ScalableVectorType>(Mask->getType()))
2296 getShuffleMask(Mask, MaskAsInts);
2297 return isReplicationMask(MaskAsInts, ReplicationFactor, VF);
2301 bool isReplicationMask(
int &ReplicationFactor,
int &VF)
const;
2312 static bool isOneUseSingleSourceMask(
ArrayRef<int> Mask,
int VF);
2316 bool isOneUseSingleSourceMask(
int VF)
const;
2321 unsigned InVecNumElts) {
2322 for (
int &
Idx : Mask) {
2325 Idx =
Idx < (int)InVecNumElts ?
Idx + InVecNumElts :
Idx - InVecNumElts;
2327 "shufflevector mask index out of range");
2332 bool isInterleave(
unsigned Factor);
2353 static bool isInterleaveMask(
ArrayRef<int> Mask,
unsigned Factor,
2354 unsigned NumInputElts,
2357 unsigned NumInputElts) {
2359 return isInterleaveMask(Mask, Factor, NumInputElts, StartIndexes);
2365 static bool isDeInterleaveMaskOfFactor(
ArrayRef<int> Mask,
unsigned Factor,
2369 return isDeInterleaveMaskOfFactor(Mask, Factor, Unused);
2383 static bool isBitRotateMask(
ArrayRef<int> Mask,
unsigned EltSizeInBits,
2384 unsigned MinSubElts,
unsigned MaxSubElts,
2385 unsigned &NumSubElts,
unsigned &RotateAmt);
2389 return I->getOpcode() == Instruction::ShuffleVector;
2392 return isa<Instruction>(V) && classof(cast<Instruction>(V));
2431 const Twine &NameStr =
"",
2452 return getOperand(0);
2455 return getOperand(0);
2466 return (
unsigned)Indices.
size();
2475 return I->getOpcode() == Instruction::ExtractValue;
2478 return isa<Instruction>(V) && classof(cast<Instruction>(V));
2482ExtractValueInst::ExtractValueInst(Value *Agg, ArrayRef<unsigned> Idxs,
2483 const Twine &NameStr,
2484 InsertPosition InsertBefore)
2486 ExtractValue, Agg, InsertBefore) {
2487 init(Idxs, NameStr);
2514 const Twine &NameStr =
"",
2518 const Twine &NameStr);
2528 void *
operator new(
size_t S) {
return User::operator
new(S, AllocMarker); }
2529 void operator delete(
void *
Ptr) { User::operator
delete(
Ptr); }
2533 const Twine &NameStr =
"",
2574 return (
unsigned)Indices.
size();
2583 return I->getOpcode() == Instruction::InsertValue;
2586 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
2595InsertValueInst::InsertValueInst(
Value *Agg,
Value *Val,
2599 init(Agg, Val, Idxs, NameStr);
2617 unsigned ReservedSpace;
2621 explicit PHINode(
Type *Ty,
unsigned NumReservedValues,
2622 const Twine &NameStr =
"",
2624 :
Instruction(Ty, Instruction::PHI, AllocMarker, InsertBefore),
2625 ReservedSpace(NumReservedValues) {
2628 allocHungoffUses(ReservedSpace);
2648 const Twine &NameStr =
"",
2650 return new (AllocMarker)
2651 PHINode(Ty, NumReservedValues, NameStr, InsertBefore);
2670 return block_begin() + getNumOperands();
2674 return make_range(block_begin(), block_end());
2688 return getOperand(i);
2691 assert(V &&
"PHI node got a null value!");
2693 "All operands to PHI node must be the same type as the PHI node!");
2708 return block_begin()[i];
2715 assert(
this == U.getUser() &&
"Iterator doesn't point to PHI's Uses?");
2716 return getIncomingBlock(
unsigned(&U - op_begin()));
2723 return getIncomingBlock(
I.getUse());
2739 assert(New && Old &&
"PHI node got a null basic block!");
2740 for (
unsigned Op = 0, NumOps = getNumOperands();
Op != NumOps; ++
Op)
2741 if (getIncomingBlock(
Op) == Old)
2742 setIncomingBlock(
Op, New);
2748 if (getNumOperands() == ReservedSpace)
2751 setNumHungOffUseOperands(getNumOperands() + 1);
2752 setIncomingValue(getNumOperands() - 1, V);
2753 setIncomingBlock(getNumOperands() - 1, BB);
2764 Value *removeIncomingValue(
unsigned Idx,
bool DeletePHIIfEmpty =
true);
2767 int Idx = getBasicBlockIndex(BB);
2768 assert(
Idx >= 0 &&
"Invalid basic block argument to remove!");
2769 return removeIncomingValue(
Idx, DeletePHIIfEmpty);
2775 bool DeletePHIIfEmpty =
true);
2781 for (
unsigned i = 0, e = getNumOperands(); i != e; ++i)
2782 if (block_begin()[i] == BB)
2788 int Idx = getBasicBlockIndex(BB);
2789 assert(
Idx >= 0 &&
"Invalid basic block argument!");
2790 return getIncomingValue(
Idx);
2795 assert(BB &&
"PHI node got a null basic block!");
2797 for (
unsigned Op = 0, NumOps = getNumOperands();
Op != NumOps; ++
Op)
2798 if (getIncomingBlock(
Op) == BB) {
2800 setIncomingValue(
Op, V);
2803 assert(Found &&
"Invalid basic block argument to set!");
2808 Value *hasConstantValue()
const;
2813 bool hasConstantOrUndefValue()
const;
2820 return getBasicBlockIndex(Pred) >= 0;
2826 return I->getOpcode() == Instruction::PHI;
2829 return isa<Instruction>(V) && classof(cast<Instruction>(V));
2833 void growOperands();
2859 unsigned ReservedSpace;
2871 void *
operator new(
size_t S) {
return User::operator
new(S, AllocMarker); }
2873 void growOperands(
unsigned Size);
2874 void init(
unsigned NumReservedValues,
const Twine &NameStr);
2883 void operator delete(
void *
Ptr) { User::operator
delete(
Ptr); }
2888 const Twine &NameStr =
"",
2897 bool isCleanup()
const {
return getSubclassData<CleanupField>(); }
2908 return cast<Constant>(getOperandList()[
Idx]);
2913 return !isa<ArrayType>(getOperandList()[
Idx]->
getType());
2918 return isa<ArrayType>(getOperandList()[
Idx]->
getType());
2930 return I->getOpcode() == Instruction::LandingPad;
2933 return isa<Instruction>(V) && classof(cast<Instruction>(V));
2980 return new (AllocMarker)
ReturnInst(
C, retVal, AllocMarker, InsertBefore);
2985 return new (AllocMarker)
ReturnInst(
C,
nullptr, AllocMarker, InsertAtEnd);
2993 return getNumOperands() != 0 ? getOperand(0) :
nullptr;
3000 return (
I->getOpcode() == Instruction::Ret);
3003 return isa<Instruction>(V) && classof(cast<Instruction>(V));
3007 BasicBlock *getSuccessor(
unsigned idx)
const {
3011 void setSuccessor(
unsigned idx, BasicBlock *
B) {
3063 std::random_access_iterator_tag, BasicBlock *,
3064 ptrdiff_t, BasicBlock *, BasicBlock *> {
3074 std::random_access_iterator_tag,
3075 const BasicBlock *, ptrdiff_t, const BasicBlock *,
3076 const BasicBlock *> {
3087 return new (AllocMarker)
BranchInst(IfTrue, AllocMarker, InsertBefore);
3094 return new (AllocMarker)
3105 assert(isConditional() &&
"Cannot get condition of an uncond branch!");
3110 assert(isConditional() &&
"Cannot set condition of unconditional branch!");
3117 assert(i < getNumSuccessors() &&
"Successor # out of range for Branch!");
3118 return cast_or_null<BasicBlock>((&
Op<-1>() - i)->
get());
3122 assert(idx < getNumSuccessors() &&
"Successor # out of range for Branch!");
3123 *(&
Op<-1>() - idx) = NewSucc;
3131 void swapSuccessors();
3141 std::next(value_op_begin(), isConditional() ? 1 : 0)),
3147 return (
I->getOpcode() == Instruction::Br);
3150 return isa<Instruction>(V) && classof(cast<Instruction>(V));
3169 unsigned ReservedSpace;
3185 void *
operator new(
size_t S) {
return User::operator
new(S, AllocMarker); }
3188 void growOperands();
3197 void operator delete(
void *
Ptr) { User::operator
delete(
Ptr); }
3200 static const unsigned DefaultPseudoIndex =
static_cast<unsigned>(~0L-1);
3209 template <
typename SwitchInstT,
typename ConstantIntT,
typename BasicBlockT>
3228 assert((
unsigned)Index < SI->getNumCases() &&
3229 "Index out the number of cases.");
3230 return reinterpret_cast<ConstantIntT *
>(
SI->getOperand(2 +
Index * 2));
3235 assert(((
unsigned)Index < SI->getNumCases() ||
3236 (
unsigned)
Index == DefaultPseudoIndex) &&
3237 "Index out the number of cases.");
3238 return SI->getSuccessor(getSuccessorIndex());
3247 (
unsigned)Index < SI->getNumCases()) &&
3248 "Index out the number of cases.");
3249 return (
unsigned)
Index != DefaultPseudoIndex ?
Index + 1 : 0;
3253 assert(
SI ==
RHS.SI &&
"Incompatible operators.");
3270 assert((
unsigned)Index < SI->getNumCases() &&
3271 "Index out the number of cases.");
3272 SI->setOperand(2 +
Index*2,
reinterpret_cast<Value*
>(V));
3277 SI->setSuccessor(getSuccessorIndex(), S);
3281 template <
typename CaseHandleT>
3284 std::random_access_iterator_tag,
3285 const CaseHandleT> {
3286 using SwitchInstT =
typename CaseHandleT::SwitchInstType;
3302 unsigned SuccessorIndex) {
3303 assert(SuccessorIndex < SI->getNumSuccessors() &&
3304 "Successor index # out of range!");
3319 (
unsigned)(Case.Index +
N) <= Case.SI->getNumCases() &&
3320 "Case.Index out the number of cases.");
3328 (
unsigned)(Case.Index -
N) <= Case.SI->getNumCases() &&
3329 "Case.Index out the number of cases.");
3334 assert(Case.SI ==
RHS.Case.SI &&
"Incompatible operators.");
3335 return Case.Index -
RHS.Case.Index;
3338 return Case ==
RHS.Case;
3341 assert(Case.SI ==
RHS.Case.SI &&
"Incompatible operators.");
3342 return Case.Index <
RHS.Case.Index;
3364 return cast<BasicBlock>(getOperand(1));
3370 return isa<UnreachableInst>(getDefaultDest()->getFirstNonPHIOrDbg());
3374 setOperand(1,
reinterpret_cast<Value*
>(DefaultCase));
3380 return getNumOperands()/2 - 1;
3398 return CaseIt(
this, getNumCases());
3423 return CaseIt(
this, DefaultPseudoIndex);
3436 const_cast<const SwitchInst *
>(
this)->findCaseValue(
C)->getCaseIndex());
3442 if (
I != case_end())
3445 return case_default();
3451 if (BB == getDefaultDest())
3455 for (
auto Case : cases()) {
3456 if (Case.getCaseSuccessor() != BB)
3462 CI = Case.getCaseValue();
3481 CaseIt removeCase(CaseIt
I);
3485 assert(idx < getNumSuccessors() &&
"Successor idx out of range for switch!");
3486 return cast<BasicBlock>(getOperand(idx*2+1));
3489 assert(idx < getNumSuccessors() &&
"Successor # out of range for switch!");
3490 setOperand(idx * 2 + 1, NewSucc);
3495 return I->getOpcode() == Instruction::Switch;
3498 return isa<Instruction>(V) && classof(cast<Instruction>(V));
3506 std::optional<SmallVector<uint32_t, 8>> Weights;
3507 bool Changed =
false;
3559 unsigned ReservedSpace;
3573 void *
operator new(
size_t S) {
return User::operator
new(S, AllocMarker); }
3576 void growOperands();
3585 void operator delete(
void *
Ptr) { User::operator
delete(
Ptr); }
3593 std::random_access_iterator_tag, BasicBlock *,
3594 ptrdiff_t, BasicBlock *, BasicBlock *> {
3604 std::random_access_iterator_tag,
3605 const BasicBlock *, ptrdiff_t, const BasicBlock *,
3606 const BasicBlock *> {
3641 void removeDestination(
unsigned i);
3645 return cast<BasicBlock>(getOperand(i+1));
3648 setOperand(i + 1, NewSucc);
3663 return I->getOpcode() == Instruction::IndirectBr;
3666 return isa<Instruction>(V) && classof(cast<Instruction>(V));
3685 static constexpr int NumExtraOperands = 2;
3688 static constexpr int NormalDestOpEndIdx = -3;
3691 static constexpr int UnwindDestOpEndIdx = -2;
3708 static unsigned ComputeNumOperands(
unsigned NumArgs,
3709 size_t NumBundleInputs = 0) {
3712 return 1 + NumExtraOperands + NumArgs +
unsigned(NumBundleInputs);
3724 const Twine &NameStr,
3727 ComputeNumOperands(
unsigned(Args.size()))};
3728 return new (AllocMarker)
InvokeInst(Ty, Func, IfNormal, IfException, Args,
3729 {}, AllocMarker, NameStr, InsertBefore);
3735 const Twine &NameStr =
"",
3737 IntrusiveOperandsAndDescriptorAllocMarker AllocMarker{
3738 ComputeNumOperands(Args.size(), CountBundleInputs(Bundles)),
3741 return new (AllocMarker)
3742 InvokeInst(Ty, Func, IfNormal, IfException, Args, Bundles, AllocMarker,
3743 NameStr, InsertBefore);
3748 const Twine &NameStr,
3750 return Create(Func.getFunctionType(), Func.getCallee(), IfNormal,
3751 IfException, Args, {}, NameStr, InsertBefore);
3757 const Twine &NameStr =
"",
3759 return Create(Func.getFunctionType(), Func.getCallee(), IfNormal,
3760 IfException, Args, Bundles, NameStr, InsertBefore);
3769 static InvokeInst *Create(InvokeInst *
II, ArrayRef<OperandBundleDef> Bundles,
3770 InsertPosition InsertPt =
nullptr);
3791 assert(i < 2 &&
"Successor # out of range for invoke!");
3792 return i == 0 ? getNormalDest() : getUnwindDest();
3796 assert(i < 2 &&
"Successor # out of range for invoke!");
3798 setNormalDest(NewSucc);
3800 setUnwindDest(NewSucc);
3810 return (
I->getOpcode() == Instruction::Invoke);
3813 return isa<Instruction>(V) && classof(cast<Instruction>(V));
3819 template <
typename Bitfield>
3820 void setSubclassData(
typename Bitfield::Type
Value) {
3821 Instruction::setSubclassData<Bitfield>(
Value);
3825InvokeInst::InvokeInst(
FunctionType *Ty, Value *Func, BasicBlock *IfNormal,
3826 BasicBlock *IfException, ArrayRef<Value *> Args,
3827 ArrayRef<OperandBundleDef> Bundles, AllocInfo AllocInfo,
3828 const Twine &NameStr, InsertPosition InsertBefore)
3829 : CallBase(Ty->getReturnType(), Instruction::Invoke, AllocInfo,
3831 init(Ty, Func, IfNormal, IfException, Args, Bundles, NameStr);
3844 unsigned NumIndirectDests;
3862 static unsigned ComputeNumOperands(
int NumArgs,
int NumIndirectDests,
3863 int NumBundleInputs = 0) {
3866 return unsigned(2 + NumIndirectDests + NumArgs + NumBundleInputs);
3882 ComputeNumOperands(Args.size(), IndirectDests.
size())};
3883 return new (AllocMarker)
3884 CallBrInst(Ty, Func, DefaultDest, IndirectDests, Args, {}, AllocMarker,
3885 NameStr, InsertBefore);
3893 IntrusiveOperandsAndDescriptorAllocMarker AllocMarker{
3894 ComputeNumOperands(Args.size(), IndirectDests.
size(),
3898 return new (AllocMarker)
3899 CallBrInst(Ty, Func, DefaultDest, IndirectDests, Args, Bundles,
3900 AllocMarker, NameStr, InsertBefore);
3907 return Create(Func.getFunctionType(), Func.getCallee(), DefaultDest,
3908 IndirectDests, Args, NameStr, InsertBefore);
3915 const Twine &NameStr =
"",
3917 return Create(Func.getFunctionType(), Func.getCallee(), DefaultDest,
3918 IndirectDests, Args, Bundles, NameStr, InsertBefore);
3927 static CallBrInst *
Create(CallBrInst *CBI, ArrayRef<OperandBundleDef> Bundles,
3928 InsertPosition InsertBefore =
nullptr);
3957 return IndirectDests;
3968 "Successor # out of range for callbr!");
3974 "Successor # out of range for callbr!");
3982 return (
I->getOpcode() == Instruction::CallBr);
3985 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
3991 template <
typename Bitfield>
3992 void setSubclassData(
typename Bitfield::Type
Value) {
3993 Instruction::setSubclassData<Bitfield>(
Value);
3997CallBrInst::CallBrInst(
FunctionType *Ty, Value *Func, BasicBlock *DefaultDest,
3998 ArrayRef<BasicBlock *> IndirectDests,
3999 ArrayRef<Value *> Args,
4000 ArrayRef<OperandBundleDef> Bundles, AllocInfo AllocInfo,
4001 const Twine &NameStr, InsertPosition InsertBefore)
4002 : CallBase(Ty->getReturnType(), Instruction::CallBr, AllocInfo,
4004 init(Ty, Func, DefaultDest, IndirectDests, Args, Bundles, NameStr);
4029 return new (AllocMarker)
ResumeInst(Exn, InsertBefore);
4042 return I->getOpcode() == Instruction::Resume;
4045 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4049 BasicBlock *getSuccessor(
unsigned idx)
const {
4053 void setSuccessor(
unsigned idx,
BasicBlock *NewSucc) {
4075 unsigned ReservedSpace;
4087 unsigned NumHandlers,
const Twine &NameStr,
4091 void *
operator new(
size_t S) {
return User::operator
new(S, AllocMarker); }
4093 void init(
Value *ParentPad,
BasicBlock *UnwindDest,
unsigned NumReserved);
4094 void growOperands(
unsigned Size);
4103 void operator delete(
void *
Ptr) {
return User::operator
delete(
Ptr); }
4106 unsigned NumHandlers,
4107 const Twine &NameStr =
"",
4109 return new CatchSwitchInst(ParentPad, UnwindDest, NumHandlers, NameStr,
4124 if (hasUnwindDest())
4125 return cast<BasicBlock>(getOperand(1));
4131 setOperand(1, UnwindDest);
4137 if (hasUnwindDest())
4138 return getNumOperands() - 2;
4139 return getNumOperands() - 1;
4143 static BasicBlock *handler_helper(
Value *V) {
return cast<BasicBlock>(V); }
4144 static const BasicBlock *handler_helper(
const Value *V) {
4145 return cast<BasicBlock>(V);
4160 if (hasUnwindDest())
4169 if (hasUnwindDest())
4188 return make_range(handler_begin(), handler_end());
4193 return make_range(handler_begin(), handler_end());
4202 void removeHandler(handler_iterator HI);
4207 "Successor # out of range for catchswitch!");
4208 return cast<BasicBlock>(getOperand(
Idx + 1));
4212 "Successor # out of range for catchswitch!");
4213 setOperand(
Idx + 1, NewSucc);
4218 return I->getOpcode() == Instruction::CatchSwitch;
4221 return isa<Instruction>(V) && classof(cast<Instruction>(V));
4239 NameStr, InsertBefore) {}
4243 const Twine &NameStr =
"",
4245 IntrusiveOperandsAllocMarker AllocMarker{
unsigned(1 + Args.size())};
4246 return new (AllocMarker)
4247 CleanupPadInst(ParentPad, Args, AllocMarker, NameStr, InsertBefore);
4252 return I->getOpcode() == Instruction::CleanupPad;
4255 return isa<Instruction>(V) && classof(cast<Instruction>(V));
4268 NameStr, InsertBefore) {}
4272 const Twine &NameStr =
"",
4275 return new (AllocMarker)
4276 CatchPadInst(CatchSwitch, Args, AllocMarker, NameStr, InsertBefore);
4281 return cast<CatchSwitchInst>(
Op<-1>());
4285 Op<-1>() = CatchSwitch;
4290 return I->getOpcode() == Instruction::CatchPad;
4293 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4348 return (
I->getOpcode() == Instruction::CatchRet);
4351 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4397 unsigned Values = 1;
4401 return new (AllocMarker)
4413 return cast<CleanupPadInst>(
Op<0>());
4417 Op<0>() = CleanupPad;
4423 return hasUnwindDest() ? cast<BasicBlock>(
Op<1>()) :
nullptr;
4433 return (
I->getOpcode() == Instruction::CleanupRet);
4436 return isa<Instruction>(V) && classof(cast<Instruction>(V));
4442 return getUnwindDest();
4445 void setSuccessor(
unsigned Idx, BasicBlock *
B) {
4452 template <
typename Bitfield>
4453 void setSubclassData(
typename Bitfield::Type Value) {
4454 Instruction::setSubclassData<Bitfield>(Value);
4487 void *
operator new(
size_t S) {
return User::operator
new(S, AllocMarker); }
4488 void operator delete(
void *
Ptr) { User::operator
delete(
Ptr); }
4494 return I->getOpcode() == Instruction::Unreachable;
4497 return isa<Instruction>(V) && classof(cast<Instruction>(V));
4501 BasicBlock *getSuccessor(
unsigned idx)
const {
4505 void setSuccessor(
unsigned idx, BasicBlock *
B) {
4529 const Twine &NameStr =
"",
4536 return I->getOpcode() == Trunc;
4539 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4565 unsigned NoWrapKind = 0;
4593 const Twine &NameStr =
"",
4600 return I->getOpcode() == ZExt;
4603 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4624 const Twine &NameStr =
"",
4631 return I->getOpcode() == SExt;
4634 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4654 const Twine &NameStr =
"",
4661 return I->getOpcode() == FPTrunc;
4664 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4685 const Twine &NameStr =
"",
4692 return I->getOpcode() == FPExt;
4695 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4716 const Twine &NameStr =
"",
4723 return I->getOpcode() == UIToFP;
4726 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4747 const Twine &NameStr =
"",
4754 return I->getOpcode() == SIToFP;
4757 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4778 const Twine &NameStr =
"",
4785 return I->getOpcode() == FPToUI;
4788 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4809 const Twine &NameStr =
"",
4816 return I->getOpcode() == FPToSI;
4819 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4836 const Twine &NameStr =
"",
4851 return I->getOpcode() == IntToPtr;
4854 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4875 const Twine &NameStr =
"",
4894 return I->getOpcode() == PtrToInt;
4897 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4918 const Twine &NameStr =
"",
4925 return I->getOpcode() == BitCast;
4928 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4951 const Twine &NameStr =
"",
4958 return I->getOpcode() == AddrSpaceCast;
4961 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4997 if (
auto *Load = dyn_cast<LoadInst>(V))
4998 return Load->getPointerOperand();
4999 if (
auto *Store = dyn_cast<StoreInst>(V))
5000 return Store->getPointerOperand();
5004 return const_cast<Value *
>(
5013 if (
auto *Gep = dyn_cast<GetElementPtrInst>(V))
5014 return Gep->getPointerOperand();
5023 assert((isa<LoadInst>(
I) || isa<StoreInst>(
I)) &&
5024 "Expected Load or Store instruction");
5025 if (
auto *LI = dyn_cast<LoadInst>(
I))
5026 return LI->getAlign();
5027 return cast<StoreInst>(
I)->getAlign();
5032 assert((isa<LoadInst>(
I) || isa<StoreInst>(
I)) &&
5033 "Expected Load or Store instruction");
5034 if (
auto *LI = dyn_cast<LoadInst>(
I))
5035 LI->setAlignment(NewAlign);
5037 cast<StoreInst>(
I)->setAlignment(NewAlign);
5043 assert((isa<LoadInst>(
I) || isa<StoreInst>(
I)) &&
5044 "Expected Load or Store instruction");
5045 if (
auto *LI = dyn_cast<LoadInst>(
I))
5046 return LI->getPointerAddressSpace();
5047 return cast<StoreInst>(
I)->getPointerAddressSpace();
5052 assert((isa<LoadInst>(
I) || isa<StoreInst>(
I)) &&
5053 "Expected Load or Store instruction");
5054 if (
auto *LI = dyn_cast<LoadInst>(
I))
5055 return LI->getType();
5056 return cast<StoreInst>(
I)->getValueOperand()->getType();
5063 return std::nullopt;
5064 if (
auto *AI = dyn_cast<LoadInst>(
I))
5065 return AI->getSyncScopeID();
5066 if (
auto *AI = dyn_cast<StoreInst>(
I))
5067 return AI->getSyncScopeID();
5068 if (
auto *AI = dyn_cast<FenceInst>(
I))
5069 return AI->getSyncScopeID();
5070 if (
auto *AI = dyn_cast<AtomicCmpXchgInst>(
I))
5071 return AI->getSyncScopeID();
5072 if (
auto *AI = dyn_cast<AtomicRMWInst>(
I))
5073 return AI->getSyncScopeID();
5080 if (
auto *AI = dyn_cast<LoadInst>(
I))
5081 AI->setSyncScopeID(SSID);
5082 else if (
auto *AI = dyn_cast<StoreInst>(
I))
5083 AI->setSyncScopeID(SSID);
5084 else if (
auto *AI = dyn_cast<FenceInst>(
I))
5085 AI->setSyncScopeID(SSID);
5086 else if (
auto *AI = dyn_cast<AtomicCmpXchgInst>(
I))
5087 AI->setSyncScopeID(SSID);
5088 else if (
auto *AI = dyn_cast<AtomicRMWInst>(
I))
5089 AI->setSyncScopeID(SSID);
5114 return I->getOpcode() == Freeze;
5117 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
static bool isReverseMask(ArrayRef< int > M, EVT VT)
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Atomic ordering constants.
static const Function * getParent(const Value *V)
This file implements methods to test, set and extract typed bits from packed unsigned integers.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
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
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
This defines the Use class.
This file implements a map that provides insertion order iteration.
uint64_t IntrinsicInst * II
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
PowerPC Reduce CR logical Operation
StandardInstrumentations SI(Mod->getContext(), Debug, VerifyEach)
const SmallVectorImpl< MachineOperand > & Cond
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
static SymbolRef::Type getType(const Symbol *Sym)
Class for arbitrary precision integers.
This class represents a conversion between pointers from one address space to another.
const Value * getPointerOperand() const
Gets the pointer operand.
AddrSpaceCastInst * cloneImpl() const
Clone an identical AddrSpaceCastInst.
Value * getPointerOperand()
Gets the pointer operand.
static bool classof(const Instruction *I)
static bool classof(const Value *V)
unsigned getSrcAddressSpace() const
Returns the address space of the pointer operand.
unsigned getDestAddressSpace() const
Returns the address space of the result.
static unsigned getPointerOperandIndex()
Gets the operand index of the pointer operand.
an instruction to allocate memory on the stack
std::optional< TypeSize > getAllocationSizeInBits(const DataLayout &DL) const
Get allocation size in bits.
static bool classof(const Value *V)
bool isSwiftError() const
Return true if this alloca is used as a swifterror argument to a call.
void setSwiftError(bool V)
Specify whether this alloca is used to represent a swifterror.
bool isStaticAlloca() const
Return true if this alloca is in the entry block of the function and is a constant size.
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
void setAllocatedType(Type *Ty)
for use only in special circumstances that need to generically transform a whole instruction (eg: IR ...
static bool classof(const Instruction *I)
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.
AllocaInst * cloneImpl() const
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
bool isUsedWithInAlloca() const
Return true if this alloca is used as an inalloca argument to a call.
unsigned getAddressSpace() const
Return the address space for the allocation.
std::optional< TypeSize > getAllocationSize(const DataLayout &DL) const
Get allocation size in bytes.
bool isArrayAllocation() const
Return true if there is an allocation size parameter to the allocation instruction that is not 1.
void setAlignment(Align Align)
const Value * getArraySize() const
Get the number of elements allocated.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
An instruction that atomically checks whether a specified value is in a memory location,...
BoolBitfieldElementT< 0 > VolatileField
const Value * getCompareOperand() const
Value * getNewValOperand()
void setSyncScopeID(SyncScope::ID SSID)
Sets the synchronization scope ID of this cmpxchg instruction.
AtomicOrdering getMergedOrdering() const
Returns a single ordering which is at least as strong as both the success and failure orderings for t...
void setWeak(bool IsWeak)
bool isVolatile() const
Return true if this is a cmpxchg from a volatile memory location.
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
BoolBitfieldElementT< VolatileField::NextBit > WeakField
AtomicOrderingBitfieldElementT< SuccessOrderingField::NextBit > FailureOrderingField
Value * getCompareOperand()
void setFailureOrdering(AtomicOrdering Ordering)
Sets the failure ordering constraint of this cmpxchg instruction.
static bool isValidFailureOrdering(AtomicOrdering Ordering)
AtomicOrdering getFailureOrdering() const
Returns the failure ordering constraint of this cmpxchg instruction.
void setSuccessOrdering(AtomicOrdering Ordering)
Sets the success ordering constraint of this cmpxchg instruction.
AlignmentBitfieldElementT< FailureOrderingField::NextBit > AlignmentField
Value * getPointerOperand()
static AtomicOrdering getStrongestFailureOrdering(AtomicOrdering SuccessOrdering)
Returns the strongest permitted ordering on failure, given the desired ordering on success.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
AtomicCmpXchgInst * cloneImpl() const
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
const Value * getPointerOperand() const
static bool classof(const Value *V)
bool isWeak() const
Return true if this cmpxchg may spuriously fail.
void setAlignment(Align Align)
void setVolatile(bool V)
Specify whether this is a volatile cmpxchg.
static bool isValidSuccessOrdering(AtomicOrdering Ordering)
AtomicOrdering getSuccessOrdering() const
Returns the success ordering constraint of this cmpxchg instruction.
AtomicOrderingBitfieldElementT< WeakField::NextBit > SuccessOrderingField
static unsigned getPointerOperandIndex()
const Value * getNewValOperand() const
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this cmpxchg instruction.
static bool classof(const Instruction *I)
an instruction that atomically reads a memory location, combines it with another value,...
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
static bool isFPOperation(BinOp Op)
static unsigned getPointerOperandIndex()
bool isVolatile() const
Return true if this is a RMW on a volatile memory location.
void setVolatile(bool V)
Specify whether this is a volatile RMW or not.
BinOpBitfieldElement< AtomicOrderingField::NextBit > OperationField
BinOp
This enumeration lists the possible modifications atomicrmw can make.
@ USubCond
Subtract only if no unsigned overflow.
@ Min
*p = old <signed v ? old : v
@ USubSat
*p = usub.sat(old, v) usub.sat matches the behavior of llvm.usub.sat.
@ UIncWrap
Increment one up to a maximum value.
@ Max
*p = old >signed v ? old : v
@ UMin
*p = old <unsigned v ? old : v
@ FMin
*p = minnum(old, v) minnum matches the behavior of llvm.minnum.
@ UMax
*p = old >unsigned v ? old : v
@ FMax
*p = maxnum(old, v) maxnum matches the behavior of llvm.maxnum.
@ UDecWrap
Decrement one until a minimum value or zero.
AtomicOrderingBitfieldElementT< VolatileField::NextBit > AtomicOrderingField
void setSyncScopeID(SyncScope::ID SSID)
Sets the synchronization scope ID of this rmw instruction.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
Value * getPointerOperand()
void setOrdering(AtomicOrdering Ordering)
Sets the ordering constraint of this rmw instruction.
bool isFloatingPointOperation() const
static bool classof(const Instruction *I)
const Value * getPointerOperand() const
void setOperation(BinOp Operation)
static bool classof(const Value *V)
BinOp getOperation() const
const Value * getValOperand() const
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this rmw instruction.
void setAlignment(Align Align)
AtomicOrdering getOrdering() const
Returns the ordering constraint of this rmw instruction.
AlignmentBitfieldElementT< OperationField::NextBit > AlignmentField
BoolBitfieldElementT< 0 > VolatileField
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
LLVM Basic Block Representation.
This class represents a no-op cast from one type to another.
static bool classof(const Instruction *I)
static bool classof(const Value *V)
BitCastInst * cloneImpl() const
Clone an identical BitCastInst.
Conditional or Unconditional Branch instruction.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
iterator_range< succ_op_iterator > successors()
static BranchInst * Create(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, InsertPosition InsertBefore=nullptr)
void setCondition(Value *V)
static bool classof(const Instruction *I)
bool isConditional() const
unsigned getNumSuccessors() const
static bool classof(const Value *V)
static BranchInst * Create(BasicBlock *IfTrue, InsertPosition InsertBefore=nullptr)
BasicBlock * getSuccessor(unsigned i) const
bool isUnconditional() const
void setSuccessor(unsigned idx, BasicBlock *NewSucc)
Value * getCondition() const
iterator_range< const_succ_op_iterator > successors() const
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
void addFnAttr(Attribute::AttrKind Kind)
Adds the attribute to the function.
bool hasFnAttr(Attribute::AttrKind Kind) const
Determine whether this call has the given attribute.
Intrinsic::ID getIntrinsicID() const
Returns the intrinsic ID of the intrinsic called or Intrinsic::not_intrinsic if the called function i...
static unsigned CountBundleInputs(ArrayRef< OperandBundleDef > Bundles)
Return the total number of values used in Bundles.
unsigned arg_size() const
unsigned getNumTotalBundleOperands() const
Return the total number operands (not operand bundles) used by every operand bundle in this OperandBu...
CallBr instruction, tracking function calls that may not return control but instead transfer it to a ...
static bool classof(const Value *V)
static CallBrInst * Create(FunctionType *Ty, Value *Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static bool classof(const Instruction *I)
static CallBrInst * Create(FunctionCallee Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
SmallVector< BasicBlock *, 16 > getIndirectDests() const
static CallBrInst * Create(FunctionCallee Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)
void setSuccessor(unsigned i, BasicBlock *NewSucc)
BasicBlock * getSuccessor(unsigned i) const
Value * getIndirectDestLabelUse(unsigned i) const
BasicBlock * getIndirectDest(unsigned i) const
void setDefaultDest(BasicBlock *B)
unsigned getNumSuccessors() const
void setIndirectDest(unsigned i, BasicBlock *B)
Value * getIndirectDestLabel(unsigned i) const
getIndirectDestLabel - Return the i-th indirect dest label.
BasicBlock * getDefaultDest() const
unsigned getNumIndirectDests() const
Return the number of callbr indirect dest labels.
static CallBrInst * Create(FunctionType *Ty, Value *Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)
CallBrInst * cloneImpl() const
This class represents a function call, abstracting a target machine's calling convention.
bool isNoTailCall() const
void updateProfWeight(uint64_t S, uint64_t T)
Updates profile metadata by scaling it by S / T.
static bool classof(const Value *V)
void setTailCallKind(TailCallKind TCK)
static CallInst * Create(FunctionType *Ty, Value *Func, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static CallInst * Create(FunctionType *Ty, Value *Func, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)
bool canReturnTwice() const
Return true if the call can return twice.
TailCallKind getTailCallKind() const
CallInst * cloneImpl() const
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
void setTailCall(bool IsTc=true)
bool isMustTailCall() const
static CallInst * Create(FunctionCallee Func, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)
static bool classof(const Instruction *I)
bool isNonContinuableTrap() const
Return true if the call is for a noreturn trap intrinsic.
static CallInst * Create(FunctionCallee Func, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static CallInst * Create(FunctionCallee Func, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
This is the base class for all instructions that perform data casts.
CatchSwitchInst * getCatchSwitch() const
Convenience accessors.
void setCatchSwitch(Value *CatchSwitch)
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
static CatchPadInst * Create(Value *CatchSwitch, ArrayRef< Value * > Args, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static bool classof(const Value *V)
static bool classof(const Instruction *I)
BasicBlock * getSuccessor() const
CatchPadInst * getCatchPad() const
Convenience accessors.
void setSuccessor(BasicBlock *NewSucc)
static bool classof(const Value *V)
static CatchReturnInst * Create(Value *CatchPad, BasicBlock *BB, InsertPosition InsertBefore=nullptr)
unsigned getNumSuccessors() const
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
void setCatchPad(CatchPadInst *CatchPad)
CatchReturnInst * cloneImpl() const
Value * getCatchSwitchParentPad() const
Get the parentPad of this catchret's catchpad's catchswitch.
void setUnwindDest(BasicBlock *UnwindDest)
static bool classof(const Instruction *I)
BasicBlock *(*)(Value *) DerefFnTy
const BasicBlock *(*)(const Value *) ConstDerefFnTy
unsigned getNumSuccessors() const
const_handler_iterator handler_begin() const
Returns an iterator that points to the first handler in the CatchSwitchInst.
unsigned getNumHandlers() const
return the number of 'handlers' in this catchswitch instruction, except the default handler
void setSuccessor(unsigned Idx, BasicBlock *NewSucc)
Value * getParentPad() const
void setParentPad(Value *ParentPad)
bool unwindsToCaller() const
static bool classof(const Value *V)
handler_iterator handler_end()
Returns a read-only iterator that points one past the last handler in the CatchSwitchInst.
BasicBlock * getUnwindDest() const
BasicBlock * getSuccessor(unsigned Idx) const
const_handler_iterator handler_end() const
Returns an iterator that points one past the last handler in the CatchSwitchInst.
bool hasUnwindDest() const
handler_iterator handler_begin()
Returns an iterator that points to the first handler in CatchSwitchInst.
static CatchSwitchInst * Create(Value *ParentPad, BasicBlock *UnwindDest, unsigned NumHandlers, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
handler_range handlers()
iteration adapter for range-for loops.
const_handler_range handlers() const
iteration adapter for range-for loops.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
static bool classof(const Value *V)
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
static CleanupPadInst * Create(Value *ParentPad, ArrayRef< Value * > Args={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static bool classof(const Instruction *I)
CleanupPadInst * getCleanupPad() const
Convenience accessor.
unsigned getNumSuccessors() const
BasicBlock * getUnwindDest() const
bool unwindsToCaller() const
void setCleanupPad(CleanupPadInst *CleanupPad)
static bool classof(const Value *V)
void setUnwindDest(BasicBlock *NewDest)
static CleanupReturnInst * Create(Value *CleanupPad, BasicBlock *UnwindBB=nullptr, InsertPosition InsertBefore=nullptr)
bool hasUnwindDest() const
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
This class is the base class for the comparison instructions.
static Type * makeCmpResultType(Type *opnd_type)
Create a result type for fcmp/icmp.
void setPredicate(Predicate P)
Set the predicate for this instruction to the specified value.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
@ FCMP_OEQ
0 0 0 1 True if ordered and equal
@ FCMP_TRUE
1 1 1 1 Always true (always folded)
@ FCMP_ONE
0 1 1 0 True if ordered and operands are unequal
@ FCMP_UEQ
1 0 0 1 True if unordered or equal
@ FCMP_ORD
0 1 1 1 True if ordered (no nans)
@ FCMP_UNE
1 1 1 0 True if unordered or not equal
@ FCMP_FALSE
0 0 0 0 Always false (always folded)
@ FCMP_UNO
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
Predicate getSwappedPredicate() const
For example, EQ->EQ, SLE->SGE, ULT->UGT, OEQ->OEQ, ULE->UGE, OLT->OGT, etc.
static auto FCmpPredicates()
Returns the sequence of all FCmp predicates.
bool isFPPredicate() const
Predicate getPredicate() const
Return the predicate for this instruction.
An abstraction over a floating-point predicate, and a pack of an integer predicate with samesign info...
bool hasSameSign() const
Query samesign information, for optimizations.
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.
This instruction compares its operands according to the predicate given to the constructor.
bool isRelational() const
FCmpInst(Predicate Pred, Value *LHS, Value *RHS, const Twine &NameStr="", Instruction *FlagsSource=nullptr)
Constructor with no-insertion semantics.
static bool classof(const Value *V)
bool isCommutative() const
static bool isCommutative(Predicate Pred)
static bool compare(const APFloat &LHS, const APFloat &RHS, FCmpInst::Predicate Pred)
Return result of LHS Pred RHS comparison.
static bool isEquality(Predicate Pred)
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
static auto predicates()
Returns the sequence of all FCmp predicates.
FCmpInst * cloneImpl() const
Clone an identical FCmpInst.
void swapOperands()
Exchange the two operands to this instruction in such a way that it does not modify the semantics of ...
FCmpInst(InsertPosition InsertBefore, Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
Constructor with insertion semantics.
This class represents an extension of floating point types.
static bool classof(const Value *V)
FPExtInst * cloneImpl() const
Clone an identical FPExtInst.
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
This class represents a cast from floating point to signed integer.
static bool classof(const Value *V)
FPToSIInst * cloneImpl() const
Clone an identical FPToSIInst.
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
This class represents a cast from floating point to unsigned integer.
static bool classof(const Value *V)
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
FPToUIInst * cloneImpl() const
Clone an identical FPToUIInst.
This class represents a truncation of floating point types.
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const Value *V)
FPTruncInst * cloneImpl() const
Clone an identical FPTruncInst.
An instruction for ordering other memory operations.
static bool classof(const Value *V)
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this fence instruction.
void setSyncScopeID(SyncScope::ID SSID)
Sets the synchronization scope ID of this fence instruction.
static bool classof(const Instruction *I)
void setOrdering(AtomicOrdering Ordering)
Sets the ordering constraint of this fence instruction.
AtomicOrdering getOrdering() const
Returns the ordering constraint of this fence instruction.
This class represents a freeze function that returns random concrete value if an operand is either a ...
static bool classof(const Value *V)
FreezeInst * cloneImpl() const
Clone an identical FreezeInst.
static bool classof(const Instruction *I)
friend class CatchPadInst
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
Class to represent function types.
Represents flags for the getelementptr instruction/expression.
static GEPNoWrapFlags inBounds()
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
bool isInBounds() const
Determine whether the GEP has the inbounds flag.
bool hasNoUnsignedSignedWrap() const
Determine whether the GEP has the nusw flag.
static Type * getTypeAtIndex(Type *Ty, Value *Idx)
Return the type of the element at the given index of an indexable type.
Value * getPointerOperand()
bool hasAllZeroIndices() const
Return true if all of the indices of this GEP are zeros.
static Type * getGEPReturnType(Value *Ptr, ArrayRef< Value * > IdxList)
Returns the pointer type returned by the GEP instruction, which may be a vector of pointers.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
void setResultElementType(Type *Ty)
bool hasNoUnsignedWrap() const
Determine whether the GEP has the nuw flag.
bool hasAllConstantIndices() const
Return true if all of the indices of this GEP are constant integers.
unsigned getAddressSpace() const
Returns the address space of this instruction's pointer type.
iterator_range< const_op_iterator > indices() const
Type * getResultElementType() const
static bool classof(const Instruction *I)
static bool classof(const Value *V)
iterator_range< op_iterator > indices()
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
void setIsInBounds(bool b=true)
Set or clear the inbounds flag on this GEP instruction.
void setSourceElementType(Type *Ty)
static Type * getIndexedType(Type *Ty, ArrayRef< Value * > IdxList)
Returns the result type of a getelementptr with the given source element type and indexes.
Type * getSourceElementType() const
static GetElementPtrInst * CreateInBounds(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Create an "inbounds" getelementptr.
Type * getPointerOperandType() const
Method to return the pointer operand as a PointerType.
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, GEPNoWrapFlags NW, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static unsigned getPointerOperandIndex()
bool accumulateConstantOffset(const DataLayout &DL, APInt &Offset) const
Accumulate the constant address offset of this GEP if possible.
const_op_iterator idx_begin() const
GetElementPtrInst * cloneImpl() const
bool collectOffset(const DataLayout &DL, unsigned BitWidth, SmallMapVector< Value *, APInt, 4 > &VariableOffsets, APInt &ConstantOffset) const
void setNoWrapFlags(GEPNoWrapFlags NW)
Set nowrap flags for GEP instruction.
unsigned getNumIndices() const
GEPNoWrapFlags getNoWrapFlags() const
Get the nowrap flags for the GEP instruction.
const_op_iterator idx_end() const
const Value * getPointerOperand() const
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
This instruction compares its operands according to the predicate given to the constructor.
bool hasSameSign() const
An icmp instruction, which can be marked as "samesign", indicating that the two operands have the sam...
static bool classof(const Value *V)
void setSameSign(bool B=true)
ICmpInst(InsertPosition InsertBefore, Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
Constructor with insertion semantics.
static bool isCommutative(Predicate P)
static CmpPredicate getSwappedCmpPredicate(CmpPredicate Pred)
CmpPredicate getCmpPredicate() const
bool isCommutative() const
static bool isGE(Predicate P)
Return true if the predicate is SGE or UGE.
CmpPredicate getSwappedCmpPredicate() const
static bool isLT(Predicate P)
Return true if the predicate is SLT or ULT.
CmpPredicate getInverseCmpPredicate() const
Predicate getNonStrictCmpPredicate() const
For example, SGT -> SGE, SLT -> SLE, ULT -> ULE, UGT -> UGE.
static bool isGT(Predicate P)
Return true if the predicate is SGT or UGT.
static bool classof(const Instruction *I)
Predicate getFlippedSignednessPredicate() const
For example, SLT->ULT, ULT->SLT, SLE->ULE, ULE->SLE, EQ->EQ.
static CmpPredicate getNonStrictCmpPredicate(CmpPredicate Pred)
Predicate getSignedPredicate() const
For example, EQ->EQ, SLE->SLE, UGT->SGT, etc.
static CmpPredicate getInverseCmpPredicate(CmpPredicate Pred)
bool isEquality() const
Return true if this predicate is either EQ or NE.
static bool isEquality(Predicate P)
Return true if this predicate is either EQ or NE.
static bool isRelational(Predicate P)
Return true if the predicate is relational (not EQ or NE).
void swapOperands()
Exchange the two operands to this instruction in such a way that it does not modify the semantics of ...
static auto predicates()
Returns the sequence of all ICmp predicates.
ICmpInst(Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
Constructor with no-insertion semantics.
bool isRelational() const
Return true if the predicate is relational (not EQ or NE).
Predicate getUnsignedPredicate() const
For example, EQ->EQ, SLE->ULE, UGT->UGT, etc.
static bool isLE(Predicate P)
Return true if the predicate is SLE or ULE.
Indirect Branch Instruction.
static IndirectBrInst * Create(Value *Address, unsigned NumDests, InsertPosition InsertBefore=nullptr)
BasicBlock * getDestination(unsigned i)
Return the specified destination.
static bool classof(const Value *V)
const Value * getAddress() const
static bool classof(const Instruction *I)
BasicBlock * getSuccessor(unsigned i) const
iterator_range< const_succ_op_iterator > successors() const
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
unsigned getNumDestinations() const
return the number of possible destinations in this indirectbr instruction.
const BasicBlock * getDestination(unsigned i) const
void setSuccessor(unsigned i, BasicBlock *NewSucc)
void setAddress(Value *V)
unsigned getNumSuccessors() const
iterator_range< succ_op_iterator > successors()
This instruction inserts a single (scalar) element into a VectorType value.
static bool classof(const Value *V)
static InsertElementInst * Create(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
VectorType * getType() const
Overload to return most specific vector type.
static bool classof(const Instruction *I)
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
This instruction inserts a struct field of array element value into an aggregate value.
Value * getInsertedValueOperand()
static bool classof(const Instruction *I)
static unsigned getAggregateOperandIndex()
Value * getAggregateOperand()
static bool classof(const Value *V)
unsigned getNumIndices() const
ArrayRef< unsigned > getIndices() const
iterator_range< idx_iterator > indices() const
static unsigned getInsertedValueOperandIndex()
InsertValueInst * cloneImpl() const
idx_iterator idx_end() const
static InsertValueInst * Create(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
const Value * getAggregateOperand() const
const Value * getInsertedValueOperand() const
idx_iterator idx_begin() const
typename Bitfield::Element< AtomicOrdering, Offset, 3, AtomicOrdering::LAST > AtomicOrderingBitfieldElementT
typename Bitfield::Element< bool, Offset, 1 > BoolBitfieldElementT
bool isAtomic() const LLVM_READONLY
Return true if this instruction has an AtomicOrdering of unordered or higher.
typename Bitfield::Element< unsigned, Offset, 6, Value::MaxAlignmentExponent > AlignmentBitfieldElementT
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
void copyMetadata(const Instruction &SrcInst, ArrayRef< unsigned > WL=ArrayRef< unsigned >())
Copy metadata from SrcInst to this instruction.
friend class BasicBlock
Various leaf nodes.
This class represents a cast from an integer to a pointer.
static bool classof(const Instruction *I)
IntToPtrInst * cloneImpl() const
Clone an identical IntToPtrInst.
unsigned getAddressSpace() const
Returns the address space of this instruction's pointer type.
static bool classof(const Value *V)
static bool classof(const Instruction *I)
BasicBlock * getUnwindDest() const
void setNormalDest(BasicBlock *B)
static bool classof(const Value *V)
static InvokeInst * Create(FunctionCallee Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)
void setSuccessor(unsigned i, BasicBlock *NewSucc)
static InvokeInst * Create(FunctionCallee Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
BasicBlock * getSuccessor(unsigned i) const
void setUnwindDest(BasicBlock *B)
BasicBlock * getNormalDest() const
static InvokeInst * Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
unsigned getNumSuccessors() const
static InvokeInst * Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)
This is an important class for using LLVM in a threaded context.
The landingpad instruction holds all of the information necessary to generate correct exception handl...
bool isCleanup() const
Return 'true' if this landingpad instruction is a cleanup.
unsigned getNumClauses() const
Get the number of clauses for this landing pad.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
bool isCatch(unsigned Idx) const
Return 'true' if the clause and index Idx is a catch clause.
bool isFilter(unsigned Idx) const
Return 'true' if the clause and index Idx is a filter clause.
Constant * getClause(unsigned Idx) const
Get the value of the clause at index Idx.
static bool classof(const Value *V)
void setCleanup(bool V)
Indicate that this landingpad instruction is a cleanup.
void reserveClauses(unsigned Size)
Grow the size of the operand list to accommodate the new number of clauses.
static bool classof(const Instruction *I)
An instruction for reading from memory.
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
const Value * getPointerOperand() const
void setAlignment(Align Align)
Value * getPointerOperand()
bool isVolatile() const
Return true if this is a load from a volatile memory location.
static bool classof(const Instruction *I)
void setOrdering(AtomicOrdering Ordering)
Sets the ordering constraint of this load instruction.
static bool classof(const Value *V)
void setSyncScopeID(SyncScope::ID SSID)
Sets the synchronization scope ID of this load instruction.
void setAtomic(AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System)
Sets the ordering constraint and the synchronization scope ID of this load instruction.
LoadInst * cloneImpl() const
AtomicOrdering getOrdering() const
Returns the ordering constraint of this load instruction.
Type * getPointerOperandType() const
static unsigned getPointerOperandIndex()
void setVolatile(bool V)
Specify whether this is a volatile load or not.
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this load instruction.
Align getAlign() const
Return the alignment of the access that is being performed.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
BasicBlock * getIncomingBlock(Value::const_user_iterator I) const
Return incoming basic block corresponding to value use iterator.
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
bool isComplete() const
If the PHI node is complete which means all of its parent's predecessors have incoming value in this ...
iterator_range< const_block_iterator > blocks() const
op_range incoming_values()
static bool classof(const Value *V)
void allocHungoffUses(unsigned N)
const_block_iterator block_begin() const
void setIncomingValueForBlock(const BasicBlock *BB, Value *V)
Set every incoming value(s) for block BB to V.
void setIncomingBlock(unsigned i, BasicBlock *BB)
BasicBlock *const * const_block_iterator
void setIncomingValue(unsigned i, Value *V)
static unsigned getOperandNumForIncomingValue(unsigned i)
void copyIncomingBlocks(iterator_range< const_block_iterator > BBRange, uint32_t ToIdx=0)
Copies the basic blocks from BBRange to the incoming basic block list of this PHINode,...
const_block_iterator block_end() const
Value * getIncomingValueForBlock(const BasicBlock *BB) const
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
static unsigned getIncomingValueNumForOperand(unsigned i)
const_op_range incoming_values() const
Value * removeIncomingValue(const BasicBlock *BB, bool DeletePHIIfEmpty=true)
void replaceIncomingBlockWith(const BasicBlock *Old, BasicBlock *New)
Replace every incoming basic block Old to basic block New.
BasicBlock * getIncomingBlock(const Use &U) const
Return incoming basic block corresponding to an operand of the PHI.
int getBasicBlockIndex(const BasicBlock *BB) const
Return the first index of the specified basic block in the value list for this PHI.
unsigned getNumIncomingValues() const
Return the number of incoming edges.
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
Class to represent pointers.
unsigned getAddressSpace() const
Return the address space of the Pointer type.
This class represents a cast from a pointer to an integer.
Value * getPointerOperand()
Gets the pointer operand.
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
static bool classof(const Value *V)
const Value * getPointerOperand() const
Gets the pointer operand.
static unsigned getPointerOperandIndex()
Gets the operand index of the pointer operand.
static bool classof(const Instruction *I)
PtrToIntInst * cloneImpl() const
Clone an identical PtrToIntInst.
Resume the propagation of an exception.
static ResumeInst * Create(Value *Exn, InsertPosition InsertBefore=nullptr)
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
Value * getValue() const
Convenience accessor.
static bool classof(const Value *V)
unsigned getNumSuccessors() const
ResumeInst * cloneImpl() const
static bool classof(const Instruction *I)
Return a value (possibly void), from a function.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
unsigned getNumSuccessors() const
static bool classof(const Value *V)
static bool classof(const Instruction *I)
static ReturnInst * Create(LLVMContext &C, BasicBlock *InsertAtEnd)
Value * getReturnValue() const
Convenience accessor. Returns null if there is no return value.
static ReturnInst * Create(LLVMContext &C, Value *retVal=nullptr, InsertPosition InsertBefore=nullptr)
This class represents a sign extension of integer types.
static bool classof(const Value *V)
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
SExtInst * cloneImpl() const
Clone an identical SExtInst.
This class represents a cast from signed integer to floating point.
SIToFPInst * cloneImpl() const
Clone an identical SIToFPInst.
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const Value *V)
This class represents the LLVM 'select' instruction.
static SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr="", InsertPosition InsertBefore=nullptr, Instruction *MDFrom=nullptr)
void setFalseValue(Value *V)
const Value * getFalseValue() const
void setTrueValue(Value *V)
OtherOps getOpcode() const
void swapValues()
Swap the true and false values of the select instruction.
const Value * getCondition() const
SelectInst * cloneImpl() const
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
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 *V)
void setCondition(Value *V)
const Value * getTrueValue() const
static bool classof(const Instruction *I)
This instruction constructs a fixed permutation of two input vectors.
static bool classof(const Value *V)
static bool isInterleaveMask(ArrayRef< int > Mask, unsigned Factor, unsigned NumInputElts)
Constant * getShuffleMaskForBitcode() const
Return the mask for this instruction, for use in bitcode.
bool isSingleSource() const
Return true if this shuffle chooses elements from exactly one source vector without changing the leng...
bool changesLength() const
Return true if this shuffle returns a vector with a different number of elements than its source vect...
bool isExtractSubvectorMask(int &Index) const
Return true if this shuffle mask is an extract subvector mask.
ArrayRef< int > getShuffleMask() const
static bool isInsertSubvectorMask(const Constant *Mask, int NumSrcElts, int &NumSubElts, int &Index)
static bool isSingleSourceMask(const Constant *Mask, int NumSrcElts)
int getMaskValue(unsigned Elt) const
Return the shuffle mask value of this instruction for the given element index.
void getShuffleMask(SmallVectorImpl< int > &Result) const
Return the mask for this instruction as a vector of integers.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
static bool isDeInterleaveMaskOfFactor(ArrayRef< int > Mask, unsigned Factor)
VectorType * getType() const
Overload to return most specific vector type.
bool isInsertSubvectorMask(int &NumSubElts, int &Index) const
Return true if this shuffle mask is an insert subvector mask.
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 isExtractSubvectorMask(const Constant *Mask, int NumSrcElts, int &Index)
bool isSelect() const
Return true if this shuffle chooses elements from its source vectors without lane crossings and all o...
static bool isSpliceMask(const Constant *Mask, int NumSrcElts, int &Index)
bool isTranspose() const
Return true if this shuffle transposes the elements of its inputs without changing the length of the ...
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 isSplice(int &Index) const
Return true if this shuffle splices two inputs without changing the length of the vectors.
static bool isReverseMask(const Constant *Mask, int NumSrcElts)
static bool isSelectMask(const Constant *Mask, int NumSrcElts)
static bool classof(const Instruction *I)
static bool isZeroEltSplatMask(const Constant *Mask, int NumSrcElts)
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 isTransposeMask(const Constant *Mask, int NumSrcElts)
bool isReverse() const
Return true if this shuffle swaps the order of elements from exactly one source vector.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
static bool classof(const Instruction *I)
AtomicOrdering getOrdering() const
Returns the ordering constraint of this store instruction.
const Value * getPointerOperand() const
Type * getPointerOperandType() const
void setVolatile(bool V)
Specify whether this is a volatile store or not.
void setAlignment(Align Align)
const Value * getValueOperand() const
void setOrdering(AtomicOrdering Ordering)
Sets the ordering constraint of this store instruction.
Value * getValueOperand()
static bool classof(const Value *V)
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
void setSyncScopeID(SyncScope::ID SSID)
Sets the synchronization scope ID of this store instruction.
StoreInst * cloneImpl() const
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
static unsigned getPointerOperandIndex()
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this store instruction.
bool isVolatile() const
Return true if this is a store to a volatile memory location.
Value * getPointerOperand()
void setAtomic(AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System)
Sets the ordering constraint and the synchronization scope ID of this store instruction.
StringRef - Represent a constant reference to a string, i.e.
A wrapper class to simplify modification of SwitchInst cases along with their prof branch_weights met...
void setSuccessorWeight(unsigned idx, CaseWeightOpt W)
Instruction::InstListType::iterator eraseFromParent()
Delegate the call to the underlying SwitchInst::eraseFromParent() and mark this object to not touch t...
void addCase(ConstantInt *OnVal, BasicBlock *Dest, CaseWeightOpt W)
Delegate the call to the underlying SwitchInst::addCase() and set the specified branch weight for the...
SwitchInstProfUpdateWrapper(SwitchInst &SI)
~SwitchInstProfUpdateWrapper()
CaseWeightOpt getSuccessorWeight(unsigned idx)
MDNode * buildProfBranchWeightsMD()
std::optional< uint32_t > CaseWeightOpt
SwitchInst * operator->()
SwitchInst::CaseIt removeCase(SwitchInst::CaseIt I)
Delegate the call to the underlying SwitchInst::removeCase() and remove correspondent branch weight.
A handle to a particular switch case.
unsigned getCaseIndex() const
Returns number of current case.
unsigned getSuccessorIndex() const
Returns successor index for current case successor.
BasicBlockT * getCaseSuccessor() const
Resolves successor for current case.
CaseHandleImpl(SwitchInstT *SI, ptrdiff_t Index)
bool operator==(const CaseHandleImpl &RHS) const
ConstantIntT * getCaseValue() const
Resolves case value for current case.
SwitchInstT SwitchInstType
CaseHandle(SwitchInst *SI, ptrdiff_t Index)
void setValue(ConstantInt *V) const
Sets the new value for current case.
void setSuccessor(BasicBlock *S) const
Sets the new successor for current case.
const CaseHandleT & operator*() const
CaseIteratorImpl()=default
Default constructed iterator is in an invalid state until assigned to a case for a particular switch.
CaseIteratorImpl & operator-=(ptrdiff_t N)
bool operator==(const CaseIteratorImpl &RHS) const
CaseIteratorImpl & operator+=(ptrdiff_t N)
ptrdiff_t operator-(const CaseIteratorImpl &RHS) const
bool operator<(const CaseIteratorImpl &RHS) const
CaseIteratorImpl(SwitchInstT *SI, unsigned CaseNum)
Initializes case iterator for given SwitchInst and for given case number.
static CaseIteratorImpl fromSuccessorIndex(SwitchInstT *SI, unsigned SuccessorIndex)
Initializes case iterator for given SwitchInst and for given successor index.
BasicBlock * getDefaultDest() const
CaseIt case_end()
Returns a read/write iterator that points one past the last in the SwitchInst.
BasicBlock * getSuccessor(unsigned idx) const
ConstCaseIt findCaseValue(const ConstantInt *C) const
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
static SwitchInst * Create(Value *Value, BasicBlock *Default, unsigned NumCases, InsertPosition InsertBefore=nullptr)
void setCondition(Value *V)
ConstCaseIt case_begin() const
Returns a read-only iterator that points to the first case in the SwitchInst.
bool defaultDestUndefined() const
Returns true if the default branch must result in immediate undefined behavior, false otherwise.
iterator_range< ConstCaseIt > cases() const
Constant iteration adapter for range-for loops.
ConstantInt * findCaseDest(BasicBlock *BB)
Finds the unique case value for a given successor.
void setSuccessor(unsigned idx, BasicBlock *NewSucc)
static bool classof(const Value *V)
unsigned getNumSuccessors() const
CaseIt case_default()
Returns an iterator that points to the default case.
void setDefaultDest(BasicBlock *DefaultCase)
unsigned getNumCases() const
Return the number of 'cases' in this switch instruction, excluding the default case.
CaseIt findCaseValue(const ConstantInt *C)
Search all of the case values for the specified constant.
Value * getCondition() const
ConstCaseIt case_default() const
CaseIt case_begin()
Returns a read/write iterator that points to the first case in the SwitchInst.
static bool classof(const Instruction *I)
iterator_range< CaseIt > cases()
Iteration adapter for range-for loops.
ConstCaseIt case_end() const
Returns a read-only iterator that points one past the last in the SwitchInst.
This class represents a truncation of integer types.
void setHasNoSignedWrap(bool B)
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
TruncInst * cloneImpl() const
Clone an identical TruncInst.
void setHasNoUnsignedWrap(bool B)
unsigned getNoWrapKind() const
Returns the no-wrap kind of the operation.
bool hasNoSignedWrap() const
Test whether this operation is known to never undergo signed overflow, aka the nsw property.
static bool classof(const Value *V)
bool hasNoUnsignedWrap() const
Test whether this operation is known to never undergo unsigned overflow, aka the nuw property.
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.
bool isVectorTy() const
True if this is an instance of VectorType.
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
bool isTokenTy() const
Return true if this is 'token'.
This class represents a cast unsigned integer to floating point.
static bool classof(const Value *V)
UIToFPInst * cloneImpl() const
Clone an identical UIToFPInst.
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
This function has undefined behavior.
unsigned getNumSuccessors() const
static bool classof(const Value *V)
static bool classof(const Instruction *I)
A Use represents the edge between a Value definition and its users.
void allocHungoffUses(unsigned N, bool IsPhi=false)
Allocate the array of Uses, followed by a pointer (with bottom bit set) to the User.
const Use & getOperandUse(unsigned i) const
Value * getOperand(unsigned i) const
unsigned getNumOperands() const
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
static bool classof(const Instruction *I)
Value * getPointerOperand()
VAArgInst(Value *List, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
const Value * getPointerOperand() const
static bool classof(const Value *V)
static unsigned getPointerOperandIndex()
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
user_iterator_impl< const User > const_user_iterator
unsigned char SubclassOptionalData
Hold subclass data that can be dropped.
void setName(const Twine &Name)
Change the name of the value.
Base class of all SIMD vector types.
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
This class represents zero extension of integer types.
static bool classof(const Instruction *I)
Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const Value *V)
ZExtInst * cloneImpl() const
Clone an identical ZExtInst.
An efficient, type-erasing, non-owning reference to a callable.
base_list_type::iterator iterator
CRTP base class for adapting an iterator to a different type.
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
A range adaptor for a pair of iterators.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
@ C
The default llvm calling convention, compatible with C.
@ BasicBlock
Various leaf nodes.
@ System
Synchronized with respect to all concurrently executing threads.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
Type * checkGEPType(Type *Ty)
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
unsigned getLoadStoreAddressSpace(const Value *I)
A helper function that returns the address space of the pointer operand of load or store instruction.
APInt operator*(APInt a, uint64_t RHS)
const Value * getLoadStorePointerOperand(const Value *V)
A helper function that returns the pointer operand of a load or store instruction.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
void setAtomicSyncScopeID(Instruction *I, SyncScope::ID SSID)
A helper function that sets an atomic operation's sync scope.
Align getLoadStoreAlignment(const Value *I)
A helper function that returns the alignment of load or store instruction.
const Value * getPointerOperand(const Value *V)
A helper function that returns the pointer operand of a load, store or GEP instruction.
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
std::optional< SyncScope::ID > getAtomicSyncScopeID(const Instruction *I)
A helper function that returns an atomic operation's sync scope; returns std::nullopt if it is not an...
constexpr int PoisonMaskElem
AtomicOrdering
Atomic ordering for LLVM's memory model.
DWARFExpression::Operation Op
OutputIt copy(R &&Range, OutputIt Out)
constexpr unsigned BitWidth
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
auto predecessors(const MachineBasicBlock *BB)
Type * getLoadStoreType(const Value *I)
A helper function that returns the type of a load or store instruction.
void setLoadStoreAlignment(Value *I, Align NewAlign)
A helper function that set the alignment of load or store instruction.
unsigned Log2(Align A)
Returns the log2 of the alignment.
@ Default
The result values are uniform if and only if all operands are uniform.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Summary of memprof metadata on allocations.
Describes an element of a Bitfield.
static constexpr bool areContiguous()
The const version of succ_op_iterator.
const BasicBlock * operator->() const
const_succ_op_iterator(const_value_op_iterator I)
const BasicBlock * operator*() const
Iterator type that casts an operand to a basic block.
BasicBlock * operator->() const
succ_op_iterator(value_op_iterator I)
BasicBlock * operator*() const
FixedNumOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
HungoffOperandTraits - determine the allocation regime of the Use array when it is not a prefix to th...
The const version of succ_op_iterator.
const BasicBlock * operator*() const
const_succ_op_iterator(const_value_op_iterator I)
const BasicBlock * operator->() const
Iterator type that casts an operand to a basic block.
BasicBlock * operator*() const
succ_op_iterator(value_op_iterator I)
BasicBlock * operator->() const
Compile-time customization of User operands.
A MapVector that performs no allocations if smaller than a certain size.
Information about how a User object was allocated, to be passed into the User constructor.
Indicates this User has operands "hung off" in another allocation.
Indicates this User has operands co-allocated.
Iterator for directly iterating over the operand Values.
VariadicOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...