From patchwork Mon Dec 16 16:43:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georg-Johann Lay X-Patchwork-Id: 1210560 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-516053-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gjlay.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="FeTWU6fJ"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gjlay.de header.i=@gjlay.de header.b="JYMBdhLr"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47c6Y845x1z9sNH for ; Tue, 17 Dec 2019 03:43:56 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:references:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=awoS6YIuafHpAGW4X Sx+Fun4BdxlWzk/enn0fCGUxJXIHQiN4rRN9xlgfeNUDHD2sSrHbC64hAT80jXJz 5aPUeFV/MH+IppwDpzEQCuIaCaU//RcOAaZBKAFd1EJQlzMGxLn7cQOG6rhRC6iq A4EqU/o+mXgC+bbtqFcPyr7jJ0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:references:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=tT98HYsREhAn/ozEY8y1hNS 6Ka4=; b=FeTWU6fJfj9/4rfxu28cdChvbnmiFD5eUNl5z/EZV0tSWpKAiiktEl2 7DU+LQTu0dSEFOOMulDTKhoomUtiYgh/pY2wezZI/TPgPDyW05A1WzdEshUzGBLa UXJfQjmJy4oYqtf7GnsDz5B3aiOmrZCKklI3MVXkw+jX9ljpoNuM= Received: (qmail 75228 invoked by alias); 16 Dec 2019 16:43:49 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 75216 invoked by uid 89); 16 Dec 2019 16:43:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=no, machine_mode, fndecl, 3264 X-HELO: mo4-p00-ob.smtp.rzone.de Received: from mo4-p00-ob.smtp.rzone.de (HELO mo4-p00-ob.smtp.rzone.de) (81.169.146.163) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 16 Dec 2019 16:43:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1576514624; s=strato-dkim-0002; d=gjlay.de; h=In-Reply-To:Date:Message-ID:References:To:From:Subject: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=Mc+IxqZFB8zeYQiZXlOYBf0HqqL0VSFdZUOyD0T25+g=; b=JYMBdhLrjcxHIkf3RgMKrFUlzcaXLDsy0Ee/WPbP0UCxQ6NM0kxd6OR9qvVKfudNcG 4cLcwvMq3FI5CrCIeXcP6fdaMEObVC6uWi0z5xz1FTAcdQYg5bU8F65nUoJ0PUiRt5HX CQD0RawOeBc8hU9b27jYOzMJ3p1RsRHkAH3C2Gq1WhM/Ip9fiPJrGdycl8LOrB8Ff0Ea VV5eKl6MEAgfEgtXwnmj4vH45JAh+5OeqR1tMvU/vF+LpQdFccTi+mA4zMZgrl14wBgx 83iGUUff/Xhzfoedv3Cr2lu4NsmdShrbRE/WHzG9nKBw4m0ByJeg/PhYVe2qGb6Uql39 gv+g== Received: from [192.168.22.245] by smtp.strato.de (RZmta 46.0.7 AUTH) with ESMTPSA id Y0651dvBGGhiOVu (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256 bits)) (Client did not present a certificate) for ; Mon, 16 Dec 2019 17:43:44 +0100 (CET) Subject: [patch,avr, 1/3] Support 64-bit (long) double: The gcc part. From: Georg-Johann Lay To: GCC Patches References: <268c2e7e-aca7-58fa-602c-6b9dafc133e7@gjlay.de> Message-ID: <3d2f9f74-fbde-8a19-e76b-5d0575298451@gjlay.de> Date: Mon, 16 Dec 2019 17:43:43 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <268c2e7e-aca7-58fa-602c-6b9dafc133e7@gjlay.de> X-IsSubscribed: yes Am 16.12.19 um 17:40 schrieb Georg-Johann Lay: Patch 1/3 is the GCC changes: Documentation and new avr-specific configure options: --with-libf7 selects to which level double support from libf7 is added to libgcc. --with-double-comparison select what FLOAT_LIB_COMPARE_RETURNS_BOOL returns. Johann gcc/ * config.gcc (tm_defines) [target=avr]: Support --with-libf7, --with-double-comparison. * doc/install.texi: Document them. * config/avr/avr-c.c (avr_cpu_cpp_builtins) : New built-in defines. * doc/invoke.texi (AVR Built-in Macros): Document them. * config/avr/avr-protos.h (avr_float_lib_compare_returns_bool): New. * config/avr/avr.c (avr_float_lib_compare_returns_bool): New function. * config/avr/avr.h (FLOAT_LIB_COMPARE_RETURNS_BOOL): New macro. Index: gcc/config/avr/avr-c.c =================================================================== --- gcc/config/avr/avr-c.c (revision 278667) +++ gcc/config/avr/avr-c.c (working copy) @@ -390,6 +390,20 @@ start address. This macro shall be used cpp_define (pfile, "__WITH_AVRLIBC__"); #endif /* WITH_AVRLIBC */ + // From configure --with-libf7={|libgcc|math|math-symbols|yes|no} + +#ifdef WITH_LIBF7_LIBGCC + cpp_define (pfile, "__WITH_LIBF7_LIBGCC__"); +#endif /* WITH_LIBF7_LIBGCC */ + +#ifdef WITH_LIBF7_MATH + cpp_define (pfile, "__WITH_LIBF7_MATH__"); +#endif /* WITH_LIBF7_MATH */ + +#ifdef WITH_LIBF7_MATH_SYMBOLS + cpp_define (pfile, "__WITH_LIBF7_MATH_SYMBOLS__"); +#endif /* WITH_LIBF7_MATH_SYMBOLS */ + // From configure --with-double={|32|32,64|64,32|64} #ifdef HAVE_DOUBLE_MULTILIB @@ -438,7 +452,23 @@ start address. This macro shall be used #error "align this with config.gcc" #endif - + // From configure --with-double-comparison={2|3} --with-libf7. + +#if defined (WITH_DOUBLE_COMPARISON) +#if WITH_DOUBLE_COMPARISON == 2 || WITH_DOUBLE_COMPARISON == 3 + /* The number of states a DFmode comparison libcall might take and + reflects what avr.c:FLOAT_LIB_COMPARE_RETURNS_BOOL returns for + DFmode. GCC's default is 3-state, but some libraries like libf7 + implement true / false (2-state). */ + cpp_define_formatted (pfile, "__WITH_DOUBLE_COMPARISON__=%d", + WITH_DOUBLE_COMPARISON); +#else +#error "align this with config.gcc" +#endif +#else +#error "align this with config.gcc" +#endif + /* Define builtin macros so that the user can easily query whether non-generic address spaces (and which) are supported or not. This is only supported for C. For C++, a language extension is needed Index: gcc/config/avr/avr-protos.h =================================================================== --- gcc/config/avr/avr-protos.h (revision 278667) +++ gcc/config/avr/avr-protos.h (working copy) @@ -128,6 +128,8 @@ extern bool avr_xload_libgcc_p (machine_ extern rtx avr_eval_addr_attrib (rtx x); extern bool avr_casei_sequence_check_operands (rtx *xop); +extern bool avr_float_lib_compare_returns_bool (machine_mode, enum rtx_code); + static inline unsigned regmask (machine_mode mode, unsigned regno) { Index: gcc/config/avr/avr.c =================================================================== --- gcc/config/avr/avr.c (revision 278667) +++ gcc/config/avr/avr.c (working copy) @@ -14575,6 +14575,23 @@ avr_fold_builtin (tree fndecl, int n_arg return NULL_TREE; } + +/* Worker function for `FLOAT_LIB_COMPARE_RETURNS_BOOL'. */ + +bool +avr_float_lib_compare_returns_bool (machine_mode mode, enum rtx_code) +{ + if (mode == DFmode) + { +#if WITH_DOUBLE_COMPARISON == 2 + return true; +#endif + } + + // This is the GCC default and also what AVR-LibC implements. + return false; +} + /* Initialize the GCC target structure. */ Index: gcc/config/avr/avr.h =================================================================== --- gcc/config/avr/avr.h (revision 278667) +++ gcc/config/avr/avr.h (working copy) @@ -107,6 +107,9 @@ These two properties are reflected by bu #define BYTES_BIG_ENDIAN 0 #define WORDS_BIG_ENDIAN 0 +#define FLOAT_LIB_COMPARE_RETURNS_BOOL(mode, comparison) \ + avr_float_lib_compare_returns_bool (mode, comparison) + #ifdef IN_LIBGCC2 /* This is to get correct SI and DI modes in libgcc2.c (32 and 64 bits). */ #define UNITS_PER_WORD 4 Index: gcc/config.gcc =================================================================== --- gcc/config.gcc (revision 278552) +++ gcc/config.gcc (working copy) @@ -1303,6 +1303,46 @@ avr-*-*) tm_file="${tm_file} ${cpu_type}/avrlibc.h" tm_defines="${tm_defines} WITH_AVRLIBC" fi + # Work out avr_double_comparison which is 2 or 3 and is used in + # target hook FLOAT_LIB_COMPARE_RETURNS_BOOL to determine whether + # DFmode comparisons return 3-state or 2-state results. + case y${with_double_comparison} in + y | ytristate) + avr_double_comparison=3 + ;; + ybool | ylibf7) + avr_double_comparison=2 + ;; + *) + echo "Error: --with-double-comparison= can only be used with: 'tristate', 'bool', 'libf7'" 1>&2 + exit 1 + ;; + esac + case "y${with_libf7}" in + yno) + # avr_double_comparison as set above. + ;; + ylibgcc) + avr_double_comparison=2 + tm_defines="${tm_defines} WITH_LIBF7_LIBGCC" + ;; + y | yyes | ymath-symbols) + avr_double_comparison=2 + tm_defines="${tm_defines} WITH_LIBF7_LIBGCC" + tm_defines="${tm_defines} WITH_LIBF7_MATH" + tm_defines="${tm_defines} WITH_LIBF7_MATH_SYMBOLS" + ;; + ymath) + avr_double_comparison=2 + tm_defines="${tm_defines} WITH_LIBF7_LIBGCC" + tm_defines="${tm_defines} WITH_LIBF7_MATH" + ;; + *) + echo "Error: --with-libf7=${with_libf7} but can only be used with: 'libgcc', 'math', 'math-symbols', 'yes', 'no'" 1>&2 + exit 1 + ;; + esac + tm_defines="${tm_defines} WITH_DOUBLE_COMPARISON=${avr_double_comparison}" case y${with_double} in y | y32) avr_double=32 @@ -1332,7 +1372,7 @@ avr-*-*) ;; esac case y${with_long_double} in - y | y32) + y32) avr_long_double=32 tm_defines="${tm_defines} HAVE_LONG_DOUBLE32" ;; @@ -1340,7 +1380,7 @@ avr-*-*) avr_long_double=64 tm_defines="${tm_defines} HAVE_LONG_DOUBLE64" ;; - y64,32) + y | y64,32) avr_long_double=64 avr_long_double_multilib=1 tm_defines="${tm_defines} HAVE_LONG_DOUBLE32" Index: gcc/doc/install.texi =================================================================== --- gcc/doc/install.texi (revision 278552) +++ gcc/doc/install.texi (working copy) @@ -2306,9 +2306,10 @@ as a multilib option. If @option{--with-long-double=double} is specified, @samp{double} and @samp{long double} will have the same layout. @item -If the configure option is not set, it defaults to @samp{32} which -is compatible with older versions of the compiler that use non-standard -32-bit types for @samp{double} and @samp{long double}. +If the configure option is not set, @option{-mdouble=} defaults to @samp{32} +which is compatible with older versions of the compiler that use non-standard +32-bit types for @samp{double}. The default for @option{-mlong-double=} +is 64. @end itemize Not all combinations of @option{--with-double=} and @option{--with-long-double=} are valid. For example, the combination @@ -2318,6 +2319,28 @@ multilibs for @samp{double}, whereas the that @samp{long double} --- and hence also @samp{double} --- is always 32@tie{}bits wide. +@item --with-double-comparison=@{tristate|3|bool|2|libf7@} +Only supported for the AVR target since version@tie{}10. +Specify what result format is returned by library functions that +compare 64-bit floating point values (@code{DFmode}). +The GCC default is @samp{tristate}. If the floating point +implementation returns a boolean instead, set it to @samp{bool}. + +@item --with-libf7=@{libgcc|math|math-symbols|no@} +Only supported for the AVR target since version@tie{}10. +Specify to which degree code from Libf7 is included in libgcc. +Libf7 is an ad-hoc, AVR-specific, 64-bit floating point emulation +written in C and (inline) assembly. @samp{libgcc} adds support +for functions that one would usually expect in libgcc like double addition, +double comparisons and double conversions. @samp{math} also adds routines +that one would expect in @file{libm.a}, but with @code{__} (two underscores) +prepended to the symbol names as specified by @file{math.h}. +@samp{math-symbols} also defines weak aliases for the functions +declared in @file{math.h}. However, @code{--with-libf7} won't +install no @file{math.h} header file whatsoever, this file must come +from elsewhere. This option sets @option{--with-double-comparison} +to @samp{bool}. + @item --with-nds32-lib=@var{library} Specifies that @var{library} setting is used for building @file{libgcc.a}. Currently, the valid @var{library} is @samp{newlib} or @samp{mculib}. Index: gcc/doc/invoke.texi =================================================================== --- gcc/doc/invoke.texi (revision 278552) +++ gcc/doc/invoke.texi (working copy) @@ -18772,6 +18772,15 @@ features like attribute @code{progmem} a The compiler is configured to be used together with AVR-Libc. See the @option{--with-avrlibc} configure option. +@item __WITH_LIBF7_LIBGCC__ +@itemx __WITH_LIBF7_MATH__ +@itemx __WITH_LIBF7_MATH_SYMBOLS__ +Reflects the @code{--with-libf7=@{libgcc|math|math-symbols@}} +configure option, see +@code{--with-libf7=math}, @code{--with-libf7=math-symbols} was +specified, respectively, see +@uref{http://gcc.gnu.org/@/install/@/configure.html#avr}. + @end table @node Blackfin Options