From patchwork Thu Feb 2 05:13:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 722751 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vDT0K14FVz9ryn for ; Thu, 2 Feb 2017 16:22:41 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="neHcJzFG"; dkim-atps=neutral Received: from localhost ([::1]:54242 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZ9qw-0006Wm-Gp for incoming@patchwork.ozlabs.org; Thu, 02 Feb 2017 00:22:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51130) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZ9jg-0007AH-Kf for qemu-devel@nongnu.org; Thu, 02 Feb 2017 00:15:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZ9je-0003X7-7T for qemu-devel@nongnu.org; Thu, 02 Feb 2017 00:15:08 -0500 Received: from ozlabs.org ([103.22.144.67]:56647) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZ9jd-0003UA-NL; Thu, 02 Feb 2017 00:15:06 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3vDSqM440Dz9s7V; Thu, 2 Feb 2017 16:14:54 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1486012495; bh=fi2C1q68bXclw7CwTUG4CwNZXwc3jVQGKXSkpzAtJ4s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=neHcJzFGhnt6naGN+abxhWHMlJFdD0EldDSPJUsTs69FVOqvaifXF1PaXIp9iyMqn cwf4DXVQfvO5YrbkkNrlYCo4v18kIklvyUiRlMtzScHt7mDyrCGcUXSmXHW5BzeVLz QkyIyxJHoy2JM0kA2kVCdb2jVYY7zaBwpFBZBjTk= From: David Gibson To: peter.maydell@linaro.org Date: Thu, 2 Feb 2017 16:13:11 +1100 Message-Id: <20170202051445.5735-14-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170202051445.5735-1-david@gibson.dropbear.id.au> References: <20170202051445.5735-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 013/107] target-ppc: Implement bcdsetsgn. instruction X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, thuth@redhat.com, qemu-devel@nongnu.org, Jose Ricardo Ziviani , mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Jose Ricardo Ziviani bcdsetsgn.: Decimal set sign. This instruction copies the register value to the result register but adjust the signal according to the preferred sign value. Signed-off-by: Jose Ricardo Ziviani Reviewed-by: David Gibson Signed-off-by: David Gibson --- target/ppc/helper.h | 1 + target/ppc/int_helper.c | 19 +++++++++++++++++++ target/ppc/translate/vmx-impl.inc.c | 8 ++++++++ 3 files changed, 28 insertions(+) diff --git a/target/ppc/helper.h b/target/ppc/helper.h index 7957633..de515ea 100644 --- a/target/ppc/helper.h +++ b/target/ppc/helper.h @@ -380,6 +380,7 @@ DEF_HELPER_3(bcdctz, i32, avr, avr, i32) DEF_HELPER_3(bcdcfsq, i32, avr, avr, i32) DEF_HELPER_3(bcdctsq, i32, avr, avr, i32) DEF_HELPER_4(bcdcpsgn, i32, avr, avr, avr, i32) +DEF_HELPER_3(bcdsetsgn, i32, avr, avr, i32) DEF_HELPER_2(xsadddp, void, env, i32) DEF_HELPER_2(xssubdp, void, env, i32) diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c index 61762ee..00d04c1 100644 --- a/target/ppc/int_helper.c +++ b/target/ppc/int_helper.c @@ -2943,6 +2943,25 @@ uint32_t helper_bcdcpsgn(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, uint32_t ps) return bcd_cmp_zero(r); } +uint32_t helper_bcdsetsgn(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps) +{ + int i; + int invalid = 0; + int sgnb = bcd_get_sgn(b); + + *r = *b; + bcd_put_digit(r, bcd_preferred_sgn(sgnb, ps), 0); + + for (i = 1; i < 32; i++) { + bcd_get_digit(b, i, &invalid); + if (unlikely(invalid)) { + return CRF_SO; + } + } + + return bcd_cmp_zero(r); +} + void helper_vsbox(ppc_avr_t *r, ppc_avr_t *a) { int i; diff --git a/target/ppc/translate/vmx-impl.inc.c b/target/ppc/translate/vmx-impl.inc.c index c14b666..b188e60 100644 --- a/target/ppc/translate/vmx-impl.inc.c +++ b/target/ppc/translate/vmx-impl.inc.c @@ -991,6 +991,7 @@ GEN_BCD2(bcdcfz) GEN_BCD2(bcdctz) GEN_BCD2(bcdcfsq) GEN_BCD2(bcdctsq) +GEN_BCD2(bcdsetsgn) GEN_BCD(bcdcpsgn); static void gen_xpnd04_1(DisasContext *ctx) @@ -1014,6 +1015,9 @@ static void gen_xpnd04_1(DisasContext *ctx) case 7: gen_bcdcfn(ctx); break; + case 31: + gen_bcdsetsgn(ctx); + break; default: gen_invalid(ctx); break; @@ -1038,12 +1042,16 @@ static void gen_xpnd04_2(DisasContext *ctx) case 7: gen_bcdcfn(ctx); break; + case 31: + gen_bcdsetsgn(ctx); + break; default: gen_invalid(ctx); break; } } + GEN_VXFORM_DUAL(vsubcuw, PPC_ALTIVEC, PPC_NONE, \ xpnd04_1, PPC_NONE, PPC2_ISA300) GEN_VXFORM_DUAL(vsubsws, PPC_ALTIVEC, PPC_NONE, \