diff mbox series

[RFC,03/15] qemu/int128: Rename int128_rshift, int128_lshift

Message ID 20201021045149.1582203-4-richard.henderson@linaro.org (mailing list archive)
State New, archived
Headers show
Series softfloat: alternate conversion of float128_addsub | expand

Commit Message

Richard Henderson Oct. 21, 2020, 4:51 a.m. UTC
Change these to sar/shl to emphasize the signed shift.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/qemu/int128.h   |  8 ++++----
 softmmu/physmem.c       |  4 ++--
 target/ppc/int_helper.c |  4 ++--
 tests/test-int128.c     | 44 ++++++++++++++++++++---------------------
 4 files changed, 30 insertions(+), 30 deletions(-)

Comments

Alex Bennée Oct. 21, 2020, 5:14 p.m. UTC | #1
Richard Henderson <richard.henderson@linaro.org> writes:

> Change these to sar/shl to emphasize the signed shift.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Philippe Mathieu-Daudé Feb. 14, 2021, 6:18 p.m. UTC | #2
On 10/21/20 6:51 AM, Richard Henderson wrote:
> Change these to sar/shl to emphasize the signed shift.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  include/qemu/int128.h   |  8 ++++----
>  softmmu/physmem.c       |  4 ++--
>  target/ppc/int_helper.c |  4 ++--
>  tests/test-int128.c     | 44 ++++++++++++++++++++---------------------
>  4 files changed, 30 insertions(+), 30 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
diff mbox series

Patch

diff --git a/include/qemu/int128.h b/include/qemu/int128.h
index 055f202d08..167f13ae10 100644
--- a/include/qemu/int128.h
+++ b/include/qemu/int128.h
@@ -63,12 +63,12 @@  static inline Int128 int128_or(Int128 a, Int128 b)
     return a | b;
 }
 
-static inline Int128 int128_rshift(Int128 a, int n)
+static inline Int128 int128_sar(Int128 a, int n)
 {
     return a >> n;
 }
 
-static inline Int128 int128_lshift(Int128 a, int n)
+static inline Int128 int128_shl(Int128 a, int n)
 {
     return a << n;
 }
@@ -218,7 +218,7 @@  static inline Int128 int128_or(Int128 a, Int128 b)
     return (Int128) { a.lo | b.lo, a.hi | b.hi };
 }
 
-static inline Int128 int128_rshift(Int128 a, int n)
+static inline Int128 int128_sar(Int128 a, int n)
 {
     int64_t h;
     if (!n) {
@@ -232,7 +232,7 @@  static inline Int128 int128_rshift(Int128 a, int n)
     }
 }
 
-static inline Int128 int128_lshift(Int128 a, int n)
+static inline Int128 int128_shl(Int128 a, int n)
 {
     uint64_t l = a.lo << (n & 63);
     if (n >= 64) {
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index e319fb2a1e..7f6e98e7b0 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -1156,8 +1156,8 @@  static void register_multipage(FlatView *fv,
     AddressSpaceDispatch *d = flatview_to_dispatch(fv);
     hwaddr start_addr = section->offset_within_address_space;
     uint16_t section_index = phys_section_add(&d->map, section);
-    uint64_t num_pages = int128_get64(int128_rshift(section->size,
-                                                    TARGET_PAGE_BITS));
+    uint64_t num_pages = int128_get64(int128_sar(section->size,
+                                                 TARGET_PAGE_BITS));
 
     assert(num_pages);
     phys_page_set(d, start_addr >> TARGET_PAGE_BITS, num_pages, section_index);
diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c
index b45626f44c..fe569590b4 100644
--- a/target/ppc/int_helper.c
+++ b/target/ppc/int_helper.c
@@ -1444,7 +1444,7 @@  void helper_vlogefp(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *b)
         } else {                                                    \
             index = ((15 - (a & 0xf) + 1) * 8) - size;              \
         }                                                           \
-        return int128_getlo(int128_rshift(b->s128, index)) &        \
+        return int128_getlo(int128_sar(b->s128, index)) &           \
             MAKE_64BIT_MASK(0, size);                               \
     }
 #else
@@ -1457,7 +1457,7 @@  void helper_vlogefp(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *b)
         } else {                                                    \
             index = (a & 0xf) * 8;                                  \
         }                                                           \
-        return int128_getlo(int128_rshift(b->s128, index)) &        \
+        return int128_getlo(int128_sar(b->s128, index)) &           \
             MAKE_64BIT_MASK(0, size);                               \
     }
 #endif
diff --git a/tests/test-int128.c b/tests/test-int128.c
index b86a3c76e6..9bd6cb59ec 100644
--- a/tests/test-int128.c
+++ b/tests/test-int128.c
@@ -176,34 +176,34 @@  static void test_gt(void)
 /* Make sure to test undefined behavior at runtime! */
 
 static void __attribute__((__noinline__)) ATTRIBUTE_NOCLONE
-test_rshift_one(uint32_t x, int n, uint64_t h, uint64_t l)
+test_sar_one(uint32_t x, int n, uint64_t h, uint64_t l)
 {
     Int128 a = expand(x);
-    Int128 r = int128_rshift(a, n);
+    Int128 r = int128_sar(a, n);
     g_assert_cmpuint(int128_getlo(r), ==, l);
     g_assert_cmpuint(int128_gethi(r), ==, h);
 }
 
