From 71653e20fbcd82c4940c69fb17190541038616a5 Mon Sep 17 00:00:00 2001 From: "Daniel R. Carvalho" Date: Sun, 21 Mar 2021 11:28:13 -0300 Subject: [PATCH] base-stats: Remove Stats::Group dependency from Stats::Info The parent group was not being used. The only thing required was the information of whether the info concerns a new or an old-style stats. Removing this dependency simplifies code and removes a possible cyclic dependency. Change-Id: I4d734cd83e9c7975a3ef45229edea4eebf1e430e Signed-off-by: Daniel R. Carvalho Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/43589 Tested-by: kokoro Reviewed-by: Giacomo Travaglini Maintainer: Giacomo Travaglini --- src/base/statistics.hh | 2 +- src/base/stats/info.cc | 14 +++----------- src/base/stats/info.hh | 14 +++++++++----- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/base/statistics.hh b/src/base/statistics.hh index e0d268000d..6a7e23e21a 100644 --- a/src/base/statistics.hh +++ b/src/base/statistics.hh @@ -255,7 +255,7 @@ class DataWrap : public InfoAccess parent->addStat(info); if (name) { - info->setName(parent, name); + info->setName(name, parent == nullptr); info->flags.set(display); } diff --git a/src/base/stats/info.cc b/src/base/stats/info.cc index 85bf698bc6..c6024e7d84 100644 --- a/src/base/stats/info.cc +++ b/src/base/stats/info.cc @@ -111,13 +111,7 @@ validateStatName(const std::string &name) } void -Info::setName(const std::string &name) -{ - setName(nullptr, name); -} - -void -Info::setName(const Group *parent, const std::string &name) +Info::setName(const std::string &name, bool old_style) { if (!validateStatName(name)) panic("invalid stat name '%s'", name); @@ -126,12 +120,10 @@ Info::setName(const Group *parent, const std::string &name) // old-style stats without a parent group. New-style stats should // be unique since their names should correspond to a member // variable. - if (!parent) { + if (old_style) { auto p = nameMap().insert(make_pair(name, this)); - if (!p.second) - panic("same statistic name used twice! name=%s\n", - name); + panic_if(!p.second, "same statistic name used twice! name=%s\n", name); } this->name = name; diff --git a/src/base/stats/info.hh b/src/base/stats/info.hh index 6665102d5b..0e7e39883c 100644 --- a/src/base/stats/info.hh +++ b/src/base/stats/info.hh @@ -38,8 +38,6 @@ GEM5_DEPRECATED_NAMESPACE(Stats, statistics); namespace statistics { -class Group; - typedef uint16_t FlagsType; typedef ::Flags Flags; @@ -101,9 +99,15 @@ class Info Info(); virtual ~Info(); - /** Set the name of this statistic */ - void setName(const std::string &name); - void setName(const Group *parent, const std::string &name); + /** + * Set the name of this statistic. Special handling must be done when + * creating an old-style statistic (i.e., stats without a parent group). + * + * @param name The new name. + * @param old_style Whether we are using the old style. + */ + void setName(const std::string &name, bool old_style=true); + void setSeparator(std::string _sep) { separatorString = _sep;} /**