types.hh (11306:a5340a2a24f9) types.hh (11990:5fad911cc326)
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;

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

68 * Cycles is a wrapper class for representing cycle counts, i.e. a
69 * relative difference between two points in time, expressed in a
70 * number of clock cycles.
71 *
72 * The Cycles wrapper class is a type-safe alternative to a
73 * typedef, aiming to avoid unintentional mixing of cycles and ticks
74 * in the code base.
75 *
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;

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

68 * Cycles is a wrapper class for representing cycle counts, i.e. a
69 * relative difference between two points in time, expressed in a
70 * number of clock cycles.
71 *
72 * The Cycles wrapper class is a type-safe alternative to a
73 * typedef, aiming to avoid unintentional mixing of cycles and ticks
74 * in the code base.
75 *
76 * Operators are defined inside an ifndef block to avoid swig touching
77 * them. Note that there is no overloading of the bool operator as the
76 * Note that there is no overloading of the bool operator as the
78 * compiler is allowed to turn booleans into integers and this causes
79 * a whole range of issues in a handful locations. The solution to
80 * this problem would be to use the safe bool idiom, but for now we
81 * make do without the test and use the more elaborate comparison >
82 * Cycles(0).
83 */
84class Cycles
85{
86
87 private:
88
89 /** Member holding the actual value. */
90 uint64_t c;
91
92 public:
93
77 * compiler is allowed to turn booleans into integers and this causes
78 * a whole range of issues in a handful locations. The solution to
79 * this problem would be to use the safe bool idiom, but for now we
80 * make do without the test and use the more elaborate comparison >
81 * Cycles(0).
82 */
83class Cycles
84{
85
86 private:
87
88 /** Member holding the actual value. */
89 uint64_t c;
90
91 public:
92
94#ifndef SWIG // SWIG gets confused by constexpr
95 /** Explicit constructor assigning a value. */
96 explicit constexpr Cycles(uint64_t _c) : c(_c) { }
93 /** Explicit constructor assigning a value. */
94 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
95
96 /** Default constructor for parameter classes. */
97 Cycles() : c(0) { }
98
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. */

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

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);
99 /** Converting back to the value type. */
100 constexpr operator uint64_t() const { return c; }
101
102 /** Prefix increment operator. */
103 Cycles& operator++()
104 { ++c; return *this; }
105
106 /** Prefix decrement operator. Is only temporarily used in the O3 CPU. */

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

126
127 constexpr Cycles operator <<(const int32_t shift) const
128 { return Cycles(c << shift); }
129
130 constexpr Cycles operator >>(const int32_t shift) const
131 { return Cycles(c >> shift); }
132
133 friend std::ostream& operator<<(std::ostream &out, const Cycles & cycles);
141
142#endif // SWIG not touching operators
143
144};
145
146/**
147 * Address type
148 * This will probably be moved somewhere else in the near future.
149 * This should be at least as big as the biggest address width in use
150 * in the system, which will probably be 64 bits.
151 */

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

189 * Port index/ID type, and a symbolic name for an invalid port id.
190 */
191typedef int16_t PortID;
192const PortID InvalidPortID = (PortID)-1;
193
194class FaultBase;
195typedef std::shared_ptr<FaultBase> Fault;
196
134};
135
136/**
137 * Address type
138 * This will probably be moved somewhere else in the near future.
139 * This should be at least as big as the biggest address width in use
140 * in the system, which will probably be 64 bits.
141 */

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

179 * Port index/ID type, and a symbolic name for an invalid port id.
180 */
181typedef int16_t PortID;
182const PortID InvalidPortID = (PortID)-1;
183
184class FaultBase;
185typedef std::shared_ptr<FaultBase> Fault;
186
197#ifndef SWIG // Swig gets really confused by decltype
198// Rather than creating a shared_ptr instance and assigning it nullptr,
199// we just create an alias.
200constexpr decltype(nullptr) NoFault = nullptr;
187// Rather than creating a shared_ptr instance and assigning it nullptr,
188// we just create an alias.
189constexpr decltype(nullptr) NoFault = nullptr;
201#endif
202
203struct AtomicOpFunctor
204{
205 virtual void operator()(uint8_t *p) = 0;
206 virtual ~AtomicOpFunctor() {}
207};
208
209template <class T>

--- 12 unchanged lines hidden ---
190
191struct AtomicOpFunctor
192{
193 virtual void operator()(uint8_t *p) = 0;
194 virtual ~AtomicOpFunctor() {}
195};
196
197template <class T>

--- 12 unchanged lines hidden ---