summaryrefslogtreecommitdiff
path: root/src/base/types.hh
diff options
context:
space:
mode:
authorNilay Vaish <nilay@cs.wisc.edu>2013-02-10 21:26:23 -0600
committerNilay Vaish <nilay@cs.wisc.edu>2013-02-10 21:26:23 -0600
commitaffd77ea77860fa9231aba8e43ad95dea06a114a (patch)
treebe4d99a2f40e29059cd296643192bcade7f86609 /src/base/types.hh
parentbc1daae7fd528ca72ba14d669a0d00243f553be5 (diff)
downloadgem5-affd77ea77860fa9231aba8e43ad95dea06a114a.tar.xz
base: add some mathematical operators to Cycles class
Diffstat (limited to 'src/base/types.hh')
-rw-r--r--src/base/types.hh12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/base/types.hh b/src/base/types.hh
index 7f4375048..b4cb69a0c 100644
--- a/src/base/types.hh
+++ b/src/base/types.hh
@@ -113,6 +113,18 @@ class Cycles
bool operator>(const Cycles& cc) const
{ return c > cc.c; }
+ const Cycles operator +(const Cycles& b) const
+ { return Cycles(c + b.c); }
+
+ const Cycles operator -(const Cycles& b) const
+ { assert(c >= b.c); return Cycles(c - b.c); }
+
+ const Cycles operator <<(const int32_t shift)
+ { return Cycles(c << shift); }
+
+ const Cycles operator >>(const int32_t shift)
+ { return Cycles(c >> shift); }
+
#endif // SWIG not touching operators
};