From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45394) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiUk0-0000Rw-CO for qemu-devel@nongnu.org; Fri, 31 May 2013 15:11:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UiUjw-0001jj-Pm for qemu-devel@nongnu.org; Fri, 31 May 2013 15:11:56 -0400 Received: from mail-vc0-f182.google.com ([209.85.220.182]:38476) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiUjw-0001jb-KZ for qemu-devel@nongnu.org; Fri, 31 May 2013 15:11:52 -0400 Received: by mail-vc0-f182.google.com with SMTP id gf12so1331154vcb.13 for ; Fri, 31 May 2013 12:11:52 -0700 (PDT) Sender: Richard Henderson Message-ID: <51A8F5F4.3060407@twiddle.net> Date: Fri, 31 May 2013 12:11:48 -0700 From: Richard Henderson MIME-Version: 1.0 References: <51A8E339.5000500@huawei.com> <51A8E597.4040608@huawei.com> In-Reply-To: <51A8E597.4040608@huawei.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/4] tcg/aarch64: implement byte swap operations List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jani Kokkonen Cc: Laurent Desnogues , Peter Maydell , Claudio Fontana , qemu-devel@nongnu.org On 05/31/2013 11:01 AM, Jani Kokkonen wrote: > +static inline void tcg_out_rev(TCGContext *s, int ext, TCGReg rd, TCGReg rm) > +{ > + /* using REV 0x5ac00800 */ > + unsigned int base = ext ? 0xdac00c00 : 0x5ac00800; > + tcg_out32(s, base | rm << 5 | rd); > +} > + > +static inline void tcg_out_rev16(TCGContext *s, int ext, TCGReg rd, TCGReg rm) > +{ > + /* using REV16 0x5ac00400 */ > + unsigned int base = ext ? 0xdac00400 : 0x5ac00400; > + tcg_out32(s, base | rm << 5 | rd); > +} > + > +static inline void tcg_out_rev32(TCGContext *s, TCGReg rd, TCGReg rm) > +{ > + /* using REV32 0xdac00800 */ > + unsigned int base = 0xdac00800; > + tcg_out32(s, base | rm << 5 | rd); > +} You don't actually need rev32. > * bswap32_i32/i64 t0, t1 > > 32 bit byte swap on a 32/64 bit value. With a 64 bit value, it assumes that > the four high order bytes are set to zero. The fact that the high order bytes are known to be zero means that you can always use tcg_out_rev with ext=0. case INDEX_op_bswap64_i64: ext = 1; /* FALLTHRU */ case INDEX_op_bswap32_i64: case INDEX_op_bswap32_i32: tcg_out_rev(s, ext, args[0], args[1]); break; case INDEX_op_bswap16_i64: case INDEX_op_bswap16_i32: tcg_out_rev16(s, 0, args[0], args[1]); break; r~