xref: /dpdk/lib/eal/loongarch/include/rte_vect.h (revision c6552d9a8deffa448de2d5e2e726f50508c1efd2)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2022 Loongson Technology Corporation Limited
3  */
4 
5 #ifndef RTE_VECT_LOONGARCH_H
6 #define RTE_VECT_LOONGARCH_H
7 
8 #include <stdint.h>
9 #include "generic/rte_vect.h"
10 #include "rte_common.h"
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 #define RTE_VECT_DEFAULT_SIMD_BITWIDTH RTE_VECT_SIMD_DISABLED
17 
18 typedef union __rte_aligned(16) xmm {
19 	int8_t   i8[16];
20 	int16_t  i16[8];
21 	int32_t  i32[4];
22 	int64_t  i64[2];
23 	uint8_t  u8[16];
24 	uint16_t u16[8];
25 	uint32_t u32[4];
26 	uint64_t u64[2];
27 	double   pd[2];
28 } xmm_t;
29 
30 #define XMM_SIZE        (sizeof(xmm_t))
31 #define XMM_MASK        (XMM_SIZE - 1)
32 
33 typedef union __rte_aligned(16) rte_xmm {
34 	xmm_t	 x;
35 	uint8_t	 u8[XMM_SIZE / sizeof(uint8_t)];
36 	uint16_t u16[XMM_SIZE / sizeof(uint16_t)];
37 	uint32_t u32[XMM_SIZE / sizeof(uint32_t)];
38 	uint64_t u64[XMM_SIZE / sizeof(uint64_t)];
39 	double   pd[XMM_SIZE / sizeof(double)];
40 } rte_xmm_t;
41 
42 static inline xmm_t
vect_load_128(void * p)43 vect_load_128(void *p)
44 {
45 	xmm_t ret = *((xmm_t *)p);
46 
47 	return ret;
48 }
49 
50 static inline xmm_t
vect_and(xmm_t data,xmm_t mask)51 vect_and(xmm_t data, xmm_t mask)
52 {
53 	rte_xmm_t ret = {.x = data };
54 	rte_xmm_t m = {.x = mask };
55 	ret.u64[0] &= m.u64[0];
56 	ret.u64[1] &= m.u64[1];
57 
58 	return ret.x;
59 }
60 
61 #ifdef __cplusplus
62 }
63 #endif
64 
65 #endif /* RTE_VECT_LOONGARCH_H */
66