#include #include #include #define XCR0_FMT "\177\020" \ "b\000" "x87 FPU/MMX\0" \ "b\001" "SSE\0" \ "b\002" "AVX\0" \ "b\003" "BNDREG\0" \ "b\004" "BNDCSR\0" \ "b\005" "Opmask\0" \ "b\006" "ZMM_Hi256\0" \ "b\007" "Hi16_ZMM\0" \ "b\011" "PKRU\0" \ "b\021" "TILECONFIG\0" \ "b\022" "TILEDATA\0" \ /* end of XCR0_FMT */ int main(void) { uint32_t eax, ebx, ecx, edx, xcr0lo, xcr0hi; uint64_t xcr0; char buf[128]; asm("cpuid" : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) : "a"(0x0d), "c"(0x00)); snprintb(buf, sizeof(buf), XCR0_FMT, eax); printf("XFeatureSupportedMask[0:31] = %s\n", buf); printf("XFeatureEnabledSizeMask = 0x%x\n", ebx); printf("XFeatureSupportedSizeMask = 0x%x\n", ecx); snprintb(buf, sizeof(buf), XCR0_FMT, (uint64_t)edx << 32); printf("XFeatureSupportedMask[32:63] = %s\n", buf); fflush(stdout); asm("xgetbv" : "=a"(xcr0lo), "=d"(xcr0hi) : "c"(0)); xcr0 = (uint64_t)xcr0hi << 32 | xcr0lo; snprintb(buf, sizeof(buf), XCR0_FMT, xcr0); printf("xcr0 = %s\n", buf); fflush(stdout); fflush(stdout); return ferror(stdout); }