From nobody Wed Feb 11 02:10:25 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517718346059623.7061180850603; Sat, 3 Feb 2018 20:25:46 -0800 (PST) Received: from localhost ([::1]:58332 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiBs6-0008Bd-Q2 for importer@patchew.org; Sat, 03 Feb 2018 23:25:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47454) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiBf2-0004tn-QN for qemu-devel@nongnu.org; Sat, 03 Feb 2018 23:12:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiBf1-00055h-9W for qemu-devel@nongnu.org; Sat, 03 Feb 2018 23:12:12 -0500 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:39324) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eiBf1-000553-25 for qemu-devel@nongnu.org; Sat, 03 Feb 2018 23:12:11 -0500 Received: by mail-pl0-x244.google.com with SMTP id o13so9359917pli.6 for ; Sat, 03 Feb 2018 20:12:11 -0800 (PST) Received: from cloudburst.twiddle.net (174-21-6-47.tukw.qwest.net. [174.21.6.47]) by smtp.gmail.com with ESMTPSA id k3sm1399425pgr.12.2018.02.03.20.12.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Feb 2018 20:12:09 -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; bh=hrzvhydRP8GcrH7J589GBvfvzE6ByNOtrc6l/vYJHbY=; b=KJWnv+17Cwh5MRsPlKHZbdFnZrjPd/RUPPyEwQ369kC10c0SGBST629xynQNMTow6m jwBTwh6qGPVzhm2PYf/mcr8GpU3xTK6uoSi1UfGYFcFIogtGjQHbuOdESQJj6E/LqZYI xXGdmJOISMOT3iPFR0qxYo1QIx1FFOQKa5nKE= 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=hrzvhydRP8GcrH7J589GBvfvzE6ByNOtrc6l/vYJHbY=; b=fLxVTjzxaZaK/ccq+EDaKfcqezmS/I1UeM9rz57pe5s66IUkHWJ+RXdz2MqswKxr9R 8gx3jed0r0a4uhSCFP+2BfCjCYcdwyyzVMo0+YPgB7Z6XO/pWA5vd5fiCxj1zs3jWknR g0Lmj7l5LycNPBbUMYGlAbW51QhAQEb3fTmvokHxjful1TejBAAySSlhoHWjAKwwFt7S EfXiR3wQPQBIQudGF2rYOgbuevy8v/EktW9EJQ0G/WQpEEhxQ1wNEZsJg6oJBH/coyAy oaNbCgykCzNBI7OSMM6L8lsm9KgIDsDcz/K163oCearSCiPfM3tng1MhJUuCYAsocTQC mtQQ== X-Gm-Message-State: AKwxytdBd93hCJs6fBFACzYRNfdZbpWLWY1gQqk3Mx/fEEKqVPDajE8m 2eTomQnGPqem7Px3Qf9fCUK6eUv5luk= X-Google-Smtp-Source: AH8x2252wadlB6wv/2FDjTsqUN1kIlgafw90FFnNDJTN1Fqf7dTtw5w9ixX6X4563uSp8J4LzP4NKw== X-Received: by 2002:a17:902:bf41:: with SMTP id u1-v6mr29909371pls.416.1517717529892; Sat, 03 Feb 2018 20:12:09 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Feb 2018 20:11:33 -0800 Message-Id: <20180204041136.17525-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180204041136.17525-1-richard.henderson@linaro.org> References: <20180204041136.17525-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::244 Subject: [Qemu-devel] [PATCH 21/24] fpu: Implement scalbn with soft-fp.h 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, cota@braap.org, alex.bennee@linaro.org, hsp.cat7@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add float16 support. Signed-off-by: Richard Henderson --- include/fpu/softfloat.h | 1 + fpu/floatxx.inc.c | 28 +++++++++++++ fpu/softfloat.c | 109 --------------------------------------------= ---- 3 files changed, 29 insertions(+), 109 deletions(-) diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index 0aae0454e2..b97022be1d 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -267,6 +267,7 @@ float16 float16_minnum(float16, float16, float_status *= status); float16 float16_maxnum(float16, float16, float_status *status); float16 float16_minnummag(float16, float16, float_status *status); float16 float16_maxnummag(float16, float16, float_status *status); +float16 float16_scalbn(float16, int, float_status *status); =20 int float16_is_quiet_nan(float16, float_status *status); int float16_is_signaling_nan(float16, float_status *status); diff --git a/fpu/floatxx.inc.c b/fpu/floatxx.inc.c index 7a7f53dd5d..8c009dd966 100644 --- a/fpu/floatxx.inc.c +++ b/fpu/floatxx.inc.c @@ -117,6 +117,34 @@ FLOATXX glue(FLOATXX,_sqrt)(FLOATXX a, float_status *s= tatus) return r; } =20 +FLOATXX glue(FLOATXX,_scalbn)(FLOATXX a, int n, float_status *status) +{ + FP_DECL_EX; + glue(FP_DECL_, FS)(A); + + FP_INIT_ROUNDMODE; + glue(FP_UNPACK_, FS)(A, a); + + if (likely(A_c =3D=3D FP_CLS_NORMAL)) { + /* Bound N such that the exponent can safely adjusted without + overflowing. The maximum is large enough to take the smallest + denormal up beyond the largest normal, which will overflow + to infinity when we repack. */ + int max =3D glue(_FP_EXPMAX_, FS) + glue(_FP_FRACBITS_, FS); + if (n > max) { + n =3D max; + } else if (n < -max) { + n =3D -max; + } + A_e +=3D n; + } + + glue(FP_PACK_, FS)(a, A); + FP_HANDLE_EXCEPTIONS; + + return a; +} + #define DO_FLOAT_TO_INT(NAME, SZ, FP_TO_INT_WHICH) \ int##SZ##_t NAME(FLOATXX a, float_status *status) \ { \ diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 83995cc60f..2550028d9f 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -4120,79 +4120,6 @@ int floatx80_unordered_quiet(floatx80 a, floatx80 b,= float_status *status) =3D=3D float_relation_unordered; } =20 -/* Multiply A by 2 raised to the power N. */ -float32 float32_scalbn(float32 a, int n, float_status *status) -{ - flag aSign; - int16_t aExp; - uint32_t aSig; - - a =3D float32_squash_input_denormal(a, status); - aSig =3D extractFloat32Frac( a ); - aExp =3D extractFloat32Exp( a ); - aSign =3D extractFloat32Sign( a ); - - if ( aExp =3D=3D 0xFF ) { - if ( aSig ) { - return propagateFloat32NaN(a, a, status); - } - return a; - } - if (aExp !=3D 0) { - aSig |=3D 0x00800000; - } else if (aSig =3D=3D 0) { - return a; - } else { - aExp++; - } - - if (n > 0x200) { - n =3D 0x200; - } else if (n < -0x200) { - n =3D -0x200; - } - - aExp +=3D n - 1; - aSig <<=3D 7; - return normalizeRoundAndPackFloat32(aSign, aExp, aSig, status); -} - -float64 float64_scalbn(float64 a, int n, float_status *status) -{ - flag aSign; - int16_t aExp; - uint64_t aSig; - - a =3D float64_squash_input_denormal(a, status); - aSig =3D extractFloat64Frac( a ); - aExp =3D extractFloat64Exp( a ); - aSign =3D extractFloat64Sign( a ); - - if ( aExp =3D=3D 0x7FF ) { - if ( aSig ) { - return propagateFloat64NaN(a, a, status); - } - return a; - } - if (aExp !=3D 0) { - aSig |=3D LIT64( 0x0010000000000000 ); - } else if (aSig =3D=3D 0) { - return a; - } else { - aExp++; - } - - if (n > 0x1000) { - n =3D 0x1000; - } else if (n < -0x1000) { - n =3D -0x1000; - } - - aExp +=3D n - 1; - aSig <<=3D 10; - return normalizeRoundAndPackFloat64(aSign, aExp, aSig, status); -} - floatx80 floatx80_scalbn(floatx80 a, int n, float_status *status) { flag aSign; @@ -4231,39 +4158,3 @@ floatx80 floatx80_scalbn(floatx80 a, int n, float_st= atus *status) return normalizeRoundAndPackFloatx80(status->floatx80_rounding_precisi= on, aSign, aExp, aSig, 0, status); } - -float128 float128_scalbn(float128 a, int n, float_status *status) -{ - flag aSign; - int32_t aExp; - uint64_t aSig0, aSig1; - - aSig1 =3D extractFloat128Frac1( a ); - aSig0 =3D extractFloat128Frac0( a ); - aExp =3D extractFloat128Exp( a ); - aSign =3D extractFloat128Sign( a ); - if ( aExp =3D=3D 0x7FFF ) { - if ( aSig0 | aSig1 ) { - return propagateFloat128NaN(a, a, status); - } - return a; - } - if (aExp !=3D 0) { - aSig0 |=3D LIT64( 0x0001000000000000 ); - } else if (aSig0 =3D=3D 0 && aSig1 =3D=3D 0) { - return a; - } else { - aExp++; - } - - if (n > 0x10000) { - n =3D 0x10000; - } else if (n < -0x10000) { - n =3D -0x10000; - } - - aExp +=3D n - 1; - return normalizeRoundAndPackFloat128( aSign, aExp, aSig0, aSig1 - , status); - -} --=20 2.14.3