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 (C)

70 return std::nullopt;

71 assert(Size.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;

205 growHungoffUses(ReservedSpace, true);

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)

262 OL[I] = InOL[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 (F)

426 return false;

427

428 if (F->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

627

636

642

647 }

649

651 }

652 ME &= FnME;

653 }

654 return ME;

655}

659

660

667

668

675

676

683

684

685

692

693

694

701

702

703

711

714

715

718

721 CI &= Fn->getAttributes().getParamAttrs(OpNo).getCaptureInfo();

722 return CI;

723 }

724

725

728

729

733}

734

736 for (unsigned I = 0, E = arg_size(); I < E; ++I) {

738 continue;

739

742 CI &= Fn->getAttributes().getParamAttrs(I).getCaptureInfo();

744 return true;

745 }

746 return false;

747}

748

749

750

751

752

755 this->FTy = FTy;

757 "NumOperands not set up?");

758

759#ifndef NDEBUG

762 "Calling a function with bad signature!");

763

764 for (unsigned i = 0; i != Args.size(); ++i)

767 "Calling a function with a bad signature!");

768#endif

769

770

771

774

776 (void)It;

777 assert(It + 1 == op_end() && "Should add up!");

778

780}

781

783 this->FTy = FTy;

786

788

790}

791

795 InsertBefore) {

796 init(Ty, Func, Name);

797}

798

802 "Wrong number of operands allocated");

805

810}

811

815

817 Args, OpB, CI->getName(), InsertPt);

823 return NewCI;

824}

825

826

827

828

830 if (T == 0) {

831 LLVM_DEBUG(dbgs() << "Attempting to update profile weights will result in "

832 "div by 0. Ignoring. Likely the function "

834 << " has 0 entry count, and contains call instructions "

835 "with non-zero prof info.");

836 return;

837 }

839}

840

841

842

843

844

848 const Twine &NameStr) {

849 this->FTy = FTy;

850

853 "NumOperands not set up?");

854

855#ifndef NDEBUG

858 "Invoking a function with bad signature");

859

860 for (unsigned i = 0, e = Args.size(); i != e; i++)

863 "Invoking a function with a bad signature!");

864#endif

865

866

867

872

874 (void)It;

875 assert(It + 3 == op_end() && "Should add up!");

876

878}

879

883 "Wrong number of operands allocated");

885 std::copy(II.op_begin(), II.op_end(), op_begin());

886 std::copy(II.bundle_op_info_begin(), II.bundle_op_info_end(),

889}

890

893 std::vector<Value *> Args(II->arg_begin(), II->arg_end());

894

896 II->getFunctionType(), II->getCalledOperand(), II->getNormalDest(),

897 II->getUnwindDest(), Args, OpB, II->getName(), InsertPt);

898 NewII->setCallingConv(II->getCallingConv());

899 NewII->SubclassOptionalData = II->SubclassOptionalData;

900 NewII->setAttributes(II->getAttributes());

901 NewII->setDebugLoc(II->getDebugLoc());

902 return NewII;

903}

904

908

910 if (T == 0) {

911 LLVM_DEBUG(dbgs() << "Attempting to update profile weights will result in "

912 "div by 0. Ignoring. Likely the function "

914 << " has 0 entry count, and contains call instructions "

915 "with non-zero prof info.");

916 return;

917 }

919}

920

921

922

923

924

929 const Twine &NameStr) {

930 this->FTy = FTy;

931

933 IndirectDests.size(),

935 "NumOperands not set up?");

936

937#ifndef NDEBUG

940 "Calling a function with bad signature");

941

942 for (unsigned i = 0, e = Args.size(); i != e; i++)

945 "Calling a function with a bad signature!");

946#endif

947

948

949

951 NumIndirectDests = IndirectDests.size();

953 for (unsigned i = 0; i != NumIndirectDests; ++i)

956

958 (void)It;

959 assert(It + 2 + IndirectDests.size() == op_end() && "Should add up!");

960

962}

963

968 "Wrong number of operands allocated");

974 NumIndirectDests = CBI.NumIndirectDests;

975}

976

980

988 NewCBI->NumIndirectDests = CBI->NumIndirectDests;

989 return NewCBI;

990}

991

992

993

994

995

1000 "Wrong number of operands allocated");

1004}

1005

1009 InsertBefore) {

1010 if (retVal)

1011 Op<0>() = retVal;

1012}

1013

1014

1015

1016

1017

1018ResumeInst::ResumeInst(const ResumeInst &RI)

1020 AllocMarker) {

1022}

1023

1026 AllocMarker, InsertBefore) {

1028}

1029

1030

1031

1032

1033

1034CleanupReturnInst::CleanupReturnInst(const CleanupReturnInst &CRI,

1038 "Wrong number of operands allocated");

1039 setSubclassDataInstruction::OpaqueField(

1044}

1045

1046void CleanupReturnInst::init(Value *CleanupPad, BasicBlock *UnwindBB) {

1047 if (UnwindBB)

1048 setSubclassData(true);

1049

1050 Op<0>() = CleanupPad;

1051 if (UnwindBB)

1052 Op<1>() = UnwindBB;

1053}

1054

1055CleanupReturnInst::CleanupReturnInst(Value *CleanupPad, BasicBlock *UnwindBB,

1060 init(CleanupPad, UnwindBB);

1061}

1062

1063

1064

1065

1066void CatchReturnInst::init(Value *CatchPad, BasicBlock *BB) {

1067 Op<0>() = CatchPad;

1069}

1070

1071CatchReturnInst::CatchReturnInst(const CatchReturnInst &CRI)

1073 AllocMarker) {

1076}

1077

1078CatchReturnInst::CatchReturnInst(Value *CatchPad, BasicBlock *BB,

1081 AllocMarker, InsertBefore) {

1082 init(CatchPad, BB);

1083}

1084

1085

1086

1087

1088

1089CatchSwitchInst::CatchSwitchInst(Value *ParentPad, BasicBlock *UnwindDest,

1090 unsigned NumReservedValues,

1091 const Twine &NameStr,

1094 InsertBefore) {

1095 if (UnwindDest)

1096 ++NumReservedValues;

1097 init(ParentPad, UnwindDest, NumReservedValues + 1);

1099}

1100

1101CatchSwitchInst::CatchSwitchInst(const CatchSwitchInst &CSI)

1108 for (unsigned I = 1, E = ReservedSpace; I != E; ++I)

1109 OL[I] = InOL[I];

1110}

1111

1112void CatchSwitchInst::init(Value *ParentPad, BasicBlock *UnwindDest,

1113 unsigned NumReservedValues) {

1114 assert(ParentPad && NumReservedValues);

1115

1116 ReservedSpace = NumReservedValues;

1119

1120 Op<0>() = ParentPad;

1121 if (UnwindDest) {

1124 }

1125}

1126

1127

1128

1129void CatchSwitchInst::growOperands(unsigned Size) {

1131 assert(NumOperands >= 1);

1132 if (ReservedSpace >= NumOperands + Size)

1133 return;

1134 ReservedSpace = (NumOperands + Size / 2) * 2;

1136}

1137

1140 growOperands(1);

1141 assert(OpNo < ReservedSpace && "Growing didn't work!");

1144}

1145

1147

1149 for (Use *CurDst = HI.getCurrent(); CurDst != EndDst; ++CurDst)

1150 *CurDst = *(CurDst + 1);

1151

1152 *EndDst = nullptr;

1153

1155}

1156

1157

1158

1159

1161 const Twine &NameStr) {

1166}

1167

1171 "Wrong number of operands allocated");

1174}

1175

1178 const Twine &NameStr,

1181 init(ParentPad, Args, NameStr);

1182}

1183

1184

1185

1186

1187

1191 AllocMarker, InsertBefore) {}

1192

1193

1194

1195

1196

1197void BranchInst::AssertOK() {

1200 "May only branch on boolean predicates!");

1201}

1202

1207 assert(IfTrue && "Branch destination may not be null!");

1208 Op<-1>() = IfTrue;

1209}

1210

1215

1217 Op<-2>() = IfFalse;

1218 Op<-1>() = IfTrue;

1219#ifndef NDEBUG

1220 AssertOK();

1221#endif

1222}

1223

1228 "Wrong number of operands allocated");

1229

1232 Op<-3>() = BI.Op<-3>();

1233 Op<-2>() = BI.Op<-2>();

1234 }

1235 Op<-1>() = BI.Op<-1>();

1237}

1238

1241 "Cannot swap successors of an unconditional branch");

1243

1244

1245

1247}

1248

1249

1250

1251

1252

1254 if (!Amt)

1256 else {

1258 "Passed basic block into allocation size parameter! Use other ctor");

1260 "Allocation array size is not an integer!");

1261 }

1262 return Amt;

1263}

1264

1267 "Insertion position cannot be null when alignment not provided!");

1270 "BB must be in a Function when alignment not provided!");

1272 return DL.getPrefTypeAlign(Ty);

1273}

1274

1277 : AllocaInst(Ty, AddrSpace, nullptr, Name, InsertBefore) {}

1278

1281 : AllocaInst(Ty, AddrSpace, ArraySize,

1283 InsertBefore) {}

1284

1290 AllocatedType(Ty) {

1292 assert(!Ty->isVoidTy() && "Cannot allocate void!");

1294}

1295

1298 return !CI->isOne();

1299 return true;

1300}

1301

1302

1303

1304

1313

1314

1315

1316

1317

1318void LoadInst::AssertOK() {

1320 "Ptr must have pointer type.");

1321}

1322

1325 "Insertion position cannot be null when alignment not provided!");

1328 "BB must be in a Function when alignment not provided!");

1330 return DL.getABITypeAlign(Ty);

1331}

1332

1336

1341

1346

1357

1358

1359

1360

1361

1362void StoreInst::AssertOK() {

1365 "Ptr must have pointer type!");

1366}

1367

1370

1376

1381

1386 InsertBefore) {

1392 AssertOK();

1393}

1394

1395

1396

1397

1398

1399void AtomicCmpXchgInst::Init(Value *Ptr, Value *Cmp, Value *NewVal,

1405 Op<2>() = NewVal;

1410

1412 "All operands must be non-null!");

1414 "Ptr must have pointer type!");

1416 "Cmp type and NewVal type must be same!");

