LLVM: include/llvm/IR/User.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#ifndef LLVM_IR_USER_H
19#define LLVM_IR_USER_H
20
28#include
29#include
30#include
31#include
32
33namespace llvm {
34
35template class ArrayRef;
37
38
39
40
41template <class>
43
47
49 allocateFixedOperandUser(size_t, unsigned, unsigned);
50
51protected:
52
53
54 void *operator new(size_t Size) = delete;
55
56
58
59
64
65
73
74
75
76
77
78
80 public:
86
88
91
94
98 };
99
100
101
102
103
104 LLVM_ABI void *operator new(size_t Size, HungOffOperandsAllocMarker);
105
106
107
108
110 IntrusiveOperandsAllocMarker allocTrait);
111
112
113
114
116 operator new(size_t Size,
117 IntrusiveOperandsAndDescriptorAllocMarker allocTrait);
118
121 "Too many operands");
124 "Cannot have both hung off uses and a descriptor");
127
128
130 "Error in initializing hung off uses for User");
131 }
132
133
134
135
136
138
139
140
142
143protected:
145
146public:
148
149
150 LLVM_ABI void operator delete(void *Usr);
151
153
154
155
156
157
158 User::operator delete(Usr);
159
160#ifndef LLVM_ENABLE_EXCEPTIONS
162#endif
163 }
164
166
167
168
169
170 User::operator delete(Usr);
171
172#ifndef LLVM_ENABLE_EXCEPTIONS
174#endif
175 }
176
178
179
180
181
182 User::operator delete(Usr);
183
184#ifndef LLVM_ENABLE_EXCEPTIONS
186#endif
187 }
188
189protected:
190 template <int Idx, typename U> static Use &OpFrom(const U *that) {
191 return Idx < 0
194 }
195
198 }
199 template const Use &Op() const {
201 }
202
203private:
204 const Use *getHungOffOperands() const {
205 return *(reinterpret_cast<const Use *const *>(this) - 1);
206 }
207
208 Use *&getHungOffOperands() { return *(reinterpret_cast<Use **>(this) - 1); }
209
210 const Use *getIntrusiveOperands() const {
212 }
213
214 Use *getIntrusiveOperands() {
216 }
217
218 void setOperandList(Use *NewList) {
220 "Setting operand list only required for hung off uses");
221 getHungOffOperands() = NewList;
222 }
223
224public:
226 return HasHungOffUses ? getHungOffOperands() : getIntrusiveOperands();
227 }
229 return const_cast<Use *>(static_cast<const User *>(this)->getOperandList());
230 }
231
236
241 "Cannot mutate a constant with setOperand!");
243 }
244
253
255
256
258
259
261
262
263
264
270
271
272
273
275
276
277
278
283
298
299
302 std::random_access_iterator_tag, Value *,
303 ptrdiff_t, Value *, Value *> {
305
308 };
309
319
322 std::random_access_iterator_tag, const Value *,
323 ptrdiff_t, const Value *, const Value *> {
326
329 };
330
340
341
342
343
344
345
346
347
348
351 U.set(nullptr);
352 }
353
354
355
356
357
359
360
364};
365
366
367static_assert(alignof(Use) >= alignof(User),
368 "Alignment is insufficient after objects prepended to User");
369static_assert(alignof(Use *) >= alignof(User),
370 "Alignment is insufficient after objects prepended to User");
371
374
376 return Val->get();
377 }
378};
381
383 return Val->get();
384 }
385};
386
387}
388
389#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_PREFERRED_TYPE(T)
\macro LLVM_PREFERRED_TYPE Adjust type of bit-field in debug info.
#define LLVM_ATTRIBUTE_ALWAYS_INLINE
LLVM_ATTRIBUTE_ALWAYS_INLINE - On compilers where we have a directive to do so, mark a method "always...
This defines the Use class.
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
The instances of the Type class are immutable: once they are created, they are never changed.
A Use represents the edge between a Value definition and its users.
iterator_range< const_op_iterator > const_op_range
Definition User.h:282
Use * op_iterator
Definition User.h:279
const Use * getOperandList() const
Definition User.h:225
op_range operands()
Definition User.h:292
User(Type *ty, unsigned vty, AllocInfo AllocInfo)
Definition User.h:119
op_iterator op_begin()
Definition User.h:284
const Use & getOperandUse(unsigned i) const
Definition User.h:245
const_op_iterator op_begin() const
Definition User.h:285
void dropAllReferences()
Drop all references to operands.
Definition User.h:349
const_op_iterator op_end() const
Definition User.h:289
LLVM_ABI ArrayRef< const uint8_t > getDescriptor() const
Returns the descriptor co-allocated with this User instance.
value_op_iterator value_op_end()
Definition User.h:313
void setOperand(unsigned i, Value *Val)
Definition User.h:237
friend struct HungoffOperandTraits
Definition User.h:45
Use * getOperandList()
Definition User.h:228
const Use * const_op_iterator
Definition User.h:280
Use & getOperandUse(unsigned i)
Definition User.h:249
const_value_op_iterator value_op_begin() const
Definition User.h:331
void setNumHungOffUseOperands(unsigned NumOps)
Subclasses with hung off uses need to manage the operand count themselves.
Definition User.h:265
Use & Op()
Definition User.h:196
LLVM_ABI void growHungoffUses(unsigned N, bool IsPhi=false)
Grow the number of hung off uses.
static bool classof(const Value *V)
Definition User.h:361
iterator_range< op_iterator > op_range
Definition User.h:281
LLVM_ABI bool isDroppable() const
A droppable user is a user for which uses can be dropped without affecting correctness and should be ...
LLVM_ABI void allocHungoffUses(unsigned N, bool IsPhi=false)
Allocate the array of Uses, followed by a pointer (with bottom bit set) to the User.
LLVM_ABI bool replaceUsesOfWith(Value *From, Value *To)
Replace uses of one Value with another.
static Use & OpFrom(const U *that)
Definition User.h:190
Value * getOperand(unsigned i) const
Definition User.h:232
User(const User &)=delete
iterator_range< const_value_op_iterator > operand_values() const
Definition User.h:337
const Use & Op() const
Definition User.h:199
const_op_range operands() const
Definition User.h:295
friend struct ConstantAggrKeyType
Definition User.h:46
value_op_iterator value_op_begin()
Definition User.h:310
unsigned getNumOperands() const
Definition User.h:254
iterator_range< value_op_iterator > operand_values()
Definition User.h:316
op_iterator op_end()
Definition User.h:286
const_value_op_iterator value_op_end() const
Definition User.h:334
LLVM Value Representation.
LLVM_ABI Value(Type *Ty, unsigned scid)
iterator_adaptor_base()=default
A range adaptor for a pair of iterators.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
NodeAddr< UseNode * > Use
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
bool isa(const From &Val)
isa - Return true if the parameter to the template is an instance of one of the template type argu...
Compile-time customization of User operands.
Definition User.h:42
Information about how a User object was allocated, to be passed into the User constructor.
Definition User.h:79
const unsigned HasHungOffUses
Definition User.h:83
constexpr AllocInfo(const IntrusiveOperandsAllocMarker Alloc)
Definition User.h:92
constexpr AllocInfo(const IntrusiveOperandsAndDescriptorAllocMarker Alloc)
Definition User.h:95
const unsigned HasDescriptor
Definition User.h:85
const unsigned NumOps
Definition User.h:81
Indicates this User has operands "hung off" in another allocation.
Definition User.h:57
Indicates this User has operands co-allocated.
Definition User.h:60
const unsigned NumOps
The number of operands for this User.
Definition User.h:62
Indicates this User has operands and a descriptor co-allocated .
Definition User.h:66
const unsigned NumOps
The number of operands for this User.
Definition User.h:68
const unsigned DescBytes
The number of bytes to allocate for the descriptor.
Definition User.h:71
const_value_op_iterator(const Use *U=nullptr)
Definition User.h:324
const Value * operator*() const
Definition User.h:327
const Value * operator->() const
Definition User.h:328
Iterator for directly iterating over the operand Values.
Definition User.h:303
Value * operator->() const
Definition User.h:307
Value * operator*() const
Definition User.h:306
value_op_iterator(Use *U=nullptr)
Definition User.h:304
static SimpleType getSimplifiedValue(User::const_op_iterator &Val)
Definition User.h:382
Value * SimpleType
Definition User.h:380
static SimpleType getSimplifiedValue(User::op_iterator &Val)
Definition User.h:375
Value * SimpleType
Definition User.h:373
Define a template that can be specialized by smart pointers to reflect the fact that they are automat...