mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-07 16:28:22 +02:00
* separate tracking the def of a temp and whether or not it needs to be
finalised (for llvm, we always keep track of the def) git-svn-id: branches/hlcgllvm@28485 -
This commit is contained in:
parent
3b7f43ad77
commit
344acef9b5
@ -4475,7 +4475,8 @@ implementation
|
||||
hp:=tg.templist;
|
||||
while assigned(hp) do
|
||||
begin
|
||||
if assigned(hp^.def) and
|
||||
if hp^.fini and
|
||||
assigned(hp^.def) and
|
||||
is_managed_type(hp^.def) then
|
||||
begin
|
||||
reference_reset_base(href,voidstackpointertype,current_procinfo.framepointer,hp^.pos,voidstackpointertype.size);
|
||||
@ -4522,7 +4523,8 @@ implementation
|
||||
hp:=tg.templist;
|
||||
while assigned(hp) do
|
||||
begin
|
||||
if assigned(hp^.def) and
|
||||
if hp^.fini and
|
||||
assigned(hp^.def) and
|
||||
is_managed_type(hp^.def) then
|
||||
begin
|
||||
include(current_procinfo.flags,pi_needs_implicit_finally);
|
||||
|
@ -37,7 +37,7 @@ unit tgcpu;
|
||||
|
||||
ttgi8086 = class(ttgobj)
|
||||
protected
|
||||
procedure alloctemp(list: TAsmList; size,alignment : longint; temptype : ttemptype; def:tdef; out ref: treference);override;
|
||||
procedure alloctemp(list: TAsmList; size,alignment : longint; temptype : ttemptype; def:tdef; fini: boolean; out ref: treference);override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@ -47,7 +47,7 @@ uses
|
||||
|
||||
{ ttgi8086 }
|
||||
|
||||
procedure ttgi8086.alloctemp(list: TAsmList; size, alignment: longint; temptype: ttemptype; def: tdef; out ref: treference);
|
||||
procedure ttgi8086.alloctemp(list: TAsmList; size, alignment: longint; temptype: ttemptype; def: tdef; fini: boolean; out ref: treference);
|
||||
begin
|
||||
inherited;
|
||||
ref.segment:=NR_SS;
|
||||
|
@ -42,7 +42,7 @@ unit tgcpu;
|
||||
protected
|
||||
procedure getimplicitobjtemp(list: TAsmList; def: tdef; temptype: ttemptype; out ref: treference);
|
||||
function getifspecialtemp(list: TAsmList; def: tdef; forcesize: asizeint; temptype: ttemptype; out ref: treference): boolean;
|
||||
procedure alloctemp(list: TAsmList; size, alignment: longint; temptype: ttemptype; def: tdef; out ref: treference); override;
|
||||
procedure alloctemp(list: TAsmList; size, alignment: longint; temptype: ttemptype; def: tdef; fini: boolean; out ref: treference); override;
|
||||
public
|
||||
procedure setfirsttemp(l : longint); override;
|
||||
procedure getlocal(list: TAsmList; size: longint; alignment: shortint; def: tdef; var ref: treference); override;
|
||||
@ -215,7 +215,7 @@ unit tgcpu;
|
||||
end;
|
||||
|
||||
|
||||
procedure ttgjvm.alloctemp(list: TAsmList; size, alignment: longint; temptype: ttemptype; def: tdef; out ref: treference);
|
||||
procedure ttgjvm.alloctemp(list: TAsmList; size, alignment: longint; temptype: ttemptype; def: tdef; fini: boolean; out ref: treference);
|
||||
begin
|
||||
{ the JVM only supports 1 slot (= 4 bytes in FPC) and 2 slot (= 8 bytes in
|
||||
FPC) temps on the stack. double and int64 are 2 slots, the rest is one slot.
|
||||
@ -227,7 +227,7 @@ unit tgcpu;
|
||||
internalerror(2010121401);
|
||||
{ don't pass on "def", since we don't care if a slot is used again for a
|
||||
different type }
|
||||
inherited alloctemp(list, size shr 2, 1, temptype, nil,ref);
|
||||
inherited alloctemp(list, size shr 2, 1, temptype, nil, false, ref);
|
||||
end;
|
||||
|
||||
|
||||
|
@ -55,7 +55,7 @@ unit tgllvm;
|
||||
|
||||
ttgllvm = class(ttgobj)
|
||||
protected
|
||||
procedure alloctemp(list: TAsmList; size,alignment : longint; temptype : ttemptype; def:tdef; out ref: treference); override;
|
||||
procedure alloctemp(list: TAsmList; size, alignment: longint; temptype: ttemptype; def: tdef; fini: boolean; out ref: treference); override;
|
||||
public
|
||||
alloclist: tasmlist;
|
||||
|
||||
@ -82,7 +82,7 @@ implementation
|
||||
|
||||
{ ttgllvm }
|
||||
|
||||
procedure ttgllvm.alloctemp(list: TAsmList; size, alignment: longint; temptype: ttemptype; def: tdef; out ref: treference);
|
||||
procedure ttgllvm.alloctemp(list: TAsmList; size, alignment: longint; temptype: ttemptype; def: tdef; fini: boolean; out ref: treference);
|
||||
var
|
||||
tl: ptemprecord;
|
||||
oldfileinfo: tfileposinfo;
|
||||
@ -92,6 +92,7 @@ implementation
|
||||
|
||||
tl^.temptype:=temptype;
|
||||
tl^.def:=def;
|
||||
tl^.fini:=fini;
|
||||
tl^.pos:=getsupreg(ref.base);
|
||||
tl^.size:=size;
|
||||
tl^.next:=templist;
|
||||
@ -150,7 +151,7 @@ implementation
|
||||
|
||||
procedure ttgllvm.gethltemp(list: TAsmList; def: tdef; forcesize: asizeint; temptype: ttemptype; out ref: treference);
|
||||
begin
|
||||
alloctemp(list,def.size,def.alignment,temptype,def,ref);
|
||||
alloctemp(list,def.size,def.alignment,temptype,def,false,ref);
|
||||
end;
|
||||
|
||||
|
||||
|
@ -42,6 +42,8 @@ unit tgobj;
|
||||
ptemprecord = ^ttemprecord;
|
||||
ttemprecord = record
|
||||
temptype : ttemptype;
|
||||
{ finalize this temp if it's a managed type }
|
||||
fini : boolean;
|
||||
pos : longint;
|
||||
size : longint;
|
||||
def : tdef;
|
||||
@ -59,9 +61,9 @@ unit tgobj;
|
||||
protected
|
||||
{ contains all free temps using nextfree links }
|
||||
tempfreelist : ptemprecord;
|
||||
procedure alloctemp(list: TAsmList; size,alignment : longint; temptype : ttemptype; def:tdef; out ref: treference); virtual;
|
||||
procedure alloctemp(list: TAsmList; size,alignment : longint; temptype : ttemptype; def:tdef; fini: boolean; out ref: treference); virtual;
|
||||
procedure freetemp(list: TAsmList; pos:longint;temptypes:ttemptypeset);virtual;
|
||||
procedure gettempinternal(list: TAsmList; size, alignment : longint;temptype:ttemptype;def: tdef;out ref : treference);
|
||||
procedure gettempinternal(list: TAsmList; size, alignment : longint;temptype:ttemptype;def: tdef; fini: boolean; out ref : treference);
|
||||
public
|
||||
{ contains all temps }
|
||||
templist : ptemprecord;
|
||||
@ -236,7 +238,7 @@ implementation
|
||||
end;
|
||||
|
||||
|
||||
procedure ttgobj.alloctemp(list: TAsmList; size,alignment : longint; temptype : ttemptype;def : tdef; out ref: treference);
|
||||
procedure ttgobj.alloctemp(list: TAsmList; size,alignment : longint; temptype : ttemptype;def : tdef; fini: boolean; out ref: treference);
|
||||
var
|
||||
tl,htl,
|
||||
bestslot,bestprev,
|
||||
@ -280,12 +282,14 @@ implementation
|
||||
{$endif}
|
||||
{ Check only slots that are
|
||||
- free
|
||||
- share the same type
|
||||
- share the same type if either has to be finalised
|
||||
- contain enough space
|
||||
- has a correct alignment }
|
||||
adjustedpos:=hp^.pos+alignmismatch;
|
||||
if (hp^.temptype=freetype) and
|
||||
(hp^.def=def) and
|
||||
(hp^.fini=fini) and
|
||||
((hp^.def=def) or
|
||||
not fini) and
|
||||
(hp^.size>=size) and
|
||||
((adjustedpos=align(adjustedpos,alignment)) or
|
||||
(adjustedpos+hp^.size-size = align(adjustedpos+hp^.size-size,alignment))) then
|
||||
@ -387,6 +391,7 @@ implementation
|
||||
inc(tl^.pos,tl^.size-size);
|
||||
|
||||
{ Create new block and resize the old block }
|
||||
tl^.fini:=fini;
|
||||
tl^.size:=size;
|
||||
tl^.nextfree:=nil;
|
||||
{ Resize the old block }
|
||||
@ -415,6 +420,7 @@ implementation
|
||||
lasttemp:=tl^.pos+size;
|
||||
end;
|
||||
|
||||
tl^.fini:=fini;
|
||||
tl^.size:=size;
|
||||
tl^.next:=templist;
|
||||
tl^.nextfree:=nil;
|
||||
@ -529,29 +535,29 @@ implementation
|
||||
|
||||
procedure ttgobj.gethltempmanaged(list: TAsmList; def: tdef; temptype: ttemptype; out ref: treference);
|
||||
begin
|
||||
gettemptyped(list,def,temptype,ref);
|
||||
gettempmanaged(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);
|
||||
gettempinternal(list,size,alignment,temptype,nil,false,ref);
|
||||
end;
|
||||
|
||||
|
||||
procedure ttgobj.gettempinternal(list: TAsmList; size, alignment : longint;temptype:ttemptype;def: tdef;out ref : treference);
|
||||
procedure ttgobj.gettempinternal(list: TAsmList; size, alignment : longint;temptype:ttemptype;def: tdef; fini: boolean; out ref : treference);
|
||||
var
|
||||
varalign : shortint;
|
||||
begin
|
||||
varalign:=used_align(alignment,current_settings.alignment.localalignmin,current_settings.alignment.localalignmax);
|
||||
alloctemp(list,size,varalign,temptype,def,ref);
|
||||
alloctemp(list,size,varalign,temptype,def,fini,ref);
|
||||
end;
|
||||
|
||||
|
||||
procedure ttgobj.gettempmanaged(list: TAsmList; def:tdef;temptype:ttemptype;out ref : treference);
|
||||
begin
|
||||
gettempinternal(list,def.size,def.alignment,temptype,def,ref);
|
||||
gettempinternal(list,def.size,def.alignment,temptype,def,true,ref);
|
||||
end;
|
||||
|
||||
|
||||
@ -681,7 +687,7 @@ implementation
|
||||
procedure ttgobj.getlocal(list: TAsmList; size : longint; alignment : shortint; def:tdef;var ref : treference);
|
||||
begin
|
||||
alignment:=used_align(alignment,current_settings.alignment.localalignmin,current_settings.alignment.localalignmax);
|
||||
alloctemp(list,size,alignment,tt_persistent,nil,ref);
|
||||
alloctemp(list,size,alignment,tt_persistent,def,false,ref);
|
||||
end;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user