m68k structure packing
Jim Wilson
wilson@cygnus.com
Thu Oct 2 20:09:00 GMT 1997
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
More information about the Gcc
mailing list