From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27809 invoked by alias); 30 Oct 2017 22:57:44 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 27799 invoked by uid 89); 30 Oct 2017 22:57:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-8.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW,URIBL_BLACK autolearn=ham version=3.3.2 spammy=wholesale X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 30 Oct 2017 22:57:41 +0000 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v9UMsgWG132256 for ; Mon, 30 Oct 2017 18:57:39 -0400 Received: from e12.ny.us.ibm.com (e12.ny.us.ibm.com [129.33.205.202]) by mx0a-001b2d01.pphosted.com with ESMTP id 2dxd280q6m-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 30 Oct 2017 18:57:39 -0400 Received: from localhost by e12.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 30 Oct 2017 18:57:38 -0400 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e12.ny.us.ibm.com (146.89.104.199) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 30 Oct 2017 18:57:36 -0400 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v9UMvZIl41287858; Mon, 30 Oct 2017 22:57:35 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 694952803E; Mon, 30 Oct 2017 18:57:28 -0400 (EDT) Received: from ibm-tiger.the-meissners.org (unknown [9.32.77.111]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP id 4E88D2803D; Mon, 30 Oct 2017 18:57:28 -0400 (EDT) Received: by ibm-tiger.the-meissners.org (Postfix, from userid 500) id 2751C485C2; Mon, 30 Oct 2017 18:57:35 -0400 (EDT) Date: Mon, 30 Oct 2017 23:06:00 -0000 From: Michael Meissner To: Joseph Myers Cc: Michael Meissner , GCC Patches , Segher Boessenkool , David Edelsohn , Bill Schmidt Subject: Re: [PATCH, version 5a], Add support for _Float and _FloatX sqrt, fma, fmin, fmax built-in functions Mail-Followup-To: Michael Meissner , Joseph Myers , GCC Patches , Segher Boessenkool , David Edelsohn , Bill Schmidt References: <20171025202736.GA18058@ibm-tiger.the-meissners.org> <20171025224724.GA25269@ibm-tiger.the-meissners.org> <20171025235709.GA8932@ibm-tiger.the-meissners.org> <20171026001118.GA11364@ibm-tiger.the-meissners.org> <20171030180507.GA14054@ibm-tiger.the-meissners.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="ew6BAiZeqk4r7MaW" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-12-10) X-TM-AS-GCONF: 00 x-cbid: 17103022-0048-0000-0000-000001FDBD41 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007983; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000239; SDB=6.00938828; UDB=6.00473265; IPR=6.00719089; BA=6.00005663; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017799; XFM=3.00000015; UTC=2017-10-30 22:57:37 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17103022-0049-0000-0000-000043079BE1 Message-Id: <20171030225734.GA450@ibm-tiger.the-meissners.org> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-10-30_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=9 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710300296 X-IsSubscribed: yes X-SW-Source: 2017-10/txt/msg02259.txt.bz2 --ew6BAiZeqk4r7MaW Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 2991 On Mon, Oct 30, 2017 at 06:32:44PM +0000, Joseph Myers wrote: > On Mon, 30 Oct 2017, Michael Meissner wrote: > > > > One obvious possible fix would be for the builtins.def macros never to > > > define public names such as sqrtf128 for C++, only ever for C. That would > > > be on the basis that C++ code is expected to be using a sqrt overload > > > anyway - so making the built-in function available under a public name, in > > > the case where __float128 exists for C++, is a matter for libstdc++ > > > headers. > > > > Arghh, yes, I can restrict it to just the C language. Would you prefer just > > that? Do we want a target hook to be able to over-ride this on a platform > > Yes, I think such a restriction is appropriate (that is, C and ObjC get > both sqrtf128 and __builtin_sqrtf128 built-in functions, C++ and ObjC++ > get only __builtin_sqrtf128). > > > basis (with the default behavior only enabling it for C)? > > If we think that the preferred way for C++ code to access the underlying > functions is via function overloads for __float128 (not currently > implemented in libstdc++, it seems) rather than suffixed functions, or > through accessing the format as long double once that support is working, > a target hook may not be neded. If C++ code is expected to use > f128-suffixed functions directly, presumably it's desirable for a C++ call > to sqrtf128 to be inlined where possible and so you'd want a hook, or some > other way of enabling the built-in functions for C++ only in the case > where they are usefully distinct from the float / double / long double > functions. This patch fixes exporting the non __builtin_ names to be done by default only for the C language. I added a target hook in case a port needs to enable built-ins for C++ (either wholesale, or for particular built-in functions). I have done a bootstrap on a little endian Power8 system and it had no regressions. The x86-64 bootstrap just entered stage3. Assuming there are no regressions on x86-64, can I check this patch into the trunk? 2017-10-30 Michael Meissner * builtins.def (DEF_FLOATN_BUILTIN): Change most _Float and _FloatX built-in functions so that the variant without the "__builtin_" prefix is only enabled for the GNU C language when it is non-strict ANSI/ISO mode. (DEF_EXT_LIB_FLOATN_NX_BUILTINS): Likewise. * target.def (floatn_builtin_p): Add a target hook to control whether _Float and _FloatX built-in functions without the "__builtin_" prefix are enabled. Include langhooks.h in targhooks.c. * targhooks.h (default_floatn_builtin_p): Likewise. * targhooks.c (default_floatn_builtin_p): Likewise. * doc/tm.texi.in (TARGET_FLOATN_BUILTIN_P): Document the floatn_builtin_p target hook. * doc/tm.texi (TARGET_FLOATN_BUILTIN_P): Likewise. -- Michael Meissner, IBM IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA email: meissner@linux.vnet.ibm.com, phone: +1 (978) 899-4797 --ew6BAiZeqk4r7MaW Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=ieee128-patch50b Content-length: 7008 Index: gcc/builtins.def =================================================================== --- gcc/builtins.def (revision 254232) +++ gcc/builtins.def (working copy) @@ -130,18 +130,26 @@ along with GCC; see the file COPYING3. /* A set of GCC builtins for _FloatN and _FloatNx types. TYPE_MACRO is called with an argument such as FLOAT32 to produce the enum value for the type. If - we are being fully conformant we ignore the version of these builtins that - does not being with __builtin_. */ + we are compiling for the C language with GNU extensions, we enable the name + without the __builtin_ prefix as well as the name with the __builtin_ + prefix. C++ does not enable these names by default because they don't have + the _Float and _FloatX keywords, and a class based library should use + the __builtin_ names. */ +#undef DEF_FLOATN_BUILTIN +#define DEF_FLOATN_BUILTIN(ENUM, NAME, TYPE, ATTRS) \ + DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \ + targetm.floatn_builtin_p ((int) ENUM), \ + targetm.floatn_builtin_p ((int) ENUM), true, ATTRS, false, true) #undef DEF_EXT_LIB_FLOATN_NX_BUILTINS -#define DEF_EXT_LIB_FLOATN_NX_BUILTINS(ENUM, NAME, TYPE_MACRO, ATTRS) \ - DEF_EXT_LIB_BUILTIN (ENUM ## F16, NAME "f16", TYPE_MACRO (FLOAT16), ATTRS) \ - DEF_EXT_LIB_BUILTIN (ENUM ## F32, NAME "f32", TYPE_MACRO (FLOAT32), ATTRS) \ - DEF_EXT_LIB_BUILTIN (ENUM ## F64, NAME "f64", TYPE_MACRO (FLOAT64), ATTRS) \ - DEF_EXT_LIB_BUILTIN (ENUM ## F128, NAME "f128", TYPE_MACRO (FLOAT128), ATTRS)\ - DEF_EXT_LIB_BUILTIN (ENUM ## F32X, NAME "f32x", TYPE_MACRO (FLOAT32X), ATTRS)\ - DEF_EXT_LIB_BUILTIN (ENUM ## F64X, NAME "f64x", TYPE_MACRO (FLOAT64X), ATTRS)\ - DEF_EXT_LIB_BUILTIN (ENUM ## F128X, NAME "f128x", TYPE_MACRO (FLOAT128X), \ - ATTRS) +#define DEF_EXT_LIB_FLOATN_NX_BUILTINS(ENUM, NAME, TYPE_MACRO, ATTRS) \ + DEF_FLOATN_BUILTIN (ENUM ## F16, NAME "f16", TYPE_MACRO (FLOAT16), ATTRS) \ + DEF_FLOATN_BUILTIN (ENUM ## F32, NAME "f32", TYPE_MACRO (FLOAT32), ATTRS) \ + DEF_FLOATN_BUILTIN (ENUM ## F64, NAME "f64", TYPE_MACRO (FLOAT64), ATTRS) \ + DEF_FLOATN_BUILTIN (ENUM ## F128, NAME "f128", TYPE_MACRO (FLOAT128), ATTRS) \ + DEF_FLOATN_BUILTIN (ENUM ## F32X, NAME "f32x", TYPE_MACRO (FLOAT32X), ATTRS) \ + DEF_FLOATN_BUILTIN (ENUM ## F64X, NAME "f64x", TYPE_MACRO (FLOAT64X), ATTRS) \ + DEF_FLOATN_BUILTIN (ENUM ## F128X, NAME "f128x", TYPE_MACRO (FLOAT128X), \ + ATTRS) /* Like DEF_LIB_BUILTIN, except that the function is only a part of the standard in C94 or above. */ Index: gcc/target.def =================================================================== --- gcc/target.def (revision 254232) +++ gcc/target.def (working copy) @@ -3458,6 +3458,19 @@ if @var{extended} is false, 16 or greate opt_scalar_float_mode, (int n, bool extended), default_floatn_mode) +DEFHOOK +(floatn_builtin_p, + "Define this to return true if the @code{_Float@var{n}} and\n\ +@code{_Float@var{n}x} built-in functions should implicitly enable the\n\ +built-in function without the @code{__builtin_} prefix in addition to the\n\ +normal built-in function with the @code{__builtin_} prefix. The default is\n\ +to only enable built-in functions without the @code{__builtin_} prefix for\n\ +the GNU C langauge. In strict ANSI/ISO mode, the built-in function without\n\ +the @code{__builtin_} prefix is not enabled. The argument @code{FUNC} is the\n\ +@code{enum builtin_in_function} id of the function to be enabled.", + bool, (int func), + default_floatn_builtin_p) + /* Compute cost of moving data from a register of class FROM to one of TO, using MODE. */ DEFHOOK Index: gcc/targhooks.h =================================================================== --- gcc/targhooks.h (revision 254232) +++ gcc/targhooks.h (working copy) @@ -75,6 +75,7 @@ extern tree default_mangle_assembler_nam extern bool default_scalar_mode_supported_p (scalar_mode); extern bool default_libgcc_floating_mode_supported_p (scalar_float_mode); extern opt_scalar_float_mode default_floatn_mode (int, bool); +extern bool default_floatn_builtin_p (int); extern bool targhook_words_big_endian (void); extern bool targhook_float_words_big_endian (void); extern bool default_float_exceptions_rounding_supported_p (void); Index: gcc/targhooks.c =================================================================== --- gcc/targhooks.c (revision 254232) +++ gcc/targhooks.c (working copy) @@ -81,7 +81,7 @@ along with GCC; see the file COPYING3. #include "predict.h" #include "params.h" #include "real.h" - +#include "langhooks.h" bool default_legitimate_address_p (machine_mode mode ATTRIBUTE_UNUSED, @@ -563,6 +563,19 @@ default_floatn_mode (int n, bool extende return opt_scalar_float_mode (); } +/* Define this to return true if the _Floatn and _Floatnx built-in functions + should implicitly enable the built-in function without the __builtin_ prefix + in addition to the normal built-in function with the __builtin_ prefix. The + default is to only enable built-in functions without the __builtin_ prefix + for the GNU C langauge. The argument FUNC is the enum builtin_in_function + id of the function to be enabled. */ + +bool +default_floatn_builtin_p (int func ATTRIBUTE_UNUSED) +{ + return lang_GNU_C (); +} + /* Make some target macros useable by target-independent code. */ bool targhook_words_big_endian (void) Index: gcc/doc/tm.texi.in =================================================================== --- gcc/doc/tm.texi.in (revision 254232) +++ gcc/doc/tm.texi.in (working copy) @@ -3326,6 +3326,8 @@ stack. @hook TARGET_FLOATN_MODE +@hook TARGET_FLOATN_BUILTIN_P + @hook TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P @node Scalar Return Index: gcc/doc/tm.texi =================================================================== --- gcc/doc/tm.texi (revision 254232) +++ gcc/doc/tm.texi (working copy) @@ -4284,6 +4284,17 @@ ISO/IEC TS 18661-3:2015; that is, @var{n if @var{extended} is false, 16 or greater than 128 and a multiple of 32. @end deftypefn +@deftypefn {Target Hook} bool TARGET_FLOATN_BUILTIN_P (int @var{func}) +Define this to return true if the @code{_Float@var{n}} and +@code{_Float@var{n}x} built-in functions should implicitly enable the +built-in function without the @code{__builtin_} prefix in addition to the +normal built-in function with the @code{__builtin_} prefix. The default is +to only enable built-in functions without the @code{__builtin_} prefix for +the GNU C langauge. In strict ANSI/ISO mode, the built-in function without +the @code{__builtin_} prefix is not enabled. The argument @code{FUNC} is the +@code{enum builtin_in_function} id of the function to be enabled. +@end deftypefn + @deftypefn {Target Hook} bool TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P (machine_mode @var{mode}) Define this to return nonzero for machine modes for which the port has small register classes. If this target hook returns nonzero for a given --ew6BAiZeqk4r7MaW--