patches/gcc/3.4.4/71_all_sh-pr16665-fix.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sat Feb 24 11:00:05 2007 +0000 (2007-02-24)
changeset 1 eeea35fbf182
permissions -rw-r--r--
Add the full crosstool-NG sources to the new repository of its own.
You might just say: 'Yeah! crosstool-NG's got its own repo!".
Unfortunately, that's because the previous repo got damaged beyond repair and I had no backup.
That means I'm putting backups in place in the afternoon.
That also means we've lost history... :-(
yann@1
     1
--- gcc/gcc/config/sh/sh.c
yann@1
     2
+++ gcc/gcc/config/sh/sh.c
yann@1
     3
@@ -9106,6 +9106,15 @@ sh_output_mi_thunk (FILE *file, tree thu
yann@1
     4
     }
yann@1
     5
   this = FUNCTION_ARG (cum, Pmode, ptr_type_node, 1);
yann@1
     6
 
yann@1
     7
+  /* In PIC case, we set PIC register to compute the target address.  We
yann@1
     8
+     can use a scratch register to save and restore the original value  
yann@1
     9
+     except for SHcompact.  For SHcompact, use stack.  */
yann@1
    10
+  if (flag_pic && TARGET_SHCOMPACT)
yann@1
    11
+    {
yann@1
    12
+      push (PIC_OFFSET_TABLE_REGNUM);
yann@1
    13
+      emit_insn (gen_GOTaddr2picreg ());
yann@1
    14
+    }
yann@1
    15
+
yann@1
    16
   /* For SHcompact, we only have r0 for a scratch register: r1 is the
yann@1
    17
      static chain pointer (even if you can't have nested virtual functions
yann@1
    18
      right now, someone might implement them sometime), and the rest of the
yann@1
    19
@@ -9188,8 +9197,24 @@ sh_output_mi_thunk (FILE *file, tree thu
yann@1
    20
       assemble_external (function);
yann@1
    21
       TREE_USED (function) = 1;
yann@1
    22
     }
yann@1
    23
+  /* We can use scratch1 to save and restore the original value of
yann@1
    24
+     PIC register except for SHcompact.  */
yann@1
    25
+  if (flag_pic && ! TARGET_SHCOMPACT)
yann@1
    26
+    {
yann@1
    27
+      emit_move_insn (scratch1,
yann@1
    28
+		      gen_rtx_REG (Pmode, PIC_OFFSET_TABLE_REGNUM));
yann@1
    29
+      emit_insn (gen_GOTaddr2picreg ());
yann@1
    30
+    }
yann@1
    31
   funexp = XEXP (DECL_RTL (function), 0);
yann@1
    32
   emit_move_insn (scratch2, funexp);
yann@1
    33
+  if (flag_pic)
yann@1
    34
+    {
yann@1
    35
+      if (! TARGET_SHCOMPACT)
yann@1
    36
+	emit_move_insn (gen_rtx_REG (Pmode, PIC_OFFSET_TABLE_REGNUM),
yann@1
    37
+			scratch1);
yann@1
    38
+      else
yann@1
    39
+	pop (PIC_OFFSET_TABLE_REGNUM);
yann@1
    40
+    }
yann@1
    41
   funexp = gen_rtx_MEM (FUNCTION_MODE, scratch2);
yann@1
    42
   sibcall = emit_call_insn (gen_sibcall (funexp, const0_rtx, NULL_RTX));
yann@1
    43
   SIBLING_CALL_P (sibcall) = 1;