+ pseudo procedure aligned: tells the compiler to assume that the given parameter is naturally aligned, counterpart of unaligned

git-svn-id: trunk@23310 -
This commit is contained in:
florian 2013-01-04 19:13:24 +00:00
parent fce9e953b4
commit b43b4bb455
9 changed files with 28 additions and 3 deletions

1
.gitattributes vendored
View File

@ -10505,6 +10505,7 @@ tests/test/taes1.pp svneol=native#text/plain
tests/test/talign.pp svneol=native#text/plain tests/test/talign.pp svneol=native#text/plain
tests/test/talign1.pp svneol=native#text/plain tests/test/talign1.pp svneol=native#text/plain
tests/test/talign2.pp svneol=native#text/plain tests/test/talign2.pp svneol=native#text/plain
tests/test/taligned1.pp svneol=native#text/pascal
tests/test/targ1a.pp svneol=native#text/plain tests/test/targ1a.pp svneol=native#text/plain
tests/test/targ1b.pp svneol=native#text/plain tests/test/targ1b.pp svneol=native#text/plain
tests/test/tarray1.pp svneol=native#text/plain tests/test/tarray1.pp svneol=native#text/plain

View File

@ -87,6 +87,7 @@ const
in_box_x = 77; { managed platforms: wrap in class instance } in_box_x = 77; { managed platforms: wrap in class instance }
in_unbox_x_y = 78; { manage platforms: extract from class instance } in_unbox_x_y = 78; { manage platforms: extract from class instance }
in_popcnt_x = 79; in_popcnt_x = 79;
in_aligned_x = 80;
{ Internal constant functions } { Internal constant functions }
in_const_sqr = 100; in_const_sqr = 100;

View File

@ -1761,7 +1761,7 @@ implementation
begin begin
if ((valid_const in opts) and if ((valid_const in opts) and
(tinlinenode(hp).inlinenumber in [in_typeof_x])) or (tinlinenode(hp).inlinenumber in [in_typeof_x])) or
(tinlinenode(hp).inlinenumber in [in_unaligned_x]) then (tinlinenode(hp).inlinenumber in [in_unaligned_x,in_aligned_x]) then
result:=true result:=true
else else
if report_errors then if report_errors then

View File

@ -144,6 +144,13 @@ implementation
if location.loc in [LOC_CREFERENCE,LOC_REFERENCE] then if location.loc in [LOC_CREFERENCE,LOC_REFERENCE] then
location.reference.alignment:=1; location.reference.alignment:=1;
end; end;
in_aligned_x:
begin
secondpass(tcallparanode(left).left);
location:=tcallparanode(left).left.location;
if location.loc in [LOC_CREFERENCE,LOC_REFERENCE] then
location.reference.alignment:=0;
end;
{$ifdef SUPPORT_MMX} {$ifdef SUPPORT_MMX}
in_mmx_pcmpeqb..in_mmx_pcmpgtw: in_mmx_pcmpeqb..in_mmx_pcmpgtw:
begin begin

View File

@ -2998,6 +2998,7 @@ implementation
begin begin
end; end;
{$endif SUPPORT_MMX} {$endif SUPPORT_MMX}
in_aligned_x,
in_unaligned_x: in_unaligned_x:
begin begin
resultdef:=left.resultdef; resultdef:=left.resultdef;
@ -3472,11 +3473,11 @@ implementation
begin begin
expectloc:=LOC_REGISTER; expectloc:=LOC_REGISTER;
end; end;
in_prefetch_var: in_prefetch_var:
begin begin
expectloc:=LOC_VOID; expectloc:=LOC_VOID;
end; end;
in_aligned_x,
in_unaligned_x: in_unaligned_x:
begin begin
expectloc:=tcallparanode(left).left.expectloc; expectloc:=tcallparanode(left).left.expectloc;

View File

@ -683,6 +683,7 @@ implementation
in_sqr_real, in_sqr_real,
in_sqrt_real, in_sqrt_real,
in_ln_real, in_ln_real,
in_aligned_x,
in_unaligned_x, in_unaligned_x,
in_prefetch_var: in_prefetch_var:
begin begin

View File

@ -517,6 +517,7 @@ implementation
end; end;
end; end;
in_aligned_x,
in_unaligned_x : in_unaligned_x :
begin begin
err:=false; err:=false;
@ -524,7 +525,7 @@ implementation
in_args:=true; in_args:=true;
p1:=comp_expr(true,false); p1:=comp_expr(true,false);
p2:=ccallparanode.create(p1,nil); p2:=ccallparanode.create(p1,nil);
p2:=geninlinenode(in_unaligned_x,false,p2); p2:=geninlinenode(l,false,p2);
consume(_RKLAMMER); consume(_RKLAMMER);
statement_syssym:=p2; statement_syssym:=p2;
end; end;

View File

@ -100,6 +100,7 @@ implementation
systemunit.insert(tsyssym.create('Get_Frame',in_get_frame)); systemunit.insert(tsyssym.create('Get_Frame',in_get_frame));
{$endif defined(x86) or defined(arm) or defined(jvm)} {$endif defined(x86) or defined(arm) or defined(jvm)}
systemunit.insert(tsyssym.create('Unaligned',in_unaligned_x)); systemunit.insert(tsyssym.create('Unaligned',in_unaligned_x));
systemunit.insert(tsyssym.create('Aligned',in_aligned_x));
systemunit.insert(tsyssym.create('ObjCSelector',in_objc_selector_x)); { objc only } systemunit.insert(tsyssym.create('ObjCSelector',in_objc_selector_x)); { objc only }
systemunit.insert(tsyssym.create('ObjCEncode',in_objc_encode_x)); { objc only } systemunit.insert(tsyssym.create('ObjCEncode',in_objc_encode_x)); { objc only }
systemunit.insert(tsyssym.create('Default',in_default_x)); systemunit.insert(tsyssym.create('Default',in_default_x));

12
tests/test/taligned1.pp Normal file
View File

@ -0,0 +1,12 @@
var
r1 : record
dummy : byte;
a,b : longint;
end;
begin
r1.a:=aligned(r1.b)*2;
aligned(r1.a):=r1.b*2;
r1.a:=r1.b;
r1.a:=r1.b div 10;
end.