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

Change subject: cpu,arch-arm: Use a sentry class valid for invalid RegIds.
......................................................................

cpu,arch-arm: Use a sentry class valid for invalid RegIds.

The default constructor for RegId would initialize it with the
IntRegClass and register index 0. This is arbitrary and
indistinguishable from a real ID to the first integer register.

Instead, add a new class type constant InvalidRegClass, and use that to
initialize an otherwise uninitialized RegId.

Also, fill out some enums that needed to handle that value to silence
compiler warnings.

Change-Id: I3b58559f41adc1da5f661121225dbd389230e3af
---
M src/arch/arm/isa.hh
M src/cpu/o3/regfile.cc
M src/cpu/reg_class.hh
3 files changed, 9 insertions(+), 3 deletions(-)



diff --git a/src/arch/arm/isa.hh b/src/arch/arm/isa.hh
index 89ba7bc..aa3b482 100644
--- a/src/arch/arm/isa.hh
+++ b/src/arch/arm/isa.hh
@@ -556,6 +556,8 @@
                 return RegId(CCRegClass, flattenCCIndex(regId.index()));
               case MiscRegClass:
return RegId(MiscRegClass, flattenMiscIndex(regId.index()));
+              case InvalidRegClass:
+                panic("Tried to flatten an invalid RegId.");
             }
             return RegId();
         }
diff --git a/src/cpu/o3/regfile.cc b/src/cpu/o3/regfile.cc
index 0038e83..8e5d418 100644
--- a/src/cpu/o3/regfile.cc
+++ b/src/cpu/o3/regfile.cc
@@ -189,6 +189,8 @@
         return std::make_pair(ccRegIds.begin(), ccRegIds.end());
       case MiscRegClass:
         return std::make_pair(miscRegIds.begin(), miscRegIds.end());
+      case InvalidRegClass:
+        panic("Tried to get register IDs for the invalid class.");
     }
     /* There is no way to make an empty iterator */
     return std::make_pair(PhysIds::iterator(),
diff --git a/src/cpu/reg_class.hh b/src/cpu/reg_class.hh
index 60725b7..326b355 100644
--- a/src/cpu/reg_class.hh
+++ b/src/cpu/reg_class.hh
@@ -43,6 +43,7 @@

 #include <any>
 #include <cstddef>
+#include <limits>
 #include <string>

 #include "base/cprintf.hh"
@@ -64,7 +65,8 @@
     VecElemClass,
     VecPredRegClass,
     CCRegClass,         ///< Condition-code register
-    MiscRegClass        ///< Control (misc) register
+    MiscRegClass,       ///< Control (misc) register
+    InvalidRegClass = -1
 };

 class RegId;
@@ -135,7 +137,7 @@
     friend struct std::hash<RegId>;

   public:
-    RegId() : RegId(IntRegClass, 0) {}
+    RegId() : RegId(InvalidRegClass, 0) {}

     explicit RegId(RegClassType reg_class, RegIndex reg_idx)
         : regClass(reg_class), regIdx(reg_idx), numPinnedWrites(0)
@@ -232,7 +234,7 @@
     bool pinned;

   public:
-    explicit PhysRegId() : RegId(IntRegClass, -1), flatIdx(-1),
+    explicit PhysRegId() : RegId(InvalidRegClass, -1), flatIdx(-1),
                            numPinnedWritesToComplete(0)
     {}


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/49710
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: I3b58559f41adc1da5f661121225dbd389230e3af
Gerrit-Change-Number: 49710
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to