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: Richard Henderson
Subject: Re: [Qemu-devel] [PATCH 26/29] target-sparc: store the UA2005 entries in sun4u format
Date: Tue, 11 Oct 2016 09:31:46 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0

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.


r~



reply via email to

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