42 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
43 return CFP->isZero() && CFP->isNegative();
47 if (CV->getElementType()->isFloatingPointTy() && CV->isSplat())
48 if (CV->getElementAsAPFloat(0).isNegZero())
52 if (
ConstantFP *SplatCFP = dyn_cast_or_null<ConstantFP>(CV->getSplatValue()))
53 if (SplatCFP && SplatCFP->isZero() && SplatCFP->isNegative())
57 if (
getType()->isFPOrFPVectorTy())
68 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
73 if (CV->getElementType()->isFloatingPointTy() && CV->isSplat())
74 if (CV->getElementAsAPFloat(0).isZero())
78 if (
ConstantFP *SplatCFP = dyn_cast_or_null<ConstantFP>(CV->getSplatValue()))
79 if (SplatCFP && SplatCFP->isZero())
88 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(
this))
92 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
93 return CFP->isZero() && !CFP->isNegative();
97 return isa<ConstantAggregateZero>(
this) || isa<ConstantPointerNull>(
this) ||
98 isa<ConstantTokenNone>(
this);
103 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(
this))
104 return CI->isMinusOne();
107 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
108 return CFP->getValueAPF().bitcastToAPInt().isAllOnesValue();
113 return Splat->isAllOnesValue();
118 if (CV->getElementType()->isFloatingPointTy())
119 return CV->getElementAsAPFloat(0).bitcastToAPInt().isAllOnesValue();
120 return CV->getElementAsAPInt(0).isAllOnesValue();
129 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(
this))
133 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
134 return CFP->getValueAPF().bitcastToAPInt().isOneValue();
139 return Splat->isOneValue();
144 if (CV->getElementType()->isFloatingPointTy())
145 return CV->getElementAsAPFloat(0).bitcastToAPInt().isOneValue();
146 return CV->getElementAsAPInt(0).isOneValue();
155 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(
this))
156 return !CI->isOneValue();
159 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
160 return !CFP->getValueAPF().bitcastToAPInt().isOneValue();
163 if (this->
getType()->isVectorTy()) {
164 unsigned NumElts = this->
getType()->getVectorNumElements();
165 for (
unsigned i = 0; i != NumElts; ++i) {
166 Constant *Elt = this->getAggregateElement(i);
179 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(
this))
180 return CI->isMinValue(
true);
183 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
184 return CFP->getValueAPF().bitcastToAPInt().isMinSignedValue();
189 return Splat->isMinSignedValue();
194 if (CV->getElementType()->isFloatingPointTy())
195 return CV->getElementAsAPFloat(0).bitcastToAPInt().isMinSignedValue();
196 return CV->getElementAsAPInt(0).isMinSignedValue();
205 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(
this))
206 return !CI->isMinValue(
true);
209 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
210 return !CFP->getValueAPF().bitcastToAPInt().isMinSignedValue();
213 if (this->
getType()->isVectorTy()) {
214 unsigned NumElts = this->
getType()->getVectorNumElements();
215 for (
unsigned i = 0; i != NumElts; ++i) {
216 Constant *Elt = this->getAggregateElement(i);
228 if (
auto *CFP = dyn_cast<ConstantFP>(
this))
229 return CFP->getValueAPF().isFiniteNonZero();
232 for (
unsigned i = 0,
e =
getType()->getVectorNumElements(); i !=
e; ++i) {
233 auto *CFP = dyn_cast_or_null<ConstantFP>(this->getAggregateElement(i));
234 if (!CFP || !CFP->getValueAPF().isFiniteNonZero())
241 if (
auto *CFP = dyn_cast<ConstantFP>(
this))
242 return CFP->getValueAPF().isNormal();
245 for (
unsigned i = 0,
e =
getType()->getVectorNumElements(); i !=
e; ++i) {
246 auto *CFP = dyn_cast_or_null<ConstantFP>(this->getAggregateElement(i));
247 if (!CFP || !CFP->getValueAPF().isNormal())
254 if (
auto *CFP = dyn_cast<ConstantFP>(
this))
255 return CFP->getValueAPF().getExactInverse(
nullptr);
258 for (
unsigned i = 0,
e =
getType()->getVectorNumElements(); i !=
e; ++i) {
259 auto *CFP = dyn_cast_or_null<ConstantFP>(this->getAggregateElement(i));
260 if (!CFP || !CFP->getValueAPF().getExactInverse(
nullptr))
267 if (
auto *CFP = dyn_cast<ConstantFP>(
this))
271 for (
unsigned i = 0,
e =
getType()->getVectorNumElements(); i !=
e; ++i) {
272 auto *CFP = dyn_cast_or_null<ConstantFP>(this->getAggregateElement(i));
273 if (!CFP || !CFP->isNaN())
292 const_cast<Constant *>(
this),
300 for (
unsigned i = 0,
e =
getType()->getVectorNumElements(); i !=
e; ++i)
301 if (isa<UndefValue>(getAggregateElement(i)))
310 for (
unsigned i = 0,
e =
getType()->getVectorNumElements(); i !=
e; ++i)
311 if (isa<ConstantExpr>(getAggregateElement(i)))
362 if (
PointerType *PTy = dyn_cast<PointerType>(ScalarTy))
366 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
385 getAllOnesValue(VTy->getElementType()));
390 return Elt < CC->getNumOperands() ? CC->getOperand(Elt) :
nullptr;
393 return Elt < CAZ->getNumElements() ? CAZ->getElementValue(Elt) :
nullptr;
395 if (
const UndefValue *UV = dyn_cast<UndefValue>(
this))
396 return Elt < UV->getNumElements() ? UV->getElementValue(Elt) :
nullptr;
399 return Elt < CDS->getNumElements() ? CDS->getElementAsConstant(Elt)
405 assert(isa<IntegerType>(Elt->
getType()) &&
"Index must be an integer");
406 if (
ConstantInt *CI = dyn_cast<ConstantInt>(Elt)) {
408 if (CI->getValue().getActiveBits() > 64)
410 return getAggregateElement(CI->getZExtValue());
418 switch (getValueID()) {
421 #define HANDLE_CONSTANT(Name) \ 422 case Value::Name##Val: \ 423 cast<Name>(this)->destroyConstantImpl(); \ 425 #include "llvm/IR/Value.def" 435 while (!use_empty()) {
436 Value *V = user_back();
437 #ifndef NDEBUG // Only in -g mode... 438 if (!isa<Constant>(V)) {
439 dbgs() <<
"While deleting: " << *
this 440 <<
"\n\nUse still stuck around after Def is destroyed: " << *V
444 assert(isa<Constant>(V) &&
"References remain to Constant being destroyed");
445 cast<Constant>(V)->destroyConstant();
448 assert((use_empty() || user_back() != V) &&
"Constant not removed!");
465 if (
ConstantExpr *
Op = dyn_cast<ConstantExpr>(CE->getOperand(i))) {
472 switch (CE->getOpcode()) {
475 case Instruction::UDiv:
476 case Instruction::SDiv:
477 case Instruction::URem:
478 case Instruction::SRem:
480 if (!isa<ConstantInt>(CE->getOperand(1)) ||CE->getOperand(1)->isNullValue())
500 while (!WorkList.
empty()) {
502 if (
const auto *GV = dyn_cast<GlobalValue>(WorkItem))
509 if (Visited.
insert(ConstOp).second)
517 auto DLLImportPredicate = [](
const GlobalValue *GV) {
518 return GV->isThreadLocal();
524 auto DLLImportPredicate = [](
const GlobalValue *GV) {
525 return GV->hasDLLImportStorageClass();
533 if (!UC || isa<GlobalValue>(UC))
543 if (isa<GlobalValue>(
this))
546 if (
const BlockAddress *BA = dyn_cast<BlockAddress>(
this))
547 return BA->getFunction()->needsRelocation();
549 if (
const ConstantExpr *CE = dyn_cast<ConstantExpr>(
this)) {
550 if (CE->getOpcode() == Instruction::Sub) {
553 if (LHS && RHS && LHS->
getOpcode() == Instruction::PtrToInt &&
554 RHS->getOpcode() == Instruction::PtrToInt) {
562 if (isa<BlockAddress>(LHSOp0) && isa<BlockAddress>(RHSOp0) &&
570 if (LHSGV->isDSOLocal() && RHSGV->isDSOLocal())
577 for (
unsigned i = 0,
e = getNumOperands(); i !=
e; ++i)
578 Result |= cast<Constant>(getOperand(i))->needsRelocation();
586 if (isa<GlobalValue>(C))
return false;
590 if (!User)
return false;
595 const_cast<Constant*
>(
C)->destroyConstant();
620 if (LastNonDeadUser ==
E)
623 I = std::next(LastNonDeadUser);
628 assert(C && Replacement &&
"Expected non-nullptr constant arguments");
631 assert(Ty == Replacement->
getType() &&
"Expected matching types");
641 for (
unsigned i = 0; i != NumElts; ++i) {
644 "Expected matching types");
645 NewC[i] = EltC &&
match(EltC,
m_Undef()) ? Replacement : EltC;
677 if (
auto *VTy = dyn_cast<VectorType>(Ty))
685 if (
auto *VTy = dyn_cast<VectorType>(Ty))
694 std::unique_ptr<ConstantInt> &Slot = pImpl->
IntConstants[V];
708 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
719 return get(Ty, V,
true);
723 return get(Ty, V,
true);
729 "ConstantInt type doesn't match the type implied by its value!");
732 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
743 void ConstantInt::destroyConstantImpl() {
777 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
786 "ConstantFP type doesn't match the type implied by its value!");
789 if (
auto *VTy = dyn_cast<VectorType>(Ty))
802 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
813 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
824 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
835 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
846 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
855 return getNegativeZero(Ty);
865 std::unique_ptr<ConstantFP> &Slot = pImpl->
FPConstants[V];
881 "Unknown FP format");
894 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
907 return Val.bitwiseIsEqual(V);
911 void ConstantFP::destroyConstantImpl() {
928 if (isa<SequentialType>(
getType()))
929 return getSequentialElement();
930 return getStructElement(cast<ConstantInt>(C)->getZExtValue());
934 if (isa<SequentialType>(
getType()))
935 return getSequentialElement();
936 return getStructElement(Idx);
941 if (
auto *AT = dyn_cast<ArrayType>(Ty))
942 return AT->getNumElements();
943 if (
auto *VT = dyn_cast<VectorType>(Ty))
944 return VT->getNumElements();
961 if (isa<SequentialType>(
getType()))
962 return getSequentialElement();
963 return getStructElement(cast<ConstantInt>(C)->getZExtValue());
967 if (isa<SequentialType>(
getType()))
968 return getSequentialElement();
969 return getStructElement(Idx);
974 if (
auto *
ST = dyn_cast<SequentialType>(Ty))
975 return ST->getNumElements();
983 template <
typename ItTy,
typename EltTy>
985 for (; Start != End; ++Start)
991 template <
typename SequentialTy,
typename ElementTy>
993 assert(!V.
empty() &&
"Cannot get empty int sequence.");
997 if (
auto *CI = dyn_cast<ConstantInt>(C))
1001 return SequentialTy::get(V[0]->getContext(), Elts);
1004 template <
typename SequentialTy,
typename ElementTy>
1006 assert(!V.
empty() &&
"Cannot get empty FP sequence.");
1010 if (
auto *CFP = dyn_cast<ConstantFP>(C))
1011 Elts.
push_back(CFP->getValueAPF().bitcastToAPInt().getLimitedValue());
1014 return SequentialTy::getFP(V[0]->getContext(), Elts);
1017 template <
typename SequenceTy>
1024 if (CI->getType()->isIntegerTy(8))
1025 return getIntSequenceIfElementsMatch<SequenceTy, uint8_t>(V);
1026 else if (CI->getType()->isIntegerTy(16))
1027 return getIntSequenceIfElementsMatch<SequenceTy, uint16_t>(V);
1028 else if (CI->getType()->isIntegerTy(32))
1029 return getIntSequenceIfElementsMatch<SequenceTy, uint32_t>(V);
1030 else if (CI->getType()->isIntegerTy(64))
1031 return getIntSequenceIfElementsMatch<SequenceTy, uint64_t>(V);
1032 }
else if (
ConstantFP *CFP = dyn_cast<ConstantFP>(C)) {
1033 if (CFP->getType()->isHalfTy())
1034 return getFPSequenceIfElementsMatch<SequenceTy, uint16_t>(V);
1035 else if (CFP->getType()->isFloatTy())
1036 return getFPSequenceIfElementsMatch<SequenceTy, uint32_t>(V);
1037 else if (CFP->getType()->isDoubleTy())
1038 return getFPSequenceIfElementsMatch<SequenceTy, uint64_t>(V);
1051 if (
auto *
ST = dyn_cast<StructType>(T))
1054 for (
unsigned I = 0,
E = V.
size();
I !=
E; ++
I)
1056 "Initializer for composite element doesn't match!");
1062 "Invalid initializer for constant array");
1076 for (
unsigned i = 0,
e = V.
size(); i !=
e; ++i) {
1078 "Wrong type in array element initializer");
1094 return getSequenceIfElementsMatch<ConstantDataArray>(
C, V);
1103 unsigned VecSize = V.
size();
1105 for (
unsigned i = 0; i != VecSize; ++i)
1106 EltTypes[i] = V[i]->
getType();
1115 "ConstantStruct::getTypeForElements cannot be called on empty list");
1116 return getTypeForElements(V[0]->
getContext(), V, Packed);
1122 "Invalid initializer for constant struct");
1128 "Incorrect # elements specified to ConstantStruct::get");
1135 isUndef = isa<UndefValue>(V[0]);
1136 isZero = V[0]->isNullValue();
1137 if (isUndef || isZero) {
1138 for (
unsigned i = 0,
e = V.
size(); i !=
e; ++i) {
1141 if (!isa<UndefValue>(V[i]))
1157 "Invalid initializer for constant vector");
1175 bool isZero = C->isNullValue();
1178 if (isZero || isUndef) {
1179 for (
unsigned i = 1,
e = V.
size(); i !=
e; ++i)
1181 isZero = isUndef =
false;
1194 return getSequenceIfElementsMatch<ConstantDataVector>(
C, V);
1204 if ((isa<ConstantFP>(V) || isa<ConstantInt>(V)) &&
1220 void ConstantTokenNone::destroyConstantImpl() {
1236 if (
getOpcode() != Instruction::GetElementPtr)
return false;
1243 for (; GEPI !=
E; ++GEPI, ++OI) {
1244 if (isa<UndefValue>(*OI))
1248 (CI->getValue().getActiveBits() > 64 ||
1258 return getOpcode() == Instruction::ExtractValue ||
1259 getOpcode() == Instruction::InsertValue;
1264 dyn_cast<ExtractValueConstantExpr>(
this))
1265 return EVCE->Indices;
1267 return cast<InsertValueConstantExpr>(
this)->Indices;
1271 return cast<CompareConstantExpr>(
this)->predicate;
1277 "Replacing operand with value of different type!");
1279 return const_cast<ConstantExpr*>(
this);
1285 return getWithOperands(NewOps);
1289 bool OnlyIfReduced,
Type *SrcTy)
const {
1296 Type *OnlyIfReducedTy = OnlyIfReduced ? Ty :
nullptr;
1298 case Instruction::Trunc:
1299 case Instruction::ZExt:
1300 case Instruction::SExt:
1301 case Instruction::FPTrunc:
1302 case Instruction::FPExt:
1303 case Instruction::UIToFP:
1304 case Instruction::SIToFP:
1305 case Instruction::FPToUI:
1306 case Instruction::FPToSI:
1307 case Instruction::PtrToInt:
1308 case Instruction::IntToPtr:
1309 case Instruction::BitCast:
1310 case Instruction::AddrSpaceCast:
1314 case Instruction::InsertElement:
1317 case Instruction::ExtractElement:
1319 case Instruction::InsertValue:
1322 case Instruction::ExtractValue:
1324 case Instruction::ShuffleVector:
1327 case Instruction::GetElementPtr: {
1328 auto *GEPO = cast<GEPOperator>(
this);
1331 SrcTy ? SrcTy : GEPO->getSourceElementType(), Ops[0], Ops.
slice(1),
1332 GEPO->isInBounds(), GEPO->getInRangeIndex(), OnlyIfReducedTy);
1334 case Instruction::ICmp:
1335 case Instruction::FCmp:
1352 return Val == 0 || Val == 1;
1359 return Val == 0 || Val == 1 || Val == -1;
1360 return isIntN(NumBits, Val);
1416 "Cannot create an aggregate zero of non-aggregate type!");
1418 std::unique_ptr<ConstantAggregateZero> &
Entry =
1427 void ConstantAggregateZero::destroyConstantImpl() {
1432 void ConstantArray::destroyConstantImpl() {
1441 void ConstantStruct::destroyConstantImpl() {
1446 void ConstantVector::destroyConstantImpl() {
1451 assert(this->
getType()->isVectorTy() &&
"Only valid for vectors!");
1452 if (isa<ConstantAggregateZero>(
this))
1455 return CV->getSplatValue();
1457 return CV->getSplatValue(AllowUndefs);
1475 if (isa<UndefValue>(OpC))
1479 if (isa<UndefValue>(Elt))
1489 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(
this))
1490 return CI->getValue();
1493 assert(C && isa<ConstantInt>(C) &&
"Not a vector of numbers!");
1494 return cast<ConstantInt>(
C)->getValue();
1501 std::unique_ptr<ConstantPointerNull> &
Entry =
1510 void ConstantPointerNull::destroyConstantImpl() {
1523 void UndefValue::destroyConstantImpl() {
1548 BB->AdjustBlockAddressRefCount(1);
1556 assert(F &&
"Block must have a parent");
1559 assert(BA &&
"Refcount and block address map disagree!");
1564 void BlockAddress::destroyConstantImpl() {
1567 getBasicBlock()->AdjustBlockAddressRefCount(-1);
1579 assert(From == NewBB &&
"From does not match any operand");
1580 NewBB = cast<BasicBlock>(To);
1590 getBasicBlock()->AdjustBlockAddressRefCount(-1);
1599 getBasicBlock()->AdjustBlockAddressRefCount(1);
1612 bool OnlyIfReduced =
false) {
1630 bool OnlyIfReduced) {
1633 assert(C && Ty &&
"Null arguments to getCast");
1639 case Instruction::Trunc:
1640 return getTrunc(C, Ty, OnlyIfReduced);
1641 case Instruction::ZExt:
1642 return getZExt(C, Ty, OnlyIfReduced);
1643 case Instruction::SExt:
1644 return getSExt(C, Ty, OnlyIfReduced);
1645 case Instruction::FPTrunc:
1646 return getFPTrunc(C, Ty, OnlyIfReduced);
1647 case Instruction::FPExt:
1648 return getFPExtend(C, Ty, OnlyIfReduced);
1649 case Instruction::UIToFP:
1650 return getUIToFP(C, Ty, OnlyIfReduced);
1651 case Instruction::SIToFP:
1652 return getSIToFP(C, Ty, OnlyIfReduced);
1653 case Instruction::FPToUI:
1654 return getFPToUI(C, Ty, OnlyIfReduced);
1655 case Instruction::FPToSI:
1656 return getFPToSI(C, Ty, OnlyIfReduced);
1657 case Instruction::PtrToInt:
1658 return getPtrToInt(C, Ty, OnlyIfReduced);
1659 case Instruction::IntToPtr:
1660 return getIntToPtr(C, Ty, OnlyIfReduced);
1661 case Instruction::BitCast:
1662 return getBitCast(C, Ty, OnlyIfReduced);
1663 case Instruction::AddrSpaceCast:
1664 return getAddrSpaceCast(C, Ty, OnlyIfReduced);
1670 return getBitCast(C, Ty);
1671 return getZExt(C, Ty);
1676 return getBitCast(C, Ty);
1677 return getSExt(C, Ty);
1682 return getBitCast(C, Ty);
1683 return getTrunc(C, Ty);
1692 return getPtrToInt(S, Ty);
1696 return getAddrSpaceCast(S, Ty);
1698 return getBitCast(S, Ty);
1707 return getAddrSpaceCast(S, Ty);
1709 return getBitCast(S, Ty);
1718 (SrcBits == DstBits ? Instruction::BitCast :
1719 (SrcBits > DstBits ? Instruction::Trunc :
1720 (isSigned ? Instruction::SExt : Instruction::ZExt)));
1721 return getCast(opcode, C, Ty);
1729 if (SrcBits == DstBits)
1732 (SrcBits > DstBits ? Instruction::FPTrunc : Instruction::FPExt);
1733 return getCast(opcode, C, Ty);
1741 assert((fromVec == toVec) &&
"Cannot convert from scalar to/from vector");
1745 "SrcTy must be larger than DestTy for Trunc!");
1747 return getFoldedCast(Instruction::Trunc, C, Ty, OnlyIfReduced);
1755 assert((fromVec == toVec) &&
"Cannot convert from scalar to/from vector");
1759 "SrcTy must be smaller than DestTy for SExt!");
1761 return getFoldedCast(Instruction::SExt, C, Ty, OnlyIfReduced);
1769 assert((fromVec == toVec) &&
"Cannot convert from scalar to/from vector");
1773 "SrcTy must be smaller than DestTy for ZExt!");
1775 return getFoldedCast(Instruction::ZExt, C, Ty, OnlyIfReduced);
1783 assert((fromVec == toVec) &&
"Cannot convert from scalar to/from vector");
1786 "This is an illegal floating point truncation!");
1787 return getFoldedCast(Instruction::FPTrunc, C, Ty, OnlyIfReduced);
1795 assert((fromVec == toVec) &&
"Cannot convert from scalar to/from vector");
1798 "This is an illegal floating point extension!");
1799 return getFoldedCast(Instruction::FPExt, C, Ty, OnlyIfReduced);
1807 assert((fromVec == toVec) &&
"Cannot convert from scalar to/from vector");
1809 "This is an illegal uint to floating point cast!");
1810 return getFoldedCast(Instruction::UIToFP, C, Ty, OnlyIfReduced);
1818 assert((fromVec == toVec) &&
"Cannot convert from scalar to/from vector");
1820 "This is an illegal sint to floating point cast!");
1821 return getFoldedCast(Instruction::SIToFP, C, Ty, OnlyIfReduced);
1829 assert((fromVec == toVec) &&
"Cannot convert from scalar to/from vector");
1831 "This is an illegal floating point to uint cast!");
1832 return getFoldedCast(Instruction::FPToUI, C, Ty, OnlyIfReduced);
1840 assert((fromVec == toVec) &&
"Cannot convert from scalar to/from vector");
1842 "This is an illegal floating point to sint cast!");
1843 return getFoldedCast(Instruction::FPToSI, C, Ty, OnlyIfReduced);
1847 bool OnlyIfReduced) {
1849 "PtrToInt source must be pointer or pointer vector");
1851 "PtrToInt destination must be integer or integer vector");
1852 assert(isa<VectorType>(C->
getType()) == isa<VectorType>(DstTy));
1853 if (isa<VectorType>(C->
getType()))
1855 "Invalid cast between a different number of vector elements");
1856 return getFoldedCast(Instruction::PtrToInt, C, DstTy, OnlyIfReduced);
1860 bool OnlyIfReduced) {
1862 "IntToPtr source must be integer or integer vector");
1864 "IntToPtr destination must be a pointer or pointer vector");
1865 assert(isa<VectorType>(C->
getType()) == isa<VectorType>(DstTy));
1866 if (isa<VectorType>(C->
getType()))
1868 "Invalid cast between a different number of vector elements");
1869 return getFoldedCast(Instruction::IntToPtr, C, DstTy, OnlyIfReduced);
1873 bool OnlyIfReduced) {
1875 "Invalid constantexpr bitcast!");
1879 if (C->
getType() == DstTy)
return C;
1881 return getFoldedCast(Instruction::BitCast, C, DstTy, OnlyIfReduced);
1885 bool OnlyIfReduced) {
1887 "Invalid constantexpr addrspacecast!");
1893 Type *DstElemTy = DstScalarTy->getElementType();
1896 if (
VectorType *VT = dyn_cast<VectorType>(DstTy)) {
1900 C = getBitCast(C, MidTy);
1902 return getFoldedCast(Instruction::AddrSpaceCast, C, DstTy, OnlyIfReduced);
1906 Type *OnlyIfReducedTy) {
1909 "Invalid opcode in unary constant expression");
1913 case Instruction::FNeg:
1915 "Tried to create a floating-point operation on a " 1916 "non-floating-point type!");
1926 if (OnlyIfReducedTy == C->
getType())
1937 unsigned Flags,
Type *OnlyIfReducedTy) {
1940 "Invalid opcode in binary constant expression");
1942 "Operand types in binary constant expression should match");
1947 case Instruction::Sub:
1948 case Instruction::Mul:
1949 case Instruction::UDiv:
1950 case Instruction::SDiv:
1951 case Instruction::URem:
1952 case Instruction::SRem:
1954 "Tried to create an integer operation on a non-integer type!");
1956 case Instruction::FAdd:
1957 case Instruction::FSub:
1958 case Instruction::FMul:
1959 case Instruction::FDiv:
1960 case Instruction::FRem:
1962 "Tried to create a floating-point operation on a " 1963 "non-floating-point type!");
1965 case Instruction::And:
1966 case Instruction::Or:
1967 case Instruction::Xor:
1969 "Tried to create a logical operation on a non-integral type!");
1971 case Instruction::Shl:
1972 case Instruction::LShr:
1973 case Instruction::AShr:
1975 "Tried to create a shift operation on a non-integer type!");
1985 if (OnlyIfReducedTy == C1->
getType())
2001 return getPtrToInt(GEP,
2012 Constant *Indices[2] = { Zero, One };
2013 Constant *
GEP = getGetElementPtr(AligningTy, NullPtr, Indices);
2014 return getPtrToInt(GEP,
2032 return getPtrToInt(GEP,
2037 Constant *C2,
bool OnlyIfReduced) {
2040 switch (Predicate) {
2048 return getFCmp(Predicate, C1, C2, OnlyIfReduced);
2054 return getICmp(Predicate, C1, C2, OnlyIfReduced);
2059 Type *OnlyIfReducedTy) {
2065 if (OnlyIfReducedTy == V1->
getType())
2078 Type *OnlyIfReducedTy) {
2091 assert(DestTy &&
"GEP indices invalid!");
2095 unsigned NumVecElts = 0;
2098 else for (
auto Idx : Idxs)
2099 if (Idx->getType()->isVectorTy())
2100 NumVecElts = Idx->getType()->getVectorNumElements();
2105 if (OnlyIfReducedTy == ReqTy)
2109 std::vector<Constant*> ArgVec;
2110 ArgVec.reserve(1 + Idxs.size());
2111 ArgVec.push_back(C);
2112 for (
unsigned i = 0,
e = Idxs.size(); i !=
e; ++i) {
2114 Idxs[i]->
getType()->getVectorNumElements() == NumVecElts) &&
2115 "getelementptr index type missmatch");
2117 Constant *Idx = cast<Constant>(Idxs[i]);
2120 ArgVec.push_back(Idx);
2123 unsigned SubClassOptionalData = InBounds ? GEPOperator::IsInBounds : 0;
2124 if (InRangeIndex && *InRangeIndex < 63)
2125 SubClassOptionalData |= (*InRangeIndex + 1) << 1;
2127 SubClassOptionalData,
None, Ty);
2134 Constant *RHS,
bool OnlyIfReduced) {
2137 "Invalid ICmp Predicate");
2159 Constant *RHS,
bool OnlyIfReduced) {
2162 "Invalid FCmp Predicate");
2184 Type *OnlyIfReducedTy) {
2186 "Tried to create extractelement operation on non-vector type!");
2188 "Extractelement index must be an integer type!");
2194 if (OnlyIfReducedTy == ReqTy)
2208 "Tried to create insertelement operation on non-vector type!");
2210 "Insertelement types must match!");
2212 "Insertelement index must be i32 type!");
2217 if (OnlyIfReducedTy == Val->
getType())
2221 Constant *ArgVec[] = { Val, Elt, Idx };
2231 "Invalid shuffle vector constant expr operands!");
2240 if (OnlyIfReducedTy == ShufTy)
2253 Type *OnlyIfReducedTy) {
2255 "Non-first-class type for constant insertvalue expression");
2259 "insertvalue indices invalid!");
2265 if (OnlyIfReducedTy == ReqTy)
2276 Type *OnlyIfReducedTy) {
2278 "Tried to create extractelement operation on non-first-class type!");
2282 assert(ReqTy &&
"extractvalue indices invalid!");
2285 "Non-first-class type for constant extractvalue expression");
2289 if (OnlyIfReducedTy == ReqTy)
2301 "Cannot NEG a nonintegral value!");
2308 "Cannot FNEG a non-floating-point value!");
2309 return get(Instruction::FNeg,
C);
2314 "Cannot NOT a nonintegral value!");
2319 bool HasNUW,
bool HasNSW) {
2326 return get(Instruction::FAdd, C1, C2);
2330 bool HasNUW,
bool HasNSW) {
2333 return get(Instruction::Sub, C1, C2, Flags);
2337 return get(Instruction::FSub, C1, C2);
2341 bool HasNUW,
bool HasNSW) {
2344 return get(Instruction::Mul, C1, C2, Flags);
2348 return get(Instruction::FMul, C1, C2);
2352 return get(Instruction::UDiv, C1, C2,
2357 return get(Instruction::SDiv, C1, C2,
2362 return get(Instruction::FDiv, C1, C2);
2366 return get(Instruction::URem, C1, C2);
2370 return get(Instruction::SRem, C1, C2);
2374 return get(Instruction::FRem, C1, C2);
2378 return get(Instruction::And, C1, C2);
2382 return get(Instruction::Or, C1, C2);
2386 return get(Instruction::Xor, C1, C2);
2390 bool HasNUW,
bool HasNSW) {
2393 return get(Instruction::Shl, C1, C2, Flags);
2397 return get(Instruction::LShr, C1, C2,
2402 return get(Instruction::AShr, C1, C2,
2407 bool AllowRHSConstant) {
2414 case Instruction::Or:
2415 case Instruction::Xor:
2417 case Instruction::Mul:
2419 case Instruction::And:
2421 case Instruction::FAdd:
2424 case Instruction::FMul:
2432 if (!AllowRHSConstant)
2436 case Instruction::Sub:
2437 case Instruction::Shl:
2438 case Instruction::LShr:
2439 case Instruction::AShr:
2440 case Instruction::FSub:
2442 case Instruction::SDiv:
2443 case Instruction::UDiv:
2445 case Instruction::FDiv:
2458 case Instruction::Or:
2461 case Instruction::And:
2462 case Instruction::Mul:
2468 void ConstantExpr::destroyConstantImpl() {
2476 GetElementPtrConstantExpr::GetElementPtrConstantExpr(
2480 (IdxList.
size() + 1),
2481 IdxList.
size() + 1),
2482 SrcElementTy(SrcElementTy),
2486 for (
unsigned i = 0,
E = IdxList.
size(); i !=
E; ++i)
2487 OperandList[i+1] = IdxList[i];
2491 return SrcElementTy;
2495 return ResElementTy;
2502 return getType()->getElementType();
2506 return StringRef(DataElements, getNumElements()*getElementByteSize());
2511 if (
auto *
IT = dyn_cast<IntegerType>(Ty)) {
2512 switch (
IT->getBitWidth()) {
2526 return AT->getNumElements();
2532 return getElementType()->getPrimitiveSizeInBits()/8;
2536 const char *ConstantDataSequential::getElementPointer(
unsigned Elt)
const {
2537 assert(Elt < getNumElements() &&
"Invalid Elt");
2538 return DataElements+Elt*getElementByteSize();
2573 Entry = &Node->Next, Node = *Entry)
2574 if (Node->getType() == Ty)
2579 if (isa<ArrayType>(Ty))
2582 assert(isa<VectorType>(Ty));
2586 void ConstantDataSequential::destroyConstantImpl() {
2592 CDSConstants.
find(getRawDataValues());
2594 assert(Slot != CDSConstants.
end() &&
"CDS not found in uniquing table");
2599 if (!(*Entry)->Next) {
2602 assert((*Entry) ==
this &&
"Hash mismatch in ConstantDataSequential");
2608 Entry = &Node->Next, Node = *Entry) {
2609 assert(Node &&
"Didn't find entry in its uniquing hash table!");
2612 *Entry = Node->Next;
2631 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2637 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2643 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2657 return get(
Context, ElementVals);
2665 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2670 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2675 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2680 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2685 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2690 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2702 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2708 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2714 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2720 "Element type not compatible with ConstantData");
2722 if (CI->getType()->isIntegerTy(8)) {
2726 if (CI->getType()->isIntegerTy(16)) {
2730 if (CI->getType()->isIntegerTy(32)) {
2734 assert(CI->getType()->isIntegerTy(64) &&
"Unsupported ConstantData type");
2739 if (
ConstantFP *CFP = dyn_cast<ConstantFP>(V)) {
2740 if (CFP->getType()->isHalfTy()) {
2742 NumElts, CFP->getValueAPF().bitcastToAPInt().getLimitedValue());
2745 if (CFP->getType()->isFloatTy()) {
2747 NumElts, CFP->getValueAPF().bitcastToAPInt().getLimitedValue());
2750 if (CFP->getType()->isDoubleTy()) {
2752 NumElts, CFP->getValueAPF().bitcastToAPInt().getLimitedValue());
2761 assert(isa<IntegerType>(getElementType()) &&
2762 "Accessor can only be used when element is an integer");
2763 const char *EltPtr = getElementPointer(Elt);
2767 switch (getElementType()->getIntegerBitWidth()) {
2770 return *
reinterpret_cast<const uint8_t *
>(EltPtr);
2772 return *
reinterpret_cast<const uint16_t *
>(EltPtr);
2774 return *
reinterpret_cast<const uint32_t *
>(EltPtr);
2776 return *
reinterpret_cast<const uint64_t *
>(EltPtr);
2781 assert(isa<IntegerType>(getElementType()) &&
2782 "Accessor can only be used when element is an integer");
2783 const char *EltPtr = getElementPointer(Elt);
2787 switch (getElementType()->getIntegerBitWidth()) {
2790 auto EltVal = *
reinterpret_cast<const uint8_t *
>(EltPtr);
2791 return APInt(8, EltVal);
2794 auto EltVal = *
reinterpret_cast<const uint16_t *
>(EltPtr);
2795 return APInt(16, EltVal);
2798 auto EltVal = *
reinterpret_cast<const uint32_t *
>(EltPtr);
2799 return APInt(32, EltVal);
2802 auto EltVal = *
reinterpret_cast<const uint64_t *
>(EltPtr);
2803 return APInt(64, EltVal);
2809 const char *EltPtr = getElementPointer(Elt);
2811 switch (getElementType()->
getTypeID()) {
2813 llvm_unreachable(
"Accessor can only be used when element is float/double!");
2815 auto EltVal = *
reinterpret_cast<const uint16_t *
>(EltPtr);
2819 auto EltVal = *
reinterpret_cast<const uint32_t *
>(EltPtr);
2823 auto EltVal = *
reinterpret_cast<const uint64_t *
>(EltPtr);
2830 assert(getElementType()->isFloatTy() &&
2831 "Accessor can only be used when element is a 'float'");
2832 return *
reinterpret_cast<const float *
>(getElementPointer(Elt));
2836 assert(getElementType()->isDoubleTy() &&
2837 "Accessor can only be used when element is a 'float'");
2838 return *
reinterpret_cast<const double *
>(getElementPointer(Elt));
2842 if (getElementType()->isHalfTy() || getElementType()->isFloatTy() ||
2843 getElementType()->isDoubleTy())
2850 return isa<ArrayType>(
getType()) && getElementType()->isIntegerTy(CharSize);
2860 if (Str.
back() != 0)
return false;
2867 const char *
Base = getRawDataValues().data();
2870 unsigned EltSize = getElementByteSize();
2871 for (
unsigned i = 1,
e = getNumElements(); i !=
e; ++i)
2872 if (
memcmp(Base, Base+i*EltSize, EltSize))
2880 return isSplat() ? getElementAsConstant(0) :
nullptr;
2898 Value *Replacement =
nullptr;
2902 #define HANDLE_CONSTANT(Name) \ 2903 case Value::Name##Val: \ 2904 Replacement = cast<Name>(this)->handleOperandChangeImpl(From, To); \ 2906 #include "llvm/IR/Value.def" 2915 assert(Replacement !=
this &&
"I didn't contain From!");
2924 Value *ConstantArray::handleOperandChangeImpl(
Value *From,
Value *To) {
2925 assert(isa<Constant>(To) &&
"Cannot make Constant refer to non-constant!");
2926 Constant *ToC = cast<Constant>(To);
2933 unsigned NumUpdated = 0;
2936 bool AllSame =
true;
2938 unsigned OperandNo = 0;
2940 Constant *Val = cast<Constant>(
O->get());
2942 OperandNo = (
O - OperandList);
2946 Values.push_back(Val);
2947 AllSame &= Val == ToC;
2953 if (AllSame && isa<UndefValue>(ToC))
2962 Values,
this, From, ToC, NumUpdated, OperandNo);
2965 Value *ConstantStruct::handleOperandChangeImpl(
Value *From,
Value *To) {
2966 assert(isa<Constant>(To) &&
"Cannot make Constant refer to non-constant!");
2967 Constant *ToC = cast<Constant>(To);
2976 unsigned NumUpdated = 0;
2977 bool AllSame =
true;
2978 unsigned OperandNo = 0;
2980 Constant *Val = cast<Constant>(
O->get());
2982 OperandNo = (
O - OperandList);
2987 AllSame &= Val == ToC;
2993 if (AllSame && isa<UndefValue>(ToC))
2998 Values,
this, From, ToC, NumUpdated, OperandNo);
3001 Value *ConstantVector::handleOperandChangeImpl(
Value *From,
Value *To) {
3002 assert(isa<Constant>(To) &&
"Cannot make Constant refer to non-constant!");
3003 Constant *ToC = cast<Constant>(To);
3007 unsigned NumUpdated = 0;
3008 unsigned OperandNo = 0;
3016 Values.push_back(Val);
3024 Values,
this, From, ToC, NumUpdated, OperandNo);
3027 Value *ConstantExpr::handleOperandChangeImpl(
Value *From,
Value *ToV) {
3028 assert(isa<Constant>(ToV) &&
"Cannot make Constant refer to non-constant!");
3029 Constant *To = cast<Constant>(ToV);
3032 unsigned NumUpdated = 0;
3033 unsigned OperandNo = 0;
3041 NewOps.push_back(Op);
3043 assert(NumUpdated &&
"I didn't contain From!");
3050 NewOps,
this, From, To, NumUpdated, OperandNo);
3058 case Instruction::Trunc:
3059 case Instruction::ZExt:
3060 case Instruction::SExt:
3061 case Instruction::FPTrunc:
3062 case Instruction::FPExt:
3063 case Instruction::UIToFP:
3064 case Instruction::SIToFP:
3065 case Instruction::FPToUI:
3066 case Instruction::FPToSI:
3067 case Instruction::PtrToInt:
3068 case Instruction::IntToPtr:
3069 case Instruction::BitCast:
3070 case Instruction::AddrSpaceCast:
3075 case Instruction::InsertElement:
3077 case Instruction::ExtractElement:
3079 case Instruction::InsertValue:
3081 case Instruction::ExtractValue:
3083 case Instruction::ShuffleVector:
3086 case Instruction::GetElementPtr: {
3087 const auto *GO = cast<GEPOperator>(
this);
3088 if (GO->isInBounds())
3090 Ops[0], Ops.
slice(1));
3094 case Instruction::ICmp:
3095 case Instruction::FCmp:
3098 case Instruction::FNeg:
3105 if (isa<OverflowingBinaryOperator>(BO)) {
3111 if (isa<PossiblyExactOperator>(BO))
bool isBoundedSequential() const
bool isFPPredicate() const
const T & front() const
front - Get the first element.
static Constant * getFPTrunc(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Type * getVectorElementType() const
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 APFloat getNaN(const fltSemantics &Sem, bool Negative=false, uint64_t payload=0)
Factory for NaN values.
static const fltSemantics & IEEEquad() LLVM_READNONE
IntegerType * getType() const
getType - Specialize the getType() method to always return an IntegerType, which reduces the amount o...
static ConstantInt * getFalse(LLVMContext &Context)
class_match< UndefValue > m_Undef()
Match an arbitrary undef constant.
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)
bool isAllOnesValue() const
Return true if this is the value that would be returned by getAllOnesValue.
static IntegerType * getInt1Ty(LLVMContext &C)
static Constant * getFAdd(Constant *C1, Constant *C2)
unsigned getOpcode() const
Return the opcode at the root of this constant expression.
unsigned getNumElements() const
Return the number of elements in the array, vector, or struct.
static APInt getAllOnesValue(unsigned numBits)
Get the all-ones value.
unsigned getValueID() const
Return an ID for the concrete type of this object.
bool isNaN() const
Return true if this is a floating-point NaN constant or a vector floating-point constant with all NaN...
static Constant * getPointerBitCastOrAddrSpaceCast(Constant *C, Type *Ty)
Create a BitCast or AddrSpaceCast for a pointer type depending on the address space.
This class represents lattice values for constants.
Constant * getElementAsConstant(unsigned i) const
Return a Constant for a specified index's element.
DenseMap< std::pair< const Function *, const BasicBlock * >, BlockAddress * > BlockAddresses
static Constant * getGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant *> IdxList, bool InBounds=false, Optional< unsigned > InRangeIndex=None, Type *OnlyIfReducedTy=nullptr)
Getelementptr form.
static Constant * getInfinity(Type *Ty, bool Negative=false)
2: 32-bit floating point type
bool needsRelocation() const
This method classifies the entry according to whether or not it may generate a relocation entry...
bool isConstantUsed() const
Return true if the constant has users other than constant expressions and other dangling things...
unsigned getNumElements() const
Random access to the elements.
void push_back(const T &Elt)
static Constant * getAddrSpaceCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static ConstantAggregateZero * get(Type *Ty)
APInt getElementAsAPInt(unsigned i) const
If this is a sequential container of integers (of any size), return the specified element as an APInt...
bool isFP128Ty() const
Return true if this is 'fp128'.
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value *> IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constant * ConstantFoldExtractElementInstruction(Constant *Val, Constant *Idx)
Attempt to constant fold an extractelement instruction with the specified operands and indices...
Constant * getSplatValue(bool AllowUndefs=false) const
If all elements of the vector constant 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)
Constant * ConstantFoldCastInstruction(unsigned opcode, Constant *V, Type *DestTy)
static Constant * getIntToPtr(Constant *C, Type *Ty, bool OnlyIfReduced=false)
uint64_t getElementByteSize() const
Return the size (in bytes) of each element in the array/vector.
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)
LLVMContext & getContext() const
All values hold a context through their type.
ConstantInt * TheFalseVal
1 1 1 0 True if unordered or not equal
const APInt & getUniqueInteger() const
If C is a constant integer then return its value, otherwise C must be a vector of constant integers...
4: 80-bit floating point type (X87)
const fltSemantics & getSemantics() const
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
static APFloat getZero(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Zero.
1: 16-bit floating point type
static IntegerType * getInt64Ty(LLVMContext &C)
bool isOpaque() const
Return true if this is a type with an identity that has no body specified yet.
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)
bool isVectorTy() const
True if this is an instance of VectorType.
void reserve(size_type N)
static IntegerType * getInt16Ty(LLVMContext &C)
unsigned getPredicate() const
Return the ICMP or FCMP predicate value.
bool isPPC_FP128Ty() const
Return true if this is powerpc long double.
static Type * getX86_FP80Ty(LLVMContext &C)
static Constant * get(ArrayType *T, ArrayRef< Constant *> V)
unsigned getBitWidth() const
Return the number of bits in the APInt.
Constant * getElementValue(Constant *C) const
Return a zero of the right value for the specified GEP index if we can, otherwise return null (e...
static Constant * getInsertElement(Constant *Vec, Constant *Elt, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
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)
static Constant * getFPSequenceIfElementsMatch(ArrayRef< Constant *> V)
Function * getFunction() const
ConstantClass * replaceOperandsInPlace(ArrayRef< Constant *> Operands, ConstantClass *CP, Value *From, Constant *To, unsigned NumUpdated=0, unsigned OperandNo=~0u)
1 0 0 1 True if unordered or equal
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
The address of a basic block.
bool match(Val *V, const Pattern &P)
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)
Instruction * getAsInstruction() const
Returns an Instruction which implements the same operation as this ConstantExpr.
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 Type * getFloatTy(LLVMContext &C)
static Constant * getNegativeZero(Type *Ty)
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
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.
'undef' values are things that do not have specified contents.
static APFloat getAllOnesValue(unsigned BitWidth, bool isIEEE=false)
Returns a float which is bitcasted from an all one value int.
StringRef getRawDataValues() const
Return the raw, underlying, bytes of this data.
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)
Constant * ConstantFoldUnaryInstruction(unsigned Opcode, Constant *V)
PointerType * getPointerTo(unsigned AddrSpace=0) const
Return a pointer to the current type.
static Optional< unsigned > getOpcode(ArrayRef< VPValue *> Values)
Returns the opcode of Values or ~0 if they do not all agree.
bool isIntegerTy() const
True if this is an instance of IntegerType.
0 1 0 1 True if ordered and less than or equal
static Constant * getSExt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
UndefValue * getElementValue(Constant *C) const
Return an undef of the right value for the specified GEP index if we can, otherwise return null (e...
uint64_t getNumElements() const
For scalable vectors, this will return the minimum number of elements in the vector.
void remove(ConstantClass *CP)
Remove this constant from the map.
static Type * getPPC_FP128Ty(LLVMContext &C)
static StructType * get(LLVMContext &Context, ArrayRef< Type *> Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
All zero aggregate value.
static Constant * getSequenceIfElementsMatch(Constant *C, ArrayRef< Constant *> V)
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.
static Constant * getZExt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Type * getResultElementType() const
static Constant * getSizeOf(Type *Ty)
getSizeOf constant expr - computes the (alloc) size of a type (in address-units, not bits) in a targe...
bool isNullValue() const
Return true if this is the value that would be returned by getNullValue.
A constant value that is initialized with an expression using other constant values.
void setIsExact(bool b=true)
Set or clear the exact flag on this instruction, which must be an operator which supports this flag...
Type * getType() const
All values are typed, get the type of this value.
bool canTrap() const
Return true if evaluation of this constant could trap.
bool isFirstClassType() const
Return true if the type is "first class", meaning it is a valid type for a Value. ...
opStatus convert(const fltSemantics &ToSemantics, roundingMode RM, bool *losesInfo)
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...
static Constant * getAShr(Constant *C1, Constant *C2, bool isExact=false)
Class to represent array types.
bool isNotOneValue() const
Return true if the value is not the one value, or, for vectors, does not contain one value elements...
static Constant * getSelect(Constant *C, Constant *V1, Constant *V2, Type *OnlyIfReducedTy=nullptr)
Select constant expr.
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)...
LLVM_NODISCARD size_t size() const
size - Get the string size.
bool isGEPWithNoNotionalOverIndexing() const
Return true if this is a getelementptr expression and all the index operands are compile-time known i...
ArrayConstantsTy ArrayConstants
bool isFiniteNonZeroFP() const
Return true if this is a finite and non-zero floating-point scalar constant or a vector constant with...
Constant * ConstantFoldInsertValueInstruction(Constant *Agg, Constant *Val, ArrayRef< unsigned > Idxs)
ConstantFoldInsertValueInstruction - Attempt to constant fold an insertvalue instruction with the spe...
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
static const fltSemantics & IEEEdouble() LLVM_READNONE
static Constant * getUDiv(Constant *C1, Constant *C2, bool isExact=false)
static Function * getFunction(Constant *C)
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
static Constant * replaceUndefsWith(Constant *C, Constant *Replacement)
Try to replace undefined constant C or undefined elements in C with Replacement.
Constant(Type *ty, ValueTy vty, Use *Ops, unsigned NumOps)
bool isMinSignedValue() const
Return true if the value is the smallest signed value.
static Constant * getFDiv(Constant *C1, Constant *C2)
static APFloat getInf(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Infinity.
Type * getElementType() const
Return the element type of the array/vector.
Value * getOperand(unsigned i) const
void removeDeadConstantUsers() const
If there are any dead constant users dangling off of this constant, remove them.
Class to represent pointers.
Constant * getAggregateElement(unsigned Elt) const
For aggregates (struct/array/vector) return the constant that corresponds to the specified element if...
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
bool isZeroValue() const
Return true if the value is negative zero or null value.
11: Arbitrary bit width integers
static Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Constant * getSplatValue(bool AllowUndefs=false) const
If all elements of the vector constant have the same value, return that value.
ElementCount getVectorElementCount() const
static bool removeDeadUsersOfConstant(const Constant *C)
If the specified constantexpr is dead, remove it.
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
bool isThreadDependent() const
Return true if the value can vary between threads.
DenseMap< PointerType *, std::unique_ptr< ConstantPointerNull > > CPNConstants
static Constant * getInsertValue(Constant *Agg, Constant *Val, ArrayRef< unsigned > Idxs, Type *OnlyIfReducedTy=nullptr)
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)
Attempt to constant fold a shufflevector instruction with the specified operands and indices...
static Constant * getFNeg(Constant *C)
static Constant * getFRem(Constant *C1, Constant *C2)
const Use * getOperandList() const
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.
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.
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
Constant * getSplatValue() const
If this is a splat constant, meaning that all of the elements have the same value, return that value.
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.
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.
Constant * getWithOperandReplaced(unsigned OpNo, Constant *Op) const
Return a constant expression identical to this one, but with the specified operand set to the specifi...
static BlockAddress * get(Function *F, BasicBlock *BB)
Return a BlockAddress for the specified function and basic block.
size_t size() const
size - Get the array size.
const char * getOpcodeName() const
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
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...
static Constant * getAnd(Constant *C1, Constant *C2)
bool hasIndices() const
Return true if this is an insertvalue or extractvalue expression, and the getIndices() method may be ...
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.
static Constant * getSExtOrBitCast(Constant *C, Type *Ty)
float getElementAsFloat(unsigned i) const
If this is an sequential container of floats, return the specified element as a float.
LLVM_NODISCARD size_t find(char C, size_t From=0) const
Search for the first character C in the string.
bool isDLLImportDependent() const
Return true if the value is dependent on a dllimport variable.
static Constant * getShuffleVector(Constant *V1, Constant *V2, Constant *Mask, Type *OnlyIfReducedTy=nullptr)
const char * getOpcodeName() const
Return a string representation for an opcode.
bool isHalfTy() const
Return true if this is 'half', a 16-bit IEEE fp type.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
static Constant * getBinOpIdentity(unsigned Opcode, Type *Ty, bool AllowRHSConstant=false)
Return the identity constant for a binary opcode.
6: 128-bit floating point type (two 64-bits, PowerPC)
static Constant * get(StructType *T, ArrayRef< Constant *> V)
0 1 1 1 True if ordered (no nans)
unsigned getStructNumElements() const
static bool isValueValidForType(Type *Ty, const APFloat &V)
Return true if Ty is big enough to represent V.
unsigned getAddressSpace() const
Return the address space of the Pointer type.
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...
static const fltSemantics & x87DoubleExtended() LLVM_READNONE
Class to represent integer types.
Constant Vector Declarations.
bool isNegativeZeroValue() const
Return true if the value is what would be returned by getZeroValueForNegation.
static Constant * getQNaN(Type *Ty, bool Negative=false, APInt *Payload=nullptr)
static Constant * getSplat(unsigned NumElts, Constant *Elt)
Return a ConstantVector with the specified constant in each element.
static Constant * getNot(Constant *C)
static Constant * getAllOnesValue(Type *Ty)
1 1 1 1 Always true (always folded)
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
static bool isElementTypeCompatible(Type *Ty)
Return true if a ConstantDataSequential can be formed with a vector or array of the specified element...
bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
static const fltSemantics * TypeToFloatSemantics(Type *Ty)
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
const Constant * stripPointerCasts() const
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
static UnaryOperator * Create(UnaryOps Op, Value *S, const Twine &Name=Twine(), Instruction *InsertBefore=nullptr)
Construct a unary instruction, given the opcode and an operand.
LLVM_NODISCARD char back() const
back - Get the last character in the string.
static wasm::ValType getType(const TargetRegisterClass *RC)
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
Constant * getWithOperands(ArrayRef< Constant *> Ops) const
This returns the current constant expression with the operands replaced with the specified values...
Constant * ConstantFoldBinaryInstruction(unsigned Opcode, Constant *V1, Constant *V2)
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
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 isNormalFP() const
Return true if this is a normal (as opposed to denormal) floating-point scalar constant or a vector c...
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.
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches, switches, etc.
static bool isUndef(ArrayRef< int > Mask)
static Constant * getSIToFP(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static Type * getHalfTy(LLVMContext &C)
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
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.
Type * getSequentialElementType() const
void setHasNoSignedWrap(bool b=true)
Set or clear the nsw flag on this instruction, which must be an operator which supports this flag...
static const fltSemantics & IEEEsingle() LLVM_READNONE
static bool isAllZeros(StringRef Arr)
Return true if the array is empty or all zeros.
Predicate getPredicate(unsigned Condition, unsigned Hint)
Return predicate consisting of specified condition and hint bits.
unsigned getNumOperands() const
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...
This is the shared class of boolean and integer constants.
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
BlockVerifier::State From
static const fltSemantics & IEEEhalf() LLVM_READNONE
Type * getSourceElementType() const
16: SIMD 'packed' format, or other vector type
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...
bool containsUndefElement() const
Return true if this is a vector constant that includes any undefined elements.
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...
uint64_t getElementAsInteger(unsigned i) const
If this is a sequential container of integers (of any size), return the specified element in the low ...
Module.h This file contains the declarations for the Module class.
bool isCString() const
This method returns true if the array "isString", ends with a null byte, and does not contains any ot...
A constant pointer value that points to null.
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
LLVM_NODISCARD T pop_back_val()
CHAIN = SC CHAIN, Imm128 - System call.
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...
static ConstantInt * getTrue(LLVMContext &Context)
ValueTy
Concrete subclass of this.
bool isCommutative() const
Return true if the instruction is commutative:
void handleOperandChange(Value *, Value *)
This method is a special form of User::replaceUsesOfWith (which does not work on constants) that does...
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.
unsigned getVectorNumElements() const
bool isIntPredicate() const
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.
static APFloat getSNaN(const fltSemantics &Sem, bool Negative=false, const APInt *payload=nullptr)
Factory for SNaN values.
bool isSplat() const
Returns true if this is a splat constant, meaning that all elements have the same value...
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.
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)
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 Constant * getZExtOrBitCast(Constant *C, Type *Ty)
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
Common super class of ArrayType, StructType and VectorType.
bool isX86_FP80Ty() const
Return true if this is x86 long double.
user_iterator_impl< const User > const_user_iterator
bool containsConstantExpression() const
Return true if this is a vector constant that includes any constant expressions.
static Constant * getFSub(Constant *C1, Constant *C2)
static Constant * getTruncOrBitCast(Constant *C, Type *Ty)
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")))
static Constant * getIntSequenceIfElementsMatch(ArrayRef< Constant *> V)
static const fltSemantics & PPCDoubleDouble() LLVM_READNONE
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)
Constant * ConstantFoldSelectInstruction(Constant *Cond, Constant *V1, Constant *V2)
Attempt to constant fold a select instruction with the specified operands.
static Constant * getNaN(Type *Ty, bool Negative=false, uint64_t Payload=0)
const unsigned char * bytes_begin() const
Merge contiguous icmps into a memcmp
APFloat getElementAsAPFloat(unsigned i) const
If this is a sequential container of floating point type, return the specified element as an APFloat...
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...
static IntegerType * getInt32Ty(LLVMContext &C)
unsigned getIntegerBitWidth() const
uint64_t getSequentialNumElements() const
LLVM_NODISCARD bool empty() const
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 VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
static InsertValueInst * Create(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
double getElementAsDouble(unsigned i) const
If this is an sequential container of doubles, return the specified element as a double.
const Function * getParent() const
Return the enclosing method, or null if none.
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.
Constant * ConstantFoldInsertElementInstruction(Constant *Val, Constant *Elt, Constant *Idx)
Attempt to constant fold an insertelement instruction with the specified operands and indices...
bool isCompare() const
Return true if this is a compare constant expression.
0 1 1 0 True if ordered and operands are unequal
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.
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.
static ConstantTokenNone * get(LLVMContext &Context)
Return the ConstantTokenNone.
ConstantUniqueMap< ConstantExpr > ExprConstants
1 0 1 0 True if unordered or greater than
Constant * ConstantFoldGetElementPtr(Type *Ty, Constant *C, bool InBounds, Optional< unsigned > InRangeIndex, ArrayRef< Value *> Idxs)
Constant * getStructElement(unsigned Elt) const
If this CAZ has struct type, return a zero with the right element type for the specified element...
ArrayRef< unsigned > getIndices() const
Assert that this is an insertvalue or exactvalue expression and return the list of indices...
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
bool isOneValue() const
Returns true if the value is one.
void setHasNoUnsignedWrap(bool b=true)
Set or clear the nuw flag on this instruction, which must be an operator which supports this flag...
3: 64-bit floating point type
static GetElementPtrInst * CreateInBounds(Value *Ptr, ArrayRef< Value *> IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Create an "inbounds" getelementptr.
static Constant * getSNaN(Type *Ty, bool Negative=false, APInt *Payload=nullptr)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static Constant * getSRem(Constant *C1, Constant *C2)
Base class for aggregate constants (with operands).
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
LLVM_NODISCARD StringRef drop_back(size_t N=1) const
Return a StringRef equal to 'this' but with the last N elements dropped.
cst_pred_ty< is_one > m_One()
Match an integer 1 or a vector with all elements equal to 1.
static Constant * getURem(Constant *C1, Constant *C2)
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.
bool hasExactInverseFP() const
Return true if this scalar has an exact multiplicative inverse or this vector has an exact multiplica...
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)
bool isCast() const
Return true if this is a convert constant expression.
ConstantClass * getOrCreate(TypeClass *Ty, ValType V)
Return the specified constant from the map, creating it if necessary.
unsigned getNumElements() const
Return the number of elements in the array, vector, or struct.
Type * getElementType() const
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 ...
bool isNotMinSignedValue() const
Return true if the value is not the smallest signed value, or, for vectors, does not contain smallest...
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...
static bool isSplat(ArrayRef< Value *> VL)
unsigned getNumElements() const
Return the number of elements in the array or vector.
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...
static LazyValueInfoImpl & getImpl(void *&PImpl, AssumptionCache *AC, const DataLayout *DL, DominatorTree *DT=nullptr)
This lazily constructs the LazyValueInfoImpl.
static bool canTrapImpl(const Constant *C, SmallPtrSetImpl< const ConstantExpr *> &NonTrappingOps)
bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
OutputIt copy(R &&Range, OutputIt Out)
0 0 1 1 True if ordered and greater than or equal
static Constant * getFPExtend(Constant *C, Type *Ty, bool OnlyIfReduced=false)
UndefValue * getStructElement(unsigned Elt) const
If this undef has struct type, return a undef with the right element type for the specified element...
Constant * getSequentialElement() const
If this CAZ has array or vector type, return a zero with the right element type.
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
StringMap< ConstantDataSequential * > CDSConstants
Base class for constants with no operands.
ConstantAggregate(CompositeType *T, ValueTy VT, ArrayRef< Constant *> V)
static Constant * getBinOpAbsorber(unsigned Opcode, Type *Ty)
Return the absorbing element for the given binary operation, i.e.
static IntegerType * getInt8Ty(LLVMContext &C)
static Constant * get(ArrayRef< Constant *> V)
static APFloat getQNaN(const fltSemantics &Sem, bool Negative=false, const APInt *payload=nullptr)
Factory for QNaN values.
Type * getElementType() const
UndefValue * getSequentialElement() const
If this Undef has array or vector type, return a undef with the right element type.
PointerType * getType() const
Global values are always pointers.
0 0 0 0 Always false (always folded)
bool isStructTy() const
True if this is an instance of StructType.
bool empty() const
empty - Check if the array is empty.
bool isArrayTy() const
True if this is an instance of ArrayType.
Type * getTypeAtIndex(const Value *V) const
Given an index value into the type, return the type of the element.
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)
bool isString(unsigned CharSize=8) const
This method returns true if this is an array of CharSize integers.
bool isElementWiseEqual(Value *Y) const
Return true if this constant and a constant 'Y' are element-wise equal.
static Constant * get(unsigned Opcode, Constant *C1, unsigned Flags=0, Type *OnlyIfReducedTy=nullptr)
get - Return a unary operator constant expression, folding if possible.
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...