Message ID | 20210628220810.2919600-9-richard.henderson@linaro.org |
---|---|
State | New |
Headers | show |
Series | target/nios2: Convert to TranslatorOps | expand |
On Mon, 28 Jun 2021 at 23:13, Richard Henderson <richard.henderson@linaro.org> wrote: > > Move handle_instruction into nios2_tr_translate_insn > as the only caller. > > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > target/nios2/translate.c | 66 +++++++++++++++++++--------------------- > 1 file changed, 31 insertions(+), 35 deletions(-) Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Side note: I think we could replace all the handling of dc->zero by having load_gpr() return a tcg_constant_i32(0) for R_ZERO, which then never needs freeing. (We never try to write back to what we get from load_gpr().) thanks -- PMM
On 6/29/21 2:27 AM, Peter Maydell wrote: > On Mon, 28 Jun 2021 at 23:13, Richard Henderson > <richard.henderson@linaro.org> wrote: >> >> Move handle_instruction into nios2_tr_translate_insn >> as the only caller. >> >> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> >> --- >> target/nios2/translate.c | 66 +++++++++++++++++++--------------------- >> 1 file changed, 31 insertions(+), 35 deletions(-) > > Reviewed-by: Peter Maydell <peter.maydell@linaro.org> > > Side note: I think we could replace all the handling of dc->zero > by having load_gpr() return a tcg_constant_i32(0) for R_ZERO, > which then never needs freeing. (We never try to write back > to what we get from load_gpr().) Quite right. There are several targets that could benefit from that simplification. r~
On Tue, 29 Jun 2021 at 14:53, Richard Henderson <richard.henderson@linaro.org> wrote: > > On 6/29/21 2:27 AM, Peter Maydell wrote: > > On Mon, 28 Jun 2021 at 23:13, Richard Henderson > > <richard.henderson@linaro.org> wrote: > >> > >> Move handle_instruction into nios2_tr_translate_insn > >> as the only caller. > >> > >> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > >> --- > >> target/nios2/translate.c | 66 +++++++++++++++++++--------------------- > >> 1 file changed, 31 insertions(+), 35 deletions(-) > > > > Reviewed-by: Peter Maydell <peter.maydell@linaro.org> > > > > Side note: I think we could replace all the handling of dc->zero > > by having load_gpr() return a tcg_constant_i32(0) for R_ZERO, > > which then never needs freeing. (We never try to write back > > to what we get from load_gpr().) > > Quite right. There are several targets that could benefit from that simplification. I'm still hoping one day you'll get around to making tcg_temp_free_*() calls entirely unnecessary :-) -- PMM
diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 9e71267b42..abc7e5f96a 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -735,38 +735,6 @@ illegal_op: t_gen_helper_raise_exception(dc, EXCP_ILLEGAL); } -static void handle_instruction(DisasContext *dc, CPUNios2State *env) -{ - uint32_t code; - uint8_t op; - const Nios2Instruction *instr; - -#if defined(CONFIG_USER_ONLY) - /* FIXME: Is this needed ? */ - if (dc->pc >= 0x1000 && dc->pc < 0x2000) { - t_gen_helper_raise_exception(dc, 0xaa); - return; - } -#endif - - code = cpu_ldl_code(env, dc->pc); - op = get_opcode(code); - - if (unlikely(op >= ARRAY_SIZE(i_type_instructions))) { - t_gen_helper_raise_exception(dc, EXCP_ILLEGAL); - return; - } - - dc->zero = NULL; - - instr = &i_type_instructions[op]; - instr->handler(dc, code, instr->flags); - - if (dc->zero) { - tcg_temp_free(dc->zero); - } -} - static const char * const regnames[] = { "zero", "at", "r2", "r3", "r4", "r5", "r6", "r7", @@ -842,12 +810,40 @@ static void nios2_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) { DisasContext *dc = container_of(dcbase, DisasContext, base); CPUNios2State *env = cs->env_ptr; + const Nios2Instruction *instr; + uint32_t code, pc; + uint8_t op; - dc->pc = dc->base.pc_next; - dc->base.pc_next += 4; + pc = dc->base.pc_next; + dc->pc = pc; + dc->base.pc_next = pc + 4; /* Decode an instruction */ - handle_instruction(dc, env); + +#if defined(CONFIG_USER_ONLY) + /* FIXME: Is this needed ? */ + if (pc >= 0x1000 && pc < 0x2000) { + t_gen_helper_raise_exception(dc, 0xaa); + return; + } +#endif + + code = cpu_ldl_code(env, pc); + op = get_opcode(code); + + if (unlikely(op >= ARRAY_SIZE(i_type_instructions))) { + t_gen_helper_raise_exception(dc, EXCP_ILLEGAL); + return; + } + + dc->zero = NULL; + + instr = &i_type_instructions[op]; + instr->handler(dc, code, instr->flags); + + if (dc->zero) { + tcg_temp_free(dc->zero); + } } static void nios2_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs)
Move handle_instruction into nios2_tr_translate_insn as the only caller. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- target/nios2/translate.c | 66 +++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 35 deletions(-)