+ introduced the tcgvecnode.get_address_type virtual method and use its result,

instead of voidpointertype in tcgvecnode.update_reference_reg_mul and
  .update_reference_reg_packed

git-svn-id: branches/wasm@48160 -
This commit is contained in:
nickysn 2021-01-15 15:29:58 +00:00
parent 2ee61e003d
commit 34d3d39dbe

View File

@ -61,6 +61,7 @@ interface
procedure rangecheck_array;
procedure rangecheck_string;
protected
function get_address_type: tdef;virtual;
{# This routine is used to calculate the address of the reference.
On entry reg contains the index in the array,
and l contains the size of each element in the array.
@ -624,6 +625,12 @@ implementation
end;
function tcgvecnode.get_address_type: tdef;
begin
result:=cpointerdef.getreusable(resultdef);
end;
{ this routine must, like any other routine, not change the contents }
{ of base/index registers of references, as these may be regvars. }
{ The register allocator can coalesce one LOC_REGISTER being moved }
@ -638,8 +645,8 @@ implementation
begin
if l<>1 then
begin
hreg:=hlcg.getaddressregister(current_asmdata.CurrAsmList,voidpointertype);
hlcg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_IMUL,voidpointertype,l,maybe_const_reg,hreg);
hreg:=hlcg.getaddressregister(current_asmdata.CurrAsmList,get_address_type);
hlcg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_IMUL,get_address_type,l,maybe_const_reg,hreg);
maybe_const_reg:=hreg;
end;
if location.reference.base=NR_NO then
@ -648,8 +655,8 @@ implementation
location.reference.index:=maybe_const_reg
else
begin
hreg:=hlcg.getaddressregister(current_asmdata.CurrAsmList,voidpointertype);
hlcg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,resultdef,voidpointertype,location.reference,hreg);
hreg:=hlcg.getaddressregister(current_asmdata.CurrAsmList,get_address_type);
hlcg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,resultdef,get_address_type,location.reference,hreg);
reference_reset_base(location.reference,hreg,0,location.reference.temppos,location.reference.alignment,location.reference.volatility);
{ insert new index register }
location.reference.index:=maybe_const_reg;
@ -686,24 +693,24 @@ implementation
if (l > 8*sizeof(aint)) then
internalerror(200608051);
sref.ref := location.reference;
hreg := hlcg.getaddressregister(current_asmdata.CurrAsmList,voidpointertype);
hlcg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_SUB,voidpointertype,tarraydef(left.resultdef).lowrange,maybe_const_reg,hreg);
hlcg.a_op_const_reg(current_asmdata.CurrAsmList,OP_IMUL,voidpointertype,l,hreg);
hreg := hlcg.getaddressregister(current_asmdata.CurrAsmList,get_address_type);
hlcg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_SUB,get_address_type,tarraydef(left.resultdef).lowrange,maybe_const_reg,hreg);
hlcg.a_op_const_reg(current_asmdata.CurrAsmList,OP_IMUL,get_address_type,l,hreg);
{ keep alignment for index }
sref.ref.alignment := left.resultdef.alignment;
if not ispowerof2(packedbitsloadsize(l),temp) then
internalerror(2006081201);
alignpower:=temp;
offsetreg := hlcg.getaddressregister(current_asmdata.CurrAsmList,voidpointertype);
hlcg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_SHR,voidpointertype,3+alignpower,hreg,offsetreg);
hlcg.a_op_const_reg(current_asmdata.CurrAsmList,OP_SHL,voidpointertype,alignpower,offsetreg);
offsetreg := hlcg.getaddressregister(current_asmdata.CurrAsmList,get_address_type);
hlcg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_SHR,get_address_type,3+alignpower,hreg,offsetreg);
hlcg.a_op_const_reg(current_asmdata.CurrAsmList,OP_SHL,get_address_type,alignpower,offsetreg);
if (sref.ref.base = NR_NO) then
sref.ref.base := offsetreg
else if (sref.ref.index = NR_NO) then
sref.ref.index := offsetreg
else
begin
hlcg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_ADD,voidpointertype,sref.ref.base,offsetreg);
hlcg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_ADD,get_address_type,sref.ref.base,offsetreg);
sref.ref.base := offsetreg;
end;