gem5 v24.0.0.0
Loading...
Searching...
No Matches
bitfield.hh File Reference
#include <bitset>
#include <cassert>
#include <climits>
#include <cstddef>
#include <cstdint>
#include <limits>
#include <type_traits>

Go to the source code of this file.

Namespaces

namespace  gem5
 Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
 

Macros

#define __has_builtin(foo)   0
 

Functions

constexpr uint64_t gem5::mask (unsigned nbits)
 Generate a 64-bit mask of 'nbits' 1s, right justified.
 
template<class T >
constexpr T gem5::bits (T val, unsigned first, unsigned last)
 Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
 
template<class T >
constexpr T gem5::bits (T val, unsigned bit)
 Extract the bit from this position from 'val' and right justify it.
 
template<class T >
constexpr T gem5::mbits (T val, unsigned first, unsigned last)
 Mask off the given bits in place like bits() but without shifting.
 
constexpr uint64_t gem5::mask (unsigned first, unsigned last)
 
template<int N>
constexpr uint64_t gem5::sext (uint64_t val)
 Sign-extend an N-bit value to 64 bits.
 
constexpr uint64_t gem5::sext (uint64_t val, int N)
 Sign-extend an N-bit value to 64 bits.
 
template<int N>
constexpr uint64_t gem5::szext (uint64_t val)
 Sign-extend an N-bit value to 64 bits.
 
template<class T , class B >
constexpr T gem5::insertBits (T val, unsigned first, unsigned last, B bit_val)
 Returns val with bits first to last set to the LSBs of bit_val.
 
template<class T , class B >
constexpr T gem5::insertBits (T val, unsigned bit, B bit_val)
 Overloaded for access to only one bit in value.
 
template<class T , class B >
constexpr void gem5::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.
 
template<class T , class B >
constexpr void gem5::replaceBits (T &val, unsigned bit, B bit_val)
 Overloaded function to allow to access only 1 bit.
 
template<class T >
std::enable_if_t< std::is_integral_v< T >, T > gem5::reverseBits (T val, size_t size=sizeof(T))
 Takes a value and returns the bit reversed version.
 
constexpr int gem5::findMsbSet (uint64_t val)
 Returns the bit position of the MSB that is set in the input.
 
constexpr int gem5::findLsbSet (uint64_t val)
 Returns the bit position of the LSB that is set in the input That function will either use a builtin that exploit a "count trailing zeros" instruction or use fall back method, findLsbSetFallback.
 
template<size_t N>
constexpr int gem5::findLsbSet (std::bitset< N > bs)
 
constexpr int gem5::popCount (uint64_t val)
 Returns the number of set ones in the provided value.
 
constexpr uint64_t gem5::alignToPowerOfTwo (uint64_t val)
 Align to the next highest power of two.
 
constexpr int gem5::ctz32 (uint32_t value)
 Count trailing zeros in a 32-bit value.
 
constexpr int gem5::ctz64 (uint64_t value)
 Count trailing zeros in a 64-bit value.
 
constexpr int gem5::clz32 (uint32_t value)
 Count leading zeros in a 32-bit value.
 
constexpr int gem5::clz64 (uint64_t value)
 Count leading zeros in a 64-bit value.
 

Macro Definition Documentation

◆ __has_builtin

#define __has_builtin ( foo)    0

Generated on Tue Jun 18 2024 16:24:08 for gem5 by doxygen 1.11.0