diff gcc/config/avr/genmultilib.awk @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
line wrap: on
line diff
--- a/gcc/config/avr/genmultilib.awk	Thu Oct 25 07:37:49 2018 +0900
+++ b/gcc/config/avr/genmultilib.awk	Thu Feb 13 11:34:05 2020 +0900
@@ -1,4 +1,4 @@
-# Copyright (C) 2011-2018 Free Software Foundation, Inc.
+# Copyright (C) 2011-2020 Free Software Foundation, Inc.
 #
 # This file is part of GCC.
 #
@@ -43,10 +43,30 @@
     #    m_options     <->    MULTILIB_OPTIONS
     #    m_dirnames    <->    MULTILIB_DIRNAMES
     #    m_required    <->    MULTILIB_REQUIRED
+    #    m_reuse       <->    MULTILIB_REUSE
     m_sep = ""
     m_options    = "\nMULTILIB_OPTIONS = "
     m_dirnames   = "\nMULTILIB_DIRNAMES ="
     m_required   = "\nMULTILIB_REQUIRED ="
+    m_reuse      = "\nMULTILIB_REUSE ="
+
+    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)
 }
 
 ##################################################################
@@ -75,6 +95,26 @@
     # 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
 }
 
@@ -130,7 +170,35 @@
 	# leading "mmcu=avr2/" in order not to confuse genmultilib.
 	gsub (/^mmcu=avr2\//, "", opts)
 	if (opts != "mmcu=avr2")
+	{
 	    m_required = m_required " \\\n\t" opts
+	    if (have_double_multi && have_long_double_multi)
+	    {
+		m_required = m_required " \\\n\t" opts "/" opt_double
+		m_required = m_required " \\\n\t" opts "/" opt_long_double
+
+		# 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_double
+	    else if (have_long_double_multi)
+		m_required = m_required " \\\n\t" opts "/" opt_long_double
+	}
     }
 }
 
@@ -143,9 +211,45 @@
     # Output that Stuff
     ############################################################
 
-    # Intended Target: ./gcc/config/avr/t-multilib
+    # Intended Target: $(top_builddir)/gcc/t-multilib-avr
+
+    if (have_double_multi && have_long_double_multi)
+    {
+	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_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
 
-    print m_options  " " opt_tiny " " opt_rcall
-    print m_dirnames " " dir_tiny " " dir_rcall
+	}
+    }
+    else if (have_double_multi)
+    {
+	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_double
+	print m_dirnames " " dir_tiny " " dir_rcall " " dir_long_double
+	m_required = m_required " \\\n\t" opt_long_double
+    }
+    else
+    {
+	print m_options  " " opt_tiny " " opt_rcall
+	print m_dirnames " " dir_tiny " " dir_rcall
+    }
+
     print m_required
+    print m_reuse
 }