base: Introduce a version of reverseBits for 8 bit types.
These types shouldn't be shifted by 8, since shifting a type by its width is technically undefined behavior. We never actually use the result from this shift, but it still upsets certain versions of clang. Change-Id: I425431473fa44a6e0de2edf780c265ff4e3f440e Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/41593 Reviewed-by: Gabe Black <gabe.black@gmail.com> Reviewed-by: Jason Lowe-Power <power.jg@gmail.com> Maintainer: Gabe Black <gabe.black@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -209,7 +209,7 @@ replaceBits(T& val, unsigned bit, B bit_val)
|
||||
* @ingroup api_bitfield
|
||||
*/
|
||||
template <class T>
|
||||
std::enable_if_t<std::is_integral<T>::value, T>
|
||||
std::enable_if_t<std::is_integral<T>::value && sizeof(T) != 1, T>
|
||||
reverseBits(T val, size_t size=sizeof(T))
|
||||
{
|
||||
assert(size <= sizeof(T));
|
||||
@@ -223,6 +223,14 @@ reverseBits(T val, size_t size=sizeof(T))
|
||||
return output;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
std::enable_if_t<std::is_integral<T>::value && sizeof(T) == 1, T>
|
||||
reverseBits(T val, size_t size=sizeof(T))
|
||||
{
|
||||
assert(size == 1);
|
||||
return reverseBitsLookUpTable[val];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bit position of the MSB that is set in the input
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user