diff --git a/src/arch/arm/fastmodel/iris/thread_context.cc b/src/arch/arm/fastmodel/iris/thread_context.cc index 98fc09eb3a..85171fcf8c 100644 --- a/src/arch/arm/fastmodel/iris/thread_context.cc +++ b/src/arch/arm/fastmodel/iris/thread_context.cc @@ -589,7 +589,7 @@ ThreadContext::readVecReg(const RegId ®_id) const iris::ResourceReadResult result; call().resource_read(_instId, result, vecRegIds.at(idx)); size_t data_size = result.data.size() * (sizeof(*result.data.data())); - size_t size = std::min(data_size, reg.SIZE); + size_t size = std::min(data_size, reg.size()); memcpy(reg.raw_ptr(), (void *)result.data.data(), size); return reg; diff --git a/src/arch/generic/vec_reg.hh b/src/arch/generic/vec_reg.hh index 8b9bea1084..4156ac5efd 100644 --- a/src/arch/generic/vec_reg.hh +++ b/src/arch/generic/vec_reg.hh @@ -170,12 +170,16 @@ template class VecRegT { /** Size of the register in bytes. */ - static constexpr size_t SIZE = sizeof(VecElem) * NumElems; + static constexpr inline size_t + size() + { + return sizeof(VecElem) * NumElems; + } public: /** Container type alias. */ using Container = typename std::conditional, - VecRegContainer>::type; + const VecRegContainer, + VecRegContainer>::type; private: /** My type alias. */ using MyClass = VecRegT; @@ -238,7 +242,7 @@ class VecRegT { /* 0-sized is not allowed */ os << "[" << std::hex << (uint32_t)vr[0]; - for (uint32_t e = 1; e < vr.SIZE; e++) + for (uint32_t e = 1; e < vr.size(); e++) os << " " << std::hex << (uint32_t)vr[e]; os << ']'; return os; @@ -264,16 +268,16 @@ class VecLaneT; * portion through the method 'as * @tparam Sz Size of the container in bytes. */ -template +template class VecRegContainer { - static_assert(Sz > 0, + static_assert(SIZE > 0, "Cannot create Vector Register Container of zero size"); - static_assert(Sz <= MaxVecRegLenInBytes, + static_assert(SIZE <= MaxVecRegLenInBytes, "Vector Register size limit exceeded"); public: - static constexpr size_t SIZE = Sz; - using Container = std::array; + static constexpr inline size_t size() { return SIZE; }; + using Container = std::array; private: Container container; using MyClass = VecRegContainer; @@ -377,7 +381,7 @@ class VecRegContainer * @tparam NumElem Amount of elements in the view. */ /** @{ */ - template + template VecRegT as() const { static_assert(SIZE % sizeof(VecElem) == 0, @@ -387,7 +391,7 @@ class VecRegContainer return VecRegT(*this); } - template + template VecRegT as() { static_assert(SIZE % sizeof(VecElem) == 0, @@ -638,10 +642,10 @@ template inline bool to_number(const std::string& value, VecRegContainer& v) { - fatal_if(value.size() > 2 * VecRegContainer::SIZE, + fatal_if(value.size() > 2 * VecRegContainer::size(), "Vector register value overflow at unserialize"); - for (int i = 0; i < VecRegContainer::SIZE; i++) { + for (int i = 0; i < VecRegContainer::size(); i++) { uint8_t b = 0; if (2 * i < value.size()) b = stoul(value.substr(i * 2, 2), nullptr, 16);