[fpc-devel] Data alignment feature

Florian Klämpfl florian at freepascal.org
Mon Jan 22 22:07:14 CET 2018

Am 19.01.2018 um 21:08 schrieb J. Gareth Moreton:
> 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.

In r38020 I committed a fix and an example tm128 how these records (m128/m256) can be implemented
properly without any additional suffix. Please give it a try.

More information about the fpc-devel mailing list