Re: [patch][avr] PR92055: Add switches to enable 64-bit [long] double.

2019-11-25 Thread Georg-Johann Lay

Am 06.11.19 um 23:32 schrieb Jeff Law:

On 10/31/19 3:55 PM, Georg-Johann Lay wrote:

Hi, this adds the possibility to enable IEEE compatible double
and long double support in avr-gcc.

It supports 2 configure options

--with-double={32|64|32,64|64,32}
--with-long-double={32|64|32,64|64,32|double}

which select the default layout of these types and also chose
which mutlilib variants are built and available.

These two config option map to the new compiler options
-mdouble= and -mlong-double= which are new multilib options.

The patch only deals with option handling and multilib bits,
it does not add any double functionality.  The double support
functions are supposed to be provided by avr-libc which also hosts
all the float stuff, including __addsf3 etc.

Ok for trunk?

Johann


gcc/
 Support 64-bit double and 64-bit long double configurations.

 PR target/92055
 * config.gcc (tm_defines) [avr]: Set from --with-double=,
 --with-long-double=.
 * config/avr/t-multilib: Remove.
 * config/avr/t-avr: Output of genmultilib.awk is now fully
 dynamically generated and no more part of the repo.
 (HAVE_DOUBLE_MULTILIB, HAVE_LONG_DOUBLE_MULTILIB): New variables.
 Pass them down to...
 * config/avr/genmultilib.awk: ...here and handle them.
 * gcc/config/avr/avr.opt (-mdouble=, avr_double). New option and var.
 (-mlong-double=, avr_long_double). New option and var.
 * common/config/avr/avr-common.c (opts.h): Include.
 (diagnostic.h): Include.
 (TARGET_OPTION_OPTIMIZATION_TABLE) -mdouble=: Set default as
 requested by --with-double=.
 -mlong-double=: Set default as requested by --with-long-double=.

 (TARGET_OPTION_OPTIMIZATION_TABLE) -mdouble=, -mlong-double=:
 Set default as requested by --with-double=
 (TARGET_HANDLE_OPTION): Define to this...
 (avr_handle_option): ...new hook worker.
 * config/avr/avr.h (DOUBLE_TYPE_SIZE): Define to avr_double.
 (LONG_DOUBLE_TYPE_SIZE): Define to avr_long_double.
 (avr_double_lib): New proto for spec function.
 (EXTRA_SPEC_FUNCTIONS) double-lib: Add.
 (DRIVER_SELF_SPECS): Call %:double-lib.
 * config/avr/avr.c (avr_option_override): Assert
 sizeof(long double) = sizeof(double) for the target.
 * config/avr/avr-c.c (avr_cpu_cpp_builtins)
 [__HAVE_DOUBLE_MULTILIB__, __HAVE_LONG_DOUBLE_MULTILIB__]
 [__HAVE_DOUBLE64__, __HAVE_DOUBLE32__, __DEFAULT_DOUBLE__=]
 [__HAVE_LONG_DOUBLE64__, __HAVE_LONG_DOUBLE32__]
 [__HAVE_LONG_DOUBLE_IS_DOUBLE__, __DEFAULT_LONG_DOUBLE__=]:
 New built-in defined depending on --with-double=, --with-long-double=.
 * config/avr/driver-avr.c (avr_double_lib): New spec function.
 * doc/invoke.tex (AVR Options) -mdouble=,-mlong-double=: Doc.

libgcc/
 Support 64-bit double and 64-bit long double configurations.

 PR target/92055
 * config/avr/t-avr (HOST_LIBGCC2_CFLAGS): Only add -DF=SF if
 long double is a 32-bit type.
 * config/avr/t-avrlibc: Copy double64 and long-double64
 multilib(s) from the vanilla one.
 * config/avr/t-copy-libgcc: New Makefile snip.


OK
jeff


Hi, I applied the following patch which also treats -m[long-]double=32 
as multilib options provided the default is -m[long-]double=64.  It 
changes the t-multilib-avr build script (and the options that are fed in).


