diff options
author | Gabor Greif <ggreif@gmail.com> | 2009-02-11 22:09:00 +0000 |
---|---|---|
committer | Gabor Greif <ggreif@gmail.com> | 2009-02-11 22:09:00 +0000 |
commit | e3069ab6e5d1d9553517c11dfadf28ae9c0bb54b (patch) | |
tree | d0ade871601600d6a4df78388dd53360b7b202f6 | |
parent | 22cc840947548df3cd0192f12497b05475980401 (diff) | |
download | bcm5719-llvm-e3069ab6e5d1d9553517c11dfadf28ae9c0bb54b.tar.gz bcm5719-llvm-e3069ab6e5d1d9553517c11dfadf28ae9c0bb54b.zip |
Fill in a glaring omission in derived User classes, namely
add efficient versions of op_begin and op_end. Up to now always those from User have been
called, which in most cases follow an indirection (OperandList) even if the exact Instruction
type is known.
llvm-svn: 64331
-rw-r--r-- | llvm/include/llvm/OperandTraits.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/llvm/include/llvm/OperandTraits.h b/llvm/include/llvm/OperandTraits.h index 4c1c0382c86..a4b634c7623 100644 --- a/llvm/include/llvm/OperandTraits.h +++ b/llvm/include/llvm/OperandTraits.h @@ -119,6 +119,10 @@ 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 <unsigned> inline Use &Op(); \ template <unsigned> inline const Use &Op() const; \ @@ -127,6 +131,18 @@ struct HungoffOperandTraits { /// Macro for generating out-of-class operand accessor definitions #define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS) \ +CLASS::op_iterator CLASS::op_begin() { \ + return OperandTraits<CLASS>::op_begin(this); \ +} \ +CLASS::const_op_iterator CLASS::op_begin() const { \ + return OperandTraits<CLASS>::op_begin(const_cast<CLASS*>(this)); \ +} \ +CLASS::op_iterator CLASS::op_end() { \ + return OperandTraits<CLASS>::op_end(this); \ +} \ +CLASS::const_op_iterator CLASS::op_end() const { \ + return OperandTraits<CLASS>::op_end(const_cast<CLASS*>(this)); \ +} \ VALUECLASS *CLASS::getOperand(unsigned i_nocapture) const { \ assert(i_nocapture < OperandTraits<CLASS>::operands(this) \ && "getOperand() out of range!"); \ @@ -153,6 +169,18 @@ template <unsigned Idx_nocapture> const Use &CLASS::Op() const { \ /// 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<CLASS>::op_begin(this); \ +} \ +CLASS::const_op_iterator CLASS::op_begin() const { \ + return OperandTraits<CLASS>::op_begin(const_cast<CLASS*>(this)); \ +} \ +CLASS::op_iterator CLASS::op_end() { \ + return OperandTraits<CLASS>::op_end(this); \ +} \ +CLASS::const_op_iterator CLASS::op_end() const { \ + return OperandTraits<CLASS>::op_end(const_cast<CLASS*>(this)); \ +} \ VALUECLASS *CLASS::getOperand(unsigned i_nocapture) const { \ assert(i_nocapture < OperandTraits<CLASS>::operands(this) \ && "getOperand() out of range!"); \ |