Skip to contentSkip to conversation

Drop float32/float64 accessors used by gdbstub code

PATCH Applied Peter Maydell 5 participants 10 messages Feb 8, 2021 – Feb 9, 2021

lore
Share & tools
lore
#0 lore raw

cover Drop float32/float64 accessors used by gdbstub code

We used to make a distinction between 'float64'/'float32' types and the 'uint64_t'/'uint32_t' types, requiring special conversion operations to go between them. We've now dropped this distinction as unnecessary, and the 'float*' types remain primarily for documentation purposes when used in places like the function prototypes of TCG helper functions.

This means that there's no need for special gdb_get_float64() and gdb_get_float32() functions to write float64 or float32 values to the GDB protocol buffer; we can just use gdb_get_reg64() and gdb_get_reg32().

Similarly, for reading a value out of the GDB buffer into a float64 or float32 we can use ldq_p() or ldl_p() and need not use ldfq_p() or ldfl_p().

This patchseries drops the use of the gdb_get_float* and ldf* functions from the three targets that were using them, and then removes the now-unused functions from gdbstub.h and bswap.h.

thanks
-- PMM

Peter Maydell (5):
target/sh4: Drop use of gdb_get_float32() and ldfl_p() target/m68k: Drop use of gdb_get_float64() and ldfq_p() target/ppc: Drop use of gdb_get_float64() and ldfq_p()
gdbstub: Remove unused gdb_get_float32() and gdb_get_float64() bswap.h: Remove unused float-access functions

 docs/devel/loads-stores.rst     | 14 +++-----
 include/exec/cpu-all.h          |  8 -----
 include/exec/gdbstub.h          | 20 -----------
 include/qemu/bswap.h            | 60 ---------------------------------
 target/m68k/helper.c            |  5 ++-
 target/ppc/gdbstub.c            |  8 ++---
 target/sh4/gdbstub.c            |  8 ++---
 target/ppc/translate_init.c.inc |  4 +--
 8 files changed, 17 insertions(+), 110 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/5 target/sh4: Drop use of gdb_get_float32() and ldfl_p()

We used to make a distinction between 'float64'/'float32' types and the 'uint64_t'/'uint32_t' types, requiring special conversion operations to go between them. We've now dropped this distinction as unnecessary, and the 'float*' types remain primarily for documentation purposes when used in places like the function prototypes of TCG helper functions.

This means that there's no need for a special gdb_get_float32() function to write a float32 value to the GDB protocol buffer; we can just use gdb_get_reg32().

Similarly, for reading a value out of the GDB buffer into a float32 we can use ldl_p() and need not use ldfl_p().

---
 target/sh4/gdbstub.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
target/sh4/gdbstub.c +4 -4
index 34ad3ca0508..3488f68e326 100644
@@ -58,9 +58,9 @@ int superh_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
         return gdb_get_regl(mem_buf, env->fpscr);
     case 25 ... 40:
         if (env->fpscr & FPSCR_FR) {
-            return gdb_get_float32(mem_buf, env->fregs[n - 9]);
+            return gdb_get_reg32(mem_buf, env->fregs[n - 9]);
         }
-        return gdb_get_float32(mem_buf, env->fregs[n - 25]);
+        return gdb_get_reg32(mem_buf, env->fregs[n - 25]);
     case 41:
         return gdb_get_regl(mem_buf, env->ssr);
     case 42:
@@ -119,9 +119,9 @@ int superh_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
         break;
     case 25 ... 40:
         if (env->fpscr & FPSCR_FR) {
-            env->fregs[n - 9] = ldfl_p(mem_buf);
+            env->fregs[n - 9] = ldl_p(mem_buf);
         } else {
-            env->fregs[n - 25] = ldfl_p(mem_buf);
+            env->fregs[n - 25] = ldl_p(mem_buf);
         }
         break;
     case 41:
Signature · 1 line
2.20.1
#2 lore raw

PATCH 2/5 target/m68k: Drop use of gdb_get_float64() and ldfq_p()

In reply to Peter Maydell

We used to make a distinction between 'float64'/'float32' types and the 'uint64_t'/'uint32_t' types, requiring special conversion operations to go between them. We've now dropped this distinction as unnecessary, and the 'float*' types remain primarily for documentation purposes when used in places like the function prototypes of TCG helper functions.

This means that there's no need for a special gdb_get_float64() function to write a float64 value to the GDB protocol buffer; we can just use gdb_get_reg64().

Similarly, for reading a value out of the GDB buffer into a float64 we can use ldq_p() and need not use ldfq_p().

---
 target/m68k/helper.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
target/m68k/helper.c +2 -3
index 3ff57657958..09f0391d508 100644
@@ -72,8 +72,7 @@ static int cf_fpu_gdb_get_reg(CPUM68KState *env, GByteArray *mem_buf, int n)
 {
     if (n < 8) {
         float_status s;
-        return gdb_get_float64(mem_buf,
-                               floatx80_to_float64(env->fregs[n].d, &s));
+        return gdb_get_reg64(mem_buf, floatx80_to_float64(env->fregs[n].d, &s));
     }
     switch (n) {
     case 8: /* fpcontrol */
@@ -90,7 +89,7 @@ static int cf_fpu_gdb_set_reg(CPUM68KState *env, uint8_t *mem_buf, int n)
 {
     if (n < 8) {
         float_status s;
-        env->fregs[n].d = float64_to_floatx80(ldfq_p(mem_buf), &s);
+        env->fregs[n].d = float64_to_floatx80(ldq_p(mem_buf), &s);
         return 8;
     }
     switch (n) {
Signature · 1 line
2.20.1
Acked-by on v1 2/5
#3 lore raw

Re: [PATCH 2/5] target/m68k: Drop use of gdb_get_float64() and ldfq_p()

Le 08/02/2021 à 12:34, Peter Maydell a écrit :

Quoted 35 lines

We used to make a distinction between 'float64'/'float32' types and the 'uint64_t'/'uint32_t' types, requiring special conversion operations to go between them. We've now dropped this distinction as unnecessary, and the 'float*' types remain primarily for documentation purposes when used in places like the function prototypes of TCG helper functions.

This means that there's no need for a special gdb_get_float64() function to write a float64 value to the GDB protocol buffer; we can just use gdb_get_reg64().

Similarly, for reading a value out of the GDB buffer into a float64 we can use ldq_p() and need not use ldfq_p().

---
 target/m68k/helper.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
target/m68k/helper.c +1 -2
index 3ff57657958..09f0391d508 100644
@@ -72,8 +72,7 @@ static int cf_fpu_gdb_get_reg(CPUM68KState *env, GByteArray *mem_buf, int n)
 {
     if (n < 8) {
         float_status s;
-        return gdb_get_float64(mem_buf,
-                               floatx80_to_float64(env->fregs[n].d, &s));
+        return gdb_get_reg64(mem_buf, floatx80_to_float64(env->fregs[n].d, &s));
     }
     switch (n) {
     case 8: /* fpcontrol */

target/m68k/helper.c static int cf_fpu_gdb_set_reg(CPUM68KState *env, uint8_t *mem_buf, int n) · line 95

Quoted 8 lines
target/m68k/helper.c +1 -1
@@ -90,7 +89,7 @@ static int cf_fpu_gdb_set_reg(CPUM68KState *env, uint8_t *mem_buf, int n)
 {
     if (n < 8) {
         float_status s;
-        env->fregs[n].d = float64_to_floatx80(ldfq_p(mem_buf), &s);
+        env->fregs[n].d = float64_to_floatx80(ldq_p(mem_buf), &s);
         return 8;
     }
     switch (n) {
#4 lore raw

PATCH 3/5 target/ppc: Drop use of gdb_get_float64() and ldfq_p()

In reply to Peter Maydell

We used to make a distinction between 'float64'/'float32' types and the 'uint64_t'/'uint32_t' types, requiring special conversion operations to go between them. We've now dropped this distinction as unnecessary, and the 'float*' types remain primarily for documentation purposes when used in places like the function prototypes of TCG helper functions.

This means that there's no need for a special gdb_get_float64() function to write a float64 value to the GDB protocol buffer; we can just use gdb_get_reg64().

Similarly, for reading a value out of the GDB buffer into a float64 we can use ldq_p() and need not use ldfq_p().

---
 target/ppc/gdbstub.c            | 8 ++++----
 target/ppc/translate_init.c.inc | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)
target/ppc/gdbstub.c +4 -4
index 01459dd31d2..c28319fb974 100644
@@ -130,7 +130,7 @@ int ppc_cpu_gdb_read_register(CPUState *cs, GByteArray *buf, int n)
         gdb_get_regl(buf, env->gpr[n]);
     } else if (n < 64) {
         /* fprs */
-        gdb_get_float64(buf, *cpu_fpr_ptr(env, n - 32));
+        gdb_get_reg64(buf, *cpu_fpr_ptr(env, n - 32));
     } else {
         switch (n) {
         case 64:
@@ -184,7 +184,7 @@ int ppc_cpu_gdb_read_register_apple(CPUState *cs, GByteArray *buf, int n)
         gdb_get_reg64(buf, env->gpr[n]);
     } else if (n < 64) {
         /* fprs */
-        gdb_get_float64(buf, *cpu_fpr_ptr(env, n - 32));
+        gdb_get_reg64(buf, *cpu_fpr_ptr(env, n - 32));
     } else if (n < 96) {
         /* Altivec */
         gdb_get_reg64(buf, n - 64);
@@ -241,7 +241,7 @@ int ppc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
         env->gpr[n] = ldtul_p(mem_buf);
     } else if (n < 64) {
         /* fprs */
-        *cpu_fpr_ptr(env, n - 32) = ldfq_p(mem_buf);
+        *cpu_fpr_ptr(env, n - 32) = ldq_p(mem_buf);
     } else {
         switch (n) {
         case 64:
@@ -291,7 +291,7 @@ int ppc_cpu_gdb_write_register_apple(CPUState *cs, uint8_t *mem_buf, int n)
         env->gpr[n] = ldq_p(mem_buf);
     } else if (n < 64) {
         /* fprs */
-        *cpu_fpr_ptr(env, n - 32) = ldfq_p(mem_buf);
+        *cpu_fpr_ptr(env, n - 32) = ldq_p(mem_buf);
     } else {
         switch (n) {
         case 64 + 32:
target/ppc/translate_init.c.inc +2 -2
index 9867d0a6e4a..7bd111d905e 100644
@@ -9907,7 +9907,7 @@ static int gdb_get_float_reg(CPUPPCState *env, GByteArray *buf, int n)
 {
     uint8_t *mem_buf;
     if (n < 32) {
-        gdb_get_float64(buf, *cpu_fpr_ptr(env, n));
+        gdb_get_reg64(buf, *cpu_fpr_ptr(env, n));
         mem_buf = gdb_get_reg_ptr(buf, 8);
         ppc_maybe_bswap_register(env, mem_buf, 8);
         return 8;
@@ -9925,7 +9925,7 @@ static int gdb_set_float_reg(CPUPPCState *env, uint8_t *mem_buf, int n)
 {
     if (n < 32) {
         ppc_maybe_bswap_register(env, mem_buf, 8);
-        *cpu_fpr_ptr(env, n) = ldfq_p(mem_buf);
+        *cpu_fpr_ptr(env, n) = ldq_p(mem_buf);
         return 8;
     }
     if (n == 32) {
Signature · 1 line
2.20.1
Acked-by on v1 3/5
#5 lore raw

Re: [PATCH 3/5] target/ppc: Drop use of gdb_get_float64() and ldfq_p()

Quoted 7 lines · Peter Maydell

We used to make a distinction between 'float64'/'float32' types and the 'uint64_t'/'uint32_t' types, requiring special conversion operations to go between them. We've now dropped this distinction as unnecessary, and the 'float*' types remain primarily for documentation purposes when used in places like the function prototypes of TCG helper functions.

Quoted 8 lines

This means that there's no need for a special gdb_get_float64() function to write a float64 value to the GDB protocol buffer; we can just use gdb_get_reg64().

Similarly, for reading a value out of the GDB buffer into a float64 we can use ldq_p() and need not use ldfq_p().

Quoted 67 lines
---
 target/ppc/gdbstub.c            | 8 ++++----
 target/ppc/translate_init.c.inc | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)
target/ppc/gdbstub.c +4 -4
index 01459dd31d2..c28319fb974 100644
@@ -130,7 +130,7 @@ int ppc_cpu_gdb_read_register(CPUState *cs, GByteArray *buf, int n)
         gdb_get_regl(buf, env->gpr[n]);
     } else if (n < 64) {
         /* fprs */
-        gdb_get_float64(buf, *cpu_fpr_ptr(env, n - 32));
+        gdb_get_reg64(buf, *cpu_fpr_ptr(env, n - 32));
     } else {
         switch (n) {
         case 64:
@@ -184,7 +184,7 @@ int ppc_cpu_gdb_read_register_apple(CPUState *cs, GByteArray *buf, int n)
         gdb_get_reg64(buf, env->gpr[n]);
     } else if (n < 64) {
         /* fprs */
-        gdb_get_float64(buf, *cpu_fpr_ptr(env, n - 32));
+        gdb_get_reg64(buf, *cpu_fpr_ptr(env, n - 32));
     } else if (n < 96) {
         /* Altivec */
         gdb_get_reg64(buf, n - 64);
@@ -241,7 +241,7 @@ int ppc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
         env->gpr[n] = ldtul_p(mem_buf);
     } else if (n < 64) {
         /* fprs */
-        *cpu_fpr_ptr(env, n - 32) = ldfq_p(mem_buf);
+        *cpu_fpr_ptr(env, n - 32) = ldq_p(mem_buf);
     } else {
         switch (n) {
         case 64:
@@ -291,7 +291,7 @@ int ppc_cpu_gdb_write_register_apple(CPUState *cs, uint8_t *mem_buf, int n)
         env->gpr[n] = ldq_p(mem_buf);
     } else if (n < 64) {
         /* fprs */
-        *cpu_fpr_ptr(env, n - 32) = ldfq_p(mem_buf);
+        *cpu_fpr_ptr(env, n - 32) = ldq_p(mem_buf);
     } else {
         switch (n) {
         case 64 + 32:
target/ppc/translate_init.c.inc +2 -2
index 9867d0a6e4a..7bd111d905e 100644
@@ -9907,7 +9907,7 @@ static int gdb_get_float_reg(CPUPPCState *env, GByteArray *buf, int n)
 {
     uint8_t *mem_buf;
     if (n < 32) {
-        gdb_get_float64(buf, *cpu_fpr_ptr(env, n));
+        gdb_get_reg64(buf, *cpu_fpr_ptr(env, n));
         mem_buf = gdb_get_reg_ptr(buf, 8);
         ppc_maybe_bswap_register(env, mem_buf, 8);
         return 8;
@@ -9925,7 +9925,7 @@ static int gdb_set_float_reg(CPUPPCState *env, uint8_t *mem_buf, int n)
 {
     if (n < 32) {
         ppc_maybe_bswap_register(env, mem_buf, 8);
-        *cpu_fpr_ptr(env, n) = ldfq_p(mem_buf);
+        *cpu_fpr_ptr(env, n) = ldq_p(mem_buf);
         return 8;
     }
     if (n == 32) {
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
Reviewed-by on the v1 series
#6 lore raw
In reply to Peter Maydell
Quoted 30 lines · Peter Maydell

We used to make a distinction between 'float64'/'float32' types and the 'uint64_t'/'uint32_t' types, requiring special conversion operations to go between them. We've now dropped this distinction as unnecessary, and the 'float*' types remain primarily for documentation purposes when used in places like the function prototypes of TCG helper functions.

This means that there's no need for special gdb_get_float64() and gdb_get_float32() functions to write float64 or float32 values to the GDB protocol buffer; we can just use gdb_get_reg64() and gdb_get_reg32().

Similarly, for reading a value out of the GDB buffer into a float64 or float32 we can use ldq_p() or ldl_p() and need not use ldfq_p() or ldfl_p().

This patchseries drops the use of the gdb_get_float* and ldf* functions from the three targets that were using them, and then removes the now-unused functions from gdbstub.h and bswap.h.

thanks
-- PMM

Peter Maydell (5):
target/sh4: Drop use of gdb_get_float32() and ldfl_p() target/m68k: Drop use of gdb_get_float64() and ldfq_p() target/ppc: Drop use of gdb_get_float64() and ldfq_p()
gdbstub: Remove unused gdb_get_float32() and gdb_get_float64() bswap.h: Remove unused float-access functions

Quoted 9 lines
 docs/devel/loads-stores.rst     | 14 +++-----
 include/exec/cpu-all.h          |  8 -----
 include/exec/gdbstub.h          | 20 -----------
 include/qemu/bswap.h            | 60 ---------------------------------
 target/m68k/helper.c            |  5 ++-
 target/ppc/gdbstub.c            |  8 ++---
 target/sh4/gdbstub.c            |  8 ++---
 target/ppc/translate_init.c.inc |  4 +--
 8 files changed, 17 insertions(+), 110 deletions(-)

Series:

Thanks for the cleanup!

#7 lore raw

PATCH 4/5 gdbstub: Remove unused gdb_get_float32() and gdb_get_float64()

In reply to Peter Maydell

The functions gdb_get_float32() and gdb_get_float64() are now unused; remove them.

---
 include/exec/gdbstub.h | 20 --------------------
 1 file changed, 20 deletions(-)
include/exec/gdbstub.h +0 -20
index ff0b7bc45ec..a024a0350df 100644
@@ -135,26 +135,6 @@ static inline int gdb_get_reg128(GByteArray *buf, uint64_t val_hi,
     return 16;
 }
 
-static inline int gdb_get_float32(GByteArray *array, float32 val)
-{
-    uint8_t buf[sizeof(CPU_FloatU)];
-
-    stfl_p(buf, val);
-    g_byte_array_append(array, buf, sizeof(buf));
-
-    return sizeof(buf);
-}
-
-static inline int gdb_get_float64(GByteArray *array, float64 val)
-{
-    uint8_t buf[sizeof(CPU_DoubleU)];
-
-    stfq_p(buf, val);
-    g_byte_array_append(array, buf, sizeof(buf));
-
-    return sizeof(buf);
-}
-
 static inline int gdb_get_zeroes(GByteArray *array, size_t len)
 {
     guint oldlen = array->len;
Signature · 1 line
2.20.1
#8 lore raw

PATCH 5/5 bswap.h: Remove unused float-access functions

In reply to Peter Maydell

The float-access functions stfl_*, stfq*, ldfl* and ldfq* are now unused; remove them. (Accesses to float64 and float32 types can be made with the ldl/stl/ldq/stq functions, as float64 and float32 are guaranteed to be typedefs for normal integer types.)

---
 docs/devel/loads-stores.rst | 14 ++++-----
 include/exec/cpu-all.h      |  8 -----
 include/qemu/bswap.h        | 60 -------------------------------------
 3 files changed, 5 insertions(+), 77 deletions(-)
docs/devel/loads-stores.rst +5 -9
index ee43f5dfee2..568274baec0 100644
@@ -24,16 +24,12 @@ potentially unaligned pointer values.
 
 Function names follow the pattern:
 
-load: ``ld{type}{sign}{size}_{endian}_p(ptr)``
+load: ``ld{sign}{size}_{endian}_p(ptr)``
 
-store: ``st{type}{size}_{endian}_p(ptr, val)``
-
-``type``
- - (empty) : integer access
- - ``f`` : float access
+store: ``st{size}_{endian}_p(ptr, val)``
 
 ``sign``
- - (empty) : for 32 or 64 bit sizes (including floats and doubles)
+ - (empty) : for 32 or 64 bit sizes
  - ``u`` : unsigned
  - ``s`` : signed
 
@@ -67,8 +63,8 @@ of size ``sz`` bytes.
 
 
 Regexes for git grep
- - ``\<ldf\?[us]\?[bwlq]\(_[hbl]e\)\?_p\>``
- - ``\<stf\?[bwlq]\(_[hbl]e\)\?_p\>``
+ - ``\<ld[us]\?[bwlq]\(_[hbl]e\)\?_p\>``
+ - ``\<st[bwlq]\(_[hbl]e\)\?_p\>``
  - ``\<ldn_\([hbl]e\)?_p\>``
  - ``\<stn_\([hbl]e\)?_p\>``
 
include/exec/cpu-all.h +0 -8
index cfb1d793311..babf0a8959f 100644
@@ -125,13 +125,9 @@ static inline void tswap64s(uint64_t *s)
 #define ldsw_p(p) ldsw_be_p(p)
 #define ldl_p(p) ldl_be_p(p)
 #define ldq_p(p) ldq_be_p(p)
-#define ldfl_p(p) ldfl_be_p(p)
-#define ldfq_p(p) ldfq_be_p(p)
 #define stw_p(p, v) stw_be_p(p, v)
 #define stl_p(p, v) stl_be_p(p, v)
 #define stq_p(p, v) stq_be_p(p, v)
-#define stfl_p(p, v) stfl_be_p(p, v)
-#define stfq_p(p, v) stfq_be_p(p, v)
 #define ldn_p(p, sz) ldn_be_p(p, sz)
 #define stn_p(p, sz, v) stn_be_p(p, sz, v)
 #else
@@ -139,13 +135,9 @@ static inline void tswap64s(uint64_t *s)
 #define ldsw_p(p) ldsw_le_p(p)
 #define ldl_p(p) ldl_le_p(p)
 #define ldq_p(p) ldq_le_p(p)
-#define ldfl_p(p) ldfl_le_p(p)
-#define ldfq_p(p) ldfq_le_p(p)
 #define stw_p(p, v) stw_le_p(p, v)
 #define stl_p(p, v) stl_le_p(p, v)
 #define stq_p(p, v) stq_le_p(p, v)
-#define stfl_p(p, v) stfl_le_p(p, v)
-#define stfq_p(p, v) stfq_le_p(p, v)
 #define ldn_p(p, sz) ldn_le_p(p, sz)
 #define stn_p(p, sz, v) stn_le_p(p, sz, v)
 #endif
include/qemu/bswap.h +0 -60

72 lines not on this page · raw message

Signature · 1 line
2.20.1
Applied
#9 lore raw
In reply to Peter Maydell
Quoted 12 lines · Peter Maydell

We used to make a distinction between 'float64'/'float32' types and the 'uint64_t'/'uint32_t' types, requiring special conversion operations to go between them. We've now dropped this distinction as unnecessary, and the 'float*' types remain primarily for documentation purposes when used in places like the function prototypes of TCG helper functions.

This means that there's no need for special gdb_get_float64() and gdb_get_float32() functions to write float64 or float32 values to the GDB protocol buffer; we can just use gdb_get_reg64() and gdb_get_reg32().

Quoted 7 lines

Similarly, for reading a value out of the GDB buffer into a float64 or float32 we can use ldq_p() or ldl_p() and need not use ldfq_p() or ldfl_p().

This patchseries drops the use of the gdb_get_float* and ldf* functions from the three targets that were using them, and then removes the now-unused functions from gdbstub.h and bswap.h.

Queued to gdbstub/next, thanks.

Signature · 1 line
Alex Bennée