aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/avr/avr-devices.c
diff options
context:
space:
mode:
authorGeorg-Johann Lay <avr@gjlay.de>2015-03-10 09:50:41 +0000
committerGeorg-Johann Lay <gjl@gcc.gnu.org>2015-03-10 09:50:41 +0000
commit4a2caf6ced93a63e1703870ed67385d3f89da474 (patch)
treefa8390902e4ef79ccff88b2c2384679848448dc0 /gcc/config/avr/avr-devices.c
parent768fbdd49e8535486ea71eebc507c3b813521a1b (diff)
downloadgcc-4a2caf6ced93a63e1703870ed67385d3f89da474.zip
gcc-4a2caf6ced93a63e1703870ed67385d3f89da474.tar.gz
gcc-4a2caf6ced93a63e1703870ed67385d3f89da474.tar.bz2
re PR target/65296 ([avr] fix various issues with specs file generation)
PR target/65296 * config.gcc (extra_options) [avr]: Remove. (extra_gcc_objs) [avr]: Use driver-avr.o, avr-devices.o. (tm_file) [avr]: Add avr/specs.h after avr/avr.h. (tm_defines) [avr-*-rtems*]: Add WITH_RTEMS. * config/avr/avr.opt (config/avr/avr-arch.h): Remove include. (-mmcu=): Add Var and MissingArgError properties. (-march=): Remove. * config/avr/genmultilib.awk: Use -mmcu= instead of -march=. * config/avr/t-multilib: Regenerate. * config/avr/specs.h: New file. * config/avr/driver-avr.c: New file. * config/avr/genopt.sh: Remove file. * config/avr/avr-tables.opt: Remove file. * config/avr/predicates.md (avr_current_arch): Rename to avr_arch. * config/avr/avr-c.c: Same. * avr-arch.h: Same. (avr_current_device): Remove proto. * config/avr/avr.h (avr_current_arch): Rename to avr_arch. (AVR_HAVE_8BIT_SP): Don't depend on avr_current_device. (EXTRA_SPEC_FUNCTIONS): Define. (avr_devicespecs_file): New specs function proto. (DRIVER_SELF_SPECS): Use device-specs-file spec function. * config/avr/avr.c (avr_current_arch): Rename to avr_arch. (avr_current_device): Remove definition and usage. (avr_set_core_architecture): New static function. (avr_option_override): Use it. * config/avr/avr-devices.c (diagnostic.h, avr-arch.h): Include them. (mcu_name): New static array. (comparator, avr_archs_str, avr_mcus_str): New static functions. (avr_inform_devices, avr_inform_core_architectures): New functions. * config/avr/gen-avr-mmcu-specs.c (avr-arch.h, specs.h): Include. (avrlibc.h) [WITH_AVRLIBC]: Include. (../rtems.h, rtems.h) [WITH_RTEMS]: Include. (print_mcu): Rewrite from scratch. * config/avr/avrlibc.h (LIB_SPEC, LIBGCC_SPEC, STARTFILE_SPEC): Forward to avr-specific specs defined in device-specs file. * config/avr/t-avr (driver-avr.o): New rule. (avr-devices.o): Depend on avr-arch.h. (avr-mcus): No more depend on avr-tables.opt. (avr-tables.opt): Remove rule. (install-device-specs): Use INSTALL_DATA, not INSTALL_PROGRAM. From-SVN: r221316
Diffstat (limited to 'gcc/config/avr/avr-devices.c')
-rw-r--r--gcc/config/avr/avr-devices.c100
1 files changed, 99 insertions, 1 deletions
diff --git a/gcc/config/avr/avr-devices.c b/gcc/config/avr/avr-devices.c
index 387686a..082e789 100644
--- a/gcc/config/avr/avr-devices.c
+++ b/gcc/config/avr/avr-devices.c
@@ -21,9 +21,12 @@
#include "config.h"
#include "system.h"
#include "coretypes.h"
+#include "diagnostic.h"
#include "tm.h"
#endif /* IN_GEN_AVR_MMCU_TEXI */
+#include "avr-arch.h"
+
/* List of all known AVR MCU architectures.
Order as of enum avr_arch from avr.h. */
@@ -31,7 +34,7 @@ const avr_arch_t
avr_arch_types[] =
{
/* unknown device specified */
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x0060, 32, NULL, "avr2" },
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x0060, 32, NULL, AVR_MMCU_DEFAULT },
/*
A M J LM E E E X R T d S S O A
S U M PO L L I M A I a t F ff r
@@ -116,3 +119,98 @@ avr_mcu_types[] =
{ NULL, ARCH_UNKNOWN, AVR_ISA_NONE, NULL, 0, 0, 0, NULL }
};
+
+
+
+#ifndef IN_GEN_AVR_MMCU_TEXI
+
+/* Copy-pastes from `gen-avr-mmcu-texi.c' follow... */
+
+static const char*
+mcu_name[sizeof avr_mcu_types / sizeof avr_mcu_types[0]];
+
+static int
+comparator (const void *va, const void *vb)
+{
+ const char *a = *(const char* const*) va;
+ const char *b = *(const char* const*) vb;
+
+ while (*a && *b)
+ {
+ /* Make letters smaller than digits so that `atmega16a' follows
+ `atmega16' without `atmega161' etc. between them. */
+
+ if (ISALPHA (*a) && ISDIGIT (*b))
+ return -1;
+
+ if (ISDIGIT (*a) && ISALPHA (*b))
+ return 1;
+
+ if (*a != *b)
+ return *a - *b;
+
+ a++;
+ b++;
+ }
+
+ return *a - *b;
+}
+
+
+static char*
+avr_archs_str (void)
+{
+ char *archs = concat ("", NULL);
+
+ // Build of core architectures' names.
+
+ for (const avr_mcu_t *mcu = avr_mcu_types; mcu->name; mcu++)
+ if (!mcu->macro)
+ archs = concat (archs, " ", avr_arch_types[mcu->arch_id].name, NULL);
+
+ return archs;
+}
+
+
+static char*
+avr_mcus_str (void)
+{
+ size_t n_mcus = 0;
+ char *mcus = concat ("", NULL);
+
+ // Build array of proper devices' names.
+
+ for (const avr_mcu_t *mcu = avr_mcu_types; mcu->name; mcu++)
+ if (mcu->macro)
+ mcu_name[n_mcus++] = mcu->name;
+
+ // Sort MCUs so that they are displayed in the same canonical order as
+ // in doc/avr-mcus.texi.
+
+ qsort (mcu_name, n_mcus, sizeof (char*), comparator);
+
+ for (size_t i = 0; i < n_mcus; i++)
+ mcus = concat (mcus, " ", mcu_name[i], NULL);
+
+ return mcus;
+}
+
+
+void
+avr_inform_devices (void)
+{
+ char *mcus = avr_mcus_str ();
+ inform (input_location, "devices natively supported:%s", mcus);
+ free (mcus);
+}
+
+
+void
+avr_inform_core_architectures (void)
+{
+ char *archs = avr_archs_str ();
+ inform (input_location, "supported core architectures:%s", archs);
+ free (archs);
+}
+
+#endif // IN_GEN_AVR_MMCU_TEXI