arch: Promote instReady to the base InstDecoder class.

Move the instDone flag, and the instReady function which was
consistently implemented just to return it, to the base InstDecoder
class. This flag can still be accessed easily from the subclasses, but
now it can be retrieved with just an InstDecoder pointer without a
virtual function call.

Change-Id: I8c662aa01da8fe33ffe679071c701e0aadc1a795
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/52072
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 5f0e68b..14167eb 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 instDone;
     bool outOfBytes;
     int offset;
     bool foundIt;
@@ -147,16 +146,6 @@
     bool needMoreBytes() const { return outOfBytes; }
 
     /**
-     * Is an instruction ready to be decoded?
-     *
-     * CPU models call this method to determine if decode() will
-     * return a new instruction on the next call. It typically only
-     * returns false if the decoder hasn't received enough data to
-     * decode a full instruction.
-     */
-    bool instReady() const { return instDone; }
-
-    /**
      * 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 6bfc199..a6aaaf5 100644
--- a/src/arch/generic/decoder.hh
+++ b/src/arch/generic/decoder.hh
@@ -43,6 +43,8 @@
     size_t _moreBytesSize;
     Addr _pcMask;
 
+    bool instDone = false;
+
   public:
     template <typename MoreBytesType>
     InstDecoder(MoreBytesType *mb_buf) :
@@ -56,6 +58,16 @@
     void *moreBytesPtr() const { return _moreBytesPtr; }
     size_t moreBytesSize() const { return _moreBytesSize; }
     Addr pcMask() const { return _pcMask; }
+
+    /**
+     * Is an instruction ready to be decoded?
+     *
+     * CPU models call this method to determine if decode() will
+     * return a new instruction on the next call. It typically only
+     * returns false if the decoder hasn't received enough data to
+     * decode a full instruction.
+     */
+    bool instReady() const { return instDone; }
 };
 
 } // namespace gem5
diff --git a/src/arch/mips/decoder.hh b/src/arch/mips/decoder.hh
index d90e9c5..25a84d3 100644
--- a/src/arch/mips/decoder.hh
+++ b/src/arch/mips/decoder.hh
@@ -50,10 +50,9 @@
     //The extended machine instruction being generated
     ExtMachInst emi;
     uint32_t machInst;
-    bool instDone;
 
   public:
-    Decoder(ISA* isa = nullptr) : InstDecoder(&machInst), instDone(false)
+    Decoder(ISA* isa = nullptr) : InstDecoder(&machInst)
     {}
 
     void
@@ -82,12 +81,6 @@
         return true;
     }
 
-    bool
-    instReady()
-    {
-        return instDone;
-    }
-
     void takeOverFrom(Decoder *old) {}
 
   protected:
diff --git a/src/arch/power/decoder.hh b/src/arch/power/decoder.hh
index f3a2721..3ec7031 100644
--- a/src/arch/power/decoder.hh
+++ b/src/arch/power/decoder.hh
@@ -48,10 +48,9 @@
   protected:
     // The extended machine instruction being generated
     ExtMachInst emi;
-    bool instDone;
 
   public:
-    Decoder(ISA* isa=nullptr) : InstDecoder(&emi), instDone(false) {}
+    Decoder(ISA* isa=nullptr) : InstDecoder(&emi) {}
 
     void
     process()
@@ -79,12 +78,6 @@
         return true;
     }
 
-    bool
-    instReady()
-    {
-        return instDone;
-    }
-
     void takeOverFrom(Decoder *old) {}
 
   protected:
diff --git a/src/arch/riscv/decoder.hh b/src/arch/riscv/decoder.hh
index c12a48a..f5866be 100644
--- a/src/arch/riscv/decoder.hh
+++ b/src/arch/riscv/decoder.hh
@@ -57,7 +57,6 @@
     //The extended machine instruction being generated
     ExtMachInst emi;
     uint32_t machInst;
-    bool instDone;
 
     StaticInstPtr decodeInst(ExtMachInst mach_inst);
 
@@ -79,7 +78,6 @@
     void moreBytes(const PCStateBase &pc, Addr fetchPC);
 
     bool needMoreBytes() { return more; }
-    bool instReady() { return instDone; }
     void takeOverFrom(Decoder *old) {}
 
     StaticInstPtr decode(PCStateBase &nextPC);
diff --git a/src/arch/sparc/decoder.hh b/src/arch/sparc/decoder.hh
index 44695e9..af1c95a 100644
--- a/src/arch/sparc/decoder.hh
+++ b/src/arch/sparc/decoder.hh
@@ -48,11 +48,10 @@
     // The extended machine instruction being generated
     ExtMachInst emi;
     uint32_t machInst;
-    bool instDone;
     RegVal asi;
 
   public:
-    Decoder(ISA* isa=nullptr) : InstDecoder(&machInst), instDone(false), asi(0)
+    Decoder(ISA* isa=nullptr) : InstDecoder(&machInst), asi(0)
     {}
 
     void process() {}
@@ -89,12 +88,6 @@
         return true;
     }
 
-    bool
-    instReady()
-    {
-        return instDone;
-    }
-
     void
     setContext(RegVal _asi)
     {
diff --git a/src/arch/x86/decoder.hh b/src/arch/x86/decoder.hh
index bf5906d..c8722b9 100644
--- a/src/arch/x86/decoder.hh
+++ b/src/arch/x86/decoder.hh
@@ -176,8 +176,6 @@
   protected:
     // Whether or not we're out of bytes.
     bool outOfBytes = true;
-    // Whether we've completed generating an ExtMachInst.
-    bool instDone = false;
     // The size of the displacement value.
     int displacementSize;
     // The size of the immediate value.
@@ -324,7 +322,6 @@
     }
 
     bool needMoreBytes() { return outOfBytes; }
-    bool instReady() { return instDone; }
 
     void
     updateNPC(X86ISA::PCState &nextPC)