2 #include "arm-neon-ref.h"
3 #include "compute-ref-data.h"
5 /* Expected results for vtbl1. */
6 VECT_VAR_DECL(expected_vtbl1
,int,8,8) [] = { 0x0, 0xf2, 0xf2, 0xf2,
7 0x0, 0x0, 0xf2, 0xf2 };
8 VECT_VAR_DECL(expected_vtbl1
,uint
,8,8) [] = { 0x0, 0xf3, 0xf3, 0xf3,
9 0x0, 0x0, 0xf3, 0xf3 };
10 VECT_VAR_DECL(expected_vtbl1
,poly
,8,8) [] = { 0x0, 0xf3, 0xf3, 0xf3,
11 0x0, 0x0, 0xf3, 0xf3 };
13 /* Expected results for vtbl2. */
14 VECT_VAR_DECL(expected_vtbl2
,int,8,8) [] = { 0xf6, 0xf3, 0xf3, 0xf3,
15 0x0, 0x0, 0xf3, 0xf3 };
16 VECT_VAR_DECL(expected_vtbl2
,uint
,8,8) [] = { 0xf6, 0xf5, 0xf5, 0xf5,
17 0x0, 0x0, 0xf5, 0xf5 };
18 VECT_VAR_DECL(expected_vtbl2
,poly
,8,8) [] = { 0xf6, 0xf5, 0xf5, 0xf5,
19 0x0, 0x0, 0xf5, 0xf5 };
21 /* Expected results for vtbl3. */
22 VECT_VAR_DECL(expected_vtbl3
,int,8,8) [] = { 0xf8, 0xf4, 0xf4, 0xf4,
23 0xff, 0x0, 0xf4, 0xf4 };
24 VECT_VAR_DECL(expected_vtbl3
,uint
,8,8) [] = { 0xf8, 0xf7, 0xf7, 0xf7,
25 0xff, 0x0, 0xf7, 0xf7 };
26 VECT_VAR_DECL(expected_vtbl3
,poly
,8,8) [] = { 0xf8, 0xf7, 0xf7, 0xf7,
27 0xff, 0x0, 0xf7, 0xf7 };
29 /* Expected results for vtbl4. */
30 VECT_VAR_DECL(expected_vtbl4
,int,8,8) [] = { 0xfa, 0xf5, 0xf5, 0xf5,
31 0x3, 0x0, 0xf5, 0xf5 };
32 VECT_VAR_DECL(expected_vtbl4
,uint
,8,8) [] = { 0xfa, 0xf9, 0xf9, 0xf9,
33 0x3, 0x0, 0xf9, 0xf9 };
34 VECT_VAR_DECL(expected_vtbl4
,poly
,8,8) [] = { 0xfa, 0xf9, 0xf9, 0xf9,
35 0x3, 0x0, 0xf9, 0xf9 };
37 /* Expected results for vtbx1. */
38 VECT_VAR_DECL(expected_vtbx1
,int,8,8) [] = { 0x33, 0xf2, 0xf2, 0xf2,
39 0x33, 0x33, 0xf2, 0xf2 };
40 VECT_VAR_DECL(expected_vtbx1
,uint
,8,8) [] = { 0xcc, 0xf3, 0xf3, 0xf3,
41 0xcc, 0xcc, 0xf3, 0xf3 };
42 VECT_VAR_DECL(expected_vtbx1
,poly
,8,8) [] = { 0xcc, 0xf3, 0xf3, 0xf3,
43 0xcc, 0xcc, 0xf3, 0xf3 };
45 /* Expected results for vtbx2. */
46 VECT_VAR_DECL(expected_vtbx2
,int,8,8) [] = { 0xf6, 0xf3, 0xf3, 0xf3,
47 0x33, 0x33, 0xf3, 0xf3 };
48 VECT_VAR_DECL(expected_vtbx2
,uint
,8,8) [] = { 0xf6, 0xf5, 0xf5, 0xf5,
49 0xcc, 0xcc, 0xf5, 0xf5 };
50 VECT_VAR_DECL(expected_vtbx2
,poly
,8,8) [] = { 0xf6, 0xf5, 0xf5, 0xf5,
51 0xcc, 0xcc, 0xf5, 0xf5 };
53 /* Expected results for vtbx3. */
54 VECT_VAR_DECL(expected_vtbx3
,int,8,8) [] = { 0xf8, 0xf4, 0xf4, 0xf4,
55 0xff, 0x33, 0xf4, 0xf4 };
56 VECT_VAR_DECL(expected_vtbx3
,uint
,8,8) [] = { 0xf8, 0xf7, 0xf7, 0xf7,
57 0xff, 0xcc, 0xf7, 0xf7 };
58 VECT_VAR_DECL(expected_vtbx3
,poly
,8,8) [] = { 0xf8, 0xf7, 0xf7, 0xf7,
59 0xff, 0xcc, 0xf7, 0xf7 };
61 /* Expected results for vtbx4. */
62 VECT_VAR_DECL(expected_vtbx4
,int,8,8) [] = { 0xfa, 0xf5, 0xf5, 0xf5,
63 0x3, 0x33, 0xf5, 0xf5 };
64 VECT_VAR_DECL(expected_vtbx4
,uint
,8,8) [] = { 0xfa, 0xf9, 0xf9, 0xf9,
65 0x3, 0xcc, 0xf9, 0xf9 };
66 VECT_VAR_DECL(expected_vtbx4
,poly
,8,8) [] = { 0xfa, 0xf9, 0xf9, 0xf9,
67 0x3, 0xcc, 0xf9, 0xf9 };
73 /* In this case, input variables are arrays of vectors. */
74 #define DECL_VTBX(T1, W, N, X) \
75 VECT_ARRAY_TYPE(T1, W, N, X) VECT_ARRAY_VAR(table_vector, T1, W, N, X)
77 /* The vtbl1 variant is different from vtbl{2,3,4} because it takes a
78 vector as 1st param, instead of an array of vectors. */
79 #define TEST_VTBL1(T1, T2, T3, W, N) \
80 VECT_VAR(table_vector, T1, W, N) = \
81 vld1##_##T2##W((T1##W##_t *)lookup_table); \
83 VECT_VAR(vector_res, T1, W, N) = \
84 vtbl1_##T2##W(VECT_VAR(table_vector, T1, W, N), \
85 VECT_VAR(vector, T3, W, N)); \
86 vst1_##T2##W(VECT_VAR(result, T1, W, N), \
87 VECT_VAR(vector_res, T1, W, N));
89 #define TEST_VTBLX(T1, T2, T3, W, N, X) \
90 VECT_ARRAY_VAR(table_vector, T1, W, N, X) = \
91 vld##X##_##T2##W((T1##W##_t *)lookup_table); \
93 VECT_VAR(vector_res, T1, W, N) = \
94 vtbl##X##_##T2##W(VECT_ARRAY_VAR(table_vector, T1, W, N, X), \
95 VECT_VAR(vector, T3, W, N)); \
96 vst1_##T2##W(VECT_VAR(result, T1, W, N), \
97 VECT_VAR(vector_res, T1, W, N));
99 /* We need to define a lookup table. */
100 uint8_t lookup_table
[32];
102 DECL_VARIABLE(vector
, int, 8, 8);
103 DECL_VARIABLE(vector
, uint
, 8, 8);
104 DECL_VARIABLE(vector
, poly
, 8, 8);
105 DECL_VARIABLE(vector_res
, int, 8, 8);
106 DECL_VARIABLE(vector_res
, uint
, 8, 8);
107 DECL_VARIABLE(vector_res
, poly
, 8, 8);
110 DECL_VARIABLE(table_vector
, int, 8, 8);
111 DECL_VARIABLE(table_vector
, uint
, 8, 8);
112 DECL_VARIABLE(table_vector
, poly
, 8, 8);
115 DECL_VARIABLE(default_vector
, int, 8, 8);
116 DECL_VARIABLE(default_vector
, uint
, 8, 8);
117 DECL_VARIABLE(default_vector
, poly
, 8, 8);
119 /* We need only 8 bits variants. */
120 #define DECL_ALL_VTBLX(X) \
121 DECL_VTBX(int, 8, 8, X); \
122 DECL_VTBX(uint, 8, 8, X); \
123 DECL_VTBX(poly, 8, 8, X)
125 #define TEST_ALL_VTBL1() \
126 TEST_VTBL1(int, s, int, 8, 8); \
127 TEST_VTBL1(uint, u, uint, 8, 8); \
128 TEST_VTBL1(poly, p, uint, 8, 8)
130 #define TEST_ALL_VTBLX(X) \
131 TEST_VTBLX(int, s, int, 8, 8, X); \
132 TEST_VTBLX(uint, u, uint, 8, 8, X); \
133 TEST_VTBLX(poly, p, uint, 8, 8, X)
135 /* Declare the temporary buffers / variables. */
140 /* Fill the lookup table. */
141 for (i
=0; i
<32; i
++) {
142 lookup_table
[i
] = i
-15;
145 /* Choose init value arbitrarily, will be used as table index. */
146 VDUP(vector
, , int, s
, 8, 8, 1);
147 VDUP(vector
, , uint
, u
, 8, 8, 2);
148 VDUP(vector
, , poly
, p
, 8, 8, 2);
150 /* To ensure coverage, add some indexes larger than 8,16 and 32
151 except: lane 0 (by 6), lane 1 (by 8) and lane 2 (by 9). */
152 VSET_LANE(vector
, , int, s
, 8, 8, 0, 10);
153 VSET_LANE(vector
, , int, s
, 8, 8, 4, 20);
154 VSET_LANE(vector
, , int, s
, 8, 8, 5, 40);
155 VSET_LANE(vector
, , uint
, u
, 8, 8, 0, 10);
156 VSET_LANE(vector
, , uint
, u
, 8, 8, 4, 20);
157 VSET_LANE(vector
, , uint
, u
, 8, 8, 5, 40);
158 VSET_LANE(vector
, , poly
, p
, 8, 8, 0, 10);
159 VSET_LANE(vector
, , poly
, p
, 8, 8, 4, 20);
160 VSET_LANE(vector
, , poly
, p
, 8, 8, 5, 40);
165 #define TEST_MSG "VTBL1"
168 CHECK(TEST_MSG
, int, 8, 8, PRIx8
, expected_vtbl1
, "");
169 CHECK(TEST_MSG
, uint
, 8, 8, PRIx8
, expected_vtbl1
, "");
170 CHECK(TEST_MSG
, poly
, 8, 8, PRIx8
, expected_vtbl1
, "");
175 #define TEST_MSG "VTBL2"
178 CHECK(TEST_MSG
, int, 8, 8, PRIx8
, expected_vtbl2
, "");
179 CHECK(TEST_MSG
, uint
, 8, 8, PRIx8
, expected_vtbl2
, "");
180 CHECK(TEST_MSG
, poly
, 8, 8, PRIx8
, expected_vtbl2
, "");
185 #define TEST_MSG "VTBL3"
188 CHECK(TEST_MSG
, int, 8, 8, PRIx8
, expected_vtbl3
, "");
189 CHECK(TEST_MSG
, uint
, 8, 8, PRIx8
, expected_vtbl3
, "");
190 CHECK(TEST_MSG
, poly
, 8, 8, PRIx8
, expected_vtbl3
, "");
195 #define TEST_MSG "VTBL4"
198 CHECK(TEST_MSG
, int, 8, 8, PRIx8
, expected_vtbl4
, "");
199 CHECK(TEST_MSG
, uint
, 8, 8, PRIx8
, expected_vtbl4
, "");
200 CHECK(TEST_MSG
, poly
, 8, 8, PRIx8
, expected_vtbl4
, "");
205 /* The vtbx1 variant is different from vtbx{2,3,4} because it takes a
206 vector as 1st param, instead of an array of vectors. */
207 #define TEST_VTBX1(T1, T2, T3, W, N) \
208 VECT_VAR(table_vector, T1, W, N) = \
209 vld1##_##T2##W((T1##W##_t *)lookup_table); \
211 VECT_VAR(vector_res, T1, W, N) = \
212 vtbx1_##T2##W(VECT_VAR(default_vector, T1, W, N), \
213 VECT_VAR(table_vector, T1, W, N), \
214 VECT_VAR(vector, T3, W, N)); \
215 vst1_##T2##W(VECT_VAR(result, T1, W, N), \
216 VECT_VAR(vector_res, T1, W, N));
218 #define TEST_VTBXX(T1, T2, T3, W, N, X) \
219 VECT_ARRAY_VAR(table_vector, T1, W, N, X) = \
220 vld##X##_##T2##W((T1##W##_t *)lookup_table); \
222 VECT_VAR(vector_res, T1, W, N) = \
223 vtbx##X##_##T2##W(VECT_VAR(default_vector, T1, W, N), \
224 VECT_ARRAY_VAR(table_vector, T1, W, N, X), \
225 VECT_VAR(vector, T3, W, N)); \
226 vst1_##T2##W(VECT_VAR(result, T1, W, N), \
227 VECT_VAR(vector_res, T1, W, N));
229 #define TEST_ALL_VTBX1() \
230 TEST_VTBX1(int, s, int, 8, 8); \
231 TEST_VTBX1(uint, u, uint, 8, 8); \
232 TEST_VTBX1(poly, p, uint, 8, 8)
234 #define TEST_ALL_VTBXX(X) \
235 TEST_VTBXX(int, s, int, 8, 8, X); \
236 TEST_VTBXX(uint, u, uint, 8, 8, X); \
237 TEST_VTBXX(poly, p, uint, 8, 8, X)
239 /* Choose init value arbitrarily, will be used as default value. */
240 VDUP(default_vector
, , int, s
, 8, 8, 0x33);
241 VDUP(default_vector
, , uint
, u
, 8, 8, 0xCC);
242 VDUP(default_vector
, , poly
, p
, 8, 8, 0xCC);
247 #define TEST_MSG "VTBX1"
250 CHECK(TEST_MSG
, int, 8, 8, PRIx8
, expected_vtbx1
, "");
251 CHECK(TEST_MSG
, uint
, 8, 8, PRIx8
, expected_vtbx1
, "");
252 CHECK(TEST_MSG
, poly
, 8, 8, PRIx8
, expected_vtbx1
, "");
257 #define TEST_MSG "VTBX2"
260 CHECK(TEST_MSG
, int, 8, 8, PRIx8
, expected_vtbx2
, "");
261 CHECK(TEST_MSG
, uint
, 8, 8, PRIx8
, expected_vtbx2
, "");
262 CHECK(TEST_MSG
, poly
, 8, 8, PRIx8
, expected_vtbx2
, "");
267 #define TEST_MSG "VTBX3"
270 CHECK(TEST_MSG
, int, 8, 8, PRIx8
, expected_vtbx3
, "");
271 CHECK(TEST_MSG
, uint
, 8, 8, PRIx8
, expected_vtbx3
, "");
272 CHECK(TEST_MSG
, poly
, 8, 8, PRIx8
, expected_vtbx3
, "");
277 #define TEST_MSG "VTBX4"
280 CHECK(TEST_MSG
, int, 8, 8, PRIx8
, expected_vtbx4
, "");
281 CHECK(TEST_MSG
, uint
, 8, 8, PRIx8
, expected_vtbx4
, "");
282 CHECK(TEST_MSG
, poly
, 8, 8, PRIx8
, expected_vtbx4
, "");