Commit 1c2adb95 authored by Richard Henderson's avatar Richard Henderson
Browse files

tcg: Initialize cpu_env generically



This is identical for each target.  So, move the initialization to
common code.  Move the variable itself out of tcg_ctx and name it
cpu_env to minimize changes within targets.

This also means we can remove tcg_global_reg_new_{ptr,i32,i64},
since there are no longer global-register temps created by targets.

Reviewed-by: default avatarEmilio G. Cota <cota@braap.org>
Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: default avatarRichard Henderson <richard.henderson@linaro.org>
parent 3468b59e
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ static inline void gen_tb_start(TranslationBlock *tb)
        count = tcg_temp_new_i32();
    }

    tcg_gen_ld_i32(count, tcg_ctx->tcg_env,
    tcg_gen_ld_i32(count, cpu_env,
                   -ENV_OFFSET + offsetof(CPUState, icount_decr.u32));

    if (tb_cflags(tb) & CF_USE_ICOUNT) {
@@ -36,7 +36,7 @@ static inline void gen_tb_start(TranslationBlock *tb)
    tcg_gen_brcondi_i32(TCG_COND_LT, count, 0, tcg_ctx->exitreq_label);

    if (tb_cflags(tb) & CF_USE_ICOUNT) {
        tcg_gen_st16_i32(count, tcg_ctx->tcg_env,
        tcg_gen_st16_i32(count, cpu_env,
                         -ENV_OFFSET + offsetof(CPUState, icount_decr.u16.low));
    }

@@ -61,16 +61,14 @@ static inline void gen_tb_end(TranslationBlock *tb, int num_insns)
static inline void gen_io_start(void)
{
    TCGv_i32 tmp = tcg_const_i32(1);
    tcg_gen_st_i32(tmp, tcg_ctx->tcg_env,
                   -ENV_OFFSET + offsetof(CPUState, can_do_io));
    tcg_gen_st_i32(tmp, cpu_env, -ENV_OFFSET + offsetof(CPUState, can_do_io));
    tcg_temp_free_i32(tmp);
}

static inline void gen_io_end(void)
{
    TCGv_i32 tmp = tcg_const_i32(0);
    tcg_gen_st_i32(tmp, tcg_ctx->tcg_env,
                   -ENV_OFFSET + offsetof(CPUState, can_do_io));
    tcg_gen_st_i32(tmp, cpu_env, -ENV_OFFSET + offsetof(CPUState, can_do_io));
    tcg_temp_free_i32(tmp);
}

+0 −4
Original line number Diff line number Diff line
@@ -78,7 +78,6 @@ struct DisasContext {
#define DISAS_PC_STALE            DISAS_TARGET_2

/* global register indexes */
static TCGv_env cpu_env;
static TCGv cpu_std_ir[31];
static TCGv cpu_fir[31];
static TCGv cpu_pc;
@@ -126,9 +125,6 @@ void alpha_translate_init(void)

    int i;

    cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env");
    tcg_ctx->tcg_env = cpu_env;

    for (i = 0; i < 31; i++) {
        cpu_std_ir[i] = tcg_global_mem_new_i64(cpu_env,
                                               offsetof(CPUAlphaState, ir[i]),
+0 −4
Original line number Diff line number Diff line
@@ -58,7 +58,6 @@
#define IS_USER(s) (s->user)
#endif

TCGv_env cpu_env;
/* We reuse the same 64-bit temporaries for efficiency.  */
static TCGv_i64 cpu_V0, cpu_V1, cpu_M0;
static TCGv_i32 cpu_R[16];
@@ -81,9 +80,6 @@ void arm_translate_init(void)
{
    int i;

    cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env");
    tcg_ctx->tcg_env = cpu_env;

    for (i = 0; i < 16; i++) {
        cpu_R[i] = tcg_global_mem_new_i32(cpu_env,
                                          offsetof(CPUARMState, regs[i]),
+0 −1
Original line number Diff line number Diff line
@@ -80,7 +80,6 @@ typedef struct DisasCompare {
} DisasCompare;

/* Share the TCG temporaries common between 32 and 64 bit modes.  */
extern TCGv_env cpu_env;
extern TCGv_i32 cpu_NF, cpu_ZF, cpu_CF, cpu_VF;
extern TCGv_i64 cpu_exclusive_addr;
extern TCGv_i64 cpu_exclusive_val;
+0 −3
Original line number Diff line number Diff line
@@ -66,7 +66,6 @@
#define CC_MASK_NZVC 0xf
#define CC_MASK_RNZV 0x10e

static TCGv_env cpu_env;
static TCGv cpu_R[16];
static TCGv cpu_PR[16];
static TCGv cc_x;
@@ -3368,8 +3367,6 @@ void cris_initialize_tcg(void)
{
    int i;

    cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env");
    tcg_ctx->tcg_env = cpu_env;
    cc_x = tcg_global_mem_new(cpu_env,
                              offsetof(CPUCRISState, cc_x), "cc_x");
    cc_src = tcg_global_mem_new(cpu_env,
Loading