34,35c34,35
< #include "mem/cache/base.hh"
< #include "mem/cache/blk.hh"
---
> #include <memory>
>
39a40,61
> * The replacement data needed by the replacement policy.
> * Each replacement policy should have its own replacement data.
> */
> struct ReplacementData {};
>
> /**
> * A replaceable entry is used by any table-like structure that needs to
> * implement replacement functionality. It provides the replacement data
> * pointer instantiated and needed by the replacement policy used.
> * @sa Replacement Policies
> */
> class ReplaceableEntry
> {
> public:
> /**
> * Replacement data associated to this entry.
> * It is instantiated by the replacement policy.
> */
> std::shared_ptr<ReplacementData> replacementData;
> };
>
> /**
41,51d62
< *
< * The base functions touch() and reset() must be called by all subclasses
< * that override them.
< *
< * @todo
< * Currently the replacement candidates are simply the cache blocks
< * derived from the possible placement locations of an address, as
< * defined by the getPossibleLocations() from BaseTags. In a future
< * patch it should be an inheritable class to allow the replacement
< * policies to be used with any table-like structure that needs to
< * replace its entries.
53c64
< typedef std::vector<CacheBlk*> ReplacementCandidates;
---
> typedef std::vector<ReplaceableEntry*> ReplacementCandidates;
69c80
< BaseReplacementPolicy(const Params *p);
---
> BaseReplacementPolicy(const Params *p) : SimObject(p) {}
77,78c88
< * Touch a block to update its replacement data.
< * Updates number of references.
---
> * Invalidate replacement data to set it as the next probable victim.
80c90,96
< * This base function must be called by all subclasses that override it.
---
> * @param replacement_data Replacement data to be invalidated.
> */
> virtual void invalidate(const std::shared_ptr<ReplacementData>&
> replacement_data) const = 0;
>
> /**
> * Update replacement data.
82c98
< * @param blk Cache block to be touched.
---
> * @param replacement_data Replacement data to be touched.
84c100,101
< virtual void touch(CacheBlk *blk);
---
> virtual void touch(const std::shared_ptr<ReplacementData>&
> replacement_data) const = 0;
87,88c104
< * Reset replacement data for a block. Used when a block is inserted.
< * Sets the insertion tick, and update number of references.
---
> * Reset replacement data. Used when it's holder is inserted/validated.
90,92c106
< * This base function must be called by all subclasses that override it.
< *
< * @param blk Cache block to be reset.
---
> * @param replacement_data Replacement data to be reset.
94c108,109
< virtual void reset(CacheBlk *blk);
---
> virtual void reset(const std::shared_ptr<ReplacementData>&
> replacement_data) const = 0;
100c115
< * @return Cache block to be replaced.
---
> * @return Replacement entry to be replaced.
102c117,125
< virtual CacheBlk* getVictim(const ReplacementCandidates& candidates) = 0;
---
> virtual ReplaceableEntry* getVictim(
> const ReplacementCandidates& candidates) const = 0;
>
> /**
> * Instantiate a replacement data entry.
> *
> * @return A shared pointer to the new replacement data.
> */
> virtual std::shared_ptr<ReplacementData> instantiateEntry() = 0;