Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/41993 )

Change subject: arch: Simplify and correct style of VecReg types.
......................................................................

arch: Simplify and correct style of VecReg types.

Change-Id: Ib15d2e03c3e9cabcf56b316d5c57d2e892ad255d
---
M src/arch/generic/vec_reg.hh
1 file changed, 23 insertions(+), 63 deletions(-)



diff --git a/src/arch/generic/vec_reg.hh b/src/arch/generic/vec_reg.hh
index 7828108..c8e7938 100644
--- a/src/arch/generic/vec_reg.hh
+++ b/src/arch/generic/vec_reg.hh
@@ -125,12 +125,14 @@
 template <typename VecElem, size_t NumElems, bool Const>
 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<Const,
@@ -146,21 +148,9 @@
     /** Constructor. */
     VecRegT(Container& cnt) : container(cnt) {};

-    /** Zero the container. */
-    template<bool Condition = !Const>
-    typename std::enable_if_t<Condition, void>
-    zero() { container.zero(); }
-
-    template<bool Condition = !Const>
-    typename std::enable_if_t<Condition, MyClass&>
-    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<VecElem>()[idx];
     }
@@ -173,25 +163,6 @@
         return container.template raw_ptr<VecElem>()[idx];
     }

-    /** Equality operator.
-     * Required to compare thread contexts.
-     */
-    template<typename VE2, size_t NE2, bool C2>
-    bool
-    operator==(const VecRegT<VE2, NE2, C2>& that) const
-    {
-        return container == that.container;
-    }
-    /** Inequality operator.
-     * Required to compare thread contexts.
-     */
-    template<typename VE2, size_t NE2, bool C2>
-    bool
-    operator!=(const VecRegT<VE2, NE2, C2>& that) const
-    {
-        return !operator==(that);
-    }
-
     /** Output stream operator. */
     friend std::ostream&
     operator<<(std::ostream& os, const MyClass& vr)
@@ -205,6 +176,7 @@
     }

     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 @@
 template <size_t SIZE>
 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<uint8_t, SIZE>;
@@ -251,16 +224,17 @@
     /** 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 @@
     /** From vector<uint8_t>.
      * This is required for de-serialisation.
      * */
-    MyClass& operator=(const std::vector<uint8_t>& that)
+    MyClass&
+    operator=(const std::vector<uint8_t>& that)
     {
         assert(that.size() >= SIZE);
         std::memcpy(container.data(), that.data(), SIZE);
@@ -277,24 +252,6 @@
     }
     /** @} */

-    /** 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<uint8_t>
-     * This is required for serialisation.
-     * */
-    void copyTo(std::vector<uint8_t>& dst) const
-    {
-        dst.resize(SIZE);
-        std::memcpy(dst.data(), container.data(), SIZE);
-    }
-    /** @} */
-
     /** Equality operator.
      * Required to compare thread contexts.
      */
@@ -335,7 +292,8 @@
      */
     /** @{ */
     template <typename VecElem, size_t NumElems=(SIZE / sizeof(VecElem))>
-    VecRegT<VecElem, NumElems, true> as() const
+    VecRegT<VecElem, NumElems, true>
+    as() const
     {
         static_assert(SIZE % sizeof(VecElem) == 0,
                 "VecElem does not evenly divide the register size");
@@ -345,7 +303,8 @@
     }

     template <typename VecElem, size_t NumElems=(SIZE / sizeof(VecElem))>
-    VecRegT<VecElem, NumElems, false> as()
+    VecRegT<VecElem, NumElems, false>
+    as()
     {
         static_assert(SIZE % sizeof(VecElem) == 0,
                 "VecElem does not evenly divide the register size");
@@ -359,7 +318,8 @@
      * 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);

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/41993
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ib15d2e03c3e9cabcf56b316d5c57d2e892ad255d
Gerrit-Change-Number: 41993
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <gabe.bl...@gmail.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to