stats: Move the swpipl function into the Alpha kernel stats.

This stat is only incremented by Alpha. Also move the _hwrei into the Alpha
stats object since it's the class that actually sets up and maintains that
value and it probably should have been there all along.

Change-Id: Ibd038a33230c01432c160490926d8e1e55f8ccb0
Reviewed-on: https://gem5-review.googlesource.com/4601
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>
diff --git a/src/arch/alpha/kernel_stats.cc b/src/arch/alpha/kernel_stats.cc
index a1ed532..39f460f 100644
--- a/src/arch/alpha/kernel_stats.cc
+++ b/src/arch/alpha/kernel_stats.cc
@@ -52,7 +52,8 @@
 
 Statistics::Statistics()
     : ::Kernel::Statistics(),
-      idleProcess((Addr)-1), themode(kernel), lastModeTick(0)
+      idleProcess((Addr)-1), themode(kernel), lastModeTick(0),
+      iplLast(0), iplLastTick(0)
 {
 }
 
@@ -120,6 +121,35 @@
         .name(name() + ".swap_context")
         .desc("number of times the context was actually changed")
         ;
+
+    _iplCount
+        .init(32)
+        .name(name() + ".ipl_count")
+        .desc("number of times we switched to this ipl")
+        .flags(total | pdf | nozero | nonan)
+        ;
+
+    _iplGood
+        .init(32)
+        .name(name() + ".ipl_good")
+        .desc("number of times we switched to this ipl from a different ipl")
+        .flags(total | pdf | nozero | nonan)
+        ;
+
+    _iplTicks
+        .init(32)
+        .name(name() + ".ipl_ticks")
+        .desc("number of cycles we spent at this ipl")
+        .flags(total | pdf | nozero | nonan)
+        ;
+
+    _iplUsed
+        .name(name() + ".ipl_used")
+        .desc("fraction of swpipl calls that actually changed the ipl")
+        .flags(total | nozero | nonan)
+        ;
+
+    _iplUsed = _iplGood / _iplCount;
 }
 
 void
@@ -184,6 +214,22 @@
 }
 
 void
+Statistics::swpipl(int ipl)
+{
+    assert(ipl >= 0 && ipl <= 0x1f && "invalid IPL\n");
+
+    _iplCount[ipl]++;
+
+    if (ipl == iplLast)
+        return;
+
+    _iplGood[ipl]++;
+    _iplTicks[iplLast] += curTick() - iplLastTick;
+    iplLastTick = curTick();
+    iplLast = ipl;
+}
+
+void
 Statistics::serialize(CheckpointOut &cp) const
 {
     ::Kernel::Statistics::serialize(cp);
@@ -191,6 +237,8 @@
     SERIALIZE_SCALAR(exemode);
     SERIALIZE_SCALAR(idleProcess);
     SERIALIZE_SCALAR(lastModeTick);
+    SERIALIZE_SCALAR(iplLast);
+    SERIALIZE_SCALAR(iplLastTick);
 }
 
 void
@@ -202,6 +250,8 @@
     UNSERIALIZE_SCALAR(idleProcess);
     UNSERIALIZE_SCALAR(lastModeTick);
     themode = (cpu_mode)exemode;
+    UNSERIALIZE_SCALAR(iplLast);
+    UNSERIALIZE_SCALAR(iplLastTick);
 }
 
 } // namespace Kernel
diff --git a/src/arch/alpha/kernel_stats.hh b/src/arch/alpha/kernel_stats.hh
index 3b2b5a0..1bedeb0 100644
--- a/src/arch/alpha/kernel_stats.hh
+++ b/src/arch/alpha/kernel_stats.hh
@@ -59,7 +59,8 @@
 
   private:
     Stats::Vector _callpal;
-//    Stats::Vector _faults;
+
+    Stats::Scalar _hwrei;
 
     Stats::Vector _mode;
     Stats::Vector _modeGood;
@@ -68,6 +69,15 @@
 
     Stats::Scalar _swap_context;
 
