This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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: dual result function & ABI (using extra register), e.g. for Go


> > Does the Go language define a specific ABI convention for returning
> > two values from a function thru registers? If yes, how does GCC
> > implement it? Or is it some future work?
> 
> The Go language does not define an ABI for returning multiple values.
> The gccgo frontend implements it by saying that a function which returns
> multiple values returns a struct with fields whose types are the types
> of the result parameter.
> 
> It's desirable to make it possible to write C functions which return
> multiple values to Go code.  For example, some of the runtime support
> functions work that way.  Having the Go return a struct ensures that it
> is easy to write compatible C code.

So the original question becomes "How are structures returned from a 
function". The answer depends on the ABI.

If the ABI for your favourite target doesn't behave as you might like I guess 
we could invent a target attribute to change this on a per-function basis, 
similar to __attribute__((regparm)).  Some third party ARM toolchains already 
have this.

Paul


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