Path: utzoo!utgpu!water!watmath!clyde!bellcore!decvax!ucbvax!agate!ig!uwmcsd1!bbn!husc6!linus!philabs!pwa-b!mmintl!franka From: franka@mmintl.UUCP (Frank Adams) Newsgroups: comp.arch Subject: Re: RISC data alignment Message-ID: <2710@mmintl.UUCP> Date: 9 Feb 88 14:34:51 GMT References: <2635@calmasd.GE.COM> <28200092@ccvaxa> Reply-To: franka@mmintl.UUCP (Frank Adams) Organization: Multimate International, E. Hartford, CT. Lines: 19 In article <28200092@ccvaxa> aglew@ccvaxa.UUCP (Andy "Krazy" Glew) writes: >I have often wanted an optimizing compiler that could take >struct { long a; int b; long c; char d; } >which is usually mapped into bytes as AAAABBxxCCCCDxxx >(on a machine where misaligned accesses are penalized) >and make it into AAAACCCCBBDx. How about AAAABBDxCCCC? This is what results if you follow the rule "put each component into the first suitable place for it". It has the important property that structures with the first few components identically defined will have those components in the same place. This is important -- the C++ translator relies on it, for example. Code that includes a size 1 (or size 0) array at the end of a structure to represent a variable-sized array may still be broken, however. -- Frank Adams ihnp4!philabs!pwa-b!mmintl!franka Ashton-Tate 52 Oakland Ave North E. Hartford, CT 06108