Browse Source

* reorganized ror/rol defines

git-svn-id: trunk@11472 -
florian 17 years ago
parent
commit
20e632c8d8
3 changed files with 104 additions and 97 deletions
  1. 0 27
      rtl/i386/i386.inc
  2. 52 37
      rtl/inc/generic.inc
  3. 52 33
      rtl/inc/systemh.inc

+ 0 - 27
rtl/i386/i386.inc

@@ -1538,30 +1538,3 @@ end;
 
 {$endif}
 
-{$ifdef FPC_HAS_INTERNAL_ROX}
-{ the i386 cg doesn't support yet directly coded 64 bit rotates }
-function Ror(Const AValue : QWord): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
-  begin
-    Result:=(AValue shr 1) or (AValue shl 63);
-  end;
-
-
-function Ror(Const AValue : QWord;Dist : Byte): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
-  begin
-    Dist:=Dist and 63;
-    Result:=(AValue shr Dist) or (AValue shl (64-Dist));
-  end;
-
-
-function Rol(Const AValue : QWord): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
-  begin
-    Result:=(AValue shl 1) or (AValue shr 63);
-  end;
-
-
-function Rol(Const AValue : QWord;Dist : Byte): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
-  begin
-    Dist:=Dist and 63;
-    Result:=(AValue shl Dist) or (AValue shr (64-Dist));
-  end;
-{$endif FPC_HAS_INTERNAL_ROX}

+ 52 - 37
rtl/inc/generic.inc

@@ -2045,8 +2045,8 @@ end;
 
 {$endif FPC_SYSTEM_HAS_MEM_BARRIER}
 
-{$ifndef FPC_HAS_INTERNAL_ROX}
-{$ifndef FPC_SYSTEM_HAS_ROX}
+{$ifndef FPC_HAS_INTERNAL_ROX_BYTE}
+{$ifndef FPC_SYSTEM_HAS_ROX_BYTE}
 
 function Ror(Const AValue : Byte): Byte;{$ifdef SYSTEMINLINE}inline;{$endif}
   begin
@@ -2060,7 +2060,25 @@ function Ror(Const AValue : Byte;Dist : Byte): Byte;{$ifdef SYSTEMINLINE}inline;
     Result:=(AValue shr Dist) or (AValue shl (8-Dist));
   end;
 
-  
+
+function Rol(Const AValue : Byte): Byte;{$ifdef SYSTEMINLINE}inline;{$endif}
+  begin
+    Result:=(AValue shl 1) or (AValue shr 7);
+  end;
+
+
+function Rol(Const AValue : Byte;Dist : Byte): Byte;{$ifdef SYSTEMINLINE}inline;{$endif}
+  begin
+    Dist:=Dist and 7;
+    Result:=(AValue shl Dist) or (AValue shr (8-Dist));
+  end;
+
+{$endif FPC_SYSTEM_HAS_ROX_BYTE}
+{$endif FPC_HAS_INTERNAL_ROX_BYTE}
+
+{$ifndef FPC_HAS_INTERNAL_ROX_WORD}
+{$ifndef FPC_SYSTEM_HAS_ROX_WORD}
+
 function Ror(Const AValue : Word): Word;{$ifdef SYSTEMINLINE}inline;{$endif}
   begin
     Result:=(AValue shr 1) or (AValue shl 15);
@@ -2073,69 +2091,66 @@ function Ror(Const AValue : Word;Dist : Byte): Word;{$ifdef SYSTEMINLINE}inline;
     Result:=(AValue shr Dist) or (AValue shl (16-Dist));
   end;
 
-  
-function Ror(Const AValue : DWord): DWord;{$ifdef SYSTEMINLINE}inline;{$endif}
+
+function Rol(Const AValue : Word): Word;{$ifdef SYSTEMINLINE}inline;{$endif}
   begin
-    Result:=(AValue shr 1) or (AValue shl 31);
+    Result:=(AValue shl 1) or (AValue shr 15);
   end;
 
 
-function Ror(Const AValue : DWord;Dist : Byte): DWord;{$ifdef SYSTEMINLINE}inline;{$endif}
+function Rol(Const AValue : Word;Dist : Byte): Word;{$ifdef SYSTEMINLINE}inline;{$endif}
   begin
-    Dist:=Dist and 31;
-    Result:=(AValue shr Dist) or (AValue shl (32-Dist));
+    Dist:=Dist and 15;
+    Result:=(AValue shl Dist) or (AValue shr (16-Dist));
   end;
-  
 
-function Ror(Const AValue : QWord): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
-  begin
-    Result:=(AValue shr 1) or (AValue shl 63);
-  end;
+{$endif FPC_SYSTEM_HAS_ROX_WORD}
+{$endif FPC_HAS_INTERNAL_ROX_WORD}
 
+{$ifndef FPC_HAS_INTERNAL_ROX_DWORD}
+{$ifndef FPC_SYSTEM_HAS_ROX_DWORD}
 
-function Ror(Const AValue : QWord;Dist : Byte): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
+function Ror(Const AValue : DWord): DWord;{$ifdef SYSTEMINLINE}inline;{$endif}
   begin
-    Dist:=Dist and 63;
-    Result:=(AValue shr Dist) or (AValue shl (64-Dist));
+    Result:=(AValue shr 1) or (AValue shl 31);
   end;
 
 
-function Rol(Const AValue : Byte): Byte;{$ifdef SYSTEMINLINE}inline;{$endif}
+function Ror(Const AValue : DWord;Dist : Byte): DWord;{$ifdef SYSTEMINLINE}inline;{$endif}
   begin
-    Result:=(AValue shl 1) or (AValue shr 7);
+    Dist:=Dist and 31;
+    Result:=(AValue shr Dist) or (AValue shl (32-Dist));
   end;
 
 
-function Rol(Const AValue : Byte;Dist : Byte): Byte;{$ifdef SYSTEMINLINE}inline;{$endif}
+function Rol(Const AValue : DWord): DWord;{$ifdef SYSTEMINLINE}inline;{$endif}
   begin
-    Dist:=Dist and 7;
-    Result:=(AValue shl Dist) or (AValue shr (8-Dist));
+    Result:=(AValue shl 1) or (AValue shr 31);
   end;
 
 
-function Rol(Const AValue : Word): Word;{$ifdef SYSTEMINLINE}inline;{$endif}
+function Rol(Const AValue : DWord;Dist : Byte): DWord;{$ifdef SYSTEMINLINE}inline;{$endif}
   begin
-    Result:=(AValue shl 1) or (AValue shr 15);
+    Dist:=Dist and 31;
+    Result:=(AValue shl Dist) or (AValue shr (32-Dist));
   end;
 
+{$endif FPC_SYSTEM_HAS_ROX_DWORD}
+{$endif FPC_HAS_INTERNAL_ROX_DWORD}
 
-function Rol(Const AValue : Word;Dist : Byte): Word;{$ifdef SYSTEMINLINE}inline;{$endif}
-  begin
-    Dist:=Dist and 15;
-    Result:=(AValue shl Dist) or (AValue shr (16-Dist));
-  end;
-
+{$ifndef FPC_HAS_INTERNAL_ROX_QWORD}
+{$ifndef FPC_SYSTEM_HAS_ROX_QWORD}
 
-function Rol(Const AValue : DWord): DWord;{$ifdef SYSTEMINLINE}inline;{$endif}
+function Ror(Const AValue : QWord): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
   begin
-    Result:=(AValue shl 1) or (AValue shr 31);
+    Result:=(AValue shr 1) or (AValue shl 63);
   end;
 
 
-function Rol(Const AValue : DWord;Dist : Byte): DWord;{$ifdef SYSTEMINLINE}inline;{$endif}
+function Ror(Const AValue : QWord;Dist : Byte): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
   begin
-    Dist:=Dist and 31;
-    Result:=(AValue shl Dist) or (AValue shr (32-Dist));
+    Dist:=Dist and 63;
+    Result:=(AValue shr Dist) or (AValue shl (64-Dist));
   end;
 
 
@@ -2151,6 +2166,6 @@ function Rol(Const AValue : QWord;Dist : Byte): QWord;{$ifdef SYSTEMINLINE}inlin
     Result:=(AValue shl Dist) or (AValue shr (64-Dist));
   end;
 
-{$endif FPC_SYSTEM_HAS_ROX}
-{$endif FPC_HAS_INTERNAL_ROX}
+{$endif FPC_SYSTEM_HAS_ROX_QWORD}
+{$endif FPC_HAS_INTERNAL_ROX_QWORD}
 

+ 52 - 33
rtl/inc/systemh.inc

@@ -609,55 +609,74 @@ function NtoLE(const AValue: Int64): Int64;{$ifdef SYSTEMINLINE}inline;{$endif}
 function NtoLE(const AValue: QWord): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
 
 {$ifdef FPC_HAS_INTERNAL_ROX}
+{$if defined(cpux86_64) or defined(cpui386)}
+{$define FPC_HAS_INTERNAL_ROX_BYTE}
+{$define FPC_HAS_INTERNAL_ROX_WORD}
+{$define FPC_HAS_INTERNAL_ROX_DWORD}
+{$endif defined(cpux86_64) or defined(cpui386)}
+{$if defined(cpux86_64)}
+{$define FPC_HAS_INTERNAL_ROX_QWORD}
+{$endif defined(cpux86_64)}
+{$endif FPC_HAS_INTERNAL_ROX}
+
+{$ifdef FPC_HAS_INTERNAL_ROX_BYTE}
 function Ror(Const AValue : Byte): Byte;[internproc:fpc_in_ror_x];
 function Ror(Const AValue : Byte;Dist : Byte): Byte;[internproc:fpc_in_ror_x_x];
-function Ror(Const AValue : Word): Word;[internproc:fpc_in_ror_x];
-function Ror(Const AValue : Word;Dist : Byte): Word;[internproc:fpc_in_ror_x_x];
-function Ror(Const AValue : DWord): DWord;[internproc:fpc_in_ror_x];
-function Ror(Const AValue : DWord;Dist : Byte): DWord;[internproc:fpc_in_ror_x_x];
-{ the i386 cg doesn't support yet directly coded 64 bit rotates }
-{$ifndef cpui386}
-function Ror(Const AValue : QWord): QWord;[internproc:fpc_in_ror_x];
-function Ror(Const AValue : QWord;Dist : Byte): QWord;[internproc:fpc_in_ror_x_x];
-{$else cpui386}
-function Ror(Const AValue : QWord): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
-function Ror(Const AValue : QWord;Dist : Byte): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
-{$endif cpui386}
 
 function Rol(Const AValue : Byte): Byte;[internproc:fpc_in_rol_x];
 function Rol(Const AValue : Byte;Dist : Byte): Byte;[internproc:fpc_in_rol_x_x];
-function Rol(Const AValue : Word): Word;[internproc:fpc_in_rol_x];
-function Rol(Const AValue : Word;Dist : Byte): Word;[internproc:fpc_in_rol_x_x];
-function Rol(Const AValue : DWord): DWord;[internproc:fpc_in_rol_x];
-function Rol(Const AValue : DWord;Dist : Byte): DWord;[internproc:fpc_in_rol_x_x];
-{ the i386 cg doesn't support yet directly coded 64 bit rotates }
-{$ifndef cpui386}
-function Rol(Const AValue : QWord): QWord;[internproc:fpc_in_rol_x];
-function Rol(Const AValue : QWord;Dist : Byte): QWord;[internproc:fpc_in_rol_x_x];
-{$else cpui386}
-function Rol(Const AValue : QWord): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
-function Rol(Const AValue : QWord;Dist : Byte): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
-{$endif cpui386}
-
-{$else FPC_HAS_INTERNAL_ROX}
+{$else FPC_HAS_INTERNAL_ROX_BYTE}
 function Ror(Const AValue : Byte): Byte;{$ifdef SYSTEMINLINE}inline;{$endif}
 function Ror(Const AValue : Byte;Dist : Byte): Byte;{$ifdef SYSTEMINLINE}inline;{$endif}
-function Ror(Const AValue : Word): Word;{$ifdef SYSTEMINLINE}inline;{$endif}
-function Ror(Const AValue : Word;Dist : Byte): Word;{$ifdef SYSTEMINLINE}inline;{$endif}
-function Ror(Const AValue : DWord): DWord;{$ifdef SYSTEMINLINE}inline;{$endif}
-function Ror(Const AValue : DWord;Dist : Byte): DWord;{$ifdef SYSTEMINLINE}inline;{$endif}
-function Ror(Const AValue : QWord): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
-function Ror(Const AValue : QWord;Dist : Byte): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
 
 function Rol(Const AValue : Byte): Byte;{$ifdef SYSTEMINLINE}inline;{$endif}
 function Rol(Const AValue : Byte;Dist : Byte): Byte;{$ifdef SYSTEMINLINE}inline;{$endif}
+{$endif FPC_HAS_INTERNAL_ROX_BYTE}
+
+
+{$ifdef FPC_HAS_INTERNAL_ROX_WORD}
+function Ror(Const AValue : Word): Word;[internproc:fpc_in_ror_x];
+function Ror(Const AValue : Word;Dist : Byte): Word;[internproc:fpc_in_ror_x_x];
+
+function Rol(Const AValue : Word): Word;[internproc:fpc_in_rol_x];
+function Rol(Const AValue : Word;Dist : Byte): Word;[internproc:fpc_in_rol_x_x];
+{$else FPC_HAS_INTERNAL_ROX_WORD}
+function Ror(Const AValue : Word): Word;{$ifdef SYSTEMINLINE}inline;{$endif}
+function Ror(Const AValue : Word;Dist : Byte): Word;{$ifdef SYSTEMINLINE}inline;{$endif}
+
 function Rol(Const AValue : Word): Word;{$ifdef SYSTEMINLINE}inline;{$endif}
 function Rol(Const AValue : Word;Dist : Byte): Word;{$ifdef SYSTEMINLINE}inline;{$endif}
+{$endif FPC_HAS_INTERNAL_ROX_WORD}
+
+
+{$ifdef FPC_HAS_INTERNAL_ROX_DWORD}
+function Ror(Const AValue : DWord): DWord;[internproc:fpc_in_ror_x];
+function Ror(Const AValue : DWord;Dist : Byte): DWord;[internproc:fpc_in_ror_x_x];
+
+function Rol(Const AValue : DWord): DWord;[internproc:fpc_in_rol_x];
+function Rol(Const AValue : DWord;Dist : Byte): DWord;[internproc:fpc_in_rol_x_x];
+{$else FPC_HAS_INTERNAL_ROX_DWORD}
+function Ror(Const AValue : DWord): DWord;{$ifdef SYSTEMINLINE}inline;{$endif}
+function Ror(Const AValue : DWord;Dist : Byte): DWord;{$ifdef SYSTEMINLINE}inline;{$endif}
+
 function Rol(Const AValue : DWord): DWord;{$ifdef SYSTEMINLINE}inline;{$endif}
 function Rol(Const AValue : DWord;Dist : Byte): DWord;{$ifdef SYSTEMINLINE}inline;{$endif}
+{$endif FPC_HAS_INTERNAL_ROX_DWORD}
+
+
+{$ifdef FPC_HAS_INTERNAL_ROX_QWORD}
+function Ror(Const AValue : QWord): QWord;[internproc:fpc_in_ror_x];
+function Ror(Const AValue : QWord;Dist : Byte): QWord;[internproc:fpc_in_ror_x_x];
+
+function Rol(Const AValue : QWord): QWord;[internproc:fpc_in_rol_x];
+function Rol(Const AValue : QWord;Dist : Byte): QWord;[internproc:fpc_in_rol_x_x];
+{$else FPC_HAS_INTERNAL_ROX_QWORD}
+function Ror(Const AValue : QWord): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
+function Ror(Const AValue : QWord;Dist : Byte): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
+
 function Rol(Const AValue : QWord): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
 function Rol(Const AValue : QWord;Dist : Byte): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
-{$endif FPC_HAS_INTERNAL_ROX}
+{$endif FPC_HAS_INTERNAL_ROX_QWORD}
 
 {$ifndef FPUNONE}
 { float math routines }