isReadOnly(p->is_read_only),
blocked(0),
order(0),
- noTargetMSHR(NULL),
+ noTargetMSHR(nullptr),
missCount(p->max_miss_count),
addrRanges(p->addr_ranges.begin(), p->addr_ranges.end()),
system(p->system)
old_blk->invalidate();
}
- blk = NULL;
+ blk = nullptr;
// lookupLatency is the latency in case the request is uncacheable.
lat = lookupLatency;
return false;
return true;
}
- if (blk == NULL) {
+ if (blk == nullptr) {
// need to do a replacement
blk = allocateBlock(pkt->getAddr(), pkt->isSecure(), writebacks);
- if (blk == NULL) {
+ if (blk == nullptr) {
// no replaceable block available: give up, fwd to next level.
incMissCount(pkt);
return false;
incHitCount(pkt);
return true;
} else if (pkt->cmd == MemCmd::CleanEvict) {
- if (blk != NULL) {
+ if (blk != nullptr) {
// Found the block in the tags, need to stop CleanEvict from
// propagating further down the hierarchy. Returning true will
// treat the CleanEvict like a satisfied write request and delete
// like a Writeback which could not find a replaceable block so has to
// go to next level.
return false;
- } else if ((blk != NULL) &&
+ } else if ((blk != nullptr) &&
(pkt->needsWritable() ? blk->isWritable() :
blk->isReadable())) {
// OK to satisfy access
return true;
}
- // Can't satisfy access normally... either no block (blk == NULL)
+ // Can't satisfy access normally... either no block (blk == nullptr)
// or have block but need writable
incMissCount(pkt);
- if (blk == NULL && pkt->isLLSC() && pkt->isWrite()) {
+ if (blk == nullptr && pkt->isLLSC() && pkt->isWrite()) {
// complete miss on store conditional... just give up now
pkt->req->setExtraData(0);
return true;
// We use lookupLatency here because it is used to specify the latency
// to access.
Cycles lat = lookupLatency;
- CacheBlk *blk = NULL;
+ CacheBlk *blk = nullptr;
bool satisfied = false;
{
PacketList writebacks;
// writebacks... that would mean that someone used an atomic
// access in timing mode
- CacheBlk *blk = NULL;
+ CacheBlk *blk = nullptr;
PacketList writebacks;
bool satisfied = access(pkt, blk, lat, writebacks);
PacketPtr bus_pkt = createMissPacket(pkt, blk, pkt->needsWritable());
- bool is_forward = (bus_pkt == NULL);
+ bool is_forward = (bus_pkt == nullptr);
if (is_forward) {
// just forwarding the same request to the next level
if (mshr == noTargetMSHR) {
// we always clear at least one target
clearBlocked(Blocked_NoTargets);
- noTargetMSHR = NULL;
+ noTargetMSHR = nullptr;
}
// Initial target is used just for stats
pkt->getAddr());
blk = handleFill(pkt, blk, writebacks, mshr->allocOnFill);
- assert(blk != NULL);
+ assert(blk != nullptr);
}
// allow invalidation responses originating from write-line
mshr->promoteWritable();
// NB: we use the original packet here and not the response!
blk = handleFill(tgt_pkt, blk, writebacks, mshr->allocOnFill);
- assert(blk != NULL);
+ assert(blk != nullptr);
// treat as a fill, and discard the invalidation
// response
{
CacheBlk *blk = tags->findVictim(addr);
- // It is valid to return NULL if there is no victim
+ // It is valid to return nullptr if there is no victim
if (!blk)
return nullptr;
assert(repl_mshr->needsWritable());
// too hard to replace block with transient state
// allocation failed, block not inserted
- return NULL;
+ return nullptr;
} else {
DPRINTF(Cache, "replacement: replacing %#llx (%s) with %#llx "
"(%s): %s\n", repl_addr, blk->isSecure() ? "s" : "ns",
assert(addr == blockAlign(addr));
assert(!writeBuffer.findMatch(addr, is_secure));
- if (blk == NULL) {
+ if (blk == nullptr) {
// better have read new data...
assert(pkt->hasData());
// need to do a replacement if allocating, otherwise we stick
// with the temporary storage
- blk = allocate ? allocateBlock(addr, is_secure, writebacks) : NULL;
+ blk = allocate ? allocateBlock(addr, is_secure, writebacks) : nullptr;
- if (blk == NULL) {
+ if (blk == nullptr) {
// No replaceable block or a mostly exclusive
// cache... just use temporary storage to complete the
// current request and then get rid of it
// prefetch request because prefetch requests need an MSHR and may
// generate a snoop response.
assert(pkt->isEviction());
- snoop_pkt.senderState = NULL;
+ snoop_pkt.senderState = nullptr;
cpuSidePort->sendTimingSnoopReq(&snoop_pkt);
// Writeback/CleanEvict snoops do not generate a snoop response.
assert(!(snoop_pkt.cacheResponding()));
if (tgt_pkt->cmd == MemCmd::HardPFReq && forwardSnoops) {
// we should never have hardware prefetches to allocated
// blocks
- assert(blk == NULL);
+ assert(blk == nullptr);
// We need to check the caches above us to verify that
// they don't have a copy of this block in the dirty state
// MSHR request, proceed to get the packet to send downstream
PacketPtr pkt = createMissPacket(tgt_pkt, blk, mshr->needsWritable());
- mshr->isForward = (pkt == NULL);
+ mshr->isForward = (pkt == nullptr);
if (mshr->isForward) {
// not a cache block request, but a response is expected
* Find a block frame for new block at address addr targeting the
* given security space, assuming that the block is not currently
* in the cache. Append writebacks if any to provided packet
- * list. Return free block frame. May return NULL if there are
+ * list. Return free block frame. May return nullptr if there are
* no replaceable blocks at the moment.
*/
CacheBlk *allocateBlock(Addr addr, bool is_secure, PacketList &writebacks);
* given parameters.
* @param cpu_pkt The miss that needs to be satisfied.
* @param blk The block currently in the cache corresponding to
- * cpu_pkt (NULL if none).
+ * cpu_pkt (nullptr if none).
* @param needsWritable Indicates that the block must be writable
* even if the request in cpu_pkt doesn't indicate that.
- * @return A new Packet containing the request, or NULL if the
+ * @return A new Packet containing the request, or nullptr if the
* current request in cpu_pkt should just be forwarded on.
*/
PacketPtr createMissPacket(PacketPtr cpu_pkt, CacheBlk *blk,
// an MSHR entry. If we do, set the downstreamPending
// flag. Otherwise, do nothing.
MSHR *mshr = pkt->findNextSenderState<MSHR>();
- if (mshr != NULL) {
+ if (mshr != nullptr) {
assert(!mshr->downstreamPending);
mshr->downstreamPending = true;
} else {
// downstreamPending flag in all caches this packet has
// passed through.
MSHR *mshr = t.pkt->findNextSenderState<MSHR>();
- if (mshr != NULL) {
+ if (mshr != nullptr) {
mshr->clearDownstreamPending();
}
}
// For other requests, we iterate over the individual targets
// since that's where the actual data lies.
if (pkt->isPrint()) {
- pkt->checkFunctional(this, blkAddr, isSecure, blkSize, NULL);
+ pkt->checkFunctional(this, blkAddr, isSecure, blkSize, nullptr);
return false;
} else {
return (targets.checkFunctional(pkt) ||
if (pfq.empty()) {
DPRINTF(HWPrefetch, "No hardware prefetches available.\n");
- return NULL;
+ return nullptr;
}
PacketPtr pkt = pfq.begin()->pkt;
pfq.pop_front();
pfIssued++;
- assert(pkt != NULL);
+ assert(pkt != nullptr);
DPRINTF(HWPrefetch, "Generating prefetch for %#x.\n", pkt->getAddr());
return pkt;
}
Entry* getNext() const
{
if (readyList.empty() || readyList.front()->readyTime > curTick()) {
- return NULL;
+ return nullptr;
}
return readyList.front();
}
/**
* Access block and update replacement data. May not succeed, in which case
- * NULL pointer is returned. This has all the implications of a cache
+ * nullptr is returned. This has all the implications of a cache
* access and should only be used as such. Returns the access latency as a
* side effect.
* @param addr The address to find.
// a hit. Sequential access with a miss doesn't access data.
tagAccesses += allocAssoc;
if (sequentialAccess) {
- if (blk != NULL) {
+ if (blk != nullptr) {
dataAccesses += 1;
}
} else {
dataAccesses += allocAssoc;
}
- if (blk != NULL) {
+ if (blk != nullptr) {
if (blk->whenReady > curTick()
&& cache->ticksToCycles(blk->whenReady - curTick())
> accessLatency) {
*/
CacheBlk* findVictim(Addr addr) override
{
- BlkType *blk = NULL;
+ BlkType *blk = nullptr;
int set = extractSet(addr);
// prefer to evict an invalid block
return blks[i];
}
}
- return NULL;
+ return nullptr;
}
template <class Blktype>
head = &(blks[0]);
tail = &(blks[numBlocks-1]);
- head->prev = NULL;
+ head->prev = nullptr;
head->next = &(blks[1]);
head->inCache = cacheMask;
tail->prev = &(blks[numBlocks-2]);
- tail->next = NULL;
+ tail->next = nullptr;
tail->inCache = 0;
unsigned index = (1 << 17) / blkSize;
if (iter != tagHash.end()) {
return (*iter).second;
}
- return NULL;
+ return nullptr;
}
void
moveToHead(blk);
}
} else {
- blk = NULL;
+ blk = nullptr;
for (unsigned i = 0; i <= numCaches; ++i) {
misses[i]++;
}
if (blk && blk->isValid()) {
assert(blk->tag == blkAddr);
} else {
- blk = NULL;
+ blk = nullptr;
}
return blk;
}
blk->inCache = cacheMask;
if (blk != head) {
if (blk == tail){
- assert(blk->next == NULL);
+ assert(blk->next == nullptr);
tail = blk->prev;
- tail->next = NULL;
+ tail->next = nullptr;
} else {
blk->prev->next = blk->next;
blk->next->prev = blk->prev;
}
blk->next = head;
- blk->prev = NULL;
+ blk->prev = nullptr;
head->prev = blk;
head = blk;
}
/**
* Access block and update replacement data. May not succeed, in which
- * case NULL pointer is returned. This has all the implications of a cache
- * access and should only be used as such.
+ * case nullptr pointer is returned. This has all the implications of a
+ * cache access and should only be used as such.
* Returns the access latency and inCache flags as a side effect.
* @param addr The address to look for.
* @param is_secure True if the target memory space is secure.
{
CacheBlk *blk = BaseSetAssoc::accessBlock(addr, is_secure, lat, master_id);
- if (blk != NULL) {
+ if (blk != nullptr) {
// move this block to head of the MRU list
sets[blk->set].moveToHead(blk);
DPRINTF(CacheRepl, "set %x: moving blk %x (%s) to MRU\n",
{
int set = extractSet(addr);
// grab a replacement candidate
- BlkType *blk = NULL;
+ BlkType *blk = nullptr;
for (int i = assoc - 1; i >= 0; i--) {
BlkType *b = sets[set].blks[i];
if (b->way < allocAssoc) {
// entity. For other requests, we iterate over the individual
// targets since that's where the actual data lies.
if (pkt->isPrint()) {
- pkt->checkFunctional(this, blkAddr, isSecure, blkSize, NULL);
+ pkt->checkFunctional(this, blkAddr, isSecure, blkSize, nullptr);
return false;
} else {
return targets.checkFunctional(pkt);