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