Re: [PATCH v2 27/45] target/hppa: Remove cond_free

2024-05-14 Thread Helge Deller
* Richard Henderson :
> Now that we do not need to free tcg temporaries, the only
> thing cond_free does is reset the condition to never.
> Instead, simply write a new condition over the old, which
> may be simply cond_make_f() for the never condition.
> 
> The do_*_cond functions do the right thing with c or cf == 0,
> so there's no need for a special case anymore.
> 
> Signed-off-by: Richard Henderson 
> ---
>  target/hppa/translate.c | 102 +++-
>  1 file changed, 27 insertions(+), 75 deletions(-)

Reviewed-by: Helge Deller 



Re: [PATCH v2 27/45] target/hppa: Remove cond_free

2024-05-13 Thread Philippe Mathieu-Daudé

On 13/5/24 09:46, Richard Henderson wrote:

Now that we do not need to free tcg temporaries, the only
thing cond_free does is reset the condition to never.
Instead, simply write a new condition over the old, which
may be simply cond_make_f() for the never condition.

The do_*_cond functions do the right thing with c or cf == 0,
so there's no need for a special case anymore.

Signed-off-by: Richard Henderson 
---
  target/hppa/translate.c | 102 +++-
  1 file changed, 27 insertions(+), 75 deletions(-)


Reviewed-by: Philippe Mathieu-Daudé 




[PATCH v2 27/45] target/hppa: Remove cond_free

2024-05-13 Thread Richard Henderson
Now that we do not need to free tcg temporaries, the only
thing cond_free does is reset the condition to never.
Instead, simply write a new condition over the old, which
may be simply cond_make_f() for the never condition.

The do_*_cond functions do the right thing with c or cf == 0,
so there's no need for a special case anymore.

Signed-off-by: Richard Henderson 
---
 target/hppa/translate.c | 102 +++-
 1 file changed, 27 insertions(+), 75 deletions(-)

diff --git a/target/hppa/translate.c b/target/hppa/translate.c
index ef62cd7e94..e06c14dd15 100644
--- a/target/hppa/translate.c
+++ b/target/hppa/translate.c
@@ -373,21 +373,6 @@ static DisasCond cond_make_vv(TCGCond c, TCGv_i64 a0, 
TCGv_i64 a1)
 return cond_make_tt(c, t0, t1);
 }
 
-static void cond_free(DisasCond *cond)
-{
-switch (cond->c) {
-default:
-cond->a0 = NULL;
-cond->a1 = NULL;
-/* fallthru */
-case TCG_COND_ALWAYS:
-cond->c = TCG_COND_NEVER;
-break;
-case TCG_COND_NEVER:
-break;
-}
-}
-
 static TCGv_i64 load_gpr(DisasContext *ctx, unsigned reg)
 {
 if (reg == 0) {
@@ -537,7 +522,7 @@ static void nullify_over(DisasContext *ctx)
 
 tcg_gen_brcond_i64(ctx->null_cond.c, ctx->null_cond.a0,
ctx->null_cond.a1, ctx->null_lab);
-cond_free(>null_cond);
+ctx->null_cond = cond_make_f();
 }
 }
 
@@ -555,7 +540,7 @@ static void nullify_save(DisasContext *ctx)
 ctx->null_cond.a0, ctx->null_cond.a1);
 ctx->psw_n_nonzero = true;
 }
-cond_free(>null_cond);
+ctx->null_cond = cond_make_f();
 }
 
 /* Set a PSW[N] to X.  The intention is that this is used immediately
@@ -1165,7 +1150,6 @@ static void do_add(DisasContext *ctx, unsigned rt, 
TCGv_i64 orig_in1,
 save_gpr(ctx, rt, dest);
 
 /* Install the new nullification.  */
-cond_free(>null_cond);
 ctx->null_cond = cond;
 }
 
@@ -1262,7 +1246,6 @@ static void do_sub(DisasContext *ctx, unsigned rt, 
TCGv_i64 in1,
 save_gpr(ctx, rt, dest);
 
 /* Install the new nullification.  */
-cond_free(>null_cond);
 ctx->null_cond = cond;
 }
 
