summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorflorian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2>2021-04-25 08:53:12 +0000
committerflorian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2>2021-04-25 08:53:12 +0000
commit3595ed4d1c56d42ef6f335152ffadb8e11cb20fe (patch)
tree27fe76bea2f2b4638469a16035687f278ef3e8f8
parent15b5f77fe00f94a1215a4b2891644df339178b5f (diff)
downloadfpc-3595ed4d1c56d42ef6f335152ffadb8e11cb20fe.tar.gz
+ Aarch64: use frintz for int(...) instead of creating a helper call
git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@49260 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r--compiler/aarch64/ncpuinl.pas24
-rw-r--r--rtl/aarch64/math.inc30
2 files changed, 38 insertions, 16 deletions
diff --git a/compiler/aarch64/ncpuinl.pas b/compiler/aarch64/ncpuinl.pas
index a2e5f1352f..26fd698dae 100644
--- a/compiler/aarch64/ncpuinl.pas
+++ b/compiler/aarch64/ncpuinl.pas
@@ -1,7 +1,7 @@
{
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
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_round_real: tnode; override;
function first_trunc_real: tnode; override;
+ function first_int_real: tnode; override;
function first_fma : tnode; override;
procedure second_abs_real; override;
procedure second_sqr_real; override;
@@ -42,6 +43,7 @@ interface
procedure second_abs_long; override;
procedure second_round_real; override;
procedure second_trunc_real; override;
+ procedure second_int_real; override;
procedure second_get_frame; override;
procedure second_fma; override;
procedure second_prefetch; override;
@@ -108,6 +110,13 @@ implementation
end;
+ function taarch64inlinenode.first_int_real : tnode;
+ begin
+ expectloc:=LOC_MMREGISTER;
+ result:=nil;
+ end;
+
+
function taarch64inlinenode.first_fma : tnode;
begin
if ((is_double(resultdef)) or (is_single(resultdef))) then
@@ -187,6 +196,19 @@ implementation
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;
begin
location_reset(location,LOC_CREGISTER,OS_ADDR);
diff --git a/rtl/aarch64/math.inc b/rtl/aarch64/math.inc
index 8be40b21a8..de98808322 100644
--- a/rtl/aarch64/math.inc
+++ b/rtl/aarch64/math.inc
@@ -53,33 +53,33 @@
{$ifndef 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;
{$endif FPC_SYSTEM_HAS_INT}
{$ifndef 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;
{$endif FPC_SYSTEM_HAS_TRUNC}
{$ifndef 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;
{$endif FPC_SYSTEM_HAS_ROUND}