This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: mips 64-bit address generation is broken.


cgd@broadcom.com wrote:
[snip]
> >   - Make la and dla always behaving different with the possible exception
> >     of 32 bit GPRS. This will lose compatibility to existing code.
> >   - Assume embedded mips is the only dual 32/64 bit ABI and expand
> >     for it according to the code. Do expansion to the ABI's definition
> >     in all other cases.
> 
> So, I _think_ what you want to do is:
> 
> (1) if you have 64-bit addresses, make dla and la behave identically.
> 
> (2) If you have 32-bit addresses, they need to behave (potentially --
>     depending on the exact calculation involved) differently,
>     depending on the addresses involved.  Obviously, e.g. loads of
>     pointers should be done as 32-bit loads, but then the subsequent
>     operations (e.g. adding offsets) need to be done as 64-bit ops.

I see. Doing so will result in different behaviour for dla in 32bit
code as e.g. SGI has. Of course, one could argue that such code is
bugged and should be fixed. :-)

[snip]
> > --- source-orig/gas/config/tc-mips.c	Tue Feb 12 17:04:35 2002
> > +++ source/gas/config/tc-mips.c	Mon Feb 18 04:35:00 2002
> > @@ -4616,11 +4640,11 @@ macro (ip)
> >  	      macro_build ((char *) NULL, &icnt, &offset_expr, "lui", "t,u",
> >  			   tempreg, (int) BFD_RELOC_PCREL_HI16_S);
> >  	      macro_build ((char *) NULL, &icnt, (expressionS *) NULL,
> > -			   HAVE_32BIT_ADDRESSES ? "addu" : "daddu",
> > +			   dbl ? "addu" : "daddu",
> >  			   "d,v,t", tempreg, tempreg, breg);
> >  	    }
> >  	  macro_build ((char *) NULL, &icnt, &offset_expr,
> > -		       HAVE_32BIT_ADDRESSES ? "addiu" : "daddiu",
> > +		       dbl ? "addiu" : "daddiu",
> >  		       "t,r,j", treg, tempreg, (int) BFD_RELOC_PCREL_LO16);
> >  	  if (! used_at)
> >  	    return;
> 
> because of the way the HAVE_32BIT_ADDRESSES macro works, actually,
> these (the embedded-pic case) basically evaluate to HAVE_32BIT_GPRS.
> 
> The existing (embedded-pic) code here will always evaluate to using
> daddu & daddiu if 64-bit GPRs.
> 
> Maybe this is the right thing, but it changes the current behaviour.
> The test cases won't test it.  8-)

And the check is now the wrong way around, too. 8-) The test cases
are really insufficient WRT.

[snip]
> >  	  macro_build (p, &icnt, &offset_expr,
> > -		       dbl ? "ld" : "lw",
> > +		       HAVE_32BIT_ADDRESSES ? "lw" : "ld",
> >  		       "t,o(b)", tempreg, (int) BFD_RELOC_MIPS_GOT16, GP);
> >  	  p += 4;
> >  	  if (expr1.X_add_number >= -0x8000
> 
> These three have nothing to do with the embedded-ABI stuff, right?

Yes, I cleaned up two useless leftovers. The third is a bugfix,
$gp loading must always follow the addressing mode.

[snip]
> > @@ -5072,8 +5095,16 @@ macro (ip)
> >  	       addiu	$tempreg,$gp,<sym>	(BFD_RELOC_GPREL16)
> >  	     */
> >  	  macro_build ((char *) NULL, &icnt, &offset_expr,
> > -		       HAVE_32BIT_ADDRESSES ? "addiu" : "daddiu",
> > +		       dbl ? "addiu" : "daddiu",
> >  		       "t,r,j", tempreg, GP, (int) BFD_RELOC_GPREL16);
> > +	  if (breg != 0)
> > +	    macro_build ((char *) NULL, &icnt, (expressionS *) NULL,
> > +			 dbl ? "addu" : "daddu",
> > +			 "d,v,t", treg, tempreg, breg);
> > +	  if (! used_at)
> > +	    return;
> > +
> > +	  break;
> >  	}
> >        else
> >  	abort ();
> 
> hmm.  This is not sufficient, I don't think.  You also need to do this
> for the NO_PIC case.

What will not work for NO_PIC otherwise?


Thiemo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]