Browse Source

llvm: version 14.0 support

Jonas Maebe 3 years ago
parent
commit
a45e5e7ab6
3 changed files with 21 additions and 9 deletions
  1. 8 4
      compiler/llvm/agllvm.pas
  2. 4 1
      compiler/llvm/llvmdef.pas
  3. 9 4
      compiler/llvm/llvminfo.pas

+ 8 - 4
compiler/llvm/agllvm.pas

@@ -108,7 +108,7 @@ interface
         function getopcodestr(hp: taillvm): TSymStr;
         function getopcodestr(hp: taillvm): TSymStr;
         function getopstr(const o:toper; refwithalign: boolean) : TSymStr;
         function getopstr(const o:toper; refwithalign: boolean) : TSymStr;
         procedure writetaioper(ai: tai);
         procedure writetaioper(ai: tai);
-        procedure writeparas(const paras: tfplist);
+        procedure writeparas(const paras: tfplist; asmblock: boolean);
         procedure WriteAsmRegisterAllocationClobbers(list: tasmlist);
         procedure WriteAsmRegisterAllocationClobbers(list: tasmlist);
       end;
       end;
 
 
@@ -329,7 +329,7 @@ implementation
       end;
       end;
 
 
 
 
-   procedure TLLVMInstrWriter.writeparas(const paras: tfplist);
+   procedure TLLVMInstrWriter.writeparas(const paras: tfplist; asmblock: boolean);
 
 
      var
      var
        hp: tai;
        hp: tai;
@@ -354,6 +354,10 @@ implementation
              owner.writer.AsmWrite(llvmparatypeattr(' byval',para^.def,true));
              owner.writer.AsmWrite(llvmparatypeattr(' byval',para^.def,true));
            if para^.sret then
            if para^.sret then
              owner.writer.AsmWrite(llvmparatypeattr(' sret',para^.def,true));
              owner.writer.AsmWrite(llvmparatypeattr(' sret',para^.def,true));
+           if asmblock and
+              (llvmflag_opaque_ptr_transition in llvmversion_properties[current_settings.llvmversion]) and
+              (para^.def.typ=pointerdef) then
+             owner.writer.AsmWrite(llvmparatypeattr(' elementtype',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
@@ -495,7 +499,7 @@ implementation
            end;
            end;
          top_para:
          top_para:
            begin
            begin
-             writeparas(o.paras);
+             writeparas(o.paras,false);
              result:='';
              result:='';
            end;
            end;
          top_tai:
          top_tai:
@@ -598,7 +602,7 @@ implementation
             owner.writer.AsmWrite('~{memory},~{fpsr},~{flags}');
             owner.writer.AsmWrite('~{memory},~{fpsr},~{flags}');
             WriteAsmRegisterAllocationClobbers(taillvm(hp).oper[0]^.asmlist);
             WriteAsmRegisterAllocationClobbers(taillvm(hp).oper[0]^.asmlist);
             owner.writer.AsmWrite('"');
             owner.writer.AsmWrite('"');
-            writeparas(taillvm(hp).oper[1]^.paras);
+            writeparas(taillvm(hp).oper[1]^.paras,true);
             done:=true;
             done:=true;
           end;
           end;
         la_load,
         la_load,

+ 4 - 1
compiler/llvm/llvmdef.pas

@@ -295,7 +295,10 @@ implementation
             begin
             begin
               if paradef.typ<>pointerdef then
               if paradef.typ<>pointerdef then
                 internalerror(2022060310);
                 internalerror(2022060310);
-              result:=result+'('+llvmencodetypename(tpointerdef(paradef).pointeddef)+')'
+              if not is_void(tpointerdef(paradef).pointeddef) then
+                result:=result+'('+llvmencodetypename(tpointerdef(paradef).pointeddef)+')'
+              else
+                result:=result+'(i8)'
             end;
             end;
         end;
         end;
     end;
     end;

+ 9 - 4
compiler/llvm/llvminfo.pas

@@ -52,7 +52,8 @@ Type
        llvmver_12_0,
        llvmver_12_0,
        llvmver_xc_13,
        llvmver_xc_13,
        llvmver_13_0,
        llvmver_13_0,
-       llvmver_xc_13_3
+       llvmver_xc_13_3,
+       llvmver_14_0
       );
       );
 
 
 type
 type
@@ -66,7 +67,8 @@ type
      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 }
+     llvmflag_para_attr_type,               { parameter attributes such as noalias and byval need to repeat the type }
+     llvmflag_opaque_ptr_transition         { initial opaque pointer introduction, needs to some elementtype attributes }
    );
    );
    tllvmversionflags = set of tllvmversionflag;
    tllvmversionflags = set of tllvmversionflag;
 
 
@@ -89,7 +91,8 @@ Const
      '12.0',
      '12.0',
      'Xcode-13.0',
      'Xcode-13.0',
      '13.0',
      '13.0',
-     'Xcode-13.3'
+     'Xcode-13.3',
+     '14.0'
    );
    );
 
 
    llvm_debuginfo_metadata_format : array[tllvmversion] of byte = (
    llvm_debuginfo_metadata_format : array[tllvmversion] of byte = (
@@ -110,6 +113,7 @@ Const
      3,
      3,
      3,
      3,
      3,
      3,
+     3,
      3
      3
    );
    );
 
 
@@ -132,7 +136,8 @@ Const
        { 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],
        { 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],
        { llvmver_xc_13_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],
        { llvmver_xc_13_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],
        { llvmver_13_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],
        { llvmver_13_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],
-       { llvmver_xc_13_3 } [llvmflag_memcpy_indiv_align,llvmflag_null_pointer_valid_new,llvmflag_constrained_fptrunc_fpext,llvmflag_constrained_fptoi_itofp,llvmflag_array_datalocation,llvmflag_para_attr_type]
+       { llvmver_xc_13_3 } [llvmflag_memcpy_indiv_align,llvmflag_null_pointer_valid_new,llvmflag_constrained_fptrunc_fpext,llvmflag_constrained_fptoi_itofp,llvmflag_array_datalocation,llvmflag_para_attr_type],
+       { llvmver_xc_13_3 } [llvmflag_memcpy_indiv_align,llvmflag_null_pointer_valid_new,llvmflag_constrained_fptrunc_fpext,llvmflag_constrained_fptoi_itofp,llvmflag_array_datalocation,llvmflag_para_attr_type,llvmflag_opaque_ptr_transition]
      );
      );
 
 
    { Supported optimizations, only used for information }
    { Supported optimizations, only used for information }