+ gethltemp() to allocate a temp specifying full type information even

for regular temps. This is required for targets that need special
    handling of the temps depending on the type
  * converted most gettemp() calls to gethltemp() calls

git-svn-id: branches/jvmbackend@18376 -
This commit is contained in:
Jonas Maebe 2011-08-20 07:54:04 +00:00
parent 8643ab7905
commit 0e87627218
9 changed files with 43 additions and 27 deletions

View File

@ -595,10 +595,10 @@ implementation
*)
LOC_FPUREGISTER,LOC_CFPUREGISTER:
begin
tg.GetTemp(list,size.size,size.alignment,tt_normal,ref);
tg.gethltemp(list,size,size.size,tt_normal,ref);
a_load_reg_ref(list,size,size,r,ref);
a_loadfpu_ref_cgpara(list,size,ref,cgpara);
tg.Ungettemp(list,ref);
tg.ungettemp(list,ref);
end
else
internalerror(2010120415);
@ -1039,7 +1039,7 @@ implementation
LOC_REGISTER,LOC_CREGISTER:
begin
{ paramfpu_ref does the check_simpe_location check here if necessary }
tg.GetTemp(list,fromsize.size,fromsize.alignment,tt_normal,ref);
tg.gethltemp(list,fromsize,fromsize.size,tt_normal,ref);
a_loadfpu_reg_ref(list,fromsize,fromsize,r,ref);
a_loadfpu_ref_cgpara(list,fromsize,ref,cgpara);
tg.Ungettemp(list,ref);
@ -1676,7 +1676,7 @@ implementation
LOC_FPUREGISTER,
LOC_CFPUREGISTER :
begin
tg.GetTemp(list,TCGSize2Size[l.size],TCGSize2Size[l.size],tt_normal,r);
tg.gethltemp(list,size,size.size,tt_normal,r);
hlcg.a_loadfpu_reg_ref(list,size,size,l.register,r);
location_reset_ref(l,LOC_REFERENCE,l.size,0);
l.reference:=r;
@ -1685,7 +1685,7 @@ implementation
LOC_MMREGISTER,
LOC_CMMREGISTER:
begin
tg.GetTemp(list,TCGSize2Size[l.size],TCGSize2Size[l.size],tt_normal,r);
tg.gethltemp(list,size,size.size,tt_normal,r);
cg.a_loadmm_reg_ref(list,l.size,l.size,l.register,r,mms_movescalar);
location_reset_ref(l,LOC_REFERENCE,l.size,0);
l.reference:=r;
@ -1695,7 +1695,7 @@ implementation
LOC_REGISTER,
LOC_CREGISTER :
begin
tg.GetTemp(list,TCGSize2Size[l.size],TCGSize2Size[l.size],tt_normal,r);
tg.gethltemp(list,size,size.size,tt_normal,r);
hlcg.a_load_loc_ref(list,size,size,l,r);
location_reset_ref(l,LOC_REFERENCE,l.size,0);
l.reference:=r;
@ -1706,7 +1706,7 @@ implementation
LOC_SUBSETREF,
LOC_CSUBSETREF:
begin
tg.GetTemp(list,TCGSize2Size[l.size],TCGSize2Size[l.size],tt_normal,r);
tg.gethltemp(list,size,size.size,tt_normal,r);
cg.a_load_loc_ref(list,l.size,l,r);
location_reset_ref(l,LOC_REFERENCE,l.size,0);
l.reference:=r;

View File

@ -80,7 +80,7 @@ implementation
procedure tjvmcallnode.set_result_location(realresdef: tstoreddef);
begin
location_reset_ref(location,LOC_REFERENCE,def_cgsize(realresdef),1);
tg.gettemp(current_asmdata.CurrAsmList,realresdef.size,1,tt_normal,location.reference);
tg.gethltemp(current_asmdata.CurrAsmList,realresdef,realresdef.size,tt_normal,location.reference);
end;

View File

@ -411,7 +411,7 @@ interface
else
begin
location_reset_ref(tempinfo^.location,LOC_REFERENCE,def_cgsize(tempinfo^.typedef),0);
tg.GetTemp(current_asmdata.CurrAsmList,size,tempinfo^.typedef.alignment,tempinfo^.temptype,tempinfo^.location.reference);
tg.gethltemp(current_asmdata.CurrAsmList,tempinfo^.typedef,size,tempinfo^.temptype,tempinfo^.location.reference);
end;
include(tempinfo^.flags,ti_valid);
if assigned(tempinfo^.tempinitcode) then

