dpdk: Add support for Mellanox ConnectX-4 devices
[vpp.git] / vppinfra / vppinfra / vector_iwmmxt.h
1 /*
2  * Copyright (c) 2015 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 /*
16   Copyright (c) 2008 Eliot Dresselhaus
17
18   Permission is hereby granted, free of charge, to any person obtaining
19   a copy of this software and associated documentation files (the
20   "Software"), to deal in the Software without restriction, including
21   without limitation the rights to use, copy, modify, merge, publish,
22   distribute, sublicense, and/or sell copies of the Software, and to
23   permit persons to whom the Software is furnished to do so, subject to
24   the following conditions:
25
26   The above copyright notice and this permission notice shall be
27   included in all copies or substantial portions of the Software.
28
29   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
30   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
31   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
32   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
33   LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
34   OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
35   WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 */
37
38 #ifndef included_vector_iwmmxt_h
39 #define included_vector_iwmmxt_h
40
41 #include <vppinfra/error.h>     /* for ASSERT */
42
43 /* 64 bit interleaves. */
44 always_inline u8x8
45 u8x8_interleave_hi (u8x8 a, u8x8 b)
46 {
47   return __builtin_arm_wunpckihb (a, b);
48 }
49
50 always_inline u8x8
51 u8x8_interleave_lo (u8x8 a, u8x8 b)
52 {
53   return __builtin_arm_wunpckilb (a, b);
54 }
55
56 always_inline u16x4
57 u16x4_interleave_hi (u16x4 a, u16x4 b)
58 {
59   return __builtin_arm_wunpckihh (a, b);
60 }
61
62 always_inline u16x4
63 u16x4_interleave_lo (u16x4 a, u16x4 b)
64 {
65   return __builtin_arm_wunpckilh (a, b);
66 }
67
68 always_inline u32x2
69 u32x2_interleave_hi (u32x2 a, u32x2 b)
70 {
71   return __builtin_arm_wunpckihw (a, b);
72 }
73
74 always_inline u32x2
75 u32x2_interleave_lo (u32x2 a, u32x2 b)
76 {
77   return __builtin_arm_wunpckilw (a, b);
78 }
79
80 always_inline u32x2
81 u32x2_splat (u32 a)
82 {
83   u32x2 x = { a };
84   x = u32x2_interleave_lo (x, x);
85   return x;
86 }
87
88 always_inline u16x4
89 u16x4_splat (u16 a)
90 {
91   u32 t = (u32) a | ((u32) a << 16);
92   return u32x2_splat (t);
93 }
94
95 always_inline u8x8
96 u8x8_splat (u8 a)
97 {
98   u32 t = (u32) a | ((u32) a << 8);
99   t |= t << 16;
100   return u32x2_splat (t);
101 }
102
103 #define i32x2_splat u32x2_splat
104 #define i16x4_splat u16x4_splat
105 #define i8x8_splat u8x8_splat
106
107 /* 64 bit shifts. */
108
109 /* As of July 2008 the __builtin_arm shifts cause gcc-4.3.1 to crash
110    so we use asm versions. */
111 #define _(t,u,lr,f)                             \
112   always_inline t                               \
113   t##_##lr (t x, int i)                         \
114   {                                             \
115     i16x4 y;                                    \
116     asm (#f " %[y], %[x], %[shift]"             \
117          : [y] "=y" (y)                         \
118          : [x] "y" (x), [shift] "i" (i * u));   \
119     return y;                                   \
120   }
121
122 _(u16x4, 1, shift_left, wsllhi)
123 _(u32x2, 1, shift_left, wsllwi)
124 _(u16x4, 1, shift_right, wsrlhi)
125 _(u32x2, 1, shift_right, wsrlwi)
126 _(i16x4, 1, shift_left, wsllhi)
127 _(i32x2, 1, shift_left, wsllwi)
128 _(i16x4, 1, shift_right, wsrahi) _(i32x2, 1, shift_right, wsrawi)
129 /* Word shifts. */
130   _(u8x8, 8, word_shift_left, wslldi)
131 _(u16x4, 16, word_shift_left, wslldi)
132 _(u32x2, 32, word_shift_left, wslldi)
133 _(u8x8, 8, word_shift_right, wsrldi)
134 _(u16x4, 16, word_shift_right, wsrldi)
135 _(u32x2, 32, word_shift_right, wsrldi)
136 _(i8x8, 8, word_shift_left, wslldi)
137 _(i16x4, 16, word_shift_left, wslldi)
138 _(i32x2, 32, word_shift_left, wslldi)
139 _(i8x8, 8, word_shift_right, wsrldi)
140 _(i16x4, 16, word_shift_right, wsrldi) _(i32x2, 32, word_shift_right, wsrldi)
141 #undef _
142 #endif /* included_vector_iwmmxt_h */
143 /*
144  * fd.io coding-style-patch-verification: ON
145  *
146  * Local Variables:
147  * eval: (c-set-style "gnu")
148  * End:
149  */