[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] -fpacked-struct compiler option
From: |
Ben L. Titzer |
Subject: |
Re: [avr-gcc-list] -fpacked-struct compiler option |
Date: |
Thu, 6 Jan 2005 13:19:28 -0800 |
On Jan 6, 2005, at 12:58 PM, E. Weddington wrote:
Anton Erasmus wrote:
Hi,
The makefile example that comes with WinAVR uses the -fpacked-struct
compiler option.
The gcc documentation has the following warning on this option:
Warning: the -fpack-struct switch causes GCC to generate code that is
not binary compatible with code generated without that switch.
Additionally, it makes the code suboptimial. Use it to conform to a
non-default application binary interface.
1. We don't have to worry much about "binary compatibility" as AVR
projects are compiled into one image, i.e. no loading of external, 3rd
party binary images.
2. AFAIK it is only suboptimal on targets that have alignments > 1.
So why is this option used in the example makefile. I would have
thought that with the
avr being an 8-bit architecture that structures would automatically
be packed, as there
is no advantage in accessing non-byte alligned data compared to
accessing byte alligned data.
Um, perhaps just being paranoid? Seemed like a good thing to do at the
time? It shouldn't hurt anything to have it in?
Anybody have any other reasoning they'd like to throw around? :-)
Many compilers choose to align on the size of the data type, rather on
the size of the underlying architecture. This is done so that a data
item that might be larger than a word does not span a cache line
boundary, which can hurt performance measurably. So for an 8-byte
quantity like a double precision floating point or long long (on most
architectures), it is aligned on an 8-byte boundary. Therefore on AVR,
a 16-bit integer is likely to be aligned on a 2-byte boundary,
regardless of the fact that the memory is byte addressable and the
registers are 8 bits (and there is no cache). There are many
desktop-class assumptions in GCC. They work fairly well for
desktop-class processors, but really suck when it comes to compiling
for an 8-bit mcu.
-B
Eric
_______________________________________________
avr-gcc-list mailing list
address@hidden
http://www.avr1.org/mailman/listinfo/avr-gcc-list
======================================================
Imagination is more important than knowledge.
-- Albert Einstein