From 07b4d5592ac761e48bf712f0dd07281bb7f8ab52 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Fri, 28 Sep 2012 16:40:29 +0000 Subject: [PATCH] PackedVector: Make the BitVector implementation configurable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164826 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/PackedVector.h | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/include/llvm/ADT/PackedVector.h b/include/llvm/ADT/PackedVector.h index 2eaddc2b4ee..1ae2a77e7ea 100644 --- a/include/llvm/ADT/PackedVector.h +++ b/include/llvm/ADT/PackedVector.h @@ -19,32 +19,32 @@ namespace llvm { -template +template class PackedVectorBase; // This won't be necessary if we can specialize members without specializing // the parent template. -template -class PackedVectorBase { +template +class PackedVectorBase { protected: - static T getValue(const llvm::BitVector &Bits, unsigned Idx) { + static T getValue(const BitVectorTy &Bits, unsigned Idx) { T val = T(); for (unsigned i = 0; i != BitNum; ++i) val = T(val | ((Bits[(Idx << (BitNum-1)) + i] ? 1UL : 0UL) << i)); return val; } - static void setValue(llvm::BitVector &Bits, unsigned Idx, T val) { + static void setValue(BitVectorTy &Bits, unsigned Idx, T val) { assert((val >> BitNum) == 0 && "value is too big"); for (unsigned i = 0; i != BitNum; ++i) Bits[(Idx << (BitNum-1)) + i] = val & (T(1) << i); } }; -template -class PackedVectorBase { +template +class PackedVectorBase { protected: - static T getValue(const llvm::BitVector &Bits, unsigned Idx) { + static T getValue(const BitVectorTy &Bits, unsigned Idx) { T val = T(); for (unsigned i = 0; i != BitNum-1; ++i) val = T(val | ((Bits[(Idx << (BitNum-1)) + i] ? 1UL : 0UL) << i)); @@ -53,7 +53,7 @@ protected: return val; } - static void setValue(llvm::BitVector &Bits, unsigned Idx, T val) { + static void setValue(BitVectorTy &Bits, unsigned Idx, T val) { if (val < 0) { val = ~val; Bits.set((Idx << (BitNum-1)) + BitNum-1); @@ -71,11 +71,12 @@ protected: /// @endcode /// will create a vector accepting values -2, -1, 0, 1. Any other value will hit /// an assertion. -template -class PackedVector : public PackedVectorBase +class PackedVector : public PackedVectorBase::is_signed> { - llvm::BitVector Bits; - typedef PackedVectorBase::is_signed> base; + BitVectorTy Bits; + typedef PackedVectorBase::is_signed> base; public: class reference {