summaryrefslogtreecommitdiff
path: root/src/mem/cache/mshr.cc
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2015-03-27 04:55:57 -0400
committerAndreas Hansson <andreas.hansson@arm.com>2015-03-27 04:55:57 -0400
commitfe806a0dd7daef6cd42f78d7caaafcb5db9fd6a5 (patch)
tree12d5ffb834b9284ba00341b4d572120454b00f68 /src/mem/cache/mshr.cc
parentd5e03beac2a63b4363a275a63951ae38e03bdb0c (diff)
downloadgem5-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.cc')
-rw-r--r--src/mem/cache/mshr.cc32
1 files changed, 14 insertions, 18 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())