qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 26/29] target-sparc: store the UA2005 entries in


From: Artyom Tarasenko
Subject: Re: [Qemu-devel] [PATCH 26/29] target-sparc: store the UA2005 entries in sun4u format
Date: Wed, 12 Oct 2016 13:28:48 +0200

On Tue, Oct 11, 2016 at 4:31 PM, Richard Henderson <address@hidden> wrote:
> On 10/01/2016 05:05 AM, Artyom Tarasenko wrote:
>>
>> +    sun4u_tte = TTE_PA(sun4v_tte) | (sun4v_tte & TTE_VALID_BIT);
>> +    sun4u_tte |= (sun4v_tte & 3ULL) << 61;
>> +    sun4u_tte |= (sun4v_tte & TTE_NFO_BIT_UA2005) >> 2;
>> +    sun4u_tte |= (sun4v_tte & TTE_USED_BIT_UA2005) >> 6;
>> +    sun4u_tte |= (sun4v_tte & TTE_W_OK_BIT_UA2005) >> 5;
>> +    sun4u_tte |= (sun4v_tte & TTE_SIDEEFFECT_BIT_UA2005) >> 8;
>> +    sun4u_tte |= (sun4v_tte & TTE_PRIV_BIT_UA2005) >> 6;
>> +    sun4u_tte |= (sun4v_tte & TTE_LOCKED_BIT_UA2005) >> 55;
>
>
> I think it might be clearer to use
>
> #define CONVERT_BIT(X, SRC, DST) \
>     (SRC > DST ? (X) / (SRC / DST) & (DST) : ((X) & SRC) * (DST / SRC))
>
>   sun4u_tte |= CONVERT_BIT(sun4v_tte, TTE_NFO_BIT_UA2005, TTE_NFO_BIT);
>
> The compiler folds all of the constants down to the same code, but you don't
> have to manually compute the shift counts.

Nice! Will do.


-- 
Regards,
Artyom Tarasenko

SPARC and PPC PReP under qemu blog: http://tyom.blogspot.com/search/label/qemu



reply via email to

[Prev in Thread] Current Thread [Next in Thread]