1 /* Template file for saturating binary 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 binary 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 /* vector_res = OP(vector1,vector2), then store the result. */
20 #define TEST_BINARY_SAT_OP1(INSN, Q, T1, T2, W, N, EXPECTED_CUMULATIVE_SAT, CMT) \
21 Set_Neon_Cumulative_Sat(0, VECT_VAR(vector_res, T1, W, N)); \
22 VECT_VAR(vector_res, T1, W, N) = \
23 INSN##Q##_##T2##W(VECT_VAR(vector1, T1, W, N), \
24 VECT_VAR(vector2, T1, W, N)); \
25 vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), \
26 VECT_VAR(vector_res, T1, W, N)); \
27 CHECK_CUMULATIVE_SAT(TEST_MSG, T1, W, N, EXPECTED_CUMULATIVE_SAT, CMT)
29 #define TEST_BINARY_SAT_OP(INSN, Q, T1, T2, W, N, EXPECTED_CUMULATIVE_SAT, CMT) \
30 TEST_BINARY_SAT_OP1(INSN, Q, T1, T2, W, N, EXPECTED_CUMULATIVE_SAT, CMT)
32 DECL_VARIABLE_ALL_VARIANTS(vector1);
33 DECL_VARIABLE_ALL_VARIANTS(vector2);
34 DECL_VARIABLE_ALL_VARIANTS(vector_res);
38 /* Initialize input "vector1" from "buffer". */
39 TEST_MACRO_ALL_VARIANTS_2_5(VLOAD, vector1, buffer);
41 /* Choose arbitrary initialization values. */
42 VDUP(vector2, , int, s, 8, 8, 0x11);
43 VDUP(vector2, , int, s, 16, 4, 0x22);
44 VDUP(vector2, , int, s, 32, 2, 0x33);
45 VDUP(vector2, , int, s, 64, 1, 0x44);
46 VDUP(vector2, , uint, u, 8, 8, 0x55);
47 VDUP(vector2, , uint, u, 16, 4, 0x66);
48 VDUP(vector2, , uint, u, 32, 2, 0x77);
49 VDUP(vector2, , uint, u, 64, 1, 0x88);
51 VDUP(vector2, q, int, s, 8, 16, 0x11);
52 VDUP(vector2, q, int, s, 16, 8, 0x22);
53 VDUP(vector2, q, int, s, 32, 4, 0x33);
54 VDUP(vector2, q, int, s, 64, 2, 0x44);
55 VDUP(vector2, q, uint, u, 8, 16, 0x55);
56 VDUP(vector2, q, uint, u, 16, 8, 0x66);
57 VDUP(vector2, q, uint, u, 32, 4, 0x77);
58 VDUP(vector2, q, uint, u, 64, 2, 0x88);
60 /* Apply a saturating binary operator named INSN_NAME. */
61 TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 8, 8, expected_cumulative_sat, "");
62 TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 16, 4, expected_cumulative_sat, "");
63 TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 32, 2, expected_cumulative_sat, "");
64 TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 64, 1, expected_cumulative_sat, "");
65 TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 8, 8, expected_cumulative_sat, "");
66 TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 16, 4, expected_cumulative_sat, "");
67 TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 32, 2, expected_cumulative_sat, "");
68 TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 64, 1, expected_cumulative_sat, "");
70 TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 8, 16, expected_cumulative_sat, "");
71 TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 16, 8, expected_cumulative_sat, "");
72 TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 32, 4, expected_cumulative_sat, "");
73 TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 64, 2, expected_cumulative_sat, "");
74 TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 8, 16, expected_cumulative_sat, "");
75 TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 16, 8, expected_cumulative_sat, "");
76 TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 32, 4, expected_cumulative_sat, "");
77 TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 64, 2, expected_cumulative_sat, "");
79 CHECK_RESULTS (TEST_MSG, "");
88 FNNAME (INSN_NAME) ();