fpc/tests/webtbs/uw15582.pp
Jonas Maebe a5cb157091 * enable specifying the alignment mismatch of the frame/stack pointer
relative to the normal stack alignment of the target (e.g., when using
    ebp as framepointer, all addresses are offset 8 to the stack pointer) in
    the temp generator. This enables allocating temps/locals with the correct
    alignment as long as the required alignment is not bigger than the
    guaranteed stack pointer alignment (fixes mantis #15582 on systems where
    the stack pointer is at least aligned to 16 bytes; e.g., not yet on
    i386-platforms other than darwin)

git-svn-id: trunk@22277 -
2012-09-02 14:32:05 +00:00

73 lines
1.3 KiB
ObjectPascal

unit uw15582;
{$MODE OBJFPC}{$H+}
{$codealign varmin=16}
{$codealign localmin=16}
interface
var
n_checks : integer = 0;
n_failed : integer = 0;
procedure check(const v : string;p : pointer);
procedure l_unit(const pfx : string);
procedure l_unit_nostackframe;
implementation
var g1,g2,g3 : byte;
g4 : integer;
g5 : byte;
g6 : array[0..39] of double;
procedure check(const v : string;p : pointer);
begin
inc(n_checks);
if (ptruint(p) and ptruint(-16)) <> ptruint(p) then begin
writeln('Wrong aligned: "',v,'" : ',hexstr(p));
inc(n_failed);
end;
end;
procedure l_unit(const pfx : string);
var l1,l2,l3 : byte;
l4 : integer;
l5 : byte;
l6 : array[0..39] of double;
begin
check(pfx+'l_unit1',@l1);
check(pfx+'l_unit2',@l2);
check(pfx+'l_unit3',@l3);
check(pfx+'l_unit4',@l4);
check(pfx+'l_unit5',@l5);
check(pfx+'l_unit6',@l6);
end;
procedure l_unit_nostackframe;
var
b1, b2: byte;
begin
inc(n_checks);
if (ptruint(@b1) and ptruint(15)) <> 0 then
inc(n_failed);
inc(n_checks);
if (ptruint(@b2) and ptruint(15)) <> 0 then
inc(n_failed);
end;
initialization
check('g_unit1',@g1);
check('g_unit2',@g2);
check('g_unit3',@g3);
check('g_unit4',@g4);
check('g_unit5',@g5);
check('g_unit6',@g6);
l_unit('ca_unit.initialization ');
end.