1417}

1418

1420 Align Alignment,

1427 AtomicCmpXchg, AllocMarker, InsertBefore) {

1428 Init(Ptr, Cmp, NewVal, Alignment, SuccessOrdering, FailureOrdering, SSID);

1429}

1430

1431

1432

1433

1434

1439 "atomicrmw instructions can only be atomic.");

1441 "atomicrmw instructions cannot be unordered.");

1448

1451 "Ptr must have pointer type!");

1453 "AtomicRMW instructions must be atomic!");

1454}

1455

1459 : Instruction(Val->getType(), AtomicRMW, AllocMarker, InsertBefore) {

1460 Init(Operation, Ptr, Val, Alignment, Ordering, SSID);

1461}

1462

1464 switch (Op) {

1466 return "xchg";

1468 return "add";

1470 return "sub";

1472 return "and";

1474 return "nand";

1476 return "or";

1478 return "xor";

1480 return "max";

1482 return "min";

1484 return "umax";

1486 return "umin";

1488 return "fadd";

1490 return "fsub";

1492 return "fmax";

1494 return "fmin";

1496 return "fmaximum";

1498 return "fminimum";

1500 return "uinc_wrap";

1502 return "udec_wrap";

1504 return "usub_cond";

1506 return "usub_sat";

1508 return "";

1509 }

1510

1512}

1513

1514

1515

1516

1517

1520 : Instruction(Type::getVoidTy(C), Fence, AllocMarker, InsertBefore) {

1523}

1524

1525

1526

1527

1528

1530 const Twine &Name) {

1532 "NumOperands not initialized?");

1536}

1537

1538GetElementPtrInst::GetElementPtrInst(const GetElementPtrInst &GEPI,

1541 SourceElementType(GEPI.SourceElementType),

1542 ResultElementType(GEPI.ResultElementType) {

1544 "Wrong number of operands allocated");

1547}

1548

1551 if (!Struct->indexValid(Idx))

1552 return nullptr;

1553 return Struct->getTypeAtIndex(Idx);

1554 }

1556 return nullptr;

1558 return Array->getElementType();

1560 return Vector->getElementType();

1561 return nullptr;

1562}

1563

1566 if (Idx >= Struct->getNumElements())

1567 return nullptr;

1568 return Struct->getElementType(Idx);

1569 }

1571 return Array->getElementType();

1573 return Vector->getElementType();

1574 return nullptr;

1575}

1576

1577template

1579 if (IdxList.empty())

1580 return Ty;

1581 for (IndexTy V : IdxList.slice(1)) {

1583 if (!Ty)

1584 return Ty;

1585 }

1586 return Ty;

1587}

1588

1592

1597

1601

1602

1603

1604

1606 for (unsigned i = 1, e = getNumOperands(); i != e; ++i) {

1608 if (!CI->isZero()) return false;

1609 } else {

1610 return false;

1611 }

1612 }

1613 return true;

1614}

1615

1616

1617

1618

1620 for (unsigned i = 1, e = getNumOperands(); i != e; ++i) {

1622 return false;

1623 }

1624 return true;

1625}

1626

1630

1633 if (B)

1635 else

1638}

1639

1643

1647

1651

1655

1661

1665 APInt &ConstantOffset) const {

1666

1668 ConstantOffset);

1669}

1670

1671

1672

1673

1674

1675ExtractElementInst::ExtractElementInst(Value *Val, Value *Index,

1676 const Twine &Name,

1679 ExtractElement, AllocMarker, InsertBef) {

1680 assert(isValidOperands(Val, Index) &&

1681 "Invalid extractelement instruction operands!");

1683 Op<1>() = Index;

1685}

1686

1688 if (!Val->getType()->isVectorTy() || !Index->getType()->isIntegerTy())

1689 return false;

1690 return true;

1691}

1692

1693

1694

1695

1696

1697InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index,

1698 const Twine &Name,

1700 : Instruction(Vec->getType(), InsertElement, AllocMarker, InsertBef) {

1702 "Invalid insertelement instruction operands!");

1705 Op<2>() = Index;

1707}

1708

1710 const Value *Index) {

1712 return false;

1713

1715 return false;

1716

1717 if (!Index->getType()->isIntegerTy())

1718 return false;

1719 return true;

1720}

1721

1722

1723

1724

1725

1727 assert(V && "Cannot create placeholder of nullptr V");

1729}

1730

1735

1737 const Twine &Name,

1740 InsertBefore) {}

1741

1743 const Twine &Name,

1748 ShuffleVector, AllocMarker, InsertBefore) {

1750 "Invalid shuffle vector instruction operands!");

1751

1758}

1759

1761 const Twine &Name,

1766 ShuffleVector, AllocMarker, InsertBefore) {

1768 "Invalid shuffle vector instruction operands!");

1773}

1774

1777 int NumMaskElts = ShuffleMask.size();

1779 for (int i = 0; i != NumMaskElts; ++i) {

1783 continue;

1784 }

1785 assert(MaskElt >= 0 && MaskElt < 2 * NumOpElts && "Out-of-range mask");

1786 MaskElt = (MaskElt < NumOpElts) ? MaskElt + NumOpElts : MaskElt - NumOpElts;

1787 NewMask[i] = MaskElt;

1788 }

1791}

1792

1795

1797 return false;

1798

1799

1800 int V1Size =

1802 for (int Elem : Mask)

1804 return false;

1805

1808 return false;

1809

1810 return true;

1811}

1812

1814 const Value *Mask) {

1815

1817 return false;

1818

1819

1820

1822 if (!MaskTy || !MaskTy->getElementType()->isIntegerTy(32) ||

1824 return false;

1825

1826

1828 return true;

1829

1830

1831

1833 return false;

1834

1836

1838 return !CI->uge(V1Size * 2);

1839

1841 for (Value *Op : MV->operands()) {

1843 if (CI->uge(V1Size*2))

1844 return false;

1846 return false;

1847 }

1848 }

1849 return true;

1850 }

1851

1854 i != e; ++i)

1855 if (CDS->getElementAsInteger(i) >= V1Size*2)

1856 return false;

1857 return true;

1858 }

1859

1860 return false;

1861}

1862

1866

1869 Result.append(EC.getKnownMinValue(), MaskVal);

1870 return;

1871 }

1872

1873 assert(!EC.isScalable() &&

1874 "Scalable vector shuffle mask must be undef or zeroinitializer");

1875

1876 unsigned NumElts = EC.getFixedValue();

1877

1878 Result.reserve(NumElts);

1879

1881 for (unsigned i = 0; i != NumElts; ++i)

1882 Result.push_back(CDS->getElementAsInteger(i));

1883 return;

1884 }

1885 for (unsigned i = 0; i != NumElts; ++i) {

1886 Constant *C = Mask->getAggregateElement(i);

1889 }

1890}

1891

1893 ShuffleMask.assign(Mask.begin(), Mask.end());

1895}

1896

1898 Type *ResultTy) {

1903 if (Mask[0] == 0)

1906 }

1908 for (int Elem : Mask) {

1911 else

1913 }

1915}

1916

1918 assert(!Mask.empty() && "Shuffle mask must contain elements");

1919 bool UsesLHS = false;

1920 bool UsesRHS = false;

1921 for (int I : Mask) {

1922 if (I == -1)

1923 continue;

1924 assert(I >= 0 && I < (NumOpElts * 2) &&

1925 "Out-of-bounds shuffle mask element");

1926 UsesLHS |= (I < NumOpElts);

1927 UsesRHS |= (I >= NumOpElts);

1928 if (UsesLHS && UsesRHS)

1929 return false;

1930 }

1931

1932 return UsesLHS || UsesRHS;

1933}

1934

1940

1943 return false;

1944 for (int i = 0, NumMaskElts = Mask.size(); i < NumMaskElts; ++i) {

1945 if (Mask[i] == -1)

1946 continue;

1947 if (Mask[i] != i && Mask[i] != (NumOpElts + i))

1948 return false;

1949 }

1950 return true;

1951}

1952

1954 if (Mask.size() != static_cast<unsigned>(NumSrcElts))

1955 return false;

1956

1957

1959}

1960

1962 if (Mask.size() != static_cast<unsigned>(NumSrcElts))

1963 return false;

1965 return false;

1966

1967

1968 if (NumSrcElts < 2)

1969 return false;

1970

1971 for (int I = 0, E = Mask.size(); I < E; ++I) {

1972 if (Mask[I] == -1)

1973 continue;

1974 if (Mask[I] != (NumSrcElts - 1 - I) &&

1975 Mask[I] != (NumSrcElts + NumSrcElts - 1 - I))

1976 return false;

1977 }

1978 return true;

1979}

1980

1982 if (Mask.size() != static_cast<unsigned>(NumSrcElts))

1983 return false;

1985 return false;

1986 for (int I = 0, E = Mask.size(); I < E; ++I) {

1987 if (Mask[I] == -1)

1988 continue;

1989 if (Mask[I] != 0 && Mask[I] != NumSrcElts)

1990 return false;

1991 }

1992 return true;

1993}

1994

1996 if (Mask.size() != static_cast<unsigned>(NumSrcElts))

1997 return false;

1998

2000 return false;

2001 for (int I = 0, E = Mask.size(); I < E; ++I) {

2002 if (Mask[I] == -1)

2003 continue;

2004 if (Mask[I] != I && Mask[I] != (NumSrcElts + I))

2005 return false;

2006 }

2007 return true;

2008}

2009

2011

2012

2013

2014

2015

2016

2017 if (Mask.size() != static_cast<unsigned>(NumSrcElts))

2018 return false;

2019

2020 int Sz = Mask.size();

2022 return false;

2023

2024

2025 if (Mask[0] != 0 && Mask[0] != 1)

2026 return false;

2027

2028

2029

2030 if ((Mask[1] - Mask[0]) != NumSrcElts)

2031 return false;

2032

2033

2034

2035 for (int I = 2; I < Sz; ++I) {

2036 int MaskEltVal = Mask[I];

2037 if (MaskEltVal == -1)

2038 return false;

2039 int MaskEltPrevVal = Mask[I - 2];

2040 if (MaskEltVal - MaskEltPrevVal != 2)

2041 return false;

2042 }

2043 return true;

2044}

2045

