X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FOperandTraits.h;h=b614ccbc3777a31e9c2c922e05ad88bc1789ea34;hb=c8141dfc7f983cb04e65d8acd6bcbdc8e4b8a0ae;hp=a4b634c76238a07eed9fd8fdf4a62cc9d5565652;hpb=6cd093b56e80ed54a2062e789937a096ba3afe56;p=oota-llvm.git diff --git a/include/llvm/OperandTraits.h b/include/llvm/OperandTraits.h index a4b634c7623..b614ccbc377 100644 --- a/include/llvm/OperandTraits.h +++ b/include/llvm/OperandTraits.h @@ -20,7 +20,7 @@ namespace llvm { //===----------------------------------------------------------------------===// -// FixedNumOperands Trait Class +// FixedNumOperand Trait Class //===----------------------------------------------------------------------===// /// FixedNumOperandTraits - determine the allocation regime of the Use array @@ -44,19 +44,21 @@ struct FixedNumOperandTraits { }; template struct Layout { - struct overlay : prefix, U { + struct overlay : public prefix, public U { overlay(); // DO NOT IMPLEMENT }; }; - static inline void *allocate(unsigned); // FIXME }; //===----------------------------------------------------------------------===// -// OptionalOperands Trait Class +// OptionalOperand Trait Class //===----------------------------------------------------------------------===// +/// OptionalOperandTraits - when the number of operands may change at runtime. +/// Naturally it may only decrease, because the allocations may not change. + template -struct OptionalOperandTraits : FixedNumOperandTraits { +struct OptionalOperandTraits : public FixedNumOperandTraits { static unsigned operands(const User *U) { return U->getNumOperands(); } @@ -81,7 +83,6 @@ struct VariadicOperandTraits { static unsigned operands(const User *U) { return U->getNumOperands(); } - static inline void *allocate(unsigned); // FIXME }; //===----------------------------------------------------------------------===// @@ -109,7 +110,6 @@ struct HungoffOperandTraits { static unsigned operands(const User *U) { return U->getNumOperands(); } - static inline void *allocate(unsigned); // FIXME }; /// Macro for generating in-class operand accessor declarations. @@ -124,8 +124,8 @@ struct HungoffOperandTraits { inline op_iterator op_end(); \ inline const_op_iterator op_end() const; \ protected: \ - template inline Use &Op(); \ - template inline const Use &Op() const; \ + template inline Use &Op(); \ + template inline const Use &Op() const; \ public: \ inline unsigned getNumOperands() const @@ -157,12 +157,11 @@ void CLASS::setOperand(unsigned i_nocapture, VALUECLASS *Val_nocapture) { \ unsigned CLASS::getNumOperands() const { \ return OperandTraits::operands(this); \ } \ -template Use &CLASS::Op() { \ - return OperandTraits::op_begin(this)[Idx_nocapture]; \ +template Use &CLASS::Op() { \ + return this->OpFrom(this); \ } \ -template const Use &CLASS::Op() const { \ - return OperandTraits::op_begin( \ - const_cast(this))[Idx_nocapture]; \ +template const Use &CLASS::Op() const { \ + return this->OpFrom(this); \ } @@ -195,12 +194,11 @@ void CLASS::setOperand(unsigned i_nocapture, VALUECLASS *Val_nocapture) { \ unsigned CLASS::getNumOperands() const { \ return OperandTraits::operands(this); \ } \ -template Use &CLASS::Op() { \ - return OperandTraits::op_begin(this)[Idx_nocapture]; \ +template Use &CLASS::Op() { \ + return this->OpFrom(this); \ } \ -template const Use &CLASS::Op() const { \ - return OperandTraits::op_begin( \ - const_cast(this))[Idx_nocapture]; \ +template const Use &CLASS::Op() const { \ + return this->OpFrom(this); \ }