This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[bfin] Deal with long call for FDPIC
- From: "Jie Zhang" <jzhang918 at gmail dot com>
- To: "GCC Patches" <gcc-patches at gcc dot gnu dot org>
- Cc: "Bernd Schmidt" <bernds_cb1 at t-online dot de>
- Date: Thu, 11 May 2006 23:58:12 +0800
- Subject: [bfin] Deal with long call for FDPIC
This patch deals with long call function attribute for Blackfin FDPIC
case. I have discussed with Bernd on this patch in our Blackfin
uClinux website. And this is the final patch, which has been modified
as suggested by Bernd's comments and entered our CVS in
blackfin.uclinux.org.
Is it OK for FSF repository, for both trunk and 4.1?
Thanks,
Jie
* config/bfin/bfin.c (bfin_expand_call): Deal with long call
for FDPIC.
* testsuite/gcc.dg/bfin-longcall-3.c: New testcase.
* testsuite/gcc.dg/bfin-longcall-4.c: New testcase.
Index: config/bfin/bfin.c
===================================================================
RCS file: /cvsroot/gcc3/gcc-3.4/gcc/config/bfin/bfin.c,v
retrieving revision 1.106
diff -u -p -r1.106 bfin.c
--- config/bfin/bfin.c 7 Apr 2006 16:14:49 -0000 1.106
+++ config/bfin/bfin.c 11 May 2006 14:28:43 -0000
@@ -1935,7 +1946,8 @@ bfin_expand_call (rtx retval, rtx fnaddr
if (TARGET_FDPIC)
{
- if (GET_CODE (callee) != SYMBOL_REF)
+ if (GET_CODE (callee) != SYMBOL_REF
+ || bfin_longcall_p (callee, INTVAL (cookie)))
{
rtx addr = callee;
if (! address_operand (addr, Pmode))
Index: testsuite/gcc.dg/bfin-longcall-3.c
===================================================================
RCS file: testsuite/gcc.dg/bfin-longcall-3.c
diff -N testsuite/gcc.dg/bfin-longcall-3.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.dg/bfin-longcall-3.c 11 May 2006 14:29:02 -0000
@@ -0,0 +1,66 @@
+/* Check that long call */
+/* { dg-do run { target bfin-*-* } } */
+/* { dg-options "-O2" } */
+
+int __attribute__((longcall, noinline))
+foo (int a, int b)
+{
+ return a * 2 + b * 3;
+}
+
+int __attribute__((shortcall, noinline))
+bar (int a, int b)
+{
+ return a * 3 + b * 7;
+}
+
+int __attribute__((noinline))
+baz (int a, int b)
+{
+ return a * 2 + b * 5;
+}
+
+int __attribute__((noinline))
+t1 ()
+{
+ if (foo (1, 3) != 1 * 2 + 3 * 3)
+ abort ();
+ if (bar (1, 3) != 1 * 3 + 3 * 7)
+ abort ();
+ if (baz (1, 3) != 1 * 2 + 3 * 5)
+ abort ();
+
+ return 4;
+}
+
+int __attribute__((noinline))
+t2 (int a, int b)
+{
+ return foo (a, b);
+}
+
+int __attribute__((noinline))
+t3 (int a, int b)
+{
+ return bar (a, b);
+}
+
+int __attribute__((noinline))
+t4 (int a, int b)
+{
+ return baz (a, b);
+}
+
+int main ()
+{
+ if (t1 () != 4)
+ abort ();
+ if (t2 (2, 9) != 2 * 2 + 9 * 3)
+ abort ();
+ if (t3 (2, 9) != 2 * 3 + 9 * 7)
+ abort ();
+ if (t4 (2, 9) != 2 * 2 + 9 * 5)
+ abort ();
+
+ return 0;
+}
Index: testsuite/gcc.dg/bfin-longcall-4.c
===================================================================
RCS file: testsuite/gcc.dg/bfin-longcall-4.c
diff -N testsuite/gcc.dg/bfin-longcall-4.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.dg/bfin-longcall-4.c 11 May 2006 14:29:02 -0000
@@ -0,0 +1,66 @@
+/* Check that long call */
+/* { dg-do run { target bfin-*-* } } */
+/* { dg-options "-O2 -mlong-calls" } */
+
+int __attribute__((longcall, noinline))
+foo (int a, int b)
+{
+ return a * 2 + b * 3;
+}
+
+int __attribute__((shortcall, noinline))
+bar (int a, int b)
+{
+ return a * 3 + b * 7;
+}
+
+int __attribute__((noinline))
+baz (int a, int b)
+{
+ return a * 2 + b * 5;
+}
+
+int __attribute__((noinline))
+t1 ()
+{
+ if (foo (1, 3) != 1 * 2 + 3 * 3)
+ abort ();
+ if (bar (1, 3) != 1 * 3 + 3 * 7)
+ abort ();
+ if (baz (1, 3) != 1 * 2 + 3 * 5)
+ abort ();
+
+ return 4;
+}
+
+int __attribute__((noinline))
+t2 (int a, int b)
+{
+ return foo (a, b);
+}
+
+int __attribute__((noinline))
+t3 (int a, int b)
+{
+ return bar (a, b);
+}
+
+int __attribute__((noinline))
+t4 (int a, int b)
+{
+ return baz (a, b);
+}
+
+int main ()
+{
+ if (t1 () != 4)
+ abort ();
+ if (t2 (2, 9) != 2 * 2 + 9 * 3)
+ abort ();
+ if (t3 (2, 9) != 2 * 3 + 9 * 7)
+ abort ();
+ if (t4 (2, 9) != 2 * 2 + 9 * 5)
+ abort ();
+
+ return 0;
+}