eal: move arch-specific C files
[dpdk.git] / lib / librte_eal / common / include / arch / x86 / rte_vect.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2015 Intel Corporation
3  */
4
5 #ifndef _RTE_VECT_X86_H_
6 #define _RTE_VECT_X86_H_
7
8 /**
9  * @file
10  *
11  * RTE SSE/AVX related header.
12  */
13
14 #include <stdint.h>
15 #include <rte_config.h>
16 #include "generic/rte_vect.h"
17
18 #if (defined(__ICC) || \
19         (defined(_WIN64)) || \
20         (__GNUC__ == 4 &&  __GNUC_MINOR__ < 4))
21
22 #include <smmintrin.h> /* SSE4 */
23
24 #if defined(__AVX__)
25 #include <immintrin.h>
26 #endif
27
28 #else
29
30 #include <x86intrin.h>
31
32 #endif
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 typedef __m128i xmm_t;
39
40 #define XMM_SIZE        (sizeof(xmm_t))
41 #define XMM_MASK        (XMM_SIZE - 1)
42
43 typedef union rte_xmm {
44         xmm_t    x;
45         uint8_t  u8[XMM_SIZE / sizeof(uint8_t)];
46         uint16_t u16[XMM_SIZE / sizeof(uint16_t)];
47         uint32_t u32[XMM_SIZE / sizeof(uint32_t)];
48         uint64_t u64[XMM_SIZE / sizeof(uint64_t)];
49         double   pd[XMM_SIZE / sizeof(double)];
50 } rte_xmm_t;
51
52 #ifdef __AVX__
53
54 typedef __m256i ymm_t;
55
56 #define YMM_SIZE        (sizeof(ymm_t))
57 #define YMM_MASK        (YMM_SIZE - 1)
58
59 typedef union rte_ymm {
60         ymm_t    y;
61         xmm_t    x[YMM_SIZE / sizeof(xmm_t)];
62         uint8_t  u8[YMM_SIZE / sizeof(uint8_t)];
63         uint16_t u16[YMM_SIZE / sizeof(uint16_t)];
64         uint32_t u32[YMM_SIZE / sizeof(uint32_t)];
65         uint64_t u64[YMM_SIZE / sizeof(uint64_t)];
66         double   pd[YMM_SIZE / sizeof(double)];
67 } rte_ymm_t;
68
69 #endif /* __AVX__ */
70
71 #ifdef RTE_ARCH_I686
72 #define _mm_cvtsi128_si64(a)    \
73 __extension__ ({                \
74         rte_xmm_t m;            \
75         m.x = (a);              \
76         (m.u64[0]);             \
77 })
78 #endif
79
80 /*
81  * Prior to version 12.1 icc doesn't support _mm_set_epi64x.
82  */
83 #if (defined(__ICC) && __ICC < 1210)
84 #define _mm_set_epi64x(a, b)     \
85 __extension__ ({                 \
86         rte_xmm_t m;             \
87         m.u64[0] = b;            \
88         m.u64[1] = a;            \
89         (m.x);                   \
90 })
91 #endif /* (defined(__ICC) && __ICC < 1210) */
92
93 #ifdef __cplusplus
94 }
95 #endif
96
97 #endif /* _RTE_VECT_X86_H_ */