mem-cache: Add invalidation function to StrideEntry
authorDaniel <odanrc@yahoo.com.br>
Sun, 11 Nov 2018 16:56:08 +0000 (17:56 +0100)
committerDaniel Carvalho <odanrc@yahoo.com.br>
Thu, 15 Nov 2018 16:53:16 +0000 (16:53 +0000)
Add invalidation function to StrideEntry so that every
entry can be invalidated appropriately.

Change-Id: I38c42b7d7c93d839f797d116f1d2c88572123c0e
Signed-off-by: Daniel <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/14359
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>

src/mem/cache/prefetch/stride.cc
src/mem/cache/prefetch/stride.hh

index c09facef015c424351e16f53c6c88e60fea86d5b..4520f12c27450a1c6e2f43fa48d57dd04d80f8f5 100644 (file)
 #include "debug/HWPrefetch.hh"
 #include "params/StridePrefetcher.hh"
 
+StridePrefetcher::StrideEntry::StrideEntry()
+{
+    invalidate();
+}
+
+void
+StridePrefetcher::StrideEntry::invalidate()
+{
+    instAddr = 0;
+    lastAddr = 0;
+    isSecure = false;
+    stride = 0;
+    confidence = 0;
+}
+
 StridePrefetcher::StridePrefetcher(const StridePrefetcherParams *p)
     : QueuedPrefetcher(p),
       maxConf(p->max_conf),
@@ -182,10 +197,14 @@ StridePrefetcher::calculatePrefetch(const PacketPtr &pkt,
                 is_secure ? "s" : "ns");
 
         StrideEntry* entry = pcTable->findVictim(pc);
+
+        // Invalidate victim
+        entry->invalidate();
+
+        // Insert new entry's data
         entry->instAddr = pc;
         entry->lastAddr = pkt_addr;
         entry->isSecure= is_secure;
-        entry->stride = 0;
         entry->confidence = startConf;
     }
 }
index ec22ca63f9b1a5cbf83566dffa3f7d339c43537a..772c3a51107beb8c8ea816215130a6a400874f13 100644 (file)
@@ -75,9 +75,11 @@ class StridePrefetcher : public QueuedPrefetcher
 
     struct StrideEntry
     {
-        StrideEntry() : instAddr(0), lastAddr(0), isSecure(false), stride(0),
-                        confidence(0)
-        { }
+        /** Default constructor */
+        StrideEntry();
+
+        /** Invalidate the entry */
+        void invalidate();
 
         Addr instAddr;
         Addr lastAddr;