1/* Template file for unary operator validation. 2 3 This file is meant to be included by the relevant test files, which 4 have to define the intrinsic family to test. If a given intrinsic 5 supports variants which are not supported by all the other unary 6 operators, these can be tested by providing a definition for 7 EXTRA_TESTS. */ 8 9#include <arm_neon.h> 10#include "arm-neon-ref.h" 11#include "compute-ref-data.h" 12 13#define FNNAME1(NAME) exec_ ## NAME 14#define FNNAME(NAME) FNNAME1(NAME) 15 16void FNNAME (INSN_NAME) (void) 17{ 18 /* Basic test: y=OP(x), then store the result. */ 19#define TEST_UNARY_OP1(INSN, Q, T1, T2, W, N) \ 20 VECT_VAR(vector_res, T1, W, N) = \ 21 INSN##Q##_##T2##W(VECT_VAR(vector, T1, W, N)); \ 22 vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), VECT_VAR(vector_res, T1, W, N)) 23 24#define TEST_UNARY_OP(INSN, Q, T1, T2, W, N) \ 25 TEST_UNARY_OP1(INSN, Q, T1, T2, W, N) \ 26 27 /* No need for 64 bits variants in the general case. */ 28 DECL_VARIABLE(vector, int, 8, 8); 29 DECL_VARIABLE(vector, int, 16, 4); 30 DECL_VARIABLE(vector, int, 32, 2); 31 DECL_VARIABLE(vector, int, 8, 16); 32 DECL_VARIABLE(vector, int, 16, 8); 33 DECL_VARIABLE(vector, int, 32, 4); 34 35 DECL_VARIABLE(vector_res, int, 8, 8); 36 DECL_VARIABLE(vector_res, int, 16, 4); 37 DECL_VARIABLE(vector_res, int, 32, 2); 38 DECL_VARIABLE(vector_res, int, 8, 16); 39 DECL_VARIABLE(vector_res, int, 16, 8); 40 DECL_VARIABLE(vector_res, int, 32, 4); 41 42 clean_results (); 43 44 /* Initialize input "vector" from "buffer". */ 45 VLOAD(vector, buffer, , int, s, 8, 8); 46 VLOAD(vector, buffer, , int, s, 16, 4); 47 VLOAD(vector, buffer, , int, s, 32, 2); 48 VLOAD(vector, buffer, q, int, s, 8, 16); 49 VLOAD(vector, buffer, q, int, s, 16, 8); 50 VLOAD(vector, buffer, q, int, s, 32, 4); 51 52 /* Apply a unary operator named INSN_NAME. */ 53 TEST_UNARY_OP(INSN_NAME, , int, s, 8, 8); 54 TEST_UNARY_OP(INSN_NAME, , int, s, 16, 4); 55 TEST_UNARY_OP(INSN_NAME, , int, s, 32, 2); 56 TEST_UNARY_OP(INSN_NAME, q, int, s, 8, 16); 57 TEST_UNARY_OP(INSN_NAME, q, int, s, 16, 8); 58 TEST_UNARY_OP(INSN_NAME, q, int, s, 32, 4); 59 60 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected, ""); 61 CHECK(TEST_MSG, int, 16, 4, PRIx16, expected, ""); 62 CHECK(TEST_MSG, int, 32, 2, PRIx32, expected, ""); 63 CHECK(TEST_MSG, int, 8, 16, PRIx8, expected, ""); 64 CHECK(TEST_MSG, int, 16, 8, PRIx16, expected, ""); 65 CHECK(TEST_MSG, int, 32, 4, PRIx32, expected, ""); 66 67#ifdef EXTRA_TESTS 68 EXTRA_TESTS(); 69#endif 70} 71 72int main (void) 73{ 74 FNNAME (INSN_NAME)(); 75 76 return 0; 77} 78