From patchwork Fri Oct 13 16:24:14 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: 115788 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp921841qgn; Fri, 13 Oct 2017 09:29:33 -0700 (PDT) X-Received: by 10.200.50.230 with SMTP id a35mr2893794qtb.226.1507912173247; Fri, 13 Oct 2017 09:29:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507912173; cv=none; d=google.com; s=arc-20160816; b=lHBiagSjLf52EEwoJeLyG1Ci8JjsgcK2vlCj1UKyV93O4hF94HcJqDC6HoEv7BG+S+ vFaddZ//N4JBjAbOMA5//WGt9ab/1MJHnvboz/P4bhVXrxiQa9Krbda+q1B45kGLupbj I8nDdy4M66lQH8QAcysNe7RpdkAHOVTjqxfjQbxW89DSq19LshQjf75UEP+p8rjdfMnv BJ6hFJX2O0lhOs8JJGje/v3h1wuNZY4tQ6+J1LygmlPVNaNziGK270zKXeNw/GDNOkYU gH3XF+Drrg92oTLk94js3Ss1iBSnYmAXDsby+k+iqwvxw+aiPyBTBXNpHC8eG4ezhHAX Q+ag== 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=/ILSMgJPmHL8NTcJ6LKg/3Dh7htBXoyvVG+Xzv5BpWM=; b=zL4XDdu2tpuMxBB+1DP2aHNi+Ma6fT/7uQj+I0e3cSz+UjMlkoAW+pWroYf55vqKIh SIfEfPg234aPllPwRyHJyRVTPSd5hVuWRbjJSEoWqNShTxHft1a/hTUnJCVdhcf57zb4 bZuGv7wQJ9565RLcJPoYGpDmNvPridy+0LgM41LozaImtAIA3rqOQbbTnkpSDWvkFO9w Y5ot7oXghjWkFt7/kErf/GQbR236OcC00xg2ib6aMJOYJGLd6dg0ExHS5V66qJvh0Dqp 8vbv8eLyj5HN3FjAv1kTL+SU6dUbZ0/DjQsrtCAN7emNvsrzrXcjp8LznSpUD8oArCW3 usRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RLPZZY0c; 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 a9si171138qkh.311.2017.10.13.09.29.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 13 Oct 2017 09:29:33 -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.s=google header.b=RLPZZY0c; 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]:51042 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e32q2-0006LJ-S8 for patch@linaro.org; Fri, 13 Oct 2017 12:29:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e32lU-0002Qq-8J for qemu-devel@nongnu.org; Fri, 13 Oct 2017 12:24:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e32lT-0006Wp-6u for qemu-devel@nongnu.org; Fri, 13 Oct 2017 12:24:48 -0400 Received: from mail-wr0-x22e.google.com ([2a00:1450:400c:c0c::22e]:53996) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e32lS-0006VQ-RZ for qemu-devel@nongnu.org; Fri, 13 Oct 2017 12:24:46 -0400 Received: by mail-wr0-x22e.google.com with SMTP id y44so1424697wry.10 for ; Fri, 13 Oct 2017 09:24:46 -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=/ILSMgJPmHL8NTcJ6LKg/3Dh7htBXoyvVG+Xzv5BpWM=; b=RLPZZY0cNtkqpNTUREEa1RZ8I4sYgOmXXuMZrRYWPrM4WxK+Er2+tBXcjSPiieHXTl Qi4Qu6JK5GC/iYPcZoO7lgQbuZzDRjnFZu0jCrjMYg6XW+nQs62QdsHoiMmeEChZehkY ctL4wCXEuBlWeC+Bam+Y4k+Jy/gpxx74eViIA= 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=/ILSMgJPmHL8NTcJ6LKg/3Dh7htBXoyvVG+Xzv5BpWM=; b=p6slkQtVCFWMZHOqODnhATBOa2ylE/72T9qmzUyD/O8wmj4p3WkXQkByKow4o0uP6W jZEc+orowABQILOIA/1uDBGgXq4A4aN29HLgERp+0yw8Iv+0sAsgGlvg0M7u72ecYXua EK+QAeh8RlEGtNNixjdkqt8ZOAQ45VZwacEnXpdVwTkYtrrxhsuCppdUygHfB+j0C6bu 67JLe/N5rMQCV9yFzlaa8V7Ey1DXWFcVD/e8zkkyfi1+9yhFvL9yuuH3Z+f/tvIZtspS RSSrBNx1mebMnWeTqGex2r99FsjRBOwwzYVMODDNtnAOjTTRLnspZLwL41Nni/AyCKh9 y/Lg== X-Gm-Message-State: AMCzsaUqN+CP2kjVjaqQhdyIklfLg3U3xsQ4WtwGD9n9c2kAlKKzcsaw hobgh05mw2bJlZzq0UOwHlS6gQ== X-Google-Smtp-Source: AOwi7QAcSTGMPGxi/Lw5yRBCFPKOK4B89G/TG5E2IOxQSKJ0L7L6NyDNvuO7kldLs8tZN4xo8KQebQ== X-Received: by 10.223.169.33 with SMTP id u30mr1820536wrc.205.1507911885779; Fri, 13 Oct 2017 09:24:45 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id e132sm1404279wmd.42.2017.10.13.09.24.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Oct 2017 09:24:42 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id D243C3E0756; Fri, 13 Oct 2017 17:24:38 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: richard.henderson@linaro.org Date: Fri, 13 Oct 2017 17:24:14 +0100 Message-Id: <20171013162438.32458-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171013162438.32458-1-alex.bennee@linaro.org> References: <20171013162438.32458-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:c0c::22e Subject: [Qemu-devel] [RFC PATCH 06/30] fpu/softfloat: 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: peter.maydell@linaro.org, qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , qemu-devel@nongnu.org, Aurelien Jarno 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/softfloat.c | 15 +++++++++++++++ include/fpu/softfloat.h | 1 + 2 files changed, 16 insertions(+) -- 2.14.1 Reviewed-by: Richard Henderson diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 433c5dad2d..3a4ab1355f 100644 --- a/fpu/softfloat.c +++ b/fpu/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/softfloat.h b/include/fpu/softfloat.h index 0f96a0edd1..d5e99667b6 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -277,6 +277,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);