2047 int &Index) {

2048 if (Mask.size() != static_cast<unsigned>(NumSrcElts))

2049 return false;

2050

2051 int StartIndex = -1;

2052 for (int I = 0, E = Mask.size(); I != E; ++I) {

2053 int MaskEltVal = Mask[I];

2054 if (MaskEltVal == -1)

2055 continue;

2056

2057 if (StartIndex == -1) {

2058

2059

2060 if (MaskEltVal < I || NumSrcElts <= (MaskEltVal - I))

2061 return false;

2062

2063 StartIndex = MaskEltVal - I;

2064 continue;

2065 }

2066

2067

2068 if (MaskEltVal != (StartIndex + I))

2069 return false;

2070 }

2071

2072 if (StartIndex == -1)

2073 return false;

2074

2075

2076 Index = StartIndex;

2077 return true;

2078}

2079

2081 int NumSrcElts, int &Index) {

2082

2084 return false;

2085

2086

2087 if (NumSrcElts <= (int)Mask.size())

2088 return false;

2089

2090

2091 int SubIndex = -1;

2092 for (int i = 0, e = Mask.size(); i != e; ++i) {

2093 int M = Mask[i];

2094 if (M < 0)

2095 continue;

2096 int Offset = (M % NumSrcElts) - i;

2097 if (0 <= SubIndex && SubIndex != Offset)

2098 return false;

2100 }

2101

2102 if (0 <= SubIndex && SubIndex + (int)Mask.size() <= NumSrcElts) {

2103 Index = SubIndex;

2104 return true;

2105 }

2106 return false;

2107}

2108

2110 int NumSrcElts, int &NumSubElts,

2111 int &Index) {

2112 int NumMaskElts = Mask.size();

2113

2114

2115 if (NumMaskElts < NumSrcElts)

2116 return false;

2117

2118

2120 return false;

2121

2122

2126 bool Src0Identity = true;

2127 bool Src1Identity = true;

2128

2129 for (int i = 0; i != NumMaskElts; ++i) {

2130 int M = Mask[i];

2131 if (M < 0) {

2132 UndefElts.setBit(i);

2133 continue;

2134 }

2135 if (M < NumSrcElts) {

2137 Src0Identity &= (M == i);

2138 continue;

2139 }

2141 Src1Identity &= (M == (i + NumSrcElts));

2142 }

2143 assert((Src0Elts | Src1Elts | UndefElts).isAllOnes() &&

2144 "unknown shuffle elements");

2146 "2-source shuffle not found");

2147

2148

2149

2152 int Src0Hi = NumMaskElts - Src0Elts.countl_zero();

2153 int Src1Hi = NumMaskElts - Src1Elts.countl_zero();

2154

2155

2156

2157 if (Src0Identity) {

2158 int NumSub1Elts = Src1Hi - Src1Lo;

2159 ArrayRef Sub1Mask = Mask.slice(Src1Lo, NumSub1Elts);

2161 NumSubElts = NumSub1Elts;

2162 Index = Src1Lo;

2163 return true;

2164 }

2165 }

2166

2167

2168

2169 if (Src1Identity) {

2170 int NumSub0Elts = Src0Hi - Src0Lo;

2171 ArrayRef Sub0Mask = Mask.slice(Src0Lo, NumSub0Elts);

2173 NumSubElts = NumSub0Elts;

2174 Index = Src0Lo;

2175 return true;

2176 }

2177 }

2178

2179 return false;

2180}

2181

2183

2184

2186 return false;

2187

2190 if (NumMaskElts <= NumOpElts)

2191 return false;

2192

2193

2196 return false;

2197

2198

2199 for (int i = NumOpElts; i < NumMaskElts; ++i)

2200 if (Mask[i] != -1)

2201 return false;

2202

2203 return true;

2204}

2205

2207

2208

2210 return false;

2211

2214 if (NumMaskElts >= NumOpElts)

2215 return false;

2216

2218}

2219

2221

2223 return false;

2224

2225

2226

2228 return false;

2229

2232 if (NumMaskElts != NumOpElts * 2)

2233 return false;

2234

2235

2236

2237

2238

2240}

2241

2243 int ReplicationFactor, int VF) {

2244 assert(Mask.size() == (unsigned)ReplicationFactor * VF &&

2245 "Unexpected mask size.");

2246

2247 for (int CurrElt : seq(VF)) {

2248 ArrayRef CurrSubMask = Mask.take_front(ReplicationFactor);

2249 assert(CurrSubMask.size() == (unsigned)ReplicationFactor &&

2250 "Run out of mask?");

2251 Mask = Mask.drop_front(ReplicationFactor);

2252 if (all\_of(CurrSubMask, [CurrElt](int MaskElt) {

2253 return MaskElt == PoisonMaskElem || MaskElt == CurrElt;

2254 }))

2255 return false;

2256 }

2257 assert(Mask.empty() && "Did not consume the whole mask?");

2258

2259 return true;

2260}

2261

2263 int &ReplicationFactor, int &VF) {

2264

2266 ReplicationFactor =

2267 Mask.take_while([](int MaskElt) { return MaskElt == 0; }).size();

2268 if (ReplicationFactor == 0 || Mask.size() % ReplicationFactor != 0)

2269 return false;

2270 VF = Mask.size() / ReplicationFactor;

2272 }

2273

2274

2275

2276

2277

2278

2279

2280

2281 int Largest = -1;

2282 for (int MaskElt : Mask) {

2284 continue;

2285

2286 if (MaskElt < Largest)

2287 return false;

2288 Largest = std::max(Largest, MaskElt);

2289 }

2290

2291

2292 for (int PossibleReplicationFactor :

2294 if (Mask.size() % PossibleReplicationFactor != 0)

2295 continue;

2296 int PossibleVF = Mask.size() / PossibleReplicationFactor;

2298 PossibleVF))

2299 continue;

2300 ReplicationFactor = PossibleReplicationFactor;

2301 VF = PossibleVF;

2302 return true;

2303 }

2304

2305 return false;

2306}

2307

2309 int &VF) const {

2310

2311

2313 return false;

2314

2316 if (ShuffleMask.size() % VF != 0)

2317 return false;

2318 ReplicationFactor = ShuffleMask.size() / VF;

2319

2321}

2322

2324 if (VF <= 0 || Mask.size() < static_cast<unsigned>(VF) ||

2325 Mask.size() % VF != 0)

2326 return false;

2327 for (unsigned K = 0, Sz = Mask.size(); K < Sz; K += VF) {

2330 continue;

2332 for (int Idx : SubMask) {

2334 Used.set(Idx);

2335 }

2336 if (!Used.all())

2337 return false;

2338 }

2339 return true;

2340}

2341

2342

2344

2345

2347 return false;

2349 return false;

2350

2352}

2353

2356

2357

2358 if (!OpTy)

2359 return false;

2361

2362 return isInterleaveMask(ShuffleMask, Factor, OpNumElts * 2);

2363}

2364

2366 ArrayRef Mask, unsigned Factor, unsigned NumInputElts,

2368 unsigned NumElts = Mask.size();

2369 if (NumElts % Factor)

2370 return false;

2371

2372 unsigned LaneLen = NumElts / Factor;

2374 return false;

2375

2376 StartIndexes.resize(Factor);

2377

2378

2379

2380

2381 unsigned I = 0, J;

2382 for (; I < Factor; I++) {

2383 unsigned SavedLaneValue;

2384 unsigned SavedNoUndefs = 0;

2385

2386

2387 for (J = 0; J < LaneLen - 1; J++) {

2388

2389 unsigned Lane = J * Factor + I;

2390 unsigned NextLane = Lane + Factor;

2391 int LaneValue = Mask[Lane];

2392 int NextLaneValue = Mask[NextLane];

2393

2394

2395 if (LaneValue >= 0 && NextLaneValue >= 0 &&

2396 LaneValue + 1 != NextLaneValue)

2397 break;

2398

2399

2400 if (LaneValue >= 0 && NextLaneValue < 0) {

2401 SavedLaneValue = LaneValue;

2402 SavedNoUndefs = 1;

2403 }

2404

2405

2406

2407

2408

2409

2410 if (SavedNoUndefs > 0 && LaneValue < 0) {

2411 SavedNoUndefs++;

2412 if (NextLaneValue >= 0 &&

2413 SavedLaneValue + SavedNoUndefs != (unsigned)NextLaneValue)

2414 break;

2415 }

2416 }

2417

2418 if (J < LaneLen - 1)

2419 return false;

2420

2421 int StartMask = 0;

2422 if (Mask[I] >= 0) {

2423

2424 StartMask = Mask[I];

2425 } else if (Mask[(LaneLen - 1) * Factor + I] >= 0) {

2426

2427 StartMask = Mask[(LaneLen - 1) * Factor + I] - J;

2428 } else if (SavedNoUndefs > 0) {

2429

2430 StartMask = SavedLaneValue - (LaneLen - 1 - SavedNoUndefs);

2431 }

2432

2433

2434 if (StartMask < 0)

2435 return false;

2436

2437 if (StartMask + LaneLen > NumInputElts)

2438 return false;

2439

2440 StartIndexes[I] = StartMask;

2441 }

2442

2443 return true;

2444}

2445

2446

2447

2448

2450 unsigned Factor,

2451 unsigned &Index) {

2452

2453 for (unsigned Idx = 0; Idx < Factor; Idx++) {

2454 unsigned I = 0;

2455

2456

2457

2458 for (; I < Mask.size(); I++)

2459 if (Mask[I] >= 0 && static_cast<unsigned>(Mask[I]) != Idx + I * Factor)

2460 break;

2461

2462 if (I == Mask.size()) {

2463 Index = Idx;

2464 return true;

2465 }

2466 }

2467

2468 return false;

2469}

2470

2471

2472

2473

2474

2476 int NumElts = Mask.size();

2477 assert((NumElts % NumSubElts) == 0 && "Illegal shuffle mask");

2478

2479 int RotateAmt = -1;

2480 for (int i = 0; i != NumElts; i += NumSubElts) {

2481 for (int j = 0; j != NumSubElts; ++j) {

2482 int M = Mask[i + j];

2483 if (M < 0)

2484 continue;

2485 if (M < i || M >= i + NumSubElts)

2486 return -1;

2487 int Offset = (NumSubElts - (M - (i + j))) % NumSubElts;

2488 if (0 <= RotateAmt && Offset != RotateAmt)

2489 return -1;

2491 }

2492 }

