summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVilas Sridharan <vilas.sridharan@gmail.com>2007-10-30 22:21:05 -0400
committerVilas Sridharan <vilas.sridharan@gmail.com>2007-10-30 22:21:05 -0400
commit04d1cfe31ce92809830722081f3223a4d61b05df (patch)
treee5ceb6504ff0b5edac486157d846d164783ce720
parent503fb8ebed9d1ad4acc088b9d73a7725f3f0b983 (diff)
downloadgem5-04d1cfe31ce92809830722081f3223a4d61b05df.tar.xz
Add constant stat.
Signed Off: Ali Saidi <saidi@eecs.umich.edu> --HG-- extra : convert_revision : 3da9e507117d0279e212d151d78c312fd9cf0b5c
-rw-r--r--src/base/statistics.hh40
1 files changed, 40 insertions, 0 deletions
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 T>
+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 <class Op>
struct OpString;
@@ -2888,6 +2921,13 @@ constant(T val)
return NodePtr(new ConstNode<T>(val));
}
+template <typename T>
+inline Temp
+constantVector(T val)
+{
+ return NodePtr(new ConstVectorNode<T>(val));
+}
+
inline Temp
sum(Temp val)
{