From patchwork Thu Jul 20 15:04:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 108370 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2267543qge; Thu, 20 Jul 2017 08:18:15 -0700 (PDT) X-Received: by 10.200.35.221 with SMTP id r29mr5082790qtr.169.1500563895263; Thu, 20 Jul 2017 08:18:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500563895; cv=none; d=google.com; s=arc-20160816; b=iUJcnA13Wm9nvl4mg/BdlD7taXZmkgFa2r6NcckzXl0MuYP1MClslBJ7NHi4UXCsq9 VtKCXKU60ZM2RTQFlLgKhBGVRre/k2ZJsdcYiq5sJm6DgJw2UztUD6IqbeR+pKux7smj bO9LYREkUBLqGjMDlkzo+1eRJ02REtHDKodRx9SU3ORsIutG6nvUTPNZtrWZdv1laaHs Ts9ejsKQ86QWoNGSr20DNlWMDW7hD4Y1oXsZkIqcIv41H4ifTGxKNPnN32aShJ5yExSu wFXwqg/rQtVe1kuYVIgd2Kk94SOKB6twFIYJjtxbo+UCsYcM0W6ase1wkne3nzwqtSc6 iksw== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=+YSM1TSI70fvNJ6R6uDo0JFbaepCnTrr91TNW11bOvo=; b=k2Z95dq292FwQ4P7RIrqsLsWa8+pdHdUNYR5OE7YP6oTHZzdSCGbZxx/DvrnvBcfSv 7O4ppksWlhMtxHGYQ3cmGhfJbDnthAJ09Cfek8pV4vEOueCexBva0oOxqH7o0wbVpJMO BG6wa67eWYJawgpq7PCp4w+6kUGsg3TuajoToktG0USrZvkUs5o17nyk2UsbpzCalTuM 3BmmNqXSsgh8rwR3skdpHOEnFaD0WtYJgcYQ2dPeLx2WcQ8Hn8X9edKurcyT5eJQk8OL 6w2knDVH6nz6OAssVG1YpEPfhjLf461qmzUqQjwJUSTPCBoOTXar6aL4YTmRmcVC8PmP Oocg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=KYYJYL6R; 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 t34si2040214qtd.40.2017.07.20.08.18.14 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 20 Jul 2017 08:18:15 -0700 (PDT) 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.b=KYYJYL6R; 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]:38548 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dYDDQ-0000Ci-HY for patch@linaro.org; Thu, 20 Jul 2017 11:18:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55580) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dYD83-00039T-0o for qemu-devel@nongnu.org; Thu, 20 Jul 2017 11:12:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dYD82-0004Jx-3W for qemu-devel@nongnu.org; Thu, 20 Jul 2017 11:12:39 -0400 Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]:35043) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dYD81-0004JN-T7 for qemu-devel@nongnu.org; Thu, 20 Jul 2017 11:12:38 -0400 Received: by mail-wm0-x229.google.com with SMTP id w126so27195883wme.0 for ; Thu, 20 Jul 2017 08:12:37 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=+YSM1TSI70fvNJ6R6uDo0JFbaepCnTrr91TNW11bOvo=; b=KYYJYL6Radr40XChi4rkuqRlvevwtiwtkkZ/UcTPK90dRE9vjFnqanjGdY8mAXJAJr 5dXc9YqAWb4p2xi5anuzLgVnngccLqraJ3+NAMLKfmPCP1h6TSye/R2SGxAQ8labvudf UDSu5sX3iNJzHkfnwBSahVdaaes7is4jPz9fI= 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:mime-version:content-transfer-encoding; bh=+YSM1TSI70fvNJ6R6uDo0JFbaepCnTrr91TNW11bOvo=; b=A4ehnw7Rg7C5YfbYp0ENYF3FVswRG05Q8cmtD9xowsYMsyooDdlQPAFM5HJq4cD9G/ kQmIZouqt58uKMXoBW7Y0sQDQM5FI+PjGLtR2YyxfhJ7/PYrDxp+6vqGr5wsPNHkHWrS EqVzWjt1xdjrT7Bf316h73myHRo+T1EnCyhrywMrrtymyIqnxdRaqlzKcOay9rR3N92i E6D4bvf5BpfJTeh4Iu8W+5GK8Fphs73w7h5SsSgHmYf7t8qh7U0AB+u1b/ScBocnWbrR tzxTnjClIH4E9X+n15H+oSCWDEMNPW9mS3u2YK7qMFCJM6/Ys3DRre0L3n6yBPo9f1Fq RkrQ== X-Gm-Message-State: AIVw113H0PCDpZXF6H9G51vPp97Fww2hkc0j1faqxfcUNUlnqKlOQyWk S/tZlFDHEU8YZw3YFKRAEA== X-Received: by 10.28.178.204 with SMTP id b195mr2327003wmf.99.1500563556869; Thu, 20 Jul 2017 08:12:36 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id r3sm4081875wra.97.2017.07.20.08.12.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jul 2017 08:12:32 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id B8A753E0B27; Thu, 20 Jul 2017 16:04:33 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Thu, 20 Jul 2017 16:04:21 +0100 Message-Id: <20170720150426.12393-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170720150426.12393-1-alex.bennee@linaro.org> References: <20170720150426.12393-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::229 Subject: [Qemu-devel] [RFC PATCH for 2.11 18/23] fpu/softfloat2a: implement float16_squash_input_denormal 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: qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Aurelien Jarno , rth@twiddle.net Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This will be required when expanding the MINMAX() macro for 16 bit/half-precision operations. Signed-off-by: Alex Bennée --- fpu/softfloat2a/softfloat.c | 15 +++++++++++++++ include/fpu/softfloat2a/softfloat.h | 1 + 2 files changed, 16 insertions(+) -- 2.13.0 diff --git a/fpu/softfloat2a/softfloat.c b/fpu/softfloat2a/softfloat.c index 59b9bc9e24..4f1abbe08f 100644 --- a/fpu/softfloat2a/softfloat.c +++ b/fpu/softfloat2a/softfloat.c @@ -3488,6 +3488,21 @@ static float16 roundAndPackFloat16(flag zSign, int zExp, return packFloat16(zSign, zExp, zSig >> 13); } +/*---------------------------------------------------------------------------- +| If `a' is denormal and we are in flush-to-zero mode then set the +| input-denormal exception and return zero. Otherwise just return the value. +*----------------------------------------------------------------------------*/ +float16 float16_squash_input_denormal(float16 a, float_status *status) +{ + if (status->flush_inputs_to_zero) { + if (extractFloat16Exp(a) == 0 && extractFloat16Frac(a) != 0) { + float_raise(float_flag_input_denormal, status); + return make_float16(float16_val(a) & 0x8000); + } + } + return a; +} + static void normalizeFloat16Subnormal(uint32_t aSig, int *zExpPtr, uint32_t *zSigPtr) { diff --git a/include/fpu/softfloat2a/softfloat.h b/include/fpu/softfloat2a/softfloat.h index d9689eca2a..a274dc7419 100644 --- a/include/fpu/softfloat2a/softfloat.h +++ b/include/fpu/softfloat2a/softfloat.h @@ -282,6 +282,7 @@ void float_raise(uint8_t flags, float_status *status); | If `a' is denormal and we are in flush-to-zero mode then set the | input-denormal exception and return zero. Otherwise just return the value. *----------------------------------------------------------------------------*/ +float16 float16_squash_input_denormal(float16 a, float_status *status); float32 float32_squash_input_denormal(float32 a, float_status *status); float64 float64_squash_input_denormal(float64 a, float_status *status);