From nobody Fri Dec 19 17:42:04 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1621959844; cv=none; d=zohomail.com; s=zohoarc; b=Nyy24WhGKny3y4w+OgNuJtT7DDYyv4+FX0eRSHgt8izUn4UZVwqrGgTFagxF4mcrsDOypHHkR1KgccfrfD+3z0SMAoih63ftZiHlnfTtXV07LnuZKz5dvT0QhNCLewyb8cY/ggPGz05f5sFhjMrDX5V2df2EwMPAmpwHzGvcwI0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621959844; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rGDd4IrgxvYUwN/P21Hl5FXEtH+AR/o/zuzvqPcST80=; b=TFZsSunQDhgkFj0St2QPYfM071JJacOqzxyvvq1xr1YHQu8Bj1mrpzgZIBk62gTMK3nPR+pVL29LM6+rIA6LDBmIDqjSTYPtmjGAACwt8YeWLZs0dpfnL0F5SV78/m00/PzJsKmJkhjI4DW9SZ8FZPfIw4spXEiFF5bl8WJST9Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1621959844469182.699908147541; Tue, 25 May 2021 09:24:04 -0700 (PDT) Received: from localhost ([::1]:47566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llZqd-0006pi-Dn for importer@patchew.org; Tue, 25 May 2021 12:24:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llYeO-0001Uw-4d for qemu-devel@nongnu.org; Tue, 25 May 2021 11:07:20 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]:52803) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1llYeE-0006d1-CZ for qemu-devel@nongnu.org; Tue, 25 May 2021 11:07:19 -0400 Received: by mail-pj1-x102c.google.com with SMTP id q6so17013435pjj.2 for ; Tue, 25 May 2021 08:07:09 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id z19sm2231943pjq.11.2021.05.25.08.07.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 May 2021 08:07:08 -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=rGDd4IrgxvYUwN/P21Hl5FXEtH+AR/o/zuzvqPcST80=; b=I8yzv1wq757NIPDwnMio/+AxYdSBxOvyRi1A8SdCyrBIRMzofpJIH4jJznULi6Vsbo JSCpuFSpOVbkXQRD9XKOTAdEJua12Em2CBdESEVs9eQZfa5Z6k7ddAwl1mcenODuApIm njL+AdBgLEI45MeW1HRKOGbX1XVAivEpf4WqUhTnHLVs23yCVt039Rf/2LLWJTGX3Gwc TRbqYLo7p1FexSRvzhHUEW+9DhrpiN9mFGp87dC6BEaY0ZtyWxeqfDRYonl75wz44srm Ea9JVgWOrTpIqQlEABpCKHFb649z1JsPZBvj2PgVSBd+DGd3eXvR3IlPnwLP02ON9/SJ 41eQ== 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=rGDd4IrgxvYUwN/P21Hl5FXEtH+AR/o/zuzvqPcST80=; b=iSbX3XBdVmfuG+jR5X1M5BhEfcLc+ZFKzZ+j/Z+LOAAFA7YbrNhrio+/ECJ8r3ZWf1 KWXQwmTdwzCotpnmm3c0XOKRf152xYYFUTNdTGkymLDhCndExvgBuRQZE7XjVaFjD0nt LvGzQbfVpgBG/2DDK8Lly4I1KjKg4CTl3i8hpaOhoiDV8ulfqm1rRO+FGLkkSbLedvYn giuIBmTXuIS+NLLluDFvY7GPy+UQJPyzF3VjvpMRNsk/0y7e960rIfNMZaHp1lyC3ZOR XTSfE0nXNoc4wtKsqNRlbTAX9h9R36pUCEnvIAXduV1ID85uM99XPOJlCaMsCd+rzEzb qCQw== X-Gm-Message-State: AOAM531Im/MJBazkfN9MVf53nEy0Lj6CvdNvH6I31gV8XdbCW9hUieDq 6zxDaUbmSELi2sQVVA0rYhSWB7vb1CUHvQ== X-Google-Smtp-Source: ABdhPJwZsJm8PfLKm3VQweFDVtoO1h3Cwr6pWMJ9/ghKaAr2kjR+aCviR0M/cwwqChDRqciONilXWA== X-Received: by 2002:a17:90a:9d88:: with SMTP id k8mr5235831pjp.64.1621955229060; Tue, 25 May 2021 08:07:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 02/28] softfloat: Move int_to_float to softfloat-parts.c.inc Date: Tue, 25 May 2021 08:06:40 -0700 Message-Id: <20210525150706.294968-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210525150706.294968-1-richard.henderson@linaro.org> References: <20210525150706.294968-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: alex.bennee@linaro.org, david@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Rename to parts$N_sint_to_float. Reimplement int{32,64}_to_float128 with FloatParts128. Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Reviewed-by: David Hildenbrand --- fpu/softfloat.c | 136 +++++++++++--------------------------- fpu/softfloat-parts.c.inc | 32 +++++++++ 2 files changed, 70 insertions(+), 98 deletions(-) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 3181678ea9..6404a2997f 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -849,6 +849,14 @@ static uint64_t parts128_float_to_uint(FloatParts128 *= p, FloatRoundMode rmode, #define parts_float_to_uint(P, R, Z, M, S) \ PARTS_GENERIC_64_128(float_to_uint, P)(P, R, Z, M, S) =20 +static void parts64_sint_to_float(FloatParts64 *p, int64_t a, + int scale, float_status *s); +static void parts128_sint_to_float(FloatParts128 *p, int64_t a, + int scale, float_status *s); + +#define parts_sint_to_float(P, I, Z, S) \ + PARTS_GENERIC_64_128(sint_to_float, P)(P, I, Z, S) + /* * Helper functions for softfloat-parts.c.inc, per-size operations. */ @@ -2940,42 +2948,15 @@ uint64_t bfloat16_to_uint64_round_to_zero(bfloat16 = a, float_status *s) } =20 /* - * Integer to float conversions - * - * Returns the result of converting the two's complement integer `a' - * to the floating-point format. The conversion is performed according - * to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. + * Signed integer to floating-point conversions */ =20 -static FloatParts64 int_to_float(int64_t a, int scale, float_status *statu= s) -{ - FloatParts64 r =3D { .sign =3D false }; - - if (a =3D=3D 0) { - r.cls =3D float_class_zero; - } else { - uint64_t f =3D a; - int shift; - - r.cls =3D float_class_normal; - if (a < 0) { - f =3D -f; - r.sign =3D true; - } - shift =3D clz64(f); - scale =3D MIN(MAX(scale, -0x10000), 0x10000); - - r.exp =3D DECOMPOSED_BINARY_POINT - shift + scale; - r.frac =3D f << shift; - } - - return r; -} - float16 int64_to_float16_scalbn(int64_t a, int scale, float_status *status) { - FloatParts64 pa =3D int_to_float(a, scale, status); - return float16_round_pack_canonical(&pa, status); + FloatParts64 p; + + parts_sint_to_float(&p, a, scale, status); + return float16_round_pack_canonical(&p, status); } =20 float16 int32_to_float16_scalbn(int32_t a, int scale, float_status *status) @@ -3010,8 +2991,10 @@ float16 int8_to_float16(int8_t a, float_status *stat= us) =20 float32 int64_to_float32_scalbn(int64_t a, int scale, float_status *status) { - FloatParts64 pa =3D int_to_float(a, scale, status); - return float32_round_pack_canonical(&pa, status); + FloatParts64 p; + + parts64_sint_to_float(&p, a, scale, status); + return float32_round_pack_canonical(&p, status); } =20 float32 int32_to_float32_scalbn(int32_t a, int scale, float_status *status) @@ -3041,8 +3024,10 @@ float32 int16_to_float32(int16_t a, float_status *st= atus) =20 float64 int64_to_float64_scalbn(int64_t a, int scale, float_status *status) { - FloatParts64 pa =3D int_to_float(a, scale, status); - return float64_round_pack_canonical(&pa, status); + FloatParts64 p; + + parts_sint_to_float(&p, a, scale, status); + return float64_round_pack_canonical(&p, status); } =20 float64 int32_to_float64_scalbn(int32_t a, int scale, float_status *status) @@ -3070,15 +3055,12 @@ float64 int16_to_float64(int16_t a, float_status *s= tatus) return int64_to_float64_scalbn(a, 0, status); } =20 -/* - * Returns the result of converting the two's complement integer `a' - * to the bfloat16 format. - */ - bfloat16 int64_to_bfloat16_scalbn(int64_t a, int scale, float_status *stat= us) { - FloatParts64 pa =3D int_to_float(a, scale, status); - return bfloat16_round_pack_canonical(&pa, status); + FloatParts64 p; + + parts_sint_to_float(&p, a, scale, status); + return bfloat16_round_pack_canonical(&p, status); } =20 bfloat16 int32_to_bfloat16_scalbn(int32_t a, int scale, float_status *stat= us) @@ -3106,6 +3088,19 @@ bfloat16 int16_to_bfloat16(int16_t a, float_status *= status) return int64_to_bfloat16_scalbn(a, 0, status); } =20 +float128 int64_to_float128(int64_t a, float_status *status) +{ + FloatParts128 p; + + parts_sint_to_float(&p, a, 0, status); + return float128_round_pack_canonical(&p, status); +} + +float128 int32_to_float128(int32_t a, float_status *status) +{ + return int64_to_float128(a, status); +} + /* * Unsigned Integer to float conversions * @@ -4956,28 +4951,6 @@ floatx80 int32_to_floatx80(int32_t a, float_status *= status) =20 } =20 -/*------------------------------------------------------------------------= ---- -| Returns the result of converting the 32-bit two's complement integer `a'= to -| the quadruple-precision floating-point format. The conversion is perfor= med -| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. -*-------------------------------------------------------------------------= ---*/ - -float128 int32_to_float128(int32_t a, float_status *status) -{ - bool zSign; - uint32_t absA; - int8_t shiftCount; - uint64_t zSig0; - - if ( a =3D=3D 0 ) return packFloat128( 0, 0, 0, 0 ); - zSign =3D ( a < 0 ); - absA =3D zSign ? - a : a; - shiftCount =3D clz32(absA) + 17; - zSig0 =3D absA; - return packFloat128( zSign, 0x402E - shiftCount, zSig0<cls =3D float_class_zero; + return; + } + + p->cls =3D float_class_normal; + if (a < 0) { + f =3D -f; + p->sign =3D true; + } + shift =3D clz64(f); + scale =3D MIN(MAX(scale, -0x10000), 0x10000); + + p->exp =3D DECOMPOSED_BINARY_POINT - shift + scale; + p->frac_hi =3D f << shift; +} --=20 2.25.1