From nobody Sat Jul 12 15:14: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 1486013329751929.9005444141459; Wed, 1 Feb 2017 21:28:49 -0800 (PST) Received: from localhost ([::1]:54269 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZ9wt-0003Ro-PB for importer@patchew.org; Thu, 02 Feb 2017 00:28:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50988) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZ9jc-00075A-Po for qemu-devel@nongnu.org; Thu, 02 Feb 2017 00:15:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZ9ja-0003TI-UX for qemu-devel@nongnu.org; Thu, 02 Feb 2017 00:15:04 -0500 Received: from ozlabs.org ([103.22.144.67]:46347) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZ9ja-0003Pw-He; Thu, 02 Feb 2017 00:15:02 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3vDSqL3qCmz9s7T; 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=1486012494; bh=wK6UQk0ffXzYoTM7ODweHECZxKJjmYs6XRrMH5jcI58=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mvnN2lJfRhOTr8EoiL146sEzfNX3UgX+B51C5PGxkmtYabCP98KHXTSqTnOvty2gU OGyJHd8st0k3r2x477hqXSieLV4SdcoEBFTR0w/AkrI7wj9ne82xNW1vaaoJ64GheZ wvxlY68jub1jXcKGMUzJKyV3/To5DR0i+xC2mbSw= From: David Gibson To: peter.maydell@linaro.org Date: Thu, 2 Feb 2017 16:13:09 +1100 Message-Id: <20170202051445.5735-12-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 011/107] target-ppc: Implement bcdctsq. 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 bcdctsq.: Decimal convert to signed quadword. It is possible to convert packed decimal values to signed quadwords. 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 | 40 +++++++++++++++++++++++++++++++++= ++++ target/ppc/translate/vmx-impl.inc.c | 7 +++++++ 3 files changed, 48 insertions(+) diff --git a/target/ppc/helper.h b/target/ppc/helper.h index ec5ccbe..daf5a6e 100644 --- a/target/ppc/helper.h +++ b/target/ppc/helper.h @@ -378,6 +378,7 @@ DEF_HELPER_3(bcdctn, i32, avr, avr, i32) DEF_HELPER_3(bcdcfz, i32, avr, avr, i32) DEF_HELPER_3(bcdctz, i32, avr, avr, i32) DEF_HELPER_3(bcdcfsq, i32, avr, avr, i32) +DEF_HELPER_3(bcdctsq, i32, avr, avr, i32) =20 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 a809482..fa7cfdd 100644 --- a/target/ppc/int_helper.c +++ b/target/ppc/int_helper.c @@ -2880,6 +2880,46 @@ uint32_t helper_bcdcfsq(ppc_avr_t *r, ppc_avr_t *b, = uint32_t ps) return cr; } =20 +uint32_t helper_bcdctsq(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps) +{ + uint8_t i; + int cr; + uint64_t carry; + uint64_t unused; + uint64_t lo_value; + uint64_t hi_value =3D 0; + int sgnb =3D bcd_get_sgn(b); + int invalid =3D (sgnb =3D=3D 0); + + lo_value =3D bcd_get_digit(b, 31, &invalid); + for (i =3D 30; i > 0; i--) { + mulu64(&lo_value, &carry, lo_value, 10ULL); + mulu64(&hi_value, &unused, hi_value, 10ULL); + lo_value +=3D bcd_get_digit(b, i, &invalid); + hi_value +=3D carry; + + if (unlikely(invalid)) { + break; + } + } + + if (sgnb =3D=3D -1) { + r->s64[LO_IDX] =3D -lo_value; + r->s64[HI_IDX] =3D ~hi_value + !r->s64[LO_IDX]; + } else { + r->s64[LO_IDX] =3D lo_value; + r->s64[HI_IDX] =3D hi_value; + } + + cr =3D bcd_cmp_zero(b); + + if (unlikely(invalid)) { + 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 36141e5..1579b58 100644 --- a/target/ppc/translate/vmx-impl.inc.c +++ b/target/ppc/translate/vmx-impl.inc.c @@ -990,10 +990,14 @@ GEN_BCD2(bcdctn) GEN_BCD2(bcdcfz) GEN_BCD2(bcdctz) GEN_BCD2(bcdcfsq) +GEN_BCD2(bcdctsq) =20 static void gen_xpnd04_1(DisasContext *ctx) { switch (opc4(ctx->opcode)) { + case 0: + gen_bcdctsq(ctx); + break; case 2: gen_bcdcfsq(ctx); break; @@ -1018,6 +1022,9 @@ static void gen_xpnd04_1(DisasContext *ctx) static void gen_xpnd04_2(DisasContext *ctx) { switch (opc4(ctx->opcode)) { + case 0: + gen_bcdctsq(ctx); + break; case 2: gen_bcdcfsq(ctx); break; --=20 2.9.3