From nobody Tue Feb 10 19:48:38 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=linaro.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517718006298865.1851102741153; Sat, 3 Feb 2018 20:20:06 -0800 (PST) Received: from localhost ([::1]:58289 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiBmW-0002pY-NV for importer@patchew.org; Sat, 03 Feb 2018 23:19:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47355) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiBep-0004hf-Sq for qemu-devel@nongnu.org; Sat, 03 Feb 2018 23:12:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiBeo-0004y1-Tw for qemu-devel@nongnu.org; Sat, 03 Feb 2018 23:11:59 -0500 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:37814) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eiBeo-0004xn-Ng for qemu-devel@nongnu.org; Sat, 03 Feb 2018 23:11:58 -0500 Received: by mail-pl0-x241.google.com with SMTP id ay8so9372650plb.4 for ; Sat, 03 Feb 2018 20:11:58 -0800 (PST) Received: from cloudburst.twiddle.net (174-21-6-47.tukw.qwest.net. [174.21.6.47]) by smtp.gmail.com with ESMTPSA id k3sm1399425pgr.12.2018.02.03.20.11.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Feb 2018 20:11:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0SCjxxEWFJsjx9dBnP24HcnJKoUvfKn58tKIdmV+sDM=; b=hJeba4/qX4IsaQKHq9pIlc410L5cAviqAM8VKHGfqa7MToK/QrurxFZ0c7AROx7kAl ttUUgiqt7U5sfqIgUlDK0a4Lo+6/NDH9vXC7mmnp6eOg5eouO/60bbnMeB8gvM/6noiP sh+ID/d0kD2NciC2XQn8r3om9hVw1VeCwmupI= 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:in-reply-to :references; bh=0SCjxxEWFJsjx9dBnP24HcnJKoUvfKn58tKIdmV+sDM=; b=tFdLaZYNLdwJk9G46OL12wdPD50HNkNcKmwFQDD7CMINr4K4/KcJo635V4zrj9CGAq bdQRpaIxDgG1sKDpUAW/gW3ACnblr6WtKlD+dlU/pNe5KAR4NR0zEMIFbrzR3cTqh8NH JVVcgXOXZtdvYLqskOoHHv4hnaWvQK/eoD+Dh5lR17m6dPltiBCK4Gdeb4PNOm6w7atC lgOuW4j4ubIFWfUBxcSQB1W0jssDKjbB8m7ziHEPLQhKpTSA7sF6uFm6N+y+V5KavlvL qmuJXBp7dgAPcoUE3g1JMtHC5JApc3fG0ay92xPo5aP+WsEXdkCiiIl8XvELl6qejNd0 +aSQ== X-Gm-Message-State: AKwxytfYwm2crV0iH7W0J4TAWzf2vS5LQznZCFWy6OXZY6Am3HPUExl1 Hib0kUJYZ7KwwvV4Y+DTKAUItQSbI48= X-Google-Smtp-Source: AH8x226h7YuEAbC28u5mZWNnMhh1EC7lFbGOLJ94anE06eKtbs0TwUVIJPynM3HNgfY1I9grEkFPGw== X-Received: by 2002:a17:902:8c89:: with SMTP id t9-v6mr38495202plo.2.1517717517495; Sat, 03 Feb 2018 20:11:57 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Feb 2018 20:11:24 -0800 Message-Id: <20180204041136.17525-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180204041136.17525-1-richard.henderson@linaro.org> References: <20180204041136.17525-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [PATCH 12/24] fpu/soft-fp: Add ties_away and to_odd rounding modes 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: peter.maydell@linaro.org, cota@braap.org, alex.bennee@linaro.org, hsp.cat7@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" These rounding modes are used by ARM and PowerPC respectively. Signed-off-by: Richard Henderson --- fpu/op-common.h | 20 ++++++++++++++++++++ fpu/soft-fp.h | 25 +++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/fpu/op-common.h b/fpu/op-common.h index 4526afd1b6..c5f33c0148 100644 --- a/fpu/op-common.h +++ b/fpu/op-common.h @@ -130,6 +130,7 @@ do \ { \ if (FP_ROUNDMODE =3D=3D FP_RND_NEAREST \ + || FP_ROUNDMODE =3D=3D FP_RND_TIESAWAY \ || (FP_ROUNDMODE =3D=3D FP_RND_PINF && !X##_s) \ || (FP_ROUNDMODE =3D=3D FP_RND_MINF && X##_s)) \ { \ @@ -287,6 +288,7 @@ switch (FP_ROUNDMODE) \ { \ case FP_RND_NEAREST: \ + case FP_RND_TIESAWAY: \ X##_c =3D FP_CLS_INF; \ break; \ case FP_RND_PINF: \ @@ -297,6 +299,10 @@ if (X##_s) \ X##_c =3D FP_CLS_INF; \ break; \ + case FP_RND_ODD: \ + break; \ + default: \ + _FP_UNREACHABLE; \ } \ if (X##_c =3D=3D FP_CLS_INF) \ { \ @@ -1610,10 +1616,14 @@ switch (FP_ROUNDMODE) \ { \ case FP_RND_NEAREST: \ + case FP_RND_TIESAWAY: \ _FP_TO_INT_ROUND_rounds_away \ =3D (X##_e =3D=3D _FP_EXPBIAS_##fs - 1 \ && !_FP_FRAC_ZEROP_##wc (X)); \ break; \ + case FP_RND_ODD: \ + _FP_TO_INT_ROUND_rounds_away =3D 1; \ + break; \ case FP_RND_ZERO: \ /* _FP_TO_INT_ROUND_rounds_away is already 0. */ \ break; \ @@ -1623,6 +1633,8 @@ case FP_RND_MINF: \ _FP_TO_INT_ROUND_rounds_away =3D X##_s; \ break; \ + default: \ + _FP_UNREACHABLE; \ } \ if ((rsigned) =3D=3D 0 && _FP_TO_INT_ROUND_rounds_away && X##_s) \ { \ @@ -1740,6 +1752,14 @@ case FP_RND_MINF: \ _FP_ROUND_MINF (wc, X); \ break; \ + case FP_RND_TIESAWAY: \ + _FP_ROUND_TIESAWAY (wc, X); \ + break; \ + case FP_RND_ODD: \ + _FP_ROUND_ODD (wc, X); \ + break; \ + default: \ + _FP_UNREACHABLE; \ } \ } \ _FP_FRAC_SRL_##wc (X, _FP_WORKBITS); \ diff --git a/fpu/soft-fp.h b/fpu/soft-fp.h index a7a01334b7..a95485f465 100644 --- a/fpu/soft-fp.h +++ b/fpu/soft-fp.h @@ -93,6 +93,8 @@ # define FP_RND_ZERO 1 # define FP_RND_PINF 2 # define FP_RND_MINF 3 +# define FP_RND_TIESAWAY 4 +# define FP_RND_ODD 5 #endif #ifndef FP_ROUNDMODE # define FP_ROUNDMODE FP_RND_NEAREST @@ -282,6 +284,21 @@ } \ while (0) =20 +#define _FP_ROUND_TIESAWAY(wc, X) \ + do \ + { \ + _FP_FRAC_ADDI_##wc (X, _FP_WORK_ROUND); \ + } \ + while (0) + +#define _FP_ROUND_ODD(wc, X) \ + do \ + { \ + if (!(_FP_FRAC_LOW_##wc (X) & _FP_WORK_LSB)) \ + _FP_FRAC_ADDI_##wc (X, _FP_WORK_LSB - 1); \ + } \ + while (0) + #define _FP_ROUND(wc, X) \ do \ { \ @@ -302,6 +319,14 @@ case FP_RND_MINF: \ _FP_ROUND_MINF (wc, X); \ break; \ + case FP_RND_TIESAWAY: \ + _FP_ROUND_TIESAWAY (wc, X); \ + break; \ + case FP_RND_ODD: \ + _FP_ROUND_ODD (wc, X); \ + break; \ + default: \ + _FP_UNREACHABLE; \ } \ } \ } \ --=20 2.14.3