patches/gcc/3.4.6/190-all_sh-pr16665-fix.patch
author Arnaud Lacombe <lacombar@gmail.com>
Tue Aug 03 06:17:51 2010 +0200 (2010-08-03)
changeset 2064 f5ebe8c429dc
parent 402 197e1b49586e
permissions -rw-r--r--
libc/uClibc: add uClibc 0.9.30.3

This version has been released a couple of month ago, but it never reached
crosstool-ng tree. This may be linked to the fact that the current 0.9.30.2,
once patched, has nothing much different from 0.9.30.3, released.

I'm not including any patch with this upgrade, on purpose.

Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
yann@402
     1
diff -durN gcc-3.4.6.orig/gcc/config/sh/sh.c gcc-3.4.6/gcc/config/sh/sh.c
yann@402
     2
--- gcc-3.4.6.orig/gcc/config/sh/sh.c	2004-09-03 08:51:30.000000000 +0200
yann@402
     3
+++ gcc-3.4.6/gcc/config/sh/sh.c	2007-08-15 23:01:48.000000000 +0200
yann@402
     4
@@ -9107,6 +9107,15 @@
yann@402
     5
     }
yann@402
     6
   this = FUNCTION_ARG (cum, Pmode, ptr_type_node, 1);
yann@402
     7
 
yann@402
     8
+  /* In PIC case, we set PIC register to compute the target address.  We
yann@402
     9
+     can use a scratch register to save and restore the original value  
yann@402
    10
+     except for SHcompact.  For SHcompact, use stack.  */
yann@402
    11
+  if (flag_pic && TARGET_SHCOMPACT)
yann@402
    12
+    {
yann@402
    13
+      push (PIC_OFFSET_TABLE_REGNUM);
yann@402
    14
+      emit_insn (gen_GOTaddr2picreg ());
yann@402
    15
+    }
yann@402
    16
+
yann@402
    17
   /* For SHcompact, we only have r0 for a scratch register: r1 is the
yann@402
    18
      static chain pointer (even if you can't have nested virtual functions
yann@402
    19
      right now, someone might implement them sometime), and the rest of the
yann@402
    20
@@ -9189,8 +9198,24 @@
yann@402
    21
       assemble_external (function);
yann@402
    22
       TREE_USED (function) = 1;
yann@402
    23
     }
yann@402
    24
+  /* We can use scratch1 to save and restore the original value of
yann@402
    25
+     PIC register except for SHcompact.  */
yann@402
    26
+  if (flag_pic && ! TARGET_SHCOMPACT)
yann@402
    27
+    {
yann@402
    28
+      emit_move_insn (scratch1,
yann@402
    29
+		      gen_rtx_REG (Pmode, PIC_OFFSET_TABLE_REGNUM));
yann@402
    30
+      emit_insn (gen_GOTaddr2picreg ());
yann@402
    31
+    }
yann@402
    32
   funexp = XEXP (DECL_RTL (function), 0);
yann@402
    33
   emit_move_insn (scratch2, funexp);
yann@402
    34
+  if (flag_pic)
yann@402
    35
+    {
yann@402
    36
+      if (! TARGET_SHCOMPACT)
yann@402
    37
+	emit_move_insn (gen_rtx_REG (Pmode, PIC_OFFSET_TABLE_REGNUM),
yann@402
    38
+			scratch1);
yann@402
    39
+      else
yann@402
    40
+	pop (PIC_OFFSET_TABLE_REGNUM);
yann@402
    41
+    }
yann@402
    42
   funexp = gen_rtx_MEM (FUNCTION_MODE, scratch2);
yann@402
    43
   sibcall = emit_call_insn (gen_sibcall (funexp, const0_rtx, NULL_RTX));
yann@402
    44
   SIBLING_CALL_P (sibcall) = 1;