diff mbox series

[4/4] target/ppc: Use tcg_constant_i32() in gen_ld/st()

Message ID 20211024161619.325903-5-f4bug@amsat.org
State Accepted, archived
Headers show
Series target/alpha,arm,ppc: More uses of tcg_constant() | expand

Commit Message

Philippe Mathieu-Daudé Oct. 24, 2021, 4:16 p.m. UTC
Avoid using a TCG temporary by moving the MemOp index
to the constant pool.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/ppc/translate.c | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

Comments

Richard Henderson Oct. 24, 2021, 9:27 p.m. UTC | #1
On 10/24/21 9:16 AM, Philippe Mathieu-Daudé wrote:
> Avoid using a TCG temporary by moving the MemOp index
> to the constant pool.
> 
> Signed-off-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
>   target/ppc/translate.c | 29 +++++++++++++----------------
>   1 file changed, 13 insertions(+), 16 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
David Gibson Oct. 25, 2021, 12:21 a.m. UTC | #2
On Sun, Oct 24, 2021 at 06:16:19PM +0200, Philippe Mathieu-Daudé wrote:
> Avoid using a TCG temporary by moving the MemOp index
> to the constant pool.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Acked-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  target/ppc/translate.c | 29 +++++++++++++----------------
>  1 file changed, 13 insertions(+), 16 deletions(-)
> 
> diff --git a/target/ppc/translate.c b/target/ppc/translate.c
> index 507f6699f47..9a4ae61a39d 100644
> --- a/target/ppc/translate.c
> +++ b/target/ppc/translate.c
> @@ -3347,15 +3347,14 @@ static void gen_lq(DisasContext *ctx)
>  
>      if (tb_cflags(ctx->base.tb) & CF_PARALLEL) {
>          if (HAVE_ATOMIC128) {
> -            TCGv_i32 oi = tcg_temp_new_i32();
> +            TCGv_i32 oi;
>              if (ctx->le_mode) {
> -                tcg_gen_movi_i32(oi, make_memop_idx(MO_LEQ, ctx->mem_idx));
> +                oi = tcg_constant_i32(make_memop_idx(MO_LEQ, ctx->mem_idx));
>                  gen_helper_lq_le_parallel(lo, cpu_env, EA, oi);
>              } else {
> -                tcg_gen_movi_i32(oi, make_memop_idx(MO_BEQ, ctx->mem_idx));
> +                oi = tcg_constant_i32(make_memop_idx(MO_BEQ, ctx->mem_idx));
>                  gen_helper_lq_be_parallel(lo, cpu_env, EA, oi);
>              }
> -            tcg_temp_free_i32(oi);
>              tcg_gen_ld_i64(hi, cpu_env, offsetof(CPUPPCState, retxh));
>          } else {
>              /* Restart with exclusive lock.  */
> @@ -3458,17 +3457,16 @@ static void gen_std(DisasContext *ctx)
>  
>          if (tb_cflags(ctx->base.tb) & CF_PARALLEL) {
>              if (HAVE_ATOMIC128) {
> -                TCGv_i32 oi = tcg_temp_new_i32();
> +                TCGv_i32 oi;
>                  if (ctx->le_mode) {
> -                    tcg_gen_movi_i32(oi, make_memop_idx(MO_LE | MO_128,
> -                                                        ctx->mem_idx));
> +                    oi = tcg_constant_i32(make_memop_idx(MO_LE | MO_128,
> +                                                         ctx->mem_idx));
>                      gen_helper_stq_le_parallel(cpu_env, EA, lo, hi, oi);
>                  } else {
> -                    tcg_gen_movi_i32(oi, make_memop_idx(MO_BE | MO_128,
> -                                                        ctx->mem_idx));
> +                    oi = tcg_constant_i32(make_memop_idx(MO_BE | MO_128,
> +                                                         ctx->mem_idx));
>                      gen_helper_stq_be_parallel(cpu_env, EA, lo, hi, oi);
>                  }
> -                tcg_temp_free_i32(oi);
>              } else {
>                  /* Restart with exclusive lock.  */
>                  gen_helper_exit_atomic(cpu_env);
> @@ -4065,17 +4063,16 @@ static void gen_lqarx(DisasContext *ctx)
>  
>      if (tb_cflags(ctx->base.tb) & CF_PARALLEL) {
>          if (HAVE_ATOMIC128) {
> -            TCGv_i32 oi = tcg_temp_new_i32();
> +            TCGv_i32 oi;
>              if (ctx->le_mode) {
> -                tcg_gen_movi_i32(oi, make_memop_idx(MO_LE | MO_128 | MO_ALIGN,
> -                                                    ctx->mem_idx));
> +                oi = tcg_constant_i32(make_memop_idx(MO_LE | MO_128 | MO_ALIGN,
> +                                                     ctx->mem_idx));
>                  gen_helper_lq_le_parallel(lo, cpu_env, EA, oi);
>              } else {
> -                tcg_gen_movi_i32(oi, make_memop_idx(MO_BE | MO_128 | MO_ALIGN,
> -                                                    ctx->mem_idx));
> +                oi = tcg_constant_i32(make_memop_idx(MO_BE | MO_128 | MO_ALIGN,
> +                                                     ctx->mem_idx));
>                  gen_helper_lq_be_parallel(lo, cpu_env, EA, oi);
>              }
> -            tcg_temp_free_i32(oi);
>              tcg_gen_ld_i64(hi, cpu_env, offsetof(CPUPPCState, retxh));
>          } else {
>              /* Restart with exclusive lock.  */
diff mbox series

Patch

diff --git a/target/ppc/translate.c b/target/ppc/translate.c
index 507f6699f47..9a4ae61a39d 100644
--- a/target/ppc/translate.c
+++ b/target/ppc/translate.c
@@ -3347,15 +3347,14 @@  static void gen_lq(DisasContext *ctx)
 
     if (tb_cflags(ctx->base.tb) & CF_PARALLEL) {
         if (HAVE_ATOMIC128) {
-            TCGv_i32 oi = tcg_temp_new_i32();
+            TCGv_i32 oi;
             if (ctx->le_mode) {
-                tcg_gen_movi_i32(oi, make_memop_idx(MO_LEQ, ctx->mem_idx));
+                oi = tcg_constant_i32(make_memop_idx(MO_LEQ, ctx->mem_idx));
                 gen_helper_lq_le_parallel(lo, cpu_env, EA, oi);
             } else {
-                tcg_gen_movi_i32(oi, make_memop_idx(MO_BEQ, ctx->mem_idx));
+                oi = tcg_constant_i32(make_memop_idx(MO_BEQ, ctx->mem_idx));
                 gen_helper_lq_be_parallel(lo, cpu_env, EA, oi);
             }
-            tcg_temp_free_i32(oi);
             tcg_gen_ld_i64(hi, cpu_env, offsetof(CPUPPCState, retxh));
         } else {
             /* Restart with exclusive lock.  */
@@ -3458,17 +3457,16 @@  static void gen_std(DisasContext *ctx)
 
         if (tb_cflags(ctx->base.tb) & CF_PARALLEL) {
             if (HAVE_ATOMIC128) {
-                TCGv_i32 oi = tcg_temp_new_i32();
+                TCGv_i32 oi;
                 if (ctx->le_mode) {
-                    tcg_gen_movi_i32(oi, make_memop_idx(MO_LE | MO_128,
-                                                        ctx->mem_idx));
+                    oi = tcg_constant_i32(make_memop_idx(MO_LE | MO_128,
+                                                         ctx->mem_idx));
                     gen_helper_stq_le_parallel(cpu_env, EA, lo, hi, oi);
                 } else {
-                    tcg_gen_movi_i32(oi, make_memop_idx(MO_BE | MO_128,
-                                                        ctx->mem_idx));
+                    oi = tcg_constant_i32(make_memop_idx(MO_BE | MO_128,
+                                                         ctx->mem_idx));
                     gen_helper_stq_be_parallel(cpu_env, EA, lo, hi, oi);
                 }
-                tcg_temp_free_i32(oi);
             } else {
                 /* Restart with exclusive lock.  */
                 gen_helper_exit_atomic(cpu_env);
@@ -4065,17 +4063,16 @@  static void gen_lqarx(DisasContext *ctx)
 
     if (tb_cflags(ctx->base.tb) & CF_PARALLEL) {
         if (HAVE_ATOMIC128) {
-            TCGv_i32 oi = tcg_temp_new_i32();
+            TCGv_i32 oi;
             if (ctx->le_mode) {
-                tcg_gen_movi_i32(oi, make_memop_idx(MO_LE | MO_128 | MO_ALIGN,
-                                                    ctx->mem_idx));
+                oi = tcg_constant_i32(make_memop_idx(MO_LE | MO_128 | MO_ALIGN,
+                                                     ctx->mem_idx));
                 gen_helper_lq_le_parallel(lo, cpu_env, EA, oi);
             } else {
-                tcg_gen_movi_i32(oi, make_memop_idx(MO_BE | MO_128 | MO_ALIGN,
-                                                    ctx->mem_idx));
+                oi = tcg_constant_i32(make_memop_idx(MO_BE | MO_128 | MO_ALIGN,
+                                                     ctx->mem_idx));
                 gen_helper_lq_be_parallel(lo, cpu_env, EA, oi);
             }
-            tcg_temp_free_i32(oi);
             tcg_gen_ld_i64(hi, cpu_env, offsetof(CPUPPCState, retxh));
         } else {
             /* Restart with exclusive lock.  */