diff options
Diffstat (limited to 'gcc/config/avr')
-rw-r--r-- | gcc/config/avr/avr-protos.h | 1 | ||||
-rw-r--r-- | gcc/config/avr/avr.c | 28 | ||||
-rw-r--r-- | gcc/config/avr/avr.h | 25 |
3 files changed, 31 insertions, 23 deletions
diff --git a/gcc/config/avr/avr-protos.h b/gcc/config/avr/avr-protos.h index 930329b00ae..169be85f6d4 100644 --- a/gcc/config/avr/avr-protos.h +++ b/gcc/config/avr/avr-protos.h @@ -35,7 +35,6 @@ extern void asm_globalize_label (FILE *file, const char *name); extern void order_regs_for_local_alloc (void); extern int initial_elimination_offset (int from, int to); extern int avr_simple_epilogue (void); -extern void progmem_section (void); extern int mask_one_bit_p (HOST_WIDE_INT mask); extern void gas_output_limited_string (FILE *file, const char *str); extern void gas_output_ascii (FILE *file, const char *str, size_t length); diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index 5367bd1fdb2..f6e9f9fbd03 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -69,6 +69,7 @@ static void avr_file_end (void); static void avr_output_function_prologue (FILE *, HOST_WIDE_INT); static void avr_output_function_epilogue (FILE *, HOST_WIDE_INT); static void avr_insert_attributes (tree, tree *); +static void avr_asm_init_sections (void); static unsigned int avr_section_type_flags (tree, const char *, int); static void avr_reorg (void); @@ -114,6 +115,8 @@ static int jump_tables_size; const char *avr_base_arch_macro; const char *avr_extra_arch_macro; +section *progmem_section; + /* More than 8K of program memory: use "call" and "jmp". */ int avr_mega_p = 0; @@ -4756,6 +4759,29 @@ avr_insert_attributes (tree node, tree *attributes) } } +/* A get_unnamed_section callback for switching to progmem_section. */ + +static void +avr_output_progmem_section_asm_op (const void *arg ATTRIBUTE_UNUSED) +{ + fprintf (asm_out_file, + "\t.section .progmem.gcc_sw_table, \"%s\", @progbits\n", + AVR_MEGA ? "a" : "ax"); + /* Should already be aligned, this is just to be safe if it isn't. */ + fprintf (asm_out_file, "\t.p2align 1\n"); +} + +/* Implement TARGET_ASM_INIT_SECTIONS. */ + +static void +avr_asm_init_sections (void) +{ + progmem_section = get_unnamed_section (AVR_MEGA ? 0 : SECTION_CODE, + avr_output_progmem_section_asm_op, + NULL); + readonly_data_section = data_section; +} + static unsigned int avr_section_type_flags (tree decl, const char *name, int reloc) { @@ -5847,7 +5873,7 @@ avr_output_bld (rtx operands[], int bit_nr) void avr_output_addr_vec_elt (FILE *stream, int value) { - progmem_section (); + switch_to_section (progmem_section); if (AVR_MEGA) fprintf (stream, "\t.word pm(.L%d)\n", value); else diff --git a/gcc/config/avr/avr.h b/gcc/config/avr/avr.h index 53a0f9fb567..d69e67b7eba 100644 --- a/gcc/config/avr/avr.h +++ b/gcc/config/avr/avr.h @@ -47,6 +47,7 @@ extern const char *avr_extra_arch_macro; extern int avr_mega_p; extern int avr_enhanced_p; extern int avr_asm_only_p; +extern GTY(()) section *progmem_section; #define AVR_MEGA (avr_mega_p && !TARGET_SHORT_CALLS) #define AVR_ENHANCED (avr_enhanced_p) @@ -476,26 +477,6 @@ do { \ #define TARGET_ASM_DESTRUCTOR avr_asm_out_dtor -#define EXTRA_SECTIONS in_progmem - -#define EXTRA_SECTION_FUNCTIONS \ - \ -void \ -progmem_section (void) \ -{ \ - if (in_section != in_progmem) \ - { \ - fprintf (asm_out_file, \ - "\t.section .progmem.gcc_sw_table, \"%s\", @progbits\n", \ - AVR_MEGA ? "a" : "ax"); \ - /* Should already be aligned, this is just to be safe if it isn't. */ \ - fprintf (asm_out_file, "\t.p2align 1\n"); \ - in_section = in_progmem; \ - } \ -} - -#define READONLY_DATA_SECTION data_section - #define JUMP_TABLES_IN_TEXT_SECTION 0 #define ASM_COMMENT_START " ; " @@ -506,6 +487,7 @@ progmem_section (void) \ /* Switch into a generic section. */ #define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section +#define TARGET_ASM_INIT_SECTIONS avr_asm_init_sections #define ASM_OUTPUT_ASCII(FILE, P, SIZE) gas_output_ascii (FILE,P,SIZE) @@ -682,7 +664,8 @@ sprintf (STRING, "*.%s%lu", PREFIX, (unsigned long)(NUM)) avr_output_addr_vec_elt(STREAM, VALUE) #define ASM_OUTPUT_CASE_LABEL(STREAM, PREFIX, NUM, TABLE) \ - progmem_section (), (*targetm.asm_out.internal_label) (STREAM, PREFIX, NUM) + (switch_to_section (progmem_section), \ + (*targetm.asm_out.internal_label) (STREAM, PREFIX, NUM)) #define ASM_OUTPUT_SKIP(STREAM, N) \ fprintf (STREAM, "\t.skip %lu,0\n", (unsigned long)(N)) |