cpu: Track misc regs in vectors in the O3 CPU instruction class.
authorGabe Black <gabe.black@gmail.com>
Tue, 8 Dec 2020 02:11:50 +0000 (18:11 -0800)
committerGabe Black <gabe.black@gmail.com>
Wed, 10 Feb 2021 06:25:12 +0000 (06:25 +0000)
Most instructions won't actually write to misc regs, so the overhead
should be quite small, particularlly compared to the other overheads in
the O3.

Change-Id: I840d6002cc8151f91611cfcbe2bfa52acc284c0f
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/38388
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Maintainer: Giacomo Travaglini <giacomo.travaglini@arm.com>

src/cpu/o3/dyn_inst.hh
src/cpu/o3/dyn_inst_impl.hh

index b89b3c7f0001fe61a45e24ea6081ca966e1f8584..f084368676a0c6c3aeae33476a815c5bbaf85a4b 100644 (file)
@@ -93,17 +93,13 @@ class BaseO3DynInst : public BaseDynInst<Impl>
     using BaseDynInst<Impl>::cpu;
 
     /** Values to be written to the destination misc. registers. */
-    std::array<RegVal, TheISA::MaxMiscDestRegs> _destMiscRegVal;
+    std::vector<RegVal> _destMiscRegVal;
 
     /** Indexes of the destination misc. registers. They are needed to defer
      * the write accesses to the misc. registers until the commit stage, when
      * the instruction is out of its speculative state.
      */
-    std::array<short, TheISA::MaxMiscDestRegs> _destMiscRegIdx;
-
-    /** Number of destination misc. registers. */
-    uint8_t _numDestMiscRegs;
-
+    std::vector<short> _destMiscRegIdx;
 
   public:
 #if TRACING_ON
@@ -139,17 +135,13 @@ class BaseO3DynInst : public BaseDynInst<Impl>
          * committed instead of making a new entry. If not, make a new
          * entry and record the write.
          */
-        for (int idx = 0; idx < _numDestMiscRegs; idx++) {
-            if (_destMiscRegIdx[idx] == misc_reg) {
-               _destMiscRegVal[idx] = val;
-               return;
-            }
+        for (auto &idx: _destMiscRegIdx) {
+            if (idx == misc_reg)
+                return;
         }
 
-        assert(_numDestMiscRegs < TheISA::MaxMiscDestRegs);
-        _destMiscRegIdx[_numDestMiscRegs] = misc_reg;
-        _destMiscRegVal[_numDestMiscRegs] = val;
-        _numDestMiscRegs++;
+        _destMiscRegIdx.push_back(misc_reg);
+        _destMiscRegVal.push_back(val);
     }
 
     /** Reads a misc. register, including any side-effects the read
@@ -185,7 +177,7 @@ class BaseO3DynInst : public BaseDynInst<Impl>
         bool no_squash_from_TC = this->thread->noSquashFromTC;
         this->thread->noSquashFromTC = true;
 
-        for (int i = 0; i < _numDestMiscRegs; i++)
+        for (int i = 0; i < _destMiscRegIdx.size(); i++)
             this->cpu->setMiscReg(
                 _destMiscRegIdx[i], _destMiscRegVal[i], this->threadNumber);
 
index d960ad012cb88de51bb68eb6fa569243254f9469..07131c3fcc8ca7cfe220698f4d3ffed64e442a81 100644 (file)
@@ -106,8 +106,6 @@ BaseO3DynInst<Impl>::initVars()
 {
     this->regs.init();
 
-    _numDestMiscRegs = 0;
-
 #if TRACING_ON
     // Value -1 indicates that particular phase
     // hasn't happened (yet).