// __asm__ blocks are only checked for inline functions that end up being // emitted, so call functions with __asm__ blocks to make sure their inline // assembly parses. void f() { __movsb(0, 0, 0); __movsd(0, 0, 0); __movsw(0, 0, 0); __stosd(0, 0, 0); __stosw(0, 0, 0); #ifdef _M_X64 __movsq(0, 0, 0); __stosq(0, 0, 0); #endif int info[4]; __cpuid(info, 0); __cpuidex(info, 0, 0); _xgetbv(0); __halt(); __nop(); __readmsr(0); // FIXME: Call these in 64-bit too once the intrinsics have been fixed to // work there, PR19301 #ifndef _M_X64 __readcr3(); __writecr3(0); #endif #ifdef _M_ARM __dmb(_ARM_BARRIER_ISHST); #endif }
static int CPUCheckForExtensions() { int result = 0; int cpuinfo[4]; __cpuid(cpuinfo, 1); if (IS_BIT_SET(cpuinfo[3], 0)) result |= CPUF_FPU; if (IS_BIT_SET(cpuinfo[3], 23)) result |= CPUF_MMX; if (IS_BIT_SET(cpuinfo[3], 25)) result |= CPUF_SSE | CPUF_INTEGER_SSE; if (IS_BIT_SET(cpuinfo[3], 26)) result |= CPUF_SSE2; if (IS_BIT_SET(cpuinfo[2], 0)) result |= CPUF_SSE3; if (IS_BIT_SET(cpuinfo[2], 9)) result |= CPUF_SSSE3; if (IS_BIT_SET(cpuinfo[2], 19)) result |= CPUF_SSE4_1; if (IS_BIT_SET(cpuinfo[2], 20)) result |= CPUF_SSE4_2; // AVX #if (_MSC_FULL_VER >= 160040219) // We require VC++2010 SP1 at least bool xgetbv_supported = IS_BIT_SET(cpuinfo[2], 27); bool avx_supported = IS_BIT_SET(cpuinfo[2], 28); if (xgetbv_supported && avx_supported) { if ((_xgetbv(_XCR_XFEATURE_ENABLED_MASK) & 0x6ull) == 0x6ull) result |= CPUF_AVX; } #endif // 3DNow!, 3DNow!, and ISSE __cpuid(cpuinfo, 0x80000000); if (cpuinfo[0] >= 0x80000001) { __cpuid(cpuinfo, 0x80000001); if (IS_BIT_SET(cpuinfo[3], 31)) result |= CPUF_3DNOW; if (IS_BIT_SET(cpuinfo[3], 30)) result |= CPUF_3DNOW_EXT; if (IS_BIT_SET(cpuinfo[3], 22)) result |= CPUF_INTEGER_SSE; } return result; }
static void xgetbv(unsigned int op, unsigned int* eax, unsigned int* edx) { *eax = 0; *edx = 0; if (op == 0) *eax = _xgetbv(_XCR_XFEATURE_ENABLED_MASK); }
uint32_t GetXCR0Eax(void) { return _xgetbv(0); }
unsigned int xgetsetbv (void) { _xsetbv (0, 0); return _xgetbv (0); }