mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 08:09:33 +02:00
+ usedasmsymbollist to check and reset only the used symbols (merged)
This commit is contained in:
parent
2c58f511b0
commit
cdbe6a1fa3
@ -101,10 +101,9 @@ unit aasm;
|
||||
|
||||
pasmsymbol = ^tasmsymbol;
|
||||
tasmsymbol = object(tnamedindexobject)
|
||||
orgbind,
|
||||
defbind,
|
||||
bind : TAsmsymbind;
|
||||
typ : TAsmsymtype;
|
||||
proclocal : boolean;
|
||||
{ the next fields are filled in the binary writer }
|
||||
section : tsection;
|
||||
idx : longint;
|
||||
@ -116,10 +115,13 @@ unit aasm;
|
||||
{ alternate symbol which can be used for 'renaming' needed for
|
||||
inlining }
|
||||
altsymbol : pasmsymbol;
|
||||
{ is the symbol local for a procedure/function }
|
||||
proclocal : boolean;
|
||||
{ is the symbol in the used list }
|
||||
inusedlist : boolean;
|
||||
constructor init(const s:string;_bind:TAsmsymbind;_typ:Tasmsymtype);
|
||||
procedure reset;
|
||||
function is_used:boolean;
|
||||
procedure setbind(t:tasmsymbind);
|
||||
procedure setaddress(sec:tsection;offset,len:longint);
|
||||
procedure GenerateAltSymbol;
|
||||
end;
|
||||
@ -145,10 +147,6 @@ unit aasm;
|
||||
end;
|
||||
|
||||
|
||||
pasmsymbollist = ^tasmsymbollist;
|
||||
tasmsymbollist = object(tdictionary)
|
||||
end;
|
||||
|
||||
{ the short name makes typing easier }
|
||||
pai = ^tai;
|
||||
tai = object(tlinkedlist_item)
|
||||
@ -394,7 +392,8 @@ type
|
||||
resourcesection,rttilist,
|
||||
resourcestringlist : paasmoutput;
|
||||
{ asm symbol list }
|
||||
asmsymbollist : pasmsymbollist;
|
||||
asmsymbollist : pdictionary;
|
||||
usedasmsymbollist : psinglelist;
|
||||
|
||||
const
|
||||
nextaltnr : longint = 1;
|
||||
@ -415,9 +414,13 @@ type
|
||||
function getasmsymbol(const s : string) : pasmsymbol;
|
||||
function renameasmsymbol(const sold, snew : string):pasmsymbol;
|
||||
|
||||
procedure ResetAsmsymbolList;
|
||||
procedure ResetAsmSymbolListAltSymbol;
|
||||
procedure CheckAsmSymbolListUndefined;
|
||||
procedure InitUsedAsmSymbolList;
|
||||
procedure DoneUsedAsmSymbolList;
|
||||
procedure UsedAsmSymbolListInsert(p:pasmsymbol);
|
||||
procedure UsedAsmSymbolListReset;
|
||||
procedure UsedAsmSymbolListResetAltSym;
|
||||
procedure UsedAsmSymbolListCheckUndefined;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
@ -903,15 +906,13 @@ uses
|
||||
|
||||
constructor tasmsymbol.init(const s:string;_bind:TAsmsymbind;_typ:Tasmsymtype);
|
||||
begin;
|
||||
{$IFDEF NEWST}
|
||||
inherited init(s);
|
||||
{$ELSE}
|
||||
inherited initname(s);
|
||||
{$ENDIF NEWST}
|
||||
reset;
|
||||
orgbind:=_bind;
|
||||
bind:=_bind;
|
||||
defbind:=_bind;
|
||||
typ:=_typ;
|
||||
inusedlist:=false;
|
||||
{ mainly used to remove unused labels from the codesegment }
|
||||
refs:=0;
|
||||
end;
|
||||
|
||||
procedure tasmsymbol.GenerateAltSymbol;
|
||||
@ -934,8 +935,6 @@ uses
|
||||
idx:=-1;
|
||||
bind:=AB_EXTERNAL;
|
||||
proclocal:=false;
|
||||
{ mainly used to remove unused labels from the codesegment }
|
||||
refs:=0;
|
||||
end;
|
||||
|
||||
function tasmsymbol.is_used:boolean;
|
||||
@ -943,21 +942,15 @@ uses
|
||||
is_used:=(refs>0);
|
||||
end;
|
||||
|
||||
procedure tasmsymbol.setbind(t:tasmsymbind);
|
||||
begin
|
||||
bind:=t;
|
||||
orgbind:=t;
|
||||
end;
|
||||
|
||||
procedure tasmsymbol.setaddress(sec:tsection;offset,len:longint);
|
||||
begin
|
||||
section:=sec;
|
||||
address:=offset;
|
||||
size:=len;
|
||||
{ when the typ was reset to External, set it back to the original
|
||||
type it got when defined }
|
||||
if (bind=AB_EXTERNAL) and (orgbind<>AB_NONE) then
|
||||
bind:=orgbind;
|
||||
{ when the bind was reset to External, set it back to the default
|
||||
bind it got when defined }
|
||||
if (bind=AB_EXTERNAL) and (defbind<>AB_NONE) then
|
||||
bind:=defbind;
|
||||
end;
|
||||
|
||||
|
||||
@ -1012,25 +1005,23 @@ uses
|
||||
hp : pasmsymbol;
|
||||
begin
|
||||
hp:=pasmsymbol(asmsymbollist^.search(s));
|
||||
if assigned(hp) then
|
||||
if not assigned(hp) then
|
||||
begin
|
||||
newasmsymbol:=hp;
|
||||
exit;
|
||||
{ Not found, insert it as an External }
|
||||
hp:=new(pasmsymbol,init(s,AB_EXTERNAL,AT_FUNCTION));
|
||||
asmsymbollist^.insert(hp);
|
||||
end;
|
||||
{ Not found, insert it as an External }
|
||||
hp:=new(pasmsymbol,init(s,AB_EXTERNAL,AT_FUNCTION));
|
||||
asmsymbollist^.insert(hp);
|
||||
newasmsymbol:=hp;
|
||||
end;
|
||||
|
||||
|
||||
function newasmsymboltype(const s : string;_bind:TAsmSymBind;_typ:Tasmsymtype) : pasmsymbol;
|
||||
function newasmsymboltype(const s : string;_bind:TAsmSymBind;_typ:Tasmsymtype) : pasmsymbol;
|
||||
var
|
||||
hp : pasmsymbol;
|
||||
begin
|
||||
hp:=pasmsymbol(asmsymbollist^.search(s));
|
||||
if assigned(hp) then
|
||||
hp^.setbind(_bind)
|
||||
hp^.defbind:=_bind
|
||||
else
|
||||
begin
|
||||
{ Not found, insert it as an External }
|
||||
@ -1054,41 +1045,84 @@ uses
|
||||
end;
|
||||
|
||||
|
||||
procedure ResetAsmSym(p:Pnamedindexobject);{$ifndef FPC}far;{$endif}
|
||||
{*****************************************************************************
|
||||
Used AsmSymbolList
|
||||
*****************************************************************************}
|
||||
|
||||
procedure InitUsedAsmSymbolList;
|
||||
begin
|
||||
pasmsymbol(p)^.reset;
|
||||
if assigned(usedasmsymbollist) then
|
||||
internalerror(78455782);
|
||||
new(usedasmsymbollist,init);
|
||||
usedasmsymbollist^.noclear:=true;
|
||||
end;
|
||||
|
||||
|
||||
procedure ResetAsmsymbolList;
|
||||
procedure DoneUsedAsmSymbolList;
|
||||
begin
|
||||
asmsymbollist^.foreach({$ifndef TP}@{$endif}resetasmsym);
|
||||
dispose(usedasmsymbollist,done);
|
||||
usedasmsymbollist:=nil;
|
||||
end;
|
||||
|
||||
|
||||
procedure ResetAltSym(p:Pnamedindexobject);{$ifndef FPC}far;{$endif}
|
||||
procedure UsedAsmSymbolListInsert(p:pasmsymbol);
|
||||
begin
|
||||
pasmsymbol(p)^.altsymbol:=nil;
|
||||
if not p^.inusedlist then
|
||||
usedasmsymbollist^.insert(p);
|
||||
p^.inusedlist:=true;
|
||||
end;
|
||||
|
||||
|
||||
procedure ResetAsmSymbolListAltSymbol;
|
||||
procedure UsedAsmSymbolListReset;
|
||||
var
|
||||
hp : pasmsymbol;
|
||||
begin
|
||||
asmsymbollist^.foreach({$ifndef TP}@{$endif}resetaltsym);
|
||||
hp:=pasmsymbol(usedasmsymbollist^.first);
|
||||
while assigned(hp) do
|
||||
begin
|
||||
with hp^ do
|
||||
begin
|
||||
reset;
|
||||
inusedlist:=false;
|
||||
end;
|
||||
hp:=pasmsymbol(hp^.next);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure checkundefinedasmsym(p:Pnamedindexobject);{$ifndef FPC}far;{$endif}
|
||||
procedure UsedAsmSymbolListResetAltSym;
|
||||
var
|
||||
hp : pasmsymbol;
|
||||
begin
|
||||
if (pasmsymbol(p)^.refs>0) and
|
||||
(pasmsymbol(p)^.section=Sec_none) and
|
||||
(pasmsymbol(p)^.bind<>AB_EXTERNAL) then
|
||||
Message1(asmw_e_undefined_label,pasmsymbol(p)^.name);
|
||||
hp:=pasmsymbol(usedasmsymbollist^.first);
|
||||
while assigned(hp) do
|
||||
begin
|
||||
with hp^ do
|
||||
begin
|
||||
altsymbol:=nil;
|
||||
inusedlist:=false;
|
||||
end;
|
||||
hp:=pasmsymbol(hp^.next);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure CheckAsmSymbolListUndefined;
|
||||
|
||||
procedure UsedAsmSymbolListCheckUndefined;
|
||||
var
|
||||
hp : pasmsymbol;
|
||||
begin
|
||||
asmsymbollist^.foreach({$ifndef TP}@{$endif}checkundefinedasmsym);
|
||||
hp:=pasmsymbol(usedasmsymbollist^.first);
|
||||
while assigned(hp) do
|
||||
begin
|
||||
with hp^ do
|
||||
begin
|
||||
if (refs>0) and
|
||||
(section=Sec_none) and
|
||||
(bind<>AB_EXTERNAL) then
|
||||
Message1(asmw_e_undefined_label,name);
|
||||
end;
|
||||
hp:=pasmsymbol(hp^.next);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
@ -1146,7 +1180,10 @@ uses
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.6 2000-08-09 19:49:44 peter
|
||||
Revision 1.7 2000-08-12 15:34:21 peter
|
||||
+ usedasmsymbollist to check and reset only the used symbols (merged)
|
||||
|
||||
Revision 1.6 2000/08/09 19:49:44 peter
|
||||
* packenumfixed things so it compiles with 1.0.0 again
|
||||
|
||||
Revision 1.5 2000/08/05 13:25:06 peter
|
||||
|
@ -185,6 +185,7 @@ unit ag386bin;
|
||||
sec:=ps^.section;
|
||||
ofs:=ps^.address;
|
||||
reloc:=true;
|
||||
UsedAsmSymbolListInsert(ps);
|
||||
end;
|
||||
if j<256 then
|
||||
begin
|
||||
@ -207,6 +208,7 @@ unit ag386bin;
|
||||
internalerror(33008);
|
||||
ofs:=ofs-ps^.address;
|
||||
reloc:=false;
|
||||
UsedAsmSymbolListInsert(ps);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -214,7 +216,7 @@ unit ag386bin;
|
||||
{ external bss need speical handling (PM) }
|
||||
if assigned(ps) and (ps^.section=sec_none) then
|
||||
begin
|
||||
if currpass<>1 then
|
||||
if currpass=2 then
|
||||
objectoutput^.writesymbol(ps);
|
||||
objectoutput^.WriteSymStabs(sec,ofs,hp,ps,nidx,nother,line,reloc)
|
||||
end
|
||||
@ -308,11 +310,11 @@ unit ag386bin;
|
||||
else
|
||||
curr_n:=n_includefile;
|
||||
{ get symbol for this includefile }
|
||||
hp:=newasmsymbol('Ltext'+ToStr(IncludeCount));
|
||||
hp:=newasmsymboltype('Ltext'+ToStr(IncludeCount),AB_LOCAL,AT_FUNCTION);
|
||||
if currpass=1 then
|
||||
begin
|
||||
hp^.setbind(AB_LOCAL);
|
||||
hp^.setaddress(objectalloc^.currsec,objectalloc^.sectionsize,0);
|
||||
UsedAsmSymbolListInsert(hp);
|
||||
end
|
||||
else
|
||||
objectoutput^.writesymbol(hp);
|
||||
@ -355,11 +357,11 @@ unit ag386bin;
|
||||
exit;
|
||||
store_sec:=objectalloc^.currsec;
|
||||
objectalloc^.setsection(sec_code);
|
||||
hp:=newasmsymbol('Letext');
|
||||
hp:=newasmsymboltype('Letext',AB_LOCAL,AT_FUNCTION);
|
||||
if currpass=1 then
|
||||
begin
|
||||
hp^.setbind(AB_LOCAL);
|
||||
hp^.setaddress(objectalloc^.currsec,objectalloc^.sectionsize,0);
|
||||
UsedAsmSymbolListInsert(hp);
|
||||
end
|
||||
else
|
||||
objectoutput^.writesymbol(hp);
|
||||
@ -473,7 +475,7 @@ unit ag386bin;
|
||||
|
||||
function ti386binasmlist.TreePass1(hp:pai):pai;
|
||||
var
|
||||
l : longint;
|
||||
i,l : longint;
|
||||
begin
|
||||
while assigned(hp) do
|
||||
begin
|
||||
@ -508,8 +510,10 @@ unit ag386bin;
|
||||
begin
|
||||
if pai_datablock(hp)^.is_global then
|
||||
begin
|
||||
pai_datablock(hp)^.sym^.setbind(AB_COMMON);
|
||||
pai_datablock(hp)^.sym^.setaddress(sec_none,pai_datablock(hp)^.size,pai_datablock(hp)^.size);
|
||||
{ force to be common/external, must be after setaddress as that would
|
||||
set it to AS_GLOBAL }
|
||||
pai_datablock(hp)^.sym^.bind:=AB_COMMON;
|
||||
end
|
||||
else
|
||||
begin
|
||||
@ -518,7 +522,6 @@ unit ag386bin;
|
||||
objectalloc^.sectionalign(4)
|
||||
else if l>1 then
|
||||
objectalloc^.sectionalign(2);
|
||||
pai_datablock(hp)^.sym^.setbind(AB_LOCAL);
|
||||
pai_datablock(hp)^.sym^.setaddress(objectalloc^.currsec,objectalloc^.sectionsize,
|
||||
pai_datablock(hp)^.size);
|
||||
objectalloc^.sectionalloc(pai_datablock(hp)^.size);
|
||||
@ -527,10 +530,6 @@ unit ag386bin;
|
||||
else
|
||||
{$endif}
|
||||
begin
|
||||
if pai_datablock(hp)^.is_global then
|
||||
pai_datablock(hp)^.sym^.setbind(AB_GLOBAL)
|
||||
else
|
||||
pai_datablock(hp)^.sym^.setbind(AB_LOCAL);
|
||||
l:=pai_datablock(hp)^.size;
|
||||
if l>2 then
|
||||
objectalloc^.sectionalign(4)
|
||||
@ -539,6 +538,7 @@ unit ag386bin;
|
||||
pai_datablock(hp)^.sym^.setaddress(objectalloc^.currsec,objectalloc^.sectionsize,pai_datablock(hp)^.size);
|
||||
objectalloc^.sectionalloc(pai_datablock(hp)^.size);
|
||||
end;
|
||||
UsedAsmSymbolListInsert(pai_datablock(hp)^.sym);
|
||||
end;
|
||||
ait_const_32bit :
|
||||
objectalloc^.sectionalloc(4);
|
||||
@ -556,7 +556,10 @@ unit ag386bin;
|
||||
objectalloc^.sectionalloc(8);
|
||||
ait_const_rva,
|
||||
ait_const_symbol :
|
||||
objectalloc^.sectionalloc(4);
|
||||
begin
|
||||
objectalloc^.sectionalloc(4);
|
||||
UsedAsmSymbolListInsert(pai_const_symbol(hp)^.sym);
|
||||
end;
|
||||
ait_section:
|
||||
begin
|
||||
objectalloc^.setsection(pai_section(hp)^.sec);
|
||||
@ -577,38 +580,60 @@ unit ag386bin;
|
||||
ait_stabs :
|
||||
convertstabs(pai_stabs(hp)^.str);
|
||||
ait_stab_function_name :
|
||||
if assigned(pai_stab_function_name(hp)^.str) then
|
||||
funcname:=getasmsymbol(strpas(pai_stab_function_name(hp)^.str))
|
||||
else
|
||||
funcname:=nil;
|
||||
begin
|
||||
if assigned(pai_stab_function_name(hp)^.str) then
|
||||
begin
|
||||
funcname:=getasmsymbol(strpas(pai_stab_function_name(hp)^.str));
|
||||
UsedAsmSymbolListInsert(funcname);
|
||||
end
|
||||
else
|
||||
funcname:=nil;
|
||||
end;
|
||||
ait_force_line :
|
||||
stabslastfileinfo.line:=0;
|
||||
{$endif}
|
||||
ait_symbol :
|
||||
begin
|
||||
if pai_symbol(hp)^.is_global then
|
||||
pai_symbol(hp)^.sym^.setbind(AB_GLOBAL)
|
||||
else
|
||||
pai_symbol(hp)^.sym^.setbind(AB_LOCAL);
|
||||
pai_symbol(hp)^.sym^.setaddress(objectalloc^.currsec,objectalloc^.sectionsize,0);
|
||||
UsedAsmSymbolListInsert(pai_symbol(hp)^.sym);
|
||||
end;
|
||||
ait_symbol_end :
|
||||
begin
|
||||
if target_info.target=target_i386_linux then
|
||||
pai_symbol(hp)^.sym^.size:=objectalloc^.sectionsize-pai_symbol(hp)^.sym^.address;
|
||||
begin
|
||||
pai_symbol(hp)^.sym^.size:=objectalloc^.sectionsize-pai_symbol(hp)^.sym^.address;
|
||||
UsedAsmSymbolListInsert(pai_symbol(hp)^.sym);
|
||||
end;
|
||||
end;
|
||||
ait_label :
|
||||
begin
|
||||
if pai_label(hp)^.is_global then
|
||||
pai_label(hp)^.l^.setbind(AB_GLOBAL)
|
||||
else
|
||||
pai_label(hp)^.l^.setbind(AB_LOCAL);
|
||||
pai_label(hp)^.l^.setaddress(objectalloc^.currsec,objectalloc^.sectionsize,0);
|
||||
UsedAsmSymbolListInsert(pai_label(hp)^.l);
|
||||
end;
|
||||
ait_string :
|
||||
objectalloc^.sectionalloc(pai_string(hp)^.len);
|
||||
ait_instruction :
|
||||
objectalloc^.sectionalloc(paicpu(hp)^.Pass1(objectalloc^.sectionsize));
|
||||
begin
|
||||
objectalloc^.sectionalloc(paicpu(hp)^.Pass1(objectalloc^.sectionsize));
|
||||
{ fixup the references }
|
||||
for i:=1 to paicpu(hp)^.ops do
|
||||
begin
|
||||
with paicpu(hp)^.oper[i-1] do
|
||||
begin
|
||||
case typ of
|
||||
top_ref :
|
||||
begin
|
||||
if assigned(ref^.symbol) then
|
||||
UsedAsmSymbolListInsert(ref^.symbol);
|
||||
end;
|
||||
top_symbol :
|
||||
begin
|
||||
UsedAsmSymbolListInsert(sym);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
ait_direct :
|
||||
Message(asmw_f_direct_not_supported);
|
||||
ait_cut :
|
||||
@ -747,8 +772,7 @@ unit ag386bin;
|
||||
objectoutput^.initwriting(cut_normal);
|
||||
objectoutput^.defaultsection(sec_code);
|
||||
{ reset the asmsymbol list }
|
||||
ResetAsmsymbolList;
|
||||
objectoutput^.defaultsection(sec_code);
|
||||
InitUsedAsmsymbolList;
|
||||
|
||||
{$ifdef MULTIPASS}
|
||||
{ Pass 0 }
|
||||
@ -787,8 +811,9 @@ unit ag386bin;
|
||||
{$ifdef GDB}
|
||||
EndFileLineInfo;
|
||||
{$endif GDB}
|
||||
{ check for undefined labels }
|
||||
CheckAsmSymbolListUndefined;
|
||||
{ check for undefined labels and reset }
|
||||
UsedAsmSymbolListCheckUndefined;
|
||||
|
||||
{ set section sizes }
|
||||
objectoutput^.setsectionsizes(objectalloc^.secsize);
|
||||
{ leave if errors have occured }
|
||||
@ -819,6 +844,11 @@ unit ag386bin;
|
||||
|
||||
{ write last objectfile }
|
||||
objectoutput^.donewriting;
|
||||
|
||||
{ reset the used symbols back, must be after the .o has been
|
||||
written }
|
||||
UsedAsmsymbolListReset;
|
||||
DoneUsedAsmsymbolList;
|
||||
end;
|
||||
|
||||
|
||||
@ -834,6 +864,7 @@ unit ag386bin;
|
||||
objectoutput^.initwriting(cut_normal);
|
||||
objectoutput^.defaultsection(sec_code);
|
||||
startsec:=sec_code;
|
||||
|
||||
{ start with list 1 }
|
||||
currlistidx:=1;
|
||||
currlist:=list[currlistidx];
|
||||
@ -841,7 +872,7 @@ unit ag386bin;
|
||||
while assigned(hp) do
|
||||
begin
|
||||
{ reset the asmsymbol list }
|
||||
ResetAsmsymbolList;
|
||||
InitUsedAsmSymbolList;
|
||||
|
||||
{$ifdef MULTIPASS}
|
||||
{ Pass 0 }
|
||||
@ -866,7 +897,8 @@ unit ag386bin;
|
||||
EndFileLineInfo;
|
||||
{$endif GDB}
|
||||
{ check for undefined labels }
|
||||
CheckAsmSymbolListUndefined;
|
||||
UsedAsmSymbolListCheckUndefined;
|
||||
|
||||
{ set section sizes }
|
||||
objectoutput^.setsectionsizes(objectalloc^.secsize);
|
||||
{ leave if errors have occured }
|
||||
@ -890,6 +922,11 @@ unit ag386bin;
|
||||
{ if not end then write the current objectfile }
|
||||
objectoutput^.donewriting;
|
||||
|
||||
{ reset the used symbols back, must be after the .o has been
|
||||
written }
|
||||
UsedAsmsymbolListReset;
|
||||
DoneUsedAsmsymbolList;
|
||||
|
||||
{ end of lists? }
|
||||
if not MaybeNextList(hp) then
|
||||
break;
|
||||
@ -1002,7 +1039,10 @@ unit ag386bin;
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.5 2000-08-08 19:28:57 peter
|
||||
Revision 1.6 2000-08-12 15:34:22 peter
|
||||
+ usedasmsymbollist to check and reset only the used symbols (merged)
|
||||
|
||||
Revision 1.5 2000/08/08 19:28:57 peter
|
||||
* memdebug/memory patches (merged)
|
||||
* only once illegal directive (merged)
|
||||
|
||||
|
@ -260,6 +260,17 @@ unit cobjects;
|
||||
procedure inserttree(currtree,currroot:Pnamedindexobject);
|
||||
end;
|
||||
|
||||
psinglelist=^tsinglelist;
|
||||
tsinglelist=object
|
||||
noclear : boolean;
|
||||
first,
|
||||
last : Pnamedindexobject;
|
||||
constructor init;
|
||||
destructor done;
|
||||
procedure clear;
|
||||
procedure insert(p:Pnamedindexobject);
|
||||
end;
|
||||
|
||||
pdynamicarray = ^tdynamicarray;
|
||||
tdynamicarray = object
|
||||
posn,
|
||||
@ -286,8 +297,9 @@ unit cobjects;
|
||||
|
||||
pindexarray=^tindexarray;
|
||||
tindexarray=object
|
||||
first : Pnamedindexobject;
|
||||
count : longint;
|
||||
noclear : boolean;
|
||||
first : Pnamedindexobject;
|
||||
count : longint;
|
||||
constructor init(Agrowsize:longint);
|
||||
destructor done;
|
||||
procedure clear;
|
||||
@ -1762,6 +1774,51 @@ end;
|
||||
end;
|
||||
|
||||
|
||||
{****************************************************************************
|
||||
tsinglelist
|
||||
****************************************************************************}
|
||||
|
||||
constructor tsinglelist.init;
|
||||
begin
|
||||
first:=nil;
|
||||
last:=nil;
|
||||
noclear:=false;
|
||||
end;
|
||||
|
||||
|
||||
destructor tsinglelist.done;
|
||||
begin
|
||||
if not noclear then
|
||||
clear;
|
||||
end;
|
||||
|
||||
|
||||
procedure tsinglelist.clear;
|
||||
var
|
||||
hp : pnamedindexobject;
|
||||
begin
|
||||
hp:=first;
|
||||
while assigned(hp) do
|
||||
begin
|
||||
dispose(hp,done);
|
||||
hp:=hp^.next;
|
||||
end;
|
||||
first:=nil;
|
||||
last:=nil;
|
||||
end;
|
||||
|
||||
|
||||
procedure tsinglelist.insert(p:Pnamedindexobject);
|
||||
begin
|
||||
if not assigned(first) then
|
||||
first:=p
|
||||
else
|
||||
last^.next:=p;
|
||||
last:=p;
|
||||
p^.next:=nil;
|
||||
end;
|
||||
|
||||
|
||||
{****************************************************************************
|
||||
tdynamicarray
|
||||
****************************************************************************}
|
||||
@ -1790,13 +1847,13 @@ end;
|
||||
procedure tdynamicarray.grow;
|
||||
var
|
||||
osize : longint;
|
||||
{$ifndef REALLOCMEM}
|
||||
{$ifndef USEREALLOCMEM}
|
||||
odata : pchar;
|
||||
{$endif REALLOCMEM}
|
||||
{$endif USEREALLOCMEM}
|
||||
begin
|
||||
osize:=size;
|
||||
inc(limit,growcount);
|
||||
{$ifndef REALLOCMEM}
|
||||
{$ifndef USEREALLOCMEM}
|
||||
odata:=data;
|
||||
getmem(data,size);
|
||||
if assigned(odata) then
|
||||
@ -1804,9 +1861,9 @@ end;
|
||||
move(odata^,data^,osize);
|
||||
freemem(odata,osize);
|
||||
end;
|
||||
{$else REALLOCMEM}
|
||||
{$else USEREALLOCMEM}
|
||||
reallocmem(data,size);
|
||||
{$endif REALLOCMEM}
|
||||
{$endif USEREALLOCMEM}
|
||||
fillchar(data[osize],growcount*elemlen,0);
|
||||
end;
|
||||
|
||||
@ -1892,13 +1949,15 @@ end;
|
||||
count:=0;
|
||||
data:=nil;
|
||||
first:=nil;
|
||||
noclear:=false;
|
||||
end;
|
||||
|
||||
destructor tindexarray.done;
|
||||
begin
|
||||
if assigned(data) then
|
||||
begin
|
||||
clear;
|
||||
if not noclear then
|
||||
clear;
|
||||
freemem(data,size*4);
|
||||
data:=nil;
|
||||
end;
|
||||
@ -1941,13 +2000,13 @@ end;
|
||||
procedure tindexarray.grow(gsize:longint);
|
||||
var
|
||||
osize : longint;
|
||||
{$ifndef REALLOCMEM}
|
||||
{$ifndef USEREALLOCMEM}
|
||||
odata : Pnamedindexobjectarray;
|
||||
{$endif fpc}
|
||||
{$endif USEREALLOCMEM}
|
||||
begin
|
||||
osize:=size;
|
||||
inc(size,gsize);
|
||||
{$ifndef REALLOCMEM}
|
||||
{$ifndef USEREALLOCMEM}
|
||||
odata:=data;
|
||||
getmem(data,size*4);
|
||||
if assigned(odata) then
|
||||
@ -1955,9 +2014,9 @@ end;
|
||||
move(odata^,data^,osize*4);
|
||||
freemem(odata,osize*4);
|
||||
end;
|
||||
{$else REALLOCMEM}
|
||||
{$else USEREALLOCMEM}
|
||||
reallocmem(data,size*4);
|
||||
{$endif REALLOCMEM}
|
||||
{$endif USEREALLOCMEM}
|
||||
fillchar(data^[osize+1],gsize*4,0);
|
||||
end;
|
||||
|
||||
@ -2424,7 +2483,10 @@ end;
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.6 2000-08-10 12:20:44 jonas
|
||||
Revision 1.7 2000-08-12 15:34:22 peter
|
||||
+ usedasmsymbollist to check and reset only the used symbols (merged)
|
||||
|
||||
Revision 1.6 2000/08/10 12:20:44 jonas
|
||||
* reallocmem is now also used under Delphi (merged from fixes branch)
|
||||
|
||||
Revision 1.5 2000/08/09 12:09:45 jonas
|
||||
|
@ -373,7 +373,7 @@ implementation
|
||||
exportssection:=nil;
|
||||
resourcesection:=nil;
|
||||
{ assembler symbols }
|
||||
asmsymbollist:=new(pasmsymbollist,init);
|
||||
asmsymbollist:=new(pdictionary,init);
|
||||
asmsymbollist^.usehash;
|
||||
{ resourcestrings }
|
||||
new(ResourceStrings,Init);
|
||||
@ -462,7 +462,10 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.3 2000-08-03 13:17:26 jonas
|
||||
Revision 1.4 2000-08-12 15:34:22 peter
|
||||
+ usedasmsymbollist to check and reset only the used symbols (merged)
|
||||
|
||||
Revision 1.3 2000/08/03 13:17:26 jonas
|
||||
+ allow regvars to be used inside inlined procs, which required the
|
||||
following changes:
|
||||
+ load regvars in genentrycode/free them in genexitcode (cgai386)
|
||||
|
@ -260,7 +260,7 @@ unit parser;
|
||||
olddebuglist,
|
||||
oldwithdebuglist,
|
||||
oldconsts : paasmoutput;
|
||||
oldasmsymbollist : pasmsymbollist;
|
||||
oldasmsymbollist : pdictionary;
|
||||
{ resourcestrings }
|
||||
OldResourceStrings : PResourceStrings;
|
||||
{ akt.. things }
|
||||
@ -607,7 +607,10 @@ unit parser;
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.2 2000-07-13 11:32:44 michael
|
||||
Revision 1.3 2000-08-12 15:34:22 peter
|
||||
+ usedasmsymbollist to check and reset only the used symbols (merged)
|
||||
|
||||
Revision 1.2 2000/07/13 11:32:44 michael
|
||||
+ removed logs
|
||||
|
||||
}
|
||||
|
@ -129,7 +129,10 @@ implementation
|
||||
if p^.proclocal then
|
||||
begin
|
||||
if not assigned(p^.altsymbol) then
|
||||
p^.GenerateAltSymbol;
|
||||
begin
|
||||
p^.GenerateAltSymbol;
|
||||
UsedAsmSymbolListInsert(p);
|
||||
end;
|
||||
p:=p^.altsymbol;
|
||||
end;
|
||||
end;
|
||||
@ -138,14 +141,13 @@ implementation
|
||||
hp,hp2 : pai;
|
||||
localfixup,parafixup,
|
||||
i : longint;
|
||||
r : preference;
|
||||
skipnode : boolean;
|
||||
begin
|
||||
if inlining_procedure then
|
||||
begin
|
||||
InitUsedAsmSymbolList;
|
||||
localfixup:=aktprocsym^.definition^.localst^.address_fixup;
|
||||
parafixup:=aktprocsym^.definition^.parast^.address_fixup;
|
||||
ResetAsmSymbolListAltSymbol;
|
||||
hp:=pai(p^.p_asm^.first);
|
||||
while assigned(hp) do
|
||||
begin
|
||||
@ -167,24 +169,28 @@ implementation
|
||||
{$ifdef i386}
|
||||
{ fixup the references }
|
||||
for i:=1 to paicpu(hp2)^.ops do
|
||||
case paicpu(hp2)^.oper[i-1].typ of
|
||||
top_ref :
|
||||
begin
|
||||
r:=paicpu(hp2)^.oper[i-1].ref;
|
||||
case r^.options of
|
||||
ref_parafixup :
|
||||
r^.offsetfixup:=parafixup;
|
||||
ref_localfixup :
|
||||
r^.offsetfixup:=localfixup;
|
||||
begin
|
||||
with paicpu(hp2)^.oper[i-1] do
|
||||
begin
|
||||
case typ of
|
||||
top_ref :
|
||||
begin
|
||||
case ref^.options of
|
||||
ref_parafixup :
|
||||
ref^.offsetfixup:=parafixup;
|
||||
ref_localfixup :
|
||||
ref^.offsetfixup:=localfixup;
|
||||
end;
|
||||
if assigned(ref^.symbol) then
|
||||
ReLabel(ref^.symbol);
|
||||
end;
|
||||
top_symbol :
|
||||
begin
|
||||
ReLabel(sym);
|
||||
end;
|
||||
end;
|
||||
if assigned(r^.symbol) then
|
||||
ReLabel(r^.symbol);
|
||||
end;
|
||||
top_symbol :
|
||||
begin
|
||||
ReLabel(paicpu(hp2)^.oper[i-1].sym);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
{$endif i386}
|
||||
end;
|
||||
ait_marker :
|
||||
@ -200,7 +206,10 @@ implementation
|
||||
else
|
||||
dispose(hp2,done);
|
||||
hp:=pai(hp^.next);
|
||||
end
|
||||
end;
|
||||
{ restore used symbols }
|
||||
UsedAsmSymbolListResetAltSym;
|
||||
DoneUsedAsmSymbolList;
|
||||
end
|
||||
else
|
||||
begin
|
||||
@ -489,50 +498,50 @@ implementation
|
||||
if (cs_regalloc in aktglobalswitches) and
|
||||
((procinfo^.flags and (pi_uses_asm or pi_uses_exceptions))=0) then
|
||||
begin
|
||||
{ can we omit the stack frame ? }
|
||||
{ conditions:
|
||||
1. procedure (not main block)
|
||||
2. no constructor or destructor
|
||||
3. no call to other procedures
|
||||
4. no interrupt handler
|
||||
}
|
||||
{!!!!!! this doesn work yet, because of problems with
|
||||
with linux and windows
|
||||
}
|
||||
(*
|
||||
if assigned(aktprocsym) then
|
||||
begin
|
||||
if not(assigned(procinfo^._class)) and
|
||||
not(aktprocsym^.definition^.proctypeoption in [potype_constructor,potype_destructor]) and
|
||||
not(po_interrupt in aktprocsym^.definition^.procoptions) and
|
||||
((procinfo^.flags and pi_do_call)=0) and
|
||||
(lexlevel>=normal_function_level) then
|
||||
begin
|
||||
{ use ESP as frame pointer }
|
||||
procinfo^.framepointer:=stack_pointer;
|
||||
use_esp_stackframe:=true;
|
||||
{ can we omit the stack frame ? }
|
||||
{ conditions:
|
||||
1. procedure (not main block)
|
||||
2. no constructor or destructor
|
||||
3. no call to other procedures
|
||||
4. no interrupt handler
|
||||
}
|
||||
{!!!!!! this doesn work yet, because of problems with
|
||||
with linux and windows
|
||||
}
|
||||
(*
|
||||
if assigned(aktprocsym) then
|
||||
begin
|
||||
if not(assigned(procinfo^._class)) and
|
||||
not(aktprocsym^.definition^.proctypeoption in [potype_constructor,potype_destructor]) and
|
||||
not(po_interrupt in aktprocsym^.definition^.procoptions) and
|
||||
((procinfo^.flags and pi_do_call)=0) and
|
||||
(lexlevel>=normal_function_level) then
|
||||
begin
|
||||
{ use ESP as frame pointer }
|
||||
procinfo^.framepointer:=stack_pointer;
|
||||
use_esp_stackframe:=true;
|
||||
|
||||
{ calc parameter distance new }
|
||||
dec(procinfo^.framepointer_offset,4);
|
||||
dec(procinfo^.selfpointer_offset,4);
|
||||
{ calc parameter distance new }
|
||||
dec(procinfo^.framepointer_offset,4);
|
||||
dec(procinfo^.selfpointer_offset,4);
|
||||
|
||||
{ is this correct ???}
|
||||
{ retoffset can be negativ for results in eax !! }
|
||||
{ the value should be decreased only if positive }
|
||||
if procinfo^.retoffset>=0 then
|
||||
dec(procinfo^.retoffset,4);
|
||||
{ is this correct ???}
|
||||
{ retoffset can be negativ for results in eax !! }
|
||||
{ the value should be decreased only if positive }
|
||||
if procinfo^.retoffset>=0 then
|
||||
dec(procinfo^.retoffset,4);
|
||||
|
||||
dec(procinfo^.para_offset,4);
|
||||
aktprocsym^.definition^.parast^.address_fixup:=procinfo^.para_offset;
|
||||
end;
|
||||
end;
|
||||
*)
|
||||
end;
|
||||
dec(procinfo^.para_offset,4);
|
||||
aktprocsym^.definition^.parast^.address_fixup:=procinfo^.para_offset;
|
||||
end;
|
||||
end;
|
||||
*)
|
||||
end;
|
||||
{ process register variable stuff (JM) }
|
||||
assign_regvars(p);
|
||||
load_regvars(procinfo^.aktentrycode,p);
|
||||
cleanup_regvars(procinfo^.aktexitcode);
|
||||
|
||||
|
||||
if assigned(aktprocsym) and
|
||||
(pocall_inline in aktprocsym^.definition^.proccalloptions) then
|
||||
make_const_global:=true;
|
||||
@ -549,7 +558,10 @@ implementation
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.5 2000-08-03 13:17:25 jonas
|
||||
Revision 1.6 2000-08-12 15:34:22 peter
|
||||
+ usedasmsymbollist to check and reset only the used symbols (merged)
|
||||
|
||||
Revision 1.5 2000/08/03 13:17:25 jonas
|
||||
+ allow regvars to be used inside inlined procs, which required the
|
||||
following changes:
|
||||
+ load regvars in genentrycode/free them in genexitcode (cgai386)
|
||||
|
Loading…
Reference in New Issue
Block a user