[fpc-devel] Data alignment feature
J. Gareth Moreton
gareth at moreton-family.com
Fri Jan 19 21:08:07 CET 2018
Hi everyone,
So unless anyone has any objections, I would like to start experimenting to implement a feature that allows
for per-type data alignment. The main purpose for this is to better support x86-64 SIMD extensions, where
aligned data is far faster to process. While there is a compiler directive that enforces byte alignment,
this risks causing conflicts with third party units and is a bit much of a demand for a programmer wishing
to use an SIMD-tuned unit, say.
Bug/feature details: https://bugs.freepascal.org/view.php?id=32780
The format would be as follows:
type TypeName = TypeInfo [align ByteAmount];
The syntax for declaring a type is exactly the same, with a new optional "align" keyword before the
terminating semicolon. "ByteAmount" has to be a power of 2, which I will probably limit to 128 currently,
just so it doesn't cause ridiculous or malicious memory usage. There will probably have to be a minimum
alignment as well, although this will probably just be automatically enforced (e.g. Single is always aligned
on a 4-byte boundary minimum).
The intention here is that this feature will be a stepping stone for properly supporting vectorisation,
implementing some form of the "M128" and "M256" types, and the "vectorcall" compiler directive for Windows.
Gareth aka. Kit
More information about the fpc-devel
mailing list