X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FOperandTraits.h;h=f0df5fa9bde82336f6c07edeff452ce849b810ab;hb=07ea23aa2d17f701fa125442c20c1eba75b55fdb;hp=83c1025c07b7ab8d797c2806a123f0f2a10880e3;hpb=20cb46287cf5deb49cb484c9770e73f7cf246e7b;p=oota-llvm.git diff --git a/include/llvm/OperandTraits.h b/include/llvm/OperandTraits.h index 83c1025c07b..f0df5fa9bde 100644 --- a/include/llvm/OperandTraits.h +++ b/include/llvm/OperandTraits.h @@ -20,43 +20,35 @@ namespace llvm { //===----------------------------------------------------------------------===// -// FixedNumOperands Trait Class +// FixedNumOperand Trait Class //===----------------------------------------------------------------------===// /// FixedNumOperandTraits - determine the allocation regime of the Use array /// when it is a prefix to the User object, and the number of Use objects is /// known at compile time. -template +template struct FixedNumOperandTraits { - static Use *op_begin(User* U) { + static Use *op_begin(SubClass* U) { return reinterpret_cast(U) - ARITY; } - static Use *op_end(User* U) { + static Use *op_end(SubClass* U) { return reinterpret_cast(U); } static unsigned operands(const User*) { return ARITY; } - struct prefix { - Use Ops[ARITY]; - prefix(); // DO NOT IMPLEMENT - }; - template - struct Layout { - struct overlay : prefix, U { - overlay(); // DO NOT IMPLEMENT - }; - }; - static inline void *allocate(unsigned); // FIXME }; //===----------------------------------------------------------------------===// -// OptionalOperands Trait Class +// OptionalOperand Trait Class //===----------------------------------------------------------------------===// -template -struct OptionalOperandTraits : FixedNumOperandTraits { +/// OptionalOperandTraits - when the number of operands may change at runtime. +/// Naturally it may only decrease, because the allocations may not change. + +template +struct OptionalOperandTraits : public FixedNumOperandTraits { static unsigned operands(const User *U) { return U->getNumOperands(); } @@ -70,18 +62,17 @@ struct OptionalOperandTraits : FixedNumOperandTraits { /// when it is a prefix to the User object, and the number of Use objects is /// only known at allocation time. -template +template struct VariadicOperandTraits { - static Use *op_begin(User* U) { - return reinterpret_cast(U) - U->getNumOperands(); + static Use *op_begin(SubClass* U) { + return reinterpret_cast(U) - static_cast(U)->getNumOperands(); } - static Use *op_end(User* U) { + static Use *op_end(SubClass* U) { return reinterpret_cast(U); } static unsigned operands(const User *U) { return U->getNumOperands(); } - static inline void *allocate(unsigned); // FIXME }; //===----------------------------------------------------------------------===// @@ -109,7 +100,6 @@ struct HungoffOperandTraits { static unsigned operands(const User *U) { return U->getNumOperands(); } - static inline void *allocate(unsigned); // FIXME }; /// Macro for generating in-class operand accessor declarations.