19 #ifndef LLVM_IR_USER_H
20 #define LLVM_IR_USER_H
40 virtual void anchor();
47 void *
operator new(
size_t Size);
52 void *
operator new(
size_t Size,
unsigned Us);
61 "Error in initializing hung off uses for User");
78 void operator delete(
void *Usr);
88 template <
int Idx,
typename U>
static Use &
OpFrom(
const U *that) {
94 return OpFrom<Idx>(
this);
96 template <
int Idx>
const Use &
Op()
const {
97 return OpFrom<Idx>(
this);
100 Use *&getHungOffOperands() {
return *(
reinterpret_cast<Use **
>(
this) - 1); }
102 Use *getIntrusiveOperands() {
106 void setOperandList(Use *NewList) {
108 "Setting operand list only required for hung off uses");
109 getHungOffOperands() = NewList;
113 return HasHungOffUses ? getHungOffOperands() : getIntrusiveOperands();
124 assert((!isa<Constant>((
const Value*)
this) ||
125 isa<GlobalValue>((
const Value*)
this)) &&
126 "Cannot mutate a constant with setOperand!");
149 assert(NumOps <= 1 &&
"GlobalVariable can only have 0 or 1 operands");
162 assert(NumOps <= 1 &&
"Function can only have 0 or 1 operands");
170 assert(
HasHungOffUses &&
"Must have hung off uses to use this method");
201 std::random_access_iterator_tag, Value *,
202 ptrdiff_t, Value *, Value *> {
240 return isa<Instruction>(V) || isa<Constant>(V);
244 static_assert(AlignOf<Use>::Alignment >= AlignOf<User>::Alignment,
245 "Alignment is insufficient after objects prepended to User");
246 static_assert(AlignOf<Use *>::Alignment >= AlignOf<User>::Alignment,
247 "Alignment is insufficient after objects prepended to User");
static Use & OpFrom(const U *that)
const Use & getOperandUse(unsigned i) const
void setFunctionNumOperands(unsigned NumOps)
Set the number of operands on a Function.
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()
Use & getOperandUse(unsigned i)
value_op_iterator value_op_end()
iterator_range< op_iterator > op_range
const_op_range operands() const
const Use * getOperandList() const
static bool classof(const Value *V)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
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.
const_op_iterator op_end() const
const_op_iterator op_begin() const
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.
void setOperand(unsigned i, Value *Val)
A range adaptor for a pair of iterators.
iterator_range< const_op_iterator > const_op_range
User(Type *ty, unsigned vty, Use *OpList, unsigned NumOps)
iterator_range< value_op_iterator > operand_values()
Compile-time customization of User operands.
Value * operator*() const
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)
const Use * const_op_iterator