LLVM: include/llvm/IR/Instructions.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15#ifndef LLVM_IR_INSTRUCTIONS_H

16#define LLVM_IR_INSTRUCTIONS_H

17

39#include

40#include

41#include

42#include

43#include

44

45namespace llvm {

46

48class APInt;

50class ConstantInt;

51class DataLayout;

52struct KnownBits;

53class StringRef;

56class UnreachableInst;

57

58

59

60

61

62

64 Type *AllocatedType;

65

70 SwiftErrorField>(),

71 "Bitfields must be contiguous");

72

73protected:

74

76

78

79public:

82

85

88

89

90

92

93

94

97

98

101 }

102

103

106 }

107

108

109

111

112

113

115

116

118

119

121

122

123

125 return Align(1ULL << getSubclassData());

126 }

127

129 setSubclassData(Log2(Align));

130 }

131

132

133

134

136

137

138

140 return getSubclassData();

141 }

142

143

145 setSubclassData(V);

146 }

147

148

149 bool isSwiftError() const { return getSubclassData(); }

150

151 void setSwiftError(bool V) { setSubclassData(V); }

152

153

155 return (I->getOpcode() == Instruction::Alloca);

156 }

158 return isa(V) && classof(cast(V));

159 }

160

161private:

162

163

164 template

165 void setSubclassData(typename Bitfield::Type Value) {

166 Instruction::setSubclassData(Value);

167 }

168};

169

170

171

172

173

174

175

180 static_assert(

181 Bitfield::areContiguous<VolatileField, AlignmentField, OrderingField>(),

182 "Bitfields must be contiguous");

183

184 void AssertOK();

185

186protected:

187

189

191

192public:

203

204

205 bool isVolatile() const { return getSubclassData(); }

206

207

208 void setVolatile(bool V) { setSubclassData(V); }

209

210

212 return Align(1ULL << (getSubclassData()));

213 }

214

216 setSubclassData(Log2(Align));

217 }

218

219

221 return getSubclassData();

222 }

223

224

226 setSubclassData(Ordering);

227 }

228

229

231 return SSID;

232 }

233

234

236 this->SSID = SSID;

237 }

238

239

240

245 }

246

248

253 }

254

259

260

263 }

264

265

267 return I->getOpcode() == Instruction::Load;

268 }

270 return isa(V) && classof(cast(V));

271 }

272

273private:

274

275

276 template

277 void setSubclassData(typename Bitfield::Type Value) {

278 Instruction::setSubclassData(Value);

279 }

280

281

282

283

285};

286

287

288

289

290

291

296 static_assert(

297 Bitfield::areContiguous<VolatileField, AlignmentField, OrderingField>(),

298 "Bitfields must be contiguous");

299

300 void AssertOK();

301

303

304protected:

305

307

309

310public:

319

320

321 void *operator new(size_t S) { return User::operator new(S, AllocMarker); }

322 void operator delete(void *Ptr) { User::operator delete(Ptr); }

323

324

325 bool isVolatile() const { return getSubclassData(); }

326

327

328 void setVolatile(bool V) { setSubclassData(V); }

329

330

332

334 return Align(1ULL << (getSubclassData()));

335 }

336

338 setSubclassData(Log2(Align));

339 }

340

341

343 return getSubclassData();

344 }

345

346

347

349 setSubclassData(Ordering);

350 }

351

352

354 return SSID;

355 }

356

357

359 this->SSID = SSID;

360 }

361

362

363

368 }

369

371

376 }

377

380

385

386

389 }

390

391

393 return I->getOpcode() == Instruction::Store;

394 }

396 return isa(V) && classof(cast(V));

397 }

398

399private:

400

401

402 template

403 void setSubclassData(typename Bitfield::Type Value) {

404 Instruction::setSubclassData(Value);

405 }

406

407

408

409

411};

412

413template <>

415};

416

418

419

420

421

422

423

426

428

430

431protected:

432

434

436

437public:

438

439

443

444

445 void *operator new(size_t S) { return User::operator new(S, AllocMarker); }

446 void operator delete(void *Ptr) { User::operator delete(Ptr); }

447

448

450 return getSubclassData();

451 }

452

453

454

456 setSubclassData(Ordering);

457 }

458

459

461 return SSID;

462 }

463

464

466 this->SSID = SSID;

467 }

468

469

471 return I->getOpcode() == Instruction::Fence;

472 }

474 return isa(V) && classof(cast(V));

475 }

476

477private:

478

479

480 template

481 void setSubclassData(typename Bitfield::Type Value) {

482 Instruction::setSubclassData(Value);

483 }

484

485

486

487

489};

490

491

492

493

494

495

496

497

498

499

500

505

506 template

507 using AtomicOrderingBitfieldElement =

510

512

513protected:

514

516

518

519public:

524

525

526 void *operator new(size_t S) { return User::operator new(S, AllocMarker); }

527 void operator delete(void *Ptr) { User::operator delete(Ptr); }

528

537 static_assert(

540 "Bitfields must be contiguous");

541

542

543

545 return Align(1ULL << getSubclassData());

546 }

547

549 setSubclassData(Log2(Align));

550 }

551

552

553

554

555 bool isVolatile() const { return getSubclassData(); }

556

557

558

559 void setVolatile(bool V) { setSubclassData(V); }

560

561

562 bool isWeak() const { return getSubclassData(); }

563

564 void setWeak(bool IsWeak) { setSubclassData(IsWeak); }

565

566

568

572 }

573

579 }

580

581

583 return getSubclassData();

584 }

585

586

589 "invalid CmpXchg success ordering");

590 setSubclassData(Ordering);

591 }

592

593

595 return getSubclassData();

596 }

597

598

601 "invalid CmpXchg failure ordering");

602 setSubclassData(Ordering);

603 }

604

605

606

615 }

617 }

618

619

621 return SSID;

622 }

623

624

626 this->SSID = SSID;

627 }

628

632

635

638

639

642 }

643

644

645

646

647

648

649

650

653 switch (SuccessOrdering) {

654 default:

664 }

665 }

666

667

669 return I->getOpcode() == Instruction::AtomicCmpXchg;

670 }

672 return isa(V) && classof(cast(V));

673 }

674

675private:

676

677

678 template

679 void setSubclassData(typename Bitfield::Type Value) {

680 Instruction::setSubclassData(Value);

681 }

682

683

684

685

687};

688

689template <>

692};

693

695

696

697

698

699

700

701

702

703

705protected:

706

708

710

711public:

712

713

714

715

717

719

721

723

725

727

729

731

733

735

737

739

740

742

743

745

746

747

749

750

751

753

754

755

757

758

759

761

762

763

765

766

767

769

770 FIRST_BINOP = Xchg,

771 LAST_BINOP = USubSat,

772 BAD_BINOP

774

775private:

776 template

777 using AtomicOrderingBitfieldElement =

780

781 template

782 using BinOpBitfieldElement =

784

785 constexpr static IntrusiveOperandsAllocMarker AllocMarker{2};

786

787public:

788 AtomicRMWInst(BinOp Operation, Value *Ptr, Value *Val, Align Alignment,

790 InsertPosition InsertBefore = nullptr);

791

792

793 void *operator new(size_t S) { return User::operator new(S, AllocMarker); }

794 void operator delete(void *Ptr) { User::operator delete(Ptr); }

795

799 using OperationField = BinOpBitfieldElementAtomicOrderingField::NextBit;

803 "Bitfields must be contiguous");

804

806

807 static StringRef getOperationName(BinOp Op);

808

810 switch (Op) {

815 return true;

816 default:

817 return false;

818 }

819 }

820

822 setSubclassData(Operation);

823 }

824

825

826

828 return Align(1ULL << getSubclassData());

829 }

830

832 setSubclassData(Log2(Align));

833 }

834

835

836

837 bool isVolatile() const { return getSubclassData(); }

838

839

840

841 void setVolatile(bool V) { setSubclassData(V); }

842

843

845

846

848 return getSubclassData();

849 }

850

851

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

856 "atomicrmw instructions cannot be unordered.");

857 setSubclassData(Ordering);

858 }

859

860

862 return SSID;

863 }

864

865

867 this->SSID = SSID;

868 }

869

873

876

877

880 }

881

883 return isFPOperation(getOperation());

884 }

885

886

888 return I->getOpcode() == Instruction::AtomicRMW;

889 }

891 return isa(V) && classof(cast(V));

892 }

893

894private:

897

898

899

900 template

901 void setSubclassData(typename Bitfield::Type Value) {

902 Instruction::setSubclassData(Value);

903 }

904

905

906

907

909};

910

911template <>

914};

915

917

918

919

920

921

922

923

924

926 assert(Ty && "Invalid GetElementPtrInst indices for type!");

927 return Ty;

928}

929

930

931

932

934 Type *SourceElementType;

935 Type *ResultElementType;

936

938

939

940

941

942

946

948

949protected:

950

952

954

955public:

958 const Twine &NameStr = "",

960 unsigned Values = 1 + unsigned(IdxList.size());

961 assert(PointeeType && "Must specify element type");

964 PointeeType, Ptr, IdxList, AllocMarker, NameStr, InsertBefore);

965 }

966

969 const Twine &NameStr = "",

972 Create(PointeeType, Ptr, IdxList, NameStr, InsertBefore);

973 GEP->setNoWrapFlags(NW);

974 return GEP;

975 }

976

977

978

981 const Twine &NameStr = "",

984 NameStr, InsertBefore);

985 }

986

987

989

991

994

996 return ResultElementType;

997 }

998

999

1001

1002

1004 }

1005

1006

1007

1008

1009

1010

1014

1015

1016

1017

1018

1019

1022

1027

1030 }

1031

1034 }

1035

1038 }

1041 }

1043 return 0U;

1044 }

1045

1046

1047

1050 }

1051

1052

1055 }

1056

1057

1058

1060

1061 Type *Ty = Ptr->getType();

1063 return Ty;

1064

1066 if (auto *IndexVTy = dyn_cast(Index->getType())) {

1067 ElementCount EltCount = IndexVTy->getElementCount();

1069 }

1070

1071 return Ty;

1072 }

1073

1076 }

1077

1080 }

1081

1082

1083

1084

1086

1087

1088

1089

1091

1092

1094

1095

1096

1097

1099

1100

1102

1103

1105

1106

1108

1109

1111

1112

1113

1114

1115

1116

1117

1118

1119

1123 APInt &ConstantOffset) const;

1124

1126 return (I->getOpcode() == Instruction::GetElementPtr);

1127 }

1129 return isa(V) && classof(cast(V));

1130 }

1131};

1132

1133template <>

1136

1137GetElementPtrInst::GetElementPtrInst(Type *PointeeType, Value *Ptr,

1142 InsertBefore),

1143 SourceElementType(PointeeType),

1144 ResultElementType(getIndexedType(PointeeType, IdxList)) {

1145 init(Ptr, IdxList, NameStr);

1146}

1147

1149

1150

1151

1152

1153

1154

1155

1156

1157

1159 void AssertOK() {

1160 assert(isIntPredicate() &&

1161 "Invalid ICmp predicate value");

1163 "Both operands to ICmp instruction are not of the same type!");

1164

1165 assert((getOperand(0)->getType()->isIntOrIntVectorTy() ||

1166 getOperand(0)->getType()->isPtrOrPtrVectorTy()) &&

1167 "Invalid operand types for ICmp instruction");

1168 }

1169

1170 enum { SameSign = (1 << 0) };

1171

1172protected:

1173

1175

1176

1177 ICmpInst *cloneImpl() const;

1178

1179public:

1180

1182 Predicate pred,

1183 Value *LHS,

1184 Value *RHS,

1185 const Twine &NameStr = ""

1186 )

1188 RHS, NameStr, InsertBefore) {

1189#ifndef NDEBUG

1190 AssertOK();

1191#endif

1192 }

1193

1194

1196 Predicate pred,

1197 Value *LHS,

1198 Value *RHS,

1199 const Twine &NameStr = ""

1202#ifndef NDEBUG

1203 AssertOK();

1204#endif

1205 }

1206

1207

1209 return {getPredicate(), hasSameSign()};

1210 }

1211

1212

1213

1215 return {getInversePredicate(Pred), Pred.hasSameSign()};

1216 }

1217

1218

1220 return getInverseCmpPredicate(getCmpPredicate());

1221 }

1222

1223

1224

1226 return {getSwappedPredicate(Pred), Pred.hasSameSign()};

1227 }

1228

1229

1231 return getSwappedCmpPredicate(getCmpPredicate());

1232 }

1233

1234

1235

1236

1237

1239 return getSignedPredicate(getPredicate());

1240 }

1241

1242

1243 static Predicate getSignedPredicate(Predicate Pred);

1244

1245

1246

1247

1248

1250 return getUnsignedPredicate(getPredicate());

1251 }

1252

1253

1254 static Predicate getUnsignedPredicate(Predicate Pred);

1255

1256

1257

1258

1259

1260 static Predicate getFlippedSignednessPredicate(Predicate Pred);

1261

1262

1263

1264

1266 return getFlippedSignednessPredicate(getPredicate());

1267 }

1268

1269

1270

1271 static std::optional isImpliedByMatchingCmp(CmpPredicate Pred1,

1273

1275 SubclassOptionalData = (SubclassOptionalData & ~SameSign) | (B * SameSign);

1276 }

1277

1278

1279

1280

1281 bool hasSameSign() const { return SubclassOptionalData & SameSign; }

1282

1283

1284

1286 return P == ICMP_EQ || P == ICMP_NE;

1287 }

1288

1289

1290

1292 return isEquality(getPredicate());

1293 }

1294

1295

1296

1298

1299

1300

1302

1303

1304

1306 return !isEquality();

1307 }

1308

1309

1310

1312 return !isEquality(P);

1313 }

1314

1315

1316

1318 return P == ICMP_SGT || P == ICMP_UGT;

1319 }

1320

1321

1322

1324 return P == ICMP_SLT || P == ICMP_ULT;

1325 }

1326

1327

1328

1330 return P == ICMP_SGE || P == ICMP_UGE;

1331 }

1332

1333

1334

1336 return P == ICMP_SLE || P == ICMP_ULE;

1337 }

1338

1339

1340

1341 static auto predicates() { return ICmpPredicates(); }

1342

1343

1344

1345

1346

1347

1349 setPredicate(getSwappedPredicate());

1351 }

1352

1353

