llvm.org GIT mirror llvm / e9faa09
[X86] Use MSVC's __cpuidex intrinsic instead of inline assembly in getHostCPUName/getHostCPUFeatures for 32-bit builds too. We're already using it in 64-bit builds because 64-bit MSVC doesn't support inline assembly. As far as I know we were using inline assembly because at the time the code was added we had to support MSVC 2008 pre-SP1 while the intrinsic was added to MSVC in SP1. Now that we don't have to support that we should be able to just use the intrinsic. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308163 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 3 years ago
1 changed file(s) with 11 addition(s) and 30 deletion(s). Raw diff Collapse all Expand all
459459 static bool getX86CpuIDAndInfoEx(unsigned value, unsigned subleaf,
460460 unsigned *rEAX, unsigned *rEBX, unsigned *rECX,
461461 unsigned *rEDX) {
462 #if defined(__x86_64__) || defined(_M_X64)
463462 #if defined(__GNUC__) || defined(__clang__)
463 #if defined(__x86_64__)
464464 // gcc doesn't know cpuid would clobber ebx/rbx. Preserve it manually.
465465 // FIXME: should we save this for Clang?
466466 __asm__("movq\t%%rbx, %%rsi\n\t"
469469 : "=a"(*rEAX), "=S"(*rEBX), "=c"(*rECX), "=d"(*rEDX)
470470 : "a"(value), "c"(subleaf));
471471 return false;
472 #elif defined(__i386__)
473 __asm__("movl\t%%ebx, %%esi\n\t"
474 "cpuid\n\t"
475 "xchgl\t%%ebx, %%esi\n\t"
476 : "=a"(*rEAX), "=S"(*rEBX), "=c"(*rECX), "=d"(*rEDX)
477 : "a"(value), "c"(subleaf));
478 return false;
479 #else
480 return true;
481 #endif
472482 #elif defined(_MSC_VER)
473483 int registers[4];
474484 __cpuidex(registers, value, subleaf);
477487 *rECX = registers[2];
478488 *rEDX = registers[3];
479489 return false;
480 #else
481 return true;
482 #endif
483 #elif defined(__i386__) || defined(_M_IX86)
484 #if defined(__GNUC__) || defined(__clang__)
485 __asm__("movl\t%%ebx, %%esi\n\t"
486 "cpuid\n\t"
487 "xchgl\t%%ebx, %%esi\n\t"
488 : "=a"(*rEAX), "=S"(*rEBX), "=c"(*rECX), "=d"(*rEDX)
489 : "a"(value), "c"(subleaf));
490 return false;
491 #elif defined(_MSC_VER)
492 __asm {
493 mov eax,value
494 mov ecx,subleaf
495 cpuid
496 mov esi,rEAX
497 mov dword ptr [esi],eax
498 mov esi,rEBX
499 mov dword ptr [esi],ebx
500 mov esi,rECX
501 mov dword ptr [esi],ecx
502 mov esi,rEDX
503 mov dword ptr [esi],edx
504 }
505 return false;
506 #else
507 return true;
508 #endif
509490 #else
510491 return true;
511492 #endif