14 #ifndef LLVM_ADT_PACKEDVECTOR_H 15 #define LLVM_ADT_PACKEDVECTOR_H 23 template <
typename T,
unsigned BitNum,
typename BitVectorTy,
bool isSigned>
28 template <
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);
45 template <
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);
75 template <
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;
151 #endif // LLVM_ADT_PACKEDVECTOR_H PackedVector & operator|=(const PackedVector &RHS)
This class represents lattice values for constants.
bool operator==(const PackedVector &RHS) const
static T getValue(const BitVectorTy &Bits, unsigned Idx)
block Block Frequency true
reference operator[](unsigned Idx)
static T getValue(const BitVectorTy &Bits, unsigned Idx)
static void setValue(BitVectorTy &Bits, unsigned Idx, T val)
Store a vector of values using a specific number of bits for each value.
PackedVector(unsigned size)
bool operator!=(const PackedVector &RHS) const
reference(PackedVector &vec, unsigned idx)
static void setValue(BitVectorTy &Bits, unsigned Idx, T val)
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
T operator[](unsigned Idx) const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
reference & operator=(T val)