1356

1357

1358

1361

1362

1364 return I->getOpcode() == Instruction::ICmp;

1365 }

1367 return isa(V) && classof(cast(V));

1368 }

1369};

1370

1371

1372

1373

1374

1375

1376

1377

1378

1380 void AssertOK() {

1383 "Both operands to FCmp instruction are not of the same type!");

1384

1386 "Invalid operand types for FCmp instruction");

1387 }

1388

1389protected:

1390

1392

1393

1395

1396public:

1397

1399 Predicate pred,

1400 Value *LHS,

1401 Value *RHS,

1402 const Twine &NameStr = ""

1403 )

1405 RHS, NameStr, InsertBefore) {

1406 AssertOK();

1407 }

1408

1409

1411 Value *LHS,

1412 Value *RHS,

1413 const Twine &NameStr = "",

1416 RHS, NameStr, nullptr, FlagsSource) {

1417 AssertOK();

1418 }

1419

1420

1421

1425 }

1426

1427

1428

1430

1431

1432

1436 }

1437

1438

1439

1441

1442

1443

1445

1446

1447

1448

1449

1450

1454 }

1455

1456

1457

1459

1460

1463

1464

1466 return I->getOpcode() == Instruction::FCmp;

1467 }

1469 return isa(V) && classof(cast(V));

1470 }

1471};

1472

1473

1474

1475

1476

1477

1478

1481

1482

1486

1490 : CallInst(Ty, Func, Args, {}, NameStr, AllocInfo, InsertBefore) {}

1491

1494

1498

1499

1500 static unsigned ComputeNumOperands(unsigned NumArgs,

1501 unsigned NumBundleInputs = 0) {

1502

1503

1504 return 1 + NumArgs + NumBundleInputs;

1505 }

1506

1507protected:

1508

1510

1512

1513public:

1517 return new (AllocMarker)

1518 CallInst(Ty, F, NameStr, AllocMarker, InsertBefore);

1519 }

1520

1522 const Twine &NameStr,

1525 return new (AllocMarker)

1526 CallInst(Ty, Func, Args, {}, NameStr, AllocMarker, InsertBefore);

1527 }

1528

1531 const Twine &NameStr = "",

1533 IntrusiveOperandsAndDescriptorAllocMarker AllocMarker{

1534 ComputeNumOperands(unsigned(Args.size()), CountBundleInputs(Bundles)),

1535 unsigned(Bundles.size() * sizeof(BundleOpInfo))};

1536

1537 return new (AllocMarker)

1538 CallInst(Ty, Func, Args, Bundles, NameStr, AllocMarker, InsertBefore);

1539 }

1540

1543 return Create(Func.getFunctionType(), Func.getCallee(), NameStr,

1544 InsertBefore);

1545 }

1546

1549 const Twine &NameStr = "",

1551 return Create(Func.getFunctionType(), Func.getCallee(), Args, Bundles,

1552 NameStr, InsertBefore);

1553 }

1554

1556 const Twine &NameStr,

1558 return Create(Func.getFunctionType(), Func.getCallee(), Args, NameStr,

1559 InsertBefore);

1560 }

1561

1562

1563

1564

1565

1566

1567

1570

1571

1579

1581 static_assert(

1582 Bitfield::areContiguous<TailCallKindField, CallBase::CallingConvField>(),

1583 "Bitfields must be contiguous");

1584

1586 return getSubclassData();

1587 }

1588

1592 }

1593

1595

1597

1599 setSubclassData(TCK);

1600 }

1601

1604 }

1605

1606

1609

1610

1613 case Intrinsic:🪤

1614 case Intrinsic::ubsantrap:

1615 return hasFnAttr("trap-func-name");

1616 default:

1617 return false;

1618 }

1619 }

1620

1621

1623 return I->getOpcode() == Instruction::Call;

1624 }

1626 return isa(V) && classof(cast(V));

1627 }

1628

1629

1631

1632private:

1633

1634

1635 template

1636 void setSubclassData(typename Bitfield::Type Value) {

1637 Instruction::setSubclassData(Value);

1638 }

1639};

1640

1641CallInst::CallInst(FunctionType *Ty, Value *Func, ArrayRef<Value *> Args,

1642 ArrayRef Bundles, const Twine &NameStr,

1643 AllocInfo AllocInfo, InsertPosition InsertBefore)

1644 : CallBase(Ty->getReturnType(), Instruction::Call, AllocInfo,

1645 InsertBefore) {

1646 assert(AllocInfo.NumOps ==

1648 init(Ty, Func, Args, Bundles, NameStr);

1649}

1650

1651

1652

1653

1654

1655

1656

1659

1662 : Instruction(S1->getType(), Instruction::Select, AllocMarker,

1663 InsertBefore) {

1664 init(C, S1, S2);

1666 }

1667

1673 }

1674

1675protected:

1676

1678

1680

1681public:

1683 const Twine &NameStr = "",

1687 new (AllocMarker) SelectInst(C, S1, S2, NameStr, InsertBefore);

1688 if (MDFrom)

1690 return Sel;

1691 }

1692

1699

1703

1704

1705

1707

1708

1709

1711

1712

1714

1717 }

1718

1719

1721 return I->getOpcode() == Instruction::Select;

1722 }

1724 return isa(V) && classof(cast(V));

1725 }

1726};

1727

1728template <>

1730};

1731

1733

1734

1735

1736

1737

1738

1739

1740

1742protected:

1743

1745

1747

1748public:

1752 setName(NameStr);

1753 }

1754

1758

1759

1761 return I->getOpcode() == VAArg;

1762 }

1764 return isa(V) && classof(cast(V));

1765 }

1766};

1767

1768

1769

1770

1771

1772

1773

1774

1777

1780

1781protected:

1782

1784

1786

1787public:

1789 const Twine &NameStr = "",

1791 return new (AllocMarker)

1793 }

1794

1795

1796

1798

1803

1806 }

1807

1808

1810

1811

1813 return I->getOpcode() == Instruction::ExtractElement;

1814 }

1816 return isa(V) && classof(cast(V));

1817 }

1818};

1819

1820template <>

1823};

1824

1826

1827

1828

1829

1830

1831

1832

1833

1836

1838 const Twine &NameStr = "",

1840

1841protected:

1842

1844

1846

1847public:

1849 const Twine &NameStr = "",

1851 return new (AllocMarker)

1853 }

1854

1855

1856

1857 static bool isValidOperands(const Value *Vec, const Value *NewElt,

1859

1860

1861

1864 }

1865

1866

1868

1869

1871 return I->getOpcode() == Instruction::InsertElement;

1872 }

1874 return isa(V) && classof(cast(V));

1875 }

1876};

1877

1878template <>

1881};

1882

1884

1885

1886

1887

1888

1890

1891

1892

1893

1894

1895

1896

1897

1898

1899

1900

1903

1905 Constant *ShuffleMaskForBitcode;

1906

1907protected:

1908

1910

1912

1913public:

1919 const Twine &NameStr = "",

1922 const Twine &NameStr = "",

1924

1925 void *operator new(size_t S) { return User::operator new(S, AllocMarker); }

1926 void operator delete(void *Ptr) { return User::operator delete(Ptr); }

1927

1928

1929

1930 void commute();

1931

1932

1933

1934 static bool isValidOperands(const Value *V1, const Value *V2,

1935 const Value *Mask);

1936 static bool isValidOperands(const Value *V1, const Value *V2,

1938

1939

1940

1943 }

1944

1945

1947

1948

1949

1950 int getMaskValue(unsigned Elt) const { return ShuffleMask[Elt]; }

1951

1952

1953

1954 static void getShuffleMask(const Constant *Mask,

1956

1957

1958

1960 Result.assign(ShuffleMask.begin(), ShuffleMask.end());

1961 }

1962

1963

1964

1965

1966

1968

1970 Type *ResultTy);

1971

1973

1975

1976

1977

1978

1979

1981 unsigned NumSourceElts = cast(Op<0>()->getType())

1982 ->getElementCount()

1983 .getKnownMinValue();

1984 unsigned NumMaskElts = ShuffleMask.size();

1985 return NumSourceElts != NumMaskElts;

1986 }

1987

1988

1989

1990

1992 unsigned NumSourceElts = cast(Op<0>()->getType())

1993 ->getElementCount()

1994 .getKnownMinValue();

1995 unsigned NumMaskElts = ShuffleMask.size();

1996 return NumSourceElts < NumMaskElts;

1997 }

1998

1999

2000

2001

2002

2003

2004 static bool isSingleSourceMask(ArrayRef Mask, int NumSrcElts);

2006 assert(Mask->getType()->isVectorTy() && "Shuffle needs vector constant.");

2008 getShuffleMask(Mask, MaskAsInts);

2009 return isSingleSourceMask(MaskAsInts, NumSrcElts);

2010 }

2011

2012

2013

2014

2015

2017 return !changesLength() &&

2018 isSingleSourceMask(ShuffleMask, ShuffleMask.size());

2019 }

2020

2021

2022

2023

2024

2025

2026 static bool isIdentityMask(ArrayRef Mask, int NumSrcElts);

2028 assert(Mask->getType()->isVectorTy() && "Shuffle needs vector constant.");

2029

2030

2031

2032 if (isa(Mask->getType()))

2033 return false;

2034

2036 getShuffleMask(Mask, MaskAsInts);

2037 return isIdentityMask(MaskAsInts, NumSrcElts);

2038 }

2039

2040

2041

2042

2043

2045

2046

2047 if (isa(getType()))

2048 return false;

2049

2050 return !changesLength() && isIdentityMask(ShuffleMask, ShuffleMask.size());

2051 }

2052

2053

2054

2055 bool isIdentityWithPadding() const;

2056

2057

2058

2059 bool isIdentityWithExtract() const;

2060

2061

2062

2063

2064 bool isConcat() const;

2065

2066

2067

2068

2069

2070

2071

2072

2073

2074 static bool isSelectMask(ArrayRef Mask, int NumSrcElts);

2076 assert(Mask->getType()->isVectorTy() && "Shuffle needs vector constant.");

2078 getShuffleMask(Mask, MaskAsInts);

2079 return isSelectMask(MaskAsInts, NumSrcElts);

2080 }

2081

2082

2083

2084

2085

2086

2087

2088

2089

2091 return !changesLength() && isSelectMask(ShuffleMask, ShuffleMask.size());

2092 }

2093

2094

2095

2096

2097

2098

2101 assert(Mask->getType()->isVectorTy() && "Shuffle needs vector constant.");

2103 getShuffleMask(Mask, MaskAsInts);

2105 }

2106

2107

2108

2109

2110

2112 return !changesLength() && isReverseMask(ShuffleMask, ShuffleMask.size());

2113 }

2114

2115

2116

2117

2118

2119

2120 static bool isZeroEltSplatMask(ArrayRef Mask, int NumSrcElts);

2122 assert(Mask->getType()->isVectorTy() && "Shuffle needs vector constant.");

2124 getShuffleMask(Mask, MaskAsInts);

2125 return isZeroEltSplatMask(MaskAsInts, NumSrcElts);

2126 }

2127

2128

2129

2130

2131

2132

2133

2135 return !changesLength() &&

2136 isZeroEltSplatMask(ShuffleMask, ShuffleMask.size());

2137 }

2138

2139

2140

2141

2142

2143

2144

2145

2146

2147

2148

2149

2150

2151

2152

2153

2154

2155

2156

2157

2158

2159

2160

2161

2162

2163

2164

2165

2166

2167

2168

2169

2170

2171 static bool isTransposeMask(ArrayRef Mask, int NumSrcElts);

2173 assert(Mask->getType()->isVectorTy() && "Shuffle needs vector constant.");

2175 getShuffleMask(Mask, MaskAsInts);

2176 return isTransposeMask(MaskAsInts, NumSrcElts);

2177 }

2178

2179

2180

2181

2182

2183

2185 return !changesLength() && isTransposeMask(ShuffleMask, ShuffleMask.size());

2186 }

2187

2188

2189

2190

2191

2192

2193

2194 static bool isSpliceMask(ArrayRef Mask, int NumSrcElts, int &Index);

2196 assert(Mask->getType()->isVectorTy() && "Shuffle needs vector constant.");

2198 getShuffleMask(Mask, MaskAsInts);

2199 return isSpliceMask(MaskAsInts, NumSrcElts, Index);

2200 }

2201

2202

2203

2204

2205

2207 return !changesLength() &&

2208 isSpliceMask(ShuffleMask, ShuffleMask.size(), Index);

2209 }

2210

2211

2212

2213

2214 static bool isExtractSubvectorMask(ArrayRef Mask, int NumSrcElts,

2218 assert(Mask->getType()->isVectorTy() && "Shuffle needs vector constant.");

2219

2220

2221 if (isa(Mask->getType()))

2222 return false;

2224 getShuffleMask(Mask, MaskAsInts);

2225 return isExtractSubvectorMask(MaskAsInts, NumSrcElts, Index);

2226 }

2227

2228

2230

2231

2232 if (isa(getType()))

2233 return false;

2234

2235 int NumSrcElts =

2236 cast(Op<0>()->getType())->getNumElements();

2237 return isExtractSubvectorMask(ShuffleMask, NumSrcElts, Index);

2238 }

2239

2240

2241

2242

2243

2244 static bool isInsertSubvectorMask(ArrayRef Mask, int NumSrcElts,

2245 int &NumSubElts, int &Index);

2247 int &NumSubElts, int &Index) {

2248 assert(Mask->getType()->isVectorTy() && "Shuffle needs vector constant.");

2249

2250

2251 if (isa(Mask->getType()))

2252 return false;

2254 getShuffleMask(Mask, MaskAsInts);

2255 return isInsertSubvectorMask(MaskAsInts, NumSrcElts, NumSubElts, Index);

2256 }

2257

2258

2260

2261

2262 if (isa(getType()))

2263 return false;

2264

2265 int NumSrcElts =

2266 cast(Op<0>()->getType())->getNumElements();

2267 return isInsertSubvectorMask(ShuffleMask, NumSrcElts, NumSubElts, Index);

2268 }

2269

2270

2271

2272

2273

2274 static bool isReplicationMask(ArrayRef Mask, int &ReplicationFactor,

2275 int &VF);

