gcc 4.2.4 support
[openwrt/staging/chunkeey.git] / toolchain / gcc / patches / 4.2.4 / 906-avr32_use_rjmp_instead_of_got_when_jumping.patch
1 Index: gcc-4.2.3/gcc/config/avr32/avr32.c
2 ===================================================================
3 --- gcc-4.2.3.orig/gcc/config/avr32/avr32.c 2008-05-21 13:45:59.762288215 +0200
4 +++ gcc-4.2.3/gcc/config/avr32/avr32.c 2008-05-21 13:46:00.342290304 +0200
5 @@ -695,8 +695,7 @@
6
7
8 if (!avr32_const_ok_for_constraint_p (mi_delta, 'I', "Is21")
9 - || vcall_offset
10 - || flag_pic)
11 + || vcall_offset)
12 {
13 fputs ("\tpushm\tlr\n", file);
14 }
15 @@ -728,47 +727,23 @@
16 }
17
18
19 - if ( (!avr32_const_ok_for_constraint_p (mi_delta, 'I', "Is21")
20 - || vcall_offset)
21 - && !flag_pic )
22 + if (!avr32_const_ok_for_constraint_p (mi_delta, 'I', "Is21")
23 + || vcall_offset)
24 {
25 fputs ("\tpopm\tlr\n", file);
26 }
27 -
28 - if (flag_pic)
29 - {
30 - /* Load the got into lr and then load the pointer
31 - to the function from the got and put it on the stack.
32 - We can then call the function and restore lr by issuing
33 - a doubleword load from the stack. We do not use a popm/ldm
34 - since it will be treated as a return and might need a flushing
35 - of the return-stack if available. */
36 - rtx label = gen_label_rtx ();
37 - /* Load the got. */
38 - fputs ("\tlddpc\tlr, 0f\n", file);
39 - (*targetm.asm_out.internal_label) (file, "L",
40 - CODE_LABEL_NUMBER (label));
41 - fputs ("\trsub\tlr, pc\n", file);
42 - /* Load the function pointer. */
43 - fputs ("\tld.w\tlr, lr[", file);
44 - assemble_name (file, XSTR (XEXP (DECL_RTL (function), 0), 0));
45 - fputs ("@got]\n", file);
46 - /* Push the function pointer on the stack.*/
47 - fputs ("\tpushm\tlr\n", file);
48 - /* Restore the old lr value and load the function pointer into
49 - pc. */
50 - fputs ("\tld.d\tlr,sp++\n", file);
51 - fprintf (file, "\t.align 2\n");
52 - fprintf (file, "0:\t.long\t.L%d - _GLOBAL_OFFSET_TABLE_\n", CODE_LABEL_NUMBER (label));
53 - }
54 - else
55 - {
56 - fprintf (file, "\tlddpc\tpc, 0f\n");
57 - fprintf (file, "\t.align 2\n");
58 - fputs ("0:\t.long\t", file);
59 - assemble_name (file, XSTR (XEXP (DECL_RTL (function), 0), 0));
60 - fputc ('\n', file);
61 - }
62 +
63 + /* Jump to the function. We assume that we can use an rjmp since the
64 + function to jump to is local and probably not too far away from
65 + the thunk. If this assumption proves to be wrong we could implement
66 + this jump by calculating the offset between the jump source and destination
67 + and put this in the constant pool and then perform an add to pc.
68 + This would also be legitimate PIC code. But for now we hope that an rjmp
69 + will be sufficient...
70 + */
71 + fputs ("\trjmp\t", file);
72 + assemble_name (file, XSTR (XEXP (DECL_RTL (function), 0), 0));
73 + fputc ('\n', file);
74 }
75
76 /* Implements target hook vector_mode_supported. */
77 @@ -1742,7 +1717,7 @@
78 if (TREE_CODE (*node) != FUNCTION_DECL)
79 {
80 warning ("`%s' attribute only applies to functions",
81 - IDENTIFIER_POINTER (name));
82 + IDENTIFIER_POINTER (name));
83 *no_add_attrs = true;
84 }
85 /* FIXME: the argument if any is checked for type attributes; should it