diff --git a/target/e2k/translate.c b/target/e2k/translate.c index c92e2c6f4e..0d341543c4 100644 --- a/target/e2k/translate.c +++ b/target/e2k/translate.c @@ -270,20 +270,10 @@ static inline target_ulong do_decode(DisasContext *ctx, CPUState *cs) */ static inline void do_execute(DisasContext *ctx) { - unsigned int i; - - e2k_plu_execute(ctx); - e2k_control_gen(ctx); - - for (i = 0; i < 6; i++) { - ctx->al_results[i].type = AL_RESULT_NONE; - - if (ctx->bundle.als_present[i]) { - e2k_alc_execute(ctx, i); - } - } - + e2k_control_execute(ctx); + e2k_alc_execute(ctx); e2k_aau_execute(ctx); + e2k_plu_execute(ctx); } /* @@ -299,7 +289,7 @@ static inline void do_commit(DisasContext *ctx) e2k_alc_commit(ctx); e2k_aau_commit(ctx); e2k_plu_commit(ctx); - e2k_commit_stubs(ctx); + e2k_stubs_commit(ctx); } static inline void do_branch(DisasContext *ctx, target_ulong pc_next) diff --git a/target/e2k/translate.h b/target/e2k/translate.h index 3a24fc32d1..564b91fc77 100644 --- a/target/e2k/translate.h +++ b/target/e2k/translate.h @@ -406,17 +406,15 @@ static inline void e2k_gen_cond_i64(DisasContext *ctx, TCGv_i64 ret, tcg_temp_free_i32(t0); } -void e2k_control_gen(DisasContext *dc); +void e2k_control_execute(DisasContext *ctx); +void e2k_stubs_commit(DisasContext *ctx); -void e2k_alc_execute(DisasContext *ctx, int index); -void e2k_alc_commit(DisasContext *dc); +void e2k_alc_execute(DisasContext *ctx); +void e2k_alc_commit(DisasContext *ctx); void e2k_aau_execute(DisasContext *ctx); void e2k_aau_commit(DisasContext *ctx); - void e2k_plu_execute(DisasContext *ctx); void e2k_plu_commit(DisasContext *ctx); -void e2k_commit_stubs(DisasContext *dc); - #endif diff --git a/target/e2k/translate/alc.c b/target/e2k/translate/alc.c index 5415dc9832..11c8a3baa6 100644 --- a/target/e2k/translate/alc.c +++ b/target/e2k/translate/alc.c @@ -2293,7 +2293,7 @@ static void execute_ext_0f(DisasContext *ctx, Instr *instr) e2k_tr_gen_exception(ctx, E2K_EXCP_ILLOPC); } -void e2k_alc_execute(DisasContext *ctx, int chan) +static void chan_execute(DisasContext *ctx, int chan) { const UnpackedBundle *bundle = &ctx->bundle; uint16_t rlp = find_cond(ctx, chan); @@ -2354,6 +2354,19 @@ void e2k_alc_execute(DisasContext *ctx, int chan) ctx->al_cond[chan].value = cond; } +void e2k_alc_execute(DisasContext *ctx) +{ + unsigned int i; + + for (i = 0; i < 6; i++) { + ctx->al_results[i].type = AL_RESULT_NONE; + + if (ctx->bundle.als_present[i]) { + chan_execute(ctx, i); + } + } +} + void e2k_alc_commit(DisasContext *ctx) { unsigned int i; diff --git a/target/e2k/translate/control.c b/target/e2k/translate/control.c index f9fc97d81c..93a7d609ea 100644 --- a/target/e2k/translate/control.c +++ b/target/e2k/translate/control.c @@ -124,7 +124,7 @@ static inline void gen_cur_dec(DisasContext *ctx, TCGv_i32 ret, int cond, tcg_temp_free_i32(t0); } -void e2k_commit_stubs(DisasContext *ctx) +void e2k_stubs_commit(DisasContext *ctx) { uint32_t ss = ctx->bundle.ss; // unsigned int vfdi = (ss & 0x04000000) >> 26; @@ -143,7 +143,10 @@ void e2k_commit_stubs(DisasContext *ctx) } if (abp) { - gen_cur_dec(ctx, e2k_cs.pcur, abp, e2k_cs.pcur, 1, e2k_cs.psize); + TCGv_i32 t0 = tcg_temp_local_new_i32(); + tcg_gen_addi_i32(t0, e2k_cs.psize, 1); + gen_cur_dec(ctx, e2k_cs.pcur, abp, e2k_cs.pcur, 1, t0); + tcg_temp_free_i32(t0); } if (abn) { @@ -617,7 +620,7 @@ static void gen_jmp(DisasContext *dc) } } -void e2k_control_gen(DisasContext *dc) +void e2k_control_execute(DisasContext *dc) { dc->ct.type = CT_NONE; diff --git a/target/e2k/translate/state.c b/target/e2k/translate/state.c index 64f249a01f..ee1dc81d41 100644 --- a/target/e2k/translate/state.c +++ b/target/e2k/translate/state.c @@ -3,30 +3,40 @@ #include "exec/log.h" #include "translate.h" -static void gen_preg_offset(TCGv_i64 ret, int reg) +static inline void gen_preg_index(TCGv_i32 ret, int idx) { - assert(reg < 32); - - TCGv_i32 zero = tcg_const_i32(0); - TCGv_i32 pf_size = tcg_const_i32(E2K_PR_COUNT); + TCGv_i32 i = tcg_const_i32(idx); TCGv_i32 t0 = tcg_temp_new_i32(); TCGv_i32 t1 = tcg_temp_new_i32(); TCGv_i32 t2 = tcg_temp_new_i32(); TCGv_i32 t3 = tcg_temp_new_i32(); - tcg_gen_addi_i32(t0, e2k_cs.pcur, reg); - tcg_gen_movcond_i32(TCG_COND_NE, t1, e2k_cs.psize, zero, - e2k_cs.psize, pf_size); - tcg_gen_remu_i32(t2, t0, t1); - tcg_gen_muli_i32(t3, t2, 2); - tcg_gen_extu_i32_i64(ret, t3); + assert(idx < 32); + + tcg_gen_addi_i32(t0, e2k_cs.psize, 1); + tcg_gen_addi_i32(t1, e2k_cs.pcur, idx); + tcg_gen_remu_i32(t2, t1, t0); + tcg_gen_movi_i32(t3, idx); + tcg_gen_movcond_i32(TCG_COND_LEU, ret, i, e2k_cs.psize, t2, t3); tcg_temp_free_i32(t3); tcg_temp_free_i32(t2); tcg_temp_free_i32(t1); tcg_temp_free_i32(t0); - tcg_temp_free_i32(pf_size); - tcg_temp_free_i32(zero); + tcg_temp_free_i32(i); +} + +static void gen_preg_offset(TCGv_i64 ret, int idx) +{ + TCGv_i32 t0 = tcg_temp_new_i32(); + TCGv_i32 t1 = tcg_temp_new_i32(); + + gen_preg_index(t0, idx); + tcg_gen_muli_i32(t1, t0, 2); + tcg_gen_extu_i32_i64(ret, t1); + + tcg_temp_free_i32(t1); + tcg_temp_free_i32(t0); } static void gen_preg_clear(TCGv_i64 ret, TCGv_i64 offset)