OLD | NEW |
1 /* libFLAC - Free Lossless Audio Codec library | 1 /* libFLAC - Free Lossless Audio Codec library |
2 * Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Josh Coalson | 2 * Copyright (C) 2001-2009 Josh Coalson |
| 3 * Copyright (C) 2011-2014 Xiph.Org Foundation |
3 * | 4 * |
4 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
6 * are met: | 7 * are met: |
7 * | 8 * |
8 * - Redistributions of source code must retain the above copyright | 9 * - Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
10 * | 11 * |
11 * - Redistributions in binary form must reproduce the above copyright | 12 * - Redistributions in binary form must reproduce the above copyright |
12 * notice, this list of conditions and the following disclaimer in the | 13 * notice, this list of conditions and the following disclaimer in the |
(...skipping 18 matching lines...) Expand all Loading... |
31 | 32 |
32 #ifndef FLAC__PRIVATE__CPU_H | 33 #ifndef FLAC__PRIVATE__CPU_H |
33 #define FLAC__PRIVATE__CPU_H | 34 #define FLAC__PRIVATE__CPU_H |
34 | 35 |
35 #include "FLAC/ordinals.h" | 36 #include "FLAC/ordinals.h" |
36 | 37 |
37 #ifdef HAVE_CONFIG_H | 38 #ifdef HAVE_CONFIG_H |
38 #include <config.h> | 39 #include <config.h> |
39 #endif | 40 #endif |
40 | 41 |
| 42 #if defined FLAC__HAS_X86INTRIN |
| 43 /* SSE intrinsics support by ICC/MSVC/GCC */ |
| 44 #if defined __INTEL_COMPILER |
| 45 #define FLAC__SSE_TARGET(x) |
| 46 #define FLAC__SSE_SUPPORTED 1 |
| 47 #define FLAC__SSE2_SUPPORTED 1 |
| 48 #if (__INTEL_COMPILER >= 1000) /* Intel C++ Compiler 10.0 */ |
| 49 #define FLAC__SSSE3_SUPPORTED 1 |
| 50 #define FLAC__SSE4_1_SUPPORTED 1 |
| 51 #endif |
| 52 #if (__INTEL_COMPILER >= 1110) /* Intel C++ Compiler 11.1 */ |
| 53 #define FLAC__AVX_SUPPORTED 1 |
| 54 #endif |
| 55 #if (__INTEL_COMPILER >= 1300) /* Intel C++ Compiler 13.0 */ |
| 56 #define FLAC__AVX2_SUPPORTED 1 |
| 57 #define FLAC__FMA_SUPPORTED 1 |
| 58 #endif |
| 59 #elif defined _MSC_VER |
| 60 #define FLAC__SSE_TARGET(x) |
| 61 #define FLAC__SSE_SUPPORTED 1 |
| 62 #define FLAC__SSE2_SUPPORTED 1 |
| 63 #if (_MSC_VER >= 1500) /* MS Visual Studio 2008 */ |
| 64 #define FLAC__SSSE3_SUPPORTED 1 |
| 65 #define FLAC__SSE4_1_SUPPORTED 1 |
| 66 #endif |
| 67 #if (_MSC_FULL_VER >= 160040219) /* MS Visual Studio 2010 SP1 */ |
| 68 #define FLAC__AVX_SUPPORTED 1 |
| 69 #endif |
| 70 #if (_MSC_VER >= 1700) /* MS Visual Studio 2012 */ |
| 71 #define FLAC__AVX2_SUPPORTED 1 |
| 72 #define FLAC__FMA_SUPPORTED 1 |
| 73 #endif |
| 74 #elif defined __GNUC__ |
| 75 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) /* since GCC 4.9
-msse.. compiler options aren't necessary */ |
| 76 #define FLAC__SSE_TARGET(x) __attribute__ ((__target__ (x))) |
| 77 #define FLAC__SSE_SUPPORTED 1 |
| 78 #define FLAC__SSE2_SUPPORTED 1 |
| 79 #define FLAC__SSSE3_SUPPORTED 1 |
| 80 #define FLAC__SSE4_1_SUPPORTED 1 |
| 81 #define FLAC__AVX_SUPPORTED 1 |
| 82 #define FLAC__AVX2_SUPPORTED 1 |
| 83 #define FLAC__FMA_SUPPORTED 1 |
| 84 #else /* for GCC older than 4.9 */ |
| 85 #define FLAC__SSE_TARGET(x) |
| 86 #ifdef __SSE__ |
| 87 #define FLAC__SSE_SUPPORTED 1 |
| 88 #endif |
| 89 #ifdef __SSE2__ |
| 90 #define FLAC__SSE2_SUPPORTED 1 |
| 91 #endif |
| 92 #ifdef __SSSE3__ |
| 93 #define FLAC__SSSE3_SUPPORTED 1 |
| 94 #endif |
| 95 #ifdef __SSE4_1__ |
| 96 #define FLAC__SSE4_1_SUPPORTED 1 |
| 97 #endif |
| 98 #ifdef __AVX__ |
| 99 #define FLAC__AVX_SUPPORTED 1 |
| 100 #endif |
| 101 #ifdef __AVX2__ |
| 102 #define FLAC__AVX2_SUPPORTED 1 |
| 103 #endif |
| 104 #ifdef __FMA__ |
| 105 #define FLAC__FMA_SUPPORTED 1 |
| 106 #endif |
| 107 #endif /* GCC version */ |
| 108 #endif /* compiler version */ |
| 109 #endif /* intrinsics support */ |
| 110 |
41 typedef enum { | 111 typedef enum { |
42 FLAC__CPUINFO_TYPE_IA32, | 112 FLAC__CPUINFO_TYPE_IA32, |
43 » FLAC__CPUINFO_TYPE_PPC, | 113 » FLAC__CPUINFO_TYPE_X86_64, |
44 FLAC__CPUINFO_TYPE_UNKNOWN | 114 FLAC__CPUINFO_TYPE_UNKNOWN |
45 } FLAC__CPUInfo_Type; | 115 } FLAC__CPUInfo_Type; |
46 | 116 |
| 117 #if defined FLAC__CPU_IA32 |
47 typedef struct { | 118 typedef struct { |
48 FLAC__bool cpuid; | |
49 FLAC__bool bswap; | |
50 FLAC__bool cmov; | 119 FLAC__bool cmov; |
51 FLAC__bool mmx; | 120 FLAC__bool mmx; |
52 FLAC__bool fxsr; | |
53 FLAC__bool sse; | 121 FLAC__bool sse; |
54 FLAC__bool sse2; | 122 FLAC__bool sse2; |
| 123 |
55 FLAC__bool sse3; | 124 FLAC__bool sse3; |
56 FLAC__bool ssse3; | 125 FLAC__bool ssse3; |
57 » FLAC__bool _3dnow; | 126 » FLAC__bool sse41; |
58 » FLAC__bool ext3dnow; | 127 » FLAC__bool sse42; |
59 » FLAC__bool extmmx; | 128 » FLAC__bool avx; |
| 129 » FLAC__bool avx2; |
| 130 » FLAC__bool fma; |
60 } FLAC__CPUInfo_IA32; | 131 } FLAC__CPUInfo_IA32; |
61 | 132 #elif defined FLAC__CPU_X86_64 |
62 typedef struct { | 133 typedef struct { |
63 » FLAC__bool altivec; | 134 » FLAC__bool sse3; |
64 » FLAC__bool ppc64; | 135 » FLAC__bool ssse3; |
65 } FLAC__CPUInfo_PPC; | 136 » FLAC__bool sse41; |
| 137 » FLAC__bool sse42; |
| 138 » FLAC__bool avx; |
| 139 » FLAC__bool avx2; |
| 140 » FLAC__bool fma; |
| 141 } FLAC__CPUInfo_x86; |
| 142 #endif |
66 | 143 |
67 typedef struct { | 144 typedef struct { |
68 FLAC__bool use_asm; | 145 FLAC__bool use_asm; |
69 FLAC__CPUInfo_Type type; | 146 FLAC__CPUInfo_Type type; |
70 » union { | 147 #if defined FLAC__CPU_IA32 |
71 » » FLAC__CPUInfo_IA32 ia32; | 148 » FLAC__CPUInfo_IA32 ia32; |
72 » » FLAC__CPUInfo_PPC ppc; | 149 #elif defined FLAC__CPU_X86_64 |
73 » } data; | 150 » FLAC__CPUInfo_x86 x86; |
| 151 #endif |
74 } FLAC__CPUInfo; | 152 } FLAC__CPUInfo; |
75 | 153 |
76 void FLAC__cpu_info(FLAC__CPUInfo *info); | 154 void FLAC__cpu_info(FLAC__CPUInfo *info); |
77 | 155 |
78 #ifndef FLAC__NO_ASM | 156 #ifndef FLAC__NO_ASM |
79 #ifdef FLAC__CPU_IA32 | 157 # if defined FLAC__CPU_IA32 && defined FLAC__HAS_NASM |
80 #ifdef FLAC__HAS_NASM | |
81 FLAC__uint32 FLAC__cpu_have_cpuid_asm_ia32(void); | 158 FLAC__uint32 FLAC__cpu_have_cpuid_asm_ia32(void); |
82 void FLAC__cpu_info_asm_ia32(FLAC__uint32 *flags_edx, FLAC__uint32 *flag
s_ecx); | 159 void FLAC__cpu_info_asm_ia32(FLAC__uint32 *flags_edx, FLAC__uint32 *flag
s_ecx); |
83 FLAC__uint32 FLAC__cpu_info_extended_amd_asm_ia32(void); | 160 # endif |
84 #endif | 161 # if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && defined FLAC__HAS_X
86INTRIN |
85 #endif | 162 FLAC__uint32 FLAC__cpu_have_cpuid_x86(void); |
| 163 void FLAC__cpu_info_x86(FLAC__uint32 level, FLAC__uint32 *eax, FLAC__uin
t32 *ebx, FLAC__uint32 *ecx, FLAC__uint32 *edx); |
| 164 FLAC__uint32 FLAC__cpu_xgetbv_x86(void); |
| 165 # endif |
86 #endif | 166 #endif |
87 | 167 |
88 #endif | 168 #endif |
OLD | NEW |