Commit Graph

18 Commits

Author SHA1 Message Date
Georg-Johann Lay 40ca3cdefc AVR: target/122220 - Let (int32_t) -0x1p31L return INT32_MIN.
PR target/122220
libgcc/config/avr/libf7/
	* libf7-asm.sx (to_integer): Return 0x80... on negative overflow.

gcc/testsuite/
	* gcc.target/avr/pr122220.c: New test.

(cherry picked from commit 3ea09e4d43)
2025-10-09 22:18:43 +02:00
Georg-Johann Lay bbc7b4c9b9 AVR: target/122210 - Add double -> fixed-point conversions.
PR target/122210
libgcc/config/avr/libf7/
	* libf7-common.mk (F7_ASM_PARTS): Add D2<fx> modules.
	* libf7-asm.sx: Implement the D2<fx> modules.

gcc/testsuite/
	* gcc.target/avr/dtofx.c: New test.

(cherry picked from commit b0bc615d93)
2025-10-09 22:18:42 +02:00
Georg-Johann Lay dbd8c4e000 AVR: target/122210 - Add fixed-point -> double conversions.
PR target/122210
libgcc/config/avr/libf7/
	* libf7-common.mk (F7_ASM_PARTS): Add <fx>2D modules.
	* libf7-asm.sx: Implement the <fx>2D modules.

gcc/testsuite/
	* gcc.target/avr/fxtod.c: New test.

(cherry picked from commit 7304e83f1f)
2025-10-09 22:18:42 +02:00
Georg-Johann Lay 9eec8783e7 AVR/LibF7: Implement sincos.
libgcc/config/avr/libf7/
	* libf7-common.mk (F7_ASM_PARTS): Add D_sincos.
	* libf7-asm.sx: (D_sincos): New module implements sincos / sincosl.

gcc/testsuite/
	* gcc.target/avr/sincos-1.c: New test.

(cherry picked from commit e3a05e0502)
2025-10-09 22:18:41 +02:00
Georg-Johann Lay 1b05992fe0 AVR/LibF7: target/122177 - fix fmin / fmax return value for one NaN arg.
fmin and fmax should return the non-NaN argument in the case where
exactly one argument is a NaN.

Moreover, IEEE double fmin and fmax can be performed without
first converting the args to the internal representation and
then converting back again.

	PR target/122177
libgcc/config/avr/libf7/
	* libf7-common.mk (m_ddd): Remove: fmin, fmax.
	(F7_ASM_PARTS): Add: D_fminfmax.
	* libf7-asm.sx (D_fmanfmax): New module.
	* f7-wraps.h: Rebuild.

gcc/testsuite/
	* gcc.target/avr/fminfmax-1.c: New test.

(cherry picked from commit efb3cd64fd)
2025-10-09 22:18:40 +02:00
Georg-Johann Lay d9eb1657f7 AVR: Speed up IEEE double comparisons.
IEEE double can be compared without first converting them to
the internal representation.

libgcc/config/avr/libf7/
	* libf7-common.mk (g_xdd_cmp): Remove le, lt, ge, gt, ne, eq, unord.
	(F7_ASM_PARTS): Add D_cmp, D_eq, D_ne, D_ge, D_gt, D_le, D_lt, D_unord.
	* libf7-asm.sx (D_cmp, D_eq, D_ne, D_ge, D_gt, D_le, D_lt, D_unord):
	New modules.
	* f7-wraps.h: Rebuild.

gcc/testsuite/
	* gcc.target/avr/cmpdi-1.c: New test.

(cherry picked from commit e5731a4bc5)
2025-10-09 22:18:39 +02:00
Georg-Johann Lay d7f42794d9 AVR: target/115317 - Make isinf(-Inf) return -1.
PR target/115317
libgcc/config/avr/libf7/
	* libf7-asm.sx (__isinf): Map -Inf to -1.

gcc/testsuite/
	* gcc.target/avr/torture/pr115317-isinf.c: New test.

