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