Build double32 / long-double32 multilibs if needed.
authorGeorg-Johann Lay <avr@gjlay.de>
Mon, 25 Nov 2019 08:59:06 +0000 (08:59 +0000)
committerGeorg-Johann Lay <gjl@gcc.gnu.org>
Mon, 25 Nov 2019 08:59:06 +0000 (08:59 +0000)
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.

From-SVN: r278668

gcc/ChangeLog
gcc/config/avr/driver-avr.c
gcc/config/avr/genmultilib.awk
gcc/config/avr/t-avr

index f4d0ee5db7b58e49ac6f234eda53e176a661cad7..25adf2ee635febcb2b6b25a1b1b5c52db5f4aa1a 100644 (file)
@@ -1,3 +1,17 @@
+2019-11-25  Georg-Johann Lay  <avr@gjlay.de>
+
+       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.
+
 2019-11-25  Richard Biener  <rguenther@suse.de>
 
        * cfgloop.h (get_loop_exit_edges): Add extra parameter denoting
index a6239dac949fe3797fd97516e84547fc8e701e2a..b0079544a2256efed16d7fadcd10f5340cbecf24 100644 (file)
@@ -114,10 +114,7 @@ avr_devicespecs_file (int argc, const char **argv)
 
 
 /* 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)
index 1228022837755e1ed21164e9672355c1ed5ea11e..c1c82cf21d7d18668e82452102a11ac74124f41f 100644 (file)
@@ -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
-
-               # -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
+               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_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 5384af41c56aedbfc46c84666a6bca2463fcda20..f87a5e602c12de062a5f4141a3e452b668552859 100644 (file)
 # 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-avr
 
 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