Skip to content

Commit

Permalink
target-*: Unconditionally emit tcg_gen_insn_start
Browse files Browse the repository at this point in the history
While we're at it, emit the opcode adjacent to where we currently
record data for search_pc.  This puts gen_io_start et al on the
"correct" side of the marker.

Reviewed-by: Aurelien Jarno <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
  • Loading branch information
rth7680 committed Oct 7, 2015
1 parent 765b842 commit 667b8e2
Show file tree
Hide file tree
Showing 20 changed files with 41 additions and 81 deletions.
6 changes: 2 additions & 4 deletions target-alpha/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2933,16 +2933,14 @@ static inline void gen_intermediate_code_internal(AlphaCPU *cpu,
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = num_insns;
}
tcg_gen_insn_start(ctx.pc);

if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) {
gen_io_start();
}
insn = cpu_ldl_code(env, ctx.pc);
num_insns++;

if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_insn_start(ctx.pc);
}

TCGV_UNUSED_I64(ctx.zero);
TCGV_UNUSED_I64(ctx.sink);
TCGV_UNUSED_I64(ctx.lit);
Expand Down
5 changes: 1 addition & 4 deletions target-arm/translate-a64.c
Original file line number Diff line number Diff line change
Expand Up @@ -11103,15 +11103,12 @@ void gen_intermediate_code_internal_a64(ARMCPU *cpu,
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = num_insns;
}
tcg_gen_insn_start(dc->pc);

if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) {
gen_io_start();
}

if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_insn_start(dc->pc);
}

if (dc->ss_active && !dc->pstate_ss) {
/* Singlestep state is Active-pending.
* If we're in this state at the start of a TB then either
Expand Down
5 changes: 1 addition & 4 deletions target-arm/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -11348,14 +11348,11 @@ static inline void gen_intermediate_code_internal(ARMCPU *cpu,
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = num_insns;
}
tcg_gen_insn_start(dc->pc);

if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO))
gen_io_start();

if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_insn_start(dc->pc);
}

if (dc->ss_active && !dc->pstate_ss) {
/* Singlestep state is Active-pending.
* If we're in this state at the start of a TB then either
Expand Down
5 changes: 1 addition & 4 deletions target-cris/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2994,10 +2994,6 @@ static unsigned int crisv32_decoder(CPUCRISState *env, DisasContext *dc)
int insn_len = 2;
int i;

if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_insn_start(dc->pc);
}

/* Load a halfword onto the instruction register. */
dc->ir = cris_fetch(env, dc, dc->pc, 2, 0);

Expand Down Expand Up @@ -3197,6 +3193,7 @@ gen_intermediate_code_internal(CRISCPU *cpu, TranslationBlock *tb,
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = num_insns;
}
tcg_gen_insn_start(dc->pc);

/* Pretty disas. */
LOG_DIS("%8.8x:\t", dc->pc);
Expand Down
3 changes: 0 additions & 3 deletions target-cris/translate_v10.c
Original file line number Diff line number Diff line change
Expand Up @@ -1199,9 +1199,6 @@ static unsigned int crisv10_decoder(CPUCRISState *env, DisasContext *dc)
{
unsigned int insn_len = 2;

if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP)))
tcg_gen_insn_start(dc->pc);

/* Load a halfword onto the instruction register. */
dc->ir = cpu_lduw_code(env, dc->pc);

Expand Down
5 changes: 2 additions & 3 deletions target-i386/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -4401,9 +4401,6 @@ static target_ulong disas_insn(CPUX86State *env, DisasContext *s,
target_ulong next_eip, tval;
int rex_w, rex_r;

if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_insn_start(pc_start);
}
s->pc = pc_start;
prefixes = 0;
s->override = -1;
Expand Down Expand Up @@ -7962,6 +7959,8 @@ static inline void gen_intermediate_code_internal(X86CPU *cpu,
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = num_insns;
}
tcg_gen_insn_start(pc_ptr);

if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO))
gen_io_start();

Expand Down
5 changes: 1 addition & 4 deletions target-lm32/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1005,10 +1005,6 @@ static const DecoderInfo decinfo[] = {

static inline void decode(DisasContext *dc, uint32_t ir)
{
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_insn_start(dc->pc);
}

dc->ir = ir;
LOG_DIS("%8.8x\t", dc->ir);

Expand Down Expand Up @@ -1106,6 +1102,7 @@ void gen_intermediate_code_internal(LM32CPU *cpu,
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = num_insns;
}
tcg_gen_insn_start(dc->pc);

/* Pretty disas. */
LOG_DIS("%8.8x:\t", dc->pc);
Expand Down
10 changes: 5 additions & 5 deletions target-m68k/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2955,10 +2955,6 @@ static void disas_m68k_insn(CPUM68KState * env, DisasContext *s)
{
uint16_t insn;

if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_insn_start(s->pc);
}

insn = cpu_lduw_code(env, s->pc);
s->pc += 2;

Expand Down Expand Up @@ -3025,8 +3021,12 @@ gen_intermediate_code_internal(M68kCPU *cpu, TranslationBlock *tb,
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = num_insns;
}
if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO))
tcg_gen_insn_start(dc->pc);

