Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
accel/tcg: Refactor gen_io_start() as set_can_do_io()
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20230914174436.1597356-4-richard.henderson@linaro.org>
[PMD: Split patch in 2, extracting set_can_do_io() first]
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
  • Loading branch information
philmd authored and Michael Tokarev committed Sep 20, 2023
1 parent d30da97 commit ebe230e
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions accel/tcg/translator.c
Expand Up @@ -16,9 +16,9 @@
#include "tcg/tcg-op-common.h"
#include "internal.h"

static void gen_io_start(void)
static void set_can_do_io(DisasContextBase *db, bool val)
{
tcg_gen_st_i32(tcg_constant_i32(1), cpu_env,
tcg_gen_st_i32(tcg_constant_i32(val), cpu_env,
offsetof(ArchCPU, parent_obj.can_do_io) -
offsetof(ArchCPU, env));
}
Expand All @@ -35,7 +35,7 @@ bool translator_io_start(DisasContextBase *db)
return true;
}

gen_io_start();
set_can_do_io(db, true);

/*
* Ensure that this instruction will be the last in the TB.
Expand All @@ -47,7 +47,7 @@ bool translator_io_start(DisasContextBase *db)
return true;
}

static TCGOp *gen_tb_start(uint32_t cflags)
static TCGOp *gen_tb_start(DisasContextBase *db, uint32_t cflags)
{
TCGv_i32 count = NULL;
TCGOp *icount_start_insn = NULL;
Expand Down Expand Up @@ -91,12 +91,9 @@ static TCGOp *gen_tb_start(uint32_t cflags)
* cpu->can_do_io is cleared automatically here at the beginning of
* each translation block. The cost is minimal and only paid for
* -icount, plus it would be very easy to forget doing it in the
* translator. Doing it here means we don't need a gen_io_end() to
* go with gen_io_start().
* translator.
*/
tcg_gen_st_i32(tcg_constant_i32(0), cpu_env,
offsetof(ArchCPU, parent_obj.can_do_io) -
offsetof(ArchCPU, env));
set_can_do_io(db, false);
}

return icount_start_insn;
Expand Down Expand Up @@ -154,7 +151,7 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns,
tcg_debug_assert(db->is_jmp == DISAS_NEXT); /* no early exit */

/* Start translating. */
icount_start_insn = gen_tb_start(cflags);
icount_start_insn = gen_tb_start(db, cflags);
ops->tb_start(db, cpu);
tcg_debug_assert(db->is_jmp == DISAS_NEXT); /* no early exit */

Expand All @@ -181,7 +178,7 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns,
the next instruction. */
if (db->num_insns == db->max_insns && (cflags & CF_LAST_IO)) {
/* Accept I/O on the last instruction. */
gen_io_start();
set_can_do_io(db, true);
}
ops->translate_insn(db, cpu);

Expand Down

0 comments on commit ebe230e

Please sign in to comment.