14#ifndef LLVM_IR_OPERANDTRAITS_H
15#define LLVM_IR_OPERANDTRAITS_H
29template <
typename SubClass,
unsigned ARITY>
33 !std::is_polymorphic<SubClass>::value,
34 "adding virtual methods to subclasses of User breaks use lists");
35 return reinterpret_cast<Use*
>(U) - ARITY;
38 return reinterpret_cast<Use*
>(U);
52template <
typename SubClass,
unsigned ARITY = 1>
55 return U->getNumOperands();
70 !std::is_polymorphic<SubClass>::value,
71 "adding virtual methods to subclasses of User breaks use lists");
75 return reinterpret_cast<Use*
>(U);
78 return U->getNumOperands();
95 return U->getHungOffOperands();
98 return U->getHungOffOperands() + U->getNumOperands();
101 return U->getNumOperands();
108#define DECLARE_TRANSPARENT_OPERAND_ACCESSORS(VALUECLASS) \
110 inline VALUECLASS *getOperand(unsigned) const; \
111 inline void setOperand(unsigned, VALUECLASS*); \
112 inline op_iterator op_begin(); \
113 inline const_op_iterator op_begin() const; \
114 inline op_iterator op_end(); \
115 inline const_op_iterator op_end() const; \
117 template <int> inline Use &Op(); \
118 template <int> inline const Use &Op() const; \
120 inline unsigned getNumOperands() const
123#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS) \
124CLASS::op_iterator CLASS::op_begin() { \
125 return OperandTraits<CLASS>::op_begin(this); \
127CLASS::const_op_iterator CLASS::op_begin() const { \
128 return OperandTraits<CLASS>::op_begin(const_cast<CLASS*>(this)); \
130CLASS::op_iterator CLASS::op_end() { \
131 return OperandTraits<CLASS>::op_end(this); \
133CLASS::const_op_iterator CLASS::op_end() const { \
134 return OperandTraits<CLASS>::op_end(const_cast<CLASS*>(this)); \
136VALUECLASS *CLASS::getOperand(unsigned i_nocapture) const { \
137 assert(i_nocapture < OperandTraits<CLASS>::operands(this) \
138 && "getOperand() out of range!"); \
139 return cast_or_null<VALUECLASS>( \
140 OperandTraits<CLASS>::op_begin(const_cast<CLASS*>(this))[i_nocapture].get()); \
142void CLASS::setOperand(unsigned i_nocapture, VALUECLASS *Val_nocapture) { \
143 assert(i_nocapture < OperandTraits<CLASS>::operands(this) \
144 && "setOperand() out of range!"); \
145 OperandTraits<CLASS>::op_begin(this)[i_nocapture] = Val_nocapture; \
147unsigned CLASS::getNumOperands() const { \
148 return OperandTraits<CLASS>::operands(this); \
150template <int Idx_nocapture> Use &CLASS::Op() { \
151 return this->OpFrom<Idx_nocapture>(this); \
153template <int Idx_nocapture> const Use &CLASS::Op() const { \
154 return this->OpFrom<Idx_nocapture>(this); \
A Use represents the edge between a Value definition and its users.
unsigned getNumOperands() const
This is an optimization pass for GlobalISel generic memory operations.
FixedNumOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
static unsigned operands(const User *)
static Use * op_begin(SubClass *U)
static Use * op_end(SubClass *U)
HungoffOperandTraits - determine the allocation regime of the Use array when it is not a prefix to th...
static Use * op_end(User *U)
static Use * op_begin(User *U)
static unsigned operands(const User *U)
OptionalOperandTraits - when the number of operands may change at runtime.
static unsigned operands(const User *U)
VariadicOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
static Use * op_begin(SubClass *U)
static Use * op_end(SubClass *U)
static unsigned operands(const User *U)