cpu-o3: convert rob to new style stats

Change-Id: I84430d50c49742cd536dd75ce25184c2316dce51
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/33398
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
diff --git a/src/cpu/o3/cpu.cc b/src/cpu/o3/cpu.cc
index c5b4a82..bbc6b82 100644
--- a/src/cpu/o3/cpu.cc
+++ b/src/cpu/o3/cpu.cc
@@ -443,7 +443,6 @@
 
     this->rename.regStats();
     this->iew.regStats();
-    this->rob.regStats();
 
     intRegfileReads
         .name(name() + ".int_regfile_reads")
diff --git a/src/cpu/o3/rob.hh b/src/cpu/o3/rob.hh
index eb8d1d6..4b87dc4 100644
--- a/src/cpu/o3/rob.hh
+++ b/src/cpu/o3/rob.hh
@@ -257,9 +257,6 @@
      */
     size_t countInsts(ThreadID tid);
 
-    /** Registers statistics. */
-    void regStats();
-
   private:
     /** Reset the ROB state */
     void resetState();
@@ -323,10 +320,15 @@
     /** Number of active threads. */
     ThreadID numThreads;
 
-    // The number of rob_reads
-    Stats::Scalar robReads;
-    // The number of rob_writes
-    Stats::Scalar robWrites;
+
+    struct ROBStats : public Stats::Group {
+        ROBStats(Stats::Group *parent);
+
+        // The number of rob_reads
+        Stats::Scalar reads;
+        // The number of rob_writes
+        Stats::Scalar writes;
+    } stats;
 };
 
 #endif //__CPU_O3_ROB_HH__
diff --git a/src/cpu/o3/rob_impl.hh b/src/cpu/o3/rob_impl.hh
index 80ea1e6..bfc368b 100644
--- a/src/cpu/o3/rob_impl.hh
+++ b/src/cpu/o3/rob_impl.hh
@@ -58,7 +58,8 @@
       numEntries(params->numROBEntries),
       squashWidth(params->squashWidth),
       numInstsInROB(0),
-      numThreads(params->numThreads)
+      numThreads(params->numThreads),
+      stats(_cpu)
 {
     //Figure out rob policy
     if (robPolicy == SMTQueuePolicy::Dynamic) {
@@ -204,7 +205,7 @@
 {
     assert(inst);
 
-    robWrites++;
+    stats.writes++;
 
     DPRINTF(ROB, "Adding inst PC %s to the ROB.\n", inst->pcState());
 
@@ -239,7 +240,7 @@
 void
 ROB<Impl>::retireHead(ThreadID tid)
 {
-    robWrites++;
+    stats.writes++;
 
     assert(numInstsInROB > 0);
 
@@ -274,7 +275,7 @@
 bool
 ROB<Impl>::isHeadReady(ThreadID tid)
 {
-    robReads++;
+    stats.reads++;
     if (threadEntries[tid] != 0) {
         return instList[tid].front()->readyToCommit();
     }
@@ -319,7 +320,7 @@
 void
 ROB<Impl>::doSquash(ThreadID tid)
 {
-    robWrites++;
+    stats.writes++;
     DPRINTF(ROB, "[tid:%i] Squashing instructions until [sn:%llu].\n",
             tid, squashedSeqNum[tid]);
 
@@ -528,17 +529,11 @@
 }
 
 template <class Impl>
-void
-ROB<Impl>::regStats()
+ROB<Impl>::ROBStats::ROBStats(Stats::Group *parent)
+    : Stats::Group(parent, "rob"),
+      ADD_STAT(reads, "The number of ROB reads"),
+      ADD_STAT(writes, "The number of ROB writes")
 {
-    using namespace Stats;
-    robReads
-        .name(name() + ".rob_reads")
-        .desc("The number of ROB reads");
-
-    robWrites
-        .name(name() + ".rob_writes")
-        .desc("The number of ROB writes");
 }
 
 template <class Impl>