From: Gabe Black Date: Tue, 8 Oct 2019 22:44:29 +0000 (-0700) Subject: cpu: Clean up some style issues in pc_event.(hh|cc). X-Git-Tag: v19.0.0.0~435 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3c642b1c5c95f9c8bae4994ae44ff2a12662f488;p=gem5.git 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 Maintainer: Gabe Black Tested-by: kokoro --- 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 map_t; + typedef std::vector 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 range_t; typedef std::pair 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);