From patchwork Tue Feb 6 16:47:54 2018 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: 127024 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3087096ljc; Tue, 6 Feb 2018 08:48:53 -0800 (PST) X-Google-Smtp-Source: AH8x2260nHlyGt2mOaizZsszPa8IsTgNik3OYv1gEWpOR+nIQqczGiivs86u5NBpjQqakmAxJLX0 X-Received: by 10.37.132.5 with SMTP id u5mr2067862ybk.138.1517935733089; Tue, 06 Feb 2018 08:48:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517935733; cv=none; d=google.com; s=arc-20160816; b=n+SBYhFIw8hbhq8ZRvfLuqYtPaOXFqHOP8zzp/IpuKyVbSt7girgFZaaBVfRurMPfc +mNYAcOp0Ruy/kufKAWqDRxR/x+2If4eUvYR+13KOzTP5J0vM63+by1LeRE5Knv9/HcP 73hL3GLKotEP91uiVwZIJiaZlqq/t4Icj2GCwJe+PqM1FiUKvcuwDmeatI6v624jE8BO QD9SPuwmvXp4jiktKVuehUc412Ir0IR3cPZKTGkgUVyiYr3lVMwoknceBsqqTI302eD4 nhOTUsArhEtQx8nO2mZ9P0/7RvLTXQB6WQvWHeYA2iurn0zrl22Nq3n4mZSGRZvsPzjE aWNQ== 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=h31NeeUXL9yU7R2Yb4mynZARITWdaJeJqTMLzgQtKsM=; b=Q/zbpXbHrhj11IhbKrE7Tqt0iWPzpcmwApMgVVlYPApaXobXN1jXemw2raddjCo91v zsmlluKmkxE4o9uQTOGK+D/FWSZ/sV9a0oCR/TN0pdGhghIwEU5prStPCijRT+hKLeaN dfql8JMo/UIWN/k5vdliu7vPijXA432OGDBe4psMu2LG3ww08HhYJtFdW8vh0A9De+f4 rBDC+XrX6El55npXIPglwKJjXWCmLkpLCuGTsA5Dtg4jCFCGlv6C2qKbGQut7Cb9Fo3Y QSHR8tdExuK/SqJu6SYmYo8TBL0QAxfsESFxlmfdg7/HUReafEzMAAxy1biaVyfyZ0Tn jl9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UBW3sjxX; 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 o17si1300654ybm.292.2018.02.06.08.48.52 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 06 Feb 2018 08:48:53 -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=UBW3sjxX; 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]:37432 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ej6QO-0000Ty-EG for patch@linaro.org; Tue, 06 Feb 2018 11:48:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33392) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ej6Pu-0000T7-5b for qemu-devel@nongnu.org; Tue, 06 Feb 2018 11:48:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ej6Pq-0004fE-Ol for qemu-devel@nongnu.org; Tue, 06 Feb 2018 11:48:22 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:41050) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ej6Pq-0004dQ-IY for qemu-devel@nongnu.org; Tue, 06 Feb 2018 11:48:18 -0500 Received: by mail-wr0-x242.google.com with SMTP id v15so2649510wrb.8 for ; Tue, 06 Feb 2018 08:48:18 -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=h31NeeUXL9yU7R2Yb4mynZARITWdaJeJqTMLzgQtKsM=; b=UBW3sjxXiaaaSup07qEIjhv3D24YUUTp1qMVT6dWyOK8yMxuAvrRpPriPaPkN7/QIR F8c3ptyo9zA0G/Butz/BuTuUSlI7O9YvjGIZt8ZnsJlWrqgd+4+B7kdvNdxkFSEMC+IK mehiytcGxrYWr3DIq7RuE7SBRQ87dSN5gTdcI= 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=h31NeeUXL9yU7R2Yb4mynZARITWdaJeJqTMLzgQtKsM=; b=syKM9/LJm3qSrTPYdHikAJCRHHyJ2zbEM3B9/nLemCB7IezhwGCpJCMM5pdnQ1Ztbv XGtFbtW5+uIAd9wiIQF8gkY3NzqjqeO1k8Cn3KtOXZvOkChyZJ7ROmjjBVUvzCPTicxk aUcwwuMAW4tacjsNqA44T7PrlKvg/MBvsn7TXThS4YSwEat06NTvkuZw/tv6vTG7GHhB 7sFgTY8OO3VAkKcfh8m2zGqPsq0/ASMH2q3+LpNRIFJD3sEyhe5h1xvncCDAZn4p8NVM QQG9kZM+urGJH2Y2B9Am8CjOf8xoWs4kWvvroMFjqJmZAGpQBAY0msnQiHZqyaPdN6nA LZRA== X-Gm-Message-State: APf1xPCS7wbCeG73bhE3Ohf2IZ37+ortmu/zG7dKjn1+eyHEOg8XQnOP WRnGx4ISpN47v+AEvJanMglsXA== X-Received: by 10.223.163.207 with SMTP id m15mr2968527wrb.174.1517935697375; Tue, 06 Feb 2018 08:48:17 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id k3sm23125266wmk.3.2018.02.06.08.48.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Feb 2018 08:48:16 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 2DC043E025C; Tue, 6 Feb 2018 16:48:15 +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 Date: Tue, 6 Feb 2018 16:47:54 +0000 Message-Id: <20180206164815.10084-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180206164815.10084-1-alex.bennee@linaro.org> References: <20180206164815.10084-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::242 Subject: [Qemu-devel] [PATCH v4 01/22] 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 Reviewed-by: Peter Maydell --- 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);