+ ttgobj.gethltemptyped() routine for allocating managed types with high level

code generator support
  * refactored some internal temp generator code

git-svn-id: branches/jvmbackend@18681 -
This commit is contained in:
Jonas Maebe 2011-08-20 08:24:07 +00:00
parent 085d0efead
commit cef61300ff
3 changed files with 24 additions and 12 deletions

View File

@ -46,6 +46,7 @@ unit tgcpu;
procedure setfirsttemp(l : longint); override;
procedure getlocal(list: TAsmList; size: longint; alignment: shortint; def: tdef; var ref: treference); override;
procedure gethltemp(list: TAsmList; def: tdef; forcesize: aint; temptype: ttemptype; out ref: treference); override;
procedure gethltemptyped(list: TAsmList; def: tdef; temptype: ttemptype; out ref: treference); override;
end;
implementation
@ -234,6 +235,11 @@ unit tgcpu;
inherited;
end;
procedure ttgjvm.gethltemptyped(list: TAsmList; def: tdef; temptype: ttemptype; out ref: treference);
begin
gethltemp(list,def,def.size,temptype,ref);
end;
begin
tgobjclass:=ttgjvm;

View File

@ -403,7 +403,7 @@ interface
if is_managed_type(tempinfo^.typedef) then
begin
location_reset_ref(tempinfo^.location,LOC_REFERENCE,def_cgsize(tempinfo^.typedef),0);
tg.GetTempTyped(current_asmdata.CurrAsmList,tempinfo^.typedef,tempinfo^.temptype,tempinfo^.location.reference);
tg.gethltemptyped(current_asmdata.CurrAsmList,tempinfo^.typedef,tempinfo^.temptype,tempinfo^.location.reference);
{ the temp could have been used previously either because the memory location was reused or
because we're in a loop }
hlcg.g_finalize(current_asmdata.CurrAsmList,tempinfo^.typedef,tempinfo^.location.reference);

View File

@ -61,6 +61,7 @@ unit tgobj;
tempfreelist : ptemprecord;
function alloctemp(list: TAsmList; size,alignment : longint; temptype : ttemptype; def:tdef) : longint; virtual;
procedure freetemp(list: TAsmList; pos:longint;temptypes:ttemptypeset);
procedure gettempinternal(list: TAsmList; size, alignment : longint;temptype:ttemptype;def: tdef;out ref : treference);
public
{ contains all temps }
templist : ptemprecord;
@ -87,6 +88,7 @@ unit tgobj;
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); virtual;
procedure gethltemptyped(list: TAsmList; def: tdef; temptype: ttemptype; out ref: treference); virtual;
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);
@ -508,7 +510,20 @@ implementation
end;
procedure ttgobj.gethltemptyped(list: TAsmList; def: tdef; temptype: ttemptype; out ref: treference);
begin
gettemptyped(list,def,temptype,ref);
end;
procedure ttgobj.gettemp(list: TAsmList; size, alignment : longint;temptype:ttemptype;out ref : treference);
begin
gettempinternal(list,size,alignment,temptype,nil,ref);
end;
procedure ttgobj.gettempinternal(list: TAsmList; size, alignment : longint;temptype:ttemptype;def: tdef;out ref : treference);
var
varalign : shortint;
begin
@ -517,23 +532,14 @@ implementation
on cgobj (PFV) }
fillchar(ref,sizeof(ref),0);
ref.base:=current_procinfo.framepointer;
ref.offset:=alloctemp(list,size,varalign,temptype,nil);
ref.offset:=alloctemp(list,size,varalign,temptype,def);
ref.alignment:=varalign;
end;
procedure ttgobj.gettemptyped(list: TAsmList; def:tdef;temptype:ttemptype;out ref : treference);
var
varalign : shortint;
begin
varalign:=def.alignment;
varalign:=used_align(varalign,current_settings.alignment.localalignmin,current_settings.alignment.localalignmax);
{ can't use reference_reset_base, because that will let tgobj depend
on cgobj (PFV) }
fillchar(ref,sizeof(ref),0);
ref.base:=current_procinfo.framepointer;
ref.offset:=alloctemp(list,def.size,varalign,temptype,def);
ref.alignment:=varalign;
gettempinternal(list,def.size,def.alignment,temptype,def,ref);
end;