From: Daniel Date: Tue, 13 Nov 2018 19:59:50 +0000 (+0100) Subject: mem-cache: Return entry in StridePrefetcher::pcTableHit() X-Git-Tag: v19.0.0.0~1396 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=359a2ef70996fb4ed64d09421344eef2e4c85ab1;p=gem5.git mem-cache: Return entry in StridePrefetcher::pcTableHit() Return a pointer to the entry instead of returning a boolean and passing a pointer reference. As a side effect, change the name of the function to be more descriptive of the functionality. Change-Id: Iad44979e98031754c1d0857b1790c0eaf77e9765 Signed-off-by: Daniel Reviewed-on: https://gem5-review.googlesource.com/c/14356 Reviewed-by: Nikos Nikoleris Maintainer: Nikos Nikoleris --- diff --git a/src/mem/cache/prefetch/stride.cc b/src/mem/cache/prefetch/stride.cc index 3cea78ed7..a00b10a05 100644 --- a/src/mem/cache/prefetch/stride.cc +++ b/src/mem/cache/prefetch/stride.cc @@ -115,10 +115,10 @@ StridePrefetcher::calculatePrefetch(const PacketPtr &pkt, bool is_secure = pkt->isSecure(); MasterID master_id = useMasterId ? pkt->req->masterId() : 0; - // Lookup pc-based information - StrideEntry *entry; + // Search for entry in the pc table + StrideEntry *entry = findEntry(pc, is_secure, master_id); - if (pcTableHit(pc, is_secure, master_id, entry)) { + if (entry != nullptr) { // Hit in table int new_stride = pkt_addr - entry->lastAddr; bool stride_match = (new_stride == entry->stride); @@ -198,22 +198,20 @@ StridePrefetcher::pcTableVictim(Addr pc, int master_id) return &pcTable[master_id][set][way]; } -inline bool -StridePrefetcher::pcTableHit(Addr pc, bool is_secure, int master_id, - StrideEntry* &entry) +inline StridePrefetcher::StrideEntry* +StridePrefetcher::findEntry(Addr pc, bool is_secure, int master_id) { int set = pcHash(pc); StrideEntry* set_entries = pcTable[master_id][set]; for (int way = 0; way < pcTableAssoc; way++) { + StrideEntry* entry = &set_entries[way]; // Search ways for match - if (set_entries[way].instAddr == pc && - set_entries[way].isSecure == is_secure) { + if ((entry->instAddr == pc) && (entry->isSecure == is_secure)) { DPRINTF(HWPrefetch, "Lookup hit table[%d][%d].\n", set, way); - entry = &set_entries[way]; - return true; + return entry; } } - return false; + return nullptr; } StridePrefetcher* diff --git a/src/mem/cache/prefetch/stride.hh b/src/mem/cache/prefetch/stride.hh index 03ceec584..605b5432d 100644 --- a/src/mem/cache/prefetch/stride.hh +++ b/src/mem/cache/prefetch/stride.hh @@ -110,7 +110,16 @@ class StridePrefetcher : public QueuedPrefetcher }; PCTable pcTable; - bool pcTableHit(Addr pc, bool is_secure, int master_id, StrideEntry* &entry); + /** + * Search for an entry in the pc table. + * + * @param pc The PC to look for. + * @param is_secure True if the target memory space is secure. + * @param master_id The context. + * @return Pointer to the entry. + */ + StrideEntry* findEntry(Addr pc, bool is_secure, int master_id); + StrideEntry* pcTableVictim(Addr pc, int master_id); Addr pcHash(Addr pc) const;