On 1/11/19 10:49 PM, Max Filippov wrote: > @@ -706,6 +716,17 @@ static inline void cpu_get_tb_cpu_state(CPUXtensaState > *env, target_ulong *pc, > *flags |= xtensa_get_ring(env); > if (env->sregs[PS] & PS_EXCM) { > *flags |= XTENSA_TBFLAG_EXCM; > + } else if (xtensa_option_enabled(env->config, XTENSA_OPTION_LOOP)) { > + target_ulong lend_dist = env->sregs[LEND] - (env->pc & > LINKABLE_MASK); > + > + if (lend_dist < LINKABLE_SIZE + env->config->max_insn_size) { > + target_ulong lbeg_off = env->sregs[LEND] - env->sregs[LBEG]; > + > + *cs_base = lend_dist; > + if (lbeg_off < 256) { > + *cs_base |= lbeg_off << XTENSA_CSBASE_LBEG_OFF_SHIFT; > + } > + } > } > if (xtensa_option_enabled(env->config, XTENSA_OPTION_EXTENDED_L32R) && > (env->sregs[LITBASE] & 1)) {
I think the only other thing that would be nice is some comment that describes the loop scheme. I can follow it now, but it took a while of re-reading. In particular, the fact that 0 means "disabled", and happens to work because we (correctly) only check for LEND at the end of an instruction. Thus the offset from pc_first will always be non-zero when we check. r~