19 #ifndef LLVM_IR_USER_H
20 #define LLVM_IR_USER_H
36 template <
typename T>
class ArrayRef;
37 template <
typename T>
class MutableArrayRef;
50 allocateFixedOperandUser(
size_t,
unsigned,
unsigned);
57 void *
operator new(
size_t Size);
62 void *
operator new(
size_t Size,
unsigned Us);
72 void *
operator new(
size_t Size,
unsigned Us,
unsigned DescBytes);
81 "Error in initializing hung off uses for User");
101 void operator delete(
void *Usr);
112 template <
int Idx,
typename U>
static Use &
OpFrom(
const U *that) {
119 return OpFrom<Idx>(
this);
121 template <
int Idx>
const Use &
Op()
const {
122 return OpFrom<Idx>(
this);
126 const Use *getHungOffOperands()
const {
127 return *(
reinterpret_cast<const Use *
const *
>(
this) - 1);
130 Use *&getHungOffOperands() {
return *(
reinterpret_cast<Use **
>(
this) - 1); }
132 const Use *getIntrusiveOperands()
const {
136 Use *getIntrusiveOperands() {
140 void setOperandList(Use *NewList) {
142 "Setting operand list only required for hung off uses");
143 getHungOffOperands() = NewList;
148 return HasHungOffUses ? getHungOffOperands() : getIntrusiveOperands();
162 isa<GlobalValue>((
const Value*)
this)) &&
163 "Cannot mutate a constant with setOperand!");
193 assert(NumOps <= 1 &&
"GlobalVariable can only have 0 or 1 operands");
232 std::random_access_iterator_tag, Value *,
233 ptrdiff_t, Value *, Value *> {
252 std::random_access_iterator_tag, const Value *,
253 ptrdiff_t, const Value *, const Value *> {
292 return isa<Instruction>(V) || isa<Constant>(V);
297 static_assert(
alignof(Use) >=
alignof(User),
298 "Alignment is insufficient after objects prepended to User");
299 static_assert(
alignof(Use *) >=
alignof(User),
300 "Alignment is insufficient after objects prepended to User");
319 #endif // LLVM_IR_USER_H
static Use & OpFrom(const U *that)
const Use & getOperandUse(unsigned i) const
const_value_op_iterator value_op_end() const
const Value * operator->() const
void dropAllReferences()
Drop all references to operands.
unsigned getNumOperands() const
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
value_op_iterator value_op_begin()
iterator_range< op_iterator > op_range
Use & getOperandUse(unsigned i)
const_value_op_iterator value_op_begin() const
value_op_iterator value_op_end()
This defines the Use class.
const_op_range operands() const
const Use * getOperandList() const
const Value * operator*() const
static bool classof(const Value *V)
const_value_op_iterator(const Use *U=nullptr)
A Use represents the edge between a Value definition and its users.
void growHungoffUses(unsigned N, bool IsPhi=false)
Grow the number of hung off uses.
#define LLVM_ATTRIBUTE_ALWAYS_INLINE
LLVM_ATTRIBUTE_ALWAYS_INLINE - On compilers where we have a directive to do so, mark a method "always...
const_op_iterator op_end() const
iterator_range< const_value_op_iterator > operand_values() const
const_op_iterator op_begin() const
iterator_range< const_op_iterator > const_op_range
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
void replaceUsesOfWith(Value *From, Value *To)
Replace uses of one Value with another.
Value * operator->() const
The instances of the Type class are immutable: once they are created, they are never changed...
CRTP base class for adapting an iterator to a different type.
Value * getOperand(unsigned i) const
void setGlobalVariableNumOperands(unsigned NumOps)
Set the number of operands on a GlobalVariable.
static SimpleType getSimplifiedValue(User::const_op_iterator &Val)
Iterator for directly iterating over the operand Values.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
User(Type *ty, unsigned vty, Use *, unsigned NumOps)
void setOperand(unsigned i, Value *Val)
A range adaptor for a pair of iterators.
ArrayRef< const uint8_t > getDescriptor() const
Returns the descriptor co-allocated with this User instance.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
llvm_unreachable("Unknown RegBank!")
iterator_range< value_op_iterator > operand_values()
Compile-time customization of User operands.
Value * operator*() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
HungoffOperandTraits - determine the allocation regime of the Use array when it is not a prefix to th...
void allocHungoffUses(unsigned N, bool IsPhi=false)
Allocate the array of Uses, followed by a pointer (with bottom bit set) to the User.
void setNumHungOffUseOperands(unsigned NumOps)
Subclasses with hung off uses need to manage the operand count themselves.
static SimpleType getSimplifiedValue(User::op_iterator &Val)
value_op_iterator(Use *U=nullptr)