mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 17:23:56 -06:00
Hexagon (target/hexagon) Use direct block chaining for direct jump/branch
Direct block chaining is documented here https://qemu.readthedocs.io/en/latest/devel/tcg.html#direct-block-chaining Recall that Hexagon allows packets with multiple jumps where only the first one with a true predicate will actually jump. We can use tcg_gen_goto_tb/tcg_gen_exit_tb when the packet contains a single PC-relative branch or jump. If not, we use tcg_gen_lookup_and_goto_ptr. We add the following to DisasContext in order to delay the branching until the end of packet commit (in gen_end_tb) branch_cond The TCGCond condition under which the branch is taken When branch_cond == TCG_COND_NEVER, there isn't a single direct branch in this packet. When branch_cond != TCG_COND_ALWAYS, the value is in hex_branch_taken branch_dest The destination of the branch Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Taylor Simpson <tsimpson@quicinc.com> Message-Id: <20221108162906.3166-11-tsimpson@quicinc.com>
This commit is contained in:
parent
97b16faf82
commit
1b9a7f2a13
3 changed files with 46 additions and 2 deletions
|
@ -116,10 +116,41 @@ static void gen_exec_counters(DisasContext *ctx)
|
|||
hex_gpr[HEX_REG_QEMU_HVX_CNT], ctx->num_hvx_insns);
|
||||
}
|
||||
|
||||
static bool use_goto_tb(DisasContext *ctx, target_ulong dest)
|
||||
{
|
||||
return translator_use_goto_tb(&ctx->base, dest);
|
||||
}
|
||||
|
||||
static void gen_goto_tb(DisasContext *ctx, int idx, target_ulong dest)
|
||||
{
|
||||
if (use_goto_tb(ctx, dest)) {
|
||||
tcg_gen_goto_tb(idx);
|
||||
tcg_gen_movi_tl(hex_gpr[HEX_REG_PC], dest);
|
||||
tcg_gen_exit_tb(ctx->base.tb, idx);
|
||||
} else {
|
||||
tcg_gen_movi_tl(hex_gpr[HEX_REG_PC], dest);
|
||||
tcg_gen_lookup_and_goto_ptr();
|
||||
}
|
||||
}
|
||||
|
||||
static void gen_end_tb(DisasContext *ctx)
|
||||
{
|
||||
gen_exec_counters(ctx);
|
||||
tcg_gen_exit_tb(NULL, 0);
|
||||
|
||||
if (ctx->branch_cond != TCG_COND_NEVER) {
|
||||
if (ctx->branch_cond != TCG_COND_ALWAYS) {
|
||||
TCGLabel *skip = gen_new_label();
|
||||
tcg_gen_brcondi_tl(ctx->branch_cond, hex_branch_taken, 0, skip);
|
||||
gen_goto_tb(ctx, 0, ctx->branch_dest);
|
||||
gen_set_label(skip);
|
||||
gen_goto_tb(ctx, 1, ctx->next_PC);
|
||||
} else {
|
||||
gen_goto_tb(ctx, 0, ctx->branch_dest);
|
||||
}
|
||||
} else {
|
||||
tcg_gen_lookup_and_goto_ptr();
|
||||
}
|
||||
|
||||
ctx->base.is_jmp = DISAS_NORETURN;
|
||||
}
|
||||
|
||||
|
@ -807,6 +838,7 @@ static void hexagon_tr_init_disas_context(DisasContextBase *dcbase,
|
|||
ctx->num_packets = 0;
|
||||
ctx->num_insns = 0;
|
||||
ctx->num_hvx_insns = 0;
|
||||
ctx->branch_cond = TCG_COND_NEVER;
|
||||
}
|
||||
|
||||
static void hexagon_tr_tb_start(DisasContextBase *db, CPUState *cpu)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue