View | Details | Return to bug 18145
Collapse All | Expand All

(-)gcc/config/avr/avr-protos.h (+3 lines)
Lines 39-44 extern int avr_simple_epilogue (void); Link Here
39
extern void gas_output_limited_string (FILE *file, const char *str);
39
extern void gas_output_limited_string (FILE *file, const char *str);
40
extern void gas_output_ascii (FILE *file, const char *str, size_t length);
40
extern void gas_output_ascii (FILE *file, const char *str, size_t length);
41
extern int avr_hard_regno_rename_ok (unsigned int, unsigned int);
41
extern int avr_hard_regno_rename_ok (unsigned int, unsigned int);
42
extern void avr_asm_output_common (FILE *stream, const char *name, unsigned HOST_WIDE_INT size, unsigned HOST_WIDE_INT rounded);
43
extern void avr_asm_output_local (FILE *stream, const char *name, unsigned HOST_WIDE_INT size, unsigned HOST_WIDE_INT rounded);
42
44
43
#ifdef TREE_CODE
45
#ifdef TREE_CODE
44
extern void asm_output_external (FILE *file, tree decl, char *name);
46
extern void asm_output_external (FILE *file, tree decl, char *name);
Lines 123-128 extern RTX_CODE avr_normalize_condition Link Here
123
extern int compare_eq_p (rtx insn);
125
extern int compare_eq_p (rtx insn);
124
extern void out_shift_with_cnt (const char *templ, rtx insn,
126
extern void out_shift_with_cnt (const char *templ, rtx insn,
125
				rtx operands[], int *len, int t_len);
127
				rtx operands[], int *len, int t_len);
128
extern rtx avr_return_addr_rtx (int count, rtx tem);
126
#endif /* RTX_CODE */
129
#endif /* RTX_CODE */
127
130
128
#ifdef HAVE_MACHINE_MODES
131
#ifdef HAVE_MACHINE_MODES
(-)gcc/config/avr/avr.c (-6 / +85 lines)
Lines 76-81 static rtx avr_function_value (const_tre Link Here
76
static void avr_insert_attributes (tree, tree *);
76
static void avr_insert_attributes (tree, tree *);
77
static void avr_asm_init_sections (void);
77
static void avr_asm_init_sections (void);
78
static unsigned int avr_section_type_flags (tree, const char *, int);
78
static unsigned int avr_section_type_flags (tree, const char *, int);
79
static void avr_asm_named_section (const char *name, unsigned int flags, tree decl);
80
/* Track if code will use .bss and/or .data */
81
static int avr_need_clear_bss_p = 0;
82
static int avr_need_copy_data_p = 0;
83
static void avr_output_data_section_asm_op (const void*);
84
static void avr_output_bss_section_asm_op (const void*);
79
85
80
static void avr_reorg (void);
86
static void avr_reorg (void);
81
static void avr_asm_out_ctor (rtx, int);
87
static void avr_asm_out_ctor (rtx, int);
Lines 4906-4911 avr_output_progmem_section_asm_op (const Link Here
4906
  fprintf (asm_out_file, "\t.p2align 1\n");
4912
  fprintf (asm_out_file, "\t.p2align 1\n");
4907
}
4913
}
4908
4914
4915
/* ASM_OUTPUT_COMMON */
4916
/* Track need of __do_clear_bss */
4917
4918
void
4919
avr_asm_output_common (FILE *stream, const char *name,
4920
                       unsigned HOST_WIDE_INT size,
4921
                       unsigned HOST_WIDE_INT rounded ATTRIBUTE_UNUSED)
4922
{
4923
    avr_need_clear_bss_p = 1;
4924
    fputs ("\t.comm ", stream);
4925
    assemble_name (stream, name);
4926
    fprintf (stream, ",%lu,1\n", (unsigned long) size);  
4927
}
4928
4929
/* ASM_OUTPUT_LOCAL */
4930
/* Track need of __do_clear_bss */
4931
4932
void
4933
avr_asm_output_local (FILE *stream, const char *name,
4934
                      unsigned HOST_WIDE_INT size,
4935
                      unsigned HOST_WIDE_INT rounded ATTRIBUTE_UNUSED)
4936
{                                                    
4937
    avr_need_clear_bss_p = 1;                           
4938
    fputs ("\t.lcomm ", stream);                      
4939
    assemble_name (stream, name);                   
4940
    fprintf (stream, ",%d\n", (int) size);           
4941
}
4942
4943
/* Unnamed section callback to track need of __do_copy_data */
4944
4945
static void
4946
avr_output_data_section_asm_op (const void *data)
4947
{
4948
    avr_need_copy_data_p = 1;
4949
    /* Dispatch to default */
4950
    output_section_asm_op (data);
4951
}
4952
4953
/* Unnamed section callback to track need of __do_clear_bss */
4954
4955
static void
4956
avr_output_bss_section_asm_op (const void *data)
4957
{
4958
    avr_need_clear_bss_p = 1;
4959
    /* Dispatch to default */
4960
    output_section_asm_op (data);
4961
}
4962
4909
/* Implement TARGET_ASM_INIT_SECTIONS.  */
4963
/* Implement TARGET_ASM_INIT_SECTIONS.  */
4910
4964
4911
static void
4965
static void
Lines 4915-4920 avr_asm_init_sections (void) Link Here
4915
					 avr_output_progmem_section_asm_op,
4969
					 avr_output_progmem_section_asm_op,
4916
					 NULL);
4970
					 NULL);
4917
  readonly_data_section = data_section;
4971
  readonly_data_section = data_section;
