mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 12:19:18 +02:00
* fixed indexing dynamic arrays and strings with a constant index (the index
was ignored in this case) git-svn-id: trunk@32741 -
This commit is contained in:
parent
31bd38c45b
commit
fad7c8f151
@ -106,6 +106,7 @@ implementation
|
|||||||
locref: preference;
|
locref: preference;
|
||||||
hreg: tregister;
|
hreg: tregister;
|
||||||
arrptrelementdef: tdef;
|
arrptrelementdef: tdef;
|
||||||
|
indirect: boolean;
|
||||||
|
|
||||||
procedure getarrelementptrdef;
|
procedure getarrelementptrdef;
|
||||||
begin
|
begin
|
||||||
@ -137,17 +138,24 @@ implementation
|
|||||||
locref:=nil;
|
locref:=nil;
|
||||||
{ avoid uninitialised warning }
|
{ avoid uninitialised warning }
|
||||||
arrptrelementdef:=nil;
|
arrptrelementdef:=nil;
|
||||||
if not arraytopointerconverted and
|
indirect:=
|
||||||
not is_dynamicstring(left.resultdef) and
|
not is_dynamicstring(left.resultdef) and
|
||||||
not is_dynamic_array(left.resultdef) then
|
not is_dynamic_array(left.resultdef);
|
||||||
|
if (not arraytopointerconverted and
|
||||||
|
indirect) or
|
||||||
|
(constarrayoffset<>0) then
|
||||||
begin
|
begin
|
||||||
{ the result is currently a pointer to left.resultdef (the array type)
|
{ the result is currently a pointer to left.resultdef (the array type)
|
||||||
-> convert it into a pointer to an element inside this array }
|
-> convert it into a pointer to an element inside this array }
|
||||||
getarrelementptrdef;
|
getarrelementptrdef;
|
||||||
hreg:=hlcg.getaddressregister(current_asmdata.CurrAsmList,arrptrelementdef);
|
hreg:=hlcg.getaddressregister(current_asmdata.CurrAsmList,arrptrelementdef);
|
||||||
locref^:=thlcgllvm(hlcg).make_simple_ref(current_asmdata.CurrAsmList,location.reference,left.resultdef);
|
locref^:=thlcgllvm(hlcg).make_simple_ref(current_asmdata.CurrAsmList,location.reference,left.resultdef);
|
||||||
current_asmdata.CurrAsmList.Concat(taillvm.getelementptr_reg_size_ref_size_const(hreg,cpointerdef.getreusable(left.resultdef),
|
if indirect then
|
||||||
locref^,ptruinttype,constarrayoffset,true));
|
current_asmdata.CurrAsmList.Concat(taillvm.getelementptr_reg_size_ref_size_const(hreg,cpointerdef.getreusable(left.resultdef),
|
||||||
|
locref^,ptruinttype,constarrayoffset,true))
|
||||||
|
else
|
||||||
|
current_asmdata.CurrAsmList.Concat(taillvm.getelementptr_reg_size_ref_size_const(hreg,left.resultdef,
|
||||||
|
locref^,ptruinttype,constarrayoffset,false));
|
||||||
reference_reset_base(locref^,hreg,0,locref^.alignment);
|
reference_reset_base(locref^,hreg,0,locref^.alignment);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -175,6 +183,7 @@ implementation
|
|||||||
hreg:=hlcg.getintregister(current_asmdata.CurrAsmList,ptruinttype);
|
hreg:=hlcg.getintregister(current_asmdata.CurrAsmList,ptruinttype);
|
||||||
hlcg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_ADD,ptruinttype,constarrayoffset,maybe_const_reg,hreg);
|
hlcg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_ADD,ptruinttype,constarrayoffset,maybe_const_reg,hreg);
|
||||||
maybe_const_reg:=hreg;
|
maybe_const_reg:=hreg;
|
||||||
|
constarrayoffset:=0;
|
||||||
end;
|
end;
|
||||||
hreg:=hlcg.getaddressregister(current_asmdata.CurrAsmList,cpointerdef.getreusable(resultdef));
|
hreg:=hlcg.getaddressregister(current_asmdata.CurrAsmList,cpointerdef.getreusable(resultdef));
|
||||||
location.reference:=thlcgllvm(hlcg).make_simple_ref(current_asmdata.CurrAsmList,location.reference,left.resultdef);
|
location.reference:=thlcgllvm(hlcg).make_simple_ref(current_asmdata.CurrAsmList,location.reference,left.resultdef);
|
||||||
@ -226,6 +235,7 @@ implementation
|
|||||||
sref.ref:=location.reference;
|
sref.ref:=location.reference;
|
||||||
hreg:=hlcg.getintregister(current_asmdata.CurrAsmList,ptruinttype);
|
hreg:=hlcg.getintregister(current_asmdata.CurrAsmList,ptruinttype);
|
||||||
hlcg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_SUB,ptruinttype,tarraydef(left.resultdef).lowrange-constarrayoffset,maybe_const_reg,hreg);
|
hlcg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_SUB,ptruinttype,tarraydef(left.resultdef).lowrange-constarrayoffset,maybe_const_reg,hreg);
|
||||||
|
constarrayoffset:=0;
|
||||||
|
|
||||||
{ keep alignment for index }
|
{ keep alignment for index }
|
||||||
sref.ref.alignment:=left.resultdef.alignment;
|
sref.ref.alignment:=left.resultdef.alignment;
|
||||||
|
Loading…
Reference in New Issue
Block a user