mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 15:09:20 +02:00
* i386: Perform all CPU-related initialization in fpc_cpucodeinit, instead of having it scattered between fpc_cpuinit,fpc_cpucodeinit and check_sse_support. Simplifies things quite a bit.
- check_sse_support and mmx_support are no longer needed, removed. git-svn-id: trunk@27169 -
This commit is contained in:
parent
a9b0a92873
commit
6baba5065c
@ -43,58 +43,6 @@ function cpuid_support : boolean;assembler;nostackframe;
|
|||||||
setnz %al
|
setnz %al
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure check_sse_support;
|
|
||||||
var
|
|
||||||
_ecx,_edx : longint;
|
|
||||||
begin
|
|
||||||
if cpuid_support then
|
|
||||||
begin
|
|
||||||
asm
|
|
||||||
pushl %ebx
|
|
||||||
movl $1,%eax
|
|
||||||
cpuid
|
|
||||||
movl %edx,_edx
|
|
||||||
movl %ecx,_ecx
|
|
||||||
popl %ebx
|
|
||||||
end;
|
|
||||||
has_sse_support:=((_edx and $2000000)<>0) and os_supports_sse;
|
|
||||||
has_sse2_support:=((_edx and $4000000)<>0) and os_supports_sse;
|
|
||||||
has_sse3_support:=((_ecx and $200)<>0) and os_supports_sse;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
{ a cpu with without cpuid instruction supports never sse }
|
|
||||||
has_sse_support:=false;
|
|
||||||
has_sse2_support:=false;
|
|
||||||
has_sse3_support:=false;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{ returns true, if the processor supports the mmx instructions }
|
|
||||||
function mmx_support : boolean;
|
|
||||||
|
|
||||||
var
|
|
||||||
_edx : longint;
|
|
||||||
|
|
||||||
begin
|
|
||||||
if cpuid_support then
|
|
||||||
begin
|
|
||||||
asm
|
|
||||||
pushl %ebx
|
|
||||||
movl $1,%eax
|
|
||||||
cpuid
|
|
||||||
movl %edx,_edx
|
|
||||||
popl %ebx
|
|
||||||
end;
|
|
||||||
mmx_support:=(_edx and $800000)<>0;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
{ a cpu with without cpuid instruction supports never mmx }
|
|
||||||
mmx_support:=false;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{$ifndef FPC_PIC}
|
{$ifndef FPC_PIC}
|
||||||
{$ifndef FPC_SYSTEM_HAS_MOVE}
|
{$ifndef FPC_SYSTEM_HAS_MOVE}
|
||||||
{$define USE_FASTMOVE}
|
{$define USE_FASTMOVE}
|
||||||
@ -110,10 +58,6 @@ procedure fpc_cpuinit;
|
|||||||
has_mmx_support:=mmx_support;
|
has_mmx_support:=mmx_support;
|
||||||
setup_fastmove;
|
setup_fastmove;
|
||||||
}
|
}
|
||||||
os_supports_sse:=false;
|
|
||||||
{ don't let libraries influence the FPU cw set by the host program }
|
|
||||||
if IsLibrary then
|
|
||||||
Default8087CW:=Get8087CW;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$ifndef darwin}
|
{$ifndef darwin}
|
||||||
@ -1449,33 +1393,46 @@ Procedure SysResetFPU;
|
|||||||
|
|
||||||
{ because of the brain dead sse detection on x86, this test is post poned }
|
{ because of the brain dead sse detection on x86, this test is post poned }
|
||||||
procedure fpc_cpucodeinit;
|
procedure fpc_cpucodeinit;
|
||||||
|
var
|
||||||
|
_ecx,_edx : longint;
|
||||||
begin
|
begin
|
||||||
os_supports_sse:=true;
|
if cpuid_support then
|
||||||
check_sse_support;
|
|
||||||
os_supports_sse:=has_sse_support;
|
|
||||||
if os_supports_sse then
|
|
||||||
begin
|
begin
|
||||||
sse_check:=true;
|
|
||||||
asm
|
asm
|
||||||
{ force an sse exception if no sse is supported, the exception handler sets
|
movl $1,%eax
|
||||||
os_supports_sse to false then }
|
cpuid
|
||||||
{ don't change this instruction, the code above depends on its size }
|
movl %edx,_edx
|
||||||
movaps %xmm7, %xmm6
|
movl %ecx,_ecx
|
||||||
end;
|
end ['ebx'];
|
||||||
sse_check:=false;
|
has_mmx_support:=(_edx and $800000)<>0;
|
||||||
|
if ((_edx and $2000000)<>0) then
|
||||||
|
begin
|
||||||
|
os_supports_sse:=true;
|
||||||
|
sse_check:=true;
|
||||||
|
asm
|
||||||
|
{ force an sse exception if no sse is supported, the exception handler sets
|
||||||
|
os_supports_sse to false then }
|
||||||
|
{ don't change this instruction, the code above depends on its size }
|
||||||
|
movaps %xmm7, %xmm6
|
||||||
|
end;
|
||||||
|
sse_check:=false;
|
||||||
|
has_sse_support:=os_supports_sse;
|
||||||
|
end;
|
||||||
|
if has_sse_support then
|
||||||
|
begin
|
||||||
|
has_sse2_support:=((_edx and $4000000)<>0);
|
||||||
|
has_sse3_support:=((_ecx and $200)<>0);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ don't let libraries influence the FPU cw set by the host program }
|
||||||
|
if IsLibrary then
|
||||||
|
begin
|
||||||
|
Default8087CW:=Get8087CW;
|
||||||
|
if has_sse_support then
|
||||||
|
mxcsr:=GetSSECSR;
|
||||||
end;
|
end;
|
||||||
has_sse_support:=os_supports_sse;
|
|
||||||
if not(has_sse_support) then
|
|
||||||
begin
|
|
||||||
has_sse2_support:=false;
|
|
||||||
has_sse3_support:=false;
|
|
||||||
end;
|
|
||||||
{ don't let libraries influence the FPU cw set by the host program }
|
|
||||||
if has_sse_support and
|
|
||||||
IsLibrary then
|
|
||||||
mxcsr:=GetSSECSR;
|
|
||||||
|
|
||||||
has_mmx_support:=mmx_support;
|
|
||||||
SysResetFPU;
|
SysResetFPU;
|
||||||
if not(IsLibrary) then
|
if not(IsLibrary) then
|
||||||
SysInitFPU;
|
SysInitFPU;
|
||||||
|
@ -28,7 +28,7 @@ function getaltfpustate(sigcontext:psigcontextrec):longint; {inline;}
|
|||||||
begin
|
begin
|
||||||
if assigned(sigcontext) then
|
if assigned(sigcontext) then
|
||||||
begin
|
begin
|
||||||
if mmx_support then
|
if has_mmx_support then
|
||||||
getaltfpustate:=sigcontext^.sc_fpustate^.xmmState.fx_fsw
|
getaltfpustate:=sigcontext^.sc_fpustate^.xmmState.fx_fsw
|
||||||
else
|
else
|
||||||
getaltfpustate:=sigcontext^.sc_fpustate^.x87state.en_sw
|
getaltfpustate:=sigcontext^.sc_fpustate^.x87state.en_sw
|
||||||
|
Loading…
Reference in New Issue
Block a user