diff options
Diffstat (limited to 'volk')
-rw-r--r-- | volk/gen/make_cpuid_c.py | 21 | ||||
-rw-r--r-- | volk/lib/gcc_x86_cpuid.h | 28 |
2 files changed, 34 insertions, 15 deletions
diff --git a/volk/gen/make_cpuid_c.py b/volk/gen/make_cpuid_c.py index c6bb5059e..49b216677 100644 --- a/volk/gen/make_cpuid_c.py +++ b/volk/gen/make_cpuid_c.py @@ -41,11 +41,32 @@ struct VOLK_CPU volk_cpu; #include <gcc_x86_cpuid.h> #define cpuid_x86(op, r) __get_cpuid(op, (unsigned int *)r+0, (unsigned int *)r+1, (unsigned int *)r+2, (unsigned int *)r+3) + /* Return Intel AVX extended CPU capabilities register. + * This function will bomb on non-AVX-capable machines, so + * check for AVX capability before executing. + */ + #if __GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 + static inline unsigned long long _xgetbv(unsigned int index){ + unsigned int eax, edx; + __asm__ __volatile__("xgetbv" : "=a"(eax), "=d"(edx) : "c"(index)); + return ((unsigned long long)edx << 32) | eax; + } + #define __xgetbv() _xgetbv(0) + #else + #define __xgetbv() 0 + #endif + //implement get cpuid for MSVC compilers using __cpuid intrinsic #elif defined(_MSC_VER) #include <intrin.h> #define cpuid_x86(op, r) __cpuid(r, op) + #if defined(_XCR_XFEATURE_ENABLED_MASK) + #define __xgetbv() _xgetbv(_XCR_XFEATURE_ENABLED_MASK) + #else + #define __xgetbv() 0 + #endif + #else #error "A get cpuid for volk is not available on this compiler..." #endif diff --git a/volk/lib/gcc_x86_cpuid.h b/volk/lib/gcc_x86_cpuid.h index 2345ed213..3c3f47b00 100644 --- a/volk/lib/gcc_x86_cpuid.h +++ b/volk/lib/gcc_x86_cpuid.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. + * Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. * * This file is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -35,6 +35,8 @@ #define bit_XSAVE (1 << 26) #define bit_OSXSAVE (1 << 27) #define bit_AVX (1 << 28) +#define bit_F16C (1 << 29) +#define bit_RDRND (1 << 30) /* %edx */ #define bit_CMPXCHG8B (1 << 8) @@ -47,14 +49,22 @@ /* Extended Features */ /* %ecx */ #define bit_LAHF_LM (1 << 0) +#define bit_ABM (1 << 5) #define bit_SSE4a (1 << 6) -#define bit_SSE5 (1 << 11) +#define bit_XOP (1 << 11) +#define bit_LWP (1 << 15) +#define bit_FMA4 (1 << 16) +#define bit_TBM (1 << 21) /* %edx */ +#define bit_MMXEXT (1 << 22) #define bit_LM (1 << 29) #define bit_3DNOWP (1 << 30) #define bit_3DNOW (1 << 31) +/* Extended Features (%eax == 7) */ +#define bit_FSGSBASE (1 << 0) +#define bit_BMI (1 << 3) #if defined(__i386__) && defined(__PIC__) /* %ebx may be the PIC register. */ @@ -114,8 +124,8 @@ __get_cpuid_max (unsigned int __ext, unsigned int *__sig) unsigned int __eax, __ebx, __ecx, __edx; #ifndef __x86_64__ -#if __GNUC__ >= 3 /* See if we can use cpuid. On AMD64 we always can. */ +#if __GNUC__ >= 3 __asm__ ("pushf{l|d}\n\t" "pushf{l|d}\n\t" "pop{l}\t%0\n\t" @@ -176,15 +186,3 @@ __get_cpuid (unsigned int __level, __cpuid (__level, *__eax, *__ebx, *__ecx, *__edx); return 1; } - -/* Return Intel AVX extended CPU capabilities register. - * This function will bomb on non-AVX-capable machines, so - * check for AVX capability before executing. - */ -static __inline unsigned int -__xgetbv(void) -{ - unsigned int index, __eax, __edx; - __asm__ ("xgetbv" : "=a"(__eax), "=d"(__edx) : "c" (index)); - return __eax; -} |