View File

@ -317,7 +317,7 @@ implementation
else
begin
location_reset_ref(location,LOC_REFERENCE,def_cgsize(realresdef),0);
tg.GetTemp(current_asmdata.CurrAsmList,retloc.intsize,retloc.Alignment,tt_normal,location.reference);
tg.gethltemp(current_asmdata.CurrAsmList,realresdef,retloc.intsize,tt_normal,location.reference);
end;
end;

View File

@ -364,7 +364,7 @@ interface
case tstringdef(resultdef).stringtype of
st_shortstring :
begin
tg.GetTemp(current_asmdata.CurrAsmList,256,2,tt_normal,location.reference);
tg.gethltemp(current_asmdata.CurrAsmList,cshortstringtype,256,tt_normal,location.reference);
cg.a_load_loc_ref(current_asmdata.CurrAsmList,left.location.size,left.location,
location.reference);
location_freetemp(current_asmdata.CurrAsmList,left.location);
@ -393,7 +393,7 @@ interface
if (left.location.loc in [LOC_CREFERENCE,LOC_REFERENCE]) then
location_force_fpureg(current_asmdata.CurrAsmList,left.location,false);
{ round them down to the proper precision }
tg.gettemp(current_asmdata.currasmlist,resultdef.size,resultdef.alignment,tt_normal,tr);
tg.gethltemp(current_asmdata.currasmlist,resultdef,resultdef.size,tt_normal,tr);
cg.a_loadfpu_reg_ref(current_asmdata.CurrAsmList,left.location.size,location.size,left.location.register,tr);
location_reset_ref(left.location,LOC_REFERENCE,location.size,tr.alignment);
left.location.reference:=tr;
@ -494,7 +494,7 @@ interface
{ assigning a global function to a nested procvar -> create
tmethodpointer record and set the "frame pointer" to nil }
location_reset_ref(location,LOC_REFERENCE,int_cgsize(sizeof(pint)*2),sizeof(pint));
tg.gettemp(current_asmdata.CurrAsmList,resultdef.size,sizeof(pint),tt_normal,location.reference);
tg.gethltemp(current_asmdata.CurrAsmList,resultdef,resultdef.size,tt_normal,location.reference);
tmpreg:=cg.getaddressregister(current_asmdata.CurrAsmList);
cg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,left.location.reference,tmpreg);
cg.a_load_reg_ref(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,tmpreg,location.reference);
@ -513,7 +513,7 @@ interface
var r:Treference;
begin
tg.gettemp(current_asmdata.currasmlist,2*sizeof(puint),sizeof(puint),tt_normal,r);
tg.gethltemp(current_asmdata.currasmlist,methodpointertype,methodpointertype.size,tt_normal,r);
location_reset_ref(location,LOC_REFERENCE,def_cgsize(resultdef),0);
location.reference:=r;
cg.a_load_const_ref(current_asmdata.currasmlist,OS_ADDR,0,r);

View File

