On Tue, 2012-11-20 at 08:11 +0000, Jeremy Bennett wrote:
> On Tue, 2012-11-20 at 08:50 +0100, Jonas Bonn wrote: 
> > 
> > This means we put X in r3 going into the function call and get X in r11
> > coming out... what's the point?

> I'm not sure of the rationale, but I observe that all the ABI's I've
> looked at recently pass the address of a struct to be returned in the
> first argument location, which suggests there might be  a reason for it.
> I've asked Joern if there is a reason for this. It might be connected
> with C++ expecting "this" in the first argument register?

Sure, except:
i)  'this' isn't generally passed by value
ii) 'this' is part of the C++ ABI and shouldn't influence C; and
besides, it's an implicit _first_ parameter, anyway

Which ABI's have you been looking at?  How do they handle return
values... do they have a dedicated RV register or do they return the
function result in the same register as the first parameter?

> I have also seen more complex ABI's, which modify this rule for simple
> structs (e.g. if the struct will fit in 32-bits, it is returned in R11
> and if it fits in 64-bits it is returned in R11/R12). You have to be
> sure the size of the struct is always determined, so that the caller
> knows it will be coming back in registers, and there is no need to pass
> an address.

This is a nice optimization, but unfortunately one that needs to be
specified in the ABI instead of the compiler just doing it
transparently.  Do we want this?  I'd say it's too complex for now and
just leave it for ABIv2 (somewhere down the road).

/Jonas

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

Reply via email to