llvm: version 12.0 support

This commit is contained in:
Jonas Maebe 2021-11-11 11:48:49 +01:00
parent 762057f46d
commit 1b06599e82
3 changed files with 45 additions and 15 deletions

View File

@ -330,6 +330,7 @@ implementation
procedure TLLVMInstrWriter.writeparas(const paras: tfplist); procedure TLLVMInstrWriter.writeparas(const paras: tfplist);
var var
hp: tai; hp: tai;
para: pllvmcallpara; para: pllvmcallpara;
@ -350,9 +351,9 @@ implementation
if para^.valueext<>lve_none then if para^.valueext<>lve_none then
owner.writer.AsmWrite(llvmvalueextension2str[para^.valueext]); owner.writer.AsmWrite(llvmvalueextension2str[para^.valueext]);
if para^.byval then if para^.byval then
owner.writer.AsmWrite(' byval'); owner.writer.AsmWrite(llvmparatypeattr(' byval',para^.def,true));
if para^.sret then if para^.sret then
owner.writer.AsmWrite(' sret'); owner.writer.AsmWrite(llvmparatypeattr(' sret',para^.def,true));
{ For byval, this means "alignment on the stack" and of the passed source data. { For byval, this means "alignment on the stack" and of the passed source data.
For other pointer parameters, this means "alignment of the passed source data" } For other pointer parameters, this means "alignment of the passed source data" }
if (para^.alignment<>std_param_align) or if (para^.alignment<>std_param_align) or

View File