2277 int &VF) {

2278 assert(Mask->getType()->isVectorTy() && "Shuffle needs vector constant.");

2279

2280

2281 if (isa(Mask->getType()))

2282 return false;

2284 getShuffleMask(Mask, MaskAsInts);

2285 return isReplicationMask(MaskAsInts, ReplicationFactor, VF);

2286 }

2287

2288

2289 bool isReplicationMask(int &ReplicationFactor, int &VF) const;

2290

2291

2292

2293

2294

2295

2296

2297

2298

2299

2300 static bool isOneUseSingleSourceMask(ArrayRef Mask, int VF);

2301

2302

2303

2304 bool isOneUseSingleSourceMask(int VF) const;

2305

2306

2307

2309 unsigned InVecNumElts) {

2310 for (int &Idx : Mask) {

2311 if (Idx == -1)

2312 continue;

2313 Idx = Idx < (int)InVecNumElts ? Idx + InVecNumElts : Idx - InVecNumElts;

2314 assert(Idx >= 0 && Idx < (int)InVecNumElts * 2 &&

2315 "shufflevector mask index out of range");

2316 }

2317 }

2318

2319

2320 bool isInterleave(unsigned Factor);

2321

2322

2323

2324

2325

2326

2327

2328

2329

2330

2331

2332

2333

2334

2335

2336

2337

2338

2339

2340

2341 static bool isInterleaveMask(ArrayRef Mask, unsigned Factor,

2342 unsigned NumInputElts,

2345 unsigned NumInputElts) {

2347 return isInterleaveMask(Mask, Factor, NumInputElts, StartIndexes);

2348 }

2349

2350

2351

2352

2353 static bool isDeInterleaveMaskOfFactor(ArrayRef Mask, unsigned Factor,

2354 unsigned &Index);

2356 unsigned Unused;

2357 return isDeInterleaveMaskOfFactor(Mask, Factor, Unused);

2358 }

2359

2360

2361

2362

2363

2364

2365

2366

2367

2368

2369

2370

2371 static bool isBitRotateMask(ArrayRef Mask, unsigned EltSizeInBits,

2372 unsigned MinSubElts, unsigned MaxSubElts,

2373 unsigned &NumSubElts, unsigned &RotateAmt);

2374

2375

2377 return I->getOpcode() == Instruction::ShuffleVector;

2378 }

2380 return isa(V) && classof(cast(V));

2381 }

2382};

2383

2384template <>

2387

2389

2390

2391

2392

2393

2394

2395

2396

2399

2401

2402

2403

2404

2405

2408

2410

2411protected:

2412

2414

2416

2417public:

2419 const Twine &NameStr = "",

2421 return new

2423 }

2424

2425

2426

2427

2428

2430

2432

2436 return make_range(idx_begin(), idx_end());

2437 }

2438

2440 return getOperand(0);

2441 }

2443 return getOperand(0);

2444 }

2446 return 0U;

2447 }

2448

2450 return Indices;

2451 }

2452

2454 return (unsigned)Indices.size();

2455 }

2456

2458 return true;

2459 }

2460

2461

2463 return I->getOpcode() == Instruction::ExtractValue;

2464 }

2466 return isa(V) && classof(cast(V));

2467 }

2468};

2469

2470ExtractValueInst::ExtractValueInst(Value *Agg, ArrayRef Idxs,

2471 const Twine &NameStr,

2472 InsertPosition InsertBefore)

2474 ExtractValue, Agg, InsertBefore) {

2475 init(Idxs, NameStr);

2476}

2477

2478

2479

2480

2481

2482

2483

2484

2487

2489

2491

2492

2493

2494

2495

2498

2499

2500

2502 const Twine &NameStr = "",

2504

2506 const Twine &NameStr);

2507

2508protected:

2509

2511

2513

2514public:

2515

2516 void *operator new(size_t S) { return User::operator new(S, AllocMarker); }

2517 void operator delete(void *Ptr) { User::operator delete(Ptr); }

2518

2521 const Twine &NameStr = "",

2523 return new InsertValueInst(Agg, Val, Idxs, NameStr, InsertBefore);

2524 }

2525

2526

2528

2530

2535 }

2536

2539 }

2542 }

2544 return 0U;

2545 }

2546

2549 }

2552 }

2554 return 1U;

2555 }

2556

2558 return Indices;

2559 }

2560

2562 return (unsigned)Indices.size();

2563 }

2564

2566 return true;

2567 }

2568

2569

2571 return I->getOpcode() == Instruction::InsertValue;

2572 }

2574 return isa(V) && classof(cast(V));

2575 }

2576};

2577

2578template <>

2581};

2582

2583InsertValueInst::InsertValueInst(Value *Agg, Value *Val,

2586 : Instruction(Agg->getType(), InsertValue, AllocMarker, InsertBefore) {

2587 init(Agg, Val, Idxs, NameStr);

2588}

2589

2591

2592

2593

2594

2595

2596

2597

2598

2599

2602

2603

2604

2605 unsigned ReservedSpace;

2606

2608

2609 explicit PHINode(Type *Ty, unsigned NumReservedValues,

2610 const Twine &NameStr = "",

2612 : Instruction(Ty, Instruction::PHI, AllocMarker, InsertBefore),

2613 ReservedSpace(NumReservedValues) {

2614 assert(!Ty->isTokenTy() && "PHI nodes cannot have token type!");

2615 setName(NameStr);

2616 allocHungoffUses(ReservedSpace);

2617 }

2618

2619protected:

2620

2622

2623 PHINode *cloneImpl() const;

2624

2625

2626

2627

2630 }

2631

2632public:

2633

2634

2636 const Twine &NameStr = "",

2638 return new (AllocMarker)

2639 PHINode(Ty, NumReservedValues, NameStr, InsertBefore);

2640 }

2641

2642

2644

2645

2646

2647

2648

2649

2652

2655 }

2656

2658 return block_begin() + getNumOperands();

2659 }

2660

2662 return make_range(block_begin(), block_end());

2663 }

2664

2666

2668

2669

2670

2672

2673

2674

2676 return getOperand(i);

2677 }

2679 assert(V && "PHI node got a null value!");

2681 "All operands to PHI node must be the same type as the PHI node!");

2682 setOperand(i, V);

2683 }

2684

2686 return i;

2687 }

2688

2690 return i;

2691 }

2692

2693

2694

2696 return block_begin()[i];

2697 }

2698

2699

2700

2701

2703 assert(this == U.getUser() && "Iterator doesn't point to PHI's Uses?");

2704 return getIncomingBlock(unsigned(&U - op_begin()));

2705 }

2706

2707

2708

2709

2711 return getIncomingBlock(I.getUse());

2712 }

2713

2716 }

2717

2718

2719

2723 }

2724

2725

2727 assert(New && Old && "PHI node got a null basic block!");

2728 for (unsigned Op = 0, NumOps = getNumOperands(); Op != NumOps; ++Op)

2729 if (getIncomingBlock(Op) == Old)

2730 setIncomingBlock(Op, New);

2731 }

2732

2733

2734

2736 if (getNumOperands() == ReservedSpace)

2737 growOperands();

2738

2739 setNumHungOffUseOperands(getNumOperands() + 1);

2740 setIncomingValue(getNumOperands() - 1, V);

2741 setIncomingBlock(getNumOperands() - 1, BB);

2742 }

2743

2744

2745

2746

2747

2748

2749

2750

2751

2752 Value *removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty = true);

2753

2755 int Idx = getBasicBlockIndex(BB);

2756 assert(Idx >= 0 && "Invalid basic block argument to remove!");

2757 return removeIncomingValue(Idx, DeletePHIIfEmpty);

2758 }

2759

2760

2761

2762 void removeIncomingValueIf(function_ref<bool(unsigned)> Predicate,

2763 bool DeletePHIIfEmpty = true);

2764

2765

2766

2767

2769 for (unsigned i = 0, e = getNumOperands(); i != e; ++i)

2770 if (block_begin()[i] == BB)

2771 return i;

2772 return -1;

2773 }

2774

2776 int Idx = getBasicBlockIndex(BB);

2777 assert(Idx >= 0 && "Invalid basic block argument!");

2778 return getIncomingValue(Idx);

2779 }

2780

2781

2783 assert(BB && "PHI node got a null basic block!");

2784 bool Found = false;

2785 for (unsigned Op = 0, NumOps = getNumOperands(); Op != NumOps; ++Op)

2786 if (getIncomingBlock(Op) == BB) {

2787 Found = true;

2788 setIncomingValue(Op, V);

2789 }

2790 (void)Found;

2791 assert(Found && "Invalid basic block argument to set!");

2792 }

2793

2794

2795

2796 Value *hasConstantValue() const;

2797

2798

2799

2800

2801 bool hasConstantOrUndefValue() const;

2802

2803

2804

2808 return getBasicBlockIndex(Pred) >= 0;

2809 });

2810 }

2811

2812

2814 return I->getOpcode() == Instruction::PHI;

2815 }

2817 return isa(V) && classof(cast(V));

2818 }

2819

2820private:

2821 void growOperands();

2822};

2823

2825

2827

2828

2829

2830

2831

2832

2833

2834

2835

2836

2837

2838

2839

2842

2844

2845

2846

2847 unsigned ReservedSpace;

2848

2850

2851public:

2853

2854private:

2857

2858

2859 void *operator new(size_t S) { return User::operator new(S, AllocMarker); }

2860

2861 void growOperands(unsigned Size);

2862 void init(unsigned NumReservedValues, const Twine &NameStr);

2863

2864protected:

2865

2867

2869

2870public:

2871 void operator delete(void *Ptr) { User::operator delete(Ptr); }

2872

2873

2874

2876 const Twine &NameStr = "",

2878

2879

2881

2882

2883

2884

2885 bool isCleanup() const { return getSubclassData(); }

2886

2887

2888 void setCleanup(bool V) { setSubclassData(V); }

2889

2890

2892

2893

2894

2896 return cast(getOperandList()[Idx]);

2897 }

2898

2899

2901 return !isa(getOperandList()[Idx]->getType());

2902 }

2903

2904

2906 return isa(getOperandList()[Idx]->getType());

2907 }

2908

2909

2911

2912

2913

2915

2916

2918 return I->getOpcode() == Instruction::LandingPad;

2919 }

2921 return isa(V) && classof(cast(V));

2922 }

2923};

2924

2925template <>

2927

2929

2930

2931

2932

2933

2934

2935

2936

2937

2940

2941private:

2942

2943

2944

2945

2946

2947

2948

2949

2950

2951

2952

2953

2954

2957

2958protected:

2959

2961

2963

2964public:

2968 return new (AllocMarker) ReturnInst(C, retVal, AllocMarker, InsertBefore);

2969 }

2970

2973 return new (AllocMarker) ReturnInst(C, nullptr, AllocMarker, InsertAtEnd);

2974 }

2975

2976

2978

2979

2981 return getNumOperands() != 0 ? getOperand(0) : nullptr;

2982 }

2983

2985

2986

2988 return (I->getOpcode() == Instruction::Ret);

2989 }

2991 return isa(V) && classof(cast(V));

2992 }

2993

2994private:

2995 BasicBlock *getSuccessor(unsigned idx) const {

2997 }

2998

2999 void setSuccessor(unsigned idx, BasicBlock *B) {

3001 }

3002};

3003

3004template <>

3006

3008

3009

3010

3011

3012

3013

3014

3015

3017

3018

3019

3020

3022

3023

3024

3025

3026

3027

3028

3029

3030

3035

3036 void AssertOK();

3037

3038protected:

3039

3041

3043

3044public:

3045

3046

3047

3048

3051 std::random_access_iterator_tag, BasicBlock *,

3052 ptrdiff_t, BasicBlock *, BasicBlock *> {

3054

3057 };

3058

3059

3062 std::random_access_iterator_tag,

3063 const BasicBlock *, ptrdiff_t, const BasicBlock *,

3064 const BasicBlock *> {

3067

3070 };

3071

3075 return new (AllocMarker) BranchInst(IfTrue, AllocMarker, InsertBefore);

3076 }

3077

3082 return new (AllocMarker)

3083 BranchInst(IfTrue, IfFalse, Cond, AllocMarker, InsertBefore);

3084 }

3085

3086

3088

3091

3093 assert(isConditional() && "Cannot get condition of an uncond branch!");

3094 return Op<-3>();

3095 }

3096

3098 assert(isConditional() && "Cannot set condition of unconditional branch!");

3099 Op<-3>() = V;

3100 }

3101

3103

3105 assert(i < getNumSuccessors() && "Successor # out of range for Branch!");

3106 return cast_or_null((&Op<-1>() - i)->get());

3107 }

3108

3110 assert(idx < getNumSuccessors() && "Successor # out of range for Branch!");

3111 *(&Op<-1>() - idx) = NewSucc;

3112 }

3113

3114

3115

3116

3117

3118

3119 void swapSuccessors();

3120

3123 succ_op_iterator(std::next(value_op_begin(), isConditional() ? 1 : 0)),

3125 }

3126

3129 std::next(value_op_begin(), isConditional() ? 1 : 0)),

3131 }

3132

3133

3135 return (I->getOpcode() == Instruction::Br);

3136 }

3138 return isa(V) && classof(cast(V));

3139 }

3140};

3141

3142template <>

3144

3146

3147

3148

3149

3150

3151

3152

3153

3156

3157 unsigned ReservedSpace;

3158

3159

3160

3161

3162

3164

3165

3166

3167

3168

3171

3172

3173 void *operator new(size_t S) { return User::operator new(S, AllocMarker); }

3174

3176 void growOperands();

3177

3178protected:

3179

3181

3183

3184public:

3185 void operator delete(void *Ptr) { User::operator delete(Ptr); }

3186

3187

3188 static const unsigned DefaultPseudoIndex = static_cast<unsigned>(~0L-1);

3189

3191

3192

3193

3194

3195

3196

3197 template <typename SwitchInstT, typename ConstantIntT, typename BasicBlockT>

3199

3201 CaseHandleImpl<SwitchInstT, ConstantIntT, BasicBlockT>>;

3202

3203 protected:

3204

3206

3209

3212

3213 public:

3214

3216 assert((unsigned)Index < SI->getNumCases() &&

3217 "Index out the number of cases.");

3218 return reinterpret_cast<ConstantIntT *>(SI->getOperand(2 + Index * 2));

3219 }

3220

3221

3223 assert(((unsigned)Index < SI->getNumCases() ||

3224 (unsigned)Index == DefaultPseudoIndex) &&

3225 "Index out the number of cases.");

