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
 # <http://www.gnu.org/licenses/>.
 
-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)))
+WITH_LONG_DOUBLE=32
+endif
+
+ifeq (WITH_LONG_DOUBLE64, $(findstring WITH_LONG_DOUBLE64, $(tm_defines)))
+WITH_LONG_DOUBLE=64
+endif
 
 PASSES_EXTRA += $(srcdir)/config/avr/avr-passes.def
 
@@ -101,8 +120,13 @@ multilib.h Makefile s-mlib: t-multilib-a
 
 t-multilib-avr: $(srcdir)/config/avr/genmultilib.awk \
 				 $(AVR_MCUS)
-	$(AWK)	-v HAVE_DOUBLE_MULTILIB=$(HAVE_DOUBLE_MULTILIB) \
-		-v HAVE_LONG_DOUBLE_MULTILIB=$(HAVE_LONG_DOUBLE_MULTILIB) \
+	$(AWK)	-v HAVE_LONG_DOUBLE_IS_DOUBLE=$(HAVE_LONG_DOUBLE_IS_DOUBLE) \
+		-v HAVE_DOUBLE32=$(HAVE_DOUBLE32) 			\
+		-v HAVE_DOUBLE64=$(HAVE_DOUBLE64) 			\
+		-v HAVE_LONG_DOUBLE32=$(HAVE_LONG_DOUBLE32)		\
+		-v HAVE_LONG_DOUBLE64=$(HAVE_LONG_DOUBLE64) 		\
+		-v with_double=$(WITH_DOUBLE) 				\
+		-v with_long_double=$(WITH_LONG_DOUBLE)			\
 		-f $< $< $(AVR_MCUS) > $@
 
 include t-multilib-avr
Index: config/avr/genmultilib.awk
===================================================================
--- config/avr/genmultilib.awk	(revision 278552)
+++ config/avr/genmultilib.awk	(working copy)
@@ -38,12 +38,6 @@ BEGIN {
     dir_rcall = "short-calls"
     opt_rcall = "mshort-calls"
 
-    dir_double64 = "double64"
-    opt_double64 = "mdouble=64"
-
-    dir_long_double64 = "long-double64"
-    opt_long_double64 = "mlong-double=64"
-
     #    awk Variable         Makefile Variable  
     #  ------------------------------------------
     #    m_options     <->    MULTILIB_OPTIONS
@@ -56,8 +50,23 @@ BEGIN {
     m_required   = "\nMULTILIB_REQUIRED ="
     m_reuse      = "\nMULTILIB_REUSE ="
 
-    have_double_multi = (HAVE_DOUBLE_MULTILIB == "HAVE_DOUBLE_MULTILIB")
-    have_long_double_multi = (HAVE_LONG_DOUBLE_MULTILIB == "HAVE_LONG_DOUBLE_MULTILIB")
+    have_long_double_is_double = (HAVE_LONG_DOUBLE_IS_DOUBLE \
+				  == "HAVE_LONG_DOUBLE_IS_DOUBLE")
+    have_double32 = (HAVE_DOUBLE32 == "HAVE_DOUBLE32")
+    have_double64 = (HAVE_DOUBLE64 == "HAVE_DOUBLE64")
+    have_long_double32 = (HAVE_LONG_DOUBLE32 == "HAVE_LONG_DOUBLE32")
+    have_long_double64 = (HAVE_LONG_DOUBLE64 == "HAVE_LONG_DOUBLE64")
+
+    have_double_multi = (have_double32 && have_double64)
+    have_long_double_multi = (! have_long_double_is_double \
+			      && have_long_double32 && have_long_double64)
+
+    # How to switch away from the default.
+    dir_double = "double"   (96 - with_double)
+    opt_double = "mdouble=" (96 - with_double)
+
+    dir_long_double = "long-double"   (96 - with_long_double)
+    opt_long_double = "mlong-double=" (96 - with_long_double)
 }
 
 ##################################################################
@@ -86,6 +95,26 @@ BEGIN {
     # The first empty line stops copy-pasting the GPL comments
     # from this file to the generated file.
 
+    if (comment)
+    {
+	print
+
+	if (have_double_multi)
+	{
+	    print "# dir_double = " dir_double
+	    print "# opt_double = -" opt_double
+	}
+	else
+	    print "# No multilib for double."
+
+	if (have_long_double_multi)
+	{
+	    print "# dir_long_double = " dir_long_double
+	    print "# opt_long_double = -" opt_long_double
+	}
+	else
+	    print "# No multilib for long double."
+    }
     comment = 0
 }
 
@@ -145,21 +174,30 @@ BEGIN {
 	    m_required = m_required " \\\n\t" opts
 	    if (have_double_multi && have_long_double_multi)
 	    {
-		m_required = m_required " \\\n\t" opts "/" opt_double64
-		m_required = m_required " \\\n\t" opts "/" opt_long_double64
+		m_required = m_required " \\\n\t" opts "/" opt_double
+		m_required = m_required " \\\n\t" opts "/" opt_long_double
 
-		# -mlong-double=64 -mdouble=64 is the same as -mdouble=64,
-		# hence add a respective reuse.
-		d_opts  = opts "/" opt_double64
-		d_reuse = opts "/" opt_double64 "/" opt_long_double64
-		gsub (/=/, ".", d_opts)
-		gsub (/=/, ".", d_reuse)
-		m_reuse = m_reuse " \\\n\t" d_opts "=" d_reuse
+		# We have only 3 different combinations because -mdouble=64
+		# implies -mlong-double=64, and -mlong-double=32 implies
+		# -mdouble=32, hence add respective reuses.  The reuse is
+		# not needed in the case with_double != with_long_double
+		# which means with_double=32 with_long_double=64 because
+		# the driver will rectify combining -mdouble=64 and
+		# -mlong-double=32.
+		if (with_double == with_long_double)
+		{
+		    d_opts = with_double == 32 ? opt_double : opt_long_double
+		    d_opts  = opts "/" d_opts
+		    d_reuse = opts "/" opt_double "/" opt_long_double
+		    gsub (/=/, ".", d_opts)
+		    gsub (/=/, ".", d_reuse)
+		    m_reuse = m_reuse " \\\n\t" d_opts "=" d_reuse
+		}
 	    }
 	    else if (have_double_multi)
-		m_required = m_required " \\\n\t" opts "/" opt_double64
+		m_required = m_required " \\\n\t" opts "/" opt_double
 	    else if (have_long_double_multi)
-		m_required = m_required " \\\n\t" opts "/" opt_long_double64
+		m_required = m_required " \\\n\t" opts "/" opt_long_double
 	}
     }
 }
