LLVM: lib/IR/Instructions.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
48#include
49#include
50#include
51#include
52#include
53
54using namespace llvm;
55
57 "disable-i2p-p2i-opt", cl::init(false),
58 cl::desc("Disables inttoptr/ptrtoint roundtrip optimization"));
59
60
61
62
63
64std::optional
69 if ()
70 return std::nullopt;
71 assert(.isScalable() && "Array elements cannot have a scalable size");
72 auto CheckedProd =
74 if (!CheckedProd)
75 return std::nullopt;
77 }
79}
80
81std::optional
85 return std::nullopt;
88 if (!CheckedProd)
89 return std::nullopt;
91}
92
93
94
95
96
97
98
101 return "both values to select must have same type";
102
104 return "select values cannot have token type";
105
107
109 return "vector select condition element type must be i1";
111 if (!ET)
112 return "selected values for vector select must be vectors";
114 return "vector select requires selected vectors to have "
115 "the same vector length as select condition";
117 return "select condition must be i1 or ";
118 }
119 return nullptr;
120}
121
122
123
124
125
126PHINode::PHINode(const PHINode &PN)
128 ReservedSpace(PN.getNumOperands()) {
134}
135
136
137
140
141
142
143
144
145
148
149
150 Op<-1>().set(nullptr);
152
153
155
158 }
159 return Removed;
160}
161
163 bool DeletePHIIfEmpty) {
166 if (Predicate(Idx))
167 RemoveIndices.insert(Idx);
168
169 if (RemoveIndices.empty())
170 return;
171
172
174 return RemoveIndices.contains(U.getOperandNo());
175 });
177 U.set(nullptr);
178
179
183 });
184
186
187
189
192 }
193}
194
195
196
197
198
199void PHINode::growOperands() {
201 unsigned NumOps = e + e / 2;
202 if (NumOps < 2) NumOps = 2;
203
204 ReservedSpace = NumOps;
206}
207
208
209
211
215 if (ConstantValue != this)
216 return nullptr;
217
219 }
220 if (ConstantValue == this)
222 return ConstantValue;
223}
224
225
226
227
228
229
231 Value *ConstantValue = nullptr;
235 if (ConstantValue && ConstantValue != Incoming)
236 return false;
238 }
239 }
240 return true;
241}
242
243
244
245
246
247LandingPadInst::LandingPadInst(Type *RetTy, unsigned NumReservedValues,
248 const Twine &NameStr,
251 init(NumReservedValues, NameStr);
252}
253
254LandingPadInst::LandingPadInst(const LandingPadInst &LP)
256 ReservedSpace(LP.getNumOperands()) {
261 for (unsigned I = 0, E = ReservedSpace; I != E; ++I)
263
265}
266
268 const Twine &NameStr,
270 return new LandingPadInst(RetTy, NumReservedClauses, NameStr, InsertBefore);
271}
272
273void LandingPadInst::init(unsigned NumReservedValues, const Twine &NameStr) {
274 ReservedSpace = NumReservedValues;
279}
280
281
282
283void LandingPadInst::growOperands(unsigned Size) {
285 if (ReservedSpace >= e + Size) return;
286 ReservedSpace = (std::max(e, 1U) + Size / 2) * 2;
288}
289
292 growOperands(1);
293 assert(OpNo < ReservedSpace && "Growing didn't work!");
296}
297
298
299
300
301
305 case Instruction::Call:
307 case Instruction::Invoke:
309 case Instruction::CallBr:
311 default:
313 }
314}
315
321 if (ChildOB.getTagName() != OpB.getTag())
323 }
326}
327
329
331 assert(getOpcode() == Instruction::CallBr && "Unexpected opcode!");
333}
334
341
342
343
346 return CI->isMustTailCall();
347 return false;
348}
349
350
353 return CI->isTailCall();
354 return false;
355}
356
359 return F->getIntrinsicID();
361}
362
365
367 Mask |= F->getAttributes().getRetNoFPClass();
368 return Mask;
369}
370
373
375 Mask |= F->getAttributes().getParamNoFPClass(i);
376 return Mask;
377}
378
380 Attribute CallAttr = Attrs.getRetAttr(Attribute::Range);
383 FnAttr = F->getRetAttribute(Attribute::Range);
384
389 if (FnAttr.isValid())
390 return FnAttr.getRange();
391 return std::nullopt;
392}
393
396 return true;
397
400 return true;
401
402 return false;
403}
404
406 unsigned Index;
407
408 if (Attrs.hasAttrSomewhere(Kind, &Index))
409 return getArgOperand(Index - AttributeList::FirstArgIndex);
411 if (F->getAttributes().hasAttrSomewhere(Kind, &Index))
412 return getArgOperand(Index - AttributeList::FirstArgIndex);
413
414 return nullptr;
415}
416
417
419 assert(ArgNo < arg_size() && "Param index out of bounds!");
420
421 if (Attrs.hasParamAttr(ArgNo, Kind))
422 return true;
423
425 if ()
426 return false;
427
428 if (->getAttributes().hasParamAttr(ArgNo, Kind))
429 return false;
430
431
432 switch (Kind) {
433 case Attribute::ReadNone:
435 case Attribute::ReadOnly:
437 case Attribute::WriteOnly:
439 default:
440 return true;
441 }
442}
443
445 bool AllowUndefOrPoison) const {
447 "Argument must be a pointer");
448 if (paramHasAttr(ArgNo, Attribute::NonNull) &&
449 (AllowUndefOrPoison || paramHasAttr(ArgNo, Attribute::NoUndef)))
450 return true;
451
452 if (paramHasAttr(ArgNo, Attribute::Dereferenceable) &&
456 return true;
457
458 return false;
459}
460
461bool CallBase::hasFnAttrOnCalledFunction(Attribute::AttrKind Kind) const {
463 return F->getAttributes().hasFnAttr(Kind);
464
465 return false;
466}
467
468bool CallBase::hasFnAttrOnCalledFunction(StringRef Kind) const {
470 return F->getAttributes().hasFnAttr(Kind);
471
472 return false;
473}
474
475template
476Attribute CallBase::getFnAttrOnCalledFunction(AK Kind) const {
477 if constexpr (std::is_same_v<AK, Attribute::AttrKind>) {
478
479
480 assert(Kind != Attribute::Memory && "Use getMemoryEffects() instead");
481 }
482
484 return F->getAttributes().getFnAttr(Kind);
485
487}
488
492CallBase::getFnAttrOnCalledFunction(StringRef Kind) const;
493
494template
495Attribute CallBase::getParamAttrOnCalledFunction(unsigned ArgNo,
496 AK Kind) const {
498
500 return F->getAttributes().getParamAttr(ArgNo, Kind);
501
503}
504template LLVM_ABI Attribute CallBase::getParamAttrOnCalledFunction(
507CallBase::getParamAttrOnCalledFunction(unsigned ArgNo, StringRef Kind) const;
508
514
517 const unsigned BeginIndex) {
518 auto It = op_begin() + BeginIndex;
519 for (auto &B : Bundles)
520 It = std::copy(B.input_begin(), B.input_end(), It);
521
523 auto BI = Bundles.begin();
524 unsigned CurrentIndex = BeginIndex;
525
527 assert(BI != Bundles.end() && "Incorrect allocation?");
528
529 BOI.Tag = ContextImpl->getOrInsertBundleTag(BI->getTag());
530 BOI.Begin = CurrentIndex;
531 BOI.End = CurrentIndex + BI->input_size();
532 CurrentIndex = BOI.End;
533 BI++;
534 }
535
536 assert(BI == Bundles.end() && "Incorrect allocation?");
537
538 return It;
539}
540
542
543
544
547 if (BOI.Begin <= OpIdx && OpIdx < BOI.End)
548 return BOI;
549
550 llvm_unreachable("Did not find operand bundle for operand!");
551 }
552
556 "The Idx isn't in the operand bundle");
557
558
559
560 constexpr unsigned NumberScaling = 1024;
561
565
566 while (Begin != End) {
567 unsigned ScaledOperandPerBundle =
568 NumberScaling * (std::prev(End)->End - Begin->Begin) / (End - Begin);
569 Current = Begin + (((OpIdx - Begin->Begin) * NumberScaling) /
570 ScaledOperandPerBundle);
571 if (Current >= End)
572 Current = std::prev(End);
573 assert(Current < End && Current >= Begin &&
574 "the operand bundle doesn't cover every value in the range");
576 break;
578 Begin = Current + 1;
579 else
580 End = Current;
581 }
582
584 "the operand bundle doesn't cover every value in the range");
585 return *Current;
586}
587
592 return CB;
593
597 return Create(CB, Bundles, InsertPt);
598}
599
603 bool CreateNew = false;
604
607 if (Bundle.getTagID() == ID) {
608 CreateNew = true;
609 continue;
610 }
612 }
613
614 return CreateNew ? Create(CB, Bundles, InsertPt) : CB;
615}
616
626
634
640
645 }
647
649 }
650 ME &= FnME;
651 }
652 return ME;
653}
657
658
665
666
673
674
681
682
683
690
691
692
699
700
701
709
712
713
716
719 CI &= Fn->getAttributes().getParamAttrs(OpNo).getCaptureInfo();
720 return CI;
721 }
722
723
727}
728
730 for (unsigned I = 0, E = arg_size(); I < E; ++I) {
732 continue;
733
736 CI &= Fn->getAttributes().getParamAttrs(I).getCaptureInfo();
738 return true;
739 }
740 return false;
741}
742
743
744
745
746
749 this->FTy = FTy;
751 "NumOperands not set up?");
752
753#ifndef NDEBUG
756 "Calling a function with bad signature!");
757
758 for (unsigned i = 0; i != Args.size(); ++i)
761 "Calling a function with a bad signature!");
762#endif
763
764
765
768
770 (void)It;
771 assert(It + 1 == op_end() && "Should add up!");
772
774}
775
777 this->FTy = FTy;
780
782
784}
785
789 InsertBefore) {
790 init(Ty, Func, Name);
791}
792
796 "Wrong number of operands allocated");
799
804}
805
809
811 Args, OpB, CI->getName(), InsertPt);
817 return NewCI;
818}
819
820
821
822
824 if (T == 0) {
825 LLVM_DEBUG(dbgs() << "Attempting to update profile weights will result in "
826 "div by 0. Ignoring. Likely the function "
828 << " has 0 entry count, and contains call instructions "
829 "with non-zero prof info.");
830 return;
831 }
833}
834
835
836
837
838
842 const Twine &NameStr) {
843 this->FTy = FTy;
844
847 "NumOperands not set up?");
848
849#ifndef NDEBUG
852 "Invoking a function with bad signature");
853
854 for (unsigned i = 0, e = Args.size(); i != e; i++)
857 "Invoking a function with a bad signature!");
858#endif
859
860
861
866
868 (void)It;
869 assert(It + 3 == op_end() && "Should add up!");
870
872}
873
877 "Wrong number of operands allocated");
879 std::copy(II.op_begin(), II.op_end(), op_begin());
880 std::copy(II.bundle_op_info_begin(), II.bundle_op_info_end(),
883}
884
887 std::vector<Value *> Args(II->arg_begin(), II->arg_end());
888
890 II->getFunctionType(), II->getCalledOperand(), II->getNormalDest(),
891 II->getUnwindDest(), Args, OpB, II->getName(), InsertPt);
892 NewII->setCallingConv(II->getCallingConv());
893 NewII->SubclassOptionalData = II->SubclassOptionalData;
894 NewII->setAttributes(II->getAttributes());
895 NewII->setDebugLoc(II->getDebugLoc());
896 return NewII;
897}
898
902
904 if (T == 0) {
905 LLVM_DEBUG(dbgs() << "Attempting to update profile weights will result in "
906 "div by 0. Ignoring. Likely the function "
908 << " has 0 entry count, and contains call instructions "
909 "with non-zero prof info.");
910 return;
911 }
913}
914
915
916
917
918
923 const Twine &NameStr) {
924 this->FTy = FTy;
925
927 IndirectDests.size(),
929 "NumOperands not set up?");
930
931#ifndef NDEBUG
934 "Calling a function with bad signature");
935
936 for (unsigned i = 0, e = Args.size(); i != e; i++)
939 "Calling a function with a bad signature!");
940#endif
941
942
943
945 NumIndirectDests = IndirectDests.size();
947 for (unsigned i = 0; i != NumIndirectDests; ++i)
950
952 (void)It;
953 assert(It + 2 + IndirectDests.size() == op_end() && "Should add up!");
954
956}
957
962 "Wrong number of operands allocated");
968 NumIndirectDests = CBI.NumIndirectDests;
969}
970
974
982 NewCBI->NumIndirectDests = CBI->NumIndirectDests;
983 return NewCBI;
984}
985
986
987
988
989
994 "Wrong number of operands allocated");
998}
999
1003 InsertBefore) {
1004 if (retVal)
1005 Op<0>() = retVal;
1006}
1007
1008
1009
1010
1011
1012ResumeInst::ResumeInst(const ResumeInst &RI)
1014 AllocMarker) {
1016}
1017
1020 AllocMarker, InsertBefore) {
1022}
1023
1024
1025
1026
1027
1028CleanupReturnInst::CleanupReturnInst(const CleanupReturnInst &CRI,
1032 "Wrong number of operands allocated");
1033 setSubclassDataInstruction::OpaqueField(
1038}
1039
1040void CleanupReturnInst::init(Value *CleanupPad, BasicBlock *UnwindBB) {
1041 if (UnwindBB)
1042 setSubclassData(true);
1043
1044 Op<0>() = CleanupPad;
1045 if (UnwindBB)
1046 Op<1>() = UnwindBB;
1047}
1048
1049CleanupReturnInst::CleanupReturnInst(Value *CleanupPad, BasicBlock *UnwindBB,
1054 init(CleanupPad, UnwindBB);
1055}
1056
1057
1058
1059
1060void CatchReturnInst::init(Value *CatchPad, BasicBlock *BB) {
1061 Op<0>() = CatchPad;
1063}
1064
1065CatchReturnInst::CatchReturnInst(const CatchReturnInst &CRI)
1067 AllocMarker) {
1070}
1071
1072CatchReturnInst::CatchReturnInst(Value *CatchPad, BasicBlock *BB,
1075 AllocMarker, InsertBefore) {
1076 init(CatchPad, BB);
1077}
1078
1079
1080
1081
1082
1083CatchSwitchInst::CatchSwitchInst(Value *ParentPad, BasicBlock *UnwindDest,
1084 unsigned NumReservedValues,
1085 const Twine &NameStr,
1088 InsertBefore) {
1089 if (UnwindDest)
1090 ++NumReservedValues;
1091 init(ParentPad, UnwindDest, NumReservedValues + 1);
1093}
1094
1095CatchSwitchInst::CatchSwitchInst(const CatchSwitchInst &CSI)
1102 for (unsigned I = 1, E = ReservedSpace; I != E; ++I)
1104}
1105
1106void CatchSwitchInst::init(Value *ParentPad, BasicBlock *UnwindDest,
1107 unsigned NumReservedValues) {
1108 assert(ParentPad && NumReservedValues);
1109
1110 ReservedSpace = NumReservedValues;
1113
1114 Op<0>() = ParentPad;
1115 if (UnwindDest) {
1118 }
1119}
1120
1121
1122
1123void CatchSwitchInst::growOperands(unsigned Size) {
1125 assert(NumOperands >= 1);
1126 if (ReservedSpace >= NumOperands + Size)
1127 return;
1128 ReservedSpace = (NumOperands + Size / 2) * 2;
1130}
1131
1134 growOperands(1);
1135 assert(OpNo < ReservedSpace && "Growing didn't work!");
1138}
1139
1141
1143 for (Use *CurDst = HI.getCurrent(); CurDst != EndDst; ++CurDst)
1144 *CurDst = *(CurDst + 1);
1145
1146 *EndDst = nullptr;
1147
1149}
1150
1151
1152
1153
1155 const Twine &NameStr) {
1160}
1161
1165 "Wrong number of operands allocated");
1168}
1169
1172 const Twine &NameStr,
1175 init(ParentPad, Args, NameStr);
1176}
1177
1178
1179
1180
1181
1185 AllocMarker, InsertBefore) {}
1186
1187
1188
1189
1190
1191void BranchInst::AssertOK() {
1194 "May only branch on boolean predicates!");
1195}
1196
1201 assert(IfTrue && "Branch destination may not be null!");
1202 Op<-1>() = IfTrue;
1203}
1204
1209
1211 Op<-2>() = IfFalse;
1212 Op<-1>() = IfTrue;
1213#ifndef NDEBUG
1214 AssertOK();
1215#endif
1216}
1217
1222 "Wrong number of operands allocated");
1223
1228 }
1231}
1232
1235 "Cannot swap successors of an unconditional branch");
1237
1238
1239
1241}
1242
1243
1244
1245
1246
1248 if (!Amt)
1250 else {
1252 "Passed basic block into allocation size parameter! Use other ctor");
1254 "Allocation array size is not an integer!");
1255 }
1256 return Amt;
1257}
1258
1261 "Insertion position cannot be null when alignment not provided!");
1264 "BB must be in a Function when alignment not provided!");
1266 return DL.getPrefTypeAlign(Ty);
1267}
1268
1271 : AllocaInst(Ty, AddrSpace, nullptr, Name, InsertBefore) {}
1272
1275 : AllocaInst(Ty, AddrSpace, ArraySize,
1277 InsertBefore) {}
1278
1284 AllocatedType(Ty) {
1286 assert(!Ty->isVoidTy() && "Cannot allocate void!");
1288}
1289
1292 return !CI->isOne();
1293 return true;
1294}
1295
1296
1297
1298
1307
1308
1309
1310
1311
1312void LoadInst::AssertOK() {
1314 "Ptr must have pointer type.");
1315}
1316
1319 "Insertion position cannot be null when alignment not provided!");
1322 "BB must be in a Function when alignment not provided!");
1324 return DL.getABITypeAlign(Ty);
1325}
1326
1330
1335
1340
1351
1352
1353
1354
1355
1356void StoreInst::AssertOK() {
1359 "Ptr must have pointer type!");
1360}
1361
1364
1370
1375
1380 InsertBefore) {
1386 AssertOK();
1387}
1388
1389
1390
1391
1392
1399 Op<2>() = NewVal;
1404
1406 "All operands must be non-null!");
1408 "Ptr must have pointer type!");
1410 "Cmp type and NewVal type must be same!");
1411}
1412
1414 Align Alignment,
1421 AtomicCmpXchg, AllocMarker, InsertBefore) {
1422 Init(Ptr, Cmp, NewVal, Alignment, SuccessOrdering, FailureOrdering, SSID);
1423}
1424
1425
1426
1427
1428
1433 "atomicrmw instructions can only be atomic.");
1435 "atomicrmw instructions cannot be unordered.");
1442
1445 "Ptr must have pointer type!");
1447 "AtomicRMW instructions must be atomic!");
1448}
1449
1456
1458 switch (Op) {
1460 return "xchg";
1462 return "add";
1464 return "sub";
1466 return "and";
1468 return "nand";
1470 return "or";
1472 return "xor";
1474 return "max";
1476 return "min";
1478 return "umax";
1480 return "umin";
1482 return "fadd";
1484 return "fsub";
1486 return "fmax";
1488 return "fmin";
1490 return "fmaximum";
1492 return "fminimum";
1494 return "uinc_wrap";
1496 return "udec_wrap";
1498 return "usub_cond";
1500 return "usub_sat";
1502 return "";
1503 }
1504
1506}
1507
1508
1509
1510
1511
1514 : Instruction(Type::getVoidTy(C), Fence, AllocMarker, InsertBefore) {
1517}
1518
1519
1520
1521
1522
1524 const Twine &Name) {
1526 "NumOperands not initialized?");
1530}
1531
1532GetElementPtrInst::GetElementPtrInst(const GetElementPtrInst &GEPI,
1535 SourceElementType(GEPI.SourceElementType),
1536 ResultElementType(GEPI.ResultElementType) {
1538 "Wrong number of operands allocated");
1541}
1542
1545 if (->indexValid(Idx))
1546 return nullptr;
1547 return Struct->getTypeAtIndex(Idx);
1548 }
1550 return nullptr;
1552 return Array->getElementType();
1554 return Vector->getElementType();
1555 return nullptr;
1556}
1557
1560 if (Idx >= Struct->getNumElements())
1561 return nullptr;
1562 return Struct->getElementType(Idx);
1563 }
1565 return Array->getElementType();
1567 return Vector->getElementType();
1568 return nullptr;
1569}
1570
1571template
1573 if (IdxList.empty())
1574 return Ty;
1575 for (IndexTy V : IdxList.slice(1)) {
1577 if (!Ty)
1578 return Ty;
1579 }
1580 return Ty;
1581}
1582
1586
1591
1595
1596
1597
1598
1600 for (unsigned i = 1, e = getNumOperands(); i != e; ++i) {
1602 if (!CI->isZero()) return false;
1603 } else {
1604 return false;
1605 }
1606 }
1607 return true;
1608}
1609
1610
1611
1612
1614 for (unsigned i = 1, e = getNumOperands(); i != e; ++i) {
1616 return false;
1617 }
1618 return true;
1619}
1620
1624
1627 if (B)
1629 else
1632}
1633
1637
1641
1645
1649
1655
1659 APInt &ConstantOffset) const {
1660
1662 ConstantOffset);
1663}
1664
1665
1666
1667
1668
1669ExtractElementInst::ExtractElementInst(Value *Val, Value *Index,
1670 const Twine &Name,
1673 ExtractElement, AllocMarker, InsertBef) {
1674 assert(isValidOperands(Val, Index) &&
1675 "Invalid extractelement instruction operands!");
1677 Op<1>() = Index;
1679}
1680
1682 if (!Val->getType()->isVectorTy() || !Index->getType()->isIntegerTy())
1683 return false;
1684 return true;
1685}
1686
1687
1688
1689
1690
1691InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index,
1692 const Twine &Name,
1694 : Instruction(Vec->getType(), InsertElement, AllocMarker, InsertBef) {
1696 "Invalid insertelement instruction operands!");
1699 Op<2>() = Index;
1701}
1702
1704 const Value *Index) {
1706 return false;
1707
1709 return false;
1710
1711 if (!Index->getType()->isIntegerTy())
1712 return false;
1713 return true;
1714}
1715
1716
1717
1718
1719
1721 assert(V && "Cannot create placeholder of nullptr V");
1723}
1724
1729
1731 const Twine &Name,
1734 InsertBefore) {}
1735
1737 const Twine &Name,
1742 ShuffleVector, AllocMarker, InsertBefore) {
1744 "Invalid shuffle vector instruction operands!");
1745
1752}
1753
1755 const Twine &Name,
1760 ShuffleVector, AllocMarker, InsertBefore) {
1762 "Invalid shuffle vector instruction operands!");
1767}
1768
1771 int NumMaskElts = ShuffleMask.size();
1773 for (int i = 0; i != NumMaskElts; ++i) {
1777 continue;
1778 }
1779 assert(MaskElt >= 0 && MaskElt < 2 * NumOpElts && "Out-of-range mask");
1780 MaskElt = (MaskElt < NumOpElts) ? MaskElt + NumOpElts : MaskElt - NumOpElts;
1781 NewMask[i] = MaskElt;
1782 }
1785}
1786
1789
1791 return false;
1792
1793
1794 int V1Size =
1796 for (int Elem : Mask)
1798 return false;
1799
1802 return false;
1803
1804 return true;
1805}
1806
1808 const Value *Mask) {
1809
1811 return false;
1812
1813
1814
1816 if (!MaskTy || !MaskTy->getElementType()->isIntegerTy(32) ||
1818 return false;
1819
1820
1822 return true;
1823
1824
1825
1827 return false;
1828
1830
1832 return !CI->uge(V1Size * 2);
1833
1835 for (Value *Op : MV->operands()) {
1837 if (CI->uge(V1Size*2))
1838 return false;
1840 return false;
1841 }
1842 }
1843 return true;
1844 }
1845
1848 i != e; ++i)
1849 if (CDS->getElementAsInteger(i) >= V1Size*2)
1850 return false;
1851 return true;
1852 }
1853
1854 return false;
1855}
1856
1860
1863 Result.append(EC.getKnownMinValue(), MaskVal);
1864 return;
1865 }
1866
1867 assert(!EC.isScalable() &&
1868 "Scalable vector shuffle mask must be undef or zeroinitializer");
1869
1870 unsigned NumElts = EC.getFixedValue();
1871
1872 Result.reserve(NumElts);
1873
1875 for (unsigned i = 0; i != NumElts; ++i)
1876 Result.push_back(CDS->getElementAsInteger(i));
1877 return;
1878 }
1879 for (unsigned i = 0; i != NumElts; ++i) {
1880 Constant *C = Mask->getAggregateElement(i);
1883 }
1884}
1885
1887 ShuffleMask.assign(Mask.begin(), Mask.end());
1889}
1890
1892 Type *ResultTy) {
1897 if (Mask[0] == 0)
1900 }
1902 for (int Elem : Mask) {
1905 else
1907 }
1909}
1910
1912 assert(!Mask.empty() && "Shuffle mask must contain elements");
1913 bool UsesLHS = false;
1914 bool UsesRHS = false;
1915 for (int I : Mask) {
1916 if (I == -1)
1917 continue;
1918 assert(I >= 0 && I < (NumOpElts * 2) &&
1919 "Out-of-bounds shuffle mask element");
1920 UsesLHS |= (I < NumOpElts);
1921 UsesRHS |= (I >= NumOpElts);
1922 if (UsesLHS && UsesRHS)
1923 return false;
1924 }
1925
1926 return UsesLHS || UsesRHS;
1927}
1928
1934
1937 return false;
1938 for (int i = 0, NumMaskElts = Mask.size(); i < NumMaskElts; ++i) {
1939 if (Mask[i] == -1)
1940 continue;
1941 if (Mask[i] != i && Mask[i] != (NumOpElts + i))
1942 return false;
1943 }
1944 return true;
1945}
1946
1948 if (Mask.size() != static_cast<unsigned>(NumSrcElts))
1949 return false;
1950
1951
1953}
1954
1956 if (Mask.size() != static_cast<unsigned>(NumSrcElts))
1957 return false;
1959 return false;
1960
1961
1962 if (NumSrcElts < 2)
1963 return false;
1964
1965 for (int I = 0, E = Mask.size(); I < E; ++I) {
1966 if (Mask[I] == -1)
1967 continue;
1968 if (Mask[I] != (NumSrcElts - 1 - I) &&
1969 Mask[I] != (NumSrcElts + NumSrcElts - 1 - I))
1970 return false;
1971 }
1972 return true;
1973}
1974
1976 if (Mask.size() != static_cast<unsigned>(NumSrcElts))
1977 return false;
1979 return false;
1980 for (int I = 0, E = Mask.size(); I < E; ++I) {
1981 if (Mask[I] == -1)
1982 continue;
1983 if (Mask[I] != 0 && Mask[I] != NumSrcElts)
1984 return false;
1985 }
1986 return true;
1987}
1988
1990 if (Mask.size() != static_cast<unsigned>(NumSrcElts))
1991 return false;
1992
1994 return false;
1995 for (int I = 0, E = Mask.size(); I < E; ++I) {
1996 if (Mask[I] == -1)
1997 continue;
1998 if (Mask[I] != I && Mask[I] != (NumSrcElts + I))
1999 return false;
2000 }
2001 return true;
2002}
2003
2005
2006
2007
2008
2009
2010
2011 if (Mask.size() != static_cast<unsigned>(NumSrcElts))
2012 return false;
2013
2014 int Sz = Mask.size();
2016 return false;
2017
2018
2019 if (Mask[0] != 0 && Mask[0] != 1)
2020 return false;
2021
2022
2023
2024 if ((Mask[1] - Mask[0]) != NumSrcElts)
2025 return false;
2026
2027
2028
2029 for (int I = 2; I < Sz; ++I) {
2030 int MaskEltVal = Mask[I];
2031 if (MaskEltVal == -1)
2032 return false;
2033 int MaskEltPrevVal = Mask[I - 2];
2034 if (MaskEltVal - MaskEltPrevVal != 2)
2035 return false;
2036 }
2037 return true;
2038}
2039
2041 int &Index) {
2042 if (Mask.size() != static_cast<unsigned>(NumSrcElts))
2043 return false;
2044
2045 int StartIndex = -1;
2046 for (int I = 0, E = Mask.size(); I != E; ++I) {
2047 int MaskEltVal = Mask[I];
2048 if (MaskEltVal == -1)
2049 continue;
2050
2051 if (StartIndex == -1) {
2052
2053
2054 if (MaskEltVal < I || NumSrcElts <= (MaskEltVal - I))
2055 return false;
2056
2057 StartIndex = MaskEltVal - I;
2058 continue;
2059 }
2060
2061
2062 if (MaskEltVal != (StartIndex + I))
2063 return false;
2064 }
2065
2066 if (StartIndex == -1)
2067 return false;
2068
2069
2070 Index = StartIndex;
2071 return true;
2072}
2073
2075 int NumSrcElts, int &Index) {
2076
2078 return false;
2079
2080
2081 if (NumSrcElts <= (int)Mask.size())
2082 return false;
2083
2084
2085 int SubIndex = -1;
2086 for (int i = 0, e = Mask.size(); i != e; ++i) {
2087 int M = Mask[i];
2088 if (M < 0)
2089 continue;
2090 int Offset = (M % NumSrcElts) - i;
2091 if (0 <= SubIndex && SubIndex != Offset)
2092 return false;
2094 }
2095
2096 if (0 <= SubIndex && SubIndex + (int)Mask.size() <= NumSrcElts) {
2097 Index = SubIndex;
2098 return true;
2099 }
2100 return false;
2101}
2102
2104 int NumSrcElts, int &NumSubElts,
2105 int &Index) {
2106 int NumMaskElts = Mask.size();
2107
2108
2109 if (NumMaskElts < NumSrcElts)
2110 return false;
2111
2112
2114 return false;
2115
2116
2120 bool Src0Identity = true;
2121 bool Src1Identity = true;
2122
2123 for (int i = 0; i != NumMaskElts; ++i) {
2124 int M = Mask[i];
2125 if (M < 0) {
2126 UndefElts.setBit(i);
2127 continue;
2128 }
2129 if (M < NumSrcElts) {
2131 Src0Identity &= (M == i);
2132 continue;
2133 }
2135 Src1Identity &= (M == (i + NumSrcElts));
2136 }
2137 assert((Src0Elts | Src1Elts | UndefElts).isAllOnes() &&
2138 "unknown shuffle elements");
2140 "2-source shuffle not found");
2141
2142
2143
2146 int Src0Hi = NumMaskElts - Src0Elts.countl_zero();
2147 int Src1Hi = NumMaskElts - Src1Elts.countl_zero();
2148
2149
2150
2151 if (Src0Identity) {
2152 int NumSub1Elts = Src1Hi - Src1Lo;
2153 ArrayRef Sub1Mask = Mask.slice(Src1Lo, NumSub1Elts);
2155 NumSubElts = NumSub1Elts;
2156 Index = Src1Lo;
2157 return true;
2158 }
2159 }
2160
2161
2162
2163 if (Src1Identity) {
2164 int NumSub0Elts = Src0Hi - Src0Lo;
2165 ArrayRef Sub0Mask = Mask.slice(Src0Lo, NumSub0Elts);
2167 NumSubElts = NumSub0Elts;
2168 Index = Src0Lo;
2169 return true;
2170 }
2171 }
2172
2173 return false;
2174}
2175
2177
2178
2180 return false;
2181
2184 if (NumMaskElts <= NumOpElts)
2185 return false;
2186
2187
2190 return false;
2191
2192
2193 for (int i = NumOpElts; i < NumMaskElts; ++i)
2194 if (Mask[i] != -1)
2195 return false;
2196
2197 return true;
2198}
2199
2201
2202
2204 return false;
2205
2208 if (NumMaskElts >= NumOpElts)
2209 return false;
2210
2212}
2213
2215
2217 return false;
2218
2219
2220
2222 return false;
2223
2226 if (NumMaskElts != NumOpElts * 2)
2227 return false;
2228
2229
2230
2231
2232
2234}
2235
2237 int ReplicationFactor, int VF) {
2238 assert(Mask.size() == (unsigned)ReplicationFactor * VF &&
2239 "Unexpected mask size.");
2240
2241 for (int CurrElt : seq(VF)) {
2242 ArrayRef CurrSubMask = Mask.take_front(ReplicationFactor);
2243 assert(CurrSubMask.size() == (unsigned)ReplicationFactor &&
2244 "Run out of mask?");
2245 Mask = Mask.drop_front(ReplicationFactor);
2246 if ((CurrSubMask, [CurrElt](int MaskElt) {
2247 return MaskElt == PoisonMaskElem || MaskElt == CurrElt;
2248 }))
2249 return false;
2250 }
2251 assert(Mask.empty() && "Did not consume the whole mask?");
2252
2253 return true;
2254}
2255
2257 int &ReplicationFactor, int &VF) {
2258
2260 ReplicationFactor =
2261 Mask.take_while([](int MaskElt) { return MaskElt == 0; }).size();
2262 if (ReplicationFactor == 0 || Mask.size() % ReplicationFactor != 0)
2263 return false;
2264 VF = Mask.size() / ReplicationFactor;
2266 }
2267
2268
2269
2270
2271
2272
2273
2274
2275 int Largest = -1;
2276 for (int MaskElt : Mask) {
2278 continue;
2279
2280 if (MaskElt < Largest)
2281 return false;
2282 Largest = std::max(Largest, MaskElt);
2283 }
2284
2285
2286 for (int PossibleReplicationFactor :
2288 if (Mask.size() % PossibleReplicationFactor != 0)
2289 continue;
2290 int PossibleVF = Mask.size() / PossibleReplicationFactor;
2292 PossibleVF))
2293 continue;
2294 ReplicationFactor = PossibleReplicationFactor;
2295 VF = PossibleVF;
2296 return true;
2297 }
2298
2299 return false;
2300}
2301
2303 int &VF) const {
2304
2305
2307 return false;
2308
2310 if (ShuffleMask.size() % VF != 0)
2311 return false;
2312 ReplicationFactor = ShuffleMask.size() / VF;
2313
2315}
2316
2318 if (VF <= 0 || Mask.size() < static_cast<unsigned>(VF) ||
2319 Mask.size() % VF != 0)
2320 return false;
2321 for (unsigned K = 0, Sz = Mask.size(); K < Sz; K += VF) {
2324 continue;
2326 for (int Idx : SubMask) {
2328 Used.set(Idx);
2329 }
2330 if (!Used.all())
2331 return false;
2332 }
2333 return true;
2334}
2335
2336
2338
2339
2341 return false;
2343 return false;
2344
2346}
2347
2350
2351
2352 if (!OpTy)
2353 return false;
2355
2356 return isInterleaveMask(ShuffleMask, Factor, OpNumElts * 2);
2357}
2358
2360 ArrayRef Mask, unsigned Factor, unsigned NumInputElts,
2362 unsigned NumElts = Mask.size();
2363 if (NumElts % Factor)
2364 return false;
2365
2366 unsigned LaneLen = NumElts / Factor;
2368 return false;
2369
2370 StartIndexes.resize(Factor);
2371
2372
2373
2374
2375 unsigned I = 0, J;
2376 for (; I < Factor; I++) {
2377 unsigned SavedLaneValue;
2378 unsigned SavedNoUndefs = 0;
2379
2380
2381 for (J = 0; J < LaneLen - 1; J++) {
2382
2383 unsigned Lane = J * Factor + I;
2384 unsigned NextLane = Lane + Factor;
2385 int LaneValue = Mask[Lane];
2386 int NextLaneValue = Mask[NextLane];
2387
2388
2389 if (LaneValue >= 0 && NextLaneValue >= 0 &&
2390 LaneValue + 1 != NextLaneValue)
2391 break;
2392
2393
2394 if (LaneValue >= 0 && NextLaneValue < 0) {
2395 SavedLaneValue = LaneValue;
2396 SavedNoUndefs = 1;
2397 }
2398
2399
2400
2401
2402
2403
2404 if (SavedNoUndefs > 0 && LaneValue < 0) {
2405 SavedNoUndefs++;
2406 if (NextLaneValue >= 0 &&
2407 SavedLaneValue + SavedNoUndefs != (unsigned)NextLaneValue)
2408 break;
2409 }
2410 }
2411
2412 if (J < LaneLen - 1)
2413 return false;
2414
2415 int StartMask = 0;
2416 if (Mask[I] >= 0) {
2417
2418 StartMask = Mask[I];
2419 } else if (Mask[(LaneLen - 1) * Factor + I] >= 0) {
2420
2421 StartMask = Mask[(LaneLen - 1) * Factor + I] - J;
2422 } else if (SavedNoUndefs > 0) {
2423
2424 StartMask = SavedLaneValue - (LaneLen - 1 - SavedNoUndefs);
2425 }
2426
2427
2428 if (StartMask < 0)
2429 return false;
2430
2431 if (StartMask + LaneLen > NumInputElts)
2432 return false;
2433
2434 StartIndexes[I] = StartMask;
2435 }
2436
2437 return true;
2438}
2439
2440
2441
2442
2444 unsigned Factor,
2445 unsigned &Index) {
2446
2447 for (unsigned Idx = 0; Idx < Factor; Idx++) {
2448 unsigned I = 0;
2449
2450
2451
2452 for (; I < Mask.size(); I++)
2453 if (Mask[I] >= 0 && static_cast<unsigned>(Mask[I]) != Idx + I * Factor)
2454 break;
2455
2456 if (I == Mask.size()) {
2457 Index = Idx;
2458 return true;
2459 }
2460 }
2461
2462 return false;
2463}
2464
2465
2466
2467
2468
2470 int NumElts = Mask.size();
2471 assert((NumElts % NumSubElts) == 0 && "Illegal shuffle mask");
2472
2473 int RotateAmt = -1;
2474 for (int i = 0; i != NumElts; i += NumSubElts) {
2475 for (int j = 0; j != NumSubElts; ++j) {
2476 int M = Mask[i + j];
2477 if (M < 0)
2478 continue;
2479 if (M < i || M >= i + NumSubElts)
2480 return -1;
2481 int Offset = (NumSubElts - (M - (i + j))) % NumSubElts;
2482 if (0 <= RotateAmt && Offset != RotateAmt)
2483 return -1;
2485 }
2486 }
2487 return RotateAmt;
2488}
2489
2491 ArrayRef Mask, unsigned EltSizeInBits, unsigned MinSubElts,
2492 unsigned MaxSubElts, unsigned &NumSubElts, unsigned &RotateAmt) {
2493 for (NumSubElts = MinSubElts; NumSubElts <= MaxSubElts; NumSubElts *= 2) {
2495 if (EltRotateAmt < 0)
2496 continue;
2497 RotateAmt = EltRotateAmt * EltSizeInBits;
2498 return true;
2499 }
2500
2501 return false;
2502}
2503
2504
2505
2506
2507
2509 const Twine &Name) {
2511
2512
2513
2514
2515
2516 assert(!Idxs.empty() && "InsertValueInst must have at least one index");
2517
2519 Val->getType() && "Inserted value must match indexed type!");
2522
2525}
2526
2527InsertValueInst::InsertValueInst(const InsertValueInst &IVI)
2529 Indices(IVI.Indices) {
2533}
2534
2535
2536
2537
2538
2541
2542
2543
2544 assert(!Idxs.empty() && "ExtractValueInst must have at least one index");
2545
2546 Indices.append(Idxs.begin(), Idxs.end());
2548}
2549
2550ExtractValueInst::ExtractValueInst(const ExtractValueInst &EVI)
2553 Indices(EVI.Indices) {
2555}
2556
2557
2558
2559
2560
2561
2562
2565 for (unsigned Index : Idxs) {
2566
2567
2568
2569
2570
2571
2573 if (Index >= AT->getNumElements())
2574 return nullptr;
2575 Agg = AT->getElementType();
2577 if (Index >= ST->getNumElements())
2578 return nullptr;
2579 Agg = ST->getElementType(Index);
2580 } else {
2581
2582 return nullptr;
2583 }
2584 }
2585 return Agg;
2586}
2587
2588
2589
2590
2591
2599
2604
2605void UnaryOperator::AssertOK() {
2607 (void)LHS;
2608#ifndef NDEBUG
2610 case FNeg:
2612 "Unary operation should return same type as operand!");
2614 "Tried to create a floating-point operation on a "
2615 "non-floating-point type!");
2616 break;
2618 }
2619#endif
2620}
2621
2622
2623
2624
2625
2628 : Instruction(Ty, iType, AllocMarker, InsertBefore) {
2632 AssertOK();
2633}
2634
2635void BinaryOperator::AssertOK() {
2637 (void)LHS; (void)RHS;
2638 assert(LHS->getType() == RHS->getType() &&
2639 "Binary operator operand types must match!");
2640#ifndef NDEBUG
2643 case Mul:
2645 "Arithmetic operation should return same type as operands!");
2647 "Tried to create an integer operation on a non-integer type!");
2648 break;
2649 case FAdd: case FSub:
2652 "Arithmetic operation should return same type as operands!");
2654 "Tried to create a floating-point operation on a "
2655 "non-floating-point type!");
2656 break;
2657 case UDiv:
2658 case SDiv:
2660 "Arithmetic operation should return same type as operands!");
2662 "Incorrect operand type (not integer) for S/UDIV");
2663 break;
2664 case FDiv:
2666 "Arithmetic operation should return same type as operands!");
2668 "Incorrect operand type (not floating point) for FDIV");
2669 break;
2670 case URem:
2671 case SRem:
2673 "Arithmetic operation should return same type as operands!");
2675 "Incorrect operand type (not integer) for S/UREM");
2676 break;
2677 case FRem:
2679 "Arithmetic operation should return same type as operands!");
2681 "Incorrect operand type (not floating point) for FREM");
2682 break;
2683 case Shl:
2684 case LShr:
2685 case AShr:
2687 "Shift operation should return same type as operands!");
2689 "Tried to create a shift operation on a non-integral type!");
2690 break;
2692 case Xor:
2694 "Logical operation should return same type as operands!");
2696 "Tried to create a logical operation on a non-integral type!");
2697 break;
2699 }
2700#endif
2701}
2702
2704 const Twine &Name,
2707 "Cannot create binary operator with two operands of differing type!");
2709}
2710
2713 Value *Zero = ConstantInt::get(Op->getType(), 0);
2714 return new BinaryOperator(Instruction::Sub, Zero, Op, Op->getType(), Name,
2715 InsertBefore);
2716}
2717
2720 Value *Zero = ConstantInt::get(Op->getType(), 0);
2721 return BinaryOperator::CreateNSWSub(Zero, Op, Name, InsertBefore);
2722}
2723
2728 Op->getType(), Name, InsertBefore);
2729}
2730
2731
2732
2733
2736 return true;
2738 return false;
2739}
2740
2741
2742
2743
2744
2748 if (!MD)
2749 return 0.0;
2752}
2753
2754
2755
2756
2757
2758
2761 default: return false;
2762 case Instruction::ZExt:
2763 case Instruction::SExt:
2764 case Instruction::Trunc:
2765 return true;
2766 case Instruction::BitCast:
2769 }
2770}
2771
2772
2773
2774
2775
2776
2777
2778
2779
2781 Type *SrcTy,
2782 Type *DestTy,
2784 assert(castIsValid(Opcode, SrcTy, DestTy) && "method precondition");
2785 switch (Opcode) {
2787 case Instruction::Trunc:
2788 case Instruction::ZExt:
2789 case Instruction::SExt:
2790 case Instruction::FPTrunc:
2791 case Instruction::FPExt:
2792 case Instruction::UIToFP:
2793 case Instruction::SIToFP:
2794 case Instruction::FPToUI:
2795 case Instruction::FPToSI:
2796 case Instruction::AddrSpaceCast:
2797
2798 return false;
2799 case Instruction::BitCast:
2800 return true;
2801 case Instruction::PtrToAddr:
2802 case Instruction::PtrToInt:
2803 return DL.getIntPtrType(SrcTy)->getScalarSizeInBits() ==
2805 case Instruction::IntToPtr:
2806 return DL.getIntPtrType(DestTy)->getScalarSizeInBits() ==
2807 SrcTy->getScalarSizeInBits();
2808 }
2809}
2810
2814
2815
2816
2817
2818
2819
2820
2821
2822
2825 Type *SrcTy, Type *MidTy, Type *DstTy, Type *SrcIntPtrTy, Type *MidIntPtrTy,
2826 Type *DstIntPtrTy) {
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857 const unsigned numCastOps =
2858 Instruction::CastOpsEnd - Instruction::CastOpsBegin;
2859
2860 static const uint8_t CastResults[numCastOps][numCastOps] = {
2861
2862
2863
2864
2865
2866 { 1, 0, 0,99,99, 0, 0,99,99,99,99, 0, 3, 0},
2867 { 8, 1, 9,99,99, 2,17,99,99,99,99, 2, 3, 0},
2868 { 8, 0, 1,99,99, 0, 2,99,99,99,99, 0, 3, 0},
2869 { 0, 0, 0,99,99, 0, 0,99,99,99,99, 0, 3, 0},
2870 { 0, 0, 0,99,99, 0, 0,99,99,99,99, 0, 3, 0},
2871 { 99,99,99, 0, 0,99,99, 0, 0,99,99,99, 4, 0},
2872 { 99,99,99, 0, 0,99,99, 0, 0,99,99,99, 4, 0},
2873 { 99,99,99, 0, 0,99,99, 0, 0,99,99,99, 4, 0},
2874 { 99,99,99, 2, 2,99,99, 8, 2,99,99,99, 4, 0},
2875 { 1, 0, 0,99,99, 0, 0,99,99,99,99, 7, 3, 0},
2876 { 1, 0, 0,99,99, 0, 0,99,99,99,99, 0, 3, 0},
2877 { 99,99,99,99,99,99,99,99,99,11,99,99,15, 0},
2878 { 5, 5, 5, 0, 0, 5, 5, 0, 0,16,16, 5, 1,14},
2879 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,13,12},
2880 };
2881
2882
2883
2884
2885
2886
2887 bool IsFirstBitcast = (firstOp == Instruction::BitCast);
2888 bool IsSecondBitcast = (secondOp == Instruction::BitCast);
2889 bool AreBothBitcasts = IsFirstBitcast && IsSecondBitcast;
2890
2891
2894 if (!AreBothBitcasts)
2895 return 0;
2896
2897 int ElimCase = CastResults[firstOp-Instruction::CastOpsBegin]
2898 [secondOp-Instruction::CastOpsBegin];
2899 switch (ElimCase) {
2900 case 0:
2901
2902 return 0;
2903 case 1:
2904
2905 return firstOp;
2906 case 2:
2907
2908 return secondOp;
2909 case 3:
2910
2911
2912
2913 if (!SrcTy->isVectorTy() && DstTy->isIntegerTy())
2914 return firstOp;
2915 return 0;
2916 case 4:
2917
2918
2919 if (DstTy == MidTy)
2920 return firstOp;
2921 return 0;
2922 case 5:
2923
2924
2925 if (SrcTy->isIntegerTy())
2926 return secondOp;
2927 return 0;
2928 case 7: {
2929
2931 return 0;
2932
2933
2935 return 0;
2936
2938
2939
2940
2941
2942 if (MidSize == 64)
2943 return Instruction::BitCast;
2944
2945
2946 if (!SrcIntPtrTy || DstIntPtrTy != SrcIntPtrTy)
2947 return 0;
2949 if (MidSize >= PtrSize)
2950 return Instruction::BitCast;
2951 return 0;
2952 }
2953 case 8: {
2954
2955
2956
2957 unsigned SrcSize = SrcTy->getScalarSizeInBits();
2959 if (SrcTy == DstTy)
2960 return Instruction::BitCast;
2961 if (SrcSize < DstSize)
2962 return firstOp;
2963 if (SrcSize > DstSize)
2964 return secondOp;
2965 return 0;
2966 }
2967 case 9:
2968
2969 return Instruction::ZExt;
2970 case 11: {
2971
2972 if (!MidIntPtrTy)
2973 return 0;
2975 unsigned SrcSize = SrcTy->getScalarSizeInBits();
2977 if (SrcSize <= PtrSize && SrcSize == DstSize)
2978 return Instruction::BitCast;
2979 return 0;
2980 }
2981 case 12:
2982
2983
2985 return Instruction::AddrSpaceCast;
2986 return Instruction::BitCast;
2987 case 13:
2988
2989
2990
2992 SrcTy->isPtrOrPtrVectorTy() &&
2997 "Illegal addrspacecast, bitcast sequence!");
2998
2999 return firstOp;
3000 case 14:
3001
3002 return Instruction::AddrSpaceCast;
3003 case 15:
3004
3005
3006
3008 SrcTy->isIntOrIntVectorTy() &&
3012 "Illegal inttoptr, bitcast sequence!");
3013
3014 return firstOp;
3015 case 16:
3016
3017
3018
3020 SrcTy->isPtrOrPtrVectorTy() &&
3024 "Illegal bitcast, ptrtoint sequence!");
3025
3026 return secondOp;
3027 case 17:
3028
3029 return Instruction::UIToFP;
3030 case 99:
3031
3032
3034 default:
3036 }
3037}
3038
3042
3043 switch (op) {
3044 case Trunc: return new TruncInst (S, Ty, Name, InsertBefore);
3045 case ZExt: return new ZExtInst (S, Ty, Name, InsertBefore);
3046 case SExt: return new SExtInst (S, Ty, Name, InsertBefore);
3047 case FPTrunc: return new FPTruncInst (S, Ty, Name, InsertBefore);
3048 case FPExt: return new FPExtInst (S, Ty, Name, InsertBefore);
3049 case UIToFP: return new UIToFPInst (S, Ty, Name, InsertBefore);
3050 case SIToFP: return new SIToFPInst (S, Ty, Name, InsertBefore);
3051 case FPToUI: return new FPToUIInst (S, Ty, Name, InsertBefore);
3052 case FPToSI: return new FPToSIInst (S, Ty, Name, InsertBefore);
3053 case PtrToAddr: return new PtrToAddrInst (S, Ty, Name, InsertBefore);
3054 case PtrToInt: return new PtrToIntInst (S, Ty, Name, InsertBefore);
3055 case IntToPtr: return new IntToPtrInst (S, Ty, Name, InsertBefore);
3056 case BitCast:
3057 return new BitCastInst(S, Ty, Name, InsertBefore);
3058 case AddrSpaceCast:
3060 default:
3062 }
3063}
3064
3068 return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
3069 return Create(Instruction::ZExt, S, Ty, Name, InsertBefore);
3070}
3071
3075 return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
3076 return Create(Instruction::SExt, S, Ty, Name, InsertBefore);
3077}
3078
3082 return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
3083 return Create(Instruction::Trunc, S, Ty, Name, InsertBefore);
3084}
3085
3086
3090 assert((Ty->isIntOrIntVectorTy() || Ty->isPtrOrPtrVectorTy()) &&
3091 "Invalid cast");
3093 assert((!Ty->isVectorTy() ||
3096 "Invalid cast");
3097
3098 if (Ty->isIntOrIntVectorTy())
3099 return Create(Instruction::PtrToInt, S, Ty, Name, InsertBefore);
3100
3102}
3103
3107 assert(Ty->isPtrOrPtrVectorTy() && "Invalid cast");
3108
3110 return Create(Instruction::AddrSpaceCast, S, Ty, Name, InsertBefore);
3111
3112 return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
3113}
3114
3116 const Twine &Name,
3119 return Create(Instruction::PtrToInt, S, Ty, Name, InsertBefore);
3121 return Create(Instruction::IntToPtr, S, Ty, Name, InsertBefore);
3122
3123 return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
3124}
3125
3127 const Twine &Name,
3129 assert(C->getType()->isIntOrIntVectorTy() && Ty->isIntOrIntVectorTy() &&
3130 "Invalid integer cast");
3131 unsigned SrcBits = C->getType()->getScalarSizeInBits();
3132 unsigned DstBits = Ty->getScalarSizeInBits();
3134 (SrcBits == DstBits ? Instruction::BitCast :
3135 (SrcBits > DstBits ? Instruction::Trunc :
3136 (isSigned ? Instruction::SExt : Instruction::ZExt)));
3137 return Create(opcode, C, Ty, Name, InsertBefore);
3138}
3139
3142 assert(C->getType()->isFPOrFPVectorTy() && Ty->isFPOrFPVectorTy() &&
3143 "Invalid cast");
3144 unsigned SrcBits = C->getType()->getScalarSizeInBits();
3145 unsigned DstBits = Ty->getScalarSizeInBits();
3146 assert((C->getType() == Ty || SrcBits != DstBits) && "Invalid cast");
3148 (SrcBits == DstBits ? Instruction::BitCast :
3149 (SrcBits > DstBits ? Instruction::FPTrunc : Instruction::FPExt));
3150 return Create(opcode, C, Ty, Name, InsertBefore);
3151}
3152
3154 if (!SrcTy->isFirstClassType() || !DestTy->isFirstClassType())
3155 return false;
3156
3157 if (SrcTy == DestTy)
3158 return true;
3159
3162 if (SrcVecTy->getElementCount() == DestVecTy->getElementCount()) {
3163
3164 SrcTy = SrcVecTy->getElementType();
3165 DestTy = DestVecTy->getElementType();
3166 }
3167 }
3168 }
3169
3172 return SrcPtrTy->getAddressSpace() == DestPtrTy->getAddressSpace();
3173 }
3174 }
3175
3176 TypeSize SrcBits = SrcTy->getPrimitiveSizeInBits();
3178
3179
3180
3182 return false;
3183
3184 if (SrcBits != DestBits)
3185 return false;
3186
3187 return true;
3188}
3189
3192
3195 return (IntTy->getBitWidth() == DL.getPointerTypeSizeInBits(PtrTy) &&
3196 .isNonIntegralPointerType(PtrTy));
3199 return (IntTy->getBitWidth() == DL.getPointerTypeSizeInBits(PtrTy) &&
3200 .isNonIntegralPointerType(PtrTy));
3201
3203}
3204
3205
3206
3207
3208
3209
3210
3213 const Value *Src, bool SrcIsSigned, Type *DestTy, bool DestIsSigned) {
3214 Type *SrcTy = Src->getType();
3215
3217 "Only first class types are castable!");
3218
3219 if (SrcTy == DestTy)
3220 return BitCast;
3221
3222
3225 if (SrcVecTy->getElementCount() == DestVecTy->getElementCount()) {
3226
3227
3228 SrcTy = SrcVecTy->getElementType();
3229 DestTy = DestVecTy->getElementType();
3230 }
3231
3232
3233 unsigned SrcBits = SrcTy->getPrimitiveSizeInBits();
3235
3236
3237 if (DestTy->isIntegerTy()) {
3238 if (SrcTy->isIntegerTy()) {
3239 if (DestBits < SrcBits)
3240 return Trunc;
3241 else if (DestBits > SrcBits) {
3242 if (SrcIsSigned)
3243 return SExt;
3244 else
3245 return ZExt;
3246 } else {
3247 return BitCast;
3248 }
3249 } else if (SrcTy->isFloatingPointTy()) {
3250 if (DestIsSigned)
3251 return FPToSI;
3252 else
3253 return FPToUI;
3254 } else if (SrcTy->isVectorTy()) {
3255 assert(DestBits == SrcBits &&
3256 "Casting vector to integer of different width");
3257 return BitCast;
3258 } else {
3259 assert(SrcTy->isPointerTy() &&
3260 "Casting from a value that is not first-class type");
3261 return PtrToInt;
3262 }
3263 } else if (DestTy->isFloatingPointTy()) {
3264 if (SrcTy->isIntegerTy()) {
3265 if (SrcIsSigned)
3266 return SIToFP;
3267 else
3268 return UIToFP;
3269 } else if (SrcTy->isFloatingPointTy()) {
3270 if (DestBits < SrcBits) {
3271 return FPTrunc;
3272 } else if (DestBits > SrcBits) {
3273 return FPExt;
3274 } else {
3275 return BitCast;
3276 }
3277 } else if (SrcTy->isVectorTy()) {
3278 assert(DestBits == SrcBits &&
3279 "Casting vector to floating point of different width");
3280 return BitCast;
3281 }
3282 llvm_unreachable("Casting pointer or non-first class to float");
3284 assert(DestBits == SrcBits &&
3285 "Illegal cast to vector (wrong type or size)");
3286 return BitCast;
3288 if (SrcTy->isPointerTy()) {
3290 return AddrSpaceCast;
3291 return BitCast;
3292 } else if (SrcTy->isIntegerTy()) {
3293 return IntToPtr;
3294 }
3295 llvm_unreachable("Casting pointer to other than pointer or int");
3296 }
3297 llvm_unreachable("Casting to type that is not first-class");
3298}
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308bool
3310 if (!SrcTy->isFirstClassType() || !DstTy->isFirstClassType() ||
3312 return false;
3313
3314
3315
3318 unsigned SrcScalarBitSize = SrcTy->getScalarSizeInBits();
3320
3321
3322
3323
3328
3329
3330 switch (op) {
3331 default: return false;
3332 case Instruction::Trunc:
3333 return SrcTy->isIntOrIntVectorTy() && DstTy->isIntOrIntVectorTy() &&
3334 SrcEC == DstEC && SrcScalarBitSize > DstScalarBitSize;
3335 case Instruction::ZExt:
3336 return SrcTy->isIntOrIntVectorTy() && DstTy->isIntOrIntVectorTy() &&
3337 SrcEC == DstEC && SrcScalarBitSize < DstScalarBitSize;
3338 case Instruction::SExt:
3339 return SrcTy->isIntOrIntVectorTy() && DstTy->isIntOrIntVectorTy() &&
3340 SrcEC == DstEC && SrcScalarBitSize < DstScalarBitSize;
3341 case Instruction::FPTrunc:
3342 return SrcTy->isFPOrFPVectorTy() && DstTy->isFPOrFPVectorTy() &&
3343 SrcEC == DstEC && SrcScalarBitSize > DstScalarBitSize;
3344 case Instruction::FPExt:
3345 return SrcTy->isFPOrFPVectorTy() && DstTy->isFPOrFPVectorTy() &&
3346 SrcEC == DstEC && SrcScalarBitSize < DstScalarBitSize;
3347 case Instruction::UIToFP:
3348 case Instruction::SIToFP:
3349 return SrcTy->isIntOrIntVectorTy() && DstTy->isFPOrFPVectorTy() &&
3350 SrcEC == DstEC;
3351 case Instruction::FPToUI:
3352 case Instruction::FPToSI:
3354 SrcEC == DstEC;
3355 case Instruction::PtrToAddr:
3356 case Instruction::PtrToInt:
3357 if (SrcEC != DstEC)
3358 return false;
3360 case Instruction::IntToPtr:
3361 if (SrcEC != DstEC)
3362 return false;
3364 case Instruction::BitCast: {
3367
3368
3369
3370 if (!SrcPtrTy != !DstPtrTy)
3371 return false;
3372
3373
3374
3375 if (!SrcPtrTy)
3377
3378
3380 return false;
3381
3382
3383 if (SrcIsVec && DstIsVec)
3384 return SrcEC == DstEC;
3385 if (SrcIsVec)
3387 if (DstIsVec)
3389
3390 return true;
3391 }
3392 case Instruction::AddrSpaceCast: {
3394 if (!SrcPtrTy)
3395 return false;
3396
3398 if (!DstPtrTy)
3399 return false;
3400
3402 return false;
3403
3404 return SrcEC == DstEC;
3405 }
3406 }
3407}
3408
3411 : CastInst(Ty, Trunc, S, Name, InsertBefore) {
3413}
3414
3417 : CastInst(Ty, ZExt, S, Name, InsertBefore) {
3419}
3420
3423 : CastInst(Ty, SExt, S, Name, InsertBefore) {
3425}
3426
3429 : CastInst(Ty, FPTrunc, S, Name, InsertBefore) {
3431}
3432
3435 : CastInst(Ty, FPExt, S, Name, InsertBefore) {
3437}
3438
3441 : CastInst(Ty, UIToFP, S, Name, InsertBefore) {
3443}
3444
3447 : CastInst(Ty, SIToFP, S, Name, InsertBefore) {
3449}
3450
3453 : CastInst(Ty, FPToUI, S, Name, InsertBefore) {
3455}
3456
3459 : CastInst(Ty, FPToSI, S, Name, InsertBefore) {
3461}
3462
3465 : CastInst(Ty, PtrToInt, S, Name, InsertBefore) {
3467}
3468
3471 : CastInst(Ty, PtrToAddr, S, Name, InsertBefore) {
3473}
3474
3477 : CastInst(Ty, IntToPtr, S, Name, InsertBefore) {
3479}
3480
3483 : CastInst(Ty, BitCast, S, Name, InsertBefore) {
3485}
3486
3489 : CastInst(Ty, AddrSpaceCast, S, Name, InsertBefore) {
3491}
3492
3493
3494
3495
3496
3500 : Instruction(ty, op, AllocMarker, InsertBefore) {
3505 if (FlagsSource)
3507}
3508
3511 if (Op == Instruction::ICmp) {
3512 if (InsertBefore.isValid())
3514 S1, S2, Name);
3515 else
3517 S1, S2, Name);
3518 }
3519
3520 if (InsertBefore.isValid())
3522 S1, S2, Name);
3523 else
3525 S1, S2, Name);
3526}
3527
3531 const Twine &Name,
3535 return Inst;
3536}
3537
3544
3547 return IC->isCommutative();
3549}
3550
3558
3559
3560
3564 if (auto *Const = LHS ? LHS : RHS) {
3567 }
3568 return false;
3569}
3570
3571
3572
3573
3577 return true;
3580 return false;
3581 [[fallthrough]];
3584 default:
3585 return false;
3586 }
3587}
3588
3590 switch (pred) {
3602
3619 }
3620}
3621
3623 switch (Pred) {
3624 default: return "unknown";
3651 }
3652}
3653
3658
3660 switch (pred) {
3664 return pred;
3669 }
3670}
3671
3673 switch (pred) {
3677 return pred;
3682 }
3683}
3684
3686 switch (pred) {
3689 return pred;
3698
3703 return pred;
3712 }
3713}
3714
3716 switch (pred) {
3725 return true;
3726 default:
3727 return false;
3728 }
3729}
3730
3732 switch (pred) {
3741 return true;
3742 default:
3743 return false;
3744 }
3745}
3746
3748 switch (pred) {
3765 default:
3766 return pred;
3767 }
3768}
3769
3771 switch (pred) {
3788 default:
3789 return pred;
3790 }
3791}
3792
3803
3805 switch (predicate) {
3806 default: return false;
3809 }
3810}
3811
3813 switch (predicate) {
3814 default: return false;
3817 }
3818}
3819
3823 switch (Pred) {
3825 return LHS.eq(RHS);
3827 return LHS.ne(RHS);
3829 return LHS.ugt(RHS);
3831 return LHS.uge(RHS);
3833 return LHS.ult(RHS);
3835 return LHS.ule(RHS);
3837 return LHS.sgt(RHS);
3839 return LHS.sge(RHS);
3841 return LHS.slt(RHS);
3843 return LHS.sle(RHS);
3844 default:
3846 };
3847}
3848
3852 switch (Pred) {
3853 default:
3856 return false;
3858 return true;
3887 }
3888}
3889
3893 switch (Pred) {
3914 default:
3916 }
3917}
3918
3921 return pred;
3926
3928}
3929
3931 switch (predicate) {
3932 default: return false;
3936 }
3937}
3938
3940 switch (predicate) {
3941 default: return false;
3945 }
3946}
3947
3949 switch(predicate) {
3950 default: return false;
3953 }
3954}
3955
3957 switch(predicate) {
3960 default: return false;
3961 }
3962}
3963
3993
3999
4003 return true;
4005 return false;
4006 return std::nullopt;
4007}
4008
4009
4010
4011
4012
4016 return A.HasSameSign == B.HasSameSign ? A : CmpPredicate(A.Pred);
4018 return {};
4019 if (A.HasSameSign &&
4021 return B.Pred;
4022 if (B.HasSameSign &&
4024 return A.Pred;
4025 return {};
4026}
4027
4031
4034 return ICI->getCmpPredicate();
4035 return Cmp->getPredicate();
4036}
4037
4041
4045
4046
4047
4048
4049
4052 ReservedSpace = NumReserved;
4055
4058}
4059
4060
4061
4062
4063
4067 AllocMarker, InsertBefore) {
4069}
4070
4073 init(SI.getCondition(), SI.getDefaultDest(), SI.getNumOperands());
4074 setNumHungOffUseOperands(SI.getNumOperands());
4075 Use *OL = getOperandList();
4076 const Use *InOL = SI.getOperandList();
4077 for (unsigned i = 2, E = SI.getNumOperands(); i != E; i += 2) {
4078 OL[i] = InOL[i];
4079 OL[i+1] = InOL[i+1];
4080 }
4081 SubclassOptionalData = SI.SubclassOptionalData;
4082}
4083
4084
4085
4089 if (OpNo+2 > ReservedSpace)
4090 growOperands();
4091
4092 assert(OpNo+1 < ReservedSpace && "Growing didn't work!");
4097}
4098
4099
4100
4102 unsigned idx = I->getCaseIndex();
4103
4105
4108
4109
4110 if (2 + (idx + 1) * 2 != NumOps) {
4111 OL[2 + idx * 2] = OL[NumOps - 2];
4112 OL[2 + idx * 2 + 1] = OL[NumOps - 1];
4113 }
4114
4115
4119
4120 return CaseIt(this, idx);
4121}
4122
4123
4124
4125
4126void SwitchInst::growOperands() {
4128 unsigned NumOps = e*3;
4129
4130 ReservedSpace = NumOps;
4132}
4133
4135 assert(Changed && "called only if metadata has changed");
4136
4137 if (!Weights)
4138 return nullptr;
4139
4140 assert(SI.getNumSuccessors() == Weights->size() &&
4141 "num of prof branch_weights must accord with num of successors");
4142
4143 bool AllZeroes = all_of(*Weights, [](uint32_t W) { return W == 0; });
4144
4145 if (AllZeroes || Weights->size() < 2)
4146 return nullptr;
4147
4149}
4150
4153 if (!ProfileData)
4154 return;
4155
4157 llvm_unreachable("number of prof branch_weights metadata operands does "
4158 "not correspond to number of succesors");
4159 }
4160
4163 return;
4164 this->Weights = std::move(Weights);
4165}
4166
4169 if (Weights) {
4170 assert(SI.getNumSuccessors() == Weights->size() &&
4171 "num of prof branch_weights must accord with num of successors");
4172 Changed = true;
4173
4174
4175
4176 (*Weights)[I->getCaseIndex() + 1] = Weights->back();
4177 Weights->pop_back();
4178 }
4179 return SI.removeCase(I);
4180}
4181
4185 SI.addCase(OnVal, Dest);
4186
4187 if (!Weights && W && *W) {
4188 Changed = true;
4190 (*Weights)[SI.getNumSuccessors() - 1] = *W;
4191 } else if (Weights) {
4192 Changed = true;
4193 Weights->push_back(W.value_or(0));
4194 }
4195 if (Weights)
4196 assert(SI.getNumSuccessors() == Weights->size() &&
4197 "num of prof branch_weights must accord with num of successors");
4198}
4199
4202
4203 Changed = false;
4204 if (Weights)
4205 Weights->resize(0);
4206 return SI.eraseFromParent();
4207}
4208
4211 if (!Weights)
4212 return std::nullopt;
4213 return (*Weights)[idx];
4214}
4215
4218 if (!W)
4219 return;
4220
4221 if (!Weights && *W)
4223
4224 if (Weights) {
4225 auto &OldW = (*Weights)[idx];
4226 if (*W != OldW) {
4227 Changed = true;
4228 OldW = *W;
4229 }
4230 }
4231}
4232
4235 unsigned idx) {
4237 if (ProfileData->getNumOperands() == SI.getNumSuccessors() + 1)
4239 ->getValue()
4240 .getZExtValue();
4241
4242 return std::nullopt;
4243}
4244
4245
4246
4247
4248
4249void IndirectBrInst::init(Value *Address, unsigned NumDests) {
4251 "Address of indirectbr must be a pointer");
4252 ReservedSpace = 1+NumDests;
4255
4257}
4258
4259
4260
4261
4262
4263void IndirectBrInst::growOperands() {
4265 unsigned NumOps = e*2;
4266
4267 ReservedSpace = NumOps;
4269}
4270
4271IndirectBrInst::IndirectBrInst(Value *Address, unsigned NumCases,
4274 Instruction::IndirectBr, AllocMarker, InsertBefore) {
4276}
4277
4278IndirectBrInst::IndirectBrInst(const IndirectBrInst &IBI)
4280 AllocMarker) {
4283 Use *OL = getOperandList();
4286 OL[i] = InOL[i];
4288}
4289
4290
4291
4294 if (OpNo+1 > ReservedSpace)
4295 growOperands();
4296
4297 assert(OpNo < ReservedSpace && "Growing didn't work!");
4300}
4301
4302
4303
4306
4309
4310
4311 OL[idx+1] = OL[NumOps-1];
4312
4313
4316}
4317
4318
4319
4320
4321
4326
4327
4328
4329
4330
4331
4332
4333
4336 return new (AllocMarker) GetElementPtrInst(*this, AllocMarker);
4337}
4338
4342
4346
4350
4354
4356 return new ExtractValueInst(*this);
4357}
4358
4360 return new InsertValueInst(*this);
4361}
4362
4368 return Result;
4369}
4370
4375
4380
4386 Result->setWeak(isWeak());
4387 return Result;
4388}
4389
4395 return Result;
4396}
4397
4401
4405
4409
4413
4417
4421
4425
4429
4433
4437
4441
4445
4449
4453
4457
4463 return new (AllocMarker) CallInst(*this, AllocMarker);
4464 }
4466 return new (AllocMarker) CallInst(*this, AllocMarker);
4467}
4468
4472
4476
4480
4484
4488
4490
4492 return new LandingPadInst(*this);
4493}
4494
4497 return new (AllocMarker) ReturnInst(*this, AllocMarker);
4498}
4499
4502 return new (AllocMarker) BranchInst(*this, AllocMarker);
4503}
4504
4506
4508 return new IndirectBrInst(*this);
4509}
4510
4516 return new (AllocMarker) InvokeInst(*this, AllocMarker);
4517 }
4519 return new (AllocMarker) InvokeInst(*this, AllocMarker);
4520}
4521
4527 return new (AllocMarker) CallBrInst(*this, AllocMarker);
4528 }
4530 return new (AllocMarker) CallBrInst(*this, AllocMarker);
4531}
4532
4534 return new (AllocMarker) ResumeInst(*this);
4535}
4536
4539 return new (AllocMarker) CleanupReturnInst(*this, AllocMarker);
4540}
4541
4543 return new (AllocMarker) CatchReturnInst(*this);
4544}
4545
4547 return new CatchSwitchInst(*this);
4548}
4549
4552 return new (AllocMarker) FuncletPadInst(*this, AllocMarker);
4553}
4554
4559
4561 bool NoTrapAfterNoreturn) const {
4562 if (!TrapUnreachable)
4563 return false;
4564
4565
4567 Call && Call->doesNotReturn()) {
4568 if (NoTrapAfterNoreturn)
4569 return false;
4570
4571 if (Call->isNonContinuableTrap())
4572 return false;
4573 }
4574
4575 if (getFunction()->hasFnAttribute(Attribute::Naked))
4576 return false;
4577
4578 return true;
4579}
4580
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Atomic ordering constants.
This file contains the simple types necessary to represent the attributes associated with functions a...
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static bool isSigned(unsigned int Opcode)
Module.h This file contains the declarations for the Module class.
static Align computeLoadStoreDefaultAlign(Type *Ty, InsertPosition Pos)
Definition Instructions.cpp:1317
static bool isImpliedFalseByMatchingCmp(CmpPredicate Pred1, CmpPredicate Pred2)
Definition Instructions.cpp:3994
static Value * createPlaceholderForShuffleVector(Value *V)
Definition Instructions.cpp:1720
static Align computeAllocaDefaultAlign(Type *Ty, InsertPosition Pos)
Definition Instructions.cpp:1259
static cl::opt< bool > DisableI2pP2iOpt("disable-i2p-p2i-opt", cl::init(false), cl::desc("Disables inttoptr/ptrtoint roundtrip optimization"))
static bool hasNonZeroFPOperands(const CmpInst *Cmp)
Definition Instructions.cpp:3561
static int matchShuffleAsBitRotate(ArrayRef< int > Mask, int NumSubElts)
Try to lower a vector shuffle as a bit rotation.
Definition Instructions.cpp:2469
static Type * getIndexedTypeInternal(Type *Ty, ArrayRef< IndexTy > IdxList)
Definition Instructions.cpp:1572
static bool isReplicationMaskWithParams(ArrayRef< int > Mask, int ReplicationFactor, int VF)
Definition Instructions.cpp:2236
static bool isIdentityMaskImpl(ArrayRef< int > Mask, int NumOpElts)
Definition Instructions.cpp:1935
static bool isSingleSourceMaskImpl(ArrayRef< int > Mask, int NumOpElts)
Definition Instructions.cpp:1911
static Value * getAISize(LLVMContext &Context, Value *Amt)
Definition Instructions.cpp:1247
static bool isImpliedTrueByMatchingCmp(CmpPredicate Pred1, CmpPredicate Pred2)
Definition Instructions.cpp:3964
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
MachineInstr unsigned OpIdx
uint64_t IntrinsicInst * II
PowerPC Reduce CR logical Operation
This file contains the declarations for profiling metadata utility functions.
const SmallVectorImpl< MachineOperand > & Cond
static unsigned getNumElements(Type *Ty)
This file implements the SmallBitVector class.
This file defines the SmallVector class.
static SymbolRef::Type getType(const Symbol *Sym)
static std::optional< unsigned > getOpcode(ArrayRef< VPValue * > Values)
Returns the opcode of Values or ~0 if they do not all agree.
LLVM_ABI float convertToFloat() const
Converts this APFloat to host float value.
Class for arbitrary precision integers.
void setBit(unsigned BitPosition)
Set the given bit to 1 whose position is given as "bitPosition".
bool isZero() const
Determine if this value is zero, i.e. all bits are clear.
unsigned countr_zero() const
Count the number of trailing zero bits.
unsigned countl_zero() const
The APInt version of std::countl_zero.
static APInt getZero(unsigned numBits)
Get the '0' value for the specified bit-width.
This class represents a conversion between pointers from one address space to another.
LLVM_ABI AddrSpaceCastInst * cloneImpl() const
Clone an identical AddrSpaceCastInst.
Definition Instructions.cpp:4454
LLVM_ABI AddrSpaceCastInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
Definition Instructions.cpp:3487
LLVM_ABI std::optional< TypeSize > getAllocationSizeInBits(const DataLayout &DL) const
Get allocation size in bits.
Definition Instructions.cpp:82
bool isSwiftError() const
Return true if this alloca is used as a swifterror argument to a call.
LLVM_ABI bool isStaticAlloca() const
Return true if this alloca is in the entry block of the function and is a constant size.
Definition Instructions.cpp:1299
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
LLVM_ABI AllocaInst * cloneImpl() const
Definition Instructions.cpp:4363
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
bool isUsedWithInAlloca() const
Return true if this alloca is used as an inalloca argument to a call.
unsigned getAddressSpace() const
Return the address space for the allocation.
LLVM_ABI std::optional< TypeSize > getAllocationSize(const DataLayout &DL) const
Get allocation size in bytes.
Definition Instructions.cpp:65
LLVM_ABI bool isArrayAllocation() const
Return true if there is an allocation size parameter to the allocation instruction that is not 1.
Definition Instructions.cpp:1290
void setAlignment(Align Align)
const Value * getArraySize() const
Get the number of elements allocated.
LLVM_ABI AllocaInst(Type *Ty, unsigned AddrSpace, Value *ArraySize, const Twine &Name, InsertPosition InsertBefore)
Definition Instructions.cpp:1273
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
bool empty() const
empty - Check if the array is empty.
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.
void setSyncScopeID(SyncScope::ID SSID)
Sets the synchronization scope ID of this cmpxchg instruction.
bool isVolatile() const
Return true if this is a cmpxchg from a volatile memory location.
void setFailureOrdering(AtomicOrdering Ordering)
Sets the failure ordering constraint of this cmpxchg instruction.
AtomicOrdering getFailureOrdering() const
Returns the failure ordering constraint of this cmpxchg instruction.
void setSuccessOrdering(AtomicOrdering Ordering)
Sets the success ordering constraint of this cmpxchg instruction.
LLVM_ABI AtomicCmpXchgInst * cloneImpl() const
Definition Instructions.cpp:4381
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
friend class Instruction
Iterator for Instructions in a `BasicBlock.
bool isWeak() const
Return true if this cmpxchg may spuriously fail.
void setAlignment(Align Align)
AtomicOrdering getSuccessOrdering() const
Returns the success ordering constraint of this cmpxchg instruction.
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this cmpxchg instruction.
LLVM_ABI AtomicCmpXchgInst(Value *Ptr, Value *Cmp, Value *NewVal, Align Alignment, AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering, SyncScope::ID SSID, InsertPosition InsertBefore=nullptr)
Definition Instructions.cpp:1413
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
LLVM_ABI AtomicRMWInst * cloneImpl() const
Definition Instructions.cpp:4390
bool isVolatile() const
Return true if this is a RMW on a volatile memory location.
BinOp
This enumeration lists the possible modifications atomicrmw can make.
@ USubCond
Subtract only if no unsigned overflow.
@ FMinimum
*p = minimum(old, v) minimum matches the behavior of llvm.minimum.
@ Min
*p = old <signed v ? old : v
@ USubSat
*p = usub.sat(old, v) usub.sat matches the behavior of llvm.usub.sat.
@ FMaximum
*p = maximum(old, v) maximum matches the behavior of llvm.maximum.
@ UIncWrap
Increment one up to a maximum value.
@ Max
*p = old >signed v ? old : v
@ UMin
*p = old <unsigned v ? old : v
@ FMin
*p = minnum(old, v) minnum matches the behavior of llvm.minnum.
@ UMax
*p = old >unsigned v ? old : v
@ FMax
*p = maxnum(old, v) maxnum matches the behavior of llvm.maxnum.
@ UDecWrap
Decrement one until a minimum value or zero.
void setSyncScopeID(SyncScope::ID SSID)
Sets the synchronization scope ID of this rmw instruction.
void setOrdering(AtomicOrdering Ordering)
Sets the ordering constraint of this rmw instruction.
void setOperation(BinOp Operation)
friend class Instruction
Iterator for Instructions in a `BasicBlock.
BinOp getOperation() const
LLVM_ABI AtomicRMWInst(BinOp Operation, Value *Ptr, Value *Val, Align Alignment, AtomicOrdering Ordering, SyncScope::ID SSID, InsertPosition InsertBefore=nullptr)
Definition Instructions.cpp:1450
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this rmw instruction.
void setAlignment(Align Align)
static LLVM_ABI StringRef getOperationName(BinOp Op)
Definition Instructions.cpp:1457
AtomicOrdering getOrdering() const
Returns the ordering constraint of this rmw instruction.
LLVM_ABI CaptureInfo getCaptureInfo() const
Functions, function parameters, and return types can have attributes to indicate how they should be t...
LLVM_ABI const ConstantRange & getRange() const
Returns the value of the range attribute.
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
static LLVM_ABI Attribute getWithMemoryEffects(LLVMContext &Context, MemoryEffects ME)
bool isValid() const
Return true if the attribute is any kind of attribute.
LLVM Basic Block Representation.
const Function * getParent() const
Return the enclosing method, or null if none.
LLVM_ABI const DataLayout & getDataLayout() const
Get the data layout of the module this basic block belongs to.
static LLVM_ABI BinaryOperator * CreateNeg(Value *Op, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Helper functions to construct and inspect unary operations (NEG and NOT) via binary operators SUB and...
Definition Instructions.cpp:2711
BinaryOps getOpcode() const
LLVM_ABI bool swapOperands()
Exchange the two operands to this instruction.
Definition Instructions.cpp:2734
static LLVM_ABI BinaryOperator * CreateNot(Value *Op, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Definition Instructions.cpp:2724
friend class Instruction
Iterator for Instructions in a `BasicBlock.
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.
Definition Instructions.cpp:2703
LLVM_ABI BinaryOperator(BinaryOps iType, Value *S1, Value *S2, Type *Ty, const Twine &Name, InsertPosition InsertBefore)
Definition Instructions.cpp:2626
static LLVM_ABI BinaryOperator * CreateNSWNeg(Value *Op, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Definition Instructions.cpp:2718
LLVM_ABI BinaryOperator * cloneImpl() const
Definition Instructions.cpp:4343
This class represents a no-op cast from one type to another.
LLVM_ABI BitCastInst * cloneImpl() const
Clone an identical BitCastInst.
Definition Instructions.cpp:4450
LLVM_ABI BitCastInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
Definition Instructions.cpp:3481
Conditional or Unconditional Branch instruction.
LLVM_ABI void swapSuccessors()
Swap the successors of this branch instruction.
Definition Instructions.cpp:1233
LLVM_ABI BranchInst * cloneImpl() const
Definition Instructions.cpp:4500
bool isConditional() const
Value * getCondition() const
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
LLVM_ABI FPClassTest getParamNoFPClass(unsigned i) const
Extract a test mask for disallowed floating-point value classes for the parameter.
Definition Instructions.cpp:371
bool isInlineAsm() const
Check if this call is an inline asm statement.
LLVM_ABI BundleOpInfo & getBundleOpInfoForOperand(unsigned OpIdx)
Return the BundleOpInfo for the operand at index OpIdx.
Definition Instructions.cpp:541
void setCallingConv(CallingConv::ID CC)
LLVM_ABI FPClassTest getRetNoFPClass() const
Extract a test mask for disallowed floating-point value classes for the return value.
Definition Instructions.cpp:363
bundle_op_iterator bundle_op_info_begin()
Return the start of the list of BundleOpInfo instances associated with this OperandBundleUser.
LLVM_ABI bool paramHasNonNullAttr(unsigned ArgNo, bool AllowUndefOrPoison) const
Return true if this argument has the nonnull attribute on either the CallBase instruction or the call...
Definition Instructions.cpp:444
LLVM_ABI MemoryEffects getMemoryEffects() const
Definition Instructions.cpp:635
void addFnAttr(Attribute::AttrKind Kind)
Adds the attribute to the function.
LLVM_ABI bool doesNotAccessMemory() const
Determine if the call does not access memory.
Definition Instructions.cpp:659
LLVM_ABI void getOperandBundlesAsDefs(SmallVectorImpl< OperandBundleDef > &Defs) const
Return the list of operand bundles attached to this instruction as a vector of OperandBundleDefs.
Definition Instructions.cpp:509
LLVM_ABI void setOnlyAccessesArgMemory()
Definition Instructions.cpp:687
OperandBundleUse getOperandBundleAt(unsigned Index) const
Return the operand bundle at a specific index.
OperandBundleUse operandBundleFromBundleOpInfo(const BundleOpInfo &BOI) const
Simple helper function to map a BundleOpInfo to an OperandBundleUse.
LLVM_ABI void setOnlyAccessesInaccessibleMemOrArgMem()
Definition Instructions.cpp:705
std::optional< OperandBundleUse > getOperandBundle(StringRef Name) const
Return an operand bundle by name, if present.
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
LLVM_ABI void setDoesNotAccessMemory()
Definition Instructions.cpp:662
AttributeSet getParamAttributes(unsigned ArgNo) const
Return the param attributes for this call.
bool hasRetAttr(Attribute::AttrKind Kind) const
Determine whether the return value has the given attribute.
LLVM_ABI bool onlyAccessesInaccessibleMemory() const
Determine if the function may only access memory that is inaccessible from the IR.
Definition Instructions.cpp:693
unsigned getNumOperandBundles() const
Return the number of operand bundles associated with this User.
CallingConv::ID getCallingConv() const
bundle_op_iterator bundle_op_info_end()
Return the end of the list of BundleOpInfo instances associated with this OperandBundleUser.
LLVM_ABI unsigned getNumSubclassExtraOperandsDynamic() const
Get the number of extra operands for instructions that don't have a fixed number of extra operands.
Definition Instructions.cpp:330
BundleOpInfo * bundle_op_iterator
LLVM_ABI bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Determine whether the argument or parameter has the given attribute.
Definition Instructions.cpp:418
User::op_iterator arg_begin()
Return the iterator pointing to the beginning of the argument list.
LLVM_ABI bool isMustTailCall() const
Tests if this call site must be tail call optimized.
Definition Instructions.cpp:344
LLVM_ABI bool isIndirectCall() const
Return true if the callsite is an indirect call.
Definition Instructions.cpp:335
LLVM_ABI bool onlyReadsMemory() const
Determine if the call does not access or only reads memory.
Definition Instructions.cpp:667
bool isByValArgument(unsigned ArgNo) const
Determine whether this argument is passed by value.
iterator_range< bundle_op_iterator > bundle_op_infos()
Return the range [bundle_op_info_begin, bundle_op_info_end).
LLVM_ABI void setOnlyReadsMemory()
Definition Instructions.cpp:670
static LLVM_ABI CallBase * addOperandBundle(CallBase *CB, uint32_t ID, OperandBundleDef OB, InsertPosition InsertPt=nullptr)
Create a clone of CB with operand bundle OB added.
Definition Instructions.cpp:588
LLVM_ABI bool onlyAccessesInaccessibleMemOrArgMem() const
Determine if the function may only access memory that is either inaccessible from the IR or pointed t...
Definition Instructions.cpp:702
LLVM_ABI CaptureInfo getCaptureInfo(unsigned OpNo) const
Return which pointer components this operand may capture.
Definition Instructions.cpp:710
LLVM_ABI bool hasArgumentWithAdditionalReturnCaptureComponents() const
Returns whether the call has an argument that has an attribute like captures(ret: address,...
Definition Instructions.cpp:729
CallBase(AttributeList const &A, FunctionType *FT, ArgsTy &&... Args)
Value * getCalledOperand() const
LLVM_ABI void setOnlyWritesMemory()
Definition Instructions.cpp:678
LLVM_ABI op_iterator populateBundleOperandInfos(ArrayRef< OperandBundleDef > Bundles, const unsigned BeginIndex)
Populate the BundleOpInfo instances and the Use& vector from Bundles.
Definition Instructions.cpp:516
AttributeList Attrs
parameter attributes for callable
bool hasOperandBundlesOtherThan(ArrayRef< uint32_t > IDs) const
Return true if this operand bundle user contains operand bundles with tags other than those specified...
LLVM_ABI std::optional< ConstantRange > getRange() const
If this return value has a range attribute, return the value range of the argument.
Definition Instructions.cpp:379
LLVM_ABI bool isReturnNonNull() const
Return true if the return value is known to be not null.
Definition Instructions.cpp:394
Value * getArgOperand(unsigned i) const
uint64_t getRetDereferenceableBytes() const
Extract the number of dereferenceable bytes for a call or parameter (0=unknown).
User::op_iterator arg_end()
Return the iterator pointing to the end of the argument list.
FunctionType * getFunctionType() const
LLVM_ABI Intrinsic::ID getIntrinsicID() const
Returns the intrinsic ID of the intrinsic called or Intrinsic::not_intrinsic if the called function i...
Definition Instructions.cpp:357
static unsigned CountBundleInputs(ArrayRef< OperandBundleDef > Bundles)
Return the total number of values used in Bundles.
LLVM_ABI Value * getArgOperandWithAttribute(Attribute::AttrKind Kind) const
If one of the arguments has the specified attribute, returns its operand value.
Definition Instructions.cpp:405
LLVM_ABI void setOnlyAccessesInaccessibleMemory()
Definition Instructions.cpp:696
static LLVM_ABI CallBase * Create(CallBase *CB, ArrayRef< OperandBundleDef > Bundles, InsertPosition InsertPt=nullptr)
Create a clone of CB with a different set of operand bundles and insert it before InsertPt.
Definition Instructions.cpp:302
LLVM_ABI bool onlyWritesMemory() const
Determine if the call does not access or only writes memory.
Definition Instructions.cpp:675
LLVM_ABI bool hasClobberingOperandBundles() const
Return true if this operand bundle user has operand bundles that may write to the heap.
Definition Instructions.cpp:627
void setCalledOperand(Value *V)
static LLVM_ABI CallBase * removeOperandBundle(CallBase *CB, uint32_t ID, InsertPosition InsertPt=nullptr)
Create a clone of CB with operand bundle ID removed.
Definition Instructions.cpp:600
LLVM_ABI bool hasReadingOperandBundles() const
Return true if this operand bundle user has operand bundles that may read from the heap.
Definition Instructions.cpp:617
LLVM_ABI bool onlyAccessesArgMemory() const
Determine if the call can access memmory only using pointers based on its arguments.
Definition Instructions.cpp:684
unsigned arg_size() const
AttributeList getAttributes() const
Return the attributes for this call.
LLVM_ABI void setMemoryEffects(MemoryEffects ME)
Definition Instructions.cpp:654
bool hasOperandBundles() const
Return true if this User has any operand bundles.
LLVM_ABI bool isTailCall() const
Tests if this call site is marked as a tail call.
Definition Instructions.cpp:351
LLVM_ABI Function * getCaller()
Helper to get the caller (the parent function).
Definition Instructions.cpp:328
CallBr instruction, tracking function calls that may not return control but instead transfer it to a ...
SmallVector< BasicBlock *, 16 > getIndirectDests() const
void setDefaultDest(BasicBlock *B)
void setIndirectDest(unsigned i, BasicBlock *B)
BasicBlock * getDefaultDest() const
static CallBrInst * Create(FunctionType *Ty, Value *Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)
LLVM_ABI CallBrInst * cloneImpl() const
Definition Instructions.cpp:4522
This class represents a function call, abstracting a target machine's calling convention.
LLVM_ABI void updateProfWeight(uint64_t S, uint64_t T)
Updates profile metadata by scaling it by S / T.
Definition Instructions.cpp:823
TailCallKind getTailCallKind() const
LLVM_ABI CallInst * cloneImpl() const
Definition Instructions.cpp:4458
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Represents which components of the pointer may be captured in which location.
CaptureComponents getOtherComponents() const
Get components potentially captured through locations other than the return value.
static CaptureInfo none()
Create CaptureInfo that does not capture any components of the pointer.
static CaptureInfo all()
Create CaptureInfo that may capture all components of the pointer.
CaptureComponents getRetComponents() const
Get components potentially captured by the return value.
static LLVM_ABI Instruction::CastOps getCastOpcode(const Value *Val, bool SrcIsSigned, Type *Ty, bool DstIsSigned)
Returns the opcode necessary to cast Val into Ty using usual casting rules.
Definition Instructions.cpp:3212
static LLVM_ABI CastInst * CreatePointerBitCastOrAddrSpaceCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a BitCast or an AddrSpaceCast cast instruction.
Definition Instructions.cpp:3104
Instruction::CastOps getOpcode() const
Return the opcode of this CastInst.
static LLVM_ABI CastInst * CreateIntegerCast(Value *S, Type *Ty, bool isSigned, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a ZExt, BitCast, or Trunc for int -> int casts.
Definition Instructions.cpp:3126
static LLVM_ABI CastInst * CreateFPCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create an FPExt, BitCast, or FPTrunc for fp -> fp casts.
Definition Instructions.cpp:3140
static LLVM_ABI unsigned isEliminableCastPair(Instruction::CastOps firstOpcode, Instruction::CastOps secondOpcode, Type *SrcTy, Type *MidTy, Type *DstTy, Type *SrcIntPtrTy, Type *MidIntPtrTy, Type *DstIntPtrTy)
Determine how a pair of casts can be eliminated, if they can be at all.
Definition Instructions.cpp:2823
CastInst(Type *Ty, unsigned iType, Value *S, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics for subclasses.
static LLVM_ABI bool isBitOrNoopPointerCastable(Type *SrcTy, Type *DestTy, const DataLayout &DL)
Check whether a bitcast, inttoptr, or ptrtoint cast between these types is valid and a no-op.
Definition Instructions.cpp:3190
static LLVM_ABI bool isBitCastable(Type *SrcTy, Type *DestTy)
Check whether a bitcast between these types is valid.
Definition Instructions.cpp:3153
static LLVM_ABI CastInst * CreateTruncOrBitCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a Trunc or BitCast cast instruction.
Definition Instructions.cpp:3079
static LLVM_ABI CastInst * CreatePointerCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a BitCast, AddrSpaceCast or a PtrToInt cast instruction.
Definition Instructions.cpp:3087
static LLVM_ABI CastInst * CreateBitOrPointerCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a BitCast, a PtrToInt, or an IntToPTr cast instruction.
Definition Instructions.cpp:3115
static LLVM_ABI bool isNoopCast(Instruction::CastOps Opcode, Type *SrcTy, Type *DstTy, const DataLayout &DL)
A no-op cast is one that can be effected without changing any bits.
Definition Instructions.cpp:2780
static LLVM_ABI CastInst * CreateZExtOrBitCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a ZExt or BitCast cast instruction.
Definition Instructions.cpp:3065
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 ...
Definition Instructions.cpp:3039
LLVM_ABI bool isIntegerCast() const
There are several places where we need to know if a cast instruction only deals with integer source a...
Definition Instructions.cpp:2759
static LLVM_ABI CastInst * CreateSExtOrBitCast(Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Create a SExt or BitCast cast instruction.
Definition Instructions.cpp:3072
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.
Definition Instructions.cpp:3309
LLVM_ABI CatchReturnInst * cloneImpl() const
Definition Instructions.cpp:4542
void setUnwindDest(BasicBlock *UnwindDest)
LLVM_ABI void addHandler(BasicBlock *Dest)
Add an entry to the switch instruction... Note: This action invalidates handler_end().
Definition Instructions.cpp:1132
LLVM_ABI CatchSwitchInst * cloneImpl() const
Definition Instructions.cpp:4546
mapped_iterator< op_iterator, DerefFnTy > handler_iterator
Value * getParentPad() const
void setParentPad(Value *ParentPad)
BasicBlock * getUnwindDest() const
LLVM_ABI void removeHandler(handler_iterator HI)
Definition Instructions.cpp:1140
bool hasUnwindDest() const
LLVM_ABI CleanupReturnInst * cloneImpl() const
Definition Instructions.cpp:4537
This class is the base class for the comparison instructions.
Predicate getStrictPredicate() const
For example, SGE -> SGT, SLE -> SLT, ULE -> ULT, UGE -> UGT.
bool isEquality() const
Determine if this is an equals/not equals predicate.
void setPredicate(Predicate P)
Set the predicate for this instruction to the specified value.
bool isFalseWhenEqual() const
This is just a convenience.
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)
LLVM_ABI bool isEquivalence(bool Invert=false) const
Determine if one operand of this compare can always be replaced by the other operand,...
Definition Instructions.cpp:3574
static LLVM_ABI bool isEquality(Predicate pred)
Determine if this is an equals/not equals predicate.
Definition Instructions.cpp:3551
Predicate getSwappedPredicate() const
For example, EQ->EQ, SLE->SGE, ULT->UGT, OEQ->OEQ, ULE->UGE, OLT->OGT, etc.
bool isTrueWhenEqual() const
This is just a convenience.
static LLVM_ABI CmpInst * Create(OtherOps Op, Predicate Pred, Value *S1, Value *S2, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Construct a compare instruction, given the opcode, the predicate and the two operands.
Definition Instructions.cpp:3509
static bool isFPPredicate(Predicate P)
Predicate getNonStrictPredicate() const
For example, SGT -> SGE, SLT -> SLE, ULT -> ULE, UGT -> UGE.
static LLVM_ABI CmpInst * CreateWithCopiedFlags(OtherOps Op, Predicate Pred, Value *S1, Value *S2, const Instruction *FlagsSource, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Construct a compare instruction, given the opcode, the predicate, the two operands and the instructio...
Definition Instructions.cpp:3528
bool isNonStrictPredicate() const
LLVM_ABI void swapOperands()
This is just a convenience that dispatches to the subclasses.
Definition Instructions.cpp:3538
static bool isRelational(Predicate P)
Return true if the predicate is relational (not EQ or NE).
Predicate getInversePredicate() const
For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE,...
static LLVM_ABI StringRef getPredicateName(Predicate P)
Definition Instructions.cpp:3622
Predicate getPredicate() const
Return the predicate for this instruction.
bool isStrictPredicate() const
static LLVM_ABI bool isUnordered(Predicate predicate)
Determine if the predicate is an unordered operation.
Definition Instructions.cpp:3939
Predicate getFlippedStrictnessPredicate() const
For predicate of kind "is X or equal to 0" returns the predicate "is X".
static bool isIntPredicate(Predicate P)
static LLVM_ABI bool isOrdered(Predicate predicate)
Determine if the predicate is an ordered operation.
Definition Instructions.cpp:3930
LLVM_ABI CmpInst(Type *ty, Instruction::OtherOps op, Predicate pred, Value *LHS, Value *RHS, const Twine &Name="", InsertPosition InsertBefore=nullptr, Instruction *FlagsSource=nullptr)
Definition Instructions.cpp:3497
LLVM_ABI bool isCommutative() const
This is just a convenience that dispatches to the subclasses.
Definition Instructions.cpp:3545
An abstraction over a floating-point predicate, and a pack of an integer predicate with samesign info...
static LLVM_ABI std::optional< CmpPredicate > getMatching(CmpPredicate A, CmpPredicate B)
Compares two CmpPredicates taking samesign into account and returns the canonicalized CmpPredicate if...
Definition Instructions.cpp:4013
CmpPredicate()
Default constructor.
static LLVM_ABI CmpPredicate get(const CmpInst *Cmp)
Do a ICmpInst::getCmpPredicate() or CmpInst::getPredicate(), as appropriate.
Definition Instructions.cpp:4032
LLVM_ABI CmpInst::Predicate getPreferredSignedPredicate() const
Attempts to return a signed CmpInst::Predicate from the CmpPredicate.
Definition Instructions.cpp:4028
bool hasSameSign() const
Query samesign information, for optimizations.
static LLVM_ABI CmpPredicate getSwapped(CmpPredicate P)
Get the swapped predicate of a CmpPredicate.
Definition Instructions.cpp:4038
ConstantFP - Floating Point Values [float, double].
const APFloat & getValueAPF() const
This is the shared class of boolean and integer constants.
LLVM_ABI ConstantRange intersectWith(const ConstantRange &CR, PreferredRangeType Type=Smallest) const
Return the range that results from the intersection of this range with another range.
static LLVM_ABI Constant * get(ArrayRef< Constant * > V)
This is an important base class in LLVM.
static LLVM_ABI Constant * getAllOnesValue(Type *Ty)
static LLVM_ABI Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
A parsed version of the target data layout string in and methods for querying it.
static constexpr ElementCount getFixed(ScalarTy MinVal)
This instruction compares its operands according to the predicate given to the constructor.
static LLVM_ABI bool compare(const APFloat &LHS, const APFloat &RHS, FCmpInst::Predicate Pred)
Return result of LHS Pred RHS comparison.
Definition Instructions.cpp:3849
LLVM_ABI FCmpInst * cloneImpl() const
Clone an identical FCmpInst.
Definition Instructions.cpp:4347
FCmpInst(InsertPosition InsertBefore, Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
Constructor with insertion semantics.
This class represents an extension of floating point types.
LLVM_ABI FPExtInst * cloneImpl() const
Clone an identical FPExtInst.
Definition Instructions.cpp:4418
LLVM_ABI FPExtInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
Definition Instructions.cpp:3433
LLVM_ABI float getFPAccuracy() const
Get the maximum error permitted by this operation in ULPs.
Definition Instructions.cpp:2745
This class represents a cast from floating point to signed integer.
LLVM_ABI FPToSIInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
Definition Instructions.cpp:3457
LLVM_ABI FPToSIInst * cloneImpl() const
Clone an identical FPToSIInst.
Definition Instructions.cpp:4434
This class represents a cast from floating point to unsigned integer.
LLVM_ABI FPToUIInst * cloneImpl() const
Clone an identical FPToUIInst.
Definition Instructions.cpp:4430
LLVM_ABI FPToUIInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
Definition Instructions.cpp:3451
This class represents a truncation of floating point types.
LLVM_ABI FPTruncInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
Definition Instructions.cpp:3427
LLVM_ABI FPTruncInst * cloneImpl() const
Clone an identical FPTruncInst.
Definition Instructions.cpp:4414
LLVM_ABI FenceInst(LLVMContext &C, AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System, InsertPosition InsertBefore=nullptr)
Definition Instructions.cpp:1512
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this fence instruction.
void setSyncScopeID(SyncScope::ID SSID)
Sets the synchronization scope ID of this fence instruction.
LLVM_ABI FenceInst * cloneImpl() const
Definition Instructions.cpp:4398
friend class Instruction
Iterator for Instructions in a `BasicBlock.
void setOrdering(AtomicOrdering Ordering)
Sets the ordering constraint of this fence instruction.
AtomicOrdering getOrdering() const
Returns the ordering constraint of this fence instruction.
Class to represent fixed width SIMD vectors.
unsigned getNumElements() const
LLVM_ABI FreezeInst(Value *S, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Definition Instructions.cpp:4322
LLVM_ABI FreezeInst * cloneImpl() const
Clone an identical FreezeInst.
Definition Instructions.cpp:4581
void setParentPad(Value *ParentPad)
Value * getParentPad() const
Convenience accessors.
LLVM_ABI FuncletPadInst * cloneImpl() const
Definition Instructions.cpp:4550
Class to represent function types.
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
Type * getParamType(unsigned i) const
Parameter type accessors.
Represents flags for the getelementptr instruction/expression.
static GEPNoWrapFlags inBounds()
GEPNoWrapFlags withoutInBounds() const
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
LLVM_ABI bool isInBounds() const
Determine whether the GEP has the inbounds flag.
Definition Instructions.cpp:1638
LLVM_ABI bool hasNoUnsignedSignedWrap() const
Determine whether the GEP has the nusw flag.
Definition Instructions.cpp:1642
static LLVM_ABI Type * getTypeAtIndex(Type *Ty, Value *Idx)
Return the type of the element at the given index of an indexable type.
Definition Instructions.cpp:1543
LLVM_ABI bool hasAllZeroIndices() const
Return true if all of the indices of this GEP are zeros.
Definition Instructions.cpp:1599
LLVM_ABI bool hasNoUnsignedWrap() const
Determine whether the GEP has the nuw flag.
Definition Instructions.cpp:1646
LLVM_ABI bool hasAllConstantIndices() const
Return true if all of the indices of this GEP are constant integers.
Definition Instructions.cpp:1613
LLVM_ABI void setIsInBounds(bool b=true)
Set or clear the inbounds flag on this GEP instruction.
Definition Instructions.cpp:1625
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.
Definition Instructions.cpp:1583
LLVM_ABI bool accumulateConstantOffset(const DataLayout &DL, APInt &Offset) const
Accumulate the constant address offset of this GEP if possible.
Definition Instructions.cpp:1650
LLVM_ABI GetElementPtrInst * cloneImpl() const
Definition Instructions.cpp:4334
LLVM_ABI bool collectOffset(const DataLayout &DL, unsigned BitWidth, SmallMapVector< Value *, APInt, 4 > &VariableOffsets, APInt &ConstantOffset) const
Definition Instructions.cpp:1656
LLVM_ABI void setNoWrapFlags(GEPNoWrapFlags NW)
Set nowrap flags for GEP instruction.
Definition Instructions.cpp:1621
LLVM_ABI GEPNoWrapFlags getNoWrapFlags() const
Get the nowrap flags for the GEP instruction.
Definition Instructions.cpp:1634
Module * getParent()
Get the module that this global value is contained inside of...
This instruction compares its operands according to the predicate given to the constructor.
ICmpInst(InsertPosition InsertBefore, Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")
Constructor with insertion semantics.
static LLVM_ABI bool compare(const APInt &LHS, const APInt &RHS, ICmpInst::Predicate Pred)
Return result of LHS Pred RHS comparison.
Definition Instructions.cpp:3820
LLVM_ABI ICmpInst * cloneImpl() const
Clone an identical ICmpInst.
Definition Instructions.cpp:4351
Predicate getFlippedSignednessPredicate() const
For example, SLT->ULT, ULT->SLT, SLE->ULE, ULE->SLE, EQ->EQ.
Predicate getSignedPredicate() const
For example, EQ->EQ, SLE->SLE, UGT->SGT, etc.
static CmpPredicate getInverseCmpPredicate(CmpPredicate Pred)
bool isEquality() const
Return true if this predicate is either EQ or NE.
static LLVM_ABI Predicate getFlippedSignednessPredicate(Predicate Pred)
For example, SLT->ULT, ULT->SLT, SLE->ULE, ULE->SLE, EQ->EQ.
Definition Instructions.cpp:3919
static LLVM_ABI std::optional< bool > isImpliedByMatchingCmp(CmpPredicate Pred1, CmpPredicate Pred2)
Determine if Pred1 implies Pred2 is true, false, or if nothing can be inferred about the implication,...
Definition Instructions.cpp:4000
Predicate getUnsignedPredicate() const
For example, EQ->EQ, SLE->ULE, UGT->UGT, etc.
Indirect Branch Instruction.
LLVM_ABI void addDestination(BasicBlock *Dest)
Add a destination.
Definition Instructions.cpp:4292
LLVM_ABI void removeDestination(unsigned i)
This method removes the specified successor from the indirectbr instruction.
Definition Instructions.cpp:4304
LLVM_ABI IndirectBrInst * cloneImpl() const
Definition Instructions.cpp:4507
LLVM_ABI InsertElementInst * cloneImpl() const
Definition Instructions.cpp:4481
static InsertElementInst * Create(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static LLVM_ABI bool isValidOperands(const Value *Vec, const Value *NewElt, const Value *Idx)
Return true if an insertelement instruction can be formed with the specified operands.
Definition Instructions.cpp:1703
BasicBlock * getBasicBlock()
This instruction inserts a struct field of array element value into an aggregate value.
LLVM_ABI InsertValueInst * cloneImpl() const
Definition Instructions.cpp:4359
BitfieldElement::Type getSubclassData() const
LLVM_ABI bool hasNoNaNs() const LLVM_READONLY
Determine whether the no-NaNs flag is set.
LLVM_ABI void copyIRFlags(const Value *V, bool IncludeWrapFlags=true)
Convenience method to copy supported exact, fast-math, and (optionally) wrapping flags from V to this...
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
LLVM_ABI bool isCommutative() const LLVM_READONLY
Return true if the instruction is commutative:
LLVM_ABI InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
LLVM_ABI const Function * getFunction() const
Return the function this instruction belongs to.
LLVM_ABI void swapProfMetadata()
If the instruction has "branch_weights" MD_prof metadata and the MDNode has three operands (including...
LLVM_ABI bool isVolatile() const LLVM_READONLY
Return true if this instruction has a volatile memory access.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
Bitfield::Element< uint16_t, 0, 15 > OpaqueField
Instruction(const Instruction &)=delete
friend class BasicBlock
Various leaf nodes.
void setSubclassData(typename BitfieldElement::Type Value)
This class represents a cast from an integer to a pointer.
LLVM_ABI IntToPtrInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
Definition Instructions.cpp:3475
LLVM_ABI IntToPtrInst * cloneImpl() const
Clone an identical IntToPtrInst.
Definition Instructions.cpp:4446
BasicBlock * getUnwindDest() const
void setNormalDest(BasicBlock *B)
LLVM_ABI InvokeInst * cloneImpl() const
Definition Instructions.cpp:4511
LLVM_ABI LandingPadInst * getLandingPadInst() const
Get the landingpad instruction from the landing pad block (the unwind destination).
Definition Instructions.cpp:899
void setUnwindDest(BasicBlock *B)
LLVM_ABI void updateProfWeight(uint64_t S, uint64_t T)
Updates profile metadata by scaling it by S / T.
Definition Instructions.cpp:903
static InvokeInst * Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)
This is an important class for using LLVM in a threaded context.
LLVMContextImpl *const pImpl
The landingpad instruction holds all of the information necessary to generate correct exception handl...
bool isCleanup() const
Return 'true' if this landingpad instruction is a cleanup.
LLVM_ABI LandingPadInst * cloneImpl() const
Definition Instructions.cpp:4491
static LLVM_ABI LandingPadInst * Create(Type *RetTy, unsigned NumReservedClauses, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructors - NumReservedClauses is a hint for the number of incoming clauses that this landingpad w...
Definition Instructions.cpp:267
LLVM_ABI void addClause(Constant *ClauseVal)
Add a catch or filter clause to the landing pad.
Definition Instructions.cpp:290
void setCleanup(bool V)
Indicate that this landingpad instruction is a cleanup.
void setAlignment(Align Align)
bool isVolatile() const
Return true if this is a load from a volatile memory location.
void setAtomic(AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System)
Sets the ordering constraint and the synchronization scope ID of this load instruction.
LLVM_ABI LoadInst * cloneImpl() const
Definition Instructions.cpp:4371
AtomicOrdering getOrdering() const
Returns the ordering constraint of this load instruction.
void setVolatile(bool V)
Specify whether this is a volatile load or not.
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this load instruction.
LLVM_ABI LoadInst(Type *Ty, Value *Ptr, const Twine &NameStr, InsertPosition InsertBefore)
Definition Instructions.cpp:1327
Align getAlign() const
Return the alignment of the access that is being performed.
LLVM_ABI MDNode * createBranchWeights(uint32_t TrueWeight, uint32_t FalseWeight, bool IsExpected=false)
Return metadata containing two branch weights.
const MDOperand & getOperand(unsigned I) const
static MemoryEffectsBase readOnly()
bool onlyWritesMemory() const
Whether this function only (at most) writes memory.
bool doesNotAccessMemory() const
Whether this function accesses no memory.
static MemoryEffectsBase argMemOnly(ModRefInfo MR=ModRefInfo::ModRef)
static MemoryEffectsBase inaccessibleMemOnly(ModRefInfo MR=ModRefInfo::ModRef)
bool onlyAccessesInaccessibleMem() const
Whether this function only (at most) accesses inaccessible memory.
bool onlyAccessesArgPointees() const
Whether this function only (at most) accesses argument memory.
bool onlyReadsMemory() const
Whether this function only (at most) reads memory.
static MemoryEffectsBase writeOnly()
static MemoryEffectsBase inaccessibleOrArgMemOnly(ModRefInfo MR=ModRefInfo::ModRef)
static MemoryEffectsBase none()
bool onlyAccessesInaccessibleOrArgMem() const
Whether this function only (at most) accesses argument and inaccessible memory.
iterator_range< const_block_iterator > blocks() const
void allocHungoffUses(unsigned N)
const_block_iterator block_begin() const
LLVM_ABI void removeIncomingValueIf(function_ref< bool(unsigned)> Predicate, bool DeletePHIIfEmpty=true)
Remove all incoming values for which the predicate returns true.
Definition Instructions.cpp:162
BasicBlock ** block_iterator
LLVM_ABI Value * removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty=true)
Remove an incoming value.
Definition Instructions.cpp:138
LLVM_ABI bool hasConstantOrUndefValue() const
Whether the specified PHI node always merges together the same value, assuming undefs are equal to a ...
Definition Instructions.cpp:230
void copyIncomingBlocks(iterator_range< const_block_iterator > BBRange, uint32_t ToIdx=0)
Copies the basic blocks from BBRange to the incoming basic block list of this PHINode,...
const_block_iterator block_end() const
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
LLVM_ABI Value * hasConstantValue() const
If the specified PHI node always merges together the same value, return the value,...
Definition Instructions.cpp:210
LLVM_ABI PHINode * cloneImpl() const
Definition Instructions.cpp:4489
unsigned getNumIncomingValues() const
Return the number of incoming edges.
Class to represent pointers.
unsigned getAddressSpace() const
Return the address space of the Pointer type.
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
This class represents a cast from a pointer to an address (non-capturing ptrtoint).
PtrToAddrInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
Definition Instructions.cpp:3469
PtrToAddrInst * cloneImpl() const
Clone an identical PtrToAddrInst.
Definition Instructions.cpp:4442
This class represents a cast from a pointer to an integer.
LLVM_ABI PtrToIntInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
Definition Instructions.cpp:3463
LLVM_ABI PtrToIntInst * cloneImpl() const
Clone an identical PtrToIntInst.
Definition Instructions.cpp:4438
Resume the propagation of an exception.
LLVM_ABI ResumeInst * cloneImpl() const
Definition Instructions.cpp:4533
Return a value (possibly void), from a function.
LLVM_ABI ReturnInst * cloneImpl() const
Definition Instructions.cpp:4495
This class represents a sign extension of integer types.
LLVM_ABI SExtInst * cloneImpl() const
Clone an identical SExtInst.
Definition Instructions.cpp:4410
LLVM_ABI SExtInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
Definition Instructions.cpp:3421
This class represents a cast from signed integer to floating point.
LLVM_ABI SIToFPInst * cloneImpl() const
Clone an identical SIToFPInst.
Definition Instructions.cpp:4426
LLVM_ABI SIToFPInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
Definition Instructions.cpp:3445
Class to represent scalable SIMD vectors.
static SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr="", InsertPosition InsertBefore=nullptr, Instruction *MDFrom=nullptr)
LLVM_ABI SelectInst * cloneImpl() const
Definition Instructions.cpp:4469
static LLVM_ABI const char * areInvalidOperands(Value *Cond, Value *True, Value *False)
Return a string if the specified operands are invalid for a select operation, otherwise return null.
Definition Instructions.cpp:99
static LLVM_ABI bool isZeroEltSplatMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask chooses all elements with the same value as the first element of exa...
Definition Instructions.cpp:1975
ArrayRef< int > getShuffleMask() const
static LLVM_ABI bool isSpliceMask(ArrayRef< int > Mask, int NumSrcElts, int &Index)
Return true if this shuffle mask is a splice mask, concatenating the two inputs together and then ext...
Definition Instructions.cpp:2040
int getMaskValue(unsigned Elt) const
Return the shuffle mask value of this instruction for the given element index.
LLVM_ABI ShuffleVectorInst(Value *V1, Value *Mask, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Definition Instructions.cpp:1725
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.
Definition Instructions.cpp:1807
static LLVM_ABI bool isSelectMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask chooses elements from its source vectors without lane crossings.
Definition Instructions.cpp:1989
static LLVM_ABI bool isBitRotateMask(ArrayRef< int > Mask, unsigned EltSizeInBits, unsigned MinSubElts, unsigned MaxSubElts, unsigned &NumSubElts, unsigned &RotateAmt)
Checks if the shuffle is a bit rotation of the first operand across multiple subelements,...
Definition Instructions.cpp:2490
VectorType * getType() const
Overload to return most specific vector type.
LLVM_ABI bool isIdentityWithExtract() const
Return true if this shuffle extracts the first N elements of exactly one source vector.
Definition Instructions.cpp:2200
static LLVM_ABI bool isOneUseSingleSourceMask(ArrayRef< int > Mask, int VF)
Return true if this shuffle mask represents "clustered" mask of size VF, i.e.
Definition Instructions.cpp:2317
LLVM_ABI bool isIdentityWithPadding() const
Return true if this shuffle lengthens exactly one source vector with undefs in the high elements.
Definition Instructions.cpp:2176
static LLVM_ABI bool isSingleSourceMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask chooses elements from exactly one source vector.
Definition Instructions.cpp:1929
LLVM_ABI bool isConcat() const
Return true if this shuffle concatenates its 2 source vectors.
Definition Instructions.cpp:2214
static LLVM_ABI bool isDeInterleaveMaskOfFactor(ArrayRef< int > Mask, unsigned Factor, unsigned &Index)
Check if the mask is a DE-interleave mask of the given factor Factor like: <Index,...
Definition Instructions.cpp:2443
LLVM_ABI ShuffleVectorInst * cloneImpl() const
Definition Instructions.cpp:4485
static LLVM_ABI bool isIdentityMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask chooses elements from exactly one source vector without lane crossin...
Definition Instructions.cpp:1947
static LLVM_ABI bool isExtractSubvectorMask(ArrayRef< int > Mask, int NumSrcElts, int &Index)
Return true if this shuffle mask is an extract subvector mask.
Definition Instructions.cpp:2074
LLVM_ABI void setShuffleMask(ArrayRef< int > Mask)
Definition Instructions.cpp:1886
friend class Instruction
Iterator for Instructions in a `BasicBlock.
LLVM_ABI bool isInterleave(unsigned Factor)
Return if this shuffle interleaves its two input vectors together.
Definition Instructions.cpp:2348
static LLVM_ABI bool isReverseMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask swaps the order of elements from exactly one source vector.
Definition Instructions.cpp:1955
static LLVM_ABI bool isTransposeMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask is a transpose mask.
Definition Instructions.cpp:2004
LLVM_ABI void commute()
Swap the operands and adjust the mask to preserve the semantics of the instruction.
Definition Instructions.cpp:1769
static LLVM_ABI bool isInsertSubvectorMask(ArrayRef< int > Mask, int NumSrcElts, int &NumSubElts, int &Index)
Return true if this shuffle mask is an insert subvector mask.
Definition Instructions.cpp:2103
static LLVM_ABI Constant * convertShuffleMaskForBitcode(ArrayRef< int > Mask, Type *ResultTy)
Definition Instructions.cpp:1891
static LLVM_ABI bool isReplicationMask(ArrayRef< int > Mask, int &ReplicationFactor, int &VF)
Return true if this shuffle mask replicates each of the VF elements in a vector ReplicationFactor tim...
Definition Instructions.cpp:2256
static LLVM_ABI bool isInterleaveMask(ArrayRef< int > Mask, unsigned Factor, unsigned NumInputElts, SmallVectorImpl< unsigned > &StartIndexes)
Return true if the mask interleaves one or more input vectors together.
Definition Instructions.cpp:2359
This is a 'bitvector' (really, a variable-sized bit array), optimized for the case when the array is ...
Implements a dense probed hash-table based set with some number of buckets stored inline.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
reference emplace_back(ArgTypes &&... Args)
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.
AtomicOrdering getOrdering() const
Returns the ordering constraint of this store instruction.
void setVolatile(bool V)
Specify whether this is a volatile store or not.
void setAlignment(Align Align)
friend class Instruction
Iterator for Instructions in a `BasicBlock.
LLVM_ABI StoreInst * cloneImpl() const
Definition Instructions.cpp:4376
LLVM_ABI StoreInst(Value *Val, Value *Ptr, InsertPosition InsertBefore)
Definition Instructions.cpp:1362
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this store instruction.
bool isVolatile() const
Return true if this is a store to a volatile memory location.
void setAtomic(AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System)
Sets the ordering constraint and the synchronization scope ID of this store instruction.
StringRef - Represent a constant reference to a string, i.e.
Class to represent struct types.
LLVM_ABI void init()
Definition Instructions.cpp:4151
LLVM_ABI void setSuccessorWeight(unsigned idx, CaseWeightOpt W)
Definition Instructions.cpp:4216
LLVM_ABI Instruction::InstListType::iterator eraseFromParent()
Delegate the call to the underlying SwitchInst::eraseFromParent() and mark this object to not touch t...
Definition Instructions.cpp:4201
LLVM_ABI void addCase(ConstantInt *OnVal, BasicBlock *Dest, CaseWeightOpt W)
Delegate the call to the underlying SwitchInst::addCase() and set the specified branch weight for the...
Definition Instructions.cpp:4182
LLVM_ABI CaseWeightOpt getSuccessorWeight(unsigned idx)
Definition Instructions.cpp:4210
LLVM_ABI MDNode * buildProfBranchWeightsMD()
Definition Instructions.cpp:4134
std::optional< uint32_t > CaseWeightOpt
LLVM_ABI SwitchInst::CaseIt removeCase(SwitchInst::CaseIt I)
Delegate the call to the underlying SwitchInst::removeCase() and remove correspondent branch weight.
Definition Instructions.cpp:4168
void setValue(ConstantInt *V) const
Sets the new value for current case.
void setSuccessor(BasicBlock *S) const
Sets the new successor for current case.
LLVM_ABI SwitchInst * cloneImpl() const
Definition Instructions.cpp:4505
LLVM_ABI void addCase(ConstantInt *OnVal, BasicBlock *Dest)
Add an entry to the switch instruction.
Definition Instructions.cpp:4086
CaseIteratorImpl< CaseHandle > CaseIt
unsigned getNumCases() const
Return the number of 'cases' in this switch instruction, excluding the default case.
LLVM_ABI CaseIt removeCase(CaseIt I)
This method removes the specified case and its successor from the switch instruction.
Definition Instructions.cpp:4101
This class represents a truncation of integer types.
LLVM_ABI TruncInst * cloneImpl() const
Clone an identical TruncInst.
Definition Instructions.cpp:4402
LLVM_ABI TruncInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
Definition Instructions.cpp:3409
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static constexpr TypeSize getFixed(ScalarTy ExactSize)
static constexpr TypeSize get(ScalarTy Quantity, bool Scalable)
The instances of the Type class are immutable: once they are created, they are never changed.
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.
LLVM_ABI bool isFirstClassType() const
Return true if the type is "first class", meaning it is a valid type for a Value.
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.
bool isAggregateType() const
Return true if the type is an aggregate type.
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 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.
bool isIntegerTy() const
True if this is an instance of IntegerType.
bool isTokenTy() const
Return true if this is 'token'.
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
This class represents a cast unsigned integer to floating point.
LLVM_ABI UIToFPInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
Definition Instructions.cpp:3439
LLVM_ABI UIToFPInst * cloneImpl() const
Clone an identical UIToFPInst.
Definition Instructions.cpp:4422
UnaryInstruction(Type *Ty, unsigned iType, Value *V, InsertPosition InsertBefore=nullptr)
static LLVM_ABI UnaryOperator * Create(UnaryOps Op, Value *S, const Twine &Name=Twine(), InsertPosition InsertBefore=nullptr)
Construct a unary instruction, given the opcode and an operand.
Definition Instructions.cpp:2600
LLVM_ABI UnaryOperator(UnaryOps iType, Value *S, Type *Ty, const Twine &Name, InsertPosition InsertBefore)
Definition Instructions.cpp:2592
LLVM_ABI UnaryOperator * cloneImpl() const
Definition Instructions.cpp:4339
UnaryOps getOpcode() const
LLVM_ABI UnreachableInst(LLVMContext &C, InsertPosition InsertBefore=nullptr)
Definition Instructions.cpp:1182
LLVM_ABI bool shouldLowerToTrap(bool TrapUnreachable, bool NoTrapAfterNoreturn) const
Definition Instructions.cpp:4560
friend class Instruction
Iterator for Instructions in a `BasicBlock.
LLVM_ABI UnreachableInst * cloneImpl() const
Definition Instructions.cpp:4555
A Use represents the edge between a Value definition and its users.
LLVM_ABI void set(Value *Val)
const Use * getOperandList() const
LLVM_ABI void allocHungoffUses(unsigned N, bool IsPhi=false)
Allocate the array of Uses, followed by a pointer (with bottom bit set) to the User.
void setNumHungOffUseOperands(unsigned NumOps)
Subclasses with hung off uses need to manage the operand count themselves.
Value * getOperand(unsigned i) const
unsigned getNumOperands() const
LLVM_ABI void growHungoffUses(unsigned N, bool IsPhi=false)
Grow the number of hung off uses.
VAArgInst(Value *List, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
LLVM_ABI VAArgInst * cloneImpl() const
Definition Instructions.cpp:4473
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI Value(Type *Ty, unsigned scid)
unsigned char SubclassOptionalData
Hold subclass data that can be dropped.
LLVM_ABI void setName(const Twine &Name)
Change the name of the value.
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
LLVM_ABI LLVMContext & getContext() const
All values hold a context through their type.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
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 LLVM_ABI VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
This class represents zero extension of integer types.
LLVM_ABI ZExtInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructor with insert-before-instruction semantics.
Definition Instructions.cpp:3415
LLVM_ABI ZExtInst * cloneImpl() const
Clone an identical ZExtInst.
Definition Instructions.cpp:4406
std::pair< iterator, bool > insert(const ValueT &V)
bool contains(const_arg_type_t< ValueT > V) const
Check if the set contains the given element.
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
An efficient, type-erasing, non-owning reference to a callable.
const ilist_detail::compute_node_options< Instruction, Options... >::type::parent_ty * getParent() const
Instruction * getPrevNode()
base_list_type::iterator iterator
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
bool match(Val *V, const Pattern &P)
cstfp_pred_ty< is_non_zero_not_denormal_fp > m_NonZeroNotDenormalFP()
Match a floating-point non-zero that is not a denormal.
initializer< Ty > init(const Ty &Val)
@ Switch
The "resume-switch" lowering, where there are separate resume and destroy functions that are shared b...
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)
Extract a Value from Metadata.
NodeAddr< UseNode * > Use
Context & getContext() const
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
auto seq_inclusive(T Begin, T End)
Iterate over an integral type from Begin to End inclusive.
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.
unsigned getPointerAddressSpace(const Type *T)
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
FunctionAddr VTableAddr uintptr_t uintptr_t Int32Ty
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
LLVM_ABI MDNode * getBranchWeightMDNode(const Instruction &I)
Get the branch weights metadata node.
MemoryEffectsBase< IRMemLocation > MemoryEffects
Summary of how a function affects memory in the program.
std::enable_if_t< std::is_unsigned_v< T >, std::optional< T > > checkedMulUnsigned(T LHS, T RHS)
Multiply two unsigned integers LHS and RHS.
auto dyn_cast_or_null(const Y &Val)
auto reverse(ContainerTy &&C)
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
LLVM_ABI bool NullPointerIsDefined(const Function *F, unsigned AS=0)
Check whether null pointer dereferencing is considered undefined behavior for a given function or an ...
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool isPointerTy(const Type *T)
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...
constexpr int PoisonMaskElem
LLVM_ABI unsigned getNumBranchWeights(const MDNode &ProfileData)
AtomicOrdering
Atomic ordering for LLVM's memory model.
auto remove_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::remove_if which take ranges instead of having to pass begin/end explicitly.
OperandBundleDefT< Value * > OperandBundleDef
@ Mul
Product of integers.
@ Xor
Bitwise or logical XOR of integers.
@ Sub
Subtraction of integers.
DWARFExpression::Operation Op
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
OutputIt copy(R &&Range, OutputIt Out)
constexpr unsigned BitWidth
LLVM_ABI bool extractBranchWeights(const MDNode *ProfileData, SmallVectorImpl< uint32_t > &Weights)
Extract branch weights from MD_prof metadata.
decltype(auto) cast(const From &Val)
cast - Return the argument parameter cast to the specified type.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
bool capturesAnything(CaptureComponents CC)
bool all_equal(std::initializer_list< T > Values)
Returns true if all Values in the initializer lists are equal or the list.
auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.
@ Default
The result values are uniform if and only if all operands are uniform.
LLVM_ABI void scaleProfData(Instruction &I, uint64_t S, uint64_t T)
Scaling the profile data attached to 'I' using the ratio of S/T.
cmpResult
IEEE-754R 5.11: Floating Point Comparison Relations.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Summary of memprof metadata on allocations.
Used to keep track of an operand bundle.
uint32_t End
The index in the Use& vector where operands for this operand bundle ends.
uint32_t Begin
The index in the Use& vector where operands for this operand bundle starts.
Incoming for lane maks phi as machine instruction, incoming register Reg and incoming block Block are...
static LLVM_ABI std::optional< bool > eq(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_EQ result.
static LLVM_ABI std::optional< bool > ne(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_NE result.
static LLVM_ABI std::optional< bool > sge(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_SGE result.
static LLVM_ABI std::optional< bool > ugt(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_UGT result.
static LLVM_ABI std::optional< bool > slt(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_SLT result.
static LLVM_ABI std::optional< bool > ult(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_ULT result.
static LLVM_ABI std::optional< bool > ule(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_ULE result.
static LLVM_ABI std::optional< bool > sle(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_SLE result.
static LLVM_ABI std::optional< bool > sgt(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_SGT result.
static LLVM_ABI std::optional< bool > uge(const KnownBits &LHS, const KnownBits &RHS)
Determine if these known bits always give the same ICMP_UGE result.
A MapVector that performs no allocations if smaller than a certain size.
Indicates this User has operands co-allocated.
Indicates this User has operands and a descriptor co-allocated .