avr.c (avr_base_arch_macro, [...]): New.

* config/avr/avr.c (avr_base_arch_macro, avr_extra_arch_macro): New.
	(avr_asm_only_p): Make non-static.
	(enum avr_arch): Remove.
	(avr_arch_types): New.
	(avr_mcu_types): Update.
	(avr_override_options): Use avr_arch_types table instead of switch.
	* avr.h (CPP_PREDEFINES): Die.
	(avr_base_arch_macro, avr_extra_arch_macro): New.
	(TARGET_CPU_CPP_BUILTINS): New.
	(CPP_SPEC, EXTRA_SPECS): Simplify.
	(CPP_AVR1_SPEC, CPP_AVR2_SPEC, CPP_AVR3_SPEC, CPP_AVR4_SPEC,
	CPP_AVR5_SPEC): Die.

Co-Authored-By: Marek Michalkiewicz <marekm@amelek.gda.pl>

From-SVN: r54023
This commit is contained in:
Neil Booth 2002-05-29 21:59:08 +00:00 committed by Marek Michalkiewicz
parent 4528173ea3
commit 92c392e657
3 changed files with 117 additions and 164 deletions

View File

@ -1,3 +1,19 @@
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Marek Michalkiewicz <marekm@amelek.gda.pl>
* config/avr/avr.c (avr_base_arch_macro, avr_extra_arch_macro): New.
(avr_asm_only_p): Make non-static.
(enum avr_arch): Remove.
(avr_arch_types): New.
(avr_mcu_types): Update.
(avr_override_options): Use avr_arch_types table instead of switch.
* avr.h (CPP_PREDEFINES): Die.
(avr_base_arch_macro, avr_extra_arch_macro): New.
(TARGET_CPU_CPP_BUILTINS): New.
(CPP_SPEC, EXTRA_SPECS): Simplify.
(CPP_AVR1_SPEC, CPP_AVR2_SPEC, CPP_AVR3_SPEC, CPP_AVR4_SPEC,
CPP_AVR5_SPEC): Die.
2002-05-29 Jason Thorpe <thorpej@wasabisystems.com>
* config/arm/netbsd.h (TARGET_OS_CPP_BUILTINS): Use

View File