if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) {
gen_io_start();
}

dc->insn_pc = dc->pc;
disas_m68k_insn(env, dc);
num_insns++;
Expand Down
5 changes: 1 addition & 4 deletions target-microblaze/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1588,10 +1588,6 @@ static inline void decode(DisasContext *dc, uint32_t ir)
{
int i;

if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_insn_start(dc->pc);
}

dc->ir = ir;
LOG_DIS("%8.8x\t", dc->ir);

Expand Down Expand Up @@ -1718,6 +1714,7 @@ gen_intermediate_code_internal(MicroBlazeCPU *cpu, TranslationBlock *tb,
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = num_insns;
}
tcg_gen_insn_start(dc->pc);

/* Pretty disas. */
LOG_DIS("%8.8x:\t", dc->pc);
Expand Down
9 changes: 4 additions & 5 deletions target-mips/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -18904,10 +18904,6 @@ static void decode_opc(CPUMIPSState *env, DisasContext *ctx)
gen_set_label(l1);
}

if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_insn_start(ctx->pc);
}

op = MASK_OP_MAJOR(ctx->opcode);
rs = (ctx->opcode >> 21) & 0x1f;
rt = (ctx->opcode >> 16) & 0x1f;
Expand Down Expand Up @@ -19622,8 +19618,11 @@ gen_intermediate_code_internal(MIPSCPU *cpu, TranslationBlock *tb,
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = num_insns;
}
if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO))
tcg_gen_insn_start(ctx.pc);

if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) {
gen_io_start();
}

is_slot = ctx.hflags & MIPS_HFLAG_BMASK;
if (!(ctx.hflags & MIPS_HFLAG_M16)) {
Expand Down
6 changes: 2 additions & 4 deletions target-moxie/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,6 @@ static int decode_opc(MoxieCPU *cpu, DisasContext *ctx)
/* Set the default instruction length. */
int length = 2;

if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_insn_start(ctx->pc);
}

/* Examine the 16-bit opcode. */
opcode = ctx->opcode;

Expand Down Expand Up @@ -865,6 +861,8 @@ gen_intermediate_code_internal(MoxieCPU *cpu, TranslationBlock *tb,
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = num_insns;
}
tcg_gen_insn_start(ctx.pc);

ctx.opcode = cpu_lduw_code(env, ctx.pc);
ctx.pc += decode_opc(cpu, &ctx);
num_insns++;
Expand Down
5 changes: 1 addition & 4 deletions target-openrisc/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1687,10 +1687,7 @@ static inline void gen_intermediate_code_internal(OpenRISCCPU *cpu,
tcg_ctx.gen_opc_instr_start[k] = 1;
tcg_ctx.gen_opc_icount[k] = num_insns;
}

if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_insn_start(dc->pc);
}
tcg_gen_insn_start(dc->pc);

if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) {
gen_io_start();
Expand Down
5 changes: 2 additions & 3 deletions target-ppc/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -11502,6 +11502,8 @@ static inline void gen_intermediate_code_internal(PowerPCCPU *cpu,
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = num_insns;
}
tcg_gen_insn_start(ctx.nip);

LOG_DISAS("----------------\n");
LOG_DISAS("nip=" TARGET_FMT_lx " super=%d ir=%d\n",
ctx.nip, ctx.mem_idx, (int)msr_ir);
Expand All @@ -11515,9 +11517,6 @@ static inline void gen_intermediate_code_internal(PowerPCCPU *cpu,
LOG_DISAS("translate opcode %08x (%02x %02x %02x) (%s)\n",
ctx.opcode, opc1(ctx.opcode), opc2(ctx.opcode),
opc3(ctx.opcode), ctx.le_mode ? "little" : "big");
if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_insn_start(ctx.nip);
}
ctx.nip += 4;
table = env->opcodes;
num_insns++;
Expand Down
6 changes: 2 additions & 4 deletions target-s390x/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -5370,14 +5370,12 @@ static inline void gen_intermediate_code_internal(S390CPU *cpu,
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = num_insns;
}
tcg_gen_insn_start(dc.pc);

if (++num_insns == max_insns && (tb->cflags & CF_LAST_IO)) {
gen_io_start();
}

if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_insn_start(dc.pc);
}

