LLVM: include/llvm/Support/ModRef.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef LLVM_SUPPORT_MODREF_H
15#define LLVM_SUPPORT_MODREF_H
16
20
21namespace llvm {
22
23
24
25
26
28
30
32
34
37};
38
41}
44}
47}
50}
53}
54
55
57
58
60
62
64
66
67
70};
71
73public:
75
76private:
78
79 static constexpr uint32_t BitsPerLoc = 2;
80 static constexpr uint32_t LocMask = (1 << BitsPerLoc) - 1;
81
83 return (uint32_t)Loc * BitsPerLoc;
84 }
85
87
89 Data &= ~(LocMask << getLocationPos(Loc));
90 Data |= static_cast<uint32_t>(MR) << getLocationPos(Loc);
91 }
92
93public:
94
98 }
99
100
101
103
104
105
108 setModRef(Loc, MR);
109 }
110
111
114 }
115
116
119 }
120
121
124 }
125
126
129 }
130
131
134 }
135
136
140 }
141
142
143
147 FRMB.setModRef(Location::ArgMem, MR);
148 FRMB.setModRef(Location::InaccessibleMem, MR);
149 return FRMB;
150 }
151
152
153
156 }
157
158
159
161 return Data;
162 }
163
164
166 return ModRefInfo((Data >> getLocationPos(Loc)) & LocMask);
167 }
168
169
172 ME.setModRef(Loc, MR);
173 return ME;
174 }
175
176
180 return ME;
181 }
182
183
188 return MR;
189 }
190
191
193
194
196
197
199
200
203 }
204
205
208 }
209
210
213 }
214
215
216
221 }
222
223
226 }
227
228
230 Data &= Other.Data;
231 return *this;
232 }
233
234
237 }
238
239
241 Data |= Other.Data;
242 return *this;
243 }
244
245
248 }
249
250
252 Data &= ~Other.Data;
253 return *this;
254 }
255
256
258
259
261};
262
263
264
265
266
267
269
270
272
273
275
276
285};
286
289}
290
293}
294
297}
298
301}
302
306}
307
310}
311
313
314
315
316
317
321
322public:
325 : OtherComponents(OtherComponents), RetComponents(RetComponents) {}
326
328 : OtherComponents(Components), RetComponents(Components) {}
329
330
332
333
335
336
337
339
340
341
342 operator CaptureComponents() const { return OtherComponents | RetComponents; }
343
345 return OtherComponents == Other.OtherComponents &&
346 RetComponents == Other.RetComponents;
347 }
348
350
351
354 RetComponents | Other.RetComponents);
355 }
356
357
360 RetComponents & Other.RetComponents);
361 }
362
366 }
367
368
369
371 return (uint32_t(OtherComponents) << 4) | uint32_t(RetComponents);
372 }
373};
374
376
377}
378
379#endif
unsigned const MachineRegisterInfo * MRI
Analysis containing CSE Info
Provides some synthesis utilities to produce sequences of values.
Represents which components of the pointer may be captured in which location.
static CaptureInfo createFromIntValue(uint32_t Data)
CaptureComponents getOtherComponents() const
Get components potentially captured through locations other than the return value.
bool operator==(CaptureInfo Other) const
bool operator!=(CaptureInfo Other) const
static CaptureInfo all()
Create CaptureInfo that may capture all components of the pointer.
CaptureInfo operator&(CaptureInfo Other) const
Compute intersection of CaptureInfos.
CaptureComponents getRetComponents() const
Get components potentially captured by the return value.
CaptureInfo(CaptureComponents OtherComponents, CaptureComponents RetComponents)
CaptureInfo operator|(CaptureInfo Other) const
Compute union of CaptureInfos.
uint32_t toIntValue() const
Convert CaptureInfo into an encoded integer value (used by captures attribute).
CaptureInfo(CaptureComponents Components)
MemoryEffectsBase operator&(MemoryEffectsBase Other) const
Intersect with other MemoryEffectsBase.
static MemoryEffectsBase readOnly()
Create MemoryEffectsBase that can read any memory.
bool onlyWritesMemory() const
Whether this function only (at most) writes memory.
MemoryEffectsBase getWithoutLoc(Location Loc) const
Get new MemoryEffectsBase with NoModRef on the given Loc.
MemoryEffectsBase & operator|=(MemoryEffectsBase Other)
Union (in-place) with other MemoryEffectsBase.
MemoryEffectsBase getWithModRef(Location Loc, ModRefInfo MR) const
Get new MemoryEffectsBase with modified ModRefInfo for Loc.
bool operator!=(MemoryEffectsBase Other) const
Check whether this is different from other MemoryEffectsBase.
MemoryEffectsBase operator-(MemoryEffectsBase Other) const
Subtract other MemoryEffectsBase.
bool doesNotAccessMemory() const
Whether this function accesses no memory.
static MemoryEffectsBase argMemOnly(ModRefInfo MR=ModRefInfo::ModRef)
Create MemoryEffectsBase that can only access argument memory.
MemoryEffectsBase(ModRefInfo MR)
Create MemoryEffectsBase that can access any location with the given ModRefInfo.
bool doesAccessArgPointees() const
Whether this function may access argument memory.
static MemoryEffectsBase inaccessibleMemOnly(ModRefInfo MR=ModRefInfo::ModRef)
Create MemoryEffectsBase that can only access inaccessible memory.
bool onlyAccessesInaccessibleMem() const
Whether this function only (at most) accesses inaccessible memory.
MemoryEffectsBase(Location Loc, ModRefInfo MR)
Create MemoryEffectsBase that can access only the given location with the given ModRefInfo.
ModRefInfo getModRef(Location Loc) const
Get ModRefInfo for the given Location.
MemoryEffectsBase & operator&=(MemoryEffectsBase Other)
Intersect (in-place) with other MemoryEffectsBase.
ModRefInfo getModRef() const
Get ModRefInfo for any location.
bool onlyAccessesArgPointees() const
Whether this function only (at most) accesses argument memory.
bool onlyReadsMemory() const
Whether this function only (at most) reads memory.
static MemoryEffectsBase createFromIntValue(uint32_t Data)
Create MemoryEffectsBase from an encoded integer value (used by memory attribute).
MemoryEffectsBase & operator-=(MemoryEffectsBase Other)
Subtract (in-place) with other MemoryEffectsBase.
static MemoryEffectsBase writeOnly()
Create MemoryEffectsBase that can write any memory.
MemoryEffectsBase operator|(MemoryEffectsBase Other) const
Union with other MemoryEffectsBase.
static auto locations()
Returns iterator over all supported location kinds.
uint32_t toIntValue() const
Convert MemoryEffectsBase into an encoded integer value (used by memory attribute).
static MemoryEffectsBase inaccessibleOrArgMemOnly(ModRefInfo MR=ModRefInfo::ModRef)
Create MemoryEffectsBase that can only access inaccessible or argument memory.
static MemoryEffectsBase none()
Create MemoryEffectsBase that cannot read or write any memory.
bool operator==(MemoryEffectsBase Other) const
Check whether this is the same as other MemoryEffectsBase.
bool onlyAccessesInaccessibleOrArgMem() const
Whether this function only (at most) accesses argument and inaccessible memory.
static MemoryEffectsBase unknown()
Create MemoryEffectsBase that can read and write any memory.
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.
bool capturesReadProvenanceOnly(CaptureComponents CC)
bool capturesAddressIsNullOnly(CaptureComponents CC)
auto enum_seq_inclusive(EnumT Begin, EnumT End)
Iterate over an enum type from Begin to End inclusive.
bool capturesAddress(CaptureComponents CC)
constexpr force_iteration_on_noniterable_enum_t force_iteration_on_noniterable_enum
bool capturesFullProvenance(CaptureComponents CC)
bool isModSet(const ModRefInfo MRI)
MemoryEffectsBase< IRMemLocation > MemoryEffects
Summary of how a function affects memory in the program.
bool isModOrRefSet(const ModRefInfo MRI)
CaptureComponents
Components of the pointer that may be captured.
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
@ Ref
The access may reference the value stored in memory.
@ ModRef
The access may reference and may modify the value stored in memory.
@ Mod
The access may modify the value stored in memory.
@ LLVM_MARK_AS_BITMASK_ENUM
@ NoModRef
The access neither references nor modifies the value stored in memory.
IRMemLocation
The locations at which a function might access memory.
@ ArgMem
Access to memory via argument pointers.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
@ InaccessibleMem
Memory that is inaccessible via LLVM IR.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
bool isModAndRefSet(const ModRefInfo MRI)
bool capturesAnything(CaptureComponents CC)
bool capturesNothing(CaptureComponents CC)
bool isNoModRef(const ModRefInfo MRI)
bool isRefSet(const ModRefInfo MRI)