Eventual bug in config/rs6000.md
Anton Hartl
toni@devsoft.com
Fri Nov 27 10:14:00 GMT 1998
The diff that is attached covers one potential bug and an enhancement.
OS: VxWorks
CPU: PowerPC
The problem I ran into is that on VxWorks/PPC the EABI calling
conventions are used; these assume that you don't have
more than 32 MB of memory. Thus all calls are direct calls with
the branch offset in the instruction. As the size of the offset
is limited to 24 bits you run into a problem on PPC boards with
more than 32 MB of memory. The diff that is attach adds a machine
specific option "-mlongcall" to egcs that forces all calls to be made
through a register. Please not that this patch has been put together
more by making good guesses as what certain code does, than by really
understanding all the details. So this might as well be just wrong.
It seems to work however. Provided this patch is correct and
makes sense, can this be included in further releases of egcs?
The second hunk actually points to a real bug. The original code
looks like this
if (GET_CODE (operands[1]) != SYMBOL_REF
|| (INTVAL (operands[3]) & CALL_LONG) != 0)
{
if (INTVAL (operands[2]) & CALL_LONG) <====
operands[1] = rs6000_longcall_ref (operands[1]);
This looks like a cut&paste error from code some 50 lines above
and in the marked line should probably read
if (INTVAL (operands[3]) & CALL_LONG)
This is part of the patch below.
diff -rubN egcs-1.1b.orig/gcc/config/rs6000/rs6000.c egcs-1.1b/gcc/config/rs6000/rs6000.c
--- egcs-1.1b.orig/gcc/config/rs6000/rs6000.c Tue Aug 25 20:48:18 1998
+++ egcs-1.1b/gcc/config/rs6000/rs6000.c Thu Oct 22 15:43:26 1998
@@ -1242,6 +1242,9 @@
else if (fntype && lookup_attribute ("longcall", TYPE_ATTRIBUTES (fntype)))
cum->call_cookie = CALL_LONG;
+ if (fntype && TARGET_LONGCALL)
+ cum->call_cookie = CALL_LONG;
+
if (TARGET_DEBUG_ARG)
{
fprintf (stderr, "\ninit_cumulative_args:");
diff -rubN egcs-1.1b.orig/gcc/config/rs6000/rs6000.md egcs-1.1b/gcc/config/rs6000/rs6000.md
--- egcs-1.1b.orig/gcc/config/rs6000/rs6000.md Tue Aug 25 20:48:21 1998
+++ egcs-1.1b/gcc/config/rs6000/rs6000.md Thu Oct 22 15:44:19 1998
@@ -7562,9 +7562,10 @@
}
if (GET_CODE (operands[0]) != SYMBOL_REF
+ || TARGET_LONGCALL
|| (INTVAL (operands[2]) & CALL_LONG) != 0)
{
- if (INTVAL (operands[2]) & CALL_LONG)
+ if (TARGET_LONGCALL || (INTVAL (operands[2]) & CALL_LONG))
operands[0] = rs6000_longcall_ref (operands[0]);
if (DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_AIX_NODESC || DEFAULT_ABI == ABI_SOLARIS)
@@ -7624,9 +7625,10 @@
}
if (GET_CODE (operands[1]) != SYMBOL_REF
+ || TARGET_LONGCALL
|| (INTVAL (operands[3]) & CALL_LONG) != 0)
{
- if (INTVAL (operands[2]) & CALL_LONG)
+ if (TARGET_LONGCALL || (INTVAL (operands[3]) & CALL_LONG))
operands[1] = rs6000_longcall_ref (operands[1]);
if (DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_AIX_NODESC || DEFAULT_ABI == ABI_SOLARIS)
diff -rubN egcs-1.1b.orig/gcc/config/rs6000/vxppc.h egcs-1.1b/gcc/config/rs6000/vxppc.h
--- egcs-1.1b.orig/gcc/config/rs6000/vxppc.h Fri Apr 17 16:32:23 1998
+++ egcs-1.1b/gcc/config/rs6000/vxppc.h Fri Oct 23 13:08:59 1998
@@ -22,6 +22,15 @@
#include "rs6000/sysv4.h"
+/* Generate all function call as 32 bit calls through a register */
+#define MASK_LONGCALL 0x00100000
+#define TARGET_LONGCALL (target_flags & MASK_LONGCALL)
+
+#undef EXTRA_SUBTARGET_SWITCHES
+#define EXTRA_SUBTARGET_SWITCHES \
+ { "longcall", MASK_LONGCALL }, \
+ { "no-longcall", -MASK_LONGCALL },
+
/* ??? This file redefines CPP_SPEC which is wrong. It should instead define
one of the extra specs that gets included in CPP_SPEC. For instance,
CPP_OS_DEFAULT_SPEC. The mrelocatable line was copied from CPP_SYSV_SPEC.
Best Regards,
-Toni
--
/dev Software Gmbh | Anton Hartl | Dumbo: You're an unusual cop.
Gabelsbergerstr. 51 | Phone: +49 (0)89-28659843 | Mickey Mouse: You're an unusal
80333 Muenchen | Fax: +49 (0)89-28659845 | killer, too.
Germany | Email: toni@devsoft.com | John Woo, The Killer
More information about the Gcc-bugs
mailing list