acl: new library
[dpdk.git] / lib / librte_acl / acl_vect.h
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5  *   All rights reserved.
6  *
7  *   Redistribution and use in source and binary forms, with or without
8  *   modification, are permitted provided that the following conditions
9  *   are met:
10  *
11  *     * Redistributions of source code must retain the above copyright
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright
14  *       notice, this list of conditions and the following disclaimer in
15  *       the documentation and/or other materials provided with the
16  *       distribution.
17  *     * Neither the name of Intel Corporation nor the names of its
18  *       contributors may be used to endorse or promote products derived
19  *       from this software without specific prior written permission.
20  *
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 #ifndef _RTE_ACL_VECT_H_
35 #define _RTE_ACL_VECT_H_
36
37 /**
38  * @file
39  *
40  * RTE ACL SSE/AVX related header.
41  */
42
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46
47 #define MM_ADD16(a, b)          _mm_add_epi16(a, b)
48 #define MM_ADD32(a, b)          _mm_add_epi32(a, b)
49 #define MM_ALIGNR8(a, b, c)     _mm_alignr_epi8(a, b, c)
50 #define MM_AND(a, b)            _mm_and_si128(a, b)
51 #define MM_ANDNOT(a, b)         _mm_andnot_si128(a, b)
52 #define MM_BLENDV8(a, b, c)     _mm_blendv_epi8(a, b, c)
53 #define MM_CMPEQ16(a, b)        _mm_cmpeq_epi16(a, b)
54 #define MM_CMPEQ32(a, b)        _mm_cmpeq_epi32(a, b)
55 #define MM_CMPEQ8(a, b)         _mm_cmpeq_epi8(a, b)
56 #define MM_CMPGT32(a, b)        _mm_cmpgt_epi32(a, b)
57 #define MM_CMPGT8(a, b)         _mm_cmpgt_epi8(a, b)
58 #define MM_CVT(a)               _mm_cvtsi32_si128(a)
59 #define MM_CVT32(a)             _mm_cvtsi128_si32(a)
60 #define MM_CVTU32(a)            _mm_cvtsi32_si128(a)
61 #define MM_INSERT16(a, c, b)    _mm_insert_epi16(a, c, b)
62 #define MM_INSERT32(a, c, b)    _mm_insert_epi32(a, c, b)
63 #define MM_LOAD(a)              _mm_load_si128(a)
64 #define MM_LOADH_PI(a, b)       _mm_loadh_pi(a, b)
65 #define MM_LOADU(a)             _mm_loadu_si128(a)
66 #define MM_MADD16(a, b)         _mm_madd_epi16(a, b)
67 #define MM_MADD8(a, b)          _mm_maddubs_epi16(a, b)
68 #define MM_MOVEMASK8(a)         _mm_movemask_epi8(a)
69 #define MM_OR(a, b)             _mm_or_si128(a, b)
70 #define MM_SET1_16(a)           _mm_set1_epi16(a)
71 #define MM_SET1_32(a)           _mm_set1_epi32(a)
72 #define MM_SET1_64(a)           _mm_set1_epi64(a)
73 #define MM_SET1_8(a)            _mm_set1_epi8(a)
74 #define MM_SET32(a, b, c, d)    _mm_set_epi32(a, b, c, d)
75 #define MM_SHUFFLE32(a, b)      _mm_shuffle_epi32(a, b)
76 #define MM_SHUFFLE8(a, b)       _mm_shuffle_epi8(a, b)
77 #define MM_SHUFFLEPS(a, b, c)   _mm_shuffle_ps(a, b, c)
78 #define MM_SIGN8(a, b)          _mm_sign_epi8(a, b)
79 #define MM_SLL64(a, b)          _mm_sll_epi64(a, b)
80 #define MM_SRL128(a, b)         _mm_srli_si128(a, b)
81 #define MM_SRL16(a, b)          _mm_srli_epi16(a, b)
82 #define MM_SRL32(a, b)          _mm_srli_epi32(a, b)
83 #define MM_STORE(a, b)          _mm_store_si128(a, b)
84 #define MM_STOREU(a, b)         _mm_storeu_si128(a, b)
85 #define MM_TESTZ(a, b)          _mm_testz_si128(a, b)
86 #define MM_XOR(a, b)            _mm_xor_si128(a, b)
87
88 #define MM_SET16(a, b, c, d, e, f, g, h)        \
89         _mm_set_epi16(a, b, c, d, e, f, g, h)
90
91 #define MM_SET8(c0, c1, c2, c3, c4, c5, c6, c7, \
92                 c8, c9, cA, cB, cC, cD, cE, cF) \
93         _mm_set_epi8(c0, c1, c2, c3, c4, c5, c6, c7,    \
94                 c8, c9, cA, cB, cC, cD, cE, cF)
95
96 #ifdef RTE_ARCH_X86_64
97
98 #define MM_CVT64(a)             _mm_cvtsi128_si64(a)
99
100 #else
101
102 #define MM_CVT64(a)     ({ \
103         rte_xmm_t m;       \
104         m.m = (a);         \
105         (m.u64[0]);        \
106 })
107
108 #endif /*RTE_ARCH_X86_64 */
109
110 /*
111  * Prior to version 12.1 icc doesn't support _mm_set_epi64x.
112  */
113 #if (defined(__ICC) && __ICC < 1210)
114
115 #define MM_SET64(a, b)  ({ \
116         rte_xmm_t m;       \
117         m.u64[0] = b;      \
118         m.u64[1] = a;      \
119         (m.m);             \
120 })
121
122 #else
123
124 #define MM_SET64(a, b)          _mm_set_epi64x(a, b)
125
126 #endif /* (defined(__ICC) && __ICC < 1210) */
127
128 #ifdef __cplusplus
129 }
130 #endif
131
132 #endif /* _RTE_ACL_VECT_H_ */