• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 
3 Copyright (c) 2009, 2010, 2011, 2013 STMicroelectronics
4 Written by Christophe Lyon
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12 
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15 
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 THE 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 
exec_vget_lane(void)34 void 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); \
39   fprintf(ref_file, "%s: %" PRIx##W "\n", "vget"STR(Q)"_lane_"STR(T2##W), VAR(var, T1, W))
40 
41   /* 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 
47   /* Special variant for floating-point */
48   union {
49     uint32_t var_int32;
50     float var_float32;
51   } var_int32_float32;
52 
53 #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); \
55   var_int##W##_float##W.var_float##W = VAR(var, T1, W);		\
56   fprintf(ref_file, "%s: %" PRIx##W "\n", "vget"STR(Q)"_lane_"STR(T2##W), var_int##W##_float##W.var_int##W)
57 
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);
71   VAR_DECL(var, poly, 8);
72   VAR_DECL(var, poly, 16);
73   VAR_DECL(var, float, 32);
74 
75   clean_results ();
76 
77   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);
80 
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);
92   TEST_VGET_LANE_POLY(, poly, p, 8, 8, 6);
93   TEST_VGET_LANE_POLY(, poly, p, 16, 4, 2);
94   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);
104   TEST_VGET_LANE_POLY(q, poly, p, 8, 16, 14);
105   TEST_VGET_LANE_POLY(q, poly, p, 16, 8, 6);
106   TEST_VGET_LANE_F(q, float, f, 32, 4, 3);
107 
108   fprintf(ref_file, "\n");
109 }
110