From patchwork Tue Aug 13 12:49:35 2019 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: 171182 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp861455ily; Tue, 13 Aug 2019 05:50:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqzVAiNhvpzuS59Ig6rPgiiG+lZpou+eW1huVJLVJYL2/+7w/detEYt7gJjN7Tnsak+3HFXK X-Received: by 2002:a17:906:bcf5:: with SMTP id op21mr21313510ejb.190.1565700618293; Tue, 13 Aug 2019 05:50:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565700618; cv=none; d=google.com; s=arc-20160816; b=grzVF3m5WnoCZUXVs0hDrEx1ZH1rM2JAd6BeMOL8Tc0MqokLSDTUX4XHYo2l6W16tg IYdQMy9g58X8Q8FHEmR7+iGv3NXvwE3mhOO9VP4s3QMOi+XOPBfJr0E3vdgkMawwtVf/ 99iHhH9rV8jxKHhUSPPrZigcwtSIbL2W5mHybpaYRyf/d2mw1mlKFL55yIcr/KHX54sf iRotB2yn/CUV0HKa+2rdSjqx63dGp78jFJKjmOPczR9LYPteuSyy+PYVCXCNY+jCX1j5 XXmcWOwQdYiPYlxlwHve4T9LitGXo4GwM8AeUYHw4pU0S6E07OGlDgrWY2TyKEaO9wJR MBGw== 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; bh=XEpGqIEUvdb5555PJIVv1BtkiLX36JbwzRPDngAmByI=; b=UF4GdxMmdVhK5KG++6qt7qn2OtLG2AF0M4DOtgwQ/qfcnLMXg2F5/4fq4pXpz9mg0M 8WiKZWyA5pOqSlipFwN590/ZbAG+5s0lmTBRkTy4my2/L6iGmmIb3HYA83+1kunulIlJ ukMSqVa0dgutjCQekU3svrqwbRZ/yQ3nXhcLCopS3GhmG1UTND3ne/Ueyq5wBXoghbRF lNqb9Ea86FbOy3HHFDEIpiT0bNaDBQVRiyFKZC3MoHISpTraNWs5Te7lP+dyRacunJo1 MVXW8q75kVu1ewuXjp5h5ThGt7D41klP+5GR1MF1VlE1PZtsV+bHf75Y7B8LxrqQJBCA 89aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KTkXDOfv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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. [209.51.188.17]) by mx.google.com with ESMTPS id s45si45763439edd.112.2019.08.13.05.50.17 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Aug 2019 05:50:18 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KTkXDOfv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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]:51986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxWFk-0002Na-Rg for patch@linaro.org; Tue, 13 Aug 2019 08:50:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53552) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxWFL-0002Gf-Ru for qemu-devel@nongnu.org; Tue, 13 Aug 2019 08:49:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxWFK-0000dn-Ih for qemu-devel@nongnu.org; Tue, 13 Aug 2019 08:49:51 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:35039) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hxWFK-0000ci-CI for qemu-devel@nongnu.org; Tue, 13 Aug 2019 08:49:50 -0400 Received: by mail-wm1-x342.google.com with SMTP id l2so1348443wmg.0 for ; Tue, 13 Aug 2019 05:49:50 -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=XEpGqIEUvdb5555PJIVv1BtkiLX36JbwzRPDngAmByI=; b=KTkXDOfvvzmzwEWGNlnD/FCJwALfDoET6FmIW3cUt4zj7aLXANfRtM0zGEqIHgusoL +MTUG5hXLFxVr2fFzb64aT/EPPxVN0dRVJO5Y+8nkf0WnZBGxK+lUEowJnM75gUPycoj G8xyBuXjUyAsNGXxA61tZ5ubc4lXSjNSo0JK4UXekBuqRqMr2175Jlxjby8okhSa0pun eotqhlOsFNyJWekhqmEhmnxsJ9OfTr89C59cjCou8pPxN0w5LFGXG/+3Dp3yE+lsfxpZ tSOJ5ZWAX9eOxQzTZWqcJhYOGrLyUWewYVskT4iZQ4OTZeh2z9Pf88+4GlUwXoYELc/U mGZQ== 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=XEpGqIEUvdb5555PJIVv1BtkiLX36JbwzRPDngAmByI=; b=sj/dc+UqSLBIFAsTfczoUCfJWVW2P5h6M0uwmzUNVBuiE7cbHzatotSme/X69hJSjM f0AmaFaTEbDTL/Hqm1Sbl1eFl9/msl98c1ShiVIM+MdBK3nKjsZHzfKguU8PlqRxKXYq pKc6Dl/lkTafTTY91vTgwCatJtAmHbMM2imQioXh6EJLq6S0+mDQQPZywgqK2PD6gIiN 2eoNaBRMKULRq7GdWUJ0/TGTxl3Ed6oN+UACkH250lNPxj5WkbU/5lmgO9IDe1ZcBbfV hb/X1LyfL6bxAf1KIzVLEgxYBEYinE+4sFKd+uHKHzo12sJC53Nh1Zex/2AU0yo+mMEO wkBg== X-Gm-Message-State: APjAAAVbM8EWgqJKtk8nolaaWQd15dfQyn67MEonWszlI14OFpHBTyos ycAd1LpCdujE9YpsnP7grm4vCw== X-Received: by 2002:a7b:c649:: with SMTP id q9mr2916718wmk.108.1565700589199; Tue, 13 Aug 2019 05:49:49 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 16sm1977052wmx.45.2019.08.13.05.49.47 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 13 Aug 2019 05:49:47 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 1A2241FF8F; Tue, 13 Aug 2019 13:49:47 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Tue, 13 Aug 2019 13:49:35 +0100 Message-Id: <20190813124946.25322-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190813124946.25322-1-alex.bennee@linaro.org> References: <20190813124946.25322-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:4864:20::342 Subject: [Qemu-devel] [PATCH v3 02/13] fpu: convert float[16/32/64]_squash_denormal to new modern style X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?utf-8?q?Alex_Benn=C3=A9e?= , armbru@redhat.com, Aurelien Jarno Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This also allows us to remove the extractFloat16exp/frac helpers. Signed-off-by: Alex Bennée --- fpu/softfloat.c | 110 +++++++++++++++++++++--------------------------- 1 file changed, 47 insertions(+), 63 deletions(-) -- 2.20.1 diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 2ba36ec3703..0a434555cd8 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -414,24 +414,6 @@ float64_gen2(float64 xa, float64 xb, float_status *s, return soft(ua.s, ub.s, s); } -/*---------------------------------------------------------------------------- -| Returns the fraction bits of the half-precision floating-point value `a'. -*----------------------------------------------------------------------------*/ - -static inline uint32_t extractFloat16Frac(float16 a) -{ - return float16_val(a) & 0x3ff; -} - -/*---------------------------------------------------------------------------- -| Returns the exponent bits of the half-precision floating-point value `a'. -*----------------------------------------------------------------------------*/ - -static inline int extractFloat16Exp(float16 a) -{ - return (float16_val(a) >> 10) & 0x1f; -} - /*---------------------------------------------------------------------------- | Returns the fraction bits of the single-precision floating-point value `a'. *----------------------------------------------------------------------------*/ @@ -3306,6 +3288,53 @@ float64 float64_silence_nan(float64 a, float_status *status) return float64_pack_raw(p); } + +/*---------------------------------------------------------------------------- +| 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. +*----------------------------------------------------------------------------*/ + +static FloatParts parts_squash_denormal(FloatParts p, float_status *status) +{ + if (p.exp == 0 && p.frac != 0) { + float_raise(float_flag_input_denormal, status); + p.frac = 0; + p.cls = float_class_zero; + } + + return p; +} + +float16 float16_squash_input_denormal(float16 a, float_status *status) +{ + if (status->flush_inputs_to_zero) { + FloatParts p = float16_unpack_raw(a); + p = parts_squash_denormal(p, status); + return float16_pack_raw(p); + } + return a; +} + +float32 float32_squash_input_denormal(float32 a, float_status *status) +{ + if (status->flush_inputs_to_zero) { + FloatParts p = float32_unpack_raw(a); + p = parts_squash_denormal(p, status); + return float32_pack_raw(p); + } + return a; +} + +float64 float64_squash_input_denormal(float64 a, float_status *status) +{ + if (status->flush_inputs_to_zero) { + FloatParts p = float64_unpack_raw(a); + p = parts_squash_denormal(p, status); + return float64_pack_raw(p); + } + return a; +} + /*---------------------------------------------------------------------------- | Takes a 64-bit fixed-point value `absZ' with binary point between bits 6 | and 7, and returns the properly rounded 32-bit integer corresponding to the @@ -3482,21 +3511,6 @@ static int64_t roundAndPackUint64(flag zSign, uint64_t absZ0, return absZ0; } -/*---------------------------------------------------------------------------- -| 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. -*----------------------------------------------------------------------------*/ -float32 float32_squash_input_denormal(float32 a, float_status *status) -{ - if (status->flush_inputs_to_zero) { - if (extractFloat32Exp(a) == 0 && extractFloat32Frac(a) != 0) { - float_raise(float_flag_input_denormal, status); - return make_float32(float32_val(a) & 0x80000000); - } - } - return a; -} - /*---------------------------------------------------------------------------- | Normalizes the subnormal single-precision floating-point value represented | by the denormalized significand `aSig'. The normalized exponent and @@ -3635,21 +3649,6 @@ static float32 } -/*---------------------------------------------------------------------------- -| 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. -*----------------------------------------------------------------------------*/ -float64 float64_squash_input_denormal(float64 a, float_status *status) -{ - if (status->flush_inputs_to_zero) { - if (extractFloat64Exp(a) == 0 && extractFloat64Frac(a) != 0) { - float_raise(float_flag_input_denormal, status); - return make_float64(float64_val(a) & (1ULL << 63)); - } - } - return a; -} - /*---------------------------------------------------------------------------- | Normalizes the subnormal double-precision floating-point value represented | by the denormalized significand `aSig'. The normalized exponent and @@ -4981,21 +4980,6 @@ int float32_unordered_quiet(float32 a, float32 b, float_status *status) return 0; } -/*---------------------------------------------------------------------------- -| 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; -} - /*---------------------------------------------------------------------------- | Returns the result of converting the double-precision floating-point value | `a' to the extended double-precision floating-point format. The conversion