36using namespace PatternMatch;
44 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
45 return CFP->isZero() && CFP->isNegative();
49 if (
const auto *SplatCFP = dyn_cast_or_null<ConstantFP>(
getSplatValue()))
50 return SplatCFP->isNegativeZeroValue();
53 if (
getType()->isFPOrFPVectorTy())
64 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
69 if (
const auto *SplatCFP = dyn_cast_or_null<ConstantFP>(
getSplatValue()))
70 return SplatCFP->isZero();
78 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(
this))
82 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
85 return CFP->isExactlyValue(+0.0);
89 return isa<ConstantAggregateZero>(
this) || isa<ConstantPointerNull>(
this) ||
90 isa<ConstantTokenNone>(
this) || isa<ConstantTargetNone>(
this);
95 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(
this))
96 return CI->isMinusOne();
99 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
100 return CFP->getValueAPF().bitcastToAPInt().isAllOnes();
105 return SplatVal->isAllOnesValue();
112 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(
this))
116 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
117 return CFP->getValueAPF().bitcastToAPInt().isOne();
122 return SplatVal->isOneValue();
129 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(
this))
130 return !CI->isOneValue();
133 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
134 return !CFP->getValueAPF().bitcastToAPInt().isOne();
137 if (
auto *VTy = dyn_cast<FixedVectorType>(
getType())) {
138 for (
unsigned I = 0,
E = VTy->getNumElements();
I !=
E; ++
I) {
149 return SplatVal->isNotOneValue();
157 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(
this))
158 return CI->isMinValue(
true);
161 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
162 return CFP->getValueAPF().bitcastToAPInt().isMinSignedValue();
167 return SplatVal->isMinSignedValue();
174 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(
this))
175 return !CI->isMinValue(
true);
178 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
179 return !CFP->getValueAPF().bitcastToAPInt().isMinSignedValue();
182 if (
auto *VTy = dyn_cast<FixedVectorType>(
getType())) {
183 for (
unsigned I = 0,
E = VTy->getNumElements();
I !=
E; ++
I) {
194 return SplatVal->isNotMinSignedValue();
201 if (
auto *CFP = dyn_cast<ConstantFP>(
this))
202 return CFP->getValueAPF().isFiniteNonZero();
204 if (
auto *VTy = dyn_cast<FixedVectorType>(
getType())) {
205 for (
unsigned I = 0,
E = VTy->getNumElements();
I !=
E; ++
I) {
207 if (!CFP || !CFP->getValueAPF().isFiniteNonZero())
214 if (
const auto *SplatCFP = dyn_cast_or_null<ConstantFP>(
getSplatValue()))
215 return SplatCFP->isFiniteNonZeroFP();
222 if (
auto *CFP = dyn_cast<ConstantFP>(
this))
223 return CFP->getValueAPF().isNormal();
225 if (
auto *VTy = dyn_cast<FixedVectorType>(
getType())) {
226 for (
unsigned I = 0,
E = VTy->getNumElements();
I !=
E; ++
I) {
228 if (!CFP || !CFP->getValueAPF().isNormal())
235 if (
const auto *SplatCFP = dyn_cast_or_null<ConstantFP>(
getSplatValue()))
236 return SplatCFP->isNormalFP();
243 if (
auto *CFP = dyn_cast<ConstantFP>(
this))
244 return CFP->getValueAPF().getExactInverse(
nullptr);
246 if (
auto *VTy = dyn_cast<FixedVectorType>(
getType())) {
247 for (
unsigned I = 0,
E = VTy->getNumElements();
I !=
E; ++
I) {
249 if (!CFP || !CFP->getValueAPF().getExactInverse(
nullptr))
256 if (
const auto *SplatCFP = dyn_cast_or_null<ConstantFP>(
getSplatValue()))
257 return SplatCFP->hasExactInverseFP();
264 if (
auto *CFP = dyn_cast<ConstantFP>(
this))
267 if (
auto *VTy = dyn_cast<FixedVectorType>(
getType())) {
268 for (
unsigned I = 0,
E = VTy->getNumElements();
I !=
E; ++
I) {
270 if (!CFP || !CFP->isNaN())
277 if (
const auto *SplatCFP = dyn_cast_or_null<ConstantFP>(
getSplatValue()))
278 return SplatCFP->isNaN();
290 auto *VTy = dyn_cast<VectorType>(
getType());
291 if (!isa<Constant>(
Y) || !VTy || VTy !=
Y->getType())
295 if (!(VTy->getElementType()->isIntegerTy() ||
296 VTy->getElementType()->isFloatingPointTy()))
305 return isa<UndefValue>(CmpEq) ||
match(CmpEq,
m_One());
311 if (
auto *VTy = dyn_cast<VectorType>(
C->getType())) {
314 if (isa<ConstantAggregateZero>(
C))
316 if (isa<ScalableVectorType>(
C->getType()))
319 for (
unsigned i = 0, e = cast<FixedVectorType>(VTy)->getNumElements();
321 if (
Constant *Elem =
C->getAggregateElement(i))
332 this, [&](
const auto *
C) {
return isa<UndefValue>(
C); });
337 this, [&](
const auto *
C) {
return isa<PoisonValue>(
C); });
342 return isa<UndefValue>(
C) && !isa<PoisonValue>(
C);
347 if (
auto *VTy = dyn_cast<FixedVectorType>(
getType())) {
348 for (
unsigned i = 0, e = VTy->getNumElements(); i != e; ++i)
393 if (
PointerType *PTy = dyn_cast<PointerType>(ScalarTy))
397 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
420 "Must be an aggregate/vector constant");
422 if (
const auto *
CC = dyn_cast<ConstantAggregate>(
this))
423 return Elt <
CC->getNumOperands() ?
CC->getOperand(Elt) :
nullptr;
425 if (
const auto *CAZ = dyn_cast<ConstantAggregateZero>(
this))
426 return Elt < CAZ->getElementCount().getKnownMinValue()
427 ? CAZ->getElementValue(Elt)
431 if (isa<ScalableVectorType>(
getType()))
434 if (
const auto *PV = dyn_cast<PoisonValue>(
this))
435 return Elt < PV->getNumElements() ? PV->getElementValue(Elt) :
nullptr;
437 if (
const auto *UV = dyn_cast<UndefValue>(
this))
438 return Elt < UV->getNumElements() ? UV->getElementValue(Elt) :
nullptr;
440 if (
const auto *CDS = dyn_cast<ConstantDataSequential>(
this))
441 return Elt < CDS->getNumElements() ? CDS->getElementAsConstant(Elt)
448 assert(isa<IntegerType>(Elt->
getType()) &&
"Index must be an integer");
449 if (
ConstantInt *CI = dyn_cast<ConstantInt>(Elt)) {
451 if (CI->getValue().getActiveBits() > 64)
464#define HANDLE_CONSTANT(Name) \
465 case Value::Name##Val: \
466 cast<Name>(this)->destroyConstantImpl(); \
468#include "llvm/IR/Value.def"
481 if (!isa<Constant>(V)) {
482 dbgs() <<
"While deleting: " << *
this
483 <<
"\n\nUse still stuck around after Def is destroyed: " << *V
487 assert(isa<Constant>(V) &&
"References remain to Constant being destroyed");
488 cast<Constant>(V)->destroyConstant();
499 switch (
C->getValueID()) {
500 case Constant::ConstantIntVal:
503 case Constant::ConstantFPVal:
506 case Constant::ConstantAggregateZeroVal:
509 case Constant::ConstantArrayVal:
512 case Constant::ConstantStructVal:
515 case Constant::ConstantVectorVal:
518 case Constant::ConstantPointerNullVal:
521 case Constant::ConstantDataArrayVal:
524 case Constant::ConstantDataVectorVal:
527 case Constant::ConstantTokenNoneVal:
530 case Constant::BlockAddressVal:
533 case Constant::DSOLocalEquivalentVal:
536 case Constant::NoCFIValueVal:
539 case Constant::UndefValueVal:
542 case Constant::PoisonValueVal:
545 case Constant::ConstantExprVal:
546 if (isa<CastConstantExpr>(
C))
548 else if (isa<BinaryConstantExpr>(
C))
550 else if (isa<ExtractElementConstantExpr>(
C))
552 else if (isa<InsertElementConstantExpr>(
C))
554 else if (isa<ShuffleVectorConstantExpr>(
C))
556 else if (isa<GetElementPtrConstantExpr>(
C))
558 else if (isa<CompareConstantExpr>(
C))
577 while (!WorkList.
empty()) {
579 if (
const auto *GV = dyn_cast<GlobalValue>(
WorkItem))
583 const Constant *ConstOp = dyn_cast<Constant>(Op);
586 if (Visited.
insert(ConstOp).second)
594 auto DLLImportPredicate = [](
const GlobalValue *GV) {
595 return GV->isThreadLocal();
601 auto DLLImportPredicate = [](
const GlobalValue *GV) {
602 return GV->hasDLLImportStorageClass();
609 const Constant *UC = dyn_cast<Constant>(U);
610 if (!UC || isa<GlobalValue>(UC))
620 return getRelocationInfo() == GlobalRelocation;
624 return getRelocationInfo() != NoRelocation;
627Constant::PossibleRelocationsTy Constant::getRelocationInfo()
const {
628 if (isa<GlobalValue>(
this))
629 return GlobalRelocation;
631 if (
const BlockAddress *BA = dyn_cast<BlockAddress>(
this))
632 return BA->getFunction()->getRelocationInfo();
634 if (
const ConstantExpr *CE = dyn_cast<ConstantExpr>(
this)) {
635 if (CE->getOpcode() == Instruction::Sub) {
638 if (LHS && RHS &&
LHS->getOpcode() == Instruction::PtrToInt &&
639 RHS->getOpcode() == Instruction::PtrToInt) {
647 if (isa<BlockAddress>(LHSOp0) && isa<BlockAddress>(RHSOp0) &&
656 if (
auto *LHSGV = dyn_cast<GlobalValue>(LHS)) {
657 if (LHSGV->isDSOLocal() && RHSGV->isDSOLocal())
658 return LocalRelocation;
659 }
else if (isa<DSOLocalEquivalent>(LHS)) {
660 if (RHSGV->isDSOLocal())
661 return LocalRelocation;
668 PossibleRelocationsTy
Result = NoRelocation;
671 std::max(cast<Constant>(
getOperand(i))->getRelocationInfo(), Result);
680 if (isa<GlobalValue>(
C))
return false;
685 if (!
User)
return false;
698 if (RemoveDeadUsers) {
702 const_cast<Constant *
>(
C)->destroyConstant();
728 if (LastNonDeadUser ==
E)
731 I = std::next(LastNonDeadUser);
739bool Constant::hasNLiveUses(
unsigned N)
const {
740 unsigned NumUses = 0;
754 assert(
C && Replacement &&
"Expected non-nullptr constant arguments");
755 Type *Ty =
C->getType();
757 assert(Ty == Replacement->
getType() &&
"Expected matching types");
762 auto *VTy = dyn_cast<FixedVectorType>(Ty);
766 unsigned NumElts = VTy->getNumElements();
768 for (
unsigned i = 0; i != NumElts; ++i) {
769 Constant *EltC =
C->getAggregateElement(i);
771 "Expected matching types");
772 NewC[i] = EltC &&
match(EltC,
m_Undef()) ? Replacement : EltC;
778 assert(
C &&
Other &&
"Expected non-nullptr constant arguments");
782 Type *Ty =
C->getType();
786 auto *VTy = dyn_cast<FixedVectorType>(Ty);
790 Type *EltTy = VTy->getElementType();
791 unsigned NumElts = VTy->getNumElements();
793 cast<FixedVectorType>(
Other->getType())->getNumElements() == NumElts &&
796 bool FoundExtraUndef =
false;
798 for (
unsigned I = 0;
I != NumElts; ++
I) {
799 NewC[
I] =
C->getAggregateElement(
I);
801 assert(NewC[
I] && OtherEltC &&
"Unknown vector element");
804 FoundExtraUndef =
true;
813 if (isa<ConstantData>(
this))
815 if (isa<ConstantAggregate>(
this) || isa<ConstantExpr>(
this)) {
854 if (
auto *VTy = dyn_cast<VectorType>(Ty))
862 if (
auto *VTy = dyn_cast<VectorType>(Ty))
875 std::unique_ptr<ConstantInt> &Slot =
892 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
905 "ConstantInt type doesn't match the type implied by its value!");
908 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
919void ConstantInt::destroyConstantImpl() {
937 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
946 "ConstantFP type doesn't match the type implied by its value!");
949 if (
auto *VTy = dyn_cast<VectorType>(Ty))
962 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
973 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
984 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
995 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
1006 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
1017 std::unique_ptr<ConstantFP> &Slot = pImpl->
FPConstants[V];
1031 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
1040 "FP type Mismatch");
1048void ConstantFP::destroyConstantImpl() {
1057 if (
auto *AT = dyn_cast<ArrayType>(
getType()))
1080 if (
auto *AT = dyn_cast<ArrayType>(Ty))
1082 if (
auto *VT = dyn_cast<VectorType>(Ty))
1083 return VT->getElementCount();
1115 if (
auto *AT = dyn_cast<ArrayType>(Ty))
1116 return AT->getNumElements();
1117 if (
auto *VT = dyn_cast<VectorType>(Ty))
1118 return cast<FixedVectorType>(VT)->getNumElements();
1152template <
typename ItTy,
typename EltTy>
1154 for (; Start !=
End; ++Start)
1160template <
typename SequentialTy,
typename ElementTy>
1162 assert(!V.empty() &&
"Cannot get empty int sequence.");
1166 if (
auto *CI = dyn_cast<ConstantInt>(
C))
1170 return SequentialTy::get(V[0]->getContext(), Elts);
1173template <
typename SequentialTy,
typename ElementTy>
1175 assert(!V.empty() &&
"Cannot get empty FP sequence.");
1179 if (
auto *CFP = dyn_cast<ConstantFP>(
C))
1180 Elts.
push_back(CFP->getValueAPF().bitcastToAPInt().getLimitedValue());
1183 return SequentialTy::getFP(V[0]->
getType(), Elts);
1186template <
typename SequenceTy>
1193 if (CI->getType()->isIntegerTy(8))
1194 return getIntSequenceIfElementsMatch<SequenceTy, uint8_t>(V);
1195 else if (CI->getType()->isIntegerTy(16))
1196 return getIntSequenceIfElementsMatch<SequenceTy, uint16_t>(V);
1197 else if (CI->getType()->isIntegerTy(32))
1198 return getIntSequenceIfElementsMatch<SequenceTy, uint32_t>(V);
1199 else if (CI->getType()->isIntegerTy(64))
1200 return getIntSequenceIfElementsMatch<SequenceTy, uint64_t>(V);
1201 }
else if (
ConstantFP *CFP = dyn_cast<ConstantFP>(
C)) {
1202 if (CFP->getType()->isHalfTy() || CFP->getType()->isBFloatTy())
1203 return getFPSequenceIfElementsMatch<SequenceTy, uint16_t>(V);
1204 else if (CFP->getType()->isFloatTy())
1205 return getFPSequenceIfElementsMatch<SequenceTy, uint32_t>(V);
1206 else if (CFP->getType()->isDoubleTy())
1207 return getFPSequenceIfElementsMatch<SequenceTy, uint64_t>(V);
1220 if (
auto *ST = dyn_cast<StructType>(
T)) {
1223 for (
unsigned I = 0,
E = V.size();
I !=
E; ++
I)
1225 "Initializer for struct element doesn't match!");
1231 assert(V.size() ==
T->getNumElements() &&
1232 "Invalid initializer for constant array");
1248 "Wrong type in array element initializer");
1268 return getSequenceIfElementsMatch<ConstantDataArray>(
C, V);
1277 unsigned VecSize = V.size();
1279 for (
unsigned i = 0; i != VecSize; ++i)
1280 EltTypes[i] = V[i]->
getType();
1289 "ConstantStruct::getTypeForElements cannot be called on empty list");
1295 assert((
T->isOpaque() || V.size() ==
T->getNumElements()) &&
1296 "Invalid initializer for constant struct");
1301 assert((ST->isOpaque() || ST->getNumElements() == V.size()) &&
1302 "Incorrect # elements specified to ConstantStruct::get");
1307 bool isPoison =
false;
1310 isUndef = isa<UndefValue>(V[0]);
1311 isPoison = isa<PoisonValue>(V[0]);
1312 isZero = V[0]->isNullValue();
1316 if (!
C->isNullValue())
1318 if (!isa<PoisonValue>(
C))
1320 if (isa<PoisonValue>(
C) || !isa<UndefValue>(
C))
1332 return ST->getContext().pImpl->StructConstants.getOrCreate(ST, V);
1337 assert(V.size() == cast<FixedVectorType>(
T)->getNumElements() &&
1338 "Invalid initializer for constant vector");
1350 assert(!V.empty() &&
"Vectors can't be empty");
1356 bool isZero =
C->isNullValue();
1358 bool isPoison = isa<PoisonValue>(
C);
1361 for (
unsigned i = 1, e = V.size(); i != e; ++i)
1378 return getSequenceIfElementsMatch<ConstantDataVector>(
C, V);
1386 if (!EC.isScalable()) {
1389 if ((isa<ConstantFP>(V) || isa<ConstantInt>(V)) &&
1399 if (V->isNullValue())
1401 else if (isa<UndefValue>(V))
1423void ConstantTokenNone::destroyConstantImpl() {
1439 return cast<CompareConstantExpr>(
this)->predicate;
1443 return cast<ShuffleVectorConstantExpr>(
this)->ShuffleMask;
1447 return cast<ShuffleVectorConstantExpr>(
this)->ShuffleMaskForBitcode;
1451 bool OnlyIfReduced,
Type *SrcTy)
const {
1458 Type *OnlyIfReducedTy = OnlyIfReduced ? Ty :
nullptr;
1460 case Instruction::Trunc:
1461 case Instruction::ZExt:
1462 case Instruction::SExt:
1463 case Instruction::FPTrunc:
1464 case Instruction::FPExt:
1465 case Instruction::UIToFP:
1466 case Instruction::SIToFP:
1467 case Instruction::FPToUI:
1468 case Instruction::FPToSI:
1469 case Instruction::PtrToInt:
1470 case Instruction::IntToPtr:
1471 case Instruction::BitCast:
1472 case Instruction::AddrSpaceCast:
1474 case Instruction::InsertElement:
1477 case Instruction::ExtractElement:
1479 case Instruction::ShuffleVector:
1482 case Instruction::GetElementPtr: {
1483 auto *GEPO = cast<GEPOperator>(
this);
1486 SrcTy ? SrcTy : GEPO->getSourceElementType(), Ops[0], Ops.
slice(1),
1487 GEPO->isInBounds(), GEPO->getInRangeIndex(), OnlyIfReducedTy);
1489 case Instruction::ICmp:
1490 case Instruction::FCmp:
1507 return Val == 0 || Val == 1;
1514 return Val == 0 || Val == 1 || Val == -1;
1515 return isIntN(NumBits, Val);
1581 "Cannot create an aggregate zero of non-aggregate type!");
1583 std::unique_ptr<ConstantAggregateZero> &Entry =
1592void ConstantAggregateZero::destroyConstantImpl() {
1597void ConstantArray::destroyConstantImpl() {
1606void ConstantStruct::destroyConstantImpl() {
1611void ConstantVector::destroyConstantImpl() {
1616 assert(this->
getType()->isVectorTy() &&
"Only valid for vectors!");
1617 if (isa<ConstantAggregateZero>(
this))
1620 return CV->getSplatValue();
1622 return CV->getSplatValue(AllowUndefs);
1626 const auto *Shuf = dyn_cast<ConstantExpr>(
this);
1627 if (Shuf && Shuf->getOpcode() == Instruction::ShuffleVector &&
1628 isa<UndefValue>(Shuf->getOperand(1))) {
1630 const auto *IElt = dyn_cast<ConstantExpr>(Shuf->getOperand(0));
1631 if (IElt && IElt->getOpcode() == Instruction::InsertElement &&
1632 isa<UndefValue>(IElt->getOperand(0))) {
1661 if (isa<UndefValue>(OpC))
1665 if (isa<UndefValue>(Elt))
1675 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(
this))
1676 return CI->getValue();
1678 if (isa<ConstantExpr>(
this))
1679 return cast<ConstantInt>(this->
getSplatValue())->getValue();
1684 assert(
C && isa<ConstantInt>(
C) &&
"Not a vector of numbers!");
1685 return cast<ConstantInt>(
C)->getValue();
1692 std::unique_ptr<ConstantPointerNull> &Entry =
1701void ConstantPointerNull::destroyConstantImpl() {
1710 "Target extension type not allowed to have a zeroinitializer");
1711 std::unique_ptr<ConstantTargetNone> &Entry =
1720void ConstantTargetNone::destroyConstantImpl() {
1733void UndefValue::destroyConstantImpl() {
1752void PoisonValue::destroyConstantImpl() {
1764 F->getContext().pImpl->BlockAddresses[std::make_pair(
F, BB)];
1773 :
Constant(
Type::getInt8PtrTy(
F->getContext(),
F->getAddressSpace()),
1774 Value::BlockAddressVal, &Op<0>(), 2) {
1777 BB->AdjustBlockAddressRefCount(1);
1785 assert(
F &&
"Block must have a parent");
1787 F->getContext().pImpl->BlockAddresses.lookup(std::make_pair(
F, BB));
1788 assert(BA &&
"Refcount and block address map disagree!");
1793void BlockAddress::destroyConstantImpl() {
1808 assert(
From == NewBB &&
"From does not match any operand");
1809 NewBB = cast<BasicBlock>(To);
1841 "DSOLocalFunction does not match the expected global value");
1845DSOLocalEquivalent::DSOLocalEquivalent(
GlobalValue *GV)
1851void DSOLocalEquivalent::destroyConstantImpl() {
1858 assert(isa<Constant>(To) &&
"Can only replace the operands with a constant");
1861 if (
const auto *ToObj = dyn_cast<GlobalValue>(To)) {
1898 assert(
NC->getGlobalValue() == GV &&
1899 "NoCFIValue does not match the expected global value");
1909void NoCFIValue::destroyConstantImpl() {
1918 assert(GV &&
"Can only replace the operands with a global value");
1940 bool OnlyIfReduced =
false) {
1958 bool OnlyIfReduced) {
1961 assert(
C && Ty &&
"Null arguments to getCast");
1967 case Instruction::Trunc:
1969 case Instruction::ZExt:
1970 return getZExt(
C, Ty, OnlyIfReduced);
1971 case Instruction::SExt:
1972 return getSExt(
C, Ty, OnlyIfReduced);
1973 case Instruction::FPTrunc:
1975 case Instruction::FPExt:
1977 case Instruction::UIToFP:
1979 case Instruction::SIToFP:
1981 case Instruction::FPToUI:
1983 case Instruction::FPToSI:
1985 case Instruction::PtrToInt:
1987 case Instruction::IntToPtr:
1989 case Instruction::BitCast:
1991 case Instruction::AddrSpaceCast:
2016 "Can only sign extend/truncate integers!");
2017 Type *CTy =
C->getType();
2052 assert(
C->getType()->isIntOrIntVectorTy() &&
2054 unsigned SrcBits =
C->getType()->getScalarSizeInBits();
2057 (SrcBits == DstBits ? Instruction::BitCast :
2058 (SrcBits > DstBits ? Instruction::Trunc :
2059 (
isSigned ? Instruction::SExt : Instruction::ZExt)));
2066 unsigned SrcBits =
C->getType()->getScalarSizeInBits();
2068 if (SrcBits == DstBits)
2071 (SrcBits > DstBits ? Instruction::FPTrunc : Instruction::FPExt);
2077 bool fromVec = isa<VectorType>(
C->getType());
2078 bool toVec = isa<VectorType>(Ty);
2080 assert((fromVec == toVec) &&
"Cannot convert from scalar to/from vector");
2081 assert(
C->getType()->isIntOrIntVectorTy() &&
"Trunc operand must be integer");
2084 "SrcTy must be larger than DestTy for Trunc!");
2091 bool fromVec = isa<VectorType>(
C->getType());
2092 bool toVec = isa<VectorType>(Ty);
2094 assert((fromVec == toVec) &&
"Cannot convert from scalar to/from vector");
2095 assert(
C->getType()->isIntOrIntVectorTy() &&
"SExt operand must be integral");
2098 "SrcTy must be smaller than DestTy for SExt!");
2105 bool fromVec = isa<VectorType>(
C->getType());
2106 bool toVec = isa<VectorType>(Ty);
2108 assert((fromVec == toVec) &&
"Cannot convert from scalar to/from vector");
2109 assert(
C->getType()->isIntOrIntVectorTy() &&
"ZEXt operand must be integral");
2112 "SrcTy must be smaller than DestTy for ZExt!");
2119 bool fromVec = isa<VectorType>(
C->getType());
2120 bool toVec = isa<VectorType>(Ty);
2122 assert((fromVec == toVec) &&
"Cannot convert from scalar to/from vector");
2125 "This is an illegal floating point truncation!");
2126 return getFoldedCast(Instruction::FPTrunc,
C, Ty, OnlyIfReduced);
2131 bool fromVec = isa<VectorType>(
C->getType());
2132 bool toVec = isa<VectorType>(Ty);
2134 assert((fromVec == toVec) &&
"Cannot convert from scalar to/from vector");
2137 "This is an illegal floating point extension!");
2143 bool fromVec = isa<VectorType>(
C->getType());
2144 bool toVec = isa<VectorType>(Ty);
2146 assert((fromVec == toVec) &&
"Cannot convert from scalar to/from vector");
2148 "This is an illegal uint to floating point cast!");
2154 bool fromVec = isa<VectorType>(
C->getType());
2155 bool toVec = isa<VectorType>(Ty);
2157 assert((fromVec == toVec) &&
"Cannot convert from scalar to/from vector");
2159 "This is an illegal sint to floating point cast!");
2165 bool fromVec = isa<VectorType>(
C->getType());
2166 bool toVec = isa<VectorType>(Ty);
2168 assert((fromVec == toVec) &&
"Cannot convert from scalar to/from vector");
2170 "This is an illegal floating point to uint cast!");
2176 bool fromVec = isa<VectorType>(
C->getType());
2177 bool toVec = isa<VectorType>(Ty);
2179 assert((fromVec == toVec) &&
"Cannot convert from scalar to/from vector");
2181 "This is an illegal floating point to sint cast!");
2186 bool OnlyIfReduced) {
2187 assert(
C->getType()->isPtrOrPtrVectorTy() &&
2188 "PtrToInt source must be pointer or pointer vector");
2190 "PtrToInt destination must be integer or integer vector");
2191 assert(isa<VectorType>(
C->getType()) == isa<VectorType>(DstTy));
2192 if (isa<VectorType>(
C->getType()))
2193 assert(cast<VectorType>(
C->getType())->getElementCount() ==
2194 cast<VectorType>(DstTy)->getElementCount() &&
2195 "Invalid cast between a different number of vector elements");
2196 return getFoldedCast(Instruction::PtrToInt,
C, DstTy, OnlyIfReduced);
2200 bool OnlyIfReduced) {
2201 assert(
C->getType()->isIntOrIntVectorTy() &&
2202 "IntToPtr source must be integer or integer vector");
2204 "IntToPtr destination must be a pointer or pointer vector");
2205 assert(isa<VectorType>(
C->getType()) == isa<VectorType>(DstTy));
2206 if (isa<VectorType>(
C->getType()))
2207 assert(cast<VectorType>(
C->getType())->getElementCount() ==
2208 cast<VectorType>(DstTy)->getElementCount() &&
2209 "Invalid cast between a different number of vector elements");
2210 return getFoldedCast(Instruction::IntToPtr,
C, DstTy, OnlyIfReduced);
2214 bool OnlyIfReduced) {
2216 "Invalid constantexpr bitcast!");
2220 if (
C->getType() == DstTy)
return C;
2222 return getFoldedCast(Instruction::BitCast,
C, DstTy, OnlyIfReduced);
2226 bool OnlyIfReduced) {
2228 "Invalid constantexpr addrspacecast!");
2232 PointerType *SrcScalarTy = cast<PointerType>(
C->getType()->getScalarType());
2237 if (
VectorType *VT = dyn_cast<VectorType>(DstTy)) {
2240 cast<FixedVectorType>(VT)->getNumElements());
2244 return getFoldedCast(Instruction::AddrSpaceCast,
C, DstTy, OnlyIfReduced);
2248 unsigned Flags,
Type *OnlyIfReducedTy) {
2251 "Invalid opcode in binary constant expression");
2253 "Binop not supported as constant expression");
2255 "Operand types in binary constant expression should match");
2259 case Instruction::Add:
2260 case Instruction::Sub:
2261 case Instruction::Mul:
2263 "Tried to create an integer operation on a non-integer type!");
2265 case Instruction::And:
2266 case Instruction::Or:
2267 case Instruction::Xor:
2269 "Tried to create a logical operation on a non-integral type!");
2271 case Instruction::Shl:
2272 case Instruction::LShr:
2273 case Instruction::AShr:
2275 "Tried to create a shift operation on a non-integer type!");
2285 if (OnlyIfReducedTy == C1->
getType())
2297 case Instruction::UDiv:
2298 case Instruction::SDiv:
2299 case Instruction::URem:
2300 case Instruction::SRem:
2301 case Instruction::FAdd:
2302 case Instruction::FSub:
2303 case Instruction::FMul:
2304 case Instruction::FDiv:
2305 case Instruction::FRem:
2307 case Instruction::Add:
2308 case Instruction::Sub:
2309 case Instruction::Mul:
2310 case Instruction::Shl:
2311 case Instruction::LShr:
2312 case Instruction::AShr:
2313 case Instruction::And:
2314 case Instruction::Or:
2315 case Instruction::Xor:
2324 case Instruction::UDiv:
2325 case Instruction::SDiv:
2326 case Instruction::URem:
2327 case Instruction::SRem:
2328 case Instruction::FAdd:
2329 case Instruction::FSub:
2330 case Instruction::FMul:
2331 case Instruction::FDiv:
2332 case Instruction::FRem:
2334 case Instruction::Add:
2335 case Instruction::Sub:
2336 case Instruction::Mul:
2337 case Instruction::Shl:
2338 case Instruction::LShr:
2339 case Instruction::AShr:
2340 case Instruction::And:
2341 case Instruction::Or:
2342 case Instruction::Xor:
2366 Constant *Indices[2] = { Zero, One };
2373 Constant *C2,
bool OnlyIfReduced) {
2376 switch (Predicate) {
2384 return getFCmp(Predicate, C1, C2, OnlyIfReduced);
2390 return getICmp(Predicate, C1, C2, OnlyIfReduced);
2396 std::optional<unsigned> InRangeIndex,
2397 Type *OnlyIfReducedTy) {
2398 PointerType *OrigPtrTy = cast<PointerType>(
C->getType()->getScalarType());
2399 assert(Ty &&
"Must specify element type");
2409 assert(DestTy &&
"GEP indices invalid!");
2416 if (
VectorType *VecTy = dyn_cast<VectorType>(
C->getType()))
2417 EltCount = VecTy->getElementCount();
2419 for (
auto *
Idx : Idxs)
2420 if (
VectorType *VecTy = dyn_cast<VectorType>(
Idx->getType()))
2421 EltCount = VecTy->getElementCount();
2423 if (EltCount.isNonZero())
2426 if (OnlyIfReducedTy == ReqTy)
2430 std::vector<Constant*> ArgVec;
2431 ArgVec.reserve(1 + Idxs.
size());
2432 ArgVec.push_back(
C);
2434 for (; GTI != GTE; ++GTI) {
2435 auto *
Idx = cast<Constant>(GTI.getOperand());
2437 (!isa<VectorType>(
Idx->getType()) ||
2438 cast<VectorType>(
Idx->getType())->getElementCount() == EltCount) &&
2439 "getelementptr index type missmatch");
2441 if (GTI.isStruct() &&
Idx->getType()->isVectorTy()) {
2442 Idx =
Idx->getSplatValue();
2443 }
else if (GTI.isSequential() && EltCount.isNonZero() &&
2444 !
Idx->getType()->isVectorTy()) {
2447 ArgVec.push_back(
Idx);
2450 unsigned SubClassOptionalData = InBounds ? GEPOperator::IsInBounds : 0;
2451 if (InRangeIndex && *InRangeIndex < 63)
2452 SubClassOptionalData |= (*InRangeIndex + 1) << 1;
2454 SubClassOptionalData, std::nullopt, Ty);
2461 Constant *RHS,
bool OnlyIfReduced) {
2486 Constant *RHS,
bool OnlyIfReduced) {
2511 Type *OnlyIfReducedTy) {
2513 "Tried to create extractelement operation on non-vector type!");
2515 "Extractelement index must be an integer type!");
2520 Type *ReqTy = cast<VectorType>(Val->
getType())->getElementType();
2521 if (OnlyIfReducedTy == ReqTy)
2535 "Tried to create insertelement operation on non-vector type!");
2537 "Insertelement types must match!");
2539 "Insertelement index must be i32 type!");
2544 if (OnlyIfReducedTy == Val->
getType())
2557 Type *OnlyIfReducedTy) {
2559 "Invalid shuffle vector constant expr operands!");
2564 unsigned NElts = Mask.size();
2565 auto V1VTy = cast<VectorType>(V1->
getType());
2566 Type *EltTy = V1VTy->getElementType();
2567 bool TypeIsScalable = isa<ScalableVectorType>(V1VTy);
2570 if (OnlyIfReducedTy == ShufTy)
2582 assert(
C->getType()->isIntOrIntVectorTy() &&
2583 "Cannot NEG a nonintegral value!");
2588 assert(
C->getType()->isIntOrIntVectorTy() &&
2589 "Cannot NOT a nonintegral value!");
2594 bool HasNUW,
bool HasNSW) {
2597 return get(Instruction::Add, C1, C2,
Flags);
2601 bool HasNUW,
bool HasNSW) {
2604 return get(Instruction::Sub, C1, C2,
Flags);
2608 bool HasNUW,
bool HasNSW) {
2611 return get(Instruction::Mul, C1, C2,
Flags);
2615 return get(Instruction::And, C1, C2);
2619 return get(Instruction::Or, C1, C2);
2623 return get(Instruction::Xor, C1, C2);
2627 bool HasNUW,
bool HasNSW) {
2630 return get(Instruction::Shl, C1, C2,
Flags);
2634 return get(Instruction::LShr, C1, C2,
2639 return get(Instruction::AShr, C1, C2,
2644 Type *Ty =
C->getType();
2650 auto *VecTy = dyn_cast<FixedVectorType>(Ty);
2655 for (
unsigned I = 0,
E = VecTy->getNumElements();
I !=
E; ++
I) {
2660 if (isa<UndefValue>(Elt)) {
2673 bool AllowRHSConstant,
bool NSZ) {
2679 case Instruction::Add:
2680 case Instruction::Or:
2681 case Instruction::Xor:
2683 case Instruction::Mul:
2685 case Instruction::And:
2687 case Instruction::FAdd:
2689 case Instruction::FMul:
2697 if (!AllowRHSConstant)
2701 case Instruction::Sub:
2702 case Instruction::Shl:
2703 case Instruction::LShr:
2704 case Instruction::AShr:
2705 case Instruction::FSub:
2707 case Instruction::SDiv:
2708 case Instruction::UDiv:
2710 case Instruction::FDiv:
2723 case Instruction::Or:
2726 case Instruction::And:
2727 case Instruction::Mul:
2733void ConstantExpr::destroyConstantImpl() {
2741GetElementPtrConstantExpr::GetElementPtrConstantExpr(
2745 (IdxList.
size() + 1),
2746 IdxList.
size() + 1),
2747 SrcElementTy(SrcElementTy),
2751 for (
unsigned i = 0,
E = IdxList.
size(); i !=
E; ++i)
2752 OperandList[i+1] = IdxList[i];
2756 return SrcElementTy;
2760 return ResElementTy;
2768 return ATy->getElementType();
2769 return cast<VectorType>(
getType())->getElementType();
2779 if (
auto *
IT = dyn_cast<IntegerType>(Ty)) {
2780 switch (
IT->getBitWidth()) {
2794 return AT->getNumElements();
2795 return cast<FixedVectorType>(
getType())->getNumElements();
2804const char *ConstantDataSequential::getElementPointer(
unsigned Elt)
const {
2824 if (
ArrayType *ATy = dyn_cast<ArrayType>(Ty))
2844 std::unique_ptr<ConstantDataSequential> *Entry = &Slot.second;
2845 for (; *Entry; Entry = &(*Entry)->Next)
2846 if ((*Entry)->getType() == Ty)
2847 return Entry->get();
2851 if (isa<ArrayType>(Ty)) {
2854 return Entry->get();
2857 assert(isa<VectorType>(Ty));
2860 return Entry->get();
2863void ConstantDataSequential::destroyConstantImpl() {
2870 assert(Slot != CDSConstants.
end() &&
"CDS not found in uniquing table");
2872 std::unique_ptr<ConstantDataSequential> *Entry = &Slot->getValue();
2875 if (!(*Entry)->Next) {
2878 assert(Entry->get() ==
this &&
"Hash mismatch in ConstantDataSequential");
2886 std::unique_ptr<ConstantDataSequential> &
Node = *Entry;
2887 assert(
Node &&
"Didn't find entry in its uniquing hash table!");
2889 if (
Node.get() ==
this) {
2894 Entry = &
Node->Next;
2906 "Element type is not a 16-bit float type");
2908 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2912 assert(ElementType->
isFloatTy() &&
"Element type is not a 32-bit float type");
2914 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2919 "Element type is not a 64-bit float type");
2921 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2928 const uint8_t *
Data = Str.bytes_begin();
2933 ElementVals.
append(Str.begin(), Str.end());
2943 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2948 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2953 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2958 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2963 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2968 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2981 "Element type is not a 16-bit float type");
2983 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2988 assert(ElementType->
isFloatTy() &&
"Element type is not a 32-bit float type");
2990 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2996 "Element type is not a 64-bit float type");
2998 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
3004 "Element type not compatible with ConstantData");
3006 if (CI->getType()->isIntegerTy(8)) {
3008 return get(V->getContext(), Elts);
3010 if (CI->getType()->isIntegerTy(16)) {
3012 return get(V->getContext(), Elts);
3014 if (CI->getType()->isIntegerTy(32)) {
3016 return get(V->getContext(), Elts);
3018 assert(CI->getType()->isIntegerTy(64) &&
"Unsupported ConstantData type");
3020 return get(V->getContext(), Elts);
3023 if (
ConstantFP *CFP = dyn_cast<ConstantFP>(V)) {
3024 if (CFP->getType()->isHalfTy()) {
3026 NumElts, CFP->getValueAPF().bitcastToAPInt().getLimitedValue());
3027 return getFP(V->getType(), Elts);
3029 if (CFP->getType()->isBFloatTy()) {
3031 NumElts, CFP->getValueAPF().bitcastToAPInt().getLimitedValue());
3032 return getFP(V->getType(), Elts);
3034 if (CFP->getType()->isFloatTy()) {
3036 NumElts, CFP->getValueAPF().bitcastToAPInt().getLimitedValue());
3037 return getFP(V->getType(), Elts);
3039 if (CFP->getType()->isDoubleTy()) {
3041 NumElts, CFP->getValueAPF().bitcastToAPInt().getLimitedValue());
3042 return getFP(V->getType(), Elts);
3051 "Accessor can only be used when element is an integer");
3052 const char *EltPtr = getElementPointer(Elt);
3059 return *
reinterpret_cast<const uint8_t *
>(EltPtr);
3061 return *
reinterpret_cast<const uint16_t *
>(EltPtr);
3063 return *
reinterpret_cast<const uint32_t *
>(EltPtr);
3065 return *
reinterpret_cast<const uint64_t *
>(EltPtr);
3071 "Accessor can only be used when element is an integer");
3072 const char *EltPtr = getElementPointer(Elt);
3079 auto EltVal = *
reinterpret_cast<const uint8_t *
>(EltPtr);
3080 return APInt(8, EltVal);
3083 auto EltVal = *
reinterpret_cast<const uint16_t *
>(EltPtr);
3084 return APInt(16, EltVal);
3087 auto EltVal = *
reinterpret_cast<const uint32_t *
>(EltPtr);
3088 return APInt(32, EltVal);
3091 auto EltVal = *
reinterpret_cast<const uint64_t *
>(EltPtr);
3092 return APInt(64, EltVal);
3098 const char *EltPtr = getElementPointer(Elt);
3102 llvm_unreachable(
"Accessor can only be used when element is float/double!");
3104 auto EltVal = *
reinterpret_cast<const uint16_t *
>(EltPtr);
3108 auto EltVal = *
reinterpret_cast<const uint16_t *
>(EltPtr);
3112 auto EltVal = *
reinterpret_cast<const uint32_t *
>(EltPtr);
3116 auto EltVal = *
reinterpret_cast<const uint64_t *
>(EltPtr);
3124 "Accessor can only be used when element is a 'float'");
3125 return *
reinterpret_cast<const float *
>(getElementPointer(Elt));
3130 "Accessor can only be used when element is a 'float'");
3131 return *
reinterpret_cast<const double *
>(getElementPointer(Elt));
3153 if (Str.back() != 0)
return false;
3156 return !Str.drop_back().contains(0);
3159bool ConstantDataVector::isSplatData()
const {
3174 IsSplat = isSplatData();
3199 Value *Replacement =
nullptr;
3203#define HANDLE_CONSTANT(Name) \
3204 case Value::Name##Val: \
3205 Replacement = cast<Name>(this)->handleOperandChangeImpl(From, To); \
3207#include "llvm/IR/Value.def"
3216 assert(Replacement !=
this &&
"I didn't contain From!");
3226 assert(isa<Constant>(To) &&
"Cannot make Constant refer to non-constant!");
3227 Constant *ToC = cast<Constant>(To);
3234 unsigned NumUpdated = 0;
3237 bool AllSame =
true;
3239 unsigned OperandNo = 0;
3241 Constant *Val = cast<Constant>(O->get());
3243 OperandNo = (O - OperandList);
3248 AllSame &= Val == ToC;
3254 if (AllSame && isa<UndefValue>(ToC))
3263 Values,
this,
From, ToC, NumUpdated, OperandNo);
3267 assert(isa<Constant>(To) &&
"Cannot make Constant refer to non-constant!");
3268 Constant *ToC = cast<Constant>(To);
3277 unsigned NumUpdated = 0;
3278 bool AllSame =
true;
3279 unsigned OperandNo = 0;
3281 Constant *Val = cast<Constant>(
O->get());
3283 OperandNo = (
O - OperandList);
3288 AllSame &= Val == ToC;
3294 if (AllSame && isa<UndefValue>(ToC))
3299 Values,
this,
From, ToC, NumUpdated, OperandNo);
3303 assert(isa<Constant>(To) &&
"Cannot make Constant refer to non-constant!");
3304 Constant *ToC = cast<Constant>(To);
3308 unsigned NumUpdated = 0;
3309 unsigned OperandNo = 0;
3325 Values,
this,
From, ToC, NumUpdated, OperandNo);
3329 assert(isa<Constant>(ToV) &&
"Cannot make Constant refer to non-constant!");
3330 Constant *To = cast<Constant>(ToV);
3333 unsigned NumUpdated = 0;
3334 unsigned OperandNo = 0;
3344 assert(NumUpdated &&
"I didn't contain From!");
3351 NewOps,
this,
From, To, NumUpdated, OperandNo);
3359 case Instruction::Trunc:
3360 case Instruction::ZExt:
3361 case Instruction::SExt:
3362 case Instruction::FPTrunc:
3363 case Instruction::FPExt:
3364 case Instruction::UIToFP:
3365 case Instruction::SIToFP:
3366 case Instruction::FPToUI:
3367 case Instruction::FPToSI:
3368 case Instruction::PtrToInt:
3369 case Instruction::IntToPtr:
3370 case Instruction::BitCast:
3371 case Instruction::AddrSpaceCast:
3374 case Instruction::InsertElement:
3376 case Instruction::ExtractElement:
3378 case Instruction::ShuffleVector:
3382 case Instruction::GetElementPtr: {
3383 const auto *GO = cast<GEPOperator>(
this);
3384 if (GO->isInBounds())
3386 GO->getSourceElementType(), Ops[0], Ops.
slice(1),
"", InsertBefore);
3388 Ops.
slice(1),
"", InsertBefore);
3390 case Instruction::ICmp:
3391 case Instruction::FCmp:
3399 if (isa<OverflowingBinaryOperator>(BO)) {
3405 if (isa<PossiblyExactOperator>(BO))
This file defines the StringMap class.
static cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::values(clEnumValN(DefaultIT, "arm-default-it", "Generate any type of IT block"), clEnumValN(RestrictedIT, "arm-restrict-it", "Disallow complex IT blocks")))
BlockVerifier::State From
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static bool isAllZeros(StringRef Arr)
Return true if the array is empty or all zeros.
static Constant * getFPSequenceIfElementsMatch(ArrayRef< Constant * > V)
static bool rangeOnlyContains(ItTy Start, ItTy End, EltTy Elt)
static Constant * getIntSequenceIfElementsMatch(ArrayRef< Constant * > V)
static Constant * getSequenceIfElementsMatch(Constant *C, ArrayRef< Constant * > V)
static bool ConstHasGlobalValuePredicate(const Constant *C, bool(*Predicate)(const GlobalValue *))
Check if C contains a GlobalValue for which Predicate is true.
static bool constantIsDead(const Constant *C, bool RemoveDeadUsers)
Return true if the specified constantexpr is dead.
static bool containsUndefinedElement(const Constant *C, function_ref< bool(const Constant *)> HasFn)
static Constant * getFoldedCast(Instruction::CastOps opc, Constant *C, Type *Ty, bool OnlyIfReduced=false)
This is a utility function to handle folding of casts and lookup of the cast in the ExprConstants map...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
Looks at all the uses of the given value Returns the Liveness deduced from the uses of this value Adds all uses that cause the result to be MaybeLive to MaybeLiveRetUses If the result is MaybeLiveUses might be modified but its content should be ignored(since it might not be complete). DeadArgumentEliminationPass
static Function * getFunction(Constant *C)
static bool isSigned(unsigned int Opcode)
static char getTypeID(Type *Ty)
This file contains the declaration of the GlobalIFunc class, which represents a single indirect funct...
static bool isUndef(ArrayRef< int > Mask)
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
Merge contiguous icmps into a memcmp
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
static SymbolRef::Type getType(const Symbol *Sym)
static APFloat getQNaN(const fltSemantics &Sem, bool Negative=false, const APInt *payload=nullptr)
Factory for QNaN values.
static APFloat getSNaN(const fltSemantics &Sem, bool Negative=false, const APInt *payload=nullptr)
Factory for SNaN values.
opStatus convert(const fltSemantics &ToSemantics, roundingMode RM, bool *losesInfo)
bool bitwiseIsEqual(const APFloat &RHS) const
static APFloat getAllOnesValue(const fltSemantics &Semantics)
Returns a float which is bitcasted from an all one value int.
const fltSemantics & getSemantics() const
static APFloat getInf(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Infinity.
static APFloat getNaN(const fltSemantics &Sem, bool Negative=false, uint64_t payload=0)
Factory for NaN values.
static APFloat getZero(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Zero.
Class for arbitrary precision integers.
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
unsigned logBase2() const
bool isPowerOf2() const
Check if this APInt's value is a power of two greater than zero.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
Class to represent array types.
static ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
Type * getElementType() const
LLVM Basic Block Representation.
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches,...
const Function * getParent() const
Return the enclosing method, or null if none.
BinaryConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to impleme...
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.
The address of a basic block.
static BlockAddress * lookup(const BasicBlock *BB)
Lookup an existing BlockAddress constant for the given BasicBlock.
Function * getFunction() const
BasicBlock * getBasicBlock() const
static BlockAddress * get(Function *F, BasicBlock *BB)
Return a BlockAddress for the specified function and basic block.
CastConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to implement...
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 castIsValid(Instruction::CastOps op, Type *SrcTy, Type *DstTy)
This method can be used to determine if a cast from SrcTy to DstTy using Opcode op is valid or not.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
@ FCMP_OEQ
0 0 0 1 True if ordered and equal
@ FCMP_TRUE
1 1 1 1 Always true (always folded)
@ ICMP_SLT
signed less than
@ ICMP_SLE
signed less or equal
@ FCMP_OLT
0 1 0 0 True if ordered and less than
@ FCMP_ULE
1 1 0 1 True if unordered, less than, or equal
@ FCMP_OGT
0 0 1 0 True if ordered and greater than
@ FCMP_OGE
0 0 1 1 True if ordered and greater than or equal
@ ICMP_UGE
unsigned greater or equal
@ ICMP_UGT
unsigned greater than
@ ICMP_SGT
signed greater than
@ FCMP_ULT
1 1 0 0 True if unordered or less than
@ FCMP_ONE
0 1 1 0 True if ordered and operands are unequal
@ FCMP_UEQ
1 0 0 1 True if unordered or equal
@ ICMP_ULT
unsigned less than
@ FCMP_UGT
1 0 1 0 True if unordered or greater than
@ FCMP_OLE
0 1 0 1 True if ordered and less than or equal
@ FCMP_ORD
0 1 1 1 True if ordered (no nans)
@ ICMP_SGE
signed greater or equal
@ FCMP_UNE
1 1 1 0 True if unordered or not equal
@ ICMP_ULE
unsigned less or equal
@ FCMP_UGE
1 0 1 1 True if unordered, greater than, or equal
@ FCMP_FALSE
0 0 0 0 Always false (always folded)
@ FCMP_UNO
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
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.
bool isFPPredicate() const
bool isIntPredicate() const
All zero aggregate value.
ElementCount getElementCount() const
Return the number of elements in the array, vector, or struct.
Constant * getSequentialElement() const
If this CAZ has array or vector type, return a zero with the right element type.
Constant * getElementValue(Constant *C) const
Return a zero of the right value for the specified GEP index if we can, otherwise return null (e....
Constant * getStructElement(unsigned Elt) const
If this CAZ has struct type, return a zero with the right element type for the specified element.
static ConstantAggregateZero * get(Type *Ty)
Base class for aggregate constants (with operands).
ConstantAggregate(Type *T, ValueTy VT, ArrayRef< Constant * > V)
ConstantArray - Constant Array Declarations.
static Constant * get(ArrayType *T, ArrayRef< Constant * > V)
ArrayType * getType() const
Specialize the getType() method to always return an ArrayType, which reduces the amount of casting ne...
An array constant whose element type is a simple 1/2/4/8-byte integer or float/double,...
static Constant * getString(LLVMContext &Context, StringRef Initializer, bool AddNull=true)
This method constructs a CDS and initializes it with a text string.
static Constant * get(LLVMContext &Context, ArrayRef< ElementTy > Elts)
get() constructor - Return a constant with array type with an element count and element type matching...
static Constant * getFP(Type *ElementType, ArrayRef< uint16_t > Elts)
getFP() constructors - Return a constant of array type with a float element type taken from argument ...
APInt getElementAsAPInt(unsigned i) const
If this is a sequential container of integers (of any size), return the specified element as an APInt...
double getElementAsDouble(unsigned i) const
If this is an sequential container of doubles, return the specified element as a double.
StringRef getAsString() const
If this array is isString(), then this method returns the array as a StringRef.
uint64_t getElementByteSize() const
Return the size (in bytes) of each element in the array/vector.
float getElementAsFloat(unsigned i) const
If this is an sequential container of floats, return the specified element as a float.
bool isString(unsigned CharSize=8) const
This method returns true if this is an array of CharSize integers.
uint64_t getElementAsInteger(unsigned i) const
If this is a sequential container of integers (of any size), return the specified element in the low ...
static Constant * getImpl(StringRef Bytes, Type *Ty)
This is the underlying implementation of all of the ConstantDataSequential::get methods.
unsigned getNumElements() const
Return the number of elements in the array or vector.
Constant * getElementAsConstant(unsigned i) const
Return a Constant for a specified index's element.
Type * getElementType() const
Return the element type of the array/vector.
bool isCString() const
This method returns true if the array "isString", ends with a null byte, and does not contains any ot...
APFloat getElementAsAPFloat(unsigned i) const
If this is a sequential container of floating point type, return the specified element as an APFloat.
StringRef getRawDataValues() const
Return the raw, underlying, bytes of this data.
static bool isElementTypeCompatible(Type *Ty)
Return true if a ConstantDataSequential can be formed with a vector or array of the specified element...
A vector constant whose element type is a simple 1/2/4/8-byte integer or float/double,...
Constant * getSplatValue() const
If this is a splat constant, meaning that all of the elements have the same value,...
static Constant * getSplat(unsigned NumElts, Constant *Elt)
Return a ConstantVector with the specified constant in each element.
bool isSplat() const
Returns true if this is a splat constant, meaning that all elements have the same value.
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 Constant * getFP(Type *ElementType, ArrayRef< uint16_t > Elts)
getFP() constructors - Return a constant of vector type with a float element type taken from argument...
Base class for constants with no operands.
A constant value that is initialized with an expression using other constant values.
static Constant * getSExtOrTrunc(Constant *C, Type *Ty)
Create either an sext, trunc or nothing, depending on whether Ty is wider, narrower or the same as C-...
static Constant * getSExtOrBitCast(Constant *C, Type *Ty)
static Constant * getFCmp(unsigned short pred, Constant *LHS, Constant *RHS, bool OnlyIfReduced=false)
static Constant * getIntToPtr(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static Constant * getExtractElement(Constant *Vec, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
static Constant * getAlignOf(Type *Ty)
getAlignOf constant expr - computes the alignment of a type in a target independent way (Note: the re...
static Constant * getAShr(Constant *C1, Constant *C2, bool isExact=false)
static Constant * getPointerCast(Constant *C, Type *Ty)
Create a BitCast, AddrSpaceCast, or a PtrToInt cast constant expression.
static Constant * getTruncOrBitCast(Constant *C, Type *Ty)
static Constant * getPointerBitCastOrAddrSpaceCast(Constant *C, Type *Ty)
Create a BitCast or AddrSpaceCast for a pointer type depending on the address space.
bool isCast() const
Return true if this is a convert constant expression.
static Constant * getFPToUI(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Constant * getShuffleMaskForBitcode() const
Assert that this is a shufflevector and return the mask.
static Constant * getCast(unsigned ops, Constant *C, Type *Ty, bool OnlyIfReduced=false)
Convenience function for getting a Cast operation.
static Constant * getSub(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
static Constant * getZExt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static Constant * getNot(Constant *C)
const char * getOpcodeName() const
Return a string representation for an opcode.
static Constant * getInsertElement(Constant *Vec, Constant *Elt, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
static Constant * getPtrToInt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
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...
Instruction * getAsInstruction(Instruction *InsertBefore=nullptr) const
Returns an Instruction which implements the same operation as this ConstantExpr.
bool isCompare() const
Return true if this is a compare constant expression.
static Constant * getShuffleVector(Constant *V1, Constant *V2, ArrayRef< int > Mask, Type *OnlyIfReducedTy=nullptr)
static Constant * getFPTrunc(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static Constant * getSIToFP(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static Constant * getSizeOf(Type *Ty)
getSizeOf constant expr - computes the (alloc) size of a type (in address-units, not bits) in a targe...
static bool isSupportedGetElementPtr(const Type *SrcElemTy)
Whether creating a constant expression for this getelementptr type is supported.
static Constant * getGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList, bool InBounds=false, std::optional< unsigned > InRangeIndex=std::nullopt, Type *OnlyIfReducedTy=nullptr)
Getelementptr form.
static Constant * getIntegerCast(Constant *C, Type *Ty, bool IsSigned)
Create a ZExt, Bitcast or Trunc for integer -> integer casts.
static Constant * getXor(Constant *C1, Constant *C2)
static Constant * getSExt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static Constant * getBinOpAbsorber(unsigned Opcode, Type *Ty)
Return the absorbing element for the given binary operation, i.e.
static Constant * getMul(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
static Constant * getZExtOrBitCast(Constant *C, Type *Ty)
static Constant * getShl(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
static Constant * getLShr(Constant *C1, Constant *C2, bool isExact=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 * getFPExtend(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static bool isDesirableBinOp(unsigned Opcode)
Whether creating a constant expression for this binary operator is desirable.
unsigned getPredicate() const
Return the ICMP or FCMP predicate value.
ArrayRef< int > getShuffleMask() const
Assert that this is a shufflevector and return the mask.
static bool isSupportedBinOp(unsigned Opcode)
Whether creating a constant expression for this binary operator is supported.
static Constant * getUIToFP(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static Constant * getFPToSI(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static Constant * getAddrSpaceCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
unsigned getOpcode() const
Return the opcode at the root of this constant expression.
static Constant * getOr(Constant *C1, Constant *C2)
static Constant * getAnd(Constant *C1, Constant *C2)
static Constant * getAdd(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
static Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static Constant * getBinOpIdentity(unsigned Opcode, Type *Ty, bool AllowRHSConstant=false, bool NSZ=false)
Return the identity constant for a binary opcode.
static Constant * getTrunc(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static Constant * getExactLogBase2(Constant *C)
If C is a scalar/fixed width vector of known powers of 2, then this function returns a new scalar/fix...
Constant * getWithOperands(ArrayRef< Constant * > Ops) const
This returns the current constant expression with the operands replaced with the specified values.
static Constant * getNeg(Constant *C, bool HasNUW=false, bool HasNSW=false)
static Constant * getFPCast(Constant *C, Type *Ty)
Create a FPExt, Bitcast or FPTrunc for fp -> fp casts.
static Constant * getCompare(unsigned short pred, Constant *C1, Constant *C2, bool OnlyIfReduced=false)
Return an ICmp or FCmp comparison operator constant expression.
ConstantFP - Floating Point Values [float, double].
static Constant * getSNaN(Type *Ty, bool Negative=false, APInt *Payload=nullptr)
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 Constant * getInfinity(Type *Ty, bool Negative=false)
static Constant * getZero(Type *Ty, bool Negative=false)
static Constant * getNaN(Type *Ty, bool Negative=false, uint64_t Payload=0)
bool isExactlyValue(const APFloat &V) const
We don't rely on operator== working on double values, as it returns true for things that are clearly ...
static bool isValueValidForType(Type *Ty, const APFloat &V)
Return true if Ty is big enough to represent V.
static Constant * getQNaN(Type *Ty, bool Negative=false, APInt *Payload=nullptr)
This is the shared class of boolean and integer constants.
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.
static ConstantInt * getTrue(LLVMContext &Context)
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 * getFalse(LLVMContext &Context)
static ConstantInt * getBool(LLVMContext &Context, bool V)
A constant pointer value that points to null.
static ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
PointerType * getType() const
Specialize the getType() method to always return an PointerType, which reduces the amount of casting ...
static Constant * get(StructType *T, ArrayRef< Constant * > V)
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.
StructType * getType() const
Specialization - reduce amount of casting.
A constant target extension type default initializer.
static ConstantTargetNone * get(TargetExtType *T)
Static factory methods - Return objects of the specified value.
TargetExtType * getType() const
Specialize the getType() method to always return an TargetExtType, which reduces the amount of castin...
A constant token which is empty.
static ConstantTokenNone * get(LLVMContext &Context)
Return the ConstantTokenNone.
ConstantClass * getOrCreate(TypeClass *Ty, ValType V)
Return the specified constant from the map, creating it if necessary.
void remove(ConstantClass *CP)
Remove this constant from the map.
ConstantClass * replaceOperandsInPlace(ArrayRef< Constant * > Operands, ConstantClass *CP, Value *From, Constant *To, unsigned NumUpdated=0, unsigned OperandNo=~0u)
Constant Vector Declarations.
Constant * getSplatValue(bool AllowUndefs=false) const
If all elements of the vector constant have the same value, return that value.
FixedVectorType * getType() const
Specialize the getType() method to always return a FixedVectorType, which reduces the amount of casti...
static Constant * getSplat(ElementCount EC, Constant *Elt)
Return a ConstantVector with the specified constant in each element.
static Constant * get(ArrayRef< Constant * > V)
This is an important base class in LLVM.
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 hasExactInverseFP() const
Return true if this scalar has an exact multiplicative inverse or this vector has an exact multiplica...
static Constant * replaceUndefsWith(Constant *C, Constant *Replacement)
Try to replace undefined constant C or undefined elements in C with Replacement.
bool containsUndefElement() const
Return true if this is a vector constant that includes any strictly undef (not poison) elements.
Constant * getSplatValue(bool AllowUndefs=false) const
If all elements of the vector constant have the same value, return that value.
static Constant * mergeUndefsWith(Constant *C, Constant *Other)
Merges undefs of a Constant with another Constant, along with the undefs already present.
static Constant * getAllOnesValue(Type *Ty)
bool hasZeroLiveUses() const
Return true if the constant has no live uses.
bool isOneValue() const
Returns true if the value is one.
bool isManifestConstant() const
Return true if a constant is ConstantData or a ConstantAggregate or ConstantExpr that contain only Co...
bool isNegativeZeroValue() const
Return true if the value is what would be returned by getZeroValueForNegation.
bool isAllOnesValue() const
Return true if this is the value that would be returned by getAllOnesValue.
bool hasOneLiveUse() const
Return true if the constant has exactly one live use.
bool needsRelocation() const
This method classifies the entry according to whether or not it may generate a relocation entry (eith...
bool isDLLImportDependent() const
Return true if the value is dependent on a dllimport variable.
const APInt & getUniqueInteger() const
If C is a constant integer then return its value, otherwise C must be a vector of constant integers,...
bool containsConstantExpression() const
Return true if this is a fixed width vector constant that includes any constant expressions.
bool isFiniteNonZeroFP() const
Return true if this is a finite and non-zero floating-point scalar constant or a fixed width vector c...
void removeDeadConstantUsers() const
If there are any dead constant users dangling off of this constant, remove them.
bool isNormalFP() const
Return true if this is a normal (as opposed to denormal, infinity, nan, or zero) floating-point scala...
bool needsDynamicRelocation() const
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
bool isNaN() const
Return true if this is a floating-point NaN constant or a vector floating-point constant with all NaN...
bool isMinSignedValue() const
Return true if the value is the smallest signed value.
bool isConstantUsed() const
Return true if the constant has users other than constant expressions and other dangling things.
Constant * getAggregateElement(unsigned Elt) const
For aggregates (struct/array/vector) return the constant that corresponds to the specified element if...
bool isThreadDependent() const
Return true if the value can vary between threads.
bool isZeroValue() const
Return true if the value is negative zero or null value.
void destroyConstant()
Called if some element of this constant is no longer valid.
bool isNotMinSignedValue() const
Return true if the value is not the smallest signed value, or, for vectors, does not contain smallest...
bool isNullValue() const
Return true if this is the value that would be returned by getNullValue.
bool isNotOneValue() const
Return true if the value is not the one value, or, for vectors, does not contain one value elements.
bool isElementWiseEqual(Value *Y) const
Return true if this constant and a constant 'Y' are element-wise equal.
bool containsUndefOrPoisonElement() const
Return true if this is a vector constant that includes any undef or poison elements.
bool containsPoisonElement() const
Return true if this is a vector constant that includes any poison elements.
void handleOperandChange(Value *, Value *)
This method is a special form of User::replaceUsesOfWith (which does not work on constants) that does...
Wrapper for a function that represents a value that functionally represents the original function.
GlobalValue * getGlobalValue() const
static DSOLocalEquivalent * get(GlobalValue *GV)
Return a DSOLocalEquivalent for the specified global value.
static constexpr ElementCount getFixed(ScalarTy MinVal)
static FixedVectorType * get(Type *ElementType, unsigned NumElts)
GetElementPtrConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to ...
Type * getResultElementType() const
Type * getSourceElementType() const
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
static GetElementPtrInst * CreateInBounds(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Create an "inbounds" getelementptr.
static Type * getIndexedType(Type *Ty, ArrayRef< Value * > IdxList)
Returns the result type of a getelementptr with the given source element type and indexes.
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
PointerType * getType() const
Global values are always pointers.
InsertElementConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to ...
static InsertElementInst * Create(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
void setHasNoUnsignedWrap(bool b=true)
Set or clear the nuw flag on this instruction, which must be an operator which supports this flag.
void setHasNoSignedWrap(bool b=true)
Set or clear the nsw flag on this instruction, which must be an operator which supports this flag.
bool isCommutative() const LLVM_READONLY
Return true if the instruction is commutative:
const char * getOpcodeName() const
void setIsExact(bool b=true)
Set or clear the exact flag on this instruction, which must be an operator which supports this flag.
Class to represent integer types.
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
DenseMap< unsigned, std::unique_ptr< ConstantInt > > IntOneConstants
DenseMap< unsigned, std::unique_ptr< ConstantInt > > IntZeroConstants
DenseMap< PointerType *, std::unique_ptr< ConstantPointerNull > > CPNConstants
DenseMap< Type *, std::unique_ptr< ConstantAggregateZero > > CAZConstants
ConstantInt * TheFalseVal
DenseMap< Type *, std::unique_ptr< PoisonValue > > PVConstants
DenseMap< std::pair< const Function *, const BasicBlock * >, BlockAddress * > BlockAddresses
std::unique_ptr< ConstantTokenNone > TheNoneToken
VectorConstantsTy VectorConstants
DenseMap< const GlobalValue *, NoCFIValue * > NoCFIValues
DenseMap< Type *, std::unique_ptr< UndefValue > > UVConstants
StringMap< std::unique_ptr< ConstantDataSequential > > CDSConstants
StructConstantsTy StructConstants
DenseMap< TargetExtType *, std::unique_ptr< ConstantTargetNone > > CTNConstants
ConstantUniqueMap< ConstantExpr > ExprConstants
DenseMap< APFloat, std::unique_ptr< ConstantFP >, DenseMapAPFloatKeyInfo > FPConstants
ArrayConstantsTy ArrayConstants
DenseMap< APInt, std::unique_ptr< ConstantInt >, DenseMapAPIntKeyInfo > IntConstants
DenseMap< const GlobalValue *, DSOLocalEquivalent * > DSOLocalEquivalents
This is an important class for using LLVM in a threaded context.
LLVMContextImpl *const pImpl
Wrapper for a value that won't be replaced with a CFI jump table pointer in LowerTypeTestsModule.
static NoCFIValue * get(GlobalValue *GV)
Return a NoCFIValue for the specified function.
GlobalValue * getGlobalValue() const
Class to represent pointers.
bool isOpaqueOrPointeeTypeMatches(Type *Ty)
Return true if either this is an opaque pointer type or if this pointee type matches Ty.
bool hasSameElementTypeAs(PointerType *Other)
Return true if both pointer types have the same element type.
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
unsigned getAddressSpace() const
Return the address space of the Pointer type.
static PointerType * getWithSamePointeeType(PointerType *PT, unsigned AddressSpace)
This constructs a pointer type with the same pointee type as input PointerType (or opaque pointer if ...
In order to facilitate speculative execution, many instructions do not invoke immediate undefined beh...
static PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
PoisonValue * getStructElement(unsigned Elt) const
If this poison has struct type, return a poison with the right element type for the specified element...
PoisonValue * getSequentialElement() const
If this poison has array or vector type, return a poison with the right element type.
PoisonValue * getElementValue(Constant *C) const
Return an poison of the right value for the specified GEP index if we can, otherwise return null (e....
ShuffleVectorConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to ...
This instruction constructs a fixed permutation of two input vectors.
static bool isValidOperands(const Value *V1, const Value *V2, const Value *Mask)
Return true if a shufflevector instruction can be formed with the specified operands.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
void reserve(size_type N)
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
iterator find(StringRef Key)
StringRef - Represent a constant reference to a string, i.e.
const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Class to represent struct types.
static StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
Class to represent target extensions types, which are generally unintrospectable from target-independ...
bool hasProperty(Property Prop) const
Returns true if the target extension type contains the given property.
@ HasZeroInit
zeroinitializer is valid for this target extension type.
The instances of the Type class are immutable: once they are created, they are never changed.
unsigned getIntegerBitWidth() const
static Type * getDoubleTy(LLVMContext &C)
const fltSemantics & getFltSemantics() const
bool isVectorTy() const
True if this is an instance of VectorType.
static Type * getFloatingPointTy(LLVMContext &C, const fltSemantics &S)
PointerType * getPointerTo(unsigned AddrSpace=0) const
Return a pointer to the current type.
bool isArrayTy() const
True if this is an instance of ArrayType.
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
static IntegerType * getInt1Ty(LLVMContext &C)
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
bool isBFloatTy() const
Return true if this is 'bfloat', a 16-bit bfloat type.
unsigned getStructNumElements() const
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
@ HalfTyID
16-bit floating point type
@ TargetExtTyID
Target extension type.
@ ScalableVectorTyID
Scalable SIMD vector type.
@ FloatTyID
32-bit floating point type
@ IntegerTyID
Arbitrary bit width integers.
@ FixedVectorTyID
Fixed width SIMD vector type.
@ BFloatTyID
16-bit floating point type (7-bit significand)
@ DoubleTyID
64-bit floating point type
@ X86_FP80TyID
80-bit floating point type (X87)
@ PPC_FP128TyID
128-bit floating point type (two 64-bits, PowerPC)
@ FP128TyID
128-bit floating point type (112-bit significand)
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
bool isStructTy() const
True if this is an instance of StructType.
bool isFirstClassType() const
Return true if the type is "first class", meaning it is a valid type for a Value.
static IntegerType * getInt16Ty(LLVMContext &C)
bool isHalfTy() const
Return true if this is 'half', a 16-bit IEEE fp type.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
static IntegerType * getInt8Ty(LLVMContext &C)
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
bool isFloatingPointTy() const
Return true if this is one of the floating-point types.
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
static IntegerType * getInt32Ty(LLVMContext &C)
static IntegerType * getInt64Ty(LLVMContext &C)
static Type * getFloatTy(LLVMContext &C)
bool isIntegerTy() const
True if this is an instance of IntegerType.
TypeID getTypeID() const
Return the type id for the type.
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
'undef' values are things that do not have specified contents.
UndefValue * getElementValue(Constant *C) const
Return an undef of the right value for the specified GEP index if we can, otherwise return null (e....
UndefValue * getStructElement(unsigned Elt) const
If this undef has struct type, return a undef with the right element type for the specified element.
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
unsigned getNumElements() const
Return the number of elements in the array, vector, or struct.
UndefValue * getSequentialElement() const
If this Undef has array or vector type, return a undef with the right element type.
A Use represents the edge between a Value definition and its users.
const Use * getOperandList() const
void setOperand(unsigned i, Value *Val)
Value * getOperand(unsigned i) const
unsigned getNumOperands() const
iterator_range< value_op_iterator > operand_values()
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
user_iterator_impl< const User > const_user_iterator
user_iterator user_begin()
unsigned char SubclassOptionalData
Hold subclass data that can be dropped.
const Value * stripPointerCastsAndAliases() const
Strip off pointer casts, all-zero GEPs, address space casts, and aliases.
const Value * stripInBoundsConstantOffsets() const
Strip off pointer casts and all-constant inbounds GEPs.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
iterator_range< user_iterator > users()
unsigned getValueID() const
Return an ID for the concrete type of this object.
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
LLVMContext & getContext() const
All values hold a context through their type.
iterator_range< use_iterator > uses()
void mutateType(Type *Ty)
Mutate the type of this Value to be of the specified type.
ValueTy
Concrete subclass of this.
Base class of all SIMD vector types.
ElementCount getElementCount() const
Return an ElementCount instance to represent the (possibly scalable) number of elements in the vector...
static VectorType * getInteger(VectorType *VTy)
This static method gets a VectorType with the same number of elements as the input type,...
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
Type * getElementType() const
An efficient, type-erasing, non-owning reference to a callable.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
bool match(Val *V, const Pattern &P)
cst_pred_ty< is_one > m_One()
Match an integer 1 or a vector with all elements equal to 1.
apint_match m_APInt(const APInt *&Res)
Match a ConstantInt or splatted ConstantVector, binding the specified pointer to the contained APInt.
auto m_Undef()
Match an arbitrary undef constant.
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
Constant * ConstantFoldGetElementPtr(Type *Ty, Constant *C, bool InBounds, std::optional< unsigned > InRangeIndex, ArrayRef< Value * > Idxs)
Constant * ConstantFoldCompareInstruction(CmpInst::Predicate Predicate, Constant *C1, Constant *C2)
gep_type_iterator gep_type_end(const User *GEP)
void deleteConstant(Constant *C)
Constant * ConstantFoldInsertElementInstruction(Constant *Val, Constant *Elt, Constant *Idx)
Attempt to constant fold an insertelement instruction with the specified operands and indices.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Constant * ConstantFoldExtractElementInstruction(Constant *Val, Constant *Idx)
Attempt to constant fold an extractelement instruction with the specified operands and indices.
bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
OutputIt copy(R &&Range, OutputIt Out)
gep_type_iterator gep_type_begin(const User *GEP)
Constant * ConstantFoldCastInstruction(unsigned opcode, Constant *V, Type *DestTy)
Constant * ConstantFoldShuffleVectorInstruction(Constant *V1, Constant *V2, ArrayRef< int > Mask)
Attempt to constant fold a shufflevector instruction with the specified operands and mask.
Constant * ConstantFoldBinaryInstruction(unsigned Opcode, Constant *V1, Constant *V2)
static const fltSemantics & IEEEsingle() LLVM_READNONE
static constexpr roundingMode rmNearestTiesToEven
static const fltSemantics & PPCDoubleDouble() LLVM_READNONE
static const fltSemantics & x87DoubleExtended() LLVM_READNONE
static const fltSemantics & IEEEquad() LLVM_READNONE
static const fltSemantics & IEEEdouble() LLVM_READNONE
static const fltSemantics & IEEEhalf() LLVM_READNONE
static const fltSemantics & BFloat() LLVM_READNONE
Compile-time customization of User operands.