From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MjGlz-0001Cq-2d for qemu-devel@nongnu.org; Thu, 03 Sep 2009 14:11:03 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MjGly-0001CG-FM for qemu-devel@nongnu.org; Thu, 03 Sep 2009 14:11:02 -0400 Received: from [199.232.76.173] (port=44398 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MjGly-0001CD-9W for qemu-devel@nongnu.org; Thu, 03 Sep 2009 14:11:02 -0400 Received: from ey-out-1920.google.com ([74.125.78.147]:11282) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MjGlx-0008Gq-VK for qemu-devel@nongnu.org; Thu, 03 Sep 2009 14:11:02 -0400 Received: by ey-out-1920.google.com with SMTP id 13so468974eye.14 for ; Thu, 03 Sep 2009 11:11:00 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <200909031110.n83BAwuM023891@d03av03.boulder.ibm.com> References: <200909031110.n83BAwuM023891@d03av03.boulder.ibm.com> From: Blue Swirl Date: Thu, 3 Sep 2009 21:10:40 +0300 Message-ID: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] Re: [Qemu-commits] [COMMIT 968a40f] microblaze: Trap on unaligned data accesses. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Edgar E. Iglesias" Cc: qemu-devel On Thu, Sep 3, 2009 at 2:11 PM, Anthony Liguori wrote: > From: Edgar E. Iglesias > +void helper_memalign(uint32_t addr, uint32_t dr, uint32_t wr, uint32_t s= ize) > +{ > + =C2=A0 =C2=A0uint32_t mask; > + > + =C2=A0 =C2=A0switch (size) { > + =C2=A0 =C2=A0 =C2=A0 =C2=A0case 4: mask =3D 3; break; > + =C2=A0 =C2=A0 =C2=A0 =C2=A0case 2: mask =3D 1; break; > + =C2=A0 =C2=A0 =C2=A0 =C2=A0default: > + =C2=A0 =C2=A0 =C2=A0 =C2=A0case 1: mask =3D 0; break; > + =C2=A0 =C2=A0} For additional performance (and to avoid the check for mask =3D=3D 0 case ;-)), you could perform most of the math above during translation. Sparc32 actually avoids most of these explicit tests, but I still can't understand Fabrice's magic that made it possible.