diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mem/cache/mshr.cc | 32 | ||||
-rw-r--r-- | src/mem/cache/mshr.hh | 21 | ||||
-rw-r--r-- | src/mem/cache/mshr_queue.cc | 30 |
3 files changed, 30 insertions, 53 deletions
diff --git a/src/mem/cache/mshr.cc b/src/mem/cache/mshr.cc index 8eb5e4752..79cf7a998 100644 --- a/src/mem/cache/mshr.cc +++ b/src/mem/cache/mshr.cc @@ -104,7 +104,7 @@ MSHR::TargetList::add(PacketPtr pkt, Tick readyTime, } } - push_back(Target(pkt, readyTime, order, source, markPending)); + emplace_back(Target(pkt, readyTime, order, source, markPending)); } @@ -130,9 +130,8 @@ MSHR::TargetList::replaceUpgrades() if (!hasUpgrade) return; - Iterator end_i = end(); - for (Iterator i = begin(); i != end_i; ++i) { - replaceUpgrade(i->pkt); + for (auto& t : *this) { + replaceUpgrade(t.pkt); } hasUpgrade = false; @@ -142,16 +141,15 @@ MSHR::TargetList::replaceUpgrades() void MSHR::TargetList::clearDownstreamPending() { - Iterator end_i = end(); - for (Iterator i = begin(); i != end_i; ++i) { - if (i->markedPending) { + for (auto& t : *this) { + if (t.markedPending) { // Iterate over the SenderState stack and see if we find // an MSHR entry. If we find one, clear the // downstreamPending flag by calling // clearDownstreamPending(). This recursively clears the // downstreamPending flag in all caches this packet has // passed through. - MSHR *mshr = i->pkt->findNextSenderState<MSHR>(); + MSHR *mshr = t.pkt->findNextSenderState<MSHR>(); if (mshr != NULL) { mshr->clearDownstreamPending(); } @@ -163,9 +161,8 @@ MSHR::TargetList::clearDownstreamPending() bool MSHR::TargetList::checkFunctional(PacketPtr pkt) { - Iterator end_i = end(); - for (Iterator i = begin(); i != end_i; ++i) { - if (pkt->checkFunctional(i->pkt)) { + for (auto& t : *this) { + if (pkt->checkFunctional(t.pkt)) { return true; } } @@ -175,13 +172,12 @@ MSHR::TargetList::checkFunctional(PacketPtr pkt) void -MSHR::TargetList:: -print(std::ostream &os, int verbosity, const std::string &prefix) const +MSHR::TargetList::print(std::ostream &os, int verbosity, + const std::string &prefix) const { - ConstIterator end_i = end(); - for (ConstIterator i = begin(); i != end_i; ++i) { + for (auto& t : *this) { const char *s; - switch (i->source) { + switch (t.source) { case Target::FromCPU: s = "FromCPU"; break; @@ -196,7 +192,7 @@ print(std::ostream &os, int verbosity, const std::string &prefix) const break; } ccprintf(os, "%s%s: ", prefix, s); - i->pkt->print(os, verbosity, ""); + t.pkt->print(os, verbosity, ""); } } @@ -413,7 +409,7 @@ MSHR::promoteDeferredTargets() void -MSHR::handleFill(Packet *pkt, CacheBlk *blk) +MSHR::handleFill(PacketPtr pkt, CacheBlk *blk) { if (!pkt->sharedAsserted() && !(hasPostInvalidate() || hasPostDowngrade()) diff --git a/src/mem/cache/mshr.hh b/src/mem/cache/mshr.hh index 86b8dee4d..65740c107 100644 --- a/src/mem/cache/mshr.hh +++ b/src/mem/cache/mshr.hh @@ -100,13 +100,13 @@ class MSHR : public Packet::SenderState, public Printable FromPrefetcher }; - Tick recvTime; //!< Time when request was received (for stats) - Tick readyTime; //!< Time when request is ready to be serviced - Counter order; //!< Global order (for memory consistency mgmt) - PacketPtr pkt; //!< Pending request packet. - Source source; //!< Did request come from cpu, memory, or prefetcher? - bool markedPending; //!< Did we mark upstream MSHR - //!< as downstreamPending? + const Tick recvTime; //!< Time when request was received (for stats) + const Tick readyTime; //!< Time when request is ready to be serviced + const Counter order; //!< Global order (for memory consistency mgmt) + const PacketPtr pkt; //!< Pending request packet. + const Source source; //!< Request from cpu, memory, or prefetcher? + const bool markedPending; //!< Did we mark upstream MSHR + //!< as downstreamPending? Target(PacketPtr _pkt, Tick _readyTime, Counter _order, Source _source, bool _markedPending) @@ -116,9 +116,6 @@ class MSHR : public Packet::SenderState, public Printable }; class TargetList : public std::list<Target> { - /** Target list iterator. */ - typedef std::list<Target>::iterator Iterator; - typedef std::list<Target>::const_iterator ConstIterator; public: bool needsExclusive; @@ -126,7 +123,7 @@ class MSHR : public Packet::SenderState, public Printable TargetList(); void resetFlags() { needsExclusive = hasUpgrade = false; } - bool isReset() { return !needsExclusive && !hasUpgrade; } + bool isReset() const { return !needsExclusive && !hasUpgrade; } void add(PacketPtr pkt, Tick readyTime, Counter order, Target::Source source, bool markPending); void replaceUpgrades(); @@ -285,7 +282,7 @@ class MSHR : public Packet::SenderState, public Printable bool promoteDeferredTargets(); - void handleFill(Packet *pkt, CacheBlk *blk); + void handleFill(PacketPtr pkt, CacheBlk *blk); bool checkFunctional(PacketPtr pkt); diff --git a/src/mem/cache/mshr_queue.cc b/src/mem/cache/mshr_queue.cc index 788793aff..2b72cf339 100644 --- a/src/mem/cache/mshr_queue.cc +++ b/src/mem/cache/mshr_queue.cc @@ -68,10 +68,7 @@ MSHRQueue::MSHRQueue(const std::string &_label, MSHR * MSHRQueue::findMatch(Addr blk_addr, bool is_secure) const { - MSHR::ConstIterator i = allocatedList.begin(); - MSHR::ConstIterator end = allocatedList.end(); - for (; i != end; ++i) { - MSHR *mshr = *i; + for (const auto& mshr : allocatedList) { if (mshr->blkAddr == blk_addr && mshr->isSecure == is_secure) { return mshr; } @@ -86,10 +83,7 @@ MSHRQueue::findMatches(Addr blk_addr, bool is_secure, // Need an empty vector assert(matches.empty()); bool retval = false; - MSHR::ConstIterator i = allocatedList.begin(); - MSHR::ConstIterator end = allocatedList.end(); - for (; i != end; ++i) { - MSHR *mshr = *i; + for (const auto& mshr : allocatedList) { if (mshr->blkAddr == blk_addr && mshr->isSecure == is_secure) { retval = true; matches.push_back(mshr); @@ -103,10 +97,7 @@ bool MSHRQueue::checkFunctional(PacketPtr pkt, Addr blk_addr) { pkt->pushLabel(label); - MSHR::ConstIterator i = allocatedList.begin(); - MSHR::ConstIterator end = allocatedList.end(); - for (; i != end; ++i) { - MSHR *mshr = *i; + for (const auto& mshr : allocatedList) { if (mshr->blkAddr == blk_addr && mshr->checkFunctional(pkt)) { pkt->popLabel(); return true; @@ -120,10 +111,7 @@ MSHRQueue::checkFunctional(PacketPtr pkt, Addr blk_addr) MSHR * MSHRQueue::findPending(Addr blk_addr, bool is_secure) const { - MSHR::ConstIterator i = readyList.begin(); - MSHR::ConstIterator end = readyList.end(); - for (; i != end; ++i) { - MSHR *mshr = *i; + for (const auto& mshr : readyList) { if (mshr->blkAddr == blk_addr && mshr->isSecure == is_secure) { return mshr; } @@ -139,15 +127,13 @@ MSHRQueue::addToReadyList(MSHR *mshr) return readyList.insert(readyList.end(), mshr); } - MSHR::Iterator i = readyList.begin(); - MSHR::Iterator end = readyList.end(); - for (; i != end; ++i) { + for (auto i = readyList.begin(); i != readyList.end(); ++i) { if ((*i)->readyTime > mshr->readyTime) { return readyList.insert(i, mshr); } } assert(false); - return end; // keep stupid compilers happy + return readyList.end(); // keep stupid compilers happy } @@ -251,9 +237,7 @@ MSHRQueue::forceDeallocateTarget(MSHR *mshr) void MSHRQueue::squash(int threadNum) { - MSHR::Iterator i = allocatedList.begin(); - MSHR::Iterator end = allocatedList.end(); - for (; i != end;) { + for (auto i = allocatedList.begin(); i != allocatedList.end();) { MSHR *mshr = *i; if (mshr->threadNum == threadNum) { while (mshr->hasTargets()) { |