LLVM: include/llvm/IR/GEPNoWrapFlags.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef LLVM_IR_GEPNOWRAPFLAGS_H
14#define LLVM_IR_GEPNOWRAPFLAGS_H
15
16#include <assert.h>
17
18namespace llvm {
19
20
21
22
23
24
25
26class GEPNoWrapFlags {
27 enum : unsigned {
28 InBoundsFlag = (1 << 0),
29 NUSWFlag = (1 << 1),
30 NUWFlag = (1 << 2),
31 };
32
33 unsigned Flags;
36 "inbounds implies nusw");
37 }
38
39public:
41
42
44 : Flags(IsInBounds ? (InBoundsFlag | NUSWFlag) : 0) {}
45
47 static GEPNoWrapFlags all() {
48 return GEPNoWrapFlags(InBoundsFlag | NUSWFlag | NUWFlag);
49 }
57
58 static GEPNoWrapFlags fromRaw(unsigned Flags) {
60 }
61 unsigned getRaw() const { return Flags; }
62
63 bool isInBounds() const { return Flags & InBoundsFlag; }
66
76
77
79 GEPNoWrapFlags Res = *this & Other;
80
81
84 return Res;
85 }
86
87
88
90 GEPNoWrapFlags Res = *this & Other;
91
93 return none();
94 return Res;
95 }
96
99
107 Flags &= Other.Flags;
108 return *this;
109 }
111 Flags |= Other.Flags;
112 return *this;
113 }
114};
115
116}
117
118#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
GEPNoWrapFlags & operator|=(GEPNoWrapFlags Other)
Definition GEPNoWrapFlags.h:110
static GEPNoWrapFlags inBounds()
Definition GEPNoWrapFlags.h:50
GEPNoWrapFlags withoutNoUnsignedSignedWrap() const
Definition GEPNoWrapFlags.h:70
bool operator==(GEPNoWrapFlags Other) const
Definition GEPNoWrapFlags.h:97
GEPNoWrapFlags & operator&=(GEPNoWrapFlags Other)
Definition GEPNoWrapFlags.h:106
GEPNoWrapFlags withoutInBounds() const
Definition GEPNoWrapFlags.h:67
static GEPNoWrapFlags fromRaw(unsigned Flags)
Definition GEPNoWrapFlags.h:58
static GEPNoWrapFlags all()
Definition GEPNoWrapFlags.h:47
static GEPNoWrapFlags noUnsignedWrap()
Definition GEPNoWrapFlags.h:56
static GEPNoWrapFlags noUnsignedSignedWrap()
Definition GEPNoWrapFlags.h:53
GEPNoWrapFlags intersectForReassociate(GEPNoWrapFlags Other) const
Given (gep (gep p, x), y), determine the nowrap flags for (gep (gep, p, y), x).
Definition GEPNoWrapFlags.h:89
GEPNoWrapFlags()
Definition GEPNoWrapFlags.h:40
GEPNoWrapFlags(bool IsInBounds)
Definition GEPNoWrapFlags.h:43
bool hasNoUnsignedSignedWrap() const
Definition GEPNoWrapFlags.h:64
bool operator!=(GEPNoWrapFlags Other) const
Definition GEPNoWrapFlags.h:98
bool hasNoUnsignedWrap() const
Definition GEPNoWrapFlags.h:65
bool isInBounds() const
Definition GEPNoWrapFlags.h:63
GEPNoWrapFlags operator&(GEPNoWrapFlags Other) const
Definition GEPNoWrapFlags.h:100
GEPNoWrapFlags operator|(GEPNoWrapFlags Other) const
Definition GEPNoWrapFlags.h:103
GEPNoWrapFlags intersectForOffsetAdd(GEPNoWrapFlags Other) const
Given (gep (gep p, x), y), determine the nowrap flags for (gep p, x+y).
Definition GEPNoWrapFlags.h:78
GEPNoWrapFlags withoutNoUnsignedWrap() const
Definition GEPNoWrapFlags.h:73
static GEPNoWrapFlags none()
Definition GEPNoWrapFlags.h:46
unsigned getRaw() const
Definition GEPNoWrapFlags.h:61
This is an optimization pass for GlobalISel generic memory operations.