+ is_sse3_cpu, put into cpu unit, so x86-64 and i386 can share source code

git-svn-id: trunk@18785 -
This commit is contained in:
florian 2011-08-20 12:01:48 +00:00
parent c08f9e9657
commit 88c2c77319
3 changed files with 36 additions and 8 deletions

View File

@ -25,6 +25,8 @@ unit cpu;
{ returns the contents of the cr0 register } { returns the contents of the cr0 register }
function cr0 : longint; function cr0 : longint;
var
is_sse3_cpu : boolean = false;
implementation implementation
@ -72,4 +74,28 @@ unit cpu;
floating_point_emulation:=(cr0 and $4)<>0; floating_point_emulation:=(cr0 and $4)<>0;
end; end;
{$ASMMODE ATT}
function sse3_support : boolean;
var
_ecx : longint;
begin
if cpuid_support then
begin
asm
pushl %ebx
movl $1,%eax
cpuid
movl %ecx,_ecx
popl %ebx
end;
sse3_support:=(_ecx and $1)<>0;
end
else
{ a cpu with without cpuid instruction supports never sse3 }
sse3_support:=false;
end;
begin
is_sse3_cpu:=sse3_support;
end. end.

View File

@ -199,10 +199,8 @@ unit mmx;
end; end;
function sse2_support : boolean; function sse2_support : boolean;
var var
_edx : longint; _edx : longint;
begin begin
if cpuid_support then if cpuid_support then
begin begin
@ -220,14 +218,14 @@ unit mmx;
sse2_support:=false; sse2_support:=false;
end; end;
procedure emms;assembler;
procedure emms;assembler;
asm asm
emms emms
end; end;
procedure femms;assembler;
procedure femms;assembler;
asm asm
{ femms instruction not supported with older as versions } { femms instruction not supported with older as versions }
.byte 0x0f, 0x0e .byte 0x0f, 0x0e

View File

@ -22,7 +22,7 @@ unit cpu;
// Unless overridebinutils is defined (for ports usage), use db instead of the instruction // Unless overridebinutils is defined (for ports usage), use db instead of the instruction
{$ifndef overridebinutils} {$ifndef overridebinutils}
{$define oldbinutils} {$define oldbinutils}
{$endif} {$endif}
{$endif} {$endif}
uses uses
@ -31,6 +31,9 @@ unit cpu;
function InterlockedCompareExchange128Support : boolean;inline; function InterlockedCompareExchange128Support : boolean;inline;
function AESSupport : boolean;inline; function AESSupport : boolean;inline;
var
is_sse3_cpu : boolean = false;
function InterlockedCompareExchange128(var Target: Int128Rec; NewValue: Int128Rec; Comperand: Int128Rec): Int128Rec; function InterlockedCompareExchange128(var Target: Int128Rec; NewValue: Int128Rec; Comperand: Int128Rec): Int128Rec;
implementation implementation
@ -77,7 +80,7 @@ unit cpu;
movq 8(%r9),%rdx movq 8(%r9),%rdx
{$ifdef oldbinutils} {$ifdef oldbinutils}
.byte 0xF0,0x49,0x0F,0xC7,0x08 .byte 0xF0,0x49,0x0F,0xC7,0x08
{$else} {$else}
lock cmpxchg16b (%r8) lock cmpxchg16b (%r8)
{$endif} {$endif}
@ -115,6 +118,7 @@ unit cpu;
end; end;
{$endif win64} {$endif win64}
procedure SetupSupport; procedure SetupSupport;
var var
_ecx : longint; _ecx : longint;
@ -127,10 +131,10 @@ unit cpu;
popq %rbx popq %rbx
end; end;
_InterlockedCompareExchange128Support:=(_ecx and $2000)<>0; _InterlockedCompareExchange128Support:=(_ecx and $2000)<>0;
_AESSupport:=(_ecx and $2000000)<>0; _AESSupport:=(_ecx and $2000000)<>0;
is_sse3_cpu:=(_ecx and $1)<>0;
end; end;
begin begin
SetupSupport; SetupSupport;
end. end.