mem-ruby: Use lookup function in cache
There is a function to perform lookups; there is no need to replicate its code everywhere. Change-Id: I1290594615d282722cd91071be8ef3c372414e4e Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/23946 Reviewed-by: John Alsop <johnathan.alsop@amd.com> Reviewed-by: Jason Lowe-Power <power.jg@gmail.com> Maintainer: Jason Lowe-Power <power.jg@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
committed by
Daniel Carvalho
parent
f54af2863c
commit
1ad015389c
@@ -173,15 +173,12 @@ bool
|
||||
CacheMemory::tryCacheAccess(Addr address, RubyRequestType type,
|
||||
DataBlock*& data_ptr)
|
||||
{
|
||||
assert(address == makeLineAddress(address));
|
||||
DPRINTF(RubyCache, "address: %#x\n", address);
|
||||
int64_t cacheSet = addressToCacheSet(address);
|
||||
int loc = findTagInSet(cacheSet, address);
|
||||
if (loc != -1) {
|
||||
AbstractCacheEntry* entry = lookup(address);
|
||||
if (entry != nullptr) {
|
||||
// Do we even have a tag match?
|
||||
AbstractCacheEntry* entry = m_cache[cacheSet][loc];
|
||||
m_replacementPolicy_ptr->touch(entry->replacementData);
|
||||
m_cache[cacheSet][loc]->setLastAccess(curTick());
|
||||
entry->setLastAccess(curTick());
|
||||
data_ptr = &(entry->getDataBlk());
|
||||
|
||||
if (entry->m_Permission == AccessPermission_Read_Write) {
|
||||
@@ -201,20 +198,15 @@ bool
|
||||
CacheMemory::testCacheAccess(Addr address, RubyRequestType type,
|
||||
DataBlock*& data_ptr)
|
||||
{
|
||||
assert(address == makeLineAddress(address));
|
||||
DPRINTF(RubyCache, "address: %#x\n", address);
|
||||
int64_t cacheSet = addressToCacheSet(address);
|
||||
int loc = findTagInSet(cacheSet, address);
|
||||
|
||||
if (loc != -1) {
|
||||
AbstractCacheEntry* entry = lookup(address);
|
||||
if (entry != nullptr) {
|
||||
// Do we even have a tag match?
|
||||
AbstractCacheEntry* entry = m_cache[cacheSet][loc];
|
||||
m_replacementPolicy_ptr->touch(entry->replacementData);
|
||||
m_cache[cacheSet][loc]->setLastAccess(curTick());
|
||||
entry->setLastAccess(curTick());
|
||||
data_ptr = &(entry->getDataBlk());
|
||||
|
||||
return m_cache[cacheSet][loc]->m_Permission !=
|
||||
AccessPermission_NotPresent;
|
||||
return entry->m_Permission != AccessPermission_NotPresent;
|
||||
}
|
||||
|
||||
data_ptr = NULL;
|
||||
@@ -225,11 +217,8 @@ CacheMemory::testCacheAccess(Addr address, RubyRequestType type,
|
||||
bool
|
||||
CacheMemory::isTagPresent(Addr address) const
|
||||
{
|
||||
assert(address == makeLineAddress(address));
|
||||
int64_t cacheSet = addressToCacheSet(address);
|
||||
int loc = findTagInSet(cacheSet, address);
|
||||
|
||||
if (loc == -1) {
|
||||
const AbstractCacheEntry* const entry = lookup(address);
|
||||
if (entry == nullptr) {
|
||||
// We didn't find the tag
|
||||
DPRINTF(RubyCache, "No tag match for address: %#x\n", address);
|
||||
return false;
|
||||
@@ -476,34 +465,28 @@ void
|
||||
CacheMemory::setLocked(Addr address, int context)
|
||||
{
|
||||
DPRINTF(RubyCache, "Setting Lock for addr: %#x to %d\n", address, context);
|
||||
assert(address == makeLineAddress(address));
|
||||
int64_t cacheSet = addressToCacheSet(address);
|
||||
int loc = findTagInSet(cacheSet, address);
|
||||
assert(loc != -1);
|
||||
m_cache[cacheSet][loc]->setLocked(context);
|
||||
AbstractCacheEntry* entry = lookup(address);
|
||||
assert(entry != nullptr);
|
||||
entry->setLocked(context);
|
||||
}
|
||||
|
||||
void
|
||||
CacheMemory::clearLocked(Addr address)
|
||||
{
|
||||
DPRINTF(RubyCache, "Clear Lock for addr: %#x\n", address);
|
||||
assert(address == makeLineAddress(address));
|
||||
int64_t cacheSet = addressToCacheSet(address);
|
||||
int loc = findTagInSet(cacheSet, address);
|
||||
assert(loc != -1);
|
||||
m_cache[cacheSet][loc]->clearLocked();
|
||||
AbstractCacheEntry* entry = lookup(address);
|
||||
assert(entry != nullptr);
|
||||
entry->clearLocked();
|
||||
}
|
||||
|
||||
bool
|
||||
CacheMemory::isLocked(Addr address, int context)
|
||||
{
|
||||
assert(address == makeLineAddress(address));
|
||||
int64_t cacheSet = addressToCacheSet(address);
|
||||
int loc = findTagInSet(cacheSet, address);
|
||||
assert(loc != -1);
|
||||
AbstractCacheEntry* entry = lookup(address);
|
||||
assert(entry != nullptr);
|
||||
DPRINTF(RubyCache, "Testing Lock for addr: %#llx cur %d con %d\n",
|
||||
address, m_cache[cacheSet][loc]->m_locked, context);
|
||||
return m_cache[cacheSet][loc]->isLocked(context);
|
||||
address, entry->m_locked, context);
|
||||
return entry->isLocked(context);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user