This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: m68k structure packing
- To: Peter Barada <pbarada at wavemark dot com>
- Subject: Re: m68k structure packing
- From: Jim Wilson <wilson at cygnus dot com>
- Date: Thu, 02 Oct 1997 20:09:12 -0700
- cc: mrs at wrs dot com, egcs at cygnus dot com
If you pack the structure on any hardware with strict alignment then
you have to access any non-byte element using ONLY byte accesses since
you can not assume the alignment of the address of the start of the structure.
Unfortunately on the 68k this produces some really slow code. Ex:
The solution is simple. If you care about performance, then don't pack your
structures.
If you want packed structures then they should be sized up to a short, and
anything that is not a char in a packed struct should be aligned on a
short boundary(BIGGEST_ALIGNMENT). But this is what happens on the 68k
anyway.
It makes no sense to disable structure packing because of performance
concerns. People who are packing structures are doing it because they
actually need a particular structure layout. If the programmer requests
packed structures, then the compiler should obey, and the compiler should
make structure packing work the same way for all targets. Mike Stump's
patch is a step in this direction.
Jim