4972
4973
  data_section->unnamed.callback = avr_output_data_section_asm_op;
4974
  bss_section->unnamed.callback = avr_output_bss_section_asm_op;
4975
}
4976
4977
/* TARGET_ASM_NAMED_SECTION */
4978
/* Track need of __do_clear_bss, __do_copy_data for named sections */
4979
4980
static void
4981
avr_asm_named_section (const char *name, unsigned int flags, tree decl)
4982
{
4983
    if (!avr_need_copy_data_p)
4984
        avr_need_copy_data_p =
4985
            (0 == strncmp (name, ".data", 5)
4986
             || 0 == strncmp (name, ".rodata", 7)
4987
             || 0 == strncmp (name, ".gnu.linkonce.", 14));
4988
    
4989
    if (!avr_need_clear_bss_p)
4990
        avr_need_clear_bss_p = (0 == strncmp (name, ".bss", 4));
4991
    
4992
    default_elf_asm_named_section (name, flags, decl);
4918
}
4993
}
4919
4994
4920
static unsigned int
4995
static unsigned int
Lines 4953-4964 avr_file_start (void) Link Here
4953
  
5028
  
4954
  fputs ("__tmp_reg__ = 0\n" 
5029
  fputs ("__tmp_reg__ = 0\n" 
4955
         "__zero_reg__ = 1\n", asm_out_file);
5030
         "__zero_reg__ = 1\n", asm_out_file);
4956
4957
  /* FIXME: output these only if there is anything in the .data / .bss
4958
     sections - some code size could be saved by not linking in the
4959
     initialization code from libgcc if one or both sections are empty.  */
4960
  fputs ("\t.global __do_copy_data\n", asm_out_file);
4961
  fputs ("\t.global __do_clear_bss\n", asm_out_file);
4962
}
5031
}
4963
5032
4964
/* Outputs to the stdio stream FILE some
5033
/* Outputs to the stdio stream FILE some
Lines 4967-4972 avr_file_start (void) Link Here
4967
static void
5036
static void
4968
avr_file_end (void)
5037
avr_file_end (void)
4969
{
5038
{
5039
    /* Output these only if there is anything in the
5040
       .data* / .rodata* / .gnu.linkonce.* resp. .bss*
5041
       input section(s) - some code size can be saved by not
5042
       linking in the initialization code from libgcc if resp.
5043
       sections are empty. */
5044
    if (avr_need_copy_data_p)
5045
        fputs (".global __do_copy_data\n", asm_out_file);
5046
    
5047
    if (avr_need_clear_bss_p)
5048
        fputs (".global __do_clear_bss\n", asm_out_file);
4970
}
5049
}
4971
5050
4972
/* Choose the order in which to allocate hard registers for
5051
/* Choose the order in which to allocate hard registers for
(-)gcc/config/avr/avr.h (-11 / +3 lines)
Lines 544-550 do { \ Link Here
544
#define ASM_APP_OFF "/* #NOAPP */\n"
544
#define ASM_APP_OFF "/* #NOAPP */\n"
545
545
546
/* Switch into a generic section.  */
546
/* Switch into a generic section.  */
547
#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
547
#define TARGET_ASM_NAMED_SECTION avr_asm_named_section
548
#define TARGET_ASM_INIT_SECTIONS avr_asm_init_sections
548
#define TARGET_ASM_INIT_SECTIONS avr_asm_init_sections
549
549
550
#define ASM_OUTPUT_ASCII(FILE, P, SIZE)	 gas_output_ascii (FILE,P,SIZE)
550
#define ASM_OUTPUT_ASCII(FILE, P, SIZE)	 gas_output_ascii (FILE,P,SIZE)
Lines 552-572 do { \ Link Here
552
#define IS_ASM_LOGICAL_LINE_SEPARATOR(C, STR) ((C) == '\n' || ((C) == '$'))
552
#define IS_ASM_LOGICAL_LINE_SEPARATOR(C, STR) ((C) == '\n' || ((C) == '$'))
553
553
554
#define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED)			   \
554
#define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED)			   \
555
do {									   \
555
        avr_asm_output_common (STREAM, NAME, SIZE, ROUNDED)
556
     fputs ("\t.comm ", (STREAM));					   \
557
     assemble_name ((STREAM), (NAME));					   \
558
     fprintf ((STREAM), ",%lu,1\n", (unsigned long)(SIZE));		   \
559
} while (0)
560
556
561
#define ASM_OUTPUT_BSS(FILE, DECL, NAME, SIZE, ROUNDED)			\
557
#define ASM_OUTPUT_BSS(FILE, DECL, NAME, SIZE, ROUNDED)			\
562
  asm_output_bss ((FILE), (DECL), (NAME), (SIZE), (ROUNDED))
558
  asm_output_bss ((FILE), (DECL), (NAME), (SIZE), (ROUNDED))
563
559
564
#define ASM_OUTPUT_LOCAL(STREAM, NAME, SIZE, ROUNDED)			\
560
#define ASM_OUTPUT_LOCAL(STREAM, NAME, SIZE, ROUNDED)			\
565
do {									\
561
        avr_asm_output_local (STREAM, NAME, SIZE, ROUNDED)
566
     fputs ("\t.lcomm ", (STREAM));					\
567
     assemble_name ((STREAM), (NAME));					\
568
     fprintf ((STREAM), ",%d\n", (int)(SIZE));				\
569
} while (0)
570
562
571
#undef TYPE_ASM_OP
563
#undef TYPE_ASM_OP
572
#undef SIZE_ASM_OP
564
#undef SIZE_ASM_OP

Return to bug 18145