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
5 /* Core have 'MOVW' and 'LPM Rx,Z' instructions. */
6 int avr_have_movw_lpmx_p = 0;
8 +/* Usually holds the value 2, but could be 3 for the larger devices with a
9 + 3-byte program counter. */
18 const char *const macro;
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" }
41 /* These names are used as the index into the avr_arch_types[] table
53 { "at90usb1286", ARCH_AVR5, "__AVR_AT90USB1286__" },
54 { "at90usb1287", ARCH_AVR5, "__AVR_AT90USB1287__" },
55 { "at94k", ARCH_AVR5, "__AVR_AT94K__" },
57 + { "avr6", ARCH_AVR6, NULL },
58 + { "atmega2560", ARCH_AVR6, "__AVR_ATmega2560__" },
59 + { "atmega2561", ARCH_AVR6, "__AVR_ATmega2561__" },
61 { "avr1", ARCH_AVR1, NULL },
62 { "at90s1200", ARCH_AVR1, "__AVR_AT90S1200__" },
64 avr_base_arch_macro = base->macro;
65 avr_extra_arch_macro = t->macro;
67 + if (base->three_byte_pc)
72 if (optimize && !TARGET_NO_TABLEJUMP)
73 avr_case_values_threshold = (!AVR_MEGA || TARGET_CALL_PROLOGUES) ? 8 : 17;
76 int offset = frame_pointer_needed ? 2 : 0;
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;
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");
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);
113 - prologue_size += 4;
115 - else if (minimize && (frame_pointer_needed || live_seq > 6))
116 + if (minimize && (frame_pointer_needed || live_seq > 6))
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);
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);
131 int interrupt_func_p;
137 @@ -829,27 +831,12 @@
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));
143 live_seq = sequent_regs_live ();
144 minimize = (TARGET_CALL_PROLOGUES
145 && !interrupt_func_p && !signal_func_p && live_seq);
149 - /* Return value from main() is already in the correct registers
150 - (r25:r24) as the exit() argument. */
153 - fputs ("\t" AS1 (jmp,exit) "\n", file);
154 - epilogue_size += 2;
158 - fputs ("\t" AS1 (rjmp,exit) "\n", file);
162 - else if (minimize && (frame_pointer_needed || live_seq > 4))
163 + if (minimize && (frame_pointer_needed || live_seq > 4))
165 fprintf (file, ("\t" AS2 (ldi, r30, %d) CR_TAB), live_seq);
167 @@ -1107,7 +1094,7 @@
168 && ((GET_CODE (addr) == SYMBOL_REF && SYMBOL_REF_FUNCTION_P (addr))
169 || GET_CODE (addr) == LABEL_REF))
171 - fprintf (file, "pm(");
172 + fprintf (file, "gs(");
173 output_addr_const (file,addr);
176 @@ -4528,7 +4515,7 @@
177 && ((GET_CODE (x) == SYMBOL_REF && SYMBOL_REF_FUNCTION_P (x))
178 || GET_CODE (x) == LABEL_REF))
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);
185 @@ -5918,7 +5905,7 @@
187 switch_to_section (progmem_section);
189 - fprintf (stream, "\t.word pm(.L%d)\n", value);
190 + fprintf (stream, "\t.word gs(.L%d)\n", value);
192 fprintf (stream, "\trjmp .L%d\n", value);
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
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) \
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;
214 extern GTY(()) section *progmem_section;
217 #define AVR_ENHANCED (avr_enhanced_p)
218 #define AVR_HAVE_MOVW (avr_have_movw_lpmx_p)
220 +#define AVR_3_BYTE_PC (avr_pc_size == 3)
221 +#define AVR_2_BYTE_PC (avr_pc_size == 2)
223 #define TARGET_VERSION fprintf (stderr, " (GNU assembler syntax)");
225 #define OVERRIDE_OPTIONS avr_override_options ()
226 @@ -727,12 +735,13 @@
228 #define CPP_SPEC "%{posix:-D_POSIX_SOURCE}"
230 -#define CC1_SPEC "%{profile:-p}"
231 +#define CC1_SPEC "%{profile:-p} -fno-delete-null-pointer-checks"
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'. */
242 #define ASM_SPEC "%{mmcu=avr25:-mmcu=avr2;mmcu=avr35:-mmcu=avr3;\
247 +%{mmcu=atmega256*:-m avr6}\
252 mmcu=at90usb*: -Tdata 0x800100}\
255 - mmcu=atmega1281: -Tdata 0x800200} "
257 + mmcu=atmega256*: -Tdata 0x800200} "
260 "%{!mmcu=at90s1*:%{!mmcu=attiny11:%{!mmcu=attiny12:%{!mmcu=attiny15:%{!mmcu=attiny28: -lc }}}}}"
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]))"
276 if (which_alternative==0)
284 else if (which_alternative==1)
287 - return (AS2 (movw, r30, %0) CR_TAB
291 + return (AS2 (movw, r30, %0) CR_TAB
294 + return (AS2 (movw, r30, %0) CR_TAB
298 - return (AS2 (mov, r30, %A0) CR_TAB
299 - AS2 (mov, r31, %B0) CR_TAB
303 + return (AS2 (mov, r30, %A0) CR_TAB
304 + AS2 (mov, r31, %B0) CR_TAB
307 + return (AS2 (mov, r30, %A0) CR_TAB
308 + AS2 (mov, r31, %B0) CR_TAB
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
318 + return (AS2 (ldi,r30,lo8(%0)) CR_TAB
319 + AS2 (ldi,r31,hi8(%0)) CR_TAB
322 + return (AS2 (ldi,r30,lo8(%0)) CR_TAB
323 + AS2 (ldi,r31,hi8(%0)) CR_TAB
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]))"
331 if (which_alternative==0)
339 else if (which_alternative==1)
342 - return (AS2 (movw, r30, %1) CR_TAB
346 + return (AS2 (movw, r30, %1) CR_TAB
349 + return (AS2 (movw, r30, %1) CR_TAB
353 - return (AS2 (mov, r30, %A1) CR_TAB
354 - AS2 (mov, r31, %B1) CR_TAB
358 + return (AS2 (mov, r30, %A1) CR_TAB
359 + AS2 (mov, r31, %B1) CR_TAB
362 + return (AS2 (mov, r30, %A1) CR_TAB
363 + AS2 (mov, r31, %B1) CR_TAB
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
373 + return (AS2 (ldi, r30, lo8(%1)) CR_TAB
374 + AS2 (ldi, r31, hi8(%1)) CR_TAB
377 + return (AS2 (ldi, r30, lo8(%1)) CR_TAB
378 + AS2 (ldi, r31, hi8(%1)) CR_TAB
381 [(set_attr "cc" "clobber,clobber,clobber,clobber")
382 (set_attr_alternative "length"
383 @@ -2181,13 +2227,20 @@
385 (define_insn "indirect_jump"
386 [(set (pc) (match_operand:HI 0 "register_operand" "!z,*r"))]
391 push %A0\;push %B0\;ret"
392 [(set_attr "length" "1,3")
393 (set_attr "cc" "none,none")])
395 +(define_insn "*indirect_jump_avr6"
396 + [(set (pc) (match_operand:HI 0 "register_operand" "z"))]
399 + [(set_attr "length" "1")
400 + (set_attr "cc" "none")])
404 ;; Table made from "rjmp" instructions for <=8K devices.
405 @@ -2196,7 +2249,7 @@
407 (use (label_ref (match_operand 1 "" "")))
408 (clobber (match_dup 0))]
410 + "(!AVR_MEGA) && (AVR_2_BYTE_PC)"
413 push %A0\;push %B0\;ret"
414 @@ -2214,12 +2267,27 @@
415 [(set_attr "length" "2")
416 (set_attr "cc" "clobber")])
418 +(define_insn "*tablejump_avr6"
419 + [(set (pc) (unspec:HI [(match_operand:HI 0 "register_operand" "z")]
421 + (use (label_ref (match_operand 1 "" "")))
422 + (clobber (match_dup 0))]
423 + "AVR_MEGA && AVR_ENHANCED && AVR_3_BYTE_PC"
428 + mov r30,__tmp_reg__
430 + [(set_attr "length" "6")
431 + (set_attr "cc" "clobber")])
433 (define_insn "*tablejump_enh"
434 [(set (pc) (unspec:HI [(match_operand:HI 0 "register_operand" "z")]
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"
443 @@ -2234,7 +2302,7 @@
445 (use (label_ref (match_operand 1 "" "")))
446 (clobber (match_dup 0))]
448 + "AVR_MEGA && AVR_2_BYTE_PC"
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
457 out __SREG__,__tmp_reg__
459 +#if defined (__AVR_3_BYTE_PC__)
466 #endif /* defined (L_prologue) */
468 @@ -672,13 +677,22 @@
473 +#if defined (__AVR_3_BYTE_PC__)
485 +#if defined (__AVR_3_BYTE_PC__)
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
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
503 # The many avr2 matches are not listed here - this is the default.
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
514 MULTILIB_EXCEPTIONS =