mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-13 14:09:29 +02:00
+ centralized cpu capability detection
This commit is contained in:
parent
363bc3e019
commit
704ad21b23
@ -17,6 +17,9 @@
|
||||
const
|
||||
{$I cpuinnr.inc}
|
||||
|
||||
has_avx_support : boolean = false;
|
||||
has_avx2_support : boolean = false;
|
||||
|
||||
function fpc_x86_inportb(port : word) : byte;[internproc:fpc_in_x86_inportb];
|
||||
function fpc_x86_inportw(port : word) : word;[internproc:fpc_in_x86_inportw];
|
||||
function fpc_x86_inportl(port : word) : longint;[internproc:fpc_in_x86_inportl];
|
||||
|
@ -1249,6 +1249,8 @@ const
|
||||
|
||||
{$define FPC_SYSTEM_HAS_FPC_CPUINIT}
|
||||
procedure fpc_cpuinit;
|
||||
var
|
||||
_eax,_ebx,_ecx : dword;
|
||||
begin
|
||||
{ don't let libraries influence the FPU cw set by the host program }
|
||||
if IsLibrary then
|
||||
@ -1257,6 +1259,36 @@ procedure fpc_cpuinit;
|
||||
DefaultMXCSR:=GetMXCSR;
|
||||
end;
|
||||
SysResetFPU;
|
||||
asm
|
||||
xorl %eax,%eax
|
||||
cpuid
|
||||
movl %eax,_eax
|
||||
end;
|
||||
if _eax>=7 then
|
||||
begin
|
||||
asm
|
||||
xorl %ecx,%ecx
|
||||
.byte 0x0f,0x01,0xd0 { xgetbv }
|
||||
movl %eax,_eax
|
||||
end;
|
||||
if (_eax and 6)=6 then
|
||||
begin
|
||||
asm
|
||||
movl $1,%eax
|
||||
xorl %ecx,%ecx
|
||||
cpuid
|
||||
movl %ecx,_ecx
|
||||
end;
|
||||
has_avx_support:=(_ecx and $10000000)<>0;
|
||||
asm
|
||||
movl $7,%eax
|
||||
xorl %ecx,%ecx
|
||||
cpuid
|
||||
movl %ebx,_ebx
|
||||
end;
|
||||
has_avx2_support:=(_ebx and $20)<>0;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
{$define FPC_SYSTEM_HAS_SYSINITFPU}
|
||||
|
Loading…
Reference in New Issue
Block a user