Revision 2e70f6ef target-sh4/translate.c

b/target-sh4/translate.c
56 56
    BS_EXCP     = 3, /* We reached an exception condition */
57 57
};
58 58

  
59
static TCGv cpu_env;
60

  
61
#include "gen-icount.h"
62

  
63
void sh4_translate_init()
64
{
65
    static int done_init = 0;
66
    if (done_init)
67
        return;
68
    cpu_env = tcg_global_reg_new(TCG_TYPE_PTR, TCG_AREG0, "env");
69
    done_init = 1;
70
}
71

  
59 72
#ifdef CONFIG_USER_ONLY
60 73

  
61 74
#define GEN_OP_LD(width, reg) \
......
143 156
    if (!env)
144 157
	return NULL;
145 158
    cpu_exec_init(env);
159
    sh4_translate_init();
146 160
    cpu_sh4_reset(env);
147 161
    tlb_flush(env, 1);
148 162
    return env;
......
1189 1203
    target_ulong pc_start;
1190 1204
    static uint16_t *gen_opc_end;
1191 1205
    int i, ii;
1206
    int num_insns;
1207
    int max_insns;
1192 1208

  
1193 1209
    pc_start = tb->pc;
1194 1210
    gen_opc_end = gen_opc_buf + OPC_MAX_SIZE;
......
1213 1229
#endif
1214 1230

  
1215 1231
    ii = -1;
1232
    num_insns = 0;
1233
    max_insns = tb->cflags & CF_COUNT_MASK;
1234
    if (max_insns == 0)
1235
        max_insns = CF_COUNT_MASK;
1236
    gen_icount_start();
1216 1237
    while (ctx.bstate == BS_NONE && gen_opc_ptr < gen_opc_end) {
1217 1238
	if (env->nb_breakpoints > 0) {
1218 1239
	    for (i = 0; i < env->nb_breakpoints; i++) {
......
1235 1256
            gen_opc_pc[ii] = ctx.pc;
1236 1257
            gen_opc_hflags[ii] = ctx.flags;
1237 1258
            gen_opc_instr_start[ii] = 1;
1259
            gen_opc_icount[ii] = num_insns;
1238 1260
        }
1261
        if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO))
1262
            gen_io_start();
1239 1263
#if 0
1240 1264
	fprintf(stderr, "Loading opcode at address 0x%08x\n", ctx.pc);
1241 1265
	fflush(stderr);
1242 1266
#endif
1243 1267
	ctx.opcode = lduw_code(ctx.pc);
1244 1268
	decode_opc(&ctx);
1269
        num_insns++;
1245 1270
	ctx.pc += 2;
1246 1271
	if ((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0)
1247 1272
	    break;
1248 1273
	if (env->singlestep_enabled)
1249 1274
	    break;
1275
        if (num_insns >= max_insns)
1276
            break;
1250 1277
#ifdef SH4_SINGLE_STEP
1251 1278
	break;
1252 1279
#endif
1253 1280
    }
1281
    if (tb->cflags & CF_LAST_IO)
1282
        gen_io_end();
1254 1283
    if (env->singlestep_enabled) {
1255 1284
        gen_op_debug();
1256 1285
    } else {
......
1274 1303
	}
1275 1304
    }
1276 1305

  
1306
    gen_icount_end(tb, num_insns);
1277 1307
    *gen_opc_ptr = INDEX_op_end;
1278 1308
    if (search_pc) {
1279 1309
        i = gen_opc_ptr - gen_opc_buf;
......
1282 1312
            gen_opc_instr_start[ii++] = 0;
1283 1313
    } else {
1284 1314
        tb->size = ctx.pc - pc_start;
1315
        tb->icount = num_insns;
1285 1316
    }
1286 1317

  
1287 1318
#ifdef DEBUG_DISAS

Also available in: Unified diff