1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2022 StarFive 3 * Copyright(c) 2022 SiFive 4 * Copyright(c) 2022 Semihalf 5 */ 6 7 #ifndef RTE_VECT_RISCV_H 8 #define RTE_VECT_RISCV_H 9 10 #include <stdint.h> 11 #include "generic/rte_vect.h" 12 #include "rte_common.h" 13 14 #ifdef __cplusplus 15 extern "C" { 16 #endif 17 18 #define RTE_VECT_DEFAULT_SIMD_BITWIDTH RTE_VECT_SIMD_DISABLED 19 20 typedef int32_t xmm_t __attribute__((vector_size(16))); 21 22 #define XMM_SIZE (sizeof(xmm_t)) 23 #define XMM_MASK (XMM_SIZE - 1) 24 25 typedef union __rte_aligned(16) rte_xmm { 26 xmm_t x; 27 uint8_t u8[XMM_SIZE / sizeof(uint8_t)]; 28 uint16_t u16[XMM_SIZE / sizeof(uint16_t)]; 29 uint32_t u32[XMM_SIZE / sizeof(uint32_t)]; 30 uint64_t u64[XMM_SIZE / sizeof(uint64_t)]; 31 double pd[XMM_SIZE / sizeof(double)]; 32 } rte_xmm_t; 33 34 static inline xmm_t vect_load_128(void * p)35vect_load_128(void *p) 36 { 37 xmm_t ret = *((xmm_t *)p); 38 return ret; 39 } 40 41 static inline xmm_t vect_and(xmm_t data,xmm_t mask)42vect_and(xmm_t data, xmm_t mask) 43 { 44 rte_xmm_t ret = {.x = data }; 45 rte_xmm_t m = {.x = mask }; 46 ret.u64[0] &= m.u64[0]; 47 ret.u64[1] &= m.u64[1]; 48 return ret.x; 49 } 50 51 #ifdef __cplusplus 52 } 53 #endif 54 55 #endif /* RTE_VECT_RISCV_H */ 56