From: Vilas Sridharan Date: Wed, 31 Oct 2007 02:21:05 +0000 (-0400) Subject: Add constant stat. X-Git-Tag: m5_2.0_beta4~21 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=04d1cfe31ce92809830722081f3223a4d61b05df;p=gem5.git Add constant stat. Signed Off: Ali Saidi --HG-- extra : convert_revision : 3da9e507117d0279e212d151d78c312fd9cf0b5c --- diff --git a/src/base/statistics.hh b/src/base/statistics.hh index 8d3f53d4c..3a859d364 100644 --- a/src/base/statistics.hh +++ b/src/base/statistics.hh @@ -2030,6 +2030,39 @@ class ConstNode : public Node virtual std::string str() const { return to_string(vresult[0]); } }; +template +class ConstVectorNode : public Node +{ + private: + VResult vresult; + + public: + ConstVectorNode(const T &s) : vresult(s.begin(), s.end()) {} + const VResult &result() const { return vresult; } + virtual Result total() const + { + int size = this->size(); + Result tmp = 0; + for (int i = 0; i < size; i++) + { + tmp += vresult[i]; + } + return tmp; + } + virtual size_t size() const { return vresult.size(); } + virtual std::string str() const + { + int size = this->size(); + std::string tmp = "("; + for (int i = 0; i < size; i++) + { + tmp += csprintf("%s ",to_string(vresult[i])); + } + tmp += ")"; + return tmp; + } +}; + template struct OpString; @@ -2888,6 +2921,13 @@ constant(T val) return NodePtr(new ConstNode(val)); } +template +inline Temp +constantVector(T val) +{ + return NodePtr(new ConstVectorNode(val)); +} + inline Temp sum(Temp val) {