Mercurial > hg > sv-dependency-builds
comparison src/fftw-3.3.3/simd-support/amd64-cpuid.h @ 95:89f5e221ed7b
Add FFTW3
| author | Chris Cannam <cannam@all-day-breakfast.com> | 
|---|---|
| date | Wed, 20 Mar 2013 15:35:50 +0000 | 
| parents | |
| children | 
   comparison
  equal
  deleted
  inserted
  replaced
| 94:d278df1123f9 | 95:89f5e221ed7b | 
|---|---|
| 1 /* | |
| 2 * Copyright (c) 2003, 2007-11 Matteo Frigo | |
| 3 * Copyright (c) 2003, 2007-11 Massachusetts Institute of Technology | |
| 4 * | |
| 5 * This program is free software; you can redistribute it and/or modify | |
| 6 * it under the terms of the GNU General Public License as published by | |
| 7 * the Free Software Foundation; either version 2 of the License, or | |
| 8 * (at your option) any later version. | |
| 9 * | |
| 10 * This program is distributed in the hope that it will be useful, | |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 13 * GNU General Public License for more details. | |
| 14 * | |
| 15 * You should have received a copy of the GNU General Public License | |
| 16 * along with this program; if not, write to the Free Software | |
| 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 18 * | |
| 19 */ | |
| 20 | |
| 21 | |
| 22 #ifdef _MSC_VER | |
| 23 #ifndef inline | |
| 24 #define inline __inline | |
| 25 #endif | |
| 26 #endif | |
| 27 | |
| 28 #ifdef _MSC_VER | |
| 29 #include <intrin.h> | |
| 30 #if (_MSC_VER >= 1600) && !defined(__INTEL_COMPILER) | |
| 31 #include <immintrin.h> | |
| 32 #endif | |
| 33 #endif | |
| 34 | |
| 35 static inline int cpuid_ecx(int op) | |
| 36 { | |
| 37 # ifdef _MSC_VER | |
| 38 # ifdef __INTEL_COMPILER | |
| 39 int result; | |
| 40 _asm { | |
| 41 push rbx | |
| 42 mov eax,op | |
| 43 cpuid | |
| 44 mov result,ecx | |
| 45 pop rbx | |
| 46 } | |
| 47 return result; | |
| 48 # else | |
| 49 int cpu_info[4]; | |
| 50 __cpuid(cpu_info,op); | |
| 51 return cpu_info[2]; | |
| 52 # endif | |
| 53 # else | |
| 54 int eax, ecx, edx; | |
| 55 | |
| 56 __asm__("pushq %%rbx\n\tcpuid\n\tpopq %%rbx" | |
| 57 : "=a" (eax), "=c" (ecx), "=d" (edx) | |
| 58 : "a" (op)); | |
| 59 return ecx; | |
| 60 # endif | |
| 61 } | |
| 62 | |
| 63 static inline int xgetbv_eax(int op) | |
| 64 { | |
| 65 # ifdef _MSC_VER | |
| 66 # ifdef __INTEL_COMPILER | |
| 67 int veax, vedx; | |
| 68 _asm { | |
| 69 mov ecx,op | |
| 70 xgetbv | |
| 71 mov veax,eax | |
| 72 mov vedx,edx | |
| 73 } | |
| 74 return veax; | |
| 75 # else | |
| 76 # if defined(_MSC_VER) && (_MSC_VER >= 1600) | |
| 77 unsigned __int64 result; | |
| 78 result = _xgetbv(op); | |
| 79 return (int)result; | |
| 80 # else | |
| 81 # error "Need at least Visual Studio 10 SP1 for AVX support" | |
| 82 # endif | |
| 83 # endif | |
| 84 # else | |
| 85 int eax, edx; | |
| 86 __asm__ (".byte 0x0f, 0x01, 0xd0" : "=a"(eax), "=d"(edx) : "c" (op)); | |
| 87 return eax; | |
| 88 #endif | |
| 89 } | 
