aboutsummaryrefslogtreecommitdiff
path: root/gcc/config
diff options
context:
space:
mode:
authorGeorg-Johann Lay <avr@gjlay.de>2012-09-17 15:22:37 +0000
committerGeorg-Johann Lay <gjl@gcc.gnu.org>2012-09-17 15:22:37 +0000
commite3cf7a9538c683494b4965fa3e70ff76b9e314c7 (patch)
tree92c612c0afc3dec11f361bf5f0e2430e4bc1c0ba /gcc/config
parent78ab1ff46b119d7e5e3420999499689b90e73358 (diff)
downloadgcc-e3cf7a9538c683494b4965fa3e70ff76b9e314c7.zip
gcc-e3cf7a9538c683494b4965fa3e70ff76b9e314c7.tar.gz
gcc-e3cf7a9538c683494b4965fa3e70ff76b9e314c7.tar.bz2
re PR target/54607 ([avr]: Canadian cross build fails because gen-avr-mmcu-texi.c is compiled with the wrong compiler)
PR target/54607 * config.gcc (tm_file,avr): Add avr/avr-arch.h. * config/avr/t-avr (gen-avr-mmcu-texi): Use CC_FOR_BUILD to compile. Don't depend on TM_H. Use CFLAGS_FOR_BUILD. * config/avr/avr.h (avr_arch, base_arch_s, mcu_type_s): Source out to... * config/avr/avr-arch.h: ...this new file. * config/avr/gen-avr-mmcu-texi.c: Include avr-arch.h, stdio.h, stdlib.h. * comparator: Make letters smaller than digits. * config/avr/avr-devices.c: Don't include headers if used in gen-avr-mmcu-texi.c. * doc/avr-mmcu.texi: Regenerate. From-SVN: r191390
Diffstat (limited to 'gcc/config')
-rw-r--r--gcc/config/avr/avr-arch.h156
-rw-r--r--gcc/config/avr/avr-devices.c2
-rw-r--r--gcc/config/avr/avr.h127
-rw-r--r--gcc/config/avr/gen-avr-mmcu-texi.c41
-rw-r--r--gcc/config/avr/t-avr5
5 files changed, 199 insertions, 132 deletions
diff --git a/gcc/config/avr/avr-arch.h b/gcc/config/avr/avr-arch.h
new file mode 100644
index 0000000..b28bec9
--- /dev/null
+++ b/gcc/config/avr/avr-arch.h
@@ -0,0 +1,156 @@
+/* Definitions of types that are used to store AVR architecture and
+ device information.
+ Copyright (C) 2012 Free Software Foundation, Inc.
+ Contributed by Georg-Johann Lay (avr@gjlay.de)
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+
+/* This enum supplies indices into the avr_arch_types[] table below. */
+
+enum avr_arch
+{
+ ARCH_UNKNOWN,
+ ARCH_AVR1,
+ ARCH_AVR2,
+ ARCH_AVR25,
+ ARCH_AVR3,
+ ARCH_AVR31,
+ ARCH_AVR35,
+ ARCH_AVR4,
+ ARCH_AVR5,
+ ARCH_AVR51,
+ ARCH_AVR6,
+ ARCH_AVRXMEGA2,
+ ARCH_AVRXMEGA4,
+ ARCH_AVRXMEGA5,
+ ARCH_AVRXMEGA6,
+ ARCH_AVRXMEGA7
+};
+
+
+/* Architecture-specific properties. */
+
+struct base_arch_s
+{
+ /* Assembler only. */
+ int asm_only;
+
+ /* Core have 'MUL*' instructions. */
+ int have_mul;
+
+ /* Core have 'CALL' and 'JMP' instructions. */
+ int have_jmp_call;
+
+ /* Core have 'MOVW' and 'LPM Rx,Z' instructions. */
+ int have_movw_lpmx;
+
+ /* Core have 'ELPM' instructions. */
+ int have_elpm;
+
+ /* Core have 'ELPM Rx,Z' instructions. */
+ int have_elpmx;
+
+ /* Core have 'EICALL' and 'EIJMP' instructions. */
+ int have_eijmp_eicall;
+
+ /* This is an XMEGA core. */
+ int xmega_p;
+
+ /* This core has the RAMPD special function register
+ and thus also the RAMPX, RAMPY and RAMPZ registers. */
+ int have_rampd;
+
+ /* Default start of data section address for architecture. */
+ int default_data_section_start;
+
+ /* Offset between SFR address and RAM address:
+ SFR-address = RAM-address - sfr_offset */
+ int sfr_offset;
+
+ /* Architecture id to built-in define __AVR_ARCH__ (NULL -> no macro) */
+ const char *const macro;
+
+ /* Architecture name. */
+ const char *const arch_name;
+};
+
+
+/* Device-specific properties. */
+
+struct mcu_type_s
+{
+ /* Device name. */
+ const char *const name;
+
+ /* Index in avr_arch_types[]. */
+ enum avr_arch arch;
+
+ /* Must lie outside user's namespace. NULL == no macro. */
+ const char *const macro;
+
+ /* Stack pointer have 8 bits width. */
+ int short_sp;
+
+ /* Some AVR devices have a core erratum when skipping a 2-word instruction.
+ Skip instructions are: SBRC, SBRS, SBIC, SBIS, CPSE.
+ Problems will occur with return address is IRQ executes during the
+ skip sequence.
+
+ A support ticket from Atmel returned the following information:
+
+ Subject: (ATTicket:644469) On AVR skip-bug core Erratum
+ From: avr@atmel.com Date: 2011-07-27
+ (Please keep the subject when replying to this mail)
+
+ This errata exists only in AT90S8515 and ATmega103 devices.
+
+ For information please refer the following respective errata links
+ http://www.atmel.com/dyn/resources/prod_documents/doc2494.pdf
+ http://www.atmel.com/dyn/resources/prod_documents/doc1436.pdf */
+
+ /* Core Erratum: Must not skip 2-word instruction. */
+ int errata_skip;
+
+ /* Start of data section. */
+ int data_section_start;
+
+ /* Number of 64k segments in the flash. */
+ int n_flash;
+
+ /* Name of device library. */
+ const char *const library_name;
+};
+
+/* Map architecture to its texinfo string. */
+
+struct arch_info_s
+{
+ /* Architecture ID. */
+ enum avr_arch arch;
+
+ /* textinfo source to describe the archtiecture. */
+ const char *texinfo;
+};
+
+/* Preprocessor macros to define depending on MCU type. */
+
+extern const char *avr_extra_arch_macro;
+extern const struct base_arch_s *avr_current_arch;
+extern const struct mcu_type_s *avr_current_device;
+extern const struct mcu_type_s avr_mcu_types[];
+extern const struct base_arch_s avr_arch_types[];
diff --git a/gcc/config/avr/avr-devices.c b/gcc/config/avr/avr-devices.c
index 47cfefd..3ee1eff 100644
--- a/gcc/config/avr/avr-devices.c
+++ b/gcc/config/avr/avr-devices.c
@@ -18,10 +18,12 @@
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
+#ifndef IN_GEN_AVR_MMCU_TEXI
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
+#endif /* IN_GEN_AVR_MMCU_TEXI */
/* List of all known AVR MCU architectures.
Order as of enum avr_arch from avr.h. */
diff --git a/gcc/config/avr/avr.h b/gcc/config/avr/avr.h
index f868668..8488ecd 100644
--- a/gcc/config/avr/avr.h
+++ b/gcc/config/avr/avr.h
@@ -21,133 +21,6 @@ You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
-/* Names to predefine in the preprocessor for this target machine. */
-
-struct base_arch_s
-{
- /* Assembler only. */
- int asm_only;
-
- /* Core have 'MUL*' instructions. */
- int have_mul;
-
- /* Core have 'CALL' and 'JMP' instructions. */
- int have_jmp_call;
-
- /* Core have 'MOVW' and 'LPM Rx,Z' instructions. */
- int have_movw_lpmx;
-
- /* Core have 'ELPM' instructions. */
- int have_elpm;
-
- /* Core have 'ELPM Rx,Z' instructions. */
- int have_elpmx;
-
- /* Core have 'EICALL' and 'EIJMP' instructions. */
- int have_eijmp_eicall;
-
- /* This is an XMEGA core. */
- int xmega_p;
-
- /* This core has the RAMPD special function register
- and thus also the RAMPX, RAMPY and RAMPZ registers. */
- int have_rampd;
-
- /* Default start of data section address for architecture. */
- int default_data_section_start;
-
- /* Offset between SFR address and RAM address:
- SFR-address = RAM-address - sfr_offset */
- int sfr_offset;
-
- /* Architecture id to built-in define __AVR_ARCH__ (NULL -> no macro) */
- const char *const macro;
-
- /* Architecture name. */
- const char *const arch_name;
-};
-
-/* These names are used as the index into the avr_arch_types[] table
- above. */
-
-enum avr_arch
-{
- ARCH_UNKNOWN,
- ARCH_AVR1,
- ARCH_AVR2,
- ARCH_AVR25,
- ARCH_AVR3,
- ARCH_AVR31,
- ARCH_AVR35,
- ARCH_AVR4,
- ARCH_AVR5,
- ARCH_AVR51,
- ARCH_AVR6,
- ARCH_AVRXMEGA2,
- ARCH_AVRXMEGA4,
- ARCH_AVRXMEGA5,
- ARCH_AVRXMEGA6,
- ARCH_AVRXMEGA7
-};
-
-struct mcu_type_s {
- /* Device name. */
- const char *const name;
-
- /* Index in avr_arch_types[]. */
- enum avr_arch arch;
-
- /* Must lie outside user's namespace. NULL == no macro. */
- const char *const macro;
-
- /* Stack pointer have 8 bits width. */
- int short_sp;
-
- /* Some AVR devices have a core erratum when skipping a 2-word instruction.
- Skip instructions are: SBRC, SBRS, SBIC, SBIS, CPSE.
- Problems will occur with return address is IRQ executes during the
- skip sequence.
-
- A support ticket from Atmel returned the following information:
-
- Subject: (ATTicket:644469) On AVR skip-bug core Erratum
- From: avr@atmel.com Date: 2011-07-27
- (Please keep the subject when replying to this mail)
-
- This errata exists only in AT90S8515 and ATmega103 devices.
-
- For information please refer the following respective errata links
- http://www.atmel.com/dyn/resources/prod_documents/doc2494.pdf
- http://www.atmel.com/dyn/resources/prod_documents/doc1436.pdf */
-
- /* Core Erratum: Must not skip 2-word instruction. */
- int errata_skip;
-
- /* Start of data section. */
- int data_section_start;
-
- /* Number of 64k segments in the flash. */
- int n_flash;
-
- /* Name of device library. */
- const char *const library_name;
-};
-
-struct arch_info_s {
- /* Architecture ID. */
- enum avr_arch arch;
-
- /* textinfo source to describe the archtiecture. */
- const char *texinfo;
-};
-
-/* Preprocessor macros to define depending on MCU type. */
-extern const char *avr_extra_arch_macro;
-extern const struct base_arch_s *avr_current_arch;
-extern const struct mcu_type_s *avr_current_device;
-extern const struct mcu_type_s avr_mcu_types[];
-extern const struct base_arch_s avr_arch_types[];
-
typedef struct
{
/* Id of the address space as used in c_register_addr_space */
diff --git a/gcc/config/avr/gen-avr-mmcu-texi.c b/gcc/config/avr/gen-avr-mmcu-texi.c
index f4cb24e..d5567e7 100644
--- a/gcc/config/avr/gen-avr-mmcu-texi.c
+++ b/gcc/config/avr/gen-avr-mmcu-texi.c
@@ -18,18 +18,52 @@
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
+#include <stdlib.h>
+#include <stdio.h>
+
+#define IN_GEN_AVR_MMCU_TEXI
+
+#include "avr-arch.h"
#include "avr-devices.c"
static const char*
mcu_name[sizeof avr_mcu_types / sizeof avr_mcu_types[0]];
+static int letter (char c)
+{
+ return c >= 'a' && c <= 'z';
+}
+
+static int digit (char c)
+{
+ return c >= '0' && c <= '9';
+}
+
static int
comparator (const void *va, const void *vb)
{
- const char* const *a = (const char* const*) va;
- const char* const *b = (const char* const*) 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 (letter (*a) && digit (*b))
+ return -1;
+
+ if (digit (*a) && letter (*b))
+ return 1;
+
+ if (*a != *b)
+ return *a - *b;
+
+ a++;
+ b++;
+ }
- return strcmp (*a, *b);
+ return *a - *b;
}
static void
@@ -61,6 +95,7 @@ int main (void)
printf ("@c This file is generated automatically using\n");
printf ("@c gcc/config/avr/gen-avr-mmcu-texi.c from:\n");
+ printf ("@c gcc/config/avr/avr-arch.h\n");
printf ("@c gcc/config/avr/avr-devices.c\n");
printf ("@c gcc/config/avr/avr-mcus.def\n\n");
diff --git a/gcc/config/avr/t-avr b/gcc/config/avr/t-avr
index 98f4c3db..f4cd26f 100644
--- a/gcc/config/avr/t-avr
+++ b/gcc/config/avr/t-avr
@@ -44,8 +44,9 @@ $(srcdir)/config/avr/avr-tables.opt: $(srcdir)/config/avr/genopt.sh $(AVR_MCUS)
$(SHELL) $< $(AVR_MCUS) > $@
gen-avr-mmcu-texi$(build_exeext): $(srcdir)/config/avr/gen-avr-mmcu-texi.c \
- $(TM_H) $(AVR_MCUS) $(srcdir)/config/avr/avr-devices.c
- $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< -o $@
+ $(AVR_MCUS) $(srcdir)/config/avr/avr-devices.c \
+ $(srcdir)/config/avr/avr-arch.h
+ $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $< -o $@
# Make sure that the -mmcu= documentation is in sync with the compiler.
$(srcdir)/doc/avr-mmcu.texi: s-avr-mmcu-texi; @true