* PowerPC implicit pass-by-reference for structs?
@ 2008-01-24 13:15 Wealand, Barry
2008-01-24 14:37 ` Ian Lance Taylor
0 siblings, 1 reply; 2+ messages in thread
From: Wealand, Barry @ 2008-01-24 13:15 UTC (permalink / raw)
To: gcc-help
Hello -
I'm experimenting with powerpc-eabi-g++ for both v3.4.4 and v4.1.1 of
GCC. In the past, we've also used mips-elf-g++ for a similar set of
experiments. We define "trivial structs" to introduce new types, and
then use operator overloading to re-define some of the behaviors
associated with these new types.
For example, we might have:
struct new_int {
int value;
};
I observe that if I pass these new types by value into functions, the
compiler treats them as implicit pass-by-reference: instead of a new_int
value being passed in, an address is passed in. So, for example:
static new_int saved;
void store(new_int a)
{
saved = a;
}
If I compile this with powerpc-eabi-g++, code is produced that uses r3
(the first argument register) as an address rather than a value. If I
compile the same code using mips-elf-g++, the code produced treats the
first argument register as a value, not an address.
Is there some combination of command-line switches, perhaps, (or any
other methodology) that would let the PowerPC compiler produce
pass-by-value code?
Thanks!
Barry Wealand
barry.wealand@lmco.com
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: PowerPC implicit pass-by-reference for structs?
2008-01-24 13:15 PowerPC implicit pass-by-reference for structs? Wealand, Barry
@ 2008-01-24 14:37 ` Ian Lance Taylor
0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2008-01-24 14:37 UTC (permalink / raw)
To: Wealand, Barry; +Cc: gcc-help
"Wealand, Barry" <barry.wealand@lmco.com> writes:
> Is there some combination of command-line switches, perhaps, (or any
> other methodology) that would let the PowerPC compiler produce
> pass-by-value code?
No. Sorry. This kind of thing is defined by the processor ABI.
Ian
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-01-24 1:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-24 13:15 PowerPC implicit pass-by-reference for structs? Wealand, Barry
2008-01-24 14:37 ` Ian Lance Taylor
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).