diff --git a/src/arch/generic/vec_reg.hh b/src/arch/generic/vec_reg.hh index 3091034a8e..379de28e8e 100644 --- a/src/arch/generic/vec_reg.hh +++ b/src/arch/generic/vec_reg.hh @@ -125,12 +125,14 @@ class VecRegContainer; template class VecRegT { + private: /** Size of the register in bytes. */ static constexpr inline size_t size() { return sizeof(VecElem) * NumElems; } + public: /** Container type alias. */ using Container = typename std::conditional - typename std::enable_if_t - zero() { container.zero(); } - - template - typename std::enable_if_t - operator=(const MyClass& that) - { - container = that.container; - return *this; - } - /** Index operator. */ - const VecElem& operator[](size_t idx) const + const VecElem & + operator[](size_t idx) const { return container.template raw_ptr()[idx]; } @@ -173,25 +163,6 @@ class VecRegT return container.template raw_ptr()[idx]; } - /** Equality operator. - * Required to compare thread contexts. - */ - template - bool - operator==(const VecRegT& that) const - { - return container == that.container; - } - /** Inequality operator. - * Required to compare thread contexts. - */ - template - bool - operator!=(const VecRegT& that) const - { - return !operator==(that); - } - /** Output stream operator. */ friend std::ostream& operator<<(std::ostream& os, const MyClass& vr) @@ -205,6 +176,7 @@ class VecRegT } const std::string print() const { return csprintf("%s", *this); } + /** * Cast to VecRegContainer& * It is useful to get the reference to the container for ISA tricks, @@ -223,10 +195,11 @@ class VecRegT template class VecRegContainer { - static_assert(SIZE > 0, - "Cannot create Vector Register Container of zero size"); - static_assert(SIZE <= MaxVecRegLenInBytes, - "Vector Register size limit exceeded"); + private: + static_assert(SIZE > 0, + "Cannot create Vector Register Container of zero size"); + static_assert(SIZE <= MaxVecRegLenInBytes, + "Vector Register size limit exceeded"); public: static constexpr inline size_t size() { return SIZE; }; using Container = std::array; @@ -251,16 +224,17 @@ class VecRegContainer /** Assignment operators. */ /** @{ */ /** From VecRegContainer */ - MyClass& operator=(const MyClass& that) + MyClass& + operator=(const MyClass& that) { if (&that == this) return *this; - memcpy(container.data(), that.container.data(), SIZE); - return *this; + return *this = that.container; } /** From appropriately sized uint8_t[]. */ - MyClass& operator=(const Container& that) + MyClass& + operator=(const Container& that) { std::memcpy(container.data(), that.data(), SIZE); return *this; @@ -269,7 +243,8 @@ class VecRegContainer /** From vector. * This is required for de-serialisation. * */ - MyClass& operator=(const std::vector& that) + MyClass& + operator=(const std::vector& that) { assert(that.size() >= SIZE); std::memcpy(container.data(), that.data(), SIZE); @@ -277,24 +252,6 @@ class VecRegContainer } /** @} */ - /** Copy the contents into the input buffer. */ - /** @{ */ - /** To appropriately sized uint8_t[] */ - void copyTo(Container& dst) const - { - std::memcpy(dst.data(), container.data(), SIZE); - } - - /** To vector - * This is required for serialisation. - * */ - void copyTo(std::vector& dst) const - { - dst.resize(SIZE); - std::memcpy(dst.data(), container.data(), SIZE); - } - /** @} */ - /** Equality operator. * Required to compare thread contexts. */ @@ -335,7 +292,8 @@ class VecRegContainer */ /** @{ */ template - VecRegT as() const + VecRegT + as() const { static_assert(SIZE % sizeof(VecElem) == 0, "VecElem does not evenly divide the register size"); @@ -345,7 +303,8 @@ class VecRegContainer } template - VecRegT as() + VecRegT + as() { static_assert(SIZE % sizeof(VecElem) == 0, "VecElem does not evenly divide the register size"); @@ -359,7 +318,8 @@ class VecRegContainer * Output operator. * Used for serialization. */ - friend std::ostream& operator<<(std::ostream& os, const MyClass& v) + friend std::ostream& + operator<<(std::ostream& os, const MyClass& v) { for (auto& b: v.container) { os << csprintf("%02x", b);