From patchwork Tue May 15 22:25:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135954 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp89933lji; Tue, 15 May 2018 15:44:23 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrohgVu6FFqclUkCHOSUrn309CoNGiIwJrp6VpxWBuUeNNZDfojGSEXL+q+eqwaxmcBr6+3 X-Received: by 2002:a37:6343:: with SMTP id x64-v6mr14694199qkb.182.1526424263816; Tue, 15 May 2018 15:44:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526424263; cv=none; d=google.com; s=arc-20160816; b=CcWzcstfOOilyfEGgcYOQwLav6e6nXO7A/I3wzcT9IT+5gk3pXp+Uo4L+u61e683W2 sZtw+vaI5RjAVQU2dGfCE1sSSNvFhDTyOaf0Q1aCQ5s6RuYj0OOjUimUGQkbLboqvKOV tZTaAHJNo3jjX6gmLMbAlaJ/8WBk7NGzV3F4Uw/CbPT4mzhVucrnKE8o0CCGBwv3M4Q9 L3qRkiRCcYY0ID0qHoV9Sh3x1mDT5vSgBdWiDT8/vGe5hJf5t4ZjsO5N1cKupO6C+oJE mvplRUlJzzCTD2PEVVgnltw3CEQDd4LLOvfERP1HevwXydtUg0IraDvd3xG7Z5aTPaSQ h6Ng== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=vX12ZtlpQa6Nv7/rq1wfPxTqdC3HQkrlkn2HkZRVyV4=; b=dRlJxbeWQduSuE/NdBMzgjNhkgPXrw9a2KAeVeAXBTC+OvxX/NVxK7rN0buWL9MIY8 2SOsFMpdfiRs8Hwusmt/5DMfmkyytsFud/UggxDVrAuoH6LWhONMw+MlImZvk+MNKuTt L/lNd6BWS2SgpRAKQKX8TtCr/x7TqY900wzo/jWf+frTc0zzSehMxkki42wkjwHMBhr2 Wqa9gJUnbVpsh9Z4Ig5Ow/xDzZNyo2sU3vFe+h0yQgVHYB1FtJfwVlvJSHTczLJY36qV O3ijZgtkFzKE0+A9BrcRwb3bteDRMWaSgJNHjvU9U1JQXcIDjpWQG+hWHHfpLg1Eozeq SQ8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IYK+B3BY; 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 z36-v6si1225951qtz.320.2018.05.15.15.44.23 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 15 May 2018 15:44:23 -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=IYK+B3BY; 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]:36402 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIigB-0007yV-5S for patch@linaro.org; Tue, 15 May 2018 18:44:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39853) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIiOp-0003od-DZ for qemu-devel@nongnu.org; Tue, 15 May 2018 18:26:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIiOn-0000SV-4E for qemu-devel@nongnu.org; Tue, 15 May 2018 18:26:27 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:34604) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIiOm-0000M1-Mp for qemu-devel@nongnu.org; Tue, 15 May 2018 18:26:24 -0400 Received: by mail-pl0-x243.google.com with SMTP id ay10-v6so874617plb.1 for ; Tue, 15 May 2018 15:26:24 -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; bh=vX12ZtlpQa6Nv7/rq1wfPxTqdC3HQkrlkn2HkZRVyV4=; b=IYK+B3BY4uF2ehyfhzGCfgJtgOysuc5Vfvtm/7lmqhAgx2TnGa+sqYebvU7OXILqGW 0v52Qrq8OpUMDJ3q2zhnHbAiBghgTyePh/WXs7W4KJxSSDXaoxxFmzxvjwgXjq76gaf4 5xTehqn5UbreL6+EIYFEoZYXNN/pzMsNMLX6Q= 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; bh=vX12ZtlpQa6Nv7/rq1wfPxTqdC3HQkrlkn2HkZRVyV4=; b=QTDMohCZ43ZUBG+NHtUPjxrti3bvMP6qLVBxwhZwIZwgi6QgMHEi0DSobXnejzN87r o42yPEFf0mKVaT9MPqeW6z4ACPABhVVPbO/N8y6sNiG5fiMtGw5sZiC7nKQaJv3tOjds G4D4xbplo05GadlMDmVriDnC8TgRoNzQ8qgbTnTwLxGwFSksY4Y+21rqrH8kfTLqUV1C qHZR2oGIWHsERpf/92G1MqHcOXCz9rOB+2UcSMbZ+PvI1xFzfLQHgEzjP1Iu/0CpG4vd EfN/sI5o/kq8uGseQ5alcNTUQUx2DmafzI4je8dbeHc5s/J+EUc52aZwypuYCyTsDGsZ zE+A== X-Gm-Message-State: ALKqPwf8enf6i0SmLLs8XaXfFwoIyFcv9/kOVwpiPYh10Yi2DTdFeL/s xbkDI87GH9lsIdjKYGoFtgLd7g0XBZ4= X-Received: by 2002:a17:902:c6b:: with SMTP id 98-v6mr6136415pls.270.1526423183331; Tue, 15 May 2018 15:26:23 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id g11-v6sm941419pgq.62.2018.05.15.15.26.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 May 2018 15:26:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 15 May 2018 15:25:40 -0700 Message-Id: <20180515222540.9988-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180515222540.9988-1-richard.henderson@linaro.org> References: <20180515222540.9988-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::243 Subject: [Qemu-devel] [PATCH v6 28/28] fpu/softfloat: Define floatN_silence_nan in terms of parts_silence_nan 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, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Isolate the target-specific choice to 3 functions instead of 6. The code in floatx80_default_nan tried to be over-general. There are only two targets that support this format: x86 and m68k. Thus there is no point in inventing a mechanism for snan_bit_is_one. Move routines that no longer have ifdefs out of softfloat-specialize.h. Signed-off-by: Richard Henderson --- fpu/softfloat-specialize.h | 81 ++------------------------------------ fpu/softfloat.c | 31 +++++++++++++++ 2 files changed, 35 insertions(+), 77 deletions(-) -- 2.17.0 Reviewed-by: Alex Bennée diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index ec4fb6ba8b..16c0bcb6fa 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -278,24 +278,6 @@ int float16_is_signaling_nan(float16 a_, float_status *status) #endif } -/*---------------------------------------------------------------------------- -| Returns a quiet NaN from a signalling NaN for the half-precision -| floating point value `a'. -*----------------------------------------------------------------------------*/ - -float16 float16_silence_nan(float16 a, float_status *status) -{ -#ifdef NO_SIGNALING_NANS - g_assert_not_reached(); -#else - if (snan_bit_is_one(status)) { - return float16_default_nan(status); - } else { - return a | (1 << 9); - } -#endif -} - /*---------------------------------------------------------------------------- | Returns 1 if the single-precision floating-point value `a' is a quiet | NaN; otherwise returns 0. @@ -334,30 +316,6 @@ int float32_is_signaling_nan(float32 a_, float_status *status) #endif } -/*---------------------------------------------------------------------------- -| Returns a quiet NaN from a signalling NaN for the single-precision -| floating point value `a'. -*----------------------------------------------------------------------------*/ - -float32 float32_silence_nan(float32 a, float_status *status) -{ -#ifdef NO_SIGNALING_NANS - g_assert_not_reached(); -#else - if (snan_bit_is_one(status)) { -# ifdef TARGET_HPPA - a &= ~0x00400000; - a |= 0x00200000; - return a; -# else - return float32_default_nan(status); -# endif - } else { - return a | (1 << 22); - } -#endif -} - /*---------------------------------------------------------------------------- | Returns the result of converting the single-precision floating-point NaN | `a' to the canonical NaN format. If `a' is a signaling NaN, the invalid @@ -706,31 +664,6 @@ int float64_is_signaling_nan(float64 a_, float_status *status) #endif } -/*---------------------------------------------------------------------------- -| Returns a quiet NaN from a signalling NaN for the double-precision -| floating point value `a'. -*----------------------------------------------------------------------------*/ - -float64 float64_silence_nan(float64 a, float_status *status) -{ -#ifdef NO_SIGNALING_NANS - g_assert_not_reached(); -#else - if (snan_bit_is_one(status)) { -# ifdef TARGET_HPPA - a &= ~0x0008000000000000ULL; - a |= 0x0004000000000000ULL; - return a; -# else - return float64_default_nan(status); -# endif - } else { - return a | LIT64(0x0008000000000000); - } -#endif -} - - /*---------------------------------------------------------------------------- | Returns the result of converting the double-precision floating-point NaN | `a' to the canonical NaN format. If `a' is a signaling NaN, the invalid @@ -886,16 +819,10 @@ int floatx80_is_signaling_nan(floatx80 a, float_status *status) floatx80 floatx80_silence_nan(floatx80 a, float_status *status) { -#ifdef NO_SIGNALING_NANS - g_assert_not_reached(); -#else - if (snan_bit_is_one(status)) { - return floatx80_default_nan(status); - } else { - a.low |= LIT64(0xC000000000000000); - return a; - } -#endif + /* None of the targets that have snan_bit_is_one use floatx80. */ + assert(!snan_bit_is_one(status)); + a.low |= LIT64(0xC000000000000000); + return a; } /*---------------------------------------------------------------------------- diff --git a/fpu/softfloat.c b/fpu/softfloat.c index c8b33e35f4..8cd2400081 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -2134,6 +2134,37 @@ float128 float128_default_nan(float_status *status) return r; } +/*---------------------------------------------------------------------------- +| Returns a quiet NaN from a signalling NaN for the floating point value `a'. +*----------------------------------------------------------------------------*/ + +float16 float16_silence_nan(float16 a, float_status *status) +{ + FloatParts p = float16_unpack_raw(a); + p.frac <<= float16_params.frac_shift; + p = parts_silence_nan(p, status); + p.frac >>= float16_params.frac_shift; + return float16_pack_raw(p); +} + +float32 float32_silence_nan(float32 a, float_status *status) +{ + FloatParts p = float32_unpack_raw(a); + p.frac <<= float32_params.frac_shift; + p = parts_silence_nan(p, status); + p.frac >>= float32_params.frac_shift; + return float32_pack_raw(p); +} + +float64 float64_silence_nan(float64 a, float_status *status) +{ + FloatParts p = float64_unpack_raw(a); + p.frac <<= float64_params.frac_shift; + p = parts_silence_nan(p, status); + p.frac >>= float64_params.frac_shift; + return float64_pack_raw(p); +} + /*---------------------------------------------------------------------------- | 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