@@ -177,26 +215,34 @@ END {
 
     if (have_double_multi && have_long_double_multi)
     {
-	print m_options  " " opt_tiny " " opt_rcall " " opt_double64 "/" opt_long_double64
-	print m_dirnames " " dir_tiny " " dir_rcall " " dir_double64 " " dir_long_double64
-	# Notice that the ./double64 and ./long-double64 variants cannot
+	print m_options  " " opt_tiny " " opt_rcall " " opt_double "/" opt_long_double
+	print m_dirnames " " dir_tiny " " dir_rcall " " dir_double " " dir_long_double
+	# Notice that the ./double* and ./long-double* variants cannot
 	# be copied by t-avrlibc because the . default multilib is built
 	# after all the others.
-	m_required = m_required " \\\n\t" opt_double64
-	m_required = m_required " \\\n\t" opt_long_double64
-	m_reuse = m_reuse " \\\n\tmdouble.64=mdouble.64/mlong-double.64"
+	m_required = m_required " \\\n\t" opt_double
+	m_required = m_required " \\\n\t" opt_long_double
+	if (with_double == with_long_double)
+	{
+	    d_opts  = with_double == 32 ? opt_double : opt_long_double
+	    d_reuse = opt_double "/" opt_long_double
+	    gsub (/=/, ".", d_opts)
+	    gsub (/=/, ".", d_reuse)
+	    m_reuse = m_reuse " \\\n\t" d_opts "=" d_reuse
+
+	}
     }
     else if (have_double_multi)
     {
-	print m_options  " " opt_tiny " " opt_rcall " " opt_double64
-	print m_dirnames " " dir_tiny " " dir_rcall " " dir_double64
-	m_required = m_required " \\\n\t" opt_double64
+	print m_options  " " opt_tiny " " opt_rcall " " opt_double
+	print m_dirnames " " dir_tiny " " dir_rcall " " dir_double
+	m_required = m_required " \\\n\t" opt_double
     }
     else if (have_long_double_multi)
     {
-	print m_options  " " opt_tiny " " opt_rcall " " opt_long_double64
-	print m_dirnames " " dir_tiny " " dir_rcall " " dir_long_double64
-	m_required = m_required " \\\n\t" opt_long_double64
+	print m_options  " " opt_tiny " " opt_rcall " " opt_long_double
+	print m_dirnames " " dir_tiny " " dir_rcall " " dir_long_double
+	m_required = m_required " \\\n\t" opt_long_double
     }
     else
     {
Index: config/avr/driver-avr.c
===================================================================
--- config/avr/driver-avr.c	(revision 278552)
+++ config/avr/driver-avr.c	(working copy)
@@ -114,10 +114,7 @@ avr_devicespecs_file (int argc, const ch
 
 
 /* Re-build the -mdouble= and -mlong-double= options.  This is needed
-   because multilib selection is based on the physical presence of an
-   option on the command line, which is not the case for, say, when the
-   double=64 multilib is to be selected by --with-double=64 but the user
-   does not specify -mdouble=64 explicitly.  */
+   because these options are not independent of each other.  */
 
 const char*
 avr_double_lib (int argc, const char **argv)

Reply via email to