gem5  v22.1.0.0
Public Member Functions | Private Attributes | Friends | List of all members
gem5::Cycles Class Reference

Cycles is a wrapper class for representing cycle counts, i.e. More...

#include <types.hh>

Public Member Functions

constexpr Cycles (uint64_t _c)
 Explicit constructor assigning a value. More...
 
 Cycles ()
 Default constructor for parameter classes. More...
 
constexpr operator uint64_t () const
 Converting back to the value type. More...
 
Cyclesoperator++ ()
 Prefix increment operator. More...
 
Cyclesoperator-- ()
 Prefix decrement operator. More...
 
Cyclesoperator+= (const Cycles &cc)
 In-place addition of cycles. More...
 
constexpr bool operator> (const Cycles &cc) const
 Greater than comparison used for > Cycles(0). More...
 
constexpr Cycles operator+ (const Cycles &b) const
 
constexpr Cycles operator- (const Cycles &b) const
 
constexpr Cycles operator<< (const int32_t shift) const
 
constexpr Cycles operator>> (const int32_t shift) const
 

Private Attributes

uint64_t c
 Member holding the actual value. More...
 

Friends

std::ostream & operator<< (std::ostream &out, const Cycles &cycles)
 

Detailed Description

Cycles is a wrapper class for representing cycle counts, i.e.

a relative difference between two points in time, expressed in a number of clock cycles.

The Cycles wrapper class is a type-safe alternative to a typedef, aiming to avoid unintentional mixing of cycles and ticks in the code base.

Note that there is no overloading of the bool operator as the compiler is allowed to turn booleans into integers and this causes a whole range of issues in a handful locations. The solution to this problem would be to use the safe bool idiom, but for now we make do without the test and use the more elaborate comparison > Cycles(0).

Definition at line 78 of file types.hh.

Constructor & Destructor Documentation

◆ Cycles() [1/2]

constexpr gem5::Cycles::Cycles ( uint64_t  _c)
inlineexplicitconstexpr

Explicit constructor assigning a value.

Definition at line 89 of file types.hh.

◆ Cycles() [2/2]

gem5::Cycles::Cycles ( )
inline

Default constructor for parameter classes.

Definition at line 92 of file types.hh.

Referenced by operator+(), operator-(), operator<<(), and operator>>().

Member Function Documentation

◆ operator uint64_t()

constexpr gem5::Cycles::operator uint64_t ( ) const
inlineconstexpr

Converting back to the value type.

Definition at line 95 of file types.hh.

References c.

◆ operator+()

constexpr Cycles gem5::Cycles::operator+ ( const Cycles b) const
inlineconstexpr

Definition at line 114 of file types.hh.

References gem5::ArmISA::b, c, and Cycles().

◆ operator++()

Cycles& gem5::Cycles::operator++ ( )
inline

Prefix increment operator.

Definition at line 98 of file types.hh.

References c.

◆ operator+=()

Cycles& gem5::Cycles::operator+= ( const Cycles cc)
inline

In-place addition of cycles.

Definition at line 104 of file types.hh.

References c.

◆ operator-()

constexpr Cycles gem5::Cycles::operator- ( const Cycles b) const
inlineconstexpr

Definition at line 120 of file types.hh.

References gem5::ArmISA::b, c, and Cycles().

◆ operator--()

Cycles& gem5::Cycles::operator-- ( )
inline

Prefix decrement operator.

Is only temporarily used in the O3 CPU.

Definition at line 101 of file types.hh.

References c.

◆ operator<<()

constexpr Cycles gem5::Cycles::operator<< ( const int32_t  shift) const
inlineconstexpr

Definition at line 126 of file types.hh.

References c, Cycles(), and gem5::ArmISA::shift.

◆ operator>()

constexpr bool gem5::Cycles::operator> ( const Cycles cc) const
inlineconstexpr

Greater than comparison used for > Cycles(0).

Definition at line 108 of file types.hh.

References c.

◆ operator>>()

constexpr Cycles gem5::Cycles::operator>> ( const int32_t  shift) const
inlineconstexpr

Definition at line 133 of file types.hh.

References c, Cycles(), and gem5::ArmISA::shift.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const Cycles cycles 
)
friend

Definition at line 34 of file types.cc.

Member Data Documentation

◆ c

uint64_t gem5::Cycles::c
private

Member holding the actual value.

Definition at line 84 of file types.hh.

Referenced by operator uint64_t(), operator+(), operator++(), operator+=(), operator-(), operator--(), operator<<(), operator>(), and operator>>().


The documentation for this class was generated from the following file:

Generated on Wed Dec 21 2022 10:23:12 for gem5 by doxygen 1.9.1