- // Get CPU flags using Microsoft function
- // It works for both 64 and 32 bit systems
- // no need to use assembler for getting info from register, this function does this for us
- int cpuInfo[4];
- __cpuid (cpuInfo, 1);
- cpuflags = cpuInfo[3];
-
-#else
-
-#ifndef _LP64 /* *nix; 32 bit version. This odd macro constant is required because we need something that identifies this as a 32 bit
- build on Linux and on OS X. Anything that serves this purpose will do, but this is the best thing we've identified
- so far.
- */
-
- asm volatile (
- "mov $1, %%eax\n"
- "pushl %%ebx\n"
- "cpuid\n"
- "movl %%edx, %0\n"
- "popl %%ebx\n"
- : "=r" (cpuflags)
- :
- : "%eax", "%ecx", "%edx"
- );
-
-#else /* *nix; 64 bit version */
-
- /* asm notes: although we explicitly save&restore rbx, we must tell
- gcc that ebx,rbx is clobbered so that it doesn't try to use it as an intermediate
- register when storing rbx. gcc 4.3 didn't make this "mistake", but gcc 4.4
- does, at least on x86_64.
- */
-
- asm volatile (
- "pushq %%rbx\n"
- "movq $1, %%rax\n"
- "cpuid\n"
- "movq %%rdx, %0\n"
- "popq %%rbx\n"
- : "=r" (cpuflags)
- :
- : "%rax", "%rbx", "%rcx", "%rdx"
- );
-
-#endif /* _LP64 */
-#endif /* PLATFORM_WINDOWS */
-
- if (cpuflags & ((1<<27) /* AVX */ |(1<<28) /* XGETBV */)) {
-
- std::cerr << "Looks like AVX\n";
-
- /* now check if YMM resters state is saved: which means OS does
- * know about new YMM registers and saves them during context
- * switches it's true for most cases, but we must be sure
- *
- * giving 0 as the argument to _xgetbv() fetches the
- * XCR_XFEATURE_ENABLED_MASK, which we need to check for
- * the 2nd and 3rd bits, indicating correct register save/restore.
- */
-
- uint64_t xcrFeatureMask = _xgetbv (0);
-
- if (xcrFeatureMask & 0x6) {
- std::cerr << "Definitely AVX\n";
+ __cpuid (cpu_info, 0);
+
+ int num_ids = cpu_info[0];
+ std::swap(cpu_info[2], cpu_info[3]);
+ memcpy(cpu_string, &cpu_info[1], 3 * sizeof(cpu_info[1]));
+ cpu_vendor.assign(cpu_string, 3 * sizeof(cpu_info[1]));
+
+ info << string_compose (_("CPU vendor: %1"), cpu_vendor) << endmsg;
+
+ if (num_ids > 0) {
+
+ /* Now get CPU/FPU flags */
+
+ __cpuid (cpu_info, 1);
+
+ if ((cpu_info[2] & (1<<27)) /* OSXSAVE */ &&
+ (cpu_info[2] & (1<<28) /* AVX */) &&
+ ((_xgetbv (_XCR_XFEATURE_ENABLED_MASK) & 0x6) == 0x6)) { /* OS really supports XSAVE */
+ info << _("AVX-capable processor") << endmsg;