OLD | NEW |
1 /* Copyright (c) 2010 Xiph.Org Foundation | 1 /* Copyright (c) 2014, Cisco Systems, INC |
2 * Copyright (c) 2013 Parrot */ | 2 Written by XiangMingZhu WeiZhou MinPeng YanWang |
3 /* | 3 |
4 Redistribution and use in source and binary forms, with or without | 4 Redistribution and use in source and binary forms, with or without |
5 modification, are permitted provided that the following conditions | 5 modification, are permitted provided that the following conditions |
6 are met: | 6 are met: |
7 | 7 |
8 - Redistributions of source code must retain the above copyright | 8 - Redistributions of source code must retain the above copyright |
9 notice, this list of conditions and the following disclaimer. | 9 notice, this list of conditions and the following disclaimer. |
10 | 10 |
11 - Redistributions in binary form must reproduce the above copyright | 11 - Redistributions in binary form must reproduce the above copyright |
12 notice, this list of conditions and the following disclaimer in the | 12 notice, this list of conditions and the following disclaimer in the |
13 documentation and/or other materials provided with the distribution. | 13 documentation and/or other materials provided with the distribution. |
14 | 14 |
15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
16 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 16 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
17 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 17 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
18 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER | 18 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER |
19 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 19 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
20 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 20 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
21 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 21 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
22 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 22 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
23 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 23 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
24 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 #if !defined(ARMCPU_H) | 28 #if !defined(X86CPU_H) |
29 # define ARMCPU_H | 29 # define X86CPU_H |
30 | 30 |
31 # if defined(OPUS_ARM_MAY_HAVE_EDSP) | 31 # if defined(OPUS_X86_MAY_HAVE_SSE2) |
32 # define MAY_HAVE_EDSP(name) name ## _edsp | 32 # define MAY_HAVE_SSE2(name) name ## _sse2 |
33 # else | 33 # else |
34 # define MAY_HAVE_EDSP(name) name ## _c | 34 # define MAY_HAVE_SSE2(name) name ## _c |
35 # endif | 35 # endif |
36 | 36 |
37 # if defined(OPUS_ARM_MAY_HAVE_MEDIA) | 37 # if defined(OPUS_X86_MAY_HAVE_SSE4_1) |
38 # define MAY_HAVE_MEDIA(name) name ## _media | 38 # define MAY_HAVE_SSE4_1(name) name ## _sse4_1 |
39 # else | 39 # else |
40 # define MAY_HAVE_MEDIA(name) MAY_HAVE_EDSP(name) | 40 # define MAY_HAVE_SSE4_1(name) name ## _c |
41 # endif | |
42 | |
43 # if defined(OPUS_ARM_MAY_HAVE_NEON) | |
44 # define MAY_HAVE_NEON(name) name ## _neon | |
45 # else | |
46 # define MAY_HAVE_NEON(name) MAY_HAVE_MEDIA(name) | |
47 # endif | |
48 | |
49 # if defined(OPUS_ARM_PRESUME_EDSP) | |
50 # define PRESUME_EDSP(name) name ## _edsp | |
51 # else | |
52 # define PRESUME_EDSP(name) name ## _c | |
53 # endif | |
54 | |
55 # if defined(OPUS_ARM_PRESUME_MEDIA) | |
56 # define PRESUME_MEDIA(name) name ## _media | |
57 # else | |
58 # define PRESUME_MEDIA(name) PRESUME_EDSP(name) | |
59 # endif | |
60 | |
61 # if defined(OPUS_ARM_PRESUME_NEON) | |
62 # define PRESUME_NEON(name) name ## _neon | |
63 # else | |
64 # define PRESUME_NEON(name) PRESUME_MEDIA(name) | |
65 # endif | 41 # endif |
66 | 42 |
67 # if defined(OPUS_HAVE_RTCD) | 43 # if defined(OPUS_HAVE_RTCD) |
68 int opus_select_arch(void); | 44 int opus_select_arch(void); |
69 # endif | 45 # endif |
70 | 46 |
| 47 /*gcc appears to emit MOVDQA's to load the argument of an _mm_cvtepi8_epi32() |
| 48 or _mm_cvtepi16_epi32() when optimizations are disabled, even though the |
| 49 actual PMOVSXWD instruction takes an m32 or m64. Unlike a normal memory |
| 50 reference, these require 16-byte alignment and load a full 16 bytes (instead |
| 51 of 4 or 8), possibly reading out of bounds. |
| 52 |
| 53 We can insert an explicit MOVD or MOVQ using _mm_cvtsi32_si128() or |
| 54 _mm_loadl_epi64(), which should have the same semantics as an m32 or m64 |
| 55 reference in the PMOVSXWD instruction itself, but gcc is not smart enough to |
| 56 optimize this out when optimizations ARE enabled.*/ |
| 57 # if !defined(__OPTIMIZE__) |
| 58 # define OP_CVTEPI8_EPI32_M32(x) \ |
| 59 (_mm_cvtepi8_epi32(_mm_cvtsi32_si128(*(int *)(x)))) |
| 60 |
| 61 # define OP_CVTEPI16_EPI32_M64(x) \ |
| 62 (_mm_cvtepi16_epi32(_mm_loadl_epi64((__m128i *)(x)))) |
| 63 # else |
| 64 # define OP_CVTEPI8_EPI32_M32(x) \ |
| 65 (_mm_cvtepi8_epi32(*(__m128i *)(x))) |
| 66 |
| 67 # define OP_CVTEPI16_EPI32_M64(x) \ |
| 68 (_mm_cvtepi16_epi32(*(__m128i *)(x))) |
| 69 # endif |
| 70 |
71 #endif | 71 #endif |
OLD | NEW |