3226 return SI->getSuccessor(getSuccessorIndex());

3227 }

3228

3229

3231

3232

3234 assert(((unsigned)Index == DefaultPseudoIndex ||

3235 (unsigned)Index < SI->getNumCases()) &&

3236 "Index out the number of cases.");

3237 return (unsigned)Index != DefaultPseudoIndex ? Index + 1 : 0;

3238 }

3239

3241 assert(SI == RHS.SI && "Incompatible operators.");

3243 }

3244 };

3245

3248

3250 : public CaseHandleImpl<SwitchInst, ConstantInt, BasicBlock> {

3252

3253 public:

3255

3256

3258 assert((unsigned)Index < SI->getNumCases() &&

3259 "Index out the number of cases.");

3260 SI->setOperand(2 + Index*2, reinterpret_cast<Value*>(V));

3261 }

3262

3263

3265 SI->setSuccessor(getSuccessorIndex(), S);

3266 }

3267 };

3268

3269 template

3272 std::random_access_iterator_tag,

3273 const CaseHandleT> {

3274 using SwitchInstT = typename CaseHandleT::SwitchInstType;

3275

3276 CaseHandleT Case;

3277

3278 public:

3279

3280

3282

3283

3284

3286

3287

3288

3290 unsigned SuccessorIndex) {

3291 assert(SuccessorIndex < SI->getNumSuccessors() &&

3292 "Successor index # out of range!");

3293 return SuccessorIndex != 0 ? CaseIteratorImpl(SI, SuccessorIndex - 1)

3295 }

3296

3297

3298

3301 }

3302

3304

3305

3306 assert(Case.Index + N >= 0 &&

3307 (unsigned)(Case.Index + N) <= Case.SI->getNumCases() &&

3308 "Case.Index out the number of cases.");

3309 Case.Index += N;

3310 return *this;

3311 }

3313

3314

3315 assert(Case.Index - N >= 0 &&

3316 (unsigned)(Case.Index - N) <= Case.SI->getNumCases() &&

3317 "Case.Index out the number of cases.");

3318 Case.Index -= N;

3319 return *this;

3320 }

3322 assert(Case.SI == RHS.Case.SI && "Incompatible operators.");

3323 return Case.Index - RHS.Case.Index;

3324 }

3326 return Case == RHS.Case;

3327 }

3329 assert(Case.SI == RHS.Case.SI && "Incompatible operators.");

3330 return Case.Index < RHS.Case.Index;

3331 }

3332 const CaseHandleT &operator*() const { return Case; }

3333 };

3334

3337

3339 unsigned NumCases,

3342 }

3343

3344

3346

3347

3350

3352 return cast(getOperand(1));

3353 }

3354

3355

3356

3358 return isa(getDefaultDest()->getFirstNonPHIOrDbg());

3359 }

3360

3362 setOperand(1, reinterpret_cast<Value*>(DefaultCase));

3363 }

3364

3365

3366

3368 return getNumOperands()/2 - 1;

3369 }

3370

3371

3372

3374 return CaseIt(this, 0);

3375 }

3376

3377

3378

3381 }

3382

3383

3384

3386 return CaseIt(this, getNumCases());

3387 }

3388

3389

3390

3392 return ConstCaseIt(this, getNumCases());

3393 }

3394

3395

3397 return make_range(case_begin(), case_end());

3398 }

3399

3400

3402 return make_range(case_begin(), case_end());

3403 }

3404

3405

3406

3407

3408

3409

3411 return CaseIt(this, DefaultPseudoIndex);

3412 }

3414 return ConstCaseIt(this, DefaultPseudoIndex);

3415 }

3416

3417

3418

3419

3420

3423 this,

3424 const_cast<const SwitchInst *>(this)->findCaseValue(C)->getCaseIndex());

3425 }

3429 });

3430 if (I != case_end())

3431 return I;

3432

3433 return case_default();

3434 }

3435

3436

3437

3439 if (BB == getDefaultDest())

3440 return nullptr;

3441

3443 for (auto Case : cases()) {

3444 if (Case.getCaseSuccessor() != BB)

3445 continue;

3446

3447 if (CI)

3448 return nullptr;

3449

3450 CI = Case.getCaseValue();

3451 }

3452

3453 return CI;

3454 }

3455

3456

3457

3458

3459

3461

3462

3463

3464

3465

3466

3467

3468

3469 CaseIt removeCase(CaseIt I);

3470

3473 assert(idx < getNumSuccessors() &&"Successor idx out of range for switch!");

3474 return cast(getOperand(idx*2+1));

3475 }

3477 assert(idx < getNumSuccessors() && "Successor # out of range for switch!");

3478 setOperand(idx * 2 + 1, NewSucc);

3479 }

3480

3481

3483 return I->getOpcode() == Instruction::Switch;

3484 }

3486 return isa(V) && classof(cast(V));

3487 }

3488};

3489

3490

3491

3494 std::optional<SmallVector<uint32_t, 8>> Weights;

3495 bool Changed = false;

3496

3497protected:

3499

3500 void init();

3501

3502public:

3507

3509

3511 if (Changed)

3513 }

3514

3515

3516

3518

3519

3520

3522

3523

3524

3526

3529

3531};

3532

3534

3536

3537

3538

3539

3540

3541

3542

3543

3546

3547 unsigned ReservedSpace;

3548

3549

3550

3552

3553

3554

3555

3556

3559

3560

3561 void *operator new(size_t S) { return User::operator new(S, AllocMarker); }

3562

3563 void init(Value *Address, unsigned NumDests);

3564 void growOperands();

3565

3566protected:

3567

3569

3571

3572public:

3573 void operator delete(void *Ptr) { User::operator delete(Ptr); }

3574

3575

3576

3577

3578

3581 std::random_access_iterator_tag, BasicBlock *,

3582 ptrdiff_t, BasicBlock *, BasicBlock *> {

3584

3587 };

3588

3589

3592 std::random_access_iterator_tag,

3593 const BasicBlock *, ptrdiff_t, const BasicBlock *,

3594 const BasicBlock *> {

3597

3600 };

3601

3605 }

3606

3607

3609

3610

3614

3615

3616

3618

3619

3622

3623

3624

3625 void addDestination(BasicBlock *Dest);

3626

3627

3628

3629 void removeDestination(unsigned i);

3630

3633 return cast(getOperand(i+1));

3634 }

3636 setOperand(i + 1, NewSucc);

3637 }

3638

3642 }

3643

3647 }

3648

3649

3651 return I->getOpcode() == Instruction::IndirectBr;

3652 }

3654 return isa(V) && classof(cast(V));

3655 }

3656};

3657

3658template <>

3660

3662

3663

3664

3665

3666

3667

3668

3669

3671

3672

3673 static constexpr int NumExtraOperands = 2;

3674

3675

3676 static constexpr int NormalDestOpEndIdx = -3;

3677

3678

3679 static constexpr int UnwindDestOpEndIdx = -2;

3680

3682

3683

3684

3685

3690

3694

3695

3696 static unsigned ComputeNumOperands(unsigned NumArgs,

3697 size_t NumBundleInputs = 0) {

3698

3699

3700 return 1 + NumExtraOperands + NumArgs + unsigned(NumBundleInputs);

3701 }

3702

3703protected:

3704

3706

3708

3709public:

3712 const Twine &NameStr,

3715 ComputeNumOperands(unsigned(Args.size()))};

3716 return new (AllocMarker) InvokeInst(Ty, Func, IfNormal, IfException, Args,

3717 {}, AllocMarker, NameStr, InsertBefore);

3718 }

3719

3723 const Twine &NameStr = "",

3725 IntrusiveOperandsAndDescriptorAllocMarker AllocMarker{

3726 ComputeNumOperands(Args.size(), CountBundleInputs(Bundles)),

3727 unsigned(Bundles.size() * sizeof(BundleOpInfo))};

3728

3729 return new (AllocMarker)

3730 InvokeInst(Ty, Func, IfNormal, IfException, Args, Bundles, AllocMarker,

3731 NameStr, InsertBefore);

3732 }

3733

3736 const Twine &NameStr,

3738 return Create(Func.getFunctionType(), Func.getCallee(), IfNormal,

3739 IfException, Args, {}, NameStr, InsertBefore);

3740 }

3741

3745 const Twine &NameStr = "",

3747 return Create(Func.getFunctionType(), Func.getCallee(), IfNormal,

3748 IfException, Args, Bundles, NameStr, InsertBefore);

3749 }

3750

3751

3752

3753

3754

3755

3756

3757 static InvokeInst *Create(InvokeInst *II, ArrayRef Bundles,

3758 InsertPosition InsertPt = nullptr);

3759

3760

3763 }

3766 }

3769 }

3772 }

3773

3774

3775

3777

3779 assert(i < 2 && "Successor # out of range for invoke!");

3780 return i == 0 ? getNormalDest() : getUnwindDest();

3781 }

3782

3784 assert(i < 2 && "Successor # out of range for invoke!");

3785 if (i == 0)

3786 setNormalDest(NewSucc);

3787 else

3788 setUnwindDest(NewSucc);

3789 }

3790

3792

3793

3795

3796

3798 return (I->getOpcode() == Instruction::Invoke);

3799 }

3801 return isa(V) && classof(cast(V));

3802 }

3803

3804private:

3805

3806

3807 template

3808 void setSubclassData(typename Bitfield::Type Value) {

3809 Instruction::setSubclassData(Value);

3810 }

3811};

3812

3813InvokeInst::InvokeInst(FunctionType *Ty, Value *Func, BasicBlock *IfNormal,

3814 BasicBlock *IfException, ArrayRef<Value *> Args,

3815 ArrayRef Bundles, AllocInfo AllocInfo,

3816 const Twine &NameStr, InsertPosition InsertBefore)

3817 : CallBase(Ty->getReturnType(), Instruction::Invoke, AllocInfo,

3818 InsertBefore) {

3819 init(Ty, Func, IfNormal, IfException, Args, Bundles, NameStr);

3820}

3821

3822

3823

3824

3825

3826

3827

3828

3829

3831

3832 unsigned NumIndirectDests;

3833

3835

3836

3837

3838

3844

3848

3849

3850 static unsigned ComputeNumOperands(int NumArgs, int NumIndirectDests,

3851 int NumBundleInputs = 0) {

3852

3853

3854 return unsigned(2 + NumIndirectDests + NumArgs + NumBundleInputs);

3855 }

3856

3857protected:

3858

3860

3862

3863public:

3870 ComputeNumOperands(Args.size(), IndirectDests.size())};

3871 return new (AllocMarker)

3872 CallBrInst(Ty, Func, DefaultDest, IndirectDests, Args, {}, AllocMarker,

3873 NameStr, InsertBefore);

3874 }

3875

3881 IntrusiveOperandsAndDescriptorAllocMarker AllocMarker{

3882 ComputeNumOperands(Args.size(), IndirectDests.size(),

3884 unsigned(Bundles.size() * sizeof(BundleOpInfo))};

3885

3886 return new (AllocMarker)

3887 CallBrInst(Ty, Func, DefaultDest, IndirectDests, Args, Bundles,

3888 AllocMarker, NameStr, InsertBefore);

3889 }

3890

3895 return Create(Func.getFunctionType(), Func.getCallee(), DefaultDest,

3896 IndirectDests, Args, NameStr, InsertBefore);

3897 }

3898

3903 const Twine &NameStr = "",

3905 return Create(Func.getFunctionType(), Func.getCallee(), DefaultDest,

3906 IndirectDests, Args, Bundles, NameStr, InsertBefore);

3907 }

3908

3909

3910

3911

3912

3913

3914

3915 static CallBrInst *Create(CallBrInst *CBI, ArrayRef Bundles,

3916 InsertPosition InsertBefore = nullptr);

3917

3918

3919

3921

3922

3923

3927 }

3928

3932 }

3933

3934

3937 }

3940 }

3945 return IndirectDests;

3946 }

3949 }

3952 }

3953

3956 "Successor # out of range for callbr!");

3958 }

3959

3962 "Successor # out of range for callbr!");

3964 }

3965

3967

3968

3970 return (I->getOpcode() == Instruction::CallBr);

3971 }

3973 return isa(V) && classof(cast(V));

3974 }

3975

3976private:

3977

3978

3979 template

3980 void setSubclassData(typename Bitfield::Type Value) {

3981 Instruction::setSubclassData(Value);

3982 }

3983};

3984

3985CallBrInst::CallBrInst(FunctionType *Ty, Value *Func, BasicBlock *DefaultDest,

3986 ArrayRef<BasicBlock *> IndirectDests,

3987 ArrayRef<Value *> Args,

3988 ArrayRef Bundles, AllocInfo AllocInfo,

3989 const Twine &NameStr, InsertPosition InsertBefore)

3990 : CallBase(Ty->getReturnType(), Instruction::CallBr, AllocInfo,

3991 InsertBefore) {

3992 init(Ty, Func, DefaultDest, IndirectDests, Args, Bundles, NameStr);

3993}

3994

3995

3996

3997

3998

3999

4000

4001

4004

4006

4008

4009protected:

4010

4012

4014

4015public:

4017 return new (AllocMarker) ResumeInst(Exn, InsertBefore);

4018 }

4019

4020

4022

4023

4025

4027

4028

4030 return I->getOpcode() == Instruction::Resume;

4031 }

4033 return isa(V) && classof(cast(V));

4034 }

4035

4036private:

4037 BasicBlock *getSuccessor(unsigned idx) const {

4039 }

4040

4041 void setSuccessor(unsigned idx, BasicBlock *NewSucc) {

4043 }

4044};

4045

4046template <>

4049};

4050

4052

4053

4054

4055

4058

4060

4061

4062

4063 unsigned ReservedSpace;

4064

4065

4066

4067

4069

4070

4071

4072

4073

4075 unsigned NumHandlers, const Twine &NameStr,

4077

4078

4079 void *operator new(size_t S) { return User::operator new(S, AllocMarker); }

4080

4081 void init(Value *ParentPad, BasicBlock *UnwindDest, unsigned NumReserved);

4082 void growOperands(unsigned Size);

4083

4084protected:

4085

4087

4089

4090public:

4091 void operator delete(void *Ptr) { return User::operator delete(Ptr); }

4092

4094 unsigned NumHandlers,

4095 const Twine &NameStr = "",

