Skip to content

Commit e4a8e09

Browse files
committed
accel/tcg: Move gen_intermediate_code to TCGCPUOps.translate_core
Convert all targets simultaneously, as the gen_intermediate_code function disappears from the target. While there are possible workarounds, they're larger than simply performing the conversion. Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Signed-off-by: Richard Henderson <[email protected]>
1 parent 59abfb4 commit e4a8e09

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+121
-62
lines changed

accel/tcg/cpu-exec.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,11 +1088,13 @@ bool tcg_exec_realizefn(CPUState *cpu, Error **errp)
10881088

10891089
if (!tcg_target_initialized) {
10901090
/* Check mandatory TCGCPUOps handlers */
1091+
const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops;
10911092
#ifndef CONFIG_USER_ONLY
1092-
assert(cpu->cc->tcg_ops->cpu_exec_halt);
1093-
assert(cpu->cc->tcg_ops->cpu_exec_interrupt);
1093+
assert(tcg_ops->cpu_exec_halt);
1094+
assert(tcg_ops->cpu_exec_interrupt);
10941095
#endif /* !CONFIG_USER_ONLY */
1095-
cpu->cc->tcg_ops->initialize();
1096+
assert(tcg_ops->translate_code);
1097+
tcg_ops->initialize();
10961098
tcg_target_initialized = true;
10971099
}
10981100

accel/tcg/translate-all.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,10 @@ static int setjmp_gen_code(CPUArchState *env, TranslationBlock *tb,
276276

277277
tcg_func_start(tcg_ctx);
278278

279-
tcg_ctx->cpu = env_cpu(env);
280-
gen_intermediate_code(env_cpu(env), tb, max_insns, pc, host_pc);
279+
CPUState *cs = env_cpu(env);
280+
tcg_ctx->cpu = cs;
281+
cs->cc->tcg_ops->translate_code(cs, tb, max_insns, pc, host_pc);
282+
281283
assert(tb->size != 0);
282284
tcg_ctx->cpu = NULL;
283285
*max_insns = tb->icount;
@@ -364,7 +366,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
364366
/*
365367
* Overflow of code_gen_buffer, or the current slice of it.
366368
*
367-
* TODO: We don't need to re-do gen_intermediate_code, nor
369+
* TODO: We don't need to re-do tcg_ops->translate_code, nor
368370
* should we re-do the tcg optimization currently hidden
369371
* inside tcg_gen_code. All that should be required is to
370372
* flush the TBs, allocate a new TB, re-initialize it per

include/exec/translator.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,6 @@
2121
#include "qemu/bswap.h"
2222
#include "exec/vaddr.h"
2323

24-
/**
25-
* gen_intermediate_code
26-
* @cpu: cpu context
27-
* @tb: translation block
28-
* @max_insns: max number of instructions to translate
29-
* @pc: guest virtual program counter address
30-
* @host_pc: host physical program counter address
31-
*
32-
* This function must be provided by the target, which should create
33-
* the target-specific DisasContext, and then invoke translator_loop.
34-
*/
35-
void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int *max_insns,
36-
vaddr pc, void *host_pc);
37-
3824
/**
3925
* DisasJumpType:
4026
* @DISAS_NEXT: Next instruction in program order.

include/hw/core/tcg-cpu-ops.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ struct TCGCPUOps {
2424
* Called when the first CPU is realized.
2525
*/
2626
void (*initialize)(void);
27+
/**
28+
* @translate_code: Translate guest instructions to TCGOps
29+
* @cpu: cpu context
30+
* @tb: translation block
31+
* @max_insns: max number of instructions to translate
32+
* @pc: guest virtual program counter address
33+
* @host_pc: host physical program counter address
34+
*
35+
* This function must be provided by the target, which should create
36+
* the target-specific DisasContext, and then invoke translator_loop.
37+
*/
38+
void (*translate_code)(CPUState *cpu, TranslationBlock *tb,
39+
int *max_insns, vaddr pc, void *host_pc);
2740
/**
2841
* @synchronize_from_tb: Synchronize state from a TCG #TranslationBlock
2942
*

target/alpha/cpu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ static const struct SysemuCPUOps alpha_sysemu_ops = {
224224

225225
static const TCGCPUOps alpha_tcg_ops = {
226226
.initialize = alpha_translate_init,
227+
.translate_code = alpha_translate_code,
227228
.synchronize_from_tb = alpha_cpu_synchronize_from_tb,
228229
.restore_state_to_opc = alpha_restore_state_to_opc,
229230

target/alpha/cpu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,8 @@ enum {
431431
};
432432

433433
void alpha_translate_init(void);
434+
void alpha_translate_code(CPUState *cs, TranslationBlock *tb,
435+
int *max_insns, vaddr pc, void *host_pc);
434436

435437
#define CPU_RESOLVING_TYPE TYPE_ALPHA_CPU
436438

target/alpha/translate.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2955,8 +2955,8 @@ static const TranslatorOps alpha_tr_ops = {
29552955
.tb_stop = alpha_tr_tb_stop,
29562956
};
29572957

2958-
void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int *max_insns,
2959-
vaddr pc, void *host_pc)
2958+
void alpha_translate_code(CPUState *cpu, TranslationBlock *tb,
2959+
int *max_insns, vaddr pc, void *host_pc)
29602960
{
29612961
DisasContext dc;
29622962
translator_loop(cpu, tb, max_insns, pc, host_pc, &alpha_tr_ops, &dc.base);

target/arm/cpu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2682,6 +2682,7 @@ static const struct SysemuCPUOps arm_sysemu_ops = {
26822682
#ifdef CONFIG_TCG
26832683
static const TCGCPUOps arm_tcg_ops = {
26842684
.initialize = arm_translate_init,
2685+
.translate_code = arm_translate_code,
26852686
.synchronize_from_tb = arm_cpu_synchronize_from_tb,
26862687
.debug_excp_handler = arm_debug_excp_handler,
26872688
.restore_state_to_opc = arm_restore_state_to_opc,

target/arm/internals.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,8 @@ void init_cpreg_list(ARMCPU *cpu);
357357

358358
void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu);
359359
void arm_translate_init(void);
360+
void arm_translate_code(CPUState *cs, TranslationBlock *tb,
361+
int *max_insns, vaddr pc, void *host_pc);
360362

361363
void arm_cpu_register_gdb_commands(ARMCPU *cpu);
362364
void aarch64_cpu_register_gdb_commands(ARMCPU *cpu, GString *,

target/arm/tcg/cpu-v7m.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ static void cortex_m55_initfn(Object *obj)
234234

235235
static const TCGCPUOps arm_v7m_tcg_ops = {
236236
.initialize = arm_translate_init,
237+
.translate_code = arm_translate_code,
237238
.synchronize_from_tb = arm_cpu_synchronize_from_tb,
238239
.debug_excp_handler = arm_debug_excp_handler,
239240
.restore_state_to_opc = arm_restore_state_to_opc,

0 commit comments

Comments
 (0)