mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-15 16:09:27 +02:00
+ 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:
parent
560fe24c44
commit
be2f63aa97
@ -187,12 +187,21 @@ interface
|
|||||||
TAsmLabel = class(TAsmSymbol)
|
TAsmLabel = class(TAsmSymbol)
|
||||||
protected
|
protected
|
||||||
function getname:TSymStr;override;
|
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
|
public
|
||||||
|
{$pop}
|
||||||
labelnr : longint;
|
labelnr : longint;
|
||||||
labeltype : TAsmLabelType;
|
labeltype : TAsmLabelType;
|
||||||
is_set : boolean;
|
is_set : boolean;
|
||||||
constructor Createlocal(AList:TFPHashObjectList;nr:longint;ltyp:TAsmLabelType);
|
constructor Createlocal(AList: TFPHashObjectList; nr: longint; ltyp: TAsmLabelType);
|
||||||
constructor Createglobal(AList:TFPHashObjectList;const modulename:TSymStr;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;
|
function getaltcopy(AList:TFPHashObjectList;altnr: longint): TAsmSymbol; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -419,22 +428,15 @@ implementation
|
|||||||
TAsmLabel
|
TAsmLabel
|
||||||
*****************************************************************************}
|
*****************************************************************************}
|
||||||
|
|
||||||
constructor TAsmLabel.Createlocal(AList:TFPHashObjectList;nr:longint;ltyp:TAsmLabelType);
|
constructor TAsmLabel.Createlocal(AList: TFPHashObjectList; nr: longint; ltyp: TAsmLabelType);
|
||||||
var
|
|
||||||
asmtyp: TAsmsymtype;
|
|
||||||
begin
|
begin
|
||||||
case ltyp of
|
create_non_global(AList,nr,ltyp,target_asm.labelprefix);
|
||||||
alt_addr:
|
end;
|
||||||
asmtyp:=AT_ADDR;
|
|
||||||
alt_data:
|
|
||||||
asmtyp:=AT_DATA;
|
constructor TAsmLabel.Createstatic(AList:TFPHashObjectList;nr:longint;ltyp:TAsmLabelType);
|
||||||
else
|
begin
|
||||||
asmtyp:=AT_LABEL;
|
create_non_global(AList,nr,ltyp,'_$$fpclocal$_l');
|
||||||
end;
|
|
||||||
inherited Create(AList,target_asm.labelprefix+asmlabeltypeprefix[ltyp]+tostr(nr),AB_LOCAL,asmtyp);
|
|
||||||
labelnr:=nr;
|
|
||||||
labeltype:=ltyp;
|
|
||||||
is_set:=false;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -474,8 +476,28 @@ implementation
|
|||||||
increfs;
|
increfs;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure default_global_used;
|
|
||||||
begin
|
constructor TAsmLabel.create_non_global(AList: TFPHashObjectList; nr: longint; ltyp: TAsmLabelType; const prefix: TSymStr);
|
||||||
end;
|
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.
|
end.
|
||||||
|
@ -173,8 +173,17 @@ interface
|
|||||||
procedure getjumplabel(out l : TAsmLabel);
|
procedure getjumplabel(out l : TAsmLabel);
|
||||||
procedure getglobaljumplabel(out l : TAsmLabel);
|
procedure getglobaljumplabel(out l : TAsmLabel);
|
||||||
procedure getaddrlabel(out l : TAsmLabel);
|
procedure getaddrlabel(out l : TAsmLabel);
|
||||||
procedure getlocaldatalabel(out l : TAsmLabel);
|
{ visible from outside current object }
|
||||||
procedure getglobaldatalabel(out l : TAsmLabel);
|
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 }
|
{ generate an alternative (duplicate) symbol }
|
||||||
procedure GenerateAltSymbol(p:TAsmSymbol);
|
procedure GenerateAltSymbol(p:TAsmSymbol);
|
||||||
procedure ResetAltSymbols;
|
procedure ResetAltSymbols;
|
||||||
@ -519,6 +528,13 @@ implementation
|
|||||||
end;
|
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);
|
procedure TAsmData.getlocaldatalabel(out l: TAsmLabel);
|
||||||
begin
|
begin
|
||||||
l:=TAsmLabel.createlocal(AsmSymbolDict,FNextLabelNr[alt_data],alt_data);
|
l:=TAsmLabel.createlocal(AsmSymbolDict,FNextLabelNr[alt_data],alt_data);
|
||||||
|
Loading…
Reference in New Issue
Block a user