]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/config/avr/genmultilib.awk
Update copyright years.
[thirdparty/gcc.git] / gcc / config / avr / genmultilib.awk
index b28ce79df95d99631711e4eb1d3c435875ed4b30..2d07c0e53bab7815e0b55fbbb786c655277fb5af 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2011-2017 Free Software Foundation, Inc.
+# Copyright (C) 2011-2020 Free Software Foundation, Inc.
 #
 # This file is part of GCC.
 #
 # Representation that is understood by GCC's multilib Machinery.
 #
 # The Script works as a Filter from STDIN to STDOUT.
-# 
-# FORMAT = "Makefile": Generate Makefile Snipet that sets some
-#                      MULTILIB_* Variables as needed.
+# It generates a Makefile Snippet that sets some
+# MULTILIB_* Variables as needed.
 #
 ##################################################################
 
 BEGIN {
     FS ="[(, \t]+"
     option[""] = ""
-    tiny_stack[""] = 1
     comment = 1
-    n_mcu = 0
-    n_cores = 0
 
-    mtiny[0] = ""
-    mtiny[1] = "tiny-stack"
-    option["tiny-stack"] = "msp8"
+    dir_tiny = "tiny-stack"
+    opt_tiny = "msp8"
+
+    dir_rcall = "short-calls"
+    opt_rcall = "mshort-calls"
+
+    #    awk Variable         Makefile Variable  
+    #  ------------------------------------------
+    #    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)
 }
 
 ##################################################################
@@ -51,14 +79,11 @@ BEGIN {
        next
     else if (comment == 1)
     {
-       if (FORMAT == "Makefile")
-       {
-           print "# Auto-generated Makefile Snip"
-           print "# Generated by    : ./gcc/config/avr/genmultilib.awk"
-           print "# Generated from  : ./gcc/config/avr/avr-mcus.def"
-           print "# Used by         : tmake_file from Makefile and genmultilib"
-           print ""
-       }
+       print "# Auto-generated Makefile Snip"
+       print "# Generated by    : ./gcc/config/avr/genmultilib.awk"
+       print "# Generated from  : ./gcc/config/avr/avr-mcus.def"
+       print "# Used by         : tmake_file from Makefile and genmultilib"
+       print ""
     }
 
     comment = 2;
@@ -70,16 +95,34 @@ 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
 }
 
 ##################################################################
-# Run over all AVR_MCU Lines and gather Information:
-# cores[]     : Enumerates the Cores (avr2, avr25, ...)
-# mcu[]       : Enumerates the Devices
-# tiny_stack[]: Maps Core/Device to 0 (2-byte SP) or 1 (1-byte SP)
-# option[]    : Maps Core/Device to the mmcu= option to get it
-# toCore[]    : Maps Device to its Core
+# Run over all AVR_MCU Lines.  If we encounter a required multilib
+# variant, add according combination of options to m_required,
+# but onyl once.  Add encountered cores to m_dirnames and
+# according -mmcu= options to m_options.
 ##################################################################
 
 /^AVR_MCU/ {
@@ -94,11 +137,12 @@ BEGIN {
        if (core == "avr1")
            next
 
-       cores[n_cores] = core
-       n_cores++
-       tiny_stack[core] = 0
        option[core] = "mmcu=" core
 
+       m_options  = m_options m_sep option[core]
+       m_dirnames = m_dirnames " " core
+       m_sep = "/"
+
        next
     }
 
@@ -106,116 +150,106 @@ BEGIN {
     if (core == "avr1")
        next
 
+    opts = option[core]
+
     # split device specific feature list
     n = split($4,dev_attribute,"|")
 
-    # set tiny_stack false by default
-    tiny_stack[name] = 0
     for (i=1; i <= n; i++)
-      if (dev_attribute[i] == "AVR_SHORT_SP") {
-        tiny_stack[name]  = 1
-        break
-      }
-
-    mcu[n_mcu] = name
-    n_mcu++
-    option[name]      = "mmcu=" name
-    toCore[name]      = core
-
-    if (tiny_stack[name] == 1)
-       tiny_stack[core] = 1
-}
-
-##################################################################
-# 
-# We gathered all the Information, now build/output the following:
-#
-#    awk Variable         target Variable          FORMAT
-#  -----------------------------------------------------------
-#    m_options     <->    MULTILIB_OPTIONS         Makefile
-#    m_dirnames    <->    MULTILIB_DIRNAMES           "
-#    m_exceptions  <->    MULTILIB_EXCEPTIONS         "
-#
-##################################################################
-
-END {
-    m_options    = "\nMULTILIB_OPTIONS = "
-    m_dirnames   = "\nMULTILIB_DIRNAMES ="
-    m_exceptions = "\nMULTILIB_EXCEPTIONS ="
-
-    ##############################################################
-    # Compose MULTILIB_OPTIONS.  This represents the Cross-Product
-    #    (avr2, avr25, ...) x msp8
-
-    sep = ""
-    for (c = 0; c < n_cores; c++)
     {
-       m_options = m_options sep option[cores[c]]
-       sep = "/"
+      if (dev_attribute[i] == "AVR_SHORT_SP")
+        opts = opts "/" opt_tiny
+      if (dev_attribute[i] == "AVR_ISA_RCALL")
+        opts = opts "/" opt_rcall
     }
 
-    # The ... x msp8
-    m_options = m_options " " option[mtiny[1]]
-
-    ##############################################################
-    # Map Device to its multilib
-
-    for (t = 0; t < n_mcu; t++)
+    if (!have[opts])
     {
-       core = toCore[mcu[t]]
-       
-       line = option[core] ":" option[mcu[t]]
-       gsub ("=", "?", line)
-       gsub (":", "=", line)
-    }
-
-    ####################################################################
-    # Compose MULTILIB_DIRNAMES and MULTILIB_EXEPTIONS
-
-    n_mtiny = 2
-    for (t = 0; t < n_mtiny; t++)
-       for (c = -1; c < n_cores; c++)
+       have[opts] = 1
+       # Some special handling for the default mmcu: Remove a
+       # leading "mmcu=avr2/" in order not to confuse genmultilib.
+       gsub (/^mmcu=avr2\//, "", opts)
+       if (opts != "mmcu=avr2")
        {
-           if (c == -1)
-               core = ""
-           else
-               core = cores[c]
-
-           # The Directory Name for this multilib
-
-           if (core != "" && mtiny[t] != "")
+           m_required = m_required " \\\n\t" opts
+           if (have_double_multi && have_long_double_multi)
            {
-               mdir = core "/" mtiny[t]
-               mopt = option[core] "/" option[mtiny[t]]
+               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
-           {
-               mdir = core mtiny[t]
-               mopt = option[core] option[mtiny[t]]
-           }
-
-           if (core != "" && tiny_stack[core] == 0 && mtiny[t] != "")
-           {
-               # There's not a single SP = 8 Devices for this Core:
-               # Don't build respective multilib
-               m_exceptions = m_exceptions " \\\n\t" mopt
-               continue
-           }
-
-           if (core != "avr2" || mtiny[t] == "")
-               m_dirnames = m_dirnames " " mdir
+           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
        }
+    }
+}
 
+##################################################################
+# 
+##################################################################
+
+END {
     ############################################################
     # Output that Stuff
     ############################################################
 
-    if (FORMAT == "Makefile")
+    # Intended Target: $(top_builddir)/gcc/t-multilib-avr
+
+    if (have_double_multi && have_long_double_multi)
     {
-       # Intended Target: ./gcc/config/avr/t-multilib
+       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
-       print m_dirnames
-       print m_exceptions
+       }
     }
+    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
 }