From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by sourceware.org (Postfix) with ESMTPS id 610AA3858D35 for ; Wed, 15 Feb 2023 11:17:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 610AA3858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pl1-x62f.google.com with SMTP id v23so19922842plo.1 for ; Wed, 15 Feb 2023 03:17:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=98uUM3LhAs2U/CahEOCwTZJaqlic4J7mHUrS51a5XQk=; b=Wy0rBJNkI7NKAlDMxmiBM3QNOQVdni4O+q8/u/JuuLMR4f/B+g7lT9Ldlchhjln094 WQF56ST77cEeuhGKfR+FJe2yf1BN02Vs6aonZU6/M64K0GLGjhxWqbx6kdYRfTWVWFzq pMA2BZDJhTKBuaZVBKSkAp5eoSj0U+1mB40DhC4IDes1h6/ZvFcmz9J+MiK95b8yt6Dm OLhk+R3fEK7N5aaijfQD31+wLyMvHGSYu70WwFSkHMhWH0Iy4QGQsZvxfsbO/P5xhC8t ZomkR0dGkhXnCi7ts3wFb/AvKusNfbjTbstNWpq0dk8HdXH0r208r/oYcyT3Ep+aAm8g BLRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=98uUM3LhAs2U/CahEOCwTZJaqlic4J7mHUrS51a5XQk=; b=Uk3+kgADSxfVXmogH7T99SbJ8rYhMPinrcfMwwBl0iBPFYDg4bX+O88vWL2k5AJzbZ Om6iwsB/5jBkwCtDO2MmYYiRcIns7uiRPun6kVHHmN4Lcp6s0eSZJELE5mN4/cexr+i0 M4zfj2YWZUh6q/R2ZWDDOVx37PQhjpOZEljwwvTw7DJs/AA+iUDQbdsBLnytnJWCIwHa 3xiA/SG1oZWm+1ZXKnzYOtGA31YNL7DAO4nK+Xpv9cDpI7QqYFgp9s6rXJORgJ5OqmdJ 7/S4eFbd+yInJMD9PdA055SmRe1ltBmCmAS1Jb2xl6DC+Tsz2Q9xE4ETRCMBATB+HVN5 N+IA== X-Gm-Message-State: AO0yUKUsztZORzDOkvDoG5ycgEUgrL/YJ81oAlf0PUdVqqnrlDO1ABC8 9QqnqatlwomJA7V91UN8o9lJfBA+VWwO+4AJ X-Google-Smtp-Source: AK7set/jzeyN0nOro1y47E3JH9igRq4IbeOiJB4hJvY/qUfuxLIUSKAEmBZa8xPEH/0IUfxTMSiV3w== X-Received: by 2002:a05:6a20:231a:b0:c1:344c:668f with SMTP id n26-20020a056a20231a00b000c1344c668fmr1069532pzc.12.1676459834497; Wed, 15 Feb 2023 03:17:14 -0800 (PST) Received: from hsinchu02.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id b21-20020a170902d31500b00185402cfedesm6485649plc.246.2023.02.15.03.17.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 03:17:13 -0800 (PST) From: Kito Cheng To: joseph@codesourcery.com, libc-alpha@sourceware.org, palmer@rivosinc.com, jeffreyalaw@gmail.com, darius@bluespec.com, christoph.muellner@vrull.eu, dj@redhat.com, andrew@sifive.com Cc: Kito Cheng Subject: [PATCH] riscv: Set __GLIBC_FLT_EVAL_METHOD to 0 if __FLT_EVAL_METHOD__ is -1 Date: Wed, 15 Feb 2023 19:17:09 +0800 Message-Id: <20230215111709.6803-1-kito.cheng@sifive.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_NUMSUBJECT,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: __GLIBC_FLT_EVAL_METHOD will effect the definition of float_t and double_t, currently we'll set __GLIBC_FLT_EVAL_METHOD to 2 when __FLT_EVAL_METHOD__ is -1, that means we'll define float_t and double_t to long double which is 128-bits IEEE 754 floating point type. However most RISC-V CPU isn't provide native 128-bits IEEE 754 floating point type operations (Q extension), so this will made float_t and double_t become very inefficient type, that's violate the spirit float_t and double_t. RISC-V has native single and double precision floating point opeations when F and D is present, even we don't have F or D extension, using same precision for soft-float still most efficient. Note: __FLT_EVAL_METHOD__ == -1 means the precision is indeterminable, which means compiler might using indeterminable precision during optimization/code gen, clang will set this value to -1 when fast math is enabled. Note: Default definition float_t and double_t in glibc: | __GLIBC_FLT_EVAL_METHOD | float_t | double_t | 0 or 16 | float | double | 1 | double | doulbe | 2 | long double | long double More complete list see math/math.h Ref: [1] Definition of FLT_EVAL_METHOD from C99 spec: C99 Spec draft: (https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf) Except for assignment and cast (which remove all extra range and precision), the values of operations with floating operands and values subject to the usual arithmetic conversions and of floating constants are evaluated to a format whose range and precision may be greater than required by the type. The use of evaluation formats is characterized by the implementation-defined value of FLT_EVAL_METHOD: 19) -1 indeterminable; 0 evaluate all operations and constants just to the range and precision of the type; 1 evaluate operations and constants of type float and double to the range and precision of the double type, evaluate long double operations and constants to the range and precision of the long double type; 2 evaluate all operations and constants to the range and precision of the long double type. All other negative values for FLT_EVAL_METHOD characterize implementation-defined behavior. [2] Definition of float_t and double_t in C99 spec: C99 Spec draft: (https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf) 7.12 ... The types float_t double_t are floating types at least as wide as float and double, respectively, and such that double_t is at least as wide as float_t. If FLT_EVAL_METHOD equals 0, float_t and double_t are float and double, respectively; if FLT_EVAL_METHOD equals 1, they are both double; if FLT_EVAL_METHOD equals 2, they are both long double; and for other values of FLT_EVAL_METHOD, they are otherwise implementation-defined.199) 199) The types float_t and double_t are intended to be the implementation’s most efficient types at least as wide as float and double, respectively. For FLT_EVAL_METHOD equal 0, 1, or 2, the type float_t is the narrowest type used by the implementation to evaluate floating expressions. --- sysdeps/riscv/bits/flt-eval-method.h | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 sysdeps/riscv/bits/flt-eval-method.h diff --git a/sysdeps/riscv/bits/flt-eval-method.h b/sysdeps/riscv/bits/flt-eval-method.h new file mode 100644 index 0000000000..95c907516e --- /dev/null +++ b/sysdeps/riscv/bits/flt-eval-method.h @@ -0,0 +1,31 @@ +/* Define __GLIBC_FLT_EVAL_METHOD. RISC-V version. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _MATH_H +# error "Never use directly; include instead." +#endif + +#ifdef __FLT_EVAL_METHOD__ +# if __FLT_EVAL_METHOD__ == -1 +# define __GLIBC_FLT_EVAL_METHOD 0 +# else +# define __GLIBC_FLT_EVAL_METHOD __FLT_EVAL_METHOD__ +# endif +#else +# define __GLIBC_FLT_EVAL_METHOD 0 +#endif -- 2.37.2