summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2019-10-08 15:44:29 -0700
committerGabe Black <gabeblack@google.com>2019-10-17 22:00:28 +0000
commit3c642b1c5c95f9c8bae4994ae44ff2a12662f488 (patch)
treec66e031cbf8988ba4a479132ecc8f59afd8be856 /src
parente86ad367b7cd7ef863542f3848d9233133fbddd9 (diff)
downloadgem5-3c642b1c5c95f9c8bae4994ae44ff2a12662f488.tar.xz
cpu: Clean up some style issues in pc_event.(hh|cc).
The record_t typedef isn't all that helpful, and is also not consistent with gem5 style. The map_t style is more useful but is also not compliant. This change eliminates the first typedef and replaces the second with a type called Map. There are some other small style fixups added in as well, like making the member variable pc_map pcMap. Change-Id: I8ffea529004fd6d5b42fdc60250804e2e4987e88 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21781 Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu> Maintainer: Gabe Black <gabeblack@google.com> Tested-by: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/cpu/pc_event.cc16
-rw-r--r--src/cpu/pc_event.hh23
2 files changed, 21 insertions, 18 deletions
diff --git a/src/cpu/pc_event.cc b/src/cpu/pc_event.cc
index 2dbe53789..60e781ba8 100644
--- a/src/cpu/pc_event.cc
+++ b/src/cpu/pc_event.cc
@@ -57,17 +57,15 @@ PCEventQueue::remove(PCEvent *event)
int removed = 0;
range_t range = equal_range(event);
iterator i = range.first;
- while (i != range.second &&
- i != pc_map.end()) {
+ while (i != range.second && i != pcMap.end()) {
if (*i == event) {
DPRINTF(PCEvent, "PC based event removed at %#x: %s\n",
event->pc(), event->descr());
- i = pc_map.erase(i);
+ i = pcMap.erase(i);
++removed;
} else {
i++;
}
-
}
return removed > 0;
@@ -76,8 +74,8 @@ PCEventQueue::remove(PCEvent *event)
bool
PCEventQueue::schedule(PCEvent *event)
{
- pc_map.push_back(event);
- sort(pc_map.begin(), pc_map.end(), MapCompare());
+ pcMap.push_back(event);
+ sort(pcMap.begin(), pcMap.end(), MapCompare());
DPRINTF(PCEvent, "PC based event scheduled for %#x: %s\n",
event->pc(), event->descr());
@@ -114,8 +112,8 @@ PCEventQueue::doService(ThreadContext *tc)
void
PCEventQueue::dump() const
{
- const_iterator i = pc_map.begin();
- const_iterator e = pc_map.end();
+ const_iterator i = pcMap.begin();
+ const_iterator e = pcMap.end();
for (; i != e; ++i)
cprintf("%d: event at %#x: %s\n", curTick(), (*i)->pc(),
@@ -125,7 +123,7 @@ PCEventQueue::dump() const
PCEventQueue::range_t
PCEventQueue::equal_range(Addr pc)
{
- return std::equal_range(pc_map.begin(), pc_map.end(), pc, MapCompare());
+ return std::equal_range(pcMap.begin(), pcMap.end(), pc, MapCompare());
}
BreakPCEvent::BreakPCEvent(PCEventQueue *q, const std::string &desc, Addr addr,
diff --git a/src/cpu/pc_event.hh b/src/cpu/pc_event.hh
index 0822c528a..2289c876c 100644
--- a/src/cpu/pc_event.hh
+++ b/src/cpu/pc_event.hh
@@ -66,31 +66,36 @@ class PCEvent
class PCEventQueue
{
protected:
- typedef PCEvent * record_t;
class MapCompare {
public:
- bool operator()(const record_t &l, const record_t &r) const {
+ bool
+ operator()(PCEvent * const &l, PCEvent * const &r) const
+ {
return l->pc() < r->pc();
}
- bool operator()(const record_t &l, Addr pc) const {
+ bool
+ operator()(PCEvent * const &l, Addr pc) const
+ {
return l->pc() < pc;
}
- bool operator()(Addr pc, const record_t &r) const {
+ bool
+ operator()(Addr pc, PCEvent * const &r) const
+ {
return pc < r->pc();
}
};
- typedef std::vector<record_t> map_t;
+ typedef std::vector<PCEvent *> Map;
public:
- typedef map_t::iterator iterator;
- typedef map_t::const_iterator const_iterator;
+ typedef Map::iterator iterator;
+ typedef Map::const_iterator const_iterator;
protected:
typedef std::pair<iterator, iterator> range_t;
typedef std::pair<const_iterator, const_iterator> const_range_t;
protected:
- map_t pc_map;
+ Map pcMap;
bool doService(ThreadContext *tc);
@@ -102,7 +107,7 @@ class PCEventQueue
bool schedule(PCEvent *event);
bool service(ThreadContext *tc)
{
- if (pc_map.empty())
+ if (pcMap.empty())
return false;
return doService(tc);