15#ifndef LLVM_IR_INSTRUCTIONS_H
16#define LLVM_IR_INSTRUCTIONS_H
67 "Bitfields must be contiguous");
133 return Align(1ULL << getSubclassData<AlignmentField>());
137 setSubclassData<AlignmentField>(
Log2(
Align));
148 return getSubclassData<UsedWithInAllocaField>();
153 setSubclassData<UsedWithInAllocaField>(V);
157 bool isSwiftError()
const {
return getSubclassData<SwiftErrorField>(); }
163 return (
I->getOpcode() == Instruction::Alloca);
166 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
172 template <
typename Bitfield>
173 void setSubclassData(
typename Bitfield::Type
Value) {
174 Instruction::setSubclassData<Bitfield>(
Value);
189 Bitfield::areContiguous<VolatileField, AlignmentField, OrderingField>(),
190 "Bitfields must be contiguous");
230 bool isVolatile()
const {
return getSubclassData<VolatileField>(); }
237 return Align(1ULL << (getSubclassData<AlignmentField>()));
241 setSubclassData<AlignmentField>(
Log2(
Align));
246 return getSubclassData<OrderingField>();
251 setSubclassData<OrderingField>(Ordering);
292 return I->getOpcode() == Instruction::Load;
295 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
301 template <
typename Bitfield>
302 void setSubclassData(
typename Bitfield::Type
Value) {
303 Instruction::setSubclassData<Bitfield>(
Value);
322 Bitfield::areContiguous<VolatileField, AlignmentField, OrderingField>(),
323 "Bitfields must be contiguous");
357 void *
operator new(
size_t S) {
return User::operator
new(S, 2); }
358 void operator delete(
void *
Ptr) { User::operator
delete(
Ptr); }
361 bool isVolatile()
const {
return getSubclassData<VolatileField>(); }
370 return Align(1ULL << (getSubclassData<AlignmentField>()));
374 setSubclassData<AlignmentField>(
Log2(
Align));
379 return getSubclassData<OrderingField>();
385 setSubclassData<OrderingField>(Ordering);
429 return I->getOpcode() == Instruction::Store;
432 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
438 template <
typename Bitfield>
439 void setSubclassData(
typename Bitfield::Type
Value) {
440 Instruction::setSubclassData<Bitfield>(
Value);
483 void *
operator new(
size_t S) {
return User::operator
new(S, 0); }
484 void operator delete(
void *
Ptr) { User::operator
delete(
Ptr); }
488 return getSubclassData<OrderingField>();
494 setSubclassData<OrderingField>(Ordering);
509 return I->getOpcode() == Instruction::Fence;
512 return isa<Instruction>(V) && classof(cast<Instruction>(V));
518 template <
typename Bitfield>
519 void setSubclassData(
typename Bitfield::Type
Value) {
520 Instruction::setSubclassData<Bitfield>(
Value);
544 template <
unsigned Offset>
545 using AtomicOrderingBitfieldElement =
570 void *
operator new(
size_t S) {
return User::operator
new(S, 3); }
571 void operator delete(
void *
Ptr) { User::operator
delete(
Ptr); }
584 "Bitfields must be contiguous");
589 return Align(1ULL << getSubclassData<AlignmentField>());
593 setSubclassData<AlignmentField>(
Log2(
Align));
599 bool isVolatile()
const {
return getSubclassData<VolatileField>(); }
606 bool isWeak()
const {
return getSubclassData<WeakField>(); }
608 void setWeak(
bool IsWeak) { setSubclassData<WeakField>(IsWeak); }
627 return getSubclassData<SuccessOrderingField>();
633 "invalid CmpXchg success ordering");
634 setSubclassData<SuccessOrderingField>(Ordering);
639 return getSubclassData<FailureOrderingField>();
645 "invalid CmpXchg failure ordering");
646 setSubclassData<FailureOrderingField>(Ordering);
697 switch (SuccessOrdering) {
713 return I->getOpcode() == Instruction::AtomicCmpXchg;
716 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
722 template <
typename Bitfield>
723 void setSubclassData(
typename Bitfield::Type
Value) {
724 Instruction::setSubclassData<Bitfield>(
Value);
807 LAST_BINOP = UDecWrap,
812 template <
unsigned Offset>
813 using AtomicOrderingBitfieldElement =
817 template <
unsigned Offset>
818 using BinOpBitfieldElement =
833 void *
operator new(
size_t S) {
return User::operator
new(S, 2); }
834 void operator delete(
void *
Ptr) { User::operator
delete(
Ptr); }
843 "Bitfields must be contiguous");
862 setSubclassData<OperationField>(
Operation);
868 return Align(1ULL << getSubclassData<AlignmentField>());
872 setSubclassData<AlignmentField>(
Log2(
Align));
877 bool isVolatile()
const {
return getSubclassData<VolatileField>(); }
888 return getSubclassData<AtomicOrderingField>();
894 "atomicrmw instructions can only be atomic.");
896 "atomicrmw instructions cannot be unordered.");
897 setSubclassData<AtomicOrderingField>(Ordering);
923 return isFPOperation(getOperation());
928 return I->getOpcode() == Instruction::AtomicRMW;
931 return isa<Instruction>(V) && classof(cast<Instruction>(V));
940 template <
typename Bitfield>
941 void setSubclassData(
typename Bitfield::Type
Value) {
942 Instruction::setSubclassData<Bitfield>(
Value);
966 assert(Ty &&
"Invalid GetElementPtrInst indices for type!");
974 Type *SourceElementType;
975 Type *ResultElementType;
985 const Twine &NameStr,
1005 const Twine &NameStr,
1008 assert(PointeeType &&
"Must specify element type");
1010 NameStr, InsertBefore);
1015 const Twine &NameStr =
"",
1018 assert(PointeeType &&
"Must specify element type");
1020 NameStr, InsertBefore);
1025 const Twine &NameStr,
1028 assert(PointeeType &&
"Must specify element type");
1030 NameStr, InsertAtEnd);
1037 const Twine &NameStr,
1040 Create(PointeeType,
Ptr, IdxList, NameStr, InsertBefore);
1041 GEP->setIsInBounds(
true);
1047 const Twine &NameStr =
"",
1050 Create(PointeeType,
Ptr, IdxList, NameStr, InsertBefore);
1051 GEP->setIsInBounds(
true);
1057 const Twine &NameStr,
1060 Create(PointeeType,
Ptr, IdxList, NameStr, InsertAtEnd);
1061 GEP->setIsInBounds(
true);
1074 return ResultElementType;
1144 if (
auto *IndexVTy = dyn_cast<VectorType>(
Index->getType())) {
1188 APInt &ConstantOffset)
const;
1191 return (
I->getOpcode() == Instruction::GetElementPtr);
1194 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
1203GetElementPtrInst::GetElementPtrInst(
Type *PointeeType,
Value *
Ptr,
1205 const Twine &NameStr,
1209 Values, InsertBefore),
1210 SourceElementType(PointeeType),
1211 ResultElementType(getIndexedType(PointeeType, IdxList)) {
1212 init(
Ptr, IdxList, NameStr);
1215GetElementPtrInst::GetElementPtrInst(Type *PointeeType, Value *
Ptr,
1216 ArrayRef<Value *> IdxList,
unsigned Values,
1217 const Twine &NameStr,
1218 Instruction *InsertBefore)
1219 : Instruction(getGEPReturnType(
Ptr, IdxList), GetElementPtr,
1220 OperandTraits<GetElementPtrInst>::op_end(this) - Values,
1221 Values, InsertBefore),
1222 SourceElementType(PointeeType),
1223 ResultElementType(getIndexedType(PointeeType, IdxList)) {
1224 init(
Ptr, IdxList, NameStr);
1227GetElementPtrInst::GetElementPtrInst(Type *PointeeType, Value *
Ptr,
1228 ArrayRef<Value *> IdxList,
unsigned Values,
1229 const Twine &NameStr,
1230 BasicBlock *InsertAtEnd)
1231 : Instruction(getGEPReturnType(
Ptr, IdxList), GetElementPtr,
1232 OperandTraits<GetElementPtrInst>::op_end(this) - Values,
1233 Values, InsertAtEnd),
1234 SourceElementType(PointeeType),
1235 ResultElementType(getIndexedType(PointeeType, IdxList)) {
1251 assert(isIntPredicate() &&
1252 "Invalid ICmp predicate value");
1254 "Both operands to ICmp instruction are not of the same type!");
1257 getOperand(0)->
getType()->isPtrOrPtrVectorTy()) &&
1258 "Invalid operand types for ICmp instruction");
1275 const Twine &NameStr =
""
1290 const Twine &NameStr =
""
1305 const Twine &NameStr =
""
1319 const Twine &NameStr =
""
1332 return getSignedPredicate(getPredicate());
1337 static Predicate getSignedPredicate(Predicate
pred);
1344 return getUnsignedPredicate(getPredicate());
1349 static Predicate getUnsignedPredicate(Predicate
pred);
1354 return P == ICMP_EQ ||
P == ICMP_NE;
1360 return isEquality(getPredicate());
1370 return !isEquality();
1376 return !isEquality(
P);
1382 return P == ICMP_SGT ||
P == ICMP_UGT;
1388 return P == ICMP_SLT ||
P == ICMP_ULT;
1394 return P == ICMP_SGE ||
P == ICMP_UGE;
1400 return P == ICMP_SLE ||
P == ICMP_ULE;
1413 setPredicate(getSwappedPredicate());
1423 return I->getOpcode() == Instruction::ICmp;
1426 return isa<Instruction>(V) && classof(cast<Instruction>(V));
1442 "Both operands to FCmp instruction are not of the same type!");
1445 "Invalid operand types for FCmp instruction");
1462 const Twine &NameStr =
""
1475 const Twine &NameStr =
""
1488 const Twine &NameStr =
""
1500 const Twine &NameStr =
"",
1503 RHS, NameStr, nullptr, FlagsSource) {
1552 return I->getOpcode() == Instruction::FCmp;
1555 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
1575 :
CallInst(Ty, Func, Args, std::nullopt, NameStr, InsertBefore) {}
1585 :
CallInst(Ty, Func, Args, std::nullopt, NameStr, InsertBefore) {}
1607 static int ComputeNumOperands(
int NumArgs,
int NumBundleInputs = 0) {
1610 return 1 + NumArgs + NumBundleInputs;
1622 return new (ComputeNumOperands(0))
CallInst(Ty,
F, NameStr, InsertBefore);
1627 return new (ComputeNumOperands(0))
CallInst(Ty,
F, NameStr, InsertBefore);
1631 const Twine &NameStr,
1633 return new (ComputeNumOperands(Args.size()))
1634 CallInst(Ty, Func, Args, std::nullopt, NameStr, InsertBefore);
1638 const Twine &NameStr,
1640 return new (ComputeNumOperands(Args.size()))
1641 CallInst(Ty, Func, Args, std::nullopt, NameStr, InsertBefore);
1646 const Twine &NameStr,
1648 const int NumOperands =
1652 return new (NumOperands, DescriptorBytes)
1653 CallInst(Ty, Func, Args, Bundles, NameStr, InsertBefore);
1658 const Twine &NameStr =
"",
1660 const int NumOperands =
1664 return new (NumOperands, DescriptorBytes)
1665 CallInst(Ty, Func, Args, Bundles, NameStr, InsertBefore);
1670 return new (ComputeNumOperands(0))
CallInst(Ty,
F, NameStr, InsertAtEnd);
1675 return new (ComputeNumOperands(Args.size()))
1676 CallInst(Ty, Func, Args, std::nullopt, NameStr, InsertAtEnd);
1682 const int NumOperands =
1686 return new (NumOperands, DescriptorBytes)
1687 CallInst(Ty, Func, Args, Bundles, NameStr, InsertAtEnd);
1692 return Create(Func.getFunctionType(), Func.getCallee(), NameStr,
1698 return Create(Func.getFunctionType(), Func.getCallee(), NameStr,
1704 const Twine &NameStr,
1706 return Create(Func.getFunctionType(), Func.getCallee(), Args, Bundles,
1707 NameStr, InsertBefore);
1712 const Twine &NameStr =
"",
1714 return Create(Func.getFunctionType(), Func.getCallee(), Args, Bundles,
1715 NameStr, InsertBefore);
1719 const Twine &NameStr,
1721 return Create(Func.getFunctionType(), Func.getCallee(), Args, NameStr,
1726 const Twine &NameStr,
1728 return Create(Func.getFunctionType(), Func.getCallee(), Args, NameStr,
1734 return Create(Func.getFunctionType(), Func.getCallee(), NameStr,
1740 return Create(Func.getFunctionType(), Func.getCallee(), Args, NameStr,
1747 return Create(Func.getFunctionType(), Func.getCallee(), Args, Bundles,
1748 NameStr, InsertAtEnd);
1773 Bitfield::areContiguous<TailCallKindField, CallBase::CallingConvField>(),
1774 "Bitfields must be contiguous");
1777 return getSubclassData<TailCallKindField>();
1790 setSubclassData<TailCallKindField>(TCK);
1803 return I->getOpcode() == Instruction::Call;
1806 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
1815 template <
typename Bitfield>
1816 void setSubclassData(
typename Bitfield::Type
Value) {
1817 Instruction::setSubclassData<Bitfield>(
Value);
1821CallInst::CallInst(
FunctionType *Ty, Value *Func, ArrayRef<Value *> Args,
1822 ArrayRef<OperandBundleDef> Bundles,
const Twine &NameStr,
1823 BasicBlock *InsertAtEnd)
1824 : CallBase(Ty->getReturnType(), Instruction::
Call,
1825 OperandTraits<CallBase>::op_end(this) -
1826 (
Args.
size() + CountBundleInputs(Bundles) + 1),
1829 init(Ty, Func, Args, Bundles, NameStr);
1832CallInst::CallInst(
FunctionType *Ty, Value *Func, ArrayRef<Value *> Args,
1833 ArrayRef<OperandBundleDef> Bundles,
const Twine &NameStr,
1835 : CallBase(Ty->getReturnType(), Instruction::
Call,
1836 OperandTraits<CallBase>::op_end(this) -
1837 (
Args.
size() + CountBundleInputs(Bundles) + 1),
1840 init(Ty, Func, Args, Bundles, NameStr);
1843CallInst::CallInst(
FunctionType *Ty, Value *Func, ArrayRef<Value *> Args,
1844 ArrayRef<OperandBundleDef> Bundles,
const Twine &NameStr,
1845 Instruction *InsertBefore)
1846 : CallBase(Ty->getReturnType(), Instruction::
Call,
1847 OperandTraits<CallBase>::op_end(this) -
1848 (
Args.
size() + CountBundleInputs(Bundles) + 1),
1851 init(Ty, Func, Args, Bundles, NameStr);
1872 &
Op<0>(), 3, InsertBefore) {
1880 &
Op<0>(), 3, InsertAtEnd) {
1900 const Twine &NameStr,
1910 const Twine &NameStr =
"",
1920 const Twine &NameStr,
1953 return I->getOpcode() == Instruction::Select;
1956 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
2005 return I->getOpcode() == VAArg;
2008 return isa<Instruction>(V) && classof(cast<Instruction>(V));
2035 const Twine &NameStr,
2041 const Twine &NameStr =
"",
2047 const Twine &NameStr,
2070 return I->getOpcode() == Instruction::ExtractElement;
2073 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
2095 const Twine &NameStr =
"",
2108 const Twine &NameStr,
2114 const Twine &NameStr =
"",
2120 const Twine &NameStr,
2127 static bool isValidOperands(
const Value *Vec,
const Value *NewElt,
2141 return I->getOpcode() == Instruction::InsertElement;
2144 return isa<Instruction>(V) && classof(cast<Instruction>(V));
2197 const Twine &NameStr =
"",
2204 const Twine &NameStr =
"",
2209 void *
operator new(
size_t S) {
return User::operator
new(S, 2); }
2210 void operator delete(
void *
Ptr) {
return User::operator
delete(
Ptr); }
2218 static bool isValidOperands(
const Value *V1,
const Value *V2,
2220 static bool isValidOperands(
const Value *V1,
const Value *V2,
2238 static void getShuffleMask(
const Constant *Mask,
2244 Result.assign(ShuffleMask.
begin(), ShuffleMask.
end());
2265 unsigned NumSourceElts = cast<VectorType>(
Op<0>()->
getType())
2267 .getKnownMinValue();
2268 unsigned NumMaskElts = ShuffleMask.
size();
2269 return NumSourceElts != NumMaskElts;
2276 unsigned NumSourceElts = cast<VectorType>(
Op<0>()->
getType())
2278 .getKnownMinValue();
2279 unsigned NumMaskElts = ShuffleMask.
size();
2280 return NumSourceElts < NumMaskElts;
2288 static bool isSingleSourceMask(
ArrayRef<int> Mask,
int NumSrcElts);
2290 assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2292 getShuffleMask(Mask, MaskAsInts);
2293 return isSingleSourceMask(MaskAsInts, NumSrcElts);
2301 return !changesLength() &&
2302 isSingleSourceMask(ShuffleMask, ShuffleMask.
size());
2310 static bool isIdentityMask(
ArrayRef<int> Mask,
int NumSrcElts);
2312 assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2316 if (isa<ScalableVectorType>(Mask->getType()))
2320 getShuffleMask(Mask, MaskAsInts);
2321 return isIdentityMask(MaskAsInts, NumSrcElts);
2331 if (isa<ScalableVectorType>(
getType()))
2334 return !changesLength() && isIdentityMask(ShuffleMask, ShuffleMask.
size());
2339 bool isIdentityWithPadding()
const;
2343 bool isIdentityWithExtract()
const;
2348 bool isConcat()
const;
2358 static bool isSelectMask(
ArrayRef<int> Mask,
int NumSrcElts);
2360 assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2362 getShuffleMask(Mask, MaskAsInts);
2363 return isSelectMask(MaskAsInts, NumSrcElts);
2375 return !changesLength() && isSelectMask(ShuffleMask, ShuffleMask.
size());
2385 assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2387 getShuffleMask(Mask, MaskAsInts);
2404 static bool isZeroEltSplatMask(
ArrayRef<int> Mask,
int NumSrcElts);
2406 assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2408 getShuffleMask(Mask, MaskAsInts);
2409 return isZeroEltSplatMask(MaskAsInts, NumSrcElts);
2419 return !changesLength() &&
2420 isZeroEltSplatMask(ShuffleMask, ShuffleMask.
size());
2455 static bool isTransposeMask(
ArrayRef<int> Mask,
int NumSrcElts);
2457 assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2459 getShuffleMask(Mask, MaskAsInts);
2460 return isTransposeMask(MaskAsInts, NumSrcElts);
2469 return !changesLength() && isTransposeMask(ShuffleMask, ShuffleMask.
size());
2480 assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2482 getShuffleMask(Mask, MaskAsInts);
2483 return isSpliceMask(MaskAsInts, NumSrcElts,
Index);
2491 return !changesLength() &&
2492 isSpliceMask(ShuffleMask, ShuffleMask.
size(),
Index);
2498 static bool isExtractSubvectorMask(
ArrayRef<int> Mask,
int NumSrcElts,
2502 assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2505 if (isa<ScalableVectorType>(Mask->getType()))
2508 getShuffleMask(Mask, MaskAsInts);
2509 return isExtractSubvectorMask(MaskAsInts, NumSrcElts,
Index);
2516 if (isa<ScalableVectorType>(
getType()))
2520 cast<FixedVectorType>(
Op<0>()->
getType())->getNumElements();
2521 return isExtractSubvectorMask(ShuffleMask, NumSrcElts,
Index);
2528 static bool isInsertSubvectorMask(
ArrayRef<int> Mask,
int NumSrcElts,
2529 int &NumSubElts,
int &
Index);
2531 int &NumSubElts,
int &
Index) {
2532 assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2535 if (isa<ScalableVectorType>(Mask->getType()))
2538 getShuffleMask(Mask, MaskAsInts);
2539 return isInsertSubvectorMask(MaskAsInts, NumSrcElts, NumSubElts,
Index);
2546 if (isa<ScalableVectorType>(
getType()))
2550 cast<FixedVectorType>(
Op<0>()->
getType())->getNumElements();
2551 return isInsertSubvectorMask(ShuffleMask, NumSrcElts, NumSubElts,
Index);
2558 static bool isReplicationMask(
ArrayRef<int> Mask,
int &ReplicationFactor,
2562 assert(Mask->getType()->isVectorTy() &&
"Shuffle needs vector constant.");
2565 if (isa<ScalableVectorType>(Mask->getType()))
2568 getShuffleMask(Mask, MaskAsInts);
2569 return isReplicationMask(MaskAsInts, ReplicationFactor, VF);
2573 bool isReplicationMask(
int &ReplicationFactor,
int &VF)
const;
2584 static bool isOneUseSingleSourceMask(
ArrayRef<int> Mask,
int VF);
2588 bool isOneUseSingleSourceMask(
int VF)
const;
2593 unsigned InVecNumElts) {
2594 for (
int &
Idx : Mask) {
2597 Idx =
Idx < (int)InVecNumElts ?
Idx + InVecNumElts :
Idx - InVecNumElts;
2599 "shufflevector mask index out of range");
2604 bool isInterleave(
unsigned Factor);
2625 static bool isInterleaveMask(
ArrayRef<int> Mask,
unsigned Factor,
2626 unsigned NumInputElts,
2629 unsigned NumInputElts) {
2631 return isInterleaveMask(Mask, Factor, NumInputElts, StartIndexes);
2637 static bool isDeInterleaveMaskOfFactor(
ArrayRef<int> Mask,
unsigned Factor,
2641 return isDeInterleaveMaskOfFactor(Mask, Factor, Unused);
2655 static bool isBitRotateMask(
ArrayRef<int> Mask,
unsigned EltSizeInBits,
2656 unsigned MinSubElts,
unsigned MaxSubElts,
2657 unsigned &NumSubElts,
unsigned &RotateAmt);
2661 return I->getOpcode() == Instruction::ShuffleVector;
2664 return isa<Instruction>(V) && classof(cast<Instruction>(V));
2691 const Twine &NameStr,
2695 const Twine &NameStr,
2711 const Twine &NameStr,
2719 const Twine &NameStr =
"",
2727 const Twine &NameStr,
2747 return getOperand(0);
2750 return getOperand(0);
2761 return (
unsigned)Indices.
size();
2770 return I->getOpcode() == Instruction::ExtractValue;
2773 return isa<Instruction>(V) && classof(cast<Instruction>(V));
2777ExtractValueInst::ExtractValueInst(Value *Agg, ArrayRef<unsigned> Idxs,
2778 const Twine &NameStr,
2781 ExtractValue, Agg, InsertBefore) {
2782 init(Idxs, NameStr);
2785ExtractValueInst::ExtractValueInst(Value *Agg,
2786 ArrayRef<unsigned> Idxs,
2787 const Twine &NameStr,
2788 Instruction *InsertBefore)
2790 ExtractValue, Agg, InsertBefore) {
2791 init(Idxs, NameStr);
2794ExtractValueInst::ExtractValueInst(Value *Agg,
2795 ArrayRef<unsigned> Idxs,
2796 const Twine &NameStr,
2797 BasicBlock *InsertAtEnd)
2799 ExtractValue, Agg, InsertAtEnd) {
2800 init(Idxs, NameStr);
2820 const Twine &NameStr,
2824 const Twine &NameStr,
2835 const Twine &NameStr =
"",
2841 const Twine &NameStr);
2851 void *
operator new(
size_t S) {
return User::operator
new(S, 2); }
2852 void operator delete(
void *
Ptr) { User::operator
delete(
Ptr); }
2862 const Twine &NameStr =
"",
2869 const Twine &NameStr,
2910 return (
unsigned)Indices.
size();
2919 return I->getOpcode() == Instruction::InsertValue;
2922 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
2931InsertValueInst::InsertValueInst(
Value *Agg,
2934 const Twine &NameStr,
2938 init(Agg, Val, Idxs, NameStr);
2941InsertValueInst::InsertValueInst(Value *Agg,
2943 ArrayRef<unsigned> Idxs,
2944 const Twine &NameStr,
2945 Instruction *InsertBefore)
2946 : Instruction(Agg->
getType(), InsertValue,
2947 OperandTraits<InsertValueInst>::op_begin(this),
2949 init(Agg, Val, Idxs, NameStr);
2952InsertValueInst::InsertValueInst(Value *Agg,
2954 ArrayRef<unsigned> Idxs,
2955 const Twine &NameStr,
2956 BasicBlock *InsertAtEnd)
2957 : Instruction(Agg->
getType(), InsertValue,
2958 OperandTraits<InsertValueInst>::op_begin(this),
2960 init(Agg, Val, Idxs, NameStr);
2976 unsigned ReservedSpace;
2980 explicit PHINode(
Type *Ty,
unsigned NumReservedValues,
const Twine &NameStr,
2982 :
Instruction(Ty, Instruction::PHI,
nullptr, 0, InsertBefore),
2983 ReservedSpace(NumReservedValues) {
2986 allocHungoffUses(ReservedSpace);
2989 explicit PHINode(
Type *Ty,
unsigned NumReservedValues,
2990 const Twine &NameStr =
"",
2992 :
Instruction(Ty, Instruction::PHI,
nullptr, 0, InsertBefore),
2993 ReservedSpace(NumReservedValues) {
2996 allocHungoffUses(ReservedSpace);
3001 :
Instruction(Ty, Instruction::PHI,
nullptr, 0, InsertAtEnd),
3002 ReservedSpace(NumReservedValues) {
3005 allocHungoffUses(ReservedSpace);
3025 const Twine &NameStr,
3027 return new PHINode(Ty, NumReservedValues, NameStr, InsertBefore);
3031 const Twine &NameStr =
"",
3033 return new PHINode(Ty, NumReservedValues, NameStr, InsertBefore);
3038 return new PHINode(Ty, NumReservedValues, NameStr, InsertAtEnd);
3057 return block_begin() + getNumOperands();
3061 return make_range(block_begin(), block_end());
3075 return getOperand(i);
3078 assert(V &&
"PHI node got a null value!");
3080 "All operands to PHI node must be the same type as the PHI node!");
3095 return block_begin()[i];
3102 assert(
this == U.getUser() &&
"Iterator doesn't point to PHI's Uses?");
3103 return getIncomingBlock(
unsigned(&U - op_begin()));
3110 return getIncomingBlock(
I.getUse());
3126 assert(New && Old &&
"PHI node got a null basic block!");
3127 for (
unsigned Op = 0, NumOps = getNumOperands();
Op != NumOps; ++
Op)
3128 if (getIncomingBlock(
Op) == Old)
3129 setIncomingBlock(
Op, New);
3135 if (getNumOperands() == ReservedSpace)
3138 setNumHungOffUseOperands(getNumOperands() + 1);
3139 setIncomingValue(getNumOperands() - 1, V);
3140 setIncomingBlock(getNumOperands() - 1, BB);
3151 Value *removeIncomingValue(
unsigned Idx,
bool DeletePHIIfEmpty =
true);
3154 int Idx = getBasicBlockIndex(BB);
3155 assert(
Idx >= 0 &&
"Invalid basic block argument to remove!");
3156 return removeIncomingValue(
Idx, DeletePHIIfEmpty);
3161 void removeIncomingValueIf(
function_ref<
bool(
unsigned)> Predicate,
3162 bool DeletePHIIfEmpty =
true);
3168 for (
unsigned i = 0, e = getNumOperands(); i != e; ++i)
3169 if (block_begin()[i] == BB)
3175 int Idx = getBasicBlockIndex(BB);
3176 assert(
Idx >= 0 &&
"Invalid basic block argument!");
3177 return getIncomingValue(
Idx);
3182 assert(BB &&
"PHI node got a null basic block!");
3184 for (
unsigned Op = 0, NumOps = getNumOperands();
Op != NumOps; ++
Op)
3185 if (getIncomingBlock(
Op) == BB) {
3187 setIncomingValue(
Op, V);
3190 assert(Found &&
"Invalid basic block argument to set!");
3195 Value *hasConstantValue()
const;
3200 bool hasConstantOrUndefValue()
const;
3207 return getBasicBlockIndex(Pred) >= 0;
3213 return I->getOpcode() == Instruction::PHI;
3216 return isa<Instruction>(V) && classof(cast<Instruction>(V));
3220 void growOperands();
3246 unsigned ReservedSpace;
3255 const Twine &NameStr,
3263 void *
operator new(
size_t S) {
return User::operator
new(S); }
3265 void growOperands(
unsigned Size);
3266 void init(
unsigned NumReservedValues,
const Twine &NameStr);
3275 void operator delete(
void *
Ptr) { User::operator
delete(
Ptr); }
3280 const Twine &NameStr,
3283 const Twine &NameStr =
"",
3294 bool isCleanup()
const {
return getSubclassData<CleanupField>(); }
3305 return cast<Constant>(getOperandList()[
Idx]);
3310 return !isa<ArrayType>(getOperandList()[
Idx]->
getType());
3315 return isa<ArrayType>(getOperandList()[
Idx]->
getType());
3327 return I->getOpcode() == Instruction::LandingPad;
3330 return isa<Instruction>(V) && classof(cast<Instruction>(V));
3381 return new (!!retVal)
ReturnInst(
C, retVal, InsertBefore);
3386 return new(!!retVal)
ReturnInst(
C, retVal, InsertBefore);
3391 return new(!!retVal)
ReturnInst(
C, retVal, InsertAtEnd);
3403 return getNumOperands() != 0 ? getOperand(0) :
nullptr;
3410 return (
I->getOpcode() == Instruction::Ret);
3413 return isa<Instruction>(V) && classof(cast<Instruction>(V));
3417 BasicBlock *getSuccessor(
unsigned idx)
const {
3421 void setSuccessor(
unsigned idx, BasicBlock *
B) {
3479 std::random_access_iterator_tag, BasicBlock *,
3480 ptrdiff_t, BasicBlock *, BasicBlock *> {
3490 std::random_access_iterator_tag,
3491 const BasicBlock *, ptrdiff_t, const BasicBlock *,
3492 const BasicBlock *> {
3502 return new(1)
BranchInst(IfTrue, InsertBefore);
3507 return new(1)
BranchInst(IfTrue, InsertBefore);
3521 return new(1)
BranchInst(IfTrue, InsertAtEnd);
3536 assert(isConditional() &&
"Cannot get condition of an uncond branch!");
3541 assert(isConditional() &&
"Cannot set condition of unconditional branch!");
3548 assert(i < getNumSuccessors() &&
"Successor # out of range for Branch!");
3549 return cast_or_null<BasicBlock>((&
Op<-1>() - i)->
get());
3553 assert(idx < getNumSuccessors() &&
"Successor # out of range for Branch!");
3554 *(&
Op<-1>() - idx) = NewSucc;
3562 void swapSuccessors();
3572 std::next(value_op_begin(), isConditional() ? 1 : 0)),
3578 return (
I->getOpcode() == Instruction::Br);
3581 return isa<Instruction>(V) && classof(cast<Instruction>(V));
3599 unsigned ReservedSpace;
3629 void *
operator new(
size_t S) {
return User::operator
new(S); }
3632 void growOperands();
3641 void operator delete(
void *
Ptr) { User::operator
delete(
Ptr); }
3644 static const unsigned DefaultPseudoIndex =
static_cast<unsigned>(~0L-1);
3653 template <
typename SwitchInstT,
typename ConstantIntT,
typename BasicBlockT>
3672 assert((
unsigned)Index < SI->getNumCases() &&
3673 "Index out the number of cases.");
3674 return reinterpret_cast<ConstantIntT *
>(
SI->getOperand(2 +
Index * 2));
3679 assert(((
unsigned)Index < SI->getNumCases() ||
3680 (
unsigned)
Index == DefaultPseudoIndex) &&
3681 "Index out the number of cases.");
3682 return SI->getSuccessor(getSuccessorIndex());
3691 (
unsigned)Index < SI->getNumCases()) &&
3692 "Index out the number of cases.");
3693 return (
unsigned)
Index != DefaultPseudoIndex ?
Index + 1 : 0;
3697 assert(
SI ==
RHS.SI &&
"Incompatible operators.");
3714 assert((
unsigned)Index < SI->getNumCases() &&
3715 "Index out the number of cases.");
3716 SI->setOperand(2 +
Index*2,
reinterpret_cast<Value*
>(V));
3721 SI->setSuccessor(getSuccessorIndex(), S);
3725 template <
typename CaseHandleT>
3728 std::random_access_iterator_tag,
3729 const CaseHandleT> {
3730 using SwitchInstT =
typename CaseHandleT::SwitchInstType;
3746 unsigned SuccessorIndex) {
3747 assert(SuccessorIndex < SI->getNumSuccessors() &&
3748 "Successor index # out of range!");
3763 (
unsigned)(Case.Index +
N) <= Case.SI->getNumCases() &&
3764 "Case.Index out the number of cases.");
3772 (
unsigned)(Case.Index -
N) <= Case.SI->getNumCases() &&
3773 "Case.Index out the number of cases.");
3778 assert(Case.SI ==
RHS.Case.SI &&
"Incompatible operators.");
3779 return Case.Index -
RHS.Case.Index;
3782 return Case ==
RHS.Case;
3785 assert(Case.SI ==
RHS.Case.SI &&
"Incompatible operators.");
3786 return Case.Index <
RHS.Case.Index;
3807 unsigned NumCases,
BasicBlock *InsertAtEnd) {
3819 return cast<BasicBlock>(getOperand(1));
3825 return isa<UnreachableInst>(getDefaultDest()->getFirstNonPHIOrDbg());
3829 setOperand(1,
reinterpret_cast<Value*
>(DefaultCase));
3835 return getNumOperands()/2 - 1;
3853 return CaseIt(
this, getNumCases());
3878 return CaseIt(
this, DefaultPseudoIndex);
3891 const_cast<const SwitchInst *
>(
this)->findCaseValue(
C)->getCaseIndex());
3897 if (
I != case_end())
3900 return case_default();
3906 if (BB == getDefaultDest())
3910 for (
auto Case : cases()) {
3911 if (Case.getCaseSuccessor() != BB)
3917 CI = Case.getCaseValue();
3936 CaseIt removeCase(CaseIt
I);
3940 assert(idx < getNumSuccessors() &&
"Successor idx out of range for switch!");
3941 return cast<BasicBlock>(getOperand(idx*2+1));
3944 assert(idx < getNumSuccessors() &&
"Successor # out of range for switch!");
3945 setOperand(idx * 2 + 1, NewSucc);
3950 return I->getOpcode() == Instruction::Switch;
3953 return isa<Instruction>(V) && classof(cast<Instruction>(V));
3961 std::optional<SmallVector<uint32_t, 8>> Weights;
3962 bool Changed =
false;
4014 unsigned ReservedSpace;
4040 void *
operator new(
size_t S) {
return User::operator
new(S); }
4043 void growOperands();
4052 void operator delete(
void *
Ptr) { User::operator
delete(
Ptr); }
4060 std::random_access_iterator_tag, BasicBlock *,
4061 ptrdiff_t, BasicBlock *, BasicBlock *> {
4071 std::random_access_iterator_tag,
4072 const BasicBlock *, ptrdiff_t, const BasicBlock *,
4073 const BasicBlock *> {
4118 void removeDestination(
unsigned i);
4122 return cast<BasicBlock>(getOperand(i+1));
4125 setOperand(i + 1, NewSucc);
4140 return I->getOpcode() == Instruction::IndirectBr;
4143 return isa<Instruction>(V) && classof(cast<Instruction>(V));
4163 static constexpr int NumExtraOperands = 2;
4166 static constexpr int NormalDestOpEndIdx = -3;
4169 static constexpr int UnwindDestOpEndIdx = -2;
4197 static int ComputeNumOperands(
int NumArgs,
int NumBundleInputs = 0) {
4200 return 1 + NumExtraOperands + NumArgs + NumBundleInputs;
4212 const Twine &NameStr,
4214 int NumOperands = ComputeNumOperands(Args.size());
4215 return new (NumOperands)
4216 InvokeInst(Ty, Func, IfNormal, IfException, Args, std::nullopt,
4217 NumOperands, NameStr, InsertBefore);
4222 const Twine &NameStr,
4224 int NumOperands = ComputeNumOperands(Args.size());
4225 return new (NumOperands)
4226 InvokeInst(Ty, Func, IfNormal, IfException, Args, std::nullopt,
4227 NumOperands, NameStr, InsertBefore);
4233 const Twine &NameStr,
4236 ComputeNumOperands(Args.size(), CountBundleInputs(Bundles));
4239 return new (NumOperands, DescriptorBytes)
4240 InvokeInst(Ty, Func, IfNormal, IfException, Args, Bundles, NumOperands,
4241 NameStr, InsertBefore);
4247 const Twine &NameStr =
"",
4250 ComputeNumOperands(Args.size(), CountBundleInputs(Bundles));
4253 return new (NumOperands, DescriptorBytes)
4254 InvokeInst(Ty, Func, IfNormal, IfException, Args, Bundles, NumOperands,
4255 NameStr, InsertBefore);
4261 int NumOperands = ComputeNumOperands(Args.size());
4262 return new (NumOperands)
4263 InvokeInst(Ty, Func, IfNormal, IfException, Args, std::nullopt,
4264 NumOperands, NameStr, InsertAtEnd);
4272 ComputeNumOperands(Args.size(), CountBundleInputs(Bundles));
4275 return new (NumOperands, DescriptorBytes)
4276 InvokeInst(Ty, Func, IfNormal, IfException, Args, Bundles, NumOperands,
4277 NameStr, InsertAtEnd);
4282 const Twine &NameStr,
4284 return Create(Func.getFunctionType(), Func.getCallee(), IfNormal,
4285 IfException, Args, std::nullopt, NameStr, InsertBefore);
4290 const Twine &NameStr,
4292 return Create(Func.getFunctionType(), Func.getCallee(), IfNormal,
4293 IfException, Args, std::nullopt, NameStr, InsertBefore);
4299 const Twine &NameStr,
4301 return Create(Func.getFunctionType(), Func.getCallee(), IfNormal,
4302 IfException, Args, Bundles, NameStr, InsertBefore);
4308 const Twine &NameStr =
"",
4310 return Create(Func.getFunctionType(), Func.getCallee(), IfNormal,
4311 IfException, Args, Bundles, NameStr, InsertBefore);
4317 return Create(Func.getFunctionType(), Func.getCallee(), IfNormal,
4318 IfException, Args, NameStr, InsertAtEnd);
4325 return Create(Func.getFunctionType(), Func.getCallee(), IfNormal,
4326 IfException, Args, Bundles, NameStr, InsertAtEnd);
4359 assert(i < 2 &&
"Successor # out of range for invoke!");
4360 return i == 0 ? getNormalDest() : getUnwindDest();
4364 assert(i < 2 &&
"Successor # out of range for invoke!");
4366 setNormalDest(NewSucc);
4368 setUnwindDest(NewSucc);
4375 return (
I->getOpcode() == Instruction::Invoke);
4378 return isa<Instruction>(V) && classof(cast<Instruction>(V));
4384 template <
typename Bitfield>
4385 void setSubclassData(
typename Bitfield::Type
Value) {
4386 Instruction::setSubclassData<Bitfield>(
Value);
4390InvokeInst::InvokeInst(
FunctionType *Ty, Value *Func, BasicBlock *IfNormal,
4391 BasicBlock *IfException, ArrayRef<Value *> Args,
4392 ArrayRef<OperandBundleDef> Bundles,
int NumOperands,
4394 : CallBase(Ty->getReturnType(), Instruction::Invoke,
4395 OperandTraits<CallBase>::op_end(this) - NumOperands, NumOperands,
4397 init(Ty, Func, IfNormal, IfException, Args, Bundles, NameStr);
4400InvokeInst::InvokeInst(
FunctionType *Ty, Value *Func, BasicBlock *IfNormal,
4401 BasicBlock *IfException, ArrayRef<Value *> Args,
4402 ArrayRef<OperandBundleDef> Bundles,
int NumOperands,
4403 const Twine &NameStr, Instruction *InsertBefore)
4404 : CallBase(Ty->getReturnType(), Instruction::Invoke,
4405 OperandTraits<CallBase>::op_end(this) - NumOperands, NumOperands,
4407 init(Ty, Func, IfNormal, IfException, Args, Bundles, NameStr);
4410InvokeInst::InvokeInst(
FunctionType *Ty, Value *Func, BasicBlock *IfNormal,
4411 BasicBlock *IfException, ArrayRef<Value *> Args,
4412 ArrayRef<OperandBundleDef> Bundles,
int NumOperands,
4413 const Twine &NameStr, BasicBlock *InsertAtEnd)
4414 : CallBase(Ty->getReturnType(), Instruction::Invoke,
4415 OperandTraits<CallBase>::op_end(this) - NumOperands, NumOperands,
4417 init(Ty, Func, IfNormal, IfException, Args, Bundles, NameStr);
4430 unsigned NumIndirectDests;
4438 int NumOperands,
const Twine &NameStr,
4461 static int ComputeNumOperands(
int NumArgs,
int NumIndirectDests,
4462 int NumBundleInputs = 0) {
4465 return 2 + NumIndirectDests + NumArgs + NumBundleInputs;
4480 int NumOperands = ComputeNumOperands(Args.size(), IndirectDests.
size());
4481 return new (NumOperands)
4482 CallBrInst(Ty, Func, DefaultDest, IndirectDests, Args, std::nullopt,
4483 NumOperands, NameStr, InsertBefore);
4491 int NumOperands = ComputeNumOperands(Args.size(), IndirectDests.
size());
4492 return new (NumOperands)
4493 CallBrInst(Ty, Func, DefaultDest, IndirectDests, Args, std::nullopt,
4494 NumOperands, NameStr, InsertBefore);
4502 int NumOperands = ComputeNumOperands(Args.size(), IndirectDests.
size(),
4506 return new (NumOperands, DescriptorBytes)
4507 CallBrInst(Ty, Func, DefaultDest, IndirectDests, Args, Bundles,
4508 NumOperands, NameStr, InsertBefore);
4516 int NumOperands = ComputeNumOperands(Args.size(), IndirectDests.
size(),
4520 return new (NumOperands, DescriptorBytes)
4521 CallBrInst(Ty, Func, DefaultDest, IndirectDests, Args, Bundles,
4522 NumOperands, NameStr, InsertBefore);
4530 int NumOperands = ComputeNumOperands(Args.size(), IndirectDests.
size());
4531 return new (NumOperands)
4532 CallBrInst(Ty, Func, DefaultDest, IndirectDests, Args, std::nullopt,
4533 NumOperands, NameStr, InsertAtEnd);
4542 int NumOperands = ComputeNumOperands(Args.size(), IndirectDests.
size(),
4546 return new (NumOperands, DescriptorBytes)
4547 CallBrInst(Ty, Func, DefaultDest, IndirectDests, Args, Bundles,
4548 NumOperands, NameStr, InsertAtEnd);
4555 return Create(Func.getFunctionType(), Func.getCallee(), DefaultDest,
4556 IndirectDests, Args, NameStr, InsertBefore);
4563 return Create(Func.getFunctionType(), Func.getCallee(), DefaultDest,
4564 IndirectDests, Args, NameStr, InsertBefore);
4571 const Twine &NameStr,
4573 return Create(Func.getFunctionType(), Func.getCallee(), DefaultDest,
4574 IndirectDests, Args, Bundles, NameStr, InsertBefore);
4581 const Twine &NameStr =
"",
4583 return Create(Func.getFunctionType(), Func.getCallee(), DefaultDest,
4584 IndirectDests, Args, Bundles, NameStr, InsertBefore);
4591 return Create(Func.getFunctionType(), Func.getCallee(), DefaultDest,
4592 IndirectDests, Args, NameStr, InsertAtEnd);
4601 return Create(Func.getFunctionType(), Func.getCallee(), DefaultDest,
4602 IndirectDests, Args, Bundles, NameStr, InsertAtEnd);
4644 return IndirectDests;
4655 "Successor # out of range for callbr!");
4661 "Successor # out of range for callbr!");
4669 return (
I->getOpcode() == Instruction::CallBr);
4672 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4678 template <
typename Bitfield>
4679 void setSubclassData(
typename Bitfield::Type
Value) {
4680 Instruction::setSubclassData<Bitfield>(
Value);
4684CallBrInst::CallBrInst(
FunctionType *Ty, Value *Func, BasicBlock *DefaultDest,
4685 ArrayRef<BasicBlock *> IndirectDests,
4686 ArrayRef<Value *> Args,
4687 ArrayRef<OperandBundleDef> Bundles,
int NumOperands,
4689 : CallBase(Ty->getReturnType(), Instruction::CallBr,
4690 OperandTraits<CallBase>::op_end(this) - NumOperands, NumOperands,
4692 init(Ty, Func, DefaultDest, IndirectDests, Args, Bundles, NameStr);
4695CallBrInst::CallBrInst(
FunctionType *Ty, Value *Func, BasicBlock *DefaultDest,
4696 ArrayRef<BasicBlock *> IndirectDests,
4697 ArrayRef<Value *> Args,
4698 ArrayRef<OperandBundleDef> Bundles,
int NumOperands,
4699 const Twine &NameStr, Instruction *InsertBefore)
4700 : CallBase(Ty->getReturnType(), Instruction::CallBr,
4701 OperandTraits<CallBase>::op_end(this) - NumOperands, NumOperands,
4703 init(Ty, Func, DefaultDest, IndirectDests, Args, Bundles, NameStr);
4706CallBrInst::CallBrInst(
FunctionType *Ty, Value *Func, BasicBlock *DefaultDest,
4707 ArrayRef<BasicBlock *> IndirectDests,
4708 ArrayRef<Value *> Args,
4709 ArrayRef<OperandBundleDef> Bundles,
int NumOperands,
4710 const Twine &NameStr, BasicBlock *InsertAtEnd)
4711 : CallBase(Ty->getReturnType(), Instruction::CallBr,
4712 OperandTraits<CallBase>::op_end(this) - NumOperands, NumOperands,
4714 init(Ty, Func, DefaultDest, IndirectDests, Args, Bundles, NameStr);
4739 return new (1)
ResumeInst(Exn, InsertBefore);
4760 return I->getOpcode() == Instruction::Resume;
4763 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
4767 BasicBlock *getSuccessor(
unsigned idx)
const {
4771 void setSuccessor(
unsigned idx,
BasicBlock *NewSucc) {
4791 unsigned ReservedSpace;
4803 unsigned NumHandlers,
const Twine &NameStr,
4811 unsigned NumHandlers,
const Twine &NameStr,
4819 unsigned NumHandlers,
const Twine &NameStr,
4823 void *
operator new(
size_t S) {
return User::operator
new(S); }
4825 void init(
Value *ParentPad,
BasicBlock *UnwindDest,
unsigned NumReserved);
4826 void growOperands(
unsigned Size);
4835 void operator delete(
void *
Ptr) {
return User::operator
delete(
Ptr); }
4838 unsigned NumHandlers,
const Twine &NameStr,
4840 return new CatchSwitchInst(ParentPad, UnwindDest, NumHandlers, NameStr,
4845 unsigned NumHandlers,
4846 const Twine &NameStr =
"",
4848 return new CatchSwitchInst(ParentPad, UnwindDest, NumHandlers, NameStr,
4853 unsigned NumHandlers,
const Twine &NameStr,
4855 return new CatchSwitchInst(ParentPad, UnwindDest, NumHandlers, NameStr,
4870 if (hasUnwindDest())
4871 return cast<BasicBlock>(getOperand(1));
4877 setOperand(1, UnwindDest);
4883 if (hasUnwindDest())
4884 return getNumOperands() - 2;
4885 return getNumOperands() - 1;
4889 static BasicBlock *handler_helper(
Value *V) {
return cast<BasicBlock>(V); }
4890 static const BasicBlock *handler_helper(
const Value *V) {
4891 return cast<BasicBlock>(V);
4906 if (hasUnwindDest())
4915 if (hasUnwindDest())
4934 return make_range(handler_begin(), handler_end());
4939 return make_range(handler_begin(), handler_end());
4948 void removeHandler(handler_iterator HI);
4953 "Successor # out of range for catchswitch!");
4954 return cast<BasicBlock>(getOperand(
Idx + 1));
4958 "Successor # out of range for catchswitch!");
4959 setOperand(
Idx + 1, NewSucc);
4964 return I->getOpcode() == Instruction::CatchSwitch;
4967 return isa<Instruction>(V) && classof(cast<Instruction>(V));
4982 unsigned Values,
const Twine &NameStr,
4984 :
FuncletPadInst(Instruction::CleanupPad, ParentPad, Args, Values,
4985 NameStr, InsertBefore) {}
4987 unsigned Values,
const Twine &NameStr,
4989 :
FuncletPadInst(Instruction::CleanupPad, ParentPad, Args, Values,
4990 NameStr, InsertBefore) {}
4992 unsigned Values,
const Twine &NameStr,
4994 :
FuncletPadInst(Instruction::CleanupPad, ParentPad, Args, Values,
4995 NameStr, InsertAtEnd) {}
4999 const Twine &NameStr,
5001 unsigned Values = 1 + Args.size();
5008 const Twine &NameStr =
"",
5010 unsigned Values = 1 + Args.size();
5017 unsigned Values = 1 + Args.size();
5024 return I->getOpcode() == Instruction::CleanupPad;
5027 return isa<Instruction>(V) && classof(cast<Instruction>(V));
5037 unsigned Values,
const Twine &NameStr,
5039 :
FuncletPadInst(Instruction::CatchPad, CatchSwitch, Args, Values,
5040 NameStr, InsertBefore) {}
5042 unsigned Values,
const Twine &NameStr,
5044 :
FuncletPadInst(Instruction::CatchPad, CatchSwitch, Args, Values,
5045 NameStr, InsertBefore) {}
5047 unsigned Values,
const Twine &NameStr,
5049 :
FuncletPadInst(Instruction::CatchPad, CatchSwitch, Args, Values,
5050 NameStr, InsertAtEnd) {}
5054 const Twine &NameStr,
5056 unsigned Values = 1 + Args.size();
5058 CatchPadInst(CatchSwitch, Args, Values, NameStr, InsertBefore);
5062 const Twine &NameStr =
"",
5064 unsigned Values = 1 + Args.size();
5066 CatchPadInst(CatchSwitch, Args, Values, NameStr, InsertBefore);
5071 unsigned Values = 1 + Args.size();
5073 CatchPadInst(CatchSwitch, Args, Values, NameStr, InsertAtEnd);
5078 return cast<CatchSwitchInst>(
Op<-1>());
5082 Op<-1>() = CatchSwitch;
5087 return I->getOpcode() == Instruction::CatchPad;
5090 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
5160 return (
I->getOpcode() == Instruction::CatchRet);
5163 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
5212 unsigned Values = 1;
5223 unsigned Values = 1;
5233 unsigned Values = 1;
5248 return cast<CleanupPadInst>(
Op<0>());
5252 Op<0>() = CleanupPad;
5258 return hasUnwindDest() ? cast<BasicBlock>(
Op<1>()) :
nullptr;
5268 return (
I->getOpcode() == Instruction::CleanupRet);
5271 return isa<Instruction>(V) && classof(cast<Instruction>(V));
5277 return getUnwindDest();
5280 void setSuccessor(
unsigned Idx, BasicBlock *
B) {
5287 template <
typename Bitfield>
5288 void setSubclassData(
typename Bitfield::Type Value) {
5289 Instruction::setSubclassData<Bitfield>(Value);
5321 void *
operator new(
size_t S) {
return User::operator
new(S, 0); }
5322 void operator delete(
void *
Ptr) { User::operator
delete(
Ptr); }
5328 return I->getOpcode() == Instruction::Unreachable;
5331 return isa<Instruction>(V) && classof(cast<Instruction>(V));
5335 BasicBlock *getSuccessor(
unsigned idx)
const {
5339 void setSuccessor(
unsigned idx, BasicBlock *
B) {
5364 const Twine &NameStr,
5372 const Twine &NameStr =
"",
5380 const Twine &NameStr,
5386 return I->getOpcode() == Trunc;
5389 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
5415 unsigned NoWrapKind = 0;
5444 const Twine &NameStr,
5452 const Twine &NameStr =
"",
5460 const Twine &NameStr,
5466 return I->getOpcode() == ZExt;
5469 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
5491 const Twine &NameStr,
5499 const Twine &NameStr =
"",
5507 const Twine &NameStr,
5513 return I->getOpcode() == SExt;
5516 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
5538 const Twine &NameStr,
5546 const Twine &NameStr =
"",
5554 const Twine &NameStr,
5560 return I->getOpcode() == FPTrunc;
5563 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
5585 const Twine &NameStr,
5593 const Twine &NameStr =
"",
5601 const Twine &NameStr,
5607 return I->getOpcode() == FPExt;
5610 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
5632 const Twine &NameStr,
5640 const Twine &NameStr =
"",
5648 const Twine &NameStr,
5654 return I->getOpcode() == UIToFP;
5657 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
5679 const Twine &NameStr,
5687 const Twine &NameStr =
"",
5695 const Twine &NameStr,
5701 return I->getOpcode() == SIToFP;
5704 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
5726 const Twine &NameStr,
5734 const Twine &NameStr =
"",
5742 const Twine &NameStr,
5748 return I->getOpcode() == FPToUI;
5751 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
5773 const Twine &NameStr,
5781 const Twine &NameStr =
"",
5789 const Twine &NameStr,
5795 return I->getOpcode() == FPToSI;
5798 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
5816 const Twine &NameStr,
5824 const Twine &NameStr =
"",
5832 const Twine &NameStr,
5846 return I->getOpcode() == IntToPtr;
5849 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
5871 const Twine &NameStr,
5879 const Twine &NameStr =
"",
5887 const Twine &NameStr,
5905 return I->getOpcode() == PtrToInt;
5908 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
5930 const Twine &NameStr,
5938 const Twine &NameStr =
"",
5946 const Twine &NameStr,
5952 return I->getOpcode() == BitCast;
5955 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
5978 const Twine &NameStr,
5986 const Twine &NameStr =
"",
5994 const Twine &NameStr,
6000 return I->getOpcode() == AddrSpaceCast;
6003 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
6039 if (
auto *Load = dyn_cast<LoadInst>(V))
6040 return Load->getPointerOperand();
6041 if (
auto *Store = dyn_cast<StoreInst>(V))
6042 return Store->getPointerOperand();
6046 return const_cast<Value *
>(
6055 if (
auto *Gep = dyn_cast<GetElementPtrInst>(V))
6056 return Gep->getPointerOperand();
6065 assert((isa<LoadInst>(
I) || isa<StoreInst>(
I)) &&
6066 "Expected Load or Store instruction");
6067 if (
auto *LI = dyn_cast<LoadInst>(
I))
6068 return LI->getAlign();
6069 return cast<StoreInst>(
I)->getAlign();
6075 assert((isa<LoadInst>(
I) || isa<StoreInst>(
I)) &&
6076 "Expected Load or Store instruction");
6077 if (
auto *LI = dyn_cast<LoadInst>(
I))
6078 return LI->getPointerAddressSpace();
6079 return cast<StoreInst>(
I)->getPointerAddressSpace();
6084 assert((isa<LoadInst>(
I) || isa<StoreInst>(
I)) &&
6085 "Expected Load or Store instruction");
6086 if (
auto *LI = dyn_cast<LoadInst>(
I))
6087 return LI->getType();
6088 return cast<StoreInst>(
I)->getValueOperand()->getType();
6095 return std::nullopt;
6096 if (
auto *AI = dyn_cast<LoadInst>(
I))
6097 return AI->getSyncScopeID();
6098 if (
auto *AI = dyn_cast<StoreInst>(
I))
6099 return AI->getSyncScopeID();
6100 if (
auto *AI = dyn_cast<FenceInst>(
I))
6101 return AI->getSyncScopeID();
6102 if (
auto *AI = dyn_cast<AtomicCmpXchgInst>(
I))
6103 return AI->getSyncScopeID();
6104 if (
auto *AI = dyn_cast<AtomicRMWInst>(
I))
6105 return AI->getSyncScopeID();
6127 const Twine &NameStr =
"",
6133 return I->getOpcode() == Freeze;
6136 return isa<Instruction>(V) &&
classof(cast<Instruction>(V));
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static bool isReverseMask(ArrayRef< int > M, EVT VT)
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 file implements a map that provides insertion order iteration.
#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)
This defines the Use class.
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.
@ Min
*p = old <signed v ? old : v
@ 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.
InstListType::iterator iterator
Instruction iterators...
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.
static BranchInst * Create(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, BasicBlock *InsertAtEnd)
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
iterator_range< succ_op_iterator > successors()
void setCondition(Value *V)
static BranchInst * Create(BasicBlock *IfTrue, BasicBlock *InsertAtEnd)
static bool classof(const Instruction *I)
static BranchInst * Create(BasicBlock *IfTrue, BasicBlock::iterator InsertBefore)
bool isConditional() const
static BranchInst * Create(BasicBlock *IfTrue, Instruction *InsertBefore=nullptr)
unsigned getNumSuccessors() const
static bool classof(const Value *V)
BasicBlock * getSuccessor(unsigned i) const
static BranchInst * Create(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, BasicBlock::iterator InsertBefore)
static BranchInst * Create(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, Instruction *InsertBefore=nullptr)
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.
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 CallBrInst * Create(FunctionCallee Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, const Twine &NameStr, BasicBlock *InsertAtEnd)
static CallBrInst * Create(FunctionCallee Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, const Twine &NameStr, BasicBlock::iterator InsertBefore)
static CallBrInst * Create(FunctionCallee Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, const Twine &NameStr, Instruction *InsertBefore=nullptr)
static CallBrInst * Create(FunctionType *Ty, Value *Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, const Twine &NameStr, BasicBlock::iterator InsertBefore)
static bool classof(const Value *V)
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, BasicBlock::iterator InsertBefore)
SmallVector< BasicBlock *, 16 > getIndirectDests() const
static CallBrInst * Create(FunctionCallee Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles=std::nullopt, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
static CallBrInst * Create(FunctionType *Ty, Value *Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, const Twine &NameStr, Instruction *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)
static CallBrInst * Create(FunctionCallee Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles, const Twine &NameStr, BasicBlock *InsertAtEnd)
static CallBrInst * Create(FunctionType *Ty, Value *Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles=std::nullopt, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
unsigned getNumSuccessors() const
void setIndirectDest(unsigned i, BasicBlock *B)
Value * getIndirectDestLabel(unsigned i) const
getIndirectDestLabel - Return the i-th indirect dest label.
static CallBrInst * Create(FunctionType *Ty, Value *Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, const Twine &NameStr, BasicBlock *InsertAtEnd)
static CallBrInst * Create(FunctionType *Ty, Value *Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles, const Twine &NameStr, BasicBlock::iterator InsertBefore)
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, ArrayRef< OperandBundleDef > Bundles, const Twine &NameStr, BasicBlock *InsertAtEnd)
CallBrInst * cloneImpl() const
This class represents a function call, abstracting a target machine's calling convention.
static CallInst * Create(FunctionCallee Func, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles, const Twine &NameStr, BasicBlock *InsertAtEnd)
bool isNoTailCall() const
static CallInst * Create(FunctionType *Ty, Value *Func, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles, const Twine &NameStr, BasicBlock *InsertAtEnd)
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr, BasicBlock::iterator InsertBefore)
void updateProfWeight(uint64_t S, uint64_t T)
Updates profile metadata by scaling it by S / T.
static bool classof(const Value *V)
static CallInst * Create(FunctionCallee Func, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles=std::nullopt, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
static CallInst * Create(FunctionType *Ty, Value *Func, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles, const Twine &NameStr, BasicBlock::iterator InsertBefore)
static CallInst * Create(FunctionCallee Func, const Twine &NameStr, BasicBlock::iterator InsertBefore)
static CallInst * Create(FunctionType *Ty, Value *Func, ArrayRef< Value * > Args, const Twine &NameStr, BasicBlock *InsertAtEnd)
static CallInst * Create(FunctionCallee Func, const Twine &NameStr, BasicBlock *InsertAtEnd)
void setTailCallKind(TailCallKind TCK)
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr, BasicBlock *InsertAtEnd)
static CallInst * Create(FunctionCallee Func, ArrayRef< Value * > Args, const Twine &NameStr, BasicBlock *InsertAtEnd)
bool canReturnTwice() const
Return true if the call can return twice.
static CallInst * Create(FunctionCallee Func, ArrayRef< Value * > Args, const Twine &NameStr, BasicBlock::iterator InsertBefore)
TailCallKind getTailCallKind() const
static CallInst * Create(FunctionCallee Func, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles, const Twine &NameStr, BasicBlock::iterator InsertBefore)
CallInst * cloneImpl() const
static CallInst * Create(FunctionType *Ty, Value *Func, ArrayRef< Value * > Args, const Twine &NameStr, Instruction *InsertBefore=nullptr)
static CallInst * Create(FunctionType *Ty, Value *Func, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles=std::nullopt, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
void setTailCall(bool IsTc=true)
bool isMustTailCall() const
static bool classof(const Instruction *I)
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
static CallInst * Create(FunctionCallee Func, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
static CallInst * Create(FunctionType *Ty, Value *Func, ArrayRef< Value * > Args, const Twine &NameStr, BasicBlock::iterator InsertBefore)
static CallInst * Create(FunctionCallee Func, ArrayRef< Value * > Args, const Twine &NameStr, Instruction *InsertBefore=nullptr)
This is the base class for all instructions that perform data casts.
static CatchPadInst * Create(Value *CatchSwitch, ArrayRef< Value * > Args, const Twine &NameStr, BasicBlock *InsertAtEnd)
CatchSwitchInst * getCatchSwitch() const
Convenience accessors.
void setCatchSwitch(Value *CatchSwitch)
static CatchPadInst * Create(Value *CatchSwitch, ArrayRef< Value * > Args, const Twine &NameStr, BasicBlock::iterator InsertBefore)
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="", Instruction *InsertBefore=nullptr)
static bool classof(const Value *V)
static bool classof(const Instruction *I)
static CatchReturnInst * Create(Value *CatchPad, BasicBlock *BB, BasicBlock *InsertAtEnd)
BasicBlock * getSuccessor() const
CatchPadInst * getCatchPad() const
Convenience accessors.
void setSuccessor(BasicBlock *NewSucc)
static bool classof(const Value *V)
unsigned getNumSuccessors() const
static CatchReturnInst * Create(Value *CatchPad, BasicBlock *BB, BasicBlock::iterator InsertBefore)
static CatchReturnInst * Create(Value *CatchPad, BasicBlock *BB, Instruction *InsertBefore=nullptr)
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.
static CatchSwitchInst * Create(Value *ParentPad, BasicBlock *UnwindDest, unsigned NumHandlers, const Twine &NameStr, BasicBlock::iterator InsertBefore)
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
static CatchSwitchInst * Create(Value *ParentPad, BasicBlock *UnwindDest, unsigned NumHandlers, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
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, BasicBlock *InsertAtEnd)
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 CleanupPadInst * Create(Value *ParentPad, ArrayRef< Value * > Args, const Twine &NameStr, BasicBlock *InsertAtEnd)
static bool classof(const Value *V)
static CleanupPadInst * Create(Value *ParentPad, ArrayRef< Value * > Args, const Twine &NameStr, BasicBlock::iterator InsertBefore)
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=std::nullopt, const Twine &NameStr="", Instruction *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, Instruction *InsertBefore=nullptr)
static CleanupReturnInst * Create(Value *CleanupPad, BasicBlock *UnwindBB, BasicBlock *InsertAtEnd)
bool hasUnwindDest() const
static CleanupReturnInst * Create(Value *CleanupPad, BasicBlock *UnwindBB, BasicBlock::iterator InsertBefore)
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.
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.
FCmpInst(Instruction *InsertBefore, Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
Constructor with insert-before-instruction semantics.
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 compare(const APFloat &LHS, const APFloat &RHS, FCmpInst::Predicate Pred)
Return result of LHS Pred RHS comparison.
static bool isEquality(Predicate Pred)
FCmpInst(BasicBlock *InsertAtEnd, Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
Constructor with insert-at-end semantics.
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.
FCmpInst(BasicBlock::iterator InsertBefore, Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
Constructor with insert-before-instruction semantics.
void swapOperands()
Exchange the two operands to this instruction in such a way that it does not modify the semantics of ...
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.
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.
static GetElementPtrInst * CreateInBounds(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
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.
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr, BasicBlock::iterator InsertBefore)
void setResultElementType(Type *Ty)
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
bool collectOffset(const DataLayout &DL, unsigned BitWidth, MapVector< Value *, APInt > &VariableOffsets, APInt &ConstantOffset) const
Type * getResultElementType() const
static bool classof(const Instruction *I)
static GetElementPtrInst * CreateInBounds(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr, BasicBlock *InsertAtEnd)
static bool classof(const Value *V)
iterator_range< op_iterator > indices()
static GetElementPtrInst * CreateInBounds(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr, BasicBlock::iterator InsertBefore)
Create an "inbounds" getelementptr.
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 * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr, BasicBlock *InsertAtEnd)
Type * getPointerOperandType() const
Method to return the pointer operand as a PointerType.
static unsigned getPointerOperandIndex()
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
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
unsigned getNumIndices() const
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.
static bool classof(const Value *V)
bool isCommutative() const
static bool isGE(Predicate P)
Return true if the predicate is SGE or UGE.
ICmpInst(BasicBlock *InsertAtEnd, Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
Constructor with insert-at-end semantics.
static bool isLT(Predicate P)
Return true if the predicate is SLT or ULT.
static bool isGT(Predicate P)
Return true if the predicate is SGT or UGT.
static bool classof(const Instruction *I)
Predicate getSignedPredicate() const
For example, EQ->EQ, SLE->SLE, UGT->SGT, etc.
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 ...
ICmpInst(Instruction *InsertBefore, Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
Constructor with insert-before-instruction semantics.
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.
ICmpInst(BasicBlock::iterator InsertBefore, Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
Constructor with insert-before-instruction semantics.
Indirect Branch Instruction.
BasicBlock * getDestination(unsigned i)
Return the specified destination.
static bool classof(const Value *V)
const Value * getAddress() const
static IndirectBrInst * Create(Value *Address, unsigned NumDests, Instruction *InsertBefore=nullptr)
static IndirectBrInst * Create(Value *Address, unsigned NumDests, BasicBlock::iterator InsertBefore)
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.
static IndirectBrInst * Create(Value *Address, unsigned NumDests, BasicBlock *InsertAtEnd)
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)
VectorType * getType() const
Overload to return most specific vector type.
static InsertElementInst * Create(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
static bool classof(const Instruction *I)
static InsertElementInst * Create(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr, BasicBlock::iterator InsertBefore)
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
static InsertElementInst * Create(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr, BasicBlock *InsertAtEnd)
This instruction inserts a struct field of array element value into an aggregate value.
Value * getInsertedValueOperand()
static InsertValueInst * Create(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
static bool classof(const Instruction *I)
static unsigned getAggregateOperandIndex()
static InsertValueInst * Create(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &NameStr, BasicBlock *InsertAtEnd)
Value * getAggregateOperand()
static InsertValueInst * Create(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &NameStr, BasicBlock::iterator InsertBefore)
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
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 InvokeInst * Create(FunctionCallee Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles=std::nullopt, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
static bool classof(const Instruction *I)
BasicBlock * getUnwindDest() const
static InvokeInst * Create(FunctionCallee Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, const Twine &NameStr, BasicBlock *InsertAtEnd)
void setNormalDest(BasicBlock *B)
static bool classof(const Value *V)
static InvokeInst * Create(FunctionCallee Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles, const Twine &NameStr, BasicBlock *InsertAtEnd)
static InvokeInst * Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles, const Twine &NameStr, BasicBlock *InsertAtEnd)
void setSuccessor(unsigned i, BasicBlock *NewSucc)
static InvokeInst * Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles, const Twine &NameStr, BasicBlock::iterator InsertBefore)
static InvokeInst * Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, const Twine &NameStr, BasicBlock *InsertAtEnd)
static InvokeInst * Create(FunctionCallee Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, const Twine &NameStr, BasicBlock::iterator InsertBefore)
BasicBlock * getSuccessor(unsigned i) const
void setUnwindDest(BasicBlock *B)
static InvokeInst * Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, const Twine &NameStr, BasicBlock::iterator InsertBefore)
static InvokeInst * Create(FunctionCallee Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, const Twine &NameStr, Instruction *InsertBefore=nullptr)
BasicBlock * getNormalDest() const
static InvokeInst * Create(FunctionCallee Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles, const Twine &NameStr, BasicBlock::iterator InsertBefore)
static InvokeInst * Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles=std::nullopt, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
static InvokeInst * Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, const Twine &NameStr, Instruction *InsertBefore=nullptr)
unsigned getNumSuccessors() const
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.
static LandingPadInst * Create(Type *RetTy, unsigned NumReservedClauses, const Twine &NameStr, BasicBlock::iterator InsertBefore)
Constructors - NumReservedClauses is a hint for the number of incoming clauses that this landingpad w...
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.
This class implements a map that also provides access to all stored values in a deterministic order.
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)
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr, BasicBlock::iterator InsertBefore)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
BasicBlock *const * const_block_iterator
void setIncomingValue(unsigned i, Value *V)
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
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.
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr, BasicBlock *InsertAtEnd)
unsigned getNumIncomingValues() const
Return the number of incoming edges.
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, BasicBlock::iterator InsertBefore)
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
static ResumeInst * Create(Value *Exn, Instruction *InsertBefore=nullptr)
Value * getValue() const
Convenience accessor.
static ResumeInst * Create(Value *Exn, BasicBlock *InsertAtEnd)
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.
static ReturnInst * Create(LLVMContext &C, Value *retVal, BasicBlock *InsertAtEnd)
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, BasicBlock::iterator InsertBefore)
static ReturnInst * Create(LLVMContext &C, Value *retVal=nullptr, Instruction *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.
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.
static SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr, BasicBlock *InsertAtEnd)
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 SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr, BasicBlock::iterator InsertBefore, Instruction *MDFrom=nullptr)
static bool classof(const Value *V)
void setCondition(Value *V)
const Value * getTrueValue() const
static bool classof(const Instruction *I)
static SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr="", Instruction *InsertBefore=nullptr, Instruction *MDFrom=nullptr)
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.
static SwitchInst * Create(Value *Value, BasicBlock *Default, unsigned NumCases, BasicBlock::iterator InsertBefore)
BasicBlock * getDefaultDest() const
static SwitchInst * Create(Value *Value, BasicBlock *Default, unsigned NumCases, BasicBlock *InsertAtEnd)
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, Instruction *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...
VAArgInst(Value *List, Type *Ty, const Twine &NameStr, BasicBlock::iterator InsertBefore)
VAArgInst(Value *List, Type *Ty, const Twine &NameStr, BasicBlock *InsertAtEnd)
static bool classof(const Instruction *I)
Value * getPointerOperand()
const Value * getPointerOperand() const
static bool classof(const Value *V)
VAArgInst(Value *List, Type *Ty, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
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.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
APInt operator*(APInt a, uint64_t RHS)
unsigned getLoadStoreAddressSpace(Value *I)
A helper function that returns the address space of the pointer operand of load or store instruction.
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.
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...
Align getLoadStoreAlignment(Value *I)
A helper function that returns the alignment of load or store instruction.
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)
unsigned Log2(Align A)
Returns the log2 of the alignment.
@ Default
The result values are uniform if and only if all operands are uniform.
Type * getLoadStoreType(Value *I)
A helper function that returns the type of a load or store instruction.
This struct is a compact representation of a valid (non-zero power of two) alignment.
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
Used to keep track of an operand bundle.
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.
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...