[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 01/46] qemu/host-utils: Use __builtin_bitreverseN
From: |
Richard Henderson |
Subject: |
[PULL 01/46] qemu/host-utils: Use __builtin_bitreverseN |
Date: |
Sun, 16 May 2021 07:33:46 -0500 |
Clang has added some builtins for these operations;
use them if available.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/qemu/host-utils.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/include/qemu/host-utils.h b/include/qemu/host-utils.h
index cdca2991d8..f1e52851e0 100644
--- a/include/qemu/host-utils.h
+++ b/include/qemu/host-utils.h
@@ -272,6 +272,9 @@ static inline int ctpop64(uint64_t val)
*/
static inline uint8_t revbit8(uint8_t x)
{
+#if __has_builtin(__builtin_bitreverse8)
+ return __builtin_bitreverse8(x);
+#else
/* Assign the correct nibble position. */
x = ((x & 0xf0) >> 4)
| ((x & 0x0f) << 4);
@@ -281,6 +284,7 @@ static inline uint8_t revbit8(uint8_t x)
| ((x & 0x22) << 1)
| ((x & 0x11) << 3);
return x;
+#endif
}
/**
@@ -289,6 +293,9 @@ static inline uint8_t revbit8(uint8_t x)
*/
static inline uint16_t revbit16(uint16_t x)
{
+#if __has_builtin(__builtin_bitreverse16)
+ return __builtin_bitreverse16(x);
+#else
/* Assign the correct byte position. */
x = bswap16(x);
/* Assign the correct nibble position. */
@@ -300,6 +307,7 @@ static inline uint16_t revbit16(uint16_t x)
| ((x & 0x2222) << 1)
| ((x & 0x1111) << 3);
return x;
+#endif
}
/**
@@ -308,6 +316,9 @@ static inline uint16_t revbit16(uint16_t x)
*/
static inline uint32_t revbit32(uint32_t x)
{
+#if __has_builtin(__builtin_bitreverse32)
+ return __builtin_bitreverse32(x);
+#else
/* Assign the correct byte position. */
x = bswap32(x);
/* Assign the correct nibble position. */
@@ -319,6 +330,7 @@ static inline uint32_t revbit32(uint32_t x)
| ((x & 0x22222222u) << 1)
| ((x & 0x11111111u) << 3);
return x;
+#endif
}
/**
@@ -327,6 +339,9 @@ static inline uint32_t revbit32(uint32_t x)
*/
static inline uint64_t revbit64(uint64_t x)
{
+#if __has_builtin(__builtin_bitreverse64)
+ return __builtin_bitreverse64(x);
+#else
/* Assign the correct byte position. */
x = bswap64(x);
/* Assign the correct nibble position. */
@@ -338,6 +353,7 @@ static inline uint64_t revbit64(uint64_t x)
| ((x & 0x2222222222222222ull) << 1)
| ((x & 0x1111111111111111ull) << 3);
return x;
+#endif
}
/* Host type specific sizes of these routines. */
--
2.25.1
- [PULL 00/46] softfloat: Convert float128 to FloatParts (part 1), Richard Henderson, 2021/05/16
- [PULL 01/46] qemu/host-utils: Use __builtin_bitreverseN,
Richard Henderson <=
- [PULL 03/46] qemu/host-utils: Add wrappers for carry builtins, Richard Henderson, 2021/05/16
- [PULL 05/46] tests/fp: add quad support to the benchmark utility, Richard Henderson, 2021/05/16
- [PULL 02/46] qemu/host-utils: Add wrappers for overflow builtins, Richard Henderson, 2021/05/16
- [PULL 04/46] accel/tcg: Use add/sub overflow routines in tcg-runtime-gvec.c, Richard Henderson, 2021/05/16
- [PULL 06/46] softfloat: Move the binary point to the msb, Richard Henderson, 2021/05/16
- [PULL 09/46] softfloat: Tidy a * b + inf return, Richard Henderson, 2021/05/16
- [PULL 08/46] softfloat: Use float_raise in more places, Richard Henderson, 2021/05/16
- [PULL 10/46] softfloat: Add float_cmask and constants, Richard Henderson, 2021/05/16
- [PULL 11/46] softfloat: Use return_nan in float_to_float, Richard Henderson, 2021/05/16
- [PULL 13/46] target/mips: Set set_default_nan_mode with set_snan_bit_is_one, Richard Henderson, 2021/05/16