Browse Source

* correctly handle a floating point result

git-svn-id: trunk@40664 -
svenbarth 6 năm trước cách đây
mục cha
commit
dbaf7a69bd

+ 11 - 0
packages/rtl-objpas/src/x86_64/invoke.inc

@@ -28,6 +28,8 @@ asm
 .seh_savereg %rsi, 16
 .seh_savereg %rsi, 16
   movq %rdi, 24(%rsp)
   movq %rdi, 24(%rsp)
 .seh_savereg %rdi, 24
 .seh_savereg %rdi, 24
+  movq %r8, 32(%rsp)
+.seh_savereg %r8, 32
 
 
   movq %rsp, %rbp
   movq %rsp, %rbp
 .seh_setframe %rbp, 0
 .seh_setframe %rbp, 0
@@ -71,6 +73,10 @@ asm
   { restore non-volatile registers }
   { restore non-volatile registers }
   movq %rbp, %rsp
   movq %rbp, %rsp
 
 
+  { we abuse the register area pointer for an eventual SSE2 result }
+  movq 32(%rsp), %rdi
+  movq %xmm0, (%rdi)
+
   movq 24(%rsp), %rdi
   movq 24(%rsp), %rdi
   movq 16(%rsp), %rsi
   movq 16(%rsp), %rsi
   movq 8(%rsp), %rbp
   movq 8(%rsp), %rbp
@@ -249,6 +255,11 @@ begin
 
 
   if Assigned(aResultType) and not retinparam then begin
   if Assigned(aResultType) and not retinparam then begin
     PPtrUInt(aResultValue)^ := val;
     PPtrUInt(aResultValue)^ := val;
+    if aResultType^.Kind = tkFloat then begin
+      td := GetTypeData(aResultType);
+      if td^.FloatType in [ftSingle, ftDouble] then
+        PPtrUInt(aResultValue)^ := regs[0];
+    end;
   end;
   end;
 {$else}
 {$else}
   raise EInvocationError.Create(SErrPlatformNotSupported);
   raise EInvocationError.Create(SErrPlatformNotSupported);