@@ -1317,7 +1300,6 @@ static void do_cmpclr(DisasContext *ctx, unsigned rt, 
TCGv_i64 in1,
 save_gpr(ctx, rt, dest);
 
 /* Install the new nullification.  */
-cond_free(>null_cond);
 ctx->null_cond = cond;
 }
 
@@ -1332,10 +1314,7 @@ static void do_log(DisasContext *ctx, unsigned rt, 
TCGv_i64 in1,
 save_gpr(ctx, rt, dest);
 
 /* Install the new nullification.  */
-cond_free(>null_cond);
-if (cf) {
-ctx->null_cond = do_log_cond(ctx, cf, d, dest);
-}
+ctx->null_cond = do_log_cond(ctx, cf, d, dest);
 }
 
 static bool do_log_reg(DisasContext *ctx, arg_rrr_cf_d *a,
@@ -1430,7 +1409,6 @@ static void do_unit_addsub(DisasContext *ctx, unsigned 
rt, TCGv_i64 in1,
 }
 save_gpr(ctx, rt, dest);
 
-cond_free(>null_cond);
 ctx->null_cond = cond;
 }
 
@@ -1853,7 +1831,6 @@ static bool do_cbranch(DisasContext *ctx, int64_t disp, 
bool is_n,
 
 taken = gen_new_label();
 tcg_gen_brcond_i64(c, cond->a0, cond->a1, taken);
-cond_free(cond);
 
 /* Not taken: Condition not satisfied; nullify on backward branches. */
 n = is_n && disp < 0;
@@ -2035,7 +2012,7 @@ static void do_page_zero(DisasContext *ctx)
 
 static bool trans_nop(DisasContext *ctx, arg_nop *a)
 {
-cond_free(>null_cond);
+ctx->null_cond = cond_make_f();
 return true;
 }
 
@@ -2049,7 +2026,7 @@ static bool trans_sync(DisasContext *ctx, arg_sync *a)
 /* No point in nullifying the memory barrier.  */
 tcg_gen_mb(TCG_BAR_SC | TCG_MO_ALL);
 
-cond_free(>null_cond);
+ctx->null_cond = cond_make_f();
 return true;
 }
 
@@ -2061,7 +2038,7 @@ static bool trans_mfia(DisasContext *ctx, arg_mfia *a)
 tcg_gen_andi_i64(dest, dest, -4);
 
 save_gpr(ctx, a->t, dest);
-cond_free(>null_cond);
+ctx->null_cond = cond_make_f();
 return true;
 }
 
@@ -2076,7 +2053,7 @@ static bool trans_mfsp(DisasContext *ctx, arg_mfsp *a)
 
 save_gpr(ctx, rt, t0);
 
-cond_free(>null_cond);
+ctx->null_cond = cond_make_f();
 return true;
 }
 
@@ -2121,7 +2098,7 @@ static bool trans_mfctl(DisasContext *ctx, arg_mfctl *a)
 save_gpr(ctx, rt, tmp);
 
  done:
-cond_free(>null_cond);
+ctx->null_cond = cond_make_f();
 return true;
 }
 
@@ -2161,7 +2138,7 @@ static bool trans_mtctl(DisasContext *ctx, arg_mtctl *a)
 tcg_gen_andi_i64(tmp, reg, ctx->is_pa20 ? 63 : 31);
 save_or_nullify(ctx, cpu_sar, tmp);
 
-cond_free(>null_cond);
+ctx->null_cond = cond_make_f();
 return true;
 }
 
@@ -2235,7 +2212,7 @@ static bool trans_mtsarcm(DisasContext *ctx, arg_mtsarcm 
*a)
 tcg_gen_andi_i64(tmp, tmp, ctx->is_pa20 ? 63 : 31);
 save_or_nullify(ctx, cpu_sar, tmp);
 
-cond_free(>null_cond);
+ctx->null_cond = cond_make_f();
 return true;