From 6cd093b56e80ed54a2062e789937a096ba3afe56 Mon Sep 17 00:00:00 2001 From: Gabor Greif Date: Wed, 11 Feb 2009 22:09:00 +0000 Subject: 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64331 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/OperandTraits.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'include/llvm/OperandTraits.h') diff --git a/include/llvm/OperandTraits.h b/include/llvm/OperandTraits.h index 4c1c0382c8..a4b634c762 100644 --- a/include/llvm/OperandTraits.h +++ b/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 inline Use &Op(); \ template 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::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!"); \ @@ -153,6 +169,18 @@ template 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::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!"); \ -- cgit v1.2.3