mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-27 20:39:16 +02:00
+ function needs_check_for_fpu_exceptions to unify fpu exception handling
This commit is contained in:
parent
629c87efc8
commit
a71cc71585
@ -493,7 +493,7 @@ interface
|
|||||||
if Result=nil then
|
if Result=nil then
|
||||||
begin
|
begin
|
||||||
if left.resultdef.typ=floatdef then
|
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);
|
Include(current_procinfo.flags,pi_do_call);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -85,7 +85,7 @@ implementation
|
|||||||
begin
|
begin
|
||||||
expectloc:=LOC_MMREGISTER;
|
expectloc:=LOC_MMREGISTER;
|
||||||
result:=nil;
|
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);
|
Include(current_procinfo.flags,pi_do_call);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ implementation
|
|||||||
begin
|
begin
|
||||||
expectloc:=LOC_MMREGISTER;
|
expectloc:=LOC_MMREGISTER;
|
||||||
result:=nil;
|
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);
|
Include(current_procinfo.flags,pi_do_call);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ implementation
|
|||||||
begin
|
begin
|
||||||
expectloc:=LOC_MMREGISTER;
|
expectloc:=LOC_MMREGISTER;
|
||||||
result:=nil;
|
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);
|
Include(current_procinfo.flags,pi_do_call);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ implementation
|
|||||||
begin
|
begin
|
||||||
expectloc:=LOC_MMREGISTER;
|
expectloc:=LOC_MMREGISTER;
|
||||||
result:=nil;
|
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);
|
Include(current_procinfo.flags,pi_do_call);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ implementation
|
|||||||
begin
|
begin
|
||||||
expectloc:=LOC_MMREGISTER;
|
expectloc:=LOC_MMREGISTER;
|
||||||
result:=nil;
|
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);
|
Include(current_procinfo.flags,pi_do_call);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ implementation
|
|||||||
begin
|
begin
|
||||||
expectloc:=LOC_MMREGISTER;
|
expectloc:=LOC_MMREGISTER;
|
||||||
result:=nil;
|
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);
|
Include(current_procinfo.flags,pi_do_call);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ implementation
|
|||||||
begin
|
begin
|
||||||
expectloc:=LOC_MMREGISTER;
|
expectloc:=LOC_MMREGISTER;
|
||||||
result:=nil;
|
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);
|
Include(current_procinfo.flags,pi_do_call);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -371,7 +371,7 @@ implementation
|
|||||||
begin
|
begin
|
||||||
expectloc:=LOC_MMREGISTER;
|
expectloc:=LOC_MMREGISTER;
|
||||||
Result:=nil;
|
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);
|
Include(current_procinfo.flags,pi_do_call);
|
||||||
end
|
end
|
||||||
else if is_32bitint(resultdef) then
|
else if is_32bitint(resultdef) then
|
||||||
|
@ -487,7 +487,7 @@ implementation
|
|||||||
begin
|
begin
|
||||||
Result:=inherited pass_1;
|
Result:=inherited pass_1;
|
||||||
if Result=nil then
|
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);
|
Include(current_procinfo.flags,pi_do_call);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -1780,9 +1780,8 @@ unit cgcpu;
|
|||||||
ai: taicpu;
|
ai: taicpu;
|
||||||
l: TAsmLabel;
|
l: TAsmLabel;
|
||||||
begin
|
begin
|
||||||
if ((cs_check_fpu_exceptions in current_settings.localswitches) and
|
if needs_check_for_fpu_exceptions and
|
||||||
not(FPUARM_HAS_EXCEPTION_TRAPPING in fpu_capabilities[current_settings.fputype]) and
|
(force or current_procinfo.FPUExceptionCheckNeeded) then
|
||||||
(force or current_procinfo.FPUExceptionCheckNeeded)) then
|
|
||||||
begin
|
begin
|
||||||
r:=getintregister(list,OS_INT);
|
r:=getintregister(list,OS_INT);
|
||||||
list.concat(taicpu.op_reg_reg(A_FMRX,r,NR_FPSCR));
|
list.concat(taicpu.op_reg_reg(A_FMRX,r,NR_FPSCR));
|
||||||
|
@ -224,11 +224,17 @@ unit cgutils;
|
|||||||
WARNING: d must not be a power of 2 (including 2^0 = 1) }
|
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);
|
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
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
systems,
|
systems,
|
||||||
verbose,
|
verbose,
|
||||||
|
globals,
|
||||||
|
cpuinfo,
|
||||||
cgobj;
|
cgobj;
|
||||||
|
|
||||||
{****************************************************************************
|
{****************************************************************************
|
||||||
@ -570,6 +576,24 @@ uses
|
|||||||
reciprocal:=swap_r;
|
reciprocal:=swap_r;
|
||||||
until d<=1;
|
until d<=1;
|
||||||
end;
|
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}
|
{$pop}
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -1040,7 +1040,7 @@ unit cgrv;
|
|||||||
ai: taicpu;
|
ai: taicpu;
|
||||||
l: TAsmLabel;
|
l: TAsmLabel;
|
||||||
begin
|
begin
|
||||||
if cs_check_fpu_exceptions in current_settings.localswitches then
|
if needs_check_for_fpu_exceptions then
|
||||||
begin
|
begin
|
||||||
r:=getintregister(list,OS_INT);
|
r:=getintregister(list,OS_INT);
|
||||||
list.concat(taicpu.op_reg(A_FRFLAGS,r));
|
list.concat(taicpu.op_reg(A_FRFLAGS,r));
|
||||||
|
Loading…
Reference in New Issue
Block a user