mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-11 10:58:23 +02:00
* specify the asm section type when creating an LLVM declaration
o in case it's a read-only section, mark the data as "constant" git-svn-id: branches/hlcgllvm@28155 -
This commit is contained in:
parent
394dfdd220
commit
eef6f05697
@ -149,7 +149,8 @@ interface
|
||||
initdata: tasmlist;
|
||||
namesym: tasmsymbol;
|
||||
def: tdef;
|
||||
constructor create(_namesym: tasmsymbol; _def: tdef; _initdata: tasmlist);
|
||||
sec: TAsmSectiontype;
|
||||
constructor create(_namesym: tasmsymbol; _def: tdef; _initdata: tasmlist; _sec: tasmsectiontype);
|
||||
destructor destroy; override;
|
||||
end;
|
||||
|
||||
@ -175,13 +176,14 @@ uses
|
||||
|
||||
{ taillvmprocdecl }
|
||||
|
||||
constructor taillvmdecl.create(_namesym: tasmsymbol; _def: tdef; _initdata: tasmlist);
|
||||
constructor taillvmdecl.create(_namesym: tasmsymbol; _def: tdef; _initdata: tasmlist; _sec: tasmsectiontype);
|
||||
begin
|
||||
inherited create;
|
||||
typ:=ait_llvmdecl;
|
||||
namesym:=_namesym;
|
||||
def:=_def;
|
||||
initdata:=_initdata;
|
||||
sec:=_sec;
|
||||
end;
|
||||
|
||||
destructor taillvmdecl.destroy;
|
||||
@ -223,7 +225,7 @@ uses
|
||||
internalerror(2014020701);
|
||||
def:=tpointerdef(def).pointeddef;
|
||||
end;
|
||||
current_asmdata.AsmLists[al_imports].concat(taillvmdecl.create(ref.symbol,def,nil));
|
||||
current_asmdata.AsmLists[al_imports].concat(taillvmdecl.create(ref.symbol,def,nil,sec_none));
|
||||
ref.symbol.declared:=true;
|
||||
end;
|
||||
|
||||
|
@ -885,20 +885,26 @@ implementation
|
||||
asmwrite(taillvmdecl(hp).namesym.name);
|
||||
case taillvmdecl(hp).namesym.bind of
|
||||
AB_EXTERNAL:
|
||||
asmwrite(' = external global ');
|
||||
asmwrite(' = external ');
|
||||
AB_COMMON:
|
||||
asmwrite(' = common global ');
|
||||
asmwrite(' = common ');
|
||||
AB_LOCAL:
|
||||
asmwrite(' = internal global ');
|
||||
asmwrite(' = internal ');
|
||||
AB_GLOBAL:
|
||||
asmwrite(' = global ');
|
||||
asmwrite(' = ');
|
||||
AB_WEAK_EXTERNAL:
|
||||
asmwrite(' = extern_weak global ');
|
||||
asmwrite(' = extern_weak ');
|
||||
AB_PRIVATE_EXTERN:
|
||||
asmwrite('= linker_private global ');
|
||||
asmwrite('= linker_private ');
|
||||
else
|
||||
internalerror(2014020104);
|
||||
end;
|
||||
{ todo: handle more different section types (mainly
|
||||
Objective-C }
|
||||
if taillvmdecl(hp).sec in [sec_rodata,sec_rodata_norel] then
|
||||
asmwrite('unnamed_addr constant ')
|
||||
else
|
||||
asmwrite('global ');
|
||||
if not assigned(taillvmdecl(hp).initdata) then
|
||||
begin
|
||||
asmwrite(llvmencodetype(taillvmdecl(hp).def));
|
||||
|
@ -307,7 +307,7 @@ implementation
|
||||
begin
|
||||
asmsym:=current_asmdata.RefAsmSymbol(pd.mangledname);
|
||||
if not asmsym.declared then
|
||||
current_asmdata.AsmLists[al_imports].Concat(taillvmdecl.create(asmsym,pd,nil));
|
||||
current_asmdata.AsmLists[al_imports].Concat(taillvmdecl.create(asmsym,pd,nil,sec_code));
|
||||
end;
|
||||
callparas:=tfplist.Create;
|
||||
for i:=0 to high(paras) do
|
||||
@ -940,7 +940,7 @@ implementation
|
||||
list.concat(taillvmalias.create(asmsym,item.str,current_procinfo.procdef,llv_default,lll_default));
|
||||
item:=TCmdStrListItem(item.next);
|
||||
end;
|
||||
list.concat(taillvmdecl.create(asmsym,current_procinfo.procdef,nil));
|
||||
list.concat(taillvmdecl.create(asmsym,current_procinfo.procdef,nil,sec_code));
|
||||
end;
|
||||
|
||||
|
||||
|
@ -90,7 +90,7 @@ implementation
|
||||
{ llvm declaration with as initialisation data all the elements from the
|
||||
original asmlist }
|
||||
{ TODO: propagate data/rodata different ("constant") }
|
||||
newasmlist.concat(taillvmdecl.create(sym,def,fasmlist));
|
||||
newasmlist.concat(taillvmdecl.create(sym,def,fasmlist,section));
|
||||
fasmlist:=newasmlist;
|
||||
end;
|
||||
|
||||
|
@ -62,7 +62,7 @@ implementation
|
||||
asmsym:=current_asmdata.DefineAsmSymbol(sym.mangledname,AB_GLOBAL,AT_DATA)
|
||||
else
|
||||
asmsym:=current_asmdata.DefineAsmSymbol(sym.mangledname,AB_LOCAL,AT_DATA);
|
||||
list.concat(taillvmdecl.Create(asmsym,sym.vardef,nil));
|
||||
list.concat(taillvmdecl.Create(asmsym,sym.vardef,nil,sec_data));
|
||||
end;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user