• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (c) 2014, Cisco Systems, INC
2    Written by XiangMingZhu WeiZhou MinPeng YanWang
3 
4    Redistribution and use in source and binary forms, with or without
5    modification, are permitted provided that the following conditions
6    are met:
7 
8    - Redistributions of source code must retain the above copyright
9    notice, this list of conditions and the following disclaimer.
10 
11    - Redistributions in binary form must reproduce the above copyright
12    notice, this list of conditions and the following disclaimer in the
13    documentation and/or other materials provided with the distribution.
14 
15    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16    ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
19    OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
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.
26 */
27 
28 #if !defined(X86CPU_H)
29 # define X86CPU_H
30 
31 # if defined(OPUS_X86_MAY_HAVE_SSE)
32 #  define MAY_HAVE_SSE(name) name ## _sse
33 # else
34 #  define MAY_HAVE_SSE(name) name ## _c
35 # endif
36 
37 # if defined(OPUS_X86_MAY_HAVE_SSE2)
38 #  define MAY_HAVE_SSE2(name) name ## _sse2
39 # else
40 #  define MAY_HAVE_SSE2(name) name ## _c
41 # endif
42 
43 # if defined(OPUS_X86_MAY_HAVE_SSE4_1)
44 #  define MAY_HAVE_SSE4_1(name) name ## _sse4_1
45 # else
46 #  define MAY_HAVE_SSE4_1(name) name ## _c
47 # endif
48 
49 # if defined(OPUS_X86_MAY_HAVE_AVX)
50 #  define MAY_HAVE_AVX(name) name ## _avx
51 # else
52 #  define MAY_HAVE_AVX(name) name ## _c
53 # endif
54 
55 # if defined(OPUS_HAVE_RTCD)
56 int opus_select_arch(void);
57 # endif
58 
59 /*MOVD should not impose any alignment restrictions, but the C standard does,
60    and UBSan will report errors if we actually make unaligned accesses.
61   Use this to work around those restrictions (which should hopefully all get
62    optimized to a single MOVD instruction).*/
63 #define OP_LOADU_EPI32(x) \
64   (int)((*(unsigned char *)(x) | *((unsigned char *)(x) + 1) << 8U |\
65    *((unsigned char *)(x) + 2) << 16U | (opus_uint32)*((unsigned char *)(x) + 3) << 24U))
66 
67 #define OP_CVTEPI8_EPI32_M32(x) \
68  (_mm_cvtepi8_epi32(_mm_cvtsi32_si128(OP_LOADU_EPI32(x))))
69 
70 #define OP_CVTEPI16_EPI32_M64(x) \
71  (_mm_cvtepi16_epi32(_mm_loadl_epi64((__m128i *)(x))))
72 
73 #endif
74