[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 02/15] qemu/int128: Add int128_clz, int128_ctz
From: |
Richard Henderson |
Subject: |
[RFC PATCH 02/15] qemu/int128: Add int128_clz, int128_ctz |
Date: |
Tue, 20 Oct 2020 21:51:36 -0700 |
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/qemu/int128.h | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/include/qemu/int128.h b/include/qemu/int128.h
index 52fc238421..055f202d08 100644
--- a/include/qemu/int128.h
+++ b/include/qemu/int128.h
@@ -1,9 +1,9 @@
#ifndef INT128_H
#define INT128_H
-#ifdef CONFIG_INT128
-#include "qemu/bswap.h"
+#include "qemu/host-utils.h"
+#ifdef CONFIG_INT128
typedef __int128_t Int128;
static inline Int128 int128_make64(uint64_t a)
@@ -328,4 +328,17 @@ static inline void int128_subfrom(Int128 *a, Int128 b)
}
#endif /* CONFIG_INT128 */
+
+static inline int int128_clz(Int128 a)
+{
+ uint64_t h = int128_gethi(a);
+ return h ? clz64(h) : 64 + clz64(int128_getlo(a));
+}
+
+static inline int int128_ctz(Int128 a)
+{
+ uint64_t l = int128_getlo(a);
+ return l ? ctz64(l) : 64 + ctz64(int128_gethi(a));
+}
+
#endif /* INT128_H */
--
2.25.1
- [RFC PATCH 00/15] softfloat: alternate conversion of float128_addsub, Richard Henderson, 2020/10/21
- [RFC PATCH 01/15] qemu/int128: Add int128_or, Richard Henderson, 2020/10/21
- [RFC PATCH 02/15] qemu/int128: Add int128_clz, int128_ctz,
Richard Henderson <=
- [RFC PATCH 03/15] qemu/int128: Rename int128_rshift, int128_lshift, Richard Henderson, 2020/10/21
- [RFC PATCH 05/15] qemu/int128: Add int128_geu, Richard Henderson, 2020/10/21
- [RFC PATCH 04/15] qemu/int128: Add int128_shr, Richard Henderson, 2020/10/21
- [RFC PATCH 06/15] softfloat: Use mulu64 for mul64To128, Richard Henderson, 2020/10/21
- [RFC PATCH 07/15] softfloat: Use int128.h for some operations, Richard Henderson, 2020/10/21
- [RFC PATCH 08/15] softfloat: Tidy a * b + inf return, Richard Henderson, 2020/10/21
- [RFC PATCH 10/15] softfloat: Inline float_raise, Richard Henderson, 2020/10/21