base: Extract KeyType type in the AssociativeCache from Entry
The KeyType data type is the type of the lookup and the cache extracts it from the Entry template parameter Change-Id: I147d7c2503abc11becfeebe6336e7f90989ad4e8 Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
This commit is contained in:
31
src/base/cache/associative_cache.hh
vendored
31
src/base/cache/associative_cache.hh
vendored
@@ -67,6 +67,7 @@ class AssociativeCache : public Named
|
||||
|
||||
typedef replacement_policy::Base BaseReplacementPolicy;
|
||||
typedef typename Entry::IndexingPolicy IndexingPolicy;
|
||||
typedef typename Entry::KeyType KeyType;
|
||||
|
||||
/** Associativity of the cache. */
|
||||
size_t associativity;
|
||||
@@ -164,13 +165,13 @@ class AssociativeCache : public Named
|
||||
/**
|
||||
* Do an access to the entry if it exists.
|
||||
* This is required to update the replacement information data.
|
||||
* @param addr key to the entry
|
||||
* @param key key to the entry
|
||||
* @return The entry if it exists
|
||||
*/
|
||||
virtual Entry*
|
||||
accessEntryByAddr(const Addr addr)
|
||||
accessEntry(const KeyType &key)
|
||||
{
|
||||
auto entry = findEntry(addr);
|
||||
auto entry = findEntry(key);
|
||||
|
||||
if (entry) {
|
||||
accessEntry(entry);
|
||||
@@ -191,18 +192,18 @@ class AssociativeCache : public Named
|
||||
|
||||
/**
|
||||
* Find an entry within the set
|
||||
* @param addr key element
|
||||
* @param key key element
|
||||
* @return returns a pointer to the wanted entry or nullptr if it does not
|
||||
* exist.
|
||||
*/
|
||||
virtual Entry*
|
||||
findEntry(const Addr addr) const
|
||||
findEntry(const KeyType &key) const
|
||||
{
|
||||
auto candidates = indexingPolicy->getPossibleEntries(addr);
|
||||
auto candidates = indexingPolicy->getPossibleEntries(key);
|
||||
|
||||
for (auto candidate : candidates) {
|
||||
Entry *entry = static_cast<Entry*>(candidate);
|
||||
if (entry->match(addr)) {
|
||||
if (entry->match(key)) {
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
@@ -212,13 +213,13 @@ class AssociativeCache : public Named
|
||||
|
||||
/**
|
||||
* Find a victim to be replaced
|
||||
* @param addr key to select the possible victim
|
||||
* @param key key to select the possible victim
|
||||
* @result entry to be victimized
|
||||
*/
|
||||
virtual Entry*
|
||||
findVictim(const Addr addr)
|
||||
findVictim(const KeyType &key)
|
||||
{
|
||||
auto candidates = indexingPolicy->getPossibleEntries(addr);
|
||||
auto candidates = indexingPolicy->getPossibleEntries(key);
|
||||
|
||||
auto victim = static_cast<Entry*>(replPolicy->getVictim(candidates));
|
||||
|
||||
@@ -241,13 +242,13 @@ class AssociativeCache : public Named
|
||||
|
||||
/**
|
||||
* Indicate that an entry has just been inserted
|
||||
* @param addr key of the container
|
||||
* @param key key of the container
|
||||
* @param entry pointer to the container entry to be inserted
|
||||
*/
|
||||
virtual void
|
||||
insertEntry(const Addr addr, Entry *entry)
|
||||
insertEntry(const KeyType &key, Entry *entry)
|
||||
{
|
||||
entry->insert(addr);
|
||||
entry->insert(key);
|
||||
replPolicy->reset(entry->replacementData);
|
||||
}
|
||||
|
||||
@@ -258,10 +259,10 @@ class AssociativeCache : public Named
|
||||
* @result vector of candidates matching with the provided key
|
||||
*/
|
||||
std::vector<Entry *>
|
||||
getPossibleEntries(const Addr addr) const
|
||||
getPossibleEntries(const KeyType &key) const
|
||||
{
|
||||
std::vector<ReplaceableEntry *> selected_entries =
|
||||
indexingPolicy->getPossibleEntries(addr);
|
||||
indexingPolicy->getPossibleEntries(key);
|
||||
|
||||
std::vector<Entry *> entries;
|
||||
|
||||
|
||||
1
src/base/cache/cache_entry.hh
vendored
1
src/base/cache/cache_entry.hh
vendored
@@ -60,6 +60,7 @@ class CacheEntry : public ReplaceableEntry
|
||||
{
|
||||
public:
|
||||
using IndexingPolicy = BaseIndexingPolicy;
|
||||
using KeyType = Addr;
|
||||
|
||||
CacheEntry(BaseIndexingPolicy *ip) : indexingPolicy(ip) {}
|
||||
~CacheEntry() = default;
|
||||
|
||||
1
src/mem/cache/prefetch/associative_set.hh
vendored
1
src/mem/cache/prefetch/associative_set.hh
vendored
@@ -86,7 +86,6 @@ class AssociativeSet : public AssociativeCache<Entry>
|
||||
|
||||
private:
|
||||
// The following APIs are excluded since they lack the secure bit
|
||||
using AssociativeCache<Entry>::accessEntryByAddr;
|
||||
using AssociativeCache<Entry>::findEntry;
|
||||
using AssociativeCache<Entry>::insertEntry;
|
||||
using AssociativeCache<Entry>::replPolicy;
|
||||
|
||||
Reference in New Issue
Block a user