Browse Source

* fix sincos for x86-64 windows resolves #23268
* changed to intel assembler to be more readble
* test for sincos extended

git-svn-id: trunk@22925 -

florian 12 years ago
parent
commit
a9fed57090
2 changed files with 19 additions and 20 deletions
  1. 12 20
      rtl/x86_64/mathu.inc
  2. 7 0
      tests/test/units/math/tsincos.pp

+ 12 - 20
rtl/x86_64/mathu.inc

@@ -33,8 +33,8 @@ asm
     fldt theta
     fldt theta
     fsincos
     fsincos
 {$ifdef WIN64}
 {$ifdef WIN64}
-    fstpt (%r8)
-    fstpt (%rdx)
+    fstpl (%r8)
+    fstpl (%rdx)
 {$else WIN64}
 {$else WIN64}
     fstpt (%rsi)
     fstpt (%rsi)
     fstpt (%rdi)
     fstpt (%rdi)
@@ -44,20 +44,16 @@ asm
 {$endif FPC_HAS_TYPE_EXTENDED}
 {$endif FPC_HAS_TYPE_EXTENDED}
 
 
 
 
+{$asmmode intel}
 procedure sincos(theta : double;out sinus,cosinus : double);assembler;
 procedure sincos(theta : double;out sinus,cosinus : double);assembler;
   var
   var
     t : double;
     t : double;
   asm
   asm
-    movd %xmm0,t
-    fldl t
+    movsd qword ptr t,xmm0
+    fld qword ptr t
     fsincos
     fsincos
-{$ifdef WIN64}
-    fstpl (%r8)
-    fstpl (%rdx)
-{$else WIN64}
-    fstpl (%rsi)
-    fstpl (%rdi)
-{$endif WIN64}
+    fstp qword ptr [cosinus]
+    fstp qword ptr [sinus]
     fwait
     fwait
   end;
   end;
 
 
@@ -66,20 +62,16 @@ procedure sincos(theta : single;out sinus,cosinus : single);assembler;
   var
   var
     t : single;
     t : single;
   asm
   asm
-    movss %xmm0,t
-    flds t
+    movsd dword ptr t,xmm0
+    fld dword ptr t
     fsincos
     fsincos
-{$ifdef WIN64}
-    fstps (%r8)
-    fstps (%rdx)
-{$else WIN64}
-    fstps (%rsi)
-    fstps (%rdi)
-{$endif WIN64}
+    fstp dword ptr [cosinus]
+    fstp dword ptr [sinus]
     fwait
     fwait
   end;
   end;
 
 
 
 
+{$asmmode gas}
 function GetRoundMode: TFPURoundingMode;
 function GetRoundMode: TFPURoundingMode;
 begin
 begin
 {$ifndef FPC_HAS_TYPE_EXTENDED}
 {$ifndef FPC_HAS_TYPE_EXTENDED}

+ 7 - 0
tests/test/units/math/tsincos.pp

@@ -12,6 +12,13 @@ begin
   if not(SameValue(s1,0)) or not(SameValue(s2,1)) or not(SameValue(d1,0)) or
   if not(SameValue(s1,0)) or not(SameValue(s2,1)) or not(SameValue(d1,0)) or
     not(SameValue(d2,1)) or not(SameValue(e1,0)) or not(SameValue(e2,1)) then
     not(SameValue(d2,1)) or not(SameValue(e1,0)) or not(SameValue(e2,1)) then
     halt(1);
     halt(1);
+
+  sincos(pi,s1,s2);
+  sincos(pi,d1,d2);
+  sincos(pi,e1,e2);
+  if not(SameValue(s1,0)) or not(SameValue(s2,-1)) or not(SameValue(d1,0)) or
+    not(SameValue(d2,-1)) or not(SameValue(e1,0)) or not(SameValue(e2,-1)) then
+    halt(1);
   writeln('ok');
   writeln('ok');
 end.
 end.