[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/2] target/hppa: Clean up DisasCond
From: |
Richard Henderson |
Subject: |
[PATCH 2/2] target/hppa: Clean up DisasCond |
Date: |
Thu, 8 Jul 2021 13:58:07 -0700 |
The a0_is_n flag is redundant with comparing a0 to cpu_psw_n.
The a1_is_0 flag can be removed by initializing a1 to $0,
which also means that cond_prep can be removed entirely.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/hppa/translate.c | 43 +++++++++--------------------------------
1 file changed, 9 insertions(+), 34 deletions(-)
diff --git a/target/hppa/translate.c b/target/hppa/translate.c
index d17568880f..fcb814735f 100644
--- a/target/hppa/translate.c
+++ b/target/hppa/translate.c
@@ -253,8 +253,6 @@
typedef struct DisasCond {
TCGCond c;
TCGv_reg a0, a1;
- bool a0_is_n;
- bool a1_is_0;
} DisasCond;
typedef struct DisasContext {
@@ -449,9 +447,7 @@ static DisasCond cond_make_n(void)
return (DisasCond){
.c = TCG_COND_NE,
.a0 = cpu_psw_n,
- .a0_is_n = true,
- .a1 = NULL,
- .a1_is_0 = true
+ .a1 = tcg_constant_reg(0)
};
}
@@ -459,7 +455,7 @@ static DisasCond cond_make_0_tmp(TCGCond c, TCGv_reg a0)
{
assert (c != TCG_COND_NEVER && c != TCG_COND_ALWAYS);
return (DisasCond){
- .c = c, .a0 = a0, .a1_is_0 = true
+ .c = c, .a0 = a0, .a1 = tcg_constant_reg(0)
};
}
@@ -483,26 +479,14 @@ static DisasCond cond_make(TCGCond c, TCGv_reg a0,
TCGv_reg a1)
return r;
}
-static void cond_prep(DisasCond *cond)
-{
- if (cond->a1_is_0) {
- cond->a1_is_0 = false;
- cond->a1 = tcg_const_reg(0);
- }
-}
-
static void cond_free(DisasCond *cond)
{
switch (cond->c) {
default:
- if (!cond->a0_is_n) {
+ if (cond->a0 != cpu_psw_n) {
tcg_temp_free(cond->a0);
}
- if (!cond->a1_is_0) {
- tcg_temp_free(cond->a1);
- }
- cond->a0_is_n = false;
- cond->a1_is_0 = false;
+ tcg_temp_free(cond->a1);
cond->a0 = NULL;
cond->a1 = NULL;
/* fallthru */
@@ -560,9 +544,8 @@ static TCGv_reg dest_gpr(DisasContext *ctx, unsigned reg)
static void save_or_nullify(DisasContext *ctx, TCGv_reg dest, TCGv_reg t)
{
if (ctx->null_cond.c != TCG_COND_NEVER) {
- cond_prep(&ctx->null_cond);
tcg_gen_movcond_reg(ctx->null_cond.c, dest, ctx->null_cond.a0,
- ctx->null_cond.a1, dest, t);
+ ctx->null_cond.a1, dest, t);
} else {
tcg_gen_mov_reg(dest, t);
}
@@ -669,11 +652,9 @@ static void nullify_over(DisasContext *ctx)
assert(ctx->null_cond.c != TCG_COND_ALWAYS);
ctx->null_lab = gen_new_label();
- cond_prep(&ctx->null_cond);
/* If we're using PSW[N], copy it to a temp because... */
- if (ctx->null_cond.a0_is_n) {
- ctx->null_cond.a0_is_n = false;
+ if (ctx->null_cond.a0 == cpu_psw_n) {
ctx->null_cond.a0 = tcg_temp_new();
tcg_gen_mov_reg(ctx->null_cond.a0, cpu_psw_n);
}
@@ -686,7 +667,7 @@ static void nullify_over(DisasContext *ctx)
}
tcg_gen_brcond_reg(ctx->null_cond.c, ctx->null_cond.a0,
- ctx->null_cond.a1, ctx->null_lab);
+ ctx->null_cond.a1, ctx->null_lab);
cond_free(&ctx->null_cond);
}
}
@@ -700,10 +681,9 @@ static void nullify_save(DisasContext *ctx)
}
return;
}
- if (!ctx->null_cond.a0_is_n) {
- cond_prep(&ctx->null_cond);
+ if (ctx->null_cond.a0 != cpu_psw_n) {
tcg_gen_setcond_reg(ctx->null_cond.c, cpu_psw_n,
- ctx->null_cond.a0, ctx->null_cond.a1);
+ ctx->null_cond.a0, ctx->null_cond.a1);
ctx->psw_n_nonzero = true;
}
cond_free(&ctx->null_cond);
@@ -1182,7 +1162,6 @@ static void do_add(DisasContext *ctx, unsigned rt,
TCGv_reg in1,
/* Emit any conditional trap before any writeback. */
cond = do_cond(cf, dest, cb_msb, sv);
if (is_tc) {
- cond_prep(&cond);
tmp = tcg_temp_new();
tcg_gen_setcond_reg(cond.c, tmp, cond.a0, cond.a1);
gen_helper_tcond(cpu_env, tmp);
@@ -1277,7 +1256,6 @@ static void do_sub(DisasContext *ctx, unsigned rt,
TCGv_reg in1,
/* Emit any conditional trap before any writeback. */
if (is_tc) {
- cond_prep(&cond);
tmp = tcg_temp_new();
tcg_gen_setcond_reg(cond.c, tmp, cond.a0, cond.a1);
gen_helper_tcond(cpu_env, tmp);
@@ -1403,7 +1381,6 @@ static void do_unit(DisasContext *ctx, unsigned rt,
TCGv_reg in1,
if (is_tc) {
TCGv_reg tmp = tcg_temp_new();
- cond_prep(&cond);
tcg_gen_setcond_reg(cond.c, tmp, cond.a0, cond.a1);
gen_helper_tcond(cpu_env, tmp);
tcg_temp_free(tmp);
@@ -1859,7 +1836,6 @@ static bool do_cbranch(DisasContext *ctx, target_sreg
disp, bool is_n,
}
taken = gen_new_label();
- cond_prep(cond);
tcg_gen_brcond_reg(c, cond->a0, cond->a1, taken);
cond_free(cond);
@@ -1956,7 +1932,6 @@ static bool do_ibranch(DisasContext *ctx, TCGv_reg dest,
tcg_gen_lookup_and_goto_ptr();
return nullify_end(ctx);
} else {
- cond_prep(&ctx->null_cond);
c = ctx->null_cond.c;
a0 = ctx->null_cond.a0;
a1 = ctx->null_cond.a1;
--
2.25.1