[PATCH v2 03/10] target/openrisc: Replace MO_TE -> MO_BE

Philippe Mathieu-Daudé posted 10 patches 1 month ago
Maintainers: Stafford Horne <shorne@gmail.com>
There is a newer version of this series
[PATCH v2 03/10] target/openrisc: Replace MO_TE -> MO_BE
Posted by Philippe Mathieu-Daudé 1 month ago
We only build the OpenRISC targets using big endianness order:

  $ git grep TARGET_BIG_ENDIAN configs/targets/or1k-*
  configs/targets/or1k-linux-user.mak:2:TARGET_BIG_ENDIAN=y
  configs/targets/or1k-softmmu.mak:2:TARGET_BIG_ENDIAN=y

Therefore the MO_TE definition always expands to MO_BE. Use the
latter to simplify.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/openrisc/translate.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c
index df0ebcd3138..4ece2547614 100644
--- a/target/openrisc/translate.c
+++ b/target/openrisc/translate.c
@@ -647,7 +647,7 @@ static bool trans_l_lwa(DisasContext *dc, arg_load *a)
     check_r0_write(dc, a->d);
     ea = tcg_temp_new();
     tcg_gen_addi_tl(ea, cpu_R(dc, a->a), a->i);
-    tcg_gen_qemu_ld_tl(cpu_R(dc, a->d), ea, dc->mem_idx, MO_TE | MO_UL);
+    tcg_gen_qemu_ld_tl(cpu_R(dc, a->d), ea, dc->mem_idx, MO_BE | MO_UL);
     tcg_gen_mov_tl(cpu_lock_addr, ea);
     tcg_gen_mov_tl(cpu_lock_value, cpu_R(dc, a->d));
     return true;
@@ -665,13 +665,13 @@ static void do_load(DisasContext *dc, arg_load *a, MemOp mop)
 
 static bool trans_l_lwz(DisasContext *dc, arg_load *a)
 {
-    do_load(dc, a, MO_TE | MO_UL);
+    do_load(dc, a, MO_BE | MO_UL);
     return true;
 }
 
 static bool trans_l_lws(DisasContext *dc, arg_load *a)
 {
-    do_load(dc, a, MO_TE | MO_SL);
+    do_load(dc, a, MO_BE | MO_SL);
     return true;
 }
 
@@ -689,13 +689,13 @@ static bool trans_l_lbs(DisasContext *dc, arg_load *a)
 
 static bool trans_l_lhz(DisasContext *dc, arg_load *a)
 {
-    do_load(dc, a, MO_TE | MO_UW);
+    do_load(dc, a, MO_BE | MO_UW);
     return true;
 }
 
 static bool trans_l_lhs(DisasContext *dc, arg_load *a)
 {
-    do_load(dc, a, MO_TE | MO_SW);
+    do_load(dc, a, MO_BE | MO_SW);
     return true;
 }
 
@@ -713,7 +713,7 @@ static bool trans_l_swa(DisasContext *dc, arg_store *a)
 
     val = tcg_temp_new();
     tcg_gen_atomic_cmpxchg_tl(val, cpu_lock_addr, cpu_lock_value,
-                              cpu_R(dc, a->b), dc->mem_idx, MO_TE | MO_UL);
+                              cpu_R(dc, a->b), dc->mem_idx, MO_BE | MO_UL);
     tcg_gen_setcond_tl(TCG_COND_EQ, cpu_sr_f, val, cpu_lock_value);
 
     tcg_gen_br(lab_done);
@@ -735,7 +735,7 @@ static void do_store(DisasContext *dc, arg_store *a, MemOp mop)
 
 static bool trans_l_sw(DisasContext *dc, arg_store *a)
 {
-    do_store(dc, a, MO_TE | MO_UL);
+    do_store(dc, a, MO_BE | MO_UL);
     return true;
 }
 
@@ -747,7 +747,7 @@ static bool trans_l_sb(DisasContext *dc, arg_store *a)
 
 static bool trans_l_sh(DisasContext *dc, arg_store *a)
 {
-    do_store(dc, a, MO_TE | MO_UW);
+    do_store(dc, a, MO_BE | MO_UW);
     return true;
 }
 
-- 
2.51.0


Re: [PATCH v2 03/10] target/openrisc: Replace MO_TE -> MO_BE
Posted by Philippe Mathieu-Daudé 1 month ago
On 9/10/25 10:18, Philippe Mathieu-Daudé wrote:
> We only build the OpenRISC targets using big endianness order:
> 
>    $ git grep TARGET_BIG_ENDIAN configs/targets/or1k-*
>    configs/targets/or1k-linux-user.mak:2:TARGET_BIG_ENDIAN=y
>    configs/targets/or1k-softmmu.mak:2:TARGET_BIG_ENDIAN=y
> 
> Therefore the MO_TE definition always expands to MO_BE. Use the
> latter to simplify.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/openrisc/translate.c | 16 ++++++++--------
>   1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c
> index df0ebcd3138..4ece2547614 100644
> --- a/target/openrisc/translate.c
> +++ b/target/openrisc/translate.c
> @@ -647,7 +647,7 @@ static bool trans_l_lwa(DisasContext *dc, arg_load *a)
>       check_r0_write(dc, a->d);
>       ea = tcg_temp_new();
>       tcg_gen_addi_tl(ea, cpu_R(dc, a->a), a->i);
> -    tcg_gen_qemu_ld_tl(cpu_R(dc, a->d), ea, dc->mem_idx, MO_TE | MO_UL);
> +    tcg_gen_qemu_ld_tl(cpu_R(dc, a->d), ea, dc->mem_idx, MO_BE | MO_UL);
>       tcg_gen_mov_tl(cpu_lock_addr, ea);
>       tcg_gen_mov_tl(cpu_lock_value, cpu_R(dc, a->d));
>       return true;
> @@ -665,13 +665,13 @@ static void do_load(DisasContext *dc, arg_load *a, MemOp mop)
>   
>   static bool trans_l_lwz(DisasContext *dc, arg_load *a)
>   {
> -    do_load(dc, a, MO_TE | MO_UL);
> +    do_load(dc, a, MO_BE | MO_UL);
>       return true;
>   }
>   
>   static bool trans_l_lws(DisasContext *dc, arg_load *a)
>   {
> -    do_load(dc, a, MO_TE | MO_SL);
> +    do_load(dc, a, MO_BE | MO_SL);
>       return true;
>   }

Hmm should we move MO_BE within do_load()?