[llvm] r202805 - [cleanup] Add a getOperandNo method to the Use class and implement it
Chandler Carruth
chandlerc at gmail.com
Tue Mar 4 01:19:44 PST 2014
Author: chandlerc
Date: Tue Mar 4 03:19:43 2014
New Revision: 202805
URL: http://llvm.org/viewvc/llvm-project?rev=202805&view=rev
Log:
[cleanup] Add a getOperandNo method to the Use class and implement it
out-of-line so that it can refer to the methods on User. As
a consequence, this removes the need to define one template method if
value_use_iterator in the extremely strange User.h header (!!!).
This makse Use.h slightly less peculiar. The only remaining real
peculiarity is the definition of Use::set in Value.h
Modified:
llvm/trunk/include/llvm/IR/Use.h
llvm/trunk/include/llvm/IR/User.h
llvm/trunk/lib/IR/Use.cpp
Modified: llvm/trunk/include/llvm/IR/Use.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Use.h?rev=202805&r1=202804&r2=202805&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Use.h (original)
+++ llvm/trunk/include/llvm/IR/Use.h Tue Mar 4 03:19:43 2014
@@ -116,6 +116,9 @@ public:
Use *getNext() const { return Next; }
+ /// \brief Return the operand # of this use in its User.
+ unsigned getOperandNo() const;
+
/// \brief Initializes the waymarking tags on an array of Uses.
///
/// This sets up the array of Uses such that getUser() can find the User from
@@ -208,9 +211,8 @@ public:
Use &getUse() const { return *U; }
/// \brief Return the operand # of this use in its User.
- ///
- /// Defined in User.h
- unsigned getOperandNo() const;
+ /// FIXME: Replace all callers with a direct call to Use::getOperandNo.
+ unsigned getOperandNo() const { return U->getOperandNo(); }
};
// Create wrappers for C Binding types (see CBindingWrapping.h).
Modified: llvm/trunk/include/llvm/IR/User.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/User.h?rev=202805&r1=202804&r2=202805&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/User.h (original)
+++ llvm/trunk/include/llvm/IR/User.h Tue Mar 4 03:19:43 2014
@@ -206,12 +206,6 @@ template<> struct simplify_type<User::co
}
};
-// value_use_iterator::getOperandNo - Requires the definition of the User class.
-template<typename UserTy>
-unsigned value_use_iterator<UserTy>::getOperandNo() const {
- return U - U->getUser()->op_begin();
-}
-
} // End llvm namespace
#endif
Modified: llvm/trunk/lib/IR/Use.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Use.cpp?rev=202805&r1=202804&r2=202805&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Use.cpp (original)
+++ llvm/trunk/lib/IR/Use.cpp Tue Mar 4 03:19:43 2014
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/IR/Use.h"
+#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
#include <new>
@@ -44,6 +45,10 @@ User *Use::getUser() const {
: reinterpret_cast<User *>(const_cast<Use *>(End));
}
+unsigned Use::getOperandNo() const {
+ return this - getUser()->op_begin();
+}
+
// Sets up the waymarking algoritm's tags for a series of Uses. See the
// algorithm details here:
//
More information about the llvm-commits
mailing list