@ -108,6 +108,10 @@ const char *avr_init_stack = "__stack";
/* Default MCU name */
const char *avr_mcu_name = "avr2";
/* Preprocessor macros to define depending on MCU type. */
const char *avr_base_arch_macro;
const char *avr_extra_arch_macro;
/* More than 8K of program memory: use "call" and "jmp". */
int avr_mega_p = 0;
@ -115,19 +119,29 @@ int avr_mega_p = 0;
int avr_enhanced_p = 0;
/* Assembler only. */
static int avr_asm_only_p = 0;
int avr_asm_only_p = 0;
enum avr_arch {
AVR1 = 1,
AVR2,
AVR3,
AVR4,
AVR5
struct base_arch_s {
int asm_only;
int enhanced;
int mega;
const char *const macro;
};
static const struct base_arch_s avr_arch_types[] = {
{ 1, 0, 0, NULL }, /* unknown device specified */
{ 1, 0, 0, "__AVR_ARCH__=1" },
{ 0, 0, 0, "__AVR_ARCH__=2" },
{ 0, 0, 1, "__AVR_ARCH__=3" },
{ 0, 1, 0, "__AVR_ARCH__=4" },
{ 0, 1, 1, "__AVR_ARCH__=5" }
};
struct mcu_type_s {
const char *const name;
const enum avr_arch arch;
int arch; /* index in avr_arch_types[] */
/* Must lie outside user's namespace. NULL == no macro. */
const char *const macro;
};
/* List of all known AVR MCU types - if updated, it has to be kept
@ -140,52 +154,52 @@ struct mcu_type_s {
static const struct mcu_type_s avr_mcu_types[] = {
/* Classic, <= 8K. */
{ "avr2", AVR2 },
{ "at90s2313", AVR2 },
{ "at90s2323", AVR2 },
{ "at90s2333", AVR2 },
{ "at90s2343", AVR2 },
{ "attiny22", AVR2 },
{ "attiny26", AVR2 },
{ "at90s4414", AVR2 },
{ "at90s4433", AVR2 },
{ "at90s4434", AVR2 },
{ "at90s8515", AVR2 },
{ "at90c8534", AVR2 },
{ "at90s8535", AVR2 },
{ "avr2", 2, NULL },
{ "at90s2313", 2, "__AVR_AT90S2313__" },
{ "at90s2323", 2, "__AVR_AT90S2323__" },
{ "at90s2333", 2, "__AVR_AT90S2333__" },
{ "at90s2343", 2, "__AVR_AT90S2343__" },
{ "attiny22", 2, "__AVR_ATtiny22__" },
{ "attiny26", 2, "__AVR_ATtiny26__" },
{ "at90s4414", 2, "__AVR_AT90S4414__" },
{ "at90s4433", 2, "__AVR_AT90S4433__" },
{ "at90s4434", 2, "__AVR_AT90S4434__" },
{ "at90s8515", 2, "__AVR_AT90S8515__" },
{ "at90c8534", 2, "__AVR_AT90C8534__" },
{ "at90s8535", 2, "__AVR_AT90S8535__" },
/* Classic, > 8K. */
{ "avr3", AVR3 },
{ "atmega103", AVR3 },
{ "atmega603", AVR3 },
{ "at43usb320", AVR3 },
{ "at43usb355", AVR3 },
{ "at76c711", AVR3 },
{ "avr3", 3, NULL },
{ "atmega103", 3, "__AVR_ATmega603__" },
{ "atmega603", 3, "__AVR_ATmega103__" },
{ "at43usb320", 3, "__AVR_AT43USB320__" },
{ "at43usb355", 3, "__AVR_AT43USB355__" },
{ "at76c711", 3, "__AVR_AT76C711__" },
/* Enhanced, <= 8K. */
{ "avr4", AVR4 },
{ "atmega8", AVR4 },
{ "atmega83", AVR4 },
{ "atmega85", AVR4 },
{ "atmega8515", AVR4 },
{ "avr4", 4, NULL },
{ "atmega8", 4, "__AVR_ATmega8__" },
{ "atmega83", 4, "__AVR_ATmega83__" },
{ "atmega85", 4, "__AVR_ATmega85__" },
{ "atmega8515", 4, "__AVR_ATmega8515__" },
/* Enhanced, > 8K. */
{ "avr5", AVR5 },
{ "atmega16", AVR5 },
{ "atmega161", AVR5 },
{ "atmega162", AVR5 },
{ "atmega163", AVR5 },
{ "atmega32", AVR5 },
{ "atmega323", AVR5 },
{ "atmega64", AVR5 },
{ "atmega128", AVR5 },
{ "at94k", AVR5 },
{ "avr5", 5, NULL },
{ "atmega16", 5, "__AVR_ATmega16__" },
{ "atmega161", 5, "__AVR_ATmega161__" },
{ "atmega162", 5, "__AVR_ATmega162__" },
{ "atmega163", 5, "__AVR_ATmega163__" },
{ "atmega32", 5, "__AVR_ATmega32__" },
{ "atmega323", 5, "__AVR_ATmega323__" },
{ "atmega64", 5, "__AVR_ATmega64__" },
{ "atmega128", 5, "__AVR_ATmega128__" },
{ "at94k", 5, "__AVR_AT94K__" },
/* Assembler only. */
{ "avr1", AVR1 },
{ "at90s1200", AVR1 },
{ "attiny10", AVR1 },
{ "attiny11", AVR1 },
{ "attiny12", AVR1 },
{ "attiny15", AVR1 },
{ "attiny28", AVR1 },
{ NULL, 0 }
{ "avr1", 1, NULL },
{ "at90s1200", 1, "__AVR_AT90S1200__" },
{ "attiny10", 1, "__AVR_ATtiny11__" }, /* Yes, tiny11. */
{ "attiny11", 1, "__AVR_ATtiny11__" },
{ "attiny12", 1, "__AVR_ATtiny12__" },
{ "attiny15", 1, "__AVR_ATtiny15__" },
{ "attiny28", 1, "__AVR_ATtiny28__" },
{ NULL, 0, NULL }
};
int avr_case_values_threshold = 30000;
@ -213,6 +227,7 @@ void
avr_override_options ()
{
const struct mcu_type_s *t;
const struct base_arch_s *base;
for (t = avr_mcu_types; t->name; t++)
if (strcmp (t->name, avr_mcu_name) == 0)
@ -226,17 +241,12 @@ avr_override_options ()
fprintf (stderr," %s\n", t->name);
}
switch (t->arch)
{
case AVR1:
default:
avr_asm_only_p = 1;
/* ... fall through ... */
case AVR2: avr_enhanced_p = 0; avr_mega_p = 0; break;
case AVR3: avr_enhanced_p = 0; avr_mega_p = 1; break;
case AVR4: avr_enhanced_p = 1; avr_mega_p = 0; break;
case AVR5: avr_enhanced_p = 1; avr_mega_p = 1; break;
}
base = &avr_arch_types[t->arch];
avr_asm_only_p = base->asm_only;
avr_enhanced_p = base->enhanced;
avr_mega_p = base->mega;
avr_base_arch_macro = base->macro;
avr_extra_arch_macro = t->macro;
if (optimize && !TARGET_NO_TABLEJUMP)
avr_case_values_threshold = (!AVR_MEGA || TARGET_CALL_PROLOGUES) ? 8 : 17;

View File

