[M3devel] Target.Structure_size_boundary?

Jay K jay.krell at cornell.edu
Sun Aug 16 12:12:18 CEST 2015


ok, so this structure_size_boundary isn't entirely bogus.In fact, as is typical, it might have been correct, but itsrelevance has drastically declined as the targets have shifted.Like so much of cm3, it is based closely on gcc.

It appears that

 OpenBSD/68k rounds struct sizes up to a multiple of 2. Other 68k targets do not. Perhaps historical 68k targets did -- perhaps that is a lot of what cm3 was handling. ARM sometimes rounds up to a multiple of 4, but sometimes not, depending on exact platform. sh used to? and still optionally rounds up to a multiple of 4, but I think defaults to not?

The only non-8 case we had in cm3 was for HPPA and that was wrong seeming.

Getting this value wrong should only lead to a lack of C interop on unusual records.i.e. if you have an array of records with an odd size, the adress of than the firstmight mismatch.It can have an affect in non-array-of-record cases too, if you use BYTESIZE.Or, when the C backend does layout, possibly disagreeing with the frontend.

Maybe I'm naive but this all seems like a mistake.

 sizeof(struct {char a;}) should be 1 for all targets.  sizeof(struct {char a[3];}) should be 3 for all targets. 
but I guess various ABI developers have disagreed through the decadesand we are kinda somewhat stuck with it.

There is a gcc command line switch, at least for ARM, to vary the rounding.

 - Jay


From: jay.krell at cornell.edu
To: m3devel at elegosoft.com
Subject: Target.Structure_size_boundary?
Date: Fri, 14 Aug 2015 20:43:18 +0000




air:src jay$ grep -i boundary *
Target.i3:    boundary (i.e. (size + align - 1) DIV align * align).Target.i3:  Structure_size_boundary: CARDINAL;Target.i3-old:    boundary (i.e. (size + align - 1) DIV align * align).Target.i3-old:  Structure_size_boundary: CARDINAL;Target.m3:    Structure_size_boundary   := 8;Target.m3:        Structure_size_boundary := 16;Target.m3-old:    Structure_size_boundary   := 8;Target.m3-old:                 Structure_size_boundary   := 16;Target.m3-old:                 Structure_size_boundary   := 32;Target.m3-old:                 Structure_size_boundary   := 16;Target.m3-old:                 Structure_size_boundary   := 16;Target.m3-old:                 Structure_size_boundary   := 16;Target.m3-old:                 Structure_size_boundary   := 16;Target.m3-old:                 Structure_size_boundary   := 32;Target.m3-old:                 Structure_size_boundary   := 16;Target.m3-old:                 Structure_size_boundary   := 32;Target.m3-old:                 Structure_size_boundary   := 16;TargetT.i3:  structure_size_boundary: CARDINAL;

Surely we can just consider this 8 and remove all of it uses?
Are all those old >8 uses even correct?
 sizeof(struct {char a;}) really isn't always 1?  sizeof(struct {char a[3];}) really isn't always 3? 

Actually we can verify this easily enough with a cross gcc w/o cross driver/linker/assembler/headers/libraries.I'll do that later.

Plus, we can have the C code statically verify struct sizes agreebetween front end backend, as long as they get encoded anywhere by frontend.

You know, I want to limit Target.m3 to endian and word size. Even those I wish I could remove.

Thanks, - Jay 		 	   		   		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20150816/bb04e2bf/attachment-0002.html>


More information about the M3devel mailing list