Applied as SVN r278668.

Johann


gcc/
Build double32 / long-double32 multilibs if needed.

PR target/92055
* config/avr/t-avr:
(HAVE_DOUBLE_MULTILIB, HAVE_LONG_DOUBLE_MULTILIB): Remove vars.
(HAVE_DOUBLE32, HAVE_LONG_DOUBLE32, WITH_LONG_DOUBLE)
(HAVE_DOUBLE64, HAVE_LONG_DOUBLE64, WITH_DOUBLE): Set from
tm_defines and pass to genmultilib.awk.
* config/avr/genmultilib.awk: Use these variables to add double32
and / or long-double32 multilib(s) as needed.
* config/avr/driver-avr.c (avr_double_lib): Adjust comment.

Index: config/avr/t-avr
===
--- config/avr/t-avr	(revision 278552)
+++ config/avr/t-avr	(working copy)
@@ -16,8 +16,27 @@
 # along with GCC; see the file COPYING3.  If not see
 # .
 
-HAVE_DOUBLE_MULTILIB = $(findstring HAVE_DOUBLE_MULTILIB, $(tm_defines))
-HAVE_LONG_DOUBLE_MULTILIB = $(findstring HAVE_LONG_DOUBLE_MULTILIB, $(tm_defines))
+HAVE_DOUBLE32 = $(findstring HAVE_DOUBLE32, $(tm_defines))
+HAVE_DOUBLE64 = $(findstring HAVE_DOUBLE64, $(tm_defines))
+HAVE_LONG_DOUBLE32 = $(findstring HAVE_LONG_DOUBLE32, $(tm_defines))
+HAVE_LONG_DOUBLE64 = $(findstring HAVE_LONG_DOUBLE64, $(tm_defines))
+HAVE_LONG_DOUBLE_IS_DOUBLE = $(findstring HAVE_LONG_DOUBLE_IS_DOUBLE, $(tm_defines))
+
+ifeq (WITH_DOUBLE32, $(findstring WITH_DOUBLE32, $(tm_defines)))
+WITH_DOUBLE=32
+endif
+
+ifeq (WITH_DOUBLE64, $(findstring WITH_DOUBLE64, $(tm_defines)))
+WITH_DOUBLE=64
+endif
+
+ifeq (WITH_LONG_DOUBLE32, $(findstring WITH_LONG_DOUBLE32, $(tm_defines)))

Re: [patch][avr] PR92055: Add switches to enable 64-bit [long] double.

2019-11-07 Thread Georg-Johann Lay

Am 07.11.19 um 13:49 schrieb Martin Liška:

On 11/7/19 1:39 PM, Georg-Johann Lay wrote:

Am 07.11.19 um 10:41 schrieb Martin Liška:

Hello.

I've noticed quite some GNU coding style violations with your patch.
Please next time, use something like:

$ git diff HEAD~ > /tmp/patch && ./contrib/check_GNU_style.py /tmp/patch

Thanks,
Martin



hm, I am actually using GNU style with Emacs...

You mean the lines > 80 chars in config.gcc?

I assumed that is no issue because there are already quite some lines 
that don't follow the < 80 rule.


That's fine. I'm mainly talking about:

=== ERROR type #1: blocks of 8 spaces should be replaced with tabs (45 
error(s)) ===
gcc/common/config/avr/avr-common.c:78:0:   const struct 
cl_decoded_option *decoded, location_t loc)