@ -22,8 +22,28 @@ Boston, MA 02111-1307, USA. */
/* Names to predefine in the preprocessor for this target machine. */
#define CPP_PREDEFINES "-DAVR"
#define TARGET_CPU_CPP_BUILTINS() \
do \
{ \
builtin_define_std ("AVR"); \
if (avr_base_arch_macro) \
builtin_define (avr_base_arch_macro); \
if (avr_extra_arch_macro) \
builtin_define (avr_extra_arch_macro); \
if (avr_asm_only_p) \
builtin_define ("__AVR_ASM_ONLY__"); \
if (avr_enhanced_p) \
builtin_define ("__AVR_ENHANCED__"); \
if (avr_mega_p) \
builtin_define ("__AVR_MEGA__"); \
if (TARGET_NO_INTERRUPTS) \
builtin_define ("__NO_INTERRUPTS__"); \
if (TARGET_INT8) \
builtin_define ("__INT_MAX__=127"); \
else \
builtin_define ("__INT_MAX__=32767"); \
} \
while (0)
/* This declaration should be present. */
extern int target_flags;
@ -54,9 +74,6 @@ extern int target_flags;
#define TARGET_RTL_DUMP (target_flags & MASK_RTL_DUMP)
#define TARGET_ALL_DEBUG (target_flags & MASK_ALL_DEBUG)
#define TARGET_SWITCHES { \
{ "order1", MASK_ORDER_1, NULL }, \
{ "order2", MASK_ORDER_2, NULL }, \
@ -77,8 +94,12 @@ extern int target_flags;
extern const char *avr_init_stack;
extern const char *avr_mcu_name;
extern const char *avr_base_arch_macro;
extern const char *avr_extra_arch_macro;
extern int avr_mega_p;
extern int avr_enhanced_p;
extern int avr_asm_only_p;
#define AVR_MEGA (avr_mega_p)
#define AVR_ENHANCED (avr_enhanced_p)
@ -2513,51 +2534,8 @@ extern int avr_case_values_threshold;
(and ANSI C) library functions `memcpy' and `memset' rather than
the BSD functions `bcopy' and `bzero'. */
#define CPP_SPEC "\
%{!mmcu*|mmcu=avr2:%(cpp_avr2)} \
%{mmcu=at90s2313:%(cpp_avr2) -D__AVR_AT90S2313__} \
%{mmcu=at90s2323:%(cpp_avr2) -D__AVR_AT90S2323__} \
%{mmcu=at90s2333:%(cpp_avr2) -D__AVR_AT90S2333__} \
%{mmcu=at90s2343:%(cpp_avr2) -D__AVR_AT90S2343__} \
%{mmcu=attiny22: %(cpp_avr2) -D__AVR_ATtiny22__} \
%{mmcu=attiny26: %(cpp_avr2) -D__AVR_ATtiny26__} \
%{mmcu=at90s4433:%(cpp_avr2) -D__AVR_AT90S4433__} \
%{mmcu=at90s4414:%(cpp_avr2) -D__AVR_AT90S4414__} \
%{mmcu=at90s4434:%(cpp_avr2) -D__AVR_AT90S4434__} \
%{mmcu=at90s8515:%(cpp_avr2) -D__AVR_AT90S8515__} \
%{mmcu=at90s8535:%(cpp_avr2) -D__AVR_AT90S8535__} \
%{mmcu=at90c8534:%(cpp_avr2) -D__AVR_AT90C8534__} \
%{mmcu=avr3:%(cpp_avr3)} \
%{mmcu=atmega603:%(cpp_avr3) -D__AVR_ATmega603__} \
%{mmcu=atmega103:%(cpp_avr3) -D__AVR_ATmega103__} \
%{mmcu=at43usb320:%(cpp_avr3) -D__AVR_AT43USB320__} \
%{mmcu=at43usb355:%(cpp_avr3) -D__AVR_AT43USB355__} \
%{mmcu=at76c711: %(cpp_avr3) -D__AVR_AT76C711__} \
%{mmcu=avr4:%(cpp_avr4)} \
%{mmcu=atmega8: %(cpp_avr4) -D__AVR_ATmega8__} \
%{mmcu=atmega83: %(cpp_avr4) -D__AVR_ATmega83__} \
%{mmcu=atmega85: %(cpp_avr4) -D__AVR_ATmega85__} \
%{mmcu=atmega8515: %(cpp_avr4) -D__AVR_ATmega8515__} \
%{mmcu=avr5:%(cpp_avr5)} \
%{mmcu=atmega16: %(cpp_avr5) -D__AVR_ATmega16__} \
%{mmcu=atmega161:%(cpp_avr5) -D__AVR_ATmega161__} \
%{mmcu=atmega162:%(cpp_avr5) -D__AVR_ATmega162__} \
%{mmcu=atmega163:%(cpp_avr5) -D__AVR_ATmega163__} \
%{mmcu=atmega32: %(cpp_avr5) -D__AVR_ATmega32__} \
%{mmcu=atmega323:%(cpp_avr5) -D__AVR_ATmega323__} \
%{mmcu=atmega64: %(cpp_avr5) -D__AVR_ATmega64__} \
%{mmcu=atmega128:%(cpp_avr5) -D__AVR_ATmega128__} \
%{mmcu=at94k: %(cpp_avr5) -D__AVR_AT94K__} \
%{mmcu=avr1:%(cpp_avr1)} \
%{mmcu=at90s1200:%(cpp_avr1) -D__AVR_AT90S1200__} \
%{mmcu=attiny10|mmcu=attiny11: %(cpp_avr1) -D__AVR_ATtiny11__} \
%{mmcu=attiny12: %(cpp_avr1) -D__AVR_ATtiny12__} \
%{mmcu=attiny15: %(cpp_avr1) -D__AVR_ATtiny15__} \
%{mmcu=attiny28: %(cpp_avr1) -D__AVR_ATtiny28__} \
%{mno-interrupts:-D__NO_INTERRUPTS__} \
%{mint8:-D__INT_MAX__=127} \
%{!mint*:-D__INT_MAX__=32767} \
%{posix:-D_POSIX_SOURCE}"
#define CPP_SPEC "%{posix:-D_POSIX_SOURCE}"
/* A C string constant that tells the GNU CC driver program options to
pass to CPP. It can also specify how to translate options you
give to GNU CC into options for GNU CC to pass to the CPP.
@ -2700,62 +2678,11 @@ extern int avr_case_values_threshold;
%{mmcu=atmega128:crtm128.o%s} \
%{mmcu=at94k:crtat94k.o%s}"
#define CPP_AVR1_SPEC "-D__AVR_ARCH__=1 -D__AVR_ASM_ONLY__ "
#define CPP_AVR2_SPEC "-D__AVR_ARCH__=2 "
#define CPP_AVR3_SPEC "-D__AVR_ARCH__=3 -D__AVR_MEGA__ "
#define CPP_AVR4_SPEC "-D__AVR_ARCH__=4 -D__AVR_ENHANCED__ "
#define CPP_AVR5_SPEC "-D__AVR_ARCH__=5 -D__AVR_ENHANCED__ -D__AVR_MEGA__ "
#define EXTRA_SPECS {"crt_binutils", CRT_BINUTILS_SPECS},
#define EXTRA_SPECS \
{"cpp_avr1", CPP_AVR1_SPEC}, \
{"cpp_avr2", CPP_AVR2_SPEC}, \
{"cpp_avr3", CPP_AVR3_SPEC}, \
{"cpp_avr4", CPP_AVR4_SPEC}, \
{"cpp_avr5", CPP_AVR5_SPEC}, \
{"crt_binutils", CRT_BINUTILS_SPECS},
/* Define this macro to provide additional specifications to put in
the `specs' file that can be used in various specifications like
`CC1_SPEC'.
The definition should be an initializer for an array of structures,
containing a string constant, that defines the specification name,
and a string constant that provides the specification.
Do not define this macro if it does not need to do anything.
`EXTRA_SPECS' is useful when an architecture contains several
related targets, which have various `..._SPECS' which are similar
to each other, and the maintainer would like one central place to
keep these definitions.
For example, the PowerPC System V.4 targets use `EXTRA_SPECS' to
define either `_CALL_SYSV' when the System V calling sequence is
used or `_CALL_AIX' when the older AIX-based calling sequence is
used.
The `config/rs6000/rs6000.h' target file defines:
#define EXTRA_SPECS \
{ "cpp_sysv_default", CPP_SYSV_DEFAULT },
#define CPP_SYS_DEFAULT ""
The `config/rs6000/sysv.h' target file defines:
#undef CPP_SPEC
#define CPP_SPEC \
"%{posix: -D_POSIX_SOURCE } \
%{mcall-sysv: -D_CALL_SYSV } %{mcall-aix: -D_CALL_AIX } \
%{!mcall-sysv: %{!mcall-aix: %(cpp_sysv_default) }} \
%{msoft-float: -D_SOFT_FLOAT} %{mcpu=403: -D_SOFT_FLOAT}"
#undef CPP_SYSV_DEFAULT
#define CPP_SYSV_DEFAULT "-D_CALL_SYSV"
while the `config/rs6000/eabiaix.h' target file defines
`CPP_SYSV_DEFAULT' as:
#undef CPP_SYSV_DEFAULT
#define CPP_SYSV_DEFAULT "-D_CALL_AIX" */
`CC1_SPEC'. */
/* This is the default without any -mmcu=* option (AT90S*). */
#define MULTILIB_DEFAULTS { "mmcu=avr2" }