From: Georg-Johann Lay <gjl@gcc.gnu.org>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: [Ping^2][patch,avr, 1/3] Support 64-bit (long) double: The gcc part.
Date: Mon, 06 Jan 2020 13:08:00 -0000 [thread overview]
Message-ID: <5E1331AA.4050804@gcc.gnu.org> (raw)
In-Reply-To: <3d2f9f74-fbde-8a19-e76b-5d0575298451@gjlay.de>
[-- Attachment #1: Type: text/plain, Size: 968 bytes --]
Ping #2
Georg-Johann Lay schrieb:
> 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)
> <WITH_LIBF7_LIBGCC, WITH_LIBF7_MATH, WITH_LIBF7_MATH_SYMBOLS>
> <WITH_DOUBLE_COMPARISON>: 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.
>
[-- Attachment #2: m64-gcc.diff --]
[-- Type: text/plain, Size: 8967 bytes --]
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;
+}
+
\f
/* 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
next prev parent reply other threads:[~2020-01-06 13:08 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-16 16:43 [patch,avr, 0/3] Support 64-bit (long) double Georg-Johann Lay
2019-12-16 16:46 ` [patch,avr, 1/3] Support 64-bit (long) double: The gcc part Georg-Johann Lay
2019-12-28 13:20 ` [PING^1][patch,avr, " Georg-Johann Lay
2020-01-06 13:08 ` Georg-Johann Lay [this message]
2020-01-06 16:25 ` [patch,avr, " Jeff Law
2020-01-06 17:10 ` Georg-Johann Lay
2020-01-06 17:16 ` Jeff Law
2020-12-15 7:40 ` AVR maintainership (was: [patch,avr, 1/3] Support 64-bit (long) double: The gcc part.) Gerald Pfeifer
2020-12-15 14:30 ` AVR maintainership (was: [patch, avr, " Segher Boessenkool
2020-12-15 20:42 ` AVR maintainership (was: [patch,avr, " Jeff Law
2020-12-18 16:53 ` AVR maintainership Georg-Johann Lay
2019-12-16 16:49 ` [patch,avr, 2/3] Support 64-bit (long) double: The libgcc changes Georg-Johann Lay
2019-12-28 12:00 ` [PING^1][patch,avr, " Georg-Johann Lay
2020-01-06 13:08 ` [Ping^2][patch,avr, " Georg-Johann Lay
2020-01-06 16:26 ` [patch,avr, " Jeff Law
2019-12-16 17:09 ` [patch,avr, 3/3] Support 64-bit (long) double: libf7 Georg-Johann Lay
2019-12-28 12:02 ` [PING^1][patch,avr, " Georg-Johann Lay
2020-01-06 13:09 ` [Ping^2][patch,avr, " Georg-Johann Lay
2020-01-06 16:26 ` [patch,avr, " Jeff Law
2019-12-28 11:59 ` [PING^1][patch,avr, 0/3] Support 64-bit (long) double Georg-Johann Lay
2019-12-28 11:59 ` Georg-Johann Lay
2020-01-06 13:08 ` [Ping^2][patch,avr, " Georg-Johann Lay
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5E1331AA.4050804@gcc.gnu.org \
--to=gjl@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).