status = NO_EXIT;
if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {
QTAILQ_FOREACH(bp, &cs->breakpoints, entry) {
Expand Down
14 changes: 5 additions & 9 deletions target-sh4/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1790,10 +1790,6 @@ static void decode_opc(DisasContext * ctx)
{
uint32_t old_flags = ctx->flags;

if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_insn_start(ctx->pc);
}

_decode_opc(ctx);

if (old_flags & (DELAY_SLOT | DELAY_SLOT_CONDITIONAL)) {
Expand Down Expand Up @@ -1876,12 +1872,12 @@ gen_intermediate_code_internal(SuperHCPU *cpu, TranslationBlock *tb,
tcg_ctx.gen_opc_instr_start[ii] = 1;
tcg_ctx.gen_opc_icount[ii] = num_insns;
}
if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO))
tcg_gen_insn_start(ctx.pc);

if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) {
gen_io_start();
#if 0
fprintf(stderr, "Loading opcode at address 0x%08x\n", ctx.pc);
fflush(stderr);
#endif
}

ctx.opcode = cpu_lduw_code(env, ctx.pc);
decode_opc(&ctx);
num_insns++;
Expand Down
10 changes: 5 additions & 5 deletions target-sparc/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2482,10 +2482,6 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)
TCGv_i64 cpu_src1_64, cpu_src2_64, cpu_dst_64;
target_long simm;

if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_insn_start(dc->pc);
}

opc = GET_FIELD(insn, 0, 1);
rd = GET_FIELD(insn, 2, 6);

Expand Down Expand Up @@ -5271,8 +5267,12 @@ static inline void gen_intermediate_code_internal(SPARCCPU *cpu,
tcg_ctx.gen_opc_icount[lj] = num_insns;
}
}
if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO))
tcg_gen_insn_start(dc->pc);

if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) {
gen_io_start();
}

last_pc = dc->pc;
insn = cpu_ldl_code(env, dc->pc);

Expand Down
6 changes: 2 additions & 4 deletions target-tilegx/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2008,10 +2008,6 @@ static void translate_one_bundle(DisasContext *dc, uint64_t bundle)
}
dc->num_wb = 0;

if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_insn_start(dc->pc);
}

qemu_log_mask(CPU_LOG_TB_IN_ASM, " %" PRIx64 ": { ", dc->pc);
if (get_Mode(bundle)) {
notice_excp(dc, bundle, "y0", decode_y0(dc, bundle));
Expand Down Expand Up @@ -2100,6 +2096,8 @@ static inline void gen_intermediate_code_internal(TileGXCPU *cpu,
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = num_insns;
}
tcg_gen_insn_start(dc->pc);

translate_one_bundle(dc, cpu_ldq_data(env, dc->pc));

if (dc->exit_tb) {
Expand Down
2 changes: 2 additions & 0 deletions target-tricore/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -8292,6 +8292,8 @@ gen_intermediate_code_internal(TriCoreCPU *cpu, struct TranslationBlock *tb,
tcg_clear_temp_count();
gen_tb_start(tb);
while (ctx.bstate == BS_NONE) {
tcg_gen_insn_start(ctx.pc);

ctx.opcode = cpu_ldl_code(env, ctx.pc);
decode_opc(env, &ctx, 0);

Expand Down
5 changes: 1 addition & 4 deletions target-unicore32/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1794,10 +1794,6 @@ static void disas_uc32_insn(CPUUniCore32State *env, DisasContext *s)
UniCore32CPU *cpu = uc32_env_get_cpu(env);
unsigned int insn;

if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_insn_start(s->pc);
}

insn = cpu_ldl_code(env, s->pc);
s->pc += 4;

Expand Down Expand Up @@ -1941,6 +1937,7 @@ static inline void gen_intermediate_code_internal(UniCore32CPU *cpu,
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = num_insns;
}
tcg_gen_insn_start(dc->pc);

if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) {
gen_io_start();
Expand Down
5 changes: 1 addition & 4 deletions target-xtensa/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -3076,10 +3076,7 @@ void gen_intermediate_code_internal(XtensaCPU *cpu,
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = insn_count;
}

if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) {
tcg_gen_insn_start(dc.pc);
}
tcg_gen_insn_start(dc.pc);

++dc.ccount_delta;

Expand Down

0 comments on commit 667b8e2

Please sign in to comment.