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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31#ifndef LLVM_IR_CONSTANTRANGE_H

32#define LLVM_IR_CONSTANTRANGE_H

33

38#include

39

40namespace llvm {

41

45

46

48 APInt Lower, Upper;

49

50

53 }

54

55

58 }

59

60public:

61

63

64

66

67

68

69

71

72

76

77

81

82

83

85 if (Lower == Upper)

86 return getFull(Lower.getBitWidth());

87 return ConstantRange(std::move(Lower), std::move(Upper));

88 }

89

90

91

92

94 bool IsSigned);

95

96

97

99

100

101

102

103

104

105

106

107

110

111

112

113

114

115

116

117

118

121

122

123

124

125

126

127

128

131

132

133

135

136

137

139 areInsensitiveToSignednessOfICmpPredicate(const ConstantRange &CR1,

141

142

143

145 areInsensitiveToSignednessOfInvertedICmpPredicate(const ConstantRange &CR1,

147

148

149

150

151

152

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

177

178

179

182 unsigned NoWrapKind);

183

184

185

186

189

190

191

193

194

197

198

199

200

202

203

204

207

208

210

211

213

214

216

217

218

219 LLVM_ABI bool isFullSet() const;

220

221

222 LLVM_ABI bool isEmptySet() const;

223

224

225

226

227

228 LLVM_ABI bool isWrappedSet() const;

229

230

231

232

233

234

235 LLVM_ABI bool isUpperWrapped() const;

236

237

238

239

240

241 LLVM_ABI bool isSignWrappedSet() const;

242

243

244

245

246

247

248 LLVM_ABI bool isUpperSignWrapped() const;

249

250

252

253

255

256

258 if (Upper == Lower + 1)

259 return &Lower;

260 return nullptr;

261 }

262

263

264

266 if (Lower == Upper + 1)

267 return &Upper;

268 return nullptr;

269 }

270

271

273

274

276

277

279

280

281 LLVM_ABI bool isAllNegative() const;

282

283

284 LLVM_ABI bool isAllNonNegative() const;

285

286

287 LLVM_ABI bool isAllPositive() const;

288

289

291

292

294

295

297

298

300

301

303 return Lower == CR.Lower && Upper == CR.Upper;

304 }

308

309

310

311 LLVM_ABI unsigned getActiveBits() const;

312

313

314

315 LLVM_ABI unsigned getMinSignedBits() const;

316

317

319

320

321

323

324

325

326

327

328

329

330

331

332

334

335

336

337

339 const ConstantRange &CR, PreferredRangeType Type = Smallest) const;

340

341

342

343

344

345

347 PreferredRangeType Type = Smallest) const;

348

349

350

351 LLVM_ABI std::optional

352 exactIntersectWith(const ConstantRange &CR) const;

353

354

355

356 LLVM_ABI std::optional

358

359

360

361

362

363

364

367

368

369

370

371

373

374

375

376

377

379

380

381

382

383

384

386 unsigned NoWrapKind = 0) const;

387

388

389

391

392

393

395

396

397

398

401

402

403

404

405

408 unsigned NoWrapKind) const;

409

410

411

413

414

415

416

417

418

421 PreferredRangeType RangeType = Smallest) const;

422

423

424

426

427

428

429

430

431

434 PreferredRangeType RangeType = Smallest) const;

435

436

437

438

440

441

442

443

444

445

448 PreferredRangeType RangeType = Smallest) const;

449

450

451

452

454

455

456

458

459

460

462

463

464

466

467

468

470

471

472

473

475

476

477

478

479

480

482

483

484

485

487

488

489

490

492

493

494

495

497

498

499

501

502

503

505

506

507

509

510

511

512

514

515

516

517

518

519

522 PreferredRangeType RangeType = Smallest) const;

523

524

525

527

528

529

531

532

534

535

537

538

540

541

543

544

546

547

549

550

551

553

554

555

557

558

560

