[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 04/15] qemu/int128: Add int128_shr
From: |
Richard Henderson |
Subject: |
[RFC PATCH 04/15] qemu/int128: Add int128_shr |
Date: |
Tue, 20 Oct 2020 21:51:38 -0700 |
Add unsigned right shift as an operation.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/qemu/int128.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/include/qemu/int128.h b/include/qemu/int128.h
index 167f13ae10..c53002039a 100644
--- a/include/qemu/int128.h
+++ b/include/qemu/int128.h
@@ -68,6 +68,11 @@ static inline Int128 int128_sar(Int128 a, int n)
return a >> n;
}
+static inline Int128 int128_shr(Int128 a, int n)
+{
+ return (__uint128_t)a >> n;
+}
+
static inline Int128 int128_shl(Int128 a, int n)
{
return a << n;
@@ -232,6 +237,17 @@ static inline Int128 int128_sar(Int128 a, int n)
}
}
+static inline Int128 int128_shr(Int128 a, int n)
+{
+ uint64_t h = (uint64_t)a.hi >> (n & 63);
+ if (n >= 64) {
+ return int128_make64(h);
+ } else if (n > 0) {
+ return int128_make128((a.lo >> n) | ((uint64_t)a.hi << (64 - n)), h);
+ }
+ return a;
+}
+
static inline Int128 int128_shl(Int128 a, int n)
{
uint64_t l = a.lo << (n & 63);
--
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, 2020/10/21
- [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 <=
- [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
- [RFC PATCH 09/15] softfloat: Add float_cmask and constants, Richard Henderson, 2020/10/21
- [RFC PATCH 12/15] softfloat: Streamline FloatFmt, Richard Henderson, 2020/10/21
- [RFC PATCH 11/15] Test split to softfloat-parts.c.inc, Richard Henderson, 2020/10/21
- [RFC PATCH 13/15] Test float128_addsub, Richard Henderson, 2020/10/21
- [RFC PATCH 15/15] softfloat: Improve subtraction of equal exponent, Richard Henderson, 2020/10/21