blob: 0e6f1d8c202f70477eb88bb4ecd5c76db175302b [file] [log] [blame]
Christophe Lyon073831a2011-01-24 17:37:40 +01001/*
2
Christophe Lyon80902f62013-03-29 16:26:42 +01003Copyright (c) 2009, 2010, 2011, 2013 STMicroelectronics
Christophe Lyon073831a2011-01-24 17:37:40 +01004Written 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
Christophe Lyon1775be02014-07-10 13:46:54 +020026#if defined(__arm__) || defined(__aarch64__)
Christophe Lyon073831a2011-01-24 17:37:40 +010027#include <arm_neon.h>
28#else
Christophe Lyon0dab5f72011-07-19 17:14:09 +020029#include "stm-arm-neon.h"
Christophe Lyon073831a2011-01-24 17:37:40 +010030#endif
31
32#include "stm-arm-neon-ref.h"
33
34#ifndef INSN_NAME
35#define INSN_NAME vuzp
36#define TEST_MSG "VUZP/VUZPQ"
37#endif
38
39#define FNNAME1(NAME) void exec_ ## NAME (void)
40#define FNNAME(NAME) FNNAME1(NAME)
41
42FNNAME (INSN_NAME)
43{
44 /* In this case, output variables are arrays of vectors */
45#define DECL_VUZP(T1, W, N) \
46 VECT_ARRAY_TYPE(T1, W, N, 2) VECT_ARRAY_VAR(result_vec, T1, W, N, 2); \
47 VECT_VAR_DECL(result_bis, T1, W, N)[2 * N]
48
49 /* We need to use a temporary result buffer (result_bis), because
50 the one used for other tests is not large enough. A subset of the
51 result data is moved from result_bis to result, and it is this
52 subset which is used to check the actual behaviour. The next
53 macro enables to move another chunk of data from result_bis to
54 result. */
55#define TEST_VUZP(INSN, Q, T1, T2, W, N) \
56 VECT_ARRAY_VAR(result_vec, T1, W, N, 2) = \
57 INSN##Q##_##T2##W(VECT_VAR(vector1, T1, W, N), \
58 VECT_VAR(vector2, T1, W, N)); \
59 vst2##Q##_##T2##W(VECT_VAR(result_bis, T1, W, N), \
60 VECT_ARRAY_VAR(result_vec, T1, W, N, 2)); \
61 memcpy(VECT_VAR(result, T1, W, N), VECT_VAR(result_bis, T1, W, N), \
62 sizeof(VECT_VAR(result, T1, W, N)));
63
64 /* Overwrite "result" with the contents of "result_bis"[X] */
65#define TEST_EXTRA_CHUNK(T1, W, N, X) \
Christophe Lyon3f968e42013-01-10 18:49:49 +010066 memcpy(VECT_VAR(result, T1, W, N), &(VECT_VAR(result_bis, T1, W, N)[X*N]), \
Christophe Lyon073831a2011-01-24 17:37:40 +010067 sizeof(VECT_VAR(result, T1, W, N)));
68
69 /* With ARM RVCT, we need to declare variables before any executable
70 statement */
71 DECL_VARIABLE_ALL_VARIANTS(vector1);
72 DECL_VARIABLE_ALL_VARIANTS(vector2);
73
74 /* We don't need 64 bits variants */
75#define DECL_ALL_VUZP() \
76 DECL_VUZP(int, 8, 8); \
77 DECL_VUZP(int, 16, 4); \
78 DECL_VUZP(int, 32, 2); \
79 DECL_VUZP(uint, 8, 8); \
80 DECL_VUZP(uint, 16, 4); \
81 DECL_VUZP(uint, 32, 2); \
Christophe Lyon80902f62013-03-29 16:26:42 +010082 DECL_VUZP(poly, 8, 8); \
83 DECL_VUZP(poly, 16, 4); \
Christophe Lyon073831a2011-01-24 17:37:40 +010084 DECL_VUZP(float, 32, 2); \
85 DECL_VUZP(int, 8, 16); \
86 DECL_VUZP(int, 16, 8); \
87 DECL_VUZP(int, 32, 4); \
88 DECL_VUZP(uint, 8, 16); \
89 DECL_VUZP(uint, 16, 8); \
90 DECL_VUZP(uint, 32, 4); \
Christophe Lyon80902f62013-03-29 16:26:42 +010091 DECL_VUZP(poly, 8, 16); \
92 DECL_VUZP(poly, 16, 8); \
Christophe Lyon073831a2011-01-24 17:37:40 +010093 DECL_VUZP(float, 32, 4)
94
95 DECL_ALL_VUZP();
96
97 /* Initialize input "vector" from "buffer" */
Christophe Lyonf2053672014-12-16 10:26:00 +010098 TEST_MACRO_ALL_VARIANTS_2_5(VLOAD, vector1, buffer);
99 VLOAD(vector1, buffer, , float, f, 32, 2);
100 VLOAD(vector1, buffer, q, float, f, 32, 4);
Christophe Lyon073831a2011-01-24 17:37:40 +0100101
102 /* Choose arbitrary initialization values */
Christophe Lyonf2053672014-12-16 10:26:00 +0100103 VDUP(vector2, , int, s, 8, 8, 0x11);
104 VDUP(vector2, , int, s, 16, 4, 0x22);
105 VDUP(vector2, , int, s, 32, 2, 0x33);
106 VDUP(vector2, , uint, u, 8, 8, 0x55);
107 VDUP(vector2, , uint, u, 16, 4, 0x66);
108 VDUP(vector2, , uint, u, 32, 2, 0x77);
109 VDUP(vector2, , poly, p, 8, 8, 0x55);
110 VDUP(vector2, , poly, p, 16, 4, 0x66);
111 VDUP(vector2, , float, f, 32, 2, 33.6f);
Christophe Lyon073831a2011-01-24 17:37:40 +0100112
Christophe Lyonf2053672014-12-16 10:26:00 +0100113 VDUP(vector2, q, int, s, 8, 16, 0x11);
114 VDUP(vector2, q, int, s, 16, 8, 0x22);
115 VDUP(vector2, q, int, s, 32, 4, 0x33);
116 VDUP(vector2, q, uint, u, 8, 16, 0x55);
117 VDUP(vector2, q, uint, u, 16, 8, 0x66);
118 VDUP(vector2, q, uint, u, 32, 4, 0x77);
119 VDUP(vector2, q, poly, p, 8, 16, 0x55);
120 VDUP(vector2, q, poly, p, 16, 8, 0x66);
121 VDUP(vector2, q, float, f, 32, 4, 33.8f);
Christophe Lyon073831a2011-01-24 17:37:40 +0100122
123#define TEST_ALL_VUZP(INSN) \
124 TEST_VUZP(INSN, , int, s, 8, 8); \
125 TEST_VUZP(INSN, , int, s, 16, 4); \
126 TEST_VUZP(INSN, , int, s, 32, 2); \
127 TEST_VUZP(INSN, , uint, u, 8, 8); \
128 TEST_VUZP(INSN, , uint, u, 16, 4); \
129 TEST_VUZP(INSN, , uint, u, 32, 2); \
Christophe Lyon80902f62013-03-29 16:26:42 +0100130 TEST_VUZP(INSN, , poly, p, 8, 8); \
131 TEST_VUZP(INSN, , poly, p, 16, 4); \
Christophe Lyon073831a2011-01-24 17:37:40 +0100132 TEST_VUZP(INSN, , float, f, 32, 2); \
133 TEST_VUZP(INSN, q, int, s, 8, 16); \
134 TEST_VUZP(INSN, q, int, s, 16, 8); \
135 TEST_VUZP(INSN, q, int, s, 32, 4); \
136 TEST_VUZP(INSN, q, uint, u, 8, 16); \
137 TEST_VUZP(INSN, q, uint, u, 16, 8); \
138 TEST_VUZP(INSN, q, uint, u, 32, 4); \
Christophe Lyon80902f62013-03-29 16:26:42 +0100139 TEST_VUZP(INSN, q, poly, p, 8, 16); \
140 TEST_VUZP(INSN, q, poly, p, 16, 8); \
Christophe Lyon073831a2011-01-24 17:37:40 +0100141 TEST_VUZP(INSN, q, float, f, 32, 4)
142
143#define TEST_ALL_EXTRA_CHUNKS() \
144 TEST_EXTRA_CHUNK(int, 8, 8, 1); \
145 TEST_EXTRA_CHUNK(int, 16, 4, 1); \
146 TEST_EXTRA_CHUNK(int, 32, 2, 1); \
147 TEST_EXTRA_CHUNK(uint, 8, 8, 1); \
148 TEST_EXTRA_CHUNK(uint, 16, 4, 1); \
149 TEST_EXTRA_CHUNK(uint, 32, 2, 1); \
Christophe Lyon80902f62013-03-29 16:26:42 +0100150 TEST_EXTRA_CHUNK(poly, 8, 8, 1); \
151 TEST_EXTRA_CHUNK(poly, 16, 4, 1); \
Christophe Lyon073831a2011-01-24 17:37:40 +0100152 TEST_EXTRA_CHUNK(float, 32, 2, 1); \
153 TEST_EXTRA_CHUNK(int, 8, 16, 1); \
154 TEST_EXTRA_CHUNK(int, 16, 8, 1); \
155 TEST_EXTRA_CHUNK(int, 32, 4, 1); \
156 TEST_EXTRA_CHUNK(uint, 8, 16, 1); \
157 TEST_EXTRA_CHUNK(uint, 16, 8, 1); \
158 TEST_EXTRA_CHUNK(uint, 32, 4, 1); \
Christophe Lyon80902f62013-03-29 16:26:42 +0100159 TEST_EXTRA_CHUNK(poly, 8, 16, 1); \
160 TEST_EXTRA_CHUNK(poly, 16, 8, 1); \
Christophe Lyon073831a2011-01-24 17:37:40 +0100161 TEST_EXTRA_CHUNK(float, 32, 4, 1)
162
163 /* Check vuzp/vuzpq */
164 clean_results ();
165 TEST_ALL_VUZP(INSN_NAME);
166
167 dump_results_hex2 (TEST_MSG, " chunk 0");
168
169 TEST_ALL_EXTRA_CHUNKS();
170 dump_results_hex2 (TEST_MSG, " chunk 1");
171}