1073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon/*
2073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
3c94d4c1e27bb7e2b2869cc230872669df1459533Christophe LyonCopyright (c) 2009, 2010, 2011, 2012 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
261775be0bcaa673c19bb1f60f0c1bce1b91cdb414Christophe Lyon#if defined(__arm__) || defined(__aarch64__)
27073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#include <arm_neon.h>
28073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#else
290dab5f72da4b2434882b51b44ac377af9e3160feChristophe Lyon#include "stm-arm-neon.h"
30073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#endif
31073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
32073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#include "stm-arm-neon-ref.h"
33073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
34073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#define INSN vqdmull
35073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#define TEST_MSG "VQDMULL_LANE"
36073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#define FNNAME1(NAME) void exec_ ## NAME ## _lane (void)
37073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#define FNNAME(NAME) FNNAME1(NAME)
38073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
39073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonFNNAME (INSN)
40073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon{
41073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  int i;
42073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
43073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  /* vector_res = vqdmull_lane(vector,vector2,lane), then store the result.  */
444a6e5cc95176769664bc9e56d4e7c92b7a2fc816Christophe Lyon#define TEST_VQDMULL_LANE2(INSN, T1, T2, W, W2, N, L)		\
45c1cc7826d74587e0dc1c855810633a219b161ab3Christophe Lyon  Set_Neon_Cumulative_Sat(0, VECT_VAR(vector_res, T1, W2, N));	\
464a6e5cc95176769664bc9e56d4e7c92b7a2fc816Christophe Lyon  VECT_VAR(vector_res, T1, W2, N) =				\
474a6e5cc95176769664bc9e56d4e7c92b7a2fc816Christophe Lyon    INSN##_lane_##T2##W(VECT_VAR(vector, T1, W, N),		\
484a6e5cc95176769664bc9e56d4e7c92b7a2fc816Christophe Lyon			VECT_VAR(vector2, T1, W, N),		\
494a6e5cc95176769664bc9e56d4e7c92b7a2fc816Christophe Lyon			L);					\
504a6e5cc95176769664bc9e56d4e7c92b7a2fc816Christophe Lyon  vst1q_##T2##W2(VECT_VAR(result, T1, W2, N),			\
514a6e5cc95176769664bc9e56d4e7c92b7a2fc816Christophe Lyon		 VECT_VAR(vector_res, T1, W2, N));		\
524a6e5cc95176769664bc9e56d4e7c92b7a2fc816Christophe Lyon  dump_neon_cumulative_sat(TEST_MSG, xSTR(INSN##_lane_##T2##W),	\
534a6e5cc95176769664bc9e56d4e7c92b7a2fc816Christophe Lyon			   xSTR(T1), W, N)
54073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
55073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  /* Two auxliary macros are necessary to expand INSN */
56073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#define TEST_VQDMULL_LANE1(INSN, T1, T2, W, W2, N, L)	\
57073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  TEST_VQDMULL_LANE2(INSN, T1, T2, W, W2, N, L)
58073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
59073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#define TEST_VQDMULL_LANE(T1, T2, W, W2, N, L)	\
60073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  TEST_VQDMULL_LANE1(INSN, T1, T2, W, W2, N, L)
61073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
62073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
63073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  /* With ARM RVCT, we need to declare variables before any executable
64073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon     statement */
65073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  DECL_VARIABLE(vector, int, 16, 4);
66073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  DECL_VARIABLE(vector, int, 32, 2);
67073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  DECL_VARIABLE(vector2, int, 16, 4);
68073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  DECL_VARIABLE(vector2, int, 32, 2);
69073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
70073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  DECL_VARIABLE(vector_res, int, 32, 4);
71073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  DECL_VARIABLE(vector_res, int, 64, 2);
72073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
73073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  clean_results ();
74073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
75073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  /* Initialize vector */
76f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon  VDUP(vector, , int, s, 16, 4, 0x1000);
77f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon  VDUP(vector, , int, s, 32, 2, 0x1000);
78073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
79073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  /* Initialize vector2 */
80f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon  VDUP(vector2, , int, s, 16, 4, 0x4);
81f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon  VDUP(vector2, , int, s, 32, 2, 0x2);
82073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
83073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  /* Choose lane arbitrarily */
844a6e5cc95176769664bc9e56d4e7c92b7a2fc816Christophe Lyon  fprintf(ref_file, "\n%s cumulative saturation output:\n", TEST_MSG);
85073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  TEST_VQDMULL_LANE(int, s, 16, 32, 4, 2);
86073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  TEST_VQDMULL_LANE(int, s, 32, 64, 2, 1);
87073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
88073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
89073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "\n%s output:\n", TEST_MSG);
90bf2182605cb0dac32f6cd9194664994beae299faChristophe Lyon  fprintf(gcc_tests_file, "\n%s output:\n", TEST_MSG);
91073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  DUMP(TEST_MSG, int, 32, 4, PRIx32);
92073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  DUMP(TEST_MSG, int, 64, 2, PRIx64);
93073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
94073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
95073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
96f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon  VDUP(vector, , int, s, 16, 4, 0x8000);
97f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon  VDUP(vector2, , int, s, 16, 4, 0x8000);
98f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon  VDUP(vector, , int, s, 32, 2, 0x80000000);
99f20536724d4cc8432d5b804082415c8391f88f9bChristophe Lyon  VDUP(vector2, , int, s, 32, 2, 0x80000000);
1004a6e5cc95176769664bc9e56d4e7c92b7a2fc816Christophe Lyon  fprintf(ref_file, "\n%s cumulative saturation output:\n",
1014a6e5cc95176769664bc9e56d4e7c92b7a2fc816Christophe Lyon	  TEST_MSG " (check mul cumulative saturation)");
102073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  TEST_VQDMULL_LANE(int, s, 16, 32, 4, 2);
103073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  TEST_VQDMULL_LANE(int, s, 32, 64, 2, 1);
104073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
1054a6e5cc95176769664bc9e56d4e7c92b7a2fc816Christophe Lyon  fprintf (ref_file, "\n%s output:\n",
1064a6e5cc95176769664bc9e56d4e7c92b7a2fc816Christophe Lyon	   TEST_MSG " (check mul cumulative saturation)");
107073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  DUMP(TEST_MSG, int, 32, 4, PRIx32);
108073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  DUMP(TEST_MSG, int, 64, 2, PRIx64);
109073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon}
110