target/cris: Remove dc->flagx_known

Ever since 2a44f7f173, flagx_known is always true.
Fold away all of the tests against the flag.

Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Tested-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2021-06-22 08:18:12 -07:00
parent 3a1a80cc05
commit 0ce97a315f
2 changed files with 24 additions and 81 deletions

View File

@ -120,8 +120,6 @@ typedef struct DisasContext {
int cc_x_uptodate; /* 1 - ccs, 2 - known | X_FLAG. 0 not up-to-date. */ int cc_x_uptodate; /* 1 - ccs, 2 - known | X_FLAG. 0 not up-to-date. */
int flags_uptodate; /* Whether or not $ccs is up-to-date. */ int flags_uptodate; /* Whether or not $ccs is up-to-date. */
int flagx_known; /* Whether or not flags_x has the x flag known at
translation time. */
int flags_x; int flags_x;
int clear_x; /* Clear x after this insn? */ int clear_x; /* Clear x after this insn? */
@ -377,68 +375,28 @@ static inline void t_gen_add_flag(TCGv d, int flag)
static inline void t_gen_addx_carry(DisasContext *dc, TCGv d) static inline void t_gen_addx_carry(DisasContext *dc, TCGv d)
{ {
if (dc->flagx_known) {
if (dc->flags_x) { if (dc->flags_x) {
TCGv c; TCGv c = tcg_temp_new();
c = tcg_temp_new();
t_gen_mov_TN_preg(c, PR_CCS); t_gen_mov_TN_preg(c, PR_CCS);
/* C flag is already at bit 0. */ /* C flag is already at bit 0. */
tcg_gen_andi_tl(c, c, C_FLAG); tcg_gen_andi_tl(c, c, C_FLAG);
tcg_gen_add_tl(d, d, c); tcg_gen_add_tl(d, d, c);
tcg_temp_free(c); tcg_temp_free(c);
} }
} else {
TCGv x, c;
x = tcg_temp_new();
c = tcg_temp_new();
t_gen_mov_TN_preg(x, PR_CCS);
tcg_gen_mov_tl(c, x);
/* Propagate carry into d if X is set. Branch free. */
tcg_gen_andi_tl(c, c, C_FLAG);
tcg_gen_andi_tl(x, x, X_FLAG);
tcg_gen_shri_tl(x, x, 4);
tcg_gen_and_tl(x, x, c);
tcg_gen_add_tl(d, d, x);
tcg_temp_free(x);
tcg_temp_free(c);
}
} }
static inline void t_gen_subx_carry(DisasContext *dc, TCGv d) static inline void t_gen_subx_carry(DisasContext *dc, TCGv d)
{ {
if (dc->flagx_known) {
if (dc->flags_x) { if (dc->flags_x) {
TCGv c; TCGv c = tcg_temp_new();
c = tcg_temp_new();
t_gen_mov_TN_preg(c, PR_CCS); t_gen_mov_TN_preg(c, PR_CCS);
/* C flag is already at bit 0. */ /* C flag is already at bit 0. */
tcg_gen_andi_tl(c, c, C_FLAG); tcg_gen_andi_tl(c, c, C_FLAG);
tcg_gen_sub_tl(d, d, c); tcg_gen_sub_tl(d, d, c);
tcg_temp_free(c); tcg_temp_free(c);
} }
} else {
TCGv x, c;
x = tcg_temp_new();
c = tcg_temp_new();
t_gen_mov_TN_preg(x, PR_CCS);
tcg_gen_mov_tl(c, x);
/* Propagate carry into d if X is set. Branch free. */
tcg_gen_andi_tl(c, c, C_FLAG);
tcg_gen_andi_tl(x, x, X_FLAG);
tcg_gen_shri_tl(x, x, 4);
tcg_gen_and_tl(x, x, c);
tcg_gen_sub_tl(d, d, x);
tcg_temp_free(x);
tcg_temp_free(c);
}
} }
/* Swap the two bytes within each half word of the s operand. /* Swap the two bytes within each half word of the s operand.
@ -541,11 +499,9 @@ static void gen_goto_tb(DisasContext *dc, int n, target_ulong dest)
static inline void cris_clear_x_flag(DisasContext *dc) static inline void cris_clear_x_flag(DisasContext *dc)
{ {
if (dc->flagx_known && dc->flags_x) { if (dc->flags_x) {
dc->flags_uptodate = 0; dc->flags_uptodate = 0;
} }
dc->flagx_known = 1;
dc->flags_x = 0; dc->flags_x = 0;
} }
@ -630,13 +586,11 @@ static void cris_evaluate_flags(DisasContext *dc)
break; break;
} }
if (dc->flagx_known) {
if (dc->flags_x) { if (dc->flags_x) {
tcg_gen_ori_tl(cpu_PR[PR_CCS], cpu_PR[PR_CCS], X_FLAG); tcg_gen_ori_tl(cpu_PR[PR_CCS], cpu_PR[PR_CCS], X_FLAG);
} else if (dc->cc_op == CC_OP_FLAGS) { } else if (dc->cc_op == CC_OP_FLAGS) {
tcg_gen_andi_tl(cpu_PR[PR_CCS], cpu_PR[PR_CCS], ~X_FLAG); tcg_gen_andi_tl(cpu_PR[PR_CCS], cpu_PR[PR_CCS], ~X_FLAG);
} }
}
dc->flags_uptodate = 1; dc->flags_uptodate = 1;
} }
@ -670,16 +624,11 @@ static void cris_update_cc_op(DisasContext *dc, int op, int size)
static inline void cris_update_cc_x(DisasContext *dc) static inline void cris_update_cc_x(DisasContext *dc)
{ {
/* Save the x flag state at the time of the cc snapshot. */ /* Save the x flag state at the time of the cc snapshot. */
if (dc->flagx_known) {
if (dc->cc_x_uptodate == (2 | dc->flags_x)) { if (dc->cc_x_uptodate == (2 | dc->flags_x)) {
return; return;
} }
tcg_gen_movi_tl(cc_x, dc->flags_x); tcg_gen_movi_tl(cc_x, dc->flags_x);
dc->cc_x_uptodate = 2 | dc->flags_x; dc->cc_x_uptodate = 2 | dc->flags_x;
} else {
tcg_gen_andi_tl(cc_x, cpu_PR[PR_CCS], X_FLAG);
dc->cc_x_uptodate = 1;
}
} }
/* Update cc prior to executing ALU op. Needs source operands untouched. */ /* Update cc prior to executing ALU op. Needs source operands untouched. */
@ -1131,7 +1080,7 @@ static void gen_store (DisasContext *dc, TCGv addr, TCGv val,
/* Conditional writes. We only support the kind were X and P are known /* Conditional writes. We only support the kind were X and P are known
at translation time. */ at translation time. */
if (dc->flagx_known && dc->flags_x && (dc->tb_flags & P_FLAG)) { if (dc->flags_x && (dc->tb_flags & P_FLAG)) {
dc->postinc = 0; dc->postinc = 0;
cris_evaluate_flags(dc); cris_evaluate_flags(dc);
tcg_gen_ori_tl(cpu_PR[PR_CCS], cpu_PR[PR_CCS], C_FLAG); tcg_gen_ori_tl(cpu_PR[PR_CCS], cpu_PR[PR_CCS], C_FLAG);
@ -1140,7 +1089,7 @@ static void gen_store (DisasContext *dc, TCGv addr, TCGv val,
tcg_gen_qemu_st_tl(val, addr, mem_index, MO_TE + ctz32(size)); tcg_gen_qemu_st_tl(val, addr, mem_index, MO_TE + ctz32(size));
if (dc->flagx_known && dc->flags_x) { if (dc->flags_x) {
cris_evaluate_flags(dc); cris_evaluate_flags(dc);
tcg_gen_andi_tl(cpu_PR[PR_CCS], cpu_PR[PR_CCS], ~C_FLAG); tcg_gen_andi_tl(cpu_PR[PR_CCS], cpu_PR[PR_CCS], ~C_FLAG);
} }
@ -1727,8 +1676,8 @@ static int dec_addc_r(CPUCRISState *env, DisasContext *dc)
LOG_DIS("addc $r%u, $r%u\n", LOG_DIS("addc $r%u, $r%u\n",
dc->op1, dc->op2); dc->op1, dc->op2);
cris_evaluate_flags(dc); cris_evaluate_flags(dc);
/* Set for this insn. */ /* Set for this insn. */
dc->flagx_known = 1;
dc->flags_x = X_FLAG; dc->flags_x = X_FLAG;
cris_cc_mask(dc, CC_MASK_NZVC); cris_cc_mask(dc, CC_MASK_NZVC);
@ -2015,7 +1964,6 @@ static int dec_setclrf(CPUCRISState *env, DisasContext *dc)
} }
if (flags & X_FLAG) { if (flags & X_FLAG) {
dc->flagx_known = 1;
if (set) { if (set) {
dc->flags_x = X_FLAG; dc->flags_x = X_FLAG;
} else { } else {
@ -2479,7 +2427,6 @@ static int dec_addc_mr(CPUCRISState *env, DisasContext *dc)
cris_evaluate_flags(dc); cris_evaluate_flags(dc);
/* Set for this insn. */ /* Set for this insn. */
dc->flagx_known = 1;
dc->flags_x = X_FLAG; dc->flags_x = X_FLAG;
cris_alu_m_alloc_temps(t); cris_alu_m_alloc_temps(t);
@ -3141,7 +3088,6 @@ static void cris_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
dc->ppc = pc_start; dc->ppc = pc_start;
dc->pc = pc_start; dc->pc = pc_start;
dc->flags_uptodate = 1; dc->flags_uptodate = 1;
dc->flagx_known = 1;
dc->flags_x = tb_flags & X_FLAG; dc->flags_x = tb_flags & X_FLAG;
dc->cc_x_uptodate = 0; dc->cc_x_uptodate = 0;
dc->cc_mask = 0; dc->cc_mask = 0;
@ -3217,7 +3163,6 @@ static void cris_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
} }
/* Fold unhandled changes to X_FLAG into cpustate_changed. */ /* Fold unhandled changes to X_FLAG into cpustate_changed. */
dc->cpustate_changed |= !dc->flagx_known;
dc->cpustate_changed |= dc->flags_x != (dc->base.tb->flags & X_FLAG); dc->cpustate_changed |= dc->flags_x != (dc->base.tb->flags & X_FLAG);
/* /*

View File

@ -106,9 +106,8 @@ static void gen_store_v10(DisasContext *dc, TCGv addr, TCGv val,
cris_store_direct_jmp(dc); cris_store_direct_jmp(dc);
} }
/* Conditional writes. We only support the kind were X is known /* Conditional writes. */
at translation time. */ if (dc->flags_x) {
if (dc->flagx_known && dc->flags_x) {
gen_store_v10_conditional(dc, addr, val, size, mem_index); gen_store_v10_conditional(dc, addr, val, size, mem_index);
return; return;
} }
@ -376,7 +375,6 @@ static unsigned int dec10_setclrf(DisasContext *dc)
if (flags & X_FLAG) { if (flags & X_FLAG) {
dc->flagx_known = 1;
if (set) if (set)
dc->flags_x = X_FLAG; dc->flags_x = X_FLAG;
else else