On 3/13/20 2:32 PM, LIU Zhiwei wrote: >>> +/* check functions */ >>> +static bool vext_check_isa_ill(DisasContext *s, target_ulong isa) >>> +{ >>> + return !s->vill && ((s->misa & isa) == isa); >>> +} >> I don't think we need a new function to check ISA. > I don't think so. > > Although there is a riscv_has_ext(env, isa) in cpu.h, it is not proper in this > file, > as it is in translation time and usually DisasContext is used here instead > of CPURISCVState.
In translate.c we have has_ext() for this purpose. I think you don't need to test has_ext(s, RVV) at all, because in cpu_get_tb_cpu_state(), you already tested RVV, and set VILL if RVV was not present. Thus testing vill here is sufficient. A comment here to remind us of that fact would be appropriate. For those few cases where you have an extension beyond RVV, e.g. amo_check() I think you should simply use has_ext() like so: static bool amo_check(DisasContext *s, arg_rwdvm *a) { return (!s->vill && has_ext(s, RVA) && ...); } r~