blob: 0789d249cf9afce352dafd3103c94c6b11c4038c [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
34void exec_vget_lane (void)
35{
36 /* vec=vget_lane(vec, lane), then store the result. */
37#define TEST_VGET_LANE(Q, T1, T2, W, N, L) \
38 VAR(var, T1, W) = vget##Q##_lane_##T2##W(VECT_VAR(vector, T1, W, N), L); \
Christophe Lyonf4747d52013-03-28 13:00:53 +010039 fprintf(ref_file, "%s: %" PRIx##W "\n", "vget"STR(Q)"_lane_"STR(T2##W), VAR(var, T1, W))
Christophe Lyon073831a2011-01-24 17:37:40 +010040
Christophe Lyond9ab3e32014-07-11 16:44:32 +020041 /* Special variant for poly* types, to clear sign bits in output. */
42#define TEST_VGET_LANE_POLY(Q, T1, T2, W, N, L) \
43 VAR(var, T1, W) = vget##Q##_lane_##T2##W(VECT_VAR(vector, T1, W, N), L); \
44 fprintf(ref_file, "%s: %" PRIx##W "\n", "vget"STR(Q)"_lane_"STR(T2##W), \
45 (uint##W##_t)VAR(var, T1, W))
46
Christophe Lyon073831a2011-01-24 17:37:40 +010047 /* Special variant for floating-point */
Christophe Lyon9c0f0822013-02-05 16:02:00 +010048 union {
49 uint32_t var_int32;
50 float var_float32;
51 } var_int32_float32;
52
Christophe Lyon073831a2011-01-24 17:37:40 +010053#define TEST_VGET_LANE_F(Q, T1, T2, W, N, L) \
54 VAR(var, T1, W) = vget##Q##_lane_##T2##W(VECT_VAR(vector, T1, W, N), L); \
Christophe Lyon9c0f0822013-02-05 16:02:00 +010055 var_int##W##_float##W.var_float##W = VAR(var, T1, W); \
Christophe Lyonf4747d52013-03-28 13:00:53 +010056 fprintf(ref_file, "%s: %" PRIx##W "\n", "vget"STR(Q)"_lane_"STR(T2##W), var_int##W##_float##W.var_int##W)
Christophe Lyon073831a2011-01-24 17:37:40 +010057
58 /* With ARM RVCT, we need to declare variables before any executable
59 statement */
60 DECL_VARIABLE_ALL_VARIANTS(vector);
61
62 /* Scalar variables */
63 VAR_DECL(var, int, 8);
64 VAR_DECL(var, int, 16);
65 VAR_DECL(var, int, 32);
66 VAR_DECL(var, int, 64);
67 VAR_DECL(var, uint, 8);
68 VAR_DECL(var, uint, 16);
69 VAR_DECL(var, uint, 32);
70 VAR_DECL(var, uint, 64);
Christophe Lyon80902f62013-03-29 16:26:42 +010071 VAR_DECL(var, poly, 8);
72 VAR_DECL(var, poly, 16);
Christophe Lyon073831a2011-01-24 17:37:40 +010073 VAR_DECL(var, float, 32);
74
75 clean_results ();
76
Christophe Lyonf2053672014-12-16 10:26:00 +010077 TEST_MACRO_ALL_VARIANTS_2_5(VLOAD, vector, buffer);
78 VLOAD(vector, buffer, , float, f, 32, 2);
79 VLOAD(vector, buffer, q, float, f, 32, 4);
Christophe Lyon073831a2011-01-24 17:37:40 +010080
81 fprintf(ref_file, "\n%s output:\n", "VGET_LANE/VGETQ_LANE");
82
83 /* Choose lane arbitrarily */
84 TEST_VGET_LANE(, int, s, 8, 8, 7);
85 TEST_VGET_LANE(, int, s, 16, 4, 3);
86 TEST_VGET_LANE(, int, s, 32, 2, 1);
87 TEST_VGET_LANE(, int, s, 64, 1, 0);
88 TEST_VGET_LANE(, uint, u, 8, 8, 6);
89 TEST_VGET_LANE(, uint, u, 16, 4, 2);
90 TEST_VGET_LANE(, uint, u, 32, 2, 1);
91 TEST_VGET_LANE(, uint, u, 64, 1, 0);
Christophe Lyond9ab3e32014-07-11 16:44:32 +020092 TEST_VGET_LANE_POLY(, poly, p, 8, 8, 6);
93 TEST_VGET_LANE_POLY(, poly, p, 16, 4, 2);
Christophe Lyon073831a2011-01-24 17:37:40 +010094 TEST_VGET_LANE_F(, float, f, 32, 2, 1);
95
96 TEST_VGET_LANE(q, int, s, 8, 16, 15);
97 TEST_VGET_LANE(q, int, s, 16, 8, 5);
98 TEST_VGET_LANE(q, int, s, 32, 4, 3);
99 TEST_VGET_LANE(q, int, s, 64, 2, 1);
100 TEST_VGET_LANE(q, uint, u, 8, 16, 14);
101 TEST_VGET_LANE(q, uint, u, 16, 8, 6);
102 TEST_VGET_LANE(q, uint, u, 32, 4, 2);
103 TEST_VGET_LANE(q, uint, u, 64, 2, 1);
Christophe Lyond9ab3e32014-07-11 16:44:32 +0200104 TEST_VGET_LANE_POLY(q, poly, p, 8, 16, 14);
105 TEST_VGET_LANE_POLY(q, poly, p, 16, 8, 6);
Christophe Lyon073831a2011-01-24 17:37:40 +0100106 TEST_VGET_LANE_F(q, float, f, 32, 4, 3);
107
108 fprintf(ref_file, "\n");
109}