mirror of https://github.com/PCSX2/pcsx2.git
common: include cpuid.h on unix
I tested both clang and gcc.
This commit is contained in:
parent
25bc2dff07
commit
c56ca4a0fa
|
@ -33,11 +33,7 @@
|
|||
|
||||
#include "Pcsx2Types.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# include <intrin.h>
|
||||
#else
|
||||
# include <intrin_x86.h>
|
||||
#endif
|
||||
#include "x86emitter/x86_intrin.h"
|
||||
|
||||
// Renamed ARRAYSIZE to ArraySize -- looks nice and gets rid of Windows.h conflicts (air)
|
||||
// Notes: I'd have used ARRAY_SIZE instead but ran into cross-platform lib conflicts with
|
||||
|
|
|
@ -69,16 +69,6 @@ static __inline__ __attribute__((always_inline)) s64 _InterlockedExchange64(vola
|
|||
}
|
||||
|
||||
/*** System information ***/
|
||||
static __inline__ __attribute__((always_inline)) void __cpuid(int CPUInfo[], const int InfoType)
|
||||
{
|
||||
__asm__ __volatile__("cpuid": "=a" (CPUInfo[0]), "=b" (CPUInfo[1]), "=c" (CPUInfo[2]), "=d" (CPUInfo[3]) : "a" (InfoType));
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void __cpuidex(int CPUInfo[], const int level, const int count)
|
||||
{
|
||||
__asm__ __volatile__("cpuid": "=a" (CPUInfo[0]), "=b" (CPUInfo[1]), "=c" (CPUInfo[2]), "=d" (CPUInfo[3]) : "a" (level), "c" (count));
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) unsigned long long _xgetbv(unsigned int index)
|
||||
{
|
||||
unsigned int eax, edx;
|
||||
|
|
|
@ -31,6 +31,27 @@
|
|||
|
||||
#endif
|
||||
|
||||
// CPU information support
|
||||
#if defined(_WIN32)
|
||||
|
||||
#define cpuid __cpuid
|
||||
#define cpuidex __cpuidex
|
||||
|
||||
#else
|
||||
|
||||
#include <cpuid.h>
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void cpuidex(int CPUInfo[], const int InfoType, const int count) {
|
||||
__cpuid_count(InfoType, count, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]);
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline)) void cpuid(int CPUInfo[], const int InfoType) {
|
||||
__cpuid(InfoType, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Rotate instruction
|
||||
#if defined(__clang__)
|
||||
// Seriously what is so complicated to provided this bunch of intrinsics in clangs.
|
||||
static unsigned int _rotr(unsigned int x, int s)
|
||||
|
|
|
@ -149,7 +149,7 @@ void x86capabilities::CountCores()
|
|||
s32 regs[ 4 ];
|
||||
u32 cmds;
|
||||
|
||||
__cpuid( regs, 0x80000000 );
|
||||
cpuid( regs, 0x80000000 );
|
||||
cmds = regs[ 0 ];
|
||||
|
||||
// detect multicore for AMD cpu
|
||||
|
@ -191,7 +191,7 @@ void x86capabilities::Identify()
|
|||
#endif
|
||||
|
||||
memzero( VendorName );
|
||||
__cpuid( regs, 0 );
|
||||
cpuid( regs, 0 );
|
||||
|
||||
cmds = regs[ 0 ];
|
||||
((u32*)VendorName)[ 0 ] = regs[ 1 ];
|
||||
|
@ -211,7 +211,7 @@ void x86capabilities::Identify()
|
|||
|
||||
if ( cmds >= 0x00000001 )
|
||||
{
|
||||
__cpuid( regs, 0x00000001 );
|
||||
cpuid( regs, 0x00000001 );
|
||||
|
||||
StepID = regs[ 0 ] & 0xf;
|
||||
Model = (regs[ 0 ] >> 4) & 0xf;
|
||||
|
@ -227,16 +227,16 @@ void x86capabilities::Identify()
|
|||
if ( cmds >= 0x00000007 )
|
||||
{
|
||||
// Note: ECX must be 0 for AVX2 detection.
|
||||
__cpuidex( regs, 0x00000007, 0 );
|
||||
cpuidex( regs, 0x00000007, 0 );
|
||||
|
||||
SEFlag = regs[ 1 ];
|
||||
}
|
||||
|
||||
__cpuid( regs, 0x80000000 );
|
||||
cpuid( regs, 0x80000000 );
|
||||
cmds = regs[ 0 ];
|
||||
if ( cmds >= 0x80000001 )
|
||||
{
|
||||
__cpuid( regs, 0x80000001 );
|
||||
cpuid( regs, 0x80000001 );
|
||||
|
||||
#ifdef __x86_64__
|
||||
x86_64_12BITBRANDID = regs[1] & 0xfff;
|
||||
|
@ -246,9 +246,9 @@ void x86capabilities::Identify()
|
|||
}
|
||||
|
||||
memzero( FamilyName );
|
||||
__cpuid( (int*)FamilyName, 0x80000002);
|
||||
__cpuid( (int*)(FamilyName+16), 0x80000003);
|
||||
__cpuid( (int*)(FamilyName+32), 0x80000004);
|
||||
cpuid( (int*)FamilyName, 0x80000002);
|
||||
cpuid( (int*)(FamilyName+16), 0x80000003);
|
||||
cpuid( (int*)(FamilyName+32), 0x80000004);
|
||||
|
||||
hasFloatingPointUnit = ( Flags >> 0 ) & 1;
|
||||
hasVirtual8086ModeEnhancements = ( Flags >> 1 ) & 1;
|
||||
|
|
Loading…
Reference in New Issue