On 8/22/19 9:00 AM, Peter Maydell wrote:
> On Mon, 19 Aug 2019 at 22:38, Richard Henderson
> <[email protected]> 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 <[email protected]>
>> ---
>> 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.
Yes, I know. I tried several different alternatives, but the macro expands 3
different functions with 3 different structures, and I couldn't find a way to
work around that. Especially...
>> +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;
... with this modification. I suppose I could expand the comment above.
r~