From nobody Wed Nov 12 11:55:37 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1570184081; cv=none; d=zoho.com; s=zohoarc; b=Ux6x99iGW9iSg6TdUfzokKTcqJtTv16Y+T62r23OV320Nazy1DF9M40SWmoGhTIbyVtUA6X5LY/ybKwx9hyAcHnQF4/yxOGTmXsc1DXGmVbi1LeSKOkQQXCG//CuWFgzomZ0AtxZ1J2Lj/JsCHIawr8uSz3j9HRK8+wtURbR1to= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570184081; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=kiCNw8FUGecaz8sOKQdVLHUKgu6EqJ8oqMyEqy77nUI=; b=e4Q3dHze51G/Rx1iGUoaKHkqoe5z0jRB0WHTNDbRUqbarPditA8k0IsTL//JfGF/p9ah1Jx5ce9H3BSCSqYvUkIiv1TQO/JHKsHh52q/c2uzzmkYywujFk9OlKZNQRx63o5n6B2HPEFo6uV0eSWa/UWOPAplOQczTrFDPL6Np3A= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1570184080450366.4105433555118; Fri, 4 Oct 2019 03:14:40 -0700 (PDT) Received: from localhost ([::1]:44792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iGKbc-00007W-TJ for importer@patchew.org; Fri, 04 Oct 2019 06:14:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52806) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iGK2j-0005N3-67 for qemu-devel@nongnu.org; Fri, 04 Oct 2019 05:38:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iGK2h-0005Uo-AX for qemu-devel@nongnu.org; Fri, 04 Oct 2019 05:38:32 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:54621) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iGK2g-000594-Ud; Fri, 04 Oct 2019 05:38:31 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 46l4YK34D2z9sRs; Fri, 4 Oct 2019 19:37:57 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1570181877; bh=LrZVxyuWBaqlkbXslxNK7uWmeRD8cNDrcKqcQ3Wc2go=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WKgbSbRvshWEa9zkqSxHLsYXyYtru1/Fs2l+u8RNU26eOjjg87csubtCtszo3yh4O hhhUqixbWKaHBMFrwb539uj51SQ4rq/+OLJnuJgFSLxdYQA0+Q9JzSdn+nR4fQfSZQ rT6PtylHUnVvDjVEC2I3BPkM7YVdjeNZFdtV70CI= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 22/53] target/ppc: introduce get_dfp{64, 128}() helper functions Date: Fri, 4 Oct 2019 19:37:16 +1000 Message-Id: <20191004093747.31350-23-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191004093747.31350-1-david@gibson.dropbear.id.au> References: <20191004093747.31350-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, aik@ozlabs.ru, Richard Henderson , Mark Cave-Ayland , qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Mark Cave-Ayland The existing functions (now incorrectly) assume that the MSB and LSB of DFP numbers are stored as consecutive 64-bit words in memory. Instead of access= ing the DFP numbers directly, introduce get_dfp{64,128}() helper functions to e= ase the switch to the correct representation. Signed-off-by: Mark Cave-Ayland Reviewed-by: Richard Henderson Message-Id: <20190926185801.11176-2-mark.cave-ayland@ilande.co.uk> Signed-off-by: David Gibson --- target/ppc/dfp_helper.c | 52 ++++++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/target/ppc/dfp_helper.c b/target/ppc/dfp_helper.c index 753399177c..e4369ebe9b 100644 --- a/target/ppc/dfp_helper.c +++ b/target/ppc/dfp_helper.c @@ -36,6 +36,17 @@ #define LO_IDX 0 #endif =20 +static void get_dfp64(uint64_t *dst, uint64_t *dfp) +{ + dst[0] =3D dfp[0]; +} + +static void get_dfp128(uint64_t *dst, uint64_t *dfp) +{ + dst[0] =3D dfp[HI_IDX]; + dst[1] =3D dfp[LO_IDX]; +} + struct PPC_DFP { CPUPPCState *env; uint64_t t64[2], a64[2], b64[2]; @@ -129,7 +140,7 @@ static void dfp_prepare_decimal64(struct PPC_DFP *dfp, = uint64_t *a, dfp->env =3D env; =20 if (a) { - dfp->a64[0] =3D *a; + get_dfp64(dfp->a64, a); decimal64ToNumber((decimal64 *)dfp->a64, &dfp->a); } else { dfp->a64[0] =3D 0; @@ -137,7 +148,7 @@ static void dfp_prepare_decimal64(struct PPC_DFP *dfp, = uint64_t *a, } =20 if (b) { - dfp->b64[0] =3D *b; + get_dfp64(dfp->b64, b); decimal64ToNumber((decimal64 *)dfp->b64, &dfp->b); } else { dfp->b64[0] =3D 0; @@ -153,8 +164,7 @@ static void dfp_prepare_decimal128(struct PPC_DFP *dfp,= uint64_t *a, dfp->env =3D env; =20 if (a) { - dfp->a64[0] =3D a[HI_IDX]; - dfp->a64[1] =3D a[LO_IDX]; + get_dfp128(dfp->a64, a); decimal128ToNumber((decimal128 *)dfp->a64, &dfp->a); } else { dfp->a64[0] =3D dfp->a64[1] =3D 0; @@ -162,8 +172,7 @@ static void dfp_prepare_decimal128(struct PPC_DFP *dfp,= uint64_t *a, } =20 if (b) { - dfp->b64[0] =3D b[HI_IDX]; - dfp->b64[1] =3D b[LO_IDX]; + get_dfp128(dfp->b64, b); decimal128ToNumber((decimal128 *)dfp->b64, &dfp->b); } else { dfp->b64[0] =3D dfp->b64[1] =3D 0; @@ -617,10 +626,12 @@ uint32_t helper_##op(CPUPPCState *env, uint64_t *a, u= int64_t *b) \ { \ struct PPC_DFP dfp; \ unsigned k; \ + uint64_t a64; \ \ dfp_prepare_decimal##size(&dfp, 0, b, env); \ \ - k =3D *a & 0x3F; = \ + get_dfp64(&a64, a); \ + k =3D a64 & 0x3F; = \ \ if (unlikely(decNumberIsSpecial(&dfp.b))) { \ dfp.crbf =3D 1; = \ @@ -817,11 +828,15 @@ void helper_##op(CPUPPCState *env, uint64_t *t, uint6= 4_t *a, \ uint64_t *b, uint32_t rmc) \ { \ struct PPC_DFP dfp; \ - int32_t ref_sig =3D *a & 0x3F; \ + uint64_t a64; \ + int32_t ref_sig; \ int32_t xmax =3D ((size) =3D=3D 64) ? 369 : 6111; = \ \ dfp_prepare_decimal##size(&dfp, 0, b, env); \ \ + get_dfp64(&a64, a); \ + ref_sig =3D a64 & 0x3f; \ + \ _dfp_reround(rmc, ref_sig, xmax, &dfp); \ decimal##size##FromNumber((decimal##size *)dfp.t64, &dfp.t, \ &dfp.context); \ @@ -881,7 +896,12 @@ DFP_HELPER_RINT(drintnq, RINTN_PPs, 128) void helper_dctdp(CPUPPCState *env, uint64_t *t, uint64_t *b) { struct PPC_DFP dfp; - uint32_t b_short =3D *b; + uint64_t b64; + uint32_t b_short; + + get_dfp64(&b64, b); + b_short =3D (uint32_t)b64; + dfp_prepare_decimal64(&dfp, 0, 0, env); decimal32ToNumber((decimal32 *)&b_short, &dfp.t); decimal64FromNumber((decimal64 *)t, &dfp.t, &dfp.context); @@ -891,8 +911,10 @@ void helper_dctdp(CPUPPCState *env, uint64_t *t, uint6= 4_t *b) void helper_dctqpq(CPUPPCState *env, uint64_t *t, uint64_t *b) { struct PPC_DFP dfp; + uint64_t b64; dfp_prepare_decimal128(&dfp, 0, 0, env); - decimal64ToNumber((decimal64 *)b, &dfp.t); + get_dfp64(&b64, b); + decimal64ToNumber((decimal64 *)&b64, &dfp.t); =20 dfp_check_for_VXSNAN_and_convert_to_QNaN(&dfp); dfp_set_FPRF_from_FRT(&dfp); @@ -940,8 +962,10 @@ void helper_drdpq(CPUPPCState *env, uint64_t *t, uint6= 4_t *b) void helper_##op(CPUPPCState *env, uint64_t *t, uint64_t *b) = \ { = \ struct PPC_DFP dfp; = \ + uint64_t b64; = \ dfp_prepare_decimal##size(&dfp, 0, b, env); = \ - decNumberFromInt64(&dfp.t, (int64_t)(*b)); = \ + get_dfp64(&b64, b); = \ + decNumberFromInt64(&dfp.t, (int64_t)b64); = \ decimal##size##FromNumber((decimal##size *)dfp.t64, &dfp.t, &dfp.conte= xt); \ CFFIX_PPs(&dfp); = \ = \ @@ -1183,10 +1207,12 @@ static void dfp_set_raw_exp_128(uint64_t *t, uint64= _t raw) void helper_##op(CPUPPCState *env, uint64_t *t, uint64_t *a, uint64_t *b) \ { \ struct PPC_DFP dfp; \ - uint64_t raw_qnan, raw_snan, raw_inf, max_exp; \ + uint64_t raw_qnan, raw_snan, raw_inf, max_exp, a64; \ int bias; \ - int64_t exp =3D *((int64_t *)a); = \ + int64_t exp; \ \ + get_dfp64(&a64, a); \ + exp =3D (int64_t)a64; = \ dfp_prepare_decimal##size(&dfp, 0, b, env); \ \ if ((size) =3D=3D 64) { = \ --=20 2.21.0