]> git.pld-linux.org Git - packages/crossavr-gcc.git/blame - crossavr-gcc-zz-atmega256x.patch
- updated for 4.2.2
[packages/crossavr-gcc.git] / crossavr-gcc-zz-atmega256x.patch
CommitLineData
cbd86a33 1diff -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
4@@ -129,22 +129,28 @@
5 /* Core have 'MOVW' and 'LPM Rx,Z' instructions. */
6 int avr_have_movw_lpmx_p = 0;
1321be35
ER
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;
cbd86a33 16 int have_movw_lpmx;
1321be35
ER
17+ int three_byte_pc;
18 const char *const macro;
19 };
20
21 static const struct base_arch_s avr_arch_types[] = {
cbd86a33 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" }
1321be35
ER
37 };
38
cbd86a33 39 /* These names are used as the index into the avr_arch_types[] table
40@@ -269,6 +275,10 @@
41 { "at90usb1286", ARCH_AVR5, "__AVR_AT90USB1286__" },
42 { "at90usb1287", ARCH_AVR5, "__AVR_AT90USB1287__" },
43 { "at94k", ARCH_AVR5, "__AVR_AT94K__" },
1321be35
ER
44+ /* 3-Byte PC */
45+ { "avr6", 6, NULL },
46+ { "atmega2560", 6, "__AVR_ATmega2560__" },
47+ { "atmega2561", 6, "__AVR_ATmega2561__" },
48 /* Assembler only. */
cbd86a33 49 { "avr1", ARCH_AVR1, NULL },
50 { "at90s1200", ARCH_AVR1, "__AVR_AT90S1200__" },
51@@ -354,6 +364,11 @@
1321be35
ER
52 avr_base_arch_macro = base->macro;
53 avr_extra_arch_macro = t->macro;
54
55+ if (base->three_byte_pc)
56+ avr_pc_size = 3;
57+ else
58+ avr_pc_size = 2;
59+
60 if (optimize && !TARGET_NO_TABLEJUMP)
61 avr_case_values_threshold = (!AVR_MEGA || TARGET_CALL_PROLOGUES) ? 8 : 17;
62
cbd86a33 63@@ -482,7 +497,7 @@
1321be35
ER
64 int offset = frame_pointer_needed ? 2 : 0;
65
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;
69 }
70 }
71
cbd86a33 72@@ -666,7 +681,6 @@
1321be35
ER
73 int reg;
74 int interrupt_func_p;
75 int signal_func_p;
76- int main_p;
77 int live_seq;
78 int minimize;
79
cbd86a33 80@@ -684,7 +698,6 @@
1321be35
ER
81
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);
cbd86a33 88@@ -704,25 +717,14 @@
1321be35
ER
89 AS1 (clr,__zero_reg__) "\n");
90 prologue_size += 5;
91 }
92- if (main_p)
93- {
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);
100-
101- prologue_size += 4;
102- }
103- else if (minimize && (frame_pointer_needed || live_seq > 6))
104+ if (minimize && (frame_pointer_needed || live_seq > 6))
105 {
106 fprintf (file, ("\t"
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);
109
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);
114
115 prologue_size += 4;
116
cbd86a33 117@@ -793,7 +795,6 @@
1321be35
ER
118 int reg;
119 int interrupt_func_p;
120 int signal_func_p;
121- int main_p;
122 int function_size;
123 int live_seq;
124 int minimize;
cbd86a33 125@@ -825,27 +826,12 @@
1321be35
ER
126
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));
130+
131 live_seq = sequent_regs_live ();
132 minimize = (TARGET_CALL_PROLOGUES
133 && !interrupt_func_p && !signal_func_p && live_seq);
134
135- if (main_p)
136- {
137- /* Return value from main() is already in the correct registers
138- (r25:r24) as the exit() argument. */
139- if (AVR_MEGA)
140- {
141- fputs ("\t" AS1 (jmp,exit) "\n", file);
142- epilogue_size += 2;
143- }
144- else
145- {
146- fputs ("\t" AS1 (rjmp,exit) "\n", file);
147- ++epilogue_size;
148- }
149- }
150- else if (minimize && (frame_pointer_needed || live_seq > 4))
151+ if (minimize && (frame_pointer_needed || live_seq > 4))
152 {
153 fprintf (file, ("\t" AS2 (ldi, r30, %d) CR_TAB), live_seq);
154 ++epilogue_size;
cbd86a33 155@@ -1103,7 +1089,7 @@
1321be35
ER
156 && ((GET_CODE (addr) == SYMBOL_REF && SYMBOL_REF_FUNCTION_P (addr))
157 || GET_CODE (addr) == LABEL_REF))
158 {
159- fprintf (file, "pm(");
160+ fprintf (file, "gs(");
161 output_addr_const (file,addr);
162 fprintf (file ,")");
163 }
cbd86a33 164@@ -4524,7 +4510,7 @@
1321be35
ER
165 && ((GET_CODE (x) == SYMBOL_REF && SYMBOL_REF_FUNCTION_P (x))
166 || GET_CODE (x) == LABEL_REF))
167 {
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);
172 return true;
cbd86a33 173@@ -5914,7 +5900,7 @@
1321be35 174 {
cbd86a33 175 switch_to_section (progmem_section);
1321be35
ER
176 if (AVR_MEGA)
177- fprintf (stream, "\t.word pm(.L%d)\n", value);
178+ fprintf (stream, "\t.word gs(.L%d)\n", value);
179 else
180 fprintf (stream, "\trjmp .L%d\n", value);
181
cbd86a33 182diff -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
185@@ -36,6 +36,10 @@
186 builtin_define ("__AVR_HAVE_LPMX__"); \
1321be35
ER
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__"); \
cbd86a33 195 if (avr_enhanced_p) \
196@@ -53,6 +57,7 @@
1321be35
ER
197 extern int avr_enhanced_p;
198 extern int avr_asm_only_p;
cbd86a33 199 extern int avr_have_movw_lpmx_p;
1321be35 200+extern int avr_pc_size;
cbd86a33 201 #ifndef IN_LIBGCC2
202 extern GTY(()) section *progmem_section;
203 #endif
204@@ -61,6 +66,9 @@
1321be35 205 #define AVR_ENHANCED (avr_enhanced_p)
cbd86a33 206 #define AVR_HAVE_MOVW (avr_have_movw_lpmx_p)
1321be35
ER
207
208+#define AVR_3_BYTE_PC (avr_pc_size == 3)
209+#define AVR_2_BYTE_PC (avr_pc_size == 2)
210+
211 #define TARGET_VERSION fprintf (stderr, " (GNU assembler syntax)");
212
213 #define OVERRIDE_OPTIONS avr_override_options ()
cbd86a33 214@@ -727,12 +735,13 @@
1321be35
ER
215
216 #define CPP_SPEC "%{posix:-D_POSIX_SOURCE}"
217
218-#define CC1_SPEC "%{profile:-p}"
219+#define CC1_SPEC "%{profile:-p} -fno-delete-null-pointer-checks"
220
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'. */
229
cbd86a33 230 #define ASM_SPEC "%{mmcu=avr25:-mmcu=avr2;\
231@@ -773,6 +782,7 @@
1321be35
ER
232 mmcu=at90can*|\
233 mmcu=at90usb*|\
234 mmcu=at94k:-m avr5}\
235+%{mmcu=atmega256*:-m avr6}\
236 %{mmcu=atmega324*|\
cbd86a33 237 mmcu=atmega325*|\
238 mmcu=atmega329*|\
239@@ -796,7 +806,8 @@
1321be35
ER
240 mmcu=at90usb*: -Tdata 0x800100}\
241 %{mmcu=atmega640|\
242 mmcu=atmega1280|\
243- mmcu=atmega1281: -Tdata 0x800200} "
244+ mmcu=atmega1281|\
245+ mmcu=atmega256*: -Tdata 0x800200} "
246
247 #define LIB_SPEC \
248 "%{!mmcu=at90s1*:%{!mmcu=attiny11:%{!mmcu=attiny12:%{!mmcu=attiny15:%{!mmcu=attiny28: -lc }}}}}"
cbd86a33 249@@ -887,6 +898,8 @@
1321be35
ER
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} \
cbd86a33 255 %{mmcu=atmega8hva:crtm8hva.o%s} \
256 %{mmcu=atmega16hva:crtm16hva.o%s} \
1321be35 257 %{mmcu=at90can32:crtcan32.o%s} \
cbd86a33 258diff -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 @@
1321be35
ER
262 "(register_operand (operands[0], HImode) || CONSTANT_P (operands[0]))"
263 "*{
264 if (which_alternative==0)
265- return \"icall\";
266+ {
267+ if (AVR_3_BYTE_PC)
268+ return \"eicall\";
269+ else
270+ return \"icall\";
271+ }
272 else if (which_alternative==1)
273 {
cbd86a33 274 if (AVR_HAVE_MOVW)
1321be35
ER
275- return (AS2 (movw, r30, %0) CR_TAB
276- \"icall\");
277+ {
278+ if (AVR_3_BYTE_PC)
279+ return (AS2 (movw, r30, %0) CR_TAB
280+ \"eicall\");
281+ else
282+ return (AS2 (movw, r30, %0) CR_TAB
283+ \"icall\");
284+ }
285 else
286- return (AS2 (mov, r30, %A0) CR_TAB
287- AS2 (mov, r31, %B0) CR_TAB
288- \"icall\");
289+ {
290+ if (AVR_3_BYTE_PC)
cbd86a33 291+ return (AS2 (mov, r30, %A0) CR_TAB
1321be35
ER
292+ AS2 (mov, r31, %B0) CR_TAB
293+ \"eicall\");
294+ else
cbd86a33 295+ return (AS2 (mov, r30, %A0) CR_TAB
1321be35
ER
296+ AS2 (mov, r31, %B0) CR_TAB
297+ \"icall\");
298+ }
299 }
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
304- \"icall\");
1321be35
ER
305+ if (AVR_3_BYTE_PC)
306+ return (AS2 (ldi,r30,lo8(%0)) CR_TAB
307+ AS2 (ldi,r31,hi8(%0)) CR_TAB
308+ \"eicall\");
309+ else
310+ return (AS2 (ldi,r30,lo8(%0)) CR_TAB
311+ AS2 (ldi,r31,hi8(%0)) CR_TAB
cbd86a33 312+ \"icall\");
1321be35
ER
313 }"
314 [(set_attr "cc" "clobber,clobber,clobber,clobber")
315 (set_attr_alternative "length"
cbd86a33 316@@ -2136,22 +2159,45 @@
1321be35
ER
317 "(register_operand (operands[0], VOIDmode) || CONSTANT_P (operands[0]))"
318 "*{
319 if (which_alternative==0)
320- return \"icall\";
321+ {
322+ if (AVR_3_BYTE_PC)
323+ return \"eicall\";
324+ else
325+ return \"icall\";
326+ }
327 else if (which_alternative==1)
328 {
cbd86a33 329 if (AVR_HAVE_MOVW)
1321be35
ER
330- return (AS2 (movw, r30, %1) CR_TAB
331- \"icall\");
332+ {
333+ if (AVR_3_BYTE_PC)
334+ return (AS2 (movw, r30, %1) CR_TAB
335+ \"eicall\");
336+ else
337+ return (AS2 (movw, r30, %1) CR_TAB
338+ \"icall\");
339+ }
340 else
341- return (AS2 (mov, r30, %A1) CR_TAB
342- AS2 (mov, r31, %B1) CR_TAB
343- \"icall\");
344+ {
345+ if (AVR_3_BYTE_PC)
346+ return (AS2 (mov, r30, %A1) CR_TAB
347+ AS2 (mov, r31, %B1) CR_TAB
348+ \"eicall\");
349+ else
350+ return (AS2 (mov, r30, %A1) CR_TAB
351+ AS2 (mov, r31, %B1) CR_TAB
352+ \"icall\");
353+ }
354 }
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
359- \"icall\");
1321be35
ER
360+ if (AVR_3_BYTE_PC)
361+ return (AS2 (ldi, r30, lo8(%1)) CR_TAB
362+ AS2 (ldi, r31, hi8(%1)) CR_TAB
363+ \"eicall\");
364+ else
365+ return (AS2 (ldi, r30, lo8(%1)) CR_TAB
366+ AS2 (ldi, r31, hi8(%1)) CR_TAB
cbd86a33 367+ \"icall\");
1321be35
ER
368 }"
369 [(set_attr "cc" "clobber,clobber,clobber,clobber")
370 (set_attr_alternative "length"
cbd86a33 371@@ -2181,13 +2227,20 @@
1321be35
ER
372 ; indirect jump
373 (define_insn "indirect_jump"
374 [(set (pc) (match_operand:HI 0 "register_operand" "!z,*r"))]
375- ""
376+ "AVR_2_BYTE_PC"
377 "@
378 ijmp
379 push %A0\;push %B0\;ret"
380 [(set_attr "length" "1,3")
381 (set_attr "cc" "none,none")])
382
383+(define_insn "*indirect_jump_avr6"
384+ [(set (pc) (match_operand:HI 0 "register_operand" "z"))]
385+ "AVR_3_BYTE_PC"
386+ "eijmp"
387+ [(set_attr "length" "1")
388+ (set_attr "cc" "none")])
389+
390 ;; table jump
391
392 ;; Table made from "rjmp" instructions for <=8K devices.
cbd86a33 393@@ -2196,7 +2249,7 @@
394 UNSPEC_INDEX_JMP))
1321be35
ER
395 (use (label_ref (match_operand 1 "" "")))
396 (clobber (match_dup 0))]
397- "!AVR_MEGA"
398+ "(!AVR_MEGA) && (AVR_2_BYTE_PC)"
399 "@
400 ijmp
401 push %A0\;push %B0\;ret"
cbd86a33 402@@ -2214,12 +2267,27 @@
1321be35
ER
403 [(set_attr "length" "2")
404 (set_attr "cc" "clobber")])
405
406+(define_insn "*tablejump_avr6"
407+ [(set (pc) (unspec:HI [(match_operand:HI 0 "register_operand" "z")]
408+ 1))
409+ (use (label_ref (match_operand 1 "" "")))
410+ (clobber (match_dup 0))]
411+ "AVR_MEGA && AVR_ENHANCED && AVR_3_BYTE_PC"
412+ "lsl r30
cbd86a33 413+ rol r31
414+ lpm __tmp_reg__,Z+
415+ lpm r31,Z
416+ mov r30,__tmp_reg__
417+ eijmp"
1321be35
ER
418+ [(set_attr "length" "6")
419+ (set_attr "cc" "clobber")])
420+
421 (define_insn "*tablejump_enh"
cbd86a33 422 [(set (pc) (unspec:HI [(match_operand:HI 0 "register_operand" "z")]
423 UNSPEC_INDEX_JMP))
1321be35
ER
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"
428 "lsl r30
429 rol r31
430 lpm __tmp_reg__,Z+
cbd86a33 431@@ -2234,7 +2302,7 @@
432 UNSPEC_INDEX_JMP))
1321be35
ER
433 (use (label_ref (match_operand 1 "" "")))
434 (clobber (match_dup 0))]
435- "AVR_MEGA"
436+ "AVR_MEGA && AVR_2_BYTE_PC"
437 "lsl r30
438 rol r31
439 lpm
cbd86a33 440diff -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
1321be35
ER
443@@ -593,7 +593,12 @@
444 out __SP_H__,r29
445 out __SREG__,__tmp_reg__
446 out __SP_L__,r28
447+#if defined (__AVR_3_BYTE_PC__)
448+ eijmp
449+#else
450 ijmp
451+#endif
452+
453 .endfunc
454 #endif /* defined (L_prologue) */
455
456@@ -672,13 +677,22 @@
457 lpm __tmp_reg__, Z+
458 lpm r31, Z
459 mov r30, __tmp_reg__
460+
461+#if defined (__AVR_3_BYTE_PC__)
462+ eijmp
463+#else
464 ijmp
465+#endif
466+
467 #else
468 lpm
469 adiw r30, 1
470 push r0
471 lpm
472 push r0
473+#if defined (__AVR_3_BYTE_PC__)
474+ push __zero_reg__
475+#endif
476 ret
477 #endif
478 .endfunc
cbd86a33 479diff -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
1321be35
ER
482@@ -37,8 +37,8 @@
483
484 FPBIT = fp-bit.c
485
cbd86a33 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
1321be35
ER
490
491 # The many avr2 matches are not listed here - this is the default.
492 MULTILIB_MATCHES = \
cbd86a33 493@@ -111,7 +111,9 @@
1321be35
ER
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
501
502 MULTILIB_EXCEPTIONS =
503
This page took 0.156399 seconds and 4 git commands to generate.