From patchwork Mon Feb 18 20:21:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 221529 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 30ED52C0291 for ; Tue, 19 Feb 2013 09:28:46 +1100 (EST) Received: from localhost ([::1]:34272 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7XEU-0006je-Qn for incoming@patchwork.ozlabs.org; Mon, 18 Feb 2013 15:22:38 -0500 Received: from eggs.gnu.org ([208.118.235.92]:38043) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7XDi-0005Lt-Pp for qemu-devel@nongnu.org; Mon, 18 Feb 2013 15:21:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U7XDe-00027d-Pr for qemu-devel@nongnu.org; Mon, 18 Feb 2013 15:21:50 -0500 Received: from mail-pa0-f45.google.com ([209.85.220.45]:43787) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U7XDe-00027T-JV for qemu-devel@nongnu.org; Mon, 18 Feb 2013 15:21:46 -0500 Received: by mail-pa0-f45.google.com with SMTP id kl14so2948535pab.18 for ; Mon, 18 Feb 2013 12:21:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=HtGwVA3bN146Yxyj9VS2ti2CXBgdk3RlD0Hi/AuE+Wk=; b=m18OxIcU56yxCKu23zKyiqvdh+SaKC49ButLC9A4QvbCF9tYufBFQGWXn6bKTDFyUN 9GYAlXSaMFNkcY5EvIof6slwSmR2eYBo4L1Jij7W92+LN9NEhJ3ZlTzzW5NypoD/bLM5 RABWM1vRcQssHW/HQag+PygyHMyU3QuQokBFdR3zd3cZHR8S+TggQRPOeVQmKjHon9w/ Q/AaJbaB8MC399Th4TNKyzuWhcfek0DrOS1b8dgrWeRpRZfIsMIsqiPhwPkCQcYkpfeu 7D17AzbUuqnegwxkJWgmUP+JbtBTjhxZ+yMwAnxNVaB/LbUlNDtD/emPhv2CDAtw07Ot gJuw== X-Received: by 10.68.232.69 with SMTP id tm5mr33364168pbc.150.1361218905870; Mon, 18 Feb 2013 12:21:45 -0800 (PST) Received: from pebble.twiddle.net (50-194-63-110-static.hfc.comcastbusiness.net. [50.194.63.110]) by mx.google.com with ESMTPS id z6sm78739077pav.3.2013.02.18.12.21.44 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 18 Feb 2013 12:21:45 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 18 Feb 2013 12:21:06 -0800 Message-Id: <1361218873-1754-18-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1361218873-1754-1-git-send-email-rth@twiddle.net> References: <1361218873-1754-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.220.45 Cc: av1474@comtv.ru Subject: [Qemu-devel] [PATCH 17/24] tcg-ppc64: Implement bswap64 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Richard Henderson --- tcg/ppc64/tcg-target.c | 35 +++++++++++++++++++++++++++++++++++ tcg/ppc64/tcg-target.h | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/tcg/ppc64/tcg-target.c b/tcg/ppc64/tcg-target.c index 723cc77..576effc 100644 --- a/tcg/ppc64/tcg-target.c +++ b/tcg/ppc64/tcg-target.c @@ -1706,6 +1706,40 @@ static void tcg_out_op (TCGContext *s, TCGOpcode opc, const TCGArg *args, } break; + case INDEX_op_bswap64_i64: + a0 = args[0], a1 = args[1], a2 = 0; + if (a0 == a1) { + a0 = 0; + a2 = a1; + } + + /* a1 = # abcd efgh */ + /* a0 = rl32(a1, 8) # 0000 fghe */ + tcg_out_rlw(s, RLWINM, a0, a1, 8, 0, 31); + /* a0 = dep(a0, rl32(a1, 24), 0xff000000) # 0000 hghe */ + tcg_out_rlw(s, RLWIMI, a0, a1, 24, 0, 7); + /* a0 = dep(a0, rl32(a1, 24), 0x0000ff00) # 0000 hgfe */ + tcg_out_rlw(s, RLWIMI, a0, a1, 24, 16, 23); + + /* a0 = rl64(a0, 32) # hgfe 0000 */ + /* a2 = rl64(a1, 32) # efgh abcd */ + tcg_out_rld(s, RLDICL, a0, a0, 32, 0); + tcg_out_rld(s, RLDICL, a2, a1, 32, 0); + + /* a0 = dep(a0, rl32(a2, 8), 0xffffffff) # hgfe bcda */ + tcg_out_rlw(s, RLWIMI, a0, a2, 8, 0, 31); + /* a0 = dep(a0, rl32(a2, 24), 0xff000000) # hgfe dcda */ + tcg_out_rlw(s, RLWIMI, a0, a2, 24, 0, 7); + /* a0 = dep(a0, rl32(a2, 24), 0x0000ff00) # hgfe dcba */ + tcg_out_rlw(s, RLWIMI, a0, a2, 24, 16, 23); + + if (a0 == 0) { + tcg_out_mov(s, TCG_TYPE_I64, args[0], a0); + /* Revert the source rotate that we performed above. */ + tcg_out_rld(s, RLDICL, a1, a1, 32, 0); + } + break; + default: tcg_dump_ops (s); tcg_abort (); @@ -1816,6 +1850,7 @@ static const TCGTargetOpDef ppc_op_defs[] = { { INDEX_op_bswap16_i64, { "r", "r" } }, { INDEX_op_bswap32_i32, { "r", "r" } }, { INDEX_op_bswap32_i64, { "r", "r" } }, + { INDEX_op_bswap64_i64, { "r", "r" } }, { -1 }, }; diff --git a/tcg/ppc64/tcg-target.h b/tcg/ppc64/tcg-target.h index 9e76e77..f283dc8 100644 --- a/tcg/ppc64/tcg-target.h +++ b/tcg/ppc64/tcg-target.h @@ -98,7 +98,7 @@ typedef enum { #define TCG_TARGET_HAS_ext32u_i64 1 #define TCG_TARGET_HAS_bswap16_i64 1 #define TCG_TARGET_HAS_bswap32_i64 1 -#define TCG_TARGET_HAS_bswap64_i64 0 +#define TCG_TARGET_HAS_bswap64_i64 1 #define TCG_TARGET_HAS_not_i64 1 #define TCG_TARGET_HAS_neg_i64 1 #define TCG_TARGET_HAS_andc_i64 0