From patchwork Mon Dec 11 12:56:47 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: 121395 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2757476qgn; Mon, 11 Dec 2017 05:00:31 -0800 (PST) X-Google-Smtp-Source: ACJfBouUYOk7ISA90Ja6o0LYGq4EWhQIffFPzTiJJU5bX2bFZmLVUfFiXndFz7zP+TDv2U5rCaf3 X-Received: by 10.37.58.7 with SMTP id h7mr181519yba.284.1512997231135; Mon, 11 Dec 2017 05:00:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512997231; cv=none; d=google.com; s=arc-20160816; b=RDhP68SNFuwNvdC6kc1ZoPwZBaBGMvyO2idXgBo4fMx5cYqYmnoaxm6BqE7AfRcwNP SKlCmhVOUPFSkFNVjhx9V8BNPo/Hhq4l6hhBVuifqD4uy7CQoK4KjPQGq8NHfdD7TI7g uLOqcHBHpJBLwyahzQ5ssAQNLATH0yC2IikBWvjQ8O0aW3/LlL16dFjELt16NCUyhRCn fluEPVUOLGevvk2TFWy/k4tfjc7uEQDjfzVLZySxXLLv8uf0S2d0I5da6s/sIj18C9oY OLIqPlXDJfL/ziZk1lzGJRNt/GSyQXZJuIjSo4xwfVV+IRqI7rsVLnI2myBpZmmzaG23 WwGQ== 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=kFWWImcJFakK6Q/MS9IUPme+eMbtlWRk0/W9mj8nEvI=; b=VUj61xqNZ9+PuI+CoJOyOUduZUeyqymK/M6+JykfqJ4nW0JpTQqnY7y39kUAHBQgMY 1Vl70JL65jn2GIWhYPyP2UX/PPyu3gKKYwwC9qwfkKuzl1PYSdZc8njPC5+o8uLHbjOv KgcPyNMMRPyps4AAAb4rrz/8MlYUUq3ytux74wA0WFa9hoVSRGmmc6AEsKW4pDFOrakQ fe5rHgIFDLvCKSD5ZRpZJTTPy/rxaRj58SH/pLpSG9xPCk9laIwxln3ykPYNBB70I2pg p9PnoY/XC9GuWUgunAfJM4shMNx+Yjtw8D3WdbZyEtsdjZhyQekNrA6RWYnlmS5w8hGb 0JWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ea6sGEAV; 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 l14si3041738ywi.554.2017.12.11.05.00.31 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 11 Dec 2017 05:00:31 -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=ea6sGEAV; 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]:52595 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eONh8-0004ju-L7 for patch@linaro.org; Mon, 11 Dec 2017 08:00:30 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51416) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eONdv-0002JW-VX for qemu-devel@nongnu.org; Mon, 11 Dec 2017 07:57:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eONdt-0007Y5-At for qemu-devel@nongnu.org; Mon, 11 Dec 2017 07:57:12 -0500 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:43926) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eONdt-0007XB-4U for qemu-devel@nongnu.org; Mon, 11 Dec 2017 07:57:09 -0500 Received: by mail-wr0-x244.google.com with SMTP id z34so17439199wrz.10 for ; Mon, 11 Dec 2017 04:57:08 -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 :mime-version:content-transfer-encoding; bh=kFWWImcJFakK6Q/MS9IUPme+eMbtlWRk0/W9mj8nEvI=; b=ea6sGEAVJgWF1bzup+xnZvuOFG8RCcJnt+M36usCfZx2qxRSCj/r3lmSntOkiucKWU HGfh1d3GtuRJOGBFQQSvNmdFXFdDFZhURtqCa3gIfp4+mmlyvm9+bmoJGHnzBpvdMpdu h5b1I+X3yJJ/ATHTz1upZIKH3vlXYtPSVqcU8= 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=kFWWImcJFakK6Q/MS9IUPme+eMbtlWRk0/W9mj8nEvI=; b=WvsjEc4ck0ymMKTlBVwAQAXwV9/qJN1btQQQk/GNUu/kRdW3gy42j8nHDTcICwoOAz pAeDxRL9Q3tteDDxLF62dEgLxzTHDuMPzKhY7iqjrQdm42RptauBFieol+WckcNqvjPk XCo7Gu9N3Tpym8oDEngvnkZC93rbPGt3c0wPZgVpygTXXcuLO0WXB18ChjAJHVPUXTuY jpMNoaI1yhqqHRtgl2IvmlXs5Nu3buaXjMtzL9qgopYE6UjIUJx6y1Pia0aLLE37Qd4L 5A42TqqVJhRe6VeDUoAZEQLET+zL05DDi73dhlldlP4adGzIf7C8LlK4z3NDhaewRbbw mXCw== X-Gm-Message-State: AKGB3mII6uO/C7wflZfIAaj0YWGLigEKQJjuSLt5f7mUMF+7Eh6+cSJV gNoaJ8u48/g/QAk5kHMGtznMmQ== X-Received: by 10.223.176.113 with SMTP id g46mr300933wra.267.1512997027866; Mon, 11 Dec 2017 04:57:07 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id r14sm20060585wrb.43.2017.12.11.04.57.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Dec 2017 04:57:06 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 76C5B3E042D; Mon, 11 Dec 2017 12:57:05 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: richard.henderson@linaro.org, peter.maydell@linaro.org, laurent@vivier.eu, bharata@linux.vnet.ibm.com, andrew@andrewdutcher.com, aleksandar.markovic@imgtec.com Date: Mon, 11 Dec 2017 12:56:47 +0000 Message-Id: <20171211125705.16120-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20171211125705.16120-1-alex.bennee@linaro.org> References: <20171211125705.16120-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::244 Subject: [Qemu-devel] [PATCH v1 01/19] 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: =?utf-8?q?Alex_Benn=C3=A9e?= , 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 Reviewed-by: Richard Henderson --- fpu/softfloat.c | 15 +++++++++++++++ include/fpu/softfloat.h | 1 + 2 files changed, 16 insertions(+) -- 2.15.1 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);