Browse Source

x86-64: keep tcgpara vardef the same as the para's real def

Only override the paraloc's vardef if necessary. This fixes compilation of
tests/test/cg/tvectorcall*.pp for LLVM
Jonas Maebe 3 years ago
parent
commit
c42e64db82
1 changed files with 18 additions and 15 deletions
  1. 18 15
      compiler/x86_64/cpupara.pas

+ 18 - 15
compiler/x86_64/cpupara.pas

@@ -1634,7 +1634,8 @@ unit cpupara;
       var
       var
         hp         : tparavarsym;
         hp         : tparavarsym;
         fdef,
         fdef,
-        paradef    : tdef;
+        paradef,
+        paralocdef : tdef;
         paraloc    : pcgparalocation;
         paraloc    : pcgparalocation;
         subreg     : tsubregister;
         subreg     : tsubregister;
         pushaddr   : boolean;
         pushaddr   : boolean;
@@ -1659,6 +1660,7 @@ unit cpupara;
           begin
           begin
             hp:=tparavarsym(paras[i]);
             hp:=tparavarsym(paras[i]);
             paradef:=hp.vardef;
             paradef:=hp.vardef;
+            paralocdef:=hp.vardef;
 
 
             { in syscalls the libbase might be set as explicit paraloc }
             { in syscalls the libbase might be set as explicit paraloc }
             if (vo_has_explicit_paraloc in hp.varoptions) then
             if (vo_has_explicit_paraloc in hp.varoptions) then
@@ -1682,9 +1684,9 @@ unit cpupara;
                tabstractrecordsymtable(tabstractrecorddef(paradef).symtable).has_single_field(fdef) and
                tabstractrecordsymtable(tabstractrecorddef(paradef).symtable).has_single_field(fdef) and
                (fdef.typ=floatdef) and
                (fdef.typ=floatdef) and
                (tfloatdef(fdef).floattype in [s32real,s64real]) then
                (tfloatdef(fdef).floattype in [s32real,s64real]) then
-              paradef:=fdef;
+              paralocdef:=fdef;
 
 
-            pushaddr:=push_addr_param(hp.varspez,paradef,p.proccalloption);
+            pushaddr:=push_addr_param(hp.varspez,paralocdef,p.proccalloption);
             if pushaddr then
             if pushaddr then
               begin
               begin
                 loc[0].typ:=X86_64_INTEGER_CLASS;
                 loc[0].typ:=X86_64_INTEGER_CLASS;
@@ -1692,7 +1694,8 @@ unit cpupara;
                 paracgsize:=OS_ADDR;
                 paracgsize:=OS_ADDR;
                 paralen:=sizeof(pint);
                 paralen:=sizeof(pint);
                 paradef:=cpointerdef.getreusable_no_free(paradef);
                 paradef:=cpointerdef.getreusable_no_free(paradef);
-                loc[0].def:=paradef;
+                paralocdef:=paradef;
+                loc[0].def:=paralocdef;
                 loc[1].def:=nil;
                 loc[1].def:=nil;
                 for j:=2 to high(loc) do
                 for j:=2 to high(loc) do
                   begin
                   begin
@@ -1702,17 +1705,17 @@ unit cpupara;
               end
               end
             else
             else
               begin
               begin
-                getvalueparaloc(p.proccalloption,hp.varspez,paradef,loc);
-                paralen:=push_size(hp.varspez,paradef,p.proccalloption);
+                getvalueparaloc(p.proccalloption,hp.varspez,paralocdef,loc);
+                paralen:=push_size(hp.varspez,paralocdef,p.proccalloption);
                 if p.proccalloption = pocall_vectorcall then
                 if p.proccalloption = pocall_vectorcall then
                   begin
                   begin
                     { TODO: Can this set of instructions be put into 'defutil' without it relying on the argument classification? [Kit] }
                     { TODO: Can this set of instructions be put into 'defutil' without it relying on the argument classification? [Kit] }
 
 
                     { The SIMD vector types have to be OS_M128 etc., not OS_128 etc.}
                     { The SIMD vector types have to be OS_M128 etc., not OS_128 etc.}
