mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-01 21:30:35 +02:00
* converted tnodeutils.InsertRuntimeInits() to the high level typed const
builder git-svn-id: trunk@34443 -
This commit is contained in:
parent
8957d7b364
commit
473cec9d85
@ -207,7 +207,8 @@ interface
|
|||||||
sym: tsym;
|
sym: tsym;
|
||||||
offset: aint;
|
offset: aint;
|
||||||
datalabel: TAsmSymbol;
|
datalabel: TAsmSymbol;
|
||||||
constructor Create(asym: tsym; aoffset: aint; alabel: TAsmSymbol);
|
datadef: TDef;
|
||||||
|
constructor Create(asym: tsym; aoffset: aint; alabel: TAsmSymbol; alabeldef: tdef);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -287,12 +288,13 @@ implementation
|
|||||||
*****************************************************************************}
|
*****************************************************************************}
|
||||||
|
|
||||||
|
|
||||||
constructor TTCInitItem.Create(asym: tsym; aoffset: aint; alabel: TAsmSymbol);
|
constructor TTCInitItem.Create(asym: tsym; aoffset: aint; alabel: TAsmSymbol; alabeldef: tdef);
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
sym:=asym;
|
sym:=asym;
|
||||||
offset:=aoffset;
|
offset:=aoffset;
|
||||||
datalabel:=alabel;
|
datalabel:=alabel;
|
||||||
|
datadef:=alabeldef;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{*****************************************************************************
|
{*****************************************************************************
|
||||||
|
@ -1212,30 +1212,40 @@ implementation
|
|||||||
var
|
var
|
||||||
s: string;
|
s: string;
|
||||||
item: TTCInitItem;
|
item: TTCInitItem;
|
||||||
|
tcb: ttai_typedconstbuilder;
|
||||||
|
rawdatadef: tdef;
|
||||||
begin
|
begin
|
||||||
item:=TTCInitItem(list.First);
|
item:=TTCInitItem(list.First);
|
||||||
if item=nil then
|
if item=nil then
|
||||||
exit;
|
exit;
|
||||||
s:=make_mangledname(prefix,current_module.localsymtable,'');
|
s:=make_mangledname(prefix,current_module.localsymtable,'');
|
||||||
maybe_new_object_file(current_asmdata.asmlists[al_globals]);
|
tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable,tcalo_new_section]);
|
||||||
new_section(current_asmdata.asmlists[al_globals],sec_data,s,sizeof(pint));
|
tcb.begin_anonymous_record('',default_settings.packrecords,sizeof(pint),
|
||||||
{ TODO: def of the symbol to be fixed when this is converted to to the
|
targetinfos[target_info.system]^.alignment.recordalignmin,
|
||||||
typed constant builder }
|
targetinfos[target_info.system]^.alignment.maxCrecordalign );
|
||||||
current_asmdata.asmlists[al_globals].concat(Tai_symbol.Createname_global(s,AT_DATA,0,voidpointertype));
|
|
||||||
repeat
|
repeat
|
||||||
{ optimize away unused local/static symbols }
|
{ optimize away unused local/static symbols }
|
||||||
if (item.sym.refs>0) or (item.sym.owner.symtabletype=globalsymtable) then
|
if (item.sym.refs>0) or (item.sym.owner.symtabletype=globalsymtable) then
|
||||||
begin
|
begin
|
||||||
{ address to initialize }
|
{ address to initialize }
|
||||||
current_asmdata.asmlists[al_globals].concat(Tai_const.createname(item.sym.mangledname, item.offset));
|
tcb.queue_init(voidpointertype);
|
||||||
|
rawdatadef:=carraydef.getreusable(cansichartype,tstaticvarsym(item.sym).vardef.size);
|
||||||
|
tcb.queue_vecn(rawdatadef,item.offset);
|
||||||
|
tcb.queue_typeconvn(cpointerdef.getreusable(tstaticvarsym(item.sym).vardef),cpointerdef.getreusable(rawdatadef));
|
||||||
|
tcb.queue_emit_staticvar(tstaticvarsym(item.sym));
|
||||||
{ value with which to initialize }
|
{ value with which to initialize }
|
||||||
current_asmdata.asmlists[al_globals].concat(Tai_const.Create_sym(item.datalabel));
|
tcb.emit_tai(Tai_const.Create_sym(item.datalabel),item.datadef)
|
||||||
end;
|
end;
|
||||||
item:=TTCInitItem(item.Next);
|
item:=TTCInitItem(item.Next);
|
||||||
until item=nil;
|
until item=nil;
|
||||||
{ end-of-list marker }
|
{ end-of-list marker }
|
||||||
current_asmdata.asmlists[al_globals].concat(Tai_const.Create_sym(nil));
|
tcb.emit_tai(Tai_const.Create_nil_dataptr,voidpointertype);
|
||||||
current_asmdata.asmlists[al_globals].concat(Tai_symbol_end.Createname(s));
|
rawdatadef:=tcb.end_anonymous_record;
|
||||||
|
current_asmdata.asmlists[al_globals].concatList(
|
||||||
|
tcb.get_final_asmlist(
|
||||||
|
current_asmdata.DefineAsmSymbol(s,AB_GLOBAL,AT_DATA,rawdatadef),
|
||||||
|
rawdatadef,sec_data,s,sizeof(pint)));
|
||||||
|
tcb.free;
|
||||||
current_module.flags:=current_module.flags or unitflag;
|
current_module.flags:=current_module.flags or unitflag;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -511,7 +511,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
|
|||||||
begin
|
begin
|
||||||
current_asmdata.ResStrInits.Concat(
|
current_asmdata.ResStrInits.Concat(
|
||||||
TTCInitItem.Create(tcsym,curoffset,
|
TTCInitItem.Create(tcsym,curoffset,
|
||||||
current_asmdata.RefAsmSymbol(make_mangledname('RESSTR',hsym.owner,hsym.name),AT_DATA))
|
current_asmdata.RefAsmSymbol(make_mangledname('RESSTR',hsym.owner,hsym.name),AT_DATA),charpointertype)
|
||||||
);
|
);
|
||||||
Include(tcsym.varoptions,vo_force_finalize);
|
Include(tcsym.varoptions,vo_force_finalize);
|
||||||
end;
|
end;
|
||||||
@ -583,7 +583,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
|
|||||||
if ll.ofs<>0 then
|
if ll.ofs<>0 then
|
||||||
internalerror(2012051704);
|
internalerror(2012051704);
|
||||||
current_asmdata.WideInits.Concat(
|
current_asmdata.WideInits.Concat(
|
||||||
TTCInitItem.Create(tcsym,curoffset,ll.lab)
|
TTCInitItem.Create(tcsym,curoffset,ll.lab,widecharpointertype)
|
||||||
);
|
);
|
||||||
ll.lab:=nil;
|
ll.lab:=nil;
|
||||||
ll.ofs:=0;
|
ll.ofs:=0;
|
||||||
|
Loading…
Reference in New Issue
Block a user