4097 return new CatchSwitchInst(ParentPad, UnwindDest, NumHandlers, NameStr,

4098 InsertBefore);

4099 }

4100

4101

4103

4104

4107

4108

4109 bool hasUnwindDest() const { return getSubclassData(); }

4112 if (hasUnwindDest())

4113 return cast(getOperand(1));

4114 return nullptr;

4115 }

4118 assert(hasUnwindDest());

4119 setOperand(1, UnwindDest);

4120 }

4121

4122

4123

4125 if (hasUnwindDest())

4126 return getNumOperands() - 2;

4127 return getNumOperands() - 1;

4128 }

4129

4130private:

4131 static BasicBlock *handler_helper(Value *V) { return cast(V); }

4132 static const BasicBlock *handler_helper(const Value *V) {

4133 return cast(V);

4134 }

4135

4136public:

4144

4145

4148 if (hasUnwindDest())

4149 ++It;

4151 }

4152

4153

4154

4157 if (hasUnwindDest())

4158 ++It;

4160 }

4161

4162

4163

4166 }

4167

4168

4169

4172 }

4173

4174

4176 return make_range(handler_begin(), handler_end());

4177 }

4178

4179

4181 return make_range(handler_begin(), handler_end());

4182 }

4183

4184

4185

4186

4187

4189

4190 void removeHandler(handler_iterator HI);

4191

4194 assert(Idx < getNumSuccessors() &&

4195 "Successor # out of range for catchswitch!");

4196 return cast(getOperand(Idx + 1));

4197 }

4199 assert(Idx < getNumSuccessors() &&

4200 "Successor # out of range for catchswitch!");

4201 setOperand(Idx + 1, NewSucc);

4202 }

4203

4204

4206 return I->getOpcode() == Instruction::CatchSwitch;

4207 }

4209 return isa(V) && classof(cast(V));

4210 }

4211};

4212

4213template <>

4215

4217

4218

4219

4220

4222private:

4227 NameStr, InsertBefore) {}

4228

4229public:

4231 const Twine &NameStr = "",

4233 IntrusiveOperandsAllocMarker AllocMarker{unsigned(1 + Args.size())};

4234 return new (AllocMarker)

4235 CleanupPadInst(ParentPad, Args, AllocMarker, NameStr, InsertBefore);

4236 }

4237

4238

4240 return I->getOpcode() == Instruction::CleanupPad;

4241 }

4243 return isa(V) && classof(cast(V));

4244 }

4245};

4246

4247

4248

4249

4251private:

4256 NameStr, InsertBefore) {}

4257

4258public:

4260 const Twine &NameStr = "",

4263 return new (AllocMarker)

4264 CatchPadInst(CatchSwitch, Args, AllocMarker, NameStr, InsertBefore);

4265 }

4266

4267

4269 return cast(Op<-1>());

4270 }

4272 assert(CatchSwitch);

4273 Op<-1>() = CatchSwitch;

4274 }

4275

4276

4278 return I->getOpcode() == Instruction::CatchPad;

4279 }

4281 return isa(V) && classof(cast(V));

4282 }

4283};

4284

4285

4286

4287

4288

4291

4294

4296

4297protected:

4298

4300

4302

4303public:

4308 return new (AllocMarker) CatchReturnInst(CatchPad, BB, InsertBefore);

4309 }

4310

4311

4313

4314

4318 Op<0>() = CatchPad;

4319 }

4320

4324 Op<1>() = NewSucc;

4325 }

4327

4328

4329

4332 }

4333

4334

4336 return (I->getOpcode() == Instruction::CatchRet);

4337 }

4339 return isa(V) && classof(cast(V));

4340 }

4341

4342private:

4346 }

4347

4351 }

4352};

4353

4354template <>

4357

4359

4360

4361

4362

4363

4366

4367private:

4371

4373

4374protected:

4375

4377

4379

4380public:

4385 unsigned Values = 1;

4386 if (UnwindBB)

4387 ++Values;

4389 return new (AllocMarker)

4390 CleanupReturnInst(CleanupPad, UnwindBB, AllocMarker, InsertBefore);

4391 }

4392

4393

4395

4396 bool hasUnwindDest() const { return getSubclassData(); }

4398

4399

4401 return cast(Op<0>());

4402 }

4405 Op<0>() = CleanupPad;

4406 }

4407

4409

4411 return hasUnwindDest() ? cast(Op<1>()) : nullptr;

4412 }

4415 assert(hasUnwindDest());

4416 Op<1>() = NewDest;

4417 }

4418

4419

4421 return (I->getOpcode() == Instruction::CleanupRet);

4422 }

4424 return isa(V) && classof(cast(V));

4425 }

4426

4427private:

4430 return getUnwindDest();

4431 }

4432

4433 void setSuccessor(unsigned Idx, BasicBlock *B) {

4435 setUnwindDest(B);

4436 }

4437

4438

4439

4440 template

4441 void setSubclassData(typename Bitfield::Type Value) {

4442 Instruction::setSubclassData(Value);

4443 }

4444};

4445

4446template <>

4449

4451

4452

4453

4454

4455

4456

4457

4458

4459

4460

4463

4464protected:

4465

4467

4469

4470public:

4473

4474

4475 void *operator new(size_t S) { return User::operator new(S, AllocMarker); }

4476 void operator delete(void *Ptr) { User::operator delete(Ptr); }

4477

4479

4480

4482 return I->getOpcode() == Instruction::Unreachable;

4483 }

4485 return isa(V) && classof(cast(V));

4486 }

4487

4488private:

4489 BasicBlock *getSuccessor(unsigned idx) const {

4491 }

4492

4493 void setSuccessor(unsigned idx, BasicBlock *B) {

4495 }

4496};

4497

4498

4499

4500

4501

4502

4504protected:

4505

4507

4508

4510

4511public:

4513

4514

4516 Type *Ty,

4517 const Twine &NameStr = "",

4519 nullptr

4520 );

4521

4522

4524 return I->getOpcode() == Trunc;

4525 }

4527 return isa(V) && classof(cast(V));

4528 }

4529

4533 }

4537 }

4538

4539

4540

4543 }

4544

4545

4546

4549 }

4550

4551

4553 unsigned NoWrapKind = 0;

4556

4559

4560 return NoWrapKind;

4561 }

4562};

4563

4564

4565

4566

4567

4568

4570protected:

4571

4573

4574

4576

4577public:

4578

4579 ZExtInst(Value *S,

4580 Type *Ty,

4581 const Twine &NameStr = "",

4583 nullptr

4584 );

4585

4586

4588 return I->getOpcode() == ZExt;

4589 }

4591 return isa(V) && classof(cast(V));

4592 }

4593};

4594

4595

4596

4597

4598

4599

4601protected:

4602

4604

4605

4607

4608public:

4609

4610 SExtInst(Value *S,

4611 Type *Ty,

4612 const Twine &NameStr = "",

4614 nullptr

4615 );

4616

4617

4619 return I->getOpcode() == SExt;

4620 }

4622 return isa(V) && classof(cast(V));

4623 }

4624};

4625

4626

4627

4628

4629

4630

4632protected:

4633

4635

4636

4638

4639public:

4641 Type *Ty,

4642 const Twine &NameStr = "",

4644 nullptr

4645 );

4646

4647

4649 return I->getOpcode() == FPTrunc;

4650 }

4652 return isa(V) && classof(cast(V));

4653 }

4654};

4655

4656

4657

4658

4659

4660

4662protected:

4663

4665

4666

4668

4669public:

4670

4672 Type *Ty,

4673 const Twine &NameStr = "",

4675 nullptr

4676 );

4677

4678

4680 return I->getOpcode() == FPExt;

4681 }

4683 return isa(V) && classof(cast(V));

4684 }

4685};

4686

4687

4688

4689

4690

4691

4693protected:

4694

4696

4697

4699

4700public:

4701

4703 Type *Ty,

4704 const Twine &NameStr = "",

4706 nullptr

4707 );

4708

4709

4711 return I->getOpcode() == UIToFP;

4712 }

4714 return isa(V) && classof(cast(V));

4715 }

4716};

4717

4718

4719

4720

4721

4722

4724protected:

4725

4727

4728

4730

4731public:

4732

4734 Type *Ty,

4735 const Twine &NameStr = "",

4737 nullptr

4738 );

4739

4740

4742 return I->getOpcode() == SIToFP;

4743 }

4745 return isa(V) && classof(cast(V));

4746 }

4747};

4748

4749

4750

4751

4752

4753

4755protected:

4756

4758

4759

4761

4762public:

4763

4765 Type *Ty,

4766 const Twine &NameStr = "",

4768 nullptr

4769 );

4770

4771

4773 return I->getOpcode() == FPToUI;

4774 }

4776 return isa(V) && classof(cast(V));

4777 }

4778};

4779

4780

4781

4782

4783

4784

4786protected:

4787

4789

4790

4792

4793public:

4794

4796 Type *Ty,

4797 const Twine &NameStr = "",

4799 nullptr

4800 );

4801

4802

4804 return I->getOpcode() == FPToSI;

4805 }

4807 return isa(V) && classof(cast(V));

4808 }

4809};

4810

4811

4812

4813

4814

4815

4817public:

4818

4820

4821

4823 Type *Ty,

4824 const Twine &NameStr = "",

4826 nullptr

4827 );

4828

4829

4831

4832

4835 }

4836

4837

4839 return I->getOpcode() == IntToPtr;

4840 }

4842 return isa(V) && classof(cast(V));

4843 }

4844};

4845

4846

4847

4848

4849

4850

4852protected:

4853

4855

4856

4858

4859public:

4860

4862 Type *Ty,

4863 const Twine &NameStr = "",

4865 nullptr

4866 );

4867

4868

4870

4872

4874

4875

4878 }

4879

4880

4882 return I->getOpcode() == PtrToInt;

4883 }

4885 return isa(V) && classof(cast(V));

4886 }

4887};

4888

4889

4890

4891

4892

4893

4895protected:

4896

4898

4899

4901

4902public:

4903

4905 Type *Ty,

4906 const Twine &NameStr = "",

4908 nullptr

4909 );

4910

4911

4913 return I->getOpcode() == BitCast;

4914 }

4916 return isa(V) && classof(cast(V));

4917 }

4918};

4919

4920

4921

4922

4923

4924

4925

4927protected:

4928

4930

4931

4933

4934public:

4935

4937 Value *S,

4938 Type *Ty,

4939 const Twine &NameStr = "",

4941 nullptr

4942 );

4943

4944

4946 return I->getOpcode() == AddrSpaceCast;

4947 }

4949 return isa(V) && classof(cast(V));

4950 }

4951

4952

4955 }

4956

4957

4960 }

4961

4962

4964 return 0U;

4965 }

4966

4967

4970 }

4971

4972

4975 }

4976};

4977

4978

4979

4980

4981

4982

4983

4985 if (auto *Load = dyn_cast(V))

4986 return Load->getPointerOperand();

4987 if (auto *Store = dyn_cast(V))

4988 return Store->getPointerOperand();

4989 return nullptr;

4990}

4992 return const_cast<Value *>(

4994}

4995

4996

4997

5000 return Ptr;

5001 if (auto *Gep = dyn_cast(V))

5002 return Gep->getPointerOperand();

5003 return nullptr;

5004}

5007}

5008

5009

5011 assert((isa(I) || isa(I)) &&

5012 "Expected Load or Store instruction");

5013 if (auto *LI = dyn_cast(I))

5014 return LI->getAlign();

5015 return cast(I)->getAlign();

5016}

5017

5018

5020 assert((isa(I) || isa(I)) &&

5021 "Expected Load or Store instruction");

5022 if (auto *LI = dyn_cast(I))

5023 LI->setAlignment(NewAlign);

5024 else

5025 cast(I)->setAlignment(NewAlign);

5026}

5027

5028

5029

5031 assert((isa(I) || isa(I)) &&

5032 "Expected Load or Store instruction");

5033 if (auto *LI = dyn_cast(I))

5034 return LI->getPointerAddressSpace();

5035 return cast(I)->getPointerAddressSpace();

5036}

5037

5038

5040 assert((isa(I) || isa(I)) &&

5041 "Expected Load or Store instruction");

5042 if (auto *LI = dyn_cast(I))

5043 return LI->getType();

5044 return cast(I)->getValueOperand()->getType();

5045}

5046

5047

5048

5050 if (I->isAtomic())

5051 return std::nullopt;

5052 if (auto *AI = dyn_cast(I))

5053 return AI->getSyncScopeID();

5054 if (auto *AI = dyn_cast(I))

5055 return AI->getSyncScopeID();

5056 if (auto *AI = dyn_cast(I))

5057 return AI->getSyncScopeID();

5058 if (auto *AI = dyn_cast(I))

5059 return AI->getSyncScopeID();

5060 if (auto *AI = dyn_cast(I))

5061 return AI->getSyncScopeID();

5063}

5064

5065

5068 if (auto *AI = dyn_cast(I))

5069 AI->setSyncScopeID(SSID);

5070 else if (auto *AI = dyn_cast(I))

5071 AI->setSyncScopeID(SSID);

5072 else if (auto *AI = dyn_cast(I))

5073 AI->setSyncScopeID(SSID);

5074 else if (auto *AI = dyn_cast(I))

5075 AI->setSyncScopeID(SSID);

5076 else if (auto *AI = dyn_cast(I))

5077 AI->setSyncScopeID(SSID);

5078 else

5080}

5081

5082

5083

5084

5085

5086

5087

5089protected:

5090

5092

5093

5095

5096public:

5099

5100

5102 return I->getOpcode() == Freeze;

5103 }

5105 return isa(V) && classof(cast(V));

5106 }

5107};

5108

5109}

5110

5111#endif

static bool isReverseMask(ArrayRef< int > M, EVT VT)

MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL

Atomic ordering constants.

static const Function * getParent(const Value *V)

This file implements methods to test, set and extract typed bits from packed unsigned integers.

static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")

Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx

This file provides various utilities for inspecting and working with the control flow graph in LLVM I...

This defines the Use class.

This file implements a map that provides insertion order iteration.

uint64_t IntrinsicInst * II

#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)

Macro for generating out-of-class operand accessor definitions.

PowerPC Reduce CR logical Operation

StandardInstrumentations SI(Mod->getContext(), Debug, VerifyEach)

const SmallVectorImpl< MachineOperand > & Cond

assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())

This file defines the SmallVector class.

