[Feature Request] Per-type Byte Alignment
Original Reporter info from Mantis: CuriousKit @CuriousKit
-
Reporter name: J. Gareth Moreton
Original Reporter info from Mantis: CuriousKit @CuriousKit
- Reporter name: J. Gareth Moreton
Description:
Outside of global compiler directives, I would like to request a feature where you can tell the compiler that variables of a particular type must be aligned to a particular byte in memory. This is useful because aligning vectors, for example, on 16-byte boundaries allow for a significant speed boost and are actually necessary for some SSE and AVX instructions. For example:
type
AlignedDouble = Double align 16;
TVector4f = packed record
X: Single;
Y: Single;
Z: Single;
W: Single;
end align 16;
TVector4fArray = array of TVector4f align 32; { Stricter boundary, so should be okay }
Steps to reproduce:
N/A
Additional information:
Also listed here: http://wiki.lazarus.freepascal.org/Feature_Ideas#Per-type_Byte_Alignment - also contains some nuances and questions with syntax and the like.
Apparently Delphi has a similar feature, but it is not well-documented.
Mantis conversion info:
- Mantis ID: 32780
- OS: Windows 7 (64-bit)
- OS Build: Enterprise
- Build: x86_64-win64-win32/win64
- Platform: Win32/Win64
- Version: 3.1.1
- Monitored by: » @dliw (d.l.i.w), » @MageSlayer (Denis Golovan), » @CuriousKit (J. Gareth Moreton), » @PascalDragon (Sven Barth)