From 5da379ab3f6c64efb6a16caad3b7fa5538b7fbc0 Mon Sep 17 00:00:00 2001 From: Jonas Maebe <jonas@freepascal.org> Date: Mon, 23 Feb 2015 22:53:07 +0000 Subject: [PATCH] + inlined support for round/trunc on AArch64 git-svn-id: trunk@29923 - --- compiler/aarch64/ncpuinl.pas | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/compiler/aarch64/ncpuinl.pas b/compiler/aarch64/ncpuinl.pas index 2b0529335c..596eefe6c4 100644 --- a/compiler/aarch64/ncpuinl.pas +++ b/compiler/aarch64/ncpuinl.pas @@ -33,10 +33,14 @@ interface function first_abs_real: tnode; override; function first_sqr_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_sqr_real; override; procedure second_sqrt_real; override; procedure second_abs_long; override; + procedure second_round_real; override; + procedure second_trunc_real; override; private procedure load_fpu_location; end; @@ -85,6 +89,20 @@ implementation 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; begin 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)); 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 cinlinenode:=taarch64inlinenode; end.