Browse Source

+ Aarch64: use frintz for int(...) instead of creating a helper call

git-svn-id: trunk@49260 -
florian 4 years ago
parent
commit
cd3570caf1
2 changed files with 38 additions and 16 deletions
  1. 23 1
      compiler/aarch64/ncpuinl.pas
  2. 15 15
      rtl/aarch64/math.inc

+ 23 - 1
compiler/aarch64/ncpuinl.pas

@@ -1,7 +1,7 @@
 {
 {
     Copyright (c) 1998-2002 by Florian Klaempfl
     Copyright (c) 1998-2002 by Florian Klaempfl
 
 
-    Generates ARM inline nodes
+    Generates AAarch64 inline nodes
 
 
     This program is free software; you can redistribute it and/or modify
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     it under the terms of the GNU General Public License as published by
@@ -35,6 +35,7 @@ interface
         function first_sqrt_real: tnode; override;
         function first_sqrt_real: tnode; override;
         function first_round_real: tnode; override;
         function first_round_real: tnode; override;
         function first_trunc_real: tnode; override;
         function first_trunc_real: tnode; override;
+        function first_int_real: tnode; override;
         function first_fma : tnode; override;
         function first_fma : tnode; override;
         procedure second_abs_real; override;
         procedure second_abs_real; override;
         procedure second_sqr_real; override;
         procedure second_sqr_real; override;
@@ -42,6 +43,7 @@ interface
         procedure second_abs_long; override;
         procedure second_abs_long; override;
         procedure second_round_real; override;
         procedure second_round_real; override;
         procedure second_trunc_real; override;
         procedure second_trunc_real; override;
+        procedure second_int_real; override;
         procedure second_get_frame; override;
         procedure second_get_frame; override;
         procedure second_fma; override;
         procedure second_fma; override;
         procedure second_prefetch; override;
         procedure second_prefetch; override;
@@ -108,6 +110,13 @@ implementation
       end;
       end;
 
 
 
 
+    function taarch64inlinenode.first_int_real : tnode;
+      begin
+       expectloc:=LOC_MMREGISTER;
+       result:=nil;
+      end;
+
+
      function taarch64inlinenode.first_fma : tnode;
      function taarch64inlinenode.first_fma : tnode;
        begin
        begin
          if ((is_double(resultdef)) or (is_single(resultdef))) then
          if ((is_double(resultdef)) or (is_single(resultdef))) then
@@ -187,6 +196,19 @@ implementation
       end;
       end;
 
 
 
 
+    procedure taarch64inlinenode.second_int_real;
+      var
+        hreg: tregister;
+      begin
+        secondpass(left);
+        hlcg.location_force_mmregscalar(current_asmdata.CurrAsmList,left.location,left.resultdef,true);
+        location_reset(location,LOC_MMREGISTER,def_cgsize(resultdef));
+        location.register:=cg.getmmregister(current_asmdata.CurrAsmList,location.size);
+        current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_FRINTZ,location.register,left.location.register));
+        cg.maybe_check_for_fpu_exception(current_asmdata.CurrAsmList);
+      end;
+
+
     procedure taarch64inlinenode.second_get_frame;
     procedure taarch64inlinenode.second_get_frame;
       begin
       begin
         location_reset(location,LOC_CREGISTER,OS_ADDR);
         location_reset(location,LOC_CREGISTER,OS_ADDR);

+ 15 - 15
rtl/aarch64/math.inc

@@ -53,33 +53,33 @@
 
 
     {$ifndef FPC_SYSTEM_HAS_INT}
     {$ifndef FPC_SYSTEM_HAS_INT}
     {$define FPC_SYSTEM_HAS_INT}
     {$define FPC_SYSTEM_HAS_INT}
-    function fpc_int_real(d : ValReal) : ValReal;assembler;nostackframe;compilerproc;
-      asm
-        // { round as floating point towards zero }
-        frintz d0,d0
+    function fpc_int_real(d : ValReal) : ValReal;compilerproc;
+      begin
+        { Function is handled internal in the compiler }
+        runerror(207);
+        result:=0;
       end;
       end;
     {$endif FPC_SYSTEM_HAS_INT}
     {$endif FPC_SYSTEM_HAS_INT}
 
 
 
 
     {$ifndef FPC_SYSTEM_HAS_TRUNC}
     {$ifndef FPC_SYSTEM_HAS_TRUNC}
     {$define FPC_SYSTEM_HAS_TRUNC}
     {$define FPC_SYSTEM_HAS_TRUNC}
-    function fpc_trunc_real(d : ValReal) : int64;assembler;nostackframe;compilerproc;
-      asm
-        // { round to signed integer towards zero }
-        fcvtzs x0,d0
+    function fpc_trunc_real(d : ValReal) : int64;compilerproc;
+      begin
+        { Function is handled internal in the compiler }
+        runerror(207);
+        result:=0;
       end;
       end;
     {$endif FPC_SYSTEM_HAS_TRUNC}
     {$endif FPC_SYSTEM_HAS_TRUNC}
 
 
 
 
     {$ifndef FPC_SYSTEM_HAS_ROUND}
     {$ifndef FPC_SYSTEM_HAS_ROUND}
     {$define FPC_SYSTEM_HAS_ROUND}
     {$define FPC_SYSTEM_HAS_ROUND}
-    function fpc_round_real(d : ValReal) : int64;assembler;nostackframe;compilerproc;
-      asm
-        // { round as floating point using current rounding mode }
-        frintx d0,d0
-        // { convert to signed integer rounding towards zero (there's no "round to
-        //   integer using current rounding mode") }
-        fcvtzs x0,d0
+    function fpc_round_real(d : ValReal) : int64;compilerproc;
+      begin
+        { Function is handled internal in the compiler }
+        runerror(207);
+        result:=0;
       end;
       end;
     {$endif FPC_SYSTEM_HAS_ROUND}
     {$endif FPC_SYSTEM_HAS_ROUND}