Browse Source

+ inlined support for round/trunc on AArch64

git-svn-id: trunk@29923 -
Jonas Maebe 10 years ago
parent
commit
5da379ab3f
1 changed files with 46 additions and 0 deletions
  1. 46 0
      compiler/aarch64/ncpuinl.pas

+ 46 - 0
compiler/aarch64/ncpuinl.pas

@@ -33,10 +33,14 @@ interface
         function first_abs_real: tnode; override;
         function first_abs_real: tnode; override;
         function first_sqr_real: tnode; override;
         function first_sqr_real: tnode; override;
         function first_sqrt_real: tnode; override;
         function first_sqrt_real: tnode; override;
+        function first_round_real: tnode; override;
+        function first_trunc_real: tnode; override;
         procedure second_abs_real; override;
         procedure second_abs_real; override;
         procedure second_sqr_real; override;
         procedure second_sqr_real; override;
         procedure second_sqrt_real; override;
         procedure second_sqrt_real; override;
         procedure second_abs_long; override;
         procedure second_abs_long; override;
+        procedure second_round_real; override;
+        procedure second_trunc_real; override;
       private
       private
         procedure load_fpu_location;
         procedure load_fpu_location;
       end;
       end;
@@ -85,6 +89,20 @@ implementation
       end;
       end;
 
 
 
 
+    function taarch64inlinenode.first_round_real: tnode;
+      begin
+        expectloc:=LOC_MMREGISTER;
+        result:=nil;
+      end;
+
+
+    function taarch64inlinenode.first_trunc_real: tnode;
+      begin
+        expectloc:=LOC_MMREGISTER;
+        result:=nil;
+      end;
+
+
     procedure taarch64inlinenode.second_abs_real;
     procedure taarch64inlinenode.second_abs_real;
       begin
       begin
         load_fpu_location;
         load_fpu_location;
@@ -121,6 +139,34 @@ implementation
         current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg_cond(A_CSEL,location.register,location.register,left.location.register,C_GE));
         current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg_cond(A_CSEL,location.register,location.register,left.location.register,C_GE));
       end;
       end;
 
 
+
+    procedure taarch64inlinenode.second_round_real;
+      var
+        hreg: tregister;
+      begin
+        secondpass(left);
+        hlcg.location_force_mmregscalar(current_asmdata.CurrAsmList,left.location,left.resultdef,true);
+        location_reset(location,LOC_REGISTER,def_cgsize(resultdef));
+        location.register:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
+        hreg:=cg.getmmregister(current_asmdata.CurrAsmList,left.location.size);
+        { round as floating point using current rounding mode }
+        current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_FRINTX,hreg,left.location.register));
+        { convert to signed integer rounding towards zero (there's no "round to
+          integer using current rounding mode") }
+        current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_FCVTZS,location.register,hreg));
+      end;
+
+
+    procedure taarch64inlinenode.second_trunc_real;
+      begin
+        secondpass(left);
+        hlcg.location_force_mmregscalar(current_asmdata.CurrAsmList,left.location,left.resultdef,true);
+        location_reset(location,LOC_REGISTER,def_cgsize(resultdef));
+        location.register:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
+        { convert to signed integer rounding towards zero }
+        current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_FCVTZS,location.register,left.location.register));
+      end;
+
 begin
 begin
   cinlinenode:=taarch64inlinenode;
   cinlinenode:=taarch64inlinenode;
 end.
 end.