blob: a273a3a03f5cf0abdb2bd5a295b63c61c83595bd [file] [log] [blame]
Christophe Lyon073831a2011-01-24 17:37:40 +01001/*
2
3Copyright (c) 2009, 2010, 2011 STMicroelectronics
4Written 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#ifndef INSN_NAME
35#define INSN_NAME vtst
36#define TEST_MSG "VTST/VTSTQ"
37#endif
38
39/* Can't use the standard ref_v_binary_op.c template because vtst has
40 no 64 bits variant, and outputs are always of uint type */
41#define FNNAME1(NAME) void exec_ ## NAME (void)
42#define FNNAME(NAME) FNNAME1(NAME)
43
44FNNAME (INSN_NAME)
45{
46 /* Basic test: y=OP(x,x), then store the result. */
47#define TEST_BINARY_OP1(INSN, Q, T1, T2, W, N) \
48 VECT_VAR(vector_res, uint, W, N) = \
49 INSN##Q##_##T2##W(VECT_VAR(vector, T1, W, N), \
50 VECT_VAR(vector2, T1, W, N)); \
51 vst1##Q##_u##W(VECT_VAR(result, uint, W, N), \
52 VECT_VAR(vector_res, uint, W, N))
53
54#define TEST_BINARY_OP(INSN, Q, T1, T2, W, N) \
55 TEST_BINARY_OP1(INSN, Q, T1, T2, W, N) \
56
57 /* With ARM RVCT, we need to declare variables before any executable
58 statement */
59 DECL_VARIABLE_ALL_VARIANTS(vector);
60 DECL_VARIABLE_ALL_VARIANTS(vector2);
61 DECL_VARIABLE_UNSIGNED_VARIANTS(vector_res);
62
63
64 clean_results ();
65
66 /* Initialize input "vector" from "buffer" */
Christophe Lyonf2053672014-12-16 10:26:00 +010067 TEST_MACRO_ALL_VARIANTS_2_5(VLOAD, vector, buffer);
Christophe Lyon073831a2011-01-24 17:37:40 +010068
69 /* Choose init value arbitrarily, will be used as comparison value */
Christophe Lyonf2053672014-12-16 10:26:00 +010070 VDUP(vector2, , int, s, 8, 8, 15);
71 VDUP(vector2, , int, s, 16, 4, 5);
72 VDUP(vector2, , int, s, 32, 2, 1);
73 VDUP(vector2, , uint, u, 8, 8, 15);
74 VDUP(vector2, , uint, u, 16, 4, 5);
75 VDUP(vector2, , uint, u, 32, 2, 1);
76 VDUP(vector2, q, int, s, 8, 16, 15);
77 VDUP(vector2, q, int, s, 16, 8, 5);
78 VDUP(vector2, q, int, s, 32, 4, 1);
79 VDUP(vector2, q, uint, u, 8, 16, 15);
80 VDUP(vector2, q, uint, u, 16, 8, 5);
81 VDUP(vector2, q, uint, u, 32, 4, 1);
Christophe Lyon073831a2011-01-24 17:37:40 +010082
83#define TEST_MACRO_NO64BIT_VARIANT_1_5(MACRO, VAR, T1, T2) \
84 MACRO(VAR, , T1, T2, 8, 8); \
85 MACRO(VAR, , T1, T2, 16, 4); \
86 MACRO(VAR, , T1, T2, 32, 2); \
87 MACRO(VAR, q, T1, T2, 8, 16); \
88 MACRO(VAR, q, T1, T2, 16, 8); \
89 MACRO(VAR, q, T1, T2, 32, 4)
90
91 /* Split the test, as both signed and unsigned variants output their
92 result in an unsigned form (thus the same output variable is used
93 in these tests) */
94 TEST_MACRO_NO64BIT_VARIANT_1_5(TEST_BINARY_OP, INSN_NAME, int, s);
95 dump_results_hex2 (TEST_MSG, " (signed input)");
96
97 TEST_MACRO_NO64BIT_VARIANT_1_5(TEST_BINARY_OP, INSN_NAME, uint, u);
98 dump_results_hex2 (TEST_MSG, " (unsigned input)");
99}