From be2f63aa977b641bdb2a18de780527ac1b7ac617 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Fri, 27 Mar 2015 21:25:40 +0000 Subject: [PATCH] + tasmlabel.createstatic() constructor for creating static data labels (object-local, but not starting with (.)L, so they're still treated as the start of a subsection by Darwin's linker when dead-stripping) + tasmdata.getstaticdatalabel() that uses the above git-svn-id: branches/hlcgllvm@30338 - --- compiler/aasmbase.pas | 62 +++++++++++++++++++++++++++++-------------- compiler/aasmdata.pas | 18 ++++++++++++- 2 files changed, 59 insertions(+), 21 deletions(-) diff --git a/compiler/aasmbase.pas b/compiler/aasmbase.pas index 73aeb7b915..8602dd432d 100644 --- a/compiler/aasmbase.pas +++ b/compiler/aasmbase.pas @@ -187,12 +187,21 @@ interface TAsmLabel = class(TAsmSymbol) protected function getname:TSymStr;override; + {$push}{$warnings off} + { new visibility section to let "warnings off" take effect } + protected + { this constructor is only supposed to be used internally by + createstatoc/createlocal -> disable warning that constructors should + be public } + constructor create_non_global(AList: TFPHashObjectList; nr: longint; ltyp: TAsmLabelType; const prefix: TSymStr); public + {$pop} labelnr : longint; labeltype : TAsmLabelType; is_set : boolean; - constructor Createlocal(AList:TFPHashObjectList;nr:longint;ltyp:TAsmLabelType); - constructor Createglobal(AList:TFPHashObjectList;const modulename:TSymStr;nr:longint;ltyp:TAsmLabelType); + constructor Createlocal(AList: TFPHashObjectList; nr: longint; ltyp: TAsmLabelType); + constructor Createstatic(AList: TFPHashObjectList; nr: longint; ltyp: TAsmLabelType); + constructor Createglobal(AList: TFPHashObjectList; const modulename: TSymStr; nr: longint; ltyp: TAsmLabelType); function getaltcopy(AList:TFPHashObjectList;altnr: longint): TAsmSymbol; override; end; @@ -419,22 +428,15 @@ implementation TAsmLabel *****************************************************************************} - constructor TAsmLabel.Createlocal(AList:TFPHashObjectList;nr:longint;ltyp:TAsmLabelType); - var - asmtyp: TAsmsymtype; + constructor TAsmLabel.Createlocal(AList: TFPHashObjectList; nr: longint; ltyp: TAsmLabelType); begin - case ltyp of - alt_addr: - asmtyp:=AT_ADDR; - alt_data: - asmtyp:=AT_DATA; - else - asmtyp:=AT_LABEL; - end; - inherited Create(AList,target_asm.labelprefix+asmlabeltypeprefix[ltyp]+tostr(nr),AB_LOCAL,asmtyp); - labelnr:=nr; - labeltype:=ltyp; - is_set:=false; + create_non_global(AList,nr,ltyp,target_asm.labelprefix); + end; + + + constructor TAsmLabel.Createstatic(AList:TFPHashObjectList;nr:longint;ltyp:TAsmLabelType); + begin + create_non_global(AList,nr,ltyp,'_$$fpclocal$_l'); end; @@ -474,8 +476,28 @@ implementation increfs; end; - procedure default_global_used; - begin - end; + + constructor TAsmLabel.create_non_global(AList: TFPHashObjectList; nr: longint; ltyp: TAsmLabelType; const prefix: TSymStr); + var + asmtyp: TAsmsymtype; + begin + case ltyp of + alt_addr: + asmtyp:=AT_ADDR; + alt_data: + asmtyp:=AT_DATA; + else + asmtyp:=AT_LABEL; + end; + inherited Create(AList,prefix+asmlabeltypeprefix[ltyp]+tostr(nr),AB_LOCAL,asmtyp); + labelnr:=nr; + labeltype:=ltyp; + is_set:=false; + end; + + + procedure default_global_used; + begin + end; end. diff --git a/compiler/aasmdata.pas b/compiler/aasmdata.pas index 821888b754..e743212aa6 100644 --- a/compiler/aasmdata.pas +++ b/compiler/aasmdata.pas @@ -173,8 +173,17 @@ interface procedure getjumplabel(out l : TAsmLabel); procedure getglobaljumplabel(out l : TAsmLabel); procedure getaddrlabel(out l : TAsmLabel); - procedure getlocaldatalabel(out l : TAsmLabel); + { visible from outside current object } procedure getglobaldatalabel(out l : TAsmLabel); + { visible only inside current object, but doesn't start with + target_asm.label_prefix (treated the Darwin linker as the start of a + dead-strippable data block) } + procedure getstaticdatalabel(out l : TAsmLabel); + { visible only inside the current object and does start with + target_asm.label_prefix (not treated by the Darwin linker as the start + of a dead-strippable data block, and references to such labels are + also ignored to determine whether a data block should be live) } + procedure getlocaldatalabel(out l : TAsmLabel); { generate an alternative (duplicate) symbol } procedure GenerateAltSymbol(p:TAsmSymbol); procedure ResetAltSymbols; @@ -519,6 +528,13 @@ implementation end; + procedure TAsmData.getstaticdatalabel(out l : TAsmLabel); + begin + l:=TAsmLabel.createstatic(AsmSymbolDict,FNextLabelNr[alt_data],alt_data); + inc(FNextLabelNr[alt_data]); + end; + + procedure TAsmData.getlocaldatalabel(out l: TAsmLabel); begin l:=TAsmLabel.createlocal(AsmSymbolDict,FNextLabelNr[alt_data],alt_data);