561

562

563

565

566

567

569

570

571

573

574

576

577

578

589

590

593

594

597

598

601

602

605

606

609

610

612

613

615

616

618};

619

624

625

626

627

629

630}

631

632#endif

This file implements a class to represent arbitrary precision integral constant values and operations...

static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)

static void splitPosNeg(const APFloat &Lower, const APFloat &Upper, std::optional< SameSignRange > &NegPart, std::optional< SameSignRange > &PosPart)

Split the range into positive and negative components.

const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]

bool operator==(const MergedFunctionsInfo &LHS, const MergedFunctionsInfo &RHS)

static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)

static unsigned getBitWidth(Type *Ty, const DataLayout &DL)

Returns the bitwidth of the given scalar or pointer type.

Class for arbitrary precision integers.

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

Predicate

This enumeration lists the possible predicates for CmpInst subclasses.

This class represents a range of values.

Definition ConstantRange.h:47

PreferredRangeType

If represented precisely, the result of some range operations may consist of multiple disjoint ranges...

Definition ConstantRange.h:333

@ Smallest

Definition ConstantRange.h:333

@ Signed

Definition ConstantRange.h:333

@ Unsigned

Definition ConstantRange.h:333

const APInt * getSingleElement() const

If this set contains a single element, return it, otherwise return null.

Definition ConstantRange.h:257

static ConstantRange getFull(uint32_t BitWidth)

Create full constant range with the given bit width.

Definition ConstantRange.h:78

const APInt * getSingleMissingElement() const

If this set contains all but a single element, return it, otherwise return null.

Definition ConstantRange.h:265

const APInt & getLower() const

Return the lower value for this range.

Definition ConstantRange.h:209

LLVM_ABI bool isFullSet() const

Return true if this set contains all of the elements possible for this data-type.

bool operator==(const ConstantRange &CR) const

Return true if this range is equal to another range.

Definition ConstantRange.h:302

LLVM_ABI void print(raw_ostream &OS) const

Print out the bounds to a stream.

LLVM_ABI ConstantRange(uint32_t BitWidth, bool isFullSet)

Initialize a full or empty set for the specified bit width.

bool isSingleElement() const

Return true if this set contains exactly one member.

Definition ConstantRange.h:272

const APInt & getUpper() const

Return the upper value for this range.

Definition ConstantRange.h:212

OverflowResult

Represents whether an operation on the given constant range is known to always or never overflow.

Definition ConstantRange.h:579

@ NeverOverflows

Never overflows.

Definition ConstantRange.h:587

@ AlwaysOverflowsHigh

Always overflows in the direction of signed/unsigned max value.

Definition ConstantRange.h:583

@ AlwaysOverflowsLow

Always overflows in the direction of signed/unsigned min value.

Definition ConstantRange.h:581

@ MayOverflow

May or may not overflow.

Definition ConstantRange.h:585

bool operator!=(const ConstantRange &CR) const

Definition ConstantRange.h:305

static ConstantRange getNonEmpty(APInt Lower, APInt Upper)

Create non-empty constant range with the given bounds.

Definition ConstantRange.h:84

uint32_t getBitWidth() const

Get the bit width of this ConstantRange.

Definition ConstantRange.h:215

static ConstantRange getEmpty(uint32_t BitWidth)

Create empty constant range with the given bit width.

Definition ConstantRange.h:73

The instances of the Type class are immutable: once they are created, they are never changed.

LLVM Value Representation.

This class implements an extremely fast bulk output stream that can only output to a stream.

@ C

The default llvm calling convention, compatible with C.

This is an optimization pass for GlobalISel generic memory operations.

void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)

APFloat abs(APFloat X)

Returns the absolute value of the argument.

LLVM_ABI ConstantRange getConstantRangeFromMetadata(const MDNode &RangeMD)

Parse out a conservative ConstantRange from !range metadata.

raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)

constexpr unsigned BitWidth