diff options
author | gjl <gjl@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-12-06 14:39:25 +0000 |
---|---|---|
committer | gjl <gjl@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-12-06 14:39:25 +0000 |
commit | 9d734fa8cb3d2255d8947e484ed998724a333568 (patch) | |
tree | 0cfaea0687caa989b7c511a83be4f8466b623d68 /gcc/config/avr/avr-c.c | |
parent | ed235da6ce3bca2f622bdf52cb556e1706662660 (diff) | |
download | gcc-9d734fa8cb3d2255d8947e484ed998724a333568.tar.gz |
PR target/51409
PR target/49868
* config/avr/avr.h (ADDR_SPACE_PGM, ADDR_SPACE_PGM1,
ADDR_SPACE_PGM2, ADDR_SPACE_PGM3, ADDR_SPACE_PGM4,
ADDR_SPACE_PGM5, ADDR_SPACE_PGMX): Write as enum.
(avr_addrspace_t): New typedef.
(avr_addrspace): New declaration.
* config/avr/avr-c.c (avr_toupper): New static function.
(avr_register_target_pragmas, avr_cpu_cpp_builtins): Use
avr_addrspace to get address space information.
* config/avr/avr.c (avr_addrspace): New variable.
(avr_out_lpm, avr_pgm_check_var_decl, avr_insert_attributes,
avr_asm_named_section, avr_section_type_flags,
avr_asm_select_section, avr_addr_space_address_mode,
avr_addr_space_convert, avr_emit_movmemhi): Use it.
(avr_addr_space_pointer_mode): Forward to avr_addr_space_address_mode.
(avr_pgm_segment): Remove.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182051 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/config/avr/avr-c.c')
-rw-r--r-- | gcc/config/avr/avr-c.c | 55 |
1 files changed, 41 insertions, 14 deletions
diff --git a/gcc/config/avr/avr-c.c b/gcc/config/avr/avr-c.c index fd03b361b5e..97a1a5ea861 100644 --- a/gcc/config/avr/avr-c.c +++ b/gcc/config/avr/avr-c.c @@ -36,16 +36,39 @@ void avr_register_target_pragmas (void) { - c_register_addr_space ("__pgm", ADDR_SPACE_PGM); - c_register_addr_space ("__pgm1", ADDR_SPACE_PGM1); - c_register_addr_space ("__pgm2", ADDR_SPACE_PGM2); - c_register_addr_space ("__pgm3", ADDR_SPACE_PGM3); - c_register_addr_space ("__pgm4", ADDR_SPACE_PGM4); - c_register_addr_space ("__pgm5", ADDR_SPACE_PGM5); - c_register_addr_space ("__pgmx", ADDR_SPACE_PGMX); + int i; + + gcc_assert (ADDR_SPACE_GENERIC == ADDR_SPACE_RAM); + + /* Register address spaces. The order must be the same as in the respective + enum from avr.h (or designated initialized must be used in avr.c). */ + + for (i = 0; avr_addrspace[i].name; i++) + { + gcc_assert (i == avr_addrspace[i].id); + + if (!ADDR_SPACE_GENERIC_P (i)) + c_register_addr_space (avr_addrspace[i].name, avr_addrspace[i].id); + } } +/* Transorm LO into uppercase and write the result to UP. + You must provide enough space for UP. Return UP. */ + +static char* +avr_toupper (char *up, const char *lo) +{ + char *up0 = up; + + for (; *lo; lo++, up++) + *up = TOUPPER (*lo); + + *up = '\0'; + + return up0; +} + /* Worker function for TARGET_CPU_CPP_BUILTINS. */ void @@ -117,13 +140,17 @@ avr_cpu_cpp_builtins (struct cpp_reader *pfile) if (!strcmp (lang_hooks.name, "GNU C")) { - cpp_define (pfile, "__PGM=__pgm"); - cpp_define (pfile, "__PGM1=__pgm1"); - cpp_define (pfile, "__PGM2=__pgm2"); - cpp_define (pfile, "__PGM3=__pgm3"); - cpp_define (pfile, "__PGM4=__pgm4"); - cpp_define (pfile, "__PGM5=__pgm5"); - cpp_define (pfile, "__PGMX=__pgmx"); + int i; + + for (i = 0; avr_addrspace[i].name; i++) + if (!ADDR_SPACE_GENERIC_P (i)) + { + const char *name = avr_addrspace[i].name; + char *Name = (char*) alloca (1 + strlen (name)); + + cpp_define_formatted (pfile, "%s=%s", + avr_toupper (Name, name), name); + } } /* Define builtin macros so that the user can |