2493 return RotateAmt;

2494}

2495

2497 ArrayRef Mask, unsigned EltSizeInBits, unsigned MinSubElts,

2498 unsigned MaxSubElts, unsigned &NumSubElts, unsigned &RotateAmt) {

2499 for (NumSubElts = MinSubElts; NumSubElts <= MaxSubElts; NumSubElts *= 2) {

2501 if (EltRotateAmt < 0)

2502 continue;

2503 RotateAmt = EltRotateAmt * EltSizeInBits;

2504 return true;

2505 }

2506

2507 return false;

2508}

2509

2510

2511

2512

2513

2515 const Twine &Name) {

2517

2518

2519

2520

2521

2522 assert(!Idxs.empty() && "InsertValueInst must have at least one index");

2523

2525 Val->getType() && "Inserted value must match indexed type!");

2528

2531}

2532

2533InsertValueInst::InsertValueInst(const InsertValueInst &IVI)

2535 Indices(IVI.Indices) {

2539}

2540

2541

2542

2543

2544

2547

2548

2549

2550 assert(!Idxs.empty() && "ExtractValueInst must have at least one index");

2551

2552 Indices.append(Idxs.begin(), Idxs.end());

2554}

2555

2556ExtractValueInst::ExtractValueInst(const ExtractValueInst &EVI)

2559 Indices(EVI.Indices) {

2561}

2562

2563

2564

2565

2566

2567

2568

2571 for (unsigned Index : Idxs) {

2572

2573

2574

2575

2576

2577

2579 if (Index >= AT->getNumElements())

2580 return nullptr;

2581 Agg = AT->getElementType();

2583 if (Index >= ST->getNumElements())

2584 return nullptr;

2585 Agg = ST->getElementType(Index);

2586 } else {

2587

2588 return nullptr;

2589 }

2590 }

2591 return Agg;

2592}

2593

2594

2595

2596

2597

2605

2610

2611void UnaryOperator::AssertOK() {

2613 (void)LHS;

2614#ifndef NDEBUG

2616 case FNeg:

2618 "Unary operation should return same type as operand!");

2620 "Tried to create a floating-point operation on a "

2621 "non-floating-point type!");

2622 break;

2624 }

2625#endif

2626}

2627

2628

2629

2630

2631

2634 : Instruction(Ty, iType, AllocMarker, InsertBefore) {

2638 AssertOK();

2639}

2640

2641void BinaryOperator::AssertOK() {

2643 (void)LHS; (void)RHS;

2644 assert(LHS->getType() == RHS->getType() &&

2645 "Binary operator operand types must match!");

2646#ifndef NDEBUG

2649 case Mul:

2651 "Arithmetic operation should return same type as operands!");

2653 "Tried to create an integer operation on a non-integer type!");

2654 break;

2655 case FAdd: case FSub:

2658 "Arithmetic operation should return same type as operands!");

2660 "Tried to create a floating-point operation on a "

2661 "non-floating-point type!");

2662 break;

2663 case UDiv:

2664 case SDiv:

2666 "Arithmetic operation should return same type as operands!");

2668 "Incorrect operand type (not integer) for S/UDIV");

2669 break;

2670 case FDiv:

2672 "Arithmetic operation should return same type as operands!");

2674 "Incorrect operand type (not floating point) for FDIV");

2675 break;

2676 case URem:

2677 case SRem:

2679 "Arithmetic operation should return same type as operands!");

2681 "Incorrect operand type (not integer) for S/UREM");

2682 break;

2683 case FRem:

2685 "Arithmetic operation should return same type as operands!");

2687 "Incorrect operand type (not floating point) for FREM");

2688 break;

2689 case Shl:

2690 case LShr:

2691 case AShr:

2693 "Shift operation should return same type as operands!");

2695 "Tried to create a shift operation on a non-integral type!");

2696 break;

2697 case And: case Or:

2698 case Xor:

2700 "Logical operation should return same type as operands!");

2702 "Tried to create a logical operation on a non-integral type!");

2703 break;

2705 }

2706#endif

2707}

2708

2710 const Twine &Name,

2713 "Cannot create binary operator with two operands of differing type!");

2715}

2716

2719 Value *Zero = ConstantInt::get(Op->getType(), 0);

2720 return new BinaryOperator(Instruction::Sub, Zero, Op, Op->getType(), Name,

2721 InsertBefore);

2722}

2723

2726 Value *Zero = ConstantInt::get(Op->getType(), 0);

2727 return BinaryOperator::CreateNSWSub(Zero, Op, Name, InsertBefore);

2728}

2729

2734 Op->getType(), Name, InsertBefore);

2735}

2736

2737

2738

2739

2742 return true;

2744 return false;

2745}

2746

2747

2748

2749

2750

2754 if (!MD)

2755 return 0.0;

2758}

2759

2760

2761

2762

2763

2764

2767 default: return false;

2768 case Instruction::ZExt:

2769 case Instruction::SExt:

2770 case Instruction::Trunc:

2771 return true;

2772 case Instruction::BitCast:

2775 }

2776}

2777

2778

2779

2780

2781

2782

2783

2784

2785

2787 Type *SrcTy,

2788 Type *DestTy,

2790 assert(castIsValid(Opcode, SrcTy, DestTy) && "method precondition");

2791 switch (Opcode) {

2793 case Instruction::Trunc:

2794 case Instruction::ZExt:

2795 case Instruction::SExt:

2796 case Instruction::FPTrunc:

2797 case Instruction::FPExt:

2798 case Instruction::UIToFP:

2799 case Instruction::SIToFP:

2800 case Instruction::FPToUI:

2801 case Instruction::FPToSI:

2802 case Instruction::AddrSpaceCast:

2803

2804 return false;

2805 case Instruction::BitCast:

2806 return true;

2807 case Instruction::PtrToAddr:

2808 case Instruction::PtrToInt:

2809 return DL.getIntPtrType(SrcTy)->getScalarSizeInBits() ==

2811 case Instruction::IntToPtr:

2812 return DL.getIntPtrType(DestTy)->getScalarSizeInBits() ==

2813 SrcTy->getScalarSizeInBits();

2814 }

2815}

2816

2820

2821

2822

2823

2824

2825

2826

2827

2828

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

2858

2859

2860

2861

2862

2863

2864 const unsigned numCastOps =

2865 Instruction::CastOpsEnd - Instruction::CastOpsBegin;

2866

2867 static const uint8_t CastResults[numCastOps][numCastOps] = {

2868

2869

2870

2871

2872

2873 { 1, 0, 0,99,99, 0, 0,99,99,99,99, 0, 3, 0},

2874 { 8, 1, 9,99,99, 2,17,99,99,99,99, 2, 3, 0},

2875 { 8, 0, 1,99,99, 0, 2,99,99,99,99, 0, 3, 0},

2876 { 0, 0, 0,99,99, 0, 0,99,99,99,99, 0, 3, 0},

2877 { 0, 0, 0,99,99, 0, 0,99,99,99,99, 0, 3, 0},

2878 { 99,99,99, 0, 0,99,99, 0, 0,99,99,99, 4, 0},

2879 { 99,99,99, 0, 0,99,99, 0, 0,99,99,99, 4, 0},

2880 { 99,99,99, 0, 0,99,99, 0, 0,99,99,99, 4, 0},

2881 { 99,99,99, 2, 2,99,99, 8, 2,99,99,99, 4, 0},

2882 { 1, 0, 0,99,99, 0, 0,99,99,99,99, 7, 3, 0},

2883 { 0, 0, 0,99,99, 0, 0,99,99,99,99, 0, 3, 0},

2884 { 99,99,99,99,99,99,99,99,99,11,11,99,15, 0},

2885 { 5, 5, 5, 0, 0, 5, 5, 0, 0,16,16, 5, 1,14},

2886 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,13,12},

2887 };

2888

2889

2890

2891

2892

2893

2894 bool IsFirstBitcast = (firstOp == Instruction::BitCast);

2895 bool IsSecondBitcast = (secondOp == Instruction::BitCast);

2896 bool AreBothBitcasts = IsFirstBitcast && IsSecondBitcast;

2897

2898

2901 if (!AreBothBitcasts)

2902 return 0;

2903

2904 int ElimCase = CastResults[firstOp-Instruction::CastOpsBegin]

2905 [secondOp-Instruction::CastOpsBegin];

2906 switch (ElimCase) {

2907 case 0:

2908

2909 return 0;

2910 case 1:

2911

2912 return firstOp;

2913 case 2:

2914

2915 return secondOp;

2916 case 3:

2917

2918

2919

2920 if (!SrcTy->isVectorTy() && DstTy->isIntegerTy())

2921 return firstOp;

2922 return 0;

2923 case 4:

2924

2925

2926 if (DstTy == MidTy)

2927 return firstOp;

2928 return 0;

2929 case 5:

2930

2931

2932 if (SrcTy->isIntegerTy())

2933 return secondOp;

2934 return 0;

2935 case 7: {

2936

2938 return 0;

2939

2940

2941 if (SrcTy != DstTy)

2942 return 0;

2943

2944

2945

2947 if (DL || MidSize < DL->getPointerTypeSizeInBits(SrcTy))

2948 return 0;

2949

2950 return Instruction::BitCast;

2951 }

2952 case 8: {

2953

2954

2955

2956 unsigned SrcSize = SrcTy->getScalarSizeInBits();

2958 if (SrcTy == DstTy)

2959 return Instruction::BitCast;

2960 if (SrcSize < DstSize)

2961 return firstOp;

2962 if (SrcSize > DstSize)

2963 return secondOp;

2964 return 0;

2965 }

2966 case 9:

2967

2968 return Instruction::ZExt;

2969 case 11: {

2970

2971 if (DL)

2972 return 0;

2973 unsigned MidSize = secondOp == Instruction::PtrToAddr

2974 ? DL->getAddressSizeInBits(MidTy)

2975 : DL->getPointerTypeSizeInBits(MidTy);

2976 unsigned SrcSize = SrcTy->getScalarSizeInBits();

2978

2979

2980 if (MidSize < SrcSize && MidSize < DstSize)

2981 return 0;

2982 if (DstSize < SrcSize)

2983 return Instruction::Trunc;

2984 if (DstSize > SrcSize)

2985 return Instruction::ZExt;

2986 return Instruction::BitCast;

2987 }

2988 case 12:

2989

2990

2992 return Instruction::AddrSpaceCast;

2993 return Instruction::BitCast;

2994 case 13:

2995

2996

2997

2999 SrcTy->isPtrOrPtrVectorTy() &&

3004 "Illegal addrspacecast, bitcast sequence!");

