On Tue, 2012-11-20 at 09:28 +0100, Jonas Bonn wrote: > 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
I agree with both of these. Most implementations choose to pass "this" as the first parameter, and the one compiler I know which did not was notorious for being incompatible with everything else! > 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? A good point. A quick look shows Epiphany, ARC and ARM also use the argument registers as result registers. Do we want to change our ABI this much? > > 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). I agree - anything I suggest is a proposal to be written into the ABI. When we were working on the compiler, one of the problems was discovering how much was missing from the ABI and defined de facto in the compiler. At the time we couldn't change the architecture manual. Now, thanks to Julius and others, we can. Best wishes, Jeremy -- Tel: +44 (1590) 610184 Cell: +44 (7970) 676050 SkypeID: jeremybennett Email: [email protected] Web: www.embecosm.com _______________________________________________ OpenRISC mailing list [email protected] http://lists.openrisc.net/listinfo/openrisc
