36using namespace PatternMatch;
41 cl::desc(
"Use ConstantInt's native fixed-length vector splat support."));
44 cl::desc(
"Use ConstantFP's native fixed-length vector splat support."));
47 cl::desc(
"Use ConstantInt's native scalable vector splat support."));
50 cl::desc(
"Use ConstantFP's native scalable vector splat support."));
58 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
59 return CFP->isZero() && CFP->isNegative();
63 if (
const auto *SplatCFP = dyn_cast_or_null<ConstantFP>(
getSplatValue()))
64 return SplatCFP->isNegativeZeroValue();
67 if (
getType()->isFPOrFPVectorTy())
78 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
83 if (
const auto *SplatCFP = dyn_cast_or_null<ConstantFP>(
getSplatValue()))
84 return SplatCFP->isZero();
92 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(
this))
96 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
99 return CFP->isExactlyValue(+0.0);
103 return isa<ConstantAggregateZero>(
this) || isa<ConstantPointerNull>(
this) ||
104 isa<ConstantTokenNone>(
this) || isa<ConstantTargetNone>(
this);
109 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(
this))
110 return CI->isMinusOne();
113 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
114 return CFP->getValueAPF().bitcastToAPInt().isAllOnes();
119 return SplatVal->isAllOnesValue();
126 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(
this))
130 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
131 return CFP->getValueAPF().bitcastToAPInt().isOne();
136 return SplatVal->isOneValue();
143 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(
this))
144 return !CI->isOneValue();
147 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
148 return !CFP->getValueAPF().bitcastToAPInt().isOne();
151 if (
auto *VTy = dyn_cast<FixedVectorType>(
getType())) {
152 for (
unsigned I = 0,
E = VTy->getNumElements();
I !=
E; ++
I) {
163 return SplatVal->isNotOneValue();
171 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(
this))
172 return CI->isMinValue(
true);
175 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
176 return CFP->getValueAPF().bitcastToAPInt().isMinSignedValue();
181 return SplatVal->isMinSignedValue();
188 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(
this))
189 return !CI->isMinValue(
true);
192 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
this))
193 return !CFP->getValueAPF().bitcastToAPInt().isMinSignedValue();
196 if (
auto *VTy = dyn_cast<FixedVectorType>(
getType())) {
197 for (
unsigned I = 0,
E = VTy->getNumElements();
I !=
E; ++
I) {
208 return SplatVal->isNotMinSignedValue();
215 if (
auto *CFP = dyn_cast<ConstantFP>(
this))
216 return CFP->getValueAPF().isFiniteNonZero();
218 if (
auto *VTy = dyn_cast<FixedVectorType>(
getType())) {
219 for (
unsigned I = 0,
E = VTy->getNumElements();
I !=
E; ++
I) {
221 if (!CFP || !CFP->getValueAPF().isFiniteNonZero())
228 if (
const auto *SplatCFP = dyn_cast_or_null<ConstantFP>(
getSplatValue()))
229 return SplatCFP->isFiniteNonZeroFP();
236 if (
auto *CFP = dyn_cast<ConstantFP>(
this))
237 return CFP->getValueAPF().isNormal();
239 if (
auto *VTy = dyn_cast<FixedVectorType>(
getType())) {
240 for (
unsigned I = 0,
E = VTy->getNumElements();
I !=
E; ++
I) {
242 if (!CFP || !CFP->getValueAPF().isNormal())
249 if (
const auto *SplatCFP = dyn_cast_or_null<ConstantFP>(
getSplatValue()))
250 return SplatCFP->isNormalFP();
257 if (
auto *CFP = dyn_cast<ConstantFP>(
this))
258 return CFP->getValueAPF().getExactInverse(
nullptr);
260 if (
auto *VTy = dyn_cast<FixedVectorType>(
getType())) {
261 for (
unsigned I = 0,
E = VTy->getNumElements();
I !=
E; ++
I) {
263 if (!CFP || !CFP->getValueAPF().getExactInverse(
nullptr))
270 if (
const auto *SplatCFP = dyn_cast_or_null<ConstantFP>(
getSplatValue()))
271 return SplatCFP->hasExactInverseFP();
278 if (
auto *CFP = dyn_cast<ConstantFP>(
this))
281 if (
auto *VTy = dyn_cast<FixedVectorType>(
getType())) {
282 for (
unsigned I = 0,
E = VTy->getNumElements();
I !=
E; ++
I) {
284 if (!CFP || !CFP->isNaN())
291 if (
const auto *SplatCFP = dyn_cast_or_null<ConstantFP>(
getSplatValue()))
292 return SplatCFP->isNaN();
304 auto *VTy = dyn_cast<VectorType>(
getType());
305 if (!isa<Constant>(
Y) || !VTy || VTy !=
Y->getType())
309 if (!(VTy->getElementType()->isIntegerTy() ||
310 VTy->getElementType()->isFloatingPointTy()))
319 return isa<UndefValue>(CmpEq) ||
match(CmpEq,
m_One());
325 if (
auto *VTy = dyn_cast<VectorType>(
C->getType())) {
328 if (isa<ConstantAggregateZero>(
C))
330 if (isa<ScalableVectorType>(
C->getType()))
333 for (
unsigned i = 0, e = cast<FixedVectorType>(VTy)->getNumElements();
335 if (
Constant *Elem =
C->getAggregateElement(i))
346 this, [&](
const auto *
C) {
return isa<UndefValue>(
C); });
351 this, [&](
const auto *
C) {
return isa<PoisonValue>(
C); });
356 return isa<UndefValue>(
C) && !isa<PoisonValue>(
C);
361 if (
auto *VTy = dyn_cast<FixedVectorType>(
getType())) {
362 for (
unsigned i = 0, e = VTy->getNumElements(); i != e; ++i)
373 return ConstantInt::get(Ty, 0);
407 if (
PointerType *PTy = dyn_cast<PointerType>(ScalarTy))
411 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
434 "Must be an aggregate/vector constant");
436 if (
const auto *
CC = dyn_cast<ConstantAggregate>(
this))
437 return Elt <
CC->getNumOperands() ?
CC->getOperand(Elt) :
nullptr;
439 if (
const auto *CAZ = dyn_cast<ConstantAggregateZero>(
this))
440 return Elt < CAZ->getElementCount().getKnownMinValue()
441 ? CAZ->getElementValue(Elt)
445 if (isa<ScalableVectorType>(
getType()))
448 if (
const auto *PV = dyn_cast<PoisonValue>(
this))
449 return Elt < PV->getNumElements() ? PV->getElementValue(Elt) :
nullptr;
451 if (
const auto *UV = dyn_cast<UndefValue>(
this))
452 return Elt < UV->getNumElements() ? UV->getElementValue(Elt) :
nullptr;
454 if (
const auto *CDS = dyn_cast<ConstantDataSequential>(
this))
455 return Elt < CDS->getNumElements() ? CDS->getElementAsConstant(Elt)
462 assert(isa<IntegerType>(Elt->
getType()) &&
"Index must be an integer");
463 if (
ConstantInt *CI = dyn_cast<ConstantInt>(Elt)) {
465 if (CI->getValue().getActiveBits() > 64)
478#define HANDLE_CONSTANT(Name) \
479 case Value::Name##Val: \
480 cast<Name>(this)->destroyConstantImpl(); \
482#include "llvm/IR/Value.def"
495 if (!isa<Constant>(V)) {
496 dbgs() <<
"While deleting: " << *
this
497 <<
"\n\nUse still stuck around after Def is destroyed: " << *V
501 assert(isa<Constant>(V) &&
"References remain to Constant being destroyed");
502 cast<Constant>(V)->destroyConstant();
513 switch (
C->getValueID()) {
514 case Constant::ConstantIntVal:
517 case Constant::ConstantFPVal:
520 case Constant::ConstantAggregateZeroVal:
523 case Constant::ConstantArrayVal:
526 case Constant::ConstantStructVal:
529 case Constant::ConstantVectorVal:
532 case Constant::ConstantPointerNullVal:
535 case Constant::ConstantDataArrayVal:
538 case Constant::ConstantDataVectorVal:
541 case Constant::ConstantTokenNoneVal:
544 case Constant::BlockAddressVal:
547 case Constant::DSOLocalEquivalentVal:
550 case Constant::NoCFIValueVal:
553 case Constant::UndefValueVal:
556 case Constant::PoisonValueVal:
559 case Constant::ConstantExprVal:
560 if (isa<CastConstantExpr>(
C))
562 else if (isa<BinaryConstantExpr>(
C))
564 else if (isa<ExtractElementConstantExpr>(
C))
566 else if (isa<InsertElementConstantExpr>(
C))
568 else if (isa<ShuffleVectorConstantExpr>(
C))
570 else if (isa<GetElementPtrConstantExpr>(
C))
572 else if (isa<CompareConstantExpr>(
C))
591 while (!WorkList.
empty()) {
593 if (
const auto *GV = dyn_cast<GlobalValue>(
WorkItem))
597 const Constant *ConstOp = dyn_cast<Constant>(
Op);
600 if (Visited.
insert(ConstOp).second)
608 auto DLLImportPredicate = [](
const GlobalValue *GV) {
609 return GV->isThreadLocal();
615 auto DLLImportPredicate = [](
const GlobalValue *GV) {
616 return GV->hasDLLImportStorageClass();
623 const Constant *UC = dyn_cast<Constant>(U);
624 if (!UC || isa<GlobalValue>(UC))
634 return getRelocationInfo() == GlobalRelocation;
638 return getRelocationInfo() != NoRelocation;
641Constant::PossibleRelocationsTy Constant::getRelocationInfo()
const {
642 if (isa<GlobalValue>(
this))
643 return GlobalRelocation;
645 if (
const BlockAddress *BA = dyn_cast<BlockAddress>(
this))
646 return BA->getFunction()->getRelocationInfo();
648 if (
const ConstantExpr *CE = dyn_cast<ConstantExpr>(
this)) {
649 if (CE->getOpcode() == Instruction::Sub) {
652 if (LHS && RHS &&
LHS->getOpcode() == Instruction::PtrToInt &&
653 RHS->getOpcode() == Instruction::PtrToInt) {
661 if (isa<BlockAddress>(LHSOp0) && isa<BlockAddress>(RHSOp0) &&
670 if (
auto *LHSGV = dyn_cast<GlobalValue>(LHS)) {
671 if (LHSGV->isDSOLocal() && RHSGV->isDSOLocal())
672 return LocalRelocation;
673 }
else if (isa<DSOLocalEquivalent>(LHS)) {
674 if (RHSGV->isDSOLocal())
675 return LocalRelocation;
682 PossibleRelocationsTy
Result = NoRelocation;
685 std::max(cast<Constant>(
getOperand(i))->getRelocationInfo(), Result);
694 if (isa<GlobalValue>(
C))
return false;
699 if (!
User)
return false;
712 if (RemoveDeadUsers) {
716 const_cast<Constant *
>(
C)->destroyConstant();
742 if (LastNonDeadUser ==
E)
745 I = std::next(LastNonDeadUser);
753bool Constant::hasNLiveUses(
unsigned N)
const {
754 unsigned NumUses = 0;
768 assert(
C && Replacement &&
"Expected non-nullptr constant arguments");
769 Type *Ty =
C->getType();
771 assert(Ty == Replacement->
getType() &&
"Expected matching types");
776 auto *VTy = dyn_cast<FixedVectorType>(Ty);
780 unsigned NumElts = VTy->getNumElements();
782 for (
unsigned i = 0; i != NumElts; ++i) {
783 Constant *EltC =
C->getAggregateElement(i);
785 "Expected matching types");
786 NewC[i] = EltC &&
match(EltC,
m_Undef()) ? Replacement : EltC;
792 assert(
C &&
Other &&
"Expected non-nullptr constant arguments");
796 Type *Ty =
C->getType();
800 auto *VTy = dyn_cast<FixedVectorType>(Ty);
804 Type *EltTy = VTy->getElementType();
805 unsigned NumElts = VTy->getNumElements();
807 cast<FixedVectorType>(
Other->getType())->getNumElements() == NumElts &&
810 bool FoundExtraUndef =
false;
812 for (
unsigned I = 0;
I != NumElts; ++
I) {
813 NewC[
I] =
C->getAggregateElement(
I);
815 assert(NewC[
I] && OtherEltC &&
"Unknown vector element");
818 FoundExtraUndef =
true;
827 if (isa<ConstantData>(
this))
829 if (isa<ConstantAggregate>(
this) || isa<ConstantExpr>(
this)) {
842ConstantInt::ConstantInt(
Type *Ty,
const APInt &V)
846 "Invalid constant for type");
870 if (
auto *VTy = dyn_cast<VectorType>(Ty))
878 if (
auto *VTy = dyn_cast<VectorType>(Ty))
891 std::unique_ptr<ConstantInt> &Slot =
908 std::unique_ptr<ConstantInt> &Slot =
919 assert(Slot->getType() == VTy);
928 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
941 "ConstantInt type doesn't match the type implied by its value!");
944 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
955void ConstantInt::destroyConstantImpl() {
973 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
982 "ConstantFP type doesn't match the type implied by its value!");
985 if (
auto *VTy = dyn_cast<VectorType>(Ty))
998 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
1009 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
1020 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
1031 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
1042 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
1053 std::unique_ptr<ConstantFP> &Slot = pImpl->
FPConstants[V];
1067 std::unique_ptr<ConstantFP> &Slot =
1078 assert(Slot->getType() == VTy);
1087 if (
VectorType *VTy = dyn_cast<VectorType>(Ty))
1096 "FP type Mismatch");
1104void ConstantFP::destroyConstantImpl() {
1113 if (
auto *AT = dyn_cast<ArrayType>(
getType()))
1136 if (
auto *AT = dyn_cast<ArrayType>(Ty))
1138 if (
auto *VT = dyn_cast<VectorType>(Ty))
1139 return VT->getElementCount();
1171 if (
auto *AT = dyn_cast<ArrayType>(Ty))
1172 return AT->getNumElements();
1173 if (
auto *VT = dyn_cast<VectorType>(Ty))
1174 return cast<FixedVectorType>(VT)->getNumElements();
1208template <
typename ItTy,
typename EltTy>
1210 for (; Start !=
End; ++Start)
1216template <
typename SequentialTy,
typename ElementTy>
1218 assert(!V.empty() &&
"Cannot get empty int sequence.");
1222 if (
auto *CI = dyn_cast<ConstantInt>(
C))
1226 return SequentialTy::get(V[0]->getContext(), Elts);
1229template <
typename SequentialTy,
typename ElementTy>
1231 assert(!V.empty() &&
"Cannot get empty FP sequence.");
1235 if (
auto *CFP = dyn_cast<ConstantFP>(
C))
1236 Elts.
push_back(CFP->getValueAPF().bitcastToAPInt().getLimitedValue());
1239 return SequentialTy::getFP(V[0]->
getType(), Elts);
1242template <
typename SequenceTy>
1249 if (CI->getType()->isIntegerTy(8))
1250 return getIntSequenceIfElementsMatch<SequenceTy, uint8_t>(V);
1251 else if (CI->getType()->isIntegerTy(16))
1252 return getIntSequenceIfElementsMatch<SequenceTy, uint16_t>(V);
1253 else if (CI->getType()->isIntegerTy(32))
1254 return getIntSequenceIfElementsMatch<SequenceTy, uint32_t>(V);
1255 else if (CI->getType()->isIntegerTy(64))
1256 return getIntSequenceIfElementsMatch<SequenceTy, uint64_t>(V);
1257 }
else if (
ConstantFP *CFP = dyn_cast<ConstantFP>(
C)) {
1258 if (CFP->getType()->isHalfTy() || CFP->getType()->isBFloatTy())
1259 return getFPSequenceIfElementsMatch<SequenceTy, uint16_t>(V);
1260 else if (CFP->getType()->isFloatTy())
1261 return getFPSequenceIfElementsMatch<SequenceTy, uint32_t>(V);
1262 else if (CFP->getType()->isDoubleTy())
1263 return getFPSequenceIfElementsMatch<SequenceTy, uint64_t>(V);
1276 if (
auto *ST = dyn_cast<StructType>(
T)) {
1279 for (
unsigned I = 0,
E = V.size();
I !=
E; ++
I)
1281 "Initializer for struct element doesn't match!");
1287 assert(V.size() ==
T->getNumElements() &&
1288 "Invalid initializer for constant array");
1304 "Wrong type in array element initializer");
1324 return getSequenceIfElementsMatch<ConstantDataArray>(
C, V);
1333 unsigned VecSize = V.size();
1335 for (
unsigned i = 0; i != VecSize; ++i)
1336 EltTypes[i] = V[i]->
getType();
1345 "ConstantStruct::getTypeForElements cannot be called on empty list");
1351 assert((
T->isOpaque() || V.size() ==
T->getNumElements()) &&
1352 "Invalid initializer for constant struct");
1357 assert((ST->isOpaque() || ST->getNumElements() == V.size()) &&
1358 "Incorrect # elements specified to ConstantStruct::get");
1363 bool isPoison =
false;
1366 isUndef = isa<UndefValue>(V[0]);
1367 isPoison = isa<PoisonValue>(V[0]);
1368 isZero = V[0]->isNullValue();
1372 if (!
C->isNullValue())
1374 if (!isa<PoisonValue>(
C))
1376 if (isa<PoisonValue>(
C) || !isa<UndefValue>(
C))
1388 return ST->getContext().pImpl->StructConstants.getOrCreate(ST, V);
1393 assert(V.size() == cast<FixedVectorType>(
T)->getNumElements() &&
1394 "Invalid initializer for constant vector");
1406 assert(!V.empty() &&
"Vectors can't be empty");
1412 bool isZero =
C->isNullValue();
1414 bool isPoison = isa<PoisonValue>(
C);
1419 for (
unsigned i = 1, e = V.size(); i != e; ++i)
1421 isZero =
isUndef = isPoison = isSplatFP = isSplatInt =
false;
1433 return ConstantFP::get(
C->getContext(),
T->getElementCount(),
1434 cast<ConstantFP>(
C)->getValue());
1436 return ConstantInt::get(
C->getContext(),
T->getElementCount(),
1437 cast<ConstantInt>(
C)->getValue());
1442 return getSequenceIfElementsMatch<ConstantDataVector>(
C, V);
1450 if (!EC.isScalable()) {
1452 if (!V->isNullValue()) {
1454 return ConstantInt::get(V->getContext(), EC,
1455 cast<ConstantInt>(V)->getValue());
1457 return ConstantFP::get(V->getContext(), EC,
1458 cast<ConstantFP>(V)->getValue());
1463 if ((isa<ConstantFP>(V) || isa<ConstantInt>(V)) &&
1472 if (!V->isNullValue()) {
1474 return ConstantInt::get(V->getContext(), EC,
1475 cast<ConstantInt>(V)->getValue());
1477 return ConstantFP::get(V->getContext(), EC,
1478 cast<ConstantFP>(V)->getValue());
1483 if (V->isNullValue())
1485 else if (isa<UndefValue>(V))
1507void ConstantTokenNone::destroyConstantImpl() {
1523 return cast<CompareConstantExpr>(
this)->predicate;
1527 return cast<ShuffleVectorConstantExpr>(
this)->ShuffleMask;
1531 return cast<ShuffleVectorConstantExpr>(
this)->ShuffleMaskForBitcode;
1535 bool OnlyIfReduced,
Type *SrcTy)
const {
1542 Type *OnlyIfReducedTy = OnlyIfReduced ? Ty :
nullptr;
1544 case Instruction::Trunc:
1545 case Instruction::ZExt:
1546 case Instruction::SExt:
1547 case Instruction::FPTrunc:
1548 case Instruction::FPExt:
1549 case Instruction::UIToFP:
1550 case Instruction::SIToFP:
1551 case Instruction::FPToUI:
1552 case Instruction::FPToSI:
1553 case Instruction::PtrToInt:
1554 case Instruction::IntToPtr:
1555 case Instruction::BitCast:
1556 case Instruction::AddrSpaceCast:
1558 case Instruction::InsertElement:
1561 case Instruction::ExtractElement:
1563 case Instruction::ShuffleVector:
1566 case Instruction::GetElementPtr: {
1567 auto *GEPO = cast<GEPOperator>(
this);
1570 SrcTy ? SrcTy : GEPO->getSourceElementType(), Ops[0], Ops.
slice(1),
1571 GEPO->isInBounds(), GEPO->getInRangeIndex(), OnlyIfReducedTy);
1573 case Instruction::ICmp:
1574 case Instruction::FCmp:
1591 return Val == 0 || Val == 1;
1598 return Val == 0 || Val == 1 || Val == -1;
1599 return isIntN(NumBits, Val);
1665 "Cannot create an aggregate zero of non-aggregate type!");
1667 std::unique_ptr<ConstantAggregateZero> &Entry =
1676void ConstantAggregateZero::destroyConstantImpl() {
1681void ConstantArray::destroyConstantImpl() {
1690void ConstantStruct::destroyConstantImpl() {
1695void ConstantVector::destroyConstantImpl() {
1700 assert(this->
getType()->isVectorTy() &&
"Only valid for vectors!");
1701 if (isa<ConstantAggregateZero>(
this))
1704 return CV->getSplatValue();
1706 return CV->getSplatValue(AllowUndefs);
1710 const auto *Shuf = dyn_cast<ConstantExpr>(
this);
1711 if (Shuf && Shuf->getOpcode() == Instruction::ShuffleVector &&
1712 isa<UndefValue>(Shuf->getOperand(1))) {
1714 const auto *IElt = dyn_cast<ConstantExpr>(Shuf->getOperand(0));
1715 if (IElt && IElt->getOpcode() == Instruction::InsertElement &&
1716 isa<UndefValue>(IElt->getOperand(0))) {
1745 if (isa<UndefValue>(OpC))
1749 if (isa<UndefValue>(Elt))
1759 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(
this))
1760 return CI->getValue();
1762 if (isa<ConstantExpr>(
this))
1763 return cast<ConstantInt>(this->
getSplatValue())->getValue();
1768 assert(
C && isa<ConstantInt>(
C) &&
"Not a vector of numbers!");
1769 return cast<ConstantInt>(
C)->getValue();
1776 std::unique_ptr<ConstantPointerNull> &Entry =
1785void ConstantPointerNull::destroyConstantImpl() {
1794 "Target extension type not allowed to have a zeroinitializer");
1795 std::unique_ptr<ConstantTargetNone> &Entry =
1804void ConstantTargetNone::destroyConstantImpl() {
1817void UndefValue::destroyConstantImpl() {
1836void PoisonValue::destroyConstantImpl() {
1848 F->getContext().pImpl->BlockAddresses[std::make_pair(
F, BB)];
1858 Value::BlockAddressVal, &
Op<0>(), 2) {
1861 BB->AdjustBlockAddressRefCount(1);
1869 assert(
F &&
"Block must have a parent");
1871 F->getContext().pImpl->BlockAddresses.lookup(std::make_pair(
F, BB));
1872 assert(BA &&
"Refcount and block address map disagree!");
1877void BlockAddress::destroyConstantImpl() {
1892 assert(
From == NewBB &&
"From does not match any operand");
1893 NewBB = cast<BasicBlock>(To);
1925 "DSOLocalFunction does not match the expected global value");
1929DSOLocalEquivalent::DSOLocalEquivalent(
GlobalValue *GV)
1935void DSOLocalEquivalent::destroyConstantImpl() {
1942 assert(isa<Constant>(To) &&
"Can only replace the operands with a constant");
1945 if (
const auto *ToObj = dyn_cast<GlobalValue>(To)) {
1982 assert(
NC->getGlobalValue() == GV &&
1983 "NoCFIValue does not match the expected global value");
1993void NoCFIValue::destroyConstantImpl() {
2002 assert(GV &&
"Can only replace the operands with a global value");
2024 bool OnlyIfReduced =
false) {
2042 bool OnlyIfReduced) {
2046 "Cast opcode not supported as constant expression");
2047 assert(
C && Ty &&
"Null arguments to getCast");
2053 case Instruction::Trunc:
2055 case Instruction::PtrToInt:
2057 case Instruction::IntToPtr:
2059 case Instruction::BitCast:
2061 case Instruction::AddrSpaceCast:
2100 bool fromVec = isa<VectorType>(
C->getType());
2101 bool toVec = isa<VectorType>(Ty);
2103 assert((fromVec == toVec) &&
"Cannot convert from scalar to/from vector");
2104 assert(
C->getType()->isIntOrIntVectorTy() &&
"Trunc operand must be integer");
2107 "SrcTy must be larger than DestTy for Trunc!");
2113 bool OnlyIfReduced) {
2114 assert(
C->getType()->isPtrOrPtrVectorTy() &&
2115 "PtrToInt source must be pointer or pointer vector");
2117 "PtrToInt destination must be integer or integer vector");
2118 assert(isa<VectorType>(
C->getType()) == isa<VectorType>(DstTy));
2119 if (isa<VectorType>(
C->getType()))
2120 assert(cast<VectorType>(
C->getType())->getElementCount() ==
2121 cast<VectorType>(DstTy)->getElementCount() &&
2122 "Invalid cast between a different number of vector elements");
2123 return getFoldedCast(Instruction::PtrToInt,
C, DstTy, OnlyIfReduced);
2127 bool OnlyIfReduced) {
2128 assert(
C->getType()->isIntOrIntVectorTy() &&
2129 "IntToPtr source must be integer or integer vector");
2131 "IntToPtr destination must be a pointer or pointer vector");
2132 assert(isa<VectorType>(
C->getType()) == isa<VectorType>(DstTy));
2133 if (isa<VectorType>(
C->getType()))
2134 assert(cast<VectorType>(
C->getType())->getElementCount() ==
2135 cast<VectorType>(DstTy)->getElementCount() &&
2136 "Invalid cast between a different number of vector elements");
2137 return getFoldedCast(Instruction::IntToPtr,
C, DstTy, OnlyIfReduced);
2141 bool OnlyIfReduced) {
2143 "Invalid constantexpr bitcast!");
2147 if (
C->getType() == DstTy)
return C;
2149 return getFoldedCast(Instruction::BitCast,
C, DstTy, OnlyIfReduced);
2153 bool OnlyIfReduced) {
2155 "Invalid constantexpr addrspacecast!");
2156 return getFoldedCast(Instruction::AddrSpaceCast,
C, DstTy, OnlyIfReduced);
2160 unsigned Flags,
Type *OnlyIfReducedTy) {
2163 "Invalid opcode in binary constant expression");
2165 "Binop not supported as constant expression");
2167 "Operand types in binary constant expression should match");
2171 case Instruction::Add:
2172 case Instruction::Sub:
2173 case Instruction::Mul:
2175 "Tried to create an integer operation on a non-integer type!");
2177 case Instruction::And:
2178 case Instruction::Or:
2179 case Instruction::Xor:
2181 "Tried to create a logical operation on a non-integral type!");
2183 case Instruction::Shl:
2184 case Instruction::LShr:
2185 case Instruction::AShr:
2187 "Tried to create a shift operation on a non-integer type!");
2197 if (OnlyIfReducedTy == C1->
getType())
2209 case Instruction::UDiv:
2210 case Instruction::SDiv:
2211 case Instruction::URem:
2212 case Instruction::SRem:
2213 case Instruction::FAdd:
2214 case Instruction::FSub:
2215 case Instruction::FMul:
2216 case Instruction::FDiv:
2217 case Instruction::FRem:
2218 case Instruction::And:
2219 case Instruction::Or:
2220 case Instruction::LShr:
2221 case Instruction::AShr:
2223 case Instruction::Add:
2224 case Instruction::Sub:
2225 case Instruction::Mul:
2226 case Instruction::Shl:
2227 case Instruction::Xor:
2236 case Instruction::UDiv:
2237 case Instruction::SDiv:
2238 case Instruction::URem:
2239 case Instruction::SRem:
2240 case Instruction::FAdd:
2241 case Instruction::FSub:
2242 case Instruction::FMul:
2243 case Instruction::FDiv:
2244 case Instruction::FRem:
2245 case Instruction::And:
2246 case Instruction::Or:
2247 case Instruction::LShr:
2248 case Instruction::AShr:
2250 case Instruction::Add:
2251 case Instruction::Sub:
2252 case Instruction::Mul:
2253 case Instruction::Shl:
2254 case Instruction::Xor:
2263 case Instruction::ZExt:
2264 case Instruction::SExt:
2265 case Instruction::FPTrunc:
2266 case Instruction::FPExt:
2267 case Instruction::UIToFP:
2268 case Instruction::SIToFP:
2269 case Instruction::FPToUI:
2270 case Instruction::FPToSI:
2272 case Instruction::Trunc:
2273 case Instruction::PtrToInt:
2274 case Instruction::IntToPtr:
2275 case Instruction::BitCast:
2276 case Instruction::AddrSpaceCast:
2285 case Instruction::ZExt:
2286 case Instruction::SExt:
2287 case Instruction::FPTrunc:
2288 case Instruction::FPExt:
2289 case Instruction::UIToFP:
2290 case Instruction::SIToFP:
2291 case Instruction::FPToUI:
2292 case Instruction::FPToSI:
2294 case Instruction::Trunc:
2295 case Instruction::PtrToInt:
2296 case Instruction::IntToPtr:
2297 case Instruction::BitCast:
2298 case Instruction::AddrSpaceCast:
2322 Constant *Indices[2] = { Zero, One };
2329 Constant *C2,
bool OnlyIfReduced) {
2332 switch (Predicate) {
2340 return getFCmp(Predicate, C1, C2, OnlyIfReduced);
2346 return getICmp(Predicate, C1, C2, OnlyIfReduced);
2352 std::optional<unsigned> InRangeIndex,
2353 Type *OnlyIfReducedTy) {
2354 assert(Ty &&
"Must specify element type");
2362 "GEP indices invalid!");;
2366 if (OnlyIfReducedTy == ReqTy)
2370 if (
VectorType *VecTy = dyn_cast<VectorType>(ReqTy))
2371 EltCount = VecTy->getElementCount();
2374 std::vector<Constant*> ArgVec;
2375 ArgVec.reserve(1 + Idxs.
size());
2376 ArgVec.push_back(
C);
2378 for (; GTI != GTE; ++GTI) {
2379 auto *
Idx = cast<Constant>(GTI.getOperand());
2381 (!isa<VectorType>(
Idx->getType()) ||
2382 cast<VectorType>(
Idx->getType())->getElementCount() == EltCount) &&
2383 "getelementptr index type missmatch");
2385 if (GTI.isStruct() &&
Idx->getType()->isVectorTy()) {
2386 Idx =
Idx->getSplatValue();
2387 }
else if (GTI.isSequential() && EltCount.isNonZero() &&
2388 !
Idx->getType()->isVectorTy()) {
2391 ArgVec.push_back(
Idx);
2394 unsigned SubClassOptionalData = InBounds ? GEPOperator::IsInBounds : 0;
2395 if (InRangeIndex && *InRangeIndex < 63)
2396 SubClassOptionalData |= (*InRangeIndex + 1) << 1;
2398 SubClassOptionalData, std::nullopt, Ty);
2405 Constant *RHS,
bool OnlyIfReduced) {
2430 Constant *RHS,
bool OnlyIfReduced) {
2455 Type *OnlyIfReducedTy) {
2457 "Tried to create extractelement operation on non-vector type!");
2459 "Extractelement index must be an integer type!");
2464 Type *ReqTy = cast<VectorType>(Val->
getType())->getElementType();
2465 if (OnlyIfReducedTy == ReqTy)
2479 "Tried to create insertelement operation on non-vector type!");
2481 "Insertelement types must match!");
2483 "Insertelement index must be i32 type!");
2488 if (OnlyIfReducedTy == Val->
getType())
2501 Type *OnlyIfReducedTy) {
2503 "Invalid shuffle vector constant expr operands!");
2508 unsigned NElts = Mask.size();
2509 auto V1VTy = cast<VectorType>(V1->
getType());
2510 Type *EltTy = V1VTy->getElementType();
2511 bool TypeIsScalable = isa<ScalableVectorType>(V1VTy);
2514 if (OnlyIfReducedTy == ShufTy)
2526 assert(
C->getType()->isIntOrIntVectorTy() &&
2527 "Cannot NEG a nonintegral value!");
2528 return getSub(ConstantInt::get(
C->getType(), 0),
C, HasNUW, HasNSW);
2532 assert(
C->getType()->isIntOrIntVectorTy() &&
2533 "Cannot NOT a nonintegral value!");
2538 bool HasNUW,
bool HasNSW) {
2541 return get(Instruction::Add, C1, C2, Flags);
2545 bool HasNUW,
bool HasNSW) {
2548 return get(Instruction::Sub, C1, C2, Flags);
2552 bool HasNUW,
bool HasNSW) {
2555 return get(Instruction::Mul, C1, C2, Flags);
2559 return get(Instruction::Xor, C1, C2);
2563 bool HasNUW,
bool HasNSW) {
2566 return get(Instruction::Shl, C1, C2, Flags);
2570 Type *Ty =
C->getType();
2573 return ConstantInt::get(Ty, IVal->
logBase2());
2576 auto *VecTy = dyn_cast<FixedVectorType>(Ty);
2581 for (
unsigned I = 0,
E = VecTy->getNumElements();
I !=
E; ++
I) {
2586 if (isa<UndefValue>(Elt)) {
2599 bool AllowRHSConstant,
bool NSZ) {
2605 case Instruction::Add:
2606 case Instruction::Or:
2607 case Instruction::Xor:
2609 case Instruction::Mul:
2610 return ConstantInt::get(Ty, 1);
2611 case Instruction::And:
2613 case Instruction::FAdd:
2615 case Instruction::FMul:
2616 return ConstantFP::get(Ty, 1.0);
2623 if (!AllowRHSConstant)
2627 case Instruction::Sub:
2628 case Instruction::Shl:
2629 case Instruction::LShr:
2630 case Instruction::AShr:
2631 case Instruction::FSub:
2633 case Instruction::SDiv:
2634 case Instruction::UDiv:
2635 return ConstantInt::get(Ty, 1);
2636 case Instruction::FDiv:
2637 return ConstantFP::get(Ty, 1.0);
2645 case Intrinsic::umax:
2647 case Intrinsic::umin:
2649 case Intrinsic::smax:
2652 case Intrinsic::smin:
2661 bool AllowRHSConstant,
bool NSZ) {
2662 if (
I->isBinaryOp())
2675 case Instruction::Or:
2678 case Instruction::And:
2679 case Instruction::Mul:
2685void ConstantExpr::destroyConstantImpl() {
2693GetElementPtrConstantExpr::GetElementPtrConstantExpr(
2697 (IdxList.
size() + 1),
2698 IdxList.
size() + 1),
2699 SrcElementTy(SrcElementTy),
2703 for (
unsigned i = 0,
E = IdxList.
size(); i !=
E; ++i)
2704 OperandList[i+1] = IdxList[i];
2708 return SrcElementTy;
2712 return ResElementTy;
2720 return ATy->getElementType();
2721 return cast<VectorType>(
getType())->getElementType();
2731 if (
auto *
IT = dyn_cast<IntegerType>(Ty)) {
2732 switch (
IT->getBitWidth()) {
2746 return AT->getNumElements();
2747 return cast<FixedVectorType>(
getType())->getNumElements();
2756const char *ConstantDataSequential::getElementPointer(
unsigned Elt)
const {
2776 if (
ArrayType *ATy = dyn_cast<ArrayType>(Ty))
2796 std::unique_ptr<ConstantDataSequential> *Entry = &Slot.second;
2797 for (; *Entry; Entry = &(*Entry)->Next)
2798 if ((*Entry)->getType() == Ty)
2799 return Entry->get();
2803 if (isa<ArrayType>(Ty)) {
2806 return Entry->get();
2809 assert(isa<VectorType>(Ty));
2812 return Entry->get();
2815void ConstantDataSequential::destroyConstantImpl() {
2822 assert(Slot != CDSConstants.
end() &&
"CDS not found in uniquing table");
2824 std::unique_ptr<ConstantDataSequential> *Entry = &Slot->getValue();
2827 if (!(*Entry)->Next) {
2830 assert(Entry->get() ==
this &&
"Hash mismatch in ConstantDataSequential");
2838 std::unique_ptr<ConstantDataSequential> &
Node = *Entry;
2839 assert(
Node &&
"Didn't find entry in its uniquing hash table!");
2841 if (
Node.get() ==
this) {
2846 Entry = &
Node->Next;
2857 assert((ElementType->isHalfTy() || ElementType->isBFloatTy()) &&
2858 "Element type is not a 16-bit float type");
2860 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2864 assert(ElementType->isFloatTy() &&
"Element type is not a 32-bit float type");
2866 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2870 assert(ElementType->isDoubleTy() &&
2871 "Element type is not a 64-bit float type");
2873 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2880 const uint8_t *
Data = Str.bytes_begin();
2885 ElementVals.
append(Str.begin(), Str.end());
2895 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2900 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2905 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2910 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2915 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2920 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2932 assert((ElementType->isHalfTy() || ElementType->isBFloatTy()) &&
2933 "Element type is not a 16-bit float type");
2935 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2940 assert(ElementType->isFloatTy() &&
"Element type is not a 32-bit float type");
2942 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2947 assert(ElementType->isDoubleTy() &&
2948 "Element type is not a 64-bit float type");
2950 const char *
Data =
reinterpret_cast<const char *
>(Elts.
data());
2956 "Element type not compatible with ConstantData");
2958 if (CI->getType()->isIntegerTy(8)) {
2960 return get(V->getContext(), Elts);
2962 if (CI->getType()->isIntegerTy(16)) {
2964 return get(V->getContext(), Elts);
2966 if (CI->getType()->isIntegerTy(32)) {
2968 return get(V->getContext(), Elts);
2970 assert(CI->getType()->isIntegerTy(64) &&
"Unsupported ConstantData type");
2972 return get(V->getContext(), Elts);
2975 if (
ConstantFP *CFP = dyn_cast<ConstantFP>(V)) {
2976 if (CFP->getType()->isHalfTy()) {
2978 NumElts, CFP->getValueAPF().bitcastToAPInt().getLimitedValue());
2979 return getFP(V->getType(), Elts);
2981 if (CFP->getType()->isBFloatTy()) {
2983 NumElts, CFP->getValueAPF().bitcastToAPInt().getLimitedValue());
2984 return getFP(V->getType(), Elts);
2986 if (CFP->getType()->isFloatTy()) {
2988 NumElts, CFP->getValueAPF().bitcastToAPInt().getLimitedValue());
2989 return getFP(V->getType(), Elts);
2991 if (CFP->getType()->isDoubleTy()) {
2993 NumElts, CFP->getValueAPF().bitcastToAPInt().getLimitedValue());
2994 return getFP(V->getType(), Elts);
3003 "Accessor can only be used when element is an integer");
3004 const char *EltPtr = getElementPointer(Elt);
3011 return *
reinterpret_cast<const uint8_t *
>(EltPtr);
3013 return *
reinterpret_cast<const uint16_t *
>(EltPtr);
3015 return *
reinterpret_cast<const uint32_t *
>(EltPtr);
3017 return *
reinterpret_cast<const uint64_t *
>(EltPtr);
3023 "Accessor can only be used when element is an integer");
3024 const char *EltPtr = getElementPointer(Elt);
3031 auto EltVal = *
reinterpret_cast<const uint8_t *
>(EltPtr);
3032 return APInt(8, EltVal);
3035 auto EltVal = *
reinterpret_cast<const uint16_t *
>(EltPtr);
3036 return APInt(16, EltVal);
3039 auto EltVal = *
reinterpret_cast<const uint32_t *
>(EltPtr);
3040 return APInt(32, EltVal);
3043 auto EltVal = *
reinterpret_cast<const uint64_t *
>(EltPtr);
3044 return APInt(64, EltVal);
3050 const char *EltPtr = getElementPointer(Elt);
3054 llvm_unreachable(
"Accessor can only be used when element is float/double!");
3056 auto EltVal = *
reinterpret_cast<const uint16_t *
>(EltPtr);
3060 auto EltVal = *
reinterpret_cast<const uint16_t *
>(EltPtr);
3064 auto EltVal = *
reinterpret_cast<const uint32_t *
>(EltPtr);
3068 auto EltVal = *
reinterpret_cast<const uint64_t *
>(EltPtr);
3076 "Accessor can only be used when element is a 'float'");
3077 return *
reinterpret_cast<const float *
>(getElementPointer(Elt));
3082 "Accessor can only be used when element is a 'float'");
3083 return *
reinterpret_cast<const double *
>(getElementPointer(Elt));
3105 if (Str.back() != 0)
return false;
3108 return !Str.drop_back().contains(0);
3111bool ConstantDataVector::isSplatData()
const {
3126 IsSplat = isSplatData();
3151 Value *Replacement =
nullptr;
3155#define HANDLE_CONSTANT(Name) \
3156 case Value::Name##Val: \
3157 Replacement = cast<Name>(this)->handleOperandChangeImpl(From, To); \
3159#include "llvm/IR/Value.def"
3168 assert(Replacement !=
this &&
"I didn't contain From!");
3178 assert(isa<Constant>(To) &&
"Cannot make Constant refer to non-constant!");
3179 Constant *ToC = cast<Constant>(To);
3186 unsigned NumUpdated = 0;
3189 bool AllSame =
true;
3191 unsigned OperandNo = 0;
3193 Constant *Val = cast<Constant>(O->get());
3195 OperandNo = (O - OperandList);
3200 AllSame &= Val == ToC;
3206 if (AllSame && isa<UndefValue>(ToC))
3215 Values,
this,
From, ToC, NumUpdated, OperandNo);
3219 assert(isa<Constant>(To) &&
"Cannot make Constant refer to non-constant!");
3220 Constant *ToC = cast<Constant>(To);
3229 unsigned NumUpdated = 0;
3230 bool AllSame =
true;
3231 unsigned OperandNo = 0;
3233 Constant *Val = cast<Constant>(
O->get());
3235 OperandNo = (
O - OperandList);
3240 AllSame &= Val == ToC;
3246 if (AllSame && isa<UndefValue>(ToC))
3251 Values,
this,
From, ToC, NumUpdated, OperandNo);
3255 assert(isa<Constant>(To) &&
"Cannot make Constant refer to non-constant!");
3256 Constant *ToC = cast<Constant>(To);
3260 unsigned NumUpdated = 0;
3261 unsigned OperandNo = 0;
3277 Values,
this,
From, ToC, NumUpdated, OperandNo);
3281 assert(isa<Constant>(ToV) &&
"Cannot make Constant refer to non-constant!");
3282 Constant *To = cast<Constant>(ToV);
3285 unsigned NumUpdated = 0;
3286 unsigned OperandNo = 0;
3296 assert(NumUpdated &&
"I didn't contain From!");
3303 NewOps,
this,
From, To, NumUpdated, OperandNo);
3311 case Instruction::Trunc:
3312 case Instruction::ZExt:
3313 case Instruction::SExt:
3314 case Instruction::FPTrunc:
3315 case Instruction::FPExt:
3316 case Instruction::UIToFP:
3317 case Instruction::SIToFP:
3318 case Instruction::FPToUI:
3319 case Instruction::FPToSI:
3320 case Instruction::PtrToInt:
3321 case Instruction::IntToPtr:
3322 case Instruction::BitCast:
3323 case Instruction::AddrSpaceCast:
3326 case Instruction::InsertElement:
3328 case Instruction::ExtractElement:
3330 case Instruction::ShuffleVector:
3334 case Instruction::GetElementPtr: {
3335 const auto *GO = cast<GEPOperator>(
this);
3336 if (GO->isInBounds())
3338 GO->getSourceElementType(), Ops[0], Ops.
slice(1),
"", InsertBefore);
3340 Ops.
slice(1),
"", InsertBefore);
3342 case Instruction::ICmp:
3343 case Instruction::FCmp:
3351 if (isa<OverflowingBinaryOperator>(BO)) {
3357 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 cl::opt< bool > UseConstantIntForScalableSplat("use-constant-int-for-scalable-splat", cl::init(false), cl::Hidden, cl::desc("Use ConstantInt's native scalable vector splat support."))
static cl::opt< bool > UseConstantIntForFixedLengthSplat("use-constant-int-for-fixed-length-splat", cl::init(false), cl::Hidden, cl::desc("Use ConstantInt's native fixed-length vector splat support."))
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 cl::opt< bool > UseConstantFPForScalableSplat("use-constant-fp-for-scalable-splat", cl::init(false), cl::Hidden, cl::desc("Use ConstantFP's native scalable vector splat support."))
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...
static cl::opt< bool > UseConstantFPForFixedLengthSplat("use-constant-fp-for-fixed-length-splat", cl::init(false), cl::Hidden, cl::desc("Use ConstantFP's native fixed-length vector splat support."))
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.
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
unsigned logBase2() const
bool isPowerOf2() const
Check if this APInt's value is a power of two greater than zero.
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, BasicBlock::iterator InsertBefore)
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, BasicBlock::iterator InsertBefore)
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, BasicBlock::iterator InsertBefore)
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 * 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 * 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 * getIdentity(Instruction *I, Type *Ty, bool AllowRHSConstant=false, bool NSZ=false)
Return the identity constant for a binary or intrinsic Instruction.
static bool isDesirableCastOp(unsigned Opcode)
Whether creating a constant expression for this cast is desirable.
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 * 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 * 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 * getIntrinsicIdentity(Intrinsic::ID, Type *Ty)
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 * getXor(Constant *C1, Constant *C2)
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 * getShl(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=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 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 * getAddrSpaceCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
unsigned getOpcode() const
Return the opcode at the root of this constant expression.
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 bool isSupportedCastOp(unsigned Opcode)
Whether creating a constant expression for this cast is supported.
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 * 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 * 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 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.
This class represents an Operation in the Expression.
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 Type * getGEPReturnType(Value *Ptr, ArrayRef< Value * > IdxList)
Returns the pointer type returned by the GEP instruction, which may be a vector of pointers.
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr, BasicBlock::iterator InsertBefore)
static GetElementPtrInst * CreateInBounds(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr, BasicBlock::iterator InsertBefore)
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.
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, BasicBlock::iterator InsertBefore)
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.
A wrapper class for inspecting calls to intrinsic functions.
DenseMap< unsigned, std::unique_ptr< ConstantInt > > IntOneConstants
DenseMap< unsigned, std::unique_ptr< ConstantInt > > IntZeroConstants
DenseMap< APFloat, std::unique_ptr< ConstantFP > > FPConstants
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
DenseMap< APInt, std::unique_ptr< ConstantInt > > IntConstants
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< std::pair< ElementCount, APInt >, std::unique_ptr< ConstantInt > > IntSplatConstants
ArrayConstantsTy ArrayConstants
DenseMap< const GlobalValue *, DSOLocalEquivalent * > DSOLocalEquivalents
DenseMap< std::pair< ElementCount, APFloat >, std::unique_ptr< ConstantFP > > FPSplatConstants
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.
PointerType * getType() const
NoCFIValue is always a pointer.
GlobalValue * getGlobalValue() const
Class to represent pointers.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
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.
constexpr 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)
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.
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.
initializer< Ty > init(const Ty &Val)
NodeAddr< FuncNode * > Func
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)
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
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.