Go to the documentation of this file.
36 #ifndef __ARCH_GENERIC_VEC_PRED_REG_HH__
37 #define __ARCH_GENERIC_VEC_PRED_REG_HH__
46 template <
size_t NumBits,
bool Packed>
65 template <
typename VecElem,
size_t NumElems,
bool Packed,
bool Const>
70 static constexpr
size_t NUM_BITS = Packed ? NumElems :
75 using Container =
typename std::conditional<
90 template<
bool Condition = !Const>
95 template<
bool Condition = !Const>
99 template<
bool Condition = !Const>
113 template<
bool Condition = !Const>
126 (Packed ? 1 :
sizeof(
VecElem)));
130 template<
bool Condition = !Const>
139 template<
typename VE2,
size_t NE2,
bool P2,
bool C2>
147 template<
typename VE2,
size_t NE2,
bool P2,
bool C2>
158 os <<
'[' <<
p.container[0];
159 for (
int i = 0;
i <
p.NUM_BITS; ++
i) {
160 os <<
" " << (
p.container[
i] ? 1 : 0);
176 size_t actual_num_elems)
const
178 assert(actual_num_elems <= NumElems);
179 for (
int i = 0;
i < actual_num_elems; ++
i) {
194 size_t actual_num_elems)
const
196 assert(actual_num_elems <= NumElems);
197 for (
int i = 0;
i < actual_num_elems; ++
i) {
198 if (
mask[
i] &&
operator[](
i)) {
212 size_t actual_num_elems)
const
214 assert(actual_num_elems <= NumElems);
215 for (
int i = actual_num_elems - 1;
i >= 0; --
i) {
230 template <
size_t NumBits,
bool Packed>
233 static_assert(NumBits > 0,
234 "Size of a predicate register must be > 0");
263 std::copy(that.begin(), that.end(),
container.begin());
282 template<
size_t N2,
bool P2>
290 template<
size_t N2,
bool P2>
309 assert(nbits > 0 && nbits <= 8 && (idx + nbits - 1) < NumBits);
311 idx = idx + nbits - 1;
312 for (
int i = 0;
i < nbits; ++
i, --idx) {
324 assert(nbits > 0 && nbits <= 8 && (idx + nbits - 1) < NumBits);
325 for (
int i = 0;
i < nbits; ++
i, ++idx) {
337 for (
auto b:
v.container) {
351 size_t NumElems = (Packed ? NumBits : NumBits /
sizeof(
VecElem))>
354 static_assert((Packed && NumElems <= NumBits) ||
356 NumBits %
sizeof(
VecElem) == 0 &&
357 sizeof(
VecElem) * NumElems <= NumBits),
358 "Container size incompatible with view size");
363 size_t NumElems = (Packed ? NumBits : NumBits /
sizeof(
VecElem))>
366 static_assert((Packed && NumElems <= NumBits) ||
368 NumBits %
sizeof(
VecElem) == 0 &&
369 sizeof(
VecElem) * NumElems <= NumBits),
370 "Container size incompatible with view size");
377 template <
size_t NumBits,
bool Packed>
382 for (
const auto&
c: value) {
401 #endif // __ARCH_GENERIC_VEC_PRED_REG_HH__
const bool & operator[](size_t idx) const
static constexpr size_t NUM_BITS
Size of the register in bits.
void set_bits(size_t idx, uint8_t nbits, uint8_t bval)
Set a subset of bits starting from a specific element in the container.
constexpr size_t DummyVecPredRegSizeBits
Generic predicate register container.
const bool & operator[](size_t idx) const
Returns a const reference to a specific element of the internal container.
constexpr bool DummyVecPredRegHasPackedRepr
Dummy type aliases and constants for architectures that do not implement vector predicate registers.
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.
bool & operator[](size_t idx)
Returns a reference to a specific element of the internal container.
const std::string print() const
Returns a string representation of the register content.
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.
static constexpr size_t NUM_BITS
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.
std::array< bool, NumBits > Container
Container & container
Container corresponding to this view.
bool to_number(const std::string &value, VecPredRegContainer< NumBits, Packed > &p)
Helper functions used for serialization/de-serialization.
const std::string print() const
Returns a string representation of the register content.
bool operator==(const VecPredRegT< VE2, NE2, P2, C2 > &that) const
Equality operator, required to compare thread contexts.
VecPredRegT(Container &c)
bool operator!=(const VecPredRegT< VE2, NE2, P2, C2 > &that) const
Inequality operator, required to compare thread contexts.
MyClass & operator=(const MyClass &that)
std::enable_if< Condition, void >::type set()
Reset the register to an all-true value.
std::enable_if< Condition, MyClass & >::type operator=(const MyClass &that)
typename std::conditional< Const, const VecPredRegContainer< NUM_BITS, Packed >, VecPredRegContainer< NUM_BITS, Packed > >::type Container
Container type alias.
VecPredRegT< VecElem, NumElems, Packed, true > as() const
Create a view of this container.
void reset()
Resets the predicate register to an all-false register.
std::enable_if< Condition, bool & >::type operator[](size_t idx)
uint8_t get_raw(size_t idx) const
Return an element of the predicate register as it appears in the raw (untyped) internal representatio...
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.
VecPredRegT< VecElem, NumElems, Packed, false > as()
uint32_t DummyVecElem
Dummy type aliases and constants for architectures that do not implement vector registers.
std::enable_if< Condition, void >::type reset()
Reset the register to an all-false value.
DummyVecPredReg::Container DummyVecPredRegContainer
void set()
Sets the predicate register to an all-true value.
std::enable_if< Condition, void >::type set_raw(size_t idx, uint8_t val)
Write a raw value in an element of the predicate register.
VecPredRegContainer< NumBits, Packed > MyClass
constexpr unsigned DummyNumVecElemPerVecReg
uint8_t get_bits(size_t idx, uint8_t nbits) const
Returns a subset of bits starting from a specific element in the container.
friend std::ostream & operator<<(std::ostream &os, const MyClass &v)
bool operator!=(const VecPredRegContainer< N2, P2 > &that) const
Inequality operator, required to compare thread contexts.
std::string csprintf(const char *format, const Args &...args)
MyClass & operator=(const std::vector< uint8_t > &that)
Required for de-serialization.
Generated on Wed Sep 30 2020 14:02:07 for gem5 by doxygen 1.8.17