PowerPC implicit pass-by-reference for structs?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux