Browse Source

+ when calling FPC_THROWFPUEXCEPTION in a sub routine, pi_do_call must be set, fixed for aarch64

florian 1 year ago
parent
commit
3ed5a4a022
3 changed files with 42 additions and 2 deletions
  1. 14 1
      compiler/aarch64/ncpuadd.pas
  2. 18 1
      compiler/aarch64/ncpuinl.pas
  3. 10 0
      compiler/aarch64/ncpumat.pas

+ 14 - 1
compiler/aarch64/ncpuadd.pas

@@ -45,12 +45,13 @@ interface
           procedure second_cmp64bit; override;
        public
           function use_generic_mul32to64: boolean; override;
+          function pass_1 : tnode;override;
        end;
 
   implementation
 
     uses
-      systems,symtype,symdef,
+      systems,symconst,symtype,symdef,
       globals,globtype,
       cutils,verbose,
       paramgr,procinfo,
@@ -485,6 +486,18 @@ interface
         result:=false;
       end;
 
+    function taarch64addnode.pass_1: tnode;
+      begin
+        Result:=inherited pass_1;
+        { if the result is not nil, a new node has been generated and the current node will be discarted }
+        if Result=nil then
+          begin
+            if left.resultdef.typ=floatdef then
+              if cs_check_fpu_exceptions in current_settings.localswitches then
+                Include(current_procinfo.flags,pi_do_call);
+          end;
+      end;
+
 
 begin
   caddnode:=taarch64addnode;

+ 18 - 1
compiler/aarch64/ncpuinl.pas

@@ -63,8 +63,9 @@ implementation
       compinnr,
       cpuinfo, defutil,symdef,aasmdata,aasmcpu,
       cgbase,cgutils,pass_1,pass_2,
+      procinfo,
       ncal,nutils,
-      cpubase,ncgutil,cgobj,cgcpu, hlcgobj;
+      cpubase,ncgutil,cgobj,cgcpu,hlcgobj;
 
 {*****************************************************************************
                               taarch64inlinenode
@@ -84,6 +85,8 @@ implementation
       begin
         expectloc:=LOC_MMREGISTER;
         result:=nil;
+        if cs_check_fpu_exceptions in current_settings.localswitches then
+          Include(current_procinfo.flags,pi_do_call);
       end;
 
 
@@ -91,6 +94,8 @@ implementation
       begin
         expectloc:=LOC_MMREGISTER;
         result:=nil;
+        if cs_check_fpu_exceptions in current_settings.localswitches then
+          Include(current_procinfo.flags,pi_do_call);
       end;
 
 
@@ -98,6 +103,8 @@ implementation
       begin
         expectloc:=LOC_MMREGISTER;
         result:=nil;
+        if cs_check_fpu_exceptions in current_settings.localswitches then
+          Include(current_procinfo.flags,pi_do_call);
       end;
 
 
@@ -105,6 +112,8 @@ implementation
       begin
         expectloc:=LOC_MMREGISTER;
         result:=nil;
+        if cs_check_fpu_exceptions in current_settings.localswitches then
+          Include(current_procinfo.flags,pi_do_call);
       end;
 
 
@@ -112,6 +121,8 @@ implementation
       begin
         expectloc:=LOC_MMREGISTER;
         result:=nil;
+        if cs_check_fpu_exceptions in current_settings.localswitches then
+          Include(current_procinfo.flags,pi_do_call);
       end;
 
 
@@ -119,6 +130,8 @@ implementation
       begin
         expectloc:=LOC_MMREGISTER;
         result:=nil;
+        if cs_check_fpu_exceptions in current_settings.localswitches then
+          Include(current_procinfo.flags,pi_do_call);
       end;
 
 
@@ -126,6 +139,8 @@ implementation
       begin
         expectloc:=LOC_MMREGISTER;
         result:=nil;
+        if cs_check_fpu_exceptions in current_settings.localswitches then
+          Include(current_procinfo.flags,pi_do_call);
       end;
 
 
@@ -356,6 +371,8 @@ implementation
           begin
             expectloc:=LOC_MMREGISTER;
             Result:=nil;
+            if cs_check_fpu_exceptions in current_settings.localswitches then
+              Include(current_procinfo.flags,pi_do_call);
           end
         else if is_32bitint(resultdef) then
           begin

+ 10 - 0
compiler/aarch64/ncpumat.pas

@@ -39,6 +39,7 @@ interface
       end;
 
       taarch64unaryminusnode = class(tcgunaryminusnode)
+         function pass_1: tnode; override;
          procedure second_float; override;
       end;
 
@@ -482,6 +483,15 @@ implementation
                                    taarch64unaryminusnode
 *****************************************************************************}
 
+    function taarch64unaryminusnode.pass_1: tnode;
+      begin
+        Result:=inherited pass_1;
+        if Result=nil then
+          if cs_check_fpu_exceptions in current_settings.localswitches then
+            Include(current_procinfo.flags,pi_do_call);
+      end;
+
+
     procedure taarch64unaryminusnode.second_float;
       begin
         secondpass(left);