Commit f30dd607 by Georg-Johann Lay Committed by Georg-Johann Lay

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
parent d5bc1808
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> 2020-01-08 Richard Earnshaw <rearnsha@arm.com>
PR target/93188 PR target/93188
......
...@@ -1336,8 +1336,48 @@ avr-*-*) ...@@ -1336,8 +1336,48 @@ avr-*-*)
tm_file="${tm_file} ${cpu_type}/avrlibc.h" tm_file="${tm_file} ${cpu_type}/avrlibc.h"
tm_defines="${tm_defines} WITH_AVRLIBC" tm_defines="${tm_defines} WITH_AVRLIBC"
fi 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 case y${with_double} in
y | y32) y32)
avr_double=32 avr_double=32
tm_defines="${tm_defines} HAVE_DOUBLE32" tm_defines="${tm_defines} HAVE_DOUBLE32"
;; ;;
...@@ -1352,7 +1392,7 @@ avr-*-*) ...@@ -1352,7 +1392,7 @@ avr-*-*)
tm_defines="${tm_defines} HAVE_DOUBLE64" tm_defines="${tm_defines} HAVE_DOUBLE64"
tm_defines="${tm_defines} HAVE_DOUBLE_MULTILIB" tm_defines="${tm_defines} HAVE_DOUBLE_MULTILIB"
;; ;;
y32,64) y | y32,64)
avr_double=32 avr_double=32
avr_double_multilib=1 avr_double_multilib=1
tm_defines="${tm_defines} HAVE_DOUBLE32" tm_defines="${tm_defines} HAVE_DOUBLE32"
...@@ -1365,7 +1405,7 @@ avr-*-*) ...@@ -1365,7 +1405,7 @@ avr-*-*)
;; ;;
esac esac
case y${with_long_double} in case y${with_long_double} in
y | y32) y32)
avr_long_double=32 avr_long_double=32
tm_defines="${tm_defines} HAVE_LONG_DOUBLE32" tm_defines="${tm_defines} HAVE_LONG_DOUBLE32"
;; ;;
...@@ -1373,7 +1413,7 @@ avr-*-*) ...@@ -1373,7 +1413,7 @@ avr-*-*)
avr_long_double=64 avr_long_double=64
tm_defines="${tm_defines} HAVE_LONG_DOUBLE64" tm_defines="${tm_defines} HAVE_LONG_DOUBLE64"
;; ;;
y64,32) y | y64,32)
avr_long_double=64 avr_long_double=64
avr_long_double_multilib=1 avr_long_double_multilib=1
tm_defines="${tm_defines} HAVE_LONG_DOUBLE32" tm_defines="${tm_defines} HAVE_LONG_DOUBLE32"
......
...@@ -390,6 +390,20 @@ avr_cpu_cpp_builtins (struct cpp_reader *pfile) ...@@ -390,6 +390,20 @@ avr_cpu_cpp_builtins (struct cpp_reader *pfile)
cpp_define (pfile, "__WITH_AVRLIBC__"); cpp_define (pfile, "__WITH_AVRLIBC__");
#endif /* 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} // From configure --with-double={|32|32,64|64,32|64}
#ifdef HAVE_DOUBLE_MULTILIB #ifdef HAVE_DOUBLE_MULTILIB
...@@ -438,7 +452,23 @@ avr_cpu_cpp_builtins (struct cpp_reader *pfile) ...@@ -438,7 +452,23 @@ avr_cpu_cpp_builtins (struct cpp_reader *pfile)
#error "align this with config.gcc" #error "align this with config.gcc"
#endif #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 /* Define builtin macros so that the user can easily query whether
non-generic address spaces (and which) are supported or not. non-generic address spaces (and which) are supported or not.
This is only supported for C. For C++, a language extension is needed This is only supported for C. For C++, a language extension is needed
......
...@@ -128,6 +128,8 @@ extern bool avr_xload_libgcc_p (machine_mode); ...@@ -128,6 +128,8 @@ extern bool avr_xload_libgcc_p (machine_mode);
extern rtx avr_eval_addr_attrib (rtx x); extern rtx avr_eval_addr_attrib (rtx x);
extern bool avr_casei_sequence_check_operands (rtx *xop); 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 static inline unsigned
regmask (machine_mode mode, unsigned regno) regmask (machine_mode mode, unsigned regno)
{ {
......
...@@ -14575,6 +14575,23 @@ avr_fold_builtin (tree fndecl, int n_args ATTRIBUTE_UNUSED, tree *arg, ...@@ -14575,6 +14575,23 @@ avr_fold_builtin (tree fndecl, int n_args ATTRIBUTE_UNUSED, tree *arg,
return NULL_TREE; 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. */ /* Initialize the GCC target structure. */
......
...@@ -107,6 +107,9 @@ FIXME: DRIVER_SELF_SPECS has changed. ...@@ -107,6 +107,9 @@ FIXME: DRIVER_SELF_SPECS has changed.
#define BYTES_BIG_ENDIAN 0 #define BYTES_BIG_ENDIAN 0
#define WORDS_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 #ifdef IN_LIBGCC2
/* This is to get correct SI and DI modes in libgcc2.c (32 and 64 bits). */ /* This is to get correct SI and DI modes in libgcc2.c (32 and 64 bits). */
#define UNITS_PER_WORD 4 #define UNITS_PER_WORD 4
......
...@@ -2309,9 +2309,10 @@ as a multilib option. ...@@ -2309,9 +2309,10 @@ as a multilib option.
If @option{--with-long-double=double} is specified, @samp{double} and If @option{--with-long-double=double} is specified, @samp{double} and
@samp{long double} will have the same layout. @samp{long double} will have the same layout.
@item @item
If the configure option is not set, it defaults to @samp{32} which The defaults are @option{--with-long-double=64,32} and
is compatible with older versions of the compiler that use non-standard @option{--with-double=32,64}. The default @samp{double} layout imposed by
32-bit types for @samp{double} and @samp{long double}. 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 @end itemize
Not all combinations of @option{--with-double=} and Not all combinations of @option{--with-double=} and
@option{--with-long-double=} are valid. For example, the combination @option{--with-long-double=} are valid. For example, the combination
...@@ -2321,6 +2322,28 @@ multilibs for @samp{double}, whereas the second option implies ...@@ -2321,6 +2322,28 @@ multilibs for @samp{double}, whereas the second option implies
that @samp{long double} --- and hence also @samp{double} --- is always that @samp{long double} --- and hence also @samp{double} --- is always
32@tie{}bits wide. 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} @item --with-nds32-lib=@var{library}
Specifies that @var{library} setting is used for building @file{libgcc.a}. Specifies that @var{library} setting is used for building @file{libgcc.a}.
Currently, the valid @var{library} is @samp{newlib} or @samp{mculib}. Currently, the valid @var{library} is @samp{newlib} or @samp{mculib}.
......
...@@ -18421,9 +18421,9 @@ subroutines. Code size is smaller. ...@@ -18421,9 +18421,9 @@ subroutines. Code size is smaller.
@opindex mdouble @opindex mdouble
@opindex mlong-double @opindex mlong-double
Set the size (in bits) of the @code{double} or @code{long double} type, 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 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}}, @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure options}},
and the same applies for the default values of the 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_*}. ...@@ -18886,6 +18886,36 @@ features like attribute @code{progmem} and @code{pgm_read_*}.
The compiler is configured to be used together with AVR-Libc. The compiler is configured to be used together with AVR-Libc.
See the @option{--with-avrlibc} configure option. 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 @end table
@node Blackfin Options @node Blackfin Options
2020-01-08 Georg-Johann Lay <avr@gjlay.de>
Implement 64-bit double functions.
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.
2020-01-05 Olivier Hainque <hainque@adacore.com> 2020-01-05 Olivier Hainque <hainque@adacore.com>
* config/gthr-vxworks.h: Guard #include vxAtomicLib.h * config/gthr-vxworks.h: Guard #include vxAtomicLib.h
......
...@@ -514,6 +514,29 @@ arm*-*-eabi* | arm*-*-symbianelf* | arm*-*-rtems*) ...@@ -514,6 +514,29 @@ arm*-*-eabi* | arm*-*-symbianelf* | arm*-*-rtems*)
avr-*-*) avr-*-*)
# Make HImode functions for AVR # Make HImode functions for AVR
tmake_file="${cpu_type}/t-avr t-fpbit" tmake_file="${cpu_type}/t-avr t-fpbit"
# Make some DFmode functions from libf7, part of avr-libgcc.
# This must be prior to adding t-avrlibc.
case "y${with_libf7}" in
yno)
# No libf7 support.
;;
ylibgcc)
tmake_file="$tmake_file ${cpu_type}/libf7/t-libf7"
;;
ymath)
tmake_file="$tmake_file ${cpu_type}/libf7/t-libf7-math"
tmake_file="$tmake_file ${cpu_type}/libf7/t-libf7"
;;
ymath-symbols | yyes | y)
tmake_file="$tmake_file ${cpu_type}/libf7/t-libf7-math-symbols"
tmake_file="$tmake_file ${cpu_type}/libf7/t-libf7-math"
tmake_file="$tmake_file ${cpu_type}/libf7/t-libf7"
;;
*)
echo "Error: --with-libf7=${with_libf7} but can only be used with: 'libgcc', 'math', 'math-symbols', 'yes', 'no'" 1>&2
exit 1
;;
esac
if test x${with_avrlibc} != xno; then if test x${with_avrlibc} != xno; then
tmake_file="$tmake_file ${cpu_type}/t-avrlibc" tmake_file="$tmake_file ${cpu_type}/t-avrlibc"
fi fi
......
2020-01-08 Georg-Johann Lay <avr@gjlay.de>
Implement 64-bit double functions.
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.
/* Copyright (C) 2019-2020 Free Software Foundation, Inc.
This file is part of LIBF7, which is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef ASM_DEFS_H
#define ASM_DEFS_H
#ifdef __AVR__
#ifdef __ASSEMBLER__
/*****************************************************************/
/* Stuff for Assembler-only */
/*****************************************************************/
#if defined (__AVR_TINY__)
#define __tmp_reg__ 16
#define __zero_reg__ 17
#else
#define __tmp_reg__ 0
#define __zero_reg__ 1
#endif /* AVR_TINY */
#define __SREG__ 0x3f
#define __SP_L__ 0x3d
#if defined (__AVR_HAVE_SPH__)
#define __SP_H__ 0x3e
#endif
#if !defined ASM_DEFS_HAVE_DEFUN
.macro DEFUN name
.global \name
.func \name
\name:
.endm
.macro ENDF name
.size \name, .-\name
.endfunc
.endm
.macro LABEL name
.global \name
\name:
.endm
#endif /* HAVE_DEFUN */
#if defined (__AVR_HAVE_JMP_CALL__)
#define XCALL call
#define XJMP jmp
#else
#define XCALL rcall
#define XJMP rjmp
#endif
#if defined (__AVR_HAVE_EIJMP_EICALL__)
#define XICALL eicall
#define XIJMP eijmp
#define PC_SIZE 3
#else
#define XICALL icall
#define XIJMP ijmp
#define PC_SIZE 2
#endif
.macro skipnext
cpse r16, r16
.endm
/*
Factor out support of MOVW. Usage is like
wmov 30, 24
to move R25:R24 to R31:R30, i.e. plain register numbers
are required and no register prefix 'R'.
*/
#if defined (__AVR_HAVE_MOVW__)
#define wmov movw
#else
.macro wmov dst src
..dst = \dst
..src = \src
..regno = 0
.irp reg, \
r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, \
r10, r11, r12, r13, r14, r15, r16, r17, r18, r19, \
r20, r21, r22, r23, r24, r25, r26, r27, r28, r29, \
r30, r31
.ifc \reg,\dst
..dst = ..regno
.endif
.ifc \reg,\src
..src = ..regno
.endif
..regno = ..regno + 1
.endr
..regno = 0
.irp reg, \
R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, \
R10, R11, R12, R13, R14, R15, R16, R17, R18, R19, \
R20, R21, R22, R23, R24, R25, R26, R27, R28, R29, \
R30, R31
.ifc \reg,\dst
..dst = ..regno
.endif
.ifc \reg,\src
..src = ..regno
.endif
..regno = ..regno + 1
.endr
..regno = 0
.irp reg, \
X, x, XL, xl, Xl, xL, x, x \
Y, y, YL, yl, Yl, yL, y, y, \
Z, z, ZL, zl, Zl, zL, z, z
.ifc \reg,\dst
..dst = (..regno / 8) + 26
.endif
.ifc \reg,\src
..src = (..regno / 8) + 26
.endif
..regno = ..regno + 1
.endr
mov ..dst+0, ..src+0
mov ..dst+1, ..src+1
.endm
#endif /* MOVW */
#if !defined (__AVR_TINY__)
/*
Convenience macro for easy use of __prologue_saves__ from libgcc.
Push the N_PUSHED callee-saved registers Y, R17, R16, R15, ...
with 0 <= N_PUSHED <= 18. The frame pointer (Y) is set up according
to a frame size of N_FRAME. Clobbers TMP_REG.
For the code of __prologue_saves__ from libgcc see
http://gcc.gnu.org/viewcvs/gcc/trunk/libgcc/config/avr/lib1funcs.S?revision=267494&view=markup#l2159
*/
.macro do_prologue_saves n_pushed n_frame=0
ldi r26, lo8(\n_frame)
ldi r27, hi8(\n_frame)
ldi r30, lo8(gs(.L_prologue_saves.\@))
ldi r31, hi8(gs(.L_prologue_saves.\@))
XJMP __prologue_saves__ + ((18 - (\n_pushed)) * 2)
.L_prologue_saves.\@:
.endm
/*
Convenience macro for easy use of __epilogue_restores__ from libgcc.
Undo the effect of __prologue_saves__. Clobbers TMP_REG.
For the code of __epilogue_restores__ from libgcc see
http://gcc.gnu.org/viewcvs/gcc/trunk/libgcc/config/avr/lib1funcs.S?revision=267494&view=markup#l2216
*/
.macro do_epilogue_restores n_pushed n_frame=0
in r28, __SP_L__
#ifdef __AVR_HAVE_SPH__
in r29, __SP_H__
.if \n_frame > 63
subi r28, lo8(-\n_frame)
sbci r29, hi8(-\n_frame)
.elseif \n_frame > 0
adiw r28, \n_frame
.endif
#else
clr r29
.if \n_frame > 0
subi r28, lo8(-\n_frame)
.endif
#endif /* HAVE SPH */
ldi r30, \n_pushed
XJMP __epilogue_restores__ + ((18 - (\n_pushed)) * 2)
.endm
#endif /* AVR_TINY */
#else /* Assembler */
/*****************************************************************/
/* Space for C/C++ only Stuff */
/*****************************************************************/
#endif /* Assembler */
/*****************************************************************/
/* Space for Generic Stuff (Assembler, C, C++) */
/*****************************************************************/
#ifdef __AVR_PM_BASE_ADDRESS__
/*
Devices with a linear address space: Flash memory is seen in the
RAM address space at an offset of __AVR_PM_BASE_ADDRESS__ and can
be accessed by LD*. This is the case for devices like ATtiny40
(avrtiny) or ATtiny1616 and ATmega4808 (avrxmega3). The default
linker script locates .rodata in the .text output section and
at the required offset.
*/
#define RODATA_SECTION .rodata.asm
#define USE_LD 1
#define USE_LPM 0
#else /* PM_BASE_ADDRESS */
/*
No linear address space. As .rodata is located in RAM, we have to
use .progmem.data (located in flash) and LPM to read the data.
This will also work for devices from avrxmega3.
*/
#define RODATA_SECTION .progmem.data.asm
#define USE_LD 0
#define USE_LPM 1
#endif /* PM_BASE_ADDRESS */
#endif /* target AVR */
#endif /* ASM_DEFS_H */
/*
Auto-generated file, do not change by hand.
Generated by: f7renames.sh.
Generated using: F7_PREFIX = __f7_ from t-libf7.
F7F, F7F_cst, F7F_asm from libf7-common.mk.
Included by: libf7.h.
Used by: libf7.c, libf7.h, libf7-asm.sx, f7-wraps.h.
*/
#ifndef F7_RENAMES_H
#define F7_RENAMES_H
#define F7_(name) __f7_##name
#define F7P __f7_
/* Renames for libf7.c, libf7.h. */
#define f7_fabs __f7_fabs
#define f7_neg __f7_neg
#define f7_add __f7_add
#define f7_sub __f7_sub
#define f7_addsub __f7_addsub
#define f7_div __f7_div
#define f7_div1 __f7_div1
#define f7_divx __f7_divx
#define f7_fmod __f7_fmod
#define f7_sqrt __f7_sqrt
#define f7_cbrt __f7_cbrt
#define f7_square __f7_square
#define f7_mul __f7_mul
#define f7_mulx __f7_mulx
#define f7_madd_msub __f7_madd_msub
#define f7_madd __f7_madd
#define f7_msub __f7_msub
#define f7_hypot __f7_hypot
#define f7_Ineg __f7_Ineg
#define f7_Iadd __f7_Iadd
#define f7_Isub __f7_Isub
#define f7_Imul __f7_Imul
#define f7_Idiv __f7_Idiv
#define f7_IRsub __f7_IRsub
#define f7_Isquare __f7_Isquare
#define f7_Ildexp __f7_Ildexp
#define f7_Isqrt __f7_Isqrt
#define f7_le __f7_le
#define f7_lt __f7_lt
#define f7_gt __f7_gt
#define f7_ge __f7_ge
#define f7_ne __f7_ne
#define f7_eq __f7_eq
#define f7_cmp __f7_cmp
#define f7_cmp_abs __f7_cmp_abs
#define f7_ordered __f7_ordered
#define f7_unordered __f7_unordered
#define f7_cmp_unordered __f7_cmp_unordered
#define f7_lt_impl __f7_lt_impl
#define f7_gt_impl __f7_gt_impl
#define f7_le_impl __f7_le_impl
#define f7_ge_impl __f7_ge_impl
#define f7_eq_impl __f7_eq_impl
#define f7_ne_impl __f7_ne_impl
#define f7_unord_impl __f7_unord_impl
#define f7_lrint __f7_lrint
#define f7_ldexp __f7_ldexp
#define f7_frexp __f7_frexp
#define f7_exp __f7_exp
#define f7_logx __f7_logx
#define f7_log __f7_log
#define f7_log10 __f7_log10
#define f7_log2 __f7_log2
#define f7_minmax __f7_minmax
#define f7_fmax __f7_fmax
#define f7_fmin __f7_fmin
#define f7_floor __f7_floor
#define f7_ceil __f7_ceil
#define f7_round __f7_round
#define f7_lround __f7_lround
#define f7_trunc __f7_trunc
#define f7_truncx __f7_truncx
#define f7_horner __f7_horner
#define f7_pow10 __f7_pow10
#define f7_exp10 __f7_exp10
#define f7_pow __f7_pow
#define f7_powi __f7_powi
#define f7_sin __f7_sin
#define f7_cos __f7_cos
#define f7_tan __f7_tan
#define f7_cotan __f7_cotan
#define f7_sincos __f7_sincos
#define f7_sinh __f7_sinh
#define f7_cosh __f7_cosh
#define f7_tanh __f7_tanh
#define f7_sinhcosh __f7_sinhcosh
#define f7_asinacos __f7_asinacos
#define f7_asin __f7_asin
#define f7_acos __f7_acos
#define f7_atan __f7_atan
#define f7_atan2 __f7_atan2
#define f7_mul_noround __f7_mul_noround
#define f7_sqrt16_round __f7_sqrt16_round
#define f7_sqrt16_floor __f7_sqrt16_floor
#define f7_clr_mant_lsbs __f7_clr_mant_lsbs
#define f7_abscmp_msb_ge __f7_abscmp_msb_ge
#define f7_lshrdi3 __f7_lshrdi3
#define f7_ashldi3 __f7_ashldi3
#define f7_assert __f7_assert
#define f7_classify __f7_classify
#define f7_class_inf __f7_class_inf
#define f7_class_nan __f7_class_nan
#define f7_class_number __f7_class_number
#define f7_class_zero __f7_class_zero
#define f7_class_nonzero __f7_class_nonzero
#define f7_class_sign __f7_class_sign
#define f7_signbit __f7_signbit
#define f7_set_sign __f7_set_sign
#define f7_set_nan __f7_set_nan
#define f7_set_inf __f7_set_inf
#define f7_is_inf __f7_is_inf
#define f7_is_nan __f7_is_nan
#define f7_is_number __f7_is_number
#define f7_is_zero __f7_is_zero
#define f7_is_nonzero __f7_is_nonzero
#define f7_clr __f7_clr
#define f7_copy __f7_copy
#define f7_copy_P __f7_copy_P
#define f7_copy_mant __f7_copy_mant
#define f7_msbit __f7_msbit
#define f7_is0 __f7_is0
#define f7_cmp_mant __f7_cmp_mant
#define f7_store_expo __f7_store_expo
#define f7_abs __f7_abs
#define f7_set_s64 __f7_set_s64
#define f7_set_s32 __f7_set_s32
#define f7_set_s16 __f7_set_s16
#define f7_set_s16_impl __f7_set_s16_impl
#define f7_set_u16_worker __f7_set_u16_worker
#define f7_set_u64 __f7_set_u64
#define f7_set_u32 __f7_set_u32
#define f7_set_u16 __f7_set_u16
#define f7_set_u16_impl __f7_set_u16_impl
#define f7_set_float __f7_set_float
#define f7_set_pdouble __f7_set_pdouble
#define f7_set_double_impl __f7_set_double_impl
#define f7_set_double __f7_set_double
#define f7_init_impl __f7_init_impl
#define f7_init __f7_init
#define f7_get_s16 __f7_get_s16
#define f7_get_s32 __f7_get_s32
#define f7_get_s64 __f7_get_s64
#define f7_get_float __f7_get_float
#define f7_get_u16 __f7_get_u16
#define f7_get_u32 __f7_get_u32
#define f7_get_u64 __f7_get_u64
#define f7_get_double __f7_get_double
#define f7_set_eps __f7_set_eps
#define f7_set_1pow2 __f7_set_1pow2
#define f7_min __f7_min
#define f7_max __f7_max
#define f7_exp10 __f7_exp10
#define f7_floatunsidf __f7_floatunsidf
#define f7_floatsidf __f7_floatsidf
#define f7_extendsfdf2 __f7_extendsfdf2
#define f7_fixdfsi __f7_fixdfsi
#define f7_fixdfdi __f7_fixdfdi
#define f7_fixunsdfdi __f7_fixunsdfdi
#define f7_fixunsdfsi __f7_fixunsdfsi
#define f7_truncdfsf2 __f7_truncdfsf2
#define f7_le_impl __f7_le_impl
#define f7_lt_impl __f7_lt_impl
#define f7_gt_impl __f7_gt_impl
#define f7_ge_impl __f7_ge_impl
#define f7_ne_impl __f7_ne_impl
#define f7_eq_impl __f7_eq_impl
#define f7_unord_impl __f7_unord_impl
/* Renames for libf7.c, libf7.h. */
#define f7_const_1 __f7_const_1
#define f7_const_1_P __f7_const_1_P
#define f7_const_2 __f7_const_2
#define f7_const_2_P __f7_const_2_P
#define f7_const_1_2 __f7_const_1_2
#define f7_const_1_2_P __f7_const_1_2_P
#define f7_const_1_3 __f7_const_1_3
#define f7_const_1_3_P __f7_const_1_3_P
#define f7_const_m1 __f7_const_m1
#define f7_const_m1_P __f7_const_m1_P
#define f7_const_pi __f7_const_pi
#define f7_const_pi_P __f7_const_pi_P
#define f7_const_ln2 __f7_const_ln2
#define f7_const_ln2_P __f7_const_ln2_P
#define f7_const_ln10 __f7_const_ln10
#define f7_const_ln10_P __f7_const_ln10_P
#define f7_const_1_ln2 __f7_const_1_ln2
#define f7_const_1_ln2_P __f7_const_1_ln2_P
#define f7_const_1_ln10 __f7_const_1_ln10
#define f7_const_1_ln10_P __f7_const_1_ln10_P
#define f7_const_sqrt2 __f7_const_sqrt2
#define f7_const_sqrt2_P __f7_const_sqrt2_P
/* Renames for libf7-asm.sx, f7-wraps.h. */
#define f7_classify_asm __f7_classify_asm
#define f7_store_expo_asm __f7_store_expo_asm
#define f7_clr_asm __f7_clr_asm
#define f7_copy_asm __f7_copy_asm
#define f7_copy_P_asm __f7_copy_P_asm
#define f7_copy_mant_asm __f7_copy_mant_asm
#define f7_cmp_mant_asm __f7_cmp_mant_asm
#define f7_normalize_asm __f7_normalize_asm
#define f7_store_expo_asm __f7_store_expo_asm
#define f7_set_u64_asm __f7_set_u64_asm
#define f7_set_s64_asm __f7_set_s64_asm
#define f7_addsub_mant_scaled_asm __f7_addsub_mant_scaled_asm
#define f7_mul_mant_asm __f7_mul_mant_asm
#define f7_to_integer_asm __f7_to_integer_asm
#define f7_to_unsigned_asm __f7_to_unsigned_asm
#define f7_clr_mant_lsbs_asm __f7_clr_mant_lsbs_asm
#define f7_div_asm __f7_div_asm
#define f7_sqrt_approx_asm __f7_sqrt_approx_asm
#define f7_sqrt16_round_asm __f7_sqrt16_round_asm
#define f7_sqrt16_floor_asm __f7_sqrt16_floor_asm
#define f7_lshrdi3_asm __f7_lshrdi3_asm
#define f7_ashldi3_asm __f7_ashldi3_asm
#define f7_class_D_asm __f7_class_D_asm
#define f7_call_ddd_asm __f7_call_ddd_asm
#define f7_call_xdd_asm __f7_call_xdd_asm
#define f7_call_ddx_asm __f7_call_ddx_asm
#define f7_call_dd_asm __f7_call_dd_asm
#define f7_call_xd_asm __f7_call_xd_asm
#define f7_call_dx_asm __f7_call_dx_asm
#endif /* F7_RENAMES_H */
#!/usr/bin/env sh
# The first command argument tells us which flavour to generate for
# the rest of the command line arguments.
what=$1
shift
# The second command argument is the prefix to prepend to all functions.
# It is defined by F7_PREFIX in $2.
PRE=$1
shift
case ${what} in
head)
cat << EOF
/*
Auto-generated file, do not change by hand.
Generated by: `basename $0`.
Generated using: F7_PREFIX = ${PRE} from $1.
F7F, F7F_cst, F7F_asm from libf7-common.mk.
Included by: libf7.h.
Used by: libf7.c, libf7.h, libf7-asm.sx, f7-wraps.h.
*/
#ifndef F7_RENAMES_H
#define F7_RENAMES_H
#define F7_(name) ${PRE}##name
#define F7P ${PRE}
EOF
;;
c)
if [ x${PRE} != xf7_ ]; then
echo " "
echo "/* Renames for libf7.c, libf7.h. */"
echo " "
for x in $*; do
echo "#define f7_$x ${PRE}$x"
done
fi
;;
cst)
if [ x${PRE} != xf7_ ]; then
echo " "
echo "/* Renames for libf7.c, libf7.h. */"
echo " "
for x in $*; do
echo "#define f7_const_${x} ${PRE}const_${x}"
echo "#define f7_const_${x}_P ${PRE}const_${x}_P"
done
fi
;;
asm)
if [ x${PRE} != xf7_ ]; then
echo " "
echo "/* Renames for libf7-asm.sx, f7-wraps.h. */"
echo " "
for x in $*; do
echo "#define f7_${x}_asm ${PRE}${x}_asm"
done
fi
;;
tail)
cat << EOF
#endif /* F7_RENAMES_H */
EOF
;;
*)
exit 1
;;
esac
#!/usr/bin/env sh
# The first command argument $1 tells us which flavour to generate for
# the rest of the command line arguments.
what=$1
shift
if [ "x$*" = "x" ]; then
none="(none)"
fi
case ${what} in
header)
cat << EOF
;; Copyright (C) 2019-2020 Free Software Foundation, Inc.
;;
;; This file is part of LIBF7, which is part of GCC.
;;
;; GCC is free software; you can redistribute it and/or modify it under
;; the terms of the GNU General Public License as published by the Free
;; Software Foundation; either version 3, or (at your option) any later
;; version.
;;
;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
;; for more details.
;;
;; Under Section 7 of GPL version 3, you are granted additional
;; permissions described in the GCC Runtime Library Exception, version
;; 3.1, as published by the Free Software Foundation.
;;
;; You should have received a copy of the GNU General Public License and
;; a copy of the GCC Runtime Library Exception along with this program;
;; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
;; <http://www.gnu.org/licenses/>. */
;; Auto-generated file, do not change by hand.
;;
;; Wrappers for double and long double functions to use functions that
;; operate on f7_t, and get f7_t* and const f7_t*.
;;
;; Generated by: `basename $0`
;; Included by : libf7-asm.sx
EOF
for n in $*; do
echo ";; $n"
done
;;
xd_libgcc)
cat << EOF
;; Functions that usually live in libgcc: __<name> for <name> in:
;; $*${none}
EOF
for n in $*; do
cat << EOF
;; type_t __${n} (double) ; $n
#ifdef F7MOD_D_${n}_
_DEFUN __${n}
.global F7_NAME($n)
ldi ZH, hi8(gs(F7_NAME($n)))
ldi ZL, lo8(gs(F7_NAME($n)))
F7jmp call_xd
_ENDF __${n}
#endif /* F7MOD_D_${n}_ */
EOF
done
;;
dx_libgcc)
cat << EOF
;; Functions that usually live in libgcc: __<name> for <name> in:
;; $*${none}
EOF
for n in $*; do
cat << EOF
;; double __${n} (type_t) ; $n
#ifdef F7MOD_D_${n}_
_DEFUN __${n}
.global F7_NAME($n)
ldi ZH, hi8(gs(F7_NAME($n)))
ldi ZL, lo8(gs(F7_NAME($n)))
F7jmp call_dx
_ENDF __${n}
#endif /* F7MOD_D_${n}_ */
EOF
done
;;
ddd_libgcc)
cat << EOF
;; Functions that usually live in libgcc: __<name>df3 for <name> in:
;; $*${none}
EOF
for n in $*; do
cat << EOF
;; double __${n}df3 (double, double) ; $n
#ifdef F7MOD_D_${n}_
_DEFUN __${n}df3
ALIAS __$n
.global F7_NAME($n)
ldi ZH, hi8(gs(F7_NAME($n)))
ldi ZL, lo8(gs(F7_NAME($n)))
F7jmp call_ddd
_ENDF __${n}df3
#endif /* F7MOD_D_${n}_ */
EOF
done
;;
xdd_libgcc_cmp)
cat << EOF
;; Functions that usually live in libgcc: __<name>df2 for <name> in:
;; $*${none}
EOF
for n in $*; do
cat << EOF
;; bool __${n}df2 (double, double) ; $n
#ifdef F7MOD_D_${n}_
_DEFUN __${n}df2
.global F7_NAME(${n}_impl)
ldi ZH, hi8(gs(F7_NAME(${n}_impl)))
ldi ZL, lo8(gs(F7_NAME(${n}_impl)))
F7jmp call_xdd
_ENDF __${n}df2
#endif /* F7MOD_D_${n}_ */
EOF
done
;;
dd_math)
cat << EOF
;; Functions that usually live in libm: Depending on [long] double layout,
;; define <name> and <name>l as weak alias(es) of __<name> for <name> in:
;; $*${none}
EOF
for n in $*; do
cat << EOF
;; double __${n} (double)
#ifdef F7MOD_D_${n}_
_DEFUN __${n}
DALIAS $n
LALIAS ${n}l
.global F7_NAME($n)
ldi ZH, hi8(gs(F7_NAME($n)))
ldi ZL, lo8(gs(F7_NAME($n)))
F7jmp call_dd
_ENDF __${n}
#endif /* F7MOD_D_${n}_ */
EOF
done
;;
xd_math)
cat << EOF
;; Functions that usually live in libm: Depending on [long] double layout,
;; define <name> and <name>l as weak alias(es) of __<name> for <name> in:
;; $*${none}
EOF
for n in $*; do
cat << EOF
;; type_t __${n} (double)
#ifdef F7MOD_D_${n}_
_DEFUN __${n}
DALIAS $n
LALIAS ${n}l
.global F7_NAME($n)
ldi ZH, hi8(gs(F7_NAME($n)))
ldi ZL, lo8(gs(F7_NAME($n)))
F7jmp call_xd
_ENDF __${n}
#endif /* F7MOD_D_${n}_ */
EOF
done
;;
ddd_math)
cat << EOF
;; Functions that usually live in libm: Depending on [long] double layout,
;; define <name> and <name>l as weak alias(es) of __<name> for <name> in:
;; $*${none}
EOF
for n in $*; do
cat << EOF
;; double __${n} (double, double)
#ifdef F7MOD_D_${n}_
_DEFUN __${n}
DALIAS $n
LALIAS ${n}l
.global F7_NAME($n)
ldi ZH, hi8(gs(F7_NAME($n)))
ldi ZL, lo8(gs(F7_NAME($n)))
F7jmp call_ddd
_ENDF __${n}
#endif /* F7MOD_D_${n}_ */
EOF
done
;;
ddx_math)
cat << EOF
;; Functions that usually live in libm: Depending on [long] double layout,
;; define <name> and <name>l as weak alias(es) of __<name> for <name> in:
;; $*${none}
EOF
for n in $*; do
cat << EOF
;; double __${n} (double, word_t)
#ifdef F7MOD_D_${n}_
_DEFUN __${n}
DALIAS $n
LALIAS ${n}l
.global F7_NAME($n)
ldi ZH, hi8(gs(F7_NAME($n)))
ldi ZL, lo8(gs(F7_NAME($n)))
F7jmp call_ddx
_ENDF __${n}
#endif /* F7MOD_D_${n}_ */
EOF
done
;;
*)
exit 1
;;
esac
/* Copyright (C) 2019-2020 Free Software Foundation, Inc.
This file is part of LIBF7, which is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
static const F7_PGMSPACE f7_t ARRAY_NAME[] =
{
#define F7_CONST_DEF(NAME, FLAGS, M6, M5, M4, M3, M2, M1, M0, EXPO) \
{ .flags = FLAGS, .mant = { M0, M1, M2, M3, M4, M5, M6 }, .expo = EXPO },
#include "libf7-const.def"
#undef F7_CONST_DEF
};
// static const uint8_t n_ARRAY_NAME = <Entries in ARRAY_NAME[]>.
#define F7_n_NAME2(X) n_##X
#define F7_n_NAME1(X) F7_n_NAME2(X)
F7_UNUSED static const uint8_t F7_n_NAME1 (ARRAY_NAME) =
#define F7_CONST_DEF(NAME, FLAGS, M6, M5, M4, M3, M2, M1, M0, EXPO) \
+ 1
#include "libf7-const.def"
#undef F7_CONST_DEF
;
#undef F7_n_NAME1
#undef F7_n_NAME2
# This file is included several times in a row, once for each element of
# $(iter-items). On each inclusion, we advance $o to the next element.
# $(iter-labels) is also advanced.
# This works similar to $(srcdir)/siditi-object.mk.
o := $(firstword $(iter-items))
iter-items := $(filter-out $o,$(iter-items))
$o-label := $(firstword $(iter-labels))
iter-labels := $(wordlist 2,$(words $(iter-labels)),$(iter-labels))
f7_asm_$o$(objext): f7_asm_%$(objext): $(libf7)/libf7-asm.sx
$(gcc_compile) -DF7MOD_$($*-label)_ $(F7_ASM_FLAGS) \
-c $<
ifeq ($(enable_shared),yes)
f7_asm_$(o)_s$(objext): f7_asm_%_s$(objext): $(libf7)/libf7-asm.sx
$(gcc_s_compile) -DF7MOD_$($*-label)_ $(F7_ASM_FLAGS) \
-c $<
endif
# This file is included several times in a row, once for each element of
# $(iter-items). On each inclusion, we advance $o to the next element.
# $(iter-labels) is also advanced.
# This works similar to $(srcdir)/siditi-object.mk.
o := $(firstword $(iter-items))
iter-items := $(filter-out $o,$(iter-items))
$o-label := $(firstword $(iter-labels))
iter-labels := $(wordlist 2,$(words $(iter-labels)),$(iter-labels))
f7_c_$o$(objext): f7_c_%$(objext): $(libf7)/libf7.c
$(gcc_compile) -DF7MOD_$($*-label)_ $(F7_C_FLAGS) \
-c $<
ifeq ($(enable_shared),yes)
f7_c_$(o)_s$(objext): %_s$(objext): $(libf7)/libf7.c
$(gcc_s_compile) -DF7MOD_$($*-label)_ $(F7_C_FLAGS) \
-c $<
endif
# f7_c_*.o modules from libf7.c.
F7_C_PARTS += set_s16 set_u16 set_s32 set_u32 init
F7_C_PARTS += get_s16 get_u16 get_s32 get_u32 get_s64 get_u64
F7_C_PARTS += lrint ldexp frexp madd_msub madd msub hypot
F7_C_PARTS += addsub add sub mulx mul square divx div div1 fmod sqrt cbrt
F7_C_PARTS += Ineg Iadd Isub Imul Idiv IRsub Isquare Ildexp Isqrt
F7_C_PARTS += set_float get_float get_double set_double set_pdouble
F7_C_PARTS += fabs neg fmin fmax minmax truncx trunc floor ceil round lround
F7_C_PARTS += horner logx log log10 log2 exp pow10 pow powi
F7_C_PARTS += sin cos tan cotan sincos sinh cosh tanh sinhcosh
F7_C_PARTS += asinacos asin acos atan atan2
F7_C_PARTS += abscmp_msb_ge cmp cmp_abs cmp_unordered
F7_C_PARTS += const_1 const_1_2 const_1_3
F7_C_PARTS += const_pi const_ln2 const_1_ln2 const_ln10 const_1_ln10 const_sqrt2
F7_C_PARTS += # const_m1 const_2 const_sqrt2
# f7_asm_*.o modules from libf7-asm.sx.
F7_ASM_PARTS += classify clr mul_mant cmp_mant set_u64
F7_ASM_PARTS += copy copy_P copy_mant clr_mant_lsbs
F7_ASM_PARTS += addsub_mant_scaled store load
F7_ASM_PARTS += to_integer to_unsigned clz normalize_with_carry normalize
F7_ASM_PARTS += store_expo sqrt16 sqrt_approx div
F7_ASM_PARTS += D_class
F7_ASM_PARTS += D_isnan D_isinf D_isfinite D_signbit D_copysign D_neg D_fabs
F7_ASM_PARTS += call_dd call_ddd
# Stuff that will be wrapped in f7-wraps.h (included by libf7-asm.sx)
# and give f7_asm_D_*.o modules.
g_ddd += add sub mul div
g_xdd_cmp += le lt ge gt ne eq unord
g_dx += floatunsidf floatsidf extendsfdf2
g_xd += fixdfsi fixdfdi fixunsdfdi fixunsdfsi truncdfsf2
m_ddd += pow fmin fmax fmod hypot atan2
m_ddx += ldexp frexp
m_dd += sqrt cbrt exp exp10 pow10 log log10 log2 sin cos tan cotan asin acos atan
m_dd += ceil floor trunc round sinh cosh tanh
m_xd += lrint lround
# -mcall-prologues
CALL_PROLOGUES += divx sqrt cbrt get_double set_double logx exp exp10 pow10
CALL_PROLOGUES += put_C truncx round minmax sincos tan cotan pow powi fmod
CALL_PROLOGUES += atan asinacos madd_msub hypot init horner sinhcosh tanh
# -mstrict-X
STRICT_X += log addsub truncx ldexp exp
# Renames used when building f7-renames.h.
F7F += fabs neg add sub addsub div div1 divx fmod sqrt cbrt
F7F += square mul mulx madd_msub madd msub hypot
F7F += Ineg Iadd Isub Imul Idiv IRsub Isquare Ildexp Isqrt
F7F += le lt gt ge ne eq cmp cmp_abs ordered unordered cmp_unordered
F7F += lt_impl gt_impl le_impl ge_impl eq_impl ne_impl unord_impl
F7F += lrint ldexp frexp exp logx log log10 log2
F7F += minmax fmax fmin floor ceil round lround trunc truncx
F7F += horner pow10 exp10 pow powi
F7F += sin cos tan cotan sincos sinh cosh tanh sinhcosh
F7F += asinacos asin acos atan atan2
F7F += mul_noround sqrt16_round sqrt16_floor
F7F += clr_mant_lsbs abscmp_msb_ge lshrdi3 ashldi3
F7F += assert
F7F += classify
F7F += class_inf class_nan class_number class_zero class_nonzero class_sign
F7F += signbit set_sign set_nan set_inf
F7F += is_inf is_nan is_number is_zero is_nonzero
F7F += clr copy copy_P copy_mant msbit is0 cmp_mant store_expo
F7F += abs
F7F += set_s64 set_s32 set_s16 set_s16_impl set_u16_worker
F7F += set_u64 set_u32 set_u16 set_u16_impl
F7F += set_float set_pdouble set_double_impl set_double init_impl init
F7F += get_s16 get_s32 get_s64 get_float
F7F += get_u16 get_u32 get_u64 get_double
F7F += set_eps set_1pow2
# Renames for ALIASes without own module.
F7F += min max exp10
F7F += floatunsidf floatsidf extendsfdf2
F7F += fixdfsi fixdfdi fixunsdfdi fixunsdfsi truncdfsf2
# Renames for f7-const.def.
F7F_cst += 1 2 1_2 1_3 m1 pi ln2 ln10 1_ln2 1_ln10 sqrt2
F7F_asm += classify
F7F_asm += store_expo clr copy copy_P copy_mant
F7F_asm += cmp_mant normalize store_expo
F7F_asm += set_u64 set_s64 addsub_mant_scaled mul_mant
F7F_asm += to_integer to_unsigned clr_mant_lsbs
F7F_asm += div sqrt_approx sqrt16_round sqrt16_floor
F7F_asm += lshrdi3 ashldi3
F7F_asm += class_D
F7F_asm += call_ddd call_xdd call_ddx
F7F_asm += call_dd call_xd call_dx
/* Copyright (C) 2019-2020 Free Software Foundation, Inc.
This file is part of LIBF7, which is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#if !defined STATIC
#define STATIC /* empty */
#endif
#if USE_LPM
#define F7_CONST_DEF(NAME, FLAGS, M6, M5, M4, M3, M2, M1, M0, EXPO) \
STATIC const __attribute__((__progmem__)) \
f7_t F7_(const_ ## NAME ## _P) = \
{ .flags = FLAGS, .mant = { M0, M1, M2, M3, M4, M5, M6 }, .expo = EXPO };
#include "libf7-const.def"
#undef F7_CONST_DEF
#else
#define F7_CONST_DEF(NAME, FLAGS, M6, M5, M4, M3, M2, M1, M0, EXPO) \
STATIC const f7_t F7_(const_ ## NAME) = \
{ .flags = FLAGS, .mant = { M0, M1, M2, M3, M4, M5, M6 }, .expo = EXPO };
#include "libf7-const.def"
#undef F7_CONST_DEF
#endif // USE_LPM
#undef STATIC
# Used except --with-libf7=no
avrsrc := $(srcdir)/config/avr
libf7 := $(avrsrc)/libf7
F7_PREFIX = __f7_
include $(libf7)/libf7-common.mk
LIBF7_DF_CONV += floatundidf floatdidf # floatunsidf floatsidf
# Wrappers like f7_lt_impl for f7_lt etc. because the latter is inline.
LIBF7_DF_CMP += lt le gt ge ne eq unord
F7_C_PARTS += $(LIBF7_DF_CONV) $(LIBF7_DF_CMP)
# -mcall-prologues
CALL_PROLOGUES += $(LIBF7_DF_CONV)
# -Wno-missing-prototypes
NO_PROTO += $(LIBF7_DF_CONV)
F7F += le_impl lt_impl gt_impl ge_impl ne_impl eq_impl unord_impl
$(libf7)/f7-renames.h: $(libf7)/f7renames.sh $(libf7)/libf7-common.mk
$< head $(F7_PREFIX) t-libf7 > $@
$< c $(F7_PREFIX) $(F7F) >> $@
$< cst $(F7_PREFIX) $(F7F_cst) >> $@
$< asm $(F7_PREFIX) $(F7F_asm) >> $@
$< tail $(F7_PREFIX) >> $@
# The right-hand sides like g_ddd come from libf7-common.mk.
# The _m_ wraps are added by t-libf7-math
# __adddf3, ...
F7_ASM_WRAPS_g_ddd += $(g_ddd)
# __ltdf2, ...
F7_ASM_WRAPS_g_xdd_cmp += $(g_xdd_cmp)
# __floatsidf, ...
F7_ASM_WRAPS_g_dx += $(g_dx)
# __fixdfsi, ...
F7_ASM_WRAPS_g_xd += $(g_xd)
$(libf7)/f7-wraps.h: $(libf7)/f7wraps.sh \
$(libf7)/libf7-common.mk $(libf7)/t-libf7-math
$< header "WITH_LIBF7_MATH_FUNCTIONS=$(WITH_LIBF7_MATH_FUNCTIONS)" "WITH_LIBF7_MATH_SYMBOLS=$(WITH_LIBF7_MATH_SYMBOLS)" > $@
$< ddd_libgcc $(F7_ASM_WRAPS_g_ddd) >> $@
$< xdd_libgcc_cmp $(F7_ASM_WRAPS_g_xdd_cmp) >> $@
$< xd_libgcc $(F7_ASM_WRAPS_g_xd) >> $@
$< dx_libgcc $(F7_ASM_WRAPS_g_dx) >> $@
$< ddd_math $(F7_ASM_WRAPS_m_ddd) >> $@
$< ddx_math $(F7_ASM_WRAPS_m_ddx) >> $@
$< dd_math $(F7_ASM_WRAPS_m_dd) >> $@
$< xd_math $(F7_ASM_WRAPS_m_xd) >> $@
F7_ASM_WRAPS += $(F7_ASM_WRAPS_g_xd)
F7_ASM_WRAPS += $(F7_ASM_WRAPS_g_dx)
F7_ASM_WRAPS += $(F7_ASM_WRAPS_g_ddd)
F7_ASM_WRAPS += $(F7_ASM_WRAPS_g_xdd_cmp)
F7_ASM_WRAPS += $(F7_ASM_WRAPS_m_ddd)
F7_ASM_WRAPS += $(F7_ASM_WRAPS_m_ddx)
F7_ASM_WRAPS += $(F7_ASM_WRAPS_m_dd)
F7_ASM_WRAPS += $(F7_ASM_WRAPS_m_xd)
F7_ASM_PARTS += $(patsubst %, D_%, $(F7_ASM_WRAPS))
# Options
F7_FLAGS += -I $(libf7) -save-temps=obj
# t-avr::HOST_LIBGCC2_CFLAGS sets -mcall-prologues which will inhibits
# tail-call optimizations. The user could get it with -mrelax, but we
# just switch it off here and then explicitly on again for the
# CALL_PROLOGUES modules.
F7_C_FLAGS += $(F7_FLAGS) \
-dp -g0 \
-mno-call-prologues \
-fno-lto -Os \
-fdata-sections -ffunction-sections \
-fno-reorder-blocks \
-fno-tree-loop-optimize \
-fno-tree-loop-im -fno-move-loop-invariants
F7_ASM_FLAGS += $(F7_FLAGS)
$(patsubst %, f7_c_%.o, $(CALL_PROLOGUES)) \
: F7_C_FLAGS += -mcall-prologues
$(patsubst %, f7_c_%.o, $(STRICT_X)) \
: F7_C_FLAGS += -mstrict-X
$(patsubst %, f7_c_%.o, $(NO_PROTO)) \
: F7_C_FLAGS += -Wno-missing-prototypes
# Depends will be worked out by the libgcc build system.
F7_C_OBJECTS = $(patsubst %, f7_c_%$(objext), $(F7_C_PARTS))
F7_ASM_OBJECTS = $(patsubst %, f7_asm_%$(objext), $(F7_ASM_PARTS))
$(F7_ASM_OBJECTS) $(F7_C_OBJECTS) : $(libf7)/t-libf7
$(F7_ASM_OBJECTS) $(F7_C_OBJECTS) : $(libf7)/t-libf7-math
$(F7_ASM_OBJECTS) $(F7_C_OBJECTS) : $(libf7)/t-libf7-math-symbols
.PHONY: log_vars
all: log_vars
log_vars:
$(info # libf7: WITH_LIBF7_MATH_FUNCTIONS = $(WITH_LIBF7_MATH_FUNCTIONS))
$(info # libf7: WITH_LIBF7_MATH_SYMBOLS = $(WITH_LIBF7_MATH_SYMBOLS))
$(info # libf7: F7_C_PARTS = $(F7_C_PARTS))
$(info # libf7: F7_C_OBJECTS = $(F7_C_OBJECTS))
$(info # libf7: F7_ASM_PARTS = $(F7_ASM_PARTS))
$(info # libf7: F7_ASM_OBJECTS = $(F7_ASM_OBJECTS))
# Build the libf7 C objects and add them to libgcc.a.
f7_parts := $(F7_C_PARTS)
iter-items := $(f7_parts)
iter-labels := $(f7_parts)
include $(srcdir)/empty.mk $(patsubst %,$(libf7)/libf7-c-object.mk,$(iter-items))
libgcc-objects += $(patsubst %,f7_c_%$(objext),$(F7_C_PARTS))
# Build the libf7 ASM objects and add them to libgcc.a.
f7_parts := $(F7_ASM_PARTS)
iter-items := $(f7_parts)
iter-labels := $(f7_parts)
include $(srcdir)/empty.mk $(patsubst %,$(libf7)/libf7-asm-object.mk,$(iter-items))
libgcc-objects += $(patsubst %,f7_asm_%$(objext),$(F7_ASM_PARTS))
.PHONY: clean-f7
clean: clean-f7
clean-f7:
rm -f $(wildcard f7_*.i f7_*.s f7_*.o)
# Get rid if any DFmode remains.
LIB2FUNCS_EXCLUDE += \
_sf_to_df \
_fixdfdi \
_fixunsdfsi \
_floatundidf \
_fixunsdfdi \
_floatdidf \
_powidf2
# Triggered by --with-libf7=math or --with-libf7=math-symbols
#
# We provide weak double wrappers for functions specified in math.h,
# but with __ prepended to the symbol name used for the double function.
# For example we provide double __sin (double) but neither sin nor sinl.
# To get weak symbols according to math.h, t-libf7-math-symbols has to
# be used which is triggered by --with-libf7=math-symbols.
WITH_LIBF7_MATH_FUNCTIONS = 1
# __sin, ...
F7_ASM_WRAPS_m_dd += $(m_dd)
# __pow, __fmin, ...
F7_ASM_WRAPS_m_ddd += $(m_ddd)
# __ldexp, ...
F7_ASM_WRAPS_m_ddx += $(m_ddx)
# __lrint, ...
F7_ASM_WRAPS_m_xd += $(m_xd)
# Triggered by --with-libf7=math-symbols
#
# We have at least one module in libgcc that depends on __SIZEOF_DOUBLE__
# or __SIZEOF_LONG_DOUBLE__ which means that t-avrlibc must not copy
# double32/64 or long-double32/64 variants from the vanilla one.
# This occurs when some module(s) define(s) weak aliases for functions
# that usually live in libm.
WITH_LIBF7_MATH_SYMBOLS = 1
F7_FLAGS += -DWITH_LIBF7_MATH_SYMBOLS
...@@ -65,6 +65,12 @@ LIB2FUNCS_EXCLUDE += \ ...@@ -65,6 +65,12 @@ LIB2FUNCS_EXCLUDE += \
_fixunssfdi \ _fixunssfdi \
_floatdisf _floatundisf _floatdisf _floatundisf
ifeq (,$(WITH_LIBF7_MATH_SYMBOLS))
# No modules depend on __SIZEOF_LONG_DOUBLE__ or __SIZEOF_DOUBLE__
# which means we might have an opportunity to copy libgcc.a.
# WITH_LIBF7_MATH_SYMBOLS is set by libf7/t-libf7-math-symbols.
ifneq (,$(findstring avr,$(MULTISUBDIR))) ifneq (,$(findstring avr,$(MULTISUBDIR)))
# We are not in the avr2 (default) subdir, hence copying will work. # We are not in the avr2 (default) subdir, hence copying will work.
...@@ -95,3 +101,4 @@ Makefile: t-copy-libgcc.dep ...@@ -95,3 +101,4 @@ Makefile: t-copy-libgcc.dep
endif endif
endif endif
endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment