14 #ifndef LLVM_IR_OPERANDTRAITS_H 15 #define LLVM_IR_OPERANDTRAITS_H 29 template <
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);
52 template <
typename SubClass,
unsigned ARITY = 1>
67 template <
typename SubClass,
unsigned MINARITY = 0>
71 !std::is_polymorphic<SubClass>::value,
72 "adding virtual methods to subclasses of User breaks use lists");
73 return reinterpret_cast<Use*
>(U) - static_cast<User*>(U)->getNumOperands();
76 return reinterpret_cast<Use*
>(U);
94 template <
unsigned MINARITY = 1>
110 #define DECLARE_TRANSPARENT_OPERAND_ACCESSORS(VALUECLASS) \ 112 inline VALUECLASS *getOperand(unsigned) const; \ 113 inline void setOperand(unsigned, VALUECLASS*); \ 114 inline op_iterator op_begin(); \ 115 inline const_op_iterator op_begin() const; \ 116 inline op_iterator op_end(); \ 117 inline const_op_iterator op_end() const; \ 119 template <int> inline Use &Op(); \ 120 template <int> inline const Use &Op() const; \ 122 inline unsigned getNumOperands() const 125 #define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS) \ 126 CLASS::op_iterator CLASS::op_begin() { \ 127 return OperandTraits<CLASS>::op_begin(this); \ 129 CLASS::const_op_iterator CLASS::op_begin() const { \ 130 return OperandTraits<CLASS>::op_begin(const_cast<CLASS*>(this)); \ 132 CLASS::op_iterator CLASS::op_end() { \ 133 return OperandTraits<CLASS>::op_end(this); \ 135 CLASS::const_op_iterator CLASS::op_end() const { \ 136 return OperandTraits<CLASS>::op_end(const_cast<CLASS*>(this)); \ 138 VALUECLASS *CLASS::getOperand(unsigned i_nocapture) const { \ 139 assert(i_nocapture < OperandTraits<CLASS>::operands(this) \ 140 && "getOperand() out of range!"); \ 141 return cast_or_null<VALUECLASS>( \ 142 OperandTraits<CLASS>::op_begin(const_cast<CLASS*>(this))[i_nocapture].get()); \ 144 void CLASS::setOperand(unsigned i_nocapture, VALUECLASS *Val_nocapture) { \ 145 assert(i_nocapture < OperandTraits<CLASS>::operands(this) \ 146 && "setOperand() out of range!"); \ 147 OperandTraits<CLASS>::op_begin(this)[i_nocapture] = Val_nocapture; \ 149 unsigned CLASS::getNumOperands() const { \ 150 return OperandTraits<CLASS>::operands(this); \ 152 template <int Idx_nocapture> Use &CLASS::Op() { \ 153 return this->OpFrom<Idx_nocapture>(this); \ 155 template <int Idx_nocapture> const Use &CLASS::Op() const { \ 156 return this->OpFrom<Idx_nocapture>(this); \ static Use * op_end(SubClass *U)
This class represents lattice values for constants.
static Use * op_end(User *U)
A Use represents the edge between a Value definition and its users.
static unsigned operands(const User *U)
const Use * getOperandList() const
static unsigned operands(const User *U)
static Use * op_end(SubClass *U)
static unsigned operands(const User *U)
OptionalOperandTraits - when the number of operands may change at runtime.
unsigned getNumOperands() const
static Use * op_begin(SubClass *U)
static Use * op_begin(SubClass *U)
static unsigned operands(const User *)
HungoffOperandTraits - determine the allocation regime of the Use array when it is not a prefix to th...
FixedNumOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
VariadicOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
static Use * op_begin(User *U)