Track the PC of the cache data stored in fetch so it doesn't access memory multiple times if information is already in fetch.
--HG-- extra : convert_revision : 00b160b255e998cf99286bcc21894110c7642624
This commit is contained in:
parent
0b0cb2bca7
commit
6d120b7912
2 changed files with 10 additions and 0 deletions
|
@ -404,6 +404,9 @@ class DefaultFetch
|
||||||
/** The cache line being fetched. */
|
/** The cache line being fetched. */
|
||||||
uint8_t *cacheData[Impl::MaxThreads];
|
uint8_t *cacheData[Impl::MaxThreads];
|
||||||
|
|
||||||
|
/** The PC of the cacheline that has been loaded. */
|
||||||
|
Addr cacheDataPC[Impl::MaxThreads];
|
||||||
|
|
||||||
/** Size of instructions. */
|
/** Size of instructions. */
|
||||||
int instSize;
|
int instSize;
|
||||||
|
|
||||||
|
|
|
@ -517,6 +517,11 @@ DefaultFetch<Impl>::fetchCacheLine(Addr fetch_PC, Fault &ret_fault, unsigned tid
|
||||||
// Align the fetch PC so it's at the start of a cache block.
|
// Align the fetch PC so it's at the start of a cache block.
|
||||||
fetch_PC = icacheBlockAlignPC(fetch_PC);
|
fetch_PC = icacheBlockAlignPC(fetch_PC);
|
||||||
|
|
||||||
|
// If we've already got the block, no need to try to fetch it again.
|
||||||
|
if (fetch_PC == cacheDataPC[tid]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup the memReq to do a read of the first instruction's address.
|
// Setup the memReq to do a read of the first instruction's address.
|
||||||
// Set the appropriate read size and flags as well.
|
// Set the appropriate read size and flags as well.
|
||||||
// Build request here.
|
// Build request here.
|
||||||
|
@ -550,6 +555,8 @@ DefaultFetch<Impl>::fetchCacheLine(Addr fetch_PC, Fault &ret_fault, unsigned tid
|
||||||
Packet::ReadReq, Packet::Broadcast);
|
Packet::ReadReq, Packet::Broadcast);
|
||||||
data_pkt->dataStatic(cacheData[tid]);
|
data_pkt->dataStatic(cacheData[tid]);
|
||||||
|
|
||||||
|
cacheDataPC[tid] = fetch_PC;
|
||||||
|
|
||||||
DPRINTF(Fetch, "Fetch: Doing instruction read.\n");
|
DPRINTF(Fetch, "Fetch: Doing instruction read.\n");
|
||||||
|
|
||||||
fetchedCacheLines++;
|
fetchedCacheLines++;
|
||||||
|
|
Loading…
Reference in a new issue