Received: from eggs.gnu.org ([2001:4830:134:3::10]:51899) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bty5x-0003Ql-L6 for qemu-devel@nongnu.org; Tue, 11 Oct 2016 10:31:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bty5t-0001vd-H1 for qemu-devel@nongnu.org; Tue, 11 Oct 2016 10:31:52 -0400 Received: from mail-qt0-x244.google.com ([2607:f8b0:400d:c0d::244]:33442) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bty5t-0001vW-Ch for qemu-devel@nongnu.org; Tue, 11 Oct 2016 10:31:49 -0400 Received: by mail-qt0-x244.google.com with SMTP id m5so662757qtb.0 for ; Tue, 11 Oct 2016 07:31:49 -0700 (PDT) Sender: Richard Henderson References: <1475316333-9776-1-git-send-email-atar4qemu@gmail.com> <1475316333-9776-27-git-send-email-atar4qemu@gmail.com> From: Richard Henderson Message-ID: Date: Tue, 11 Oct 2016 09:31:46 -0500 MIME-Version: 1.0 In-Reply-To: <1475316333-9776-27-git-send-email-atar4qemu@gmail.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 26/29] target-sparc: store the UA2005 entries in sun4u format List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Artyom Tarasenko , qemu-devel@nongnu.org Cc: Mark Cave-Ayland 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~