Browse Source

* Aarch64: fix Math.SetExceptionMask for implementations throwing hardware
exceptions

git-svn-id: trunk@46880 -

florian 4 years ago
parent
commit
9a573173dd
1 changed files with 12 additions and 14 deletions
  1. 12 14
      rtl/aarch64/mathu.inc

+ 12 - 14
rtl/aarch64/mathu.inc

@@ -103,21 +103,23 @@ function GetExceptionMask: TFPUExceptionMask;
     if ((fpcr and fpu_ide)=0) then
     if ((fpcr and fpu_ide)=0) then
       result := result+[exDenormalized];
       result := result+[exDenormalized];
     }
     }
+    { as the fpcr flags might be RAZ, the softfloat exception mask
+      is considered as the authoritative mask }
     result:=softfloat_exception_mask;
     result:=softfloat_exception_mask;
   end;
   end;
 
 
 
 
 function SetExceptionMask(const Mask: TFPUExceptionMask): TFPUExceptionMask;
 function SetExceptionMask(const Mask: TFPUExceptionMask): TFPUExceptionMask;
-  {
   var
   var
     newfpcr: dword;
     newfpcr: dword;
-  }
   begin
   begin
-    { as I am not aware of any hardware exception supporting AArch64 implementation,
-      and else the trapping enable flags are RAZ, work solely with softfloat_exception_mask (FK)
-    }
+    { clear "exception happened" flags }
+    ClearExceptions(false);
     softfloat_exception_mask:=mask;
     softfloat_exception_mask:=mask;
-    {
+
+    { at least the ThunderX AArch64 support apperently hardware exceptions,
+      so set fpcr correctly, thought it might be WI on most implementations it does not hurt
+    }
     newfpcr:=fpu_exception_mask;
     newfpcr:=fpu_exception_mask;
     if exInvalidOp in Mask then
     if exInvalidOp in Mask then
       newfpcr:=newfpcr and not(fpu_ioe);
       newfpcr:=newfpcr and not(fpu_ioe);
@@ -131,14 +133,10 @@ function SetExceptionMask(const Mask: TFPUExceptionMask): TFPUExceptionMask;
       newfpcr:=newfpcr and not(fpu_ixe);
       newfpcr:=newfpcr and not(fpu_ixe);
     if exDenormalized in Mask then
     if exDenormalized in Mask then
       newfpcr:=newfpcr and not(fpu_ide);
       newfpcr:=newfpcr and not(fpu_ide);
-    }
-    { clear "exception happened" flags }
-    ClearExceptions(false);
-    { set new exception mask }
-//    setfpcr((getfpcr and not(fpu_exception_mask)) or newfpcr);
-    { unsupported mask bits will remain 0 -> read exception mask again }
-//    result:=GetExceptionMask;
-//    softfloat_exception_mask:=result;
+    setfpcr((getfpcr and not(fpu_exception_mask)) or newfpcr);
+
+    { as the fpcr flags might be RAZ, the softfloat exception mask
+      is considered as the authoritative mask }
     result:=softfloat_exception_mask;
     result:=softfloat_exception_mask;
   end;
   end;