>From 7be2c4dfcbdca59f6b5b52f65f3fc1df6923db50 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Wed, 12 Jun 2019 09:31:14 -0700 Subject: [PATCH] !fixup target/avr: Add instruction translation When skipping, the skipped NORETURN must chain to the next. Avoid double-allocating goto_tb indexes. Choose index 1 to be the end of TB, which means all other branches use 0. --- target/avr/translate.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/target/avr/translate.c b/target/avr/translate.c index 4d9e2afa26..abb838b53f 100644 --- a/target/avr/translate.c +++ b/target/avr/translate.c @@ -622,7 +622,7 @@ static bool trans_BRBC(DisasContext *ctx, arg_BRBC *a) } tcg_gen_brcondi_i32(tcg_invert_cond(cond), var, 0, not_taken); - gen_goto_tb(ctx, 1, ctx->npc + a->imm); + gen_goto_tb(ctx, 0, ctx->npc + a->imm); gen_set_label(not_taken); ctx->bstate = DISAS_CHAIN; @@ -672,7 +672,7 @@ static bool trans_BRBS(DisasContext *ctx, arg_BRBS *a) } tcg_gen_brcondi_i32(tcg_invert_cond(cond), var, 0, not_taken); - gen_goto_tb(ctx, 1, ctx->npc + a->imm); + gen_goto_tb(ctx, 0, ctx->npc + a->imm); gen_set_label(not_taken); ctx->bstate = DISAS_CHAIN; @@ -2855,6 +2855,9 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns) if (skip_label) { canonicalize_skip(&ctx); gen_set_label(skip_label); + if (ctx.bstate == DISAS_NORETURN) { + ctx.bstate = DISAS_CHAIN; + } } } while (ctx.bstate == DISAS_NEXT && num_insns < max_insns @@ -2876,7 +2879,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns) case DISAS_CHAIN: if (!nonconst_skip) { /* Note gen_goto_tb checks singlestep. */ - gen_goto_tb(&ctx, 0, ctx.npc); + gen_goto_tb(&ctx, 1, ctx.npc); break; } tcg_gen_movi_tl(cpu_pc, ctx.npc); -- 2.17.1