aboutsummaryrefslogtreecommitdiff
path: root/llvm/include
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/ADT/PackedVector.h35
1 files changed, 13 insertions, 22 deletions
diff --git a/llvm/include/llvm/ADT/PackedVector.h b/llvm/include/llvm/ADT/PackedVector.h
index 4e31d3f0..77fcbf2 100644
--- a/llvm/include/llvm/ADT/PackedVector.h
+++ b/llvm/include/llvm/ADT/PackedVector.h
@@ -47,7 +47,7 @@ class PackedVectorBase<T, BitNum, BitVectorTy, true> {
protected:
static T getValue(const BitVectorTy &Bits, unsigned Idx) {
T val = T();
- for (unsigned i = 0; i != BitNum-1; ++i)
+ for (unsigned i = 0; i != BitNum - 1; ++i)
val = T(val | ((Bits[(Idx * BitNum) + i] ? 1UL : 0UL) << i));
if (Bits[(Idx * BitNum) + BitNum - 1])
val = ~val;
@@ -61,8 +61,8 @@ protected:
} else {
Bits.reset((Idx * BitNum) + BitNum - 1);
}
- assert((val >> (BitNum-1)) == 0 && "value is too big");
- for (unsigned i = 0; i != BitNum-1; ++i)
+ assert((val >> (BitNum - 1)) == 0 && "value is too big");
+ for (unsigned i = 0; i != BitNum - 1; ++i)
Bits[(Idx * BitNum) + i] = val & (T(1) << i);
}
};
@@ -75,8 +75,9 @@ protected:
/// will create a vector accepting values -2, -1, 0, 1. Any other value will hit
/// an assertion.
template <typename T, unsigned BitNum, typename BitVectorTy = BitVector>
-class PackedVector : public PackedVectorBase<T, BitNum, BitVectorTy,
- std::numeric_limits<T>::is_signed> {
+class PackedVector
+ : public PackedVectorBase<T, BitNum, BitVectorTy,
+ std::numeric_limits<T>::is_signed> {
BitVectorTy Bits;
// Keep track of the number of elements on our own.
// We always maintain Bits.size() == NumElements * BitNum.
@@ -99,9 +100,7 @@ public:
return *this;
}
- operator T() const {
- return Vec.getValue(Vec.Bits, Idx);
- }
+ operator T() const { return Vec.getValue(Vec.Bits, Idx); }
};
PackedVector() = default;
@@ -130,25 +129,17 @@ public:
}
void push_back(T val) {
- resize(size()+1);
- (*this)[size()-1] = val;
+ resize(size() + 1);
+ (*this)[size() - 1] = val;
}
- reference operator[](unsigned Idx) {
- return reference(*this, Idx);
- }
+ reference operator[](unsigned Idx) { return reference(*this, Idx); }
- T operator[](unsigned Idx) const {
- return base::getValue(Bits, Idx);
- }
+ T operator[](unsigned Idx) const { return base::getValue(Bits, Idx); }
- bool operator==(const PackedVector &RHS) const {
- return Bits == RHS.Bits;
- }
+ bool operator==(const PackedVector &RHS) const { return Bits == RHS.Bits; }
- bool operator!=(const PackedVector &RHS) const {
- return Bits != RHS.Bits;
- }
+ bool operator!=(const PackedVector &RHS) const { return Bits != RHS.Bits; }
PackedVector &operator|=(const PackedVector &RHS) {
Bits |= RHS.Bits;