]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/config/avr/gen-avr-mmcu-specs.c
Update copyright years.
[thirdparty/gcc.git] / gcc / config / avr / gen-avr-mmcu-specs.c
index b923aa4ee3cd69894587234705f050c86e2c09fe..b9e935bab663bce293cb4b4e2fb0998b5bb04655 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998-2017 Free Software Foundation, Inc.
+/* Copyright (C) 1998-2021 Free Software Foundation, Inc.
    Contributed by Joern Rennecke
 
    This file is part of GCC.
@@ -21,6 +21,8 @@
 #include <stdio.h>
 #include <string.h>
 
+#define IN_TARGET_CODE 1
+
 #include "config.h"
 
 #define IN_GEN_AVR_MMCU_TEXI
 #define SPECFILE_USAGE_URL                              \
   "https://gcc.gnu.org/gcc-5/changes.html"
 
-/* Return true iff STR starts with PREFIX.  */
-
-static bool
-str_prefix_p (const char *str, const char *prefix)
-{
-  return 0 == strncmp (str, prefix, strlen (prefix));
-}
-
 
 static const char header[] =
   "#\n"
@@ -103,7 +97,7 @@ static const char help_dev_lib_name[] =
   "#     #include <avr/io.h>\n"
   "#\n"
   "# will include the desired device header.  For ATmega8A the supplement\n"
-  "# to *cpp would read\n"
+  "# to *cpp_avrlibc would read\n"
   "#\n"
   "#     -D__AVR_DEV_LIB_NAME__=m8a\n"
   "\n";
@@ -131,13 +125,21 @@ print_mcu (const avr_mcu_t *mcu)
 
   FILE *f = fopen (name ,"w");
 
-  bool absdata = 0 != (mcu->dev_attribute & AVR_ISA_LDS);
-  bool errata_skip = 0 != (mcu->dev_attribute & AVR_ERRATA_SKIP);
-  bool rmw = 0 != (mcu->dev_attribute & AVR_ISA_RMW);
-  bool sp8 = 0 != (mcu->dev_attribute & AVR_SHORT_SP);
+  bool absdata = (mcu->dev_attribute & AVR_ISA_LDS) != 0;
+  bool errata_skip = (mcu->dev_attribute & AVR_ERRATA_SKIP) != 0;
+  bool rmw = (mcu->dev_attribute & AVR_ISA_RMW) != 0;
+  bool sp8 = (mcu->dev_attribute & AVR_SHORT_SP) != 0;
   bool rcall = (mcu->dev_attribute & AVR_ISA_RCALL);
-  bool is_arch = NULL == mcu->macro;
+  bool is_arch = mcu->macro == NULL;
   bool is_device = ! is_arch;
+  int flash_pm_offset = 0;
+
+  if (arch->flash_pm_offset
+      && mcu->flash_pm_offset
+      && mcu->flash_pm_offset != arch->flash_pm_offset)
+    {
+      flash_pm_offset = mcu->flash_pm_offset;
+    }
 
   if (is_arch
       && (ARCH_AVR2 == arch_id
@@ -251,7 +253,11 @@ print_mcu (const avr_mcu_t *mcu)
 
   fprintf (f, "*link_relax:\n\t%s\n\n", LINK_RELAX_SPEC);
 
-  fprintf (f, "*link_arch:\n\t%s\n\n", LINK_ARCH_SPEC);
+  fprintf (f, "*link_arch:\n\t%s", LINK_ARCH_SPEC);
+  if (is_device
+      && flash_pm_offset)
+    fprintf (f, " --defsym=__RODATA_PM_OFFSET__=0x%x", flash_pm_offset);
+  fprintf (f, "\n\n");
 
   if (is_device)
     {
@@ -279,10 +285,26 @@ print_mcu (const avr_mcu_t *mcu)
 
 #if defined (WITH_AVRLIBC)
       fprintf (f, "%s\n", help_dev_lib_name);
+
+      fprintf (f, "*cpp_avrlibc:\n");
+      fprintf (f, "\t-D__AVR_DEVICE_NAME__=%s", mcu->name);
+      fprintf (f, "\n\n");
 #endif // WITH_AVRLIBC
 
+      fprintf (f, "*cpp_mcu:\n");
+      fprintf (f, "\t-D%s", mcu->macro);
+      if (flash_pm_offset)
+       {
+         fprintf (f, " -U__AVR_PM_BASE_ADDRESS__");
+         fprintf (f, " -D__AVR_PM_BASE_ADDRESS__=0x%x", flash_pm_offset);
+       }
+      fprintf (f, "\n\n");
+
       fprintf (f, "*cpp:\n");
-      fprintf (f, "\t-D%s -D__AVR_DEVICE_NAME__=%s", mcu->macro, mcu->name);
+      fprintf (f, "\t%%(cpp_mcu)");
+#if defined (WITH_AVRLIBC)
+      fprintf (f, " %%(cpp_avrlibc)");
+#endif // WITH_AVRLIBC
       fprintf (f, "\n\n");
     }