1 diff -uNdr gcc-4.2.2/gcc/config/avr-old/avr.c gcc-4.2.2/gcc/config/avr/avr.c
2 --- gcc-4.2.2/gcc/config/avr-old/avr.c 2007-09-01 17:28:30.000000000 +0200
3 +++ gcc-4.2.2/gcc/config/avr/avr.c 2007-10-20 18:13:32.000000000 +0200
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, 1, 0, 1, "__AVR_ARCH__=4" },
28 - { 0, 1, 1, 1, "__AVR_ARCH__=5" }
29 + { 1, 0, 0, 0, 0, NULL }, /* unknown device specified */
30 + { 1, 0, 0, 0, 0, "__AVR_ARCH__=1" },
31 + { 0, 0, 0, 0, 0, "__AVR_ARCH__=2" },
32 + { 0, 0, 0, 1, 0, "__AVR_ARCH__=25"},
33 + { 0, 0, 1, 0, 0, "__AVR_ARCH__=3" },
34 + { 0, 1, 0, 1, 0, "__AVR_ARCH__=4" },
35 + { 0, 1, 1, 1, 0, "__AVR_ARCH__=5" },
36 + { 0, 1, 1, 1, 1, "__AVR_ARCH__=6" }
39 /* These names are used as the index into the avr_arch_types[] table
41 { "at90usb1286", ARCH_AVR5, "__AVR_AT90USB1286__" },
42 { "at90usb1287", ARCH_AVR5, "__AVR_AT90USB1287__" },
43 { "at94k", ARCH_AVR5, "__AVR_AT94K__" },
45 + { "avr6", 6, NULL },
46 + { "atmega2560", 6, "__AVR_ATmega2560__" },
47 + { "atmega2561", 6, "__AVR_ATmega2561__" },
49 { "avr1", ARCH_AVR1, NULL },
50 { "at90s1200", ARCH_AVR1, "__AVR_AT90S1200__" },
52 avr_base_arch_macro = base->macro;
53 avr_extra_arch_macro = t->macro;
55 + if (base->three_byte_pc)
60 if (optimize && !TARGET_NO_TABLEJUMP)
61 avr_case_values_threshold = (!AVR_MEGA || TARGET_CALL_PROLOGUES) ? 8 : 17;
64 int offset = frame_pointer_needed ? 2 : 0;
66 offset += avr_regs_to_save (NULL);
67 - return get_frame_size () + 2 + 1 + offset;
68 + return get_frame_size () + (avr_pc_size) + 1 + offset;
82 interrupt_func_p = interrupt_function_p (current_function_decl);
83 signal_func_p = signal_function_p (current_function_decl);
84 - main_p = MAIN_NAME_P (DECL_NAME (current_function_decl));
85 live_seq = sequent_regs_live ();
86 minimize = (TARGET_CALL_PROLOGUES
87 && !interrupt_func_p && !signal_func_p && live_seq);
89 AS1 (clr,__zero_reg__) "\n");
94 - fprintf (file, ("\t"
95 - AS1 (ldi,r28) ",lo8(%s - " HOST_WIDE_INT_PRINT_DEC ")" CR_TAB
96 - AS1 (ldi,r29) ",hi8(%s - " HOST_WIDE_INT_PRINT_DEC ")" CR_TAB
97 - AS2 (out,__SP_H__,r29) CR_TAB
98 - AS2 (out,__SP_L__,r28) "\n"),
99 - avr_init_stack, size, avr_init_stack, size);
101 - prologue_size += 4;
103 - else if (minimize && (frame_pointer_needed || live_seq > 6))
104 + if (minimize && (frame_pointer_needed || live_seq > 6))
107 AS1 (ldi, r26) ",lo8(" HOST_WIDE_INT_PRINT_DEC ")" CR_TAB
108 AS1 (ldi, r27) ",hi8(" HOST_WIDE_INT_PRINT_DEC ")" CR_TAB), size, size);
110 - fputs ((AS2 (ldi,r30,pm_lo8(1f)) CR_TAB
111 - AS2 (ldi,r31,pm_hi8(1f)) CR_TAB), file);
112 + fputs ((AS2 (ldi,r30,lo8(gs(1f))) CR_TAB
113 + AS2 (ldi,r31,hi8(gs(1f))) CR_TAB), file);
119 int interrupt_func_p;
125 @@ -825,27 +826,12 @@
127 interrupt_func_p = interrupt_function_p (current_function_decl);
128 signal_func_p = signal_function_p (current_function_decl);
129 - main_p = MAIN_NAME_P (DECL_NAME (current_function_decl));
131 live_seq = sequent_regs_live ();
132 minimize = (TARGET_CALL_PROLOGUES
133 && !interrupt_func_p && !signal_func_p && live_seq);
137 - /* Return value from main() is already in the correct registers
138 - (r25:r24) as the exit() argument. */
141 - fputs ("\t" AS1 (jmp,exit) "\n", file);
142 - epilogue_size += 2;
146 - fputs ("\t" AS1 (rjmp,exit) "\n", file);
150 - else if (minimize && (frame_pointer_needed || live_seq > 4))
151 + if (minimize && (frame_pointer_needed || live_seq > 4))
153 fprintf (file, ("\t" AS2 (ldi, r30, %d) CR_TAB), live_seq);
155 @@ -1103,7 +1089,7 @@
156 && ((GET_CODE (addr) == SYMBOL_REF && SYMBOL_REF_FUNCTION_P (addr))
157 || GET_CODE (addr) == LABEL_REF))
159 - fprintf (file, "pm(");
160 + fprintf (file, "gs(");
161 output_addr_const (file,addr);
164 @@ -4524,7 +4510,7 @@
165 && ((GET_CODE (x) == SYMBOL_REF && SYMBOL_REF_FUNCTION_P (x))
166 || GET_CODE (x) == LABEL_REF))
168 - fputs ("\t.word\tpm(", asm_out_file);
169 + fputs ("\t.word\tgs(", asm_out_file);
170 output_addr_const (asm_out_file, x);
171 fputs (")\n", asm_out_file);
173 @@ -5914,7 +5900,7 @@
175 switch_to_section (progmem_section);
177 - fprintf (stream, "\t.word pm(.L%d)\n", value);
178 + fprintf (stream, "\t.word gs(.L%d)\n", value);
180 fprintf (stream, "\trjmp .L%d\n", value);
182 diff -uNdr gcc-4.2.2/gcc/config/avr-old/avr.h gcc-4.2.2/gcc/config/avr/avr.h
183 --- gcc-4.2.2/gcc/config/avr-old/avr.h 2007-10-20 18:11:38.000000000 +0200
184 +++ gcc-4.2.2/gcc/config/avr/avr.h 2007-10-20 18:12:15.000000000 +0200
186 builtin_define ("__AVR_HAVE_LPMX__"); \
187 if (avr_asm_only_p) \
188 builtin_define ("__AVR_ASM_ONLY__"); \
189 + if (avr_pc_size == 2) \
190 + builtin_define ("__AVR_2_BYTE_PC__"); \
191 + if (avr_pc_size == 3) \
192 + builtin_define ("__AVR_3_BYTE_PC__"); \
193 if (avr_enhanced_p) \
194 builtin_define ("__AVR_ENHANCED__"); \
195 if (avr_enhanced_p) \
197 extern int avr_enhanced_p;
198 extern int avr_asm_only_p;
199 extern int avr_have_movw_lpmx_p;
200 +extern int avr_pc_size;
202 extern GTY(()) section *progmem_section;
205 #define AVR_ENHANCED (avr_enhanced_p)
206 #define AVR_HAVE_MOVW (avr_have_movw_lpmx_p)
208 +#define AVR_3_BYTE_PC (avr_pc_size == 3)
209 +#define AVR_2_BYTE_PC (avr_pc_size == 2)
211 #define TARGET_VERSION fprintf (stderr, " (GNU assembler syntax)");
213 #define OVERRIDE_OPTIONS avr_override_options ()
214 @@ -727,12 +735,13 @@
216 #define CPP_SPEC "%{posix:-D_POSIX_SOURCE}"
218 -#define CC1_SPEC "%{profile:-p}"
219 +#define CC1_SPEC "%{profile:-p} -fno-delete-null-pointer-checks"
221 #define CC1PLUS_SPEC "%{!frtti:-fno-rtti} \
222 %{!fenforce-eh-specs:-fno-enforce-eh-specs} \
223 - %{!fexceptions:-fno-exceptions}"
224 -/* A C string constant that tells the GCC drvier program options to
225 + %{!fexceptions:-fno-exceptions} \
226 + -fno-delete-null-pointer-checks"
227 +/* A C string constant that tells the GCC driver program options to
228 pass to `cc1plus'. */
230 #define ASM_SPEC "%{mmcu=avr25:-mmcu=avr2;\
235 +%{mmcu=atmega256*:-m avr6}\
240 mmcu=at90usb*: -Tdata 0x800100}\
243 - mmcu=atmega1281: -Tdata 0x800200} "
245 + mmcu=atmega256*: -Tdata 0x800200} "
248 "%{!mmcu=at90s1*:%{!mmcu=attiny11:%{!mmcu=attiny12:%{!mmcu=attiny15:%{!mmcu=attiny28: -lc }}}}}"
250 %{mmcu=atmega128:crtm128.o%s} \
251 %{mmcu=atmega1280:crtm1280.o%s} \
252 %{mmcu=atmega1281:crtm1281.o%s} \
253 +%{mmcu=atmega2560:crtm2560.o%s} \
254 +%{mmcu=atmega2561:crtm2561.o%s} \
255 %{mmcu=atmega8hva:crtm8hva.o%s} \
256 %{mmcu=atmega16hva:crtm16hva.o%s} \
257 %{mmcu=at90can32:crtcan32.o%s} \
258 diff -uNdr gcc-4.2.2/gcc/config/avr-old/avr.md gcc-4.2.2/gcc/config/avr/avr.md
259 --- gcc-4.2.2/gcc/config/avr-old/avr.md 2007-09-01 17:28:30.000000000 +0200
260 +++ gcc-4.2.2/gcc/config/avr/avr.md 2007-10-20 18:12:15.000000000 +0200
261 @@ -2099,22 +2099,45 @@
262 "(register_operand (operands[0], HImode) || CONSTANT_P (operands[0]))"
264 if (which_alternative==0)
272 else if (which_alternative==1)
275 - return (AS2 (movw, r30, %0) CR_TAB
279 + return (AS2 (movw, r30, %0) CR_TAB
282 + return (AS2 (movw, r30, %0) CR_TAB
286 - return (AS2 (mov, r30, %A0) CR_TAB
287 - AS2 (mov, r31, %B0) CR_TAB
291 + return (AS2 (mov, r30, %A0) CR_TAB
292 + AS2 (mov, r31, %B0) CR_TAB
295 + return (AS2 (mov, r30, %A0) CR_TAB
296 + AS2 (mov, r31, %B0) CR_TAB
300 else if (which_alternative==2)
301 return AS1(%~call,%c0);
302 - return (AS2 (ldi,r30,lo8(%0)) CR_TAB
303 - AS2 (ldi,r31,hi8(%0)) CR_TAB
306 + return (AS2 (ldi,r30,lo8(%0)) CR_TAB
307 + AS2 (ldi,r31,hi8(%0)) CR_TAB
310 + return (AS2 (ldi,r30,lo8(%0)) CR_TAB
311 + AS2 (ldi,r31,hi8(%0)) CR_TAB
314 [(set_attr "cc" "clobber,clobber,clobber,clobber")
315 (set_attr_alternative "length"
316 @@ -2136,22 +2159,45 @@
317 "(register_operand (operands[0], VOIDmode) || CONSTANT_P (operands[0]))"
319 if (which_alternative==0)
327 else if (which_alternative==1)
330 - return (AS2 (movw, r30, %1) CR_TAB
334 + return (AS2 (movw, r30, %1) CR_TAB
337 + return (AS2 (movw, r30, %1) CR_TAB
341 - return (AS2 (mov, r30, %A1) CR_TAB
342 - AS2 (mov, r31, %B1) CR_TAB
346 + return (AS2 (mov, r30, %A1) CR_TAB
347 + AS2 (mov, r31, %B1) CR_TAB
350 + return (AS2 (mov, r30, %A1) CR_TAB
351 + AS2 (mov, r31, %B1) CR_TAB
355 else if (which_alternative==2)
356 return AS1(%~call,%c1);
357 - return (AS2 (ldi, r30, lo8(%1)) CR_TAB
358 - AS2 (ldi, r31, hi8(%1)) CR_TAB
361 + return (AS2 (ldi, r30, lo8(%1)) CR_TAB
362 + AS2 (ldi, r31, hi8(%1)) CR_TAB
365 + return (AS2 (ldi, r30, lo8(%1)) CR_TAB
366 + AS2 (ldi, r31, hi8(%1)) CR_TAB
369 [(set_attr "cc" "clobber,clobber,clobber,clobber")
370 (set_attr_alternative "length"
371 @@ -2181,13 +2227,20 @@
373 (define_insn "indirect_jump"
374 [(set (pc) (match_operand:HI 0 "register_operand" "!z,*r"))]
379 push %A0\;push %B0\;ret"
380 [(set_attr "length" "1,3")
381 (set_attr "cc" "none,none")])
383 +(define_insn "*indirect_jump_avr6"
384 + [(set (pc) (match_operand:HI 0 "register_operand" "z"))]
387 + [(set_attr "length" "1")
388 + (set_attr "cc" "none")])
392 ;; Table made from "rjmp" instructions for <=8K devices.
393 @@ -2196,7 +2249,7 @@
395 (use (label_ref (match_operand 1 "" "")))
396 (clobber (match_dup 0))]
398 + "(!AVR_MEGA) && (AVR_2_BYTE_PC)"
401 push %A0\;push %B0\;ret"
402 @@ -2214,12 +2267,27 @@
403 [(set_attr "length" "2")
404 (set_attr "cc" "clobber")])
406 +(define_insn "*tablejump_avr6"
407 + [(set (pc) (unspec:HI [(match_operand:HI 0 "register_operand" "z")]
409 + (use (label_ref (match_operand 1 "" "")))
410 + (clobber (match_dup 0))]
411 + "AVR_MEGA && AVR_ENHANCED && AVR_3_BYTE_PC"
416 + mov r30,__tmp_reg__
418 + [(set_attr "length" "6")
419 + (set_attr "cc" "clobber")])
421 (define_insn "*tablejump_enh"
422 [(set (pc) (unspec:HI [(match_operand:HI 0 "register_operand" "z")]
424 (use (label_ref (match_operand 1 "" "")))
425 (clobber (match_dup 0))]
426 - "AVR_MEGA && AVR_ENHANCED"
427 + "AVR_MEGA && AVR_ENHANCED && AVR_2_BYTE_PC"
431 @@ -2234,7 +2302,7 @@
433 (use (label_ref (match_operand 1 "" "")))
434 (clobber (match_dup 0))]
436 + "AVR_MEGA && AVR_2_BYTE_PC"
440 diff -uNdr gcc-4.2.2/gcc/config/avr-old/libgcc.S gcc-4.2.2/gcc/config/avr/libgcc.S
441 --- gcc-4.2.2/gcc/config/avr-old/libgcc.S 2006-06-19 17:04:27.000000000 +0200
442 +++ gcc-4.2.2/gcc/config/avr/libgcc.S 2007-10-20 18:12:15.000000000 +0200
445 out __SREG__,__tmp_reg__
447 +#if defined (__AVR_3_BYTE_PC__)
454 #endif /* defined (L_prologue) */
456 @@ -672,13 +677,22 @@
461 +#if defined (__AVR_3_BYTE_PC__)
473 +#if defined (__AVR_3_BYTE_PC__)
479 diff -uNdr gcc-4.2.2/gcc/config/avr-old/t-avr gcc-4.2.2/gcc/config/avr/t-avr
480 --- gcc-4.2.2/gcc/config/avr-old/t-avr 2007-04-27 22:53:57.000000000 +0200
481 +++ gcc-4.2.2/gcc/config/avr/t-avr 2007-10-20 18:12:15.000000000 +0200
486 -MULTILIB_OPTIONS = mmcu=avr2/mmcu=avr25/mmcu=avr3/mmcu=avr4/mmcu=avr5
487 -MULTILIB_DIRNAMES = avr2 avr25 avr3 avr4 avr5
488 +MULTILIB_OPTIONS = mmcu=avr2/mmcu=avr25/mmcu=avr3/mmcu=avr4/mmcu=avr5/mmcu=avr6
489 +MULTILIB_DIRNAMES = avr2 avr25 avr3 avr4 avr5 avr6
491 # The many avr2 matches are not listed here - this is the default.
494 mmcu?avr5=mmcu?at90usb647 \
495 mmcu?avr5=mmcu?at90usb1286 \
496 mmcu?avr5=mmcu?at90usb1287 \
497 - mmcu?avr5=mmcu?at94k
498 + mmcu?avr5=mmcu?at94k \
499 + mmcu?avr6=mmcu?atmega2560 \
500 + mmcu?avr6=mmcu?atmega2561
502 MULTILIB_EXCEPTIONS =