-/* 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.
#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"
"# #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";
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
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)
{
#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");
}