mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 02:45:58 +02:00
* split up specifying the type of the section of a typed constant and whether
it should be put in a new section git-svn-id: branches/hlcgllvm@28753 -
This commit is contained in:
parent
6677e698cd
commit
210b532832
@ -98,6 +98,15 @@ type
|
|||||||
ofs: asizeint;
|
ofs: asizeint;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ flags for the finalisation of the typed const builder asmlist }
|
||||||
|
ttcasmlistoption = (
|
||||||
|
{ the tasmsymbol is a tasmlabel }
|
||||||
|
tcalo_is_lab,
|
||||||
|
{ start a new section }
|
||||||
|
tcalo_new_section
|
||||||
|
);
|
||||||
|
ttcasmlistoptions = set of ttcasmlistoption;
|
||||||
|
|
||||||
{ Warning: never directly create a ttai_typedconstbuilder instance,
|
{ Warning: never directly create a ttai_typedconstbuilder instance,
|
||||||
instead create a cai_typedconstbuilder (this class can be overridden) }
|
instead create a cai_typedconstbuilder (this class can be overridden) }
|
||||||
ttai_lowleveltypedconstbuilder = class abstract
|
ttai_lowleveltypedconstbuilder = class abstract
|
||||||
@ -115,7 +124,7 @@ type
|
|||||||
platform }
|
platform }
|
||||||
function aggregate_kind(def: tdef): ttypedconstkind; virtual;
|
function aggregate_kind(def: tdef): ttypedconstkind; virtual;
|
||||||
{ finalize the asmlist: add the necessary symbols etc }
|
{ finalize the asmlist: add the necessary symbols etc }
|
||||||
procedure finalize_asmlist(sym: tasmsymbol; def: tdef; section: TAsmSectiontype; const secname: TSymStr; alignment: shortint; lab: boolean); virtual;
|
procedure finalize_asmlist(sym: tasmsymbol; def: tdef; section: TAsmSectiontype; const secname: TSymStr; alignment: shortint; const options: ttcasmlistoptions); virtual;
|
||||||
public
|
public
|
||||||
constructor create; virtual;
|
constructor create; virtual;
|
||||||
destructor destroy; override;
|
destructor destroy; override;
|
||||||
@ -186,7 +195,7 @@ type
|
|||||||
This asmlist will be freed when the builder is destroyed, so add its
|
This asmlist will be freed when the builder is destroyed, so add its
|
||||||
contents to another list first. This property should only be accessed
|
contents to another list first. This property should only be accessed
|
||||||
once all data has been added. }
|
once all data has been added. }
|
||||||
function get_final_asmlist(sym: tasmsymbol; def: tdef; section: TAsmSectiontype; const secname: TSymStr; alignment: longint; lab: boolean): tasmlist;
|
function get_final_asmlist(sym: tasmsymbol; def: tdef; section: TAsmSectiontype; const secname: TSymStr; alignment: longint; const options: ttcasmlistoptions): tasmlist;
|
||||||
|
|
||||||
{ returns the offset of the string data relative to ansi/unicode/widestring
|
{ returns the offset of the string data relative to ansi/unicode/widestring
|
||||||
constant labels. On most platforms, this is 0 (with the header at a
|
constant labels. On most platforms, this is 0 (with the header at a
|
||||||
@ -413,19 +422,19 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure ttai_lowleveltypedconstbuilder.finalize_asmlist(sym: tasmsymbol; def: tdef; section: TAsmSectiontype; const secname: TSymStr; alignment: shortint; lab: boolean);
|
procedure ttai_lowleveltypedconstbuilder.finalize_asmlist(sym: tasmsymbol; def: tdef; section: TAsmSectiontype; const secname: TSymStr; alignment: shortint; const options: ttcasmlistoptions);
|
||||||
var
|
var
|
||||||
prelist: tasmlist;
|
prelist: tasmlist;
|
||||||
begin
|
begin
|
||||||
prelist:=tasmlist.create_without_marker;
|
prelist:=tasmlist.create_without_marker;
|
||||||
{ only now add items based on the symbolname, because it may be
|
{ only now add items based on the symbolname, because it may be
|
||||||
modified by the "section" specifier in case of a typed constant }
|
modified by the "section" specifier in case of a typed constant }
|
||||||
if section<>sec_none then
|
if tcalo_new_section in options then
|
||||||
begin
|
begin
|
||||||
maybe_new_object_file(prelist);
|
maybe_new_object_file(prelist);
|
||||||
new_section(prelist,section,secname,const_align(alignment));
|
new_section(prelist,section,secname,const_align(alignment));
|
||||||
end;
|
end;
|
||||||
if not lab then
|
if not(tcalo_is_lab in options) then
|
||||||
if sym.bind=AB_GLOBAL then
|
if sym.bind=AB_GLOBAL then
|
||||||
prelist.concat(tai_symbol.Create_Global(sym,0))
|
prelist.concat(tai_symbol.Create_Global(sym,0))
|
||||||
else
|
else
|
||||||
@ -441,11 +450,11 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function ttai_lowleveltypedconstbuilder.get_final_asmlist(sym: tasmsymbol; def: tdef; section: TAsmSectiontype; const secname: TSymStr; alignment: longint; lab: boolean): tasmlist;
|
function ttai_lowleveltypedconstbuilder.get_final_asmlist(sym: tasmsymbol; def: tdef; section: TAsmSectiontype; const secname: TSymStr; alignment: longint; const options: ttcasmlistoptions): tasmlist;
|
||||||
begin
|
begin
|
||||||
if not fasmlist_finalized then
|
if not fasmlist_finalized then
|
||||||
begin
|
begin
|
||||||
finalize_asmlist(sym,def,section,secname,alignment,lab);
|
finalize_asmlist(sym,def,section,secname,alignment,options);
|
||||||
fasmlist_finalized:=true;
|
fasmlist_finalized:=true;
|
||||||
end;
|
end;
|
||||||
result:=fasmlist;
|
result:=fasmlist;
|
||||||
@ -605,10 +614,10 @@ implementation
|
|||||||
var
|
var
|
||||||
s: PChar;
|
s: PChar;
|
||||||
startlab: tasmlabel;
|
startlab: tasmlabel;
|
||||||
sectype: TAsmSectiontype;
|
|
||||||
ansistrrecdef: trecorddef;
|
ansistrrecdef: trecorddef;
|
||||||
datadef: tdef;
|
datadef: tdef;
|
||||||
datatcb: ttai_lowleveltypedconstbuilder;
|
datatcb: ttai_lowleveltypedconstbuilder;
|
||||||
|
options: ttcasmlistoptions;
|
||||||
begin
|
begin
|
||||||
datatcb:=self.create;
|
datatcb:=self.create;
|
||||||
result:=datatcb.emit_string_const_common(list,st_ansistring,len,encoding,startlab);
|
result:=datatcb.emit_string_const_common(list,st_ansistring,len,encoding,startlab);
|
||||||
@ -622,11 +631,10 @@ implementation
|
|||||||
datatcb.emit_tai(tai_string.create_pchar(s,len+1),datadef);
|
datatcb.emit_tai(tai_string.create_pchar(s,len+1),datadef);
|
||||||
datatcb.maybe_end_aggregate(datadef);
|
datatcb.maybe_end_aggregate(datadef);
|
||||||
ansistrrecdef:=datatcb.end_anonymous_record;
|
ansistrrecdef:=datatcb.end_anonymous_record;
|
||||||
|
options:=[tcalo_is_lab];
|
||||||
if NewSection then
|
if NewSection then
|
||||||
sectype:=sec_rodata_norel
|
include(options,tcalo_new_section);
|
||||||
else
|
list.concatlist(datatcb.get_final_asmlist(startlab,ansistrrecdef,sec_rodata_norel,startlab.name,const_align(sizeof(pint)),options));
|
||||||
sectype:=sec_none;
|
|
||||||
list.concatlist(datatcb.get_final_asmlist(startlab,ansistrrecdef,sectype,startlab.name,const_align(sizeof(pint)),true));
|
|
||||||
datatcb.free;
|
datatcb.free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -677,7 +685,7 @@ implementation
|
|||||||
else
|
else
|
||||||
{ code generation for other sizes must be written }
|
{ code generation for other sizes must be written }
|
||||||
internalerror(200904271);
|
internalerror(200904271);
|
||||||
list.concatlist(datatcb.get_final_asmlist(startlab,uniwidestrrecdef,sec_rodata_norel,startlab.name,const_align(sizeof(pint)),true));
|
list.concatlist(datatcb.get_final_asmlist(startlab,uniwidestrrecdef,sec_rodata_norel,startlab.name,const_align(sizeof(pint)),[tcalo_is_lab,tcalo_new_section]));
|
||||||
datatcb.free;
|
datatcb.free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ interface
|
|||||||
flast_added_tai: tai;
|
flast_added_tai: tai;
|
||||||
fqueued_tai_opidx: longint;
|
fqueued_tai_opidx: longint;
|
||||||
|
|
||||||
procedure finalize_asmlist(sym: tasmsymbol; def: tdef; section: TAsmSectiontype; const secname: TSymStr; alignment: shortint; lab: boolean); override;
|
procedure finalize_asmlist(sym: tasmsymbol; def: tdef; section: TAsmSectiontype; const secname: TSymStr; alignment: shortint; const options: ttcasmlistoptions); override;
|
||||||
{ outerai: the ai that should become fqueued_tai in case it's still nil,
|
{ outerai: the ai that should become fqueued_tai in case it's still nil,
|
||||||
or that should be filled in the fqueued_tai_opidx of the current
|
or that should be filled in the fqueued_tai_opidx of the current
|
||||||
fqueued_tai if it's not nil
|
fqueued_tai if it's not nil
|
||||||
@ -87,7 +87,7 @@ implementation
|
|||||||
cpubase,llvmbase,
|
cpubase,llvmbase,
|
||||||
symbase,symtable,llvmdef,defutil;
|
symbase,symtable,llvmdef,defutil;
|
||||||
|
|
||||||
procedure tllvmtai_typedconstbuilder.finalize_asmlist(sym: tasmsymbol; def: tdef; section: TAsmSectiontype; const secname: TSymStr; alignment: shortint; lab: boolean);
|
procedure tllvmtai_typedconstbuilder.finalize_asmlist(sym: tasmsymbol; def: tdef; section: TAsmSectiontype; const secname: TSymStr; alignment: shortint; const options: ttcasmlistoptions);
|
||||||
var
|
var
|
||||||
newasmlist: tasmlist;
|
newasmlist: tasmlist;
|
||||||
begin
|
begin
|
||||||
|
@ -376,7 +376,7 @@ implementation
|
|||||||
datatcb.emit_tai(Tai_string.Create_pchar(pc,l+1),datadef);
|
datatcb.emit_tai(Tai_string.Create_pchar(pc,l+1),datadef);
|
||||||
datatcb.maybe_end_aggregate(datadef);
|
datatcb.maybe_end_aggregate(datadef);
|
||||||
current_asmdata.asmlists[al_typedconsts].concatList(
|
current_asmdata.asmlists[al_typedconsts].concatList(
|
||||||
datatcb.get_final_asmlist(lastlabel.lab,datadef,sec_rodata_norel,lastlabel.lab.name,const_align(sizeof(pint)),true)
|
datatcb.get_final_asmlist(lastlabel.lab,datadef,sec_rodata_norel,lastlabel.lab.name,const_align(sizeof(pint)),[tcalo_is_lab,tcalo_new_section])
|
||||||
);
|
);
|
||||||
datatcb.free;
|
datatcb.free;
|
||||||
end;
|
end;
|
||||||
@ -398,7 +398,7 @@ implementation
|
|||||||
datatcb.emit_tai(Tai_string.Create_pchar(pc,len+1),datadef);
|
datatcb.emit_tai(Tai_string.Create_pchar(pc,len+1),datadef);
|
||||||
datatcb.maybe_end_aggregate(datadef);
|
datatcb.maybe_end_aggregate(datadef);
|
||||||
current_asmdata.asmlists[al_typedconsts].concatList(
|
current_asmdata.asmlists[al_typedconsts].concatList(
|
||||||
datatcb.get_final_asmlist(lastlabel.lab,datadef,sec_rodata_norel,lastlabel.lab.name,const_align(sizeof(pint)),true)
|
datatcb.get_final_asmlist(lastlabel.lab,datadef,sec_rodata_norel,lastlabel.lab.name,const_align(sizeof(pint)),[tcalo_is_lab,tcalo_new_section])
|
||||||
);
|
);
|
||||||
datatcb.free;
|
datatcb.free;
|
||||||
end;
|
end;
|
||||||
|
@ -875,7 +875,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
|
|||||||
IncompatibleTypes(node.resultdef, def);
|
IncompatibleTypes(node.resultdef, def);
|
||||||
datadef:=getarraydef(cansichartype,1);
|
datadef:=getarraydef(cansichartype,1);
|
||||||
end;
|
end;
|
||||||
current_asmdata.asmlists[al_const].concatlist(datatcb.get_final_asmlist(ll,datadef,sec_rodata,ll.name,varalign,true));
|
current_asmdata.asmlists[al_const].concatlist(datatcb.get_final_asmlist(ll,datadef,sec_rodata,ll.name,varalign,[tcalo_is_lab,tcalo_new_section]));
|
||||||
datatcb.free;
|
datatcb.free;
|
||||||
{ we now emit the address of the first element of the array
|
{ we now emit the address of the first element of the array
|
||||||
containing the string data }
|
containing the string data }
|
||||||
@ -913,7 +913,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
|
|||||||
datatcb.emit_tai(Tai_const.Create_16bit(0),cwidechartype);
|
datatcb.emit_tai(Tai_const.Create_16bit(0),cwidechartype);
|
||||||
datatcb.maybe_end_aggregate(datadef);
|
datatcb.maybe_end_aggregate(datadef);
|
||||||
{ concat add the string data to the al_const asmlist }
|
{ concat add the string data to the al_const asmlist }
|
||||||
current_asmdata.asmlists[al_const].concatlist(datatcb.get_final_asmlist(ll,datadef,sec_rodata,ll.name,const_align(sizeof(pint)),true));
|
current_asmdata.asmlists[al_const].concatlist(datatcb.get_final_asmlist(ll,datadef,sec_rodata,ll.name,const_align(sizeof(pint)),[tcalo_is_lab,tcalo_new_section]));
|
||||||
datatcb.free;
|
datatcb.free;
|
||||||
{ we now emit the address of the first element of the array
|
{ we now emit the address of the first element of the array
|
||||||
containing the string data }
|
containing the string data }
|
||||||
@ -1136,7 +1136,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
|
|||||||
sec:=sec_data;
|
sec:=sec_data;
|
||||||
secname:=asmsym.Name;
|
secname:=asmsym.Name;
|
||||||
end;
|
end;
|
||||||
result:=ftcb.get_final_asmlist(asmsym,fsym.vardef,sec,secname,fsym.vardef.alignment,false);
|
result:=ftcb.get_final_asmlist(asmsym,fsym.vardef,sec,secname,fsym.vardef.alignment,[tcalo_new_section]);
|
||||||
if addstabx then
|
if addstabx then
|
||||||
begin
|
begin
|
||||||
{ see same code in ncgutil.insertbssdata }
|
{ see same code in ncgutil.insertbssdata }
|
||||||
|
Loading…
Reference in New Issue
Block a user