40 void Constant::anchor() { }
42 void ConstantData::anchor() {}
46 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
47 return CFP->isZero() && CFP->isNegative();
51 if (
ConstantFP *SplatCFP = dyn_cast_or_null<ConstantFP>(CV->getSplatValue()))
52 if (SplatCFP && SplatCFP->isZero() && SplatCFP->isNegative())
56 if (
ConstantFP *SplatCFP = dyn_cast_or_null<ConstantFP>(CV->getSplatValue()))
57 if (SplatCFP && SplatCFP->isZero() && SplatCFP->isNegative())
72 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
77 if (
ConstantFP *SplatCFP = dyn_cast_or_null<ConstantFP>(CV->getSplatValue()))
78 if (SplatCFP && SplatCFP->isZero())
82 if (
ConstantFP *SplatCFP = dyn_cast_or_null<ConstantFP>(CV->getSplatValue()))
83 if (SplatCFP && SplatCFP->isZero())
92 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(
this))
96 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
97 return CFP->isZero() && !CFP->isNegative();
101 return isa<ConstantAggregateZero>(
this) || isa<ConstantPointerNull>(
this) ||
102 isa<ConstantTokenNone>(
this);
107 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(
this))
108 return CI->isMinusOne();
111 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
112 return CFP->getValueAPF().bitcastToAPInt().isAllOnesValue();
117 return Splat->isAllOnesValue();
122 return Splat->isAllOnesValue();
129 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(
this))
133 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
134 return CFP->getValueAPF().bitcastToAPInt() == 1;
139 return Splat->isOneValue();
144 return Splat->isOneValue();
151 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(
this))
152 return CI->isMinValue(
true);
155 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
156 return CFP->getValueAPF().bitcastToAPInt().isMinSignedValue();
161 return Splat->isMinSignedValue();
166 return Splat->isMinSignedValue();
173 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(
this))
174 return !CI->isMinValue(
true);
177 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
178 return !CFP->getValueAPF().bitcastToAPInt().isMinSignedValue();
183 return Splat->isNotMinSignedValue();
188 return Splat->isNotMinSignedValue();
239 if (
PointerType *PTy = dyn_cast<PointerType>(ScalarTy))
243 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
267 return Elt < CC->getNumOperands() ? CC->getOperand(Elt) :
nullptr;
270 return Elt < CAZ->getNumElements() ? CAZ->getElementValue(Elt) :
nullptr;
272 if (
const UndefValue *UV = dyn_cast<UndefValue>(
this))
273 return Elt < UV->getNumElements() ? UV->getElementValue(Elt) :
nullptr;
276 return Elt < CDS->getNumElements() ? CDS->getElementAsConstant(Elt)
282 assert(isa<IntegerType>(Elt->
getType()) &&
"Index must be an integer");
294 #define HANDLE_CONSTANT(Name) \
295 case Value::Name##Val: \
296 cast<Name>(this)->destroyConstantImpl(); \
298 #include "llvm/IR/Value.def"
310 #ifndef NDEBUG // Only in -g mode...
311 if (!isa<Constant>(V)) {
312 dbgs() <<
"While deleting: " << *
this
313 <<
"\n\nUse still stuck around after Def is destroyed: " << *V
317 assert(isa<Constant>(V) &&
"References remain to Constant being destroyed");
345 switch (CE->getOpcode()) {
348 case Instruction::UDiv:
349 case Instruction::SDiv:
350 case Instruction::URem:
351 case Instruction::SRem:
353 if (!isa<ConstantInt>(CE->getOperand(1)) ||CE->getOperand(1)->isNullValue())
373 while (!WorkList.
empty()) {
375 if (
const auto *GV = dyn_cast<GlobalValue>(WorkItem))
382 if (Visited.
insert(ConstOp).second)
390 auto DLLImportPredicate = [](
const GlobalValue *GV) {
391 return GV->isThreadLocal();
397 auto DLLImportPredicate = [](
const GlobalValue *GV) {
398 return GV->hasDLLImportStorageClass();
406 if (!UC || isa<GlobalValue>(UC))
416 if (isa<GlobalValue>(
this))
419 if (
const BlockAddress *BA = dyn_cast<BlockAddress>(
this))
420 return BA->getFunction()->needsRelocation();
426 if (
const ConstantExpr *CE = dyn_cast<ConstantExpr>(
this))
427 if (CE->getOpcode() == Instruction::Sub) {
430 if (LHS && RHS && LHS->
getOpcode() == Instruction::PtrToInt &&
431 RHS->getOpcode() == Instruction::PtrToInt &&
433 isa<BlockAddress>(RHS->getOperand(0)) &&
434 cast<BlockAddress>(LHS->
getOperand(0))->getFunction() ==
435 cast<BlockAddress>(RHS->getOperand(0))->getFunction())
449 if (isa<GlobalValue>(C))
return false;
453 if (!User)
return false;
458 const_cast<Constant*
>(
C)->destroyConstant();
483 if (LastNonDeadUser ==
E) {
499 void ConstantInt::anchor() { }
527 "True must be vector of i1 or i1.");
539 "False must be vector of i1 or i1.");
548 std::unique_ptr<ConstantInt> &Slot = pImpl->
IntConstants[V];
562 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
573 return get(Ty, V,
true);
577 return get(Ty, V,
true);
583 "ConstantInt type doesn't match the type implied by its value!");
586 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
597 void ConstantInt::destroyConstantImpl() {
621 void ConstantFP::anchor() { }
633 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
647 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
658 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
669 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
688 std::unique_ptr<ConstantFP> &Slot = pImpl->
FPConstants[V];
704 "Unknown FP format");
717 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
734 void ConstantFP::destroyConstantImpl() {
751 if (isa<SequentialType>(
getType()))
757 if (isa<SequentialType>(
getType()))
764 if (
auto *AT = dyn_cast<ArrayType>(Ty))
765 return AT->getNumElements();
766 if (
auto *VT = dyn_cast<VectorType>(Ty))
767 return VT->getNumElements();
784 if (isa<SequentialType>(
getType()))
790 if (isa<SequentialType>(
getType()))
797 if (
auto *
ST = dyn_cast<SequentialType>(Ty))
798 return ST->getNumElements();
806 template <
typename ItTy,
typename EltTy>
808 for (; Start !=
End; ++Start)
814 template <
typename SequentialTy,
typename ElementTy>
816 assert(!V.
empty() &&
"Cannot get empty int sequence.");
820 if (
auto *CI = dyn_cast<ConstantInt>(C))
824 return SequentialTy::get(V[0]->getContext(), Elts);
827 template <
typename SequentialTy,
typename ElementTy>
829 assert(!V.
empty() &&
"Cannot get empty FP sequence.");
833 if (
auto *CFP = dyn_cast<ConstantFP>(C))
834 Elts.
push_back(CFP->getValueAPF().bitcastToAPInt().getLimitedValue());
837 return SequentialTy::getFP(V[0]->getContext(), Elts);
840 template <
typename SequenceTy>
847 if (CI->getType()->isIntegerTy(8))
848 return getIntSequenceIfElementsMatch<SequenceTy, uint8_t>(V);
849 else if (CI->getType()->isIntegerTy(16))
850 return getIntSequenceIfElementsMatch<SequenceTy, uint16_t>(V);
851 else if (CI->getType()->isIntegerTy(32))
852 return getIntSequenceIfElementsMatch<SequenceTy, uint32_t>(V);
853 else if (CI->getType()->isIntegerTy(64))
854 return getIntSequenceIfElementsMatch<SequenceTy, uint64_t>(V);
855 }
else if (
ConstantFP *CFP = dyn_cast<ConstantFP>(C)) {
856 if (CFP->getType()->isHalfTy())
857 return getFPSequenceIfElementsMatch<SequenceTy, uint16_t>(V);
858 else if (CFP->getType()->isFloatTy())
859 return getFPSequenceIfElementsMatch<SequenceTy, uint32_t>(V);
860 else if (CFP->getType()->isDoubleTy())
861 return getFPSequenceIfElementsMatch<SequenceTy, uint64_t>(V);
874 if (
auto *
ST = dyn_cast<StructType>(T))
877 for (
unsigned I = 0,
E = V.
size();
I !=
E; ++
I)
879 "Initializer for composite element doesn't match!");
885 "Invalid initializer for constant array");
899 for (
unsigned i = 0, e = V.
size();
i != e; ++
i) {
901 "Wrong type in array element initializer");
917 return getSequenceIfElementsMatch<ConstantDataArray>(
C, V);
926 unsigned VecSize = V.
size();
928 for (
unsigned i = 0;
i != VecSize; ++
i)
938 "ConstantStruct::getTypeForElements cannot be called on empty list");
945 "Invalid initializer for constant struct");
951 "Incorrect # elements specified to ConstantStruct::get");
955 bool isUndef =
false;
958 isUndef = isa<UndefValue>(V[0]);
959 isZero = V[0]->isNullValue();
960 if (isUndef || isZero) {
961 for (
unsigned i = 0, e = V.
size();
i != e; ++
i) {
964 if (!isa<UndefValue>(V[
i]))
984 return get(
T, Values);
990 "Invalid initializer for constant vector");
1008 bool isZero = C->isNullValue();
1009 bool isUndef = isa<UndefValue>(
C);
1011 if (isZero || isUndef) {
1012 for (
unsigned i = 1, e = V.
size();
i != e; ++
i)
1014 isZero = isUndef =
false;
1027 return getSequenceIfElementsMatch<ConstantDataVector>(
C, V);
1037 if ((isa<ConstantFP>(V) || isa<ConstantInt>(V)) &&
1053 void ConstantTokenNone::destroyConstantImpl() {
1069 if (
getOpcode() != Instruction::GetElementPtr)
return false;
1076 for (; GEPI !=
E; ++GEPI, ++OI) {
1077 if (isa<UndefValue>(*OI))
1081 (CI->getValue().getActiveBits() > 64 ||
1091 return getOpcode() == Instruction::ExtractValue ||
1092 getOpcode() == Instruction::InsertValue;
1097 dyn_cast<ExtractValueConstantExpr>(
this))
1098 return EVCE->Indices;
1100 return cast<InsertValueConstantExpr>(
this)->Indices;
1104 return cast<CompareConstantExpr>(
this)->predicate;
1110 "Replacing operand with value of different type!");
1112 return const_cast<ConstantExpr*>(
this);
1122 bool OnlyIfReduced,
Type *SrcTy)
const {
1129 Type *OnlyIfReducedTy = OnlyIfReduced ? Ty :
nullptr;
1131 case Instruction::Trunc:
1132 case Instruction::ZExt:
1133 case Instruction::SExt:
1134 case Instruction::FPTrunc:
1135 case Instruction::FPExt:
1136 case Instruction::UIToFP:
1137 case Instruction::SIToFP:
1138 case Instruction::FPToUI:
1139 case Instruction::FPToSI:
1140 case Instruction::PtrToInt:
1141 case Instruction::IntToPtr:
1142 case Instruction::BitCast:
1143 case Instruction::AddrSpaceCast:
1147 case Instruction::InsertElement:
1150 case Instruction::ExtractElement:
1152 case Instruction::InsertValue:
1155 case Instruction::ExtractValue:
1157 case Instruction::ShuffleVector:
1160 case Instruction::GetElementPtr: {
1161 auto *GEPO = cast<GEPOperator>(
this);
1164 SrcTy ? SrcTy : GEPO->getSourceElementType(), Ops[0], Ops.
slice(1),
1165 GEPO->isInBounds(), GEPO->getInRangeIndex(), OnlyIfReducedTy);
1167 case Instruction::ICmp:
1168 case Instruction::FCmp:
1185 return Val == 0 || Val == 1;
1188 uint64_t
Max = (1ll << NumBits) - 1;
1195 return Val == 0 || Val == 1 || Val == -1;
1198 int64_t
Min = -(1ll << (NumBits-1));
1199 int64_t
Max = (1ll << (NumBits-1)) - 1;
1200 return (Val >= Min && Val <= Max);
1256 "Cannot create an aggregate zero of non-aggregate type!");
1258 std::unique_ptr<ConstantAggregateZero> &Entry =
1267 void ConstantAggregateZero::destroyConstantImpl() {
1272 void ConstantArray::destroyConstantImpl() {
1281 void ConstantStruct::destroyConstantImpl() {
1286 void ConstantVector::destroyConstantImpl() {
1291 assert(this->
getType()->isVectorTy() &&
"Only valid for vectors!");
1292 if (isa<ConstantAggregateZero>(
this))
1295 return CV->getSplatValue();
1297 return CV->getSplatValue();
1312 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(
this))
1313 return CI->getValue();
1316 assert(C && isa<ConstantInt>(C) &&
"Not a vector of numbers!");
1317 return cast<ConstantInt>(
C)->getValue();
1324 std::unique_ptr<ConstantPointerNull> &Entry =
1333 void ConstantPointerNull::destroyConstantImpl() {
1346 void UndefValue::destroyConstantImpl() {
1371 BB->AdjustBlockAddressRefCount(1);
1379 assert(F &&
"Block must have a parent");
1382 assert(BA &&
"Refcount and block address map disagree!");
1387 void BlockAddress::destroyConstantImpl() {
1393 Value *BlockAddress::handleOperandChangeImpl(
Value *From,
Value *To) {
1402 assert(From == NewBB &&
"From does not match any operand");
1403 NewBB = cast<BasicBlock>(To);
1435 bool OnlyIfReduced =
false) {
1453 bool OnlyIfReduced) {
1456 assert(C && Ty &&
"Null arguments to getCast");
1462 case Instruction::Trunc:
1463 return getTrunc(C, Ty, OnlyIfReduced);
1464 case Instruction::ZExt:
1465 return getZExt(C, Ty, OnlyIfReduced);
1466 case Instruction::SExt:
1467 return getSExt(C, Ty, OnlyIfReduced);
1468 case Instruction::FPTrunc:
1470 case Instruction::FPExt:
1472 case Instruction::UIToFP:
1474 case Instruction::SIToFP:
1476 case Instruction::FPToUI:
1478 case Instruction::FPToSI:
1480 case Instruction::PtrToInt:
1482 case Instruction::IntToPtr:
1484 case Instruction::BitCast:
1486 case Instruction::AddrSpaceCast:
1541 (SrcBits == DstBits ? Instruction::BitCast :
1542 (SrcBits > DstBits ? Instruction::Trunc :
1543 (isSigned ? Instruction::SExt : Instruction::ZExt)));
1544 return getCast(opcode, C, Ty);
1552 if (SrcBits == DstBits)
1555 (SrcBits > DstBits ? Instruction::FPTrunc : Instruction::FPExt);
1556 return getCast(opcode, C, Ty);
1564 assert((fromVec == toVec) &&
"Cannot convert from scalar to/from vector");
1568 "SrcTy must be larger than DestTy for Trunc!");
1570 return getFoldedCast(Instruction::Trunc, C, Ty, OnlyIfReduced);
1578 assert((fromVec == toVec) &&
"Cannot convert from scalar to/from vector");
1582 "SrcTy must be smaller than DestTy for SExt!");
1584 return getFoldedCast(Instruction::SExt, C, Ty, OnlyIfReduced);
1592 assert((fromVec == toVec) &&
"Cannot convert from scalar to/from vector");
1596 "SrcTy must be smaller than DestTy for ZExt!");
1598 return getFoldedCast(Instruction::ZExt, C, Ty, OnlyIfReduced);
1606 assert((fromVec == toVec) &&
"Cannot convert from scalar to/from vector");
1609 "This is an illegal floating point truncation!");
1610 return getFoldedCast(Instruction::FPTrunc, C, Ty, OnlyIfReduced);
1618 assert((fromVec == toVec) &&
"Cannot convert from scalar to/from vector");
1621 "This is an illegal floating point extension!");
1622 return getFoldedCast(Instruction::FPExt, C, Ty, OnlyIfReduced);
1630 assert((fromVec == toVec) &&
"Cannot convert from scalar to/from vector");
1632 "This is an illegal uint to floating point cast!");
1633 return getFoldedCast(Instruction::UIToFP, C, Ty, OnlyIfReduced);
1641 assert((fromVec == toVec) &&
"Cannot convert from scalar to/from vector");
1643 "This is an illegal sint to floating point cast!");
1644 return getFoldedCast(Instruction::SIToFP, C, Ty, OnlyIfReduced);
1652 assert((fromVec == toVec) &&
"Cannot convert from scalar to/from vector");
1654 "This is an illegal floating point to uint cast!");
1655 return getFoldedCast(Instruction::FPToUI, C, Ty, OnlyIfReduced);
1663 assert((fromVec == toVec) &&
"Cannot convert from scalar to/from vector");
1665 "This is an illegal floating point to sint cast!");
1666 return getFoldedCast(Instruction::FPToSI, C, Ty, OnlyIfReduced);
1670 bool OnlyIfReduced) {
1672 "PtrToInt source must be pointer or pointer vector");
1674 "PtrToInt destination must be integer or integer vector");
1675 assert(isa<VectorType>(C->
getType()) == isa<VectorType>(DstTy));
1676 if (isa<VectorType>(C->
getType()))
1678 "Invalid cast between a different number of vector elements");
1679 return getFoldedCast(Instruction::PtrToInt, C, DstTy, OnlyIfReduced);
1683 bool OnlyIfReduced) {
1685 "IntToPtr source must be integer or integer vector");
1687 "IntToPtr destination must be a pointer or pointer vector");
1688 assert(isa<VectorType>(C->
getType()) == isa<VectorType>(DstTy));
1689 if (isa<VectorType>(C->
getType()))
1691 "Invalid cast between a different number of vector elements");
1692 return getFoldedCast(Instruction::IntToPtr, C, DstTy, OnlyIfReduced);
1696 bool OnlyIfReduced) {
1698 "Invalid constantexpr bitcast!");
1702 if (C->
getType() == DstTy)
return C;
1704 return getFoldedCast(Instruction::BitCast, C, DstTy, OnlyIfReduced);
1708 bool OnlyIfReduced) {
1710 "Invalid constantexpr addrspacecast!");
1716 Type *DstElemTy = DstScalarTy->getElementType();
1719 if (
VectorType *VT = dyn_cast<VectorType>(DstTy)) {
1725 return getFoldedCast(Instruction::AddrSpaceCast, C, DstTy, OnlyIfReduced);
1729 unsigned Flags,
Type *OnlyIfReducedTy) {
1731 assert(Opcode >= Instruction::BinaryOpsBegin &&
1732 Opcode < Instruction::BinaryOpsEnd &&
1733 "Invalid opcode in binary constant expression");
1735 "Operand types in binary constant expression should match");
1740 case Instruction::Sub:
1741 case Instruction::Mul:
1744 "Tried to create an integer operation on a non-integer type!");
1746 case Instruction::FAdd:
1747 case Instruction::FSub:
1748 case Instruction::FMul:
1751 "Tried to create a floating-point operation on a "
1752 "non-floating-point type!");
1754 case Instruction::UDiv:
1755 case Instruction::SDiv:
1758 "Tried to create an arithmetic operation on a non-arithmetic type!");
1760 case Instruction::FDiv:
1763 "Tried to create an arithmetic operation on a non-arithmetic type!");
1765 case Instruction::URem:
1766 case Instruction::SRem:
1769 "Tried to create an arithmetic operation on a non-arithmetic type!");
1771 case Instruction::FRem:
1774 "Tried to create an arithmetic operation on a non-arithmetic type!");
1781 "Tried to create a logical operation on a non-integral type!");
1783 case Instruction::Shl:
1784 case Instruction::LShr:
1785 case Instruction::AShr:
1788 "Tried to create a shift operation on a non-integer type!");
1798 if (OnlyIfReducedTy == C1->
getType())
1851 Constant *C2,
bool OnlyIfReduced) {
1854 switch (Predicate) {
1862 return getFCmp(Predicate, C1, C2, OnlyIfReduced);
1868 return getICmp(Predicate, C1, C2, OnlyIfReduced);
1873 Type *OnlyIfReducedTy) {
1879 if (OnlyIfReducedTy == V1->
getType())
1892 Type *OnlyIfReducedTy) {
1906 assert(DestTy &&
"GEP indices invalid!");
1910 unsigned NumVecElts = 0;
1913 else for (
auto Idx : Idxs)
1914 if (Idx->getType()->isVectorTy())
1915 NumVecElts = Idx->getType()->getVectorNumElements();
1920 if (OnlyIfReducedTy == ReqTy)
1924 std::vector<Constant*> ArgVec;
1925 ArgVec.reserve(1 + Idxs.size());
1926 ArgVec.push_back(C);
1927 for (
unsigned i = 0, e = Idxs.size();
i != e; ++
i) {
1929 Idxs[
i]->
getType()->getVectorNumElements() == NumVecElts) &&
1930 "getelementptr index type missmatch");
1932 Constant *Idx = cast<Constant>(Idxs[
i]);
1935 ArgVec.push_back(Idx);
1938 unsigned SubClassOptionalData = InBounds ? GEPOperator::IsInBounds : 0;
1939 if (InRangeIndex && *InRangeIndex < 63)
1940 SubClassOptionalData |= (*InRangeIndex + 1) << 1;
1942 SubClassOptionalData,
None, Ty);
1949 Constant *RHS,
bool OnlyIfReduced) {
1974 Constant *RHS,
bool OnlyIfReduced) {
1998 Type *OnlyIfReducedTy) {
2000 "Tried to create extractelement operation on non-vector type!");
2002 "Extractelement index must be an integer type!");
2008 if (OnlyIfReducedTy == ReqTy)
2022 "Tried to create insertelement operation on non-vector type!");
2024 "Insertelement types must match!");
2026 "Insertelement index must be i32 type!");
2031 if (OnlyIfReducedTy == Val->
getType())
2035 Constant *ArgVec[] = { Val, Elt, Idx };
2045 "Invalid shuffle vector constant expr operands!");
2054 if (OnlyIfReducedTy == ShufTy)
2067 Type *OnlyIfReducedTy) {
2069 "Non-first-class type for constant insertvalue expression");
2073 "insertvalue indices invalid!");
2079 if (OnlyIfReducedTy == ReqTy)
2090 Type *OnlyIfReducedTy) {
2092 "Tried to create extractelement operation on non-first-class type!");
2096 assert(ReqTy &&
"extractvalue indices invalid!");
2099 "Non-first-class type for constant extractvalue expression");
2103 if (OnlyIfReducedTy == ReqTy)
2115 "Cannot NEG a nonintegral value!");
2122 "Cannot FNEG a non-floating-point value!");
2128 "Cannot NOT a nonintegral value!");
2133 bool HasNUW,
bool HasNSW) {
2140 return get(Instruction::FAdd, C1, C2);
2144 bool HasNUW,
bool HasNSW) {
2147 return get(Instruction::Sub, C1, C2,
Flags);
2151 return get(Instruction::FSub, C1, C2);
2155 bool HasNUW,
bool HasNSW) {
2158 return get(Instruction::Mul, C1, C2,
Flags);
2162 return get(Instruction::FMul, C1, C2);
2166 return get(Instruction::UDiv, C1, C2,
2171 return get(Instruction::SDiv, C1, C2,
2176 return get(Instruction::FDiv, C1, C2);
2180 return get(Instruction::URem, C1, C2);
2184 return get(Instruction::SRem, C1, C2);
2188 return get(Instruction::FRem, C1, C2);
2204 bool HasNUW,
bool HasNSW) {
2207 return get(Instruction::Shl, C1, C2,
Flags);
2211 return get(Instruction::LShr, C1, C2,
2216 return get(Instruction::AShr, C1, C2,
2231 case Instruction::Mul:
2249 case Instruction::Mul:
2255 void ConstantExpr::destroyConstantImpl() {
2263 GetElementPtrConstantExpr::GetElementPtrConstantExpr(
2267 (IdxList.size() + 1),
2268 IdxList.size() + 1),
2269 SrcElementTy(SrcElementTy),
2273 for (
unsigned i = 0,
E = IdxList.
size();
i !=
E; ++
i)
2274 OperandList[
i+1] = IdxList[
i];
2278 return SrcElementTy;
2282 return ResElementTy;
2288 void ConstantDataArray::anchor() {}
2289 void ConstantDataVector::anchor() {}
2301 if (
auto *
IT = dyn_cast<IntegerType>(Ty)) {
2302 switch (
IT->getBitWidth()) {
2316 return AT->getNumElements();
2326 const char *ConstantDataSequential::getElementPointer(
unsigned Elt)
const {
2363 Entry = &Node->Next, Node = *Entry)
2364 if (Node->getType() == Ty)
2369 if (isa<ArrayType>(Ty))
2372 assert(isa<VectorType>(Ty));
2376 void ConstantDataSequential::destroyConstantImpl() {
2384 assert(Slot != CDSConstants.
end() &&
"CDS not found in uniquing table");
2389 if (!(*Entry)->Next) {
2392 assert((*Entry) ==
this &&
"Hash mismatch in ConstantDataSequential");
2398 Entry = &Node->Next, Node = *Entry) {
2399 assert(Node &&
"Didn't find entry in its uniquing hash table!");
2402 *Entry = Node->Next;
2418 const char *Data =
reinterpret_cast<const char *
>(Elts.
data());
2423 const char *Data =
reinterpret_cast<const char *
>(Elts.
data());
2428 const char *Data =
reinterpret_cast<const char *
>(Elts.
data());
2433 const char *Data =
reinterpret_cast<const char *
>(Elts.
data());
2438 const char *Data =
reinterpret_cast<const char *
>(Elts.
data());
2443 const char *Data =
reinterpret_cast<const char *
>(Elts.
data());
2455 const char *Data =
reinterpret_cast<const char *
>(Elts.
data());
2461 const char *Data =
reinterpret_cast<const char *
>(Elts.
data());
2467 const char *Data =
reinterpret_cast<const char *
>(Elts.
data());
2474 const uint8_t *Data =
reinterpret_cast<const uint8_t *
>(Str.
data());
2482 return get(
Context, ElementVals);
2490 const char *Data =
reinterpret_cast<const char *
>(Elts.
data());
2495 const char *Data =
reinterpret_cast<const char *
>(Elts.
data());
2500 const char *Data =
reinterpret_cast<const char *
>(Elts.
data());
2505 const char *Data =
reinterpret_cast<const char *
>(Elts.
data());
2510 const char *Data =
reinterpret_cast<const char *
>(Elts.
data());
2515 const char *Data =
reinterpret_cast<const char *
>(Elts.
data());
2527 const char *Data =
reinterpret_cast<const char *
>(Elts.
data());
2533 const char *Data =
reinterpret_cast<const char *
>(Elts.
data());
2539 const char *Data =
reinterpret_cast<const char *
>(Elts.
data());
2545 "Element type not compatible with ConstantData");
2547 if (CI->getType()->isIntegerTy(8)) {
2551 if (CI->getType()->isIntegerTy(16)) {
2555 if (CI->getType()->isIntegerTy(32)) {
2559 assert(CI->getType()->isIntegerTy(64) &&
"Unsupported ConstantData type");
2564 if (
ConstantFP *CFP = dyn_cast<ConstantFP>(V)) {
2565 if (CFP->getType()->isHalfTy()) {
2567 NumElts, CFP->getValueAPF().bitcastToAPInt().getLimitedValue());
2570 if (CFP->getType()->isFloatTy()) {
2572 NumElts, CFP->getValueAPF().bitcastToAPInt().getLimitedValue());
2575 if (CFP->getType()->isDoubleTy()) {
2577 NumElts, CFP->getValueAPF().bitcastToAPInt().getLimitedValue());
2587 "Accessor can only be used when element is an integer");
2588 const char *EltPtr = getElementPointer(Elt);
2595 return *
const_cast<uint8_t *
>(
reinterpret_cast<const uint8_t *
>(EltPtr));
2597 return *
const_cast<uint16_t *
>(
reinterpret_cast<const uint16_t *
>(EltPtr));
2599 return *
const_cast<uint32_t *
>(
reinterpret_cast<const uint32_t *
>(EltPtr));
2601 return *
const_cast<uint64_t *
>(
reinterpret_cast<const uint64_t *
>(EltPtr));
2606 const char *EltPtr = getElementPointer(Elt);
2610 llvm_unreachable(
"Accessor can only be used when element is float/double!");
2612 auto EltVal = *
reinterpret_cast<const uint16_t *
>(EltPtr);
2616 auto EltVal = *
reinterpret_cast<const uint32_t *
>(EltPtr);
2620 auto EltVal = *
reinterpret_cast<const uint64_t *
>(EltPtr);
2628 "Accessor can only be used when element is a 'float'");
2629 const float *EltPtr =
reinterpret_cast<const float *
>(getElementPointer(Elt));
2630 return *
const_cast<float *
>(EltPtr);
2635 "Accessor can only be used when element is a 'float'");
2636 const double *EltPtr =
2637 reinterpret_cast<const double *
>(getElementPointer(Elt));
2638 return *
const_cast<double *
>(EltPtr);
2660 if (Str.
back() != 0)
return false;
2672 if (memcmp(Base, Base+
i*EltSize, EltSize))
2694 Value *Replacement =
nullptr;
2698 #define HANDLE_CONSTANT(Name) \
2699 case Value::Name##Val: \
2700 Replacement = cast<Name>(this)->handleOperandChangeImpl(From, To); \
2702 #include "llvm/IR/Value.def"
2711 assert(Replacement !=
this &&
"I didn't contain From!");
2720 Value *ConstantArray::handleOperandChangeImpl(
Value *From,
Value *To) {
2721 assert(isa<Constant>(To) &&
"Cannot make Constant refer to non-constant!");
2722 Constant *ToC = cast<Constant>(To);
2729 unsigned NumUpdated = 0;
2732 bool AllSame =
true;
2734 unsigned OperandNo = 0;
2736 Constant *Val = cast<Constant>(O->get());
2738 OperandNo = (O - OperandList);
2742 Values.push_back(Val);
2743 AllSame &= Val == ToC;
2749 if (AllSame && isa<UndefValue>(ToC))
2758 Values,
this, From, ToC, NumUpdated, OperandNo);
2761 Value *ConstantStruct::handleOperandChangeImpl(
Value *From,
Value *To) {
2762 assert(isa<Constant>(To) &&
"Cannot make Constant refer to non-constant!");
2763 Constant *ToC = cast<Constant>(To);
2772 unsigned NumUpdated = 0;
2773 bool AllSame =
true;
2774 unsigned OperandNo = 0;
2776 Constant *Val = cast<Constant>(O->get());
2778 OperandNo = (O - OperandList);
2783 AllSame &= Val == ToC;
2789 if (AllSame && isa<UndefValue>(ToC))
2794 Values,
this, From, ToC, NumUpdated, OperandNo);
2797 Value *ConstantVector::handleOperandChangeImpl(
Value *From,
Value *To) {
2798 assert(isa<Constant>(To) &&
"Cannot make Constant refer to non-constant!");
2799 Constant *ToC = cast<Constant>(To);
2803 unsigned NumUpdated = 0;
2804 unsigned OperandNo = 0;
2812 Values.push_back(Val);
2820 Values,
this, From, ToC, NumUpdated, OperandNo);
2823 Value *ConstantExpr::handleOperandChangeImpl(
Value *From,
Value *ToV) {
2824 assert(isa<Constant>(ToV) &&
"Cannot make Constant refer to non-constant!");
2825 Constant *To = cast<Constant>(ToV);
2828 unsigned NumUpdated = 0;
2829 unsigned OperandNo = 0;
2837 NewOps.push_back(Op);
2839 assert(NumUpdated &&
"I didn't contain From!");
2846 NewOps,
this, From, To, NumUpdated, OperandNo);
2854 case Instruction::Trunc:
2855 case Instruction::ZExt:
2856 case Instruction::SExt:
2857 case Instruction::FPTrunc:
2858 case Instruction::FPExt:
2859 case Instruction::UIToFP:
2860 case Instruction::SIToFP:
2861 case Instruction::FPToUI:
2862 case Instruction::FPToSI:
2863 case Instruction::PtrToInt:
2864 case Instruction::IntToPtr:
2865 case Instruction::BitCast:
2866 case Instruction::AddrSpaceCast:
2871 case Instruction::InsertElement:
2873 case Instruction::ExtractElement:
2875 case Instruction::InsertValue:
2877 case Instruction::ExtractValue:
2879 case Instruction::ShuffleVector:
2882 case Instruction::GetElementPtr: {
2883 const auto *GO = cast<GEPOperator>(
this);
2884 if (GO->isInBounds())
2886 Ops[0], Ops.
slice(1));
2890 case Instruction::ICmp:
2891 case Instruction::FCmp:
2900 if (isa<OverflowingBinaryOperator>(BO)) {
2906 if (isa<PossiblyExactOperator>(BO))
static Constant * getFPSequenceIfElementsMatch(ArrayRef< Constant * > V)
static Constant * getFPTrunc(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static bool isValueValidForType(Type *Ty, uint64_t V)
This static method returns true if the type Ty is big enough to represent the value V...
A vector constant whose element type is a simple 1/2/4/8-byte integer or float/double, and whose elements are just simple data values (i.e.
static cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::ZeroOrMore, cl::values(clEnumValN(DefaultIT,"arm-default-it","Generate IT block based on arch"), clEnumValN(RestrictedIT,"arm-restrict-it","Disallow deprecated IT based on ARMv8"), clEnumValN(NoRestrictedIT,"arm-no-restrict-it","Allow IT blocks based on ARMv7")))
void push_back(const T &Elt)
static ConstantInt * getFalse(LLVMContext &Context)
IntegerType * getType() const
getType - Specialize the getType() method to always return an IntegerType, which reduces the amount o...
static Constant * getString(LLVMContext &Context, StringRef Initializer, bool AddNull=true)
This method constructs a CDS and initializes it with a text string.
static bool rangeOnlyContains(ItTy Start, ItTy End, EltTy Elt)
static Type * getDoubleTy(LLVMContext &C)
static IntegerType * getInt1Ty(LLVMContext &C)
static Constant * getFAdd(Constant *C1, Constant *C2)
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
APFloat getElementAsAPFloat(unsigned i) const
If this is a sequential container of floating point type, return the specified element as an APFloat...
static APInt getAllOnesValue(unsigned numBits)
Get the all-ones value.
static Constant * getPointerBitCastOrAddrSpaceCast(Constant *C, Type *Ty)
Create a BitCast or AddrSpaceCast for a pointer type depending on the address space.
bool isOpaque() const
Return true if this is a type with an identity that has no body specified yet.
static Constant * getNaN(Type *Ty, bool Negative=false, unsigned type=0)
unsigned getStructNumElements() const
DenseMap< std::pair< const Function *, const BasicBlock * >, BlockAddress * > BlockAddresses
static Constant * getInfinity(Type *Ty, bool Negative=false)
2: 32-bit floating point type
Constant * getSplatValue() const
If this is a splat vector constant, meaning that all of the elements have the same value...
const T & front() const
front - Get the first element.
Type * getSequentialElementType() const
unsigned getNumOperands() const
static Constant * getAddrSpaceCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static ConstantAggregateZero * get(Type *Ty)
bool isOneValue() const
Returns true if the value is one.
Constant * ConstantFoldExtractElementInstruction(Constant *Val, Constant *Idx)
Attempt to constant fold an extractelement instruction with the specified operands and indices...
Constant * getElementAsConstant(unsigned i) const
Return a Constant for a specified index's element.
static Constant * getBinOpIdentity(unsigned Opcode, Type *Ty)
Return the identity for the given binary operation, i.e.
Constant * getSplatValue() const
If this is a splat constant, meaning that all of the elements have the same value, return that value.
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space...
gep_type_iterator gep_type_end(const User *GEP)
static Constant * getGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList, bool InBounds=false, Optional< unsigned > InRangeIndex=None, Type *OnlyIfReducedTy=nullptr)
Getelementptr form.
Constant * ConstantFoldCastInstruction(unsigned opcode, Constant *V, Type *DestTy)
Type * getResultElementType() const
static Constant * getIntToPtr(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static Constant * getExtractElement(Constant *Vec, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
0 1 0 0 True if ordered and less than
iterator find(StringRef Key)
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 instruction constructs a fixed permutation of two input vectors.
static SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr="", Instruction *InsertBefore=nullptr, Instruction *MDFrom=nullptr)
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
ConstantInt * TheFalseVal
1 1 1 0 True if unordered or not equal
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
Constant * ConstantFoldGetElementPtr(Type *Ty, Constant *C, bool InBounds, Optional< unsigned > InRangeIndex, ArrayRef< Value * > Idxs)
const Function * getParent() const
Return the enclosing method, or null if none.
4: 80-bit floating point type (X87)
const APInt & getUniqueInteger() const
If C is a constant integer then return its value, otherwise C must be a vector of constant integers...
unsigned getAddressSpace() const
Return the address space of the Pointer type.
static APFloat getZero(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Zero.
1: 16-bit floating point type
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
static IntegerType * getInt64Ty(LLVMContext &C)
static Constant * getCompare(unsigned short pred, Constant *C1, Constant *C2, bool OnlyIfReduced=false)
Return an ICmp or FCmp comparison operator constant expression.
static Constant * getSub(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
LLVM_NODISCARD char back() const
back - Get the last character in the string.
Type * getElementType() const
void reserve(size_type N)
static IntegerType * getInt16Ty(LLVMContext &C)
unsigned getOpcode() const
Return the opcode at the root of this constant expression.
static Type * getX86_FP80Ty(LLVMContext &C)
static Constant * getInsertElement(Constant *Vec, Constant *Elt, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
static Constant * getAdd(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
static Constant * getFMul(Constant *C1, Constant *C2)
ConstantAggregate(CompositeType *T, ValueTy VT, ArrayRef< Constant * > V)
bool isNegativeZeroValue() const
Return true if the value is what would be returned by getZeroValueForNegation.
1 0 0 1 True if unordered or equal
The address of a basic block.
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...
static InsertElementInst * Create(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
static Constant * getIntegerCast(Constant *C, Type *Ty, bool isSigned)
Create a ZExt, Bitcast or Trunc for integer -> integer casts.
static bool castIsValid(Instruction::CastOps op, Value *S, Type *DstTy)
This method can be used to determine if a cast from S to DstTy using Opcode op is valid or not...
static const fltSemantics & x87DoubleExtended()
struct fuzzer::@269 Flags
static Type * getFloatTy(LLVMContext &C)
static Constant * getNegativeZero(Type *Ty)
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
'undef' values are things that do not have specified contents.
Constant * getSequentialElement() const
If this CAZ has array or vector type, return a zero with the right element type.
static APFloat getAllOnesValue(unsigned BitWidth, bool isIEEE=false)
Returns a float which is bitcasted from an all one value int.
static Constant * get(LLVMContext &Context, ArrayRef< uint8_t > Elts)
get() constructors - Return a constant with array type with an element count and element type matchin...
Class to represent struct types.
A Use represents the edge between a Value definition and its users.
static Constant * getLShr(Constant *C1, Constant *C2, bool isExact=false)
static Constant * get(ArrayRef< Constant * > V)
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches, switches, etc.
0 1 0 1 True if ordered and less than or equal
double getElementAsDouble(unsigned i) const
If this is an sequential container of doubles, return the specified element as a double.
static Constant * getSExt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Instruction * getAsInstruction()
Returns an Instruction which implements the same operation as this ConstantExpr.
Type * getVectorElementType() const
void remove(ConstantClass *CP)
Remove this constant from the map.
static Type * getPPC_FP128Ty(LLVMContext &C)
LLVM_NODISCARD bool empty() const
All zero aggregate value.
static bool isValidOperands(const Value *V1, const Value *V2, const Value *Mask)
Return true if a shufflevector instruction can be formed with the specified operands.
bool isDLLImportDependent() const
Return true if the value is dependent on a dllimport variable.
static Constant * getZExt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static 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 Constant * getSizeOf(Type *Ty)
getSizeOf constant expr - computes the (alloc) size of a type (in address-units, not bits) in a targe...
static StructType * getTypeForElements(ArrayRef< Constant * > V, bool Packed=false)
Return an anonymous struct type to use for a constant with the specified set of elements.
A constant value that is initialized with an expression using other constant values.
static GetElementPtrInst * CreateInBounds(Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Create an "inbounds" getelementptr.
UndefValue * getElementValue(Constant *C) const
Return an undef of the right value for the specified GEP index if we can, otherwise return null (e...
void setIsExact(bool b=true)
Set or clear the exact flag on this instruction, which must be an operator which supports this flag...
opStatus convert(const fltSemantics &ToSemantics, roundingMode RM, bool *losesInfo)
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
static Constant * getFPCast(Constant *C, Type *Ty)
Create a FPExt, Bitcast or FPTrunc for fp -> fp casts.
ConstantDataSequential - A vector or array constant whose element type is a simple 1/2/4/8-byte integ...
bool isHalfTy() const
Return true if this is 'half', a 16-bit IEEE fp type.
static Constant * getAShr(Constant *C1, Constant *C2, bool isExact=false)
Class to represent array types.
bool isConstantUsed() const
Return true if the constant has users other than constant expressions and other dangling things...
UndefValue * getStructElement(unsigned Elt) const
If this undef has struct type, return a undef with the right element type for the specified element...
static Constant * getSelect(Constant *C, Constant *V1, Constant *V2, Type *OnlyIfReducedTy=nullptr)
Select constant expr.
bool isFirstClassType() const
Return true if the type is "first class", meaning it is a valid type for a Value. ...
std::unique_ptr< ConstantTokenNone > TheNoneToken
static CmpInst * Create(OtherOps Op, Predicate predicate, Value *S1, Value *S2, const Twine &Name="", Instruction *InsertBefore=nullptr)
Construct a compare instruction, given the opcode, the predicate and the two operands.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
TypeID getTypeID() const
Return the type id for the type.
bool isFloatingPointTy() const
Return true if this is one of the six floating-point types.
ArrayConstantsTy ArrayConstants
SequentialType * getType() const
Specialize the getType() method to always return a SequentialType, which reduces the amount of castin...
Constant * ConstantFoldInsertValueInstruction(Constant *Agg, Constant *Val, ArrayRef< unsigned > Idxs)
ConstantFoldInsertValueInstruction - Attempt to constant fold an insertvalue instruction with the spe...
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
bool isArrayTy() const
True if this is an instance of ArrayType.
static Constant * getIntSequenceIfElementsMatch(ArrayRef< Constant * > V)
static Constant * getUDiv(Constant *C1, Constant *C2, bool isExact=false)
Constant * getWithOperandReplaced(unsigned OpNo, Constant *Op) const
Return a constant expression identical to this one, but with the specified operand set to the specifi...
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
const char * getOpcodeName() const
Type * getScalarType() const LLVM_READONLY
If this is a vector type, return the element type, otherwise return 'this'.
bool isPPC_FP128Ty() const
Return true if this is powerpc long double.
Type * getElementType() const
size_t size() const
size - Get the array size.
static Constant * getFDiv(Constant *C1, Constant *C2)
static APFloat getInf(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Infinity.
Class to represent pointers.
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
static const fltSemantics & IEEEsingle()
11: Arbitrary bit width integers
static Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static bool removeDeadUsersOfConstant(const Constant *C)
If the specified constantexpr is dead, remove it.
bool isNotMinSignedValue() const
Return true if the value is not the smallest signed value.
DenseMap< PointerType *, std::unique_ptr< ConstantPointerNull > > CPNConstants
an instruction for type-safe pointer arithmetic to access elements of arrays and structs ...
static Constant * getInsertValue(Constant *Agg, Constant *Val, ArrayRef< unsigned > Idxs, Type *OnlyIfReducedTy=nullptr)
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
static bool ConstHasGlobalValuePredicate(const Constant *C, bool(*Predicate)(const GlobalValue *))
Check if C contains a GlobalValue for which Predicate is true.
Constant * ConstantFoldShuffleVectorInstruction(Constant *V1, Constant *V2, Constant *Mask)
static Constant * getFNeg(Constant *C)
static Constant * getFRem(Constant *C1, Constant *C2)
static Constant * getImpl(StringRef Bytes, Type *Ty)
This is the underlying implementation of all of the ConstantDataSequential::get methods.
static ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t find(char C, size_t From=0) const
Search for the first character C in the string.
An array constant whose element type is a simple 1/2/4/8-byte integer or float/double, and whose elements are just simple data values (i.e.
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
bool canTrap() const
Return true if evaluation of this constant could trap.
static Constant * getFP(LLVMContext &Context, ArrayRef< uint16_t > Elts)
getFP() constructors - Return a constant with array type with an element count and element type of fl...
A constant token which is empty.
bool isVectorTy() const
True if this is an instance of VectorType.
static BlockAddress * get(Function *F, BasicBlock *BB)
Return a BlockAddress for the specified function and basic block.
This is an important base class in LLVM.
bool bitwiseIsEqual(const APFloat &RHS) const
uint64_t getElementByteSize() const
Return the size (in bytes) of each element in the array/vector.
bool hasIndices() const
Return true if this is an insertvalue or extractvalue expression, and the getIndices() method may be ...
StringRef getAsString() const
If this array is isString(), then this method returns the array as a StringRef.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
StringRef getRawDataValues() const
Return the raw, underlying, bytes of this data.
static Constant * getFP(LLVMContext &Context, ArrayRef< uint16_t > Elts)
getFP() constructors - Return a constant with vector type with an element count and element type of f...
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
static Constant * getAnd(Constant *C1, Constant *C2)
APInt Or(const APInt &LHS, const APInt &RHS)
Bitwise OR function for APInt.
static Constant * get(ArrayType *T, ArrayRef< Constant * > V)
ConstantFP - Floating Point Values [float, double].
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
APInt Xor(const APInt &LHS, const APInt &RHS)
Bitwise XOR function for APInt.
static const fltSemantics & IEEEhalf()
bool isZeroValue() const
Return true if the value is negative zero or null value.
static Constant * getSExtOrBitCast(Constant *C, Type *Ty)
static Constant * getShuffleVector(Constant *V1, Constant *V2, Constant *Mask, Type *OnlyIfReducedTy=nullptr)
UndefValue * getSequentialElement() const
If this Undef has array or vector type, return a undef with the right element type.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
static bool canTrapImpl(const Constant *C, SmallPtrSetImpl< const ConstantExpr * > &NonTrappingOps)
unsigned getBitWidth() const
Return the number of bits in the APInt.
unsigned getValueID() const
Return an ID for the concrete type of this object.
static const unsigned End
uint64_t getNumElements() const
6: 128-bit floating point type (two 64-bits, PowerPC)
Value * getOperand(unsigned i) const
0 1 1 1 True if ordered (no nans)
ConstantClass * replaceOperandsInPlace(ArrayRef< Constant * > Operands, ConstantClass *CP, Value *From, Constant *To, unsigned NumUpdated=0, unsigned OperandNo=~0u)
static bool isValueValidForType(Type *Ty, const APFloat &V)
Return true if Ty is big enough to represent V.
static Constant * getICmp(unsigned short pred, Constant *LHS, Constant *RHS, bool OnlyIfReduced=false)
get* - Return some common constants without having to specify the full Instruction::OPCODE identifier...
unsigned getIntegerBitWidth() const
Class to represent integer types.
Constant Vector Declarations.
static Constant * get(StructType *T, ArrayRef< Constant * > V)
static Constant * getSplat(unsigned NumElts, Constant *Elt)
Return a ConstantVector with the specified constant in each element.
bool empty() const
empty - Check if the array is empty.
static Constant * getNot(Constant *C)
bool needsRelocation() const
This method classifies the entry according to whether or not it may generate a relocation entry...
Constant * getAggregateElement(unsigned Elt) const
For aggregates (struct/array/vector) return the constant that corresponds to the specified element if...
static Constant * getAllOnesValue(Type *Ty)
Get the all ones value.
unsigned getPredicate() const
Return the ICMP or FCMP predicate value.
1 1 1 1 Always true (always folded)
ArrayRef< unsigned > getIndices() const
Assert that this is an insertvalue or exactvalue expression and return the list of indices...
static bool isElementTypeCompatible(Type *Ty)
Return true if a ConstantDataSequential can be formed with a vector or array of the specified element...
uint64_t getElementAsInteger(unsigned i) const
If this is a sequential container of integers (of any size), return the specified element in the low ...
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
static const fltSemantics * TypeToFloatSemantics(Type *Ty)
bool isFP128Ty() const
Return true if this is 'fp128'.
bool isPointerTy() const
True if this is an instance of PointerType.
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
static const fltSemantics & IEEEquad()
LLVMContext & getContext() const
All values hold a context through their type.
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
Constant * ConstantFoldBinaryInstruction(unsigned Opcode, Constant *V1, Constant *V2)
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
1 1 0 1 True if unordered, less than, or equal
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
VectorConstantsTy VectorConstants
unsigned char SubclassOptionalData
Hold subclass data that can be dropped.
LLVMContextImpl *const pImpl
bool isCString() const
This method returns true if the array "isString", ends with a null byte, and does not contains any ot...
static Type * getFP128Ty(LLVMContext &C)
static 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...
bool isCompare() const
Return true if this is a compare constant expression.
static Constant * getFCmp(unsigned short pred, Constant *LHS, Constant *RHS, bool OnlyIfReduced=false)
0 0 1 0 True if ordered and greater than
static Constant * getPointerCast(Constant *C, Type *Ty)
Create a BitCast, AddrSpaceCast, or a PtrToInt cast constant expression.
static Constant * getSIToFP(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static Type * getHalfTy(LLVMContext &C)
static Constant * getSplat(unsigned NumElts, Constant *Elt)
Return a ConstantVector with the specified constant in each element.
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
void setHasNoSignedWrap(bool b=true)
Set or clear the nsw flag on this instruction, which must be an operator which supports this flag...
static bool isAllZeros(StringRef Arr)
Return true if the array is empty or all zeros.
uint64_t getSequentialNumElements() const
ArrayType * getType() const
Specialize the getType() method to always return an ArrayType, which reduces the amount of casting ne...
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the generic address space (address sp...
static Constant * getSequenceIfElementsMatch(Constant *C, ArrayRef< Constant * > V)
This is the shared class of boolean and integer constants.
16: SIMD 'packed' format, or other vector type
static StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
static Constant * getSDiv(Constant *C1, Constant *C2, bool isExact=false)
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type...
1 1 0 0 True if unordered or less than
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Module.h This file contains the declarations for the Module class.
Type * getType() const
All values are typed, get the type of this value.
A constant pointer value that points to null.
const char * getOpcodeName() const
Return a string representation for an opcode.
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
LLVM_NODISCARD T pop_back_val()
CHAIN = SC CHAIN, Imm128 - System call.
BasicBlock * getBasicBlock() const
Value * stripPointerCasts()
Strip off pointer casts, all-zero GEPs, and aliases.
static Constant * getTrunc(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
static ConstantInt * getSigned(IntegerType *Ty, int64_t V)
Return a ConstantInt with the specified value for the specified type.
static Constant * get(Type *Ty, double V)
This returns a ConstantFP, or a vector containing a splat of a ConstantFP, for the specified value in...
bool isNullValue() const
Return true if this is the value that would be returned by getNullValue.
static ConstantInt * getTrue(LLVMContext &Context)
ValueTy
Concrete subclass of this.
void handleOperandChange(Value *, Value *)
This method is a special form of User::replaceUsesOfWith (which does not work on constants) that does...
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
bool isBoundedSequential() const
void setOperand(unsigned i, Value *Val)
static BlockAddress * lookup(const BasicBlock *BB)
Lookup an existing BlockAddress constant for the given BasicBlock.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool isAllOnesValue() const
Return true if this is the value that would be returned by getAllOnesValue.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Class to represent vector types.
Class for arbitrary precision integers.
bool isCast() const
Return true if this is a convert constant expression.
unsigned getNumElements() const
Return the number of elements in the array, vector, or struct.
bool isIntegerTy() const
True if this is an instance of IntegerType.
StructType * getType() const
Specialization - reduce amount of casting.
static BinaryOperator * Create(BinaryOps Op, Value *S1, Value *S2, const Twine &Name=Twine(), Instruction *InsertBefore=nullptr)
Construct a binary instruction, given the opcode and the two operands.
GetElementPtrConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to ...
iterator_range< user_iterator > users()
unsigned getVectorNumElements() const
static Constant * getFPToUI(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static Constant * getCast(unsigned ops, Constant *C, Type *Ty, bool OnlyIfReduced=false)
Convenience function for getting a Cast operation.
static char getTypeID(Type *Ty)
static Constant * getZExtOrBitCast(Constant *C, Type *Ty)
Common super class of ArrayType, StructType and VectorType.
static const fltSemantics & IEEEdouble()
APInt And(const APInt &LHS, const APInt &RHS)
Bitwise AND function for APInt.
bool isStructTy() const
True if this is an instance of StructType.
static Constant * getFSub(Constant *C1, Constant *C2)
static Type * getIndexedType(Type *Ty, ArrayRef< Value * > IdxList)
Returns the type of the element that would be loaded with a load instruction with the specified param...
bool isGEPWithNoNotionalOverIndexing() const
Return true if this is a getelementptr expression and all the index operands are compile-time known i...
static Constant * getTruncOrBitCast(Constant *C, Type *Ty)
static Constant * getNeg(Constant *C, bool HasNUW=false, bool HasNSW=false)
Constant * ConstantFoldCompareInstruction(unsigned short predicate, Constant *C1, Constant *C2)
static CastInst * Create(Instruction::CastOps, Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
Provides a way to construct any of the CastInst subclasses using an opcode instead of the subclass's ...
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
static APFloat getNaN(const fltSemantics &Sem, bool Negative=false, unsigned type=0)
Factory for NaN values.
Constant * getElementValue(Constant *C) const
Return a zero of the right value for the specified GEP index if we can, otherwise return null (e...
PointerType * getType() const
Global values are always pointers.
Constant * ConstantFoldSelectInstruction(Constant *Cond, Constant *V1, Constant *V2)
user_iterator_impl< const User > const_user_iterator
bool isX86_FP80Ty() const
Return true if this is x86 long double.
static IntegerType * getInt32Ty(LLVMContext &C)
float getElementAsFloat(unsigned i) const
If this is an sequential container of floats, return the specified element as a float.
static Constant * getOffsetOf(StructType *STy, unsigned FieldNo)
getOffsetOf constant expr - computes the offset of a struct field in a target independent way (Note: ...
unsigned greater or equal
static InsertValueInst * Create(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Type * getSourceElementType() const
static Constant * getPtrToInt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static Constant * getOr(Constant *C1, Constant *C2)
static Constant * getZeroValueForNegation(Type *Ty)
Floating point negation must be implemented with f(x) = -0.0 - x.
unsigned getNumElements() const
Return the number of elements in the array or vector.
unsigned getNumElements() const
Return the number of elements in the array, vector, or struct.
Constant * ConstantFoldInsertElementInstruction(Constant *Val, Constant *Elt, Constant *Idx)
0 1 1 0 True if ordered and operands are unequal
static const fltSemantics & PPCDoubleDouble()
static ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
Compile-time customization of User operands.
bool isString() const
This method returns true if this is an array of i8.
DenseMap< Type *, std::unique_ptr< ConstantAggregateZero > > CAZConstants
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
static Constant * getShl(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
void destroyConstant()
Called if some element of this constant is no longer valid.
PointerType * getType() const
Specialize the getType() method to always return an PointerType, which reduces the amount of casting ...
static ConstantTokenNone * get(LLVMContext &Context)
Return the ConstantTokenNone.
ConstantUniqueMap< ConstantExpr > ExprConstants
1 0 1 0 True if unordered or greater than
VectorType * getType() const
Specialize the getType() method to always return a VectorType, which reduces the amount of casting ne...
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 ...
Type * getElementType() const
Return the element type of the array/vector.
void setHasNoUnsignedWrap(bool b=true)
Set or clear the nsw flag on this instruction, which must be an operator which supports this flag...
3: 64-bit floating point type
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Function * getFunction() const
user_iterator user_begin()
static Constant * getSRem(Constant *C1, Constant *C2)
Base class for aggregate constants (with operands).
void removeDeadConstantUsers() const
If there are any dead constant users dangling off of this constant, remove them.
unsigned getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
0 0 0 1 True if ordered and equal
StructConstantsTy StructConstants
LLVM Value Representation.
1 0 1 1 True if unordered, greater than, or equal
DenseMap< Type *, std::unique_ptr< UndefValue > > UVConstants
static Constant * getURem(Constant *C1, Constant *C2)
static VectorType * get(Type *ElementType, unsigned NumElements)
This static method is the primary way to construct an VectorType.
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
static Constant * getUIToFP(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static Constant * getFPToSI(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Constant * getStructElement(unsigned Elt) const
If this CAZ has struct type, return a zero with the right element type for the specified element...
ConstantClass * getOrCreate(TypeClass *Ty, ValType V)
Return the specified constant from the map, creating it if necessary.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
PointerType * getPointerTo(unsigned AddrSpace=0) const
Return a pointer to the current type.
static Constant * getExtractValue(Constant *Agg, ArrayRef< unsigned > Idxs, Type *OnlyIfReducedTy=nullptr)
StringRef - Represent a constant reference to a string, i.e.
Constant * ConstantFoldExtractValueInstruction(Constant *Agg, ArrayRef< unsigned > Idxs)
Attempt to constant fold an extractvalue instruction with the specified operands and indices...
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef drop_back(size_t N=1) const
Return a StringRef equal to 'this' but with the last N elements dropped.
static APInt getNullValue(unsigned numBits)
Get the '0' value.
static Constant * getAlignOf(Type *Ty)
getAlignOf constant expr - computes the alignment of a type in a target independent way (Note: the re...
static Constant * getMul(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
static Constant * get(LLVMContext &Context, ArrayRef< uint8_t > Elts)
get() constructors - Return a constant with vector type with an element count and element type matchi...
unsigned getNumElements() const
Random access to the elements.
0 0 1 1 True if ordered and greater than or equal
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
static Constant * getFPExtend(Constant *C, Type *Ty, bool OnlyIfReduced=false)
StringMap< ConstantDataSequential * > CDSConstants
Base class for constants with no operands.
bool isThreadDependent() const
Return true if the value can vary between threads.
Constant * getWithOperands(ArrayRef< Constant * > Ops) const
This returns the current constant expression with the operands replaced with the specified values...
static Constant * getBinOpAbsorber(unsigned Opcode, Type *Ty)
Return the absorbing element for the given binary operation, i.e.
static IntegerType * getInt8Ty(LLVMContext &C)
const fltSemantics & getSemantics() const
Constant * getSplatValue() const
If this is a splat constant, meaning that all of the elements have the same value, return that value.
0 0 0 0 Always false (always folded)
Type * getTypeAtIndex(const Value *V) const
Given an index value into the type, return the type of the element.
bool isMinSignedValue() const
Return true if the value is the smallest signed value.
static Constant * getXor(Constant *C1, Constant *C2)
5: 128-bit floating point type (112-bit mantissa)
gep_type_iterator gep_type_begin(const User *GEP)
static const char * areInvalidOperands(Value *Cond, Value *True, Value *False)
Return a string if the specified operands are invalid for a select operation, otherwise return null...