x86emitter: Don't use xgetbv

All OSes now support AVX
This commit is contained in:
TellowKrinkle 2020-08-30 20:14:26 -05:00 committed by Kojin
parent 9c0865c0f4
commit 19f2d96d06
2 changed files with 6 additions and 22 deletions

View File

@ -34,7 +34,6 @@
#define cpuid __cpuid
#define cpuidex __cpuidex
#define xgetbv _xgetbv
#else
@ -50,21 +49,6 @@ static __inline__ __attribute__((always_inline)) void cpuid(int CPUInfo[], const
__cpuid(InfoType, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]);
}
#if defined(__clang__) || __GNUC__ < 8 || (__GNUC__ == 8 && __GNUC_MINOR__ < 2)
// _xgetbv on gcc 8.1 is broken (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85684).
// It also isn't present on clang and earlier versions of gcc.
static __inline__ __attribute__((always_inline)) unsigned long long xgetbv(unsigned int index)
{
unsigned int eax, edx;
__asm__ __volatile__("xgetbv"
: "=a"(eax), "=d"(edx)
: "c"(index));
return ((unsigned long long)edx << 32) | eax;
}
#else
#define xgetbv _xgetbv
#endif
#endif
// Rotate instruction

View File

@ -297,12 +297,12 @@ void x86capabilities::Identify()
if ((Flags2 >> 27) & 1) // OSXSAVE
{
if ((xgetbv(0) & 6) == 6) // XFEATURE_ENABLED_MASK[2:1] = '11b' (XMM state and YMM state are enabled by OS).
{
hasAVX = (Flags2 >> 28) & 1; //avx
hasFMA = (Flags2 >> 12) & 1; //fma
hasAVX2 = (SEFlag >> 5) & 1; //avx2
}
// Note: In theory, we should use xgetbv to check OS support
// but all OSes we officially run under support it
// and its intrinsic requires extra compiler flags
hasAVX = (Flags2 >> 28) & 1; //avx
hasFMA = (Flags2 >> 12) & 1; //fma
hasAVX2 = (SEFlag >> 5) & 1; //avx2
}
hasBMI1 = (SEFlag >> 3) & 1;