14#ifndef LLVM_ADT_PACKEDVECTOR_H
15#define LLVM_ADT_PACKEDVECTOR_H
23template <
typename T,
unsigned BitNum,
typename BitVectorTy,
bool isSigned>
28template <
typename T,
unsigned BitNum,
typename BitVectorTy>
33 for (
unsigned i = 0; i != BitNum; ++i)
34 val =
T(val | ((Bits[(
Idx << (BitNum-1)) + i] ? 1UL : 0UL) << i));
39 assert((val >> BitNum) == 0 &&
"value is too big");
40 for (
unsigned i = 0; i != BitNum; ++i)
41 Bits[(
Idx << (BitNum-1)) + i] = val & (
T(1) << i);
45template <
typename T,
unsigned BitNum,
typename BitVectorTy>
50 for (
unsigned i = 0; i != BitNum-1; ++i)
51 val =
T(val | ((Bits[(
Idx << (BitNum-1)) + i] ? 1UL : 0UL) << i));
52 if (Bits[(
Idx << (BitNum-1)) + BitNum-1])
60 Bits.set((
Idx << (BitNum-1)) + BitNum-1);
62 assert((val >> (BitNum-1)) == 0 &&
"value is too big");
63 for (
unsigned i = 0; i != BitNum-1; ++i)
64 Bits[(
Idx << (BitNum-1)) + i] = val & (
T(1) << i);
75template <
typename T,
unsigned BitNum,
typename BitVectorTy = BitVector>
77 std::numeric_limits<T>::is_signed> {
80 std::numeric_limits<T>::is_signed>;
92 Vec.setValue(Vec.Bits,
Idx, val);
97 return Vec.getValue(Vec.Bits,
Idx);
104 bool empty()
const {
return Bits.empty(); }
106 unsigned size()
const {
return Bits.size() >> (BitNum - 1); }
110 void resize(
unsigned N) { Bits.resize(
N << (BitNum - 1)); }
112 void reserve(
unsigned N) { Bits.reserve(
N << (BitNum-1)); }
121 (*this)[
size()-1] = val;
129 return base::getValue(Bits,
Idx);
133 return Bits ==
RHS.Bits;
137 return Bits !=
RHS.Bits;
145 const BitVectorTy &
raw_bits()
const {
return Bits; }
150template <
typename T>
class PackedVector<
T, 0>;
This file implements the BitVector class.
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static T getValue(const BitVectorTy &Bits, unsigned Idx)
static void setValue(BitVectorTy &Bits, unsigned Idx, T val)
static T getValue(const BitVectorTy &Bits, unsigned Idx)
static void setValue(BitVectorTy &Bits, unsigned Idx, T val)
reference(PackedVector &vec, unsigned idx)
reference & operator=(T val)
Store a vector of values using a specific number of bits for each value.
const BitVectorTy & raw_bits() const
T operator[](unsigned Idx) const
PackedVector(unsigned size)
PackedVector & operator|=(const PackedVector &RHS)
bool operator!=(const PackedVector &RHS) const
bool operator==(const PackedVector &RHS) const
reference operator[](unsigned Idx)
This is an optimization pass for GlobalISel generic memory operations.