gcc/common/config/avr/avr-common.c:86:0:{
gcc/common/config/avr/avr-common.c:88:0:  error_at (loc, "option 
%<-mdouble=64%> is only available if "
gcc/common/config/avr/avr-common.c:89:0:    "configured 
%<--with-double={64|64,32|32,64}%>");
gcc/common/config/avr/avr-common.c:91:0:  
opts->x_avr_long_double = 64;

gcc/common/config/avr/avr-common.c:92:0:}
gcc/common/config/avr/avr-common.c:94:0:{
...

Martin


My intention was to avoid a mixup of TABs and spaces mode, because
the avr backend is indented with spaces. So the indentation picks
up the style from the context (just like ypi would do it in Python
to avoid dreaded mixing of tabs ans spaces). Tabyfying the complete
sources is also something which I didn't consider, because that
makes porting much harder...

Johann



Re: [patch][avr] PR92055: Add switches to enable 64-bit [long] double.

2019-11-07 Thread Martin Liška

On 11/7/19 1:39 PM, Georg-Johann Lay wrote:

Am 07.11.19 um 10:41 schrieb Martin Liška:

Hello.

I've noticed quite some GNU coding style violations with your patch.
Please next time, use something like:

$ git diff HEAD~ > /tmp/patch && ./contrib/check_GNU_style.py /tmp/patch

Thanks,
Martin



hm, I am actually using GNU style with Emacs...

You mean the lines > 80 chars in config.gcc?

I assumed that is no issue because there are already quite some lines that don't 
follow the < 80 rule.


That's fine. I'm mainly talking about:

=== ERROR type #1: blocks of 8 spaces should be replaced with tabs (45 
error(s)) ===
gcc/common/config/avr/avr-common.c:78:0:   const struct 
cl_decoded_option *decoded, location_t loc)
gcc/common/config/avr/avr-common.c:86:0:{
gcc/common/config/avr/avr-common.c:88:0:  error_at (loc, "option 
%<-mdouble=64%> is only available if "
gcc/common/config/avr/avr-common.c:89:0:"configured 
%<--with-double={64|64,32|32,64}%>");
gcc/common/config/avr/avr-common.c:91:0:  opts->x_avr_long_double = 64;
gcc/common/config/avr/avr-common.c:92:0:}
gcc/common/config/avr/avr-common.c:94:0:{
...

Martin



Johann





Re: [patch][avr] PR92055: Add switches to enable 64-bit [long] double.

2019-11-07 Thread Georg-Johann Lay

Am 07.11.19 um 10:41 schrieb Martin Liška:

Hello.

I've noticed quite some GNU coding style violations with your patch.
Please next time, use something like:

$ git diff HEAD~ > /tmp/patch && ./contrib/check_GNU_style.py /tmp/patch

Thanks,
Martin



hm, I am actually using GNU style with Emacs...

You mean the lines > 80 chars in config.gcc?

I assumed that is no issue because there are already quite some lines 
that don't follow the < 80 rule.


Johann



Re: [patch][avr] PR92055: Add switches to enable 64-bit [long] double.

2019-11-07 Thread Martin Liška

Hello.

I've noticed quite some GNU coding style violations with your patch.
Please next time, use something like:

$ git diff HEAD~ > /tmp/patch && ./contrib/check_GNU_style.py /tmp/patch

Thanks,
Martin


Re: [patch][avr] PR92055: Add switches to enable 64-bit [long] double.

2019-11-06 Thread Jeff Law
On 10/31/19 3:55 PM, Georg-Johann Lay wrote:
> Hi, this adds the possibility to enable IEEE compatible double
> and long double support in avr-gcc.
> 
> It supports 2 configure options
> 
> --with-double={32|64|32,64|64,32}
> --with-long-double={32|64|32,64|64,32|double}
> 
> which select the default layout of these types and also chose
> which mutlilib variants are built and available.
> 
> These two config option map to the new compiler options
> -mdouble= and -mlong-double= which are new multilib options.
> 
> The patch only deals with option handling and multilib bits,
> it does not add any double functionality.  The double support
> functions are supposed to be provided by avr-libc which also hosts
> all the float stuff, including __addsf3 etc.
> 
> Ok for trunk?
> 
> Johann
> 
> 
> gcc/
> Support 64-bit double and 64-bit long double configurations.
> 
> PR target/92055
> * config.gcc (tm_defines) [avr]: Set from --with-double=,
> --with-long-double=.
> * config/avr/t-multilib: Remove.
> * config/avr/t-avr: Output of genmultilib.awk is now fully
> dynamically generated and no more part of the repo.
> (HAVE_DOUBLE_MULTILIB, HAVE_LONG_DOUBLE_MULTILIB): New variables.
> Pass them down to...
> * config/avr/genmultilib.awk: ...here and handle them.
> * gcc/config/avr/avr.opt (-mdouble=, avr_double). New option and var.
> (-mlong-double=, avr_long_double). New option and var.
> * common/config/avr/avr-common.c (opts.h): Include.
> (diagnostic.h): Include.
> (TARGET_OPTION_OPTIMIZATION_TABLE) -mdouble=: Set default as
> requested by --with-double=.
> -mlong-double=: Set default as requested by --with-long-double=.
> 
> (TARGET_OPTION_OPTIMIZATION_TABLE) -mdouble=, -mlong-double=:
> Set default as requested by --with-double=
> (TARGET_HANDLE_OPTION): Define to this...
> (avr_handle_option): ...new hook worker.
> * config/avr/avr.h (DOUBLE_TYPE_SIZE): Define to avr_double.
> (LONG_DOUBLE_TYPE_SIZE): Define to avr_long_double.
> (avr_double_lib): New proto for spec function.
> (EXTRA_SPEC_FUNCTIONS) double-lib: Add.
> (DRIVER_SELF_SPECS): Call %:double-lib.
> * config/avr/avr.c (avr_option_override): Assert
> sizeof(long double) = sizeof(double) for the target.
> * config/avr/avr-c.c (avr_cpu_cpp_builtins)
> [__HAVE_DOUBLE_MULTILIB__, __HAVE_LONG_DOUBLE_MULTILIB__]
> [__HAVE_DOUBLE64__, __HAVE_DOUBLE32__, __DEFAULT_DOUBLE__=]
> [__HAVE_LONG_DOUBLE64__, __HAVE_LONG_DOUBLE32__]
> [__HAVE_LONG_DOUBLE_IS_DOUBLE__, __DEFAULT_LONG_DOUBLE__=]:
> New built-in defined depending on --with-double=, --with-long-double=.
> * config/avr/driver-avr.c (avr_double_lib): New spec function.
> * doc/invoke.tex (AVR Options) -mdouble=,-mlong-double=: Doc.
> 
> libgcc/
> Support 64-bit double and 64-bit long double configurations.
> 
> PR target/92055
> * config/avr/t-avr (HOST_LIBGCC2_CFLAGS): Only add -DF=SF if
> long double is a 32-bit type.
> * config/avr/t-avrlibc: Copy double64 and long-double64
> multilib(s) from the vanilla one.
> * config/avr/t-copy-libgcc: New Makefile snip.
> 
OK
jeff



Re: Ping^1 [patch][avr] PR92055: Add switches to enable 64-bit [long] double.

2019-11-06 Thread Georg-Johann Lay

Am 06.11.19 um 11:39 schrieb Georg-Johann Lay:

Ping #1

Am 31.10.19 um 22:55 schrieb Georg-Johann Lay:

Hi, this adds the possibility to enable IEEE compatible double
and long double support in avr-gcc.

It supports 2 configure options

--with-double={32|64|32,64|64,32}
--with-long-double={32|64|32,64|64,32|double}

which select the default layout of these types and also chose
which mutlilib variants are built and available.

These two config option map to the new compiler options
-mdouble= and -mlong-double= which are new multilib options.

The patch only deals with option handling and multilib bits,
it does not add any double functionality.  The double support
functions are supposed to be provided by avr-libc which also hosts
all the float stuff, including __addsf3 etc.

Ok for trunk?

Johann


..and here is the addendum that documents the new configure options.

Index: gcc/doc/install.texi
===
--- gcc/doc/install.texi(revision 277236)
+++ gcc/doc/install.texi(working copy)
@@ -2277,15 +2277,45 @@ omitted from @file{libgcc.a} on the assu
 @samp{newlib}.

 @item --with-avrlibc
-Specifies that @samp{AVR-Libc} is
-being used as the target C library.  This causes float support
+Only supported for the AVR target. Specifies that @samp{AVR-Libc} is
+being used as the target C@tie{} library.  This causes float support
 functions like @code{__addsf3} to be omitted from @file{libgcc.a} on
 the assumption that it will be provided by @file{libm.a}.  For more
 technical details, cf. @uref{http://gcc.gnu.org/PR54461,,PR54461}.
-This option is only supported for the AVR target.  It is not supported for
+It is not supported for
 RTEMS configurations, which currently use newlib.  The option is
 supported since version 4.7.2 and is the default in 4.8.0 and newer.

+@item --with-double=@{32|64|32,64|64,32@}
+@itemx --with-long-double=@{32|64|32,64|64,32|double@}
+Only supported for the AVR target since version@tie{}10.
+Specify the default layout available for the C/C++ @samp{double}
+and @samp{long double} type, respectively. The following rules apply:
+@itemize
+@item
+The first value after the @samp{=} specifies the default layout (in bits)
+of the type and also the default for the @option{-mdouble=} resp.
+@option{-mlong-double=} compiler option.
+@item
+If more than one value is specified, respective multilib variants are
+available, and  @option{-mdouble=} resp. @option{-mlong-double=} acts
+as a multilib option.
+@item
+If @option{--with-long-double=double} is specified, @samp{double} and
+@samp{long double} will have the same layout.
+@item
+If the configure option is not set, it defaults to @samp{32} which
+is compatible with older versions of the compiler that use non-standard
+32-bit types for @samp{double} and @samp{long double}.
+@end itemize
+Not all combinations of @option{--with-double=} and
+@option{--with-long-double=} are valid.  For example, the combination
+@option{--with-double=32,64} @option{--with-long-double=32} will be
+rejected because the first option specifies the availability of
+multilibs for @samp{double}, whereas the second option implies
+that @samp{long double} --- and hence also @samp{double} --- is always
+32@tie{}bits wide.
+
 @item --with-nds32-lib=@var{library}
 Specifies that @var{library} setting is used for building @file{libgcc.a}.
 Currently, the valid @var{library} is @samp{newlib} or @samp{mculib}.


Ping^1 [patch][avr] PR92055: Add switches to enable 64-bit [long] double.

2019-11-06 Thread Georg-Johann Lay

Ping #1

Am 31.10.19 um 22:55 schrieb Georg-Johann Lay:

Hi, this adds the possibility to enable IEEE compatible double
and long double support in avr-gcc.

It supports 2 configure options

--with-double={32|64|32,64|64,32}
--with-long-double={32|64|32,64|64,32|double}

which select the default layout of these types and also chose
which mutlilib variants are built and available.

These two config option map to the new compiler options
-mdouble= and -mlong-double= which are new multilib options.

The patch only deals with option handling and multilib bits,
it does not add any double functionality.  The double support
functions are supposed to be provided by avr-libc which also hosts
all the float stuff, including __addsf3 etc.

Ok for trunk?

Johann


gcc/
 Support 64-bit double and 64-bit long double configurations.

 PR target/92055
 * config.gcc (tm_defines) [avr]: Set from --with-double=,
 --with-long-double=.
 * config/avr/t-multilib: Remove.
 * config/avr/t-avr: Output of genmultilib.awk is now fully
 dynamically generated and no more part of the repo.
 (HAVE_DOUBLE_MULTILIB, HAVE_LONG_DOUBLE_MULTILIB): New variables.
 Pass them down to...
 * config/avr/genmultilib.awk: ...here and handle them.
 * gcc/config/avr/avr.opt (-mdouble=, avr_double). New option and var.
 (-mlong-double=, avr_long_double). New option and var.
 * common/config/avr/avr-common.c (opts.h): Include.
 (diagnostic.h): Include.
 (TARGET_OPTION_OPTIMIZATION_TABLE) -mdouble=: Set default as
 requested by --with-double=.
 -mlong-double=: Set default as requested by 
--with-long-double=.

 (TARGET_OPTION_OPTIMIZATION_TABLE) -mdouble=, -mlong-double=:
 Set default as requested by --with-double=
 (TARGET_HANDLE_OPTION): Define to this...
 (avr_handle_option): ...new hook worker.
 * config/avr/avr.h (DOUBLE_TYPE_SIZE): Define to avr_double.
 (LONG_DOUBLE_TYPE_SIZE): Define to avr_long_double.
 (avr_double_lib): New proto for spec function.
 (EXTRA_SPEC_FUNCTIONS) double-lib: Add.
 (DRIVER_SELF_SPECS): Call %:double-lib.
 * config/avr/avr.c (avr_option_override): Assert
 sizeof(long double) = sizeof(double) for the target.
 * config/avr/avr-c.c (avr_cpu_cpp_builtins)
 [__HAVE_DOUBLE_MULTILIB__, __HAVE_LONG_DOUBLE_MULTILIB__]
 [__HAVE_DOUBLE64__, __HAVE_DOUBLE32__, __DEFAULT_DOUBLE__=]
 [__HAVE_LONG_DOUBLE64__, __HAVE_LONG_DOUBLE32__]
 [__HAVE_LONG_DOUBLE_IS_DOUBLE__, __DEFAULT_LONG_DOUBLE__=]:
 New built-in defined depending on --with-double=, --with-long-double=.
 * config/avr/driver-avr.c (avr_double_lib): New spec function.
 * doc/invoke.tex (AVR Options) -mdouble=,-mlong-double=: Doc.

libgcc/
 Support 64-bit double and 64-bit long double configurations.

 PR target/92055
 * config/avr/t-avr (HOST_LIBGCC2_CFLAGS): Only add -DF=SF if
 long double is a 32-bit type.
 * config/avr/t-avrlibc: Copy double64 and long-double64
 multilib(s) from the vanilla one.
 * config/avr/t-copy-libgcc: New Makefile snip.




[patch][avr] PR92055: Add switches to enable 64-bit [long] double.

2019-10-31 Thread Georg-Johann Lay

Hi, this adds the possibility to enable IEEE compatible double
and long double support in avr-gcc.

It supports 2 configure options

--with-double={32|64|32,64|64,32}
--with-long-double={32|64|32,64|64,32|double}

which select the default layout of these types and also chose
which mutlilib variants are built and available.

These two config option map to the new compiler options
-mdouble= and -mlong-double= which are new multilib options.

The patch only deals with option handling and multilib bits,
it does not add any double functionality.  The double support
functions are supposed to be provided by avr-libc which also hosts
all the float stuff, including __addsf3 etc.

Ok for trunk?

Johann


gcc/
Support 64-bit double and 64-bit long double configurations.

PR target/92055
* config.gcc (tm_defines) [avr]: Set from --with-double=,
--with-long-double=.
* config/avr/t-multilib: Remove.
* config/avr/t-avr: Output of genmultilib.awk is now fully
dynamically generated and no more part of the repo.
(HAVE_DOUBLE_MULTILIB, HAVE_LONG_DOUBLE_MULTILIB): New variables.
Pass them down to...
* config/avr/genmultilib.awk: ...here and handle them.
* gcc/config/avr/avr.opt (-mdouble=, avr_double). New option and var.
(-mlong-double=, avr_long_double). New option and var.
* common/config/avr/avr-common.c (opts.h): Include.
(diagnostic.h): Include.
(TARGET_OPTION_OPTIMIZATION_TABLE) -mdouble=: Set default as
requested by --with-double=.
-mlong-double=: Set default as requested by --with-long-double=.
(TARGET_OPTION_OPTIMIZATION_TABLE) -mdouble=, -mlong-double=:
Set default as requested by --with-double=
(TARGET_HANDLE_OPTION): Define to this...
(avr_handle_option): ...new hook worker.
* config/avr/avr.h (DOUBLE_TYPE_SIZE): Define to avr_double.
(LONG_DOUBLE_TYPE_SIZE): Define to avr_long_double.
(avr_double_lib): New proto for spec function.
(EXTRA_SPEC_FUNCTIONS) double-lib: Add.
(DRIVER_SELF_SPECS): Call %:double-lib.
* config/avr/avr.c (avr_option_override): Assert
sizeof(long double) = sizeof(double) for the target.
* config/avr/avr-c.c (avr_cpu_cpp_builtins)
[__HAVE_DOUBLE_MULTILIB__, __HAVE_LONG_DOUBLE_MULTILIB__]
[__HAVE_DOUBLE64__, __HAVE_DOUBLE32__, __DEFAULT_DOUBLE__=]
[__HAVE_LONG_DOUBLE64__, __HAVE_LONG_DOUBLE32__]
[__HAVE_LONG_DOUBLE_IS_DOUBLE__, __DEFAULT_LONG_DOUBLE__=]:
New built-in defined depending on --with-double=, --with-long-double=.
* config/avr/driver-avr.c (avr_double_lib): New spec function.
* doc/invoke.tex (AVR Options) -mdouble=,-mlong-double=: Doc.

libgcc/
Support 64-bit double and 64-bit long double configurations.

PR target/92055
* config/avr/t-avr (HOST_LIBGCC2_CFLAGS): Only add -DF=SF if
long double is a 32-bit type.
* config/avr/t-avrlibc: Copy double64 and long-double64
multilib(s) from the vanilla one.
* config/avr/t-copy-libgcc: New Makefile snip.




Index: gcc/common/config/avr/avr-common.c
===
--- gcc/common/config/avr/avr-common.c  (revision 277236)
+++ gcc/common/config/avr/avr-common.c  (working copy)
@@ -23,6 +23,8 @@
 #include "tm.h"
 #include "common/common-target.h"
 #include "common/common-target-def.h"
+#include "opts.h"
+#include "diagnostic.h"
 
 /* Implement TARGET_OPTION_OPTIMIZATION_TABLE.  */
 static const struct default_options avr_option_optimization_table[] =
@@ -43,9 +45,97 @@ static const struct default_options avr_
performance decrease. For the AVR though, disallowing data races
introduces additional code in LIM and increases reg pressure.  */
 { OPT_LEVELS_ALL, OPT_fallow_store_data_races, NULL, 1 },
+
+#if defined (WITH_DOUBLE64)
+{ OPT_LEVELS_ALL, OPT_mdouble_, NULL, 64 },
+#elif defined (WITH_DOUBLE32)
+{ OPT_LEVELS_ALL, OPT_mdouble_, NULL, 32 },
+#else
+#error "align this with config.gcc"
+#endif
+
+#if defined (WITH_LONG_DOUBLE64)
+{ OPT_LEVELS_ALL, OPT_mlong_double_, NULL, 64 },
+#elif defined (WITH_LONG_DOUBLE32)
+{ OPT_LEVELS_ALL, OPT_mlong_double_, NULL, 32 },
+#else
+#error "align this with config.gcc"
+#endif
+
 { OPT_LEVELS_NONE, 0, NULL, 0 }
   };
 
+
+/* Implement `TARGET_HANDLE_OPTION'.  */
+
+static bool
+avr_handle_option (struct gcc_options *opts, struct gcc_options*,
+   const struct cl_decoded_option *decoded, location_t loc)
+{
+  int value = decoded->value;
+
+  switch (decoded->opt_index)
+{
+case OPT_mdouble_:
+  if (value == 64)
+{
+#if !defined (HAVE_DOUBLE64)
+  error_at (loc, "option %<-mdouble=64%> is only available if "
+"configured %<--with-double={64|64,32|32,64}%>");
+#endif
+  opts->x_avr_long_double = 64;
+