-static void test_rshift(void)
+static void test_sar(void)
 {
-    test_rshift_one(0x00010000U, 64, 0x0000000000000000ULL, 0x0000000000000001ULL);
-    test_rshift_one(0x80010000U, 64, 0xFFFFFFFFFFFFFFFFULL, 0x8000000000000001ULL);
-    test_rshift_one(0x7FFE0000U, 64, 0x0000000000000000ULL, 0x7FFFFFFFFFFFFFFEULL);
-    test_rshift_one(0xFFFE0000U, 64, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFEULL);
-    test_rshift_one(0x00010000U, 60, 0x0000000000000000ULL, 0x0000000000000010ULL);
-    test_rshift_one(0x80010000U, 60, 0xFFFFFFFFFFFFFFF8ULL, 0x0000000000000010ULL);
-    test_rshift_one(0x00018000U, 60, 0x0000000000000000ULL, 0x0000000000000018ULL);
-    test_rshift_one(0x80018000U, 60, 0xFFFFFFFFFFFFFFF8ULL, 0x0000000000000018ULL);
-    test_rshift_one(0x7FFE0000U, 60, 0x0000000000000007ULL, 0xFFFFFFFFFFFFFFE0ULL);
-    test_rshift_one(0xFFFE0000U, 60, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFE0ULL);
-    test_rshift_one(0x7FFE8000U, 60, 0x0000000000000007ULL, 0xFFFFFFFFFFFFFFE8ULL);
-    test_rshift_one(0xFFFE8000U, 60, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFE8ULL);
-    test_rshift_one(0x00018000U,  0, 0x0000000000000001ULL, 0x8000000000000000ULL);
-    test_rshift_one(0x80018000U,  0, 0x8000000000000001ULL, 0x8000000000000000ULL);
-    test_rshift_one(0x7FFE0000U,  0, 0x7FFFFFFFFFFFFFFEULL, 0x0000000000000000ULL);
-    test_rshift_one(0xFFFE0000U,  0, 0xFFFFFFFFFFFFFFFEULL, 0x0000000000000000ULL);
-    test_rshift_one(0x7FFE8000U,  0, 0x7FFFFFFFFFFFFFFEULL, 0x8000000000000000ULL);
-    test_rshift_one(0xFFFE8000U,  0, 0xFFFFFFFFFFFFFFFEULL, 0x8000000000000000ULL);
+    test_sar_one(0x00010000U, 64, 0x0000000000000000ULL, 0x0000000000000001ULL);
+    test_sar_one(0x80010000U, 64, 0xFFFFFFFFFFFFFFFFULL, 0x8000000000000001ULL);
+    test_sar_one(0x7FFE0000U, 64, 0x0000000000000000ULL, 0x7FFFFFFFFFFFFFFEULL);
+    test_sar_one(0xFFFE0000U, 64, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFEULL);
+    test_sar_one(0x00010000U, 60, 0x0000000000000000ULL, 0x0000000000000010ULL);
+    test_sar_one(0x80010000U, 60, 0xFFFFFFFFFFFFFFF8ULL, 0x0000000000000010ULL);
+    test_sar_one(0x00018000U, 60, 0x0000000000000000ULL, 0x0000000000000018ULL);
+    test_sar_one(0x80018000U, 60, 0xFFFFFFFFFFFFFFF8ULL, 0x0000000000000018ULL);
+    test_sar_one(0x7FFE0000U, 60, 0x0000000000000007ULL, 0xFFFFFFFFFFFFFFE0ULL);
+    test_sar_one(0xFFFE0000U, 60, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFE0ULL);
+    test_sar_one(0x7FFE8000U, 60, 0x0000000000000007ULL, 0xFFFFFFFFFFFFFFE8ULL);
+    test_sar_one(0xFFFE8000U, 60, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFE8ULL);
+    test_sar_one(0x00018000U,  0, 0x0000000000000001ULL, 0x8000000000000000ULL);
+    test_sar_one(0x80018000U,  0, 0x8000000000000001ULL, 0x8000000000000000ULL);
+    test_sar_one(0x7FFE0000U,  0, 0x7FFFFFFFFFFFFFFEULL, 0x0000000000000000ULL);
+    test_sar_one(0xFFFE0000U,  0, 0xFFFFFFFFFFFFFFFEULL, 0x0000000000000000ULL);
+    test_sar_one(0x7FFE8000U,  0, 0x7FFFFFFFFFFFFFFEULL, 0x8000000000000000ULL);
+    test_sar_one(0xFFFE8000U,  0, 0xFFFFFFFFFFFFFFFEULL, 0x8000000000000000ULL);
 }
 
 int main(int argc, char **argv)
@@ -218,6 +218,6 @@  int main(int argc, char **argv)
     g_test_add_func("/int128/int128_lt", test_lt);
     g_test_add_func("/int128/int128_ge", test_ge);
     g_test_add_func("/int128/int128_gt", test_gt);
-    g_test_add_func("/int128/int128_rshift", test_rshift);
+    g_test_add_func("/int128/int128_sar", test_sar);
     return g_test_run();
 }