15 #ifndef LLVM_IR_OPERANDTRAITS_H
16 #define LLVM_IR_OPERANDTRAITS_H
30 template <
typename SubClass,
unsigned ARITY>
33 return reinterpret_cast<Use*
>(U) - ARITY;
36 return reinterpret_cast<Use*
>(U);
50 template <
typename SubClass,
unsigned ARITY = 1>
65 template <
typename SubClass,
unsigned MINARITY = 0>
68 return reinterpret_cast<Use*
>(U) - static_cast<User*>(U)->getNumOperands();
71 return reinterpret_cast<Use*
>(U);
92 template <
unsigned MINARITY = 1>
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) \
124 CLASS::op_iterator CLASS::op_begin() { \
125 return OperandTraits<CLASS>::op_begin(this); \
127 CLASS::const_op_iterator CLASS::op_begin() const { \
128 return OperandTraits<CLASS>::op_begin(const_cast<CLASS*>(this)); \
130 CLASS::op_iterator CLASS::op_end() { \
131 return OperandTraits<CLASS>::op_end(this); \
133 CLASS::const_op_iterator CLASS::op_end() const { \
134 return OperandTraits<CLASS>::op_end(const_cast<CLASS*>(this)); \
136 VALUECLASS *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()); \
142 void 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; \
147 unsigned CLASS::getNumOperands() const { \
148 return OperandTraits<CLASS>::operands(this); \
150 template <int Idx_nocapture> Use &CLASS::Op() { \
151 return this->OpFrom<Idx_nocapture>(this); \
153 template <int Idx_nocapture> const Use &CLASS::Op() const { \
154 return this->OpFrom<Idx_nocapture>(this); \
static Use * op_end(SubClass *U)
unsigned getNumOperands() const
static Use * op_end(User *U)
static unsigned operands(const User *U)
static unsigned operands(const User *U)
static Use * op_end(SubClass *U)
static unsigned operands(const User *U)
static Use * op_begin(SubClass *U)
static Use * op_begin(SubClass *U)
static unsigned operands(const User *)
static Use * op_begin(User *U)