mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-08 05:26:21 +02:00
+ added x86-specific function getx86pointerdef, similar to getpointerdef, but
allows creating the x86 special pointer types as well git-svn-id: trunk@28329 -
This commit is contained in:
parent
4ea551a0f7
commit
dfcbe03572
@ -44,7 +44,7 @@ interface
|
|||||||
uses
|
uses
|
||||||
cutils,cclasses,cfileutl,
|
cutils,cclasses,cfileutl,
|
||||||
globtype,finput,ogbase,
|
globtype,finput,ogbase,
|
||||||
symbase,symsym,
|
symbase,symconst,symsym,symcpu,
|
||||||
wpobase,
|
wpobase,
|
||||||
aasmbase,aasmtai,aasmdata;
|
aasmbase,aasmtai,aasmdata;
|
||||||
|
|
||||||
@ -143,6 +143,9 @@ interface
|
|||||||
deflist,
|
deflist,
|
||||||
symlist : TFPObjectList;
|
symlist : TFPObjectList;
|
||||||
ptrdefs : THashSet; { list of pointerdefs created in this module so we can reuse them (not saved/restored) }
|
ptrdefs : THashSet; { list of pointerdefs created in this module so we can reuse them (not saved/restored) }
|
||||||
|
{$ifdef x86}
|
||||||
|
x86ptrdefs : array [tx86pointertyp] of THashSet;
|
||||||
|
{$endif x86}
|
||||||
arraydefs : THashSet; { list of single-element-arraydefs created in this module so we can reuse them (not saved/restored) }
|
arraydefs : THashSet; { list of single-element-arraydefs created in this module so we can reuse them (not saved/restored) }
|
||||||
ansistrdef : tobject; { an ansistring def redefined for the current module }
|
ansistrdef : tobject; { an ansistring def redefined for the current module }
|
||||||
wpoinfo : tunitwpoinfobase; { whole program optimization-related information that is generated during the current run for this unit }
|
wpoinfo : tunitwpoinfobase; { whole program optimization-related information that is generated during the current run for this unit }
|
||||||
@ -514,6 +517,9 @@ implementation
|
|||||||
var
|
var
|
||||||
n:string;
|
n:string;
|
||||||
fn:TPathStr;
|
fn:TPathStr;
|
||||||
|
{$ifdef x86}
|
||||||
|
ptrtyp:tx86pointertyp;
|
||||||
|
{$endif x86}
|
||||||
begin
|
begin
|
||||||
if amodulename='' then
|
if amodulename='' then
|
||||||
n:=ChangeFileExt(ExtractFileName(afilename),'')
|
n:=ChangeFileExt(ExtractFileName(afilename),'')
|
||||||
@ -567,7 +573,13 @@ implementation
|
|||||||
derefdataintflen:=0;
|
derefdataintflen:=0;
|
||||||
deflist:=TFPObjectList.Create(false);
|
deflist:=TFPObjectList.Create(false);
|
||||||
symlist:=TFPObjectList.Create(false);
|
symlist:=TFPObjectList.Create(false);
|
||||||
|
{$ifdef x86}
|
||||||
|
for ptrtyp in tx86pointertyp do
|
||||||
|
x86ptrdefs[ptrtyp]:=THashSet.Create(64,true,false);
|
||||||
|
ptrdefs:=x86ptrdefs[tcpupointerdefclass(cpointerdef).default_x86_data_pointer_type];
|
||||||
|
{$else x86}
|
||||||
ptrdefs:=THashSet.Create(64,true,false);
|
ptrdefs:=THashSet.Create(64,true,false);
|
||||||
|
{$endif x86}
|
||||||
arraydefs:=THashSet.Create(64,true,false);
|
arraydefs:=THashSet.Create(64,true,false);
|
||||||
ansistrdef:=nil;
|
ansistrdef:=nil;
|
||||||
wpoinfo:=nil;
|
wpoinfo:=nil;
|
||||||
@ -610,6 +622,9 @@ implementation
|
|||||||
var
|
var
|
||||||
i : longint;
|
i : longint;
|
||||||
current_debuginfo_reset : boolean;
|
current_debuginfo_reset : boolean;
|
||||||
|
{$ifdef x86}
|
||||||
|
ptrtyp : tx86pointertyp;
|
||||||
|
{$endif x86}
|
||||||
begin
|
begin
|
||||||
if assigned(unitmap) then
|
if assigned(unitmap) then
|
||||||
freemem(unitmap);
|
freemem(unitmap);
|
||||||
@ -681,7 +696,13 @@ implementation
|
|||||||
derefdata.free;
|
derefdata.free;
|
||||||
deflist.free;
|
deflist.free;
|
||||||
symlist.free;
|
symlist.free;
|
||||||
|
{$ifdef x86}
|
||||||
|
for ptrtyp in tx86pointertyp do
|
||||||
|
x86ptrdefs[ptrtyp].free;
|
||||||
|
ptrdefs:=nil;
|
||||||
|
{$else x86}
|
||||||
ptrdefs.free;
|
ptrdefs.free;
|
||||||
|
{$endif x86}
|
||||||
arraydefs.free;
|
arraydefs.free;
|
||||||
ansistrdef:=nil;
|
ansistrdef:=nil;
|
||||||
wpoinfo.free;
|
wpoinfo.free;
|
||||||
@ -701,6 +722,9 @@ implementation
|
|||||||
var
|
var
|
||||||
i : longint;
|
i : longint;
|
||||||
current_debuginfo_reset : boolean;
|
current_debuginfo_reset : boolean;
|
||||||
|
{$ifdef x86}
|
||||||
|
ptrtyp : tx86pointertyp;
|
||||||
|
{$endif x86}
|
||||||
begin
|
begin
|
||||||
if assigned(scanner) then
|
if assigned(scanner) then
|
||||||
begin
|
begin
|
||||||
@ -743,8 +767,17 @@ implementation
|
|||||||
deflist:=TFPObjectList.Create(false);
|
deflist:=TFPObjectList.Create(false);
|
||||||
symlist.free;
|
symlist.free;
|
||||||
symlist:=TFPObjectList.Create(false);
|
symlist:=TFPObjectList.Create(false);
|
||||||
|
{$ifdef x86}
|
||||||
|
for ptrtyp in tx86pointertyp do
|
||||||
|
begin
|
||||||
|
x86ptrdefs[ptrtyp].free;
|
||||||
|
x86ptrdefs[ptrtyp]:=THashSet.Create(64,true,false);
|
||||||
|
end;
|
||||||
|
ptrdefs:=x86ptrdefs[tcpupointerdefclass(cpointerdef).default_x86_data_pointer_type];
|
||||||
|
{$else x86}
|
||||||
ptrdefs.free;
|
ptrdefs.free;
|
||||||
ptrdefs:=THashSet.Create(64,true,false);
|
ptrdefs:=THashSet.Create(64,true,false);
|
||||||
|
{$endif x86}
|
||||||
arraydefs.free;
|
arraydefs.free;
|
||||||
arraydefs:=THashSet.Create(64,true,false);
|
arraydefs:=THashSet.Create(64,true,false);
|
||||||
wpoinfo.free;
|
wpoinfo.free;
|
||||||
|
@ -45,10 +45,41 @@ type
|
|||||||
end;
|
end;
|
||||||
tx86pointerdefclass = class of tx86pointerdef;
|
tx86pointerdefclass = class of tx86pointerdef;
|
||||||
|
|
||||||
|
{ returns a pointerdef for def, reusing an existing one in case it exists
|
||||||
|
in the current module }
|
||||||
|
function getx86pointerdef(def: tdef;x86typ:tx86pointertyp): tpointerdef;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
globals, verbose;
|
globals, verbose, cclasses,
|
||||||
|
symbase, fmodule;
|
||||||
|
|
||||||
|
function getx86pointerdef(def: tdef;x86typ:tx86pointertyp): tpointerdef;
|
||||||
|
var
|
||||||
|
res: PHashSetItem;
|
||||||
|
oldsymtablestack: tsymtablestack;
|
||||||
|
begin
|
||||||
|
if not assigned(current_module) then
|
||||||
|
internalerror(2011071101);
|
||||||
|
res:=current_module.x86ptrdefs[x86typ].FindOrAdd(@def,sizeof(def));
|
||||||
|
if not assigned(res^.Data) then
|
||||||
|
begin
|
||||||
|
{ since these pointerdefs can be reused anywhere in the current
|
||||||
|
unit, add them to the global/staticsymtable }
|
||||||
|
oldsymtablestack:=symtablestack;
|
||||||
|
{ do not simply push/pop current_module.localsymtable, because
|
||||||
|
that can have side-effects (e.g., it removes helpers) }
|
||||||
|
symtablestack:=nil;
|
||||||
|
res^.Data:=tx86pointerdefclass(cpointerdef).createx86(def,x86typ);
|
||||||
|
if assigned(current_module.localsymtable) then
|
||||||
|
current_module.localsymtable.insertdef(tdef(res^.Data))
|
||||||
|
else
|
||||||
|
current_module.globalsymtable.insertdef(tdef(res^.Data));
|
||||||
|
symtablestack:=oldsymtablestack;
|
||||||
|
end;
|
||||||
|
result:=tpointerdef(res^.Data);
|
||||||
|
end;
|
||||||
|
|
||||||
{****************************************************************************
|
{****************************************************************************
|
||||||
tx86pointerdef
|
tx86pointerdef
|
||||||
|
Loading…
Reference in New Issue
Block a user