FD.io VPP
v17.07.01-10-g3be13f0
Vector Packet Processing
Main Page
Related Pages
Data Structures
Source
Files
Symbols
vector.h
Go to the documentation of this file.
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) 2005 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_clib_vector_h
39
#define included_clib_vector_h
40
41
#include <
vppinfra/clib.h
>
42
43
/* Vector types. */
44
45
#if defined (__MMX__) || defined (__IWMMXT__) || defined (__aarch64__)
46
#define CLIB_HAVE_VEC64
47
#endif
48
49
#if defined (__SSE2__) && __GNUC__ >= 4
50
#define CLIB_HAVE_VEC128
51
#endif
52
53
#if defined (__ALTIVEC__)
54
#define CLIB_HAVE_VEC128
55
#endif
56
57
/* 128 implies 64 */
58
#ifdef CLIB_HAVE_VEC128
59
#define CLIB_HAVE_VEC64
60
#endif
61
62
#define _vector_size(n) __attribute__ ((vector_size (n)))
63
64
#if defined (__aarch64__) || defined (__arm__)
65
typedef
unsigned
int
u32x4
_vector_size (16);
66
typedef
u8
u8x16 _vector_size (16);
67
typedef
u16
u16x8 _vector_size (16);
68
typedef
u32
u32x4
_vector_size (16);
69
typedef
u64
u64x2 _vector_size (16);
70
#endif
71
72
#ifdef CLIB_HAVE_VEC64
73
/* Signed 64 bit. */
74
typedef
char
i8x8 _vector_size (8);
75
typedef
short
i16x4 _vector_size (8);
76
typedef
int
i32x2 _vector_size (8);
77
78
/* Unsigned 64 bit. */
79
typedef
unsigned
char
u8x8 _vector_size (8);
80
typedef
unsigned
short
u16x4 _vector_size (8);
81
typedef
unsigned
int
u32x2 _vector_size (8);
82
83
/* Floating point 64 bit. */
84
typedef
float
f32x2 _vector_size (8);
85
#endif
/* CLIB_HAVE_VEC64 */
86
87
#ifdef CLIB_HAVE_VEC128
88
/* Signed 128 bit. */
89
typedef
i8
i8x16 _vector_size (16);
90
typedef
i16
i16x8
_vector_size (16);
91
typedef
i32
i32x4
_vector_size (16);
92
typedef
long
long
i64x2 _vector_size (16);
93
94
/* Unsigned 128 bit. */
95
typedef
u8
u8x16 _vector_size (16);
96
typedef
u16
u16x8 _vector_size (16);
97
typedef
u32
u32x4
_vector_size (16);
98
typedef
u64
u64x2 _vector_size (16);
99
100
typedef
f32
f32x4 _vector_size (16);
101
typedef
f64
f64x2 _vector_size (16);
102
103
/* Signed 256 bit. */
104
typedef
i8
i8x32 _vector_size (32);
105
typedef
i16
i16x16 _vector_size (32);
106
typedef
i32
i32x8 _vector_size (32);
107
typedef
long
long
i64x4 _vector_size (32);
108
109
/* Unsigned 256 bit. */
110
typedef
u8
u8x32 _vector_size (32);
111
typedef
u16
u16x16 _vector_size (32);
112
typedef
u32
u32x8 _vector_size (32);
113
typedef
u64
u64x4 _vector_size (32);
114
115
typedef
f32
f32x8 _vector_size (32);
116
typedef
f64
f64x4 _vector_size (32);
117
#endif
/* CLIB_HAVE_VEC128 */
118
119
/* Vector word sized types. */
120
#ifndef CLIB_VECTOR_WORD_BITS
121
#ifdef CLIB_HAVE_VEC128
122
#define CLIB_VECTOR_WORD_BITS 128
123
#else
124
#define CLIB_VECTOR_WORD_BITS 64
125
#endif
126
#endif
/* CLIB_VECTOR_WORD_BITS */
127
128
/* Vector word sized types. */
129
#if CLIB_VECTOR_WORD_BITS == 128
130
typedef
i8
i8x _vector_size (16);
131
typedef
i16
i16x _vector_size (16);
132
typedef
i32
i32x _vector_size (16);
133
typedef
i64
i64x _vector_size (16);
134
typedef
u8
u8x _vector_size (16);
135
typedef
u16
u16x _vector_size (16);
136
typedef
u32
u32x _vector_size (16);
137
typedef
u64
u64x _vector_size (16);
138
#endif
139
#if CLIB_VECTOR_WORD_BITS == 64
140
typedef
i8
i8x _vector_size (8);
141
typedef
i16
i16x _vector_size (8);
142
typedef
i32
i32x _vector_size (8);
143
typedef
i64
i64x _vector_size (8);
144
typedef
u8
u8x _vector_size (8);
145
typedef
u16
u16x _vector_size (8);
146
typedef
u32
u32x _vector_size (8);
147
typedef
u64
u64x _vector_size (8);
148
#endif
149
150
#undef _vector_size
151
152
#define VECTOR_WORD_TYPE(t) t##x
153
#define VECTOR_WORD_TYPE_LEN(t) (sizeof (VECTOR_WORD_TYPE(t)) / sizeof (t))
154
155
/* Union types. */
156
#if (defined(CLIB_HAVE_VEC128) || defined(CLIB_HAVE_VEC64))
157
158
#define _(t) \
159
typedef union { \
160
t##x as_##t##x; \
161
t as_##t[VECTOR_WORD_TYPE_LEN (t)]; \
162
} t##x##_union_t;
163
164
_(
u8
);
165
_(
u16
);
166
_(
u32
);
167
_(
u64
);
168
_(
i8
);
169
_(
i16
);
170
_(
i32
);
171
_(
i64
);
172
173
#undef _
174
175
#endif
176
177
#ifdef CLIB_HAVE_VEC64
178
179
#define _(t,n) \
180
typedef union { \
181
t##x##n as_##t##x##n; \
182
t as_##t[n]; \
183
} t##x##n##_union_t; \
184
185
_(
u8
, 8);
186
_(
u16
, 4);
187
_(
u32
, 2);
188
_(
i8
, 8);
189
_(
i16
, 4);
190
_(
i32
, 2);
191
192
#undef _
193
194
#endif
195
196
#ifdef CLIB_HAVE_VEC128
197
198
#define _(t,n) \
199
typedef union { \
200
t##x##n as_##t##x##n; \
201
t as_##t[n]; \
202
} t##x##n##_union_t; \
203
204
_(
u8
, 16);
205
_(
u16
, 8);
206
_(
u32
, 4);
207
_(
u64
, 2);
208
_(
i8
, 16);
209
_(
i16
, 8);
210
_(
i32
, 4);
211
_(
i64
, 2);
212
_(
f32
, 4);
213
_(
f64
, 2);
214
215
#undef _
216
217
#endif
218
219
/* When we don't have vector types, still define e.g. u32x4_union_t but as an array. */
220
#if !defined(CLIB_HAVE_VEC128) && !defined(CLIB_HAVE_VEC64)
221
222
#define _(t,n) \
223
typedef union { \
224
t as_##t[n]; \
225
} t##x##n##_union_t; \
226
227
_(
u8
, 16);
228
_(
u16
, 8);
229
_(
u32
, 4);
230
_(
u64
, 2);
231
_(
i8
, 16);
232
_(
i16
, 8);
233
_(
i32
, 4);
234
_(
i64
, 2);
235
236
#undef _
237
238
#endif
239
240
#if defined (__SSE2__) && __GNUC__ >= 4
241
#include <
vppinfra/vector_sse2.h
>
242
#endif
243
244
#if defined (__ALTIVEC__)
245
#include <
vppinfra/vector_altivec.h
>
246
#endif
247
248
#if defined (__IWMMXT__)
249
#include <
vppinfra/vector_iwmmxt.h
>
250
#endif
251
252
#if defined (__aarch64__)
253
#include <
vppinfra/vector_neon.h
>
254
#endif
255
256
#if (defined(CLIB_HAVE_VEC128) || defined(CLIB_HAVE_VEC64))
257
#include <
vppinfra/vector_funcs.h
>
258
#endif
259
260
#endif
/* included_clib_vector_h */
261
262
/*
263
* fd.io coding-style-patch-verification: ON
264
*
265
* Local Variables:
266
* eval: (c-set-style "gnu")
267
* End:
268
*/
vector_sse2.h
f32
float f32
Definition:
types.h:143
i32x4
i32x4
Definition:
vector_altivec.h:115
vector_altivec.h
u32x4
unsigned long long u32x4
Definition:
ixge.c:28
i32
int i32
Definition:
types.h:81
i8
char i8
Definition:
types.h:45
u64
unsigned long u64
Definition:
types.h:89
vector_iwmmxt.h
i64
long i64
Definition:
types.h:82
clib.h
vector_neon.h
u32
unsigned int u32
Definition:
types.h:88
i16x8
vmrglw i16x8
Definition:
vector_altivec.h:117
u16
unsigned short u16
Definition:
types.h:57
f64
double f64
Definition:
types.h:142
u8
unsigned char u8
Definition:
types.h:56
vector_funcs.h
i16
short i16
Definition:
types.h:46
src
vppinfra
vector.h
Generated on Tue Nov 7 2017 14:27:03 for FD.io VPP by
1.8.11