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.
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