+ added abs(smallint) and abs(shortint) for cpus with 8-bit or 16-bit alu

git-svn-id: trunk@36327 -
This commit is contained in:
nickysn 2017-05-25 14:14:18 +00:00
parent 9946393018
commit fa645dcaf7
3 changed files with 46 additions and 0 deletions

View File

@ -3378,6 +3378,12 @@ begin
def_system_macro('FPC_VARIANTCOPY_FIXED');
def_system_macro('FPC_DYNARRAYCOPY_FIXED');
{$if defined(avr)}
def_system_macro('FPC_HAS_INTERNAL_ABS_SHORTINT');
{$endif}
{$if defined(i8086) or defined(avr)}
def_system_macro('FPC_HAS_INTERNAL_ABS_SMALLINT');
{$endif i8086 or avr}
{ abs(long) is handled internally on all CPUs }
def_system_macro('FPC_HAS_INTERNAL_ABS_LONG');
{$if defined(x86_64) or defined(powerpc64) or defined(cpuaarch64)}

View File

@ -1889,6 +1889,30 @@ function fpc_mod_shortint(n,z : shortint) : shortint; [public,alias: 'FPC_MOD_SH
{****************************************************************************}
{$if defined(CPUINT8)}
{$ifndef FPC_SYSTEM_HAS_ABS_SHORTINT}
function abs(l:shortint):shortint;{$ifdef SYSTEMINLINE}inline;{$endif}
begin
if l<0 then
abs:=-l
else
abs:=l;
end;
{$endif not FPC_SYSTEM_HAS_ABS_SMALLINT}
{$endif CPUINT8}
{$if defined(CPUINT16) or defined(CPUINT8)}
{$ifndef FPC_SYSTEM_HAS_ABS_SMALLINT}
function abs(l:smallint):smallint;{$ifdef SYSTEMINLINE}inline;{$endif}
begin
if l<0 then
abs:=-l
else
abs:=l;
end;
{$endif not FPC_SYSTEM_HAS_ABS_SMALLINT}
{$endif CPUINT16 or CPUINT8}
{$ifndef FPC_SYSTEM_HAS_ABS_LONGINT}
{ This is only needed to bootstrap on SPARC targets
(MIPS and m68k too, but they have no releases, so bootstrapping is not an issue) }

View File

@ -847,6 +847,22 @@ Function Random: extended;
Procedure Randomize;
{$endif FPC_HAS_FEATURE_RANDOM}
{$if defined(CPUINT8)}
{$ifdef FPC_HAS_INTERNAL_ABS_SHORTINT}
{$define FPC_SYSTEM_HAS_ABS_SHORTINT}
Function abs(l:shortint):shortint;[internproc:fpc_in_abs_long];
{$else FPC_SYSTEM_HAS_ABS_SHORTINT}
Function abs(l:shortint):shortint;[internconst:fpc_in_const_abs];{$ifdef SYSTEMINLINE}inline;{$endif}
{$endif FPC_SYSTEM_HAS_ABS_SHORTINT}
{$endif CPUINT8}
{$if defined(CPUINT16) or defined(CPUINT8)}
{$ifdef FPC_HAS_INTERNAL_ABS_SMALLINT}
{$define FPC_SYSTEM_HAS_ABS_SMALLINT}
Function abs(l:smallint):smallint;[internproc:fpc_in_abs_long];
{$else FPC_HAS_INTERNAL_ABS_LONG}
Function abs(l:smallint):smallint;[internconst:fpc_in_const_abs];{$ifdef SYSTEMINLINE}inline;{$endif}
{$endif FPC_HAS_INTERNAL_ABS_LONG}
{$endif CPUINT16 or CPUINT8}
{$ifdef FPC_HAS_INTERNAL_ABS_LONG}
{$define FPC_SYSTEM_HAS_ABS_LONGINT}
Function abs(l:longint):longint;[internproc:fpc_in_abs_long];