+ 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 -
This commit is contained in:
Jonas Maebe 2015-03-27 21:25:40 +00:00
parent 560fe24c44
commit be2f63aa97
2 changed files with 59 additions and 21 deletions

View File

@ -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.

View File

@ -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);