]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
AVR: target/120442 - Support f7_fdim / fdiml in LibF7.
authorGeorg-Johann Lay <avr@gjlay.de>
Tue, 27 May 2025 10:03:13 +0000 (12:03 +0200)
committerGeorg-Johann Lay <avr@gjlay.de>
Tue, 27 May 2025 10:21:54 +0000 (12:21 +0200)
Add Support for fdiml.
PR target/120442
libgcc/config/avr/libf7/
* libf7-common.mk (LIBF_C_PARTS, m_ddd): Add fdim.
* libf7.h (f7_fdim): New proto.
* libf7.c (f7_fdim): New function.
* f7renames.sh (f7_fdim): Add rename.
* f7-wraps.h: Rebuild
* f7-renames.h: Rebuild

libgcc/config/avr/libf7/f7-renames.h
libgcc/config/avr/libf7/f7-wraps.h
libgcc/config/avr/libf7/f7renames.sh
libgcc/config/avr/libf7/libf7-common.mk
libgcc/config/avr/libf7/libf7.c
libgcc/config/avr/libf7/libf7.h

index bbe571a7532b15080b7a26bf53ec6f65bcf4bf52..bce2dd33e8a269d2dc5ff7324e66ecc0e85b9bae 100644 (file)
@@ -97,6 +97,7 @@
 #define f7_acos __f7_acos
 #define f7_atan __f7_atan
 #define f7_atan2 __f7_atan2
+#define f7_fdim __f7_fdim
 #define f7_mul_noround __f7_mul_noround
 #define f7_sqrt16_round __f7_sqrt16_round
 #define f7_sqrt16_floor __f7_sqrt16_floor
index a455b7dbd9ef775654f2190d7e353a3f9b00728e..409492ed1d29b2652ac089ca01bc7ee0ab9ec5d1 100644 (file)
@@ -239,7 +239,7 @@ _ENDF __extendsfdf2
 
 ;; 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:
-;; pow fmin fmax fmod hypot atan2
+;; pow fmin fmax fmod hypot atan2 fdim
 
 ;; double __pow (double, double)
 #ifdef F7MOD_D_pow_
@@ -313,6 +313,18 @@ _DEFUN __atan2
 _ENDF __atan2
 #endif /* F7MOD_D_atan2_ */
 
+;; double __fdim (double, double)
+#ifdef F7MOD_D_fdim_
+_DEFUN __fdim
+    DALIAS fdim
+    LALIAS fdiml
+    .global F7_NAME(fdim)
+    ldi     ZH,     hi8(gs(F7_NAME(fdim)))
+    ldi     ZL,     lo8(gs(F7_NAME(fdim)))
+    F7jmp   call_ddd
+_ENDF __fdim
+#endif /* F7MOD_D_fdim_ */
+
 ;; 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:
 ;; ldexp frexp
index 7ef251e44c997284ed5d02d7233a5f1aadd5f715..4ced42363d160f00f080f75d6552520be67087ee 100755 (executable)
@@ -35,9 +35,9 @@ EOF
 
     c)
         if [ x${PRE} != xf7_ ]; then
-            echo " "
+            echo ""
             echo "/* Renames for libf7.c, libf7.h.  */"
-            echo " "
+            echo ""
             for x in $*; do
                 echo "#define f7_$x ${PRE}$x"
             done
@@ -46,9 +46,9 @@ EOF
 
     cst)
         if [ x${PRE} != xf7_ ]; then
-            echo " "
+            echo ""
             echo "/* Renames for libf7.c, libf7.h.  */"
-            echo " "
+            echo ""
             for x in $*; do
                 echo "#define f7_const_${x}   ${PRE}const_${x}"
                 echo "#define f7_const_${x}_P ${PRE}const_${x}_P"
@@ -58,9 +58,9 @@ EOF
 
     asm)
         if [ x${PRE} != xf7_ ]; then
-            echo " "
+            echo ""
             echo "/* Renames for libf7-asm.sx, f7-wraps.h.  */"
-            echo " "
+            echo ""
             for x in $*; do
                 echo "#define f7_${x}_asm ${PRE}${x}_asm"
             done
index 5d411071c8e485bdeff62a61ceaeea3793182939..644be2cf195f7152f1ca04d6d006f1a6e0cb4332 100644 (file)
@@ -8,7 +8,7 @@ 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 += asinacos asin acos atan atan2 fdim
 F7_C_PARTS += abscmp_msb_ge cmp cmp_abs cmp_unordered
 
 F7_C_PARTS += const_1 const_1_2 const_1_3
@@ -34,7 +34,7 @@ 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_ddd += pow fmin fmax fmod hypot atan2 fdim
 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
@@ -59,7 +59,7 @@ 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 += asinacos asin acos atan atan2 fdim
 F7F += mul_noround sqrt16_round sqrt16_floor
 F7F += clr_mant_lsbs abscmp_msb_ge lshrdi3 ashldi3
 F7F += assert
index 7d70804a59adb5984531d93f47cfc1b71a049793..78c218a421bb07276d36b7a25c0de4fe2de67f72 100644 (file)
@@ -928,6 +928,21 @@ void f7_sub (f7_t *cc, const f7_t *aa, const f7_t *bb)
 #endif // F7MOD_sub_
 
 
+#ifdef F7MOD_fdim_
+F7_WEAK
+void f7_fdim (f7_t *cc, const f7_t *aa, const f7_t *bb)
+{
+  int8_t cmp = f7_cmp_unordered (aa, bb, true /*with_sign*/);
+  if (cmp == INT8_MIN)
+    return f7_set_nan (cc);
+  if (cmp < 0)
+    return f7_clr (cc);
+
+  f7_sub (cc, aa, bb);
+}
+#endif // F7MOD_fdim_
+
+
 #ifdef F7MOD_addsub_
 static void return_with_sign (f7_t *cc, const f7_t *aa, int8_t c_sign)
 {
index 8aa91c796d2e4d82378ac072cb3cd5a0c573437c..786e141eafff74abdb85dfe7ba7d39db71806a69 100644 (file)
@@ -612,6 +612,7 @@ extern void f7_cos (f7_t*, const f7_t*);
 extern void f7_tan (f7_t*, const f7_t*);
 extern void f7_atan (f7_t*, const f7_t*);
 extern void f7_atan2 (f7_t*, const f7_t*, const f7_t*);
+extern void f7_fdim (f7_t*, const f7_t*, const f7_t*);
 extern void f7_asin (f7_t*, const f7_t*);
 extern void f7_acos (f7_t*, const f7_t*);
 extern void f7_tanh (f7_t*, const f7_t*);