On Mon, 19 Aug 2019 at 22:38, Richard Henderson <richard.hender...@linaro.org> wrote: > > Convert the register shifted by immediate form of the data > processing insns. For A32, we cannot yet remove any code > because the legacy decoder intertwines the reg-shifted-reg > and immediate forms. > > Signed-off-by: Richard Henderson <richard.hender...@linaro.org> > --- > target/arm/translate.c | 229 ++++++++++++++++++++++++++++++++++------- > target/arm/a32.decode | 28 +++++ > target/arm/t32.decode | 43 ++++++++ > 3 files changed, 264 insertions(+), 36 deletions(-)
> +#define DO_ANY3(NAME, OP, L, K) \ > + static bool trans_##NAME##_rrri(DisasContext *s, arg_s_rrr_shi *a) \ > + { StoreRegKind k = (K); return op_s_rrr_shi(s, a, OP, L, k); } It's a bit non-obvious that we can return early via the expression K here (for the "trying to do an old-style exception return in usermode" case for SUB and MOV), but it does put the check early where we need it. > +DO_ANY3(SUB, a->s ? gen_sub_CC : tcg_gen_sub_i32, false, > + ({ > + StoreRegKind ret = STREG_NORMAL; > + if (a->rd == 15 && a->s) { > + /* > + * See ALUExceptionReturn: > + * In User mode, UNPREDICTABLE; we choose UNDEF. > + * In Hyp mode, UNDEFINED. > + */ > + if (IS_USER(s) || s->current_el == 2) { > + return false; > + } > + /* There is no writeback of nzcv to PSTATE. */ > + a->s = 0; > + ret = STREG_EXC_RET; > + } else if (a->rd == 13 && a->rn == 13) { > + ret = STREG_SP_CHECK; > + } > + ret; > + })) It turns out that the decode for Thumb means that we don't need to specifically check that this is Arm mode before allowing the ALUExceptionReturn handling. Reviewed-by: Peter Maydell <peter.mayd...@linaro.org> thanks -- PMM