Executes 'xgetbv' instruction.
| 81 | |
| 82 | // Executes 'xgetbv' instruction. |
| 83 | static inline void xgetbvQuery(xgetbv_t* out, uint32_t inEcx) noexcept { |
| 84 | #if defined(_MSC_VER) |
| 85 | uint64_t value = _xgetbv(inEcx); |
| 86 | out->eax = uint32_t(value & 0xFFFFFFFFu); |
| 87 | out->edx = uint32_t(value >> 32); |
| 88 | #elif defined(__GNUC__) |
| 89 | uint32_t outEax; |
| 90 | uint32_t outEdx; |
| 91 | |
| 92 | // Replaced, because the world is not perfect: |
| 93 | // __asm__ __volatile__("xgetbv" : "=a"(outEax), "=d"(outEdx) : "c"(inEcx)); |
| 94 | __asm__ __volatile__(".byte 0x0F, 0x01, 0xD0" : "=a"(outEax), "=d"(outEdx) : "c"(inEcx)); |
| 95 | |
| 96 | out->eax = outEax; |
| 97 | out->edx = outEdx; |
| 98 | #else |
| 99 | out->eax = 0; |
| 100 | out->edx = 0; |
| 101 | #endif |
| 102 | } |
| 103 | |
| 104 | // Map a 12-byte vendor string returned by `cpuid` into a `CpuInfo::Vendor` ID. |
| 105 | static inline void simplifyCpuVendor(CpuInfo& cpu, uint32_t d0, uint32_t d1, uint32_t d2) noexcept { |