1073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon/*
2073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
3073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonCopyright (c) 2009, 2010, 2011 STMicroelectronics
4073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonWritten by Christophe Lyon
5073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
6073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonPermission is hereby granted, free of charge, to any person obtaining a copy
7073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyonof this software and associated documentation files (the "Software"), to deal
8073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyonin the Software without restriction, including without limitation the rights
9073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyonto use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyoncopies of the Software, and to permit persons to whom the Software is
11073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyonfurnished to do so, subject to the following conditions:
12073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
13073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonThe above copyright notice and this permission notice shall be included in
14073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyonall copies or substantial portions of the Software.
15073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
16073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonTHE SOFTWARE.
23073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
24073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon*/
25073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
26073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon/* Template file for binary operator validation */
27073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
281775be0bcaa673c19bb1f60f0c1bce1b91cdb414Christophe Lyon#if defined(__arm__) || defined(__aarch64__)
29073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#include <arm_neon.h>
30073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#else
310dab5f72da4b2434882b51b44ac377af9e3160feChristophe Lyon#include "stm-arm-neon.h"
32073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#endif
33073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
34073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#include "stm-arm-neon-ref.h"
35073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
36073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#define FNNAME1(NAME) void exec_ ## NAME (void)
37073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#define FNNAME(NAME) FNNAME1(NAME)
38073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
39073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonFNNAME (INSN_NAME)
40073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon{
41073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  /* Basic test: y=OP(x,x), then store the result.  */
42073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#define TEST_BINARY_OP1(INSN, Q, T1, T2, W, N)				\
43073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  VECT_VAR(vector_res, T1, W, N) =					\
44073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon    INSN##Q##_##T2##W(VECT_VAR(vector, T1, W, N),			\
45073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon		      VECT_VAR(vector2, T1, W, N));			\
46073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), VECT_VAR(vector_res, T1, W, N))
47073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
48073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#define TEST_BINARY_OP(INSN, Q, T1, T2, W, N)				\
49073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  TEST_BINARY_OP1(INSN, Q, T1, T2, W, N)				\
50073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
51073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  /* With ARM RVCT, we need to declare variables before any executable
52073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon     statement  */
53073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  DECL_VARIABLE_ALL_VARIANTS(vector);
54073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  DECL_VARIABLE_ALL_VARIANTS(vector2);
55073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  DECL_VARIABLE_ALL_VARIANTS(vector_res);
56073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
57073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  clean_results ();
58073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
59073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  /* Initialize input "vector" from "buffer"  */
60f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon  TEST_MACRO_ALL_VARIANTS_2_5(VLOAD, vector, buffer);
61073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
62073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  /* Fill input vector2 with arbitrary values */
63f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon  VDUP(vector2, , int, s, 8, 8, 2);
64f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon  VDUP(vector2, , int, s, 16, 4, -4);
65f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon  VDUP(vector2, , int, s, 32, 2, 3);
66f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon  VDUP(vector2, , int, s, 64, 1, 100);
67f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon  VDUP(vector2, , uint, u, 8, 8, 20);
68f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon  VDUP(vector2, , uint, u, 16, 4, 30);
69f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon  VDUP(vector2, , uint, u, 32, 2, 40);
70f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon  VDUP(vector2, , uint, u, 64, 1, 2);
71f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon  VDUP(vector2, q, int, s, 8, 16, -10);
72f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon  VDUP(vector2, q, int, s, 16, 8, -20);
73f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon  VDUP(vector2, q, int, s, 32, 4, -30);
74f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon  VDUP(vector2, q, int, s, 64, 2, 24);
75f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon  VDUP(vector2, q, uint, u, 8, 16, 12);
76f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon  VDUP(vector2, q, uint, u, 16, 8, 3);
77f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon  VDUP(vector2, q, uint, u, 32, 4, 55);
78f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon  VDUP(vector2, q, uint, u, 64, 2, 3);
79073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
80073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  /* Apply a binary operator named INSN_NAME  */
81073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  TEST_MACRO_ALL_VARIANTS_1_5(TEST_BINARY_OP, INSN_NAME);
82073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
83073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  dump_results_hex (TEST_MSG);
84073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
85073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#ifdef EXTRA_TESTS
86073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  EXTRA_TESTS();
87073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#endif
88073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon}
89