This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
PowerPC implicit pass-by-reference for structs?
- From: "Wealand, Barry" <barry dot wealand at lmco dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Wed, 23 Jan 2008 10:14:36 -0800
- Subject: PowerPC implicit pass-by-reference for structs?
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