eal: define generic vector types
[dpdk.git] / lib / librte_eal / common / include / arch / arm / rte_vect.h
index 21cdb4d..4107c99 100644 (file)
@@ -33,6 +33,8 @@
 #ifndef _RTE_VECT_ARM_H_
 #define _RTE_VECT_ARM_H_
 
+#include <stdint.h>
+#include "generic/rte_vect.h"
 #include "arm_neon.h"
 
 #ifdef __cplusplus
@@ -53,6 +55,29 @@ typedef union rte_xmm {
        double   pd[XMM_SIZE / sizeof(double)];
 } __attribute__((aligned(16))) rte_xmm_t;
 
+#ifdef RTE_ARCH_ARM
+/* NEON intrinsic vqtbl1q_u8() is not supported in ARMv7-A(AArch32) */
+static __inline uint8x16_t
+vqtbl1q_u8(uint8x16_t a, uint8x16_t b)
+{
+       uint8_t i, pos;
+       rte_xmm_t rte_a, rte_b, rte_ret;
+
+       vst1q_u8(rte_a.u8, a);
+       vst1q_u8(rte_b.u8, b);
+
+       for (i = 0; i < 16; i++) {
+               pos = rte_b.u8[i];
+               if (pos < 16)
+                       rte_ret.u8[i] = rte_a.u8[pos];
+               else
+                       rte_ret.u8[i] = 0;
+       }
+
+       return vld1q_u8(rte_ret.u8);
+}
+#endif
+
 #ifdef __cplusplus
 }
 #endif