+ 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 }
function cr0 : longint;
var
is_sse3_cpu : boolean = false;
implementation
@ -72,4 +74,28 @@ unit cpu;
floating_point_emulation:=(cr0 and $4)<>0;
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.

View File

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

View File

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