Debian Codegraph @

gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/unary_sat_op.inc

raw
1 /* Template file for saturating 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
6 saturating unary operators, these can be tested by providing a
7 definition for 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
16 void FNNAME (INSN_NAME) (void)
17 {
18 /* y=OP(x), then store the result. */
19 #define TEST_UNARY_SAT_OP1(INSN, Q, T1, T2, W, N, CMT) \
20 Set_Neon_Cumulative_Sat(0, VECT_VAR(vector_res, T1, W, N)); \
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
26 #define TEST_UNARY_SAT_OP(INSN, Q, T1, T2, W, N, CMT) \
27 TEST_UNARY_SAT_OP1(INSN, Q, T1, T2, W, N, CMT)
28
29 /* No need for 64 bits variants. */
30 DECL_VARIABLE(vector, int, 8, 8);
31 DECL_VARIABLE(vector, int, 16, 4);
32 DECL_VARIABLE(vector, int, 32, 2);
33 DECL_VARIABLE(vector, int, 8, 16);
34 DECL_VARIABLE(vector, int, 16, 8);
35 DECL_VARIABLE(vector, int, 32, 4);
36
37 DECL_VARIABLE(vector_res, int, 8, 8);
38 DECL_VARIABLE(vector_res, int, 16, 4);
39 DECL_VARIABLE(vector_res, int, 32, 2);
40 DECL_VARIABLE(vector_res, int, 8, 16);
41 DECL_VARIABLE(vector_res, int, 16, 8);
42 DECL_VARIABLE(vector_res, int, 32, 4);
43
44 clean_results ();
45
46 /* Initialize input "vector" from "buffer". */
47 VLOAD(vector, buffer, , int, s, 8, 8);
48 VLOAD(vector, buffer, , int, s, 16, 4);
49 VLOAD(vector, buffer, , int, s, 32, 2);
50 VLOAD(vector, buffer, q, int, s, 8, 16);
51 VLOAD(vector, buffer, q, int, s, 16, 8);
52 VLOAD(vector, buffer, q, int, s, 32, 4);
53
54 /* Apply a saturating unary operator named INSN_NAME. */
55 TEST_UNARY_SAT_OP(INSN_NAME, , int, s, 8, 8, "");
56 TEST_UNARY_SAT_OP(INSN_NAME, , int, s, 16, 4, "");
57 TEST_UNARY_SAT_OP(INSN_NAME, , int, s, 32, 2, "");
58 TEST_UNARY_SAT_OP(INSN_NAME, q, int, s, 8, 16, "");
59 TEST_UNARY_SAT_OP(INSN_NAME, q, int, s, 16, 8, "");
60 TEST_UNARY_SAT_OP(INSN_NAME, q, int, s, 32, 4, "");
61
62 CHECK(TEST_MSG, int, 8, 8, PRIx8, expected, "");
63 CHECK(TEST_MSG, int, 16, 4, PRIx16, expected, "");
64 CHECK(TEST_MSG, int, 32, 2, PRIx32, expected, "");
65 CHECK(TEST_MSG, int, 8, 16, PRIx8, expected, "");
66 CHECK(TEST_MSG, int, 16, 8, PRIx16, expected, "");
67 CHECK(TEST_MSG, int, 32, 4, PRIx32, expected, "");
68
69 #ifdef EXTRA_TESTS
70 EXTRA_TESTS();
71 #endif
72 }
73
74 int main (void)
75 {
76 FNNAME (INSN_NAME) ();
77
78 return 0;
79 }