diff options
Diffstat (limited to 'src/base/statistics.cc')
-rw-r--r-- | src/base/statistics.cc | 70 |
1 files changed, 54 insertions, 16 deletions
diff --git a/src/base/statistics.cc b/src/base/statistics.cc index 123351b80..a186f9763 100644 --- a/src/base/statistics.cc +++ b/src/base/statistics.cc @@ -1,4 +1,16 @@ /* + * Copyright (c) 2019 Arm Limited + * All rights reserved. + * + * The license below extends only to copyright in the software and shall + * not be construed as granting a license to any other intellectual + * property including but not limited to intellectual property relating + * to a hardware implementation of the functionality of the software + * licensed hereunder. You may use the software subject to the license + * terms below provided that you ensure that this notice is replicated + * unmodified and in its entirety in all distributions of the software, + * modified or unmodified, in source code or in binary form. + * * Copyright (c) 2003-2005 The Regents of The University of Michigan * All rights reserved. * @@ -67,10 +79,18 @@ statsMap() } void -InfoAccess::setInfo(Info *info) +InfoAccess::setInfo(Group *parent, Info *info) { - if (statsMap().find(this) != statsMap().end()) - panic("shouldn't register stat twice!"); + panic_if(statsMap().find(this) != statsMap().end() || + _info != nullptr, + "shouldn't register stat twice!"); + + // New-style stats are reachable through the hierarchy and + // shouldn't be added to the global lists. + if (parent) { + _info = info; + return; + } statsList().push_back(info); @@ -97,17 +117,29 @@ InfoAccess::setInit() Info * InfoAccess::info() { - MapType::const_iterator i = statsMap().find(this); - assert(i != statsMap().end()); - return (*i).second; + if (_info) { + // New-style stats + return _info; + } else { + // Legacy stats + MapType::const_iterator i = statsMap().find(this); + assert(i != statsMap().end()); + return (*i).second; + } } const Info * InfoAccess::info() const { - MapType::const_iterator i = statsMap().find(this); - assert(i != statsMap().end()); - return (*i).second; + if (_info) { + // New-style stats + return _info; + } else { + // Legacy stats + MapType::const_iterator i = statsMap().find(this); + assert(i != statsMap().end()); + return (*i).second; + } } StorageParams::~StorageParams() @@ -224,7 +256,8 @@ Info::baseCheck() const #endif panic("Not all stats have been initialized.\n" "You may need to add <ParentClass>::regStats() to a" - " new SimObject's regStats() function."); + " new SimObject's regStats() function. Name: %s", + name); return false; } @@ -376,19 +409,23 @@ HistStor::add(HistStor *hs) cvec[i] += hs->cvec[i]; } -Formula::Formula() +Formula::Formula(Group *parent, const char *name, const char *desc) + : DataWrapVec<Formula, FormulaInfoProxy>(parent, name, desc) + { } -Formula::Formula(Temp r) + + +Formula::Formula(Group *parent, const char *name, const char *desc, + const Temp &r) + : DataWrapVec<Formula, FormulaInfoProxy>(parent, name, desc) { - root = r.getNodePtr(); - setInit(); - assert(size()); + *this = r; } const Formula & -Formula::operator=(Temp r) +Formula::operator=(const Temp &r) { assert(!root && "Can't change formulas"); root = r.getNodePtr(); @@ -421,6 +458,7 @@ Formula::operator/=(Temp r) return *this; } + void Formula::result(VResult &vec) const { |