1/* |
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> |
53#include <functional> |
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 */ |
181 void cleanupRefs(); |
182 183 /** 184 * Computes stats just prior to dump event 185 */ |
186 void computeStats(); |
187 188 /** 189 * Print all tags used 190 */ |
191 std::string print(); |
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 |
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); |
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__ |