Commit 562f552b by Georg-Johann Lay Committed by Georg-Johann Lay

re PR target/51409 ([avr] Build fails if configured for other languages than from c-family)

	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.

From-SVN: r182051
parent 5de62d00
2011-12-06 Georg-Johann Lay <avr@gjlay.de>
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.
2011-12-06 Richard Guenther <rguenther@suse.de>
PR middle-end/50601
......@@ -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
......
......@@ -133,6 +133,40 @@ 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 */
unsigned char id;
/* Flavour of memory: 0 = RAM, 1 = Flash */
int memory_class;
/* Width of pointer (in bytes) */
int pointer_size;
/* Name of the address space as visible to the user */
const char *name;
/* Segment (i.e. 64k memory chunk) number. */
int segment;
} avr_addrspace_t;
extern const avr_addrspace_t avr_addrspace[];
/* Known address spaces */
enum
{
ADDR_SPACE_RAM,
ADDR_SPACE_PGM,
ADDR_SPACE_PGM1,
ADDR_SPACE_PGM2,
ADDR_SPACE_PGM3,
ADDR_SPACE_PGM4,
ADDR_SPACE_PGM5,
ADDR_SPACE_PGMX
};
#define TARGET_CPU_CPP_BUILTINS() avr_cpu_cpp_builtins (pfile)
#define AVR_HAVE_JMP_CALL (avr_current_arch->have_jmp_call && !TARGET_SHORT_CALLS)
......@@ -401,15 +435,6 @@ typedef struct avr_args {
#define NO_FUNCTION_CSE
#define ADDR_SPACE_PGM 1
#define ADDR_SPACE_PGM1 2
#define ADDR_SPACE_PGM2 3
#define ADDR_SPACE_PGM3 4
#define ADDR_SPACE_PGM4 5
#define ADDR_SPACE_PGM5 6
#define ADDR_SPACE_PGMX 7
#define REGISTER_TARGET_PRAGMAS() \
do { \
avr_register_target_pragmas(); \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment