From nobody Sat Feb 7 12:29:07 2026 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.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1537219221018659.9375486007649; Mon, 17 Sep 2018 14:20:21 -0700 (PDT) Received: from localhost ([::1]:37417 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g20wN-0003gE-MW for importer@patchew.org; Mon, 17 Sep 2018 17:20:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41119) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g20vT-0003IW-10 for qemu-devel@nongnu.org; Mon, 17 Sep 2018 17:19:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g20vS-0003wH-3G for qemu-devel@nongnu.org; Mon, 17 Sep 2018 17:19:22 -0400 Received: from mail-it0-x242.google.com ([2607:f8b0:4001:c0b::242]:34496) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g20vM-0003Sn-Nv; Mon, 17 Sep 2018 17:19:16 -0400 Received: by mail-it0-x242.google.com with SMTP id x79-v6so12280967ita.1; Mon, 17 Sep 2018 14:19:16 -0700 (PDT) Received: from localhost.localdomain (d14-69-20-184.try.wideopenwest.com. [69.14.184.20]) by smtp.gmail.com with ESMTPSA id m7-v6sm3953362itb.39.2018.09.17.14.19.14 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 17 Sep 2018 14:19:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=VBzWAr5NVXmNLknMFPVyWujrxRNcPscVB84ECB6ux7I=; b=uq1fwcz+9iGnNJsDrl+PT/4osD4NHQHzUcPOgHwlNkkbGmqHnoAqgD9vs+70Bx/qPt Rk7FNH8IzSaA4wgl+bWyFa/qcg8MBL+3P32jRhXJ36pkQH+oyP3snlmTF+V1pQABk+ox AGh9jbEcJ+ksmJ2rHz7IfE/dFHpDTlp05nx08aGfDob+6A1oduMPgWbPZIUZJGorYAf7 ZNHTZux52wiYRFXb5m7TiWA/Ryx0906FjqlRtcA8n3XJb73DyKvmQ0lxtG/QqFIYChJI 8bMnM09gZcR3AAiFRHQtEhBXD20S3mDmOvOAEH6cq1ETzOnrOvMHtsph9EqLHxfFkk1y jJ4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=VBzWAr5NVXmNLknMFPVyWujrxRNcPscVB84ECB6ux7I=; b=qUDMJQHa87CYceY2DcVOOE0NQnUJlZT/Zc0tuTYGR4/ev19ijlarawDc1Cieu8FF+b NHV/DHC5d0CHXHYdk7uWD8ud0j7raeyvvBNFiDlh4mqnb/iLuc1yHPqbEPnxOIYysOQT sU8bLOM/O5WAGgUYmj9AbdLmfGYJHqr/aR51PbseZy2TodE+T1+EV+86P82ZhUIPhTPR Zd8bz+3Y8yS0VXJfEi/xouYpxfX88xfz2X6FPIAx9WEYTRRfIT+PI7opspqFK3BG1wqB hjbS3FL09ciMlEf4wNVIgQAzZHQmPnazzOg9ljT8LSyA/d9ZMrMq0K7MYcm4lEhlOiqw na3Q== X-Gm-Message-State: APzg51A/CIuBgim0h+ySh9msbAxEISL9KVtIH+wgCVl04RmZ1THYWYZH d8DGVIwj9Rt6PWFq6NaWexXkEEWz X-Google-Smtp-Source: ANB0VdaDfOhH/NKETHb+9e9TLfH6OeSzw0oR0sbisKWfdgcjI0q471CuCvE2SS6adS9/jyIcjREr0w== X-Received: by 2002:a24:8dc6:: with SMTP id w189-v6mr14843771itd.69.1537219155875; Mon, 17 Sep 2018 14:19:15 -0700 (PDT) From: John Arbuckle To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, david@gibson.dropbear.id.au, richard.henderson@linaro.org Date: Mon, 17 Sep 2018 17:18:58 -0400 Message-Id: <20180917211858.21795-1-programmingkidx@gmail.com> X-Mailer: git-send-email 2.14.3 (Apple Git-98) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4001:c0b::242 Subject: [Qemu-devel] [PATCH] fix setting the FPSCR[FR] bit 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: John Arbuckle Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" https://www.nxp.com/files-static/product/doc/MPCFPE32B.pdf Page 2-8 in table 2-4 is where the description of this bit can be found. It is described as: Floating-point fraction rounded. The last arithmetic, rounding, or conversi= on instruction incremented the fraction. This bit is NOT sticky. This patch actually implements the setting and unsetting of this bit. Signed-off-by: John Arbuckle --- fpu/softfloat.c | 12 ++++++++++-- include/fpu/softfloat-types.h | 1 + target/ppc/fpu_helper.c | 12 ++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 59ca356d0e..c5378ae9e8 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -751,9 +751,17 @@ float64 __attribute__((flatten)) float64_add(float64 a= , float64 b, { FloatParts pa =3D float64_unpack_canonical(a, status); FloatParts pb =3D float64_unpack_canonical(b, status); - FloatParts pr =3D addsub_floats(pa, pb, false, status); + FloatParts intermediate_parts =3D addsub_floats(pa, pb, false, status); =20 - return float64_round_pack_canonical(pr, status); + float64 rounded_result =3D float64_round_pack_canonical(intermediate_p= arts, + status); + FloatParts rounded_parts =3D float64_unpack_canonical(rounded_result, = status); + + if (rounded_parts.frac !=3D intermediate_parts.frac) { + float_raise(float_flag_round, status); + } + + return rounded_result; } =20 float16 __attribute__((flatten)) float16_sub(float16 a, float16 b, diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h index 2aae6a89b1..1d124e659c 100644 --- a/include/fpu/softfloat-types.h +++ b/include/fpu/softfloat-types.h @@ -147,6 +147,7 @@ enum { =20 enum { float_flag_invalid =3D 1, + float_flag_round =3D 2, float_flag_divbyzero =3D 4, float_flag_overflow =3D 8, float_flag_underflow =3D 16, diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c index b9bb1b856e..eed4f1a650 100644 --- a/target/ppc/fpu_helper.c +++ b/target/ppc/fpu_helper.c @@ -581,6 +581,7 @@ static void do_float_check_status(CPUPPCState *env, uin= tptr_t raddr) CPUState *cs =3D CPU(ppc_env_get_cpu(env)); int status =3D get_float_exception_flags(&env->fp_status); bool inexact_happened =3D false; + bool round_happened =3D false; =20 if (status & float_flag_overflow) { float_overflow_excp(env); @@ -591,11 +592,22 @@ static void do_float_check_status(CPUPPCState *env, u= intptr_t raddr) inexact_happened =3D true; } =20 + /* if the round flag was set */ + if (status & float_flag_round) { + round_happened =3D true; + env->fpscr |=3D 1 << FPSCR_FR; + } + /* if the inexact flag was not set */ if (inexact_happened =3D=3D false) { env->fpscr &=3D ~(1 << FPSCR_FI); /* clear the FPSCR[FI] bit */ } =20 + /* if the floating-point fraction rounded bit was not set */ + if (round_happened =3D=3D false) { + env->fpscr &=3D ~(1 << FPSCR_FR); /* clear the FPSCR[FR] bit */ + } + if (cs->exception_index =3D=3D POWERPC_EXCP_PROGRAM && (env->error_code & POWERPC_EXCP_FP)) { /* Differred floating-point exception after target FPR update */ --=20 2.14.3 (Apple Git-98)