@ -107,6 +107,10 @@ interface
name further according to platform conventions (we already did that) } name further according to platform conventions (we already did that) }
function llvmmangledname(const s: TSymStr): TSymStr; function llvmmangledname(const s: TSymStr): TSymStr;
{ convert a parameter attribute to a string. Depending on the target
LLVM version, we may have to add the dereferenced parameter type as well }
function llvmparatypeattr(const attr: TSymStr; paradef: tdef; strippointer: boolean): TSymStr;
function llvmasmsymname(const sym: TAsmSymbol): TSymStr; function llvmasmsymname(const sym: TAsmSymbol): TSymStr;
function llvmfloatintrinsicsuffix(def: tfloatdef): TIDString; function llvmfloatintrinsicsuffix(def: tfloatdef): TIDString;
@ -121,7 +125,7 @@ implementation
symtable,symsym, symtable,symsym,
llvmsym,hlcgobj, llvmsym,hlcgobj,
defutil,blockutl,cgbase,paramgr, defutil,blockutl,cgbase,paramgr,
cpubase; llvminfo,cpubase;
{****************************************************************** {******************************************************************
@ -280,6 +284,21 @@ implementation
result:='@'+s result:='@'+s
end; end;
function llvmparatypeattr(const attr: TSymStr; paradef: tdef; strippointer: boolean): TSymStr;
begin
result:=attr;
if llvmflag_para_attr_type in llvmversion_properties[current_settings.llvmversion] then
begin
if not strippointer then
result:=result+'('+llvmencodetypename(paradef)+')'
else
begin
if paradef.typ<>pointerdef then
internalerror(2022060310);
result:=result+'('+llvmencodetypename(tpointerdef(paradef).pointeddef)+')'
end;
end;
end;
function llvmasmsymname(const sym: TAsmSymbol): TSymStr; function llvmasmsymname(const sym: TAsmSymbol): TSymStr;
begin begin
@ -743,29 +762,30 @@ implementation
internalerror(2015101404); internalerror(2015101404);
{$endif aarch64} {$endif aarch64}
if withattributes then if withattributes then
if first begin
if first
{$ifdef aarch64} {$ifdef aarch64}
and not is_managed_type(hp.vardef) and not is_managed_type(hp.vardef)
{$endif aarch64} {$endif aarch64}
then then
encodedstr:=encodedstr+' sret noalias nocapture' encodedstr:=encodedstr+llvmparatypeattr(' sret',hp.vardef,false)+' noalias nocapture'
else else
encodedstr:=encodedstr+' noalias nocapture'; encodedstr:=encodedstr+' noalias nocapture';
end;
end end
else if not paramanager.push_addr_param(hp.varspez,hp.vardef,proccalloption) and else if not paramanager.push_addr_param(hp.varspez,hp.vardef,proccalloption) and
llvmbyvalparaloc(paraloc) then llvmbyvalparaloc(paraloc) then
begin begin
encodedstr:=encodedstr+'*';
if withattributes then if withattributes then
begin begin
encodedstr:=encodedstr+'* byval'; encodedstr:=encodedstr+llvmparatypeattr(' byval',hp.vardef,false);
if firstloc and if firstloc and
(para^.alignment<>std_param_align) then (para^.alignment<>std_param_align) then
begin begin
encodedstr:=encodedstr+' align '+tostr(para^.alignment); encodedstr:=encodedstr+' align '+tostr(para^.alignment);
end; end;
end end
else
encodedstr:=encodedstr+'*';
end end
else if withattributes and else if withattributes and
paramanager.push_addr_param(hp.varspez,hp.vardef,proccalloption) then paramanager.push_addr_param(hp.varspez,hp.vardef,proccalloption) then

View File

@ -44,7 +44,9 @@ Type
llvmver_xc_11, llvmver_xc_11,
llvmver_9_0, llvmver_9_0,
llvmver_10_0, llvmver_10_0,
llvmver_11_0 llvmver_11_0,
llvmver_11_1,
llvmver_12_0
); );
type type
@ -57,7 +59,8 @@ type
llvmflag_null_pointer_valid_new, { new syntax for the null pointer valid attribute: null_pointer_is_valid } llvmflag_null_pointer_valid_new, { new syntax for the null pointer valid attribute: null_pointer_is_valid }
llvmflag_array_datalocation, { arrays debug info supports a dataLocation attribute to specify how to obtain the array data based on the array variable } llvmflag_array_datalocation, { arrays debug info supports a dataLocation attribute to specify how to obtain the array data based on the array variable }
llvmflag_NoDISPFlags, { no DI sub program flags, but separate fields } llvmflag_NoDISPFlags, { no DI sub program flags, but separate fields }
llvmflag_NoDISPFlagMainSubprogram { MainSubprogram still in DIFlags instead of DISPFlags } llvmflag_NoDISPFlagMainSubprogram, { MainSubprogram still in DIFlags instead of DISPFlags }
llvmflag_para_attr_type { parameter attributes such as noalias and byval need to repeat the type }
); );
tllvmversionflags = set of tllvmversionflag; tllvmversionflags = set of tllvmversionflag;
@ -72,7 +75,9 @@ Const
'Xcode-11.0', 'Xcode-11.0',
'9.0', '9.0',
'10.0', '10.0',
'11.0' '11.0',
'11.1',
'12.0'
); );
llvm_debuginfo_metadata_format : array[tllvmversion] of byte = ( llvm_debuginfo_metadata_format : array[tllvmversion] of byte = (
@ -85,6 +90,8 @@ Const
3, 3,
3, 3,
3, 3,
3,
3,
3 3
); );
@ -99,7 +106,9 @@ Const
{ llvmver_xc_11 } [llvmflag_memcpy_indiv_align,llvmflag_null_pointer_valid,llvmflag_NoDISPFlagMainSubprogram], { llvmver_xc_11 } [llvmflag_memcpy_indiv_align,llvmflag_null_pointer_valid,llvmflag_NoDISPFlagMainSubprogram],
{ llvmver_9_0 } [llvmflag_memcpy_indiv_align,llvmflag_null_pointer_valid,llvmflag_constrained_fptrunc_fpext], { llvmver_9_0 } [llvmflag_memcpy_indiv_align,llvmflag_null_pointer_valid,llvmflag_constrained_fptrunc_fpext],
{ llvmver_10_0 } [llvmflag_memcpy_indiv_align,llvmflag_null_pointer_valid,llvmflag_constrained_fptrunc_fpext,llvmflag_constrained_fptoi_itofp], { llvmver_10_0 } [llvmflag_memcpy_indiv_align,llvmflag_null_pointer_valid,llvmflag_constrained_fptrunc_fpext,llvmflag_constrained_fptoi_itofp],
{ llvmver_11_0 } [llvmflag_memcpy_indiv_align,llvmflag_null_pointer_valid_new,llvmflag_constrained_fptrunc_fpext,llvmflag_constrained_fptoi_itofp,llvmflag_array_datalocation] { llvmver_11_0 } [llvmflag_memcpy_indiv_align,llvmflag_null_pointer_valid_new,llvmflag_constrained_fptrunc_fpext,llvmflag_constrained_fptoi_itofp,llvmflag_array_datalocation],
{ llvmver_11_1 } [llvmflag_memcpy_indiv_align,llvmflag_null_pointer_valid_new,llvmflag_constrained_fptrunc_fpext,llvmflag_constrained_fptoi_itofp,llvmflag_array_datalocation],
{ llvmver_12_0 } [llvmflag_memcpy_indiv_align,llvmflag_null_pointer_valid_new,llvmflag_constrained_fptrunc_fpext,llvmflag_constrained_fptoi_itofp,llvmflag_array_datalocation,llvmflag_para_attr_type]
); );
{ Supported optimizations, only used for information } { Supported optimizations, only used for information }