From: Marco Manfredini <mldb@gmx.net>
To: gcc-help@gcc.gnu.org
Subject: Re: Can a C function return TWO integers in registers on MIPS?
Date: Sat, 30 Aug 2008 23:50:00 -0000 [thread overview]
Message-ID: <200808281527.56507.mldb@gmx.net> (raw)
In-Reply-To: <af0faace0808271920w2a9a06ebge37465f1961bfc72@mail.gmail.com>
On Thursday 28 August 2008, Pan ruochen wrote:
> Hi All,
>
> I'm writing code in C language for MIPS execption handler.
> There is a function which returns two integers. For optimizing
> the performance, I want gcc to generate code where these two integers
> are returned in registers v0 & v1, instead of in memory.
> Can gcc do this?
>
> -------------
> Best Regards,
> PRC
> Aug 28, 2008
You can try to return a struct and compile your code with -freg-struct-return.
This should put a struct with two ints into v2&v3. However, it also may
invoke trouble, because MIPS seems to default to memory returns and you might
break binary compatibility:
typedef struct { int x,y; } retval_t;
retval_t fun(int x,int y) { return (retval_t){x,y}; }
You might try the vector extension instead, which enables you to return in
v2&v3 without the above mentioned flag and trouble:
typedef int v2si __attribute__((__vector_size__(2*sizeof(int))));
typedef union {
v2si l;
struct { int x,y; };
} v2si_t;
v2si foo(int x,int y)
{
return (v2si){x,y};
}
int bar()
{
v2si_t r={foo(1,2)};
return r.x+r.y;
}
next prev parent reply other threads:[~2008-08-28 13:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-30 23:14 Pan ruochen
2008-08-30 23:50 ` Marco Manfredini [this message]
2008-08-31 0:57 ` David Daney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200808281527.56507.mldb@gmx.net \
--to=mldb@gmx.net \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).