47 return CFP->isZero() && CFP->isNegative();
52 return SplatCFP->isNegativeZeroValue();
55 if (
getType()->isFPOrFPVectorTy())
65 return CI->isMinusOne();
69 return CB->isMinusOne();
73 return CFP->getValueAPF().bitcastToAPInt().isAllOnes();
78 return SplatVal->isAllOnesValue();
94 return CFP->getValueAPF().bitcastToAPInt().isOne();
99 return SplatVal->isOneValue();
107 return !CI->isOneValue();
111 return !CB->isOneValue();
115 return !CFP->getValueAPF().bitcastToAPInt().isOne();
119 for (
unsigned I = 0, E = VTy->getNumElements();
I != E; ++
I) {
130 return SplatVal->isNotOneValue();
139 return CI->isMinValue(
true);
143 return CFP->getValueAPF().bitcastToAPInt().isMinSignedValue();
148 return SplatVal->isMinSignedValue();
156 return CI->isMaxValue(
true);
160 return CFP->getValueAPF().bitcastToAPInt().isMaxSignedValue();
165 return SplatVal->isMaxSignedValue();
173 return !CI->isMinValue(
true);
177 return !CFP->getValueAPF().bitcastToAPInt().isMinSignedValue();
181 for (
unsigned I = 0, E = VTy->getNumElements();
I != E; ++
I) {
192 return SplatVal->isNotMinSignedValue();
200 return CFP->getValueAPF().isFiniteNonZero();
203 for (
unsigned I = 0, E = VTy->getNumElements();
I != E; ++
I) {
205 if (!CFP || !CFP->getValueAPF().isFiniteNonZero())
213 return SplatCFP->isFiniteNonZeroFP();
221 return CFP->getValueAPF().isNormal();
224 for (
unsigned I = 0, E = VTy->getNumElements();
I != E; ++
I) {
226 if (!CFP || !CFP->getValueAPF().isNormal())
234 return SplatCFP->isNormalFP();
242 return CFP->getValueAPF().getExactInverse(
nullptr);
245 for (
unsigned I = 0, E = VTy->getNumElements();
I != E; ++
I) {
247 if (!CFP || !CFP->getValueAPF().getExactInverse(
nullptr))
255 return SplatCFP->hasExactInverseFP();
266 for (
unsigned I = 0, E = VTy->getNumElements();
I != E; ++
I) {
268 if (!CFP || !CFP->isNaN())
276 return SplatCFP->isNaN();
293 if (!(VTy->getElementType()->isIntegerTy() ||
294 VTy->getElementType()->isFloatingPointTy()))
308 return FVTy->getNumElements();
310 return STy->getNumElements();
312 return ATy->getNumElements();
328 for (
unsigned I = 0;
I != *NumElts; ++
I) {
339 Type *Ty =
C->getType();
340 if (!Ty->isVectorTy() && !Ty->isAggregateType())
378 unsigned NumElts = FVTy->getNumElements();
379 for (
unsigned I = 0;
I != NumElts; ++
I) {
381 if (Elem && PredFn(Elem))
390 switch (Ty->getTypeID()) {
392 return ConstantByte::get(Ty, 0);
394 return ConstantInt::get(Ty, 0);
402 return ConstantFP::get(Ty->getContext(),
432 Constant *
C = ConstantInt::get(Ty->getContext(), V);
451 return ConstantInt::get(Ty->getContext(),
454 if (Ty->isFloatingPointTy()) {
456 return ConstantFP::get(Ty->getContext(), FL);
460 return ConstantByte::get(Ty->getContext(),
470 "Must be an aggregate/vector constant");
473 return Elt <
CC->getNumOperands() ?
CC->getOperand(Elt) :
nullptr;
476 return Elt < CAZ->getElementCount().getKnownMinValue()
477 ? CAZ->getElementValue(Elt)
481 return Elt < cast<VectorType>(
getType())
484 ? ConstantInt::get(
getContext(), CI->getValue())
488 return Elt < cast<VectorType>(
getType())
491 ? ConstantByte::get(
getContext(), CB->getValue())
495 return Elt < cast<VectorType>(
getType())
498 ? ConstantFP::get(
getContext(), CFP->getValue())
503 return Elt < VT->getElementCount().getKnownMinValue()
513 return Elt < PV->getNumElements() ? PV->getElementValue(Elt) :
nullptr;
516 return Elt < UV->getNumElements() ? UV->getElementValue(Elt) :
nullptr;
519 return Elt < CDS->getNumElements() ? CDS->getElementAsConstant(Elt)
529 if (CI->getValue().getActiveBits() > 64)
542#define HANDLE_CONSTANT(Name) \
543 case Value::Name##Val: \
544 cast<Name>(this)->destroyConstantImpl(); \
546#include "llvm/IR/Value.def"
560 dbgs() <<
"While deleting: " << *
this
561 <<
"\n\nUse still stuck around after Def is destroyed: " << *V
577 switch (
C->getValueID()) {
578 case Constant::ConstantIntVal:
581 case Constant::ConstantByteVal:
584 case Constant::ConstantFPVal:
587 case Constant::ConstantAggregateZeroVal:
590 case Constant::ConstantArrayVal:
593 case Constant::ConstantStructVal:
596 case Constant::ConstantVectorVal:
599 case Constant::ConstantPointerNullVal:
602 case Constant::ConstantDataArrayVal:
605 case Constant::ConstantDataVectorVal:
608 case Constant::ConstantTokenNoneVal:
611 case Constant::BlockAddressVal:
614 case Constant::DSOLocalEquivalentVal:
617 case Constant::NoCFIValueVal:
620 case Constant::ConstantPtrAuthVal:
623 case Constant::UndefValueVal:
626 case Constant::PoisonValueVal:
629 case Constant::ConstantExprVal:
659 while (!WorkList.
empty()) {
668 if (Visited.
insert(ConstOp).second)
676 auto DLLImportPredicate = [](
const GlobalValue *GV) {
677 return GV->isThreadLocal();
683 auto DLLImportPredicate = [](
const GlobalValue *GV) {
684 return GV->hasDLLImportStorageClass();
702 return getRelocationInfo() == GlobalRelocation;
706 return getRelocationInfo() != NoRelocation;
709Constant::PossibleRelocationsTy Constant::getRelocationInfo()
const {
711 return GlobalRelocation;
714 return BA->getFunction()->getRelocationInfo();
717 if (CE->getOpcode() == Instruction::Sub) {
721 (LHS->getOpcode() == Instruction::PtrToInt ||
722 LHS->getOpcode() == Instruction::PtrToAddr) &&
723 (RHS->getOpcode() == Instruction::PtrToInt ||
724 RHS->getOpcode() == Instruction::PtrToAddr)) {
742 if (LHSGV->isDSOLocal() && RHSGV->isDSOLocal())
743 return LocalRelocation;
745 if (RHSGV->isDSOLocal())
746 return LocalRelocation;
753 PossibleRelocationsTy
Result = NoRelocation;
769 if (!
User)
return false;
782 if (RemoveDeadUsers) {
786 const_cast<Constant *
>(
C)->destroyConstant();
797 if (GV && !GV->mayHaveConstantUsers())
800 bool HasLiveConstantUser =
false;
821 if (LastNonDeadUser == E)
824 I = std::next(LastNonDeadUser);
829 if (GV && !HasLiveConstantUser)
830 const_cast<GlobalValue *
>(GV)->MayHaveConstantUsers =
false;
837bool Constant::hasNLiveUses(
unsigned N)
const {
838 unsigned NumUses = 0;
852 assert(
C && Replacement &&
"Expected non-nullptr constant arguments");
853 Type *Ty =
C->getType();
855 assert(Ty == Replacement->
getType() &&
"Expected matching types");
864 unsigned NumElts = VTy->getNumElements();
866 for (
unsigned i = 0; i != NumElts; ++i) {
867 Constant *EltC =
C->getAggregateElement(i);
869 "Expected matching types");
870 NewC[i] = EltC &&
match(EltC,
m_Undef()) ? Replacement : EltC;
876 assert(
C &&
Other &&
"Expected non-nullptr constant arguments");
880 Type *Ty =
C->getType();
888 Type *EltTy = VTy->getElementType();
889 unsigned NumElts = VTy->getNumElements();
894 bool FoundExtraUndef =
false;
896 for (
unsigned I = 0;
I != NumElts; ++
I) {
897 NewC[
I] =
C->getAggregateElement(
I);
899 assert(NewC[
I] && OtherEltC &&
"Unknown vector element");
902 FoundExtraUndef =
true;
928ConstantInt::ConstantInt(
Type *Ty,
const APInt &V)
932 "Invalid constant for type");
956 assert(Ty->isIntOrIntVectorTy(1) &&
"Type not i1 or vector of i1.");
964 assert(Ty->isIntOrIntVectorTy(1) &&
"Type not i1 or vector of i1.");
979 std::unique_ptr<ConstantInt> &Slot =
986 Slot.reset(
new ConstantInt(ITy, V));
996 std::unique_ptr<ConstantInt> &Slot =
997 Context.pImpl->IntSplatConstants[std::make_pair(EC, V)];
1007 assert(Slot->getType() == VTy);
1013 bool ImplicitTrunc) {
1024ConstantInt *ConstantInt::get(
IntegerType *Ty, uint64_t V,
bool IsSigned,
1025 bool ImplicitTrunc) {
1026 return get(Ty->getContext(),
1027 APInt(Ty->getBitWidth(), V, IsSigned, ImplicitTrunc));
1031 ConstantInt *
C = get(Ty->getContext(), V);
1032 assert(
C->getType() == Ty->getScalarType() &&
1033 "ConstantInt type doesn't match the type implied by its value!");
1043 return get(Ty->getContext(),
APInt(Ty->getBitWidth(), Str, radix));
1047void ConstantInt::destroyConstantImpl() {
1055ConstantByte::ConstantByte(
Type *Ty,
const APInt &
V)
1059 "Invalid constant for type");
1068 std::unique_ptr<ConstantByte> &Slot =
1075 Slot.reset(
new ConstantByte(BTy, V));
1085 std::unique_ptr<ConstantByte> &Slot =
1086 Context.pImpl->ByteSplatConstants[std::make_pair(EC, V)];
1096 assert(Slot->getType() == VTy);
1102 bool ImplicitTrunc) {
1114 bool ImplicitTrunc) {
1115 return get(Ty->getContext(),
1120 ConstantByte *
C = get(Ty->getContext(), V);
1121 assert(
C->getType() == Ty->getScalarType() &&
1122 "ConstantByte type doesn't match the type implied by its value!");
1132 return get(Ty->getContext(),
APInt(Ty->getBitWidth(), Str, radix));
1136void ConstantByte::destroyConstantImpl() {
1144ConstantFP *ConstantFP::get(
Type *Ty,
double V) {
1149 FV.
convert(Ty->getScalarType()->getFltSemantics(),
1153 return get(Context, VTy->getElementCount(), FV);
1155 return get(Context, FV);
1160 assert(Ty->getScalarType() ==
1162 "ConstantFP type doesn't match the type implied by its value!");
1165 return get(Context, VTy->getElementCount(), V);
1167 return get(Ty->getContext(), V);
1172 APFloat FV(Ty->getScalarType()->getFltSemantics(), Str);
1175 return get(Context, VTy->getElementCount(), FV);
1177 return get(Context, FV);
1181 const fltSemantics &Semantics = Ty->getScalarType()->getFltSemantics();
1186 const fltSemantics &Semantics = Ty->getScalarType()->getFltSemantics();
1188 return get(Ty, NaN);
1192 const fltSemantics &Semantics = Ty->getScalarType()->getFltSemantics();
1194 return get(Ty, NaN);
1198 const fltSemantics &Semantics = Ty->getScalarType()->getFltSemantics();
1200 return get(Ty, NaN);
1204 const fltSemantics &Semantics = Ty->getScalarType()->getFltSemantics();
1206 return get(Ty, NegZero);
1213 std::unique_ptr<ConstantFP> &Slot = pImpl->
FPConstants[V];
1217 Slot.reset(
new ConstantFP(Ty, V));
1227 std::unique_ptr<ConstantFP> &Slot =
1228 Context.pImpl->FPSplatConstants[std::make_pair(EC, V)];
1238 assert(Slot->getType() == VTy);
1246 "FP type Mismatch");
1249 if (
V.bitcastToAPInt().isZero())
1254 return Val.bitwiseIsEqual(V);
1258void ConstantFP::destroyConstantImpl() {
1293 return VT->getElementCount();
1326 return AT->getNumElements();
1329 return Ty->getStructNumElements();
1362template <
typename ItTy,
typename EltTy>
1364 for (; Start !=
End; ++Start)
1370template <
typename SequentialTy,
typename ElementTy>
1372 assert(!
V.empty() &&
"Cannot get empty int sequence.");
1380 return SequentialTy::get(
V[0]->
getContext(), Elts);
1383template <
typename SequentialTy,
typename ElementTy>
1385 assert(!
V.empty() &&
"Cannot get empty byte sequence.");
1393 return SequentialTy::getByte(
V[0]->
getType(), Elts);
1396template <
typename SequentialTy,
typename ElementTy>
1398 assert(!
V.empty() &&
"Cannot get empty FP sequence.");
1403 Elts.
push_back(CFP->getValueAPF().bitcastToAPInt().getLimitedValue());
1406 return SequentialTy::getFP(
V[0]->
getType(), Elts);
1409template <
typename SequenceTy>
1416 if (CI->getType()->isIntegerTy(8))
1418 else if (CI->getType()->isIntegerTy(16))
1420 else if (CI->getType()->isIntegerTy(32))
1422 else if (CI->getType()->isIntegerTy(64))
1425 if (CB->getType()->isByteTy(8))
1427 else if (CB->getType()->isByteTy(16))
1429 else if (CB->getType()->isByteTy(32))
1431 else if (CB->getType()->isByteTy(64))
1434 if (CFP->getType()->isHalfTy() || CFP->getType()->isBFloatTy())
1436 else if (CFP->getType()->isFloatTy())
1438 else if (CFP->getType()->isDoubleTy())
1455 for (
unsigned I = 0, E = V.size();
I != E; ++
I)
1457 "Initializer for struct element doesn't match!");
1464 assert(V.size() ==
T->getNumElements() &&
1465 "Invalid initializer for constant array");
1471 return Ty->getContext().pImpl->ArrayConstants.getOrCreate(Ty, V);
1480 assert(
C->getType() == Ty->getElementType() &&
1481 "Wrong type in array element initializer");
1511 unsigned VecSize = V.size();
1513 for (
unsigned i = 0; i != VecSize; ++i)
1514 EltTypes[i] = V[i]->
getType();
1523 "ConstantStruct::getTypeForElements cannot be called on empty list");
1530 assert((
T->isOpaque() || V.size() ==
T->getNumElements()) &&
1531 "Invalid initializer for constant struct");
1536 assert((ST->isOpaque() || ST->getNumElements() == V.size()) &&
1537 "Incorrect # elements specified to ConstantStruct::get");
1542 bool isPoison =
false;
1547 isZero = V[0]->isNullValue();
1551 if (!
C->isNullValue())
1567 return ST->getContext().pImpl->StructConstants.getOrCreate(ST, V);
1574 "Invalid initializer for constant vector");
1582 return Ty->getContext().pImpl->VectorConstants.getOrCreate(Ty, V);
1586 assert(!V.empty() &&
"Vectors can't be empty");
1592 bool isZero =
C->isNullValue();
1598 getIROptions(
C->getContext()).use_constant_int_for_fixed_length_splat;
1602 if (
isZero ||
isUndef || isSplatFP || isSplatInt || isSplatByte ||
1604 for (
unsigned i = 1, e = V.size(); i != e; ++i)
1606 isZero =
isUndef = isPoison = isSplatFP = isSplatInt = isSplatByte =
1607 isSplatPtrNull =
false;
1621 return ConstantFP::get(
C->getContext(),
T->getElementCount(),
1624 return ConstantInt::get(
C->getContext(),
T->getElementCount(),
1627 return ConstantByte::get(
C->getContext(),
T->getElementCount(),
1647 return ConstantByte::get(V->getContext(), EC, CB->getValue());
1650 return ConstantFP::get(V->getContext(), EC, CFP->getValue());
1652 if (!EC.isScalable()) {
1654 if (!V->isNullValue()) {
1656 getIROptions(V->getContext()).use_constant_int_for_fixed_length_splat)
1657 return ConstantInt::get(V->getContext(), EC,
1672 if (!V->isNullValue()) {
1674 getIROptions(V->getContext()).use_constant_int_for_scalable_splat)
1675 return ConstantInt::get(V->getContext(), EC,
1681 if (V->isNullValue())
1702 pImpl->
TheNoneToken.reset(
new ConstantTokenNone(Context));
1707void ConstantTokenNone::destroyConstantImpl() {
1725 bool OnlyIfReduced,
Type *SrcTy)
const {
1732 Type *OnlyIfReducedTy = OnlyIfReduced ? Ty :
nullptr;
1734 case Instruction::Trunc:
1735 case Instruction::PtrToAddr:
1736 case Instruction::PtrToInt:
1737 case Instruction::IntToPtr:
1738 case Instruction::BitCast:
1739 case Instruction::AddrSpaceCast:
1741 case Instruction::InsertElement:
1744 case Instruction::ExtractElement:
1746 case Instruction::ShuffleVector:
1749 case Instruction::GetElementPtr: {
1754 SrcTy ? SrcTy : GEPO->getSourceElementType(),
Ops[0],
Ops.slice(1),
1755 GEPO->getNoWrapFlags(), GEPO->getInRange(), OnlyIfReducedTy);
1770 unsigned NumBits = Ty->getIntegerBitWidth();
1771 if (Ty->isIntegerTy(1))
1772 return Val == 0 || Val == 1;
1777 unsigned NumBits = Ty->getIntegerBitWidth();
1778 if (Ty->isIntegerTy(1))
1779 return Val == 0 || Val == 1 || Val == -1;
1780 return isIntN(NumBits, Val);
1787 switch (Ty->getTypeID()) {
1845 assert((Ty->isStructTy() || Ty->isArrayTy() || Ty->isVectorTy()) &&
1846 "Cannot create an aggregate zero of non-aggregate type!");
1848 std::unique_ptr<ConstantAggregateZero> &Entry =
1849 Ty->getContext().pImpl->CAZConstants[Ty];
1851 Entry.reset(
new ConstantAggregateZero(Ty));
1857void ConstantAggregateZero::destroyConstantImpl() {
1862void ConstantArray::destroyConstantImpl() {
1871void ConstantStruct::destroyConstantImpl() {
1876void ConstantVector::destroyConstantImpl() {
1881 assert(this->
getType()->isVectorTy() &&
"Only valid for vectors!");
1887 return ConstantInt::get(
getContext(), CI->getValue());
1889 return ConstantByte::get(
getContext(), CB->getValue());
1891 return ConstantFP::get(
getContext(), CFP->getValue());
1895 return CV->getSplatValue();
1897 return CV->getSplatValue(AllowPoison);
1902 if (Shuf && Shuf->getOpcode() == Instruction::ShuffleVector &&
1906 if (IElt && IElt->getOpcode() == Instruction::InsertElement &&
1910 Constant *SplatVal = IElt->getOperand(1);
1950 return CI->getValue();
1952 return CB->getValue();
1970 return ConstantRange::getFull(
BitWidth);
1982 for (
unsigned I = 0, E = CDV->getNumElements();
I < E; ++
I)
1983 CR = CR.
unionWith(CDV->getElementAsAPInt(
I));
1989 for (
unsigned I = 0, E = CV->getNumOperands();
I < E; ++
I) {
1992 return ConstantRange::getFull(
BitWidth);
1998 return ConstantRange::getFull(
BitWidth);
1999 CR = CR.
unionWith(CI ? CI->getValue() : CB->getValue());
2004 return ConstantRange::getFull(
BitWidth);
2013 return ConstantFPRange::getFull(Sem);
2021 for (
unsigned I = 0, E = CDV->getNumElements();
I < E; ++
I)
2028 for (
unsigned I = 0, E = CV->getNumOperands();
I < E; ++
I) {
2031 return ConstantFPRange::getFull(Sem);
2036 return ConstantFPRange::getFull(Sem);
2042 return ConstantFPRange::getFull(Sem);
2049 return get(
static_cast<Type *
>(Ty));
2053 assert(Ty->isPtrOrPtrVectorTy() &&
"invalid type for null pointer constant");
2054 std::unique_ptr<ConstantPointerNull> &Entry =
2055 Ty->getContext().pImpl->CPNConstants[Ty];
2057 Entry.reset(
new ConstantPointerNull(Ty));
2059 assert(Entry->getType() == Ty);
2064void ConstantPointerNull::destroyConstantImpl() {
2073 "Target extension type not allowed to have a zeroinitializer");
2074 std::unique_ptr<ConstantTargetNone> &Entry =
2075 Ty->getContext().pImpl->CTNConstants[Ty];
2077 Entry.reset(
new ConstantTargetNone(Ty));
2083void ConstantTargetNone::destroyConstantImpl() {
2090 Entry.reset(
new UndefValue(Ty));
2096void UndefValue::destroyConstantImpl() {
2109 Entry.reset(
new PoisonValue(Ty));
2115void PoisonValue::destroyConstantImpl() {
2123 BA =
new BlockAddress(Ty, BB);
2140 BB->setHasAddressTaken(
true);
2148 assert(BA &&
"Refcount and block address map disagree!");
2153void BlockAddress::destroyConstantImpl() {
2183 Equiv =
new DSOLocalEquivalent(GV);
2186 "DSOLocalFunction does not match the expected global value");
2190DSOLocalEquivalent::DSOLocalEquivalent(
GlobalValue *GV)
2197void DSOLocalEquivalent::destroyConstantImpl() {
2202Value *DSOLocalEquivalent::handleOperandChangeImpl(
Value *From,
Value *To) {
2214 if (DSOLocalEquivalent *NewEquiv =
2215 getContext().pImpl->DSOLocalEquivalents.lookup(GV))
2235 NC =
new NoCFIValue(GV);
2237 assert(
NC->getGlobalValue() == GV &&
2238 "NoCFIValue does not match the expected global value");
2249void NoCFIValue::destroyConstantImpl() {
2258 assert(GV &&
"Can only replace the operands with a global value");
2260 if (NoCFIValue *NewNC =
getContext().pImpl->NoCFIValues.lookup(GV))
2281 Constant *ArgVec[] = {Ptr,
Key, Disc, AddrDisc, DeactivationSymbol};
2309void ConstantPtrAuth::destroyConstantImpl() {
2313Value *ConstantPtrAuth::handleOperandChangeImpl(
Value *From,
Value *ToV) {
2317 SmallVector<Constant *, 4>
Values;
2320 unsigned NumUpdated = 0;
2323 unsigned OperandNo = 0;
2327 OperandNo = (
O - OperandList);
2335 Values,
this, From, To, NumUpdated, OperandNo);
2340 if (!CastV || CastV->getOpcode() != Instruction::IntToPtr)
2347 return IntVal->getValue() ==
Value;
2351 const Value *Discriminator,
2374 const Value *AddrDiscriminator =
nullptr;
2380 if (!
match(Discriminator,
2386 AddrDiscriminator = Discriminator;
2393 AddrDiscriminator = Cast->getPointerOperand();
2408 APInt Off2(
DL.getIndexTypeSizeInBits(AddrDiscriminator->
getType()), 0);
2412 return Base1 == Base2 && Off1 == Off2;
2421 bool OnlyIfReduced =
false) {
2422 assert(Ty->isFirstClassType() &&
"Cannot cast to an aggregate type!");
2439 bool OnlyIfReduced) {
2443 "Cast opcode not supported as constant expression");
2444 assert(
C && Ty &&
"Null arguments to getCast");
2450 case Instruction::Trunc:
2452 case Instruction::PtrToAddr:
2454 case Instruction::PtrToInt:
2456 case Instruction::IntToPtr:
2458 case Instruction::BitCast:
2460 case Instruction::AddrSpaceCast:
2466 if (
C->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
2473 assert((Ty->isIntOrIntVectorTy() || Ty->isPtrOrPtrVectorTy()) &&
2476 if (Ty->isIntOrIntVectorTy())
2480 if (Ty->isPtrOrPtrVectorTy() && SrcAS != Ty->getPointerAddressSpace())
2489 assert(Ty->isPtrOrPtrVectorTy() &&
"Invalid cast");
2502 assert((fromVec == toVec) &&
"Cannot convert from scalar to/from vector");
2503 assert(
C->getType()->isIntOrIntVectorTy() &&
"Trunc operand must be integer");
2504 assert(Ty->isIntOrIntVectorTy() &&
"Trunc produces only integral");
2505 assert(
C->getType()->getScalarSizeInBits() > Ty->getScalarSizeInBits()&&
2506 "SrcTy must be larger than DestTy for Trunc!");
2512 bool OnlyIfReduced) {
2513 assert(
C->getType()->isPtrOrPtrVectorTy() &&
2514 "PtrToAddr source must be pointer or pointer vector");
2516 "PtrToAddr destination must be integer or integer vector");
2521 "Invalid cast between a different number of vector elements");
2522 return getFoldedCast(Instruction::PtrToAddr,
C, DstTy, OnlyIfReduced);
2526 bool OnlyIfReduced) {
2527 assert(
C->getType()->isPtrOrPtrVectorTy() &&
2528 "PtrToInt source must be pointer or pointer vector");
2530 "PtrToInt destination must be integer or integer vector");
2535 "Invalid cast between a different number of vector elements");
2536 return getFoldedCast(Instruction::PtrToInt,
C, DstTy, OnlyIfReduced);
2540 bool OnlyIfReduced) {
2541 assert(
C->getType()->isIntOrIntVectorTy() &&
2542 "IntToPtr source must be integer or integer vector");
2544 "IntToPtr destination must be a pointer or pointer vector");
2549 "Invalid cast between a different number of vector elements");
2550 return getFoldedCast(Instruction::IntToPtr,
C, DstTy, OnlyIfReduced);
2554 bool OnlyIfReduced) {
2556 "Invalid constantexpr bitcast!");
2560 if (
C->getType() == DstTy)
return C;
2562 return getFoldedCast(Instruction::BitCast,
C, DstTy, OnlyIfReduced);
2566 bool OnlyIfReduced) {
2568 "Invalid constantexpr addrspacecast!");
2569 return getFoldedCast(Instruction::AddrSpaceCast,
C, DstTy, OnlyIfReduced);
2573 unsigned Flags,
Type *OnlyIfReducedTy) {
2576 "Invalid opcode in binary constant expression");
2578 "Binop not supported as constant expression");
2580 "Operand types in binary constant expression should match");
2584 case Instruction::Add:
2585 case Instruction::Sub:
2586 case Instruction::Mul:
2587 assert(
C1->getType()->isIntOrIntVectorTy() &&
2588 "Tried to create an integer operation on a non-integer type!");
2590 case Instruction::And:
2591 case Instruction::Or:
2592 case Instruction::Xor:
2593 assert(
C1->getType()->isIntOrIntVectorTy() &&
2594 "Tried to create a logical operation on a non-integral type!");
2604 if (OnlyIfReducedTy ==
C1->getType())
2616 case Instruction::UDiv:
2617 case Instruction::SDiv:
2618 case Instruction::URem:
2619 case Instruction::SRem:
2620 case Instruction::FAdd:
2621 case Instruction::FSub:
2622 case Instruction::FMul:
2623 case Instruction::FDiv:
2624 case Instruction::FRem:
2625 case Instruction::And:
2626 case Instruction::Or:
2627 case Instruction::LShr:
2628 case Instruction::AShr:
2629 case Instruction::Shl:
2630 case Instruction::Mul:
2632 case Instruction::Add:
2633 case Instruction::Sub:
2634 case Instruction::Xor:
2643 case Instruction::UDiv:
2644 case Instruction::SDiv:
2645 case Instruction::URem:
2646 case Instruction::SRem:
2647 case Instruction::FAdd:
2648 case Instruction::FSub:
2649 case Instruction::FMul:
2650 case Instruction::FDiv:
2651 case Instruction::FRem:
2652 case Instruction::And:
2653 case Instruction::Or:
2654 case Instruction::LShr:
2655 case Instruction::AShr:
2656 case Instruction::Shl:
2657 case Instruction::Mul:
2659 case Instruction::Add:
2660 case Instruction::Sub:
2661 case Instruction::Xor:
2670 case Instruction::ZExt:
2671 case Instruction::SExt:
2672 case Instruction::FPTrunc:
2673 case Instruction::FPExt:
2674 case Instruction::UIToFP:
2675 case Instruction::SIToFP:
2676 case Instruction::FPToUI:
2677 case Instruction::FPToSI:
2679 case Instruction::Trunc:
2680 case Instruction::PtrToAddr:
2681 case Instruction::PtrToInt:
2682 case Instruction::IntToPtr:
2683 case Instruction::BitCast:
2684 case Instruction::AddrSpaceCast:
2693 case Instruction::ZExt:
2694 case Instruction::SExt:
2695 case Instruction::FPTrunc:
2696 case Instruction::FPExt:
2697 case Instruction::UIToFP:
2698 case Instruction::SIToFP:
2699 case Instruction::FPToUI:
2700 case Instruction::FPToSI:
2702 case Instruction::Trunc:
2703 case Instruction::PtrToAddr:
2704 case Instruction::PtrToInt:
2705 case Instruction::IntToPtr:
2706 case Instruction::BitCast:
2707 case Instruction::AddrSpaceCast:
2745 std::optional<ConstantRange>
InRange,
2746 Type *OnlyIfReducedTy) {
2747 assert(Ty &&
"Must specify element type");
2758 if (OnlyIfReducedTy == ReqTy)
2763 EltCount = VecTy->getElementCount();
2766 std::vector<Constant*> ArgVec;
2767 ArgVec.reserve(1 + Idxs.
size());
2768 ArgVec.push_back(
C);
2770 for (; GTI != GTE; ++GTI) {
2775 "getelementptr index type missmatch");
2777 if (GTI.isStruct() && Idx->getType()->isVectorTy()) {
2778 Idx = Idx->getSplatValue();
2779 }
else if (GTI.isSequential() && EltCount.isNonZero() &&
2780 !Idx->getType()->isVectorTy()) {
2783 ArgVec.push_back(Idx);
2796 std::optional<ConstantRange>
InRange,
2797 Type *OnlyIfReducedTy) {
2799 if (Ty->isIntegerTy(8) && Idxs[0]->getType() ==
DL.getIndexType(
C->getType()))
2811 Type *IdxTy =
DL.getIndexType(RetTy);
2815 for (; GTI != GTE; ++GTI) {
2817 if (Idx->isNullValue())
2820 if (
StructType *STy = GTI.getStructTypeOrNull()) {
2821 uint64_t OpValue = Idx->getUniqueInteger().getZExtValue();
2822 uint64_t
Size =
DL.getStructLayout(STy)->getElementOffset(OpValue);
2827 ConstantInt::get(IdxTy,
Size));
2835 if (IdxTy->
isVectorTy() && !Idx->getType()->isVectorTy())
2840 if (Idx->getType() != IdxTy) {
2844 : Instruction::Trunc,
2850 TypeSize TySize = GTI.getSequentialElementStride(
DL);
2872 Type *OnlyIfReducedTy) {
2874 "Tried to create extractelement operation on non-vector type!");
2875 assert(Idx->getType()->isIntegerTy() &&
2876 "Extractelement index must be an integer type!");
2882 if (OnlyIfReducedTy == ReqTy)
2896 "Tried to create insertelement operation on non-vector type!");
2898 "Insertelement types must match!");
2899 assert(Idx->getType()->isIntegerTy() &&
2900 "Insertelement index must be i32 type!");
2905 if (OnlyIfReducedTy == Val->
getType())
2909 Constant *ArgVec[] = { Val, Elt, Idx };
2918 Type *OnlyIfReducedTy) {
2920 "Invalid shuffle vector constant expr operands!");
2925 unsigned NElts = Mask.size();
2927 Type *EltTy = V1VTy->getElementType();
2931 if (OnlyIfReducedTy == ShufTy)
2943 assert(
C->getType()->isIntOrIntVectorTy() &&
2944 "Cannot NEG a nonintegral value!");
2945 return getSub(ConstantInt::get(
C->getType(), 0),
C,
false, HasNSW);
2949 assert(
C->getType()->isIntOrIntVectorTy() &&
2950 "Cannot NOT a nonintegral value!");
2955 bool HasNUW,
bool HasNSW) {
2958 return get(Instruction::Add,
C1, C2, Flags);
2962 bool HasNUW,
bool HasNSW) {
2965 return get(Instruction::Sub,
C1, C2, Flags);
2969 return get(Instruction::Xor,
C1, C2);
2973 Type *Ty =
C->getType();
2976 return ConstantInt::get(Ty, IVal->
logBase2());
2984 for (
unsigned I = 0, E = VecTy->getNumElements();
I != E; ++
I) {
3002 bool AllowRHSConstant,
bool NSZ) {
3008 case Instruction::Add:
3009 case Instruction::Or:
3010 case Instruction::Xor:
3012 case Instruction::Mul:
3013 return ConstantInt::get(Ty, 1);
3014 case Instruction::And:
3016 case Instruction::FAdd:
3018 case Instruction::FMul:
3019 return ConstantFP::get(Ty, 1.0);
3026 if (!AllowRHSConstant)
3030 case Instruction::Sub:
3031 case Instruction::Shl:
3032 case Instruction::LShr:
3033 case Instruction::AShr:
3034 case Instruction::FSub:
3036 case Instruction::SDiv:
3037 case Instruction::UDiv:
3038 return ConstantInt::get(Ty, 1);
3039 case Instruction::FDiv:
3040 return ConstantFP::get(Ty, 1.0);
3048 case Intrinsic::umax:
3050 case Intrinsic::umin:
3052 case Intrinsic::smax:
3055 case Intrinsic::smin:
3064 bool AllowRHSConstant,
bool NSZ) {
3065 if (
I->isBinaryOp())
3073 bool AllowLHSConstant) {
3078 case Instruction::Or:
3081 case Instruction::And:
3082 case Instruction::Mul:
3087 if (!AllowLHSConstant)
3093 case Instruction::Shl:
3094 case Instruction::LShr:
3095 case Instruction::AShr:
3096 case Instruction::SDiv:
3097 case Instruction::UDiv:
3098 case Instruction::URem:
3099 case Instruction::SRem:
3105void ConstantExpr::destroyConstantImpl() {
3113GetElementPtrConstantExpr::GetElementPtrConstantExpr(
3117 SrcElementTy(SrcElementTy),
3122 for (
unsigned i = 0, E = IdxList.
size(); i != E; ++i)
3123 OperandList[i+1] = IdxList[i];
3127 return SrcElementTy;
3131 return ResElementTy;
3143 return ATy->getElementType();
3152 if (Ty->isHalfTy() || Ty->isBFloatTy() || Ty->isFloatTy() || Ty->isDoubleTy())
3155 switch (
IT->getBitWidth()) {
3165 switch (
IT->getBitWidth()) {
3180 return AT->getNumElements();
3189const char *ConstantDataSequential::getElementPointer(uint64_t Elt)
const {
3220 *Ty->getContext().pImpl->CDSConstants.try_emplace(Elements).first;
3226 std::unique_ptr<ConstantDataSequential> *Entry = &Slot.second;
3227 for (; *Entry; Entry = &(*Entry)->Next)
3228 if ((*Entry)->getType() == Ty)
3229 return Entry->get();
3236 return Entry->get();
3242 return Entry->get();
3245void ConstantDataSequential::destroyConstantImpl() {
3252 assert(Slot != CDSConstants.
end() &&
"CDS not found in uniquing table");
3254 std::unique_ptr<ConstantDataSequential> *Entry = &Slot->getValue();
3257 if (!(*Entry)->Next) {
3260 assert(Entry->get() ==
this &&
"Hash mismatch in ConstantDataSequential");
3268 std::unique_ptr<ConstantDataSequential> &
Node = *Entry;
3269 assert(
Node &&
"Didn't find entry in its uniquing hash table!");
3271 if (
Node.get() ==
this) {
3287 assert((ElementType->isHalfTy() || ElementType->isBFloatTy()) &&
3288 "Element type is not a 16-bit float type");
3290 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
3294 assert(ElementType->isFloatTy() &&
"Element type is not a 32-bit float type");
3296 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
3300 assert(ElementType->isDoubleTy() &&
3301 "Element type is not a 64-bit float type");
3303 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
3314 assert(ElementType->isByteTy(8) &&
"Element type is not a 8-bit byte type");
3316 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
3321 assert(ElementType->isByteTy(16) &&
"Element type is not a 16-bit byte type");
3323 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
3328 assert(ElementType->isByteTy(32) &&
"Element type is not a 32-bit byte type");
3330 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
3335 assert(ElementType->isByteTy(64) &&
"Element type is not a 64-bit byte type");
3337 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
3342 bool AddNull,
bool ByteString) {
3351 ElementVals.
append(Str.begin(), Str.end());
3354 :
get(Context, ElementVals);
3362 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
3367 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
3372 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
3377 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
3382 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
3387 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
3398 assert(ElementType->isByteTy(8) &&
"Element type is not a 8-bit byte");
3400 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
3405 assert(ElementType->isByteTy(16) &&
"Element type is not a 16-bit byte");
3407 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
3412 assert(ElementType->isByteTy(32) &&
"Element type is not a 32-bit byte");
3414 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
3419 assert(ElementType->isByteTy(64) &&
"Element type is not a 64-bit byte");
3421 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
3433 assert((ElementType->isHalfTy() || ElementType->isBFloatTy()) &&
3434 "Element type is not a 16-bit float type");
3436 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
3441 assert(ElementType->isFloatTy() &&
"Element type is not a 32-bit float type");
3443 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
3448 assert(ElementType->isDoubleTy() &&
3449 "Element type is not a 64-bit float type");
3451 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
3457 "Element type not compatible with ConstantData");
3459 if (CI->getType()->isIntegerTy(8)) {
3461 return get(V->getContext(), Elts);
3463 if (CI->getType()->isIntegerTy(16)) {
3465 return get(V->getContext(), Elts);
3467 if (CI->getType()->isIntegerTy(32)) {
3469 return get(V->getContext(), Elts);
3471 assert(CI->getType()->isIntegerTy(64) &&
"Unsupported ConstantData type");
3473 return get(V->getContext(), Elts);
3477 if (CB->getType()->isByteTy(8)) {
3479 return getByte(V->getType(), Elts);
3481 if (CB->getType()->isByteTy(16)) {
3483 return getByte(V->getType(), Elts);
3485 if (CB->getType()->isByteTy(32)) {
3487 return getByte(V->getType(), Elts);
3489 assert(CB->getType()->isByteTy(64) &&
"Unsupported ConstantData type");
3491 return getByte(V->getType(), Elts);
3495 if (CFP->getType()->isHalfTy()) {
3497 NumElts, CFP->getValueAPF().bitcastToAPInt().getLimitedValue());
3498 return getFP(V->getType(), Elts);
3500 if (CFP->getType()->isBFloatTy()) {
3502 NumElts, CFP->getValueAPF().bitcastToAPInt().getLimitedValue());
3503 return getFP(V->getType(), Elts);
3505 if (CFP->getType()->isFloatTy()) {
3507 NumElts, CFP->getValueAPF().bitcastToAPInt().getLimitedValue());
3508 return getFP(V->getType(), Elts);
3510 if (CFP->getType()->isDoubleTy()) {
3512 NumElts, CFP->getValueAPF().bitcastToAPInt().getLimitedValue());
3513 return getFP(V->getType(), Elts);
3522 "Accessor can only be used when element is an integer or byte");
3523 const char *EltPtr = getElementPointer(Elt);
3530 return *
reinterpret_cast<const uint8_t *
>(EltPtr);
3532 return *
reinterpret_cast<const uint16_t *
>(EltPtr);
3534 return *
reinterpret_cast<const uint32_t *
>(EltPtr);
3536 return *
reinterpret_cast<const uint64_t *
>(EltPtr);
3543 "Accessor can only be used when element is an integer or byte");
3544 const char *EltPtr = getElementPointer(Elt);
3551 auto EltVal = *
reinterpret_cast<const uint8_t *
>(EltPtr);
3552 return APInt(8, EltVal);
3555 auto EltVal = *
reinterpret_cast<const uint16_t *
>(EltPtr);
3556 return APInt(16, EltVal);
3559 auto EltVal = *
reinterpret_cast<const uint32_t *
>(EltPtr);
3560 return APInt(32, EltVal);
3563 auto EltVal = *
reinterpret_cast<const uint64_t *
>(EltPtr);
3564 return APInt(64, EltVal);
3570 const char *EltPtr = getElementPointer(Elt);
3574 llvm_unreachable(
"Accessor can only be used when element is float/double!");
3576 auto EltVal = *
reinterpret_cast<const uint16_t *
>(EltPtr);
3580 auto EltVal = *
reinterpret_cast<const uint16_t *
>(EltPtr);
3584 auto EltVal = *
reinterpret_cast<const uint32_t *
>(EltPtr);
3588 auto EltVal = *
reinterpret_cast<const uint64_t *
>(EltPtr);
3596 "Accessor can only be used when element is a 'float'");
3597 return *
reinterpret_cast<const float *
>(getElementPointer(Elt));
3602 "Accessor can only be used when element is a 'float'");
3603 return *
reinterpret_cast<const double *
>(getElementPointer(Elt));
3630 if (Str.back() != 0)
return false;
3633 return !Str.drop_back().contains(0);
3636bool ConstantDataVector::isSplatData()
const {
3642 if (memcmp(
Base,
Base+i*EltSize, EltSize))
3651 IsSplat = isSplatData();
3676 Value *Replacement =
nullptr;
3680#define HANDLE_CONSTANT(Name) \
3681 case Value::Name##Val: \
3682 Replacement = cast<Name>(this)->handleOperandChangeImpl(From, To); \
3684#include "llvm/IR/Value.def"
3693 assert(Replacement !=
this &&
"I didn't contain From!");
3702Value *ConstantArray::handleOperandChangeImpl(
Value *From,
Value *To) {
3711 unsigned NumUpdated = 0;
3714 bool AllSame =
true;
3716 unsigned OperandNo = 0;
3720 OperandNo = (O - OperandList);
3725 AllSame &= Val == ToC;
3740 Values,
this, From, ToC, NumUpdated, OperandNo);
3743Value *ConstantStruct::handleOperandChangeImpl(
Value *From,
Value *To) {
3754 unsigned NumUpdated = 0;
3755 bool AllSame =
true;
3756 unsigned OperandNo = 0;
3760 OperandNo = (
O - OperandList);
3765 AllSame &= Val == ToC;
3776 Values,
this, From, ToC, NumUpdated, OperandNo);
3779Value *ConstantVector::handleOperandChangeImpl(
Value *From,
Value *To) {
3785 unsigned NumUpdated = 0;
3786 unsigned OperandNo = 0;
3802 Values,
this, From, ToC, NumUpdated, OperandNo);
3805Value *ConstantExpr::handleOperandChangeImpl(
Value *From,
Value *ToV) {
3810 unsigned NumUpdated = 0;
3811 unsigned OperandNo = 0;
3821 assert(NumUpdated &&
"I didn't contain From!");
3828 NewOps,
this, From, To, NumUpdated, OperandNo);
3836 case Instruction::Trunc:
3837 case Instruction::PtrToAddr:
3838 case Instruction::PtrToInt:
3839 case Instruction::IntToPtr:
3840 case Instruction::BitCast:
3841 case Instruction::AddrSpaceCast:
3844 case Instruction::InsertElement:
3846 case Instruction::ExtractElement:
3848 case Instruction::ShuffleVector:
3851 case Instruction::GetElementPtr: {
3854 Ops.slice(1), GO->getNoWrapFlags(),
"");
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the StringMap class.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::values(clEnumValN(DefaultIT, "arm-default-it", "Generate any type of IT block"), clEnumValN(RestrictedIT, "arm-restrict-it", "Disallow complex IT blocks")))
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH
#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP
static bool isAllZeros(StringRef Arr)
Return true if the array is empty or all zeros.
static Constant * getByteSequenceIfElementsMatch(ArrayRef< Constant * > V)
static Constant * getFPSequenceIfElementsMatch(ArrayRef< Constant * > V)
static std::optional< unsigned > getNumWalkableElements(Type *Ty)
static bool rangeOnlyContains(ItTy Start, ItTy End, EltTy Elt)
static Constant * getIntSequenceIfElementsMatch(ArrayRef< Constant * > V)
static bool containsMatchingElement(const Constant *C, function_ref< bool(const Constant *)> PredFn)
static Constant * getSequenceIfElementsMatch(Constant *C, ArrayRef< Constant * > V)
static bool ConstHasGlobalValuePredicate(const Constant *C, bool(*Predicate)(const GlobalValue *))
Check if C contains a GlobalValue for which Predicate is true.
static bool constantIsDead(const Constant *C, bool RemoveDeadUsers)
Return true if the specified constantexpr is dead.
static bool containsUndefinedElement(const Constant *C, function_ref< bool(const Constant *)> HasFn)
static Constant * getFoldedCast(Instruction::CastOps opc, Constant *C, Type *Ty, bool OnlyIfReduced=false)
This is a utility function to handle folding of casts and lookup of the cast in the ExprConstants map...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static bool isSigned(unsigned Opcode)
static char getTypeID(Type *Ty)
This file contains the declaration of the GlobalIFunc class, which represents a single indirect funct...
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
static bool isUndef(const MachineInstr &MI)
static bool InRange(int64_t Value, unsigned short Shift, int LBound, int HBound)
uint64_t IntrinsicInst * II
Func getContext().diagnose(DiagnosticInfoUnsupported(Func
This file defines the SmallVector class.
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
static SymbolRef::Type getType(const Symbol *Sym)
static Function * getFunction(FunctionType *Ty, const Twine &Name, Module *M)
static const fltSemantics & IEEEsingle()
static const fltSemantics & BFloat()
static const fltSemantics & IEEEquad()
static const fltSemantics & IEEEdouble()
static const fltSemantics & x87DoubleExtended()
static constexpr roundingMode rmNearestTiesToEven
static const fltSemantics & IEEEhalf()
static const fltSemantics & PPCDoubleDouble()
static APFloat getQNaN(const fltSemantics &Sem, bool Negative=false, const APInt *payload=nullptr)
Factory for QNaN values.
static APFloat getSNaN(const fltSemantics &Sem, bool Negative=false, const APInt *payload=nullptr)
Factory for SNaN values.
LLVM_ABI opStatus convert(const fltSemantics &ToSemantics, roundingMode RM, bool *losesInfo)
static LLVM_ABI APFloat getAllOnesValue(const fltSemantics &Semantics)
Returns a float which is bitcasted from an all one value int.
const fltSemantics & getSemantics() const
static APFloat getInf(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Infinity.
static APFloat getNaN(const fltSemantics &Sem, bool Negative=false, uint64_t payload=0)
Factory for NaN values.
static APFloat getZero(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Zero.
Class for arbitrary precision integers.
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
unsigned logBase2() const
bool isPowerOf2() const
Check if this APInt's value is a power of two greater than zero.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
Class to represent array types.
static LLVM_ABI ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
LLVM Basic Block Representation.
const Function * getParent() const
Return the enclosing method, or null if none.
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches,...
LLVM_ABI LLVMContext & getContext() const
Get the context in which this basic block lives.
BinaryConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to impleme...
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.
The address of a basic block.
static LLVM_ABI BlockAddress * lookup(const BasicBlock *BB)
Lookup an existing BlockAddress constant for the given BasicBlock.
BasicBlock * getBasicBlock() const
static LLVM_ABI BlockAddress * get(Function *F, BasicBlock *BB)
Return a BlockAddress for the specified function and basic block.
Class to represent byte types.
static LLVM_ABI ByteType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing a ByteType.
CastConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to implement...
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 ...
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.
All zero aggregate value.
LLVM_ABI ElementCount getElementCount() const
Return the number of elements in the array, vector, or struct.
LLVM_ABI Constant * getSequentialElement() const
If this CAZ has array or vector type, return a zero with the right element type.
LLVM_ABI Constant * getElementValue(Constant *C) const
Return a zero of the right value for the specified GEP index if we can, otherwise return null (e....
LLVM_ABI Constant * getStructElement(unsigned Elt) const
If this CAZ has struct type, return a zero with the right element type for the specified element.
static LLVM_ABI ConstantAggregateZero * get(Type *Ty)
Base class for aggregate constants (with operands).
LLVM_ABI ConstantAggregate(Type *T, ValueTy VT, ArrayRef< Constant * > V, AllocInfo AllocInfo)
ConstantArray - Constant Array Declarations.
static LLVM_ABI Constant * get(ArrayType *T, ArrayRef< Constant * > V)
ArrayType * getType() const
Specialize the getType() method to always return an ArrayType, which reduces the amount of casting ne...
Class for constant bytes.
An array constant whose element type is a simple 1/2/4/8-byte integer, bytes or float/double,...
static Constant * get(LLVMContext &Context, ArrayRef< ElementTy > Elts)
get() constructor - Return a constant with array type with an element count and element type matching...
static LLVM_ABI Constant * getFP(Type *ElementType, ArrayRef< uint16_t > Elts)
getFP() constructors - Return a constant of array type with a float element type taken from argument ...
static LLVM_ABI Constant * getString(LLVMContext &Context, StringRef Initializer, bool AddNull=true, bool ByteString=false)
This method constructs a CDS and initializes it with a text string.
static LLVM_ABI Constant * getByte(Type *ElementType, ArrayRef< uint8_t > Elts)
getByte() constructors - Return a constant of array type with a byte element type taken from argument...
LLVM_ABI APFloat getElementAsAPFloat(uint64_t i) const
If this is a sequential container of floating point type, return the specified element as an APFloat.
LLVM_ABI uint64_t getElementAsInteger(uint64_t i) const
If this is a sequential container of integers (of any size), return the specified element in the low ...
StringRef getAsString() const
If this array is isString(), then this method returns the array as a StringRef.
LLVM_ABI Constant * getElementAsConstant(uint64_t i) const
Return a Constant for a specified index's element.
LLVM_ABI uint64_t getElementByteSize() const
Return the size (in bytes) of each element in the array/vector.
LLVM_ABI float getElementAsFloat(uint64_t i) const
If this is an sequential container of floats, return the specified element as a float.
LLVM_ABI bool isString(unsigned CharSize=8) const
This method returns true if this is an array of CharSize integers or bytes.
LLVM_ABI uint64_t getNumElements() const
Return the number of elements in the array or vector.
LLVM_ABI APInt getElementAsAPInt(uint64_t i) const
If this is a sequential container of integers (of any size), return the specified element as an APInt...
static LLVM_ABI Constant * getImpl(StringRef Bytes, Type *Ty)
This is the underlying implementation of all of the ConstantDataSequential::get methods.
LLVM_ABI double getElementAsDouble(uint64_t i) const
If this is an sequential container of doubles, return the specified element as a double.
LLVM_ABI Type * getElementType() const
Return the element type of the array/vector.
LLVM_ABI bool isCString() const
This method returns true if the array "isString", ends with a null byte, and does not contains any ot...
LLVM_ABI StringRef getRawDataValues() const
Return the raw, underlying, bytes of this data.
static LLVM_ABI bool isElementTypeCompatible(Type *Ty)
Return true if a ConstantDataSequential can be formed with a vector or array of the specified element...
A vector constant whose element type is a simple 1/2/4/8-byte integer or float/double,...
LLVM_ABI Constant * getSplatValue() const
If this is a splat constant, meaning that all of the elements have the same value,...
static LLVM_ABI Constant * getSplat(unsigned NumElts, Constant *Elt)
Return a ConstantVector with the specified constant in each element.
LLVM_ABI bool isSplat() const
Returns true if this is a splat constant, meaning that all elements have the same value.
static LLVM_ABI Constant * get(LLVMContext &Context, ArrayRef< uint8_t > Elts)
get() constructors - Return a constant with vector type with an element count and element type matchi...
static LLVM_ABI Constant * getFP(Type *ElementType, ArrayRef< uint16_t > Elts)
getFP() constructors - Return a constant of vector type with a float element type taken from argument...
static LLVM_ABI Constant * getByte(Type *ElementType, ArrayRef< uint8_t > Elts)
getByte() constructors - Return a constant of vector type with a byte element type taken from argumen...
Base class for constants with no operands.
A constant value that is initialized with an expression using other constant values.
static LLVM_ABI Constant * getIntToPtr(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static LLVM_ABI Constant * getExtractElement(Constant *Vec, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
ConstantExpr(Type *ty, unsigned Opcode, AllocInfo AllocInfo)
static LLVM_ABI Constant * getAlignOf(Type *Ty)
getAlignOf constant expr - computes the alignment of a type in a target independent way (Note: the re...
friend struct ConstantExprKeyType
static LLVM_ABI Constant * getPointerCast(Constant *C, Type *Ty)
Create a BitCast, AddrSpaceCast, or a PtrToInt cast constant expression.
static LLVM_ABI Constant * getTruncOrBitCast(Constant *C, Type *Ty)
static LLVM_ABI Constant * getPointerBitCastOrAddrSpaceCast(Constant *C, Type *Ty)
Create a BitCast or AddrSpaceCast for a pointer type depending on the address space.
LLVM_ABI bool isCast() const
Return true if this is a convert constant expression.
static LLVM_ABI Constant * getIdentity(Instruction *I, Type *Ty, bool AllowRHSConstant=false, bool NSZ=false)
Return the identity constant for a binary or intrinsic Instruction.
static LLVM_ABI bool isDesirableCastOp(unsigned Opcode)
Whether creating a constant expression for this cast is desirable.
LLVM_ABI Constant * getShuffleMaskForBitcode() const
Assert that this is a shufflevector and return the mask.
static LLVM_ABI Constant * getBinOpAbsorber(unsigned Opcode, Type *Ty, bool AllowLHSConstant=false)
Return the absorbing element for the given binary operation, i.e.
static LLVM_ABI Constant * getCast(unsigned ops, Constant *C, Type *Ty, bool OnlyIfReduced=false)
Convenience function for getting a Cast operation.
static LLVM_ABI Constant * getSub(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
static LLVM_ABI Constant * getNot(Constant *C)
static Constant * getPtrAdd(Constant *Ptr, Constant *Offset, GEPNoWrapFlags NW=GEPNoWrapFlags::none(), std::optional< ConstantRange > InRange=std::nullopt, Type *OnlyIfReduced=nullptr)
Create a getelementptr i8, ptr, offset constant expression.
LLVM_ABI const char * getOpcodeName() const
Return a string representation for an opcode.
static LLVM_ABI Constant * getInsertElement(Constant *Vec, Constant *Elt, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
static LLVM_ABI Constant * getPtrToInt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH Constant * getGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList, GEPNoWrapFlags NW=GEPNoWrapFlags::none(), std::optional< ConstantRange > InRange=std::nullopt, Type *OnlyIfReducedTy=nullptr)
Getelementptr form.
static LLVM_ABI Constant * getPtrToAddr(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static LLVM_ABI Constant * getShuffleVector(Constant *V1, Constant *V2, ArrayRef< int > Mask, Type *OnlyIfReducedTy=nullptr)
static LLVM_ABI Constant * getSizeOf(Type *Ty)
getSizeOf constant expr - computes the (alloc) size of a type (in address-units, not bits) in a targe...
static bool isSupportedGetElementPtr(const Type *SrcElemTy)
Whether creating a constant expression for this getelementptr type is supported.
static LLVM_ABI Constant * getIntrinsicIdentity(Intrinsic::ID, Type *Ty)
static LLVM_ABI Constant * getXor(Constant *C1, Constant *C2)
static LLVM_ABI Constant * get(unsigned Opcode, Constant *C1, Constant *C2, unsigned Flags=0, Type *OnlyIfReducedTy=nullptr)
get - Return a binary or shift operator constant expression, folding if possible.
static LLVM_ABI bool isDesirableBinOp(unsigned Opcode)
Whether creating a constant expression for this binary operator is desirable.
LLVM_ABI ArrayRef< int > getShuffleMask() const
Assert that this is a shufflevector and return the mask.
static LLVM_ABI bool isSupportedBinOp(unsigned Opcode)
Whether creating a constant expression for this binary operator is supported.
static LLVM_ABI Constant * getAddrSpaceCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
unsigned getOpcode() const
Return the opcode at the root of this constant expression.
static LLVM_ABI Constant * getAdd(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
static LLVM_ABI Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static LLVM_ABI Constant * getBinOpIdentity(unsigned Opcode, Type *Ty, bool AllowRHSConstant=false, bool NSZ=false)
Return the identity constant for a binary opcode.
static LLVM_ABI bool isSupportedCastOp(unsigned Opcode)
Whether creating a constant expression for this cast is supported.
static LLVM_ABI Constant * getNeg(Constant *C, bool HasNSW=false)
static LLVM_ABI Constant * getTrunc(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static LLVM_ABI Constant * getExactLogBase2(Constant *C)
If C is a scalar/fixed width vector of known powers of 2, then this function returns a new scalar/fix...
Constant * getWithOperands(ArrayRef< Constant * > Ops) const
This returns the current constant expression with the operands replaced with the specified values.
LLVM_ABI Instruction * getAsInstruction() const
Returns an Instruction which implements the same operation as this ConstantExpr.
This class represents a range of floating-point values.
LLVM_ABI ConstantFPRange unionWith(const ConstantFPRange &CR) const
Return the smallest range that results from the union of this range with another range.
ConstantFP - Floating Point Values [float, double].
static LLVM_ABI ConstantFP * getZero(Type *Ty, bool Negative=false)
static LLVM_ABI ConstantFP * getNaN(Type *Ty, bool Negative=false, uint64_t Payload=0)
static LLVM_ABI ConstantFP * getQNaN(Type *Ty, bool Negative=false, APInt *Payload=nullptr)
LLVM_ABI bool isExactlyValue(const APFloat &V) const
We don't rely on operator== working on double values, as it returns true for things that are clearly ...
static LLVM_ABI bool isValueValidForType(Type *Ty, const APFloat &V)
Return true if Ty is big enough to represent V.
static LLVM_ABI ConstantFP * getSNaN(Type *Ty, bool Negative=false, APInt *Payload=nullptr)
static LLVM_ABI ConstantFP * getInfinity(Type *Ty, bool Negative=false)
This is the shared class of boolean and integer constants.
static LLVM_ABI bool isValueValidForType(Type *Ty, uint64_t V)
This static method returns true if the type Ty is big enough to represent the value V.
static LLVM_ABI ConstantInt * getTrue(LLVMContext &Context)
static ConstantInt * getSigned(IntegerType *Ty, int64_t V, bool ImplicitTrunc=false)
Return a ConstantInt with the specified value for the specified type.
static LLVM_ABI ConstantInt * getFalse(LLVMContext &Context)
unsigned getBitWidth() const
getBitWidth - Return the scalar bitwidth of this constant.
static LLVM_ABI ConstantInt * getBool(LLVMContext &Context, bool V)
A constant pointer value that points to null.
static LLVM_ABI ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
A signed pointer, in the ptrauth sense.
Constant * getAddrDiscriminator() const
The address discriminator if any, or the null constant.
friend struct ConstantPtrAuthKeyType
LLVM_ABI bool isKnownCompatibleWith(const Value *Key, const Value *Discriminator, const DataLayout &DL) const
Check whether an authentication operation with key Key and (possibly blended) discriminator Discrimin...
LLVM_ABI bool hasSpecialAddressDiscriminator(uint64_t Value) const
Whether the address uses a special address discriminator.
static LLVM_ABI ConstantPtrAuth * get(Constant *Ptr, ConstantInt *Key, ConstantInt *Disc, Constant *AddrDisc, Constant *DeactivationSymbol)
Return a pointer signed with the specified parameters.
LLVM_ABI ConstantPtrAuth * getWithSameSchema(Constant *Pointer) const
Produce a new ptrauth expression signing the given value using the same schema as is stored in one.
ConstantInt * getKey() const
The Key ID, an i32 constant.
Constant * getDeactivationSymbol() const
bool hasAddressDiscriminator() const
Whether there is any non-null address discriminator.
ConstantInt * getDiscriminator() const
The integer discriminator, an i64 constant, or 0.
This class represents a range of values.
LLVM_ABI ConstantRange unionWith(const ConstantRange &CR, PreferredRangeType Type=Smallest) const
Return the range that results from the union of this range with another range.
static LLVM_ABI Constant * get(StructType *T, ArrayRef< Constant * > V)
static LLVM_ABI StructType * getTypeForElements(ArrayRef< Constant * > V, bool Packed=false)
Return an anonymous struct type to use for a constant with the specified set of elements.
StructType * getType() const
Specialization - reduce amount of casting.
static LLVM_ABI ConstantTargetNone * get(TargetExtType *T)
Static factory methods - Return objects of the specified value.
TargetExtType * getType() const
Specialize the getType() method to always return an TargetExtType, which reduces the amount of castin...
A constant token which is empty.
static LLVM_ABI ConstantTokenNone * get(LLVMContext &Context)
Return the ConstantTokenNone.
void remove(ConstantClass *CP)
Remove this constant from the map.
ConstantClass * replaceOperandsInPlace(ArrayRef< Constant * > Operands, ConstantClass *CP, Value *From, Constant *To, unsigned NumUpdated=0, unsigned OperandNo=~0u)
Constant Vector Declarations.
FixedVectorType * getType() const
Specialize the getType() method to always return a FixedVectorType, which reduces the amount of casti...
LLVM_ABI Constant * getSplatValue(bool AllowPoison=false) const
If all elements of the vector constant have the same value, return that value.
static LLVM_ABI Constant * getSplat(ElementCount EC, Constant *Elt)
Return a ConstantVector with the specified constant in each element.
static LLVM_ABI Constant * get(ArrayRef< Constant * > V)
This is an important base class in LLVM.
static LLVM_ABI Constant * getIntegerValue(Type *Ty, const APInt &V)
Return the value for an integer or pointer constant, or a vector thereof, with the given scalar value...
LLVM_ABI bool hasExactInverseFP() const
Return true if this scalar has an exact multiplicative inverse or this vector has an exact multiplica...
static LLVM_ABI Constant * replaceUndefsWith(Constant *C, Constant *Replacement)
Try to replace undefined constant C or undefined elements in C with Replacement.
LLVM_ABI Constant * getSplatValue(bool AllowPoison=false) const
If all elements of the vector constant have the same value, return that value.
LLVM_ABI bool containsUndefElement() const
Return true if this is a vector or aggregate constant that includes any strictly undef (not poison) e...
static LLVM_ABI Constant * mergeUndefsWith(Constant *C, Constant *Other)
Merges undefs of a Constant with another Constant, along with the undefs already present.
LLVM_ABI ConstantRange toConstantRange() const
Convert constant to an approximate constant range.
bool isNullValue() const
Return true if this is the value that would be returned by getNullValue.
static LLVM_ABI Constant * getAllOnesValue(Type *Ty)
LLVM_ABI bool hasZeroLiveUses() const
Return true if the constant has no live uses.
LLVM_ABI bool isOneValue() const
Returns true if the value is one.
LLVM_ABI bool isManifestConstant() const
Return true if a constant is ConstantData or a ConstantAggregate or ConstantExpr that contain only Co...
LLVM_ABI bool isNegativeZeroValue() const
Return true if the value is what would be returned by getZeroValueForNegation.
LLVM_ABI bool isAllOnesValue() const
Return true if this is the value that would be returned by getAllOnesValue.
Constant(Type *ty, ValueTy vty, AllocInfo AllocInfo)
LLVM_ABI bool containsMatchingVectorElement(function_ref< bool(Constant *)> PredFn) const
Return true if this is a vector constant where at least one element satisfies the given predicate.
LLVM_ABI bool isMaxSignedValue() const
Return true if the value is the largest signed value.
LLVM_ABI bool hasOneLiveUse() const
Return true if the constant has exactly one live use.
LLVM_ABI bool needsRelocation() const
This method classifies the entry according to whether or not it may generate a relocation entry (eith...
LLVM_ABI bool isDLLImportDependent() const
Return true if the value is dependent on a dllimport variable.
LLVM_ABI const APInt & getUniqueInteger() const
If C is a constant integer then return its value, otherwise C must be a vector of constant integers,...
LLVM_ABI bool containsConstantExpression() const
Return true if this is a fixed width vector or aggregate constant that includes any constant expressi...
LLVM_ABI bool isFiniteNonZeroFP() const
Return true if this is a finite and non-zero floating-point scalar constant or a fixed width vector c...
LLVM_ABI void removeDeadConstantUsers() const
If there are any dead constant users dangling off of this constant, remove them.
LLVM_ABI bool isNormalFP() const
Return true if this is a normal (as opposed to denormal, infinity, nan, or zero) floating-point scala...
LLVM_ABI bool needsDynamicRelocation() const
static LLVM_ABI Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
LLVM_ABI bool isNaN() const
Return true if this is a floating-point NaN constant or a vector floating-point constant with all NaN...
LLVM_ABI bool isMinSignedValue() const
Return true if the value is the smallest signed value.
LLVM_ABI bool isConstantUsed() const
Return true if the constant has users other than constant expressions and other dangling things.
LLVM_ABI Constant * getAggregateElement(unsigned Elt) const
For aggregates (struct/array/vector) return the constant that corresponds to the specified element if...
LLVM_ABI bool isThreadDependent() const
Return true if the value can vary between threads.
LLVM_ABI void destroyConstant()
Called if some element of this constant is no longer valid.
LLVM_ABI bool isNotMinSignedValue() const
Return true if the value is not the smallest signed value, or, for vectors, does not contain smallest...
LLVM_ABI ConstantFPRange toConstantFPRange() const
Convert constant to an approximate constant floating point range.
LLVM_ABI bool isNotOneValue() const
Return true if the value is not the one value, or, for vectors, does not contain one value elements.
LLVM_ABI bool isElementWiseEqual(Value *Y) const
Return true if this constant and a constant 'Y' are element-wise equal.
LLVM_ABI bool containsUndefOrPoisonElement() const
Return true if this is a vector or aggregate constant that includes any undef or poison elements.
LLVM_ABI bool containsPoisonElement() const
Return true if this is a vector or aggregate constant that includes any poison elements.
LLVM_ABI void handleOperandChange(Value *, Value *)
This method is a special form of User::replaceUsesOfWith (which does not work on constants) that does...
Wrapper for a function that represents a value that functionally represents the original function.
GlobalValue * getGlobalValue() const
static LLVM_ABI DSOLocalEquivalent * get(GlobalValue *GV)
Return a DSOLocalEquivalent for the specified global value.
A parsed version of the target data layout string in and methods for querying it.
static constexpr ElementCount getFixed(ScalarTy MinVal)
static LLVM_ABI FixedVectorType * get(Type *ElementType, unsigned NumElts)
Represents flags for the getelementptr instruction/expression.
GetElementPtrConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to ...
std::optional< ConstantRange > getInRange() const
Type * getResultElementType() const
Type * getSourceElementType() const
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
static Type * getGEPReturnType(Value *Ptr, ArrayRef< Value * > IdxList)
Returns the pointer type returned by the GEP instruction, which may be a vector of pointers.
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
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.
void setMayHaveConstantUsers()
Record that a constant other than a GlobalValue now uses this global.
PointerType * getType() const
Global values are always pointers.
InsertElementConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to ...
static InsertElementInst * Create(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
LLVM_ABI void setHasNoUnsignedWrap(bool b=true)
Set or clear the nuw flag on this instruction, which must be an operator which supports this flag.
LLVM_ABI void setHasNoSignedWrap(bool b=true)
Set or clear the nsw flag on this instruction, which must be an operator which supports this flag.
LLVM_ABI bool isCommutative() const LLVM_READONLY
Return true if the instruction is commutative:
const char * getOpcodeName() const
LLVM_ABI void setIsExact(bool b=true)
Set or clear the exact flag on this instruction, which must be an operator which supports this flag.
Class to represent integer types.
static LLVM_ABI IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
A wrapper class for inspecting calls to intrinsic functions.
DenseMap< unsigned, std::unique_ptr< ConstantInt > > IntOneConstants
DenseMap< unsigned, std::unique_ptr< ConstantInt > > IntZeroConstants
DenseMap< Type *, std::unique_ptr< ConstantPointerNull > > CPNConstants
DenseMap< APFloat, std::unique_ptr< ConstantFP > > FPConstants
DenseMap< Type *, std::unique_ptr< ConstantAggregateZero > > CAZConstants
ConstantInt * TheFalseVal
DenseMap< Type *, std::unique_ptr< PoisonValue > > PVConstants
DenseMap< APInt, std::unique_ptr< ConstantInt > > IntConstants
std::unique_ptr< ConstantTokenNone > TheNoneToken
VectorConstantsTy VectorConstants
DenseMap< const GlobalValue *, NoCFIValue * > NoCFIValues
DenseMap< const BasicBlock *, BlockAddress * > BlockAddresses
DenseMap< Type *, std::unique_ptr< UndefValue > > UVConstants
StringMap< std::unique_ptr< ConstantDataSequential > > CDSConstants
StructConstantsTy StructConstants
ConstantUniqueMap< ConstantPtrAuth > ConstantPtrAuths
DenseMap< TargetExtType *, std::unique_ptr< ConstantTargetNone > > CTNConstants
ConstantUniqueMap< ConstantExpr > ExprConstants
DenseMap< unsigned, std::unique_ptr< ConstantByte > > ByteOneConstants
ArrayConstantsTy ArrayConstants
DenseMap< const GlobalValue *, DSOLocalEquivalent * > DSOLocalEquivalents
DenseMap< unsigned, std::unique_ptr< ConstantByte > > ByteZeroConstants
DenseMap< APInt, std::unique_ptr< ConstantByte > > ByteConstants
This is an important class for using LLVM in a threaded context.
LLVMContextImpl *const pImpl
Wrapper for a value that won't be replaced with a CFI jump table pointer in LowerTypeTestsModule.
static LLVM_ABI NoCFIValue * get(GlobalValue *GV)
Return a NoCFIValue for the specified function.
PointerType * getType() const
NoCFIValue is always a pointer.
GlobalValue * getGlobalValue() const
Class to represent pointers.
static PointerType * getUnqual(LLVMContext &C)
This constructs an opaque pointer to an object in the default address space (address space zero).
In order to facilitate speculative execution, many instructions do not invoke immediate undefined beh...
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
LLVM_ABI PoisonValue * getStructElement(unsigned Elt) const
If this poison has struct type, return a poison with the right element type for the specified element...
LLVM_ABI PoisonValue * getSequentialElement() const
If this poison has array or vector type, return a poison with the right element type.
LLVM_ABI PoisonValue * getElementValue(Constant *C) const
Return an poison of the right value for the specified GEP index if we can, otherwise return null (e....
static LLVM_ABI void SalvageDebugInfo(const Constant &C)
Replace all uses of the constant with Undef in debug info metadata.
ShuffleVectorConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to ...
This instruction constructs a fixed permutation of two input vectors.
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.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
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.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
iterator find(StringRef Key)
Represent a constant reference to a string, i.e.
constexpr const char * data() const
Get a pointer to the start of the string (which may not be null terminated).
Class to represent struct types.
static LLVM_ABI StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
Class to represent target extensions types, which are generally unintrospectable from target-independ...
@ HasZeroInit
zeroinitializer is valid for this target extension type.
static constexpr TypeSize getFixed(ScalarTy ExactSize)
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)
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.
@ HalfTyID
16-bit floating point type
@ TargetExtTyID
Target extension type.
@ ScalableVectorTyID
Scalable SIMD vector type.
@ FloatTyID
32-bit floating point type
@ IntegerTyID
Arbitrary bit width integers.
@ FixedVectorTyID
Fixed width SIMD vector type.
@ BFloatTyID
16-bit floating point type (7-bit significand)
@ DoubleTyID
64-bit floating point type
@ X86_FP80TyID
80-bit floating point type (X87)
@ PPC_FP128TyID
128-bit floating point type (two 64-bits, PowerPC)
@ ByteTyID
Arbitrary bit width bytes.
@ FP128TyID
128-bit floating point type (112-bit significand)
static LLVM_ABI Type * getFloatingPointTy(LLVMContext &C, const fltSemantics &S)
static LLVM_ABI IntegerType * getInt8Ty(LLVMContext &C)
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.
static LLVM_ABI IntegerType * getInt16Ty(LLVMContext &C)
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 ByteType * getByte8Ty(LLVMContext &C)
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.
static LLVM_ABI Type * getDoubleTy(LLVMContext &C)
static LLVM_ABI Type * getFloatTy(LLVMContext &C)
LLVM_ABI const fltSemantics & getFltSemantics() const
'undef' values are things that do not have specified contents.
LLVM_ABI UndefValue * getElementValue(Constant *C) const
Return an undef of the right value for the specified GEP index if we can, otherwise return null (e....
LLVM_ABI UndefValue * getStructElement(unsigned Elt) const
If this undef has struct type, return a undef with the right element type for the specified element.
static LLVM_ABI UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
LLVM_ABI unsigned getNumElements() const
Return the number of elements in the array, vector, or struct.
LLVM_ABI UndefValue * getSequentialElement() const
If this Undef has array or vector type, return a undef with the right element type.
A Use represents the edge between a Value definition and its users.
const Use * getOperandList() const
User(Type *ty, unsigned vty, AllocInfo AllocInfo)
void setOperand(unsigned i, Value *Val)
Value * getOperand(unsigned i) const
unsigned getNumOperands() const
iterator_range< value_op_iterator > operand_values()
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
user_iterator_impl< const User > const_user_iterator
user_iterator user_begin()
LLVM_ABI Value(Type *Ty, unsigned scid)
unsigned char SubclassOptionalData
Hold arbitary subclass data.
LLVM_ABI const Value * stripInBoundsConstantOffsets() const
Strip off pointer casts and all-constant inbounds GEPs.
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.
iterator_range< user_iterator > users()
unsigned getValueID() const
Return an ID for the concrete type of this object.
LLVM_ABI const Value * stripAndAccumulateConstantOffsets(const DataLayout &DL, APInt &Offset, bool AllowNonInbounds, bool AllowInvariantGroup=false, function_ref< bool(Value &Value, APInt &Offset)> ExternalAnalysis=nullptr, bool LookThroughIntToPtr=false) const
Accumulate the constant offset this value has compared to a base pointer.
LLVM_ABI const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
iterator_range< use_iterator > uses()
void mutateType(Type *Ty)
Mutate the type of this Value to be of the specified type.
ValueTy
Concrete subclass of this.
Base class of all SIMD vector types.
static VectorType * getInteger(VectorType *VTy)
This static method gets a VectorType with the same number of elements as the input type,...
static LLVM_ABI VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
constexpr ScalarTy getFixedValue() const
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
An efficient, type-erasing, non-owning reference to a callable.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
ap_match< APInt > m_APInt(const APInt *&Res)
Match a ConstantInt or splatted ConstantVector, binding the specified pointer to the contained APInt.
bool match(Val *V, const Pattern &P)
specificval_ty m_Specific(const Value *V)
Match if we have a specific specified value.
cst_pred_ty< is_one > m_One()
Match an integer 1 or a vector with all elements equal to 1.
auto m_Value()
Match an arbitrary value and ignore it.
auto m_Intrinsic(const Ts &...Ops)
Match intrinsic calls like this: m_Intrinsic<Intrinsic::fabs>(m_Value(X))
auto m_Undef()
Match an arbitrary undef constant.
NodeAddr< UseNode * > Use
NodeAddr< NodeBase * > Node
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.
RelativeUniformCounterPtr Values
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI Constant * ConstantFoldCompareInstruction(CmpInst::Predicate Predicate, Constant *C1, Constant *C2)
constexpr bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
gep_type_iterator gep_type_end(const User *GEP)
void deleteConstant(Constant *C)
LLVM_ABI Constant * ConstantFoldGetElementPtr(Type *Ty, Constant *C, std::optional< ConstantRange > InRange, ArrayRef< Value * > Idxs)
constexpr auto equal_to(T &&Arg)
Functor variant of std::equal_to that can be used as a UnaryPredicate in functional algorithms like a...
auto dyn_cast_or_null(const Y &Val)
LLVM_ABI Constant * ConstantFoldInsertElementInstruction(Constant *Val, Constant *Elt, Constant *Idx)
Attempt to constant fold an insertelement instruction with the specified operands and indices.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
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...
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
LLVM_ABI Constant * ConstantFoldExtractElementInstruction(Constant *Val, Constant *Idx)
Attempt to constant fold an extractelement instruction with the specified operands and indices.
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
OutputIt copy(R &&Range, OutputIt Out)
const IROptions & getIROptions(const LLVMContext &C)
constexpr unsigned BitWidth
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
gep_type_iterator gep_type_begin(const User *GEP)
constexpr bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
LLVM_ABI Constant * ConstantFoldCastInstruction(unsigned opcode, Constant *V, Type *DestTy)
LLVM_ABI Constant * ConstantFoldShuffleVectorInstruction(Constant *V1, Constant *V2, ArrayRef< int > Mask)
Attempt to constant fold a shufflevector instruction with the specified operands and mask.
@ End
Run the machine verifier once, at the end of the pipeline.
constexpr detail::IsaCheckPredicate< Types... > IsaPred
Function object wrapper for the llvm::isa type check.
LLVM_ABI Constant * ConstantFoldBinaryInstruction(unsigned Opcode, Constant *V1, Constant *V2)
Implement std::hash so that hash_code can be used in STL containers.
Summary of memprof metadata on allocations.
Information about how a User object was allocated, to be passed into the User constructor.