This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[3.3 mips] Adjust calls to symbolic addresses
- From: Richard Sandiford <rsandifo at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: echristo at redhat dot com
- Date: 26 Feb 2003 14:43:38 +0000
- Subject: [3.3 mips] Adjust calls to symbolic addresses
The patch below stops calls to foo() using the fixed-form sequence
"la $25, foo; jal $31, $25". They now use "jal foo" instead.
The problem with using two instructions is that it prevents lazy binding
on irix systems. Because of a gas-specific feature, we still get lazy
binding on GNU systems, but there's talk of removing that feature soon.
See the thread starting at:
http://sources.redhat.com/ml/binutils/2003-02/msg00317.html
for details.
Is the patch OK for 3.3 branch? It doesn't fix a regression as such,
but it should improve compatibility with future binutils.
(Things have already changed on mips-3_4-rewrite-branch, so the
patch shouldn't be needed for trunk.)
Bootstrapped on mipsel-linux-gnu and mips-sgi-irix6.5. I verified
that calls on irix now have R_MIPS_CALL16 relocs as expected.
Richard
* config/mips/mips.md (call_internal2): Don't use a separate "la"
instruction for calls to symbolic addresses.
(call_value_internal2, call_value_multiple_internal2): Likewise.
Index: config/mips/mips.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/mips.md,v
retrieving revision 1.153.2.1
diff -u -d -p -F^[(a-zA-Z0-9_^#] -r1.153.2.1 mips.md
--- config/mips/mips.md 3 Jan 2003 19:43:17 -0000 1.153.2.1
+++ config/mips/mips.md 23 Feb 2003 10:41:07 -0000
@@ -10226,17 +10226,10 @@ (define_insn "call_internal2"
if (GET_CODE (target) == CONST_INT)
return \"li\\t%^,%0\\n\\tjal\\t%2,%^\";
- else if (CONSTANT_ADDRESS_P (target))
- {
- if (GET_MODE (target) == SImode)
- return \"la\\t%^,%0\\n\\tjal\\t%2,%^\";
- else
- return \"dla\\t%^,%0\\n\\tjal\\t%2,%^\";
- }
- else if (REGNO (target) != PIC_FUNCTION_ADDR_REGNUM)
+ else if (REG_P (target) && REGNO (target) != PIC_FUNCTION_ADDR_REGNUM)
return \"move\\t%^,%0\\n\\tjal\\t%2,%^\";
else
- return \"jal\\t%2,%0\";
+ return \"jal\\t%0\";
}"
[(set_attr "type" "call")
(set_attr "mode" "none")
@@ -10434,17 +10427,10 @@ (define_insn "call_value_internal2"
if (GET_CODE (target) == CONST_INT)
return \"li\\t%^,%1\\n\\tjal\\t%3,%^\";
- else if (CONSTANT_ADDRESS_P (target))
- {
- if (GET_MODE (target) == SImode)
- return \"la\\t%^,%1\\n\\tjal\\t%3,%^\";
- else
- return \"dla\\t%^,%1\\n\\tjal\\t%3,%^\";
- }
- else if (REGNO (target) != PIC_FUNCTION_ADDR_REGNUM)
+ else if (REG_P (target) && REGNO (target) != PIC_FUNCTION_ADDR_REGNUM)
return \"move\\t%^,%1\\n\\tjal\\t%3,%^\";
else
- return \"jal\\t%3,%1\";
+ return \"jal\\t%1\";
}"
[(set_attr "type" "call")
(set_attr "mode" "none")
@@ -10569,17 +10555,10 @@ (define_insn "call_value_multiple_intern
if (GET_CODE (target) == CONST_INT)
return \"li\\t%^,%1\\n\\tjal\\t%4,%^\";
- else if (CONSTANT_ADDRESS_P (target))
- {
- if (GET_MODE (target) == SImode)
- return \"la\\t%^,%1\\n\\tjal\\t%4,%^\";
- else
- return \"dla\\t%^,%1\\n\\tjal\\t%4,%^\";
- }
- else if (REGNO (target) != PIC_FUNCTION_ADDR_REGNUM)
+ else if (REG_P (target) && REGNO (target) != PIC_FUNCTION_ADDR_REGNUM)
return \"move\\t%^,%1\\n\\tjal\\t%4,%^\";
else
- return \"jal\\t%4,%1\";
+ return \"jal\\t%1\";
}"
[(set_attr "type" "call")
(set_attr "mode" "none")