3005

3006 return firstOp;

3007 case 14:

3008

3009 return Instruction::AddrSpaceCast;

3010 case 15:

3011

3012

3013

3015 SrcTy->isIntOrIntVectorTy() &&

3019 "Illegal inttoptr, bitcast sequence!");

3020

3021 return firstOp;

3022 case 16:

3023

3024

3025

3027 SrcTy->isPtrOrPtrVectorTy() &&

3031 "Illegal bitcast, ptrtoint sequence!");

3032

3033 return secondOp;

3034 case 17:

3035

3036 return Instruction::UIToFP;

3037 case 99:

3038

3039

3041 default:

3043 }

3044}

3045

3049

3050 switch (op) {

3051 case Trunc: return new TruncInst (S, Ty, Name, InsertBefore);

3052 case ZExt: return new ZExtInst (S, Ty, Name, InsertBefore);

3053 case SExt: return new SExtInst (S, Ty, Name, InsertBefore);

3054 case FPTrunc: return new FPTruncInst (S, Ty, Name, InsertBefore);

3055 case FPExt: return new FPExtInst (S, Ty, Name, InsertBefore);

3056 case UIToFP: return new UIToFPInst (S, Ty, Name, InsertBefore);

3057 case SIToFP: return new SIToFPInst (S, Ty, Name, InsertBefore);

3058 case FPToUI: return new FPToUIInst (S, Ty, Name, InsertBefore);

3059 case FPToSI: return new FPToSIInst (S, Ty, Name, InsertBefore);

3060 case PtrToAddr: return new PtrToAddrInst (S, Ty, Name, InsertBefore);

3061 case PtrToInt: return new PtrToIntInst (S, Ty, Name, InsertBefore);

3062 case IntToPtr: return new IntToPtrInst (S, Ty, Name, InsertBefore);

3063 case BitCast:

3064 return new BitCastInst(S, Ty, Name, InsertBefore);

3065 case AddrSpaceCast:

3067 default:

3069 }

3070}

3071

3075 return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);

3076 return Create(Instruction::ZExt, S, Ty, Name, InsertBefore);

3077}

3078

3082 return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);

3083 return Create(Instruction::SExt, S, Ty, Name, InsertBefore);

3084}

3085

3089 return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);

3090 return Create(Instruction::Trunc, S, Ty, Name, InsertBefore);

3091}

3092

3093

3097 assert((Ty->isIntOrIntVectorTy() || Ty->isPtrOrPtrVectorTy()) &&

3098 "Invalid cast");

3100 assert((!Ty->isVectorTy() ||

3103 "Invalid cast");

3104

3105 if (Ty->isIntOrIntVectorTy())

3106 return Create(Instruction::PtrToInt, S, Ty, Name, InsertBefore);

3107

3109}

3110

3114 assert(Ty->isPtrOrPtrVectorTy() && "Invalid cast");

3115

3117 return Create(Instruction::AddrSpaceCast, S, Ty, Name, InsertBefore);

3118

3119 return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);

3120}

3121

3123 const Twine &Name,

3126 return Create(Instruction::PtrToInt, S, Ty, Name, InsertBefore);

3128 return Create(Instruction::IntToPtr, S, Ty, Name, InsertBefore);

3129

3130 return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);

3131}

3132

3134 const Twine &Name,

3136 assert(C->getType()->isIntOrIntVectorTy() && Ty->isIntOrIntVectorTy() &&

3137 "Invalid integer cast");

3138 unsigned SrcBits = C->getType()->getScalarSizeInBits();

3139 unsigned DstBits = Ty->getScalarSizeInBits();

3141 (SrcBits == DstBits ? Instruction::BitCast :

3142 (SrcBits > DstBits ? Instruction::Trunc :

3143 (isSigned ? Instruction::SExt : Instruction::ZExt)));

3144 return Create(opcode, C, Ty, Name, InsertBefore);

3145}

3146

3149 assert(C->getType()->isFPOrFPVectorTy() && Ty->isFPOrFPVectorTy() &&

3150 "Invalid cast");

3151 unsigned SrcBits = C->getType()->getScalarSizeInBits();

3152 unsigned DstBits = Ty->getScalarSizeInBits();

3153 assert((C->getType() == Ty || SrcBits != DstBits) && "Invalid cast");

3155 (SrcBits == DstBits ? Instruction::BitCast :

3156 (SrcBits > DstBits ? Instruction::FPTrunc : Instruction::FPExt));

3157 return Create(opcode, C, Ty, Name, InsertBefore);

3158}

3159

3161 if (!SrcTy->isFirstClassType() || !DestTy->isFirstClassType())

3162 return false;

3163

3164 if (SrcTy == DestTy)

3165 return true;

3166

3169 if (SrcVecTy->getElementCount() == DestVecTy->getElementCount()) {

3170

3171 SrcTy = SrcVecTy->getElementType();

3172 DestTy = DestVecTy->getElementType();

3173 }

3174 }

3175 }

3176

3179 return SrcPtrTy->getAddressSpace() == DestPtrTy->getAddressSpace();

3180 }

3181 }

3182

3183 TypeSize SrcBits = SrcTy->getPrimitiveSizeInBits();

3185

3186

3187

3189 return false;

3190

3191 if (SrcBits != DestBits)

3192 return false;

3193

3194 return true;

3195}

3196

3199

3202 return (IntTy->getBitWidth() == DL.getPointerTypeSizeInBits(PtrTy) &&

3203 DL.isNonIntegralPointerType(PtrTy));

3206 return (IntTy->getBitWidth() == DL.getPointerTypeSizeInBits(PtrTy) &&

3207 DL.isNonIntegralPointerType(PtrTy));

3208

3210}

3211

3212

3213

3214

3215

3216

3217

3220 const Value *Src, bool SrcIsSigned, Type *DestTy, bool DestIsSigned) {

3221 Type *SrcTy = Src->getType();

3222

3224 "Only first class types are castable!");

3225

3226 if (SrcTy == DestTy)

3227 return BitCast;

3228

3229

3232 if (SrcVecTy->getElementCount() == DestVecTy->getElementCount()) {

3233

3234

3235 SrcTy = SrcVecTy->getElementType();

3236 DestTy = DestVecTy->getElementType();

3237 }

3238

3239

3240

3241

3242 unsigned SrcBits =

3243 SrcTy->getPrimitiveSizeInBits().getFixedValue();

3244 unsigned DestBits =

3246

3247

3248 if (DestTy->isIntegerTy()) {

3249 if (SrcTy->isIntegerTy()) {

3250 if (DestBits < SrcBits)

3251 return Trunc;

3252 else if (DestBits > SrcBits) {

3253 if (SrcIsSigned)

3254 return SExt;

3255 else

3256 return ZExt;

3257 } else {

3258 return BitCast;

3259 }

3260 } else if (SrcTy->isFloatingPointTy()) {

3261 if (DestIsSigned)

3262 return FPToSI;

3263 else

3264 return FPToUI;

3265 } else if (SrcTy->isVectorTy()) {

3266 assert(DestBits == SrcBits &&

3267 "Casting vector to integer of different width");

3268 return BitCast;

3269 } else {

3270 assert(SrcTy->isPointerTy() &&

3271 "Casting from a value that is not first-class type");

3272 return PtrToInt;

3273 }

3274 } else if (DestTy->isFloatingPointTy()) {

3275 if (SrcTy->isIntegerTy()) {

3276 if (SrcIsSigned)

3277 return SIToFP;

3278 else

3279 return UIToFP;

3280 } else if (SrcTy->isFloatingPointTy()) {

3281 if (DestBits < SrcBits) {

3282 return FPTrunc;

3283 } else if (DestBits > SrcBits) {

3284 return FPExt;

3285 } else {

3286 return BitCast;

3287 }

3288 } else if (SrcTy->isVectorTy()) {

3289 assert(DestBits == SrcBits &&

3290 "Casting vector to floating point of different width");

3291 return BitCast;

3292 }

3293 llvm_unreachable("Casting pointer or non-first class to float");

3295 assert(DestBits == SrcBits &&

3296 "Illegal cast to vector (wrong type or size)");

3297 return BitCast;

3299 if (SrcTy->isPointerTy()) {

3301 return AddrSpaceCast;

3302 return BitCast;

3303 } else if (SrcTy->isIntegerTy()) {

3304 return IntToPtr;

3305 }

3306 llvm_unreachable("Casting pointer to other than pointer or int");

3307 }

3308 llvm_unreachable("Casting to type that is not first-class");

3309}

3310

3311

3312

3313

3314

3315

3316

3317

3318

3319bool