@ -460,7 +460,7 @@ implementation
{$else}
internalerror(20020520);
{$endif} {$endif}
tg.GetTemp(current_asmdata.CurrAsmList,2*sizeof(pint),sizeof(pint),tt_normal,location.reference);
tg.gethltemp(current_asmdata.CurrAsmList,methodpointertype,methodpointertype.size,tt_normal,location.reference);
secondpass(left);
{ load class instance/classrefdef address }
@ -810,7 +810,7 @@ implementation
{ convert an extended into a double/single, since sse }
{ doesn't support extended) }
r:=cg.getfpuregister(current_asmdata.CurrAsmList,right.location.size);
tg.gettemp(current_asmdata.CurrAsmList,left.resultdef.size,left.resultdef.alignment,tt_normal,href);
tg.gethltemp(current_asmdata.CurrAsmList,left.resultdef,left.resultdef.size,tt_normal,href);
cg.a_loadfpu_ref_reg(current_asmdata.CurrAsmList,right.location.size,right.location.size,right.location.reference,r);
cg.a_loadfpu_reg_ref(current_asmdata.CurrAsmList,right.location.size,left.location.size,r,href);
if releaseright then
@ -894,7 +894,7 @@ implementation
begin
{ perform size conversion if needed (the mm-code cannot convert an }
{ extended into a double/single, since sse doesn't support extended) }
tg.gettemp(current_asmdata.CurrAsmList,left.resultdef.size,left.resultdef.alignment,tt_normal,href);
tg.gethltemp(current_asmdata.CurrAsmList,left.resultdef, left.resultdef.size,tt_normal,href);
cg.a_loadfpu_reg_ref(current_asmdata.CurrAsmList,right.location.size,left.location.size,right.location.register,href);
location_reset_ref(right.location,LOC_REFERENCE,left.location.size,0);
right.location.reference:=href;
@ -1016,8 +1016,8 @@ implementation
otlabel,
oflabel : tasmlabel;
vtype : longint;
elesize,
elealign : longint;
eledef: tdef;
elesize : longint;
tmpreg : tregister;
vaddr : boolean;
freetemp,
@ -1028,23 +1028,23 @@ implementation
dovariant:=(nf_forcevaria in flags) or is_variant_array(resultdef);
if dovariant then
begin
elesize:=sizeof(pint)+sizeof(pint);
elealign:=sizeof(pint);
eledef:=search_system_type('TVARREC').typedef;
elesize:=eledef.size;
end
else
begin
eledef:=tarraydef(resultdef).elementdef;
elesize:=tarraydef(resultdef).elesize;
elealign:=tarraydef(resultdef).elementdef.alignment;
end;
{ alignment is filled in by tg.gettemp below }
{ alignment is filled in by tg.gethltemp below }
location_reset_ref(location,LOC_CREFERENCE,OS_NO,0);
fillchar(paraloc,sizeof(paraloc),0);
{ Allocate always a temp, also if no elements are required, to
be sure that location is valid (PFV) }
if tarraydef(resultdef).highrange=-1 then
tg.GetTemp(current_asmdata.CurrAsmList,elesize,elealign,tt_normal,location.reference)
tg.gethltemp(current_asmdata.CurrAsmList,eledef,elesize,tt_normal,location.reference)
else
tg.GetTemp(current_asmdata.CurrAsmList,(tarraydef(resultdef).highrange+1)*elesize,resultdef.alignment,tt_normal,location.reference);
tg.gethltemp(current_asmdata.CurrAsmList,eledef,(tarraydef(resultdef).highrange+1)*elesize,tt_normal,location.reference);
href:=location.reference;
{ Process nodes in array constructor }
hp:=self;

View File

@ -90,7 +90,7 @@ begin
if not(tg.istemp(left.location.reference) and
(tg.sizeoftemp(current_asmdata.CurrAsmList,left.location.reference) = 256)) then
begin
tg.Gettemp(current_asmdata.CurrAsmList,256,1,tt_normal,href);
tg.gethltemp(current_asmdata.CurrAsmList,cshortstringtype,256,tt_normal,href);
cg.g_copyshortstring(current_asmdata.CurrAsmList,left.location.reference,href,255);
location_freetemp(current_asmdata.CurrAsmList,left.location);
{ return temp reference }

View File

@ -390,7 +390,10 @@ implementation
duplicatecgparaloc(paraloc,newparaloc)
else
begin
tg.gettemp(list,len,cgpara.alignment,tt_persistent,href);
if assigned(cgpara.def) then
tg.gethltemp(list,cgpara.def,len,tt_persistent,href)
else
tg.gettemp(list,len,cgpara.alignment,tt_persistent,href);
newparaloc^.reference.index:=href.base;
newparaloc^.reference.offset:=href.offset;
end;

View File

@ -80,6 +80,13 @@ unit tgobj;
}
procedure setfirsttemp(l : longint); virtual;
{ version of gettemp that is compatible with hlcg-based targets;
always use in common code, only use gettemp in cgobj and
architecture-specific backends.
the forcesize parameter is so that it can be used for defs that
don't have an inherent size (e.g., array of const) }
procedure gethltemp(list: TAsmList; def: tdef; forcesize: aint; temptype: ttemptype; out ref: treference);
procedure gettemp(list: TAsmList; size, alignment : longint;temptype:ttemptype;out ref : treference);
procedure gettemptyped(list: TAsmList; def:tdef;temptype:ttemptype;out ref : treference);
procedure ungettemp(list: TAsmList; const ref : treference);
@ -495,6 +502,12 @@ implementation
end;
procedure ttgobj.gethltemp(list: TAsmList; def: tdef; forcesize: aint; temptype: ttemptype; out ref: treference);
begin
gettemp(list,forcesize,def.alignment,temptype,ref);
end;
procedure ttgobj.gettemp(list: TAsmList; size, alignment : longint;temptype:ttemptype;out ref : treference);
var
varalign : shortint;