From patchwork Tue Apr 2 04:23:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 232865 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 1FE062C0132 for ; Tue, 2 Apr 2013 15:31:21 +1100 (EST) Received: from localhost ([::1]:50141 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMssR-0003Mo-A9 for incoming@patchwork.ozlabs.org; Tue, 02 Apr 2013 00:31:19 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57991) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMslp-0003Gk-4E for qemu-devel@nongnu.org; Tue, 02 Apr 2013 00:24:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UMsll-0007QF-CK for qemu-devel@nongnu.org; Tue, 02 Apr 2013 00:24:29 -0400 Received: from mail-gg0-x229.google.com ([2607:f8b0:4002:c02::229]:37123) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMsll-0007QB-5r for qemu-devel@nongnu.org; Tue, 02 Apr 2013 00:24:25 -0400 Received: by mail-gg0-f169.google.com with SMTP id j5so3171ggn.14 for ; Mon, 01 Apr 2013 21:24:24 -0700 (PDT) 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=c2z3KLayDxDVlfA+Er2dzW3urp7O703YCX/Xmy8gp2E=; b=T+Kzv3d2WkslgLcxsbkLb/IHsOvq52XsN+un5wtBUYfCj8SVrLJoOSfxjJbPzI/jXg rY7LLrtQfAjSKm0+LVZ1EJXuizPm8ON8UxgpdKrLWuS3m6qS6DuRijIW66F+HhFXkFQg hRfrnEWqJ/FCq7t3V79Rf7thkhilQ/tfxgxuNlw0cr7q2sBwFdNDDeuyq0U7QTV/tD8e W9Vhlyk3n7aa5mbNRLkuAFm3TdBl5tcH9M2SebFMZ3wFDD6jxhE0Jx1mlT1EAgV8Fp5v rI3140Lf8hxvuj6fv+tsLSRcKbOV9CNRFZdPZpEWRdM2w8kRmS6UN+XAQxcAu5s4phA7 rN+A== X-Received: by 10.236.127.39 with SMTP id c27mr13065037yhi.134.1364876664839; Mon, 01 Apr 2013 21:24:24 -0700 (PDT) Received: from pebble.com ([12.236.175.36]) by mx.google.com with ESMTPS id z64sm32502731yhc.24.2013.04.01.21.24.23 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 01 Apr 2013 21:24:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 1 Apr 2013 21:23:20 -0700 Message-Id: <1364876610-3933-18-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1364876610-3933-1-git-send-email-rth@twiddle.net> References: <1364876610-3933-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4002:c02::229 Cc: av1474@comtv.ru, agraf@suse.de, aurelien@aurel32.net Subject: [Qemu-devel] [PATCH v3 17/27] 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 Reviewed-by: Aurelien Jarno 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 d8131ec..1806364 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 bd011b8..d8e1820 100644 --- a/tcg/ppc64/tcg-target.h +++ b/tcg/ppc64/tcg-target.h @@ -102,7 +102,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