+ function needs_check_for_fpu_exceptions to unify fpu exception handling

This commit is contained in:
florian 2024-02-13 17:19:58 +01:00
parent 629c87efc8
commit a71cc71585
6 changed files with 37 additions and 14 deletions

View File

@ -493,7 +493,7 @@ interface
if Result=nil then
begin
if left.resultdef.typ=floatdef then
if cs_check_fpu_exceptions in current_settings.localswitches then
if needs_check_for_fpu_exceptions then
Include(current_procinfo.flags,pi_do_call);
end;
end;

View File

@ -85,7 +85,7 @@ implementation
begin
expectloc:=LOC_MMREGISTER;
result:=nil;
if cs_check_fpu_exceptions in current_settings.localswitches then
if needs_check_for_fpu_exceptions then
Include(current_procinfo.flags,pi_do_call);
end;
@ -94,7 +94,7 @@ implementation
begin
expectloc:=LOC_MMREGISTER;
result:=nil;
if cs_check_fpu_exceptions in current_settings.localswitches then
if needs_check_for_fpu_exceptions then
Include(current_procinfo.flags,pi_do_call);
end;
@ -103,7 +103,7 @@ implementation
begin
expectloc:=LOC_MMREGISTER;
result:=nil;
if cs_check_fpu_exceptions in current_settings.localswitches then
if needs_check_for_fpu_exceptions then
Include(current_procinfo.flags,pi_do_call);
end;
@ -112,7 +112,7 @@ implementation
begin
expectloc:=LOC_MMREGISTER;
result:=nil;
if cs_check_fpu_exceptions in current_settings.localswitches then
if needs_check_for_fpu_exceptions then
Include(current_procinfo.flags,pi_do_call);
end;
@ -121,7 +121,7 @@ implementation
begin
expectloc:=LOC_MMREGISTER;
result:=nil;
if cs_check_fpu_exceptions in current_settings.localswitches then
if needs_check_for_fpu_exceptions then
Include(current_procinfo.flags,pi_do_call);
end;
@ -130,7 +130,7 @@ implementation
begin
expectloc:=LOC_MMREGISTER;
result:=nil;
if cs_check_fpu_exceptions in current_settings.localswitches then
if needs_check_for_fpu_exceptions then
Include(current_procinfo.flags,pi_do_call);
end;
@ -139,7 +139,7 @@ implementation
begin
expectloc:=LOC_MMREGISTER;
result:=nil;
if cs_check_fpu_exceptions in current_settings.localswitches then
if needs_check_for_fpu_exceptions then
Include(current_procinfo.flags,pi_do_call);
end;
@ -371,7 +371,7 @@ implementation
begin
expectloc:=LOC_MMREGISTER;
Result:=nil;
if cs_check_fpu_exceptions in current_settings.localswitches then
if needs_check_for_fpu_exceptions then
Include(current_procinfo.flags,pi_do_call);
end
else if is_32bitint(resultdef) then

View File

@ -487,7 +487,7 @@ implementation
begin
Result:=inherited pass_1;
if Result=nil then
if cs_check_fpu_exceptions in current_settings.localswitches then
if needs_check_for_fpu_exceptions then
Include(current_procinfo.flags,pi_do_call);
end;

View File

@ -1780,9 +1780,8 @@ unit cgcpu;
ai: taicpu;
l: TAsmLabel;
begin
if ((cs_check_fpu_exceptions in current_settings.localswitches) and
not(FPUARM_HAS_EXCEPTION_TRAPPING in fpu_capabilities[current_settings.fputype]) and
(force or current_procinfo.FPUExceptionCheckNeeded)) then
if needs_check_for_fpu_exceptions and
(force or current_procinfo.FPUExceptionCheckNeeded) then
begin
r:=getintregister(list,OS_INT);
list.concat(taicpu.op_reg_reg(A_FMRX,r,NR_FPSCR));

View File

@ -224,11 +224,17 @@ unit cgutils;
WARNING: d must not be a power of 2 (including 2^0 = 1) }
procedure calc_mul_inverse(N: byte; d: aWord; out reciprocal: aWord; out shift: Byte);
{ returns true if the CPU architecture we are currently compiling for needs
software checks for fpu exceptions }
function needs_check_for_fpu_exceptions : boolean;
implementation
uses
systems,
verbose,
globals,
cpuinfo,
cgobj;
{****************************************************************************
@ -570,6 +576,24 @@ uses
reciprocal:=swap_r;
until d<=1;
end;
function needs_check_for_fpu_exceptions: boolean;
begin
{$if defined(AARCH64)}
result:=cs_check_fpu_exceptions in current_settings.localswitches;
{$elseif defined(ARM)}
result:=(cs_check_fpu_exceptions in current_settings.localswitches) and
not(FPUARM_HAS_EXCEPTION_TRAPPING in fpu_capabilities[current_settings.fputype]);
{$elseif defined(RISCV)}
result:=cs_check_fpu_exceptions in current_settings.localswitches;
{$elseif defined(XTENSA)}
result:=cs_check_fpu_exceptions in current_settings.localswitches;
{$else}
result:=false;
{$endif}
end;
{$pop}
end.

View File

@ -1040,7 +1040,7 @@ unit cgrv;
ai: taicpu;
l: TAsmLabel;
begin
if cs_check_fpu_exceptions in current_settings.localswitches then
if needs_check_for_fpu_exceptions then
begin
r:=getintregister(list,OS_INT);
list.concat(taicpu.op_reg(A_FRFLAGS,r));