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