From patchwork Sun Feb 4 04:11:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 126803 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp926782ljc; Sat, 3 Feb 2018 20:20:50 -0800 (PST) X-Google-Smtp-Source: AH8x227sdLlC/X/VVUli29QsMAy/W+lZD+mcGpVWgmF2hLFks2AJ3eCjTfbnidO5uRO0TfbOrM89 X-Received: by 10.37.206.134 with SMTP id x128mr8638634ybe.83.1517718050379; Sat, 03 Feb 2018 20:20:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517718050; cv=none; d=google.com; s=arc-20160816; b=kERcTsWXQ2LwV26UhifkCYLW7+O0nw8vI9bfAvqyALi9iWb65TDYxOyXHdKSomJ8FL 2pdgHQlK6nXS/7j6w9VcVrGaAR338Gq2/8NZDqDRRE+eWD9orgWjAMu0qS55LbyWR3WZ Hi0+lZ+PsHvKqenp++ajW+tCE51h+61BGm6mhugCFQLRaPoWrnLbF+69dW0qp8TwzVNk K9bOCT3TBE9CQsqarILhWJA2dYmLisROQ6uh/ogyy57Gte73BagNMZzHplahtvVrid4W m83bJHsLZeJ7SNFmkTTa7vHpHMn/Eunklfh67OEFFp2GOpy0dZxqoMXgtmBJ98s3fU8+ hKHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=0SCjxxEWFJsjx9dBnP24HcnJKoUvfKn58tKIdmV+sDM=; b=jWhgFyP83buwY9STppcglORPZVRP6t0WBi7juT02rPPs3CsCeavk+FEJ0I9ci5sMEX jTWzCvHg4ng8cYCmuix5MMP9aRCzAoi6IWF/7TQXrVqhtIIVqvNh7glQ5v3LNTRZnuLc qtiAzugxrcfTMDZKjHCdrBQRZDFI11ZEwh6QllyJK/j23mc2MFbMCXwoFrv2nXx1Sf9R nm/QdSFr81+pgi9S8jEu6aPwafpAA7YK/PazSPeWiYJOfxie63nzd9CRoILJu/5Tw6YJ NewXaWLtByTzdnMTg8QoOvuGbKagUj1EUSZtTZvdiU2YcMw38ahM95ms7hNXW/xCTs8l EZdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hJeba4/q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id d10si1010798ybi.758.2018.02.03.20.20.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 03 Feb 2018 20:20:50 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hJeba4/q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:58289 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiBnN-0002pY-Jg for patch@linaro.org; Sat, 03 Feb 2018 23:20:49 -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) 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-Received: by 2002:a17:902:8c89:: with SMTP id t9-v6mr38495202plo.2.1517717517495; Sat, 03 Feb 2018 20:11:57 -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) 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(+) -- 2.14.3 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 == FP_RND_NEAREST \ + || FP_ROUNDMODE == FP_RND_TIESAWAY \ || (FP_ROUNDMODE == FP_RND_PINF && !X##_s) \ || (FP_ROUNDMODE == FP_RND_MINF && X##_s)) \ { \ @@ -287,6 +288,7 @@ switch (FP_ROUNDMODE) \ { \ case FP_RND_NEAREST: \ + case FP_RND_TIESAWAY: \ X##_c = FP_CLS_INF; \ break; \ case FP_RND_PINF: \ @@ -297,6 +299,10 @@ if (X##_s) \ X##_c = FP_CLS_INF; \ break; \ + case FP_RND_ODD: \ + break; \ + default: \ + _FP_UNREACHABLE; \ } \ if (X##_c == FP_CLS_INF) \ { \ @@ -1610,10 +1616,14 @@ switch (FP_ROUNDMODE) \ { \ case FP_RND_NEAREST: \ + case FP_RND_TIESAWAY: \ _FP_TO_INT_ROUND_rounds_away \ = (X##_e == _FP_EXPBIAS_##fs - 1 \ && !_FP_FRAC_ZEROP_##wc (X)); \ break; \ + case FP_RND_ODD: \ + _FP_TO_INT_ROUND_rounds_away = 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 = X##_s; \ break; \ + default: \ + _FP_UNREACHABLE; \ } \ if ((rsigned) == 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) +#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; \ } \ } \ } \