From 04d1cfe31ce92809830722081f3223a4d61b05df Mon Sep 17 00:00:00 2001 From: Vilas Sridharan Date: Tue, 30 Oct 2007 22:21:05 -0400 Subject: [PATCH] Add constant stat. Signed Off: Ali Saidi --HG-- extra : convert_revision : 3da9e507117d0279e212d151d78c312fd9cf0b5c --- src/base/statistics.hh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) 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) { -- 2.30.2