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: [patch] MIPS gas problems with gcc's explicit relocs


On Sat, 29 May 2004, Thiemo Seufer wrote:

> > > > 	asm("dla\t%0,%1" : "=r" (result) : "m" (foo));
> > > [snip]
> > > > 	lui	$2,%highest(foo)
> > > > 	daddiu	$2,$2,%higher(foo)
> > > > 	dsll	$2,$2,16
> > > > 	daddiu	$2,$2,%hi(foo)
> > > > 	dsll	$2,$2,16
> > > > #APP
> > > > 	dla	$2,%lo(foo)($2)
> > > > #NO_APP
> > > 
> > > IMHO this is broken in the compiler. It should either only provide the
> > > sympol for %1, [...]
> > 
> >  This is what gcc 2.95 did and it was inferior -- for each %1 reference, a
> > full address load was performed.  A better alternative (and the only one
> > if I'd use the "R" constraint; 2.95 got it wrong, though) would be
> > finishing the address load sequence before the inline asm and substituting
> > "($2)" for %1.  It would waste an instruction if %1 was used for loads and
> > stores only, though.
> 
> I can't follow you here. As long as gcc is supposed to leave inline asm
> alone it shouldn't attempt to do (parts of) the expansion itself. The
> resulting asm should be something like
> 
> #APP
> 	dla	$2,foo
> #NO_APP
> 
> and leave the interpretation up to the assembler.

 Well, "%lo(foo)($2)" is a correct address of the C variable "foo" here.

> >  I like the current behavior of gcc for being optimal.
> 
> Creating broken code can hardly be called optimal.

 Please justify.  Note e.g. "dla $4,0x100($2)" is currently OK, but you 
consider "dla $4,%lo(foo)($2)" bad.  Why?

> >  Anyway, I think gas should be consistent with its interpretation of 
> > addresses for load/store and for load address instructions, i.e. it should 
> > be possible to split:
> > 
> > <op>	<reg>,<addr>
> > 
> > into:
> > 
> > la	<tmp>,<addr>
> > <op>	<reg>,(<tmp>)
> > 
> > for any valid <addr>.
> 
> This would be broken syntax.
> 
> 	<op>	<reg>,<addr>
> 
> loads an absolute address in a register, while

 Nope, it loads the content pointed to by addr, of which the register part
happens to be $zero.

> 	<op>	<reg>,<addr>(<reg2>)
> 
> loads the _content_ pointed to by reg2, with addr as offset.
> 
> 	<op>	<reg>,(<reg2>)
> 
> merely means an offset of zero, and is invalid for (d)la.

 But "la <reg>,0(<reg2>)" works.

  Maciej

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: macro@ds2.pg.gda.pl, PGP key available        +


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