Revision | 9c489ea6bed134fecfd556b439c68bba48fbe102 (tree) |
---|---|
Time | 2017-07-20 06:45:16 |
Author | Lluís Vilanova <vilanova@ac.u...> |
Commiter | Richard Henderson |
tcg: Pass generic CPUState to gen_intermediate_code()
Needed to implement a target-agnostic gen_intermediate_code()
in the future.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Reviewed-by: Alex Benneé <alex.benee@linaro.org>
Reviewed-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Message-Id: <150002025498.22386.18051908483085660588.stgit@frigg.lan>
Signed-off-by: Richard Henderson <rth@twiddle.net>
@@ -1280,7 +1280,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, | ||
1280 | 1280 | tcg_func_start(&tcg_ctx); |
1281 | 1281 | |
1282 | 1282 | tcg_ctx.cpu = ENV_GET_CPU(env); |
1283 | - gen_intermediate_code(env, tb); | |
1283 | + gen_intermediate_code(cpu, tb); | |
1284 | 1284 | tcg_ctx.cpu = NULL; |
1285 | 1285 | |
1286 | 1286 | trace_translate_block(tb, tb->pc, tb->tc_ptr); |
@@ -66,7 +66,7 @@ typedef ram_addr_t tb_page_addr_t; | ||
66 | 66 | |
67 | 67 | #include "qemu/log.h" |
68 | 68 | |
69 | -void gen_intermediate_code(CPUArchState *env, struct TranslationBlock *tb); | |
69 | +void gen_intermediate_code(CPUState *cpu, struct TranslationBlock *tb); | |
70 | 70 | void restore_state_to_opc(CPUArchState *env, struct TranslationBlock *tb, |
71 | 71 | target_ulong *data); |
72 | 72 |
@@ -2952,10 +2952,9 @@ static ExitStatus translate_one(DisasContext *ctx, uint32_t insn) | ||
2952 | 2952 | return ret; |
2953 | 2953 | } |
2954 | 2954 | |
2955 | -void gen_intermediate_code(CPUAlphaState *env, struct TranslationBlock *tb) | |
2955 | +void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | |
2956 | 2956 | { |
2957 | - AlphaCPU *cpu = alpha_env_get_cpu(env); | |
2958 | - CPUState *cs = CPU(cpu); | |
2957 | + CPUAlphaState *env = cs->env_ptr; | |
2959 | 2958 | DisasContext ctx, *ctxp = &ctx; |
2960 | 2959 | target_ulong pc_start; |
2961 | 2960 | target_ulong pc_mask; |
@@ -11179,10 +11179,10 @@ static void disas_a64_insn(CPUARMState *env, DisasContext *s) | ||
11179 | 11179 | free_tmp_a64(s); |
11180 | 11180 | } |
11181 | 11181 | |
11182 | -void gen_intermediate_code_a64(ARMCPU *cpu, TranslationBlock *tb) | |
11182 | +void gen_intermediate_code_a64(CPUState *cs, TranslationBlock *tb) | |
11183 | 11183 | { |
11184 | - CPUState *cs = CPU(cpu); | |
11185 | - CPUARMState *env = &cpu->env; | |
11184 | + CPUARMState *env = cs->env_ptr; | |
11185 | + ARMCPU *cpu = arm_env_get_cpu(env); | |
11186 | 11186 | DisasContext dc1, *dc = &dc1; |
11187 | 11187 | target_ulong pc_start; |
11188 | 11188 | target_ulong next_page_start; |
@@ -11795,10 +11795,10 @@ static bool insn_crosses_page(CPUARMState *env, DisasContext *s) | ||
11795 | 11795 | } |
11796 | 11796 | |
11797 | 11797 | /* generate intermediate code for basic block 'tb'. */ |
11798 | -void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb) | |
11798 | +void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) | |
11799 | 11799 | { |
11800 | + CPUARMState *env = cs->env_ptr; | |
11800 | 11801 | ARMCPU *cpu = arm_env_get_cpu(env); |
11801 | - CPUState *cs = CPU(cpu); | |
11802 | 11802 | DisasContext dc1, *dc = &dc1; |
11803 | 11803 | target_ulong pc_start; |
11804 | 11804 | target_ulong next_page_start; |
@@ -11812,7 +11812,7 @@ void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb) | ||
11812 | 11812 | * the A32/T32 complexity to do with conditional execution/IT blocks/etc. |
11813 | 11813 | */ |
11814 | 11814 | if (ARM_TBFLAG_AARCH64_STATE(tb->flags)) { |
11815 | - gen_intermediate_code_a64(cpu, tb); | |
11815 | + gen_intermediate_code_a64(cs, tb); | |
11816 | 11816 | return; |
11817 | 11817 | } |
11818 | 11818 |
@@ -149,7 +149,7 @@ static void disas_set_insn_syndrome(DisasContext *s, uint32_t syn) | ||
149 | 149 | |
150 | 150 | #ifdef TARGET_AARCH64 |
151 | 151 | void a64_translate_init(void); |
152 | -void gen_intermediate_code_a64(ARMCPU *cpu, TranslationBlock *tb); | |
152 | +void gen_intermediate_code_a64(CPUState *cpu, TranslationBlock *tb); | |
153 | 153 | void gen_a64_set_pc_im(uint64_t val); |
154 | 154 | void aarch64_cpu_dump_state(CPUState *cs, FILE *f, |
155 | 155 | fprintf_function cpu_fprintf, int flags); |
@@ -158,7 +158,7 @@ static inline void a64_translate_init(void) | ||
158 | 158 | { |
159 | 159 | } |
160 | 160 | |
161 | -static inline void gen_intermediate_code_a64(ARMCPU *cpu, TranslationBlock *tb) | |
161 | +static inline void gen_intermediate_code_a64(CPUState *cpu, TranslationBlock *tb) | |
162 | 162 | { |
163 | 163 | } |
164 | 164 |
@@ -3080,10 +3080,9 @@ static unsigned int crisv32_decoder(CPUCRISState *env, DisasContext *dc) | ||
3080 | 3080 | */ |
3081 | 3081 | |
3082 | 3082 | /* generate intermediate code for basic block 'tb'. */ |
3083 | -void gen_intermediate_code(CPUCRISState *env, struct TranslationBlock *tb) | |
3083 | +void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | |
3084 | 3084 | { |
3085 | - CRISCPU *cpu = cris_env_get_cpu(env); | |
3086 | - CPUState *cs = CPU(cpu); | |
3085 | + CPUCRISState *env = cs->env_ptr; | |
3087 | 3086 | uint32_t pc_start; |
3088 | 3087 | unsigned int insn_len; |
3089 | 3088 | struct DisasContext ctx; |
@@ -3105,7 +3104,7 @@ void gen_intermediate_code(CPUCRISState *env, struct TranslationBlock *tb) | ||
3105 | 3104 | * delayslot, like in real hw. |
3106 | 3105 | */ |
3107 | 3106 | pc_start = tb->pc & ~1; |
3108 | - dc->cpu = cpu; | |
3107 | + dc->cpu = cris_env_get_cpu(env); | |
3109 | 3108 | dc->tb = tb; |
3110 | 3109 | |
3111 | 3110 | dc->is_jmp = DISAS_NEXT; |
@@ -3740,10 +3740,9 @@ static ExitStatus translate_one(DisasContext *ctx, uint32_t insn) | ||
3740 | 3740 | return gen_illegal(ctx); |
3741 | 3741 | } |
3742 | 3742 | |
3743 | -void gen_intermediate_code(CPUHPPAState *env, struct TranslationBlock *tb) | |
3743 | +void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | |
3744 | 3744 | { |
3745 | - HPPACPU *cpu = hppa_env_get_cpu(env); | |
3746 | - CPUState *cs = CPU(cpu); | |
3745 | + CPUHPPAState *env = cs->env_ptr; | |
3747 | 3746 | DisasContext ctx; |
3748 | 3747 | ExitStatus ret; |
3749 | 3748 | int num_insns, max_insns, i; |
@@ -8378,10 +8378,9 @@ void tcg_x86_init(void) | ||
8378 | 8378 | } |
8379 | 8379 | |
8380 | 8380 | /* generate intermediate code for basic block 'tb'. */ |
8381 | -void gen_intermediate_code(CPUX86State *env, TranslationBlock *tb) | |
8381 | +void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) | |
8382 | 8382 | { |
8383 | - X86CPU *cpu = x86_env_get_cpu(env); | |
8384 | - CPUState *cs = CPU(cpu); | |
8383 | + CPUX86State *env = cs->env_ptr; | |
8385 | 8384 | DisasContext dc1, *dc = &dc1; |
8386 | 8385 | target_ulong pc_ptr; |
8387 | 8386 | uint32_t flags; |
@@ -1044,10 +1044,10 @@ static inline void decode(DisasContext *dc, uint32_t ir) | ||
1044 | 1044 | } |
1045 | 1045 | |
1046 | 1046 | /* generate intermediate code for basic block 'tb'. */ |
1047 | -void gen_intermediate_code(CPULM32State *env, struct TranslationBlock *tb) | |
1047 | +void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | |
1048 | 1048 | { |
1049 | + CPULM32State *env = cs->env_ptr; | |
1049 | 1050 | LM32CPU *cpu = lm32_env_get_cpu(env); |
1050 | - CPUState *cs = CPU(cpu); | |
1051 | 1051 | struct DisasContext ctx, *dc = &ctx; |
1052 | 1052 | uint32_t pc_start; |
1053 | 1053 | uint32_t next_page_start; |
@@ -5518,10 +5518,9 @@ static void disas_m68k_insn(CPUM68KState * env, DisasContext *s) | ||
5518 | 5518 | } |
5519 | 5519 | |
5520 | 5520 | /* generate intermediate code for basic block 'tb'. */ |
5521 | -void gen_intermediate_code(CPUM68KState *env, TranslationBlock *tb) | |
5521 | +void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) | |
5522 | 5522 | { |
5523 | - M68kCPU *cpu = m68k_env_get_cpu(env); | |
5524 | - CPUState *cs = CPU(cpu); | |
5523 | + CPUM68KState *env = cs->env_ptr; | |
5525 | 5524 | DisasContext dc1, *dc = &dc1; |
5526 | 5525 | target_ulong pc_start; |
5527 | 5526 | int pc_offset; |
@@ -1625,10 +1625,10 @@ static inline void decode(DisasContext *dc, uint32_t ir) | ||
1625 | 1625 | } |
1626 | 1626 | |
1627 | 1627 | /* generate intermediate code for basic block 'tb'. */ |
1628 | -void gen_intermediate_code(CPUMBState *env, struct TranslationBlock *tb) | |
1628 | +void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | |
1629 | 1629 | { |
1630 | + CPUMBState *env = cs->env_ptr; | |
1630 | 1631 | MicroBlazeCPU *cpu = mb_env_get_cpu(env); |
1631 | - CPUState *cs = CPU(cpu); | |
1632 | 1632 | uint32_t pc_start; |
1633 | 1633 | struct DisasContext ctx; |
1634 | 1634 | struct DisasContext *dc = &ctx; |
@@ -19888,10 +19888,9 @@ static void decode_opc(CPUMIPSState *env, DisasContext *ctx) | ||
19888 | 19888 | } |
19889 | 19889 | } |
19890 | 19890 | |
19891 | -void gen_intermediate_code(CPUMIPSState *env, struct TranslationBlock *tb) | |
19891 | +void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | |
19892 | 19892 | { |
19893 | - MIPSCPU *cpu = mips_env_get_cpu(env); | |
19894 | - CPUState *cs = CPU(cpu); | |
19893 | + CPUMIPSState *env = cs->env_ptr; | |
19895 | 19894 | DisasContext ctx; |
19896 | 19895 | target_ulong pc_start; |
19897 | 19896 | target_ulong next_page_start; |
@@ -822,10 +822,10 @@ static int decode_opc(MoxieCPU *cpu, DisasContext *ctx) | ||
822 | 822 | } |
823 | 823 | |
824 | 824 | /* generate intermediate code for basic block 'tb'. */ |
825 | -void gen_intermediate_code(CPUMoxieState *env, struct TranslationBlock *tb) | |
825 | +void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | |
826 | 826 | { |
827 | + CPUMoxieState *env = cs->env_ptr; | |
827 | 828 | MoxieCPU *cpu = moxie_env_get_cpu(env); |
828 | - CPUState *cs = CPU(cpu); | |
829 | 829 | DisasContext ctx; |
830 | 830 | target_ulong pc_start; |
831 | 831 | int num_insns, max_insns; |
@@ -799,10 +799,9 @@ static void gen_exception(DisasContext *dc, uint32_t excp) | ||
799 | 799 | } |
800 | 800 | |
801 | 801 | /* generate intermediate code for basic block 'tb'. */ |
802 | -void gen_intermediate_code(CPUNios2State *env, TranslationBlock *tb) | |
802 | +void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) | |
803 | 803 | { |
804 | - Nios2CPU *cpu = nios2_env_get_cpu(env); | |
805 | - CPUState *cs = CPU(cpu); | |
804 | + CPUNios2State *env = cs->env_ptr; | |
806 | 805 | DisasContext dc1, *dc = &dc1; |
807 | 806 | int num_insns; |
808 | 807 | int max_insns; |
@@ -1518,10 +1518,10 @@ static void disas_openrisc_insn(DisasContext *dc, OpenRISCCPU *cpu) | ||
1518 | 1518 | } |
1519 | 1519 | } |
1520 | 1520 | |
1521 | -void gen_intermediate_code(CPUOpenRISCState *env, struct TranslationBlock *tb) | |
1521 | +void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | |
1522 | 1522 | { |
1523 | + CPUOpenRISCState *env = cs->env_ptr; | |
1523 | 1524 | OpenRISCCPU *cpu = openrisc_env_get_cpu(env); |
1524 | - CPUState *cs = CPU(cpu); | |
1525 | 1525 | struct DisasContext ctx, *dc = &ctx; |
1526 | 1526 | uint32_t pc_start; |
1527 | 1527 | uint32_t next_page_start; |
@@ -7196,10 +7196,9 @@ void ppc_cpu_dump_statistics(CPUState *cs, FILE*f, | ||
7196 | 7196 | } |
7197 | 7197 | |
7198 | 7198 | /*****************************************************************************/ |
7199 | -void gen_intermediate_code(CPUPPCState *env, struct TranslationBlock *tb) | |
7199 | +void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | |
7200 | 7200 | { |
7201 | - PowerPCCPU *cpu = ppc_env_get_cpu(env); | |
7202 | - CPUState *cs = CPU(cpu); | |
7201 | + CPUPPCState *env = cs->env_ptr; | |
7203 | 7202 | DisasContext ctx, *ctxp = &ctx; |
7204 | 7203 | opc_handler_t **table, *handler; |
7205 | 7204 | target_ulong pc_start; |
@@ -5853,10 +5853,9 @@ static ExitStatus translate_one(CPUS390XState *env, DisasContext *s) | ||
5853 | 5853 | return ret; |
5854 | 5854 | } |
5855 | 5855 | |
5856 | -void gen_intermediate_code(CPUS390XState *env, struct TranslationBlock *tb) | |
5856 | +void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | |
5857 | 5857 | { |
5858 | - S390CPU *cpu = s390_env_get_cpu(env); | |
5859 | - CPUState *cs = CPU(cpu); | |
5858 | + CPUS390XState *env = cs->env_ptr; | |
5860 | 5859 | DisasContext dc; |
5861 | 5860 | target_ulong pc_start; |
5862 | 5861 | uint64_t next_page_start; |
@@ -2230,10 +2230,9 @@ static int decode_gusa(DisasContext *ctx, CPUSH4State *env, int *pmax_insns) | ||
2230 | 2230 | } |
2231 | 2231 | #endif |
2232 | 2232 | |
2233 | -void gen_intermediate_code(CPUSH4State * env, struct TranslationBlock *tb) | |
2233 | +void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | |
2234 | 2234 | { |
2235 | - SuperHCPU *cpu = sh_env_get_cpu(env); | |
2236 | - CPUState *cs = CPU(cpu); | |
2235 | + CPUSH4State *env = cs->env_ptr; | |
2237 | 2236 | DisasContext ctx; |
2238 | 2237 | target_ulong pc_start; |
2239 | 2238 | int num_insns; |
@@ -5739,10 +5739,9 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn) | ||
5739 | 5739 | } |
5740 | 5740 | } |
5741 | 5741 | |
5742 | -void gen_intermediate_code(CPUSPARCState * env, TranslationBlock * tb) | |
5742 | +void gen_intermediate_code(CPUState *cs, TranslationBlock * tb) | |
5743 | 5743 | { |
5744 | - SPARCCPU *cpu = sparc_env_get_cpu(env); | |
5745 | - CPUState *cs = CPU(cpu); | |
5744 | + CPUSPARCState *env = cs->env_ptr; | |
5746 | 5745 | target_ulong pc_start, last_pc; |
5747 | 5746 | DisasContext dc1, *dc = &dc1; |
5748 | 5747 | int num_insns; |
@@ -2370,12 +2370,11 @@ static void translate_one_bundle(DisasContext *dc, uint64_t bundle) | ||
2370 | 2370 | } |
2371 | 2371 | } |
2372 | 2372 | |
2373 | -void gen_intermediate_code(CPUTLGState *env, struct TranslationBlock *tb) | |
2373 | +void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | |
2374 | 2374 | { |
2375 | - TileGXCPU *cpu = tilegx_env_get_cpu(env); | |
2375 | + CPUTLGState *env = cs->env_ptr; | |
2376 | 2376 | DisasContext ctx; |
2377 | 2377 | DisasContext *dc = &ctx; |
2378 | - CPUState *cs = CPU(cpu); | |
2379 | 2378 | uint64_t pc_start = tb->pc; |
2380 | 2379 | uint64_t next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; |
2381 | 2380 | int num_insns = 0; |
@@ -8782,10 +8782,9 @@ static void decode_opc(CPUTriCoreState *env, DisasContext *ctx, int *is_branch) | ||
8782 | 8782 | } |
8783 | 8783 | } |
8784 | 8784 | |
8785 | -void gen_intermediate_code(CPUTriCoreState *env, struct TranslationBlock *tb) | |
8785 | +void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) | |
8786 | 8786 | { |
8787 | - TriCoreCPU *cpu = tricore_env_get_cpu(env); | |
8788 | - CPUState *cs = CPU(cpu); | |
8787 | + CPUTriCoreState *env = cs->env_ptr; | |
8789 | 8788 | DisasContext ctx; |
8790 | 8789 | target_ulong pc_start; |
8791 | 8790 | int num_insns, max_insns; |
@@ -1869,10 +1869,9 @@ static void disas_uc32_insn(CPUUniCore32State *env, DisasContext *s) | ||
1869 | 1869 | } |
1870 | 1870 | |
1871 | 1871 | /* generate intermediate code for basic block 'tb'. */ |
1872 | -void gen_intermediate_code(CPUUniCore32State *env, TranslationBlock *tb) | |
1872 | +void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) | |
1873 | 1873 | { |
1874 | - UniCore32CPU *cpu = uc32_env_get_cpu(env); | |
1875 | - CPUState *cs = CPU(cpu); | |
1874 | + CPUUniCore32State *env = cs->env_ptr; | |
1876 | 1875 | DisasContext dc1, *dc = &dc1; |
1877 | 1876 | target_ulong pc_start; |
1878 | 1877 | uint32_t next_page_start; |
@@ -3117,10 +3117,9 @@ static void gen_ibreak_check(CPUXtensaState *env, DisasContext *dc) | ||
3117 | 3117 | } |
3118 | 3118 | } |
3119 | 3119 | |
3120 | -void gen_intermediate_code(CPUXtensaState *env, TranslationBlock *tb) | |
3120 | +void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) | |
3121 | 3121 | { |
3122 | - XtensaCPU *cpu = xtensa_env_get_cpu(env); | |
3123 | - CPUState *cs = CPU(cpu); | |
3122 | + CPUXtensaState *env = cs->env_ptr; | |
3124 | 3123 | DisasContext dc; |
3125 | 3124 | int insn_count = 0; |
3126 | 3125 | int max_insns = tb->cflags & CF_COUNT_MASK; |