summaryrefslogtreecommitdiff
path: root/include/llvm/OperandTraits.h
diff options
context:
space:
mode:
authorGabor Greif <ggreif@gmail.com>2009-03-10 23:02:13 +0000
committerGabor Greif <ggreif@gmail.com>2009-03-10 23:02:13 +0000
commit20cb46287cf5deb49cb484c9770e73f7cf246e7b (patch)
treec119fbf99a067fbcd94cb7ea2528dba9870d2f79 /include/llvm/OperandTraits.h
parent68edf5f68a9e25120f06ab30e064a869eb83018e (diff)
downloadllvm-20cb46287cf5deb49cb484c9770e73f7cf246e7b.tar.gz
llvm-20cb46287cf5deb49cb484c9770e73f7cf246e7b.tar.bz2
llvm-20cb46287cf5deb49cb484c9770e73f7cf246e7b.tar.xz
Give Op<N>() AppleScript-like semantics, i.e. for negative N it indexes relative to op_end.
This is a preliminary to changes to come. No intended functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66593 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/OperandTraits.h')
-rw-r--r--include/llvm/OperandTraits.h22
1 files changed, 10 insertions, 12 deletions
diff --git a/include/llvm/OperandTraits.h b/include/llvm/OperandTraits.h
index a4b634c762..83c1025c07 100644
--- a/include/llvm/OperandTraits.h
+++ b/include/llvm/OperandTraits.h
@@ -124,8 +124,8 @@ struct HungoffOperandTraits {
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; \
+ template <int> inline Use &Op(); \
+ template <int> inline const Use &Op() const; \
public: \
inline unsigned getNumOperands() const
@@ -157,12 +157,11 @@ void CLASS::setOperand(unsigned i_nocapture, VALUECLASS *Val_nocapture) { \
unsigned CLASS::getNumOperands() const { \
return OperandTraits<CLASS>::operands(this); \
} \
-template <unsigned Idx_nocapture> Use &CLASS::Op() { \
- return OperandTraits<CLASS>::op_begin(this)[Idx_nocapture]; \
+template <int Idx_nocapture> Use &CLASS::Op() { \
+ return this->OpFrom<Idx_nocapture>(this); \
} \
-template <unsigned Idx_nocapture> const Use &CLASS::Op() const { \
- return OperandTraits<CLASS>::op_begin( \
- const_cast<CLASS*>(this))[Idx_nocapture]; \
+template <int Idx_nocapture> const Use &CLASS::Op() const { \
+ return this->OpFrom<Idx_nocapture>(this); \
}
@@ -195,12 +194,11 @@ void CLASS::setOperand(unsigned i_nocapture, VALUECLASS *Val_nocapture) { \
unsigned CLASS::getNumOperands() const { \
return OperandTraits<CLASS>::operands(this); \
} \
-template <unsigned Idx_nocapture> Use &CLASS::Op() { \
- return OperandTraits<CLASS>::op_begin(this)[Idx_nocapture]; \
+template <int Idx_nocapture> Use &CLASS::Op() { \
+ return this->OpFrom<Idx_nocapture>(this); \
} \
-template <unsigned Idx_nocapture> const Use &CLASS::Op() const { \
- return OperandTraits<CLASS>::op_begin( \
- const_cast<CLASS*>(this))[Idx_nocapture]; \
+template <int Idx_nocapture> const Use &CLASS::Op() const { \
+ return this->OpFrom<Idx_nocapture>(this); \
}