16
16
#ifndef LLVM_CODEGEN_MACHINEMEMOPERAND_H
17
17
#define LLVM_CODEGEN_MACHINEMEMOPERAND_H
18
18
19
+ #include " llvm/ADT/BitmaskEnum.h"
19
20
#include " llvm/ADT/PointerUnion.h"
20
21
#include " llvm/CodeGen/PseudoSourceValue.h"
21
22
#include " llvm/IR/Metadata.h"
@@ -87,15 +88,18 @@ struct MachinePointerInfo {
87
88
// / that aren't explicit in the regular LLVM IR.
88
89
// /
89
90
class MachineMemOperand {
90
- MachinePointerInfo PtrInfo;
91
- uint64_t Size ;
92
- unsigned Flags;
93
- AAMDNodes AAInfo;
94
- const MDNode *Ranges;
95
-
96
91
public:
92
+ // This is the number of bits we need to represent flags.
93
+ static constexpr unsigned MOMaxBits = 8 ;
94
+
95
+ // Target hints allow target passes to annotate memory operations.
96
+ static constexpr unsigned MOTargetStartBit = 5 ;
97
+ static constexpr unsigned MOTargetNumBits = 3 ;
98
+
97
99
// / Flags values. These may be or'd together.
98
- enum MemOperandFlags {
100
+ enum Flags : uint16_t {
101
+ // No flags set.
102
+ MONone = 0 ,
99
103
// / The memory access reads data.
100
104
MOLoad = 1 ,
101
105
// / The memory access writes data.
@@ -106,16 +110,25 @@ class MachineMemOperand {
106
110
MONonTemporal = 8 ,
107
111
// / The memory access is invariant.
108
112
MOInvariant = 16 ,
109
- // Target hints allow target passes to annotate memory operations.
110
- MOTargetStartBit = 5 ,
111
- MOTargetNumBits = 3 ,
112
- // This is the number of bits we need to represent flags.
113
- MOMaxBits = 8
113
+
114
+ // Maximum MemOperandFlag value (inclusive).
115
+ MOMaxFlag = ( 1 << MOMaxBits) - 1 ,
116
+
117
+ LLVM_MARK_AS_BITMASK_ENUM (MOMaxFlag)
114
118
};
115
119
120
+ private:
121
+ MachinePointerInfo PtrInfo;
122
+ uint64_t Size ;
123
+ Flags FlagVals;
124
+ uint16_t BaseAlignLog2; // log_2(base_alignment) + 1
125
+ AAMDNodes AAInfo;
126
+ const MDNode *Ranges;
127
+
128
+ public:
116
129
// / Construct a MachineMemOperand object with the specified PtrInfo, flags,
117
130
// / size, and base alignment.
118
- MachineMemOperand (MachinePointerInfo PtrInfo, unsigned flags, uint64_t s,
131
+ MachineMemOperand (MachinePointerInfo PtrInfo, Flags flags, uint64_t s,
119
132
unsigned base_alignment,
120
133
const AAMDNodes &AAInfo = AAMDNodes(),
121
134
const MDNode *Ranges = nullptr );
@@ -137,11 +150,11 @@ class MachineMemOperand {
137
150
138
151
const void *getOpaqueValue () const { return PtrInfo.V .getOpaqueValue (); }
139
152
140
- // / Return the raw flags of the source value, \see MemOperandFlags .
141
- unsigned int getFlags () const { return Flags & (( 1 << MOMaxBits) - 1 ) ; }
153
+ // / Return the raw flags of the source value, \see Flags .
154
+ Flags getFlags () const { return FlagVals ; }
142
155
143
156
// / Bitwise OR the current flags with the given flags.
144
- void setFlags (unsigned f) { Flags |= (f & (( 1 << MOMaxBits) - 1 )) ; }
157
+ void setFlags (Flags f) { FlagVals |= f ; }
145
158
146
159
// / For normal values, this is a byte offset added to the base address.
147
160
// / For PseudoSourceValue::FPRel values, this is the FrameIndex number.
@@ -158,19 +171,19 @@ class MachineMemOperand {
158
171
159
172
// / Return the minimum known alignment in bytes of the base address, without
160
173
// / the offset.
161
- uint64_t getBaseAlignment () const { return (1u << (Flags >> MOMaxBits) ) >> 1 ; }
174
+ uint64_t getBaseAlignment () const { return (1u << BaseAlignLog2 ) >> 1 ; }
162
175
163
176
// / Return the AA tags for the memory reference.
164
177
AAMDNodes getAAInfo () const { return AAInfo; }
165
178
166
179
// / Return the range tag for the memory reference.
167
180
const MDNode *getRanges () const { return Ranges; }
168
181
169
- bool isLoad () const { return Flags & MOLoad; }
170
- bool isStore () const { return Flags & MOStore; }
171
- bool isVolatile () const { return Flags & MOVolatile; }
172
- bool isNonTemporal () const { return Flags & MONonTemporal; }
173
- bool isInvariant () const { return Flags & MOInvariant; }
182
+ bool isLoad () const { return FlagVals & MOLoad; }
183
+ bool isStore () const { return FlagVals & MOStore; }
184
+ bool isVolatile () const { return FlagVals & MOVolatile; }
185
+ bool isNonTemporal () const { return FlagVals & MONonTemporal; }
186
+ bool isInvariant () const { return FlagVals & MOInvariant; }
174
187
175
188
// / Returns true if this memory operation doesn't have any ordering
176
189
// / constraints other than normal aliasing. Volatile and atomic memory
0 commit comments