diff options
author | Andreas Hansson <andreas.hansson@arm.com> | 2015-03-27 04:55:57 -0400 |
---|---|---|
committer | Andreas Hansson <andreas.hansson@arm.com> | 2015-03-27 04:55:57 -0400 |
commit | fe806a0dd7daef6cd42f78d7caaafcb5db9fd6a5 (patch) | |
tree | 12d5ffb834b9284ba00341b4d572120454b00f68 /src/mem/cache/mshr_queue.cc | |
parent | d5e03beac2a63b4363a275a63951ae38e03bdb0c (diff) | |
download | gem5-fe806a0dd7daef6cd42f78d7caaafcb5db9fd6a5.tar.xz |
mem: Modernise MSHR iterators to C++11
This patch updates the iterators in the MSHR and MSHR queues to use
C++11 range-based for loops. It also does a bit of additional house
keeping.
Diffstat (limited to 'src/mem/cache/mshr_queue.cc')
-rw-r--r-- | src/mem/cache/mshr_queue.cc | 30 |
1 files changed, 7 insertions, 23 deletions
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()) { |