+ put guids in a constant pool as well

git-svn-id: trunk@24061 -
This commit is contained in:
florian 2013-03-29 18:48:55 +00:00
parent e4949e3044
commit 9375529430
3 changed files with 37 additions and 19 deletions

View File

@ -89,7 +89,8 @@ interface
sp_objcvartypes, sp_objcvartypes,
sp_objcprotocolrefs, sp_objcprotocolrefs,
sp_varsets, sp_varsets,
sp_floats sp_floats,
sp_guids
); );
const const

View File

@ -525,21 +525,35 @@ implementation
procedure tcgguidconstnode.pass_generate_code; procedure tcgguidconstnode.pass_generate_code;
var var
tmplabel : TAsmLabel; lastlabel : tasmlabel;
i : integer; i : longint;
entry : PHashSetItem;
begin begin
location_reset_ref(location,LOC_CREFERENCE,OS_NO,const_align(16)); location_reset_ref(location,LOC_CREFERENCE,OS_NO,const_align(16));
{ label for GUID } lastlabel:=nil;
current_asmdata.getdatalabel(tmplabel); { const already used ? }
maybe_new_object_file(current_asmdata.asmlists[al_typedconsts]); if not assigned(lab_set) then
new_section(current_asmdata.asmlists[al_typedconsts],sec_rodata_norel,tmplabel.name,const_align(16)); begin
current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(tmplabel)); entry := current_asmdata.ConstPools[sp_guids].FindOrAdd(@value,sizeof(value));
current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_32bit(longint(value.D1))); lab_set := TAsmLabel(entry^.Data); // is it needed anymore?
current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_16bit(value.D2));
current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_16bit(value.D3)); { :-(, we must generate a new entry }
for i:=low(value.D4) to high(value.D4) do if not assigned(entry^.Data) then
current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_8bit(value.D4[i])); begin
location.reference.symbol:=tmplabel; current_asmdata.getdatalabel(lastlabel);
lab_set:=lastlabel;
entry^.Data:=lastlabel;
maybe_new_object_file(current_asmdata.asmlists[al_typedconsts]);
new_section(current_asmdata.asmlists[al_typedconsts],sec_rodata_norel,lastlabel.name,const_align(16));
current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(lastlabel));
current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_32bit(longint(value.D1)));
current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_16bit(value.D2));
current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_16bit(value.D3));
for i:=low(value.D4) to high(value.D4) do
current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_8bit(value.D4[i]));
end;
end;
location.reference.symbol:=lab_set;
end; end;

View File

@ -168,6 +168,7 @@ interface
tguidconstnode = class(tnode) tguidconstnode = class(tnode)
value : tguid; value : tguid;
lab_set : tasmsymbol;
constructor create(const g:tguid);virtual; constructor create(const g:tguid);virtual;
constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override; constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
procedure ppuwrite(ppufile:tcompilerppufile);override; procedure ppuwrite(ppufile:tcompilerppufile);override;
@ -1144,6 +1145,7 @@ implementation
value_set:=nil; value_set:=nil;
end; end;
destructor tsetconstnode.destroy; destructor tsetconstnode.destroy;
begin begin
if assigned(value_set) then if assigned(value_set) then
@ -1213,12 +1215,9 @@ implementation
end; end;
function tsetconstnode.dogetcopy : tnode; function tsetconstnode.dogetcopy : tnode;
var var
n : tsetconstnode; n : tsetconstnode;
begin begin
n:=tsetconstnode(inherited dogetcopy); n:=tsetconstnode(inherited dogetcopy);
if assigned(value_set) then if assigned(value_set) then
@ -1233,12 +1232,14 @@ implementation
dogetcopy:=n; dogetcopy:=n;
end; end;
function tsetconstnode.pass_typecheck:tnode; function tsetconstnode.pass_typecheck:tnode;
begin begin
result:=nil; result:=nil;
resultdef:=typedef; resultdef:=typedef;
end; end;
function tsetconstnode.pass_1 : tnode; function tsetconstnode.pass_1 : tnode;
begin begin
result:=nil; result:=nil;
@ -1307,22 +1308,23 @@ implementation
function tguidconstnode.dogetcopy : tnode; function tguidconstnode.dogetcopy : tnode;
var var
n : tguidconstnode; n : tguidconstnode;
begin begin
n:=tguidconstnode(inherited dogetcopy); n:=tguidconstnode(inherited dogetcopy);
n.value:=value; n.value:=value;
n.lab_set:=lab_set;
dogetcopy:=n; dogetcopy:=n;
end; end;
function tguidconstnode.pass_typecheck:tnode; function tguidconstnode.pass_typecheck:tnode;
begin begin
result:=nil; result:=nil;
resultdef:=rec_tguid; resultdef:=rec_tguid;
end; end;
function tguidconstnode.pass_1 : tnode; function tguidconstnode.pass_1 : tnode;
begin begin
result:=nil; result:=nil;
@ -1332,6 +1334,7 @@ implementation
include(current_procinfo.flags,pi_needs_got); include(current_procinfo.flags,pi_needs_got);
end; end;
function tguidconstnode.docompare(p: tnode): boolean; function tguidconstnode.docompare(p: tnode): boolean;
begin begin
docompare := docompare :=