3321 if (!SrcTy->isFirstClassType() || !DstTy->isFirstClassType() ||

3323 return false;

3324

3325

3326

3329 unsigned SrcScalarBitSize = SrcTy->getScalarSizeInBits();

3331

3332

3333

3334

3339

3340

3341 switch (op) {

3342 default: return false;

3343 case Instruction::Trunc:

3344 return SrcTy->isIntOrIntVectorTy() && DstTy->isIntOrIntVectorTy() &&

3345 SrcEC == DstEC && SrcScalarBitSize > DstScalarBitSize;

3346 case Instruction::ZExt:

3347 return SrcTy->isIntOrIntVectorTy() && DstTy->isIntOrIntVectorTy() &&

3348 SrcEC == DstEC && SrcScalarBitSize < DstScalarBitSize;

3349 case Instruction::SExt:

3350 return SrcTy->isIntOrIntVectorTy() && DstTy->isIntOrIntVectorTy() &&

3351 SrcEC == DstEC && SrcScalarBitSize < DstScalarBitSize;

3352 case Instruction::FPTrunc:

3353 return SrcTy->isFPOrFPVectorTy() && DstTy->isFPOrFPVectorTy() &&

3354 SrcEC == DstEC && SrcScalarBitSize > DstScalarBitSize;

3355 case Instruction::FPExt:

3356 return SrcTy->isFPOrFPVectorTy() && DstTy->isFPOrFPVectorTy() &&

3357 SrcEC == DstEC && SrcScalarBitSize < DstScalarBitSize;

3358 case Instruction::UIToFP:

3359 case Instruction::SIToFP:

3360 return SrcTy->isIntOrIntVectorTy() && DstTy->isFPOrFPVectorTy() &&

3361 SrcEC == DstEC;

3362 case Instruction::FPToUI:

3363 case Instruction::FPToSI:

3365 SrcEC == DstEC;

3366 case Instruction::PtrToAddr:

3367 case Instruction::PtrToInt:

3368 if (SrcEC != DstEC)

3369 return false;

3371 case Instruction::IntToPtr:

3372 if (SrcEC != DstEC)

3373 return false;

3375 case Instruction::BitCast: {

3378

3379

3380

3381 if (!SrcPtrTy != !DstPtrTy)

3382 return false;

3383

3384

3385

3386 if (!SrcPtrTy)

3388

3389

3391 return false;

3392

3393

3394 if (SrcIsVec && DstIsVec)

3395 return SrcEC == DstEC;

3396 if (SrcIsVec)

3398 if (DstIsVec)

3400

3401 return true;

3402 }

3403 case Instruction::AddrSpaceCast: {

3405 if (!SrcPtrTy)

3406 return false;

3407

3409 if (!DstPtrTy)

3410 return false;

3411

3413 return false;

3414

3415 return SrcEC == DstEC;

3416 }

3417 }

3418}

3419

3422 : CastInst(Ty, Trunc, S, Name, InsertBefore) {

3424}

3425

3428 : CastInst(Ty, ZExt, S, Name, InsertBefore) {

3430}

3431

3434 : CastInst(Ty, SExt, S, Name, InsertBefore) {

3436}

3437

3440 : CastInst(Ty, FPTrunc, S, Name, InsertBefore) {

3442}

3443

3446 : CastInst(Ty, FPExt, S, Name, InsertBefore) {

3448}

3449

3452 : CastInst(Ty, UIToFP, S, Name, InsertBefore) {

3454}

3455

3458 : CastInst(Ty, SIToFP, S, Name, InsertBefore) {

3460}

3461

3464 : CastInst(Ty, FPToUI, S, Name, InsertBefore) {

3466}

3467

3470 : CastInst(Ty, FPToSI, S, Name, InsertBefore) {

3472}

3473

3476 : CastInst(Ty, PtrToInt, S, Name, InsertBefore) {

3478}

3479

3482 : CastInst(Ty, PtrToAddr, S, Name, InsertBefore) {

3484}

3485

3488 : CastInst(Ty, IntToPtr, S, Name, InsertBefore) {

3490}

3491

3494 : CastInst(Ty, BitCast, S, Name, InsertBefore) {

3496}

3497

3500 : CastInst(Ty, AddrSpaceCast, S, Name, InsertBefore) {

3502}

3503

3504

3505

3506

3507

3511 : Instruction(ty, op, AllocMarker, InsertBefore) {

3516 if (FlagsSource)

3518}

3519

3522 if (Op == Instruction::ICmp) {

3523 if (InsertBefore.isValid())

3525 S1, S2, Name);

3526 else

3528 S1, S2, Name);

3529 }

3530

3531 if (InsertBefore.isValid())

3533 S1, S2, Name);

3534 else

3536 S1, S2, Name);

3537}

3538

3542 const Twine &Name,

3546 return Inst;

3547}

3548

3555

3558 return IC->isCommutative();

3560}

3561

3569

3570

3571

3575 if (auto *Const = LHS ? LHS : RHS) {

3578 }

3579 return false;

3580}

3581

3582

3583

3584

3588 return true;

3591 return false;

3592 [[fallthrough]];

3595 default:

3596 return false;

3597 }

3598}

3599

3601 switch (pred) {

3613

3630 }

3631}

3632

3634 switch (Pred) {

3635 default: return "unknown";

3662 }

3663}

3664

3669

3671 switch (pred) {

3675 return pred;

3680 }

3681}

3682

3684 switch (pred) {

3688 return pred;

3693 }

3694}

3695

3697 switch (pred) {

3700 return pred;

3709

3714 return pred;

3723 }

3724}

3725

3727 switch (pred) {

3736 return true;

3737 default:

3738 return false;

3739 }

3740}

3741

3743 switch (pred) {

3752 return true;

3753 default:

3754 return false;

3755 }

3756}

3757

3759 switch (pred) {

3776 default:

3777 return pred;

3778 }

3779}

3780

3782 switch (pred) {

3799 default:

3800 return pred;

3801 }

3802}

3803

3814

3816 switch (predicate) {

3817 default: return false;

3820 }

3821}

3822

3824 switch (predicate) {

3825 default: return false;

3828 }

3829}

3830

3834 switch (Pred) {

3836 return LHS.eq(RHS);

3838 return LHS.ne(RHS);

3840 return LHS.ugt(RHS);

3842 return LHS.uge(RHS);

3844 return LHS.ult(RHS);

3846 return LHS.ule(RHS);

3848 return LHS.sgt(RHS);

3850 return LHS.sge(RHS);

3852 return LHS.slt(RHS);

3854 return LHS.sle(RHS);

3855 default:

3857 };

3858}

3859

3863 switch (Pred) {

3864 default:

3867 return false;

3869 return true;

3898 }

3899}

3900

3904 switch (Pred) {

3925 default:

3927 }

3928}

3929

3932 return pred;

3937

3939}

3940

3942 switch (predicate) {

3943 default: return false;

3947 }

3948}

3949

3951 switch (predicate) {

3952 default: return false;

3956 }

3957}

3958

3960 switch(predicate) {

3961 default: return false;

3964 }

3965}

3966

3968 switch(predicate) {

3971 default: return false;

3972 }

3973}

3974

4004

4010

4014 return true;

4016 return false;

4017 return std::nullopt;

4018}

4019

4020

4021

4022

4023

4026 if (A.Pred == B.Pred)

4027 return A.HasSameSign == B.HasSameSign ? A : CmpPredicate(A.Pred);

4029 return {};

4030 if (A.HasSameSign &&

4032 return B.Pred;

4033 if (B.HasSameSign &&

4035 return A.Pred;

4036 return {};

4037}

4038

4042

4045 return ICI->getCmpPredicate();

4046 return Cmp->getPredicate();

4047}

4048

4052

4056

4057

4058

4059

4060

4063 ReservedSpace = NumReserved;

4066

4069}

4070

4071

4072

4073

4074

4078 AllocMarker, InsertBefore) {

4080}

4081

4084 init(SI.getCondition(), SI.getDefaultDest(), SI.getNumOperands());

4085 setNumHungOffUseOperands(SI.getNumOperands());

4086 Use *OL = getOperandList();

4087 ConstantInt **VL = case_values();

4088 const Use *InOL = SI.getOperandList();

4089 ConstantInt *const *InVL = SI.case_values();

4090 for (unsigned i = 2, E = SI.getNumOperands(); i != E; ++i) {

4091 OL[i] = InOL[i];

4092 VL[i - 2] = InVL[i - 2];

4093 }

4094 SubclassOptionalData = SI.SubclassOptionalData;

4095}

4096

4097

4098

4102 if (OpNo + 1 > ReservedSpace)

4103 growOperands();

4104

4105 assert(OpNo < ReservedSpace && "Growing didn't work!");

4110}

4111

4112

4113

4115 unsigned idx = I->getCaseIndex();

4116

4118

4122

4123

4124 if (2 + idx + 1 != NumOps) {

4125 OL[2 + idx] = OL[NumOps - 1];

4126 VL[idx] = VL[NumOps - 2 - 1];

4127 }

4128

4129

4131 VL[NumOps - 2 - 1] = nullptr;

4133

4134 return CaseIt(this, idx);

4135}

4136

4137

4138

4139

4140void SwitchInst::growOperands() {

4142 unsigned NumOps = e*3;

4143

4144 ReservedSpace = NumOps;

4145 growHungoffUses(ReservedSpace, true);

4146}

4147

4150 if (!ProfileData)

4151 return;

4152

4154 llvm_unreachable("number of prof branch_weights metadata operands does "

4155 "not correspond to number of succesors");

4156 }

4157

4160 return;

4161 this->Weights = std::move(Weights);

4162}

4163

4166 if (Weights) {

4167 assert(SI.getNumSuccessors() == Weights->size() &&

4168 "num of prof branch_weights must accord with num of successors");

4169 Changed = true;

4170

4171

4172

4173 (*Weights)[I->getCaseIndex() + 1] = Weights->back();

4174 Weights->pop_back();

4175 }

4176 return SI.removeCase(I);

4177}

4178

4180 auto *DestBlock = I->getCaseSuccessor();

4181 if (Weights) {

4183 (*Weights)[0] = Weight.value();

4184 }

4185

4186 SI.setDefaultDest(DestBlock);

4187}

4188

4192 SI.addCase(OnVal, Dest);

4193

4194 if (!Weights && W && *W) {

4195 Changed = true;

4197 (*Weights)[SI.getNumSuccessors() - 1] = *W;

4198 } else if (Weights) {

4199 Changed = true;

4200 Weights->push_back(W.value_or(0));

4201 }

4202 if (Weights)

4203 assert(SI.getNumSuccessors() == Weights->size() &&

4204 "num of prof branch_weights must accord with num of successors");

4205}

4206

4209

4210 Changed = false;

4211 if (Weights)

4212 Weights->resize(0);

4213 return SI.eraseFromParent();

4214}

4215

4218 if (!Weights)

4219 return std::nullopt;

4220 return (*Weights)[idx];

4221}

4222

4225 if (!W)

4226 return;

4227

4228 if (!Weights && *W)

4230

4231 if (Weights) {

4232 auto &OldW = (*Weights)[idx];

4233 if (*W != OldW) {

4234 Changed = true;

4235 OldW = *W;

4236 }

4237 }

4238}

4239

4242 unsigned idx) {

4244 if (ProfileData->getNumOperands() == SI.getNumSuccessors() + 1)

4246 ->getValue()

4247 .getZExtValue();

4248

4249 return std::nullopt;

4250}

