Browse Source

* patch by J. Gareth Moreton to fix vectorcall (no effect) for linux,
resolves #33184 and #33542

git-svn-id: trunk@38663 -

florian 7 years ago
parent
commit
25c5ee2fc3
3 changed files with 64 additions and 2 deletions
  1. 1 0
      .gitattributes
  2. 2 2
      compiler/x86_64/cpupi.pas
  3. 61 0
      tests/webtbs/tw33542.pp

+ 1 - 0
.gitattributes

@@ -16097,6 +16097,7 @@ tests/webtbs/tw3348.pp svneol=native#text/plain
 tests/webtbs/tw3349.pp svneol=native#text/plain
 tests/webtbs/tw3349.pp svneol=native#text/plain
 tests/webtbs/tw3351.pp svneol=native#text/plain
 tests/webtbs/tw3351.pp svneol=native#text/plain
 tests/webtbs/tw3353.pp svneol=native#text/plain
 tests/webtbs/tw3353.pp svneol=native#text/plain
+tests/webtbs/tw33542.pp svneol=native#text/pascal
 tests/webtbs/tw33548.pp svneol=native#text/plain
 tests/webtbs/tw33548.pp svneol=native#text/plain
 tests/webtbs/tw3356.pp svneol=native#text/plain
 tests/webtbs/tw3356.pp svneol=native#text/plain
 tests/webtbs/tw3360.pp svneol=native#text/plain
 tests/webtbs/tw3360.pp svneol=native#text/plain

+ 2 - 2
compiler/x86_64/cpupi.pas

@@ -171,9 +171,9 @@ implementation
     function x86_64_use_ms_abi(proccall: tproccalloption): boolean;
     function x86_64_use_ms_abi(proccall: tproccalloption): boolean;
       begin
       begin
         result:=
         result:=
-           ((target_info.system=system_x86_64_win64) and
+          ((target_info.system=system_x86_64_win64) and
             not(proccall in [pocall_sysv_abi_default,pocall_sysv_abi_cdecl])) or
             not(proccall in [pocall_sysv_abi_default,pocall_sysv_abi_cdecl])) or
-            (proccall in [pocall_ms_abi_default,pocall_ms_abi_cdecl,pocall_vectorcall]);
+          (proccall in [pocall_ms_abi_default,pocall_ms_abi_cdecl]);
       end;
       end;
 
 
 
 

+ 61 - 0
tests/webtbs/tw33542.pp

@@ -0,0 +1,61 @@
+{ %CPU=x86_64 }
+{ %TARGET=linux }
+program vectorcall_pd_test1;
+ 
+{$IFNDEF CPUX86_64}
+  {$FATAL This test program can only be compiled on Linux 64-bit with an Intel processor }
+{$ENDIF}
+{$IFNDEF LINUX}
+  {$FATAL This test program can only be compiled on Linux 64-bit with an Intel processor }
+{$ENDIF}
+{$MODESWITCH ADVANCEDRECORDS}
+{$ASMMODE Intel}
+type
+  { TM128 }
+  {$push}
+  {$CODEALIGN RECORDMIN=16}
+  {$PACKRECORDS C}
+  TM128 = record
+    public
+    function Add(A: TM128): TM128; vectorcall;
+    case Byte of
+      0: (M128_F32: array[0..3] of Single);
+      1: (M128_F64: array[0..1] of Double);
+  end;
+  {$pop}
+ 
+{ TM128 }
+ 
+function TM128.Add(A: TM128): TM128; vectorcall; assembler; nostackframe;
+asm
+  addps  xmm0, [RDI]   // expected convention for Self - add result into first parameter and return as result (xmm0 = first parameter and return value)
+end;
+ 
+var
+  xm1, xm2, xm3: TM128;
+ 
+begin
+  WriteLn('Linux "vectorcall" test with Self (is it in RDI?)'#10
+        + '-------------------------------------------------');
+  xm1.M128_F32[0] := 1.0;
+  xm1.M128_F32[1] := 2.0;
+  xm1.M128_F32[2] := 3.0;
+  xm1.M128_F32[3] := 4.0;
+  xm2.M128_F32[0] := 5.0;
+  xm2.M128_F32[1] := 6.0;
+  xm2.M128_F32[2] := 7.0;
+  xm2.M128_F32[3] := 8.0;
+  
+  WriteLn('xm1 = (', xm1.M128_F32[0], ', ', xm1.M128_F32[1], ', ', xm1.M128_F32[2], ', ', xm1.M128_F32[3]);
+  WriteLn('xm2 = (', xm2.M128_F32[0], ', ', xm2.M128_F32[1], ', ', xm2.M128_F32[2], ', ', xm2.M128_F32[3]);
+  xm3 := xm1.Add(xm2); { This will likely raise an exception if RDI doesn't contain Self }
+  WriteLn('xm3 = (', xm3.M128_F32[0], ', ', xm3.M128_F32[1], ', ', xm3.M128_F32[2], ', ', xm3.M128_F32[3]);
+  
+  if (xm3.M128_F32[0] <> 6.0) or (xm3.M128_F32[1] <> 8.0) or (xm3.M128_F32[2] <> 10.0) or (xm3.M128_F32[3] <> 12.0) then
+    begin
+      WriteLn('FAIL');
+	  Halt(1);
+	end;
+  
+  WriteLn('ok');
+end.