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#include <stdexcept>
46
47#include "base/refcnt.hh"
48
49/** uint64_t constant */
50#define ULL(N) ((uint64_t)N##ULL)
51/** int64_t constant */
52#define LL(N) ((int64_t)N##LL)
53

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

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

--- 59 unchanged lines hidden ---