avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] avr-gcc 4.7 fixed-point support


From: Georg-Johann Lay
Subject: Re: [avr-gcc-list] avr-gcc 4.7 fixed-point support
Date: Sat, 25 Aug 2012 13:32:36 +0200
User-agent: Thunderbird 2.0.0.24 (Windows/20100228)

Georg-Johann Lay wrote:
Some time ago I had a private conversation with Sean on porting
his avr-gcc fixed-point support to mainline avr-gcc 4.7.

During the conversation there were several draft versions of
the work against 4.7, but suddenly the conversation stopped
and the fixed-point support ended up nowhere...

Hope that nothing serious happened.

Because I think it's a pity if all that work is lost,
I decided to post the latest version of the patch from
2012-12-13 together with the according email.

Johann

[snip]

FYI, the fixed point support is upstream and integrated into the
official GCC code repository now, cf. http://gcc.gnu.org/PR54222


Many thanks to Sean for all of his work and patience!

The type layout is as follows:


   _Fract/fract    |  unsigned |   signed
 ------------------+-----------+-----------
 short             |    0.8    |    s.7
                   |    0.16   |    s.15
 long              |    0.32   |    s.31
 long long         |    0.64   |    s.63


     _Accum/accum  |  unsigned |   signed
 ------------------+-----------+-----------
 short             |    8.8    |   s7.8
                   |   16.16   |  s15.16
 long              |   32.32   |  s31.32
 long long         |   16.48   |  s15.48


For more information on the type layouts, ranges
and precisions, cf. <stdfix.h> and gcc's built-in
macros.

Many of the routines are implemented in assembler in libgcc.

The saturated flavors are not (yet) optimized and coded
in C from GCC's fixed-bit.c, which is part of libgcc.

The conversion routines that reference float/int conversion
routines will use unoptimized versions from libgcc instead
of the optimized versions from AVR-Libc because the reference
comes from libgcc and can be resolved there.

Because AVR-Libc's contributors chose to add the code to
that library instead of to GCC, the preferred way is to
arrange GCC so that libgcc does not interfere with the float
implementation from AVR-Libc.

This is performed by the attached tentative patch which adds
support for a new GCC configure option --with-avrlibc.
This patch also fixed code size regressions where LTO uses
an other library order than assumed by the "override" mechanism
of AVR-Libc.

One more problem is that AVR-Libc supplies the core float
routines as libm and not within libc.  libm would be fine
if only stuff from math.h was contained, but libm also
contains support for the language core like float addition.


Johann

--

libgcc/
        * config.host (tmake_file && avr-*-*): Add avr/t-avrlibc if
        configured --with-avrlibc=yes
        * Makefile.in (FPBIT_FUNCS): filter-out LIB2FUNCS_EXCLUDE.
        (DPBIT_FUNCS): Ditto.
        (TPBIT_FUNCS): Ditto.
        * config/avr/t-avrlibc: New.

Index: libgcc/config.host
===================================================================
--- libgcc/config.host  (revision 190644)
+++ libgcc/config.host  (working copy)
@@ -380,6 +380,9 @@ avr-*-rtems*)
 avr-*-*)
        # Make HImode functions for AVR
        tmake_file="${cpu_type}/t-avr t-fpbit"
+       if test x$with_avrlibc = xyes; then
+           tmake_file="$tmake_file ${cpu_type}/t-avrlibc"
+       fi
        tm_file="$tm_file avr/avr-lib.h"
        ;;
 bfin*-elf*)
Index: libgcc/Makefile.in
===================================================================
--- libgcc/Makefile.in  (revision 190644)
+++ libgcc/Makefile.in  (working copy)
@@ -516,6 +516,10 @@ FPBIT_FUNCS := $(filter-out _sf_to_tf,$(
 DPBIT_FUNCS := $(filter-out _df_to_tf,$(DPBIT_FUNCS))
 endif
 
+FPBIT_FUNCS := $(filter-out $(LIB2FUNCS_EXCLUDE),$(FPBIT_FUNCS))
+DPBIT_FUNCS := $(filter-out $(LIB2FUNCS_EXCLUDE),$(DPBIT_FUNCS))
+TPBIT_FUNCS := $(filter-out $(LIB2FUNCS_EXCLUDE),$(TPBIT_FUNCS))
+
 fpbit-src := $(srcdir)/fp-bit.c
 
 # Build FPBIT.
Index: libgcc/config/avr/t-avrlibc
===================================================================
--- libgcc/config/avr/t-avrlibc (revision 0)
+++ libgcc/config/avr/t-avrlibc (revision 0)
@@ -0,0 +1,36 @@
+LIB2FUNCS_EXCLUDE += \
+       _compare_sf \
+       _eq_sf \
+       _ne_sf \
+       _gt_sf \
+       _ge_sf \
+       _lt_sf \
+       _le_sf \
+       _unord_sf \
+       \
+       _negate_sf \
+       _addsub_sf \
+       _mul_sf \
+       _div_sf \
+       \
+       _si_to_sf  _sf_to_si \
+       _usi_to_sf _sf_to_usi
+
+# DF
+LIB2FUNCS_EXCLUDE += \
+       _sf_to_df
+
+LIB2FUNCS_EXCLUDE += \
+       _fixunssfsi \
+       _fixsfdi \
+       _fixunssfdi \
+       _floatdisf \
+       _floatundisf
+
+# DF
+LIB2FUNCS_EXCLUDE += \
+       _fixdfdi \
+       _fixunsdfsi \
+       _fixunsdfdi \
+       _floatdidf \
+       _floatundidf

reply via email to

[Prev in Thread] Current Thread [Next in Thread]