From nobody Mon Jul 27 08:57:42 2026 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=1777211276; cv=none; d=zohomail.com; s=zohoarc; b=MCGkzFkeLhhzRF/q7WjkXrjr1BPqcTxkabmGOLJR5CAychuBOUyEAo1ntYnOGIKZfOtE/2Bf2GXWHBQlN5DI3JZ9trPHHbsi6IrNuHKWy3OqEnrdKqfq1HUclaFCcFqZ6A85E1DsdiIJSV7K8pPK/V5k4N40SBQQEEegXcIBaoI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1777211276; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cWAjKNoEGxxdB5kcvtEjcSc2slMDjvCN3yEwCpVz4fA=; b=DmdkLsU443NWsgoNXRx0sIpcbvbhl0KxpEOrF9sfb4mY/nNyshmgc2pgj5MVqre/Ctyprg+WBtb6nZO2H/LqIgJCGMcf7g7BKc2m0Ir6TXZHrPhhY6nxAw7tCicbW4pFwbsYn8+sjukpLDAPsK4kW3XZCWzxAQaj9KCHa+vrNsI= 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) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1777211276757584.3362682471277; Sun, 26 Apr 2026 06:47:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wGzk8-0000I2-L5; Sun, 26 Apr 2026 09:41:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wGzjp-0008O2-Du for qemu-devel@nongnu.org; Sun, 26 Apr 2026 09:41:34 -0400 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wGzjk-0000Et-P7 for qemu-devel@nongnu.org; Sun, 26 Apr 2026 09:41:33 -0400 Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-c7da372b87eso539663a12.0 for ; Sun, 26 Apr 2026 06:41:28 -0700 (PDT) Received: from stoup.. ([180.233.125.15]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b5fab30f29sm277940375ad.68.2026.04.26.06.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Apr 2026 06:41:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1777210887; x=1777815687; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cWAjKNoEGxxdB5kcvtEjcSc2slMDjvCN3yEwCpVz4fA=; b=r6RhvPFk2s2fvSaRGfxNSyI2Yz0ExiSQkmTvyTtWSB+hE3lqQ2iQcSDx9VXBYIZhOx hoivP1+4XY88bI19RT3cavpO5oYllzwgV9j3LFOqt+coxqh6FsgE/zfFskEjL19CzphB JwyqOglkIjNiw6Y42KxNDQQH9hV2yjpUodfWk7dsI2os5ulTzIVqmdFAf1ZtfWFDeQpK NMVM/VNqzxXLsl9o9lwNFhtHf9Ab0/ooLkRw9qWP2wCpUQvzE+YAXwJIdJ7ZG1aP2GEL LYoHnAYH2qV5XfsgI+KLL+Q3i0JpAWLx0+BBvRprg2ewp2+2yvhbk3KiGb4UQTSslX8o ZlrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777210887; x=1777815687; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=cWAjKNoEGxxdB5kcvtEjcSc2slMDjvCN3yEwCpVz4fA=; b=PTfLxSXWivV3KigboxXLwl3/BF1Ec3Z5m9KkymxzFnKYUzptPO+9N9tYlOx0fYlqVD LG+6IAcuNhHFstvOLrxObmTjFZu9syazWvXbAV7OxCUiJbd+jDfOwour/tdRmqPyxi1Z S3QHYv4F1fli/StN/4jUh8eYR6jxUR2araLQPyD+QSCukMGsfcmZyyGRhcLVp4AYBIYE CCfqmKpPV3AuAxSbD4mYUhM06A/OJkwsJW7iSFDd1SB3fAka//kej98omPfJBkhXBj4n lwC+okF+yu9jfFLkhPgJdzz5OoFQ1Wfzh6Y/F06iBjPD+10klJc7Qop0W3+RXEM6qTXB 40yA== X-Gm-Message-State: AOJu0YyapeBPNUPY0O03ngbHY/LKKdpWNEYewEvM6LeYaCOeN+RIxOjZ SwRQn9zyaduOLzRkiGsf1wfl1E649fw+pN+yiYeqVD3TMQ7EqjhV2Rqyu2j+ip7RMt1EUf8F//l 6kTd12gw= X-Gm-Gg: AeBDietSEJM1dDDl+5x19BRGZmGOOQLg8KjLjnGWjV1hhX42MtGbS750zi2G9VRUgZY V2gRNT/T3karpY5B4qzt+eW5gBCOXQMjW8IhWXd1hgViqppw1+V/eTLVLsgUIujtelf7V+Kpd1e vjpFeQO9giIYJJR06hEBD89QYBF2qAIKJMtt+QjWlLU3sJs80FWi1a2cTO4dMiC5G0u/ZOK6Q/V 7tUnHo7k/TIV4IoMFZXihfETISqoGN1QT3ILT+UHZokI1oCEh4toeG5GCjOm5rBkHMz2LOMuLkf h3cVSwlz/oXkW/rxV34cgkKvX/ZXSM5MVikEv7ceh//4bVHDTQRbuLVEerXDdgBBK1szMcd6XSl HNhUsibQiGCKUKHJj7Biz2WOCtW8Vbkh/UA/Mk+/Wqxp10beTwXXLp1MaflR6eTmt7XaUSwWFC1 XEgIONLDuL+zRIR2gSAtORTjbr+OSXfxPGlCxO7bmA X-Received: by 2002:a17:902:ef02:b0:2b2:420a:b48a with SMTP id d9443c01a7336-2b5f9fc2eb0mr400825055ad.32.1777210887172; Sun, 26 Apr 2026 06:41:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH 30/84] fpu: Drop FRAC_GENERIC_64_128{_256} Date: Sun, 26 Apr 2026 23:39:07 +1000 Message-ID: <20260426134002.865628-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260426134002.865628-1-richard.henderson@linaro.org> References: <20260426134002.865628-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=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::529; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x529.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1777211278690154100 Content-Type: text/plain; charset="utf-8" This requires more complexity to handle const selectors, and an indirection macro for each function. Easier to just use the preprocessor. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- fpu/softfloat.c | 69 +++++---------------- fpu/softfloat-parts-addsub.c.inc | 22 +++---- fpu/softfloat-parts.c.inc | 102 +++++++++++++++---------------- 3 files changed, 77 insertions(+), 116 deletions(-) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index d077e8da69..e462fb7d74 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -774,15 +774,6 @@ static float128 QEMU_FLATTEN float128_pack_raw(const F= loatParts128 *p) * Helper functions for softfloat-parts.c.inc, per-size operations. */ =20 -#define FRAC_GENERIC_64_128(NAME, P) \ - _Generic((P), FloatParts64 *: frac64_##NAME, \ - FloatParts128 *: frac128_##NAME) - -#define FRAC_GENERIC_64_128_256(NAME, P) \ - _Generic((P), FloatParts64 *: frac64_##NAME, \ - FloatParts128 *: frac128_##NAME, \ - FloatParts256 *: frac256_##NAME) - static bool frac64_add(FloatParts64 *r, FloatParts64 *a, FloatParts64 *b) { return uadd64_overflow(a->frac, b->frac, &r->frac); @@ -806,8 +797,6 @@ static bool frac256_add(FloatParts256 *r, FloatParts256= *a, FloatParts256 *b) return c; } =20 -#define frac_add(R, A, B) FRAC_GENERIC_64_128_256(add, R)(R, A, B) - static bool frac64_addi(FloatParts64 *r, FloatParts64 *a, uint64_t c) { return uadd64_overflow(a->frac, c, &r->frac); @@ -819,8 +808,6 @@ static bool frac128_addi(FloatParts128 *r, FloatParts12= 8 *a, uint64_t c) return uadd64_overflow(a->frac_hi, c, &r->frac_hi); } =20 -#define frac_addi(R, A, C) FRAC_GENERIC_64_128(addi, R)(R, A, C) - static void frac64_allones(FloatParts64 *a) { a->frac =3D -1; @@ -831,8 +818,6 @@ static void frac128_allones(FloatParts128 *a) a->frac_hi =3D a->frac_lo =3D -1; } =20 -#define frac_allones(A) FRAC_GENERIC_64_128(allones, A)(A) - static FloatRelation frac64_cmp(FloatParts64 *a, FloatParts64 *b) { return (a->frac =3D=3D b->frac ? float_relation_equal @@ -852,8 +837,6 @@ static FloatRelation frac128_cmp(FloatParts128 *a, Floa= tParts128 *b) return ta < tb ? float_relation_less : float_relation_greater; } =20 -#define frac_cmp(A, B) FRAC_GENERIC_64_128(cmp, A)(A, B) - static void frac64_clear(FloatParts64 *a) { a->frac =3D 0; @@ -864,8 +847,6 @@ static void frac128_clear(FloatParts128 *a) a->frac_hi =3D a->frac_lo =3D 0; } =20 -#define frac_clear(A) FRAC_GENERIC_64_128(clear, A)(A) - static bool frac64_div(FloatParts64 *a, FloatParts64 *b) { uint64_t n1, n0, r, q; @@ -945,8 +926,6 @@ static bool frac128_div(FloatParts128 *a, FloatParts128= *b) return ret; } =20 -#define frac_div(A, B) FRAC_GENERIC_64_128(div, A)(A, B) - static bool frac64_eqz(FloatParts64 *a) { return a->frac =3D=3D 0; @@ -957,8 +936,6 @@ static bool frac128_eqz(FloatParts128 *a) return (a->frac_hi | a->frac_lo) =3D=3D 0; } =20 -#define frac_eqz(A) FRAC_GENERIC_64_128(eqz, A)(A) - static void frac64_mulw(FloatParts128 *r, FloatParts64 *a, FloatParts64 *b) { mulu64(&r->frac_lo, &r->frac_hi, a->frac, b->frac); @@ -970,8 +947,6 @@ static void frac128_mulw(FloatParts256 *r, FloatParts12= 8 *a, FloatParts128 *b) &r->frac_hi, &r->frac_hm, &r->frac_lm, &r->frac_lo); } =20 -#define frac_mulw(R, A, B) FRAC_GENERIC_64_128(mulw, A)(R, A, B) - static void frac64_neg(FloatParts64 *a) { a->frac =3D -a->frac; @@ -993,8 +968,6 @@ static void frac256_neg(FloatParts256 *a) a->frac_hi =3D usub64_borrow(0, a->frac_hi, &c); } =20 -#define frac_neg(A) FRAC_GENERIC_64_128_256(neg, A)(A) - static int frac64_normalize(FloatParts64 *a) { if (a->frac) { @@ -1068,8 +1041,6 @@ static int frac256_normalize(FloatParts256 *a) return ret; } =20 -#define frac_normalize(A) FRAC_GENERIC_64_128_256(normalize, A)(A) - static void frac64_modrem(FloatParts64 *a, FloatParts64 *b, uint64_t *mod_= quot) { uint64_t a0, a1, b0, t0, t1, q, quot; @@ -1248,8 +1219,6 @@ static void frac128_modrem(FloatParts128 *a, FloatPar= ts128 *b, a->frac_lo =3D a1 | (a2 !=3D 0); } =20 -#define frac_modrem(A, B, Q) FRAC_GENERIC_64_128(modrem, A)(A, B, Q) - static void frac64_shl(FloatParts64 *a, int c) { a->frac <<=3D c; @@ -1273,8 +1242,6 @@ static void frac128_shl(FloatParts128 *a, int c) a->frac_lo =3D a1; } =20 -#define frac_shl(A, C) FRAC_GENERIC_64_128(shl, A)(A, C) - static void frac64_shr(FloatParts64 *a, int c) { a->frac >>=3D c; @@ -1298,8 +1265,6 @@ static void frac128_shr(FloatParts128 *a, int c) a->frac_lo =3D a1; } =20 -#define frac_shr(A, C) FRAC_GENERIC_64_128(shr, A)(A, C) - static void frac64_shrjam(FloatParts64 *a, int c) { uint64_t a0 =3D a->frac; @@ -1388,8 +1353,6 @@ static void frac256_shrjam(FloatParts256 *a, int c) a->frac_hi =3D a0; } =20 -#define frac_shrjam(A, C) FRAC_GENERIC_64_128_256(shrjam, A)(A, C) - static bool frac64_sub(FloatParts64 *r, FloatParts64 *a, FloatParts64 *b) { return usub64_overflow(a->frac, b->frac, &r->frac); @@ -1413,8 +1376,6 @@ static bool frac256_sub(FloatParts256 *r, FloatParts2= 56 *a, FloatParts256 *b) return c; } =20 -#define frac_sub(R, A, B) FRAC_GENERIC_64_128_256(sub, R)(R, A, B) - static void frac64_truncjam(FloatParts64 *r, FloatParts128 *a) { r->frac =3D a->frac_hi | (a->frac_lo !=3D 0); @@ -1426,8 +1387,6 @@ static void frac128_truncjam(FloatParts128 *r, FloatP= arts256 *a) r->frac_lo =3D a->frac_hm | ((a->frac_lm | a->frac_lo) !=3D 0); } =20 -#define frac_truncjam(R, A) FRAC_GENERIC_64_128(truncjam, R)(R, A) - static void frac64_widen(FloatParts128 *r, FloatParts64 *a) { r->frac_hi =3D a->frac; @@ -1442,8 +1401,6 @@ static void frac128_widen(FloatParts256 *r, FloatPart= s128 *a) r->frac_lo =3D 0; } =20 -#define frac_widen(A, B) FRAC_GENERIC_64_128(widen, B)(A, B) - /* * Reciprocal sqrt table. 1 bit of exponent, 6-bits of mantessa. * From https://git.musl-libc.org/cgit/musl/tree/src/math/sqrt_data.c @@ -1468,6 +1425,8 @@ static const uint16_t rsqrt_tab[128] =3D { 0xba91, 0xb9cc, 0xb90a, 0xb84a, 0xb78c, 0xb6d0, 0xb617, 0xb560, }; =20 +#define fracN(NAME) glue(glue(glue(frac,N),_),NAME) +#define fracW(NAME) glue(glue(glue(frac,W),_),NAME) #define partsN(NAME) glue(glue(glue(parts,N),_),NAME) #define partsW(NAME) glue(glue(glue(parts,W),_),NAME) #define FloatPartsN glue(FloatParts,N) @@ -1494,6 +1453,8 @@ static const uint16_t rsqrt_tab[128] =3D { =20 #undef N #undef W +#undef fracN +#undef fracW #undef partsN #undef partsW #undef FloatPartsN @@ -1624,19 +1585,19 @@ static float64 float64r32_pack_raw(FloatParts64 *p) * The result is denormal for float32, but can be represented * in normalized form for float64. Adjust, per canonicalize. */ - int shift =3D frac_normalize(p); + int shift =3D frac64_normalize(p); p->exp =3D (float32_params.frac_shift - float32_params.exp_bias - shift + 1 + float64_params.exp_bias); - frac_shr(p, float64_params.frac_shift); + frac64_shr(p, float64_params.frac_shift); } else { - frac_shl(p, float32_params.frac_shift - float64_params.frac_sh= ift); + frac64_shl(p, float32_params.frac_shift - float64_params.frac_= shift); p->exp +=3D float64_params.exp_bias - float32_params.exp_bias; } break; case float_class_snan: case float_class_qnan: - frac_shl(p, float32_params.frac_shift - float64_params.frac_shift); + frac64_shl(p, float32_params.frac_shift - float64_params.frac_shif= t); p->exp =3D float64_params.exp_max; break; case float_class_inf: @@ -1724,7 +1685,7 @@ static floatx80 floatx80_round_pack_canonical(FloatPa= rts128 *p, =20 p64.sign =3D p->sign; p64.exp =3D p->exp; - frac_truncjam(&p64, p); + frac64_truncjam(&p64, p); parts64_uncanon_normal(&p64, s, fmt, false); frac =3D p64.frac; exp =3D p64.exp; @@ -2698,7 +2659,7 @@ static void parts_float_to_float_narrow(FloatParts64 = *a, FloatParts128 *b, float_raise(float_flag_input_denormal_used, s); /* fall through */ case float_class_normal: - frac_truncjam(a, b); + frac64_truncjam(a, b); break; case float_class_snan: case float_class_qnan: @@ -2717,7 +2678,7 @@ static void parts_float_to_float_widen(FloatParts128 = *a, FloatParts64 *b, a->cls =3D b->cls; a->sign =3D b->sign; a->exp =3D b->exp; - frac_widen(a, b); + frac64_widen(a, b); =20 if (is_nan(a->cls)) { parts128_return_nan(a, s); @@ -4939,7 +4900,7 @@ static void parts64_log2(FloatParts64 *a, float_statu= s *s, const FloatFmt *fmt) FloatParts64 f =3D { .cls =3D float_class_normal, .frac =3D r }; - f.exp =3D f_exp - frac_normalize(&f); + f.exp =3D f_exp - frac64_normalize(&f); =20 if (a_exp < 0) { parts64_sub_normal(a, &f); @@ -5010,7 +4971,7 @@ float128 float128_default_nan(float_status *status) FloatParts128 p; =20 parts128_default_nan(&p, status); - frac_shr(&p, float128_params.frac_shift); + frac128_shr(&p, float128_params.frac_shift); return float128_pack_raw(&p); } =20 @@ -5076,9 +5037,9 @@ float128 float128_silence_nan(float128 a, float_statu= s *status) FloatParts128 p; =20 float128_unpack_raw(&p, a); - frac_shl(&p, float128_params.frac_shift); + frac128_shl(&p, float128_params.frac_shift); parts128_silence_nan(&p, status); - frac_shr(&p, float128_params.frac_shift); + frac128_shr(&p, float128_params.frac_shift); return float128_pack_raw(&p); } =20 diff --git a/fpu/softfloat-parts-addsub.c.inc b/fpu/softfloat-parts-addsub.= c.inc index ae5c1017c5..accf996d7c 100644 --- a/fpu/softfloat-parts-addsub.c.inc +++ b/fpu/softfloat-parts-addsub.c.inc @@ -20,14 +20,14 @@ static void partsN(add_normal)(FloatPartsN *a, FloatPar= tsN *b) int exp_diff =3D a->exp - b->exp; =20 if (exp_diff > 0) { - frac_shrjam(b, exp_diff); + fracN(shrjam)(b, exp_diff); } else if (exp_diff < 0) { - frac_shrjam(a, -exp_diff); + fracN(shrjam)(a, -exp_diff); a->exp =3D b->exp; } =20 - if (frac_add(a, a, b)) { - frac_shrjam(a, 1); + if (fracN(add)(a, a, b)) { + fracN(shrjam)(a, 1); a->frac_hi |=3D DECOMPOSED_IMPLICIT_BIT; a->exp +=3D 1; } @@ -39,20 +39,20 @@ static bool partsN(sub_normal)(FloatPartsN *a, FloatPar= tsN *b) int shift; =20 if (exp_diff > 0) { - frac_shrjam(b, exp_diff); - frac_sub(a, a, b); + fracN(shrjam)(b, exp_diff); + fracN(sub)(a, a, b); } else if (exp_diff < 0) { a->exp =3D b->exp; a->sign ^=3D 1; - frac_shrjam(a, -exp_diff); - frac_sub(a, b, a); - } else if (frac_sub(a, a, b)) { + fracN(shrjam)(a, -exp_diff); + fracN(sub)(a, b, a); + } else if (fracN(sub)(a, a, b)) { /* Overflow means that A was less than B. */ - frac_neg(a); + fracN(neg)(a); a->sign ^=3D 1; } =20 - shift =3D frac_normalize(a); + shift =3D fracN(normalize)(a); if (likely(shift < N)) { a->exp -=3D shift; return true; diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc index 5f27efd288..5d344f9afe 100644 --- a/fpu/softfloat-parts.c.inc +++ b/fpu/softfloat-parts.c.inc @@ -98,7 +98,7 @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, Floa= tPartsN *b, ret =3D b; break; } - cmp =3D frac_cmp(a, b); + cmp =3D fracN(cmp)(a, b); if (cmp =3D=3D 0) { cmp =3D a->sign < b->sign; } @@ -215,14 +215,14 @@ static void partsN(canonicalize)(FloatPartsN *p, floa= t_status *status, (status->floatx80_behaviour & floatx80_pseudo_denormal_valid); =20 if (unlikely(p->exp =3D=3D 0)) { - if (likely(frac_eqz(p))) { + if (likely(fracN(eqz)(p))) { p->cls =3D float_class_zero; } else if (status->flush_inputs_to_zero) { float_raise(float_flag_input_denormal_flushed, status); p->cls =3D float_class_zero; - frac_clear(p); + fracN(clear)(p); } else { - int shift =3D frac_normalize(p); + int shift =3D fracN(normalize)(p); p->cls =3D float_class_denormal; p->exp =3D fmt->frac_shift - fmt->exp_bias - shift + !has_pseudo_denormals; @@ -232,10 +232,10 @@ static void partsN(canonicalize)(FloatPartsN *p, floa= t_status *status, if (unlikely(p->exp =3D=3D fmt->exp_max)) { switch (fmt->exp_max_kind) { case float_expmax_ieee: - if (likely(frac_eqz(p))) { + if (likely(fracN(eqz)(p))) { p->cls =3D float_class_inf; } else { - frac_shl(p, fmt->frac_shift); + fracN(shl)(p, fmt->frac_shift); p->cls =3D (parts_is_snan_frac(p->frac_hi, status) ? float_class_snan : float_class_qnan); } @@ -244,7 +244,7 @@ static void partsN(canonicalize)(FloatPartsN *p, float_= status *status, break; case float_expmax_e4m3: if (p->frac_hi =3D=3D 0b111) { - frac_shl(p, fmt->frac_shift); + fracN(shl)(p, fmt->frac_shift); p->cls =3D (parts_is_snan_frac(p->frac_hi, status) ? float_class_snan : float_class_qnan); return; @@ -258,7 +258,7 @@ static void partsN(canonicalize)(FloatPartsN *p, float_= status *status, =20 p->cls =3D float_class_normal; p->exp -=3D fmt->exp_bias; - frac_shl(p, fmt->frac_shift); + fracN(shl)(p, fmt->frac_shift); p->frac_hi |=3D DECOMPOSED_IMPLICIT_BIT; } =20 @@ -344,8 +344,8 @@ static void partsN(uncanon_normal)(FloatPartsN *p, floa= t_status *s, if (likely(exp > 0)) { if (p->frac_lo & round_mask) { flags |=3D float_flag_inexact; - if (frac_addi(p, p, inc)) { - frac_shr(p, 1); + if (fracN(addi)(p, p, inc)) { + fracN(shr)(p, 1); p->frac_hi |=3D DECOMPOSED_IMPLICIT_BIT; exp++; } @@ -361,13 +361,13 @@ static void partsN(uncanon_normal)(FloatPartsN *p, fl= oat_status *s, } else if (overflow_norm) { flags |=3D float_flag_inexact; exp =3D exp_max - 1; - frac_allones(p); + fracN(allones)(p); p->frac_lo &=3D ~round_mask; } else { flags |=3D float_flag_inexact; p->cls =3D float_class_inf; exp =3D exp_max; - frac_clear(p); + fracN(clear)(p); } break; =20 @@ -378,7 +378,7 @@ static void partsN(uncanon_normal)(FloatPartsN *p, floa= t_status *s, ? float_flag_invalid : float_flag_overflow | float_flag_inexact); exp =3D exp_max; - frac_allones(p); + fracN(allones)(p); p->frac_lo &=3D ~round_mask; } break; @@ -395,26 +395,26 @@ static void partsN(uncanon_normal)(FloatPartsN *p, fl= oat_status *s, g_assert_not_reached(); } } - frac_shr(p, frac_shift); + fracN(shr)(p, frac_shift); } else if (unlikely(s->rebias_underflow)) { flags |=3D float_flag_underflow; exp +=3D fmt->exp_re_bias; if (p->frac_lo & round_mask) { flags |=3D float_flag_inexact; - if (frac_addi(p, p, inc)) { - frac_shr(p, 1); + if (fracN(addi)(p, p, inc)) { + fracN(shr)(p, 1); p->frac_hi |=3D DECOMPOSED_IMPLICIT_BIT; exp++; } p->frac_lo &=3D ~round_mask; } - frac_shr(p, frac_shift); + fracN(shr)(p, frac_shift); } else if (s->flush_to_zero && s->ftz_detection =3D=3D float_ftz_before_rounding) { flags |=3D float_flag_output_denormal_flushed; p->cls =3D float_class_zero; exp =3D 0; - frac_clear(p); + fracN(clear)(p); } else { bool is_tiny =3D s->tininess_before_rounding || exp < 0; bool has_pseudo_denormals =3D fmt->has_explicit_bit && @@ -422,10 +422,10 @@ static void partsN(uncanon_normal)(FloatPartsN *p, fl= oat_status *s, =20 if (!is_tiny) { FloatPartsN discard; - is_tiny =3D !frac_addi(&discard, p, inc); + is_tiny =3D !fracN(addi)(&discard, p, inc); } =20 - frac_shrjam(p, !has_pseudo_denormals - exp); + fracN(shrjam)(p, !has_pseudo_denormals - exp); =20 if (p->frac_lo & round_mask) { /* Need to recompute round-to-even/round-to-odd. */ @@ -452,12 +452,12 @@ static void partsN(uncanon_normal)(FloatPartsN *p, fl= oat_status *s, break; } flags |=3D float_flag_inexact; - frac_addi(p, p, inc); + fracN(addi)(p, p, inc); p->frac_lo &=3D ~round_mask; } =20 exp =3D (p->frac_hi & DECOMPOSED_IMPLICIT_BIT) && !has_pseudo_deno= rmals; - frac_shr(p, frac_shift); + fracN(shr)(p, frac_shift); =20 if (is_tiny) { if (s->flush_to_zero) { @@ -465,11 +465,11 @@ static void partsN(uncanon_normal)(FloatPartsN *p, fl= oat_status *s, flags |=3D float_flag_output_denormal_flushed; p->cls =3D float_class_zero; exp =3D 0; - frac_clear(p); + fracN(clear)(p); } else if (flags & float_flag_inexact) { flags |=3D float_flag_underflow; } - if (exp =3D=3D 0 && frac_eqz(p)) { + if (exp =3D=3D 0 && fracN(eqz)(p)) { p->cls =3D float_class_zero; } } @@ -487,17 +487,17 @@ static void partsN(uncanon)(FloatPartsN *p, float_sta= tus *s, switch (p->cls) { case float_class_zero: p->exp =3D 0; - frac_clear(p); + fracN(clear)(p); return; case float_class_inf: switch (fmt->exp_max_kind) { case float_expmax_ieee: p->exp =3D fmt->exp_max; - frac_clear(p); + fracN(clear)(p); break; case float_expmax_e4m3: partsN(uncanon_e4m3_overflow)(p, s, fmt, saturate); - frac_shr(p, fmt->frac_shift); + fracN(shr)(p, fmt->frac_shift); break; case float_expmax_normal: default: @@ -508,7 +508,7 @@ static void partsN(uncanon)(FloatPartsN *p, float_statu= s *s, case float_class_snan: assert(fmt->exp_max_kind !=3D float_expmax_normal); p->exp =3D fmt->exp_max; - frac_shr(p, fmt->frac_shift); + fracN(shr)(p, fmt->frac_shift); return; default: break; @@ -625,12 +625,12 @@ static FloatPartsN *partsN(mul)(FloatPartsN *a, Float= PartsN *b, float_raise(float_flag_input_denormal_used, s); } =20 - frac_mulw(&tmp, a, b); - frac_truncjam(a, &tmp); + fracN(mulw)(&tmp, a, b); + fracN(truncjam)(a, &tmp); =20 a->exp +=3D b->exp + 1; if (!(a->frac_hi & DECOMPOSED_IMPLICIT_BIT)) { - frac_add(a, a, a); + fracN(add)(a, a, a); a->exp -=3D 1; } =20 @@ -747,16 +747,16 @@ static FloatPartsN *partsN(muladd_scalbn)(FloatPartsN= *a, FloatPartsN *b, /* Perform the multiplication step. */ p_widen.sign =3D a->sign; p_widen.exp =3D a->exp + b->exp + 1; - frac_mulw(&p_widen, a, b); + fracN(mulw)(&p_widen, a, b); if (!(p_widen.frac_hi & DECOMPOSED_IMPLICIT_BIT)) { - frac_add(&p_widen, &p_widen, &p_widen); + fracW(add)(&p_widen, &p_widen, &p_widen); p_widen.exp -=3D 1; } =20 /* Perform the addition step. */ if (c->cls !=3D float_class_zero) { /* Zero-extend C to less significant bits. */ - frac_widen(&c_widen, c); + fracN(widen)(&c_widen, c); c_widen.exp =3D c->exp; =20 if (a->sign =3D=3D c->sign) { @@ -767,7 +767,7 @@ static FloatPartsN *partsN(muladd_scalbn)(FloatPartsN *= a, FloatPartsN *b, } =20 /* Narrow with sticky bit, for proper rounding later. */ - frac_truncjam(a, &p_widen); + fracN(truncjam)(a, &p_widen); a->sign =3D p_widen.sign; a->exp =3D p_widen.exp; =20 @@ -816,7 +816,7 @@ static FloatPartsN *partsN(div)(FloatPartsN *a, FloatPa= rtsN *b, float_raise(float_flag_input_denormal_used, s); } a->sign =3D sign; - a->exp -=3D b->exp + frac_div(a, b); + a->exp -=3D b->exp + fracN(div)(a, b); return a; } =20 @@ -880,7 +880,7 @@ static FloatPartsN *partsN(modrem)(FloatPartsN *a, Floa= tPartsN *b, if (ab_mask & float_cmask_denormal) { float_raise(float_flag_input_denormal_used, s); } - frac_modrem(a, b, mod_quot); + fracN(modrem)(a, b, mod_quot); return a; } =20 @@ -969,7 +969,7 @@ static void partsN(sqrt)(FloatPartsN *a, float_status *= status, exp_odd =3D a->exp & 1; index =3D extract64(a->frac_hi, 57, 6) | (!exp_odd << 6); if (!exp_odd) { - frac_shr(a, 1); + fracN(shr)(a, 1); } =20 /* @@ -1110,7 +1110,7 @@ static void partsN(sqrt)(FloatPartsN *a, float_status= *status, /* Convert back from base 4 to base 2. */ a->exp >>=3D 1; if (!(a->frac_hi & DECOMPOSED_IMPLICIT_BIT)) { - frac_add(a, a, a); + fracN(add)(a, a, a); } else { a->exp +=3D 1; } @@ -1150,9 +1150,9 @@ static bool partsN(round_to_int_normal)(FloatPartsN *= a, FloatRoundMode rmode, if (a->exp =3D=3D -1) { FloatPartsN tmp; /* Shift left one, discarding DECOMPOSED_IMPLICIT_BIT */ - frac_add(&tmp, a, a); + fracN(add)(&tmp, a, a); /* Anything remaining means frac > 0.5. */ - one =3D !frac_eqz(&tmp); + one =3D !fracN(eqz)(&tmp); } break; case float_round_ties_away: @@ -1174,7 +1174,7 @@ static bool partsN(round_to_int_normal)(FloatPartsN *= a, FloatRoundMode rmode, g_assert_not_reached(); } =20 - frac_clear(a); + fracN(clear)(a); a->exp =3D 0; if (one) { a->frac_hi =3D DECOMPOSED_IMPLICIT_BIT; @@ -1190,7 +1190,7 @@ static bool partsN(round_to_int_normal)(FloatPartsN *= a, FloatRoundMode rmode, * which leaves room for sticky and rounding bit. */ shift_adj =3D (N - 1) - (a->exp + 2); - frac_shrjam(a, shift_adj); + fracN(shrjam)(a, shift_adj); frac_lsb =3D 1 << 2; } else { /* @@ -1208,7 +1208,7 @@ static bool partsN(round_to_int_normal)(FloatPartsN *= a, FloatRoundMode rmode, =20 if (!(a->frac_lo & rnd_mask)) { /* Fractional bits already clear, undo the shift above. */ - frac_shl(a, shift_adj); + fracN(shl)(a, shift_adj); return false; } =20 @@ -1236,21 +1236,21 @@ static bool partsN(round_to_int_normal)(FloatPartsN= *a, FloatRoundMode rmode, } =20 if (shift_adj =3D=3D 0) { - if (frac_addi(a, a, inc)) { - frac_shr(a, 1); + if (fracN(addi)(a, a, inc)) { + fracN(shr)(a, 1); a->frac_hi |=3D DECOMPOSED_IMPLICIT_BIT; a->exp++; } a->frac_lo &=3D ~rnd_mask; } else { - frac_addi(a, a, inc); + fracN(addi)(a, a, inc); a->frac_lo &=3D ~rnd_mask; /* Be careful shifting back, not to overflow */ - frac_shl(a, shift_adj - 1); + fracN(shl)(a, shift_adj - 1); if (a->frac_hi & DECOMPOSED_IMPLICIT_BIT) { a->exp++; } else { - frac_add(a, a, a); + fracN(add)(a, a, a); } } return true; @@ -1555,7 +1555,7 @@ static FloatPartsN *partsN(minmax)(FloatPartsN *a, Fl= oatPartsN *b, /* Compare magnitudes. */ cmp =3D a_exp - b_exp; if (cmp =3D=3D 0) { - cmp =3D frac_cmp(a, b); + cmp =3D fracN(cmp)(a, b); } =20 /* @@ -1597,7 +1597,7 @@ static FloatRelation partsN(compare)(FloatPartsN *a, = FloatPartsN *b, goto a_sign; } if (a->exp =3D=3D b->exp) { - cmp =3D frac_cmp(a, b); + cmp =3D fracN(cmp)(a, b); } else if (a->exp < b->exp) { cmp =3D float_relation_less; } else { --=20 2.43.0