On Tue, Oct 11, 2016 at 4:31 PM, Richard Henderson <r...@twiddle.net> 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