mem-cache: Make StridePrefetcher use Replacement Policies

Previously StridePrefetcher was only able to use random
replacement policy. This change allows all replacement
policies to be applied to the pc table.

Change-Id: I8714e71a6a4c9c31fbca49a07a456dcacd3e402c
Signed-off-by: Daniel <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/14360
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>
diff --git a/src/mem/cache/prefetch/stride.hh b/src/mem/cache/prefetch/stride.hh
index 772c3a5..aa02287 100644
--- a/src/mem/cache/prefetch/stride.hh
+++ b/src/mem/cache/prefetch/stride.hh
@@ -1,4 +1,5 @@
 /*
+ * Copyright (c) 2018 Inria
  * Copyright (c) 2012-2013, 2015 ARM Limited
  * All rights reserved
  *
@@ -38,6 +39,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * Authors: Ron Dreslinski
+ *          Daniel Carvalho
  */
 
 /**
@@ -54,8 +56,10 @@
 
 #include "base/types.hh"
 #include "mem/cache/prefetch/queued.hh"
+#include "mem/cache/replacement_policies/replaceable_entry.hh"
 #include "mem/packet.hh"
 
+class BaseReplacementPolicy;
 struct StridePrefetcherParams;
 
 class StridePrefetcher : public QueuedPrefetcher
@@ -73,7 +77,10 @@
 
     const int degree;
 
-    struct StrideEntry
+    /** Replacement policy used in the PC tables. */
+    BaseReplacementPolicy* replacementPolicy;
+
+    struct StrideEntry : public ReplaceableEntry
     {
         /** Default constructor */
         StrideEntry();
@@ -97,8 +104,10 @@
          * @param assoc Associativity of the table.
          * @param sets Number of sets in the table.
          * @param name Name of the prefetcher.
+         * @param replacementPolicy Replacement policy used by the table.
          */
-        PCTable(int assoc, int sets, const std::string name);
+        PCTable(int assoc, int sets, const std::string name,
+                BaseReplacementPolicy* replacementPolicy);
 
         /**
          * Default destructor.
@@ -124,12 +133,16 @@
 
       private:
         const std::string name() {return _name; }
-        const int pcTableAssoc;
         const int pcTableSets;
         const std::string _name;
         std::vector<std::vector<StrideEntry>> entries;
 
         /**
+         * Replacement policy used by StridePrefetcher.
+         */
+        BaseReplacementPolicy* replacementPolicy;
+
+        /**
          * PC hashing function to index sets in the table.
          *
          * @param pc The PC value.