aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorGeorg-Johann Lay <avr@gjlay.de>2020-01-08 09:31:07 +0000
committerGeorg-Johann Lay <gjl@gcc.gnu.org>2020-01-08 09:31:07 +0000
commitf30dd607669212de135dec1f1d8a93b8954c327c (patch)
tree497248e433c158b74b956765c29800219a4f94e2 /gcc
parentd5bc18085c8b0344e7b53febc3cd3cc681a98ea3 (diff)
downloadgcc-f30dd607669212de135dec1f1d8a93b8954c327c.zip
gcc-f30dd607669212de135dec1f1d8a93b8954c327c.tar.gz
gcc-f30dd607669212de135dec1f1d8a93b8954c327c.tar.bz2
Implement 64-bit double functions.
gcc/ PR target/92055 * 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. libgcc/ PR target/92055 * config.host (tmake_file) [target=avr]: Add t-libf7, t-libf7-math, t-libf7-math-symbols as specified by --with-libf7=. * config/avr/t-avrlibc: Don't copy libgcc.a if there are modules depending on sizeof (double) or sizeof (long double). * config/avr/libf7: New folder. libgcc/config/avr/libf7/ PR target/92055 * t-libf7: New file. * t-libf7-math: New file. * t-libf7-math-symbols: New file. * libf7-common.mk: New file. * libf7-asm-object.mk: New file. * libf7-c-object.mk: New file. * asm-defs.h: New file. * libf7.h: New file. * libf7.c: New file. * libf7-asm.sx: New file. * libf7-array.def: New file. * libf7-const.def: New file. * libf7-constdef.h: New file. * f7renames.sh: New script. * f7wraps.sh: New script. * f7-renames.h: New generated file. * f7-wraps.h: New generated file. From-SVN: r279994
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog16
-rw-r--r--gcc/config.gcc48
-rw-r--r--gcc/config/avr/avr-c.c32
-rw-r--r--gcc/config/avr/avr-protos.h2
-rw-r--r--gcc/config/avr/avr.c17
-rw-r--r--gcc/config/avr/avr.h3
-rw-r--r--gcc/doc/install.texi29
-rw-r--r--gcc/doc/invoke.texi34
8 files changed, 171 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b94fb86..12bf61f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,19 @@
+2020-01-08 Georg-Johann Lay <avr@gjlay.de>
+
+ Implement 64-bit double functions.
+
+ PR target/92055
+ * 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.
+
2020-01-08 Richard Earnshaw <rearnsha@arm.com>
PR target/93188
diff --git a/gcc/config.gcc b/gcc/config.gcc
index c3d6464..6c957c4 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -1336,8 +1336,48 @@ 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)
+ y32)
avr_double=32
tm_defines="${tm_defines} HAVE_DOUBLE32"
;;
@@ -1352,7 +1392,7 @@ avr-*-*)
tm_defines="${tm_defines} HAVE_DOUBLE64"
tm_defines="${tm_defines} HAVE_DOUBLE_MULTILIB"
;;
- y32,64)
+ y | y32,64)
avr_double=32
avr_double_multilib=1
tm_defines="${tm_defines} HAVE_DOUBLE32"
@@ -1365,7 +1405,7 @@ avr-*-*)
;;
esac
case y${with_long_double} in
- y | y32)
+ y32)
avr_long_double=32
tm_defines="${tm_defines} HAVE_LONG_DOUBLE32"
;;
@@ -1373,7 +1413,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"
diff --git a/gcc/config/avr/avr-c.c b/gcc/config/avr/avr-c.c
index 1b75186..35f3e7e 100644
--- a/gcc/config/avr/avr-c.c
+++ b/gcc/config/avr/avr-c.c
@@ -390,6 +390,20 @@ avr_cpu_cpp_builtins (struct cpp_reader *pfile)
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 @@ avr_cpu_cpp_builtins (struct cpp_reader *pfile)
#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
diff --git a/gcc/config/avr/avr-protos.h b/gcc/config/avr/avr-protos.h
index d1e4dc5..16c894c 100644
--- a/gcc/config/avr/avr-protos.h
+++ b/gcc/config/avr/avr-protos.h
@@ -128,6 +128,8 @@ extern bool avr_xload_libgcc_p (machine_mode);
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)
{
diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c
index 5ed5b9d..61168ed 100644
--- a/gcc/config/avr/avr.c
+++ b/gcc/config/avr/avr.c
@@ -14575,6 +14575,23 @@ avr_fold_builtin (tree fndecl, int n_args ATTRIBUTE_UNUSED, tree *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. */
diff --git a/gcc/config/avr/avr.h b/gcc/config/avr/avr.h
index 0900272..c723b8a 100644
--- a/gcc/config/avr/avr.h
+++ b/gcc/config/avr/avr.h
@@ -107,6 +107,9 @@ FIXME: DRIVER_SELF_SPECS has changed.
#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
diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index 3dee2bb..9001217 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -2309,9 +2309,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}.
+The defaults are @option{--with-long-double=64,32} and
+@option{--with-double=32,64}. The default @samp{double} layout imposed by
+the latter is compatible with older versions of the compiler that implement
+@samp{double} as a 32-bit type, which does not comply to the language standard.
@end itemize
Not all combinations of @option{--with-double=} and
@option{--with-long-double=} are valid. For example, the combination
@@ -2321,6 +2322,28 @@ multilibs for @samp{double}, whereas the second option implies
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}.
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 2b07c09..ea0c42b 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -18421,9 +18421,9 @@ subroutines. Code size is smaller.
@opindex mdouble
@opindex mlong-double
Set the size (in bits) of the @code{double} or @code{long double} type,
-respectively. Possible values for @var{bits} are 32 an 64.
+respectively. Possible values for @var{bits} are 32 and 64.
Whether or not a specific value for @var{bits} is allowed depends on
-the @code{--with--double=} and @code{--with-long-double=}
+the @code{--with-double=} and @code{--with-long-double=}
@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure options}},
and the same applies for the default values of the options.
@@ -18886,6 +18886,36 @@ features like attribute @code{progmem} and @code{pgm_read_*}.
The compiler is configured to be used together with AVR-Libc.
See the @option{--with-avrlibc} configure option.
+@item __HAVE_DOUBLE_MULTILIB__
+Defined if @option{-mdouble=} acts as a multilib option.
+
+@item __HAVE_DOUBLE32__
+@itemx __HAVE_DOUBLE64__
+Defined if the compiler supports 32-bit double resp. 64-bit double.
+The actual layout is specified by option @option{-mdouble=}.
+
+@item __DEFAULT_DOUBLE__
+The size in bits of @code{double} if @option{-mdouble=} is not set.
+To test the layout of @code{double} in a program, use the built-in
+macro @code{__SIZEOF_DOUBLE__}.
+
+@item __HAVE_LONG_DOUBLE32__
+@itemx __HAVE_LONG_DOUBLE64__
+@itemx __HAVE_LONG_DOUBLE_MULTILIB__
+@itemx __DEFAULT_LONG_DOUBLE__
+Same as above, but for @code{long double} instead of @code{double}.
+
+@item __WITH_DOUBLE_COMPARISON__
+Reflects the @code{--with-double-comparison=@{tristate|bool|libf7@}}
+@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}
+and is defined to @code{2} or @code{3}.
+
+@item __WITH_LIBF7_LIBGCC__
+@itemx __WITH_LIBF7_MATH__
+@itemx __WITH_LIBF7_MATH_SYMBOLS__
+Reflects the @code{--with-libf7=@{libgcc|math|math-symbols@}}
+@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}.
+
@end table
@node Blackfin Options