+    Stats::Vector _iplCount;
+    Stats::Vector _iplGood;
+    Stats::Vector _iplTicks;
+    Stats::Formula _iplUsed;
+
+  private:
+    int iplLast;
+    Tick iplLastTick;
+
   public:
     Statistics();
 
@@ -78,6 +88,7 @@
     void context(Addr oldpcbb, Addr newpcbb, ThreadContext *tc);
     void callpal(int code, ThreadContext *tc);
     void hwrei() { _hwrei++; }
+    void swpipl(int ipl);
 
     void setIdleProcess(Addr idle, ThreadContext *tc);
 
diff --git a/src/kern/kernel_stats.cc b/src/kern/kernel_stats.cc
index 37677c1..2d1d4fa 100644
--- a/src/kern/kernel_stats.cc
+++ b/src/kern/kernel_stats.cc
@@ -41,11 +41,6 @@
 
 namespace Kernel {
 
-Statistics::Statistics()
-    : iplLast(0), iplLastTick(0)
-{
-}
-
 void
 Statistics::regStats(const string &_name)
 {
@@ -60,65 +55,6 @@
         .name(name() + ".inst.quiesce")
         .desc("number of quiesce instructions executed")
         ;
-
-    _iplCount
-        .init(32)
-        .name(name() + ".ipl_count")
-        .desc("number of times we switched to this ipl")
-        .flags(total | pdf | nozero | nonan)
-        ;
-
-    _iplGood
-        .init(32)
-        .name(name() + ".ipl_good")
-        .desc("number of times we switched to this ipl from a different ipl")
-        .flags(total | pdf | nozero | nonan)
-        ;
-
-    _iplTicks
-        .init(32)
-        .name(name() + ".ipl_ticks")
-        .desc("number of cycles we spent at this ipl")
-        .flags(total | pdf | nozero | nonan)
-        ;
-
-    _iplUsed
-        .name(name() + ".ipl_used")
-        .desc("fraction of swpipl calls that actually changed the ipl")
-        .flags(total | nozero | nonan)
-        ;
-
-    _iplUsed = _iplGood / _iplCount;
-}
-
-void
-Statistics::swpipl(int ipl)
-{
-    assert(ipl >= 0 && ipl <= 0x1f && "invalid IPL\n");
-
-    _iplCount[ipl]++;
-
-    if (ipl == iplLast)
-        return;
-
-    _iplGood[ipl]++;
-    _iplTicks[iplLast] += curTick() - iplLastTick;
-    iplLastTick = curTick();
-    iplLast = ipl;
-}
-
-void
-Statistics::serialize(CheckpointOut &cp) const
-{
-    SERIALIZE_SCALAR(iplLast);
-    SERIALIZE_SCALAR(iplLastTick);
-}
-
-void
-Statistics::unserialize(CheckpointIn &cp)
-{
-    UNSERIALIZE_SCALAR(iplLast);
-    UNSERIALIZE_SCALAR(iplLastTick);
 }
 
 } // namespace Kernel
diff --git a/src/kern/kernel_stats.hh b/src/kern/kernel_stats.hh
index d516baa..41071ce 100644
--- a/src/kern/kernel_stats.hh
+++ b/src/kern/kernel_stats.hh
@@ -48,19 +48,8 @@
   protected:
     Stats::Scalar _arm;
     Stats::Scalar _quiesce;
-    Stats::Scalar _hwrei;
-
-    Stats::Vector _iplCount;
-    Stats::Vector _iplGood;
-    Stats::Vector _iplTicks;
-    Stats::Formula _iplUsed;
-
-  private:
-    int iplLast;
-    Tick iplLastTick;
 
   public:
-    Statistics();
     virtual ~Statistics() {}
 
     const std::string name() const { return myname; }
@@ -69,11 +58,10 @@
   public:
     void arm() { _arm++; }
     void quiesce() { _quiesce++; }
-    void swpipl(int ipl);
 
   public:
-    void serialize(CheckpointOut &cp) const override;
-    void unserialize(CheckpointIn &cp) override;
+    void serialize(CheckpointOut &cp) const override {}
+    void unserialize(CheckpointIn &cp) override {}
 };
 
 } // namespace Kernel