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

git-svn-id: trunk@49260 -
This commit is contained in:
florian 2021-04-25 08:53:12 +00:00
parent bc42d64348
commit cd3570caf1
2 changed files with 38 additions and 16 deletions

View File

@ -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);

View File

@ -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}