arch: Promote outOfBytes/needMoreBytes to the InstDecoder class.

Change-Id: Ie8f31e424081f002e3d74edd1685b4a977c545c3
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/52073
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
diff --git a/src/arch/arm/decoder.hh b/src/arch/arm/decoder.hh
index 14167eb..592a59c 100644
--- a/src/arch/arm/decoder.hh
+++ b/src/arch/arm/decoder.hh
@@ -66,7 +66,6 @@
     ExtMachInst emi;
     uint32_t data;
     bool bigThumb;
-    bool outOfBytes;
     int offset;
     bool foundIt;
     ITSTATE itBits;
@@ -137,15 +136,6 @@
     void reset();
 
     /**
-     * Can the decoder accept more data?
-     *
-     * A CPU model uses this method to determine if the decoder can
-     * accept more data. Note that an instruction can be ready (see
-     * instReady() even if this method returns true.
-     */
-    bool needMoreBytes() const { return outOfBytes; }
-
-    /**
      * Feed data to the decoder.
      *
      * A CPU model uses this interface to load instruction data into
diff --git a/src/arch/generic/decoder.hh b/src/arch/generic/decoder.hh
index a6aaaf5..658d860 100644
--- a/src/arch/generic/decoder.hh
+++ b/src/arch/generic/decoder.hh
@@ -44,6 +44,7 @@
     Addr _pcMask;
 
     bool instDone = false;
+    bool outOfBytes = true;
 
   public:
     template <typename MoreBytesType>
@@ -68,6 +69,15 @@
      * decode a full instruction.
      */
     bool instReady() const { return instDone; }
+
+    /**
+     * Can the decoder accept more data?
+     *
+     * A CPU model uses this method to determine if the decoder can
+     * accept more data. Note that an instruction can be ready (see
+     * instReady() even if this method returns true.
+     */
+    bool needMoreBytes() const { return outOfBytes; }
 };
 
 } // namespace gem5
diff --git a/src/arch/mips/decoder.hh b/src/arch/mips/decoder.hh
index 25a84d3..398e3f6 100644
--- a/src/arch/mips/decoder.hh
+++ b/src/arch/mips/decoder.hh
@@ -75,12 +75,6 @@
         instDone = true;
     }
 
-    bool
-    needMoreBytes()
-    {
-        return true;
-    }
-
     void takeOverFrom(Decoder *old) {}
 
   protected:
diff --git a/src/arch/power/decoder.hh b/src/arch/power/decoder.hh
index 3ec7031..b9a29f7 100644
--- a/src/arch/power/decoder.hh
+++ b/src/arch/power/decoder.hh
@@ -72,12 +72,6 @@
         instDone = true;
     }
 
-    bool
-    needMoreBytes()
-    {
-        return true;
-    }
-
     void takeOverFrom(Decoder *old) {}
 
   protected:
diff --git a/src/arch/riscv/decoder.cc b/src/arch/riscv/decoder.cc
index 4091e56..eaec4dc 100644
--- a/src/arch/riscv/decoder.cc
+++ b/src/arch/riscv/decoder.cc
@@ -42,7 +42,7 @@
 {
     aligned = true;
     mid = false;
-    more = true;
+    outOfBytes = true;
     emi = 0;
     instDone = false;
 }
@@ -63,19 +63,19 @@
         emi = inst;
         if (compressed(emi))
             emi = bits(emi, mid_bit, 0);
-        more = !compressed(emi);
+        outOfBytes = !compressed(emi);
         instDone = true;
     } else {
         if (mid) {
             assert(bits(emi, max_bit, mid_bit + 1) == 0);
             replaceBits(emi, max_bit, mid_bit + 1, inst);
             mid = false;
-            more = false;
+            outOfBytes = false;
             instDone = true;
         } else {
             emi = bits(inst, max_bit, mid_bit + 1);
             mid = !compressed(emi);
-            more = true;
+            outOfBytes = true;
             instDone = compressed(emi);
         }
     }
diff --git a/src/arch/riscv/decoder.hh b/src/arch/riscv/decoder.hh
index f5866be..8290620 100644
--- a/src/arch/riscv/decoder.hh
+++ b/src/arch/riscv/decoder.hh
@@ -51,7 +51,6 @@
     decode_cache::InstMap<ExtMachInst> instMap;
     bool aligned;
     bool mid;
-    bool more;
 
   protected:
     //The extended machine instruction being generated
@@ -77,7 +76,6 @@
     //when there is control flow.
     void moreBytes(const PCStateBase &pc, Addr fetchPC);
 
-    bool needMoreBytes() { return more; }
     void takeOverFrom(Decoder *old) {}
 
     StaticInstPtr decode(PCStateBase &nextPC);
diff --git a/src/arch/sparc/decoder.hh b/src/arch/sparc/decoder.hh
index af1c95a..91bf7f9 100644
--- a/src/arch/sparc/decoder.hh
+++ b/src/arch/sparc/decoder.hh
@@ -82,12 +82,6 @@
         instDone = true;
     }
 
-    bool
-    needMoreBytes()
-    {
-        return true;
-    }
-
     void
     setContext(RegVal _asi)
     {
diff --git a/src/arch/x86/decoder.hh b/src/arch/x86/decoder.hh
index c8722b9..d012d84 100644
--- a/src/arch/x86/decoder.hh
+++ b/src/arch/x86/decoder.hh
@@ -174,8 +174,6 @@
 
     // State machine state.
   protected:
-    // Whether or not we're out of bytes.
-    bool outOfBytes = true;
     // The size of the displacement value.
     int displacementSize;
     // The size of the immediate value.
@@ -321,8 +319,6 @@
         process();
     }
 
-    bool needMoreBytes() { return outOfBytes; }
-
     void
     updateNPC(X86ISA::PCState &nextPC)
     {