Skip to content

Commit

Permalink
TCG: Use gen_opc_ptr from context instead of global variable.
Browse files Browse the repository at this point in the history
Signed-off-by: Evgeny Voevodin <e.voevodin@samsung.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
  • Loading branch information
Evgeny Voevodin authored and blueswirl committed Nov 17, 2012
1 parent 8232a46 commit efd7f48
Show file tree
Hide file tree
Showing 17 changed files with 109 additions and 106 deletions.
8 changes: 4 additions & 4 deletions target-alpha/translate.c
Expand Up @@ -3406,7 +3406,7 @@ static inline void gen_intermediate_code_internal(CPUAlphaState *env,
}
}
if (search_pc) {
j = gen_opc_ptr - gen_opc_buf;
j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j)
Expand All @@ -3432,7 +3432,7 @@ static inline void gen_intermediate_code_internal(CPUAlphaState *env,
or exhaust instruction count, stop generation. */
if (ret == NO_EXIT
&& ((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0
|| gen_opc_ptr >= gen_opc_end
|| tcg_ctx.gen_opc_ptr >= gen_opc_end
|| num_insns >= max_insns
|| singlestep
|| env->singlestep_enabled)) {
Expand Down Expand Up @@ -3463,9 +3463,9 @@ static inline void gen_intermediate_code_internal(CPUAlphaState *env,
}

gen_icount_end(tb, num_insns);
*gen_opc_ptr = INDEX_op_end;
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
if (search_pc) {
j = gen_opc_ptr - gen_opc_buf;
j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
lj++;
while (lj <= j)
gen_opc_instr_start[lj++] = 0;
Expand Down
8 changes: 4 additions & 4 deletions target-arm/translate.c
Expand Up @@ -9834,7 +9834,7 @@ static inline void gen_intermediate_code_internal(CPUARMState *env,
}
}
if (search_pc) {
j = gen_opc_ptr - gen_opc_buf;
j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j)
Expand Down Expand Up @@ -9881,7 +9881,7 @@ static inline void gen_intermediate_code_internal(CPUARMState *env,
* Also stop translation when a page boundary is reached. This
* ensures prefetch aborts occur at the right place. */
num_insns ++;
} while (!dc->is_jmp && gen_opc_ptr < gen_opc_end &&
} while (!dc->is_jmp && tcg_ctx.gen_opc_ptr < gen_opc_end &&
!env->singlestep_enabled &&
!singlestep &&
dc->pc < next_page_start &&
Expand Down Expand Up @@ -9962,7 +9962,7 @@ static inline void gen_intermediate_code_internal(CPUARMState *env,

done_generating:
gen_icount_end(tb, num_insns);
*gen_opc_ptr = INDEX_op_end;
*tcg_ctx.gen_opc_ptr = INDEX_op_end;

#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
Expand All @@ -9974,7 +9974,7 @@ static inline void gen_intermediate_code_internal(CPUARMState *env,
}
#endif
if (search_pc) {
j = gen_opc_ptr - gen_opc_buf;
j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
lj++;
while (lj <= j)
gen_opc_instr_start[lj++] = 0;
Expand Down
10 changes: 5 additions & 5 deletions target-cris/translate.c
Expand Up @@ -3297,7 +3297,7 @@ gen_intermediate_code_internal(CPUCRISState *env, TranslationBlock *tb,
check_breakpoint(env, dc);

if (search_pc) {
j = gen_opc_ptr - gen_opc_buf;
j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j) {
Expand Down Expand Up @@ -3381,7 +3381,7 @@ gen_intermediate_code_internal(CPUCRISState *env, TranslationBlock *tb,
break;
}
} while (!dc->is_jmp && !dc->cpustate_changed
&& gen_opc_ptr < gen_opc_end
&& tcg_ctx.gen_opc_ptr < gen_opc_end
&& !singlestep
&& (dc->pc < next_page_start)
&& num_insns < max_insns);
Expand Down Expand Up @@ -3434,9 +3434,9 @@ gen_intermediate_code_internal(CPUCRISState *env, TranslationBlock *tb,
}
}
gen_icount_end(tb, num_insns);
*gen_opc_ptr = INDEX_op_end;
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
if (search_pc) {
j = gen_opc_ptr - gen_opc_buf;
j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
lj++;
while (lj <= j) {
gen_opc_instr_start[lj++] = 0;
Expand All @@ -3452,7 +3452,7 @@ gen_intermediate_code_internal(CPUCRISState *env, TranslationBlock *tb,
log_target_disas(env, pc_start, dc->pc - pc_start,
dc->env->pregs[PR_VR]);
qemu_log("\nisize=%d osize=%td\n",
dc->pc - pc_start, gen_opc_ptr - gen_opc_buf);
dc->pc - pc_start, tcg_ctx.gen_opc_ptr - gen_opc_buf);
}
#endif
#endif
Expand Down
8 changes: 4 additions & 4 deletions target-i386/translate.c
Expand Up @@ -7984,7 +7984,7 @@ static inline void gen_intermediate_code_internal(CPUX86State *env,
}
}
if (search_pc) {
j = gen_opc_ptr - gen_opc_buf;
j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j)
Expand Down Expand Up @@ -8015,7 +8015,7 @@ static inline void gen_intermediate_code_internal(CPUX86State *env,
break;
}
/* if too long translation, stop generation too */
if (gen_opc_ptr >= gen_opc_end ||
if (tcg_ctx.gen_opc_ptr >= gen_opc_end ||
(pc_ptr - pc_start) >= (TARGET_PAGE_SIZE - 32) ||
num_insns >= max_insns) {
gen_jmp_im(pc_ptr - dc->cs_base);
Expand All @@ -8031,10 +8031,10 @@ static inline void gen_intermediate_code_internal(CPUX86State *env,
if (tb->cflags & CF_LAST_IO)
gen_io_end();
gen_icount_end(tb, num_insns);
*gen_opc_ptr = INDEX_op_end;
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
/* we don't forget to fill the last values */
if (search_pc) {
j = gen_opc_ptr - gen_opc_buf;
j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
lj++;
while (lj <= j)
gen_opc_instr_start[lj++] = 0;
Expand Down
10 changes: 5 additions & 5 deletions target-lm32/translate.c
Expand Up @@ -1047,7 +1047,7 @@ static void gen_intermediate_code_internal(CPULM32State *env,
check_breakpoint(env, dc);

if (search_pc) {
j = gen_opc_ptr - gen_opc_buf;
j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j) {
Expand All @@ -1071,7 +1071,7 @@ static void gen_intermediate_code_internal(CPULM32State *env,
num_insns++;

} while (!dc->is_jmp
&& gen_opc_ptr < gen_opc_end
&& tcg_ctx.gen_opc_ptr < gen_opc_end
&& !env->singlestep_enabled
&& !singlestep
&& (dc->pc < next_page_start)
Expand Down Expand Up @@ -1105,9 +1105,9 @@ static void gen_intermediate_code_internal(CPULM32State *env,
}

gen_icount_end(tb, num_insns);
*gen_opc_ptr = INDEX_op_end;
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
if (search_pc) {
j = gen_opc_ptr - gen_opc_buf;
j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
lj++;
while (lj <= j) {
gen_opc_instr_start[lj++] = 0;
Expand All @@ -1122,7 +1122,7 @@ static void gen_intermediate_code_internal(CPULM32State *env,
qemu_log("\n");
log_target_disas(env, pc_start, dc->pc - pc_start, 0);
qemu_log("\nisize=%d osize=%td\n",
dc->pc - pc_start, gen_opc_ptr - gen_opc_buf);
dc->pc - pc_start, tcg_ctx.gen_opc_ptr - gen_opc_buf);
}
#endif
}
Expand Down
8 changes: 4 additions & 4 deletions target-m68k/translate.c
Expand Up @@ -3015,7 +3015,7 @@ gen_intermediate_code_internal(CPUM68KState *env, TranslationBlock *tb,
break;
}
if (search_pc) {
j = gen_opc_ptr - gen_opc_buf;
j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j)
Expand All @@ -3030,7 +3030,7 @@ gen_intermediate_code_internal(CPUM68KState *env, TranslationBlock *tb,
dc->insn_pc = dc->pc;
disas_m68k_insn(env, dc);
num_insns++;
} while (!dc->is_jmp && gen_opc_ptr < gen_opc_end &&
} while (!dc->is_jmp && tcg_ctx.gen_opc_ptr < gen_opc_end &&
!env->singlestep_enabled &&
!singlestep &&
(pc_offset) < (TARGET_PAGE_SIZE - 32) &&
Expand Down Expand Up @@ -3064,7 +3064,7 @@ gen_intermediate_code_internal(CPUM68KState *env, TranslationBlock *tb,
}
}
gen_icount_end(tb, num_insns);
*gen_opc_ptr = INDEX_op_end;
*tcg_ctx.gen_opc_ptr = INDEX_op_end;

#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
Expand All @@ -3075,7 +3075,7 @@ gen_intermediate_code_internal(CPUM68KState *env, TranslationBlock *tb,
}
#endif
if (search_pc) {
j = gen_opc_ptr - gen_opc_buf;
j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
lj++;
while (lj <= j)
gen_opc_instr_start[lj++] = 0;
Expand Down
10 changes: 5 additions & 5 deletions target-microblaze/translate.c
Expand Up @@ -1784,7 +1784,7 @@ gen_intermediate_code_internal(CPUMBState *env, TranslationBlock *tb,
check_breakpoint(env, dc);

if (search_pc) {
j = gen_opc_ptr - gen_opc_buf;
j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j)
Expand Down Expand Up @@ -1846,7 +1846,7 @@ gen_intermediate_code_internal(CPUMBState *env, TranslationBlock *tb,
if (env->singlestep_enabled)
break;
} while (!dc->is_jmp && !dc->cpustate_changed
&& gen_opc_ptr < gen_opc_end
&& tcg_ctx.gen_opc_ptr < gen_opc_end
&& !singlestep
&& (dc->pc < next_page_start)
&& num_insns < max_insns);
Expand Down Expand Up @@ -1897,9 +1897,9 @@ gen_intermediate_code_internal(CPUMBState *env, TranslationBlock *tb,
}
}
gen_icount_end(tb, num_insns);
*gen_opc_ptr = INDEX_op_end;
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
if (search_pc) {
j = gen_opc_ptr - gen_opc_buf;
j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
lj++;
while (lj <= j)
gen_opc_instr_start[lj++] = 0;
Expand All @@ -1916,7 +1916,7 @@ gen_intermediate_code_internal(CPUMBState *env, TranslationBlock *tb,
log_target_disas(env, pc_start, dc->pc - pc_start, 0);
#endif
qemu_log("\nisize=%d osize=%td\n",
dc->pc - pc_start, gen_opc_ptr - gen_opc_buf);
dc->pc - pc_start, tcg_ctx.gen_opc_ptr - gen_opc_buf);
}
#endif
#endif
Expand Down
9 changes: 5 additions & 4 deletions target-mips/translate.c
Expand Up @@ -15549,7 +15549,7 @@ gen_intermediate_code_internal (CPUMIPSState *env, TranslationBlock *tb,
}

if (search_pc) {
j = gen_opc_ptr - gen_opc_buf;
j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j)
Expand Down Expand Up @@ -15597,8 +15597,9 @@ gen_intermediate_code_internal (CPUMIPSState *env, TranslationBlock *tb,
if ((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0)
break;

if (gen_opc_ptr >= gen_opc_end)
if (tcg_ctx.gen_opc_ptr >= gen_opc_end) {
break;
}

if (num_insns >= max_insns)
break;
Expand Down Expand Up @@ -15630,9 +15631,9 @@ gen_intermediate_code_internal (CPUMIPSState *env, TranslationBlock *tb,
}
done_generating:
gen_icount_end(tb, num_insns);
*gen_opc_ptr = INDEX_op_end;
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
if (search_pc) {
j = gen_opc_ptr - gen_opc_buf;
j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
lj++;
while (lj <= j)
gen_opc_instr_start[lj++] = 0;
Expand Down
10 changes: 5 additions & 5 deletions target-openrisc/translate.c
Expand Up @@ -1703,7 +1703,7 @@ static inline void gen_intermediate_code_internal(OpenRISCCPU *cpu,
do {
check_breakpoint(cpu, dc);
if (search_pc) {
j = gen_opc_ptr - gen_opc_buf;
j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
if (k < j) {
k++;
while (k < j) {
Expand Down Expand Up @@ -1744,7 +1744,7 @@ static inline void gen_intermediate_code_internal(OpenRISCCPU *cpu,
}
}
} while (!dc->is_jmp
&& gen_opc_ptr < gen_opc_end
&& tcg_ctx.gen_opc_ptr < gen_opc_end
&& !cpu->env.singlestep_enabled
&& !singlestep
&& (dc->pc < next_page_start)
Expand Down Expand Up @@ -1782,9 +1782,9 @@ static inline void gen_intermediate_code_internal(OpenRISCCPU *cpu,
}

gen_icount_end(tb, num_insns);
*gen_opc_ptr = INDEX_op_end;
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
if (search_pc) {
j = gen_opc_ptr - gen_opc_buf;
j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
k++;
while (k <= j) {
gen_opc_instr_start[k++] = 0;
Expand All @@ -1799,7 +1799,7 @@ static inline void gen_intermediate_code_internal(OpenRISCCPU *cpu,
qemu_log("\n");
log_target_disas(&cpu->env, pc_start, dc->pc - pc_start, 0);
qemu_log("\nisize=%d osize=%td\n",
dc->pc - pc_start, gen_opc_ptr - gen_opc_buf);
dc->pc - pc_start, tcg_ctx.gen_opc_ptr - gen_opc_buf);
}
#endif
}
Expand Down
9 changes: 5 additions & 4 deletions target-ppc/translate.c
Expand Up @@ -9664,7 +9664,8 @@ static inline void gen_intermediate_code_internal(CPUPPCState *env,

gen_icount_start();
/* Set env in case of segfault during code fetch */
while (ctx.exception == POWERPC_EXCP_NONE && gen_opc_ptr < gen_opc_end) {
while (ctx.exception == POWERPC_EXCP_NONE
&& tcg_ctx.gen_opc_ptr < gen_opc_end) {
if (unlikely(!QTAILQ_EMPTY(&env->breakpoints))) {
QTAILQ_FOREACH(bp, &env->breakpoints, entry) {
if (bp->pc == ctx.nip) {
Expand All @@ -9674,7 +9675,7 @@ static inline void gen_intermediate_code_internal(CPUPPCState *env,
}
}
if (unlikely(search_pc)) {
j = gen_opc_ptr - gen_opc_buf;
j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j)
Expand Down Expand Up @@ -9774,9 +9775,9 @@ static inline void gen_intermediate_code_internal(CPUPPCState *env,
tcg_gen_exit_tb(0);
}
gen_icount_end(tb, num_insns);
*gen_opc_ptr = INDEX_op_end;
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
if (unlikely(search_pc)) {
j = gen_opc_ptr - gen_opc_buf;
j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
lj++;
while (lj <= j)
gen_opc_instr_start[lj++] = 0;
Expand Down
9 changes: 5 additions & 4 deletions target-s390x/translate.c
Expand Up @@ -5156,7 +5156,7 @@ static inline void gen_intermediate_code_internal(CPUS390XState *env,
}
}
if (search_pc) {
j = gen_opc_ptr - gen_opc_buf;
j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j) {
Expand All @@ -5182,7 +5182,8 @@ static inline void gen_intermediate_code_internal(CPUS390XState *env,
if (env->singlestep_enabled) {
gen_debug(&dc);
}
} while (!dc.is_jmp && gen_opc_ptr < gen_opc_end && dc.pc < next_page_start
} while (!dc.is_jmp && tcg_ctx.gen_opc_ptr < gen_opc_end
&& dc.pc < next_page_start
&& num_insns < max_insns && !env->singlestep_enabled
&& !singlestep);

Expand All @@ -5206,9 +5207,9 @@ static inline void gen_intermediate_code_internal(CPUS390XState *env,
tcg_gen_exit_tb(0);
}
gen_icount_end(tb, num_insns);
*gen_opc_ptr = INDEX_op_end;
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
if (search_pc) {
j = gen_opc_ptr - gen_opc_buf;
j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
lj++;
while (lj <= j) {
gen_opc_instr_start[lj++] = 0;
Expand Down

0 comments on commit efd7f48

Please sign in to comment.