diff --git a/compiler/aasmdata.pas b/compiler/aasmdata.pas index a2441796ef..35a61a401c 100644 --- a/compiler/aasmdata.pas +++ b/compiler/aasmdata.pas @@ -89,7 +89,8 @@ interface sp_objcvartypes, sp_objcprotocolrefs, sp_varsets, - sp_floats + sp_floats, + sp_guids ); const diff --git a/compiler/ncgcon.pas b/compiler/ncgcon.pas index 1b4703bf4d..8fb1c6c660 100644 --- a/compiler/ncgcon.pas +++ b/compiler/ncgcon.pas @@ -525,21 +525,35 @@ implementation procedure tcgguidconstnode.pass_generate_code; var - tmplabel : TAsmLabel; - i : integer; + lastlabel : tasmlabel; + i : longint; + entry : PHashSetItem; begin location_reset_ref(location,LOC_CREFERENCE,OS_NO,const_align(16)); - { label for GUID } - current_asmdata.getdatalabel(tmplabel); - maybe_new_object_file(current_asmdata.asmlists[al_typedconsts]); - new_section(current_asmdata.asmlists[al_typedconsts],sec_rodata_norel,tmplabel.name,const_align(16)); - current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(tmplabel)); - 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])); - location.reference.symbol:=tmplabel; + lastlabel:=nil; + { const already used ? } + if not assigned(lab_set) then + begin + entry := current_asmdata.ConstPools[sp_guids].FindOrAdd(@value,sizeof(value)); + lab_set := TAsmLabel(entry^.Data); // is it needed anymore? + + { :-(, we must generate a new entry } + if not assigned(entry^.Data) then + begin + 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; diff --git a/compiler/ncon.pas b/compiler/ncon.pas index 23d2827b51..22a9cd8e47 100644 --- a/compiler/ncon.pas +++ b/compiler/ncon.pas @@ -168,6 +168,7 @@ interface tguidconstnode = class(tnode) value : tguid; + lab_set : tasmsymbol; constructor create(const g:tguid);virtual; constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override; procedure ppuwrite(ppufile:tcompilerppufile);override; @@ -1144,6 +1145,7 @@ implementation value_set:=nil; end; + destructor tsetconstnode.destroy; begin if assigned(value_set) then @@ -1213,12 +1215,9 @@ implementation end; - function tsetconstnode.dogetcopy : tnode; - var n : tsetconstnode; - begin n:=tsetconstnode(inherited dogetcopy); if assigned(value_set) then @@ -1233,12 +1232,14 @@ implementation dogetcopy:=n; end; + function tsetconstnode.pass_typecheck:tnode; begin result:=nil; resultdef:=typedef; end; + function tsetconstnode.pass_1 : tnode; begin result:=nil; @@ -1307,22 +1308,23 @@ implementation function tguidconstnode.dogetcopy : tnode; - var n : tguidconstnode; - begin n:=tguidconstnode(inherited dogetcopy); n.value:=value; + n.lab_set:=lab_set; dogetcopy:=n; end; + function tguidconstnode.pass_typecheck:tnode; begin result:=nil; resultdef:=rec_tguid; end; + function tguidconstnode.pass_1 : tnode; begin result:=nil; @@ -1332,6 +1334,7 @@ implementation include(current_procinfo.flags,pi_needs_got); end; + function tguidconstnode.docompare(p: tnode): boolean; begin docompare :=