4251

4252

4253

4254

4255

4256void IndirectBrInst::init(Value *Address, unsigned NumDests) {

4258 "Address of indirectbr must be a pointer");

4259 ReservedSpace = 1+NumDests;

4262

4264}

4265

4266

4267

4268

4269

4270void IndirectBrInst::growOperands() {

4272 unsigned NumOps = e*2;

4273

4274 ReservedSpace = NumOps;

4276}

4277

4278IndirectBrInst::IndirectBrInst(Value *Address, unsigned NumCases,

4281 Instruction::IndirectBr, AllocMarker, InsertBefore) {

4283}

4284

4285IndirectBrInst::IndirectBrInst(const IndirectBrInst &IBI)

4287 AllocMarker) {

4290 Use *OL = getOperandList();

4293 OL[i] = InOL[i];

4295}

4296

4297

4298

4301 if (OpNo+1 > ReservedSpace)

4302 growOperands();

4303

4304 assert(OpNo < ReservedSpace && "Growing didn't work!");

4307}

4308

4309

4310

4313

4316

4317

4318 OL[idx+1] = OL[NumOps-1];

4319

4320

4323}

4324

4325

4326

4327

4328

4333

4334

4335

4336

4337

4338

4339

4340

4343 return new (AllocMarker) GetElementPtrInst(*this, AllocMarker);

4344}

4345

4349

4353

4357

4361

4363 return new ExtractValueInst(*this);

4364}

4365

4367 return new InsertValueInst(*this);

4368}

4369

4375 return Result;

4376}

4377

4382

4387

4393 Result->setWeak(isWeak());

4394 return Result;

4395}

4396

4402 return Result;

4403}

4404

4408

4412

4416

4420

4424

4428

4432

4436

4440

4444

4448

4452

4456

4460

4464

4470 return new (AllocMarker) CallInst(*this, AllocMarker);

4471 }

4473 return new (AllocMarker) CallInst(*this, AllocMarker);

4474}

4475

4479

4483

4487

4491

4495

4497

4499 return new LandingPadInst(*this);

4500}

4501

4504 return new (AllocMarker) ReturnInst(*this, AllocMarker);

4505}

4506

4509 return new (AllocMarker) BranchInst(*this, AllocMarker);

4510}

4511

4513

4515 return new IndirectBrInst(*this);

4516}

4517

4523 return new (AllocMarker) InvokeInst(*this, AllocMarker);

4524 }

4526 return new (AllocMarker) InvokeInst(*this, AllocMarker);

4527}

4528

4534 return new (AllocMarker) CallBrInst(*this, AllocMarker);

4535 }

4537 return new (AllocMarker) CallBrInst(*this, AllocMarker);

4538}

4539

4541 return new (AllocMarker) ResumeInst(*this);

4542}

4543

4546 return new (AllocMarker) CleanupReturnInst(*this, AllocMarker);

4547}

4548

4550 return new (AllocMarker) CatchReturnInst(*this);

4551}

4552

4554 return new CatchSwitchInst(*this);

4555}

4556

4559 return new (AllocMarker) FuncletPadInst(*this, AllocMarker);

4560}

4561

4566

4568 bool NoTrapAfterNoreturn) const {

4569 if (!TrapUnreachable)

4570 return false;

4571

4572

4574 Call && Call->doesNotReturn()) {

4575 if (NoTrapAfterNoreturn)

4576 return false;

4577

4578 if (Call->isNonContinuableTrap())

4579 return false;

4580 }

4581

4582 if (getFunction()->hasFnAttribute(Attribute::Naked))

4583 return false;

4584

4585 return true;

4586}

4587

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:1323

static bool isImpliedFalseByMatchingCmp(CmpPredicate Pred1, CmpPredicate Pred2)

Definition Instructions.cpp:4005

static Value * createPlaceholderForShuffleVector(Value *V)

Definition Instructions.cpp:1726

static Align computeAllocaDefaultAlign(Type *Ty, InsertPosition Pos)

Definition Instructions.cpp:1265

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:3572

static int matchShuffleAsBitRotate(ArrayRef< int > Mask, int NumSubElts)

Try to lower a vector shuffle as a bit rotation.

Definition Instructions.cpp:2475

static Type * getIndexedTypeInternal(Type *Ty, ArrayRef< IndexTy > IdxList)

Definition Instructions.cpp:1578

static bool isReplicationMaskWithParams(ArrayRef< int > Mask, int ReplicationFactor, int VF)

Definition Instructions.cpp:2242

static bool isIdentityMaskImpl(ArrayRef< int > Mask, int NumOpElts)

Definition Instructions.cpp:1941

static bool isSingleSourceMaskImpl(ArrayRef< int > Mask, int NumOpElts)

Definition Instructions.cpp:1917

static Value * getAISize(LLVMContext &Context, Value *Amt)

Definition Instructions.cpp:1253

static bool isImpliedTrueByMatchingCmp(CmpPredicate Pred1, CmpPredicate Pred2)

Definition Instructions.cpp:3975

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.

cmpResult

IEEE-754R 5.11: Floating Point Comparison Relations.

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:4461

LLVM_ABI AddrSpaceCastInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)

Constructor with insert-before-instruction semantics.

Definition Instructions.cpp:3498

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:1305

Align getAlign() const

Return the alignment of the memory that is being allocated by the instruction.

LLVM_ABI AllocaInst * cloneImpl() const

Definition Instructions.cpp:4370

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:1296

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:1279

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:4388

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:1419

Align getAlign() const

Return the alignment of the memory that is being allocated by the instruction.

LLVM_ABI AtomicRMWInst * cloneImpl() const

Definition Instructions.cpp:4397

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:1456

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:1463

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:2717

BinaryOps getOpcode() const

LLVM_ABI bool swapOperands()

Exchange the two operands to this instruction.

Definition Instructions.cpp:2740

static LLVM_ABI BinaryOperator * CreateNot(Value *Op, const Twine &Name="", InsertPosition InsertBefore=nullptr)

Definition Instructions.cpp:2730

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:2709

LLVM_ABI BinaryOperator(BinaryOps iType, Value *S1, Value *S2, Type *Ty, const Twine &Name, InsertPosition InsertBefore)

Definition Instructions.cpp:2632

static LLVM_ABI BinaryOperator * CreateNSWNeg(Value *Op, const Twine &Name="", InsertPosition InsertBefore=nullptr)

Definition Instructions.cpp:2724

LLVM_ABI BinaryOperator * cloneImpl() const

Definition Instructions.cpp:4350

This class represents a no-op cast from one type to another.

LLVM_ABI BitCastInst * cloneImpl() const

Clone an identical BitCastInst.

Definition Instructions.cpp:4457

LLVM_ABI BitCastInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)

Constructor with insert-before-instruction semantics.

Definition Instructions.cpp:3492

Conditional or Unconditional Branch instruction.

LLVM_ABI void swapSuccessors()

Swap the successors of this branch instruction.

Definition Instructions.cpp:1239

LLVM_ABI BranchInst * cloneImpl() const

Definition Instructions.cpp:4507

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:637

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:661

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:689

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:707

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:664

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:695

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:669

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:672

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:704

LLVM_ABI CaptureInfo getCaptureInfo(unsigned OpNo) const

Return which pointer components this operand may capture.

Definition Instructions.cpp:712

LLVM_ABI bool hasArgumentWithAdditionalReturnCaptureComponents() const

Returns whether the call has an argument that has an attribute like captures(ret: address,...

Definition Instructions.cpp:735

CallBase(AttributeList const &A, FunctionType *FT, ArgsTy &&... Args)

Value * getCalledOperand() const

LLVM_ABI void setOnlyWritesMemory()

Definition Instructions.cpp:680

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:698

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:677

LLVM_ABI bool hasClobberingOperandBundles() const

Return true if this operand bundle user has operand bundles that may write to the heap.

Definition Instructions.cpp:628

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:686

unsigned arg_size() const

AttributeList getAttributes() const

Return the attributes for this call.

LLVM_ABI void setMemoryEffects(MemoryEffects ME)

Definition Instructions.cpp:656

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:4529

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:829

TailCallKind getTailCallKind() const

LLVM_ABI CallInst * cloneImpl() const

Definition Instructions.cpp:4465

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:3219

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:3111

Instruction::CastOps getOpcode() const

Return the opcode of this CastInst.

static LLVM_ABI unsigned isEliminableCastPair(Instruction::CastOps firstOpcode, Instruction::CastOps secondOpcode, Type *SrcTy, Type *MidTy, Type *DstTy, const DataLayout *DL)

Determine how a pair of casts can be eliminated, if they can be at all.

Definition Instructions.cpp:2829

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:3133

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:3147

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:3197

static LLVM_ABI bool isBitCastable(Type *SrcTy, Type *DestTy)

Check whether a bitcast between these types is valid.

Definition Instructions.cpp:3160

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:3086

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:3094

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:3122

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:2786

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:3072

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:3046

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:2765

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:3079

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:3320

LLVM_ABI CatchReturnInst * cloneImpl() const

Definition Instructions.cpp:4549

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:1138

LLVM_ABI CatchSwitchInst * cloneImpl() const

Definition Instructions.cpp:4553

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:1146

bool hasUnwindDest() const

LLVM_ABI CleanupReturnInst * cloneImpl() const

Definition Instructions.cpp:4544

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:3585

static LLVM_ABI bool isEquality(Predicate pred)

Determine if this is an equals/not equals predicate.

Definition Instructions.cpp:3562

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:3520

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:3539

bool isNonStrictPredicate() const

LLVM_ABI void swapOperands()

This is just a convenience that dispatches to the subclasses.

Definition Instructions.cpp:3549

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:3633

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:3950

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:3941

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:3508

LLVM_ABI bool isCommutative() const

This is just a convenience that dispatches to the subclasses.

Definition Instructions.cpp:3556

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:4024

CmpPredicate()

Default constructor.

static LLVM_ABI CmpPredicate get(const CmpInst *Cmp)

Do a ICmpInst::getCmpPredicate() or CmpInst::getPredicate(), as appropriate.

Definition Instructions.cpp:4043

LLVM_ABI CmpInst::Predicate getPreferredSignedPredicate() const

Attempts to return a signed CmpInst::Predicate from the CmpPredicate.

Definition Instructions.cpp:4039

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:4049

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:3860

LLVM_ABI FCmpInst * cloneImpl() const

Clone an identical FCmpInst.

Definition Instructions.cpp:4354

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:4425

LLVM_ABI FPExtInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)

