19 static inline void cpuid (
int output[4],
int functionnumber) {
20 #if defined (_MSC_VER) || defined (__INTEL_COMPILER) // Microsoft or Intel compiler, intrin.h included 22 __cpuidex(output, functionnumber, 0);
24 #elif defined(__GNUC__) || defined(__clang__) // use inline assembly, Gnu/AT&T syntax 27 __asm(
"cpuid" :
"=a"(a),
"=b"(b),
"=c"(c),
"=d"(d) :
"a"(functionnumber),
"c"(0) : );
33 #else // unknown platform. try inline assembly with masm/intel syntax 36 mov eax, functionnumber
50 static inline int64_t xgetbv (
int ctr) {
51 #if (defined (_MSC_FULL_VER) && _MSC_FULL_VER >= 160040000) || (defined (__INTEL_COMPILER) && __INTEL_COMPILER >= 1200) // Microsoft or Intel compiler supporting _xgetbv intrinsic 55 #elif defined(__GNUC__) // use inline assembly, Gnu/AT&T syntax 58 __asm(
"xgetbv" :
"=a"(a),
"=d"(d) :
"c"(ctr) : );
61 #else // #elif defined (_WIN32) // other compiler. try inline assembly with masm/intel/MS syntax 98 int abcd[4] = {0,0,0,0};
100 if (abcd[0] == 0)
return iset;
102 if ((abcd[3] & (1 << 0)) == 0)
return iset;
103 if ((abcd[3] & (1 << 23)) == 0)
return iset;
104 if ((abcd[3] & (1 << 15)) == 0)
return iset;
105 if ((abcd[3] & (1 << 24)) == 0)
return iset;
106 if ((abcd[3] & (1 << 25)) == 0)
return iset;
108 if ((abcd[3] & (1 << 26)) == 0)
return iset;
110 if ((abcd[2] & (1 << 0)) == 0)
return iset;
112 if ((abcd[2] & (1 << 9)) == 0)
return iset;
114 if ((abcd[2] & (1 << 19)) == 0)
return iset;
116 if ((abcd[2] & (1 << 23)) == 0)
return iset;
117 if ((abcd[2] & (1 << 20)) == 0)
return iset;
119 if ((abcd[2] & (1 << 27)) == 0)
return iset;
120 if ((xgetbv(0) & 6) != 6)
return iset;
121 if ((abcd[2] & (1 << 28)) == 0)
return iset;
124 if ((abcd[1] & (1 << 5)) == 0)
return iset;
127 if ((abcd[0] & 0x60) != 0x60)
return iset;
137 return ((abcd[2] & (1 << 12)) != 0);
144 cpuid(abcd, 0x80000001);
145 return ((abcd[2] & (1 << 16)) != 0);
152 cpuid(abcd, 0x80000001);
153 return ((abcd[2] & (1 << 11)) != 0);
160 bool hasFMA3(
void) {
return false; }
161 bool hasFMA4(
void) {
return false; }
162 bool hasXOP(
void) {
return false; }
int instrset_detect(void)
#define cpuid(func, eax, ebx, ecx, edx)
unsigned long long uint64_t