gen-icount: use tcg_ctx.tcg_env instead of cpu_env

We are relying on cpu_env being defined as a global, yet most
targets (i.e. all but arm/a64) have it defined as a local variable.
Luckily all of them use the same "cpu_env" name, but really
compilation shouldn't break if the name of that local variable
changed.

Fix it by using tcg_ctx.tcg_env, which all targets set in their
translate_init function. This change also helps paving the way
for the upcoming "translation loop common to all targets" work.

Backports commit 53f6672bcf57d82b794a2cc3a3469be7d35c8653 from qemu
This commit is contained in:
Emilio G. Cota 2018-03-03 21:08:51 -05:00 committed by Lioncash
parent 8a7f7242cc
commit 1a4e5da043
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -28,7 +28,7 @@ static inline void gen_tb_start(TCGContext *tcg_ctx)
icount_label = gen_new_label(tcg_ctx);
count = tcg_temp_local_new_i32(tcg_ctx);
tcg_gen_ld_i32(tcg_ctx, count, cpu_env,
tcg_gen_ld_i32(tcg_ctx, count, tcg_ctx->tcg_env,
-ENV_OFFSET + offsetof(CPUState, icount_decr.u32));
imm = tcg_temp_new_i32(tcg_ctx);
/* We emit a movi with a dummy immediate argument. Keep the insn index
@ -41,7 +41,7 @@ static inline void gen_tb_start(TCGContext *tcg_ctx)
tcg_temp_free_i32(tcg_ctx, imm);
tcg_gen_brcondi_i32(tcg_ctx, TCG_COND_LT, count, 0, icount_label);
tcg_gen_st16_i32(tcg_ctx, count, cpu_env,
tcg_gen_st16_i32(tcg_ctx, count, tcg_ctx->tcg_env,
-ENV_OFFSET + offsetof(CPUState, icount_decr.u16.low));
tcg_temp_free_i32(tcg_ctx, count);
#endif
@ -57,8 +57,8 @@ static inline void gen_tb_end(TCGContext *tcg_ctx, TranslationBlock *tb, int num
/* Update the num_insn immediate parameter now that we know
* the actual insn count. */
tcg_set_insn_param(tcg_ctx, icount_start_insn_idx, 1, num_insns);
gen_set_label(icount_label);
tcg_gen_exit_tb((uintptr_t)tb + TB_EXIT_ICOUNT_EXPIRED);
gen_set_label(tcg_ctx, icount_label);
tcg_gen_exit_tb(tcg_ctx, (uintptr_t)tb + TB_EXIT_ICOUNT_EXPIRED);
}
#endif
@ -68,18 +68,18 @@ static inline void gen_tb_end(TCGContext *tcg_ctx, TranslationBlock *tb, int num
}
#if 0
static inline void gen_io_start(void)
static inline void gen_io_start(TCGContext *tcg_ctx)
{
TCGv_i32 tmp = tcg_const_i32(1);
tcg_gen_st_i32(tmp, cpu_env, -ENV_OFFSET + offsetof(CPUState, can_do_io));
tcg_temp_free_i32(tmp);
TCGv_i32 tmp = tcg_const_i32(tcg_ctx, 1);
tcg_gen_st_i32(tcg_ctx, tmp, tcg_ctx->tcg_env, -ENV_OFFSET + offsetof(CPUState, can_do_io));
tcg_temp_free_i32(tcg_ctx, tmp);
}
static inline void gen_io_end(void)
static inline void gen_io_end(TCGContext *tcg_ctx)
{
TCGv_i32 tmp = tcg_const_i32(0);
tcg_gen_st_i32(tmp, cpu_env, -ENV_OFFSET + offsetof(CPUState, can_do_io));
tcg_temp_free_i32(tmp);
TCGv_i32 tmp = tcg_const_i32(tcg_ctx, 0);
tcg_gen_st_i32(tcg_ctx, tmp, tcg_ctx->tcg_env, -ENV_OFFSET + offsetof(CPUState, can_do_io));
tcg_temp_free_i32(tcg_ctx, tmp);
}
#endif