static SymbolRef::Type getType(const Symbol *Sym)

Class for arbitrary precision integers.

This class represents a conversion between pointers from one address space to another.

const Value * getPointerOperand() const

Gets the pointer operand.

AddrSpaceCastInst * cloneImpl() const

Clone an identical AddrSpaceCastInst.

Value * getPointerOperand()

Gets the pointer operand.

static bool classof(const Instruction *I)

static bool classof(const Value *V)

unsigned getSrcAddressSpace() const

Returns the address space of the pointer operand.

unsigned getDestAddressSpace() const

Returns the address space of the result.

static unsigned getPointerOperandIndex()

Gets the operand index of the pointer operand.

an instruction to allocate memory on the stack

std::optional< TypeSize > getAllocationSizeInBits(const DataLayout &DL) const

Get allocation size in bits.

static bool classof(const Value *V)

bool isSwiftError() const

Return true if this alloca is used as a swifterror argument to a call.

void setSwiftError(bool V)

Specify whether this alloca is used to represent a swifterror.

bool isStaticAlloca() const

Return true if this alloca is in the entry block of the function and is a constant size.

Align getAlign() const

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

void setAllocatedType(Type *Ty)

for use only in special circumstances that need to generically transform a whole instruction (eg: IR ...

static bool classof(const Instruction *I)

PointerType * getType() const

Overload to return most specific pointer type.

void setUsedWithInAlloca(bool V)

Specify whether this alloca is used to represent the arguments to a call.

AllocaInst * cloneImpl() const

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.

std::optional< TypeSize > getAllocationSize(const DataLayout &DL) const

Get allocation size in bytes.

bool isArrayAllocation() const

Return true if there is an allocation size parameter to the allocation instruction that is not 1.

void setAlignment(Align Align)

const Value * getArraySize() const

Get the number of elements allocated.

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

size_t size() const

size - Get the array size.

An instruction that atomically checks whether a specified value is in a memory location,...

BoolBitfieldElementT< 0 > VolatileField

const Value * getCompareOperand() const

Value * getNewValOperand()

void setSyncScopeID(SyncScope::ID SSID)

Sets the synchronization scope ID of this cmpxchg instruction.

AtomicOrdering getMergedOrdering() const

Returns a single ordering which is at least as strong as both the success and failure orderings for t...

void setWeak(bool IsWeak)

bool isVolatile() const

Return true if this is a cmpxchg from a volatile memory location.

unsigned getPointerAddressSpace() const

Returns the address space of the pointer operand.

BoolBitfieldElementT< VolatileField::NextBit > WeakField

AtomicOrderingBitfieldElementT< SuccessOrderingField::NextBit > FailureOrderingField

Value * getCompareOperand()

void setFailureOrdering(AtomicOrdering Ordering)

Sets the failure ordering constraint of this cmpxchg instruction.

static bool isValidFailureOrdering(AtomicOrdering Ordering)

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.

AlignmentBitfieldElementT< FailureOrderingField::NextBit > AlignmentField

Value * getPointerOperand()

static AtomicOrdering getStrongestFailureOrdering(AtomicOrdering SuccessOrdering)

Returns the strongest permitted ordering on failure, given the desired ordering on success.

DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)

Transparently provide more efficient getOperand methods.

AtomicCmpXchgInst * cloneImpl() const

Align getAlign() const

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

const Value * getPointerOperand() const

static bool classof(const Value *V)

bool isWeak() const

Return true if this cmpxchg may spuriously fail.

void setAlignment(Align Align)

void setVolatile(bool V)

Specify whether this is a volatile cmpxchg.

static bool isValidSuccessOrdering(AtomicOrdering Ordering)

AtomicOrdering getSuccessOrdering() const

Returns the success ordering constraint of this cmpxchg instruction.

AtomicOrderingBitfieldElementT< WeakField::NextBit > SuccessOrderingField

static unsigned getPointerOperandIndex()

const Value * getNewValOperand() const

SyncScope::ID getSyncScopeID() const

Returns the synchronization scope ID of this cmpxchg instruction.

static bool classof(const Instruction *I)

an instruction that atomically reads a memory location, combines it with another value,...

Align getAlign() const

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

static bool isFPOperation(BinOp Op)

static unsigned getPointerOperandIndex()

bool isVolatile() const

Return true if this is a RMW on a volatile memory location.

void setVolatile(bool V)

Specify whether this is a volatile RMW or not.

BinOpBitfieldElement< AtomicOrderingField::NextBit > OperationField

BinOp

This enumeration lists the possible modifications atomicrmw can make.

@ USubCond

Subtract only if no unsigned overflow.

@ Min

*p = old <signed v ? old : v

@ USubSat

*p = usub.sat(old, v) usub.sat matches the behavior of llvm.usub.sat.

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

AtomicOrderingBitfieldElementT< VolatileField::NextBit > AtomicOrderingField

void setSyncScopeID(SyncScope::ID SSID)

Sets the synchronization scope ID of this rmw instruction.

DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)

Transparently provide more efficient getOperand methods.

Value * getPointerOperand()

void setOrdering(AtomicOrdering Ordering)

Sets the ordering constraint of this rmw instruction.

bool isFloatingPointOperation() const

static bool classof(const Instruction *I)

const Value * getPointerOperand() const

void setOperation(BinOp Operation)

static bool classof(const Value *V)

BinOp getOperation() const

const Value * getValOperand() const

SyncScope::ID getSyncScopeID() const

Returns the synchronization scope ID of this rmw instruction.

void setAlignment(Align Align)

AtomicOrdering getOrdering() const

Returns the ordering constraint of this rmw instruction.

AlignmentBitfieldElementT< OperationField::NextBit > AlignmentField

BoolBitfieldElementT< 0 > VolatileField

unsigned getPointerAddressSpace() const

Returns the address space of the pointer operand.

LLVM Basic Block Representation.

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

static bool classof(const Instruction *I)

static bool classof(const Value *V)

BitCastInst * cloneImpl() const

Clone an identical BitCastInst.

Conditional or Unconditional Branch instruction.

DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)

Transparently provide more efficient getOperand methods.

iterator_range< succ_op_iterator > successors()

static BranchInst * Create(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond, InsertPosition InsertBefore=nullptr)

void setCondition(Value *V)

static bool classof(const Instruction *I)

bool isConditional() const

unsigned getNumSuccessors() const

static bool classof(const Value *V)

static BranchInst * Create(BasicBlock *IfTrue, InsertPosition InsertBefore=nullptr)

BasicBlock * getSuccessor(unsigned i) const

bool isUnconditional() const

void setSuccessor(unsigned idx, BasicBlock *NewSucc)

Value * getCondition() const

iterator_range< const_succ_op_iterator > successors() const

Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...

void addFnAttr(Attribute::AttrKind Kind)

Adds the attribute to the function.

bool hasFnAttr(Attribute::AttrKind Kind) const

Determine whether this call has the given attribute.

Intrinsic::ID getIntrinsicID() const

Returns the intrinsic ID of the intrinsic called or Intrinsic::not_intrinsic if the called function i...

static unsigned CountBundleInputs(ArrayRef< OperandBundleDef > Bundles)

Return the total number of values used in Bundles.

unsigned arg_size() const

unsigned getNumTotalBundleOperands() const

Return the total number operands (not operand bundles) used by every operand bundle in this OperandBu...

CallBr instruction, tracking function calls that may not return control but instead transfer it to a ...

static bool classof(const Value *V)

static CallBrInst * Create(FunctionType *Ty, Value *Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)

static bool classof(const Instruction *I)

static CallBrInst * Create(FunctionCallee Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)

SmallVector< BasicBlock *, 16 > getIndirectDests() const

static CallBrInst * Create(FunctionCallee Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)

void setSuccessor(unsigned i, BasicBlock *NewSucc)

BasicBlock * getSuccessor(unsigned i) const

Value * getIndirectDestLabelUse(unsigned i) const

BasicBlock * getIndirectDest(unsigned i) const

void setDefaultDest(BasicBlock *B)

unsigned getNumSuccessors() const

void setIndirectDest(unsigned i, BasicBlock *B)

Value * getIndirectDestLabel(unsigned i) const

getIndirectDestLabel - Return the i-th indirect dest label.

BasicBlock * getDefaultDest() const

unsigned getNumIndirectDests() const

Return the number of callbr indirect dest labels.

static CallBrInst * Create(FunctionType *Ty, Value *Func, BasicBlock *DefaultDest, ArrayRef< BasicBlock * > IndirectDests, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)

CallBrInst * cloneImpl() const

This class represents a function call, abstracting a target machine's calling convention.

bool isNoTailCall() const

void updateProfWeight(uint64_t S, uint64_t T)

Updates profile metadata by scaling it by S / T.

static bool classof(const Value *V)

void setTailCallKind(TailCallKind TCK)

static CallInst * Create(FunctionType *Ty, Value *Func, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)

static CallInst * Create(FunctionType *Ty, Value *Func, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)

bool canReturnTwice() const

Return true if the call can return twice.

TailCallKind getTailCallKind() const

CallInst * cloneImpl() const

static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)

void setTailCall(bool IsTc=true)

bool isMustTailCall() const

static CallInst * Create(FunctionCallee Func, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)

static bool classof(const Instruction *I)

bool isNonContinuableTrap() const

Return true if the call is for a noreturn trap intrinsic.

static CallInst * Create(FunctionCallee Func, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)

static CallInst * Create(FunctionCallee Func, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)

This is the base class for all instructions that perform data casts.

CatchSwitchInst * getCatchSwitch() const

Convenience accessors.

void setCatchSwitch(Value *CatchSwitch)

static bool classof(const Instruction *I)

Methods for support type inquiry through isa, cast, and dyn_cast:

static CatchPadInst * Create(Value *CatchSwitch, ArrayRef< Value * > Args, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)

static bool classof(const Value *V)

static bool classof(const Instruction *I)

BasicBlock * getSuccessor() const

CatchPadInst * getCatchPad() const

Convenience accessors.

void setSuccessor(BasicBlock *NewSucc)

static bool classof(const Value *V)

static CatchReturnInst * Create(Value *CatchPad, BasicBlock *BB, InsertPosition InsertBefore=nullptr)

unsigned getNumSuccessors() const

DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)

Provide fast operand accessors.

void setCatchPad(CatchPadInst *CatchPad)

CatchReturnInst * cloneImpl() const

Value * getCatchSwitchParentPad() const

Get the parentPad of this catchret's catchpad's catchswitch.

void setUnwindDest(BasicBlock *UnwindDest)

static bool classof(const Instruction *I)

BasicBlock *(*)(Value *) DerefFnTy

const BasicBlock *(*)(const Value *) ConstDerefFnTy

unsigned getNumSuccessors() const

const_handler_iterator handler_begin() const

Returns an iterator that points to the first handler in the CatchSwitchInst.

unsigned getNumHandlers() const

return the number of 'handlers' in this catchswitch instruction, except the default handler

void setSuccessor(unsigned Idx, BasicBlock *NewSucc)

Value * getParentPad() const

void setParentPad(Value *ParentPad)

bool unwindsToCaller() const

static bool classof(const Value *V)

handler_iterator handler_end()

Returns a read-only iterator that points one past the last handler in the CatchSwitchInst.

BasicBlock * getUnwindDest() const

BasicBlock * getSuccessor(unsigned Idx) const

const_handler_iterator handler_end() const

Returns an iterator that points one past the last handler in the CatchSwitchInst.

bool hasUnwindDest() const

handler_iterator handler_begin()

Returns an iterator that points to the first handler in CatchSwitchInst.

static CatchSwitchInst * Create(Value *ParentPad, BasicBlock *UnwindDest, unsigned NumHandlers, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)

handler_range handlers()

iteration adapter for range-for loops.

const_handler_range handlers() const

iteration adapter for range-for loops.

DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)

Provide fast operand accessors.

static bool classof(const Value *V)

static bool classof(const Instruction *I)

Methods for support type inquiry through isa, cast, and dyn_cast:

static CleanupPadInst * Create(Value *ParentPad, ArrayRef< Value * > Args={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)

static bool classof(const Instruction *I)

CleanupPadInst * getCleanupPad() const

Convenience accessor.

unsigned getNumSuccessors() const

BasicBlock * getUnwindDest() const

bool unwindsToCaller() const

void setCleanupPad(CleanupPadInst *CleanupPad)

static bool classof(const Value *V)

void setUnwindDest(BasicBlock *NewDest)

static CleanupReturnInst * Create(Value *CleanupPad, BasicBlock *UnwindBB=nullptr, InsertPosition InsertBefore=nullptr)

bool hasUnwindDest() const

DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)

Provide fast operand accessors.

This class is the base class for the comparison instructions.

static Type * makeCmpResultType(Type *opnd_type)

Create a result type for fcmp/icmp.

void setPredicate(Predicate P)

Set the predicate for this instruction to the specified value.

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)

@ FCMP_ONE

0 1 1 0 True if ordered and operands are unequal

@ FCMP_UEQ

1 0 0 1 True if unordered or equal

@ FCMP_ORD

0 1 1 1 True if ordered (no nans)

@ FCMP_UNE

1 1 1 0 True if unordered or not equal

@ FCMP_FALSE

0 0 0 0 Always false (always folded)

@ FCMP_UNO

1 0 0 0 True if unordered: isnan(X) | isnan(Y)

Predicate getSwappedPredicate() const

For example, EQ->EQ, SLE->SGE, ULT->UGT, OEQ->OEQ, ULE->UGE, OLT->OGT, etc.

static auto FCmpPredicates()

Returns the sequence of all FCmp predicates.

bool isFPPredicate() const

Predicate getPredicate() const

Return the predicate for this instruction.

An abstraction over a floating-point predicate, and a pack of an integer predicate with samesign info...

bool hasSameSign() const

Query samesign information, for optimizations.

This is the shared class of boolean and integer constants.

This is an important base class in LLVM.

This class represents an Operation in the Expression.

A parsed version of the target data layout string in and methods for querying it.

This instruction compares its operands according to the predicate given to the constructor.

bool isRelational() const

FCmpInst(Predicate Pred, Value *LHS, Value *RHS, const Twine &NameStr="", Instruction *FlagsSource=nullptr)

Constructor with no-insertion semantics.

static bool classof(const Value *V)

bool isCommutative() const

static bool isCommutative(Predicate Pred)

