patches/gcc/3.4.6/190-all_sh-pr16665-fix.patch
author "Yann E. MORIN" <yann.morin.1998@free.fr>
Tue Jul 31 22:27:29 2012 +0200 (2012-07-31)
changeset 3018 7776e8369284
parent 402 197e1b49586e
permissions -rw-r--r--
complibs/cloog: create missing m4 dir

Because we now patch configure.in and configure, the Makefile quicks
in a re-build rule as the source files are now more recent than the
bundled generated files, and that fails because the m4 directory
is missing, although on some systems where aclocal is not installed,
the re-build rule does nothing (except a warning).

Always create tht directory.

Reported-by: Per Arnold Blaasmo <per-arnold.blaasmo@atmel.com>
[Also thanks to Thomas De Schampheleire <patrickdepinguin@gmail.com>
for some digging works on this issue]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
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;