const char *avr_base_arch_macro;
const char *avr_extra_arch_macro;
+/* Current architecture. */
+const struct base_arch_s *avr_current_arch;
+
section *progmem_section;
/* More than 8K of program memory: use "call" and "jmp". */
/* Core have 'MOVW' and 'LPM Rx,Z' instructions. */
int avr_have_movw_lpmx_p = 0;
-struct base_arch_s {
- int asm_only;
- int have_mul;
- int mega;
- int have_movw_lpmx;
- const char *const macro;
-};
-
static const struct base_arch_s avr_arch_types[] = {
- { 1, 0, 0, 0, NULL }, /* unknown device specified */
- { 1, 0, 0, 0, "__AVR_ARCH__=1" },
- { 0, 0, 0, 0, "__AVR_ARCH__=2" },
- { 0, 0, 0, 1, "__AVR_ARCH__=25"},
- { 0, 0, 1, 0, "__AVR_ARCH__=3" },
- { 0, 0, 1, 1, "__AVR_ARCH__=35"},
- { 0, 1, 0, 1, "__AVR_ARCH__=4" },
- { 0, 1, 1, 1, "__AVR_ARCH__=5" }
+ { 1, 0, 0, 0, 0, 0, 0, 0, NULL }, /* unknown device specified */
+ { 1, 0, 0, 0, 0, 0, 0, 0, "__AVR_ARCH__=1" },
+ { 0, 0, 0, 0, 0, 0, 0, 0, "__AVR_ARCH__=2" },
+ { 0, 0, 0, 1, 0, 0, 0, 0, "__AVR_ARCH__=25" },
+ { 0, 0, 1, 0, 0, 0, 0, 0, "__AVR_ARCH__=3" },
+ { 0, 0, 1, 0, 1, 0, 0, 0, "__AVR_ARCH__=31" },
+ { 0, 0, 1, 1, 0, 0, 0, 0, "__AVR_ARCH__=35" },
+ { 0, 1, 0, 1, 0, 0, 0, 0, "__AVR_ARCH__=4" },
+ { 0, 1, 1, 1, 0, 0, 0, 0, "__AVR_ARCH__=5" },
+ { 0, 1, 1, 1, 1, 1, 0, 0, "__AVR_ARCH__=51" }
};
/* These names are used as the index into the avr_arch_types[] table
ARCH_AVR2,
ARCH_AVR25,
ARCH_AVR3,
+ ARCH_AVR31,
ARCH_AVR35,
ARCH_AVR4,
- ARCH_AVR5
+ ARCH_AVR5,
+ ARCH_AVR51
};
struct mcu_type_s {
{ "attiny48", ARCH_AVR25, "__AVR_ATtiny48__" },
{ "attiny88", ARCH_AVR25, "__AVR_ATtiny88__" },
{ "at86rf401", ARCH_AVR25, "__AVR_AT86RF401__" },
- /* Classic, > 8K. */
+ /* Classic, > 8K, <= 64K. */
{ "avr3", ARCH_AVR3, NULL },
- { "atmega103", ARCH_AVR3, "__AVR_ATmega103__" },
{ "at43usb320", ARCH_AVR3, "__AVR_AT43USB320__" },
{ "at43usb355", ARCH_AVR3, "__AVR_AT43USB355__" },
{ "at76c711", ARCH_AVR3, "__AVR_AT76C711__" },
+ /* Classic, == 128K. */
+ { "avr31", ARCH_AVR31, NULL },
+ { "atmega103", ARCH_AVR3, "__AVR_ATmega103__" },
/* Classic + MOVW + JMP/CALL. */
{ "avr35", ARCH_AVR35, NULL },
{ "at90usb82", ARCH_AVR35, "__AVR_AT90USB82__" },
{ "at90pwm2b", ARCH_AVR4, "__AVR_AT90PWM2B__" },
{ "at90pwm3", ARCH_AVR4, "__AVR_AT90PWM3__" },
{ "at90pwm3b", ARCH_AVR4, "__AVR_AT90PWM3B__" },
- /* Enhanced, > 8K. */
+ /* Enhanced, > 8K, <= 64K. */
{ "avr5", ARCH_AVR5, NULL },
{ "atmega16", ARCH_AVR5, "__AVR_ATmega16__" },
{ "atmega161", ARCH_AVR5, "__AVR_ATmega161__" },
{ "atmega6450", ARCH_AVR5, "__AVR_ATmega6450__" },
{ "atmega649", ARCH_AVR5, "__AVR_ATmega649__" },
{ "atmega6490", ARCH_AVR5, "__AVR_ATmega6490__" },
- { "atmega128", ARCH_AVR5, "__AVR_ATmega128__" },
- { "atmega1280", ARCH_AVR5, "__AVR_ATmega1280__" },
- { "atmega1281", ARCH_AVR5, "__AVR_ATmega1281__" },
- { "atmega1284p", ARCH_AVR5, "__AVR_ATmega1284P__" },
{ "atmega16hva", ARCH_AVR5, "__AVR_ATmega16HVA__" },
{ "at90can32", ARCH_AVR5, "__AVR_AT90CAN32__" },
{ "at90can64", ARCH_AVR5, "__AVR_AT90CAN64__" },
- { "at90can128", ARCH_AVR5, "__AVR_AT90CAN128__" },
{ "at90pwm216", ARCH_AVR5, "__AVR_AT90PWM216__" },
{ "at90pwm316", ARCH_AVR5, "__AVR_AT90PWM316__" },
{ "at90usb646", ARCH_AVR5, "__AVR_AT90USB646__" },
{ "at90usb647", ARCH_AVR5, "__AVR_AT90USB647__" },
- { "at90usb1286", ARCH_AVR5, "__AVR_AT90USB1286__" },
- { "at90usb1287", ARCH_AVR5, "__AVR_AT90USB1287__" },
{ "at94k", ARCH_AVR5, "__AVR_AT94K__" },
+ /* Enhanced, == 128K. */
+ { "avr51", ARCH_AVR51, NULL },
+ { "atmega128", ARCH_AVR51, "__AVR_ATmega128__" },
+ { "atmega1280", ARCH_AVR51, "__AVR_ATmega1280__" },
+ { "atmega1281", ARCH_AVR51, "__AVR_ATmega1281__" },
+ { "atmega1284p", ARCH_AVR51, "__AVR_ATmega1284P__" },
+ { "at90can128", ARCH_AVR51, "__AVR_AT90CAN128__" },
+ { "at90usb1286", ARCH_AVR51, "__AVR_AT90USB1286__" },
+ { "at90usb1287", ARCH_AVR51, "__AVR_AT90USB1287__" },
/* Assembler only. */
{ "avr1", ARCH_AVR1, NULL },
{ "at90s1200", ARCH_AVR1, "__AVR_AT90S1200__" },
fprintf (stderr," %s\n", t->name);
}
+ avr_current_arch = &avr_arch_types[t->arch];
base = &avr_arch_types[t->arch];
avr_asm_only_p = base->asm_only;
avr_have_mul_p = base->have_mul;
- avr_mega_p = base->mega;
+ avr_mega_p = base->have_jmp_call;
avr_have_movw_lpmx_p = base->have_movw_lpmx;
avr_base_arch_macro = base->macro;
avr_extra_arch_macro = t->macro;
/* 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;
+
+ /* Reserved. */
+ int reserved;
+
+ const char *const macro;
+};
+
+extern const struct base_arch_s *avr_current_arch;
+
#define TARGET_CPU_CPP_BUILTINS() \
do \
{ \
builtin_define (avr_base_arch_macro); \
if (avr_extra_arch_macro) \
builtin_define (avr_extra_arch_macro); \
+ if (avr_current_arch->have_elpm) \
+ builtin_define ("__AVR_HAVE_RAMPZ__"); \
+ if (avr_current_arch->have_elpm) \
+ builtin_define ("__AVR_HAVE_ELPM__"); \
+ if (avr_current_arch->have_elpmx) \
+ builtin_define ("__AVR_HAVE_ELPMX__"); \
if (avr_have_movw_lpmx_p) \
builtin_define ("__AVR_HAVE_MOVW__"); \
if (avr_have_movw_lpmx_p) \
builtin_define ("__AVR_ENHANCED__"); \
if (avr_have_mul_p) \
builtin_define ("__AVR_HAVE_MUL__"); \
- if (avr_mega_p) \
+ if (avr_current_arch->have_jmp_call) \
builtin_define ("__AVR_MEGA__"); \
+ if (avr_current_arch->have_jmp_call) \
+ builtin_define ("__AVR_HAVE_JMP_CALL__"); \
if (TARGET_NO_INTERRUPTS) \
builtin_define ("__NO_INTERRUPTS__"); \
} \
/* A C string constant that tells the GCC driver program options to
pass to `cc1plus'. */
-#define ASM_SPEC "%{mmcu=avr25:-mmcu=avr2;mmcu=avr35:-mmcu=avr3;\
+#define ASM_SPEC "%{mmcu=avr25:-mmcu=avr2;mmcu=avr35:-mmcu=avr3;mmcu=avr31:-mmcu=avr3;mmcu=avr51:-mmcu=avr5;\
mmcu=*:-mmcu=%*}"
#define LINK_SPEC "\
%{mmcu=attiny43u:crttn43u.o%s} \
%{mmcu=attiny48:crttn48.o%s} \
%{mmcu=attiny88:crttn88.o%s} \
-%{mmcu=atmega103|mmcu=avr3:crtm103.o%s} \
-%{mmcu=at43usb320:crt43320.o%s} \
+%{mmcu=at43usb320|mmcu=avr3:crt43320.o%s} \
%{mmcu=at43usb355:crt43355.o%s} \
%{mmcu=at76c711:crt76711.o%s} \
+%{mmcu=atmega103|mmcu=avr31:crtm103.o%s} \
%{mmcu=at90usb162|mmcu=avr35:crtusb162.o%s} \
%{mmcu=at90usb82:crtusb82.o%s} \
%{mmcu=atmega8|mmcu=avr4:crtm8.o%s} \
%{mmcu=atmega6450:crtm6450.o%s} \
%{mmcu=atmega649:crtm649.o%s} \
%{mmcu=atmega6490:crtm6490.o%s} \
-%{mmcu=atmega128:crtm128.o%s} \
-%{mmcu=atmega1280:crtm1280.o%s} \
-%{mmcu=atmega1281:crtm1281.o%s} \
-%{mmcu=atmega1284p:crtm1284p.o%s} \
%{mmcu=atmega8hva:crtm8hva.o%s} \
%{mmcu=atmega16hva:crtm16hva.o%s} \
%{mmcu=at90can32:crtcan32.o%s} \
%{mmcu=at90can64:crtcan64.o%s} \
-%{mmcu=at90can128:crtcan128.o%s} \
%{mmcu=at90pwm216:crt90pwm216.o%s} \
%{mmcu=at90pwm316:crt90pwm316.o%s} \
%{mmcu=at90usb646:crtusb646.o%s} \
%{mmcu=at90usb647:crtusb647.o%s} \
+%{mmcu=at94k:crtat94k.o%s} \
+%{mmcu=atmega128|mmcu=avr51:crtm128.o%s} \
+%{mmcu=atmega1280:crtm1280.o%s} \
+%{mmcu=atmega1281:crtm1281.o%s} \
+%{mmcu=atmega1284p:crtm1284p.o%s} \
+%{mmcu=at90can128:crtcan128.o%s} \
%{mmcu=at90usb1286:crtusb1286.o%s} \
-%{mmcu=at90usb1287:crtusb1287.o%s} \
-%{mmcu=at94k:crtat94k.o%s}"
+%{mmcu=at90usb1287:crtusb1287.o%s}"
#define EXTRA_SPECS {"crt_binutils", CRT_BINUTILS_SPECS},