Go to the documentation of this file.
36 #ifndef __ARCH_GENERIC_VEC_PRED_REG_HH__
37 #define __ARCH_GENERIC_VEC_PRED_REG_HH__
43 #include <type_traits>
52 template <
size_t NumBits,
bool Packed>
71 template <
typename VecElem,
size_t NumElems,
bool Packed,
bool Const>
76 static constexpr
size_t NUM_BITS = Packed ? NumElems :
81 using Container =
typename std::conditional_t<
96 template<
bool Condition = !Const>
100 template<
bool Condition = !Const>
103 template<
bool Condition = !Const>
104 std::enable_if_t<Condition, MyClass&>
117 template<
bool Condition = !Const>
118 std::enable_if_t<Condition, bool&>
130 (Packed ? 1 :
sizeof(
VecElem)));
134 template<
bool Condition = !Const>
135 std::enable_if_t<Condition>
143 template<
typename VE2,
size_t NE2,
bool P2,
bool C2>
151 template<
typename VE2,
size_t NE2,
bool P2,
bool C2>
175 size_t actual_num_elems)
const
177 assert(actual_num_elems <= NumElems);
178 for (
int i = 0;
i < actual_num_elems; ++
i) {
193 size_t actual_num_elems)
const
195 assert(actual_num_elems <= NumElems);
196 for (
int i = 0;
i < actual_num_elems; ++
i) {
197 if (
mask[
i] &&
operator[](
i)) {
211 size_t actual_num_elems)
const
213 assert(actual_num_elems <= NumElems);
214 for (
int i = actual_num_elems - 1;
i >= 0; --
i) {
229 template <
size_t NumBits,
bool Packed>
232 static_assert(NumBits > 0,
233 "Size of a predicate register must be > 0");
262 std::copy(that.begin(), that.end(),
container.begin());
281 template<
size_t N2,
bool P2>
285 return NumBits == N2 && Packed == P2 &&
container == that.container;
289 template<
size_t N2,
bool P2>
308 assert(nbits > 0 && nbits <= 8 && (idx + nbits - 1) < NumBits);
310 idx = idx + nbits - 1;
311 for (
int i = 0;
i < nbits; ++
i, --idx) {
321 setBits(
size_t idx, uint8_t nbits, uint8_t bval)
323 assert(nbits > 0 && nbits <= 8 && (idx + nbits - 1) < NumBits);
324 for (
int i = 0;
i < nbits; ++
i, ++idx) {
334 for (
int i = 0;
i < NumBits;
i++)
346 template <
typename VecElem>
350 static_assert(NumBits %
sizeof(
VecElem) == 0,
351 "Container size incompatible with view size.");
353 Packed ? NumBits : (NumBits /
sizeof(
VecElem)),
354 Packed,
true>(*this);
357 template <
typename VecElem>
361 static_assert(NumBits %
sizeof(
VecElem) == 0,
362 "Container size incompatible with view size.");
364 Packed ? NumBits : (NumBits /
sizeof(
VecElem)),
365 Packed,
false>(*this);
370 template <
size_t NumBits,
bool Packed>
377 for (
const auto&
c:
s)
378 value[
i++] = (
c ==
'1');
383 template <
size_t NumBits,
bool Packed>
389 for (
auto b: value.container)
402 #endif // __ARCH_GENERIC_VEC_PRED_REG_HH__
void setBits(size_t idx, uint8_t nbits, uint8_t bval)
Set a subset of bits starting from a specific element in the container.
bool operator!=(const VecPredRegContainer< N2, P2 > &that) const
Inequality operator, required to compare thread contexts.
Generic predicate register container.
VecPredReg::Container VecPredRegContainer
uint8_t getRaw(size_t idx) const
Return an element of the predicate register as it appears in the raw (untyped) internal representatio...
std::enable_if_t< Condition > setRaw(size_t idx, uint8_t val)
Write a raw value in an element of the predicate register.
bool firstActive(const VecPredRegT< VecElem, NumElems, Packed, MC > &mask, size_t actual_num_elems) const
Returns true if the first active element of the register is true.
const bool & operator[](size_t idx) const
void ccprintf(cp::Print &print)
bool operator!=(const VecPredRegT< VE2, NE2, P2, C2 > &that) const
Inequality operator, required to compare thread contexts.
constexpr uint64_t mask(unsigned nbits)
Generate a 64-bit mask of 'nbits' 1s, right justified.
void set()
Sets the predicate register to an all-true value.
bool operator==(const VecPredRegT< VE2, NE2, P2, C2 > &that) const
Equality operator, required to compare thread contexts.
MyClass & operator=(const MyClass &that)
auto as() const
Create a view of this container.
const bool & operator[](size_t idx) const
Returns a const reference to a specific element of the internal container.
uint8_t getBits(size_t idx, uint8_t nbits) const
Returns a subset of bits starting from a specific element in the container.
std::enable_if_t< Condition > set()
Reset the register to an all-true value.
friend std::ostream & operator<<(std::ostream &os, const MyClass &p)
std::enable_if_t< Condition > reset()
Reset the register to an all-false value.
std::enable_if_t< Condition, bool & > operator[](size_t idx)
MyClass & operator=(const std::vector< uint8_t > &that)
Required for de-serialization.
typename std::conditional_t< Const, const VecPredRegContainer< NUM_BITS, Packed >, VecPredRegContainer< NUM_BITS, Packed > > Container
Container type alias.
bool lastActive(const VecPredRegT< VecElem, NumElems, Packed, MC > &mask, size_t actual_num_elems) const
Returns true if the last active element of the register is true.
bool & operator[](size_t idx)
Returns a reference to a specific element of the internal container.
VecPredRegContainer< NumBits, Packed > MyClass
static constexpr size_t NUM_BITS
Container & container
Container corresponding to this view.
static constexpr size_t NUM_BITS
Size of the register in bits.
void reset()
Resets the predicate register to an all-false register.
static bool parse(const std::string &s, VecPredRegContainer< NumBits, Packed > &value)
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::array< bool, NumBits > Container
VecPredRegT(Container &c)
friend std::ostream & operator<<(std::ostream &os, const MyClass &p)
bool operator==(const VecPredRegContainer< N2, P2 > &that) const
Equality operator, required to compare thread contexts.
bool noneActive(const VecPredRegT< VecElem, NumElems, Packed, MC > &mask, size_t actual_num_elems) const
Returns true if there are no active elements in the register.
static void show(std::ostream &os, const VecPredRegContainer< NumBits, Packed > &value)
std::enable_if_t< Condition, MyClass & > operator=(const MyClass &that)
Generated on Wed May 4 2022 12:13:50 for gem5 by doxygen 1.8.17