* factored out writing the LLVM linkage flags, take into account version

differences and also write them for procdefs

git-svn-id: trunk@32882 -
This commit is contained in:
Jonas Maebe 2016-01-07 22:06:00 +00:00
parent d290ede5a6
commit 58ae32e2d1

View File

@ -87,7 +87,7 @@ implementation
fmodule,verbose, fmodule,verbose,
aasmcnst,symconst,symdef,symtable, aasmcnst,symconst,symdef,symtable,
llvmbase,aasmllvm,itllvm,llvmdef, llvmbase,aasmllvm,itllvm,llvmdef,
cgbase,cgutils,cpubase; cgbase,cgutils,cpubase,llvminfo;
const const
line_length = 70; line_length = 70;
@ -727,6 +727,32 @@ implementation
procedure TLLVMAssember.WriteTai(const replaceforbidden: boolean; const do_line: boolean; var InlineLevel: cardinal; var asmblock: boolean; var hp: tai); procedure TLLVMAssember.WriteTai(const replaceforbidden: boolean; const do_line: boolean; var InlineLevel: cardinal; var asmblock: boolean; var hp: tai);
procedure WriteLinkageVibilityFlags(bind: TAsmSymBind);
begin
case bind of
AB_EXTERNAL:
writer.AsmWrite(' external');
AB_COMMON:
writer.AsmWrite(' common');
AB_LOCAL:
writer.AsmWrite(' internal');
AB_GLOBAL:
writer.AsmWrite('');
AB_WEAK_EXTERNAL:
writer.AsmWrite(' extern_weak');
AB_PRIVATE_EXTERN:
begin
if not(llvmflag_linker_private in llvmversion_properties[current_settings.llvmversion]) then
writer.AsmWrite(' hidden')
else
writer.AsmWrite(' linker_private');
end
else
internalerror(2014020104);
end;
end;
procedure WriteFunctionFlags(pd: tprocdef); procedure WriteFunctionFlags(pd: tprocdef);
begin begin
if (pos('FPC_SETJMP',upper(pd.mangledname))<>0) or if (pos('FPC_SETJMP',upper(pd.mangledname))<>0) or
@ -950,6 +976,7 @@ implementation
else else
begin begin
writer.AsmWrite('define'); writer.AsmWrite('define');
WriteLinkageVibilityFlags(taillvmdecl(hp).namesym.bind);
writer.AsmWrite(llvmencodeproctype(tprocdef(taillvmdecl(hp).def), '', lpd_def)); writer.AsmWrite(llvmencodeproctype(tprocdef(taillvmdecl(hp).def), '', lpd_def));
WriteFunctionFlags(tprocdef(taillvmdecl(hp).def)); WriteFunctionFlags(tprocdef(taillvmdecl(hp).def));
writer.AsmWriteln(' {'); writer.AsmWriteln(' {');
@ -958,22 +985,9 @@ implementation
else else
begin begin
writer.AsmWrite(LlvmAsmSymName(taillvmdecl(hp).namesym)); writer.AsmWrite(LlvmAsmSymName(taillvmdecl(hp).namesym));
case taillvmdecl(hp).namesym.bind of writer.AsmWrite(' =');
AB_EXTERNAL: WriteLinkageVibilityFlags(taillvmdecl(hp).namesym.bind);
writer.AsmWrite(' = external '); writer.AsmWrite(' ');
AB_COMMON:
writer.AsmWrite(' = common ');
AB_LOCAL:
writer.AsmWrite(' = internal ');
AB_GLOBAL:
writer.AsmWrite(' = ');
AB_WEAK_EXTERNAL:
writer.AsmWrite(' = extern_weak ');
AB_PRIVATE_EXTERN:
writer.AsmWrite('= linker_private ');
else
internalerror(2014020104);
end;
if (ldf_tls in taillvmdecl(hp).flags) then if (ldf_tls in taillvmdecl(hp).flags) then
writer.AsmWrite('thread_local '); writer.AsmWrite('thread_local ');
if ldf_unnamed_addr in taillvmdecl(hp).flags then if ldf_unnamed_addr in taillvmdecl(hp).flags then