static bool compare(const APFloat &LHS, const APFloat &RHS, FCmpInst::Predicate Pred)

Return result of LHS Pred RHS comparison.

static bool isEquality(Predicate Pred)

static bool classof(const Instruction *I)

Methods for support type inquiry through isa, cast, and dyn_cast:

static auto predicates()

Returns the sequence of all FCmp predicates.

FCmpInst * cloneImpl() const

Clone an identical FCmpInst.

void swapOperands()

Exchange the two operands to this instruction in such a way that it does not modify the semantics of ...

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.

static bool classof(const Value *V)

FPExtInst * cloneImpl() const

Clone an identical FPExtInst.

static bool classof(const Instruction *I)

Methods for support type inquiry through isa, cast, and dyn_cast:

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

static bool classof(const Value *V)

FPToSIInst * cloneImpl() const

Clone an identical FPToSIInst.

static bool classof(const Instruction *I)

Methods for support type inquiry through isa, cast, and dyn_cast:

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

static bool classof(const Value *V)

static bool classof(const Instruction *I)

Methods for support type inquiry through isa, cast, and dyn_cast:

FPToUIInst * cloneImpl() const

Clone an identical FPToUIInst.

This class represents a truncation of floating point types.

static bool classof(const Instruction *I)

Methods for support type inquiry through isa, cast, and dyn_cast:

static bool classof(const Value *V)

FPTruncInst * cloneImpl() const

Clone an identical FPTruncInst.

An instruction for ordering other memory operations.

static bool classof(const Value *V)

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.

static bool classof(const Instruction *I)

void setOrdering(AtomicOrdering Ordering)

Sets the ordering constraint of this fence instruction.

AtomicOrdering getOrdering() const

Returns the ordering constraint of this fence instruction.

This class represents a freeze function that returns random concrete value if an operand is either a ...

static bool classof(const Value *V)

FreezeInst * cloneImpl() const

Clone an identical FreezeInst.

static bool classof(const Instruction *I)

friend class CatchPadInst

A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...

Class to represent function types.

Represents flags for the getelementptr instruction/expression.

static GEPNoWrapFlags inBounds()

an instruction for type-safe pointer arithmetic to access elements of arrays and structs

bool isInBounds() const

Determine whether the GEP has the inbounds flag.

bool hasNoUnsignedSignedWrap() const

Determine whether the GEP has the nusw flag.

static Type * getTypeAtIndex(Type *Ty, Value *Idx)

Return the type of the element at the given index of an indexable type.

Value * getPointerOperand()

bool hasAllZeroIndices() const

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

static Type * getGEPReturnType(Value *Ptr, ArrayRef< Value * > IdxList)

Returns the pointer type returned by the GEP instruction, which may be a vector of pointers.

DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)

Transparently provide more efficient getOperand methods.

void setResultElementType(Type *Ty)

bool hasNoUnsignedWrap() const

Determine whether the GEP has the nuw flag.

bool hasAllConstantIndices() const

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

unsigned getAddressSpace() const

Returns the address space of this instruction's pointer type.

iterator_range< const_op_iterator > indices() const

Type * getResultElementType() const

static bool classof(const Instruction *I)

static bool classof(const Value *V)

iterator_range< op_iterator > indices()

static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)

void setIsInBounds(bool b=true)

Set or clear the inbounds flag on this GEP instruction.

void setSourceElementType(Type *Ty)

static Type * getIndexedType(Type *Ty, ArrayRef< Value * > IdxList)

Returns the result type of a getelementptr with the given source element type and indexes.

Type * getSourceElementType() const

static GetElementPtrInst * CreateInBounds(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)

Create an "inbounds" getelementptr.

Type * getPointerOperandType() const

Method to return the pointer operand as a PointerType.

static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, GEPNoWrapFlags NW, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)

static unsigned getPointerOperandIndex()

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

Accumulate the constant address offset of this GEP if possible.

const_op_iterator idx_begin() const

GetElementPtrInst * cloneImpl() const

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

void setNoWrapFlags(GEPNoWrapFlags NW)

Set nowrap flags for GEP instruction.

unsigned getNumIndices() const

GEPNoWrapFlags getNoWrapFlags() const

Get the nowrap flags for the GEP instruction.

const_op_iterator idx_end() const

const Value * getPointerOperand() const

unsigned getPointerAddressSpace() const

Returns the address space of the pointer operand.

This instruction compares its operands according to the predicate given to the constructor.

bool hasSameSign() const

An icmp instruction, which can be marked as "samesign", indicating that the two operands have the sam...

static bool classof(const Value *V)

void setSameSign(bool B=true)

ICmpInst(InsertPosition InsertBefore, Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")

Constructor with insertion semantics.

static bool isCommutative(Predicate P)

static CmpPredicate getSwappedCmpPredicate(CmpPredicate Pred)

CmpPredicate getCmpPredicate() const

bool isCommutative() const

static bool isGE(Predicate P)

Return true if the predicate is SGE or UGE.

CmpPredicate getSwappedCmpPredicate() const

static bool isLT(Predicate P)

Return true if the predicate is SLT or ULT.

CmpPredicate getInverseCmpPredicate() const

static bool isGT(Predicate P)

Return true if the predicate is SGT or UGT.

static bool classof(const Instruction *I)

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 bool isEquality(Predicate P)

Return true if this predicate is either EQ or NE.

static bool isRelational(Predicate P)

Return true if the predicate is relational (not EQ or NE).

void swapOperands()

Exchange the two operands to this instruction in such a way that it does not modify the semantics of ...

static auto predicates()

Returns the sequence of all ICmp predicates.

ICmpInst(Predicate pred, Value *LHS, Value *RHS, const Twine &NameStr="")

Constructor with no-insertion semantics.

bool isRelational() const

Return true if the predicate is relational (not EQ or NE).

Predicate getUnsignedPredicate() const

For example, EQ->EQ, SLE->ULE, UGT->UGT, etc.

static bool isLE(Predicate P)

Return true if the predicate is SLE or ULE.

Indirect Branch Instruction.

static IndirectBrInst * Create(Value *Address, unsigned NumDests, InsertPosition InsertBefore=nullptr)

BasicBlock * getDestination(unsigned i)

Return the specified destination.

static bool classof(const Value *V)

const Value * getAddress() const

static bool classof(const Instruction *I)

BasicBlock * getSuccessor(unsigned i) const

iterator_range< const_succ_op_iterator > successors() const

DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)

Provide fast operand accessors.

unsigned getNumDestinations() const

return the number of possible destinations in this indirectbr instruction.

const BasicBlock * getDestination(unsigned i) const

void setSuccessor(unsigned i, BasicBlock *NewSucc)

void setAddress(Value *V)

unsigned getNumSuccessors() const

iterator_range< succ_op_iterator > successors()

This instruction inserts a single (scalar) element into a VectorType value.

static bool classof(const Value *V)

static InsertElementInst * Create(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)

VectorType * getType() const

Overload to return most specific vector type.

static bool classof(const Instruction *I)

DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)

Transparently provide more efficient getOperand methods.

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

Value * getInsertedValueOperand()

static bool classof(const Instruction *I)

static unsigned getAggregateOperandIndex()

Value * getAggregateOperand()

static bool classof(const Value *V)

unsigned getNumIndices() const

ArrayRef< unsigned > getIndices() const

iterator_range< idx_iterator > indices() const

static unsigned getInsertedValueOperandIndex()

InsertValueInst * cloneImpl() const

idx_iterator idx_end() const

static InsertValueInst * Create(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)

DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)

Transparently provide more efficient getOperand methods.

const Value * getAggregateOperand() const

const Value * getInsertedValueOperand() const

idx_iterator idx_begin() const

typename Bitfield::Element< AtomicOrdering, Offset, 3, AtomicOrdering::LAST > AtomicOrderingBitfieldElementT

typename Bitfield::Element< bool, Offset, 1 > BoolBitfieldElementT

bool isAtomic() const LLVM_READONLY

Return true if this instruction has an AtomicOrdering of unordered or higher.

typename Bitfield::Element< unsigned, Offset, 6, Value::MaxAlignmentExponent > AlignmentBitfieldElementT

unsigned getOpcode() const

Returns a member of one of the enums like Instruction::Add.

void copyMetadata(const Instruction &SrcInst, ArrayRef< unsigned > WL=ArrayRef< unsigned >())

Copy metadata from SrcInst to this instruction.

friend class BasicBlock

Various leaf nodes.

This class represents a cast from an integer to a pointer.

static bool classof(const Instruction *I)

IntToPtrInst * cloneImpl() const

Clone an identical IntToPtrInst.

unsigned getAddressSpace() const

Returns the address space of this instruction's pointer type.

static bool classof(const Value *V)

static bool classof(const Instruction *I)

BasicBlock * getUnwindDest() const

void setNormalDest(BasicBlock *B)

static bool classof(const Value *V)

static InvokeInst * Create(FunctionCallee Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)

void setSuccessor(unsigned i, BasicBlock *NewSucc)

static InvokeInst * Create(FunctionCallee Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)

BasicBlock * getSuccessor(unsigned i) const

void setUnwindDest(BasicBlock *B)

BasicBlock * getNormalDest() const

static InvokeInst * Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles={}, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)

unsigned getNumSuccessors() const

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.

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.

unsigned getNumClauses() const

Get the number of clauses for this landing pad.

DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)

Provide fast operand accessors.

bool isCatch(unsigned Idx) const

Return 'true' if the clause and index Idx is a catch clause.

bool isFilter(unsigned Idx) const

Return 'true' if the clause and index Idx is a filter clause.

Constant * getClause(unsigned Idx) const

Get the value of the clause at index Idx.

static bool classof(const Value *V)

void setCleanup(bool V)

Indicate that this landingpad instruction is a cleanup.

void reserveClauses(unsigned Size)

Grow the size of the operand list to accommodate the new number of clauses.

static bool classof(const Instruction *I)

An instruction for reading from memory.

unsigned getPointerAddressSpace() const

Returns the address space of the pointer operand.

const Value * getPointerOperand() const

void setAlignment(Align Align)

Value * getPointerOperand()

bool isVolatile() const

Return true if this is a load from a volatile memory location.

static bool classof(const Instruction *I)

void setOrdering(AtomicOrdering Ordering)

Sets the ordering constraint of this load instruction.

static bool classof(const Value *V)

void setSyncScopeID(SyncScope::ID SSID)

Sets the synchronization scope ID of this load instruction.

void setAtomic(AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System)

Sets the ordering constraint and the synchronization scope ID of this load instruction.

LoadInst * cloneImpl() const

AtomicOrdering getOrdering() const

Returns the ordering constraint of this load instruction.

Type * getPointerOperandType() const

static unsigned getPointerOperandIndex()

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.

Align getAlign() const

Return the alignment of the access that is being performed.

MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...

BasicBlock * getIncomingBlock(Value::const_user_iterator I) const

Return incoming basic block corresponding to value use iterator.

static bool classof(const Instruction *I)

Methods for support type inquiry through isa, cast, and dyn_cast:

void addIncoming(Value *V, BasicBlock *BB)

Add an incoming value to the end of the PHI list.

bool isComplete() const

If the PHI node is complete which means all of its parent's predecessors have incoming value in this ...

iterator_range< const_block_iterator > blocks() const

op_range incoming_values()

static bool classof(const Value *V)

void allocHungoffUses(unsigned N)

const_block_iterator block_begin() const

void setIncomingValueForBlock(const BasicBlock *BB, Value *V)

Set every incoming value(s) for block BB to V.

void setIncomingBlock(unsigned i, BasicBlock *BB)

BasicBlock *const * const_block_iterator

void setIncomingValue(unsigned i, Value *V)

static unsigned getOperandNumForIncomingValue(unsigned i)

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 * getIncomingValueForBlock(const BasicBlock *BB) const

BasicBlock * getIncomingBlock(unsigned i) const

Return incoming basic block number i.

DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)

Provide fast operand accessors.

Value * getIncomingValue(unsigned i) const

Return incoming value number x.

static unsigned getIncomingValueNumForOperand(unsigned i)

const_op_range incoming_values() const

Value * removeIncomingValue(const BasicBlock *BB, bool DeletePHIIfEmpty=true)

void replaceIncomingBlockWith(const BasicBlock *Old, BasicBlock *New)

Replace every incoming basic block Old to basic block New.

BasicBlock * getIncomingBlock(const Use &U) const

Return incoming basic block corresponding to an operand of the PHI.

int getBasicBlockIndex(const BasicBlock *BB) const

Return the first index of the specified basic block in the value list for this PHI.

unsigned getNumIncomingValues() const

Return the number of incoming edges.

static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)

Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...

Class to represent pointers.

unsigned getAddressSpace() const

Return the address space of the Pointer type.

This class represents a cast from a pointer to an integer.

Value * getPointerOperand()

Gets the pointer operand.

unsigned getPointerAddressSpace() const

Returns the address space of the pointer operand.

static bool classof(const Value *V)

const Value * getPointerOperand() const

Gets the pointer operand.

static unsigned getPointerOperandIndex()

Gets the operand index of the pointer operand.

static bool classof(const Instruction *I)

PtrToIntInst * cloneImpl() const

Clone an identical PtrToIntInst.

Resume the propagation of an exception.

static ResumeInst * Create(Value *Exn, InsertPosition InsertBefore=nullptr)

DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)

Provide fast operand accessors.

Value * getValue() const

Convenience accessor.

static bool classof(const Value *V)

unsigned getNumSuccessors() const

ResumeInst * cloneImpl() const

static bool classof(const Instruction *I)

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

DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)

Provide fast operand accessors.

unsigned getNumSuccessors() const

static bool classof(const Value *V)

static bool classof(const Instruction *I)

static ReturnInst * Create(LLVMContext &C, BasicBlock *InsertAtEnd)

Value * getReturnValue() const

Convenience accessor. Returns null if there is no return value.

static ReturnInst * Create(LLVMContext &C, Value *retVal=nullptr, InsertPosition InsertBefore=nullptr)

This class represents a sign extension of integer types.

static bool classof(const Value *V)

static bool classof(const Instruction *I)

Methods for support type inquiry through isa, cast, and dyn_cast:

SExtInst * cloneImpl() const

Clone an identical SExtInst.

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

SIToFPInst * cloneImpl() const

Clone an identical SIToFPInst.

static bool classof(const Instruction *I)

Methods for support type inquiry through isa, cast, and dyn_cast:

