base.hh (12727:56c23b54bcb1) | base.hh (12728:57bdea4f96aa) |
---|---|
1/* | 1/* |
2 * Copyright (c) 2012-2014,2016-2017 ARM Limited | 2 * Copyright (c) 2012-2014,2016-2018 ARM Limited |
3 * All rights reserved. 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software 9 * licensed hereunder. You may use the software subject to the license 10 * terms below provided that you ensure that this notice is replicated --- 34 unchanged lines hidden (view full) --- 45 * @file 46 * Declaration of a common base class for cache tagstore objects. 47 */ 48 49#ifndef __MEM_CACHE_TAGS_BASE_HH__ 50#define __MEM_CACHE_TAGS_BASE_HH__ 51 52#include <cassert> | 3 * All rights reserved. 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software 9 * licensed hereunder. You may use the software subject to the license 10 * terms below provided that you ensure that this notice is replicated --- 34 unchanged lines hidden (view full) --- 45 * @file 46 * Declaration of a common base class for cache tagstore objects. 47 */ 48 49#ifndef __MEM_CACHE_TAGS_BASE_HH__ 50#define __MEM_CACHE_TAGS_BASE_HH__ 51 52#include <cassert> |
53#include <functional> |
|
53#include <string> 54 55#include "base/callback.hh" 56#include "base/logging.hh" 57#include "base/statistics.hh" 58#include "base/types.hh" 59#include "mem/cache/blk.hh" 60#include "mem/packet.hh" --- 111 unchanged lines hidden (view full) --- 172 * Register local statistics. 173 */ 174 void regStats(); 175 176 /** 177 * Average in the reference count for valid blocks when the simulation 178 * exits. 179 */ | 54#include <string> 55 56#include "base/callback.hh" 57#include "base/logging.hh" 58#include "base/statistics.hh" 59#include "base/types.hh" 60#include "mem/cache/blk.hh" 61#include "mem/packet.hh" --- 111 unchanged lines hidden (view full) --- 173 * Register local statistics. 174 */ 175 void regStats(); 176 177 /** 178 * Average in the reference count for valid blocks when the simulation 179 * exits. 180 */ |
180 virtual void cleanupRefs() {} | 181 void cleanupRefs(); |
181 182 /** 183 * Computes stats just prior to dump event 184 */ | 182 183 /** 184 * Computes stats just prior to dump event 185 */ |
185 virtual void computeStats() {} | 186 void computeStats(); |
186 187 /** 188 * Print all tags used 189 */ | 187 188 /** 189 * Print all tags used 190 */ |
190 virtual std::string print() const = 0; | 191 std::string print(); |
191 192 /** 193 * Find a block using the memory address 194 */ 195 virtual CacheBlk * findBlock(Addr addr, bool is_secure) const = 0; 196 197 /** 198 * Align an address to the block size. --- 85 unchanged lines hidden (view full) --- 284 * 285 * @param block The block. 286 * @return the block address. 287 */ 288 virtual Addr regenerateBlkAddr(const CacheBlk* blk) const = 0; 289 290 virtual int extractSet(Addr addr) const = 0; 291 | 192 193 /** 194 * Find a block using the memory address 195 */ 196 virtual CacheBlk * findBlock(Addr addr, bool is_secure) const = 0; 197 198 /** 199 * Align an address to the block size. --- 85 unchanged lines hidden (view full) --- 285 * 286 * @param block The block. 287 * @return the block address. 288 */ 289 virtual Addr regenerateBlkAddr(const CacheBlk* blk) const = 0; 290 291 virtual int extractSet(Addr addr) const = 0; 292 |
292 virtual void forEachBlk(CacheBlkVisitor &visitor) = 0; | 293 294 /** 295 * Visit each block in the tags and apply a visitor 296 * 297 * The visitor should be a std::function that takes a cache block 298 * reference as its parameter. 299 * 300 * @param visitor Visitor to call on each block. 301 */ 302 virtual void forEachBlk(std::function<void(CacheBlk &)> visitor) = 0; 303 304 /** 305 * Find if any of the blocks satisfies a condition 306 * 307 * The visitor should be a std::function that takes a cache block 308 * reference as its parameter. The visitor will terminate the 309 * traversal early if the condition is satisfied. 310 * 311 * @param visitor Visitor to call on each block. 312 */ 313 virtual bool anyBlk(std::function<bool(CacheBlk &)> visitor) = 0; 314 315 private: 316 /** 317 * Update the reference stats using data from the input block 318 * 319 * @param blk The input block 320 */ 321 void cleanupRefsVisitor(CacheBlk &blk); 322 323 /** 324 * Update the occupancy and age stats using data from the input block 325 * 326 * @param blk The input block 327 */ 328 void computeStatsVisitor(CacheBlk &blk); |
293}; 294 295class BaseTagsCallback : public Callback 296{ 297 BaseTags *tags; 298 public: 299 BaseTagsCallback(BaseTags *t) : tags(t) {} 300 virtual void process() { tags->cleanupRefs(); }; 301}; 302 303class BaseTagsDumpCallback : public Callback 304{ 305 BaseTags *tags; 306 public: 307 BaseTagsDumpCallback(BaseTags *t) : tags(t) {} 308 virtual void process() { tags->computeStats(); }; 309}; 310 311#endif //__MEM_CACHE_TAGS_BASE_HH__ | 329}; 330 331class BaseTagsCallback : public Callback 332{ 333 BaseTags *tags; 334 public: 335 BaseTagsCallback(BaseTags *t) : tags(t) {} 336 virtual void process() { tags->cleanupRefs(); }; 337}; 338 339class BaseTagsDumpCallback : public Callback 340{ 341 BaseTags *tags; 342 public: 343 BaseTagsDumpCallback(BaseTags *t) : tags(t) {} 344 virtual void process() { tags->computeStats(); }; 345}; 346 347#endif //__MEM_CACHE_TAGS_BASE_HH__ |