[M3devel] Target.Allow_packed_byte_aligned
Jay K
jay.krell at cornell.edu
Tue Sep 22 06:55:50 CEST 2015
There is a proposal in here..here is a variation of it..
Allow packing of records tightly on all targets.
All targets get the same layout (modulo word size), the same things can compile successfully.
Remove the caveat here that certain code will only compile for certain targets.
If Allow_packed_byte_aligned is false, and there is an unaligned read/write, there are a few choices.
m3front could transform into multiple inlined read/writes byte-wise taking the value apart of putting it back together.
Or m3front could issue function calls. The C implementation could be #ifdefed such
that amd64/x86 just do the read/write, albeit still with a function call.
C backend could set allow_packed_byte_aligned the same always.
In that case, the functions would be output into the file and inlined or macroed.
A warning might be issued about the lack of atomicity.
Heck, let's invent a feature...a pragma could be allowed on integral/floating point
values as to endianness and compiler could output the byte swaps for you.
The endianness could actually be some sort of runtime expression.
That's how some formats work -- they get written native, with an indicator as to which that is,
and swapped if necessary upon reads, and maybe swapped back for writes.
You know -- if you really want a powerful system for efficient binary persistance..
Or just leave it alone.
?
- Jay
From: jay.krell at cornell.edu
To: hendrik at topoi.pooq.com; m3devel at elegosoft.com
Date: Tue, 22 Sep 2015 00:15:05 +0000
Subject: Re: [M3devel] Target.Allow_packed_byte_aligned
Right -- I had what I think is the same idea -- I can build the n bootstrap archives, compare them, and verify where they are the same and where they are different, and then end up with fewer archives, maybe 6, maybe 2.
For that matter, I guess I should get this stuff to work in the C backend --- providing the #pragma pack(1) or whatever gcc/clang equivalent.
- Jay
> Date: Mon, 21 Sep 2015 16:25:49 -0400
> From: hendrik at topoi.pooq.com
> To: m3devel at elegosoft.com
> Subject: Re: [M3devel] Target.Allow_packed_byte_aligned
>
> On Mon, Sep 21, 2015 at 04:37:18PM +0000, Jay K wrote:
> > Also -- if anyone has a proposal that would allow Allow_packed_byte_aligned to always be true, that would also fit my agenda. I don't care true or false, I just want it the same across all targets.
> > In particular, on IA64/NT you can say stuff like: #pragma pack(1) struct { char a; __unaligned int b; } A; A.b
> > and you do get a 5 byte struct and b is at offset 1.The generated code will read b with multiple reads of bytes or shorts and reassemble the 4 byte integer.
> > Perhaps m3front can behave similarly?For all targets?
> > But for now I'll put it back and later when I generate bootstraps I'll see if they are equal, i.e. contain no packed types.
> > - Jay
>
> The fancy packing should remain in the language, for backward
> compatibility if nothing else. modula 3 is, after all, a systems
> language.
>
> But is likely no need to worry it in the bootstrap.
>
> If the bootstrap doesn't use it, it will still work portably as a
> bootstrap, no matter how machine-dependent fancy packing happens to be.
>
> -- hendrik
> _______________________________________________
> M3devel mailing list
> M3devel at elegosoft.com
> https://mail.elegosoft.com/cgi-bin/mailman/listinfo/m3devel
_______________________________________________
M3devel mailing list
M3devel at elegosoft.com
https://mail.elegosoft.com/cgi-bin/mailman/listinfo/m3devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20150922/70c7737d/attachment-0002.html>
More information about the M3devel
mailing list