PATCH: Turn mips relaxation if appropriate (Re: MIPS gas relaxation still doesn't work)

H. J. Lu hjl@lucon.org
Sun Oct 13 14:19:00 GMT 2002


On Sat, Oct 12, 2002 at 03:51:51PM -0700, H. J. Lu wrote:
> On Sat, Oct 12, 2002 at 11:34:23AM -0700, H. J. Lu wrote:
> > Hi Alexandre,
> > 
> > I don't think your MIPS gas relaxation works. I got
> > 
> > # mipsel-linux-gcc /export/gnu/src/gcc-3.2/gcc/gcc/testsuite/g++.dg/opt/longbranch1.C
> > /tmp/cc0rrnMz.s: Assembler messages:
> > /tmp/cc0rrnMz.s:33733: Error: Branch out of range
> > /tmp/cc0rrnMz.s:33740: Error: Branch out of range
> > 
> > Could you please verify it?
> > 
> 
> I see there are 2 problems:
> 
> 1. -relax-branch is not on by default.
> 2. I got
> 
> Warning: relaxed out-of-range branch into a jump
> 
> If I understand it correctly, -relax-branch is off by default since
> it may generate correct, but worse, code under certain conditions.
> My question is which ABI will generate code like
> 
> 	la	$3,l2-l3
> 
> If only EMBEDDED_PIC does it, why not turn it on for other ABIs?
> 
> Is the warning really necessary? Do other gas targets issue a warning
> for branch/jump relaxation? Does the native mips assembler issuse a
> warning? I changed the mips gas to get rid of some warnings:
> 
> http://sources.redhat.com/ml/binutils/2001-06/msg00101.html
> 
> I hate to see the new ones added for no very good reasons.
> 
> 

I am enclosing a patch to turn on branch relaxation if EMBEDDED_PIC is
not used. Also it won't give a warning if relaxation is on by default.


H.J.
-------------- next part --------------
2002-10-13  H.J. Lu <hjl@gnu.org>

	* gas/config/tc-mips.c (mips_relax_branch): Initialized to -1.
	(mips_after_parse_args): Set to 0 for EMBEDDED_PIC, otherwise
	2.
	(md_convert_frag): Warn branch relaxation if it is turned on
	from command line.

--- gas/config/tc-mips.c.relax	Sat Oct 12 08:49:24 2002
+++ gas/config/tc-mips.c	Sun Oct 13 14:11:27 2002
@@ -576,7 +576,12 @@ static int mips_fix_4122_bugs;
    fail to compute the offset before expanding the macro to the most
    efficient expansion.  */
 
-static int mips_relax_branch;
+/*
+   0: relaxation is off.
+   1: relaxation is turned on from command line.
+   2: relaxation is on by default. 
+ */
+static int mips_relax_branch = -1;
 
 /* Since the MIPS does not have multiple forms of PC relative
    instructions, we do not have to do relaxing as is done on other
@@ -10815,6 +10820,9 @@ mips_after_parse_args ()
 #endif /* OBJ_MAYBE_ECOFF */
 	mips_flag_mdebug = 0;
     }
+
+  if (mips_relax_branch < 0)
+    mips_relax_branch = (mips_pic == EMBEDDED_PIC) ? 0 : 2;
 }
 
 void
@@ -13380,8 +13388,9 @@ md_convert_frag (abfd, asec, fragp)
 	{
 	  int i;
 
-	  as_warn_where (fragp->fr_file, fragp->fr_line,
-			 _("relaxed out-of-range branch into a jump"));
+	  if (mips_relax_branch == 1)
+	    as_warn_where (fragp->fr_file, fragp->fr_line,
+			   _("relaxed out-of-range branch into a jump"));
 
 	  if (RELAX_BRANCH_UNCOND (fragp->fr_subtype))
 	    goto uncond;


More information about the Binutils mailing list