Revision 2e70f6ef target-ppc/translate.c

b/target-ppc/translate.c
43 43
/*****************************************************************************/
44 44
/* Code translation helpers                                                  */
45 45

  
46
static TCGv cpu_env;
47

  
48
#include "gen-icount.h"
49

  
50
void ppc_translate_init(void)
51
{
52
    int done_init = 0;
53
    if (done_init)
54
        return;
55
    cpu_env = tcg_global_reg_new(TCG_TYPE_PTR, TCG_AREG0, "env");
56
    done_init = 1;
57
}
58

  
46 59
#if defined(OPTIMIZE_FPRF_UPDATE)
47 60
static uint16_t *gen_fprf_buf[OPC_BUF_SIZE];
48 61
static uint16_t **gen_fprf_ptr;
......
6168 6181
    uint16_t *gen_opc_end;
6169 6182
    int supervisor, little_endian;
6170 6183
    int j, lj = -1;
6184
    int num_insns;
6185
    int max_insns;
6171 6186

  
6172 6187
    pc_start = tb->pc;
6173 6188
    gen_opc_end = gen_opc_buf + OPC_MAX_SIZE;
......
6211 6226
    /* Single step trace mode */
6212 6227
    msr_se = 1;
6213 6228
#endif
6229
    num_insns = 0;
6230
    max_insns = tb->cflags & CF_COUNT_MASK;
6231
    if (max_insns == 0)
6232
        max_insns = CF_COUNT_MASK;
6233

  
6234
    gen_icount_start();
6214 6235
    /* Set env in case of segfault during code fetch */
6215 6236
    while (ctx.exception == POWERPC_EXCP_NONE && gen_opc_ptr < gen_opc_end) {
6216 6237
        if (unlikely(env->nb_breakpoints > 0)) {
......
6230 6251
                    gen_opc_instr_start[lj++] = 0;
6231 6252
                gen_opc_pc[lj] = ctx.nip;
6232 6253
                gen_opc_instr_start[lj] = 1;
6254
                gen_opc_icount[lj] = num_insns;
6233 6255
            }
6234 6256
        }
6235 6257
#if defined PPC_DEBUG_DISAS
......
6239 6261
                    ctx.nip, supervisor, (int)msr_ir);
6240 6262
        }
6241 6263
#endif
6264
        if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO))
6265
            gen_io_start();
6242 6266
        if (unlikely(little_endian)) {
6243 6267
            ctx.opcode = bswap32(ldl_code(ctx.nip));
6244 6268
        } else {
......
6253 6277
#endif
6254 6278
        ctx.nip += 4;
6255 6279
        table = env->opcodes;
6280
        num_insns++;
6256 6281
        handler = table[opc1(ctx.opcode)];
6257 6282
        if (is_indirect_opcode(handler)) {
6258 6283
            table = ind_table(handler);
......
6306 6331
                     ctx.exception != POWERPC_EXCP_BRANCH)) {
6307 6332
            GEN_EXCP(ctxp, POWERPC_EXCP_TRACE, 0);
6308 6333
        } else if (unlikely(((ctx.nip & (TARGET_PAGE_SIZE - 1)) == 0) ||
6309
                            (env->singlestep_enabled))) {
6334
                            (env->singlestep_enabled) ||
6335
                            num_insns >= max_insns)) {
6310 6336
            /* if we reach a page boundary or are single stepping, stop
6311 6337
             * generation
6312 6338
             */
......
6316 6342
        break;
6317 6343
#endif
6318 6344
    }
6345
    if (tb->cflags & CF_LAST_IO)
6346
        gen_io_end();
6319 6347
    if (ctx.exception == POWERPC_EXCP_NONE) {
6320 6348
        gen_goto_tb(&ctx, 0, ctx.nip);
6321 6349
    } else if (ctx.exception != POWERPC_EXCP_BRANCH) {
......
6326 6354
        /* Generate the return instruction */
6327 6355
        tcg_gen_exit_tb(0);
6328 6356
    }
6357
    gen_icount_end(tb, num_insns);
6329 6358
    *gen_opc_ptr = INDEX_op_end;
6330 6359
    if (unlikely(search_pc)) {
6331 6360
        j = gen_opc_ptr - gen_opc_buf;
......
6334 6363
            gen_opc_instr_start[lj++] = 0;
6335 6364
    } else {
6336 6365
        tb->size = ctx.nip - pc_start;
6366
        tb->icount = num_insns;
6337 6367
    }
6338 6368
#if defined(DEBUG_DISAS)
6339 6369
    if (loglevel & CPU_LOG_TB_CPU) {

Also available in: Unified diff