Constructor with insert-before-instruction semantics.

Definition Instructions.cpp:3444

LLVM_ABI float getFPAccuracy() const

Get the maximum error permitted by this operation in ULPs.

Definition Instructions.cpp:2751

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:3468

LLVM_ABI FPToSIInst * cloneImpl() const

Clone an identical FPToSIInst.

Definition Instructions.cpp:4441

This class represents a cast from floating point to unsigned integer.

LLVM_ABI FPToUIInst * cloneImpl() const

Clone an identical FPToUIInst.

Definition Instructions.cpp:4437

LLVM_ABI FPToUIInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)

Constructor with insert-before-instruction semantics.

Definition Instructions.cpp:3462

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:3438

LLVM_ABI FPTruncInst * cloneImpl() const

Clone an identical FPTruncInst.

Definition Instructions.cpp:4421

LLVM_ABI FenceInst(LLVMContext &C, AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System, InsertPosition InsertBefore=nullptr)

Definition Instructions.cpp:1518

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:4405

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:4329

LLVM_ABI FreezeInst * cloneImpl() const

Clone an identical FreezeInst.

Definition Instructions.cpp:4588

void setParentPad(Value *ParentPad)

Value * getParentPad() const

Convenience accessors.

LLVM_ABI FuncletPadInst * cloneImpl() const

Definition Instructions.cpp:4557

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:1644

LLVM_ABI bool hasNoUnsignedSignedWrap() const

Determine whether the GEP has the nusw flag.

Definition Instructions.cpp:1648

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:1549

LLVM_ABI bool hasAllZeroIndices() const

Return true if all of the indices of this GEP are zeros.

Definition Instructions.cpp:1605

LLVM_ABI bool hasNoUnsignedWrap() const

Determine whether the GEP has the nuw flag.

Definition Instructions.cpp:1652

LLVM_ABI bool hasAllConstantIndices() const

Return true if all of the indices of this GEP are constant integers.

Definition Instructions.cpp:1619

LLVM_ABI void setIsInBounds(bool b=true)

Set or clear the inbounds flag on this GEP instruction.

Definition Instructions.cpp:1631

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:1589

LLVM_ABI bool accumulateConstantOffset(const DataLayout &DL, APInt &Offset) const

Accumulate the constant address offset of this GEP if possible.

Definition Instructions.cpp:1656

LLVM_ABI GetElementPtrInst * cloneImpl() const

Definition Instructions.cpp:4341

LLVM_ABI bool collectOffset(const DataLayout &DL, unsigned BitWidth, SmallMapVector< Value *, APInt, 4 > &VariableOffsets, APInt &ConstantOffset) const

Definition Instructions.cpp:1662

LLVM_ABI void setNoWrapFlags(GEPNoWrapFlags NW)

Set nowrap flags for GEP instruction.

Definition Instructions.cpp:1627

LLVM_ABI GEPNoWrapFlags getNoWrapFlags() const

Get the nowrap flags for the GEP instruction.

Definition Instructions.cpp:1640

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:3831

LLVM_ABI ICmpInst * cloneImpl() const

Clone an identical ICmpInst.

Definition Instructions.cpp:4358

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:3930

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:4011

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:4299

LLVM_ABI void removeDestination(unsigned i)

This method removes the specified successor from the indirectbr instruction.

Definition Instructions.cpp:4311

LLVM_ABI IndirectBrInst * cloneImpl() const

Definition Instructions.cpp:4514

LLVM_ABI InsertElementInst * cloneImpl() const

Definition Instructions.cpp:4488

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:1709

BasicBlock * getBasicBlock()

This instruction inserts a struct field of array element value into an aggregate value.

LLVM_ABI InsertValueInst * cloneImpl() const

Definition Instructions.cpp:4366

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:3486

LLVM_ABI IntToPtrInst * cloneImpl() const

Clone an identical IntToPtrInst.

Definition Instructions.cpp:4453

BasicBlock * getUnwindDest() const

void setNormalDest(BasicBlock *B)

LLVM_ABI InvokeInst * cloneImpl() const

Definition Instructions.cpp:4518

LLVM_ABI LandingPadInst * getLandingPadInst() const

Get the landingpad instruction from the landing pad block (the unwind destination).

Definition Instructions.cpp:905

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:909

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:4498

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:4378

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:1333

Align getAlign() const

Return the alignment of the access that is being performed.

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:4496

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:3480

PtrToAddrInst * cloneImpl() const

Clone an identical PtrToAddrInst.

Definition Instructions.cpp:4449

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:3474

LLVM_ABI PtrToIntInst * cloneImpl() const

Clone an identical PtrToIntInst.

Definition Instructions.cpp:4445

Resume the propagation of an exception.

LLVM_ABI ResumeInst * cloneImpl() const

Definition Instructions.cpp:4540

Return a value (possibly void), from a function.

LLVM_ABI ReturnInst * cloneImpl() const

Definition Instructions.cpp:4502

This class represents a sign extension of integer types.

LLVM_ABI SExtInst * cloneImpl() const

Clone an identical SExtInst.

Definition Instructions.cpp:4417

LLVM_ABI SExtInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)

Constructor with insert-before-instruction semantics.

Definition Instructions.cpp:3432

This class represents a cast from signed integer to floating point.

LLVM_ABI SIToFPInst * cloneImpl() const

Clone an identical SIToFPInst.

Definition Instructions.cpp:4433

LLVM_ABI SIToFPInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)

Constructor with insert-before-instruction semantics.

Definition Instructions.cpp:3456

Class to represent scalable SIMD vectors.

LLVM_ABI SelectInst * cloneImpl() const

Definition Instructions.cpp:4476

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 SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr="", InsertPosition InsertBefore=nullptr, const Instruction *MDFrom=nullptr)

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:1981

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:2046

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:1731

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:1813

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:1995

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:2496

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:2206

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:2323

LLVM_ABI bool isIdentityWithPadding() const

Return true if this shuffle lengthens exactly one source vector with undefs in the high elements.

Definition Instructions.cpp:2182

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:1935

LLVM_ABI bool isConcat() const

Return true if this shuffle concatenates its 2 source vectors.

Definition Instructions.cpp:2220

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:2449

LLVM_ABI ShuffleVectorInst * cloneImpl() const

Definition Instructions.cpp:4492

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:1953

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:2080

LLVM_ABI void setShuffleMask(ArrayRef< int > Mask)

Definition Instructions.cpp:1892

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:2354

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:1961

static LLVM_ABI bool isTransposeMask(ArrayRef< int > Mask, int NumSrcElts)

Return true if this shuffle mask is a transpose mask.

Definition Instructions.cpp:2010

LLVM_ABI void commute()

Swap the operands and adjust the mask to preserve the semantics of the instruction.

Definition Instructions.cpp:1775

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:2109

static LLVM_ABI Constant * convertShuffleMaskForBitcode(ArrayRef< int > Mask, Type *ResultTy)

Definition Instructions.cpp:1897

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:2262

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:2365

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:4383

LLVM_ABI StoreInst(Value *Val, Value *Ptr, InsertPosition InsertBefore)

Definition Instructions.cpp:1368

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:4148

LLVM_ABI void setSuccessorWeight(unsigned idx, CaseWeightOpt W)

Definition Instructions.cpp:4223

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:4208

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:4189

LLVM_ABI CaseWeightOpt getSuccessorWeight(unsigned idx)

Definition Instructions.cpp:4217

LLVM_ABI void replaceDefaultDest(SwitchInst::CaseIt I)

Replace the default destination by given case.

Definition Instructions.cpp:4179

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:4165

void setValue(ConstantInt *V) const

Sets the new value for current case.

void setSuccessor(BasicBlock *S) const

Sets the new successor for current case.

void allocHungoffUses(unsigned N)

LLVM_ABI SwitchInst * cloneImpl() const

Definition Instructions.cpp:4512

LLVM_ABI void addCase(ConstantInt *OnVal, BasicBlock *Dest)

Add an entry to the switch instruction.

Definition Instructions.cpp:4099

CaseIteratorImpl< CaseHandle > CaseIt

ConstantInt *const * case_values() const

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:4114

This class represents a truncation of integer types.

LLVM_ABI TruncInst * cloneImpl() const

Clone an identical TruncInst.

Definition Instructions.cpp:4409

LLVM_ABI TruncInst(Value *S, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)

Constructor with insert-before-instruction semantics.

Definition Instructions.cpp:3420

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:3450

LLVM_ABI UIToFPInst * cloneImpl() const

Clone an identical UIToFPInst.

Definition Instructions.cpp:4429

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:2606

LLVM_ABI UnaryOperator(UnaryOps iType, Value *S, Type *Ty, const Twine &Name, InsertPosition InsertBefore)

Definition Instructions.cpp:2598

LLVM_ABI UnaryOperator * cloneImpl() const

Definition Instructions.cpp:4346

UnaryOps getOpcode() const

LLVM_ABI UnreachableInst(LLVMContext &C, InsertPosition InsertBefore=nullptr)

Definition Instructions.cpp:1188

LLVM_ABI bool shouldLowerToTrap(bool TrapUnreachable, bool NoTrapAfterNoreturn) const

Definition Instructions.cpp:4567

friend class Instruction

Iterator for Instructions in a `BasicBlock.

LLVM_ABI UnreachableInst * cloneImpl() const

Definition Instructions.cpp:4562

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 WithExtraValues=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.

LLVM_ABI void growHungoffUses(unsigned N, bool WithExtraValues=false)

Grow the number of hung off uses.

Value * getOperand(unsigned i) const

unsigned getNumOperands() const

VAArgInst(Value *List, Type *Ty, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)

LLVM_ABI VAArgInst * cloneImpl() const

Definition Instructions.cpp:4480

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:3426

LLVM_ABI ZExtInst * cloneImpl() const

Clone an identical ZExtInst.

Definition Instructions.cpp:4413

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 getFixedValue() const

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()

typename 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.

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 .