[llvm-commits] [llvm] r49525 - in /llvm/branches/ggreif/use-diet: include/llvm/OperandTraits.h lib/Bitcode/Reader/BitcodeReader.cpp lib/Bitcode/Reader/BitcodeReader.h
Dan Gohman
gohman at apple.com
Thu May 29 15:36:55 PDT 2008
Hi Gabor,
Can you give HungoffOperandTraits a doxygen comment? I can mostly
guess what FixedNumOperandTraits and VariadicOperandTraits are
from their names, and even OptionalOperands mostly too, but
HungoffOperandTraits isn't quite obvious :-).
Thanks,
Dan
On Apr 11, 2008, at 3:15 AM, Gabor Greif wrote:
> Author: ggreif
> Date: Fri Apr 11 05:15:41 2008
> New Revision: 49525
>
> URL: http://llvm.org/viewvc/llvm-project?rev=49525&view=rev
> Log:
> implement more bits of BitcodeReader. move HungoffOperand to
> OperandTraits.h
>
> Modified:
> llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h
> llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp
> llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h
>
> 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=49525&r1=49524&r2=49525&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h
> (original)
> +++ llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h Fri
> Apr 11 05:15:41 2008
> @@ -7,7 +7,9 @@
> //
> //
> =
> =
> =
> ----------------------------------------------------------------------=
> ==//
> //
> -// This file defines the FIXME.
> +// This file defines the traits classes that are handy for
> enforcing the correct
> +// layout of various User subclasses. It also provides the means
> for accessing
> +// the operands in the most efficient manner.
> //
>
> #ifndef LLVM_OPERAND_TRAITS_H
> @@ -63,6 +65,24 @@
> static inline void *allocate(unsigned); // FIXME
> };
>
> +//
> =
> =
> =
> ----------------------------------------------------------------------=
> ==//
> +// HungoffOperand Trait Class
> +//
> =
> =
> =
> ----------------------------------------------------------------------=
> ==//
> +
> +template <unsigned MINARITY = 1>
> +struct HungoffOperandTraits {
> + static Use *op_begin(User* U) {
> + return U->OperandList;
> + }
> + static Use *op_end(User* U) {
> + return U->OperandList + U->getNumOperands();
> + }
> + static unsigned operands(const User *U) {
> + return U->getNumOperands();
> + }
> + 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; \
>
> Modified: llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/
> BitcodeReader.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp?rev=49525&r1=49524&r2=49525&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/
> BitcodeReader.cpp (original)
> +++ llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/
> BitcodeReader.cpp Fri Apr 11 05:15:41 2008
> @@ -154,7 +154,10 @@
>
> if (Desired > Capacity)
> {
> - // FIXME
> + Use *New = allocHangoffUses(Desired);
> + for (int i(getNumOperands() - 1); i >= 0; --i)
> + New[i] = getOperand(i);
> + OperandList = New;
> }
> }
>
>
> Modified: llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/
> BitcodeReader.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h?rev=49525&r1=49524&r2=49525&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h
> (original)
> +++ llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h
> Fri Apr 11 05:15:41 2008
> @@ -27,24 +27,6 @@
> class MemoryBuffer;
>
> //
> =
> =
> =
> ----------------------------------------------------------------------=
> ==//
> -// HungoffOperand Trait Class
> -//
> =
> =
> =
> ----------------------------------------------------------------------=
> ==//
> -
> -template <unsigned MINARITY = 1>
> -struct HungoffOperandTraits {
> - static Use *op_begin(User* U) {
> - return U->OperandList;
> - }
> - static Use *op_end(User* U) {
> - return U->OperandList + U->getNumOperands();
> - }
> - static unsigned operands(const User *U) {
> - return U->getNumOperands();
> - }
> - static inline void *allocate(unsigned); // FIXME
> -};
> -
> -//
> =
> =
> =
> ----------------------------------------------------------------------=
> ==//
> // BitcodeReaderValueList Class
> //
> =
> =
> =
> ----------------------------------------------------------------------=
> ==//
>
> @@ -59,8 +41,6 @@
> unsigned size() const { return getNumOperands(); }
> void resize(unsigned);
> void push_back(Value *V) {
> -// Uses.push_back(Use(V, this));
> -// OperandList = &Uses[0];
> ++NumOperands;
> }
>
> @@ -75,8 +55,6 @@
> bool empty() const { return NumOperands == 0; }
> void shrinkTo(unsigned N) {
> assert(N <= NumOperands && "Invalid shrinkTo request!");
> -// Uses.resize(N);
> -// NumOperands = N;
> while (NumOperands > N)
> pop_back();
> }
> @@ -100,8 +78,12 @@
>
> private:
> void initVal(unsigned Idx, Value *V) {
> -// assert(Uses[Idx] == 0 && "Cannot init an already init'd Use!");
> -// Uses[Idx].init(V, this);
> + if (Idx >= size()) {
> + // Insert a bunch of null values.
> + resize(Idx * 2 + 1);
> + }
> + assert(getOperand(Idx) == 0 && "Cannot init an already init'd
> Use!");
> + OperandList[Idx].init(V, this);
> }
> };
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list