[llvm-commits] [llvm] r64331 - /llvm/trunk/include/llvm/OperandTraits.h

Gabor Greif ggreif at gmail.com
Wed Feb 11 14:09:02 PST 2009


Author: ggreif
Date: Wed Feb 11 16:09:00 2009
New Revision: 64331

URL: http://llvm.org/viewvc/llvm-project?rev=64331&view=rev
Log:
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.

Modified:
    llvm/trunk/include/llvm/OperandTraits.h

Modified: llvm/trunk/include/llvm/OperandTraits.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/OperandTraits.h?rev=64331&r1=64330&r2=64331&view=diff

==============================================================================
--- llvm/trunk/include/llvm/OperandTraits.h (original)
+++ llvm/trunk/include/llvm/OperandTraits.h Wed Feb 11 16:09:00 2009
@@ -119,6 +119,10 @@
   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 @@
 
 /// 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 @@
 /// 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!"); \





More information about the llvm-commits mailing list