blob: 286a8ae6e82524937a48290b93cf7654032a0fdf [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#define TEST_MSG "VDUP/VDUPQ"
35void exec_vdup (void)
36{
37 int i;
38
39 /* Basic test: vec=vdup(x), then store the result. */
Christophe Lyon073831a2011-01-24 17:37:40 +010040#define TEST_VDUP(Q, T1, T2, W, N) \
41 VECT_VAR(vector, T1, W, N) = \
Christophe Lyon01af0a52013-01-17 17:23:11 +010042 vdup##Q##_n_##T2##W(VECT_VAR(buffer_dup, T1, W, N)[i]); \
Christophe Lyon073831a2011-01-24 17:37:40 +010043 vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), VECT_VAR(vector, T1, W, N))
44
45 /* Basic test: vec=vmov(x), then store the result. */
46#define TEST_VMOV(Q, T1, T2, W, N) \
47 VECT_VAR(vector, T1, W, N) = \
Christophe Lyon01af0a52013-01-17 17:23:11 +010048 vmov##Q##_n_##T2##W(VECT_VAR(buffer_dup, T1, W, N)[i]); \
Christophe Lyon073831a2011-01-24 17:37:40 +010049 vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), VECT_VAR(vector, T1, W, N))
50
51 /* With ARM RVCT, we need to declare variables before any executable
52 statement */
53 DECL_VARIABLE_ALL_VARIANTS(vector);
54
55 for (i=0; i< 3; i++) {
56 clean_results ();
57
58 TEST_VDUP(, int, s, 8, 8);
59 TEST_VDUP(, int, s, 16, 4);
60 TEST_VDUP(, int, s, 32, 2);
61 TEST_VDUP(, int, s, 64, 1);
62 TEST_VDUP(, uint, u, 8, 8);
63 TEST_VDUP(, uint, u, 16, 4);
64 TEST_VDUP(, uint, u, 32, 2);
65 TEST_VDUP(, uint, u, 64, 1);
Christophe Lyon80902f62013-03-29 16:26:42 +010066 TEST_VDUP(, poly, p, 8, 8);
67 TEST_VDUP(, poly, p, 16, 4);
Christophe Lyon073831a2011-01-24 17:37:40 +010068 TEST_VDUP(, float, f, 32, 2);
69
70 TEST_VDUP(q, int, s, 8, 16);
71 TEST_VDUP(q, int, s, 16, 8);
72 TEST_VDUP(q, int, s, 32, 4);
73 TEST_VDUP(q, int, s, 64, 2);
74 TEST_VDUP(q, uint, u, 8, 16);
75 TEST_VDUP(q, uint, u, 16, 8);
76 TEST_VDUP(q, uint, u, 32, 4);
77 TEST_VDUP(q, uint, u, 64, 2);
Christophe Lyon80902f62013-03-29 16:26:42 +010078 TEST_VDUP(q, poly, p, 8, 16);
79 TEST_VDUP(q, poly, p, 16, 8);
Christophe Lyon073831a2011-01-24 17:37:40 +010080 TEST_VDUP(q, float, f, 32, 4);
81
82 dump_results_hex (TEST_MSG);
83 }
84
85#undef TEST_MSG
86#define TEST_MSG "VMOV/VMOVQ"
87 for (i=0; i< 3; i++) {
88 clean_results ();
89
90 TEST_VMOV(, int, s, 8, 8);
91 TEST_VMOV(, int, s, 16, 4);
92 TEST_VMOV(, int, s, 32, 2);
93 TEST_VMOV(, int, s, 64, 1);
94 TEST_VMOV(, uint, u, 8, 8);
95 TEST_VMOV(, uint, u, 16, 4);
96 TEST_VMOV(, uint, u, 32, 2);
97 TEST_VMOV(, uint, u, 64, 1);
Christophe Lyon80902f62013-03-29 16:26:42 +010098 TEST_VMOV(, poly, p, 8, 8);
99 TEST_VMOV(, poly, p, 16, 4);
Christophe Lyon073831a2011-01-24 17:37:40 +0100100 TEST_VMOV(, float, f, 32, 2);
101
102 TEST_VMOV(q, int, s, 8, 16);
103 TEST_VMOV(q, int, s, 16, 8);
104 TEST_VMOV(q, int, s, 32, 4);
105 TEST_VMOV(q, int, s, 64, 2);
106 TEST_VMOV(q, uint, u, 8, 16);
107 TEST_VMOV(q, uint, u, 16, 8);
108 TEST_VMOV(q, uint, u, 32, 4);
109 TEST_VMOV(q, uint, u, 64, 2);
Christophe Lyon80902f62013-03-29 16:26:42 +0100110 TEST_VMOV(q, poly, p, 8, 16);
111 TEST_VMOV(q, poly, p, 16, 8);
Christophe Lyon073831a2011-01-24 17:37:40 +0100112 TEST_VMOV(q, float, f, 32, 4);
113
114 dump_results_hex (TEST_MSG);
115 }
116}