avr-gcc-list
[Top][All Lists]
Advanced

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

AW: [avr-gcc-list] Union as parameter


From: Haase Bjoern (PT-BEU/EMT) *
Subject: AW: [avr-gcc-list] Union as parameter
Date: Wed, 24 Aug 2005 13:10:51 +0200

If the structure fits *exactly* into 2 byte, 4 byte or 8 byte, gcc internally 
is smart enough to allocate an object of type "int" HI, "long int" SI or "long 
long int" DI for the structure. Otherwise it allocates an object of mode BLK 
which forces the object to memory, i.e. forces it to the stack frame.

Yours,

Björn

-----Ursprüngliche Nachricht-----
Von: address@hidden [mailto:address@hidden Im Auftrag von Larry Barello
Gesendet: Mittwoch, 24. August 2005 09:19
An: AVR GCC List
Betreff: [avr-gcc-list] Union as parameter

I tried using this typedef, below, as a parameter to a function.  When I do,
it gets stuck onto the stack frame.  The resulting code is a riot since
there is all sorts of set up and teardown, the value gets stuck onto the
stack, the routine called, the variable pulled off the stack into registers
where it is acted upon.

Taking out the bitfield reverts to more normal GCC behavior: the union is
passed in a dword register set. An aside from some shuffling of registers is
pretty decent code.

Gcc 3.4.3 (latest WinAvr).

Is this a known issue?

Typedef union
{
        Uint32_t dword;
        Uint16_t word[2];
        Uint8_t byte[4];
        Struct
        {
                Uint16_t offset:7;
                Uint16_t page:10;
                Uint16_t bank:2;
        } bits;
}
Addr_u;

----
Larry Barello
www.barello.net 




_______________________________________________
AVR-GCC-list mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list







reply via email to

[Prev in Thread] Current Thread [Next in Thread]