[PATCH-for-10.1 2/3] target/sparc: Inline qemu_get_betl() and qemu_put_betl()

Philippe Mathieu-Daudé posted 3 patches 10 months, 3 weeks ago
Maintainers: Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, Huacai Chen <chenhuacai@kernel.org>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Aurelien Jarno <aurelien@aurel32.net>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Aleksandar Rikalo <arikalo@gmail.com>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Artyom Tarasenko <atar4qemu@gmail.com>
[PATCH-for-10.1 2/3] target/sparc: Inline qemu_get_betl() and qemu_put_betl()
Posted by Philippe Mathieu-Daudé 10 months, 3 weeks ago
We only use qemu_get_betl() and qemu_put_betl() once in
the whole code base. Inline them (checking TARGET_SPARC64
instead of TARGET_LONG_BITS == 64) so we can remove them
later as unused.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/sparc/machine.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/target/sparc/machine.c b/target/sparc/machine.c
index 222e5709c55..cc58812781b 100644
--- a/target/sparc/machine.c
+++ b/target/sparc/machine.c
@@ -87,7 +87,13 @@ static int get_fsr(QEMUFile *f, void *opaque, size_t size,
                    const VMStateField *field)
 {
     SPARCCPU *cpu = opaque;
-    target_ulong val = qemu_get_betl(f);
+    target_ulong val;
+
+#ifdef TARGET_SPARC64
+    val = qemu_get_be64(f);
+#else
+    val = qemu_get_be32(f);
+#endif
 
     cpu_put_fsr(&cpu->env, val);
     return 0;
@@ -99,7 +105,11 @@ static int put_fsr(QEMUFile *f, void *opaque, size_t size,
     SPARCCPU *cpu = opaque;
     target_ulong val = cpu_get_fsr(&cpu->env);
 
-    qemu_put_betl(f, val);
+#ifdef TARGET_SPARC64
+    qemu_put_be64(f, val);
+#else
+    qemu_put_be32(f, val);
+#endif
     return 0;
 }
 
-- 
2.47.1


Re: [PATCH-for-10.1 2/3] target/sparc: Inline qemu_get_betl() and qemu_put_betl()
Posted by Pierrick Bouvier 10 months, 3 weeks ago
On 3/23/25 15:50, Philippe Mathieu-Daudé wrote:
> We only use qemu_get_betl() and qemu_put_betl() once in
> the whole code base. Inline them (checking TARGET_SPARC64
> instead of TARGET_LONG_BITS == 64) so we can remove them
> later as unused.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/sparc/machine.c | 14 ++++++++++++--
>   1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/target/sparc/machine.c b/target/sparc/machine.c
> index 222e5709c55..cc58812781b 100644
> --- a/target/sparc/machine.c
> +++ b/target/sparc/machine.c
> @@ -87,7 +87,13 @@ static int get_fsr(QEMUFile *f, void *opaque, size_t size,
>                      const VMStateField *field)
>   {
>       SPARCCPU *cpu = opaque;
> -    target_ulong val = qemu_get_betl(f);
> +    target_ulong val;
> +
> +#ifdef TARGET_SPARC64
> +    val = qemu_get_be64(f);
> +#else
> +    val = qemu_get_be32(f);
> +#endif
>   
>       cpu_put_fsr(&cpu->env, val);
>       return 0;
> @@ -99,7 +105,11 @@ static int put_fsr(QEMUFile *f, void *opaque, size_t size,
>       SPARCCPU *cpu = opaque;
>       target_ulong val = cpu_get_fsr(&cpu->env);
>   
> -    qemu_put_betl(f, val);
> +#ifdef TARGET_SPARC64
> +    qemu_put_be64(f, val);
> +#else
> +    qemu_put_be32(f, val);
> +#endif
>       return 0;
>   }
>   

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>