X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FOperandTraits.h;h=b614ccbc3777a31e9c2c922e05ad88bc1789ea34;hb=c8141dfc7f983cb04e65d8acd6bcbdc8e4b8a0ae;hp=028d124e463a628617ea4b6e98b8960aae4f57b6;hpb=07252fd463d2378383ae035e45f6ed3c12959efe;p=oota-llvm.git diff --git a/include/llvm/OperandTraits.h b/include/llvm/OperandTraits.h index 028d124e463..b614ccbc377 100644 --- a/include/llvm/OperandTraits.h +++ b/include/llvm/OperandTraits.h @@ -1,4 +1,4 @@ -//===-- llvm/OperandTraits.h - OperandTraits class definition ---------------------*- C++ -*-===// +//===-- llvm/OperandTraits.h - OperandTraits class definition ---*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -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. @@ -119,14 +119,30 @@ struct HungoffOperandTraits { public: \ inline VALUECLASS *getOperand(unsigned) const; \ inline void setOperand(unsigned, VALUECLASS*); \ + inline op_iterator op_begin(); \ + inline const_op_iterator op_begin() const; \ + 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 /// Macro for generating out-of-class operand accessor definitions #define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS) \ +CLASS::op_iterator CLASS::op_begin() { \ + return OperandTraits::op_begin(this); \ +} \ +CLASS::const_op_iterator CLASS::op_begin() const { \ + return OperandTraits::op_begin(const_cast(this)); \ +} \ +CLASS::op_iterator CLASS::op_end() { \ + return OperandTraits::op_end(this); \ +} \ +CLASS::const_op_iterator CLASS::op_end() const { \ + return OperandTraits::op_end(const_cast(this)); \ +} \ VALUECLASS *CLASS::getOperand(unsigned i_nocapture) const { \ assert(i_nocapture < OperandTraits::operands(this) \ && "getOperand() out of range!"); \ @@ -141,18 +157,29 @@ 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); \ } /// Macro for generating out-of-class operand accessor /// definitions with casted result #define DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(CLASS, VALUECLASS) \ +CLASS::op_iterator CLASS::op_begin() { \ + return OperandTraits::op_begin(this); \ +} \ +CLASS::const_op_iterator CLASS::op_begin() const { \ + return OperandTraits::op_begin(const_cast(this)); \ +} \ +CLASS::op_iterator CLASS::op_end() { \ + return OperandTraits::op_end(this); \ +} \ +CLASS::const_op_iterator CLASS::op_end() const { \ + return OperandTraits::op_end(const_cast(this)); \ +} \ VALUECLASS *CLASS::getOperand(unsigned i_nocapture) const { \ assert(i_nocapture < OperandTraits::operands(this) \ && "getOperand() out of range!"); \ @@ -167,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); \ }