1 /* Template file for saturating unary operator validation.
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
6 saturating unary operators, these can be tested by providing a
7 definition for EXTRA_TESTS. */
10 #include "arm-neon-ref.h"
11 #include "compute-ref-data.h"
13 #define FNNAME1(NAME) exec_ ## NAME
14 #define FNNAME(NAME) FNNAME1(NAME)
16 void FNNAME (INSN_NAME) (void)
18 /* y=OP(x), then store the result. */
19 #define TEST_UNARY_SAT_OP1(INSN, Q, T1, T2, W, N, EXPECTED_CUMULATIVE_SAT, CMT) \
20 Set_Neon_Cumulative_Sat(0); \
21 VECT_VAR(vector_res, T1, W, N) = \
22 INSN##Q##_##T2##W(VECT_VAR(vector, T1, W, N)); \
23 vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), \
24 VECT_VAR(vector_res, T1, W, N)); \
25 CHECK_CUMULATIVE_SAT(TEST_MSG, T1, W, N, EXPECTED_CUMULATIVE_SAT, CMT)
27 #define TEST_UNARY_SAT_OP(INSN, Q, T1, T2, W, N, EXPECTED_CUMULATIVE_SAT, CMT) \
28 TEST_UNARY_SAT_OP1(INSN, Q, T1, T2, W, N, EXPECTED_CUMULATIVE_SAT, CMT)
30 /* No need for 64 bits variants. */
31 DECL_VARIABLE(vector, int, 8, 8);
32 DECL_VARIABLE(vector, int, 16, 4);
33 DECL_VARIABLE(vector, int, 32, 2);
34 DECL_VARIABLE(vector, int, 8, 16);
35 DECL_VARIABLE(vector, int, 16, 8);
36 DECL_VARIABLE(vector, int, 32, 4);
38 DECL_VARIABLE(vector_res, int, 8, 8);
39 DECL_VARIABLE(vector_res, int, 16, 4);
40 DECL_VARIABLE(vector_res, int, 32, 2);
41 DECL_VARIABLE(vector_res, int, 8, 16);
42 DECL_VARIABLE(vector_res, int, 16, 8);
43 DECL_VARIABLE(vector_res, int, 32, 4);
47 /* Initialize input "vector" from "buffer". */
48 VLOAD(vector, buffer, , int, s, 8, 8);
49 VLOAD(vector, buffer, , int, s, 16, 4);
50 VLOAD(vector, buffer, , int, s, 32, 2);
51 VLOAD(vector, buffer, q, int, s, 8, 16);
52 VLOAD(vector, buffer, q, int, s, 16, 8);
53 VLOAD(vector, buffer, q, int, s, 32, 4);
55 /* Apply a saturating unary operator named INSN_NAME. */
56 TEST_UNARY_SAT_OP(INSN_NAME, , int, s, 8, 8, expected_cumulative_sat, "");
57 TEST_UNARY_SAT_OP(INSN_NAME, , int, s, 16, 4, expected_cumulative_sat, "");
58 TEST_UNARY_SAT_OP(INSN_NAME, , int, s, 32, 2, expected_cumulative_sat, "");
59 TEST_UNARY_SAT_OP(INSN_NAME, q, int, s, 8, 16, expected_cumulative_sat, "");
60 TEST_UNARY_SAT_OP(INSN_NAME, q, int, s, 16, 8, expected_cumulative_sat, "");
61 TEST_UNARY_SAT_OP(INSN_NAME, q, int, s, 32, 4, expected_cumulative_sat, "");
63 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected, "");
64 CHECK(TEST_MSG, int, 16, 4, PRIx8, expected, "");
65 CHECK(TEST_MSG, int, 32, 2, PRIx8, expected, "");
66 CHECK(TEST_MSG, int, 8, 16, PRIx8, expected, "");
67 CHECK(TEST_MSG, int, 16, 8, PRIx8, expected, "");
68 CHECK(TEST_MSG, int, 32, 4, PRIx8, expected, "");
77 FNNAME (INSN_NAME) ();