From 815b12fb4aa45bfe8b38f96f923c150880bf9200 Mon Sep 17 00:00:00 2001 From: "Daniel R. Carvalho" Date: Fri, 20 Apr 2018 17:15:41 +0200 Subject: mem-cache: Use ReplaceableEntry in findBlockBySetAndWay With a sector cache you can't find a block using only its set and way, as there is the sector offset to take into account. As all of these blocks inherit from ReplaceableEntry, the return type of this function has been updated. This function has also been declared closer to findBlock() due to their similar functionality. Change-Id: I4730a2b4ebb5738f7fc118201e208a1b9c3ba8e8 Reviewed-on: https://gem5-review.googlesource.com/10141 Reviewed-by: Nikos Nikoleris Maintainer: Nikos Nikoleris --- src/mem/cache/tags/base.hh | 17 +++++++++-------- src/mem/cache/tags/base_set_assoc.cc | 2 +- src/mem/cache/tags/base_set_assoc.hh | 17 +++++++++-------- src/mem/cache/tags/fa_lru.cc | 2 +- src/mem/cache/tags/fa_lru.hh | 17 +++++++++-------- 5 files changed, 29 insertions(+), 26 deletions(-) diff --git a/src/mem/cache/tags/base.hh b/src/mem/cache/tags/base.hh index 358ad1003..167364ff1 100644 --- a/src/mem/cache/tags/base.hh +++ b/src/mem/cache/tags/base.hh @@ -195,6 +195,15 @@ class BaseTags : public ClockedObject */ virtual CacheBlk * findBlock(Addr addr, bool is_secure) const = 0; + /** + * Find a block given set and way. + * + * @param set The set of the block. + * @param way The way of the block. + * @return The block. + */ + virtual ReplaceableEntry* findBlockBySetAndWay(int set, int way) const = 0; + /** * Align an address to the block size. * @param addr the address to align. @@ -215,14 +224,6 @@ class BaseTags : public ClockedObject return (addr & blkMask); } - /** - * Find the cache block given set and way - * @param set The set of the block. - * @param way The way of the block. - * @return The cache block. - */ - virtual CacheBlk *findBlockBySetAndWay(int set, int way) const = 0; - /** * Limit the allocation for the cache ways. * @param ways The maximum number of ways available for replacement. diff --git a/src/mem/cache/tags/base_set_assoc.cc b/src/mem/cache/tags/base_set_assoc.cc index 9cd93dbea..ae98dcf3d 100644 --- a/src/mem/cache/tags/base_set_assoc.cc +++ b/src/mem/cache/tags/base_set_assoc.cc @@ -126,7 +126,7 @@ BaseSetAssoc::findBlock(Addr addr, bool is_secure) const return blk; } -CacheBlk* +ReplaceableEntry* BaseSetAssoc::findBlockBySetAndWay(int set, int way) const { return sets[set].blks[way]; diff --git a/src/mem/cache/tags/base_set_assoc.hh b/src/mem/cache/tags/base_set_assoc.hh index 830af6f3d..475566268 100644 --- a/src/mem/cache/tags/base_set_assoc.hh +++ b/src/mem/cache/tags/base_set_assoc.hh @@ -129,14 +129,6 @@ class BaseSetAssoc : public BaseTags */ void invalidate(CacheBlk *blk) override; - /** - * Find the cache block given set and way - * @param set The set of the block. - * @param way The way of the block. - * @return The cache block. - */ - CacheBlk *findBlockBySetAndWay(int set, int way) const override; - /** * Access block and update replacement data. May not succeed, in which case * nullptr is returned. This has all the implications of a cache @@ -198,6 +190,15 @@ class BaseSetAssoc : public BaseTags */ CacheBlk* findBlock(Addr addr, bool is_secure) const override; + /** + * Find a block given set and way. + * + * @param set The set of the block. + * @param way The way of the block. + * @return The block. + */ + ReplaceableEntry* findBlockBySetAndWay(int set, int way) const override; + /** * Find replacement victim based on address. * diff --git a/src/mem/cache/tags/fa_lru.cc b/src/mem/cache/tags/fa_lru.cc index 29dab3b64..a6e1b3be1 100644 --- a/src/mem/cache/tags/fa_lru.cc +++ b/src/mem/cache/tags/fa_lru.cc @@ -185,7 +185,7 @@ FALRU::findBlock(Addr addr, bool is_secure) const return blk; } -CacheBlk* +ReplaceableEntry* FALRU::findBlockBySetAndWay(int set, int way) const { assert(set == 0); diff --git a/src/mem/cache/tags/fa_lru.hh b/src/mem/cache/tags/fa_lru.hh index dbb39b7d1..22b67c534 100644 --- a/src/mem/cache/tags/fa_lru.hh +++ b/src/mem/cache/tags/fa_lru.hh @@ -185,6 +185,15 @@ class FALRU : public BaseTags */ CacheBlk* findBlock(Addr addr, bool is_secure) const override; + /** + * Find a block given set and way. + * + * @param set The set of the block. + * @param way The way of the block. + * @return The block. + */ + ReplaceableEntry* findBlockBySetAndWay(int set, int way) const override; + /** * Find replacement victim based on address. * @@ -201,14 +210,6 @@ class FALRU : public BaseTags */ void insertBlock(PacketPtr pkt, CacheBlk *blk) override; - /** - * Find the cache block given set and way - * @param set The set of the block. - * @param way The way of the block. - * @return The cache block. - */ - CacheBlk* findBlockBySetAndWay(int set, int way) const override; - /** * Generate the tag from the addres. For fully associative this is just the * block address. -- cgit v1.2.3