mem-cache: Forward declare ReplaceableEntry
[gem5.git] / src / mem / cache / cache.cc
index f74afcb2bb8b002e5cf6289fe4e4fa957574aa34..ffd60811e4b1ecf00c89043e040d3259d630aefa 100644 (file)
@@ -271,9 +271,6 @@ Cache::recvTimingSnoopResp(PacketPtr pkt)
 {
     DPRINTF(Cache, "%s for %s\n", __func__, pkt->print());
 
-    assert(pkt->isResponse());
-    assert(!system->bypassCaches());
-
     // determine if the response is from a snoop request we created
     // (in which case it should be in the outstandingSnoop), or if we
     // merely forwarded someone else's snoop request
@@ -380,10 +377,10 @@ Cache::handleTimingReqMiss(PacketPtr pkt, CacheBlk *blk, Tick forward_time,
 
         if (!mshr) {
             // copy the request and create a new SoftPFReq packet
-            RequestPtr req = new Request(pkt->req->getPaddr(),
-                                         pkt->req->getSize(),
-                                         pkt->req->getFlags(),
-                                         pkt->req->masterId());
+            RequestPtr req = std::make_shared<Request>(pkt->req->getPaddr(),
+                                                       pkt->req->getSize(),
+                                                       pkt->req->getFlags(),
+                                                       pkt->req->masterId());
             pf = new Packet(req, pkt->cmd);
             pf->allocate();
             assert(pf->getAddr() == pkt->getAddr());
@@ -409,16 +406,6 @@ Cache::recvTimingReq(PacketPtr pkt)
 {
     DPRINTF(CacheTags, "%s tags:\n%s\n", __func__, tags->print());
 
-    assert(pkt->isRequest());
-
-    // Just forward the packet if caches are disabled.
-    if (system->bypassCaches()) {
-        // @todo This should really enqueue the packet rather
-        bool M5_VAR_USED success = memSidePort.sendTimingReq(pkt);
-        assert(success);
-        return;
-    }
-
     promoteWholeLineWrites(pkt);
 
     if (pkt->cacheResponding()) {
@@ -665,10 +652,6 @@ Cache::handleAtomicReqMiss(PacketPtr pkt, CacheBlk *blk,
 Tick
 Cache::recvAtomic(PacketPtr pkt)
 {
-    // Forward the request if the system is in cache bypass mode.
-    if (system->bypassCaches())
-        return ticksToCycles(memSidePort.sendAtomic(pkt));
-
     promoteWholeLineWrites(pkt);
 
     return BaseCache::recvAtomic(pkt);
@@ -713,7 +696,6 @@ Cache::serviceMSHRTargets(MSHR *mshr, const PacketPtr pkt, CacheBlk *blk,
                 // immediately with dummy data so the core would be able to
                 // retire it. This request completes right here, so we
                 // deallocate it.
-                delete tgt_pkt->req;
                 delete tgt_pkt;
                 break; // skip response
             }
@@ -820,7 +802,6 @@ Cache::serviceMSHRTargets(MSHR *mshr, const PacketPtr pkt, CacheBlk *blk,
             assert(tgt_pkt->cmd == MemCmd::HardPFReq);
             if (blk)
                 blk->status |= BlkHWPrefetched;
-            delete tgt_pkt->req;
             delete tgt_pkt;
             break;
 
@@ -888,10 +869,11 @@ Cache::cleanEvictBlk(CacheBlk *blk)
 {
     assert(!writebackClean);
     assert(blk && blk->isValid() && !blk->isDirty());
+
     // Creating a zero sized write, a message to the snoop filter
-    Request *req =
-        new Request(tags->regenerateBlkAddr(blk), blkSize, 0,
-                    Request::wbMasterId);
+    RequestPtr req = std::make_shared<Request>(
+        regenerateBlkAddr(blk), blkSize, 0, Request::wbMasterId);
+
     if (blk->isSecure())
         req->setFlags(Request::SECURE);
 
@@ -904,7 +886,6 @@ Cache::cleanEvictBlk(CacheBlk *blk)
     return pkt;
 }
 
-
 /////////////////////////////////////////////////////
 //
 // Snoop path: requests coming in from the memory side
@@ -1155,15 +1136,6 @@ Cache::handleSnoop(PacketPtr pkt, CacheBlk *blk, bool is_timing,
 
     if (!respond && is_deferred) {
         assert(pkt->needsResponse());
-
-        // if we copied the deferred packet with the intention to
-        // respond, but are not responding, then a cache above us must
-        // be, and we can use this as the indication of whether this
-        // is a packet where we created a copy of the request or not
-        if (!pkt->cacheResponding()) {
-            delete pkt->req;
-        }
-
         delete pkt;
     }
 
@@ -1183,9 +1155,6 @@ Cache::recvTimingSnoopReq(PacketPtr pkt)
 {
     DPRINTF(CacheVerbose, "%s: for %s\n", __func__, pkt->print());
 
-    // Snoops shouldn't happen when bypassing caches
-    assert(!system->bypassCaches());
-
     // no need to snoop requests that are not in range
     if (!inRange(pkt->getAddr())) {
         return;
@@ -1309,9 +1278,6 @@ Cache::recvTimingSnoopReq(PacketPtr pkt)
 Tick
 Cache::recvAtomicSnoop(PacketPtr pkt)
 {
-    // Snoops shouldn't happen when bypassing caches
-    assert(!system->bypassCaches());
-
     // no need to snoop requests that are not in range.
     if (!inRange(pkt->getAddr())) {
         return 0;
@@ -1419,7 +1385,6 @@ Cache::sendMSHRQueuePacket(MSHR* mshr)
             }
 
             // given that no response is expected, delete Request and Packet
-            delete tgt_pkt->req;
             delete tgt_pkt;
 
             return false;