1/*
2
3Copyright (c) 2009, 2010, 2011 STMicroelectronics
4Written by Christophe Lyon
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22THE SOFTWARE.
23
24*/
25
26#if defined(__arm__) || defined(__aarch64__)
27#include <arm_neon.h>
28#else
29#include "stm-arm-neon.h"
30#endif
31
32#include "stm-arm-neon-ref.h"
33
34#define TEST_MSG "VMUL_LANE"
35void exec_vmul_lane (void)
36{
37#define DECL_VMUL(VAR)				\
38  DECL_VARIABLE(VAR, int, 16, 4);		\
39  DECL_VARIABLE(VAR, int, 32, 2);		\
40  DECL_VARIABLE(VAR, uint, 16, 4);		\
41  DECL_VARIABLE(VAR, uint, 32, 2);		\
42  DECL_VARIABLE(VAR, float, 32, 2);		\
43  DECL_VARIABLE(VAR, int, 16, 8);		\
44  DECL_VARIABLE(VAR, int, 32, 4);		\
45  DECL_VARIABLE(VAR, uint, 16, 8);		\
46  DECL_VARIABLE(VAR, uint, 32, 4);		\
47  DECL_VARIABLE(VAR, float, 32, 4)
48
49  /* vector_res = vmul_lane(vector,vector2,lane), then store the result.  */
50#define TEST_VMUL_LANE(Q, T1, T2, W, N, N2, L)				\
51  VECT_VAR(vector_res, T1, W, N) =					\
52    vmul##Q##_lane_##T2##W(VECT_VAR(vector, T1, W, N),			\
53			   VECT_VAR(vector2, T1, W, N2),		\
54			   L);						\
55  vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N),				\
56		    VECT_VAR(vector_res, T1, W, N))
57
58  /* With ARM RVCT, we need to declare variables before any executable
59     statement */
60  DECL_VMUL(vector);
61  DECL_VMUL(vector_res);
62
63  DECL_VARIABLE(vector2, int, 16, 4);
64  DECL_VARIABLE(vector2, int, 32, 2);
65  DECL_VARIABLE(vector2, uint, 16, 4);
66  DECL_VARIABLE(vector2, uint, 32, 2);
67  DECL_VARIABLE(vector2, float, 32, 2);
68
69  clean_results ();
70
71  /* Initialize vector from pre-initialized values  */
72  VLOAD(vector, buffer, , int, s, 16, 4);
73  VLOAD(vector, buffer, , int, s, 32, 2);
74  VLOAD(vector, buffer, , uint, u, 16, 4);
75  VLOAD(vector, buffer, , uint, u, 32, 2);
76  VLOAD(vector, buffer, , float, f, 32, 2);
77  VLOAD(vector, buffer, q, int, s, 16, 8);
78  VLOAD(vector, buffer, q, int, s, 32, 4);
79  VLOAD(vector, buffer, q, uint, u, 16, 8);
80  VLOAD(vector, buffer, q, uint, u, 32, 4);
81  VLOAD(vector, buffer, q, float, f, 32, 4);
82
83  /* Initialize vector2 */
84  VDUP(vector2, , int, s, 16, 4, 0x4);
85  VDUP(vector2, , int, s, 32, 2, 0x22);
86  VDUP(vector2, , uint, u, 16, 4, 0x444);
87  VDUP(vector2, , uint, u, 32, 2, 0x532);
88  VDUP(vector2, , float, f, 32, 2, 22.8f);
89
90  /* Choose lane arbitrarily */
91  TEST_VMUL_LANE(, int, s, 16, 4, 4, 2);
92  TEST_VMUL_LANE(, int, s, 32, 2, 2, 1);
93  TEST_VMUL_LANE(, uint, u, 16, 4, 4, 2);
94  TEST_VMUL_LANE(, uint, u, 32, 2, 2, 1);
95  TEST_VMUL_LANE(, float, f, 32, 2, 2, 1);
96  TEST_VMUL_LANE(q, int, s, 16, 8, 4, 2);
97  TEST_VMUL_LANE(q, int, s, 32, 4, 2, 0);
98  TEST_VMUL_LANE(q, uint, u, 16, 8, 4, 2);
99  TEST_VMUL_LANE(q, uint, u, 32, 4, 2, 1);
100  TEST_VMUL_LANE(q, float, f, 32, 4, 2, 0);
101
102  /* FIXME: only a subset of the result buffers are used, but we
103     output all of them */
104  dump_results_hex (TEST_MSG);
105}
106