浏览代码

tllvmcallpara: record whether it's passed to metadata

Sometimes we need the def to store a the original def of the passed parameter,
e.g. for the first argument to llvm.dbg.addr
Jonas Maebe 3 年之前
父节点
当前提交
a76085e463
共有 3 个文件被更改,包括 8 次插入1 次删除
  1. 1 1
      compiler/llvm/aasmllvm.pas
  2. 5 0
      compiler/llvm/agllvm.pas
  3. 2 0
      compiler/llvm/hlcgllvm.pas

+ 1 - 1
compiler/llvm/aasmllvm.pas

@@ -209,7 +209,7 @@ interface
       destructor destroy; override;
     end;
 
-    tllvmcallparaflag = (lcp_byval, lcp_sret);
+    tllvmcallparaflag = (lcp_byval, lcp_sret, lcp_metadata);
     tllvmcallparaflags = set of tllvmcallparaflag;
 
     tllvmcallparaval = record

+ 5 - 0
compiler/llvm/agllvm.pas

@@ -347,6 +347,11 @@ implementation
            if i<>0 then
              owner.writer.AsmWrite(', ');
            para:=pllvmcallpara(paras[i]);
+           if (lcp_metadata in para^.flags) and
+              (para^.def<>llvm_metadatatype) then
+             begin
+               owner.writer.AsmWrite('metadata ')
+             end;
            owner.writer.AsmWrite(llvmencodetypename(para^.def));
            if para^.valueext<>lve_none then
              owner.writer.AsmWrite(llvmvalueextension2str[para^.valueext]);

+ 2 - 0
compiler/llvm/hlcgllvm.pas

@@ -476,6 +476,8 @@ implementation
         while assigned(paraloc) do
           begin
             new(callpara,init(paraloc^.def,std_param_align,lve_none,[]));
+            if paras[i]^.def=llvm_metadatatype then
+              include(callpara^.flags,lcp_metadata);
             callpara^.def:=paraloc^.def;
             { if the paraloc doesn't contain the value itself, it's a byval
               parameter }