o unified interface of i386 and x86-64 cpu unit:

+ InterlockedCompareExchange128Support for i386 always returning false
  + AESSupport for i386
  + dummy InterlockedCompareExchange128 for i386 throwing an rte 217

git-svn-id: trunk@32857 -
This commit is contained in:
florian 2016-01-05 15:23:26 +00:00
parent 4bf603694c
commit 77cf67b59a

View File

@ -15,8 +15,12 @@
**********************************************************************} **********************************************************************}
{$mode objfpc} {$mode objfpc}
unit cpu; unit cpu;
interface interface
uses
sysutils;
{ returns true, if the processor supports the cpuid instruction } { returns true, if the processor supports the cpuid instruction }
function cpuid_support : boolean; function cpuid_support : boolean;
@ -26,6 +30,8 @@ unit cpu;
{ returns the contents of the cr0 register } { returns the contents of the cr0 register }
function cr0 : longint; function cr0 : longint;
function InterlockedCompareExchange128Support : boolean;
function AESSupport : boolean;inline;
function AVXSupport: boolean;inline; function AVXSupport: boolean;inline;
function AVX2Support: boolean;inline; function AVX2Support: boolean;inline;
function FMASupport: boolean;inline; function FMASupport: boolean;inline;
@ -33,14 +39,24 @@ unit cpu;
var var
is_sse3_cpu : boolean = false; is_sse3_cpu : boolean = false;
function InterlockedCompareExchange128(var Target: Int128Rec; NewValue: Int128Rec; Comperand: Int128Rec): Int128Rec;
implementation implementation
{$ASMMODE INTEL} {$ASMMODE INTEL}
var var
_AVXSupport, _AVXSupport,
_AVX2Support, _AVX2Support,
_AESSupport,
_FMASupport : boolean; _FMASupport : boolean;
function InterlockedCompareExchange128(var Target: Int128Rec; NewValue: Int128Rec; Comperand: Int128Rec): Int128Rec;
begin
RunError(217);
end;
function cpuid_support : boolean;assembler; function cpuid_support : boolean;assembler;
{ {
Check if the ID-flag can be changed, if changed then CpuID is supported. Check if the ID-flag can be changed, if changed then CpuID is supported.
@ -106,7 +122,8 @@ unit cpu;
movl %ecx,_ecx movl %ecx,_ecx
popl %ebx popl %ebx
end; end;
is_sse3_cpu:=(_ecx and $1)<>0; _AESSupport:=(_ecx and $2000000)<>0;
_AVXSupport:= _AVXSupport:=
{ XGETBV suspport? } { XGETBV suspport? }
((_ecx and $08000000)<>0) and ((_ecx and $08000000)<>0) and
@ -115,6 +132,8 @@ unit cpu;
{ avx supported? } { avx supported? }
((_ecx and $10000000)<>0); ((_ecx and $10000000)<>0);
is_sse3_cpu:=(_ecx and $1)<>0;
_FMASupport:=_AVXSupport and ((_ecx and $1000)<>0); _FMASupport:=_AVXSupport and ((_ecx and $1000)<>0);
asm asm
@ -130,6 +149,19 @@ unit cpu;
end; end;
function InterlockedCompareExchange128Support : boolean;
begin
{ 32 Bit CPUs have no 128 Bit interlocked exchange support }
result:=false;
end;
function AESSupport : boolean;
begin
result:=_AESSupport;
end;
function AVXSupport: boolean;inline; function AVXSupport: boolean;inline;
begin begin
result:=_AVXSupport; result:=_AVXSupport;