gem5  v21.0.1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Macros | Functions | Variables
bitfield.hh File Reference
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <type_traits>

Go to the source code of this file.

Macros

#define __has_builtin(foo)   0
 

Functions

constexpr uint64_t mask (unsigned nbits)
 Generate a 64-bit mask of 'nbits' 1s, right justified. More...
 
template<class T >
constexpr T bits (T val, unsigned first, unsigned last)
 Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it. More...
 
template<class T >
constexpr T bits (T val, unsigned bit)
 Extract the bit from this position from 'val' and right justify it. More...
 
template<class T >
constexpr T mbits (T val, unsigned first, unsigned last)
 Mask off the given bits in place like bits() but without shifting. More...
 
constexpr uint64_t mask (unsigned first, unsigned last)
 
template<int N>
constexpr uint64_t sext (uint64_t val)
 Sign-extend an N-bit value to 64 bits. More...
 
template<class T , class B >
constexpr T insertBits (T val, unsigned first, unsigned last, B bit_val)
 Returns val with bits first to last set to the LSBs of bit_val. More...
 
template<class T , class B >
constexpr T insertBits (T val, unsigned bit, B bit_val)
 Overloaded for access to only one bit in value. More...
 
template<class T , class B >
constexpr void replaceBits (T &val, unsigned first, unsigned last, B bit_val)
 A convenience function to replace bits first to last of val with bit_val in place. More...
 
template<class T , class B >
constexpr void replaceBits (T &val, unsigned bit, B bit_val)
 Overloaded function to allow to access only 1 bit. More...
 
template<class T >
std::enable_if_t< std::is_integral< T >::value &&sizeof(T) !=1, T > reverseBits (T val, size_t size=sizeof(T))
 Takes a value and returns the bit reversed version. More...
 
template<class T >
std::enable_if_t< std::is_integral< T >::value &&sizeof(T)==1, T > reverseBits (T val, size_t size=sizeof(T))
 
constexpr int findMsbSet (uint64_t val)
 Returns the bit position of the MSB that is set in the input. More...
 
constexpr int findLsbSet (uint64_t val)
 Returns the bit position of the LSB that is set in the input. More...
 
constexpr int popCount (uint64_t val)
 Returns the number of set ones in the provided value. More...
 
constexpr uint64_t alignToPowerOfTwo (uint64_t val)
 Align to the next highest power of two. More...
 
constexpr int ctz32 (uint32_t value)
 Count trailing zeros in a 32-bit value. More...
 
constexpr int ctz64 (uint64_t value)
 Count trailing zeros in a 64-bit value. More...
 

Variables

const uint8_t reverseBitsLookUpTable []
 Lookup table used for High Speed bit reversing. More...
 

Macro Definition Documentation

◆ __has_builtin

#define __has_builtin (   foo)    0

Function Documentation

◆ reverseBits()

template<class T >
std::enable_if_t<std::is_integral<T>::value && sizeof(T) == 1, T> reverseBits ( val,
size_t  size = sizeof(T) 
)

Definition at line 228 of file bitfield.hh.

References reverseBitsLookUpTable, and X86ISA::val.

Variable Documentation

◆ reverseBitsLookUpTable

const uint8_t reverseBitsLookUpTable[]

Lookup table used for High Speed bit reversing.

Definition at line 41 of file bitfield.cc.

Referenced by reverseBits().


Generated on Tue Jun 22 2021 15:28:33 for gem5 by doxygen 1.8.17