1  #include <arm_neon.h>
       2  #include "arm-neon-ref.h"
       3  #include "compute-ref-data.h"
       4  
       5  /* Expected results.  */
       6  VECT_VAR_DECL(expected,int,8,8) [] = { 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8 };
       7  VECT_VAR_DECL(expected,uint,8,8) [] = { 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4 };
       8  VECT_VAR_DECL(expected,poly,8,8) [] = { 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4 };
       9  VECT_VAR_DECL(expected,int,8,16) [] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
      10  					0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
      11  VECT_VAR_DECL(expected,uint,8,16) [] = { 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6,
      12  					 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6 };
      13  VECT_VAR_DECL(expected,poly,8,16) [] = { 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6,
      14  					 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6, 0x6 };
      15  
      16  #define INSN_NAME vcnt
      17  #define TEST_MSG "VCNT/VCNTQ"
      18  
      19  #define FNNAME1(NAME) void exec_ ## NAME (void)
      20  #define FNNAME(NAME) FNNAME1(NAME)
      21  
      22  FNNAME (INSN_NAME)
      23  {
      24    /* Basic test: y=vcnt(x), then store the result.  */
      25  #define TEST_UNARY_OP1(INSN, Q, T1, T2, W, N)				\
      26    VECT_VAR(vector_res, T1, W, N) =					\
      27      INSN##Q##_##T2##W(VECT_VAR(vector, T1, W, N));			\
      28    vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), VECT_VAR(vector_res, T1, W, N))
      29  
      30  #define TEST_UNARY_OP(INSN, Q, T1, T2, W, N)	\
      31    TEST_UNARY_OP1(INSN, Q, T1, T2, W, N)		\
      32  
      33    /* No need for 64 bits variants.  */
      34    DECL_VARIABLE(vector, int, 8, 8);
      35    DECL_VARIABLE(vector, uint, 8, 8);
      36    DECL_VARIABLE(vector, poly, 8, 8);
      37    DECL_VARIABLE(vector, int, 8, 16);
      38    DECL_VARIABLE(vector, uint, 8, 16);
      39    DECL_VARIABLE(vector, poly, 8, 16);
      40  
      41    DECL_VARIABLE(vector_res, int, 8, 8);
      42    DECL_VARIABLE(vector_res, uint, 8, 8);
      43    DECL_VARIABLE(vector_res, poly, 8, 8);
      44    DECL_VARIABLE(vector_res, int, 8, 16);
      45    DECL_VARIABLE(vector_res, uint, 8, 16);
      46    DECL_VARIABLE(vector_res, poly, 8, 16);
      47  
      48    clean_results ();
      49  
      50    /* Fill input vector with arbitrary values.  */
      51    VDUP(vector, , int, s, 8, 8, 0xFF);
      52    VDUP(vector, , uint, u, 8, 8, 0x35);
      53    VDUP(vector, , poly, p, 8, 8, 0x35);
      54    VDUP(vector, q, int, s, 8, 16, 0);
      55    VDUP(vector, q, uint, u, 8, 16, 0xBD);
      56    VDUP(vector, q, poly, p, 8, 16, 0xBD);
      57  
      58    /* Apply a unary operator named INSN_NAME.  */
      59    TEST_UNARY_OP(INSN_NAME, , int, s, 8, 8);
      60    TEST_UNARY_OP(INSN_NAME, , uint, u, 8, 8);
      61    TEST_UNARY_OP(INSN_NAME, , poly, p, 8, 8);
      62    TEST_UNARY_OP(INSN_NAME, q, int, s, 8, 16);
      63    TEST_UNARY_OP(INSN_NAME, q, uint, u, 8, 16);
      64    TEST_UNARY_OP(INSN_NAME, q, poly, p, 8, 16);
      65  
      66    CHECK(TEST_MSG, int, 8, 8, PRIx8, expected, "");
      67    CHECK(TEST_MSG, uint, 8, 8, PRIx8, expected, "");
      68    CHECK_POLY(TEST_MSG, poly, 8, 8, PRIx8, expected, "");
      69    CHECK(TEST_MSG, int, 8, 16, PRIx8, expected, "");
      70    CHECK(TEST_MSG, uint, 8, 16, PRIx8, expected, "");
      71    CHECK_POLY(TEST_MSG, poly, 8, 16, PRIx8, expected, "");
      72  }
      73  
      74  int main (void)
      75  {
      76    exec_vcnt ();
      77    return 0;
      78  }