Revision 2e70f6ef target-cris/translate.c

b/target-cris/translate.c
77 77
TCGv env_btarget;
78 78
TCGv env_pc;
79 79

  
80
#include "gen-icount.h"
81

  
80 82
/* This is the state at translation time.  */
81 83
typedef struct DisasContext {
82 84
	CPUState *env;
......
3032 3034
	struct DisasContext *dc = &ctx;
3033 3035
	uint32_t next_page_start;
3034 3036
	target_ulong npc;
3037
        int num_insns;
3038
        int max_insns;
3035 3039

  
3036 3040
	if (!logfile)
3037 3041
		logfile = stderr;
......
3092 3096

  
3093 3097
	next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
3094 3098
	lj = -1;
3099
        num_insns = 0;
3100
        max_insns = tb->cflags & CF_COUNT_MASK;
3101
        if (max_insns == 0)
3102
            max_insns = CF_COUNT_MASK;
3103

  
3104
        gen_icount_start();
3095 3105
	do
3096 3106
	{
3097 3107
		check_breakpoint(env, dc);
......
3108 3118
			else
3109 3119
				gen_opc_pc[lj] = dc->pc;
3110 3120
			gen_opc_instr_start[lj] = 1;
3121
                        gen_opc_icount[lj] = num_insns;
3111 3122
		}
3112 3123

  
3113 3124
		/* Pretty disas.  */
......
3116 3127
			DIS(fprintf(logfile, "%x ", dc->pc));
3117 3128
		}
3118 3129

  
3130
                if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO))
3131
                    gen_io_start();
3119 3132
		dc->clear_x = 1;
3120 3133
		if (unlikely(loglevel & CPU_LOG_TB_OP))
3121 3134
			tcg_gen_debug_insn_start(dc->pc);
......
3125 3138
		if (dc->clear_x)
3126 3139
			cris_clear_x_flag(dc);
3127 3140

  
3141
                num_insns++;
3128 3142
		/* Check for delayed branches here. If we do it before
3129 3143
		   actually genereating any host code, the simulator will just
3130 3144
		   loop doing nothing for on this program location.  */
......
3151 3165
		if (!(tb->pc & 1) && env->singlestep_enabled)
3152 3166
			break;
3153 3167
	} while (!dc->is_jmp && gen_opc_ptr < gen_opc_end
3154
		 && (dc->pc < next_page_start));
3168
		 && (dc->pc < next_page_start)
3169
                 && num_insns < max_insns);
3155 3170

  
3156 3171
	npc = dc->pc;
3157 3172
	if (dc->jmp == JMP_DIRECT && !dc->delayed_branch)
3158 3173
		npc = dc->jmp_pc;
3159 3174

  
3175
        if (tb->cflags & CF_LAST_IO)
3176
            gen_io_end();
3160 3177
	/* Force an update if the per-tb cpu state has changed.  */
3161 3178
	if (dc->is_jmp == DISAS_NEXT
3162 3179
	    && (dc->cpustate_changed || !dc->flagx_known 
......
3194 3211
				break;
3195 3212
		}
3196 3213
	}
3214
        gen_icount_end(tb, num_insns);
3197 3215
	*gen_opc_ptr = INDEX_op_end;
3198 3216
	if (search_pc) {
3199 3217
		j = gen_opc_ptr - gen_opc_buf;
......
3202 3220
			gen_opc_instr_start[lj++] = 0;
3203 3221
	} else {
3204 3222
		tb->size = dc->pc - pc_start;
3223
                tb->icount = num_insns;
3205 3224
	}
3206 3225

  
3207 3226
#ifdef DEBUG_DISAS

Also available in: Unified diff