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
42class MDNode;
43class raw_ostream;
44struct KnownBits;
45
46
49
50
53 }
54
55
58 }
59
60public:
61
63
64
66
67
68
69
71
72
75 }
76
77
80 }
81
82
83
85 if (Lower == Upper)
86 return getFull(Lower.getBitWidth());
88 }
89
90
91
92
94
95
96
97
98
99
100
101
102
105
106
107
108
109
110
111
112
113
116
117
118
119
120
121
122
123
126
127
128
130
131
132
133 static bool
134 areInsensitiveToSignednessOfICmpPredicate(const ConstantRange &CR1,
136
137
138
139 static bool
140 areInsensitiveToSignednessOfInvertedICmpPredicate(const ConstantRange &CR1,
142
143
144
145
146
147
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
171 unsigned NoWrapKind);
172
173
174
177 unsigned NoWrapKind);
178
179
180
181
183
184
185
186 static bool isIntrinsicSupported(Intrinsic::ID IntrinsicID);
187
188
191
192
193
194
196
197
198
199 void
201
202
204
205
207
208
210
211
212
213 bool isFullSet() const;
214
215
216 bool isEmptySet() const;
217
218
219
220
221
222 bool isWrappedSet() const;
223
224
225
226
227
228
229 bool isUpperWrapped() const;
230
231
232
233
234
235 bool isSignWrappedSet() const;
236
237
238
239
240
241
242 bool isUpperSignWrapped() const;
243
244
246
247
249
250
252 if (Upper == Lower + 1)
253 return &Lower;
254 return nullptr;
255 }
256
257
258
260 if (Lower == Upper + 1)
262 return nullptr;
263 }
264
265
266 bool isSingleElement() const { return getSingleElement() != nullptr; }
267
268
269 bool isSizeStrictlySmallerThan(const ConstantRange &CR) const;
270
271
272 bool isSizeLargerThan(uint64_t MaxSize) const;
273
274
275 bool isAllNegative() const;
276
277
278 bool isAllNonNegative() const;
279
280
281 bool isAllPositive() const;
282
283
284 APInt getUnsignedMax() const;
285
286
287 APInt getUnsignedMin() const;
288
289
290 APInt getSignedMax() const;
291
292
293 APInt getSignedMin() const;
294
295
297 return Lower == CR.Lower && Upper == CR.Upper;
298 }
301 }
302
303
304
305 unsigned getActiveBits() const;
306
307
308
309 unsigned getMinSignedBits() const;
310
311
313
314
315
317
318
319
320
321
322
323
324
325
326
328
329
330
331
333 PreferredRangeType Type = Smallest) const;
334
335
336
337
338
339
341 PreferredRangeType Type = Smallest) const;
342
343
344
345 std::optional
346 exactIntersectWith(const ConstantRange &CR) const;
347
348
349
350 std::optional exactUnionWith(const ConstantRange &CR) const;
351
352
353
354
355
356
357
360
361
362
363
364
366
367
368
369
370
372
373
374
375
376
378
379
380
382
383
384
386
387
388
389
392
393
394
395
396
399 unsigned NoWrapKind) const;
400
401
402
404
405
406
407
408
409
411 PreferredRangeType RangeType = Smallest) const;
412
413
414
416
417
418
419
420
421
423 PreferredRangeType RangeType = Smallest) const;
424
425
426
427
429
430
431
432
433
434
437 PreferredRangeType RangeType = Smallest) const;
438
439
440
441
443
444
445
447
448
449
451
452
453
455
456
457
459
460
461
462
464
465
466
467
468
469
471
472
473
474
476
477
478
479
481
482
483
484
486
487
488
490
491
492
494
495
496
498
499
500
501
503
504
505
506
507
508
510 PreferredRangeType RangeType = Smallest) const;
511
512
513
515
516
517
519
520
522
523
525
526
528
529
531
532
534
535
537
538
539
541
542
543
545
546
548
549
550
551
553
554
555
556 ConstantRange ctlz(bool ZeroIsPoison = false) const;
557
558
559
560 ConstantRange cttz(bool ZeroIsPoison = false) const;
561
562
564
565
566
568
570
572
574
576 };
577
578
580
581
583
584
586
587
589
590
592
593
595
596
598
599
600 void dump() const;
601};
602
605 return OS;
606}
607
608
609
610
612
613}
614
615#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 GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
std::optional< std::vector< StOtherPiece > > Other
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.
PreferredRangeType
If represented precisely, the result of some range operations may consist of multiple disjoint ranges...
const APInt * getSingleElement() const
If this set contains a single element, return it, otherwise return null.
static ConstantRange getFull(uint32_t BitWidth)
Create full constant range with the given bit width.
const APInt * getSingleMissingElement() const
If this set contains all but a single element, return it, otherwise return null.
const APInt & getLower() const
Return the lower value for this range.
bool operator==(const ConstantRange &CR) const
Return true if this range is equal to another range.
void print(raw_ostream &OS) const
Print out the bounds to a stream.
bool isSingleElement() const
Return true if this set contains exactly one member.
const APInt & getUpper() const
Return the upper value for this range.
OverflowResult
Represents whether an operation on the given constant range is known to always or never overflow.
bool operator!=(const ConstantRange &CR) const
static ConstantRange getNonEmpty(APInt Lower, APInt Upper)
Create non-empty constant range with the given bounds.
uint32_t getBitWidth() const
Get the bit width of this ConstantRange.
static ConstantRange getEmpty(uint32_t BitWidth)
Create empty constant range with the given bit width.
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.
This is an optimization pass for GlobalISel generic memory operations.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
@ NeverOverflows
Never overflows.
@ AlwaysOverflowsHigh
Always overflows in the direction of signed/unsigned max value.
@ AlwaysOverflowsLow
Always overflows in the direction of signed/unsigned min value.
@ MayOverflow
May or may not overflow.
APFloat abs(APFloat X)
Returns the absolute value of the argument.
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
ConstantRange getConstantRangeFromMetadata(const MDNode &RangeMD)
Parse out a conservative ConstantRange from !range metadata.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)