Deleted Added
sdiff udiff text old ( 10839:10cac0f0f419 ) new ( 11004:2c347b12cc9c )
full compact
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 28 unchanged lines hidden (view full) ---

37#ifndef __BASE_TYPES_HH__
38#define __BASE_TYPES_HH__
39
40#include <inttypes.h>
41
42#include <cassert>
43#include <memory>
44#include <ostream>
45
46#include "base/refcnt.hh"
47
48/** uint64_t constant */
49#define ULL(N) ((uint64_t)N##ULL)
50/** int64_t constant */
51#define LL(N) ((int64_t)N##LL)
52

--- 32 unchanged lines hidden (view full) ---

85
86 private:
87
88 /** Member holding the actual value. */
89 uint64_t c;
90
91 public:
92
93 /** Explicit constructor assigning a value. */
94 explicit Cycles(uint64_t _c) : c(_c) { }
95
96 /** Default constructor for parameter classes. */
97 Cycles() : c(0) { }
98
99#ifndef SWIG // keep the operators away from SWIG
100
101 /** Converting back to the value type. */
102 operator uint64_t() const { return c; }
103
104 /** Prefix increment operator. */
105 Cycles& operator++()
106 { ++c; return *this; }
107
108 /** Prefix decrement operator. Is only temporarily used in the O3 CPU. */
109 Cycles& operator--()
110 { assert(c != 0); --c; return *this; }
111
112 /** In-place addition of cycles. */
113 const Cycles& operator+=(const Cycles& cc)
114 { c += cc.c; return *this; }
115
116 /** Greater than comparison used for > Cycles(0). */
117 bool operator>(const Cycles& cc) const
118 { return c > cc.c; }
119
120 const Cycles operator +(const Cycles& b) const
121 { return Cycles(c + b.c); }
122
123 const Cycles operator -(const Cycles& b) const
124 { assert(c >= b.c); return Cycles(c - b.c); }
125
126 const Cycles operator <<(const int32_t shift)
127 { return Cycles(c << shift); }
128
129 const Cycles operator >>(const int32_t shift)
130 { return Cycles(c >> shift); }
131
132 friend std::ostream& operator<<(std::ostream &out, const Cycles & cycles);
133
134#endif // SWIG not touching operators
135
136};
137

--- 59 unchanged lines hidden ---