From nobody Sat Jul 12 15:05:06 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 1486013495327440.03722419417124; Wed, 1 Feb 2017 21:31:35 -0800 (PST) Received: from localhost ([::1]:54288 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZ9zZ-0005gK-Ak for importer@patchew.org; Thu, 02 Feb 2017 00:31:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50966) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZ9jc-00074S-5X 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-0003St-Jn for qemu-devel@nongnu.org; Thu, 02 Feb 2017 00:15:04 -0500 Received: from ozlabs.org ([103.22.144.67]:44217) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZ9ja-0003Ps-8Y; Thu, 02 Feb 2017 00:15:02 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3vDSqL2Pbhz9s7N; 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=PnuLlZVecn1NFxn4/XzImZ9dIxQThxM/kS6MGdsZUvA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hYJc3Sb+tCCiz4Nzwi+mY8oIcNWs8QaQDn1Ky6MKc4OhyQCT6cy/uhi26OBXhUWBC hc+8umPJGRztiPxxb3BeXRVbezxE+NhB7/ZMsvw2KL8JgtMfuUFcgNNZYAGLWakzB6 d07vA4YppFUleKTc/PV1xNplcg9MWm+rAE6afmYA= From: David Gibson To: peter.maydell@linaro.org Date: Thu, 2 Feb 2017 16:13:08 +1100 Message-Id: <20170202051445.5735-11-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 010/107] target-ppc: Implement bcdcfsq. 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 bcdcfsq.: Decimal convert from signed quadword. It is not possible to convert values less than -10^31-1 or greater than 10^31-1 to be represented in packed decimal format. Signed-off-by: Jose Ricardo Ziviani [dwg: Corrected constant which should be 10^16-1 but was 10^17-1] Signed-off-by: David Gibson --- target/ppc/helper.h | 1 + target/ppc/int_helper.c | 38 +++++++++++++++++++++++++++++++++= ++++ target/ppc/translate/vmx-impl.inc.c | 7 +++++++ 3 files changed, 46 insertions(+) diff --git a/target/ppc/helper.h b/target/ppc/helper.h index 125d6c5..ec5ccbe 100644 --- a/target/ppc/helper.h +++ b/target/ppc/helper.h @@ -377,6 +377,7 @@ DEF_HELPER_3(bcdcfn, i32, avr, avr, i32) 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) =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 fbc84e2..a809482 100644 --- a/target/ppc/int_helper.c +++ b/target/ppc/int_helper.c @@ -2842,6 +2842,44 @@ uint32_t helper_bcdctz(ppc_avr_t *r, ppc_avr_t *b, u= int32_t ps) return cr; } =20 +uint32_t helper_bcdcfsq(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps) +{ + int i; + int cr =3D 0; + uint64_t lo_value; + uint64_t hi_value; + ppc_avr_t ret =3D { .u64 =3D { 0, 0 } }; + + if (b->s64[HI_IDX] < 0) { + lo_value =3D -b->s64[LO_IDX]; + hi_value =3D ~b->u64[HI_IDX] + !lo_value; + bcd_put_digit(&ret, 0xD, 0); + } else { + lo_value =3D b->u64[LO_IDX]; + hi_value =3D b->u64[HI_IDX]; + bcd_put_digit(&ret, bcd_preferred_sgn(0, ps), 0); + } + + if (divu128(&lo_value, &hi_value, 1000000000000000ULL) || + lo_value > 9999999999999999ULL) { + cr =3D CRF_SO; + } + + for (i =3D 1; i < 16; hi_value /=3D 10, i++) { + bcd_put_digit(&ret, hi_value % 10, i); + } + + for (; i < 32; lo_value /=3D 10, i++) { + bcd_put_digit(&ret, lo_value % 10, i); + } + + cr |=3D bcd_cmp_zero(&ret); + + *r =3D ret; + + 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 7143eb3..36141e5 100644 --- a/target/ppc/translate/vmx-impl.inc.c +++ b/target/ppc/translate/vmx-impl.inc.c @@ -989,10 +989,14 @@ GEN_BCD2(bcdcfn) GEN_BCD2(bcdctn) GEN_BCD2(bcdcfz) GEN_BCD2(bcdctz) +GEN_BCD2(bcdcfsq) =20 static void gen_xpnd04_1(DisasContext *ctx) { switch (opc4(ctx->opcode)) { + case 2: + gen_bcdcfsq(ctx); + break; case 4: gen_bcdctz(ctx); break; @@ -1014,6 +1018,9 @@ static void gen_xpnd04_1(DisasContext *ctx) static void gen_xpnd04_2(DisasContext *ctx) { switch (opc4(ctx->opcode)) { + case 2: + gen_bcdcfsq(ctx); + break; case 4: gen_bcdctz(ctx); break; --=20 2.9.3