]> git.pld-linux.org Git - packages/crossavr-gcc.git/blob - crossavr-gcc-zz-atmega256x.patch
- updated for 4.2.3
[packages/crossavr-gcc.git] / crossavr-gcc-zz-atmega256x.patch
1 diff -uNdr gcc-4.2.3.old/gcc/config/avr/avr.c gcc-4.2.3/gcc/config/avr/avr.c
2 --- gcc-4.2.3.old/gcc/config/avr/avr.c  2008-01-06 23:28:41.000000000 +0100
3 +++ gcc-4.2.3/gcc/config/avr/avr.c      2008-02-16 11:01:35.000000000 +0100
4 @@ -129,23 +129,29 @@
5  /* Core have 'MOVW' and 'LPM Rx,Z' instructions.  */
6  int avr_have_movw_lpmx_p = 0;
7  
8 +/* Usually holds the value 2, but could be 3 for the larger devices with a
9 +   3-byte program counter.  */
10 +int avr_pc_size = 2;
11 +
12  struct base_arch_s {
13    int asm_only;
14    int enhanced;
15    int mega;
16    int have_movw_lpmx;
17 +  int three_byte_pc;
18    const char *const macro;
19  };
20  
21  static const struct base_arch_s avr_arch_types[] = {
22 -  { 1, 0, 0, 0,  NULL },  /* unknown device specified */
23 -  { 1, 0, 0, 0, "__AVR_ARCH__=1" },
24 -  { 0, 0, 0, 0, "__AVR_ARCH__=2" },
25 -  { 0, 0, 0, 1, "__AVR_ARCH__=25"},
26 -  { 0, 0, 1, 0, "__AVR_ARCH__=3" },
27 -  { 0, 0, 1, 1, "__AVR_ARCH__=35"},
28 -  { 0, 1, 0, 1, "__AVR_ARCH__=4" },
29 -  { 0, 1, 1, 1, "__AVR_ARCH__=5" }
30 +  { 1, 0, 0, 0, 0, NULL },  /* unknown device specified */
31 +  { 1, 0, 0, 0, 0, "__AVR_ARCH__=1" },
32 +  { 0, 0, 0, 0, 0, "__AVR_ARCH__=2" },
33 +  { 0, 0, 0, 1, 0, "__AVR_ARCH__=25"},
34 +  { 0, 0, 1, 0, 0, "__AVR_ARCH__=3" },
35 +  { 0, 0, 1, 1, 0, "__AVR_ARCH__=35"},
36 +  { 0, 1, 0, 1, 0, "__AVR_ARCH__=4" },
37 +  { 0, 1, 1, 1, 0, "__AVR_ARCH__=5" },
38 +  { 0, 1, 1, 1, 1, "__AVR_ARCH__=6" }
39  };
40  
41  /* These names are used as the index into the avr_arch_types[] table 
42 @@ -160,7 +166,8 @@
43    ARCH_AVR3,
44    ARCH_AVR35,
45    ARCH_AVR4,
46 -  ARCH_AVR5
47 +  ARCH_AVR5,
48 +  ARCH_AVR6
49  };
50  
51  struct mcu_type_s {
52 @@ -273,6 +280,10 @@
53    { "at90usb1286",  ARCH_AVR5, "__AVR_AT90USB1286__" },
54    { "at90usb1287",  ARCH_AVR5, "__AVR_AT90USB1287__" },
55    { "at94k",        ARCH_AVR5, "__AVR_AT94K__" },
56 +    /* 3-Byte PC */
57 +  { "avr6",         ARCH_AVR6, NULL },
58 +  { "atmega2560",   ARCH_AVR6, "__AVR_ATmega2560__" },
59 +  { "atmega2561",   ARCH_AVR6, "__AVR_ATmega2561__" },
60      /* Assembler only.  */
61    { "avr1",         ARCH_AVR1, NULL },
62    { "at90s1200",    ARCH_AVR1, "__AVR_AT90S1200__" },
63 @@ -358,6 +369,11 @@
64    avr_base_arch_macro = base->macro;
65    avr_extra_arch_macro = t->macro;
66  
67 +  if (base->three_byte_pc)
68 +    avr_pc_size = 3;
69 +  else
70 +    avr_pc_size = 2;
71 +
72    if (optimize && !TARGET_NO_TABLEJUMP)
73      avr_case_values_threshold = (!AVR_MEGA || TARGET_CALL_PROLOGUES) ? 8 : 17;
74  
75 @@ -486,7 +502,7 @@
76        int offset = frame_pointer_needed ? 2 : 0;
77  
78        offset += avr_regs_to_save (NULL);
79 -      return get_frame_size () + 2 + 1 + offset;
80 +      return get_frame_size () + (avr_pc_size) + 1 + offset;
81      }
82  }
83  
84 @@ -670,7 +686,6 @@
85    int reg;
86    int interrupt_func_p;
87    int signal_func_p;
88 -  int main_p;
89    int live_seq;
90    int minimize;
91  
92 @@ -688,7 +703,6 @@
93  
94    interrupt_func_p = interrupt_function_p (current_function_decl);
95    signal_func_p = signal_function_p (current_function_decl);
96 -  main_p = MAIN_NAME_P (DECL_NAME (current_function_decl));
97    live_seq = sequent_regs_live ();
98    minimize = (TARGET_CALL_PROLOGUES
99               && !interrupt_func_p && !signal_func_p && live_seq);
100 @@ -708,25 +722,14 @@
101                AS1 (clr,__zero_reg__)    "\n");
102        prologue_size += 5;
103      }
104 -  if (main_p)
105 -    {
106 -      fprintf (file, ("\t" 
107 -                     AS1 (ldi,r28) ",lo8(%s - " HOST_WIDE_INT_PRINT_DEC ")" CR_TAB
108 -                     AS1 (ldi,r29) ",hi8(%s - " HOST_WIDE_INT_PRINT_DEC ")" CR_TAB
109 -                     AS2 (out,__SP_H__,r29)     CR_TAB
110 -                     AS2 (out,__SP_L__,r28) "\n"),
111 -              avr_init_stack, size, avr_init_stack, size);
112 -      
113 -      prologue_size += 4;
114 -    }
115 -  else if (minimize && (frame_pointer_needed || live_seq > 6)) 
116 +  if (minimize && (frame_pointer_needed || live_seq > 6)) 
117      {
118        fprintf (file, ("\t"
119                       AS1 (ldi, r26) ",lo8(" HOST_WIDE_INT_PRINT_DEC ")" CR_TAB
120                       AS1 (ldi, r27) ",hi8(" HOST_WIDE_INT_PRINT_DEC ")" CR_TAB), size, size);
121  
122 -      fputs ((AS2 (ldi,r30,pm_lo8(1f)) CR_TAB
123 -             AS2 (ldi,r31,pm_hi8(1f)) CR_TAB), file);
124 +      fputs ((AS2 (ldi,r30,lo8(gs(1f))) CR_TAB
125 +             AS2 (ldi,r31,hi8(gs(1f))) CR_TAB), file);
126        
127        prologue_size += 4;
128        
129 @@ -797,7 +800,6 @@
130    int reg;
131    int interrupt_func_p;
132    int signal_func_p;
133 -  int main_p;
134    int function_size;
135    int live_seq;
136    int minimize;
137 @@ -829,27 +831,12 @@
138  
139    interrupt_func_p = interrupt_function_p (current_function_decl);
140    signal_func_p = signal_function_p (current_function_decl);
141 -  main_p = MAIN_NAME_P (DECL_NAME (current_function_decl));
142 +
143    live_seq = sequent_regs_live ();
144    minimize = (TARGET_CALL_PROLOGUES
145               && !interrupt_func_p && !signal_func_p && live_seq);
146    
147 -  if (main_p)
148 -    {
149 -      /* Return value from main() is already in the correct registers
150 -        (r25:r24) as the exit() argument.  */
151 -      if (AVR_MEGA)
152 -       {
153 -         fputs ("\t" AS1 (jmp,exit) "\n", file);
154 -         epilogue_size += 2;
155 -       }
156 -      else
157 -       {
158 -         fputs ("\t" AS1 (rjmp,exit) "\n", file);
159 -         ++epilogue_size;
160 -       }
161 -    }
162 -  else if (minimize && (frame_pointer_needed || live_seq > 4))
163 +  if (minimize && (frame_pointer_needed || live_seq > 4))
164      {
165        fprintf (file, ("\t" AS2 (ldi, r30, %d) CR_TAB), live_seq);
166        ++epilogue_size;
167 @@ -1107,7 +1094,7 @@
168           && ((GET_CODE (addr) == SYMBOL_REF && SYMBOL_REF_FUNCTION_P (addr))
169               || GET_CODE (addr) == LABEL_REF))
170         {
171 -         fprintf (file, "pm(");
172 +         fprintf (file, "gs(");
173           output_addr_const (file,addr);
174           fprintf (file ,")");
175         }
176 @@ -4528,7 +4515,7 @@
177        && ((GET_CODE (x) == SYMBOL_REF && SYMBOL_REF_FUNCTION_P (x))
178           || GET_CODE (x) == LABEL_REF))
179      {
180 -      fputs ("\t.word\tpm(", asm_out_file);
181 +      fputs ("\t.word\tgs(", asm_out_file);
182        output_addr_const (asm_out_file, x);
183        fputs (")\n", asm_out_file);
184        return true;
185 @@ -5918,7 +5905,7 @@
186  {
187    switch_to_section (progmem_section);
188    if (AVR_MEGA)
189 -    fprintf (stream, "\t.word pm(.L%d)\n", value);
190 +    fprintf (stream, "\t.word gs(.L%d)\n", value);
191    else
192      fprintf (stream, "\trjmp .L%d\n", value);
193  
194 diff -uNdr gcc-4.2.3.old/gcc/config/avr/avr.h gcc-4.2.3/gcc/config/avr/avr.h
195 --- gcc-4.2.3.old/gcc/config/avr/avr.h  2008-02-16 10:53:58.000000000 +0100
196 +++ gcc-4.2.3/gcc/config/avr/avr.h      2008-02-16 10:56:47.000000000 +0100
197 @@ -36,6 +36,10 @@
198         builtin_define ("__AVR_HAVE_LPMX__");   \
199        if (avr_asm_only_p)                      \
200         builtin_define ("__AVR_ASM_ONLY__");    \
201 +      if (avr_pc_size == 2)                    \
202 +       builtin_define ("__AVR_2_BYTE_PC__");   \
203 +      if (avr_pc_size == 3)                    \
204 +       builtin_define ("__AVR_3_BYTE_PC__");   \
205        if (avr_enhanced_p)                      \
206         builtin_define ("__AVR_ENHANCED__");    \
207        if (avr_enhanced_p)                      \
208 @@ -53,6 +57,7 @@
209  extern int avr_enhanced_p;
210  extern int avr_asm_only_p;
211  extern int avr_have_movw_lpmx_p;
212 +extern int avr_pc_size;
213  #ifndef IN_LIBGCC2
214  extern GTY(()) section *progmem_section;
215  #endif
216 @@ -61,6 +66,9 @@
217  #define AVR_ENHANCED (avr_enhanced_p)
218  #define AVR_HAVE_MOVW (avr_have_movw_lpmx_p)
219  
220 +#define AVR_3_BYTE_PC (avr_pc_size == 3)
221 +#define AVR_2_BYTE_PC (avr_pc_size == 2)
222 +
223  #define TARGET_VERSION fprintf (stderr, " (GNU assembler syntax)");
224  
225  #define OVERRIDE_OPTIONS avr_override_options ()
226 @@ -727,12 +735,13 @@
227  
228  #define CPP_SPEC "%{posix:-D_POSIX_SOURCE}"
229  
230 -#define CC1_SPEC "%{profile:-p}"
231 +#define CC1_SPEC "%{profile:-p} -fno-delete-null-pointer-checks"
232  
233  #define CC1PLUS_SPEC "%{!frtti:-fno-rtti} \
234      %{!fenforce-eh-specs:-fno-enforce-eh-specs} \
235 -    %{!fexceptions:-fno-exceptions}"
236 -/* A C string constant that tells the GCC drvier program options to
237 +    %{!fexceptions:-fno-exceptions} \
238 +    -fno-delete-null-pointer-checks"
239 +/* A C string constant that tells the GCC driver program options to
240     pass to `cc1plus'.  */
241  
242  #define ASM_SPEC "%{mmcu=avr25:-mmcu=avr2;mmcu=avr35:-mmcu=avr3;\
243 @@ -776,6 +785,7 @@
244    mmcu=at90usb64*|\
245    mmcu=at90usb128*|\
246    mmcu=at94k:-m avr5}\
247 +%{mmcu=atmega256*:-m avr6}\
248  %{mmcu=atmega324*|\
249    mmcu=atmega325*|\
250    mmcu=atmega329*|\
251 @@ -799,7 +809,8 @@
252    mmcu=at90usb*: -Tdata 0x800100}\
253  %{mmcu=atmega640|\
254    mmcu=atmega1280|\
255 -  mmcu=atmega1281: -Tdata 0x800200} "
256 +  mmcu=atmega1281|\
257 +  mmcu=atmega256*: -Tdata 0x800200} "
258  
259  #define LIB_SPEC \
260    "%{!mmcu=at90s1*:%{!mmcu=attiny11:%{!mmcu=attiny12:%{!mmcu=attiny15:%{!mmcu=attiny28: -lc }}}}}"
261 @@ -892,6 +903,8 @@
262  %{mmcu=atmega128:crtm128.o%s} \
263  %{mmcu=atmega1280:crtm1280.o%s} \
264  %{mmcu=atmega1281:crtm1281.o%s} \
265 +%{mmcu=atmega2560:crtm2560.o%s} \
266 +%{mmcu=atmega2561:crtm2561.o%s} \
267  %{mmcu=atmega8hva:crtm8hva.o%s} \
268  %{mmcu=atmega16hva:crtm16hva.o%s} \
269  %{mmcu=at90can32:crtcan32.o%s} \
270 diff -uNdr gcc-4.2.3.old/gcc/config/avr/avr.md gcc-4.2.3/gcc/config/avr/avr.md
271 --- gcc-4.2.3.old/gcc/config/avr/avr.md 2007-09-01 17:28:30.000000000 +0200
272 +++ gcc-4.2.3/gcc/config/avr/avr.md     2008-02-16 10:56:47.000000000 +0100
273 @@ -2099,22 +2099,45 @@
274    "(register_operand (operands[0], HImode) || CONSTANT_P (operands[0]))"
275    "*{
276    if (which_alternative==0)
277 -     return \"icall\";
278 +    {
279 +      if (AVR_3_BYTE_PC)
280 +        return \"eicall\";
281 +      else
282 +        return \"icall\";
283 +    }
284    else if (which_alternative==1)
285      {
286        if (AVR_HAVE_MOVW)
287 -       return (AS2 (movw, r30, %0) CR_TAB
288 -               \"icall\");
289 +        {
290 +          if (AVR_3_BYTE_PC)
291 +            return (AS2 (movw, r30, %0) CR_TAB
292 +                    \"eicall\");
293 +          else
294 +            return (AS2 (movw, r30, %0) CR_TAB
295 +                    \"icall\");
296 +        }
297        else
298 -       return (AS2 (mov, r30, %A0) CR_TAB
299 -               AS2 (mov, r31, %B0) CR_TAB
300 -               \"icall\");
301 +        {
302 +          if (AVR_3_BYTE_PC)
303 +            return (AS2 (mov, r30, %A0) CR_TAB
304 +                    AS2 (mov, r31, %B0) CR_TAB
305 +                    \"eicall\");
306 +          else
307 +            return (AS2 (mov, r30, %A0) CR_TAB
308 +                    AS2 (mov, r31, %B0) CR_TAB
309 +                    \"icall\");
310 +        }
311      }
312    else if (which_alternative==2)
313      return AS1(%~call,%c0);
314 -  return (AS2 (ldi,r30,lo8(%0)) CR_TAB
315 -          AS2 (ldi,r31,hi8(%0)) CR_TAB
316 -          \"icall\");
317 +  if (AVR_3_BYTE_PC)
318 +    return (AS2 (ldi,r30,lo8(%0)) CR_TAB
319 +            AS2 (ldi,r31,hi8(%0)) CR_TAB
320 +            \"eicall\");
321 +  else
322 +    return (AS2 (ldi,r30,lo8(%0)) CR_TAB
323 +            AS2 (ldi,r31,hi8(%0)) CR_TAB
324 +            \"icall\");    
325  }"
326    [(set_attr "cc" "clobber,clobber,clobber,clobber")
327     (set_attr_alternative "length"
328 @@ -2136,22 +2159,45 @@
329    "(register_operand (operands[0], VOIDmode) || CONSTANT_P (operands[0]))"
330    "*{
331    if (which_alternative==0)
332 -     return \"icall\";
333 +    {
334 +      if (AVR_3_BYTE_PC)
335 +        return \"eicall\";
336 +      else
337 +        return \"icall\";
338 +    }
339    else if (which_alternative==1)
340      {
341        if (AVR_HAVE_MOVW)
342 -       return (AS2 (movw, r30, %1) CR_TAB
343 -               \"icall\");
344 +        {
345 +          if (AVR_3_BYTE_PC)
346 +            return (AS2 (movw, r30, %1) CR_TAB
347 +                    \"eicall\");
348 +          else
349 +            return (AS2 (movw, r30, %1) CR_TAB
350 +                    \"icall\");
351 +        }
352        else
353 -       return (AS2 (mov, r30, %A1) CR_TAB
354 -               AS2 (mov, r31, %B1) CR_TAB
355 -               \"icall\");
356 +        {
357 +          if (AVR_3_BYTE_PC)
358 +            return (AS2 (mov, r30, %A1) CR_TAB
359 +                    AS2 (mov, r31, %B1) CR_TAB
360 +                    \"eicall\");
361 +          else
362 +            return (AS2 (mov, r30, %A1) CR_TAB
363 +                    AS2 (mov, r31, %B1) CR_TAB
364 +                    \"icall\");
365 +        }
366      }
367    else if (which_alternative==2)
368      return AS1(%~call,%c1);
369 -  return (AS2 (ldi, r30, lo8(%1)) CR_TAB
370 -          AS2 (ldi, r31, hi8(%1)) CR_TAB
371 -          \"icall\");
372 +  if (AVR_3_BYTE_PC)
373 +    return (AS2 (ldi, r30, lo8(%1)) CR_TAB
374 +            AS2 (ldi, r31, hi8(%1)) CR_TAB
375 +            \"eicall\");
376 +  else
377 +    return (AS2 (ldi, r30, lo8(%1)) CR_TAB
378 +            AS2 (ldi, r31, hi8(%1)) CR_TAB
379 +            \"icall\");    
380  }"
381    [(set_attr "cc" "clobber,clobber,clobber,clobber")
382     (set_attr_alternative "length"
383 @@ -2181,13 +2227,20 @@
384  ; indirect jump
385  (define_insn "indirect_jump"
386    [(set (pc) (match_operand:HI 0 "register_operand" "!z,*r"))]
387 -  ""
388 +  "AVR_2_BYTE_PC"
389    "@
390         ijmp
391         push %A0\;push %B0\;ret"
392    [(set_attr "length" "1,3")
393     (set_attr "cc" "none,none")])
394  
395 +(define_insn "*indirect_jump_avr6"
396 +  [(set (pc) (match_operand:HI 0 "register_operand" "z"))]
397 +  "AVR_3_BYTE_PC"
398 +  "eijmp"
399 +  [(set_attr "length" "1")
400 +   (set_attr "cc" "none")])
401 +
402  ;; table jump
403  
404  ;; Table made from "rjmp" instructions for <=8K devices.
405 @@ -2196,7 +2249,7 @@
406                         UNSPEC_INDEX_JMP))
407     (use (label_ref (match_operand 1 "" "")))
408     (clobber (match_dup 0))]
409 -  "!AVR_MEGA"
410 +  "(!AVR_MEGA) && (AVR_2_BYTE_PC)"
411    "@
412         ijmp
413         push %A0\;push %B0\;ret"
414 @@ -2214,12 +2267,27 @@
415    [(set_attr "length" "2")
416     (set_attr "cc" "clobber")])
417  
418 +(define_insn "*tablejump_avr6"
419 +  [(set (pc) (unspec:HI [(match_operand:HI 0 "register_operand" "z")]
420 +                        1))
421 +   (use (label_ref (match_operand 1 "" "")))
422 +   (clobber (match_dup 0))]
423 +  "AVR_MEGA && AVR_ENHANCED && AVR_3_BYTE_PC"
424 +  "lsl r30
425 +        rol r31
426 +        lpm __tmp_reg__,Z+
427 +        lpm r31,Z
428 +        mov r30,__tmp_reg__
429 +        eijmp"
430 +  [(set_attr "length" "6")
431 +   (set_attr "cc" "clobber")])
432 +
433  (define_insn "*tablejump_enh"
434    [(set (pc) (unspec:HI [(match_operand:HI 0 "register_operand" "z")]
435                         UNSPEC_INDEX_JMP))
436     (use (label_ref (match_operand 1 "" "")))
437     (clobber (match_dup 0))]
438 -  "AVR_MEGA && AVR_ENHANCED"
439 +  "AVR_MEGA && AVR_ENHANCED && AVR_2_BYTE_PC"
440    "lsl r30
441         rol r31
442         lpm __tmp_reg__,Z+
443 @@ -2234,7 +2302,7 @@
444                         UNSPEC_INDEX_JMP))
445     (use (label_ref (match_operand 1 "" "")))
446     (clobber (match_dup 0))]
447 -  "AVR_MEGA"
448 +  "AVR_MEGA && AVR_2_BYTE_PC"
449    "lsl r30
450         rol r31
451         lpm
452 diff -uNdr gcc-4.2.3.old/gcc/config/avr/libgcc.S gcc-4.2.3/gcc/config/avr/libgcc.S
453 --- gcc-4.2.3.old/gcc/config/avr/libgcc.S       2006-06-19 17:04:27.000000000 +0200
454 +++ gcc-4.2.3/gcc/config/avr/libgcc.S   2008-02-16 10:56:47.000000000 +0100
455 @@ -593,7 +593,12 @@
456         out     __SP_H__,r29
457         out     __SREG__,__tmp_reg__
458         out     __SP_L__,r28
459 +#if defined (__AVR_3_BYTE_PC__)
460 +       eijmp
461 +#else
462         ijmp
463 +#endif
464 +
465  .endfunc
466  #endif /* defined (L_prologue) */
467  
468 @@ -672,13 +677,22 @@
469         lpm     __tmp_reg__, Z+
470         lpm     r31, Z
471         mov     r30, __tmp_reg__
472 +
473 +#if defined (__AVR_3_BYTE_PC__)
474 +       eijmp
475 +#else
476         ijmp
477 +#endif
478 +
479  #else
480         lpm
481         adiw    r30, 1
482         push    r0
483         lpm
484         push    r0
485 +#if defined (__AVR_3_BYTE_PC__)
486 +        push    __zero_reg__
487 +#endif
488         ret
489  #endif
490         .endfunc
491 diff -uNdr gcc-4.2.3.old/gcc/config/avr/t-avr gcc-4.2.3/gcc/config/avr/t-avr
492 --- gcc-4.2.3.old/gcc/config/avr/t-avr  2008-01-06 23:28:41.000000000 +0100
493 +++ gcc-4.2.3/gcc/config/avr/t-avr      2008-02-16 10:56:47.000000000 +0100
494 @@ -37,8 +37,8 @@
495  
496  FPBIT = fp-bit.c
497  
498 -MULTILIB_OPTIONS = mmcu=avr2/mmcu=avr25/mmcu=avr3/mmcu=avr35/mmcu=avr4/mmcu=avr5
499 -MULTILIB_DIRNAMES = avr2 avr25 avr3 avr35 avr4 avr5
500 +MULTILIB_OPTIONS = mmcu=avr2/mmcu=avr25/mmcu=avr3/mmcu=avr35/mmcu=avr4/mmcu=avr5/mmcu=avr6
501 +MULTILIB_DIRNAMES = avr2 avr25 avr3 avr35 avr4 avr5 avr6
502  
503  # The many avr2 matches are not listed here - this is the default.
504  MULTILIB_MATCHES = \
505 @@ -111,7 +111,9 @@
506         mmcu?avr5=mmcu?at90usb647 \
507         mmcu?avr5=mmcu?at90usb1286 \
508         mmcu?avr5=mmcu?at90usb1287 \
509 -       mmcu?avr5=mmcu?at94k
510 +       mmcu?avr5=mmcu?at94k \
511 +       mmcu?avr6=mmcu?atmega2560 \
512 +       mmcu?avr6=mmcu?atmega2561
513  
514  MULTILIB_EXCEPTIONS =
515  
This page took 0.058817 seconds and 3 git commands to generate.