This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: dual result function & ABI (using extra register), e.g. for Go
- From: Paul Brook <paul at codesourcery dot com>
- To: gcc at gcc dot gnu dot org
- Cc: Ian Lance Taylor <iant at google dot com>, Basile Starynkevitch <basile at starynkevitch dot net>
- Date: Mon, 1 Nov 2010 09:50:03 +0000
- Subject: Re: dual result function & ABI (using extra register), e.g. for Go
- References: <20101031195954.5a406af2.basile@starynkevitch.net> <mcrfwvm17sr.fsf@google.com>
> > 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