LLVM: lib/IR/Constants.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
33#include
34
35using namespace llvm;
37
38
40 "use-constant-int-for-fixed-length-splat", cl::init(false), cl::Hidden,
41 cl::desc("Use ConstantInt's native fixed-length vector splat support."));
43 "use-constant-fp-for-fixed-length-splat", cl::init(false), cl::Hidden,
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."));
51
52
53
54
55
57
59 return CFP->isZero() && CFP->isNegative();
60
61
62 if (getType()->isVectorTy())
64 return SplatCFP->isNegativeZeroValue();
65
66
67 if (getType()->isFPOrFPVectorTy())
68 return false;
69
70
72}
73
74
75
77
79 return CFP->isZero();
80
81
82 if (getType()->isVectorTy())
84 return SplatCFP->isZero();
85
86
88}
89
91
93 return CI->isZero();
94
95
97
98
99 return CFP->isExactlyValue(+0.0);
100
101
102
105}
106
108
110 return CI->isMinusOne();
111
112
114 return CFP->getValueAPF().bitcastToAPInt().isAllOnes();
115
116
117 if (getType()->isVectorTy())
119 return SplatVal->isAllOnesValue();
120
121 return false;
122}
123
125
127 return CI->isOne();
128
129
131 return CFP->getValueAPF().bitcastToAPInt().isOne();
132
133
134 if (getType()->isVectorTy())
136 return SplatVal->isOneValue();
137
138 return false;
139}
140
142
144 return !CI->isOneValue();
145
146
148 return !CFP->getValueAPF().bitcastToAPInt().isOne();
149
150
152 for (unsigned I = 0, E = VTy->getNumElements(); I != E; ++I) {
155 return false;
156 }
157 return true;
158 }
159
160
161 if (getType()->isVectorTy())
163 return SplatVal->isNotOneValue();
164
165
166 return false;
167}
168
170
172 return CI->isMinValue(true);
173
174
176 return CFP->getValueAPF().bitcastToAPInt().isMinSignedValue();
177
178
179 if (getType()->isVectorTy())
181 return SplatVal->isMinSignedValue();
182
183 return false;
184}
185
187
189 return CI->isMaxValue(true);
190
191
193 return CFP->getValueAPF().bitcastToAPInt().isMaxSignedValue();
194
195
196 if (getType()->isVectorTy())
198 return SplatVal->isMaxSignedValue();
199
200 return false;
201}
202
204
206 return !CI->isMinValue(true);
207
208
210 return !CFP->getValueAPF().bitcastToAPInt().isMinSignedValue();
211
212
214 for (unsigned I = 0, E = VTy->getNumElements(); I != E; ++I) {
217 return false;
218 }
219 return true;
220 }
221
222
223 if (getType()->isVectorTy())
225 return SplatVal->isNotMinSignedValue();
226
227
228 return false;
229}
230
233 return CFP->getValueAPF().isFiniteNonZero();
234
236 for (unsigned I = 0, E = VTy->getNumElements(); I != E; ++I) {
238 if (!CFP || !CFP->getValueAPF().isFiniteNonZero())
239 return false;
240 }
241 return true;
242 }
243
244 if (getType()->isVectorTy())
246 return SplatCFP->isFiniteNonZeroFP();
247
248
249 return false;
250}
251
254 return CFP->getValueAPF().isNormal();
255
257 for (unsigned I = 0, E = VTy->getNumElements(); I != E; ++I) {
259 if (!CFP || !CFP->getValueAPF().isNormal())
260 return false;
261 }
262 return true;
263 }
264
265 if (getType()->isVectorTy())
267 return SplatCFP->isNormalFP();
268
269
270 return false;
271}
272
275 return CFP->getValueAPF().getExactInverse(nullptr);
276
278 for (unsigned I = 0, E = VTy->getNumElements(); I != E; ++I) {
280 if (!CFP || !CFP->getValueAPF().getExactInverse(nullptr))
281 return false;
282 }
283 return true;
284 }
285
286 if (getType()->isVectorTy())
288 return SplatCFP->hasExactInverseFP();
289
290
291 return false;
292}
293
296 return CFP->isNaN();
297
299 for (unsigned I = 0, E = VTy->getNumElements(); I != E; ++I) {
301 if (!CFP || !CFP->isNaN())
302 return false;
303 }
304 return true;
305 }
306
307 if (getType()->isVectorTy())
309 return SplatCFP->isNaN();
310
311
312 return false;
313}
314
316
317 if (this == Y)
318 return true;
319
320
323 return false;
324
325
326 if (!(VTy->getElementType()->isIntegerTy() ||
327 VTy->getElementType()->isFloatingPointTy()))
328 return false;
329
330
331
337}
338
339static bool
343 if (HasFn(C))
344 return true;
346 return false;
348 return false;
349
351 i != e; ++i) {
352 if (Constant *Elem = C->getAggregateElement(i))
353 if (HasFn(Elem))
354 return true;
355 }
356 }
357
358 return false;
359}
360
365
370
376
379 return false;
380
382 for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i)
384 return true;
385 }
386 return false;
387}
388
389
391 switch (Ty->getTypeID()) {
393 return ConstantInt::get(Ty, 0);
401 return ConstantFP::get(Ty->getContext(),
414 default:
415
416 llvm_unreachable("Cannot create a null constant of that type!");
417 }
418}
419
422
423
424 Constant *C = ConstantInt::get(Ty->getContext(), V);
425
426
429
430
433
434 return C;
435}
436
439 return ConstantInt::get(Ty->getContext(),
441
442 if (Ty->isFloatingPointTy()) {
444 return ConstantFP::get(Ty->getContext(), FL);
445 }
446
450}
451
454 "Must be an aggregate/vector constant");
455
457 return Elt < CC->getNumOperands() ? CC->getOperand(Elt) : nullptr;
458
460 return Elt < CAZ->getElementCount().getKnownMinValue()
461 ? CAZ->getElementValue(Elt)
462 : nullptr;
463
465 return Elt < cast(getType())
466 ->getElementCount()
467 .getKnownMinValue()
468 ? ConstantInt::get(getContext(), CI->getValue())
469 : nullptr;
470
472 return Elt < cast(getType())
473 ->getElementCount()
474 .getKnownMinValue()
475 ? ConstantFP::get(getContext(), CFP->getValue())
476 : nullptr;
477
478
480 return nullptr;
481
483 return Elt < PV->getNumElements() ? PV->getElementValue(Elt) : nullptr;
484
486 return Elt < UV->getNumElements() ? UV->getElementValue(Elt) : nullptr;
487
489 return Elt < CDS->getNumElements() ? CDS->getElementAsConstant(Elt)
490 : nullptr;
491
492 return nullptr;
493}
494
498
499 if (CI->getValue().getActiveBits() > 64)
500 return nullptr;
502 }
503 return nullptr;
504}
505
507
508
510 default:
512#define HANDLE_CONSTANT(Name) \
513 case Value::Name##Val: \
514 cast(this)->destroyConstantImpl(); \
515 break;
516#include "llvm/IR/Value.def"
517 }
518
519
520
521
522
523
524
525
528#ifndef NDEBUG
530 dbgs() << "While deleting: " << *this
531 << "\n\nUse still stuck around after Def is destroyed: " << *V
532 << "\n\n";
533 }
534#endif
535 assert(isa(V) && "References remain to Constant being destroyed");
537
538
540 }
541
542
544}
545
547 switch (C->getValueID()) {
548 case Constant::ConstantIntVal:
550 break;
551 case Constant::ConstantFPVal:
553 break;
554 case Constant::ConstantAggregateZeroVal:
556 break;
557 case Constant::ConstantArrayVal:
559 break;
560 case Constant::ConstantStructVal:
562 break;
563 case Constant::ConstantVectorVal:
565 break;
566 case Constant::ConstantPointerNullVal:
568 break;
569 case Constant::ConstantDataArrayVal:
571 break;
572 case Constant::ConstantDataVectorVal:
574 break;
575 case Constant::ConstantTokenNoneVal:
577 break;
578 case Constant::BlockAddressVal:
580 break;
581 case Constant::DSOLocalEquivalentVal:
583 break;
584 case Constant::NoCFIValueVal:
586 break;
587 case Constant::ConstantPtrAuthVal:
589 break;
590 case Constant::UndefValueVal:
592 break;
593 case Constant::PoisonValueVal:
595 break;
596 case Constant::ConstantExprVal:
609 else
611 break;
612 default:
614 }
615}
616
617
618static bool
625
626 while (!WorkList.empty()) {
630 return true;
633 if (!ConstOp)
634 continue;
635 if (Visited.insert(ConstOp).second)
637 }
638 }
639 return false;
640}
641
643 auto DLLImportPredicate = [](const GlobalValue *GV) {
644 return GV->isThreadLocal();
645 };
647}
648
650 auto DLLImportPredicate = [](const GlobalValue *GV) {
651 return GV->hasDLLImportStorageClass();
652 };
654}
655
660 return true;
661
663 return true;
664 }
665 return false;
666}
667
669 return getRelocationInfo() == GlobalRelocation;
670}
671
673 return getRelocationInfo() != NoRelocation;
674}
675
676Constant::PossibleRelocationsTy Constant::getRelocationInfo() const {
678 return GlobalRelocation;
679
681 return BA->getFunction()->getRelocationInfo();
682
684 if (CE->getOpcode() == Instruction::Sub) {
687 if (LHS && RHS &&
688 (LHS->getOpcode() == Instruction::PtrToInt ||
689 LHS->getOpcode() == Instruction::PtrToAddr) &&
690 (RHS->getOpcode() == Instruction::PtrToInt ||
691 RHS->getOpcode() == Instruction::PtrToAddr)) {
694
695
696
697
698
702 return NoRelocation;
703
704
705 if (auto *RHSGV =
709 if (LHSGV->isDSOLocal() && RHSGV->isDSOLocal())
710 return LocalRelocation;
712 if (RHSGV->isDSOLocal())
713 return LocalRelocation;
714 }
715 }
716 }
717 }
718 }
719
720 PossibleRelocationsTy Result = NoRelocation;
723
725}
726
727
728
729
732
736 if () return false;
738 return false;
739
740
741
742
743 if (RemoveDeadUsers)
745 else
746 ++I;
747 }
748
749 if (RemoveDeadUsers) {
750
751
753 const_cast<Constant *>(C)->destroyConstant();
754 }
755
756 return true;
757}
758
762 while (I != E) {
765 LastNonDeadUser = I;
766 ++I;
767 continue;
768 }
769
771
772
773 LastNonDeadUser = I;
774 ++I;
775 continue;
776 }
777
778
779 if (LastNonDeadUser == E)
781 else
782 I = std::next(LastNonDeadUser);
783 }
784}
785
787
789
790bool Constant::hasNLiveUses(unsigned N) const {
791 unsigned NumUses = 0;
792 for (const Use &U : uses()) {
795 ++NumUses;
796
797 if (NumUses > N)
798 return false;
799 }
800 }
801 return NumUses == N;
802}
803
805 assert(C && Replacement && "Expected non-nullptr constant arguments");
808 assert(Ty == Replacement->getType() && "Expected matching types");
809 return Replacement;
810 }
811
812
814 if (!VTy)
815 return C;
816
817 unsigned NumElts = VTy->getNumElements();
819 for (unsigned i = 0; i != NumElts; ++i) {
820 Constant *EltC = C->getAggregateElement(i);
822 "Expected matching types");
823 NewC[i] = EltC && match(EltC, m_Undef()) ? Replacement : EltC;
824 }
826}
827
829 assert(C && Other && "Expected non-nullptr constant arguments");
831 return C;
832
836
838 if (!VTy)
839 return C;
840
841 Type *EltTy = VTy->getElementType();
842 unsigned NumElts = VTy->getNumElements();
845 "Type mismatch");
846
847 bool FoundExtraUndef = false;
849 for (unsigned I = 0; I != NumElts; ++I) {
850 NewC[I] = C->getAggregateElement(I);
852 assert(NewC[I] && OtherEltC && "Unknown vector element");
855 FoundExtraUndef = true;
856 }
857 }
858 if (FoundExtraUndef)
860 return C;
861}
862
865 return false;
867 return true;
871 return false;
872 return true;
873 }
874 return false;
875}
876
877
878
879
880
881ConstantInt::ConstantInt(Type *Ty, const APInt &V)
883 assert(V.getBitWidth() ==
885 "Invalid constant for type");
886}
887
894
901
905
907 assert(Ty->isIntOrIntVectorTy(1) && "Type not i1 or vector of i1.");
911 return TrueC;
912}
913
915 assert(Ty->isIntOrIntVectorTy(1) && "Type not i1 or vector of i1.");
919 return FalseC;
920}
921
925
926
928
930 std::unique_ptr &Slot =
934 if (!Slot) {
935
937 Slot.reset(new ConstantInt(ITy, V));
938 }
940 return Slot.get();
941}
942
943
945 const APInt &V) {
946
947 std::unique_ptr &Slot =
948 Context.pImpl->IntSplatConstants[std::make_pair(EC, V)];
949 if (!Slot) {
953 }
954
955#ifndef NDEBUG
958 assert(Slot->getType() == VTy);
959#endif
960 return Slot.get();
961}
962
964 bool ImplicitTrunc) {
966 get(cast(Ty->getScalarType()), V, IsSigned, ImplicitTrunc);
967
968
971
972 return C;
973}
974
976 bool ImplicitTrunc) {
977 return get(Ty->getContext(),
978 APInt(Ty->getBitWidth(), V, IsSigned, ImplicitTrunc));
979}
980
982 ConstantInt *C = get(Ty->getContext(), V);
983 assert(C->getType() == Ty->getScalarType() &&
984 "ConstantInt type doesn't match the type implied by its value!");
985
986
989
990 return C;
991}
992
994 return get(Ty->getContext(), APInt(Ty->getBitWidth(), Str, radix));
995}
996
997
998void ConstantInt::destroyConstantImpl() {
999 llvm_unreachable("You can't ConstantInt->destroyConstantImpl()!");
1000}
1001
1002
1003
1004
1005
1007 LLVMContext &Context = Ty->getContext();
1008
1010 bool ignored;
1011 FV.convert(Ty->getScalarType()->getFltSemantics(),
1014
1015
1018
1019 return C;
1020}
1021
1023 ConstantFP *C = get(Ty->getContext(), V);
1024 assert(C->getType() == Ty->getScalarType() &&
1025 "ConstantFP type doesn't match the type implied by its value!");
1026
1027
1030
1031 return C;
1032}
1033
1035 LLVMContext &Context = Ty->getContext();
1036
1037 APFloat FV(Ty->getScalarType()->getFltSemantics(), Str);
1039
1040
1043
1044 return C;
1045}
1046
1048 const fltSemantics &Semantics = Ty->getScalarType()->getFltSemantics();
1050 Constant *C = get(Ty->getContext(), NaN);
1051
1054
1055 return C;
1056}
1057
1059 const fltSemantics &Semantics = Ty->getScalarType()->getFltSemantics();
1061 Constant *C = get(Ty->getContext(), NaN);
1062
1065
1066 return C;
1067}
1068
1070 const fltSemantics &Semantics = Ty->getScalarType()->getFltSemantics();
1072 Constant *C = get(Ty->getContext(), NaN);
1073
1076
1077 return C;
1078}
1079
1081 const fltSemantics &Semantics = Ty->getScalarType()->getFltSemantics();
1083 Constant *C = get(Ty->getContext(), NegZero);
1084
1087
1088 return C;
1089}
1090
1091
1092
1095
1096 std::unique_ptr &Slot = pImpl->FPConstants[V];
1097
1098 if (!Slot) {
1100 Slot.reset(new ConstantFP(Ty, V));
1101 }
1102
1103 return Slot.get();
1104}
1105
1106
1109
1110 std::unique_ptr &Slot =
1111 Context.pImpl->FPSplatConstants[std::make_pair(EC, V)];
1112 if (!Slot) {
1116 }
1117
1118#ifndef NDEBUG
1121 assert(Slot->getType() == VTy);
1122#endif
1123 return Slot.get();
1124}
1125
1127 const fltSemantics &Semantics = Ty->getScalarType()->getFltSemantics();
1129
1132
1133 return C;
1134}
1135
1136ConstantFP::ConstantFP(Type *Ty, const APFloat &V)
1138 assert(&V.getSemantics() == &Ty->getScalarType()->getFltSemantics() &&
1139 "FP type Mismatch");
1140}
1141
1143 return Val.bitwiseIsEqual(V);
1144}
1145
1146
1147void ConstantFP::destroyConstantImpl() {
1148 llvm_unreachable("You can't ConstantFP->destroyConstantImpl()!");
1149}
1150
1151
1152
1153
1154
1160
1164
1170
1176
1182 return VT->getElementCount();
1184}
1185
1186
1187
1188
1189
1195
1199
1205
1211
1215 return AT->getNumElements();
1218 return Ty->getStructNumElements();
1219}
1220
1221
1222
1223
1224
1230
1234
1240
1246
1247
1248
1249
1250
1251template <typename ItTy, typename EltTy>
1253 for (; Start != End; ++Start)
1254 if (*Start != Elt)
1255 return false;
1256 return true;
1257}
1258
1259template <typename SequentialTy, typename ElementTy>
1261 assert(!V.empty() && "Cannot get empty int sequence.");
1262
1266 Elts.push_back(CI->getZExtValue());
1267 else
1268 return nullptr;
1269 return SequentialTy::get(V[0]->getContext(), Elts);
1270}
1271
1272template <typename SequentialTy, typename ElementTy>
1274 assert(!V.empty() && "Cannot get empty FP sequence.");
1275
1279 Elts.push_back(CFP->getValueAPF().bitcastToAPInt().getLimitedValue());
1280 else
1281 return nullptr;
1282 return SequentialTy::getFP(V[0]->getType(), Elts);
1283}
1284
1285template
1288
1289
1290
1292 if (CI->getType()->isIntegerTy(8))
1294 else if (CI->getType()->isIntegerTy(16))
1296 else if (CI->getType()->isIntegerTy(32))
1298 else if (CI->getType()->isIntegerTy(64))
1301 if (CFP->getType()->isHalfTy() || CFP->getType()->isBFloatTy())
1303 else if (CFP->getType()->isFloatTy())
1305 else if (CFP->getType()->isDoubleTy())
1307 }
1308
1309 return nullptr;
1310}
1311
1317
1318
1320 if (ST->isOpaque())
1321 return;
1322 for (unsigned I = 0, E = V.size(); I != E; ++I)
1324 "Initializer for struct element doesn't match!");
1325 }
1326}
1327
1331 assert(V.size() == T->getNumElements() &&
1332 "Invalid initializer for constant array");
1333}
1334
1336 if (Constant *C = getImpl(Ty, V))
1337 return C;
1338 return Ty->getContext().pImpl->ArrayConstants.getOrCreate(Ty, V);
1339}
1340
1342
1343 if (V.empty())
1345
1347 assert(C->getType() == Ty->getElementType() &&
1348 "Wrong type in array element initializer");
1349 (void)C;
1350 }
1351
1352
1353
1354
1358
1361
1364
1365
1366
1369
1370
1371 return nullptr;
1372}
1373
1376 bool Packed) {
1377 unsigned VecSize = V.size();
1379 for (unsigned i = 0; i != VecSize; ++i)
1380 EltTypes[i] = V[i]->getType();
1381
1383}
1384
1385
1387 bool Packed) {
1388 assert(!V.empty() &&
1389 "ConstantStruct::getTypeForElements cannot be called on empty list");
1391}
1392
1396 assert((T->isOpaque() || V.size() == T->getNumElements()) &&
1397 "Invalid initializer for constant struct");
1398}
1399
1400
1402 assert((ST->isOpaque() || ST->getNumElements() == V.size()) &&
1403 "Incorrect # elements specified to ConstantStruct::get");
1404
1405
1408 bool isPoison = false;
1409
1410 if (!V.empty()) {
1413 isZero = V[0]->isNullValue();
1414
1417 if (->isNullValue())
1420 isPoison = false;
1423 }
1424 }
1425 }
1428 if (isPoison)
1432
1433 return ST->getContext().pImpl->StructConstants.getOrCreate(ST, V);
1434}
1435
1440 "Invalid initializer for constant vector");
1441}
1442
1443
1446 return C;
1448 return Ty->getContext().pImpl->VectorConstants.getOrCreate(Ty, V);
1449}
1450
1452 assert(!V.empty() && "Vectors can't be empty");
1454
1455
1456
1458 bool isZero = C->isNullValue();
1463
1464 if (isZero || isUndef || isSplatFP || isSplatInt) {
1465 for (unsigned i = 1, e = V.size(); i != e; ++i)
1466 if (V[i] != C) {
1467 isZero = isUndef = isPoison = isSplatFP = isSplatInt = false;
1468 break;
1469 }
1470 }
1471
1474 if (isPoison)
1478 if (isSplatFP)
1479 return ConstantFP::get(C->getContext(), T->getElementCount(),
1481 if (isSplatInt)
1482 return ConstantInt::get(C->getContext(), T->getElementCount(),
1484
1485
1486
1489
1490
1491
1492 return nullptr;
1493}
1494
1496 if (!EC.isScalable()) {
1497
1498 if (!V->isNullValue()) {
1500 return ConstantInt::get(V->getContext(), EC,
1503 return ConstantFP::get(V->getContext(), EC,
1505 }
1506
1507
1508
1512
1514 return get(Elts);
1515 }
1516
1517
1518 if (!V->isNullValue()) {
1520 return ConstantInt::get(V->getContext(), EC,
1523 return ConstantFP::get(V->getContext(), EC,
1525 }
1526
1528
1529 if (V->isNullValue())
1535
1537
1538
1541
1543
1545}
1546
1550 pImpl->TheNoneToken.reset(new ConstantTokenNone(Context));
1552}
1553
1554
1555void ConstantTokenNone::destroyConstantImpl() {
1556 llvm_unreachable("You can't ConstantTokenNone->destroyConstantImpl()!");
1557}
1558
1559
1560
1561
1563
1567
1571
1573 bool OnlyIfReduced, Type *SrcTy) const {
1575
1576
1579
1580 Type *OnlyIfReducedTy = OnlyIfReduced ? Ty : nullptr;
1582 case Instruction::Trunc:
1583 case Instruction::ZExt:
1584 case Instruction::SExt:
1585 case Instruction::FPTrunc:
1586 case Instruction::FPExt:
1587 case Instruction::UIToFP:
1588 case Instruction::SIToFP:
1589 case Instruction::FPToUI:
1590 case Instruction::FPToSI:
1591 case Instruction::PtrToAddr:
1592 case Instruction::PtrToInt:
1593 case Instruction::IntToPtr:
1594 case Instruction::BitCast:
1595 case Instruction::AddrSpaceCast:
1597 case Instruction::InsertElement:
1599 OnlyIfReducedTy);
1600 case Instruction::ExtractElement:
1602 case Instruction::ShuffleVector:
1604 OnlyIfReducedTy);
1605 case Instruction::GetElementPtr: {
1609 SrcTy ? SrcTy : GEPO->getSourceElementType(), Ops[0], Ops.slice(1),
1610 GEPO->getNoWrapFlags(), GEPO->getInRange(), OnlyIfReducedTy);
1611 }
1612 default:
1615 OnlyIfReducedTy);
1616 }
1617}
1618
1619
1620
1621
1622
1624 unsigned NumBits = Ty->getIntegerBitWidth();
1625 if (Ty->isIntegerTy(1))
1626 return Val == 0 || Val == 1;
1627 return isUIntN(NumBits, Val);
1628}
1629
1631 unsigned NumBits = Ty->getIntegerBitWidth();
1632 if (Ty->isIntegerTy(1))
1633 return Val == 0 || Val == 1 || Val == -1;
1634 return isIntN(NumBits, Val);
1635}
1636
1638
1640 bool losesInfo;
1641 switch (Ty->getTypeID()) {
1642 default:
1643 return false;
1644
1645
1648 return true;
1650 return !losesInfo;
1651 }
1654 return true;
1656 return !losesInfo;
1657 }
1660 return true;
1662 return !losesInfo;
1663 }
1669 return true;
1671 return !losesInfo;
1672 }
1691 }
1692}
1693
1694
1695
1696
1697
1699 assert((Ty->isStructTy() || Ty->isArrayTy() || Ty->isVectorTy()) &&
1700 "Cannot create an aggregate zero of non-aggregate type!");
1701
1702 std::unique_ptr &Entry =
1703 Ty->getContext().pImpl->CAZConstants[Ty];
1704 if (!Entry)
1705 Entry.reset(new ConstantAggregateZero(Ty));
1706
1707 return Entry.get();
1708}
1709
1710
1711void ConstantAggregateZero::destroyConstantImpl() {
1713}
1714
1715
1716void ConstantArray::destroyConstantImpl() {
1718}
1719
1720
1721
1722
1723
1724
1725void ConstantStruct::destroyConstantImpl() {
1727}
1728
1729
1730void ConstantVector::destroyConstantImpl() {
1732}
1733
1735 assert(this->getType()->isVectorTy() && "Only valid for vectors!");
1741 return ConstantInt::get(getContext(), CI->getValue());
1743 return ConstantFP::get(getContext(), CFP->getValue());
1745 return CV->getSplatValue();
1747 return CV->getSplatValue(AllowPoison);
1748
1749
1750
1752 if (Shuf && Shuf->getOpcode() == Instruction::ShuffleVector &&
1754
1756 if (IElt && IElt->getOpcode() == Instruction::InsertElement &&
1758
1760 Constant *SplatVal = IElt->getOperand(1);
1762
1763 if (Index && Index->getValue() == 0 &&
1764 llvm::all_of(Mask, [](int I) { return I == 0; }))
1765 return SplatVal;
1766 }
1767 }
1768
1769 return nullptr;
1770}
1771
1773
1775
1778 if (OpC == Elt)
1779 continue;
1780
1781
1782 if (!AllowPoison)
1783 return nullptr;
1784
1785
1787 continue;
1788
1789
1791 Elt = OpC;
1792
1793 if (OpC != Elt)
1794 return nullptr;
1795 }
1796 return Elt;
1797}
1798
1801 return CI->getValue();
1802
1805
1806
1811}
1812
1816
1818 if (()->isVectorTy())
1819 return ConstantRange::getFull(BitWidth);
1820
1824
1827 for (unsigned I = 0, E = CDV->getNumElements(); I < E; ++I)
1828 CR = CR.unionWith(CDV->getElementAsAPInt(I));
1829 return CR;
1830 }
1831
1834 for (unsigned I = 0, E = CV->getNumOperands(); I < E; ++I) {
1835 Constant *Elem = CV->getOperand(I);
1836 if (!Elem)
1837 return ConstantRange::getFull(BitWidth);
1839 continue;
1841 if (!CI)
1842 return ConstantRange::getFull(BitWidth);
1843 CR = CR.unionWith(CI->getValue());
1844 }
1845 return CR;
1846 }
1847
1848 return ConstantRange::getFull(BitWidth);
1849}
1850
1851
1852
1853
1855 std::unique_ptr &Entry =
1857 if (!Entry)
1858 Entry.reset(new ConstantPointerNull(Ty));
1859
1860 return Entry.get();
1861}
1862
1863
1864void ConstantPointerNull::destroyConstantImpl() {
1866}
1867
1868
1869
1870
1873 "Target extension type not allowed to have a zeroinitializer");
1874 std::unique_ptr &Entry =
1875 Ty->getContext().pImpl->CTNConstants[Ty];
1876 if (!Entry)
1877 Entry.reset(new ConstantTargetNone(Ty));
1878
1879 return Entry.get();
1880}
1881
1882
1883void ConstantTargetNone::destroyConstantImpl() {
1885}
1886
1889 if (!Entry)
1890 Entry.reset(new UndefValue(Ty));
1891
1892 return Entry.get();
1893}
1894
1895
1896void UndefValue::destroyConstantImpl() {
1897
1898 if (getValueID() == UndefValueVal) {
1900 } else if (getValueID() == PoisonValueVal) {
1902 }
1904}
1905
1908 if (!Entry)
1909 Entry.reset(new PoisonValue(Ty));
1910
1911 return Entry.get();
1912}
1913
1914
1915void PoisonValue::destroyConstantImpl() {
1916
1918}
1919
1922 if (!BA)
1923 BA = new BlockAddress(Ty, BB);
1924 return BA;
1925}
1926
1931
1933 assert(BB->getParent() == F && "Block not part of specified function");
1935}
1936
1938 : Constant(Ty, Value::BlockAddressVal, AllocMarker) {
1940 BB->setHasAddressTaken(true);
1941}
1942
1945 return nullptr;
1946
1948 assert(BA && "Refcount and block address map disagree!");
1949 return BA;
1950}
1951
1952
1953void BlockAddress::destroyConstantImpl() {
1956}
1957
1958Value *BlockAddress::handleOperandChangeImpl(Value *From, Value *To) {
1961
1962
1963
1965 if (NewBA)
1966 return NewBA;
1967
1969
1970
1971
1973 NewBA = this;
1976
1977
1978
1979 return nullptr;
1980}
1981
1984 if (!Equiv)
1985 Equiv = new DSOLocalEquivalent(GV);
1986
1988 "DSOLocalFunction does not match the expected global value");
1989 return Equiv;
1990}
1991
1992DSOLocalEquivalent::DSOLocalEquivalent(GlobalValue *GV)
1995}
1996
1997
1998void DSOLocalEquivalent::destroyConstantImpl() {
2001}
2002
2003Value *DSOLocalEquivalent::handleOperandChangeImpl(Value *From, Value *To) {
2004 assert(From == getGlobalValue() && "Changing value does not match operand.");
2005 assert(isa(To) && "Can only replace the operands with a constant");
2006
2007
2009 DSOLocalEquivalent *&NewEquiv =
2011 if (NewEquiv)
2013 }
2014
2015
2016
2018 return To;
2019
2020
2021
2024 if (NewEquiv)
2026
2027
2029 NewEquiv = this;
2031
2033
2034
2036 }
2037 return nullptr;
2038}
2039
2042 if ()
2043 NC = new NoCFIValue(GV);
2044
2045 assert(NC->getGlobalValue() == GV &&
2046 "NoCFIValue does not match the expected global value");
2047 return NC;
2048}
2049
2053}
2054
2055
2056void NoCFIValue::destroyConstantImpl() {
2059}
2060
2061Value *NoCFIValue::handleOperandChangeImpl(Value *From, Value *To) {
2062 assert(From == getGlobalValue() && "Changing value does not match operand.");
2063
2065 assert(GV && "Can only replace the operands with a global value");
2066
2068 if (NewNC)
2070
2072 NewNC = this;
2074
2077
2078 return nullptr;
2079}
2080
2081
2082
2083
2086 Constant *DeactivationSymbol) {
2087 Constant *ArgVec[] = {Ptr, Key, Disc, AddrDisc, DeactivationSymbol};
2091}
2092
2097
2100 Constant *DeactivationSymbol)
2103 assert(Key->getBitWidth() == 32);
2112}
2113
2114
2115void ConstantPtrAuth::destroyConstantImpl() {
2117}
2118
2119Value *ConstantPtrAuth::handleOperandChangeImpl(Value *From, Value *ToV) {
2120 assert(isa(ToV) && "Cannot make Constant refer to non-constant!");
2122
2125
2126 unsigned NumUpdated = 0;
2127
2129 unsigned OperandNo = 0;
2130 for (Use *O = OperandList, *E = OperandList + getNumOperands(); O != E; ++O) {
2132 if (Val == From) {
2133 OperandNo = (O - OperandList);
2134 Val = To;
2135 ++NumUpdated;
2136 }
2138 }
2139
2141 Values, this, From, To, NumUpdated, OperandNo);
2142}
2143
2146 if (!CastV || CastV->getOpcode() != Instruction::IntToPtr)
2147 return false;
2148
2150 if (!IntVal)
2151 return false;
2152
2153 return IntVal->getValue() == Value;
2154}
2155
2157 const Value *Discriminator,
2159
2160
2162 return false;
2163
2164
2166 return false;
2167
2168
2169
2170
2171
2172
2173
2174
2175
2178
2179
2180 const Value *AddrDiscriminator = nullptr;
2181
2182
2184
2185
2186 if ((Discriminator,
2189 return false;
2190 } else {
2191
2192 AddrDiscriminator = Discriminator;
2193 }
2194
2195
2196
2197
2199 AddrDiscriminator = Cast->getPointerOperand();
2200
2201
2203 return false;
2204
2205
2207 return true;
2208
2209
2212 DL, Off1, true);
2213
2214 APInt Off2(DL.getIndexTypeSizeInBits(AddrDiscriminator->getType()), 0);
2216 DL, Off2, true);
2217
2218 return Base1 == Base2 && Off1 == Off2;
2219}
2220
2221
2222
2223
2224
2225
2227 bool OnlyIfReduced = false) {
2228 assert(Ty->isFirstClassType() && "Cannot cast to an aggregate type!");
2229
2231 return FC;
2232
2233 if (OnlyIfReduced)
2234 return nullptr;
2235
2237
2238
2240
2242}
2243
2245 bool OnlyIfReduced) {
2249 "Cast opcode not supported as constant expression");
2250 assert(C && Ty && "Null arguments to getCast");
2252
2253 switch (opc) {
2254 default:
2256 case Instruction::Trunc:
2257 return getTrunc(C, Ty, OnlyIfReduced);
2258 case Instruction::PtrToAddr:
2260 case Instruction::PtrToInt:
2262 case Instruction::IntToPtr:
2264 case Instruction::BitCast:
2265 return getBitCast(C, Ty, OnlyIfReduced);
2266 case Instruction::AddrSpaceCast:
2268 }
2269}
2270
2272 if (C->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
2275}
2276
2279 assert((Ty->isIntOrIntVectorTy() || Ty->isPtrOrPtrVectorTy()) &&
2280 "Invalid cast");
2281
2282 if (Ty->isIntOrIntVectorTy())
2284
2286 if (Ty->isPtrOrPtrVectorTy() && SrcAS != Ty->getPointerAddressSpace())
2288
2290}
2291
2295 assert(Ty->isPtrOrPtrVectorTy() && "Invalid cast");
2296
2299
2301}
2302
2304#ifndef NDEBUG
2307#endif
2308 assert((fromVec == toVec) && "Cannot convert from scalar to/from vector");
2309 assert(C->getType()->isIntOrIntVectorTy() && "Trunc operand must be integer");
2310 assert(Ty->isIntOrIntVectorTy() && "Trunc produces only integral");
2311 assert(C->getType()->getScalarSizeInBits() > Ty->getScalarSizeInBits()&&
2312 "SrcTy must be larger than DestTy for Trunc!");
2313
2314 return getFoldedCast(Instruction::Trunc, C, Ty, OnlyIfReduced);
2315}
2316
2318 bool OnlyIfReduced) {
2319 assert(C->getType()->isPtrOrPtrVectorTy() &&
2320 "PtrToAddr source must be pointer or pointer vector");
2322 "PtrToAddr destination must be integer or integer vector");
2327 "Invalid cast between a different number of vector elements");
2328 return getFoldedCast(Instruction::PtrToAddr, C, DstTy, OnlyIfReduced);
2329}
2330
2332 bool OnlyIfReduced) {
2333 assert(C->getType()->isPtrOrPtrVectorTy() &&
2334 "PtrToInt source must be pointer or pointer vector");
2336 "PtrToInt destination must be integer or integer vector");
2341 "Invalid cast between a different number of vector elements");
2342 return getFoldedCast(Instruction::PtrToInt, C, DstTy, OnlyIfReduced);
2343}
2344
2346 bool OnlyIfReduced) {
2347 assert(C->getType()->isIntOrIntVectorTy() &&
2348 "IntToPtr source must be integer or integer vector");
2350 "IntToPtr destination must be a pointer or pointer vector");
2355 "Invalid cast between a different number of vector elements");
2356 return getFoldedCast(Instruction::IntToPtr, C, DstTy, OnlyIfReduced);
2357}
2358
2360 bool OnlyIfReduced) {
2362 "Invalid constantexpr bitcast!");
2363
2364
2365
2366 if (C->getType() == DstTy) return C;
2367
2368 return getFoldedCast(Instruction::BitCast, C, DstTy, OnlyIfReduced);
2369}
2370
2372 bool OnlyIfReduced) {
2374 "Invalid constantexpr addrspacecast!");
2375 return getFoldedCast(Instruction::AddrSpaceCast, C, DstTy, OnlyIfReduced);
2376}
2377
2379 unsigned Flags, Type *OnlyIfReducedTy) {
2380
2382 "Invalid opcode in binary constant expression");
2384 "Binop not supported as constant expression");
2386 "Operand types in binary constant expression should match");
2387
2388#ifndef NDEBUG
2389 switch (Opcode) {
2390 case Instruction::Add:
2391 case Instruction::Sub:
2392 case Instruction::Mul:
2394 "Tried to create an integer operation on a non-integer type!");
2395 break;
2396 case Instruction::And:
2397 case Instruction::Or:
2398 case Instruction::Xor:
2400 "Tried to create a logical operation on a non-integral type!");
2401 break;
2402 default:
2403 break;
2404 }
2405#endif
2406
2408 return FC;
2409
2410 if (OnlyIfReducedTy == C1->getType())
2411 return nullptr;
2412
2413 Constant *ArgVec[] = {C1, C2};
2415
2418}
2419
2421 switch (Opcode) {
2422 case Instruction::UDiv:
2423 case Instruction::SDiv:
2424 case Instruction::URem:
2425 case Instruction::SRem:
2426 case Instruction::FAdd:
2427 case Instruction::FSub:
2428 case Instruction::FMul:
2429 case Instruction::FDiv:
2430 case Instruction::FRem:
2431 case Instruction::And:
2432 case Instruction::Or:
2433 case Instruction::LShr:
2434 case Instruction::AShr:
2435 case Instruction::Shl:
2436 case Instruction::Mul:
2437 return false;
2438 case Instruction::Add:
2439 case Instruction::Sub:
2440 case Instruction::Xor:
2441 return true;
2442 default:
2444 }
2445}
2446
2448 switch (Opcode) {
2449 case Instruction::UDiv:
2450 case Instruction::SDiv:
2451 case Instruction::URem:
2452 case Instruction::SRem:
2453 case Instruction::FAdd:
2454 case Instruction::FSub:
2455 case Instruction::FMul:
2456 case Instruction::FDiv:
2457 case Instruction::FRem:
2458 case Instruction::And:
2459 case Instruction::Or:
2460 case Instruction::LShr:
2461 case Instruction::AShr:
2462 case Instruction::Shl:
2463 case Instruction::Mul:
2464 return false;
2465 case Instruction::Add:
2466 case Instruction::Sub:
2467 case Instruction::Xor:
2468 return true;
2469 default:
2471 }
2472}
2473
2475 switch (Opcode) {
2476 case Instruction::ZExt:
2477 case Instruction::SExt:
2478 case Instruction::FPTrunc:
2479 case Instruction::FPExt:
2480 case Instruction::UIToFP:
2481 case Instruction::SIToFP:
2482 case Instruction::FPToUI:
2483 case Instruction::FPToSI:
2484 return false;
2485 case Instruction::Trunc:
2486 case Instruction::PtrToAddr:
2487 case Instruction::PtrToInt:
2488 case Instruction::IntToPtr:
2489 case Instruction::BitCast:
2490 case Instruction::AddrSpaceCast:
2491 return true;
2492 default:
2494 }
2495}
2496
2498 switch (Opcode) {
2499 case Instruction::ZExt:
2500 case Instruction::SExt:
2501 case Instruction::FPTrunc:
2502 case Instruction::FPExt:
2503 case Instruction::UIToFP:
2504 case Instruction::SIToFP:
2505 case Instruction::FPToUI:
2506 case Instruction::FPToSI:
2507 return false;
2508 case Instruction::Trunc:
2509 case Instruction::PtrToAddr:
2510 case Instruction::PtrToInt:
2511 case Instruction::IntToPtr:
2512 case Instruction::BitCast:
2513 case Instruction::AddrSpaceCast:
2514 return true;
2515 default:
2517 }
2518}
2519
2521
2522
2526 GEPIdx);
2529}
2530
2532
2533
2539 Constant *Indices[2] = {Zero, One};
2542}
2543
2547 std::optional InRange,
2548 Type *OnlyIfReducedTy) {
2549 assert(Ty && "Must specify element type");
2551
2553 return FC;
2554
2556 ;
2557
2558
2560 if (OnlyIfReducedTy == ReqTy)
2561 return nullptr;
2562
2565 EltCount = VecTy->getElementCount();
2566
2567
2568 std::vector<Constant*> ArgVec;
2569 ArgVec.reserve(1 + Idxs.size());
2570 ArgVec.push_back(C);
2572 for (; GTI != GTE; ++GTI) {
2576 cast(Idx->getType())->getElementCount() == EltCount) &&
2577 "getelementptr index type missmatch");
2578
2579 if (GTI.isStruct() && Idx->getType()->isVectorTy()) {
2580 Idx = Idx->getSplatValue();
2581 } else if (GTI.isSequential() && EltCount.isNonZero() &&
2582 !Idx->getType()->isVectorTy()) {
2584 }
2585 ArgVec.push_back(Idx);
2586 }
2587
2590
2593}
2594
2596 Type *OnlyIfReducedTy) {
2598 "Tried to create extractelement operation on non-vector type!");
2600 "Extractelement index must be an integer type!");
2601
2603 return FC;
2604
2606 if (OnlyIfReducedTy == ReqTy)
2607 return nullptr;
2608
2609
2610 Constant *ArgVec[] = { Val, Idx };
2612
2615}
2616
2620 "Tried to create insertelement operation on non-vector type!");
2622 "Insertelement types must match!");
2624 "Insertelement index must be i32 type!");
2625
2627 return FC;
2628
2629 if (OnlyIfReducedTy == Val->getType())
2630 return nullptr;
2631
2632
2633 Constant *ArgVec[] = { Val, Elt, Idx };
2635
2638}
2639
2642 Type *OnlyIfReducedTy) {
2644 "Invalid shuffle vector constant expr operands!");
2645
2647 return FC;
2648
2649 unsigned NElts = Mask.size();
2651 Type *EltTy = V1VTy->getElementType();
2654
2655 if (OnlyIfReducedTy == ShufTy)
2656 return nullptr;
2657
2658
2659 Constant *ArgVec[] = {V1, V2};
2661
2664}
2665
2667 assert(C->getType()->isIntOrIntVectorTy() &&
2668 "Cannot NEG a nonintegral value!");
2669 return getSub(ConstantInt::get(C->getType(), 0), C, false, HasNSW);
2670}
2671
2673 assert(C->getType()->isIntOrIntVectorTy() &&
2674 "Cannot NOT a nonintegral value!");
2676}
2677
2679 bool HasNUW, bool HasNSW) {
2682 return get(Instruction::Add, C1, C2, Flags);
2683}
2684
2686 bool HasNUW, bool HasNSW) {
2689 return get(Instruction::Sub, C1, C2, Flags);
2690}
2691
2693 return get(Instruction::Xor, C1, C2);
2694}
2695
2698 const APInt *IVal;
2700 return ConstantInt::get(Ty, IVal->logBase2());
2701
2702
2704 if (!VecTy)
2705 return nullptr;
2706
2708 for (unsigned I = 0, E = VecTy->getNumElements(); I != E; ++I) {
2709 Constant *Elt = C->getAggregateElement(I);
2710 if (!Elt)
2711 return nullptr;
2712
2715 continue;
2716 }
2718 return nullptr;
2719 Elts.push_back(ConstantInt::get(Ty->getScalarType(), IVal->logBase2()));
2720 }
2721
2723}
2724
2726 bool AllowRHSConstant, bool NSZ) {
2728
2729
2731 switch (Opcode) {
2732 case Instruction::Add:
2733 case Instruction::Or:
2734 case Instruction::Xor:
2736 case Instruction::Mul:
2737 return ConstantInt::get(Ty, 1);
2738 case Instruction::And:
2740 case Instruction::FAdd:
2742 case Instruction::FMul:
2743 return ConstantFP::get(Ty, 1.0);
2744 default:
2745 llvm_unreachable("Every commutative binop has an identity constant");
2746 }
2747 }
2748
2749
2750 if (!AllowRHSConstant)
2751 return nullptr;
2752
2753 switch (Opcode) {
2754 case Instruction::Sub:
2755 case Instruction::Shl:
2756 case Instruction::LShr:
2757 case Instruction::AShr:
2758 case Instruction::FSub:
2760 case Instruction::SDiv:
2761 case Instruction::UDiv:
2762 return ConstantInt::get(Ty, 1);
2763 case Instruction::FDiv:
2764 return ConstantFP::get(Ty, 1.0);
2765 default:
2766 return nullptr;
2767 }
2768}
2769
2771 switch (ID) {
2772 case Intrinsic::umax:
2774 case Intrinsic::umin:
2776 case Intrinsic::smax:
2779 case Intrinsic::smin:
2782 default:
2783 return nullptr;
2784 }
2785}
2786
2788 bool AllowRHSConstant, bool NSZ) {
2789 if (I->isBinaryOp())
2790 return getBinOpIdentity(I->getOpcode(), Ty, AllowRHSConstant, NSZ);
2793 return nullptr;
2794}
2795
2797 bool AllowLHSConstant) {
2798 switch (Opcode) {
2799 default:
2800 break;
2801
2802 case Instruction::Or:
2804
2805 case Instruction::And:
2806 case Instruction::Mul:
2808 }
2809
2810
2811 if (!AllowLHSConstant)
2812 return nullptr;
2813
2814 switch (Opcode) {
2815 default:
2816 return nullptr;
2817 case Instruction::Shl:
2818 case Instruction::LShr:
2819 case Instruction::AShr:
2820 case Instruction::SDiv:
2821 case Instruction::UDiv:
2822 case Instruction::URem:
2823 case Instruction::SRem:
2825 }
2826}
2827
2828
2829void ConstantExpr::destroyConstantImpl() {
2831}
2832
2836
2837GetElementPtrConstantExpr::GetElementPtrConstantExpr(
2841 SrcElementTy(SrcElementTy),
2842 ResElementTy(GetElementPtrInst::getIndexedType(SrcElementTy, IdxList)),
2846 for (unsigned i = 0, E = IdxList.size(); i != E; ++i)
2847 OperandList[i+1] = IdxList[i];
2848}
2849
2851 return SrcElementTy;
2852}
2853
2855 return ResElementTy;
2856}
2857
2859 return InRange;
2860}
2861
2862
2863
2864
2867 return ATy->getElementType();
2869}
2870
2874
2876 if (Ty->isHalfTy() || Ty->isBFloatTy() || Ty->isFloatTy() || Ty->isDoubleTy())
2877 return true;
2879 switch (IT->getBitWidth()) {
2880 case 8:
2881 case 16:
2882 case 32:
2883 case 64:
2884 return true;
2885 default: break;
2886 }
2887 }
2888 return false;
2889}
2890
2893 return AT->getNumElements();
2895}
2896
2900
2901
2902const char *ConstantDataSequential::getElementPointer(uint64_t Elt) const {
2905}
2906
2907
2909 for (char I : Arr)
2910 if (I != 0)
2911 return false;
2912 return true;
2913}
2914
2915
2916
2917
2918
2920#ifndef NDEBUG
2923 else
2925#endif
2926
2927
2930
2931
2932 auto &Slot =
2933 *Ty->getContext().pImpl->CDSConstants.try_emplace(Elements).first;
2934
2935
2936
2937
2938
2939 std::unique_ptr *Entry = &Slot.second;
2940 for (; *Entry; Entry = &(*Entry)->Next)
2941 if ((*Entry)->getType() == Ty)
2942 return Entry->get();
2943
2944
2945
2947
2949 return Entry->get();
2950 }
2951
2953
2955 return Entry->get();
2956}
2957
2958void ConstantDataSequential::destroyConstantImpl() {
2959
2962
2964
2965 assert(Slot != CDSConstants.end() && "CDS not found in uniquing table");
2966
2967 std::unique_ptr *Entry = &Slot->getValue();
2968
2969
2970 if (!(*Entry)->Next) {
2971
2972
2973 assert(Entry->get() == this && "Hash mismatch in ConstantDataSequential");
2975 return;
2976 }
2977
2978
2979
2980 while (true) {
2981 std::unique_ptr &Node = *Entry;
2982 assert(Node && "Didn't find entry in its uniquing hash table!");
2983
2984 if (Node.get() == this) {
2985 Node = std::move(Node->Next);
2986 return;
2987 }
2988
2990 }
2991}
2992
2993
2994
2995
2996
2997
2998
3000 assert((ElementType->isHalfTy() || ElementType->isBFloatTy()) &&
3001 "Element type is not a 16-bit float type");
3003 const char *Data = reinterpret_cast<const char *>(Elts.data());
3005}
3007 assert(ElementType->isFloatTy() && "Element type is not a 32-bit float type");
3009 const char *Data = reinterpret_cast<const char *>(Elts.data());
3011}
3013 assert(ElementType->isDoubleTy() &&
3014 "Element type is not a 64-bit float type");
3016 const char *Data = reinterpret_cast<const char *>(Elts.data());
3018}
3019
3022 if (!AddNull) {
3023 const uint8_t *Data = Str.bytes_begin();
3025 }
3026
3028 ElementVals.append(Str.begin(), Str.end());
3030 return get(Context, ElementVals);
3031}
3032
3033
3034
3035
3038 const char *Data = reinterpret_cast<const char *>(Elts.data());
3040}
3043 const char *Data = reinterpret_cast<const char *>(Elts.data());
3045}
3048 const char *Data = reinterpret_cast<const char *>(Elts.data());
3050}
3053 const char *Data = reinterpret_cast<const char *>(Elts.data());
3055}
3058 const char *Data = reinterpret_cast<const char *>(Elts.data());
3060}
3063 const char *Data = reinterpret_cast<const char *>(Elts.data());
3065}
3066
3067
3068
3069
3070
3071
3072
3075 assert((ElementType->isHalfTy() || ElementType->isBFloatTy()) &&
3076 "Element type is not a 16-bit float type");
3078 const char *Data = reinterpret_cast<const char *>(Elts.data());
3080}
3083 assert(ElementType->isFloatTy() && "Element type is not a 32-bit float type");
3085 const char *Data = reinterpret_cast<const char *>(Elts.data());
3087}
3090 assert(ElementType->isDoubleTy() &&
3091 "Element type is not a 64-bit float type");
3093 const char *Data = reinterpret_cast<const char *>(Elts.data());
3095}
3096
3099 "Element type not compatible with ConstantData");
3101 if (CI->getType()->isIntegerTy(8)) {
3103 return get(V->getContext(), Elts);
3104 }
3105 if (CI->getType()->isIntegerTy(16)) {
3107 return get(V->getContext(), Elts);
3108 }
3109 if (CI->getType()->isIntegerTy(32)) {
3111 return get(V->getContext(), Elts);
3112 }
3113 assert(CI->getType()->isIntegerTy(64) && "Unsupported ConstantData type");
3115 return get(V->getContext(), Elts);
3116 }
3117
3119 if (CFP->getType()->isHalfTy()) {
3121 NumElts, CFP->getValueAPF().bitcastToAPInt().getLimitedValue());
3122 return getFP(V->getType(), Elts);
3123 }
3124 if (CFP->getType()->isBFloatTy()) {
3126 NumElts, CFP->getValueAPF().bitcastToAPInt().getLimitedValue());
3127 return getFP(V->getType(), Elts);
3128 }
3129 if (CFP->getType()->isFloatTy()) {
3131 NumElts, CFP->getValueAPF().bitcastToAPInt().getLimitedValue());
3132 return getFP(V->getType(), Elts);
3133 }
3134 if (CFP->getType()->isDoubleTy()) {
3136 NumElts, CFP->getValueAPF().bitcastToAPInt().getLimitedValue());
3137 return getFP(V->getType(), Elts);
3138 }
3139 }
3141}
3142
3145 "Accessor can only be used when element is an integer");
3146 const char *EltPtr = getElementPointer(Elt);
3147
3148
3149
3152 case 8:
3153 return *reinterpret_cast<const uint8_t *>(EltPtr);
3154 case 16:
3155 return *reinterpret_cast<const uint16_t *>(EltPtr);
3156 case 32:
3157 return *reinterpret_cast<const uint32_t *>(EltPtr);
3158 case 64:
3159 return *reinterpret_cast<const uint64_t *>(EltPtr);
3160 }
3161}
3162
3165 "Accessor can only be used when element is an integer");
3166 const char *EltPtr = getElementPointer(Elt);
3167
3168
3169
3172 case 8: {
3173 auto EltVal = *reinterpret_cast<const uint8_t *>(EltPtr);
3174 return APInt(8, EltVal);
3175 }
3176 case 16: {
3177 auto EltVal = *reinterpret_cast<const uint16_t *>(EltPtr);
3178 return APInt(16, EltVal);
3179 }
3180 case 32: {
3181 auto EltVal = *reinterpret_cast<const uint32_t *>(EltPtr);
3182 return APInt(32, EltVal);
3183 }
3184 case 64: {
3185 auto EltVal = *reinterpret_cast<const uint64_t *>(EltPtr);
3186 return APInt(64, EltVal);
3187 }
3188 }
3189}
3190
3192 const char *EltPtr = getElementPointer(Elt);
3193
3195 default:
3196 llvm_unreachable("Accessor can only be used when element is float/double!");
3198 auto EltVal = *reinterpret_cast<const uint16_t *>(EltPtr);
3200 }
3202 auto EltVal = *reinterpret_cast<const uint16_t *>(EltPtr);
3204 }
3206 auto EltVal = *reinterpret_cast<const uint32_t *>(EltPtr);
3208 }
3210 auto EltVal = *reinterpret_cast<const uint64_t *>(EltPtr);
3212 }
3213 }
3214}
3215
3218 "Accessor can only be used when element is a 'float'");
3219 return *reinterpret_cast<const float *>(getElementPointer(Elt));
3220}
3221
3224 "Accessor can only be used when element is a 'float'");
3225 return *reinterpret_cast<const double *>(getElementPointer(Elt));
3226}
3227
3235
3239
3242 return false;
3243
3245
3246
3247 if (Str.back() != 0) return false;
3248
3249
3250 return !Str.drop_back().contains(0);
3251}
3252
3253bool ConstantDataVector::isSplatData() const {
3255
3256
3258 for (unsigned i = 1, e = getNumElements(); i != e; ++i)
3260 return false;
3261
3262 return true;
3263}
3264
3266 if (!IsSplatSet) {
3267 IsSplatSet = true;
3268 IsSplat = isSplatData();
3269 }
3270 return IsSplat;
3271}
3272
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3293 Value *Replacement = nullptr;
3295 default:
3297#define HANDLE_CONSTANT(Name) \
3298 case Value::Name##Val: \
3299 Replacement = cast(this)->handleOperandChangeImpl(From, To); \
3300 break;
3301#include "llvm/IR/Value.def"
3302 }
3303
3304
3305
3306 if (!Replacement)
3307 return;
3308
3309
3310 assert(Replacement != this && "I didn't contain From!");
3311
3312
3314
3315
3317}
3318
3319Value *ConstantArray::handleOperandChangeImpl(Value *From, Value *To) {
3320 assert(isa(To) && "Cannot make Constant refer to non-constant!");
3322
3325
3326
3327
3328 unsigned NumUpdated = 0;
3329
3330
3331 bool AllSame = true;
3333 unsigned OperandNo = 0;
3334 for (Use *O = OperandList, *E = OperandList+getNumOperands(); O != E; ++O) {
3336 if (Val == From) {
3337 OperandNo = (O - OperandList);
3338 Val = ToC;
3339 ++NumUpdated;
3340 }
3342 AllSame &= Val == ToC;
3343 }
3344
3347
3350
3351
3353 return C;
3354
3355
3357 Values, this, From, ToC, NumUpdated, OperandNo);
3358}
3359
3360Value *ConstantStruct::handleOperandChangeImpl(Value *From, Value *To) {
3361 assert(isa(To) && "Cannot make Constant refer to non-constant!");
3363
3365
3368
3369
3370
3371 unsigned NumUpdated = 0;
3372 bool AllSame = true;
3373 unsigned OperandNo = 0;
3374 for (Use *O = OperandList, *E = OperandList + getNumOperands(); O != E; ++O) {
3376 if (Val == From) {
3377 OperandNo = (O - OperandList);
3378 Val = ToC;
3379 ++NumUpdated;
3380 }
3382 AllSame &= Val == ToC;
3383 }
3384
3387
3390
3391
3393 Values, this, From, ToC, NumUpdated, OperandNo);
3394}
3395
3396Value *ConstantVector::handleOperandChangeImpl(Value *From, Value *To) {
3397 assert(isa(To) && "Cannot make Constant refer to non-constant!");
3399
3402 unsigned NumUpdated = 0;
3403 unsigned OperandNo = 0;
3404 for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
3406 if (Val == From) {
3407 OperandNo = i;
3408 ++NumUpdated;
3409 Val = ToC;
3410 }
3412 }
3413
3414 if (Constant *C = getImpl(Values))
3415 return C;
3416
3417
3419 Values, this, From, ToC, NumUpdated, OperandNo);
3420}
3421
3422Value *ConstantExpr::handleOperandChangeImpl(Value *From, Value *ToV) {
3423 assert(isa(ToV) && "Cannot make Constant refer to non-constant!");
3425
3427 unsigned NumUpdated = 0;
3428 unsigned OperandNo = 0;
3429 for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
3431 if (Op == From) {
3432 OperandNo = i;
3433 ++NumUpdated;
3434 Op = To;
3435 }
3437 }
3438 assert(NumUpdated && "I didn't contain From!");
3439
3441 return C;
3442
3443
3445 NewOps, this, From, To, NumUpdated, OperandNo);
3446}
3447
3451
3453 case Instruction::Trunc:
3454 case Instruction::PtrToAddr:
3455 case Instruction::PtrToInt:
3456 case Instruction::IntToPtr:
3457 case Instruction::BitCast:
3458 case Instruction::AddrSpaceCast:
3461 case Instruction::InsertElement:
3463 case Instruction::ExtractElement:
3465 case Instruction::ShuffleVector:
3467
3468 case Instruction::GetElementPtr: {
3471 Ops.slice(1), GO->getNoWrapFlags(), "");
3472 }
3473 default:
3482 }
3485 return BO;
3486 }
3487}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the StringMap class.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::values(clEnumValN(DefaultIT, "arm-default-it", "Generate any type of IT block"), clEnumValN(RestrictedIT, "arm-restrict-it", "Disallow complex IT blocks")))
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static bool isAllZeros(StringRef Arr)
Return true if the array is empty or all zeros.
Definition Constants.cpp:2908
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)
Definition Constants.cpp:1273
static bool rangeOnlyContains(ItTy Start, ItTy End, EltTy Elt)
Definition Constants.cpp:1252
static Constant * getIntSequenceIfElementsMatch(ArrayRef< Constant * > V)
Definition Constants.cpp:1260
static Constant * getSequenceIfElementsMatch(Constant *C, ArrayRef< Constant * > V)
Definition Constants.cpp:1286
static bool ConstHasGlobalValuePredicate(const Constant *C, bool(*Predicate)(const GlobalValue *))
Check if C contains a GlobalValue for which Predicate is true.
Definition Constants.cpp:619
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.
Definition Constants.cpp:730
static bool containsUndefinedElement(const Constant *C, function_ref< bool(const Constant *)> HasFn)
Definition Constants.cpp:340
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...
Definition Constants.cpp:2226
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...
static char getTypeID(Type *Ty)
This file contains the declaration of the GlobalIFunc class, which represents a single indirect funct...
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
static bool isUndef(const MachineInstr &MI)
Merge contiguous icmps into a memcmp
static bool InRange(int64_t Value, unsigned short Shift, int LBound, int HBound)
uint64_t IntrinsicInst * II
static unsigned getNumElements(Type *Ty)
This file defines the SmallVector class.
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
static SymbolRef::Type getType(const Symbol *Sym)
static Function * getFunction(FunctionType *Ty, const Twine &Name, Module *M)
static const fltSemantics & IEEEsingle()
static const fltSemantics & BFloat()
static const fltSemantics & IEEEquad()
static const fltSemantics & IEEEdouble()
static const fltSemantics & x87DoubleExtended()
static constexpr roundingMode rmNearestTiesToEven
static const fltSemantics & IEEEhalf()
static const fltSemantics & PPCDoubleDouble()
static APFloat getQNaN(const fltSemantics &Sem, bool Negative=false, const APInt *payload=nullptr)
Factory for QNaN values.
static APFloat getSNaN(const fltSemantics &Sem, bool Negative=false, const APInt *payload=nullptr)
Factory for SNaN values.
LLVM_ABI opStatus convert(const fltSemantics &ToSemantics, roundingMode RM, bool *losesInfo)
static LLVM_ABI APFloat getAllOnesValue(const fltSemantics &Semantics)
Returns a float which is bitcasted from an all one value int.
const fltSemantics & getSemantics() const
static APFloat getInf(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Infinity.
static APFloat getNaN(const fltSemantics &Sem, bool Negative=false, uint64_t payload=0)
Factory for NaN values.
static APFloat getZero(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Zero.
Class for arbitrary precision integers.
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
unsigned logBase2() const
bool isPowerOf2() const
Check if this APInt's value is a power of two greater than zero.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
Class to represent array types.
static LLVM_ABI ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
LLVM Basic Block Representation.
const Function * getParent() const
Return the enclosing method, or null if none.
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches,...
LLVM_ABI LLVMContext & getContext() const
Get the context in which this basic block lives.
BinaryConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to impleme...
static LLVM_ABI BinaryOperator * Create(BinaryOps Op, Value *S1, Value *S2, const Twine &Name=Twine(), InsertPosition InsertBefore=nullptr)
Construct a binary instruction, given the opcode and the two operands.
The address of a basic block.
static LLVM_ABI BlockAddress * lookup(const BasicBlock *BB)
Lookup an existing BlockAddress constant for the given BasicBlock.
Definition Constants.cpp:1943
BasicBlock * getBasicBlock() const
static LLVM_ABI BlockAddress * get(Function *F, BasicBlock *BB)
Return a BlockAddress for the specified function and basic block.
Definition Constants.cpp:1932
CastConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to implement...
static LLVM_ABI CastInst * Create(Instruction::CastOps, Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Provides a way to construct any of the CastInst subclasses using an opcode instead of the subclass's ...
static LLVM_ABI bool castIsValid(Instruction::CastOps op, Type *SrcTy, Type *DstTy)
This method can be used to determine if a cast from SrcTy to DstTy using Opcode op is valid or not.
All zero aggregate value.
LLVM_ABI ElementCount getElementCount() const
Return the number of elements in the array, vector, or struct.
Definition Constants.cpp:1177
LLVM_ABI Constant * getSequentialElement() const
If this CAZ has array or vector type, return a zero with the right element type.
Definition Constants.cpp:1155
LLVM_ABI Constant * getElementValue(Constant *C) const
Return a zero of the right value for the specified GEP index if we can, otherwise return null (e....
Definition Constants.cpp:1165
LLVM_ABI Constant * getStructElement(unsigned Elt) const
If this CAZ has struct type, return a zero with the right element type for the specified element.
Definition Constants.cpp:1161
static LLVM_ABI ConstantAggregateZero * get(Type *Ty)
Definition Constants.cpp:1698
Base class for aggregate constants (with operands).
LLVM_ABI ConstantAggregate(Type *T, ValueTy VT, ArrayRef< Constant * > V, AllocInfo AllocInfo)
Definition Constants.cpp:1312
ConstantArray - Constant Array Declarations.
static LLVM_ABI Constant * get(ArrayType *T, ArrayRef< Constant * > V)
Definition Constants.cpp:1335
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 LLVM_ABI Constant * getString(LLVMContext &Context, StringRef Initializer, bool AddNull=true)
This method constructs a CDS and initializes it with a text string.
Definition Constants.cpp:3020
static Constant * get(LLVMContext &Context, ArrayRef< ElementTy > Elts)
get() constructor - Return a constant with array type with an element count and element type matching...
static LLVM_ABI Constant * getFP(Type *ElementType, ArrayRef< uint16_t > Elts)
getFP() constructors - Return a constant of array type with a float element type taken from argument ...
Definition Constants.cpp:2999
LLVM_ABI APFloat getElementAsAPFloat(uint64_t i) const
If this is a sequential container of floating point type, return the specified element as an APFloat.
Definition Constants.cpp:3191
LLVM_ABI uint64_t getElementAsInteger(uint64_t i) const
If this is a sequential container of integers (of any size), return the specified element in the low ...
Definition Constants.cpp:3143
StringRef getAsString() const
If this array is isString(), then this method returns the array as a StringRef.
LLVM_ABI Constant * getElementAsConstant(uint64_t i) const
Return a Constant for a specified index's element.
Definition Constants.cpp:3228
LLVM_ABI uint64_t getElementByteSize() const
Return the size (in bytes) of each element in the array/vector.
Definition Constants.cpp:2897
LLVM_ABI float getElementAsFloat(uint64_t i) const
If this is an sequential container of floats, return the specified element as a float.
Definition Constants.cpp:3216
LLVM_ABI bool isString(unsigned CharSize=8) const
This method returns true if this is an array of CharSize integers.
Definition Constants.cpp:3236
LLVM_ABI uint64_t getNumElements() const
Return the number of elements in the array or vector.
Definition Constants.cpp:2891
LLVM_ABI APInt getElementAsAPInt(uint64_t i) const
If this is a sequential container of integers (of any size), return the specified element as an APInt...
Definition Constants.cpp:3163
static LLVM_ABI Constant * getImpl(StringRef Bytes, Type *Ty)
This is the underlying implementation of all of the ConstantDataSequential::get methods.
Definition Constants.cpp:2919
LLVM_ABI double getElementAsDouble(uint64_t i) const
If this is an sequential container of doubles, return the specified element as a double.
Definition Constants.cpp:3222
LLVM_ABI Type * getElementType() const
Return the element type of the array/vector.
Definition Constants.cpp:2865
LLVM_ABI bool isCString() const
This method returns true if the array "isString", ends with a null byte, and does not contains any ot...
Definition Constants.cpp:3240
LLVM_ABI StringRef getRawDataValues() const
Return the raw, underlying, bytes of this data.
Definition Constants.cpp:2871
static LLVM_ABI bool isElementTypeCompatible(Type *Ty)
Return true if a ConstantDataSequential can be formed with a vector or array of the specified element...
Definition Constants.cpp:2875
A vector constant whose element type is a simple 1/2/4/8-byte integer or float/double,...
LLVM_ABI Constant * getSplatValue() const
If this is a splat constant, meaning that all of the elements have the same value,...
Definition Constants.cpp:3273
static LLVM_ABI Constant * getSplat(unsigned NumElts, Constant *Elt)
Return a ConstantVector with the specified constant in each element.
Definition Constants.cpp:3097
LLVM_ABI bool isSplat() const
Returns true if this is a splat constant, meaning that all elements have the same value.
Definition Constants.cpp:3265
static LLVM_ABI Constant * get(LLVMContext &Context, ArrayRef< uint8_t > Elts)
get() constructors - Return a constant with vector type with an element count and element type matchi...
Definition Constants.cpp:3036
static LLVM_ABI Constant * getFP(Type *ElementType, ArrayRef< uint16_t > Elts)
getFP() constructors - Return a constant of vector type with a float element type taken from argument...
Definition Constants.cpp:3073
Base class for constants with no operands.
A constant value that is initialized with an expression using other constant values.
static LLVM_ABI Constant * getIntToPtr(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition Constants.cpp:2345
static LLVM_ABI Constant * getExtractElement(Constant *Vec, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
Definition Constants.cpp:2595
ConstantExpr(Type *ty, unsigned Opcode, AllocInfo AllocInfo)
static LLVM_ABI Constant * getAlignOf(Type *Ty)
getAlignOf constant expr - computes the alignment of a type in a target independent way (Note: the re...
Definition Constants.cpp:2531
friend struct ConstantExprKeyType
static LLVM_ABI Constant * getPointerCast(Constant *C, Type *Ty)
Create a BitCast, AddrSpaceCast, or a PtrToInt cast constant expression.
Definition Constants.cpp:2277
static LLVM_ABI Constant * getTruncOrBitCast(Constant *C, Type *Ty)
Definition Constants.cpp:2271
static LLVM_ABI Constant * getPointerBitCastOrAddrSpaceCast(Constant *C, Type *Ty)
Create a BitCast or AddrSpaceCast for a pointer type depending on the address space.
Definition Constants.cpp:2292
LLVM_ABI bool isCast() const
Return true if this is a convert constant expression.
Definition Constants.cpp:1562
static LLVM_ABI Constant * getIdentity(Instruction *I, Type *Ty, bool AllowRHSConstant=false, bool NSZ=false)
Return the identity constant for a binary or intrinsic Instruction.
Definition Constants.cpp:2787
static LLVM_ABI bool isDesirableCastOp(unsigned Opcode)
Whether creating a constant expression for this cast is desirable.
Definition Constants.cpp:2474
LLVM_ABI Constant * getShuffleMaskForBitcode() const
Assert that this is a shufflevector and return the mask.
Definition Constants.cpp:1568
static LLVM_ABI Constant * getBinOpAbsorber(unsigned Opcode, Type *Ty, bool AllowLHSConstant=false)
Return the absorbing element for the given binary operation, i.e.
Definition Constants.cpp:2796
static LLVM_ABI Constant * getCast(unsigned ops, Constant *C, Type *Ty, bool OnlyIfReduced=false)
Convenience function for getting a Cast operation.
Definition Constants.cpp:2244
static LLVM_ABI Constant * getSub(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition Constants.cpp:2685
static LLVM_ABI Constant * getNot(Constant *C)
Definition Constants.cpp:2672
LLVM_ABI const char * getOpcodeName() const
Return a string representation for an opcode.
Definition Constants.cpp:2833
static LLVM_ABI Constant * getInsertElement(Constant *Vec, Constant *Elt, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
Definition Constants.cpp:2617
static LLVM_ABI Constant * getPtrToInt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition Constants.cpp:2331
static LLVM_ABI Constant * getPtrToAddr(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition Constants.cpp:2317
static LLVM_ABI Constant * getShuffleVector(Constant *V1, Constant *V2, ArrayRef< int > Mask, Type *OnlyIfReducedTy=nullptr)
Definition Constants.cpp:2640
static LLVM_ABI Constant * getSizeOf(Type *Ty)
getSizeOf constant expr - computes the (alloc) size of a type (in address-units, not bits) in a targe...
Definition Constants.cpp:2520
static bool isSupportedGetElementPtr(const Type *SrcElemTy)
Whether creating a constant expression for this getelementptr type is supported.
static LLVM_ABI Constant * getIntrinsicIdentity(Intrinsic::ID, Type *Ty)
Definition Constants.cpp:2770
static LLVM_ABI Constant * getXor(Constant *C1, Constant *C2)
Definition Constants.cpp:2692
static LLVM_ABI Constant * get(unsigned Opcode, Constant *C1, Constant *C2, unsigned Flags=0, Type *OnlyIfReducedTy=nullptr)
get - Return a binary or shift operator constant expression, folding if possible.
Definition Constants.cpp:2378
static LLVM_ABI bool isDesirableBinOp(unsigned Opcode)
Whether creating a constant expression for this binary operator is desirable.
Definition Constants.cpp:2420
LLVM_ABI ArrayRef< int > getShuffleMask() const
Assert that this is a shufflevector and return the mask.
Definition Constants.cpp:1564
static LLVM_ABI bool isSupportedBinOp(unsigned Opcode)
Whether creating a constant expression for this binary operator is supported.
Definition Constants.cpp:2447
static LLVM_ABI Constant * getAddrSpaceCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition Constants.cpp:2371
unsigned getOpcode() const
Return the opcode at the root of this constant expression.
static Constant * getGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList, GEPNoWrapFlags NW=GEPNoWrapFlags::none(), std::optional< ConstantRange > InRange=std::nullopt, Type *OnlyIfReducedTy=nullptr)
Getelementptr form.
static LLVM_ABI Constant * getAdd(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition Constants.cpp:2678
static LLVM_ABI Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition Constants.cpp:2359
static LLVM_ABI Constant * getBinOpIdentity(unsigned Opcode, Type *Ty, bool AllowRHSConstant=false, bool NSZ=false)
Return the identity constant for a binary opcode.
Definition Constants.cpp:2725
static LLVM_ABI bool isSupportedCastOp(unsigned Opcode)
Whether creating a constant expression for this cast is supported.
Definition Constants.cpp:2497
static LLVM_ABI Constant * getNeg(Constant *C, bool HasNSW=false)
Definition Constants.cpp:2666
static LLVM_ABI Constant * getTrunc(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition Constants.cpp:2303
static LLVM_ABI Constant * getExactLogBase2(Constant *C)
If C is a scalar/fixed width vector of known powers of 2, then this function returns a new scalar/fix...
Definition Constants.cpp:2696
Constant * getWithOperands(ArrayRef< Constant * > Ops) const
This returns the current constant expression with the operands replaced with the specified values.
LLVM_ABI Instruction * getAsInstruction() const
Returns an Instruction which implements the same operation as this ConstantExpr.
Definition Constants.cpp:3448
ConstantFP - Floating Point Values [float, double].
static LLVM_ABI Constant * getSNaN(Type *Ty, bool Negative=false, APInt *Payload=nullptr)
Definition Constants.cpp:1069
static LLVM_ABI Constant * getInfinity(Type *Ty, bool Negative=false)
Definition Constants.cpp:1126
static LLVM_ABI Constant * getZero(Type *Ty, bool Negative=false)
Definition Constants.cpp:1080
static LLVM_ABI Constant * getNaN(Type *Ty, bool Negative=false, uint64_t Payload=0)
Definition Constants.cpp:1047
LLVM_ABI bool isExactlyValue(const APFloat &V) const
We don't rely on operator== working on double values, as it returns true for things that are clearly ...
Definition Constants.cpp:1142
static LLVM_ABI bool isValueValidForType(Type *Ty, const APFloat &V)
Return true if Ty is big enough to represent V.
Definition Constants.cpp:1637
static LLVM_ABI Constant * getQNaN(Type *Ty, bool Negative=false, APInt *Payload=nullptr)
Definition Constants.cpp:1058
This is the shared class of boolean and integer constants.
static LLVM_ABI bool isValueValidForType(Type *Ty, uint64_t V)
This static method returns true if the type Ty is big enough to represent the value V.
Definition Constants.cpp:1623
static LLVM_ABI ConstantInt * getTrue(LLVMContext &Context)
Definition Constants.cpp:888
static LLVM_ABI ConstantInt * getFalse(LLVMContext &Context)
Definition Constants.cpp:895
unsigned getBitWidth() const
getBitWidth - Return the scalar bitwidth of this constant.
static LLVM_ABI ConstantInt * getBool(LLVMContext &Context, bool V)
Definition Constants.cpp:902
A constant pointer value that points to null.
static LLVM_ABI ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
Definition Constants.cpp:1854
PointerType * getType() const
Specialize the getType() method to always return an PointerType, which reduces the amount of casting ...
A signed pointer, in the ptrauth sense.
Constant * getAddrDiscriminator() const
The address discriminator if any, or the null constant.
friend struct ConstantPtrAuthKeyType
LLVM_ABI bool isKnownCompatibleWith(const Value *Key, const Value *Discriminator, const DataLayout &DL) const
Check whether an authentication operation with key Key and (possibly blended) discriminator Discrimin...
Definition Constants.cpp:2156
LLVM_ABI bool hasSpecialAddressDiscriminator(uint64_t Value) const
Whether the address uses a special address discriminator.
Definition Constants.cpp:2144
static LLVM_ABI ConstantPtrAuth * get(Constant *Ptr, ConstantInt *Key, ConstantInt *Disc, Constant *AddrDisc, Constant *DeactivationSymbol)
Return a pointer signed with the specified parameters.
Definition Constants.cpp:2084
LLVM_ABI ConstantPtrAuth * getWithSameSchema(Constant *Pointer) const
Produce a new ptrauth expression signing the given value using the same schema as is stored in one.
Definition Constants.cpp:2093
ConstantInt * getKey() const
The Key ID, an i32 constant.
Constant * getDeactivationSymbol() const
bool hasAddressDiscriminator() const
Whether there is any non-null address discriminator.
ConstantInt * getDiscriminator() const
The integer discriminator, an i64 constant, or 0.
This class represents a range of values.
LLVM_ABI ConstantRange unionWith(const ConstantRange &CR, PreferredRangeType Type=Smallest) const
Return the range that results from the union of this range with another range.
static LLVM_ABI Constant * get(StructType *T, ArrayRef< Constant * > V)
Definition Constants.cpp:1401
static LLVM_ABI StructType * getTypeForElements(ArrayRef< Constant * > V, bool Packed=false)
Return an anonymous struct type to use for a constant with the specified set of elements.
Definition Constants.cpp:1386
StructType * getType() const
Specialization - reduce amount of casting.
static LLVM_ABI ConstantTargetNone * get(TargetExtType *T)
Static factory methods - Return objects of the specified value.
Definition Constants.cpp:1871
TargetExtType * getType() const
Specialize the getType() method to always return an TargetExtType, which reduces the amount of castin...
A constant token which is empty.
static LLVM_ABI ConstantTokenNone * get(LLVMContext &Context)
Return the ConstantTokenNone.
Definition Constants.cpp:1547
void remove(ConstantClass *CP)
Remove this constant from the map.
ConstantClass * replaceOperandsInPlace(ArrayRef< Constant * > Operands, ConstantClass *CP, Value *From, Constant *To, unsigned NumUpdated=0, unsigned OperandNo=~0u)
Constant Vector Declarations.
FixedVectorType * getType() const
Specialize the getType() method to always return a FixedVectorType, which reduces the amount of casti...
LLVM_ABI Constant * getSplatValue(bool AllowPoison=false) const
If all elements of the vector constant have the same value, return that value.
Definition Constants.cpp:1772
static LLVM_ABI Constant * getSplat(ElementCount EC, Constant *Elt)
Return a ConstantVector with the specified constant in each element.
Definition Constants.cpp:1495
static LLVM_ABI Constant * get(ArrayRef< Constant * > V)
Definition Constants.cpp:1444
This is an important base class in LLVM.
static LLVM_ABI Constant * getIntegerValue(Type *Ty, const APInt &V)
Return the value for an integer or pointer constant, or a vector thereof, with the given scalar value...
Definition Constants.cpp:420
LLVM_ABI bool hasExactInverseFP() const
Return true if this scalar has an exact multiplicative inverse or this vector has an exact multiplica...
Definition Constants.cpp:273
static LLVM_ABI Constant * replaceUndefsWith(Constant *C, Constant *Replacement)
Try to replace undefined constant C or undefined elements in C with Replacement.
Definition Constants.cpp:804
LLVM_ABI Constant * getSplatValue(bool AllowPoison=false) const
If all elements of the vector constant have the same value, return that value.
Definition Constants.cpp:1734
LLVM_ABI bool containsUndefElement() const
Return true if this is a vector constant that includes any strictly undef (not poison) elements.
Definition Constants.cpp:371
static LLVM_ABI Constant * mergeUndefsWith(Constant *C, Constant *Other)
Merges undefs of a Constant with another Constant, along with the undefs already present.
Definition Constants.cpp:828
LLVM_ABI ConstantRange toConstantRange() const
Convert constant to an approximate constant range.
Definition Constants.cpp:1813
static LLVM_ABI Constant * getAllOnesValue(Type *Ty)
Definition Constants.cpp:437
LLVM_ABI bool hasZeroLiveUses() const
Return true if the constant has no live uses.
Definition Constants.cpp:788
LLVM_ABI bool isOneValue() const
Returns true if the value is one.
Definition Constants.cpp:124
LLVM_ABI bool isManifestConstant() const
Return true if a constant is ConstantData or a ConstantAggregate or ConstantExpr that contain only Co...
Definition Constants.cpp:863
LLVM_ABI bool isNegativeZeroValue() const
Return true if the value is what would be returned by getZeroValueForNegation.
Definition Constants.cpp:56
LLVM_ABI bool isAllOnesValue() const
Return true if this is the value that would be returned by getAllOnesValue.
Definition Constants.cpp:107
Constant(Type *ty, ValueTy vty, AllocInfo AllocInfo)
LLVM_ABI bool isMaxSignedValue() const
Return true if the value is the largest signed value.
Definition Constants.cpp:186
LLVM_ABI bool hasOneLiveUse() const
Return true if the constant has exactly one live use.
Definition Constants.cpp:786
LLVM_ABI bool needsRelocation() const
This method classifies the entry according to whether or not it may generate a relocation entry (eith...
Definition Constants.cpp:672
LLVM_ABI bool isDLLImportDependent() const
Return true if the value is dependent on a dllimport variable.
Definition Constants.cpp:649
LLVM_ABI const APInt & getUniqueInteger() const
If C is a constant integer then return its value, otherwise C must be a vector of constant integers,...
Definition Constants.cpp:1799
LLVM_ABI bool containsConstantExpression() const
Return true if this is a fixed width vector constant that includes any constant expressions.
Definition Constants.cpp:377
LLVM_ABI bool isFiniteNonZeroFP() const
Return true if this is a finite and non-zero floating-point scalar constant or a fixed width vector c...
Definition Constants.cpp:231
LLVM_ABI void removeDeadConstantUsers() const
If there are any dead constant users dangling off of this constant, remove them.
Definition Constants.cpp:759
LLVM_ABI bool isNormalFP() const
Return true if this is a normal (as opposed to denormal, infinity, nan, or zero) floating-point scala...
Definition Constants.cpp:252
LLVM_ABI bool needsDynamicRelocation() const
Definition Constants.cpp:668
static LLVM_ABI Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
Definition Constants.cpp:390
LLVM_ABI bool isNaN() const
Return true if this is a floating-point NaN constant or a vector floating-point constant with all NaN...
Definition Constants.cpp:294
LLVM_ABI bool isMinSignedValue() const
Return true if the value is the smallest signed value.
Definition Constants.cpp:169
LLVM_ABI bool isConstantUsed() const
Return true if the constant has users other than constant expressions and other dangling things.
Definition Constants.cpp:656
LLVM_ABI Constant * getAggregateElement(unsigned Elt) const
For aggregates (struct/array/vector) return the constant that corresponds to the specified element if...
Definition Constants.cpp:452
LLVM_ABI bool isThreadDependent() const
Return true if the value can vary between threads.
Definition Constants.cpp:642
LLVM_ABI bool isZeroValue() const
Return true if the value is negative zero or null value.
Definition Constants.cpp:76
LLVM_ABI void destroyConstant()
Called if some element of this constant is no longer valid.
Definition Constants.cpp:506
LLVM_ABI bool isNotMinSignedValue() const
Return true if the value is not the smallest signed value, or, for vectors, does not contain smallest...
Definition Constants.cpp:203
LLVM_ABI bool isNullValue() const
Return true if this is the value that would be returned by getNullValue.
Definition Constants.cpp:90
LLVM_ABI bool isNotOneValue() const
Return true if the value is not the one value, or, for vectors, does not contain one value elements.
Definition Constants.cpp:141
LLVM_ABI bool isElementWiseEqual(Value *Y) const
Return true if this constant and a constant 'Y' are element-wise equal.
Definition Constants.cpp:315
LLVM_ABI bool containsUndefOrPoisonElement() const
Return true if this is a vector constant that includes any undef or poison elements.
Definition Constants.cpp:361
LLVM_ABI bool containsPoisonElement() const
Return true if this is a vector constant that includes any poison elements.
Definition Constants.cpp:366
LLVM_ABI void handleOperandChange(Value *, Value *)
This method is a special form of User::replaceUsesOfWith (which does not work on constants) that does...
Definition Constants.cpp:3292
Wrapper for a function that represents a value that functionally represents the original function.
GlobalValue * getGlobalValue() const
static LLVM_ABI DSOLocalEquivalent * get(GlobalValue *GV)
Return a DSOLocalEquivalent for the specified global value.
Definition Constants.cpp:1982
A parsed version of the target data layout string in and methods for querying it.
static constexpr ElementCount getFixed(ScalarTy MinVal)
static LLVM_ABI FixedVectorType * get(Type *ElementType, unsigned NumElts)
Represents flags for the getelementptr instruction/expression.
GetElementPtrConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to ...
std::optional< ConstantRange > getInRange() const
Definition Constants.cpp:2858
Type * getResultElementType() const
Definition Constants.cpp:2854
Type * getSourceElementType() const
Definition Constants.cpp:2850
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
static Type * getGEPReturnType(Value *Ptr, ArrayRef< Value * > IdxList)
Returns the pointer type returned by the GEP instruction, which may be a vector of pointers.
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static LLVM_ABI Type * getIndexedType(Type *Ty, ArrayRef< Value * > IdxList)
Returns the result type of a getelementptr with the given source element type and indexes.
PointerType * getType() const
Global values are always pointers.
InsertElementConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to ...
static InsertElementInst * Create(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
LLVM_ABI void setHasNoUnsignedWrap(bool b=true)
Set or clear the nuw flag on this instruction, which must be an operator which supports this flag.
LLVM_ABI void setHasNoSignedWrap(bool b=true)
Set or clear the nsw flag on this instruction, which must be an operator which supports this flag.
LLVM_ABI bool isCommutative() const LLVM_READONLY
Return true if the instruction is commutative:
const char * getOpcodeName() const
LLVM_ABI void setIsExact(bool b=true)
Set or clear the exact flag on this instruction, which must be an operator which supports this flag.
Class to represent integer types.
static LLVM_ABI IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
A wrapper class for inspecting calls to intrinsic functions.
DenseMap< unsigned, std::unique_ptr< ConstantInt > > IntOneConstants
DenseMap< unsigned, std::unique_ptr< ConstantInt > > IntZeroConstants
DenseMap< 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< APInt, std::unique_ptr< ConstantInt > > IntConstants
std::unique_ptr< ConstantTokenNone > TheNoneToken
VectorConstantsTy VectorConstants
DenseMap< const GlobalValue *, NoCFIValue * > NoCFIValues
DenseMap< const BasicBlock *, BlockAddress * > BlockAddresses
DenseMap< Type *, std::unique_ptr< UndefValue > > UVConstants
StringMap< std::unique_ptr< ConstantDataSequential > > CDSConstants
StructConstantsTy StructConstants
ConstantUniqueMap< ConstantPtrAuth > ConstantPtrAuths
DenseMap< TargetExtType *, std::unique_ptr< ConstantTargetNone > > CTNConstants
ConstantUniqueMap< ConstantExpr > ExprConstants
ArrayConstantsTy ArrayConstants
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 LLVM_ABI NoCFIValue * get(GlobalValue *GV)
Return a NoCFIValue for the specified function.
Definition Constants.cpp:2040
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 LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Definition Constants.cpp:1906
LLVM_ABI PoisonValue * getStructElement(unsigned Elt) const
If this poison has struct type, return a poison with the right element type for the specified element...
Definition Constants.cpp:1231
LLVM_ABI PoisonValue * getSequentialElement() const
If this poison has array or vector type, return a poison with the right element type.
Definition Constants.cpp:1225
LLVM_ABI PoisonValue * getElementValue(Constant *C) const
Return an poison of the right value for the specified GEP index if we can, otherwise return null (e....
Definition Constants.cpp:1235
ShuffleVectorConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to ...
This instruction constructs a fixed permutation of two input vectors.
static LLVM_ABI bool isValidOperands(const Value *V1, const Value *V2, const Value *Mask)
Return true if a shufflevector instruction can be formed with the specified operands.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
void 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 LLVM_ABI StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
Class to represent target extensions types, which are generally unintrospectable from target-independ...
@ HasZeroInit
zeroinitializer is valid for this target extension type.
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)
bool isVectorTy() const
True if this is an instance of VectorType.
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
bool isPointerTy() const
True if this is an instance of PointerType.
LLVM_ABI unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
@ HalfTyID
16-bit floating point type
@ TargetExtTyID
Target extension type.
@ ScalableVectorTyID
Scalable SIMD vector type.
@ FloatTyID
32-bit floating point type
@ IntegerTyID
Arbitrary bit width integers.
@ FixedVectorTyID
Fixed width SIMD vector type.
@ BFloatTyID
16-bit floating point type (7-bit significand)
@ DoubleTyID
64-bit floating point type
@ X86_FP80TyID
80-bit floating point type (X87)
@ PPC_FP128TyID
128-bit floating point type (two 64-bits, PowerPC)
@ FP128TyID
128-bit floating point type (112-bit significand)
static LLVM_ABI Type * getFloatingPointTy(LLVMContext &C, const fltSemantics &S)
static LLVM_ABI IntegerType * getInt8Ty(LLVMContext &C)
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
LLVM_ABI TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
static LLVM_ABI IntegerType * getInt16Ty(LLVMContext &C)
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
LLVM_ABI unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
bool isIntegerTy() const
True if this is an instance of IntegerType.
static LLVM_ABI Type * getDoubleTy(LLVMContext &C)
static LLVM_ABI Type * getFloatTy(LLVMContext &C)
'undef' values are things that do not have specified contents.
LLVM_ABI UndefValue * getElementValue(Constant *C) const
Return an undef of the right value for the specified GEP index if we can, otherwise return null (e....
Definition Constants.cpp:1200
LLVM_ABI UndefValue * getStructElement(unsigned Elt) const
If this undef has struct type, return a undef with the right element type for the specified element.
Definition Constants.cpp:1196
static LLVM_ABI UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
Definition Constants.cpp:1887
LLVM_ABI unsigned getNumElements() const
Return the number of elements in the array, vector, or struct.
Definition Constants.cpp:1212
LLVM_ABI UndefValue * getSequentialElement() const
If this Undef has array or vector type, return a undef with the right element type.
Definition Constants.cpp:1190
A Use represents the edge between a Value definition and its users.
const Use * getOperandList() const
User(Type *ty, unsigned vty, AllocInfo AllocInfo)
void setOperand(unsigned i, Value *Val)
Value * getOperand(unsigned i) const
unsigned getNumOperands() const
iterator_range< value_op_iterator > operand_values()
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
user_iterator_impl< const User > const_user_iterator
user_iterator user_begin()
LLVM_ABI Value(Type *Ty, unsigned scid)
unsigned char SubclassOptionalData
Hold subclass data that can be dropped.
LLVM_ABI const Value * stripPointerCastsAndAliases() const
Strip off pointer casts, all-zero GEPs, address space casts, and aliases.
LLVM_ABI const Value * stripInBoundsConstantOffsets() const
Strip off pointer casts and all-constant inbounds GEPs.
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
iterator_range< user_iterator > users()
unsigned getValueID() const
Return an ID for the concrete type of this object.
LLVM_ABI const Value * stripAndAccumulateConstantOffsets(const DataLayout &DL, APInt &Offset, bool AllowNonInbounds, bool AllowInvariantGroup=false, function_ref< bool(Value &Value, APInt &Offset)> ExternalAnalysis=nullptr, bool LookThroughIntToPtr=false) const
Accumulate the constant offset this value has compared to a base pointer.
LLVM_ABI const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
LLVM_ABI 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.
static VectorType * getInteger(VectorType *VTy)
This static method gets a VectorType with the same number of elements as the input type,...
static LLVM_ABI VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
constexpr ScalarTy getFixedValue() const
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.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
ap_match< APInt > m_APInt(const APInt *&Res)
Match a ConstantInt or splatted ConstantVector, binding the specified pointer to the contained APInt.
bool match(Val *V, const Pattern &P)
specificval_ty m_Specific(const Value *V)
Match if we have a specific specified value.
cst_pred_ty< is_one > m_One()
Match an integer 1 or a vector with all elements equal to 1.
IntrinsicID_match m_Intrinsic()
Match intrinsic calls like this: m_IntrinsicIntrinsic::fabs(m_Value(X))
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
auto m_Undef()
Match an arbitrary undef constant.
initializer< Ty > init(const Ty &Val)
NodeAddr< UseNode * > Use
NodeAddr< NodeBase * > Node
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.
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
LLVM_ABI Constant * ConstantFoldCompareInstruction(CmpInst::Predicate Predicate, Constant *C1, Constant *C2)
constexpr bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
gep_type_iterator gep_type_end(const User *GEP)
void deleteConstant(Constant *C)
Definition Constants.cpp:546
LLVM_ABI Constant * ConstantFoldGetElementPtr(Type *Ty, Constant *C, std::optional< ConstantRange > InRange, ArrayRef< Value * > Idxs)
auto dyn_cast_or_null(const Y &Val)
LLVM_ABI Constant * ConstantFoldInsertElementInstruction(Constant *Val, Constant *Elt, Constant *Idx)
Attempt to constant fold an insertelement instruction with the specified operands and indices.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
LLVM_ABI Constant * ConstantFoldExtractElementInstruction(Constant *Val, Constant *Idx)
Attempt to constant fold an extractelement instruction with the specified operands and indices.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
OutputIt copy(R &&Range, OutputIt Out)
constexpr unsigned BitWidth
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
decltype(auto) cast(const From &Val)
cast - Return the argument parameter cast to the specified type.
gep_type_iterator gep_type_begin(const User *GEP)
constexpr bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
LLVM_ABI Constant * ConstantFoldCastInstruction(unsigned opcode, Constant *V, Type *DestTy)
LLVM_ABI Constant * ConstantFoldShuffleVectorInstruction(Constant *V1, Constant *V2, ArrayRef< int > Mask)
Attempt to constant fold a shufflevector instruction with the specified operands and mask.
LLVM_ABI Constant * ConstantFoldBinaryInstruction(unsigned Opcode, Constant *V1, Constant *V2)
Implement std::hash so that hash_code can be used in STL containers.
Summary of memprof metadata on allocations.
Information about how a User object was allocated, to be passed into the User constructor.