[llvm-commits] [llvm] r49495 - in /llvm/branches/ggreif/use-diet/include/llvm: InstrTypes.h Instructions.h OperandTraits.h
Gabor Greif
ggreif at gmail.com
Thu Apr 10 13:38:24 PDT 2008
Author: ggreif
Date: Thu Apr 10 15:38:24 2008
New Revision: 49495
URL: http://llvm.org/viewvc/llvm-project?rev=49495&view=rev
Log:
moved FixedNumOperands to OperandTraits.h
Modified:
llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h
llvm/branches/ggreif/use-diet/include/llvm/Instructions.h
llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h
Modified: llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h?rev=49495&r1=49494&r2=49495&view=diff
==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h Thu Apr 10 15:38:24 2008
@@ -17,6 +17,7 @@
#define LLVM_INSTRUCTION_TYPES_H
#include "llvm/Instruction.h"
+#include "llvm/OperandTraits.h"
namespace llvm {
@@ -78,60 +79,6 @@
}
};
-//===----------------------------------------------------------------------===//
-// FixedNumOperands Trait Class
-//===----------------------------------------------------------------------===//
-
-template <unsigned ARITY>
-struct FixedNumOperandTraits {
- static Use *op_begin(User* U) {
- return reinterpret_cast<Use*>(U) - ARITY;
- }
- static Use *op_end(User* U) {
- return reinterpret_cast<Use*>(U);
- }
- static unsigned operands(const User*) {
- return ARITY;
- }
- struct prefix {
- Use Ops[ARITY];
- prefix(); // DO NOT IMPLEMENT
- };
- template <class U>
- struct Layout {
- struct overlay : prefix, U {
- overlay(); // DO NOT IMPLEMENT
- };
- };
- static inline void *allocate(unsigned); // FIXME
-};
-
-/// Macro for generating in-class operand accessor declarations
-#define DECLARE_TRANSPARENT_OPERAND_ACCESSORS(VALUECLASS) \
- inline VALUECLASS *getOperand(unsigned) const; \
- inline void setOperand(unsigned, VALUECLASS*); \
- inline unsigned getNumOperands() const; \
- template <unsigned Idx> inline Use &Op(); \
- template <unsigned Idx> inline const Use &Op() const
-
-/// Macro for generating out-of-class operand accessor definitions
-#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS) \
-VALUECLASS *CLASS::getOperand(unsigned i) const { \
- assert(i < OperandTraits<CLASS>::operands(this) && "getOperand() out of range!"); \
- return OperandTraits<CLASS>::op_begin(const_cast<CLASS*>(this))[i]; \
-} \
-void CLASS::setOperand(unsigned i, VALUECLASS *Val) { \
- assert(i < OperandTraits<CLASS>::operands(this) && "setOperand() out of range!"); \
- OperandTraits<CLASS>::op_begin(this)[i] = Val; \
-} \
-unsigned CLASS::getNumOperands() const { return OperandTraits<CLASS>::operands(this); } \
-template <unsigned Idx> Use &CLASS::Op() { \
- return OperandTraits<CLASS>::op_begin(this)[Idx]; \
-} \
-template <unsigned Idx> const Use &CLASS::Op() const { \
- return OperandTraits<CLASS>::op_begin(const_cast<CLASS*>(this))[Idx]; \
-}
-
//===----------------------------------------------------------------------===//
// UnaryInstruction Class
Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Instructions.h?rev=49495&r1=49494&r2=49495&view=diff
==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/Instructions.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Thu Apr 10 15:38:24 2008
@@ -21,7 +21,6 @@
#include "llvm/InstrTypes.h"
#include "llvm/DerivedTypes.h"
#include "llvm/ParameterAttributes.h"
-#include "llvm/OperandTraits.h"
namespace llvm {
Modified: llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h?rev=49495&r1=49494&r2=49495&view=diff
==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h Thu Apr 10 15:38:24 2008
@@ -18,6 +18,34 @@
namespace llvm {
//===----------------------------------------------------------------------===//
+// FixedNumOperands Trait Class
+//===----------------------------------------------------------------------===//
+
+template <unsigned ARITY>
+struct FixedNumOperandTraits {
+ static Use *op_begin(User* U) {
+ return reinterpret_cast<Use*>(U) - ARITY;
+ }
+ static Use *op_end(User* U) {
+ return reinterpret_cast<Use*>(U);
+ }
+ static unsigned operands(const User*) {
+ return ARITY;
+ }
+ struct prefix {
+ Use Ops[ARITY];
+ prefix(); // DO NOT IMPLEMENT
+ };
+ template <class U>
+ struct Layout {
+ struct overlay : prefix, U {
+ overlay(); // DO NOT IMPLEMENT
+ };
+ };
+ static inline void *allocate(unsigned); // FIXME
+};
+
+//===----------------------------------------------------------------------===//
// VariadicOperand Trait Class
//===----------------------------------------------------------------------===//
More information about the llvm-commits
mailing list