mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-04 05:51:19 +12:00
Added __cpuid and __cpuidex wrappers, and fixed wrong argument order in __cpuid.
This commit is contained in:
parent
0a170d6efc
commit
ab1e6f3f53
7 changed files with 34 additions and 30 deletions
|
@ -32,7 +32,7 @@ uint64 muldiv64(uint64 a, uint64 b, uint64 d)
|
||||||
bool PPCTimer_hasInvariantRDTSCSupport()
|
bool PPCTimer_hasInvariantRDTSCSupport()
|
||||||
{
|
{
|
||||||
uint32 cpuv[4];
|
uint32 cpuv[4];
|
||||||
__cpuid((int*)cpuv, 0x80000007);
|
cpuid((int*)cpuv, 0x80000007);
|
||||||
return ((cpuv[3] >> 8) & 1);
|
return ((cpuv[3] >> 8) & 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -575,12 +575,12 @@ void PPCRecompiler_init()
|
||||||
|
|
||||||
// query processor extensions
|
// query processor extensions
|
||||||
int cpuInfo[4];
|
int cpuInfo[4];
|
||||||
__cpuid(cpuInfo, 0x80000001);
|
cpuid(cpuInfo, 0x80000001);
|
||||||
hasLZCNTSupport = ((cpuInfo[2] >> 5) & 1) != 0;
|
hasLZCNTSupport = ((cpuInfo[2] >> 5) & 1) != 0;
|
||||||
__cpuid(cpuInfo, 0x1);
|
cpuid(cpuInfo, 0x1);
|
||||||
hasMOVBESupport = ((cpuInfo[2] >> 22) & 1) != 0;
|
hasMOVBESupport = ((cpuInfo[2] >> 22) & 1) != 0;
|
||||||
hasAVXSupport = ((cpuInfo[2] >> 28) & 1) != 0;
|
hasAVXSupport = ((cpuInfo[2] >> 28) & 1) != 0;
|
||||||
__cpuidex(cpuInfo, 0x7, 0);
|
cpuidex(cpuInfo, 0x7, 0);
|
||||||
hasBMI2Support = ((cpuInfo[1] >> 8) & 1) != 0;
|
hasBMI2Support = ((cpuInfo[1] >> 8) & 1) != 0;
|
||||||
|
|
||||||
forceLog_printf("Recompiler initialized. CPU extensions: %s%s%s", hasLZCNTSupport ? "LZCNT " : "", hasMOVBESupport ? "MOVBE " : "", hasAVXSupport ? "AVX " : "");
|
forceLog_printf("Recompiler initialized. CPU extensions: %s%s%s", hasLZCNTSupport ? "LZCNT " : "", hasMOVBESupport ? "MOVBE " : "", hasAVXSupport ? "AVX " : "");
|
||||||
|
|
|
@ -237,6 +237,30 @@ typedef union _LARGE_INTEGER {
|
||||||
#error No definition for DLLEXPORT
|
#error No definition for DLLEXPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#include <cpuid.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
inline void cpuid(int cpuInfo[4], unsigned int functionId) {
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
__cpuid(cpuInfo, functionId);
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
__cpuid(functionId, cpuInfo[0], cpuInfo[1], cpuInfo[2], cpuInfo[3]);
|
||||||
|
#else
|
||||||
|
#error No definition for cpuid
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void cpuidex(int cpuInfo[4], int functionId, int subFunctionId) {
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
__cpuidex(cpuInfo, functionId, subFunctionId);
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
__cpuid_count(functionId, subFunctionId, cpuInfo[0], cpuInfo[1], cpuInfo[2], cpuInfo[3]);
|
||||||
|
#else
|
||||||
|
#error No definition for cpuidex
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// MEMPTR
|
// MEMPTR
|
||||||
#include "Common/MemPtr.h"
|
#include "Common/MemPtr.h"
|
||||||
|
|
|
@ -7,19 +7,3 @@ uint32_t GetTickCount()
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
return (1000 * ts.tv_sec + ts.tv_nsec / 1000000);
|
return (1000 * ts.tv_sec + ts.tv_nsec / 1000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <cpuid.h>
|
|
||||||
|
|
||||||
void (__cpuid)(int __cpuVal[4], unsigned int __leaf)
|
|
||||||
{
|
|
||||||
__cpuid(__cpuVal[0], __cpuVal[1], __cpuVal[2], __cpuVal[3], __leaf);
|
|
||||||
}
|
|
||||||
#undef __cpuid
|
|
||||||
|
|
||||||
#ifdef __clang__
|
|
||||||
void __cpuidex(int __cpuid_info[4], int __leaf, int __subleaf)
|
|
||||||
{
|
|
||||||
__cpuid_count (__leaf, __subleaf, __cpuid_info[0], __cpuid_info[1],
|
|
||||||
__cpuid_info[2], __cpuid_info[3]);
|
|
||||||
}
|
|
||||||
#endif
|
|
|
@ -40,10 +40,6 @@ inline uint32_t GetExceptionError()
|
||||||
#undef Success
|
#undef Success
|
||||||
#undef ClientMessage
|
#undef ClientMessage
|
||||||
|
|
||||||
// cpu id (somewhat hacky, reorganize later)
|
|
||||||
void (__cpuid)(int __cpuVal[4], unsigned int __leaf);
|
|
||||||
void __cpuidex (int __cpuid_info[4], int __leaf, int __subleaf);
|
|
||||||
|
|
||||||
// placeholder
|
// placeholder
|
||||||
uint32_t GetTickCount();
|
uint32_t GetTickCount();
|
||||||
|
|
||||||
|
|
|
@ -62,11 +62,11 @@ void logCPUAndMemoryInfo()
|
||||||
unsigned nExIds, i = 0;
|
unsigned nExIds, i = 0;
|
||||||
char CPUBrandString[0x40];
|
char CPUBrandString[0x40];
|
||||||
// Get the information associated with each extended ID.
|
// Get the information associated with each extended ID.
|
||||||
__cpuid(CPUInfo, 0x80000000);
|
cpuid(CPUInfo, 0x80000000);
|
||||||
nExIds = CPUInfo[0];
|
nExIds = CPUInfo[0];
|
||||||
for (i = 0x80000000; i <= nExIds; ++i)
|
for (i = 0x80000000; i <= nExIds; ++i)
|
||||||
{
|
{
|
||||||
__cpuid(CPUInfo, i);
|
cpuid(CPUInfo, i);
|
||||||
// Interpret CPU brand string
|
// Interpret CPU brand string
|
||||||
if (i == 0x80000002)
|
if (i == 0x80000002)
|
||||||
memcpy(CPUBrandString, CPUInfo, sizeof(CPUInfo));
|
memcpy(CPUBrandString, CPUInfo, sizeof(CPUInfo));
|
||||||
|
@ -194,11 +194,11 @@ void mainEmulatorCommonInit()
|
||||||
PPCTimer_init();
|
PPCTimer_init();
|
||||||
// check available CPU extensions
|
// check available CPU extensions
|
||||||
int cpuInfo[4];
|
int cpuInfo[4];
|
||||||
__cpuid(cpuInfo, 0x1);
|
cpuid(cpuInfo, 0x1);
|
||||||
_cpuExtension_SSSE3 = ((cpuInfo[2] >> 9) & 1) != 0;
|
_cpuExtension_SSSE3 = ((cpuInfo[2] >> 9) & 1) != 0;
|
||||||
_cpuExtension_SSE4_1 = ((cpuInfo[2] >> 19) & 1) != 0;
|
_cpuExtension_SSE4_1 = ((cpuInfo[2] >> 19) & 1) != 0;
|
||||||
|
|
||||||
__cpuidex(cpuInfo, 0x7, 0);
|
cpuidex(cpuInfo, 0x7, 0);
|
||||||
_cpuExtension_AVX2 = ((cpuInfo[1] >> 5) & 1) != 0;
|
_cpuExtension_AVX2 = ((cpuInfo[1] >> 5) & 1) != 0;
|
||||||
|
|
||||||
#if BOOST_OS_WINDOWS
|
#if BOOST_OS_WINDOWS
|
||||||
|
|
|
@ -837,7 +837,7 @@ void AES128_init()
|
||||||
}
|
}
|
||||||
// check if AES-NI is available
|
// check if AES-NI is available
|
||||||
int v[4];
|
int v[4];
|
||||||
__cpuid(v, 1);
|
cpuid(v, 1);
|
||||||
useAESNI = (v[2] & 0x2000000) != 0;
|
useAESNI = (v[2] & 0x2000000) != 0;
|
||||||
if (useAESNI)
|
if (useAESNI)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue