FD.io VPP
v16.09
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__)
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
#endif
67
68
#ifdef CLIB_HAVE_VEC64
69
/* Signed 64 bit. */
70
typedef
char
i8x8 _vector_size (8);
71
typedef
short
i16x4 _vector_size (8);
72
typedef
int
i32x2 _vector_size (8);
73
74
/* Unsigned 64 bit. */
75
typedef
unsigned
char
u8x8 _vector_size (8);
76
typedef
unsigned
short
u16x4 _vector_size (8);
77
typedef
unsigned
int
u32x2 _vector_size (8);
78
79
/* Floating point 64 bit. */
80
typedef
float
f32x2 _vector_size (8);
81
#endif
/* CLIB_HAVE_VEC64 */
82
83
#ifdef CLIB_HAVE_VEC128
84
/* Signed 128 bit. */
85
typedef
i8
i8x16 _vector_size (16);
86
typedef
i16
i16x8
_vector_size (16);
87
typedef
i32
i32x4
_vector_size (16);
88
typedef
long
long
i64x2 _vector_size (16);
89
90
/* Unsigned 128 bit. */
91
typedef
u8
u8x16 _vector_size (16);
92
typedef
u16
u16x8 _vector_size (16);
93
typedef
u32
u32x4
_vector_size (16);
94
typedef
u64
u64x2 _vector_size (16);
95
96
typedef
f32
f32x4 _vector_size (16);
97
typedef
f64
f64x2 _vector_size (16);
98
#endif
/* CLIB_HAVE_VEC128 */
99
100
/* Vector word sized types. */
101
#ifndef CLIB_VECTOR_WORD_BITS
102
#ifdef CLIB_HAVE_VEC128
103
#define CLIB_VECTOR_WORD_BITS 128
104
#else
105
#define CLIB_VECTOR_WORD_BITS 64
106
#endif
107
#endif
/* CLIB_VECTOR_WORD_BITS */
108
109
/* Vector word sized types. */
110
#if CLIB_VECTOR_WORD_BITS == 128
111
typedef
i8
i8x _vector_size (16);
112
typedef
i16
i16x _vector_size (16);
113
typedef
i32
i32x _vector_size (16);
114
typedef
i64
i64x _vector_size (16);
115
typedef
u8
u8x _vector_size (16);
116
typedef
u16
u16x _vector_size (16);
117
typedef
u32
u32x _vector_size (16);
118
typedef
u64
u64x _vector_size (16);
119
#endif
120
#if CLIB_VECTOR_WORD_BITS == 64
121
typedef
i8
i8x _vector_size (8);
122
typedef
i16
i16x _vector_size (8);
123
typedef
i32
i32x _vector_size (8);
124
typedef
i64
i64x _vector_size (8);
125
typedef
u8
u8x _vector_size (8);
126
typedef
u16
u16x _vector_size (8);
127
typedef
u32
u32x _vector_size (8);
128
typedef
u64
u64x _vector_size (8);
129
#endif
130
131
#undef _vector_size
132
133
#define VECTOR_WORD_TYPE(t) t##x
134
#define VECTOR_WORD_TYPE_LEN(t) (sizeof (VECTOR_WORD_TYPE(t)) / sizeof (t))
135
136
/* Union types. */
137
#if (defined(CLIB_HAVE_VEC128) || defined(CLIB_HAVE_VEC64))
138
139
#define _(t) \
140
typedef union { \
141
t##x as_##t##x; \
142
t as_##t[VECTOR_WORD_TYPE_LEN (t)]; \
143
} t##x##_union_t;
144
145
_(
u8
);
146
_(
u16
);
147
_(
u32
);
148
_(
u64
);
149
_(
i8
);
150
_(
i16
);
151
_(
i32
);
152
_(
i64
);
153
154
#undef _
155
156
#endif
157
158
#ifdef CLIB_HAVE_VEC64
159
160
#define _(t,n) \
161
typedef union { \
162
t##x##n as_##t##x##n; \
163
t as_##t[n]; \
164
} t##x##n##_union_t; \
165
166
_(
u8
, 8);
167
_(
u16
, 4);
168
_(
u32
, 2);
169
_(
i8
, 8);
170
_(
i16
, 4);
171
_(
i32
, 2);
172
173
#undef _
174
175
#endif
176
177
#ifdef CLIB_HAVE_VEC128
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
, 16);
186
_(
u16
, 8);
187
_(
u32
, 4);
188
_(
u64
, 2);
189
_(
i8
, 16);
190
_(
i16
, 8);
191
_(
i32
, 4);
192
_(
i64
, 2);
193
_(
f32
, 4);
194
_(
f64
, 2);
195
196
#undef _
197
198
#endif
199
200
/* When we don't have vector types, still define e.g. u32x4_union_t but as an array. */
201
#if !defined(CLIB_HAVE_VEC128) && !defined(CLIB_HAVE_VEC64)
202
203
#define _(t,n) \
204
typedef union { \
205
t as_##t[n]; \
206
} t##x##n##_union_t; \
207
208
_(
u8
, 16);
209
_(
u16
, 8);
210
_(
u32
, 4);
211
_(
u64
, 2);
212
_(
i8
, 16);
213
_(
i16
, 8);
214
_(
i32
, 4);
215
_(
i64
, 2);
216
217
#undef _
218
219
#endif
220
221
#if defined (__SSE2__) && __GNUC__ >= 4
222
#include <
vppinfra/vector_sse2.h
>
223
#endif
224
225
#if defined (__ALTIVEC__)
226
#include <
vppinfra/vector_altivec.h
>
227
#endif
228
229
#if defined (__IWMMXT__)
230
#include <
vppinfra/vector_iwmmxt.h
>
231
#endif
232
233
#if (defined(CLIB_HAVE_VEC128) || defined(CLIB_HAVE_VEC64))
234
#include <
vppinfra/vector_funcs.h
>
235
#endif
236
237
#endif
/* included_clib_vector_h */
238
239
/*
240
* fd.io coding-style-patch-verification: ON
241
*
242
* Local Variables:
243
* eval: (c-set-style "gnu")
244
* End:
245
*/
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
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
vppinfra
vppinfra
vector.h
Generated on Fri Nov 18 2016 06:18:20 for FD.io VPP by
1.8.11