static bool classof(const Value *V)

This class represents the LLVM 'select' instruction.

static SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr="", InsertPosition InsertBefore=nullptr, Instruction *MDFrom=nullptr)

void setFalseValue(Value *V)

const Value * getFalseValue() const

void setTrueValue(Value *V)

OtherOps getOpcode() const

void swapValues()

Swap the true and false values of the select instruction.

const Value * getCondition() const

SelectInst * cloneImpl() const

DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)

Transparently provide more efficient getOperand methods.

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

static bool classof(const Value *V)

void setCondition(Value *V)

const Value * getTrueValue() const

static bool classof(const Instruction *I)

This instruction constructs a fixed permutation of two input vectors.

static bool classof(const Value *V)

static bool isInterleaveMask(ArrayRef< int > Mask, unsigned Factor, unsigned NumInputElts)

Constant * getShuffleMaskForBitcode() const

Return the mask for this instruction, for use in bitcode.

bool isSingleSource() const

Return true if this shuffle chooses elements from exactly one source vector without changing the leng...

bool changesLength() const

Return true if this shuffle returns a vector with a different number of elements than its source vect...

bool isExtractSubvectorMask(int &Index) const

Return true if this shuffle mask is an extract subvector mask.

ArrayRef< int > getShuffleMask() const

static bool isInsertSubvectorMask(const Constant *Mask, int NumSrcElts, int &NumSubElts, int &Index)

static bool isSingleSourceMask(const Constant *Mask, int NumSrcElts)

int getMaskValue(unsigned Elt) const

Return the shuffle mask value of this instruction for the given element index.

void getShuffleMask(SmallVectorImpl< int > &Result) const

Return the mask for this instruction as a vector of integers.

DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)

Transparently provide more efficient getOperand methods.

static bool isDeInterleaveMaskOfFactor(ArrayRef< int > Mask, unsigned Factor)

VectorType * getType() const

Overload to return most specific vector type.

bool isInsertSubvectorMask(int &NumSubElts, int &Index) const

Return true if this shuffle mask is an insert subvector mask.

bool increasesLength() const

Return true if this shuffle returns a vector with a greater number of elements than its source vector...

bool isZeroEltSplat() const

Return true if all elements of this shuffle are the same value as the first element of exactly one so...

static bool isExtractSubvectorMask(const Constant *Mask, int NumSrcElts, int &Index)

bool isSelect() const

Return true if this shuffle chooses elements from its source vectors without lane crossings and all o...

static bool isSpliceMask(const Constant *Mask, int NumSrcElts, int &Index)

bool isTranspose() const

Return true if this shuffle transposes the elements of its inputs without changing the length of the ...

static void commuteShuffleMask(MutableArrayRef< int > Mask, unsigned InVecNumElts)

Change values in a shuffle permute mask assuming the two vector operands of length InVecNumElts have ...

bool isSplice(int &Index) const

Return true if this shuffle splices two inputs without changing the length of the vectors.

static bool isReverseMask(const Constant *Mask, int NumSrcElts)

static bool isSelectMask(const Constant *Mask, int NumSrcElts)

static bool classof(const Instruction *I)

static bool isZeroEltSplatMask(const Constant *Mask, int NumSrcElts)

bool isIdentity() const

Return true if this shuffle chooses elements from exactly one source vector without lane crossings an...

static bool isReplicationMask(const Constant *Mask, int &ReplicationFactor, int &VF)

static bool isIdentityMask(const Constant *Mask, int NumSrcElts)

static bool isTransposeMask(const Constant *Mask, int NumSrcElts)

bool isReverse() const

Return true if this shuffle swaps the order of elements from exactly one source vector.

This class consists of common code factored out of the SmallVector class to reduce code duplication b...

void push_back(const T &Elt)

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

An instruction for storing to memory.

static bool classof(const Instruction *I)

AtomicOrdering getOrdering() const

Returns the ordering constraint of this store instruction.

const Value * getPointerOperand() const

Type * getPointerOperandType() const

void setVolatile(bool V)

Specify whether this is a volatile store or not.

void setAlignment(Align Align)

const Value * getValueOperand() const

void setOrdering(AtomicOrdering Ordering)

Sets the ordering constraint of this store instruction.

Value * getValueOperand()

static bool classof(const Value *V)

DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)

Transparently provide more efficient getOperand methods.

void setSyncScopeID(SyncScope::ID SSID)

Sets the synchronization scope ID of this store instruction.

StoreInst * cloneImpl() const

unsigned getPointerAddressSpace() const

Returns the address space of the pointer operand.

static unsigned getPointerOperandIndex()

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.

Value * getPointerOperand()

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.

A wrapper class to simplify modification of SwitchInst cases along with their prof branch_weights met...

void setSuccessorWeight(unsigned idx, CaseWeightOpt W)

Instruction::InstListType::iterator eraseFromParent()

Delegate the call to the underlying SwitchInst::eraseFromParent() and mark this object to not touch t...

void addCase(ConstantInt *OnVal, BasicBlock *Dest, CaseWeightOpt W)

Delegate the call to the underlying SwitchInst::addCase() and set the specified branch weight for the...

SwitchInstProfUpdateWrapper(SwitchInst &SI)

~SwitchInstProfUpdateWrapper()

CaseWeightOpt getSuccessorWeight(unsigned idx)

MDNode * buildProfBranchWeightsMD()

std::optional< uint32_t > CaseWeightOpt

SwitchInst * operator->()

SwitchInst::CaseIt removeCase(SwitchInst::CaseIt I)

Delegate the call to the underlying SwitchInst::removeCase() and remove correspondent branch weight.

A handle to a particular switch case.

unsigned getCaseIndex() const

Returns number of current case.

unsigned getSuccessorIndex() const

Returns successor index for current case successor.

BasicBlockT * getCaseSuccessor() const

Resolves successor for current case.

CaseHandleImpl(SwitchInstT *SI, ptrdiff_t Index)

bool operator==(const CaseHandleImpl &RHS) const

ConstantIntT * getCaseValue() const

Resolves case value for current case.

SwitchInstT SwitchInstType

CaseHandle(SwitchInst *SI, ptrdiff_t Index)

void setValue(ConstantInt *V) const

Sets the new value for current case.

void setSuccessor(BasicBlock *S) const

Sets the new successor for current case.

const CaseHandleT & operator*() const

CaseIteratorImpl()=default

Default constructed iterator is in an invalid state until assigned to a case for a particular switch.

CaseIteratorImpl & operator-=(ptrdiff_t N)

bool operator==(const CaseIteratorImpl &RHS) const

CaseIteratorImpl & operator+=(ptrdiff_t N)

ptrdiff_t operator-(const CaseIteratorImpl &RHS) const

bool operator<(const CaseIteratorImpl &RHS) const

CaseIteratorImpl(SwitchInstT *SI, unsigned CaseNum)

Initializes case iterator for given SwitchInst and for given case number.

static CaseIteratorImpl fromSuccessorIndex(SwitchInstT *SI, unsigned SuccessorIndex)

Initializes case iterator for given SwitchInst and for given successor index.

BasicBlock * getDefaultDest() const

CaseIt case_end()

Returns a read/write iterator that points one past the last in the SwitchInst.

BasicBlock * getSuccessor(unsigned idx) const

ConstCaseIt findCaseValue(const ConstantInt *C) const

DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)

Provide fast operand accessors.

static SwitchInst * Create(Value *Value, BasicBlock *Default, unsigned NumCases, InsertPosition InsertBefore=nullptr)

void setCondition(Value *V)

ConstCaseIt case_begin() const

Returns a read-only iterator that points to the first case in the SwitchInst.

bool defaultDestUndefined() const

Returns true if the default branch must result in immediate undefined behavior, false otherwise.

iterator_range< ConstCaseIt > cases() const

Constant iteration adapter for range-for loops.

ConstantInt * findCaseDest(BasicBlock *BB)

Finds the unique case value for a given successor.

void setSuccessor(unsigned idx, BasicBlock *NewSucc)

static bool classof(const Value *V)

unsigned getNumSuccessors() const

CaseIt case_default()

Returns an iterator that points to the default case.

void setDefaultDest(BasicBlock *DefaultCase)

unsigned getNumCases() const

Return the number of 'cases' in this switch instruction, excluding the default case.

CaseIt findCaseValue(const ConstantInt *C)

Search all of the case values for the specified constant.

Value * getCondition() const

ConstCaseIt case_default() const

CaseIt case_begin()

Returns a read/write iterator that points to the first case in the SwitchInst.

static bool classof(const Instruction *I)

iterator_range< CaseIt > cases()

Iteration adapter for range-for loops.

ConstCaseIt case_end() const

Returns a read-only iterator that points one past the last in the SwitchInst.

This class represents a truncation of integer types.

void setHasNoSignedWrap(bool B)

static bool classof(const Instruction *I)

Methods for support type inquiry through isa, cast, and dyn_cast:

TruncInst * cloneImpl() const

Clone an identical TruncInst.

void setHasNoUnsignedWrap(bool B)

unsigned getNoWrapKind() const

Returns the no-wrap kind of the operation.

bool hasNoSignedWrap() const

Test whether this operation is known to never undergo signed overflow, aka the nsw property.

static bool classof(const Value *V)

bool hasNoUnsignedWrap() const

Test whether this operation is known to never undergo unsigned overflow, aka the nuw property.

Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...

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.

unsigned getPointerAddressSpace() const

Get the address space of this pointer or pointer vector type.

bool isTokenTy() const

Return true if this is 'token'.

This class represents a cast unsigned integer to floating point.

static bool classof(const Value *V)

UIToFPInst * cloneImpl() const

Clone an identical UIToFPInst.

static bool classof(const Instruction *I)

Methods for support type inquiry through isa, cast, and dyn_cast:

This function has undefined behavior.

unsigned getNumSuccessors() const

static bool classof(const Value *V)

static bool classof(const Instruction *I)

A Use represents the edge between a Value definition and its users.

void allocHungoffUses(unsigned N, bool IsPhi=false)

Allocate the array of Uses, followed by a pointer (with bottom bit set) to the User.

const Use & getOperandUse(unsigned i) const

Value * getOperand(unsigned i) const

unsigned getNumOperands() const

This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...

static bool classof(const Instruction *I)

Value * getPointerOperand()

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

const Value * getPointerOperand() const

static bool classof(const Value *V)

static unsigned getPointerOperandIndex()

LLVM Value Representation.

Type * getType() const

All values are typed, get the type of this value.

user_iterator_impl< const User > const_user_iterator

unsigned char SubclassOptionalData

Hold subclass data that can be dropped.

void setName(const Twine &Name)

Change the name of the value.

Base class of all SIMD vector types.

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

static bool classof(const Instruction *I)

Methods for support type inquiry through isa, cast, and dyn_cast:

static bool classof(const Value *V)

ZExtInst * cloneImpl() const

Clone an identical ZExtInst.

An efficient, type-erasing, non-owning reference to a callable.

base_list_type::iterator iterator

CRTP base class for adapting an iterator to a different type.

CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...

A range adaptor for a pair of iterators.

This provides a very simple, boring adaptor for a begin and end iterator into a range type.

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

constexpr char Args[]

Key for Kernel::Metadata::mArgs.

@ C

The default llvm calling convention, compatible with C.

@ BasicBlock

Various leaf nodes.

@ System

Synchronized with respect to all concurrently executing threads.

initializer< Ty > init(const Ty &Val)

This is an optimization pass for GlobalISel generic memory operations.

Type * checkGEPType(Type *Ty)

bool all_of(R &&range, UnaryPredicate P)

Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.

unsigned getLoadStoreAddressSpace(const Value *I)

A helper function that returns the address space of the pointer operand of load or store instruction.

APInt operator*(APInt a, uint64_t RHS)

const Value * getLoadStorePointerOperand(const Value *V)

A helper function that returns the pointer operand of a load or store instruction.

iterator_range< T > make_range(T x, T y)

Convenience function for iterating over sub-ranges.

void setAtomicSyncScopeID(Instruction *I, SyncScope::ID SSID)

A helper function that sets an atomic operation's sync scope.

Align getLoadStoreAlignment(const Value *I)

A helper function that returns the alignment of load or store instruction.

const Value * getPointerOperand(const Value *V)

A helper function that returns the pointer operand of a load, store or GEP instruction.

decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)

std::optional< SyncScope::ID > getAtomicSyncScopeID(const Instruction *I)

A helper function that returns an atomic operation's sync scope; returns std::nullopt if it is not an...

constexpr int PoisonMaskElem

AtomicOrdering

Atomic ordering for LLVM's memory model.

DWARFExpression::Operation Op

OutputIt copy(R &&Range, OutputIt Out)

constexpr unsigned BitWidth

auto find_if(R &&Range, UnaryPredicate P)

Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.

auto predecessors(const MachineBasicBlock *BB)

Type * getLoadStoreType(const Value *I)

A helper function that returns the type of a load or store instruction.

void setLoadStoreAlignment(Value *I, Align NewAlign)

A helper function that set the alignment of load or store instruction.

unsigned Log2(Align A)

Returns the log2 of the alignment.

@ Default

The result values are uniform if and only if all operands are uniform.

This struct is a compact representation of a valid (non-zero power of two) alignment.

Summary of memprof metadata on allocations.

Describes an element of a Bitfield.

static constexpr bool areContiguous()

The const version of succ_op_iterator.

const BasicBlock * operator->() const

const_succ_op_iterator(const_value_op_iterator I)

const BasicBlock * operator*() const

Iterator type that casts an operand to a basic block.

BasicBlock * operator->() const

succ_op_iterator(value_op_iterator I)

BasicBlock * operator*() const

FixedNumOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...

HungoffOperandTraits - determine the allocation regime of the Use array when it is not a prefix to th...

The const version of succ_op_iterator.

const BasicBlock * operator*() const

const_succ_op_iterator(const_value_op_iterator I)

const BasicBlock * operator->() const

Iterator type that casts an operand to a basic block.

BasicBlock * operator*() const

succ_op_iterator(value_op_iterator I)

BasicBlock * operator->() const

Compile-time customization of User operands.

A MapVector that performs no allocations if smaller than a certain size.

Information about how a User object was allocated, to be passed into the User constructor.

Indicates this User has operands "hung off" in another allocation.

Indicates this User has operands co-allocated.

Iterator for directly iterating over the operand Values.

VariadicOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...