Просмотр исходного кода

+ added sqr(shortint) and sqr(smallint) for CPUs with 8/16-bit alu

git-svn-id: trunk@36342 -
nickysn 8 лет назад
Родитель
Сommit
ba665e103c
2 измененных файлов с 24 добавлено и 0 удалено
  1. 18 0
      rtl/inc/generic.inc
  2. 6 0
      rtl/inc/systemh.inc

+ 18 - 0
rtl/inc/generic.inc

@@ -1993,6 +1993,24 @@ end;
 
 {$endif ndef FPC_SYSTEM_HAS_ODD_QWORD}
 
+{$if defined(CPUINT8)}
+{$ifndef FPC_SYSTEM_HAS_SQR_SHORTINT}
+function sqr(l:shortint):shortint;{$ifdef SYSTEMINLINE}inline;{$endif}
+begin
+   sqr:=l*l;
+end;
+{$endif ndef FPC_SYSTEM_HAS_SQR_SHORTINT}
+{$endif CPUINT8}
+
+{$if defined(CPUINT16) or defined(CPUINT8)}
+{$ifndef FPC_SYSTEM_HAS_SQR_SMALLINT}
+function sqr(l:smallint):smallint;{$ifdef SYSTEMINLINE}inline;{$endif}
+begin
+   sqr:=l*l;
+end;
+{$endif ndef FPC_SYSTEM_HAS_SQR_SMALLINT}
+{$endif CPUINT16 or CPUINT8}
+
 {$ifndef FPC_SYSTEM_HAS_SQR_LONGINT}
 
 function sqr(l:longint):longint;{$ifdef SYSTEMINLINE}inline;{$endif}

+ 6 - 0
rtl/inc/systemh.inc

@@ -875,6 +875,12 @@ Function abs(l:Int64):Int64;[internproc:fpc_in_abs_long];
 {$else FPC_HAS_INTERNAL_ABS_INT64}
 Function abs(l:Int64):Int64;[internconst:fpc_in_const_abs];{$ifdef SYSTEMINLINE}inline;{$endif}
 {$endif FPC_HAS_INTERNAL_ABS_INT64}
+{$if defined(CPUINT8)}
+Function sqr(l:shortint):shortint;[internconst:fpc_in_const_sqr];{$ifdef SYSTEMINLINE}inline;{$endif}
+{$endif CPUINT8}
+{$if defined(CPUINT16) or defined(CPUINT8)}
+Function sqr(l:smallint):smallint;[internconst:fpc_in_const_sqr];{$ifdef SYSTEMINLINE}inline;{$endif}
+{$endif CPUINT16 or CPUINT8}
 Function sqr(l:Longint):Longint;[internconst:fpc_in_const_sqr];{$ifdef SYSTEMINLINE}inline;{$endif}
 Function sqr(l:Int64):Int64;[internconst:fpc_in_const_sqr];{$ifdef SYSTEMINLINE}inline;{$endif}
 Function sqr(l:QWord):QWord;[internconst:fpc_in_const_sqr];{$ifdef SYSTEMINLINE}inline;{$endif}