base: Tag API methods and variables in bitfield.hh

Change-Id: Ifd7d1b6ba243fd70af6974fde8228fce8aeecb40
Signed-off-by: Hoa Nguyen <hoanguyen@ucdavis.edu>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/32957
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Reviewed-by: Gabe Black <gabeblack@google.com>
This commit is contained in:
Hoa Nguyen
2020-08-19 23:14:43 -07:00
parent f470f0869a
commit 195a62b1ad

View File

@@ -54,6 +54,8 @@ extern const uint8_t reverseLookUpTable[];
* greater than 64 is given, it is truncated to 64.
*
* @param nbits The number of bits set in the mask.
*
* @ingroup api_bitfield
*/
inline uint64_t
mask(int nbits)
@@ -64,6 +66,8 @@ mask(int nbits)
/**
* Extract the bitfield from position 'first' to 'last' (inclusive)
* from 'val' and right justify it. MSB is numbered 63, LSB is 0.
*
* @ingroup api_bitfield
*/
template <class T>
inline
@@ -77,6 +81,8 @@ bits(T val, int first, int last)
/**
* Extract the bit from this position from 'val' and right justify it.
*
* @ingroup api_bitfield
*/
template <class T>
inline
@@ -89,6 +95,8 @@ bits(T val, int bit)
/**
* Mask off the given bits in place like bits() but without shifting.
* msb = 63, lsb = 0
*
* @ingroup api_bitfield
*/
template <class T>
inline
@@ -98,6 +106,9 @@ mbits(T val, int first, int last)
return val & (mask(first+1) & ~mask(last));
}
/**
* @ingroup api_bitfield
*/
inline uint64_t
mask(int first, int last)
{
@@ -106,6 +117,8 @@ mask(int first, int last)
/**
* Sign-extend an N-bit value to 64 bits.
*
* @ingroup api_bitfield
*/
template <int N>
inline
@@ -125,6 +138,8 @@ sext(uint64_t val)
* val: 0xFFFF
* bit_val: 0x0000
* returned: 0xFF0F
*
* @ingroup api_bitfield
*/
template <class T, class B>
inline
@@ -139,6 +154,8 @@ insertBits(T val, int first, int last, B bit_val)
/**
* Overloaded for access to only one bit in value
*
* @ingroup api_bitfield
*/
template <class T, class B>
inline
@@ -153,6 +170,8 @@ insertBits(T val, int bit, B bit_val)
* in place. It is functionally equivalent to insertBits.
*
* \note "first" is the MSB and "last" is the LSB. "first" >= "last"
*
* @ingroup api_bitfield
*/
template <class T, class B>
inline
@@ -162,7 +181,11 @@ replaceBits(T& val, int first, int last, B bit_val)
val = insertBits(val, first, last, bit_val);
}
/** Overloaded function to allow to access only 1 bit*/
/**
* Overloaded function to allow to access only 1 bit
*
* @ingroup api_bitfield
*/
template <class T, class B>
inline
void
@@ -182,6 +205,8 @@ replaceBits(T& val, int bit, B bit_val)
* @param val: variable lenght word
* @param size: number of bytes to mirror
* @return mirrored word
*
* @ingroup api_bitfield
*/
template <class T>
T
@@ -201,6 +226,8 @@ reverseBits(T val, std::size_t size = sizeof(T))
/**
* Returns the bit position of the MSB that is set in the input
*
* @ingroup api_bitfield
*/
inline
int
@@ -219,6 +246,8 @@ findMsbSet(uint64_t val) {
/**
* Returns the bit position of the LSB that is set in the input
*
* @ingroup api_bitfield
*/
inline int
findLsbSet(uint64_t val) {
@@ -236,6 +265,8 @@ findLsbSet(uint64_t val) {
/**
* Checks if a number is a power of two, or zero.
*
* @ingroup api_bitfield
*/
template <class T>
inline bool
@@ -247,6 +278,8 @@ isPow2(T v) {
* Returns the number of set ones in the provided value.
* PD algorithm from
* http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
*
* @ingroup api_bitfield
*/
inline int
popCount(uint64_t val) {
@@ -277,6 +310,8 @@ popCount(uint64_t val) {
*
* This code has been modified from the following:
* http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
*
* @ingroup api_bitfield
*/
inline uint64_t alignToPowerOfTwo(uint64_t val)
{
@@ -297,6 +332,8 @@ inline uint64_t alignToPowerOfTwo(uint64_t val)
*
* @param An input value
* @return The number of trailing zeros or 32 if the value is zero.
*
* @ingroup api_bitfield
*/
inline int ctz32(uint32_t value)
{
@@ -308,6 +345,8 @@ inline int ctz32(uint32_t value)
*
* @param An input value
* @return The number of trailing zeros or 64 if the value is zero.
*
* @ingroup api_bitfield
*/
inline int ctz64(uint64_t value)
{