This patch adds fdiml to libgcc/config/avr/libf7

AVR: target/120442 - Support f7_fdim / fdiml in LibF7.

        PR target/120442
        Add Support for fdiml.
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
    AVR: target/120442 - Support f7_fdim / fdiml in LibF7.
    
            PR target/120442
            Add Support for fdiml.
    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

diff --git a/libgcc/config/avr/libf7/f7-renames.h b/libgcc/config/avr/libf7/f7-renames.h
index bbe571a7532..bce2dd33e8a 100644
--- a/libgcc/config/avr/libf7/f7-renames.h
+++ b/libgcc/config/avr/libf7/f7-renames.h
@@ -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
diff --git a/libgcc/config/avr/libf7/f7-wraps.h b/libgcc/config/avr/libf7/f7-wraps.h
index a455b7dbd9e..409492ed1d2 100644
--- a/libgcc/config/avr/libf7/f7-wraps.h
+++ b/libgcc/config/avr/libf7/f7-wraps.h
@@ -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
diff --git a/libgcc/config/avr/libf7/f7renames.sh b/libgcc/config/avr/libf7/f7renames.sh
index 7ef251e44c9..4ced42363d1 100755
--- a/libgcc/config/avr/libf7/f7renames.sh
+++ b/libgcc/config/avr/libf7/f7renames.sh
@@ -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
diff --git a/libgcc/config/avr/libf7/libf7-common.mk b/libgcc/config/avr/libf7/libf7-common.mk
index 5d411071c8e..644be2cf195 100644
--- a/libgcc/config/avr/libf7/libf7-common.mk
+++ b/libgcc/config/avr/libf7/libf7-common.mk
@@ -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
diff --git a/libgcc/config/avr/libf7/libf7.c b/libgcc/config/avr/libf7/libf7.c
index 7d70804a59a..78c218a421b 100644
--- a/libgcc/config/avr/libf7/libf7.c
+++ b/libgcc/config/avr/libf7/libf7.c
@@ -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)
 {
diff --git a/libgcc/config/avr/libf7/libf7.h b/libgcc/config/avr/libf7/libf7.h
index 8aa91c796d2..786e141eaff 100644
--- a/libgcc/config/avr/libf7/libf7.h
+++ b/libgcc/config/avr/libf7/libf7.h
@@ -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*);

Reply via email to