[PATCH v3 5/9] target/sparc: Use big-endian variant of cpu_ld/st_data*()

Philippe Mathieu-Daudé posted 9 patches 1 month, 2 weeks ago
Maintainers: Laurent Vivier <laurent@vivier.eu>, Gerd Hoffmann <kraxel@redhat.com>, "Clément Chigot" <chigot@adacore.com>, Frederic Konrad <konrad.frederic@yahoo.fr>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Artyom Tarasenko <atar4qemu@gmail.com>
There is a newer version of this series
[PATCH v3 5/9] target/sparc: Use big-endian variant of cpu_ld/st_data*()
Posted by Philippe Mathieu-Daudé 1 month, 2 weeks ago
We only build the SPARC targets using big endianness order,
therefore the cpu_ld/st_data*() definitions expand to the big
endian declarations. Use the explicit big-endian variants.

Mechanical change running:

  $ tgt=sparc; \
    end=be; \
    for op in data mmuidx_ra; do \
      for ac in uw sw l q; do \
        sed -i -e "s/cpu_ld${ac}_${op}/cpu_ld${ac}_${end}_${op}/" \
                  $(git grep -l cpu_ target/${tgt}/); \
      done;
      for ac in w l q; do \
        sed -i -e "s/cpu_st${ac}_${op}/cpu_st${ac}_${end}_${op}/" \
                  $(git grep -l cpu_ target/${tgt}/); \
      done;
    done

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/sparc/ldst_helper.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c
index 9892c8f61c6..d39f7d72a7e 100644
--- a/target/sparc/ldst_helper.c
+++ b/target/sparc/ldst_helper.c
@@ -1228,13 +1228,13 @@ uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr,
             ret = cpu_ldub_data(env, addr);
             break;
         case 2:
-            ret = cpu_lduw_data(env, addr);
+            ret = cpu_lduw_be_data(env, addr);
             break;
         case 4:
-            ret = cpu_ldl_data(env, addr);
+            ret = cpu_ldl_be_data(env, addr);
             break;
         case 8:
-            ret = cpu_ldq_data(env, addr);
+            ret = cpu_ldq_be_data(env, addr);
             break;
         default:
             g_assert_not_reached();
-- 
2.52.0


Re: [PATCH v3 5/9] target/sparc: Use big-endian variant of cpu_ld/st_data*()
Posted by Richard Henderson 1 month ago
On 12/25/25 03:26, Philippe Mathieu-Daudé wrote:
> We only build the SPARC targets using big endianness order,
> therefore the cpu_ld/st_data*() definitions expand to the big
> endian declarations. Use the explicit big-endian variants.
> 
> Mechanical change running:
> 
>    $ tgt=sparc; \
>      end=be; \
>      for op in data mmuidx_ra; do \
>        for ac in uw sw l q; do \
>          sed -i -e "s/cpu_ld${ac}_${op}/cpu_ld${ac}_${end}_${op}/" \
>                    $(git grep -l cpu_ target/${tgt}/); \
>        done;
>        for ac in w l q; do \
>          sed -i -e "s/cpu_st${ac}_${op}/cpu_st${ac}_${end}_${op}/" \
>                    $(git grep -l cpu_ target/${tgt}/); \
>        done;
>      done
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   target/sparc/ldst_helper.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)

FWIW, this function could be re-organized to use cpu_ld*_mmu, to avoid the explicit BE 
load followed by an explicit bswap, for the little-endian ASIs.


r~


> 
> diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c
> index 9892c8f61c6..d39f7d72a7e 100644
> --- a/target/sparc/ldst_helper.c
> +++ b/target/sparc/ldst_helper.c
> @@ -1228,13 +1228,13 @@ uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr,
>               ret = cpu_ldub_data(env, addr);
>               break;
>           case 2:
> -            ret = cpu_lduw_data(env, addr);
> +            ret = cpu_lduw_be_data(env, addr);
>               break;
>           case 4:
> -            ret = cpu_ldl_data(env, addr);
> +            ret = cpu_ldl_be_data(env, addr);
>               break;
>           case 8:
> -            ret = cpu_ldq_data(env, addr);
> +            ret = cpu_ldq_be_data(env, addr);
>               break;
>           default:
>               g_assert_not_reached();


Re: [PATCH v3 5/9] target/sparc: Use big-endian variant of cpu_ld/st_data*()
Posted by Manos Pitsidianakis 1 month, 1 week ago
On Wed, Dec 24, 2025 at 6:27 PM Philippe Mathieu-Daudé
<philmd@linaro.org> wrote:
>
> We only build the SPARC targets using big endianness order,
> therefore the cpu_ld/st_data*() definitions expand to the big
> endian declarations. Use the explicit big-endian variants.
>
> Mechanical change running:
>
>   $ tgt=sparc; \
>     end=be; \
>     for op in data mmuidx_ra; do \
>       for ac in uw sw l q; do \
>         sed -i -e "s/cpu_ld${ac}_${op}/cpu_ld${ac}_${end}_${op}/" \
>                   $(git grep -l cpu_ target/${tgt}/); \
>       done;
>       for ac in w l q; do \
>         sed -i -e "s/cpu_st${ac}_${op}/cpu_st${ac}_${end}_${op}/" \
>                   $(git grep -l cpu_ target/${tgt}/); \
>       done;
>     done
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> ---

Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>

>  target/sparc/ldst_helper.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c
> index 9892c8f61c6..d39f7d72a7e 100644
> --- a/target/sparc/ldst_helper.c
> +++ b/target/sparc/ldst_helper.c
> @@ -1228,13 +1228,13 @@ uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr,
>              ret = cpu_ldub_data(env, addr);
>              break;
>          case 2:
> -            ret = cpu_lduw_data(env, addr);
> +            ret = cpu_lduw_be_data(env, addr);
>              break;
>          case 4:
> -            ret = cpu_ldl_data(env, addr);
> +            ret = cpu_ldl_be_data(env, addr);
>              break;
>          case 8:
> -            ret = cpu_ldq_data(env, addr);
> +            ret = cpu_ldq_be_data(env, addr);
>              break;
>          default:
>              g_assert_not_reached();
> --
> 2.52.0
>