(cherry picked from commit f12454278d)
2024-06-01 12:52:26 +02:00
Georg-Johann Lay a9e313ed38 AVR: target/114981 - Support __builtin_powi[l] / __powidf2.
This supports __powidf2 by means of a double wrapper for already
existing f7_powi (renamed to __f7_powi by f7-renames.h).
It tweaks the implementation so that it does not perform trivial
multiplications with 1.0 any more, but instead uses a move.
It also fixes the last statement of f7_powi, which was wrong.
Notice that f7_powi was unused until now.

	PR target/114981
libgcc/config/avr/libf7/
	* libf7-common.mk (F7_ASM_PARTS): Add D_powi
	* libf7-asm.sx (F7MOD_D_powi_, __powidf2): New module and function.
	* libf7.c (f7_powi): Fix last (wrong) statement.
	Tweak trivial multiplications with 1.0.

gcc/testsuite/
	* gcc.target/avr/pr114981-powil.c: New test.

(cherry picked from commit de4eea7d7e)
2024-05-09 10:13:54 +02:00
Jakub Jelinek a945c346f5 Update copyright years. 2024-01-03 12:19:35 +01:00
Georg-Johann Lay 3a5a30792f LibF7: Use paper-pencil method for sqrt instead of Newton-Raphson iteration.
libgcc/config/avr/libf7/
	* libf7-asm.sx (sqrt_approx): Rewrite.
	* libf7.c (f7_sqrt): Use it instead of sqrt_worker.
	(sqrt_worker): Remove.
2023-11-12 15:58:02 +01:00
Georg-Johann Lay f7da59104c LibF7: Tweak IEEE double multiplication.
libgcc/config/avr/libf7/
	* libf7-asm.sx (mul_mant) [AVR_HAVE_MUL]: Tweak code.
2023-11-08 12:45:25 +01:00
Georg-Johann Lay 67f7bf78ba LibF7: Implement mul_mant for devices without MUL instruction.
libgcc/config/avr/libf7/
	* libf7-asm.sx (mul_mant): Implement for devices without MUL.
	* asm-defs.h (wmov) [!HAVE_MUL]: Fix regno computation.
	* t-libf7 (F7_ASM_FLAGS): Add -g0.
2023-10-18 19:00:09 +02:00
Georg-Johann Lay c4e773b4cc LibF7: Implement fma / fmal.
libgcc/config/avr/libf7/
	* libf7.h (F7_SIZEOF): New macro.
	* libf7-asm.sx: Use F7_SIZEOF instead of magic number "10".
	(F7MOD_D_fma_, __fma): New module and function.
	(fma) [-mdouble=64]: Define as alias for __fma.
	(fmal) [-mlong-double=64]: Define as alias for __fma.
	* libf7-common.mk (F7_ASM_PARTS): Add D_fma.
2023-10-17 11:45:22 +02:00
Jakub Jelinek 83ffe9cde7 Update copyright years. 2023-01-16 11:52:17 +01:00
Georg-Johann Lay 0b5b8ac5cb Fix PR target/99184: Wrong cast from double to 16-bit and 32-bit ints
this patch fixed PR target/99184 which incorrectly rounded during 64-bit
(long) double to 16-bit and 32-bit integers.

The patch just removes the respective roundings from
libf7-asm.sx::to_integer and ::to_unsigned.  Luckily, LibF7 does nowhere
use respective functions internally, the only user is in libf7.c::f7_exp

which reads

   f7_round (qq, qq);
   int16_t q = f7_get_s16 (qq);

so that f7_get_s16() operates on an already rounded value, and therefore
this code works unaltered with or without rounding in to_integer.

	PR target/99184
libgcc/config/avr/libf7/
	* libf7-asm.sx (to_integer, to_unsigned): Don't round 16-bit
	and 32-bit integers.
2022-09-19 09:50:28 +02:00
Jakub Jelinek 7adcbafe45 Update copyright years. 2022-01-03 10:42:10 +01:00
Jakub Jelinek 99dee82307 Update copyright years. 2021-01-04 10:26:59 +01:00
Georg-Johann Lay f30dd60766 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
2020-01-08 09:31:07 +00:00