New Advanced SIMD intrinsics tests.
[platform/upstream/gcc49.git] / gcc / testsuite / gcc.target / aarch64 / advsimd-intrinsics / unary_op.inc
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
16 void 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_RESULTS (TEST_MSG, "");
61
62 #ifdef EXTRA_TESTS
63   EXTRA_TESTS();
64 #endif
65 }
66
67 int main (void)
68 {
69   FNNAME (INSN_NAME)();
70
71   return 0;
72 }