From nobody Sat Jul 12 14:57:41 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1486017145704110.16406371868777; Wed, 1 Feb 2017 22:32:25 -0800 (PST) Received: from localhost ([::1]:54647 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZAwR-0007WX-Sx for importer@patchew.org; Thu, 02 Feb 2017 01:32:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52220) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZ9k6-0007jI-1c for qemu-devel@nongnu.org; Thu, 02 Feb 2017 00:15:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZ9jz-00044y-Ks for qemu-devel@nongnu.org; Thu, 02 Feb 2017 00:15:33 -0500 Received: from ozlabs.org ([103.22.144.67]:53329) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZ9jz-0003zf-5z; Thu, 02 Feb 2017 00:15:27 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3vDSqV4B5Sz9s8J; Thu, 2 Feb 2017 16:15:00 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1486012502; bh=nzPjEXq7+DLm+jLWo/uLWTQ70eAGQMxP2j0k7weBJCg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JX9pSRuG2gZUJkQ4jQ0jVhM9ywB0qkx9I8KW7cjSzAKJOTelBrik8yzKaMCRdPSrQ yI1HBHGQmU+f6TMip3ZOfYjfcbPo7C3qaQt93ZO/zZ9GlsAn6dcFPItC2ZMJxfqgxv AP393BS2RjpXRJaq8PrPREmC1D7aqrATAfbCKGOk= From: David Gibson To: peter.maydell@linaro.org Date: Thu, 2 Feb 2017 16:14:11 +1100 Message-Id: <20170202051445.5735-74-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 073/107] ppc: Implement bcdus. 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Jose Ricardo Ziviani bcdus.: Decimal unsigned shift. This instruction works like bcds. but considers only unsigned BCDs (no sign in least meaning 4 bits). Signed-off-by: Jose Ricardo Ziviani Signed-off-by: David Gibson --- target/ppc/helper.h | 1 + target/ppc/int_helper.c | 41 +++++++++++++++++++++++++++++++++= ++++ target/ppc/translate/vmx-impl.inc.c | 3 +++ target/ppc/translate/vmx-ops.inc.c | 2 +- 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/target/ppc/helper.h b/target/ppc/helper.h index 26edbf9..161d537 100644 --- a/target/ppc/helper.h +++ b/target/ppc/helper.h @@ -394,6 +394,7 @@ 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_4(bcds, i32, avr, avr, avr, i32) +DEF_HELPER_4(bcdus, i32, avr, avr, avr, i32) =20 DEF_HELPER_2(xsadddp, void, env, i32) DEF_HELPER_2(xsaddqp, void, env, i32) diff --git a/target/ppc/int_helper.c b/target/ppc/int_helper.c index 5f53710..9d88352 100644 --- a/target/ppc/int_helper.c +++ b/target/ppc/int_helper.c @@ -3102,6 +3102,47 @@ uint32_t helper_bcds(ppc_avr_t *r, ppc_avr_t *a, ppc= _avr_t *b, uint32_t ps) return cr; } =20 +uint32_t helper_bcdus(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, uint32_t p= s) +{ + int cr; + int i; + int invalid =3D 0; + bool ox_flag =3D false; + ppc_avr_t ret =3D *b; + + for (i =3D 0; i < 32; i++) { + bcd_get_digit(b, i, &invalid); + + if (unlikely(invalid)) { + return CRF_SO; + } + } + +#if defined(HOST_WORDS_BIGENDIAN) + i =3D a->s8[7]; +#else + i =3D a->s8[8]; +#endif + if (i >=3D 32) { + ox_flag =3D true; + ret.u64[LO_IDX] =3D ret.u64[HI_IDX] =3D 0; + } else if (i <=3D -32) { + ret.u64[LO_IDX] =3D ret.u64[HI_IDX] =3D 0; + } else if (i > 0) { + ulshift(&ret.u64[LO_IDX], &ret.u64[HI_IDX], i * 4, &ox_flag); + } else { + urshift(&ret.u64[LO_IDX], &ret.u64[HI_IDX], -i * 4); + } + *r =3D ret; + + cr =3D bcd_cmp_zero(r); + if (ox_flag) { + cr |=3D CRF_SO; + } + + return cr; +} + 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 84ebb7e..fc54881 100644 --- a/target/ppc/translate/vmx-impl.inc.c +++ b/target/ppc/translate/vmx-impl.inc.c @@ -1017,6 +1017,7 @@ GEN_BCD2(bcdctsq) GEN_BCD2(bcdsetsgn) GEN_BCD(bcdcpsgn); GEN_BCD(bcds); +GEN_BCD(bcdus); =20 static void gen_xpnd04_1(DisasContext *ctx) { @@ -1093,6 +1094,8 @@ GEN_VXFORM_DUAL(vaddshs, PPC_ALTIVEC, PPC_NONE, \ bcdcpsgn, PPC_NONE, PPC2_ISA300) GEN_VXFORM_DUAL(vsubudm, PPC2_ALTIVEC_207, PPC_NONE, \ bcds, PPC_NONE, PPC2_ISA300) +GEN_VXFORM_DUAL(vsubuwm, PPC_ALTIVEC, PPC_NONE, \ + bcdus, PPC_NONE, PPC2_ISA300) =20 static void gen_vsbox(DisasContext *ctx) { diff --git a/target/ppc/translate/vmx-ops.inc.c b/target/ppc/translate/vmx-= ops.inc.c index 7b4b009..cdd3abe 100644 --- a/target/ppc/translate/vmx-ops.inc.c +++ b/target/ppc/translate/vmx-ops.inc.c @@ -61,7 +61,7 @@ GEN_VXFORM(vadduwm, 0, 2), GEN_VXFORM_207(vaddudm, 0, 3), GEN_VXFORM_DUAL(vsububm, bcdadd, 0, 16, PPC_ALTIVEC, PPC_NONE), GEN_VXFORM_DUAL(vsubuhm, bcdsub, 0, 17, PPC_ALTIVEC, PPC_NONE), -GEN_VXFORM(vsubuwm, 0, 18), +GEN_VXFORM_DUAL(vsubuwm, bcdus, 0, 18, PPC_ALTIVEC, PPC2_ISA300), GEN_VXFORM_DUAL(vsubudm, bcds, 0, 19, PPC2_ALTIVEC_207, PPC2_ISA300), GEN_VXFORM_300(bcds, 0, 27), GEN_VXFORM(vmaxub, 1, 0), --=20 2.9.3