-                    case is_simd_vector_type_or_homogeneous_aggregate(pocall_vectorcall,paradef,vs_value) of
+                    case is_simd_vector_type_or_homogeneous_aggregate(pocall_vectorcall,paralocdef,vs_value) of
                       0:
                       0:
                         { Not a vector or valid aggregate }
                         { Not a vector or valid aggregate }
-                        paracgsize:=def_cgsize(paradef);
+                        paracgsize:=def_cgsize(paralocdef);
                       4:
                       4:
                         paracgsize:=OS_F32;
                         paracgsize:=OS_F32;
                       8:
                       8:
@@ -1728,28 +1731,28 @@ unit cpupara;
                     end;
                     end;
                   end
                   end
                 else
                 else
-                  paracgsize:=def_cgsize(paradef);
+                  paracgsize:=def_cgsize(paralocdef);
               end;
               end;
 
 
             { cheat for now, we should copy the value to an mm reg as well (FK) }
             { cheat for now, we should copy the value to an mm reg as well (FK) }
             if varargsparas and
             if varargsparas and
                use_ms_abi and
                use_ms_abi and
-               (paradef.typ = floatdef) then
+               (paralocdef.typ = floatdef) then
               begin
               begin
                 loc[1].typ:=X86_64_NO_CLASS;
                 loc[1].typ:=X86_64_NO_CLASS;
                 if paracgsize=OS_F64 then
                 if paracgsize=OS_F64 then
                   begin
                   begin
                     loc[0].typ:=X86_64_INTEGER_CLASS;
                     loc[0].typ:=X86_64_INTEGER_CLASS;
                     paracgsize:=OS_64;
                     paracgsize:=OS_64;
-                    paradef:=u64inttype;
+                    paralocdef:=u64inttype;
                   end
                   end
                 else
                 else
                   begin
                   begin
                     loc[0].typ:=X86_64_INTEGERSI_CLASS;
                     loc[0].typ:=X86_64_INTEGERSI_CLASS;
                     paracgsize:=OS_32;
                     paracgsize:=OS_32;
-                    paradef:=u32inttype;
+                    paralocdef:=u32inttype;
                   end;
                   end;
-                loc[0].def:=paradef;
+                loc[0].def:=paralocdef;
               end;
               end;
 
 
             hp.paraloc[side].reset;
             hp.paraloc[side].reset;
@@ -1789,7 +1792,7 @@ unit cpupara;
                       eightbyte of an argument, the whole argument is
                       eightbyte of an argument, the whole argument is
                       passed on the stack. }
                       passed on the stack. }
                     loc[low(loc)].typ:=X86_64_MEMORY_CLASS;
                     loc[low(loc)].typ:=X86_64_MEMORY_CLASS;
-                    loc[low(loc)].def:=paradef;
+                    loc[low(loc)].def:=paralocdef;
                     for locidx:=succ(low(loc)) to high(loc) do
                     for locidx:=succ(low(loc)) to high(loc) do
                       loc[locidx].typ:=X86_64_NO_CLASS;
                       loc[locidx].typ:=X86_64_NO_CLASS;
                   end;
                   end;
@@ -2000,7 +2003,7 @@ unit cpupara;
               begin
               begin
                 paraloc:=hp.paraloc[side].add_location;
                 paraloc:=hp.paraloc[side].add_location;
                 paraloc^.loc:=LOC_VOID;
                 paraloc^.loc:=LOC_VOID;
-                paraloc^.def:=paradef;
+                paraloc^.def:=paralocdef;
               end;
               end;
           end;
           end;
         { Register parameters are assigned from left-to-right, but the
         { Register parameters are assigned from left-to-right, but the