diff mbox series

[03/12] target/cris: Use generic hrev32_i32() in SWAPB opcode

Message ID 20230822124042.54739-4-philmd@linaro.org
State New
Headers show
Series tcg: Factor hrev{32,64}_{i32,i64,tl} out | expand

Commit Message

Philippe Mathieu-Daudé Aug. 22, 2023, 12:40 p.m. UTC
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/cris/translate.c         | 20 +-------------------
 target/cris/translate_v10.c.inc |  2 +-
 2 files changed, 2 insertions(+), 20 deletions(-)

Comments

Philippe Mathieu-Daudé Aug. 22, 2023, 1:27 p.m. UTC | #1
On 22/8/23 14:40, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/cris/translate.c         | 20 +-------------------
>   target/cris/translate_v10.c.inc |  2 +-
>   2 files changed, 2 insertions(+), 20 deletions(-)
> 
> diff --git a/target/cris/translate.c b/target/cris/translate.c
> index 925ed2c6f6..00bbe6c645 100644
> --- a/target/cris/translate.c
> +++ b/target/cris/translate.c
> @@ -381,24 +381,6 @@ static inline void t_gen_subx_carry(DisasContext *dc, TCGv d)
>       }
>   }
>   
> -/* Swap the two bytes within each half word of the s operand.
> -   T0 = ((T0 << 8) & 0xff00ff00) | ((T0 >> 8) & 0x00ff00ff)  */
> -static inline void t_gen_swapb(TCGv d, TCGv s)
> -{
> -    TCGv t, org_s;
> -
> -    t = tcg_temp_new();
> -    org_s = tcg_temp_new();
> -
> -    /* d and s may refer to the same object.  */
> -    tcg_gen_mov_tl(org_s, s);
> -    tcg_gen_shli_tl(t, org_s, 8);
> -    tcg_gen_andi_tl(d, t, 0xff00ff00);
> -    tcg_gen_shri_tl(t, org_s, 8);
> -    tcg_gen_andi_tl(t, t, 0x00ff00ff);
> -    tcg_gen_or_tl(d, d, t);
> -}
> -
>   /*
>    * Reverse the bits within each byte.
>    *
> @@ -1666,7 +1648,7 @@ static int dec_swap_r(CPUCRISState *env, DisasContext *dc)
>           tcg_gen_hswap_i32(t0, t0);
>       }
>       if (dc->op2 & 2) {
> -        t_gen_swapb(t0, t0);
> +        tcg_gen_hrev32_i32(t0, t0);

Here we should use tcg_gen_hrev32_tl (added later in this series).

>       }
diff mbox series

Patch

diff --git a/target/cris/translate.c b/target/cris/translate.c
index 925ed2c6f6..00bbe6c645 100644
--- a/target/cris/translate.c
+++ b/target/cris/translate.c
@@ -381,24 +381,6 @@  static inline void t_gen_subx_carry(DisasContext *dc, TCGv d)
     }
 }
 
-/* Swap the two bytes within each half word of the s operand.
-   T0 = ((T0 << 8) & 0xff00ff00) | ((T0 >> 8) & 0x00ff00ff)  */
-static inline void t_gen_swapb(TCGv d, TCGv s)
-{
-    TCGv t, org_s;
-
-    t = tcg_temp_new();
-    org_s = tcg_temp_new();
-
-    /* d and s may refer to the same object.  */
-    tcg_gen_mov_tl(org_s, s);
-    tcg_gen_shli_tl(t, org_s, 8);
-    tcg_gen_andi_tl(d, t, 0xff00ff00);
-    tcg_gen_shri_tl(t, org_s, 8);
-    tcg_gen_andi_tl(t, t, 0x00ff00ff);
-    tcg_gen_or_tl(d, d, t);
-}
-
 /*
  * Reverse the bits within each byte.
  *
@@ -1666,7 +1648,7 @@  static int dec_swap_r(CPUCRISState *env, DisasContext *dc)
         tcg_gen_hswap_i32(t0, t0);
     }
     if (dc->op2 & 2) {
-        t_gen_swapb(t0, t0);
+        tcg_gen_hrev32_i32(t0, t0);
     }
     if (dc->op2 & 1) {
         t_gen_swapr(t0, t0);
diff --git a/target/cris/translate_v10.c.inc b/target/cris/translate_v10.c.inc
index 0ff15769ec..86cc5de8ad 100644
--- a/target/cris/translate_v10.c.inc
+++ b/target/cris/translate_v10.c.inc
@@ -508,7 +508,7 @@  static void dec10_reg_swap(DisasContext *dc)
     if (dc->dst & 4)
         tcg_gen_hswap_i32(t0, t0);
     if (dc->dst & 2)
-        t_gen_swapb(t0, t0);
+        tcg_gen_hrev32_i32(t0, t0);
     if (dc->dst & 1)
         t_gen_swapr(t0, t0);
     cris_alu(dc, CC_OP_MOVE, cpu_R[dc->src], cpu_R[dc->src], t0, 4);