On Tue, Nov 20, 2012 at 10:48:57AM +0100, Jonas Bonn wrote:
> That said, this discussion isn't even about using r3 for the return
> value... just forget about that because it's not even on the table.
> This discussion is about not copying around a constant (the location
> of the struct).
> 
> The other arch's that we are talking about here effectively (using
> OR regs just for 'comparableness'):
> 
> i)   copy the struct location to r3
> ii)  don't modify r3 during the function execution
> iii) return the struct location in r3
> 

FWIW, MIPS O32 ABI do the pass in $4 and return in $2.
That doesn't of course mean it is justified, I mention it because
you asked for an example of an other ABI that does it.

> ...but they haven't actually copied the value around because it's
> always been in r3.  But in doing so, they end up shifting the
> parameter registers as the first parameter ends up in r4.
> 
> We can achieve the same thing by using r11 in place of r3 as that
> gets us the zero-copy behaviour; plus we gain the elegance of not
> having the parameters shifted up a register position (whatever
> that's worth, but it appeals to me).
> 

We also gain the inelegance of adding a couple of extra lines of code in
the compilers to handle this, although this is perhaps a small prize to pay.

But perhaps this is the reason we have what we have now,
under the assumption gcc 'automatically' puts the pointer in the first
argument register, it has by 'accident' became the defacto ABI
(as many other things).

> With our r3->r11 copy, we:
> i)  introduce at lest one extra copy
> ii) r3 and r11 are both call-clobbered regs and need to be handled
> accordingly
> 

I agree on I), but once you've done the copy, you've "freed up" r3,
so II) isn't valid anymore, right?

> Switching to r11 gains us:
> i)  one less call-clobbered paramter register (the r3 above)
> ii) r11 effectively becomes callee-saved (but the save costs
> nothing, presumably, because this register is heavily used in the
> function filling the struct)
> 
> Anyway, some of the above is tantamount to bikeshedding, so I won't
> belabour this; but if this doesn't break things terribly, then I do
> think there are some subtle gains to be had from using r11.
> 

I think the point is, even if it doesn't break things terribly,
it's bound to break something, and the gains are probably not worth it.

> Thanks for listening! :)

It's a pleasure ;)

Stefan
_______________________________________________
OpenRISC mailing list
[email protected]
http://lists.openrisc.net/listinfo/openrisc

Reply via email to