65std::optional<TypeSize>
75 std::optional<uint64_t> NumElements =
C->getValue().tryZExtValue();
78 assert(!
Size.isScalable() &&
"Array elements cannot have a scalable size");
88std::optional<TypeSize>
108 return "both values to select must have same type";
111 return "select values cannot have token type";
116 return "vector select condition element type must be i1";
119 return "selected values for vector select must be vectors";
121 return "vector select requires selected vectors to have "
122 "the same vector length as select condition";
124 return "select condition must be i1 or <n x i1>";
133PHINode::PHINode(
const PHINode &PN)
135 ReservedSpace(PN.getNumOperands()) {
155 Op<-1>().set(
nullptr);
168 bool DeletePHIIfEmpty) {
172 for (
unsigned Idx =
NumOps; Idx-- > 0;) {
173 if (Predicate(Idx)) {
174 unsigned LastIdx =
NumOps - 1;
175 if (Idx != LastIdx) {
198void PHINode::growOperands() {
200 unsigned NumOps = e + e / 2;
214 if (ConstantValue !=
this)
219 if (ConstantValue ==
this)
221 return ConstantValue;
230 Value *ConstantValue =
nullptr;
234 if (ConstantValue && ConstantValue != Incoming)
236 ConstantValue = Incoming;
246LandingPadInst::LandingPadInst(
Type *RetTy,
unsigned NumReservedValues,
247 const Twine &NameStr,
250 init(NumReservedValues, NameStr);
255 ReservedSpace(LP.getNumOperands()) {
260 for (
unsigned I = 0,
E = ReservedSpace;
I !=
E; ++
I)
267 const Twine &NameStr,
269 return new LandingPadInst(RetTy, NumReservedClauses, NameStr, InsertBefore);
272void LandingPadInst::init(
unsigned NumReservedValues,
const Twine &NameStr) {
273 ReservedSpace = NumReservedValues;
282void LandingPadInst::growOperands(
unsigned Size) {
284 if (ReservedSpace >= e +
Size)
return;
285 ReservedSpace = (std::max(e, 1U) +
Size / 2) * 2;
292 assert(OpNo < ReservedSpace &&
"Growing didn't work!");
304 case Instruction::Call:
306 case Instruction::Invoke:
308 case Instruction::CallBr:
320 if (ChildOB.getTagName() != OpB.
getTag())
345 return CI->isMustTailCall();
352 return CI->isTailCall();
358 return F->getIntrinsicID();
366 Mask |=
F->getAttributes().getRetNoFPClass();
374 Mask |=
F->getAttributes().getParamNoFPClass(i);
382 FnAttr =
F->getRetAttribute(Attribute::Range);
407 if (
Attrs.hasAttrSomewhere(Kind, &Index))
410 if (
F->getAttributes().hasAttrSomewhere(Kind, &Index))
420 if (
Attrs.hasParamAttr(ArgNo, Kind))
427 if (!
F->getAttributes().hasParamAttr(ArgNo, Kind))
432 case Attribute::ReadNone:
434 case Attribute::ReadOnly:
436 case Attribute::WriteOnly:
444 bool AllowUndefOrPoison)
const {
446 "Argument must be a pointer");
448 (AllowUndefOrPoison ||
paramHasAttr(ArgNo, Attribute::NoUndef)))
462 return F->getAttributes().hasFnAttr(Kind);
467bool CallBase::hasFnAttrOnCalledFunction(
StringRef Kind)
const {
469 return F->getAttributes().hasFnAttr(Kind);
474template <
typename AK>
475Attribute CallBase::getFnAttrOnCalledFunction(AK Kind)
const {
476 if constexpr (std::is_same_v<AK, Attribute::AttrKind>) {
479 assert(Kind != Attribute::Memory &&
"Use getMemoryEffects() instead");
483 return F->getAttributes().getFnAttr(Kind);
491CallBase::getFnAttrOnCalledFunction(
StringRef Kind)
const;
493template <
typename AK>
494Attribute CallBase::getParamAttrOnCalledFunction(
unsigned ArgNo,
499 return F->getAttributes().getParamAttr(ArgNo, Kind);
506CallBase::getParamAttrOnCalledFunction(
unsigned ArgNo,
StringRef Kind)
const;
516 const unsigned BeginIndex) {
518 for (
auto &
B : Bundles)
519 It = std::copy(
B.input_begin(),
B.input_end(), It);
522 auto BI = Bundles.
begin();
523 unsigned CurrentIndex = BeginIndex;
526 assert(BI != Bundles.
end() &&
"Incorrect allocation?");
528 BOI.Tag = ContextImpl->getOrInsertBundleTag(BI->getTag());
529 BOI.Begin = CurrentIndex;
530 BOI.End = CurrentIndex + BI->input_size();
531 CurrentIndex = BOI.End;
535 assert(BI == Bundles.
end() &&
"Incorrect allocation?");
546 if (BOI.Begin <= OpIdx && OpIdx < BOI.End)
552 assert(OpIdx >=
arg_size() &&
"the Idx is not in the operand bundles");
555 "The Idx isn't in the operand bundle");
559 constexpr unsigned NumberScaling = 1024;
565 while (Begin !=
End) {
566 unsigned ScaledOperandPerBundle =
567 NumberScaling * (std::prev(
End)->End - Begin->
Begin) / (
End - Begin);
568 Current = Begin + (((OpIdx - Begin->
Begin) * NumberScaling) /
569 ScaledOperandPerBundle);
571 Current = std::prev(
End);
572 assert(Current < End && Current >= Begin &&
573 "the operand bundle doesn't cover every value in the range");
574 if (OpIdx >= Current->
Begin && OpIdx < Current->
End)
576 if (OpIdx >= Current->
End)
583 "the operand bundle doesn't cover every value in the range");
596 return Create(CB, Bundles, InsertPt);
602 bool CreateNew =
false;
606 if (Bundle.getTagID() == ID) {
613 return CreateNew ?
Create(CB, Bundles, InsertPt) : CB;
620 "Trying to remove non-existant operand bundle");
622 Bundles.
reserve(OpBundleCount - 1);
627 for (;
I != OpBundleCount; ++
I)
629 return Create(CB, Bundles, InsertPt);
736 CI &= Fn->getAttributes().getParamAttrs(OpNo).getCaptureInfo();
757 CI &= Fn->getAttributes().getParamAttrs(
I).getCaptureInfo();
772 "NumOperands not set up?");
777 "Calling a function with bad signature!");
779 for (
unsigned i = 0; i != Args.size(); ++i)
782 "Calling a function with a bad signature!");
811 init(Ty, Func, Name);
817 "Wrong number of operands allocated");
832 Args, OpB, CI->
getName(), InsertPt);
835 NewCI->FMF = CI->
FMF;
846 LLVM_DEBUG(
dbgs() <<
"Attempting to update profile weights will result in "
847 "div by 0. Ignoring. Likely the function "
849 <<
" has 0 entry count, and contains call instructions "
850 "with non-zero prof info.");
863 const Twine &NameStr) {
868 "NumOperands not set up?");
873 "Invoking a function with bad signature");
875 for (
unsigned i = 0, e = Args.size(); i != e; i++)
878 "Invoking a function with a bad signature!");
898 "Wrong number of operands allocated");
901 std::copy(
II.bundle_op_info_begin(),
II.bundle_op_info_end(),
908 std::vector<Value *> Args(
II->arg_begin(),
II->arg_end());
911 II->getFunctionType(),
II->getCalledOperand(),
II->getNormalDest(),
912 II->getUnwindDest(), Args, OpB,
II->getName(), InsertPt);
913 NewII->setCallingConv(
II->getCallingConv());
914 NewII->SubclassOptionalData =
II->SubclassOptionalData;
915 NewII->setAttributes(
II->getAttributes());
916 NewII->setDebugLoc(
II->getDebugLoc());
926 LLVM_DEBUG(
dbgs() <<
"Attempting to update profile weights will result in "
927 "div by 0. Ignoring. Likely the function "
929 <<
" has 0 entry count, and contains call instructions "
930 "with non-zero prof info.");
944 const Twine &NameStr) {
948 IndirectDests.
size(),
950 "NumOperands not set up?");
955 "Calling a function with bad signature");
957 for (
unsigned i = 0, e = Args.size(); i != e; i++)
960 "Calling a function with a bad signature!");
966 NumIndirectDests = IndirectDests.
size();
968 for (
unsigned i = 0; i != NumIndirectDests; ++i)
983 "Wrong number of operands allocated");
989 NumIndirectDests = CBI.NumIndirectDests;
1003 NewCBI->NumIndirectDests = CBI->NumIndirectDests;
1015 "Wrong number of operands allocated");
1041 AllocMarker, InsertBefore) {
1053 "Wrong number of operands allocated");
1054 setSubclassData<Instruction::OpaqueField>(
1061void CleanupReturnInst::init(
Value *CleanupPad,
BasicBlock *UnwindBB) {
1063 setSubclassData<UnwindDestField>(
true);
1065 Op<0>() = CleanupPad;
1070CleanupReturnInst::CleanupReturnInst(
Value *CleanupPad,
BasicBlock *UnwindBB,
1075 init(CleanupPad, UnwindBB);
1096 AllocMarker, InsertBefore) {
1104CatchSwitchInst::CatchSwitchInst(
Value *ParentPad,
BasicBlock *UnwindDest,
1105 unsigned NumReservedValues,
1106 const Twine &NameStr,
1111 ++NumReservedValues;
1112 init(ParentPad, UnwindDest, NumReservedValues + 1);
1123 for (
unsigned I = 1,
E = ReservedSpace;
I !=
E; ++
I)
1128 unsigned NumReservedValues) {
1129 assert(ParentPad && NumReservedValues);
1131 ReservedSpace = NumReservedValues;
1135 Op<0>() = ParentPad;
1144void CatchSwitchInst::growOperands(
unsigned Size) {
1146 assert(NumOperands >= 1);
1147 if (ReservedSpace >= NumOperands +
Size)
1149 ReservedSpace = (NumOperands +
Size / 2) * 2;
1156 assert(OpNo < ReservedSpace &&
"Growing didn't work!");
1164 for (
Use *CurDst = HI.getCurrent(); CurDst != EndDst; ++CurDst)
1165 *CurDst = *(CurDst + 1);
1176 const Twine &NameStr) {
1186 "Wrong number of operands allocated");
1193 const Twine &NameStr,
1196 init(ParentPad, Args, NameStr);
1206 AllocMarker, InsertBefore) {}
1214 AllocMarker, InsertBefore) {
1221 Op<-1>() = BI.
Op<-1>();
1229void CondBrInst::AssertOK() {
1231 "May only branch on boolean predicates!");
1237 AllocMarker, InsertBefore) {
1251 Op<-3>() = BI.
Op<-3>();
1252 Op<-2>() = BI.
Op<-2>();
1253 Op<-1>() = BI.
Op<-1>();
1274 "Passed basic block into allocation size parameter! Use other ctor");
1276 "Allocation array size is not an integer!");
1283 "Insertion position cannot be null when alignment not provided!");
1286 "BB must be in a Function when alignment not provided!");
1288 return DL.getPrefTypeAlign(Ty);
1293 :
AllocaInst(Ty, AddrSpace, nullptr, Name, InsertBefore) {}
1308 assert(!Ty->isVoidTy() &&
"Cannot allocate void!");
1314 return !CI->isOne();
1334void LoadInst::AssertOK() {
1336 "Ptr must have pointer type.");
1341 "Insertion position cannot be null when alignment not provided!");
1344 "BB must be in a Function when alignment not provided!");
1346 return DL.getABITypeAlign(Ty);
1366 :
LoadInst(Ty, Ptr, Name, Props.IsVolatile, Props.Alignment, Props.Ordering,
1367 Props.SSID, InsertBef) {
1386void StoreInst::AssertOK() {
1389 "Ptr must have pointer type!");
1409 :
StoreInst(Val, Ptr, Props.IsVolatile, Props.Alignment, Props.Ordering,
1410 Props.SSID, InsertBefore) {
1444 "All operands must be non-null!");
1446 "Ptr must have pointer type!");
1448 "Cmp type and NewVal type must be same!");
1459 AtomicCmpXchg, AllocMarker, InsertBefore) {
1460 Init(Ptr, Cmp, NewVal, Alignment, SuccessOrdering, FailureOrdering, SSID);
1467void AtomicRMWInst::Init(BinOp Operation,
Value *Ptr,
Value *Val,
1471 "atomicrmw instructions can only be atomic.");
1473 "atomicrmw instructions cannot be unordered.");
1484 "Ptr must have pointer type!");
1486 "AtomicRMW instructions must be atomic!");
1494 Init(Operation, Ptr, Val, Alignment, Ordering, SSID, Elementwise);
1534 return "fmaximumnum";
1536 return "fminimumnum";
1546 return "<invalid operation>";
1568 const Twine &Name) {
1570 "NumOperands not initialized?");
1579 SourceElementType(GEPI.SourceElementType),
1580 ResultElementType(GEPI.ResultElementType) {
1582 "Wrong number of operands allocated");
1589 if (!Struct->indexValid(Idx))
1591 return Struct->getTypeAtIndex(Idx);
1593 if (!Idx->getType()->isIntOrIntVectorTy())
1596 return Array->getElementType();
1598 return Vector->getElementType();
1604 if (Idx >= Struct->getNumElements())
1606 return Struct->getElementType(Idx);
1609 return Array->getElementType();
1611 return Vector->getElementType();
1615template <
typename IndexTy>
1617 if (IdxList.
empty())
1619 for (IndexTy V : IdxList.
slice(1)) {
1646 if (!CI->isZero())
return false;
1703 APInt &ConstantOffset)
const {
1713ExtractElementInst::ExtractElementInst(
Value *Val,
Value *Index,
1717 ExtractElement, AllocMarker, InsertBef) {
1718 assert(isValidOperands(Val, Index) &&
1719 "Invalid extractelement instruction operands!");
1735InsertElementInst::InsertElementInst(
Value *Vec,
Value *Elt,
Value *Index,
1740 "Invalid insertelement instruction operands!");
1748 const Value *Index) {
1755 if (!Index->getType()->isIntegerTy())
1765 assert(V &&
"Cannot create placeholder of nullptr V");
1786 ShuffleVector, AllocMarker, InsertBefore) {
1788 "Invalid shuffle vector instruction operands!");
1804 ShuffleVector, AllocMarker, InsertBefore) {
1806 "Invalid shuffle vector instruction operands!");
1815 int NumMaskElts = ShuffleMask.size();
1817 for (
int i = 0; i != NumMaskElts; ++i) {
1823 assert(MaskElt >= 0 && MaskElt < 2 * NumOpElts &&
"Out-of-range mask");
1824 MaskElt = (MaskElt < NumOpElts) ? MaskElt + NumOpElts : MaskElt - NumOpElts;
1825 NewMask[i] = MaskElt;
1843 for (
int Elem : Mask)
1850 const Value *Mask) {
1852 if (!
V1->getType()->isVectorTy() ||
V1->getType() != V2->
getType())
1858 if (!MaskTy || !MaskTy->getElementType()->isIntegerTy(32) ||
1874 return !CI->uge(V1Size * 2);
1877 for (
Value *
Op : MV->operands()) {
1879 if (CI->uge(V1Size*2))
1891 if (CDS->getElementAsInteger(i) >= V1Size*2)
1905 Result.append(EC.getKnownMinValue(), MaskVal);
1909 assert(!EC.isScalable() &&
1910 "Scalable vector shuffle mask must be undef or zeroinitializer");
1912 unsigned NumElts = EC.getFixedValue();
1914 Result.reserve(NumElts);
1917 for (
unsigned i = 0; i != NumElts; ++i)
1918 Result.push_back(CDS->getElementAsInteger(i));
1921 for (
unsigned i = 0; i != NumElts; ++i) {
1922 Constant *
C = Mask->getAggregateElement(i);
1929 ShuffleMask.assign(Mask.begin(), Mask.end());
1944 for (
int Elem : Mask) {
1948 MaskConst.
push_back(ConstantInt::get(Int32Ty, Elem));
1954 assert(!Mask.empty() &&
"Shuffle mask must contain elements");
1955 bool UsesLHS =
false;
1956 bool UsesRHS =
false;
1957 for (
int I : Mask) {
1960 assert(
I >= 0 &&
I < (NumOpElts * 2) &&
1961 "Out-of-bounds shuffle mask element");
1962 UsesLHS |= (
I < NumOpElts);
1963 UsesRHS |= (
I >= NumOpElts);
1964 if (UsesLHS && UsesRHS)
1968 return UsesLHS || UsesRHS;
1980 for (
int i = 0, NumMaskElts = Mask.size(); i < NumMaskElts; ++i) {
1983 if (Mask[i] != i && Mask[i] != (NumOpElts + i))
1990 if (Mask.size() !=
static_cast<unsigned>(NumSrcElts))
1998 if (Mask.size() !=
static_cast<unsigned>(NumSrcElts))
2007 for (
int I = 0, E = Mask.size();
I < E; ++
I) {
2010 if (Mask[
I] != (NumSrcElts - 1 -
I) &&
2011 Mask[
I] != (NumSrcElts + NumSrcElts - 1 -
I))
2018 if (Mask.size() !=
static_cast<unsigned>(NumSrcElts))
2022 for (
int I = 0, E = Mask.size();
I < E; ++
I) {
2025 if (Mask[
I] != 0 && Mask[
I] != NumSrcElts)
2032 if (Mask.size() !=
static_cast<unsigned>(NumSrcElts))
2037 for (
int I = 0, E = Mask.size();
I < E; ++
I) {
2040 if (Mask[
I] !=
I && Mask[
I] != (NumSrcElts +
I))
2053 if (Mask.size() !=
static_cast<unsigned>(NumSrcElts))
2056 int Sz = Mask.size();
2061 if (Mask[0] != 0 && Mask[0] != 1)
2066 if ((Mask[1] - Mask[0]) != NumSrcElts)
2071 for (
int I = 2;
I < Sz; ++
I) {
2072 int MaskEltVal = Mask[
I];
2073 if (MaskEltVal == -1)
2075 int MaskEltPrevVal = Mask[
I - 2];
2076 if (MaskEltVal - MaskEltPrevVal != 2)
2084 if (Mask.size() !=
static_cast<unsigned>(NumSrcElts))
2087 int StartIndex = -1;
2088 for (
int I = 0, E = Mask.size();
I != E; ++
I) {
2089 int MaskEltVal = Mask[
I];
2090 if (MaskEltVal == -1)
2093 if (StartIndex == -1) {
2096 if (MaskEltVal <
I || NumSrcElts <= (MaskEltVal -
I))
2099 StartIndex = MaskEltVal -
I;
2104 if (MaskEltVal != (StartIndex +
I))
2108 if (StartIndex == -1)
2117 int NumSrcElts,
int &Index) {
2123 if (NumSrcElts <= (
int)Mask.size())
2128 for (
int i = 0, e = Mask.size(); i != e; ++i) {
2132 int Offset = (M % NumSrcElts) - i;
2133 if (0 <= SubIndex && SubIndex !=
Offset)
2138 if (0 <= SubIndex && SubIndex + (
int)Mask.size() <= NumSrcElts) {
2146 int NumSrcElts,
int &NumSubElts,
2148 int NumMaskElts = Mask.size();
2151 if (NumMaskElts < NumSrcElts)
2162 bool Src0Identity =
true;
2163 bool Src1Identity =
true;
2165 for (
int i = 0; i != NumMaskElts; ++i) {
2171 if (M < NumSrcElts) {
2173 Src0Identity &= (M == i);
2177 Src1Identity &= (M == (i + NumSrcElts));
2179 assert((Src0Elts | Src1Elts | UndefElts).isAllOnes() &&
2180 "unknown shuffle elements");
2182 "2-source shuffle not found");
2188 int Src0Hi = NumMaskElts - Src0Elts.
countl_zero();
2189 int Src1Hi = NumMaskElts - Src1Elts.
countl_zero();
2194 int NumSub1Elts = Src1Hi - Src1Lo;
2197 NumSubElts = NumSub1Elts;
2206 int NumSub0Elts = Src0Hi - Src0Lo;
2209 NumSubElts = NumSub0Elts;
2226 if (NumMaskElts <= NumOpElts)
2235 for (
int i = NumOpElts; i < NumMaskElts; ++i)
2250 if (NumMaskElts >= NumOpElts)
2268 if (NumMaskElts != NumOpElts * 2)
2279 int ReplicationFactor,
int VF) {
2280 assert(Mask.size() == (
unsigned)ReplicationFactor * VF &&
2281 "Unexpected mask size.");
2283 for (
int CurrElt :
seq(VF)) {
2284 ArrayRef<int> CurrSubMask = Mask.take_front(ReplicationFactor);
2285 assert(CurrSubMask.
size() == (
unsigned)ReplicationFactor &&
2286 "Run out of mask?");
2287 Mask = Mask.drop_front(ReplicationFactor);
2288 if (!
all_of(CurrSubMask, [CurrElt](
int MaskElt) {
2293 assert(Mask.empty() &&
"Did not consume the whole mask?");
2299 int &ReplicationFactor,
int &VF) {
2303 Mask.take_while([](
int MaskElt) {
return MaskElt == 0; }).
size();
2304 if (ReplicationFactor == 0 || Mask.size() % ReplicationFactor != 0)
2306 VF = Mask.size() / ReplicationFactor;
2318 for (
int MaskElt : Mask) {
2322 if (MaskElt < Largest)
2324 Largest = std::max(Largest, MaskElt);
2328 for (
int PossibleReplicationFactor :
2330 if (Mask.size() % PossibleReplicationFactor != 0)
2332 int PossibleVF = Mask.size() / PossibleReplicationFactor;
2336 ReplicationFactor = PossibleReplicationFactor;
2352 if (ShuffleMask.size() % VF != 0)
2354 ReplicationFactor = ShuffleMask.size() / VF;
2360 if (VF <= 0 || Mask.size() <
static_cast<unsigned>(VF) ||
2361 Mask.size() % VF != 0)
2363 for (
unsigned K = 0, Sz = Mask.size();
K < Sz;
K += VF) {
2368 for (
int Idx : SubMask) {
2396 unsigned OpNumElts =
OpTy->getNumElements();
2404 unsigned NumElts = Mask.size();
2405 if (NumElts % Factor)
2408 unsigned LaneLen = NumElts / Factor;
2412 StartIndexes.
resize(Factor);
2418 for (;
I < Factor;
I++) {
2419 unsigned SavedLaneValue;
2420 unsigned SavedNoUndefs = 0;
2423 for (J = 0; J < LaneLen - 1; J++) {
2425 unsigned Lane = J * Factor +
I;
2426 unsigned NextLane = Lane + Factor;
2427 int LaneValue = Mask[Lane];
2428 int NextLaneValue = Mask[NextLane];
2431 if (LaneValue >= 0 && NextLaneValue >= 0 &&
2432 LaneValue + 1 != NextLaneValue)
2436 if (LaneValue >= 0 && NextLaneValue < 0) {
2437 SavedLaneValue = LaneValue;
2446 if (SavedNoUndefs > 0 && LaneValue < 0) {
2448 if (NextLaneValue >= 0 &&
2449 SavedLaneValue + SavedNoUndefs != (
unsigned)NextLaneValue)
2454 if (J < LaneLen - 1)
2460 StartMask = Mask[
I];
2461 }
else if (Mask[(LaneLen - 1) * Factor +
I] >= 0) {
2463 StartMask = Mask[(LaneLen - 1) * Factor +
I] - J;
2464 }
else if (SavedNoUndefs > 0) {
2466 StartMask = SavedLaneValue - (LaneLen - 1 - SavedNoUndefs);
2473 if (StartMask + LaneLen > NumInputElts)
2476 StartIndexes[
I] = StartMask;
2489 for (
unsigned Idx = 0; Idx < Factor; Idx++) {
2494 for (;
I < Mask.size();
I++)
2495 if (Mask[
I] >= 0 &&
static_cast<unsigned>(Mask[
I]) != Idx +
I * Factor)
2498 if (
I == Mask.size()) {
2512 int NumElts = Mask.size();
2513 assert((NumElts % NumSubElts) == 0 &&
"Illegal shuffle mask");
2516 for (
int i = 0; i != NumElts; i += NumSubElts) {
2517 for (
int j = 0; j != NumSubElts; ++j) {
2518 int M = Mask[i + j];
2521 if (M < i || M >= i + NumSubElts)
2523 int Offset = (NumSubElts - (M - (i + j))) % NumSubElts;
2524 if (0 <= RotateAmt &&
Offset != RotateAmt)
2533 ArrayRef<int> Mask,
unsigned EltSizeInBits,
unsigned MinSubElts,
2534 unsigned MaxSubElts,
unsigned &NumSubElts,
unsigned &RotateAmt) {
2535 for (NumSubElts = MinSubElts; NumSubElts <= MaxSubElts; NumSubElts *= 2) {
2537 if (EltRotateAmt < 0)
2539 RotateAmt = EltRotateAmt * EltSizeInBits;
2551 const Twine &Name) {
2558 assert(!Idxs.
empty() &&
"InsertValueInst must have at least one index");
2561 Val->
getType() &&
"Inserted value must match indexed type!");
2571 Indices(IVI.Indices) {
2586 assert(!Idxs.
empty() &&
"ExtractValueInst must have at least one index");
2588 Indices.append(Idxs.
begin(), Idxs.
end());
2595 Indices(EVI.Indices) {
2607 for (
unsigned Index : Idxs) {
2615 if (Index >= AT->getNumElements())
2617 Agg = AT->getElementType();
2619 if (Index >= ST->getNumElements())
2621 Agg = ST->getElementType(Index);
2637 "Invalid bitinsert instruction operands!");
2646 if (!
Base->getType()->isByteTy())
2647 return "bitinsert base must be a byte type";
2650 return "bitinsert value must be an integer, floating-point, pointer, or "
2652 if (!
Offset->getType()->isIntegerTy(32))
2653 return "bitinsert offset must be i32";
2662 :
Instruction(Ty, BitExtract, AllocMarker, InsertBef) {
2664 "Invalid bitextract instruction operands!");
2672 if (!(Ty->isFloatingPointTy() || Ty->isIntegerTy() || Ty->isPointerTy() ||
2674 return "bitextract result must be an integer, floating-point, pointer, or "
2676 if (!Src->getType()->isByteTy())
2677 return "bitextract source must be a byte type";
2678 if (!
Offset->getType()->isIntegerTy(32))
2679 return "bitextract offset must be i32";
2698 case UnaryOps::FNeg:
2705void UnaryOperator::AssertOK() {
2712 "Unary operation should return same type as operand!");
2714 "Tried to create a floating-point operation on a "
2715 "non-floating-point type!");
2728 :
Instruction(Ty, iType, AllocMarker, InsertBefore) {
2735void BinaryOperator::AssertOK() {
2737 (void)LHS; (void)RHS;
2738 assert(LHS->getType() == RHS->getType() &&
2739 "Binary operator operand types must match!");
2745 "Arithmetic operation should return same type as operands!");
2747 "Tried to create an integer operation on a non-integer type!");
2752 "Arithmetic operation should return same type as operands!");
2754 "Tried to create a floating-point operation on a "
2755 "non-floating-point type!");
2760 "Arithmetic operation should return same type as operands!");
2762 "Incorrect operand type (not integer) for S/UDIV");
2766 "Arithmetic operation should return same type as operands!");
2768 "Incorrect operand type (not floating point) for FDIV");
2773 "Arithmetic operation should return same type as operands!");
2775 "Incorrect operand type (not integer) for S/UREM");
2779 "Arithmetic operation should return same type as operands!");
2781 "Incorrect operand type (not floating point) for FREM");
2787 "Shift operation should return same type as operands!");
2789 "Tried to create a shift operation on a non-integral type!");
2794 "Logical operation should return same type as operands!");
2796 "Tried to create a logical operation on a non-integral type!");
2807 "Cannot create binary operator with two operands of differing type!");
2809 case BinaryOps::FAdd:
2810 case BinaryOps::FSub:
2811 case BinaryOps::FMul:
2812 case BinaryOps::FDiv:
2813 case BinaryOps::FRem:
2822 Value *Zero = ConstantInt::get(
Op->getType(), 0);
2829 Value *Zero = ConstantInt::get(
Op->getType(), 0);
2830 return BinaryOperator::CreateNSWSub(Zero,
Op, Name, InsertBefore);
2837 Op->getType(), Name, InsertBefore);
2870 default:
return false;
2871 case Instruction::ZExt:
2872 case Instruction::SExt:
2873 case Instruction::Trunc:
2875 case Instruction::BitCast:
2896 case Instruction::Trunc:
2897 case Instruction::ZExt:
2898 case Instruction::SExt:
2899 case Instruction::FPTrunc:
2900 case Instruction::FPExt:
2901 case Instruction::UIToFP:
2902 case Instruction::SIToFP:
2903 case Instruction::FPToUI:
2904 case Instruction::FPToSI:
2905 case Instruction::AddrSpaceCast:
2908 case Instruction::BitCast:
2910 case Instruction::PtrToAddr:
2911 case Instruction::PtrToInt:
2912 return DL.getIntPtrType(SrcTy)->getScalarSizeInBits() ==
2914 case Instruction::IntToPtr:
2915 return DL.getIntPtrType(DestTy)->getScalarSizeInBits() ==
2916 SrcTy->getScalarSizeInBits();
2967 const unsigned numCastOps =
2968 Instruction::CastOpsEnd - Instruction::CastOpsBegin;
2970 static const uint8_t CastResults[numCastOps][numCastOps] = {
2976 { 1, 0, 0,99,99, 0, 0,99,99,99,99, 0, 3, 0},
2977 { 8, 1, 9,99,99, 2,17,99,99,99,99, 2, 3, 0},
2978 { 8, 0, 1,99,99, 0, 2,99,99,99,99, 0, 3, 0},
2979 { 0, 0, 0,99,99, 0, 0,99,99,99,99, 0, 3, 0},
2980 { 0, 0, 0,99,99, 0, 0,99,99,99,99, 0, 3, 0},
2981 { 99,99,99, 0, 0,99,99, 0, 0,99,99,99, 4, 0},
2982 { 99,99,99, 0, 0,99,99, 0, 0,99,99,99, 4, 0},
2983 { 99,99,99, 0, 0,99,99, 0, 0,99,99,99, 4, 0},
2984 { 99,99,99, 2, 2,99,99, 8, 2,99,99,99, 4, 0},
2985 { 1, 0, 0,99,99, 0, 0,99,99,99,99, 7, 3, 0},
2986 { 0, 0, 0,99,99, 0, 0,99,99,99,99, 0, 3, 0},
2987 { 99,99,99,99,99,99,99,99,99,11,11,99,15, 0},
2988 { 5, 5, 5, 0, 0, 5, 5, 0, 0,16,16, 5,18,14},
2989 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,13,12},
2997 bool IsFirstBitcast = (firstOp == Instruction::BitCast);
2998 bool IsSecondBitcast = (secondOp == Instruction::BitCast);
2999 bool AreBothBitcasts = IsFirstBitcast && IsSecondBitcast;
3004 if (!AreBothBitcasts)
3007 int ElimCase = CastResults[firstOp-Instruction::CastOpsBegin]
3008 [secondOp-Instruction::CastOpsBegin];
3035 if (SrcTy->isIntegerTy())
3050 if (!
DL || MidSize < DL->getPointerTypeSizeInBits(SrcTy))
3053 return Instruction::BitCast;
3059 unsigned SrcSize = SrcTy->getScalarSizeInBits();
3062 return Instruction::BitCast;
3063 if (SrcSize < DstSize)
3065 if (SrcSize > DstSize)
3071 return Instruction::ZExt;
3076 unsigned MidSize = secondOp == Instruction::PtrToAddr
3077 ?
DL->getAddressSizeInBits(MidTy)
3078 :
DL->getPointerTypeSizeInBits(MidTy);
3079 unsigned SrcSize = SrcTy->getScalarSizeInBits();
3083 if (MidSize < SrcSize && MidSize < DstSize)
3085 if (DstSize < SrcSize)
3086 return Instruction::Trunc;
3087 if (DstSize > SrcSize)
3088 return Instruction::ZExt;
3089 return Instruction::BitCast;
3095 return Instruction::AddrSpaceCast;
3096 return Instruction::BitCast;
3106 SrcTy->isPtrOrPtrVectorTy() &&
3111 "Illegal addrspacecast, bitcast sequence!");
3118 if (!SrcTy->isPtrOrPtrVectorTy())
3120 return Instruction::AddrSpaceCast;
3130 SrcTy->isIntOrIntVectorTy() &&
3134 "Illegal inttoptr, bitcast sequence!");
3145 if (!SrcTy->isPtrOrPtrVectorTy()) {
3148 if (secondOp == Instruction::PtrToAddr &&
3150 return Instruction::BitCast;
3154 SrcTy->isPtrOrPtrVectorTy() &&
3158 "Illegal bitcast, ptrtoint sequence!");
3163 return Instruction::UIToFP;
3174 return Instruction::BitCast;
3177 return Instruction::BitCast;
3179 return Instruction::BitCast;
3180 if (SrcTy->isVectorTy() == DstTy->
isVectorTy() &&
DL) {
3183 return Instruction::PtrToInt;
3185 SrcTy->getScalarSizeInBits() ==
DL->getPointerTypeSizeInBits(DstTy))
3186 return Instruction::IntToPtr;
3203 case Trunc:
return new TruncInst (S, Ty, Name, InsertBefore);
3204 case ZExt:
return new ZExtInst (S, Ty, Name, InsertBefore);
3205 case SExt:
return new SExtInst (S, Ty, Name, InsertBefore);
3206 case FPTrunc:
return new FPTruncInst (S, Ty, Name, InsertBefore);
3207 case FPExt:
return new FPExtInst (S, Ty, Name, InsertBefore);
3208 case UIToFP:
return new UIToFPInst (S, Ty, Name, InsertBefore);
3209 case SIToFP:
return new SIToFPInst (S, Ty, Name, InsertBefore);
3210 case FPToUI:
return new FPToUIInst (S, Ty, Name, InsertBefore);
3211 case FPToSI:
return new FPToSIInst (S, Ty, Name, InsertBefore);
3212 case PtrToAddr:
return new PtrToAddrInst (S, Ty, Name, InsertBefore);
3213 case PtrToInt:
return new PtrToIntInst (S, Ty, Name, InsertBefore);
3214 case IntToPtr:
return new IntToPtrInst (S, Ty, Name, InsertBefore);
3216 return new BitCastInst(S, Ty, Name, InsertBefore);
3227 return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
3228 return Create(Instruction::ZExt, S, Ty, Name, InsertBefore);
3234 return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
3235 return Create(Instruction::SExt, S, Ty, Name, InsertBefore);
3241 return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
3242 return Create(Instruction::Trunc, S, Ty, Name, InsertBefore);
3249 assert((Ty->isIntOrIntVectorTy() || Ty->isPtrOrPtrVectorTy()) &&
3252 assert((!Ty->isVectorTy() ||
3257 if (Ty->isIntOrIntVectorTy())
3258 return Create(Instruction::PtrToInt, S, Ty, Name, InsertBefore);
3266 assert(Ty->isPtrOrPtrVectorTy() &&
"Invalid cast");
3269 return Create(Instruction::AddrSpaceCast, S, Ty, Name, InsertBefore);
3271 return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
3278 return Create(Instruction::PtrToInt, S, Ty, Name, InsertBefore);
3280 return Create(Instruction::IntToPtr, S, Ty, Name, InsertBefore);
3282 return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
3288 assert(
C->getType()->isIntOrIntVectorTy() && Ty->isIntOrIntVectorTy() &&
3289 "Invalid integer cast");
3290 unsigned SrcBits =
C->getType()->getScalarSizeInBits();
3291 unsigned DstBits = Ty->getScalarSizeInBits();
3293 (SrcBits == DstBits ? Instruction::BitCast :
3294 (SrcBits > DstBits ? Instruction::Trunc :
3295 (
isSigned ? Instruction::SExt : Instruction::ZExt)));
3296 return Create(opcode,
C, Ty, Name, InsertBefore);
3301 assert(
C->getType()->isFPOrFPVectorTy() && Ty->isFPOrFPVectorTy() &&
3303 unsigned SrcBits =
C->getType()->getScalarSizeInBits();
3304 unsigned DstBits = Ty->getScalarSizeInBits();
3305 assert((
C->getType() == Ty || SrcBits != DstBits) &&
"Invalid cast");
3307 (SrcBits == DstBits ? Instruction::BitCast :
3308 (SrcBits > DstBits ? Instruction::FPTrunc : Instruction::FPExt));
3309 return Create(opcode,
C, Ty, Name, InsertBefore);
3316 if (SrcTy == DestTy)
3321 if (SrcVecTy->getElementCount() == DestVecTy->getElementCount()) {
3323 SrcTy = SrcVecTy->getElementType();
3324 DestTy = DestVecTy->getElementType();
3331 return SrcPtrTy->getAddressSpace() == DestPtrTy->getAddressSpace();
3335 TypeSize SrcBits = SrcTy->getPrimitiveSizeInBits();
3343 if (SrcBits != DestBits)
3354 return (IntTy->getBitWidth() ==
DL.getPointerTypeSizeInBits(PtrTy) &&
3355 !
DL.isNonIntegralPointerType(PtrTy));
3358 return (IntTy->getBitWidth() ==
DL.getPointerTypeSizeInBits(PtrTy) &&
3359 !
DL.isNonIntegralPointerType(PtrTy));
3372 const Value *Src,
bool SrcIsSigned,
Type *DestTy,
bool DestIsSigned) {
3373 Type *SrcTy = Src->getType();
3376 "Only first class types are castable!");
3378 if (SrcTy == DestTy)
3384 if (SrcVecTy->getElementCount() == DestVecTy->getElementCount()) {
3387 SrcTy = SrcVecTy->getElementType();
3388 DestTy = DestVecTy->getElementType();
3395 SrcTy->getPrimitiveSizeInBits().getFixedValue();
3401 if (SrcTy->isIntegerTy()) {
3402 assert(DestBits == SrcBits &&
"Illegal cast from integer to byte type");
3404 }
else if (SrcTy->isPointerTy()) {
3405 assert(DestBits == SrcBits &&
"Illegal cast from pointer to byte type");
3410 if (SrcTy->isIntegerTy()) {
3411 if (DestBits < SrcBits)
3413 else if (DestBits > SrcBits) {
3421 }
else if (SrcTy->isFloatingPointTy()) {
3426 }
else if (SrcTy->isVectorTy()) {
3427 assert(DestBits == SrcBits &&
3428 "Casting vector to integer of different width");
3431 assert(SrcTy->isPointerTy() &&
3432 "Casting from a value that is not first-class type");
3436 if (SrcTy->isIntegerTy()) {
3441 }
else if (SrcTy->isFloatingPointTy()) {
3442 if (DestBits < SrcBits) {
3444 }
else if (DestBits > SrcBits) {
3449 }
else if (SrcTy->isVectorTy()) {
3450 assert(DestBits == SrcBits &&
3451 "Casting vector to floating point of different width");
3456 assert(DestBits == SrcBits &&
3457 "Illegal cast to vector (wrong type or size)");
3460 if (SrcTy->isPointerTy()) {
3462 return AddrSpaceCast;
3464 }
else if (SrcTy->isIntegerTy()) {
3490 unsigned SrcScalarBitSize = SrcTy->getScalarSizeInBits();
3503 default:
return false;
3504 case Instruction::Trunc:
3506 SrcEC == DstEC && SrcScalarBitSize > DstScalarBitSize;
3507 case Instruction::ZExt:
3509 SrcEC == DstEC && SrcScalarBitSize < DstScalarBitSize;
3510 case Instruction::SExt:
3512 SrcEC == DstEC && SrcScalarBitSize < DstScalarBitSize;
3513 case Instruction::FPTrunc:
3515 SrcEC == DstEC && SrcScalarBitSize > DstScalarBitSize;
3516 case Instruction::FPExt:
3518 SrcEC == DstEC && SrcScalarBitSize < DstScalarBitSize;
3519 case Instruction::UIToFP:
3520 case Instruction::SIToFP:
3523 case Instruction::FPToUI:
3524 case Instruction::FPToSI:
3527 case Instruction::PtrToAddr:
3528 case Instruction::PtrToInt:
3532 case Instruction::IntToPtr:
3536 case Instruction::BitCast: {
3550 (SrcTy->isByteOrByteVectorTy() && DstPtrTy))
3552 if (!SrcPtrTy != !DstPtrTy)
3565 if (SrcIsVec && DstIsVec)
3566 return SrcEC == DstEC;
3574 case Instruction::AddrSpaceCast: {
3586 return SrcEC == DstEC;
3593 :
CastInst(Ty, Trunc, S, Name, InsertBefore) {
3599 :
CastInst(Ty, ZExt, S, Name, InsertBefore) {
3605 :
CastInst(Ty, SExt, S, Name, InsertBefore) {
3611 :
CastInst(Ty, FPTrunc, S, Name, InsertBefore) {
3617 :
CastInst(Ty, FPExt, S, Name, InsertBefore) {
3623 :
CastInst(Ty, UIToFP, S, Name, InsertBefore) {
3629 :
CastInst(Ty, SIToFP, S, Name, InsertBefore) {
3635 :
CastInst(Ty, FPToUI, S, Name, InsertBefore) {
3641 :
CastInst(Ty, FPToSI, S, Name, InsertBefore) {
3647 :
CastInst(Ty, PtrToInt, S, Name, InsertBefore) {
3653 :
CastInst(Ty, PtrToAddr, S, Name, InsertBefore) {
3659 :
CastInst(Ty, IntToPtr, S, Name, InsertBefore) {
3665 :
CastInst(Ty, BitCast, S, Name, InsertBefore) {
3671 :
CastInst(Ty, AddrSpaceCast, S, Name, InsertBefore) {
3690 if (
Op == Instruction::ICmp) {
3726 return IC->isCommutative();
3803 default:
return "unknown";
3992 return LHS.ugt(RHS);
3994 return LHS.uge(RHS);
3996 return LHS.ult(RHS);
3998 return LHS.ule(RHS);
4000 return LHS.sgt(RHS);
4002 return LHS.sge(RHS);
4004 return LHS.slt(RHS);
4006 return LHS.sle(RHS);
4094 switch (predicate) {
4095 default:
return false;
4103 switch (predicate) {
4104 default:
return false;
4113 default:
return false;
4123 default:
return false;
4169 return std::nullopt;
4178 if (
A.Pred ==
B.Pred)
4182 if (
A.HasSameSign &&
4185 if (
B.HasSameSign &&
4197 return ICI->getCmpPredicate();
4198 return Cmp->getPredicate();
4219 ReservedSpace = NumReserved;
4234 AllocMarker, InsertBefore) {
4240 init(
SI.getCondition(),
SI.getDefaultDest(),
SI.getNumOperands());
4241 setNumHungOffUseOperands(
SI.getNumOperands());
4242 Use *OL = getOperandList();
4243 ConstantInt **VL = case_values();
4244 const Use *InOL =
SI.getOperandList();
4245 ConstantInt *
const *InVL =
SI.case_values();
4246 for (
unsigned i = 2,
E =
SI.getNumOperands(); i !=
E; ++i) {
4248 VL[i - 2] = InVL[i - 2];
4250 SubclassOptionalData =
SI.SubclassOptionalData;
4258 if (OpNo + 1 > ReservedSpace)
4261 assert(OpNo < ReservedSpace &&
"Growing didn't work!");
4271 unsigned idx =
I->getCaseIndex();
4280 if (2 + idx + 1 !=
NumOps) {
4281 OL[2 + idx] = OL[
NumOps - 1];
4282 VL[idx] = VL[
NumOps - 2 - 1];
4287 VL[
NumOps - 2 - 1] =
nullptr;
4290 return CaseIt(
this, idx);
4296void SwitchInst::growOperands() {
4311 "not correspond to number of succesors");
4317 this->Weights = std::move(Weights);
4323 assert(SI.getNumSuccessors() == Weights->size() &&
4324 "num of prof branch_weights must accord with num of successors");
4329 (*Weights)[
I->getCaseIndex() + 1] = Weights->back();
4330 Weights->pop_back();
4332 return SI.removeCase(
I);
4336 auto *DestBlock =
I->getCaseSuccessor();
4339 (*Weights)[0] = Weight.value();
4342 SI.setDefaultDest(DestBlock);
4348 SI.addCase(OnVal, Dest);
4350 if (!Weights && W && *W) {
4353 (*Weights)[SI.getNumSuccessors() - 1] = *W;
4354 }
else if (Weights) {
4356 Weights->push_back(W.value_or(0));
4359 assert(SI.getNumSuccessors() == Weights->size() &&
4360 "num of prof branch_weights must accord with num of successors");
4369 return SI.eraseFromParent();
4375 return std::nullopt;
4376 return (*Weights)[idx];
4388 auto &OldW = (*Weights)[idx];
4402 return Weights[idx];
4405 return std::nullopt;
4412void IndirectBrInst::init(
Value *
Address,
unsigned NumDests) {
4414 "Address of indirectbr must be a pointer");
4415 ReservedSpace = 1 + NumDests;
4426void IndirectBrInst::growOperands() {
4434IndirectBrInst::IndirectBrInst(
Value *
Address,
unsigned NumCases,
4437 Instruction::IndirectBr, AllocMarker, InsertBefore) {
4446 Use *OL = getOperandList();
4457 if (OpNo+1 > ReservedSpace)
4460 assert(OpNo < ReservedSpace &&
"Growing didn't work!");
4474 OL[idx+1] = OL[
NumOps-1];
4499 return new (AllocMarker) GetElementPtrInst(*
this, AllocMarker);
4514 "Should call FPBinaryOperator::cloneImpl!");
4538 return new ExtractValueInst(*
this);
4542 return new InsertValueInst(*
this);
4568 Result->setWeak(
isWeak());
4653 return new (AllocMarker) CallInst(*
this, AllocMarker);
4656 return new (AllocMarker) CallInst(*
this, AllocMarker);
4692 return new LandingPadInst(*
this);
4697 return new (AllocMarker) ReturnInst(*
this, AllocMarker);
4701 return new (AllocMarker) UncondBrInst(*
this);
4705 return new (AllocMarker) CondBrInst(*
this);
4711 return new IndirectBrInst(*
this);
4719 return new (AllocMarker) InvokeInst(*
this, AllocMarker);
4722 return new (AllocMarker) InvokeInst(*
this, AllocMarker);
4730 return new (AllocMarker) CallBrInst(*
this, AllocMarker);
4733 return new (AllocMarker) CallBrInst(*
this, AllocMarker);
4737 return new (AllocMarker) ResumeInst(*
this);
4742 return new (AllocMarker) CleanupReturnInst(*
this, AllocMarker);
4746 return new (AllocMarker) CatchReturnInst(*
this);
4750 return new CatchSwitchInst(*
this);
4755 return new (AllocMarker) FuncletPadInst(*
this, AllocMarker);
4764 bool NoTrapAfterNoreturn)
const {
4765 if (!TrapUnreachable)
4771 if (NoTrapAfterNoreturn)
4774 if (
Call->isNonContinuableTrap())
4778 if (
getFunction()->hasFnAttribute(Attribute::Naked))
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Atomic ordering constants.
This file contains the simple types necessary to represent the attributes associated with functions a...
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static bool isSigned(unsigned Opcode)
Module.h This file contains the declarations for the Module class.
static Align computeLoadStoreDefaultAlign(Type *Ty, InsertPosition Pos)
static bool isImpliedFalseByMatchingCmp(CmpPredicate Pred1, CmpPredicate Pred2)
static Value * createPlaceholderForShuffleVector(Value *V)
static Align computeAllocaDefaultAlign(Type *Ty, InsertPosition Pos)
static bool hasNonZeroFPOperands(const CmpInst *Cmp)
static int matchShuffleAsBitRotate(ArrayRef< int > Mask, int NumSubElts)
Try to lower a vector shuffle as a bit rotation.
static Type * getIndexedTypeInternal(Type *Ty, ArrayRef< IndexTy > IdxList)
static bool isReplicationMaskWithParams(ArrayRef< int > Mask, int ReplicationFactor, int VF)
static bool isIdentityMaskImpl(ArrayRef< int > Mask, int NumOpElts)
static Value * getAISize(LLVMContext &Context, Value *Amt)
static bool isImpliedTrueByMatchingCmp(CmpPredicate Pred1, CmpPredicate Pred2)
static bool isSingleSourceMaskImpl(ArrayRef< int > Mask, int64_t NumOpElts)
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
uint64_t IntrinsicInst * II
This file contains the declarations for profiling metadata utility functions.
const SmallVectorImpl< MachineOperand > & Cond
Func getContext().diagnose(DiagnosticInfoUnsupported(Func
This file implements the SmallBitVector class.
This file defines the SmallVector class.
static SymbolRef::Type getType(const Symbol *Sym)
cmpResult
IEEE-754R 5.11: Floating Point Comparison Relations.
LLVM_ABI float convertToFloat() const
Converts this APFloat to host float value.
Class for arbitrary precision integers.
void setBit(unsigned BitPosition)
Set the given bit to 1 whose position is given as "bitPosition".
bool isZero() const
Determine if this value is zero, i.e. all bits are clear.
unsigned countr_zero() const
Count the number of trailing zero bits.
unsigned countl_zero() const
The APInt version of std::countl_zero.
static APInt getZero(unsigned numBits)
Get the '0' value for the specified bit-width.
This class represents a conversion between pointers from one address space to another.
LLVM_ABI AddrSpaceCastInst * cloneImpl() const
Clone an identical AddrSpaceCastInst.
LLVM_ABI AddrSpaceCastInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
LLVM_ABI std::optional< TypeSize > getAllocationSizeInBits(const DataLayout &DL) const
Get allocation size in bits.
bool isSwiftError() const
Return true if this alloca is used as a swifterror argument to a call.
LLVM_ABI 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.
LLVM_ABI TypeSize getAllocationBaseSize(const DataLayout &DL) const
Get the size of the allocated type.
LLVM_ABI 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.
LLVM_ABI std::optional< TypeSize > getAllocationSize(const DataLayout &DL) const
Get allocation size in bytes.
LLVM_ABI 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.
LLVM_ABI AllocaInst(Type *Ty, unsigned AddrSpace, Value *ArraySize, const Twine &Name, InsertPosition InsertBefore)
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
bool empty() const
Check if the array is empty.
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
Class to represent array types.
void setSyncScopeID(SyncScope::ID SSID)
Sets the synchronization scope ID of this cmpxchg instruction.
bool isVolatile() const
Return true if this is a cmpxchg from a volatile memory location.
void setFailureOrdering(AtomicOrdering Ordering)
Sets the failure ordering constraint of this cmpxchg instruction.
AtomicOrdering getFailureOrdering() const
Returns the failure ordering constraint of this cmpxchg instruction.
void setSuccessOrdering(AtomicOrdering Ordering)
Sets the success ordering constraint of this cmpxchg instruction.
LLVM_ABI AtomicCmpXchgInst * cloneImpl() const
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
friend class Instruction
Iterator for Instructions in a `BasicBlock.
bool isWeak() const
Return true if this cmpxchg may spuriously fail.
void setAlignment(Align Align)
AtomicOrdering getSuccessOrdering() const
Returns the success ordering constraint of this cmpxchg instruction.
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this cmpxchg instruction.
LLVM_ABI AtomicCmpXchgInst(Value *Ptr, Value *Cmp, Value *NewVal, Align Alignment, AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering, SyncScope::ID SSID, InsertPosition InsertBefore=nullptr)
bool isElementwise() const
Return true if this RMW has elementwise vector semantics.
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
LLVM_ABI AtomicRMWInst * cloneImpl() const
bool isVolatile() const
Return true if this is a RMW on a volatile memory location.
LLVM_ABI AtomicRMWInst(BinOp Operation, Value *Ptr, Value *Val, Align Alignment, AtomicOrdering Ordering, SyncScope::ID SSID, bool Elementwise=false, InsertPosition InsertBefore=nullptr)
BinOp
This enumeration lists the possible modifications atomicrmw can make.
@ USubCond
Subtract only if no unsigned overflow.
@ FMinimum
*p = minimum(old, v) minimum matches the behavior of llvm.minimum.
@ Min
*p = old <signed v ? old : v
@ USubSat
*p = usub.sat(old, v) usub.sat matches the behavior of llvm.usub.sat.
@ FMaximum
*p = maximum(old, v) maximum matches the behavior of llvm.maximum.
@ 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
@ FMaximumNum
*p = maximumnum(old, v) maximumnum matches the behavior of llvm.maximumnum.
@ FMax
*p = maxnum(old, v) maxnum matches the behavior of llvm.maxnum.
@ UDecWrap
Decrement one until a minimum value or zero.
@ FMinimumNum
*p = minimumnum(old, v) minimumnum matches the behavior of llvm.minimumnum.
void setSyncScopeID(SyncScope::ID SSID)
Sets the synchronization scope ID of this rmw instruction.
void setOrdering(AtomicOrdering Ordering)
Sets the ordering constraint of this rmw instruction.
void setOperation(BinOp Operation)
friend class Instruction
Iterator for Instructions in a `BasicBlock.
BinOp getOperation() const
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this rmw instruction.
void setAlignment(Align Align)
void setElementwise(bool V)
Specify whether this RMW has elementwise vector semantics.
static LLVM_ABI StringRef getOperationName(BinOp Op)
AtomicOrdering getOrdering() const
Returns the ordering constraint of this rmw instruction.
LLVM_ABI CaptureInfo getCaptureInfo() const
Functions, function parameters, and return types can have attributes to indicate how they should be t...
LLVM_ABI const ConstantRange & getRange() const
Returns the value of the range attribute.
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
static LLVM_ABI Attribute getWithMemoryEffects(LLVMContext &Context, MemoryEffects ME)
bool isValid() const
Return true if the attribute is any kind of attribute.
LLVM Basic Block Representation.
const Function * getParent() const
Return the enclosing method, or null if none.
LLVM_ABI const DataLayout & getDataLayout() const
Get the data layout of the module this basic block belongs to.
static LLVM_ABI BinaryOperator * CreateNeg(Value *Op, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Helper functions to construct and inspect unary operations (NEG and NOT) via binary operators SUB and...
BinaryOps getOpcode() const
LLVM_ABI bool swapOperands()
Exchange the two operands to this instruction.
static LLVM_ABI BinaryOperator * CreateNot(Value *Op, const Twine &Name="", InsertPosition InsertBefore=nullptr)
friend class Instruction
Iterator for Instructions in a `BasicBlock.
static LLVM_ABI BinaryOperator * Create(BinaryOps Op, Value *S1, Value *S2, const Twine &Name=Twine(), InsertPosition InsertBefore=nullptr)
Construct a binary instruction, given the opcode and the two operands.
LLVM_ABI BinaryOperator(BinaryOps iType, Value *S1, Value *S2, Type *Ty, const Twine &Name, InsertPosition InsertBefore)
static LLVM_ABI BinaryOperator * CreateNSWNeg(Value *Op, const Twine &Name="", InsertPosition InsertBefore=nullptr)
LLVM_ABI BinaryOperator * cloneImpl() const
This class represents a no-op cast from one type to another.
LLVM_ABI BitCastInst * cloneImpl() const
Clone an identical BitCastInst.
LLVM_ABI BitCastInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
static LLVM_ABI const char * areInvalidOperands(Value *Base, Value *Val, Value *Offset)
Return a string if the specified operands are invalid for a bitinsert operation, otherwise return nul...
static BitInsertInst * Create(Value *Base, Value *Val, Value *Offset, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
LLVM_ABI BitInsertInst * cloneImpl() const
Clone an identical BitInsertInst.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
LLVM_ABI FPClassTest getParamNoFPClass(unsigned i) const
Extract a test mask for disallowed floating-point value classes for the parameter.
bool isInlineAsm() const
Check if this call is an inline asm statement.
LLVM_ABI BundleOpInfo & getBundleOpInfoForOperand(unsigned OpIdx)
Return the BundleOpInfo for the operand at index OpIdx.
void setCallingConv(CallingConv::ID CC)
LLVM_ABI FPClassTest getRetNoFPClass() const
Extract a test mask for disallowed floating-point value classes for the return value.
bundle_op_iterator bundle_op_info_begin()
Return the start of the list of BundleOpInfo instances associated with this OperandBundleUser.
LLVM_ABI bool paramHasNonNullAttr(unsigned ArgNo, bool AllowUndefOrPoison) const
Return true if this argument has the nonnull attribute on either the CallBase instruction or the call...
LLVM_ABI MemoryEffects getMemoryEffects() const
void addFnAttr(Attribute::AttrKind Kind)
Adds the attribute to the function.
LLVM_ABI bool doesNotAccessMemory() const
Determine if the call does not access memory.
LLVM_ABI void getOperandBundlesAsDefs(SmallVectorImpl< OperandBundleDef > &Defs) const
Return the list of operand bundles attached to this instruction as a vector of OperandBundleDefs.
LLVM_ABI void setOnlyAccessesArgMemory()
OperandBundleUse getOperandBundleAt(unsigned Index) const
Return the operand bundle at a specific index.
OperandBundleUse operandBundleFromBundleOpInfo(const BundleOpInfo &BOI) const
Simple helper function to map a BundleOpInfo to an OperandBundleUse.
LLVM_ABI void setOnlyAccessesInaccessibleMemOrArgMem()
std::optional< OperandBundleUse > getOperandBundle(StringRef Name) const
Return an operand bundle by name, if present.
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
LLVM_ABI void setDoesNotAccessMemory()
AttributeSet getParamAttributes(unsigned ArgNo) const
Return the param attributes for this call.
bool hasRetAttr(Attribute::AttrKind Kind) const
Determine whether the return value has the given attribute.
LLVM_ABI bool onlyAccessesInaccessibleMemory() const
Determine if the function may only access memory that is inaccessible from the IR.
unsigned getNumOperandBundles() const
Return the number of operand bundles associated with this User.
CallingConv::ID getCallingConv() const
bundle_op_iterator bundle_op_info_end()
Return the end of the list of BundleOpInfo instances associated with this OperandBundleUser.
LLVM_ABI unsigned getNumSubclassExtraOperandsDynamic() const
Get the number of extra operands for instructions that don't have a fixed number of extra operands.
BundleOpInfo * bundle_op_iterator
LLVM_ABI bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Determine whether the argument or parameter has the given attribute.
User::op_iterator arg_begin()
Return the iterator pointing to the beginning of the argument list.
LLVM_ABI bool isMustTailCall() const
Tests if this call site must be tail call optimized.
LLVM_ABI bool isIndirectCall() const
Return true if the callsite is an indirect call.
LLVM_ABI bool onlyReadsMemory() const
Determine if the call does not access or only reads memory.
bool isByValArgument(unsigned ArgNo) const
Determine whether this argument is passed by value.
iterator_range< bundle_op_iterator > bundle_op_infos()
Return the range [bundle_op_info_begin, bundle_op_info_end).
LLVM_ABI void setOnlyReadsMemory()
static LLVM_ABI CallBase * addOperandBundle(CallBase *CB, uint32_t ID, OperandBundleDef OB, InsertPosition InsertPt=nullptr)
Create a clone of CB with operand bundle OB added.
LLVM_ABI bool onlyAccessesInaccessibleMemOrArgMem() const
Determine if the function may only access memory that is either inaccessible from the IR or pointed t...
static LLVM_ABI CallBase * removeOperandBundleAt(CallBase *CB, size_t Offset, InsertPosition InsertPtr=nullptr)
LLVM_ABI CaptureInfo getCaptureInfo(unsigned OpNo) const
Return which pointer components this operand may capture.
LLVM_ABI bool hasArgumentWithAdditionalReturnCaptureComponents() const
Returns whether the call has an argument that has an attribute like captures(ret: address,...
CallBase(AttributeList const &A, FunctionType *FT, ArgsTy &&... Args)
Value * getCalledOperand() const
LLVM_ABI void setOnlyWritesMemory()
LLVM_ABI op_iterator populateBundleOperandInfos(ArrayRef< OperandBundleDef > Bundles, const unsigned BeginIndex)
Populate the BundleOpInfo instances and the Use& vector from Bundles.
AttributeList Attrs
parameter attributes for callable
bool hasOperandBundlesOtherThan(ArrayRef< uint32_t > IDs) const
Return true if this operand bundle user contains operand bundles with tags other than those specified...
LLVM_ABI std::optional< ConstantRange > getRange() const
If this return value has a range attribute, return the value range of the argument.
LLVM_ABI bool isReturnNonNull() const
Return true if the return value is known to be not null.
Value * getArgOperand(unsigned i) const
uint64_t getRetDereferenceableBytes() const
Extract the number of dereferenceable bytes for a call or parameter (0=unknown).
User::op_iterator arg_end()
Return the iterator pointing to the end of the argument list.
FunctionType * getFunctionType() const
LLVM_ABI Intrinsic::ID getIntrinsicID() const
Returns the intrinsic ID of the intrinsic called or Intrinsic::not_intrinsic if the called function i...
static unsigned CountBundleInputs(ArrayRef< OperandBundleDef > Bundles)
Return the total number of values used in Bundles.
LLVM_ABI Value * getArgOperandWithAttribute(Attribute::AttrKind Kind) const
If one of the arguments has the specified attribute, returns its operand value.
LLVM_ABI void setOnlyAccessesInaccessibleMemory()
static LLVM_ABI CallBase * Create(CallBase *CB, ArrayRef< OperandBundleDef > Bundles, InsertPosition InsertPt=nullptr)
Create a clone of CB with a different set of operand bundles and insert it before InsertPt.
LLVM_ABI bool onlyWritesMemory() const
Determine if the call does not access or only writes memory.
LLVM_ABI bool hasClobberingOperandBundles() const
Return true if this operand bundle user has operand bundles that may write to the heap.
void setCalledOperand(Value *V)
static LLVM_ABI CallBase * removeOperandBundle(CallBase *CB, uint32_t ID, InsertPosition InsertPt=nullptr)
Create a clone of CB with operand bundle ID removed.
LLVM_ABI bool hasReadingOperandBundles() const
Return true if this operand bundle user has operand bundles that may read from the heap.
LLVM_ABI bool onlyAccessesArgMemory() const
Determine if the call can access memmory only using pointers based on its arguments.
unsigned arg_size() const
AttributeList getAttributes() const
Return the attributes for this call.
LLVM_ABI void setMemoryEffects(MemoryEffects ME)
bool hasOperandBundles() const
Return true if this User has any operand bundles.
LLVM_ABI bool isTailCall() const
Tests if this call site is marked as a tail call.
LLVM_ABI Function * getCaller()
Helper to get the caller (the parent function).
CallBr instruction, tracking function calls that may not return control but instead transfer it to a ...
SmallVector< BasicBlock *, 16 > getIndirectDests() const
void setDefaultDest(BasicBlock *B)
void setIndirectDest(unsigned i, BasicBlock *B)
BasicBlock * getDefaultDest() const
static CallBrInst * Create(FunctionType *Ty, Value *Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)
LLVM_ABI CallBrInst * cloneImpl() const
This class represents a function call, abstracting a target machine's calling convention.
LLVM_ABI void updateProfWeight(uint64_t S, uint64_t T)
Updates profile metadata by scaling it by S / T.
TailCallKind getTailCallKind() const
LLVM_ABI CallInst * cloneImpl() const
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Represents which components of the pointer may be captured in which location.
CaptureComponents getOtherComponents() const
Get components potentially captured through locations other than the return value.
static CaptureInfo none()
Create CaptureInfo that does not capture any components of the pointer.
static CaptureInfo all()
Create CaptureInfo that may capture all components of the pointer.
CaptureComponents getRetComponents() const
Get components potentially captured by the return value.
static LLVM_ABI Instruction::CastOps getCastOpcode(const Value *Val, bool SrcIsSigned, Type *Ty, bool DstIsSigned)
Returns the opcode necessary to cast Val into Ty using usual casting rules.
static LLVM_ABI CastInst * CreatePointerBitCastOrAddrSpaceCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a BitCast or an AddrSpaceCast cast instruction.
Instruction::CastOps getOpcode() const
Return the opcode of this CastInst.
static LLVM_ABI unsigned isEliminableCastPair(Instruction::CastOps firstOpcode, Instruction::CastOps secondOpcode, Type *SrcTy, Type *MidTy, Type *DstTy, const DataLayout *DL)
Determine how a pair of casts can be eliminated, if they can be at all.
static LLVM_ABI CastInst * CreateIntegerCast(Value *S, Type *Ty, bool isSigned, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a ZExt, BitCast, or Trunc for int -> int casts.
static LLVM_ABI CastInst * CreateFPCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create an FPExt, BitCast, or FPTrunc for fp -> fp casts.
CastInst(Type *Ty, unsigned iType, Value *S, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics for subclasses.
static LLVM_ABI bool isBitOrNoopPointerCastable(Type *SrcTy, Type *DestTy, const DataLayout &DL)
Check whether a bitcast, inttoptr, or ptrtoint cast between these types is valid and a no-op.
static LLVM_ABI bool isBitCastable(Type *SrcTy, Type *DestTy)
Check whether a bitcast between these types is valid.
static LLVM_ABI CastInst * CreateTruncOrBitCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a Trunc or BitCast cast instruction.
static LLVM_ABI CastInst * CreatePointerCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a BitCast, AddrSpaceCast or a PtrToInt cast instruction.
static LLVM_ABI CastInst * CreateBitOrPointerCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a BitCast, a PtrToInt, or an IntToPTr cast instruction.
static LLVM_ABI bool isNoopCast(Instruction::CastOps Opcode, Type *SrcTy, Type *DstTy, const DataLayout &DL)
A no-op cast is one that can be effected without changing any bits.
static LLVM_ABI CastInst * CreateZExtOrBitCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a ZExt or BitCast cast instruction.
static LLVM_ABI CastInst * Create(Instruction::CastOps, Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Provides a way to construct any of the CastInst subclasses using an opcode instead of the subclass's ...
LLVM_ABI bool isIntegerCast() const
There are several places where we need to know if a cast instruction only deals with integer source a...
static LLVM_ABI CastInst * CreateSExtOrBitCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a SExt or BitCast cast instruction.
static LLVM_ABI bool castIsValid(Instruction::CastOps op, Type *SrcTy, Type *DstTy)
This method can be used to determine if a cast from SrcTy to DstTy using Opcode op is valid or not.
LLVM_ABI CatchReturnInst * cloneImpl() const
void setUnwindDest(BasicBlock *UnwindDest)
LLVM_ABI void addHandler(BasicBlock *Dest)
Add an entry to the switch instruction... Note: This action invalidates handler_end().
LLVM_ABI CatchSwitchInst * cloneImpl() const
mapped_iterator< op_iterator, DerefFnTy > handler_iterator
Value * getParentPad() const
void setParentPad(Value *ParentPad)
BasicBlock * getUnwindDest() const
LLVM_ABI void removeHandler(handler_iterator HI)
bool hasUnwindDest() const
LLVM_ABI CleanupReturnInst * cloneImpl() const
This class is the base class for the comparison instructions.
Predicate getStrictPredicate() const
For example, SGE -> SGT, SLE -> SLT, ULE -> ULT, UGE -> UGT.
bool isEquality() const
Determine if this is an equals/not equals predicate.
void setPredicate(Predicate P)
Set the predicate for this instruction to the specified value.
bool isFalseWhenEqual() const
This is just a convenience.
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)
@ ICMP_SLT
signed less than
@ ICMP_SLE
signed less or equal
@ FCMP_OLT
0 1 0 0 True if ordered and less than
@ FCMP_ULE
1 1 0 1 True if unordered, less than, or equal
@ FCMP_OGT
0 0 1 0 True if ordered and greater than
@ FCMP_OGE
0 0 1 1 True if ordered and greater than or equal
@ ICMP_UGE
unsigned greater or equal
@ ICMP_UGT
unsigned greater than
@ ICMP_SGT
signed greater than
@ FCMP_ULT
1 1 0 0 True if unordered or less than
@ FCMP_ONE
0 1 1 0 True if ordered and operands are unequal
@ FCMP_UEQ
1 0 0 1 True if unordered or equal
@ ICMP_ULT
unsigned less than
@ FCMP_UGT
1 0 1 0 True if unordered or greater than
@ FCMP_OLE
0 1 0 1 True if ordered and less than or equal
@ FCMP_ORD
0 1 1 1 True if ordered (no nans)
@ ICMP_SGE
signed greater or equal
@ FCMP_UNE
1 1 1 0 True if unordered or not equal
@ ICMP_ULE
unsigned less or equal
@ FCMP_UGE
1 0 1 1 True if unordered, greater than, or equal
@ FCMP_FALSE
0 0 0 0 Always false (always folded)
@ FCMP_UNO
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
LLVM_ABI bool isEquivalence(bool Invert=false) const
Determine if one operand of this compare can always be replaced by the other operand,...
static LLVM_ABI bool isEquality(Predicate pred)
Determine if this is an equals/not equals predicate.
Predicate getSwappedPredicate() const
For example, EQ->EQ, SLE->SGE, ULT->UGT, OEQ->OEQ, ULE->UGE, OLT->OGT, etc.
bool isTrueWhenEqual() const
This is just a convenience.
static LLVM_ABI CmpInst * Create(OtherOps Op, Predicate Pred, Value *S1, Value *S2, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Construct a compare instruction, given the opcode, the predicate and the two operands.
static bool isFPPredicate(Predicate P)
Predicate getNonStrictPredicate() const
For example, SGT -> SGE, SLT -> SLE, ULT -> ULE, UGT -> UGE.
static LLVM_ABI CmpInst * CreateWithCopiedFlags(OtherOps Op, Predicate Pred, Value *S1, Value *S2, const Instruction *FlagsSource, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Construct a compare instruction, given the opcode, the predicate, the two operands and the instructio...
LLVM_ABI CmpInst(Type *ty, Instruction::OtherOps op, Predicate pred, Value *LHS, Value *RHS, const Twine &Name="", InsertPosition InsertBefore=nullptr)
bool isNonStrictPredicate() const
LLVM_ABI void swapOperands()
This is just a convenience that dispatches to the subclasses.
static bool isRelational(Predicate P)
Return true if the predicate is relational (not EQ or NE).
Predicate getInversePredicate() const
For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE,...
static LLVM_ABI StringRef getPredicateName(Predicate P)
Predicate getPredicate() const
Return the predicate for this instruction.
bool isStrictPredicate() const
static LLVM_ABI bool isUnordered(Predicate predicate)
Determine if the predicate is an unordered operation.
Predicate getFlippedStrictnessPredicate() const
For predicate of kind "is X or equal to 0" returns the predicate "is X".
static bool isIntPredicate(Predicate P)
static LLVM_ABI bool isOrdered(Predicate predicate)
Determine if the predicate is an ordered operation.
LLVM_ABI bool isCommutative() const
This is just a convenience that dispatches to the subclasses.
An abstraction over a floating-point predicate, and a pack of an integer predicate with samesign info...
static LLVM_ABI std::optional< CmpPredicate > getMatching(CmpPredicate A, CmpPredicate B)
Compares two CmpPredicates taking samesign into account and returns the canonicalized CmpPredicate if...
static LLVM_ABI CmpPredicate getInverse(CmpPredicate P)
Get the inverse predicate of a CmpPredicate.
CmpPredicate()
Default constructor.
static LLVM_ABI CmpPredicate get(const CmpInst *Cmp)
Do a ICmpInst::getCmpPredicate() or CmpInst::getPredicate(), as appropriate.
LLVM_ABI CmpInst::Predicate getPreferredSignedPredicate() const
Attempts to return a signed CmpInst::Predicate from the CmpPredicate.
bool hasSameSign() const
Query samesign information, for optimizations.
static LLVM_ABI CmpPredicate getSwapped(CmpPredicate P)
Get the swapped predicate of a CmpPredicate.
Conditional Branch instruction.
LLVM_ABI void swapSuccessors()
Swap the successors of this branch instruction.
LLVM_ABI CondBrInst * cloneImpl() const
Value * getCondition() const
ConstantFP - Floating Point Values [float, double].
const APFloat & getValueAPF() const
This is the shared class of boolean and integer constants.
LLVM_ABI ConstantRange intersectWith(const ConstantRange &CR, PreferredRangeType Type=Smallest) const
Return the range that results from the intersection of this range with another range.
static LLVM_ABI Constant * get(ArrayRef< Constant * > V)
This is an important base class in LLVM.
static LLVM_ABI Constant * getAllOnesValue(Type *Ty)
static LLVM_ABI Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
A parsed version of the target data layout string in and methods for querying it.
static constexpr ElementCount getFixed(ScalarTy MinVal)
This instruction compares its operands according to the predicate given to the constructor.
static LLVM_ABI bool compare(const APFloat &LHS, const APFloat &RHS, FCmpInst::Predicate Pred)
Return result of LHS Pred RHS comparison.
LLVM_ABI FCmpInst * cloneImpl() const
Clone an identical FCmpInst.
FCmpInst(InsertPosition InsertBefore, Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
Constructor with insertion semantics.
Binary operators support fast-math flags, users should not use this class directly,...
This class represents an extension of floating point types.
LLVM_ABI FPExtInst * cloneImpl() const
Clone an identical FPExtInst.
LLVM_ABI FPExtInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
LLVM_ABI float getFPAccuracy() const
Get the maximum error permitted by this operation in ULPs.
This class represents a cast from floating point to signed integer.
LLVM_ABI FPToSIInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
LLVM_ABI FPToSIInst * cloneImpl() const
Clone an identical FPToSIInst.
This class represents a cast from floating point to unsigned integer.
LLVM_ABI FPToUIInst * cloneImpl() const
Clone an identical FPToUIInst.
LLVM_ABI FPToUIInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
This class represents a truncation of floating point types.
LLVM_ABI FPTruncInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
LLVM_ABI FPTruncInst * cloneImpl() const
Clone an identical FPTruncInst.
Unary operators support fast-math flags, users should not use this class directly,...
LLVM_ABI FenceInst(LLVMContext &C, AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System, InsertPosition InsertBefore=nullptr)
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.
LLVM_ABI FenceInst * cloneImpl() const
friend class Instruction
Iterator for Instructions in a `BasicBlock.
void setOrdering(AtomicOrdering Ordering)
Sets the ordering constraint of this fence instruction.
AtomicOrdering getOrdering() const
Returns the ordering constraint of this fence instruction.
Class to represent fixed width SIMD vectors.
LLVM_ABI FreezeInst(Value *S, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
LLVM_ABI FreezeInst * cloneImpl() const
Clone an identical FreezeInst.
void setParentPad(Value *ParentPad)
Value * getParentPad() const
Convenience accessors.
LLVM_ABI FuncletPadInst * cloneImpl() const
Class to represent function types.
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
Type * getParamType(unsigned i) const
Parameter type accessors.
Represents flags for the getelementptr instruction/expression.
static GEPNoWrapFlags inBounds()
GEPNoWrapFlags withoutInBounds() const
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
LLVM_ABI bool isInBounds() const
Determine whether the GEP has the inbounds flag.
LLVM_ABI bool hasNoUnsignedSignedWrap() const
Determine whether the GEP has the nusw flag.
static LLVM_ABI Type * getTypeAtIndex(Type *Ty, Value *Idx)
Return the type of the element at the given index of an indexable type.
LLVM_ABI bool hasAllZeroIndices() const
Return true if all of the indices of this GEP are zeros.
LLVM_ABI bool hasNoUnsignedWrap() const
Determine whether the GEP has the nuw flag.
LLVM_ABI bool hasAllConstantIndices() const
Return true if all of the indices of this GEP are constant integers.
LLVM_ABI void setIsInBounds(bool b=true)
Set or clear the inbounds flag on this GEP instruction.
static LLVM_ABI Type * getIndexedType(Type *Ty, ArrayRef< Value * > IdxList)
Returns the result type of a getelementptr with the given source element type and indexes.
LLVM_ABI bool accumulateConstantOffset(const DataLayout &DL, APInt &Offset) const
Accumulate the constant address offset of this GEP if possible.
LLVM_ABI GetElementPtrInst * cloneImpl() const
LLVM_ABI bool collectOffset(const DataLayout &DL, unsigned BitWidth, SmallMapVector< Value *, APInt, 4 > &VariableOffsets, APInt &ConstantOffset) const
LLVM_ABI void setNoWrapFlags(GEPNoWrapFlags NW)
Set nowrap flags for GEP instruction.
LLVM_ABI GEPNoWrapFlags getNoWrapFlags() const
Get the nowrap flags for the GEP instruction.
Module * getParent()
Get the module that this global value is contained inside of...
This instruction compares its operands according to the predicate given to the constructor.
bool hasSameSign() const
An icmp instruction, which can be marked as "samesign", indicating that the two operands have the sam...
ICmpInst(InsertPosition InsertBefore, Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
Constructor with insertion semantics.
static LLVM_ABI bool compare(const APInt &LHS, const APInt &RHS, ICmpInst::Predicate Pred)
Return result of LHS Pred RHS comparison.
LLVM_ABI ICmpInst * cloneImpl() const
Clone an identical ICmpInst.
Predicate getFlippedSignednessPredicate() const
For example, SLT->ULT, ULT->SLT, SLE->ULE, ULE->SLE, EQ->EQ.
Predicate getSignedPredicate() const
For example, EQ->EQ, SLE->SLE, UGT->SGT, etc.
static CmpPredicate getInverseCmpPredicate(CmpPredicate Pred)
bool isEquality() const
Return true if this predicate is either EQ or NE.
static LLVM_ABI Predicate getFlippedSignednessPredicate(Predicate Pred)
For example, SLT->ULT, ULT->SLT, SLE->ULE, ULE->SLE, EQ->EQ.
static LLVM_ABI std::optional< bool > isImpliedByMatchingCmp(CmpPredicate Pred1, CmpPredicate Pred2)
Determine if Pred1 implies Pred2 is true, false, or if nothing can be inferred about the implication,...
Predicate getUnsignedPredicate() const
For example, EQ->EQ, SLE->ULE, UGT->UGT, etc.
Indirect Branch Instruction.
LLVM_ABI void addDestination(BasicBlock *Dest)
Add a destination.
LLVM_ABI void removeDestination(unsigned i)
This method removes the specified successor from the indirectbr instruction.
LLVM_ABI IndirectBrInst * cloneImpl() const
LLVM_ABI InsertElementInst * cloneImpl() const
static InsertElementInst * Create(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static LLVM_ABI bool isValidOperands(const Value *Vec, const Value *NewElt, const Value *Idx)
Return true if an insertelement instruction can be formed with the specified operands.
BasicBlock * getBasicBlock()
This instruction inserts a struct field of array element value into an aggregate value.
LLVM_ABI InsertValueInst * cloneImpl() const
BitfieldElement::Type getSubclassData() const
LLVM_ABI bool hasNoNaNs() const LLVM_READONLY
Determine whether the no-NaNs flag is set.
LLVM_ABI void copyIRFlags(const Value *V, bool IncludeWrapFlags=true)
Convenience method to copy supported exact, fast-math, and (optionally) wrapping flags from V to this...
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
LLVM_ABI bool isCommutative() const LLVM_READONLY
Return true if the instruction is commutative:
LLVM_ABI InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
LLVM_ABI const Function * getFunction() const
Return the function this instruction belongs to.
LLVM_ABI void swapProfMetadata()
If the instruction has "branch_weights" MD_prof metadata and the MDNode has three operands (including...
LLVM_ABI bool isVolatile() const LLVM_READONLY
Return true if this instruction has a volatile memory access.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
Bitfield::Element< uint16_t, 0, 16 > OpaqueField
Instruction(const Instruction &)=delete
friend class BasicBlock
Various leaf nodes.
void setSubclassData(typename BitfieldElement::Type Value)
This class represents a cast from an integer to a pointer.
LLVM_ABI IntToPtrInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
LLVM_ABI IntToPtrInst * cloneImpl() const
Clone an identical IntToPtrInst.
BasicBlock * getUnwindDest() const
void setNormalDest(BasicBlock *B)
LLVM_ABI InvokeInst * cloneImpl() const
LLVM_ABI LandingPadInst * getLandingPadInst() const
Get the landingpad instruction from the landing pad block (the unwind destination).
void setUnwindDest(BasicBlock *B)
LLVM_ABI void updateProfWeight(uint64_t S, uint64_t T)
Updates profile metadata by scaling it by S / T.
static InvokeInst * Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)
This is an important class for using LLVM in a threaded context.
LLVMContextImpl *const pImpl
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.
LLVM_ABI LandingPadInst * cloneImpl() const
static LLVM_ABI LandingPadInst * Create(Type *RetTy, unsigned NumReservedClauses, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructors - NumReservedClauses is a hint for the number of incoming clauses that this landingpad w...
LLVM_ABI void addClause(Constant *ClauseVal)
Add a catch or filter clause to the landing pad.
void setCleanup(bool V)
Indicate that this landingpad instruction is a cleanup.
void setElementwise(bool V)
Specify whether this is an elementwise atomic load or not.
void setAlignment(Align Align)
bool isVolatile() const
Return true if this is a load from a volatile memory location.
void setAtomic(AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System)
Sets the ordering constraint and the synchronization scope ID of this load instruction.
LLVM_ABI LoadInst * cloneImpl() const
void setVolatile(bool V)
Specify whether this is a volatile load or not.
LoadStoreInstProperties getProperties() const
Returns the properties of this load instruction.
LLVM_ABI LoadInst(Type *Ty, Value *Ptr, const Twine &NameStr, InsertPosition InsertBefore)
const MDOperand & getOperand(unsigned I) const
static MemoryEffectsBase readOnly()
bool onlyWritesMemory() const
Whether this function only (at most) writes memory.
bool doesNotAccessMemory() const
Whether this function accesses no memory.
static MemoryEffectsBase argMemOnly(ModRefInfo MR=ModRefInfo::ModRef)
static MemoryEffectsBase inaccessibleMemOnly(ModRefInfo MR=ModRefInfo::ModRef)
bool onlyAccessesInaccessibleMem() const
Whether this function only (at most) accesses inaccessible memory.
bool onlyAccessesArgPointees() const
Whether this function only (at most) accesses argument memory.
bool onlyReadsMemory() const
Whether this function only (at most) reads memory.
static MemoryEffectsBase writeOnly()
static MemoryEffectsBase inaccessibleOrArgMemOnly(ModRefInfo MR=ModRefInfo::ModRef)
static MemoryEffectsBase none()
bool onlyAccessesInaccessibleOrArgMem() const
Whether this function only (at most) accesses argument and inaccessible memory.
void allocHungoffUses(unsigned N)
const_block_iterator block_begin() const
LLVM_ABI void removeIncomingValueIf(function_ref< bool(unsigned)> Predicate, bool DeletePHIIfEmpty=true)
Remove all incoming values for which the predicate returns true.
void setIncomingBlock(unsigned i, BasicBlock *BB)
LLVM_ABI Value * removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty=true)
Remove an incoming value.
LLVM_ABI bool hasConstantOrUndefValue() const
Whether the specified PHI node always merges together the same value, assuming undefs are equal to a ...
void setIncomingValue(unsigned i, Value *V)
const_block_iterator block_end() const
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
LLVM_ABI Value * hasConstantValue() const
If the specified PHI node always merges together the same value, return the value,...
LLVM_ABI PHINode * cloneImpl() const
unsigned getNumIncomingValues() const
Return the number of incoming edges.
Class to represent pointers.
unsigned getAddressSpace() const
Return the address space of the Pointer type.
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
This class represents a cast from a pointer to an address (non-capturing ptrtoint).
LLVM_ABI PtrToAddrInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
LLVM_ABI PtrToAddrInst * cloneImpl() const
Clone an identical PtrToAddrInst.
This class represents a cast from a pointer to an integer.
LLVM_ABI PtrToIntInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
LLVM_ABI PtrToIntInst * cloneImpl() const
Clone an identical PtrToIntInst.
Resume the propagation of an exception.
LLVM_ABI ResumeInst * cloneImpl() const
Return a value (possibly void), from a function.
LLVM_ABI ReturnInst * cloneImpl() const
This class represents a sign extension of integer types.
LLVM_ABI SExtInst * cloneImpl() const
Clone an identical SExtInst.
LLVM_ABI SExtInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
This class represents a cast from signed integer to floating point.
LLVM_ABI SIToFPInst * cloneImpl() const
Clone an identical SIToFPInst.
LLVM_ABI SIToFPInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
Class to represent scalable SIMD vectors.
LLVM_ABI SelectInst * cloneImpl() const
static LLVM_ABI 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="", InsertPosition InsertBefore=nullptr, const Instruction *MDFrom=nullptr)
static LLVM_ABI bool isZeroEltSplatMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask chooses all elements with the same value as the first element of exa...
ArrayRef< int > getShuffleMask() const
static LLVM_ABI bool isSpliceMask(ArrayRef< int > Mask, int NumSrcElts, int &Index)
Return true if this shuffle mask is a splice mask, concatenating the two inputs together and then ext...
int getMaskValue(unsigned Elt) const
Return the shuffle mask value of this instruction for the given element index.
LLVM_ABI ShuffleVectorInst(Value *V1, Value *Mask, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static LLVM_ABI bool isValidOperands(const Value *V1, const Value *V2, const Value *Mask)
Return true if a shufflevector instruction can be formed with the specified operands.
static LLVM_ABI bool isSelectMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask chooses elements from its source vectors without lane crossings.
static LLVM_ABI bool isBitRotateMask(ArrayRef< int > Mask, unsigned EltSizeInBits, unsigned MinSubElts, unsigned MaxSubElts, unsigned &NumSubElts, unsigned &RotateAmt)
Checks if the shuffle is a bit rotation of the first operand across multiple subelements,...
VectorType * getType() const
Overload to return most specific vector type.
LLVM_ABI bool isIdentityWithExtract() const
Return true if this shuffle extracts the first N elements of exactly one source vector.
static LLVM_ABI bool isOneUseSingleSourceMask(ArrayRef< int > Mask, int VF)
Return true if this shuffle mask represents "clustered" mask of size VF, i.e.
LLVM_ABI bool isIdentityWithPadding() const
Return true if this shuffle lengthens exactly one source vector with undefs in the high elements.
static LLVM_ABI bool isSingleSourceMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask chooses elements from exactly one source vector.
LLVM_ABI bool isConcat() const
Return true if this shuffle concatenates its 2 source vectors.
static LLVM_ABI bool isDeInterleaveMaskOfFactor(ArrayRef< int > Mask, unsigned Factor, unsigned &Index)
Check if the mask is a DE-interleave mask of the given factor Factor like: <Index,...
LLVM_ABI ShuffleVectorInst * cloneImpl() const
static LLVM_ABI bool isIdentityMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask chooses elements from exactly one source vector without lane crossin...
static LLVM_ABI bool isExtractSubvectorMask(ArrayRef< int > Mask, int NumSrcElts, int &Index)
Return true if this shuffle mask is an extract subvector mask.
LLVM_ABI void setShuffleMask(ArrayRef< int > Mask)
friend class Instruction
Iterator for Instructions in a `BasicBlock.
LLVM_ABI bool isInterleave(unsigned Factor)
Return if this shuffle interleaves its two input vectors together.
static LLVM_ABI bool isReverseMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask swaps the order of elements from exactly one source vector.
static LLVM_ABI bool isTransposeMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask is a transpose mask.
LLVM_ABI void commute()
Swap the operands and adjust the mask to preserve the semantics of the instruction.
static LLVM_ABI bool isInsertSubvectorMask(ArrayRef< int > Mask, int NumSrcElts, int &NumSubElts, int &Index)
Return true if this shuffle mask is an insert subvector mask.
static LLVM_ABI Constant * convertShuffleMaskForBitcode(ArrayRef< int > Mask, Type *ResultTy)
static LLVM_ABI bool isReplicationMask(ArrayRef< int > Mask, int &ReplicationFactor, int &VF)
Return true if this shuffle mask replicates each of the VF elements in a vector ReplicationFactor tim...
static LLVM_ABI bool isInterleaveMask(ArrayRef< int > Mask, unsigned Factor, unsigned NumInputElts, SmallVectorImpl< unsigned > &StartIndexes)
Return true if the mask interleaves one or more input vectors together.
This is a 'bitvector' (really, a variable-sized bit array), optimized for the case when the array is ...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
reference emplace_back(ArgTypes &&... Args)
void reserve(size_type N)
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
void setVolatile(bool V)
Specify whether this is a volatile store or not.
void setAlignment(Align Align)
friend class Instruction
Iterator for Instructions in a `BasicBlock.
LoadStoreInstProperties getProperties() const
Returns the properties of this store instruction.
LLVM_ABI StoreInst * cloneImpl() const
void setElementwise(bool V)
Specify whether this is an elementwise atomic store or not.
LLVM_ABI StoreInst(Value *Val, Value *Ptr, InsertPosition InsertBefore)
bool isVolatile() const
Return true if this is a store to a volatile memory location.
void setAtomic(AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System)
Sets the ordering constraint and the synchronization scope ID of this store instruction.
Represent a constant reference to a string, i.e.
Class to represent struct types.
LLVM_ABI void setSuccessorWeight(unsigned idx, CaseWeightOpt W)
LLVM_ABI Instruction::InstListType::iterator eraseFromParent()
Delegate the call to the underlying SwitchInst::eraseFromParent() and mark this object to not touch t...
LLVM_ABI void addCase(ConstantInt *OnVal, BasicBlock *Dest, CaseWeightOpt W)
Delegate the call to the underlying SwitchInst::addCase() and set the specified branch weight for the...
LLVM_ABI CaseWeightOpt getSuccessorWeight(unsigned idx)
LLVM_ABI void replaceDefaultDest(SwitchInst::CaseIt I)
Replace the default destination by given case.
std::optional< uint32_t > CaseWeightOpt
LLVM_ABI SwitchInst::CaseIt removeCase(SwitchInst::CaseIt I)
Delegate the call to the underlying SwitchInst::removeCase() and remove correspondent branch weight.
void setValue(ConstantInt *V) const
Sets the new value for current case.
void setSuccessor(BasicBlock *S) const
Sets the new successor for current case.
void allocHungoffUses(unsigned N)
LLVM_ABI SwitchInst * cloneImpl() const
LLVM_ABI void addCase(ConstantInt *OnVal, BasicBlock *Dest)
Add an entry to the switch instruction.
CaseIteratorImpl< CaseHandle > CaseIt
ConstantInt *const * case_values() const
unsigned getNumCases() const
Return the number of 'cases' in this switch instruction, excluding the default case.
LLVM_ABI CaseIt removeCase(CaseIt I)
This method removes the specified case and its successor from the switch instruction.
Target - Wrapper for Target specific information.
This class represents a truncation of integer types.
LLVM_ABI TruncInst * cloneImpl() const
Clone an identical TruncInst.
LLVM_ABI TruncInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static constexpr TypeSize getFixed(ScalarTy ExactSize)
static constexpr TypeSize get(ScalarTy Quantity, bool Scalable)
The instances of the Type class are immutable: once they are created, they are never changed.
bool isByteTy() const
True if this is an instance of ByteType.
bool isVectorTy() const
True if this is an instance of VectorType.
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
bool isPointerTy() const
True if this is an instance of PointerType.
LLVM_ABI unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
bool isSingleValueType() const
Return true if the type is a valid type for a register in codegen.
LLVM_ABI bool isFirstClassType() const
Return true if the type is "first class", meaning it is a valid type for a Value.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
LLVM_ABI TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
bool isByteOrByteVectorTy() const
Return true if this is a byte type or a vector of byte types.
bool isTargetExtTy() const
Return true if this is a target extension type.
bool isAggregateType() const
Return true if the type is an aggregate type.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
LLVM_ABI unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)
bool isFloatingPointTy() const
Return true if this is one of the floating-point types.
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
bool isIntegerTy() const
True if this is an instance of IntegerType.
bool isTokenTy() const
Return true if this is 'token'.
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
This class represents a cast unsigned integer to floating point.
LLVM_ABI UIToFPInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
LLVM_ABI UIToFPInst * cloneImpl() const
Clone an identical UIToFPInst.
UnaryInstruction(Type *Ty, unsigned iType, Value *V, InsertPosition InsertBefore=nullptr)
static LLVM_ABI UnaryOperator * Create(UnaryOps Op, Value *S, const Twine &Name=Twine(), InsertPosition InsertBefore=nullptr)
Construct a unary instruction, given the opcode and an operand.
LLVM_ABI UnaryOperator(UnaryOps iType, Value *S, Type *Ty, const Twine &Name, InsertPosition InsertBefore)
LLVM_ABI UnaryOperator * cloneImpl() const
UnaryOps getOpcode() const
Unconditional Branch instruction.
LLVM_ABI UncondBrInst * cloneImpl() const
LLVM_ABI UnreachableInst(LLVMContext &C, InsertPosition InsertBefore=nullptr)
LLVM_ABI bool shouldLowerToTrap(bool TrapUnreachable, bool NoTrapAfterNoreturn) const
friend class Instruction
Iterator for Instructions in a `BasicBlock.
LLVM_ABI UnreachableInst * cloneImpl() const
A Use represents the edge between a Value definition and its users.
LLVM_ABI void set(Value *Val)
const Use * getOperandList() const
LLVM_ABI void allocHungoffUses(unsigned N, bool WithExtraValues=false)
Allocate the array of Uses, followed by a pointer (with bottom bit set) to the User.
const Use & getOperandUse(unsigned i) const
void setNumHungOffUseOperands(unsigned NumOps)
Subclasses with hung off uses need to manage the operand count themselves.
LLVM_ABI void growHungoffUses(unsigned N, bool WithExtraValues=false)
Grow the number of hung off uses.
Value * getOperand(unsigned i) const
unsigned getNumOperands() const
VAArgInst(Value *List, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
LLVM_ABI VAArgInst * cloneImpl() const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
unsigned char SubclassOptionalData
Hold arbitary subclass data.
LLVM_ABI void setName(const Twine &Name)
Change the name of the value.
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
LLVMContext & getContext() const
All values hold a context through their type.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
Base class of all SIMD vector types.
ElementCount getElementCount() const
Return an ElementCount instance to represent the (possibly scalable) number of elements in the vector...
static LLVM_ABI 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.
LLVM_ABI ZExtInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
LLVM_ABI ZExtInst * cloneImpl() const
Clone an identical ZExtInst.
constexpr ScalarTy getFixedValue() const
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
An efficient, type-erasing, non-owning reference to a callable.
const ilist_detail::compute_node_options< Instruction, Options... >::type::parent_ty * getParent() const
Instruction * getPrevNode()
typename base_list_type::iterator iterator
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
bool match(Val *V, const Pattern &P)
cstfp_pred_ty< is_non_zero_not_denormal_fp > m_NonZeroNotDenormalFP()
Match a floating-point non-zero that is not a denormal.
initializer< Ty > init(const Ty &Val)
@ Switch
The "resume-switch" lowering, where there are separate resume and destroy functions that are shared b...
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)
Extract a Value from Metadata.
NodeAddr< UseNode * > Use
This is an optimization pass for GlobalISel generic memory operations.
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.
unsigned getPointerAddressSpace(const Type *T)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
constexpr auto seq_inclusive(T Begin, T End)
Iterate over an integral type from Begin to End inclusive.
@ Load
The value being inserted comes from a load (InsertElement only).
@ Store
The extracted value is stored (ExtractElement only).
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
LLVM_ABI MDNode * getBranchWeightMDNode(const Instruction &I)
Get the branch weights metadata node.
MemoryEffectsBase< IRMemLocation > MemoryEffects
Summary of how a function affects memory in the program.
constexpr auto equal_to(T &&Arg)
Functor variant of std::equal_to that can be used as a UnaryPredicate in functional algorithms like a...
std::enable_if_t< std::is_unsigned_v< T >, std::optional< T > > checkedMulUnsigned(T LHS, T RHS)
Multiply two unsigned integers LHS and RHS.
auto dyn_cast_or_null(const Y &Val)
auto reverse(ContainerTy &&C)
LLVM_ABI MDNode * getValidBranchWeightMDNode(const Instruction &I)
Get the valid branch weights metadata node.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
LLVM_ABI bool NullPointerIsDefined(const Function *F, unsigned AS=0)
Check whether null pointer dereferencing is considered undefined behavior for a given function or an ...
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool isPointerTy(const Type *T)
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
constexpr int PoisonMaskElem
LLVM_ABI unsigned getNumBranchWeights(const MDNode &ProfileData)
AtomicOrdering
Atomic ordering for LLVM's memory model.
LLVM_ABI void extractFromBranchWeightMD32(const MDNode *ProfileData, SmallVectorImpl< uint32_t > &Weights)
Faster version of extractBranchWeights() that skips checks and must only be called with "branch_weigh...
OperandBundleDefT< Value * > OperandBundleDef
@ Mul
Product of integers.
@ FSub
Subtraction of floats.
@ Xor
Bitwise or logical XOR of integers.
@ Sub
Subtraction of integers.
DWARFExpression::Operation Op
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
OutputIt copy(R &&Range, OutputIt Out)
const IROptions & getIROptions(const LLVMContext &C)
constexpr unsigned BitWidth
LLVM_ABI bool extractBranchWeights(const MDNode *ProfileData, SmallVectorImpl< uint32_t > &Weights)
Extract branch weights from MD_prof metadata.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
constexpr auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
bool capturesAnything(CaptureComponents CC)
bool all_equal(std::initializer_list< T > Values)
Returns true if all Values in the initializer lists are equal or the list.
@ End
Run the machine verifier once, at the end of the pipeline.
LLVM_ABI void scaleProfData(Instruction &I, uint64_t S, uint64_t T)
Scaling the profile data attached to 'I' using the ratio of S/T.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Summary of memprof metadata on allocations.
Used to keep track of an operand bundle.
uint32_t End
The index in the Use& vector where operands for this operand bundle ends.
uint32_t Begin
The index in the Use& vector where operands for this operand bundle starts.
static LLVM_ABI std::optional< bool > eq(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_EQ result.
static LLVM_ABI std::optional< bool > ne(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_NE result.
static LLVM_ABI std::optional< bool > sge(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_SGE result.
static LLVM_ABI std::optional< bool > ugt(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_UGT result.
static LLVM_ABI std::optional< bool > slt(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_SLT result.
static LLVM_ABI std::optional< bool > ult(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_ULT result.
static LLVM_ABI std::optional< bool > ule(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_ULE result.
static LLVM_ABI std::optional< bool > sle(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_SLE result.
static LLVM_ABI std::optional< bool > sgt(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_SGT result.
static LLVM_ABI std::optional< bool > uge(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_UGE result.
A structure representing the properties of a load or store instruction.
A MapVector that performs no allocations if smaller than a certain size.
Indicates this User has operands co-allocated.
Indicates this User has operands and a descriptor co-allocated .