blob: d0086e5d5e80f242fabf34cc535a9d5ab0a851e7 [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"
Christophe Lyonc8aa0f62011-09-26 18:00:27 +020033#include <math.h>
Christophe Lyon073831a2011-01-24 17:37:40 +010034
35#ifndef INSN_NAME
36#define INSN_NAME vmax
37#define TEST_MSG "VMAX/VMAXQ"
38#endif
39
40/* Can't use the standard ref_v_binary_op.c template because vmax has
41 no 64 bits variant */
42#define FNNAME1(NAME) void exec_ ## NAME (void)
43#define FNNAME(NAME) FNNAME1(NAME)
44
45FNNAME (INSN_NAME)
46{
Christophe Lyonc8aa0f62011-09-26 18:00:27 +020047 int i;
48
Christophe Lyon073831a2011-01-24 17:37:40 +010049 /* Basic test: y=OP(x,x), then store the result. */
50#define TEST_BINARY_OP1(INSN, Q, T1, T2, W, N) \
51 VECT_VAR(vector_res, T1, W, N) = \
52 INSN##Q##_##T2##W(VECT_VAR(vector, T1, W, N), \
53 VECT_VAR(vector2, T1, W, N)); \
54 vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), VECT_VAR(vector_res, T1, W, N))
55
56#define TEST_BINARY_OP(INSN, Q, T1, T2, W, N) \
57 TEST_BINARY_OP1(INSN, Q, T1, T2, W, N) \
58
59 /* With ARM RVCT, we need to declare variables before any executable
60 statement */
61 DECL_VARIABLE_ALL_VARIANTS(vector);
62 DECL_VARIABLE_ALL_VARIANTS(vector2);
63 DECL_VARIABLE_ALL_VARIANTS(vector_res);
64
65 clean_results ();
66
67 /* Initialize input "vector" from "buffer" */
Christophe Lyonf2053672014-12-16 10:26:00 +010068 TEST_MACRO_ALL_VARIANTS_2_5(VLOAD, vector, buffer);
Christophe Lyon073831a2011-01-24 17:37:40 +010069#ifndef NO_FLOAT_VARIANT
Christophe Lyonf2053672014-12-16 10:26:00 +010070 VLOAD(vector, buffer, , float, f, 32, 2);
71 VLOAD(vector, buffer, q, float, f, 32, 4);
Christophe Lyon073831a2011-01-24 17:37:40 +010072#endif
73
74 /* Choose init value arbitrarily, will be used as comparison value */
Christophe Lyonf2053672014-12-16 10:26:00 +010075 VDUP(vector2, , int, s, 8, 8, -13);
76 VDUP(vector2, , int, s, 16, 4, -14);
77 VDUP(vector2, , int, s, 32, 2, -16);
78 VDUP(vector2, , uint, u, 8, 8, 0xf3);
79 VDUP(vector2, , uint, u, 16, 4, 0xfff1);
80 VDUP(vector2, , uint, u, 32, 2, 0xfffffff0);
81 VDUP(vector2, q, int, s, 8, 16, -12);
82 VDUP(vector2, q, int, s, 16, 8, -13);
83 VDUP(vector2, q, int, s, 32, 4, -15);
84 VDUP(vector2, q, uint, u, 8, 16, 0xf9);
85 VDUP(vector2, q, uint, u, 16, 8, 0xfff2);
86 VDUP(vector2, q, uint, u, 32, 4, 0xfffffff1);
Christophe Lyon073831a2011-01-24 17:37:40 +010087#ifndef NO_FLOAT_VARIANT
Christophe Lyonf2053672014-12-16 10:26:00 +010088 VDUP(vector2, , float, f, 32, 2, -15.5f);
89 VDUP(vector2, q, float, f, 32, 4, -14.5f);
Christophe Lyon073831a2011-01-24 17:37:40 +010090#endif
91
92#ifndef NO_FLOAT_VARIANT
93#define FLOAT_VARIANT(MACRO, VAR) \
94 MACRO(VAR, , float, f, 32, 2); \
95 MACRO(VAR, q, float, f, 32, 4)
96#else
97#define FLOAT_VARIANT(MACRO, VAR)
98#endif
99
100#define TEST_MACRO_NO64BIT_VARIANT_1_5(MACRO, VAR) \
101 MACRO(VAR, , int, s, 8, 8); \
102 MACRO(VAR, , int, s, 16, 4); \
103 MACRO(VAR, , int, s, 32, 2); \
104 MACRO(VAR, , uint, u, 8, 8); \
105 MACRO(VAR, , uint, u, 16, 4); \
106 MACRO(VAR, , uint, u, 32, 2); \
107 MACRO(VAR, q, int, s, 8, 16); \
108 MACRO(VAR, q, int, s, 16, 8); \
109 MACRO(VAR, q, int, s, 32, 4); \
110 MACRO(VAR, q, uint, u, 8, 16); \
111 MACRO(VAR, q, uint, u, 16, 8); \
112 MACRO(VAR, q, uint, u, 32, 4); \
113 FLOAT_VARIANT(MACRO, VAR)
114
115 /* Apply a binary operator named INSN_NAME */
116 TEST_MACRO_NO64BIT_VARIANT_1_5(TEST_BINARY_OP, INSN_NAME);
117
118 dump_results_hex (TEST_MSG);
Christophe Lyonc8aa0f62011-09-26 18:00:27 +0200119
120
121#ifndef NO_FLOAT_VARIANT
122 /* Extra FP tests with special values (NaN, ....) */
Christophe Lyonf2053672014-12-16 10:26:00 +0100123 VDUP(vector, q, float, f, 32, 4, 1.0f);
124 VDUP(vector2, q, float, f, 32, 4, NAN);
Christophe Lyonc8aa0f62011-09-26 18:00:27 +0200125 TEST_BINARY_OP(INSN_NAME, q, float, f, 32, 4);
Christophe Lyon269df922011-10-17 15:53:53 +0200126 DUMP_FP(TEST_MSG " FP special (NaN)", float, 32, 4, PRIx32);
Christophe Lyonc8aa0f62011-09-26 18:00:27 +0200127
Christophe Lyonf2053672014-12-16 10:26:00 +0100128 VDUP(vector, q, float, f, 32, 4, -NAN);
129 VDUP(vector2, q, float, f, 32, 4, 1.0f);
Christophe Lyonc8aa0f62011-09-26 18:00:27 +0200130 TEST_BINARY_OP(INSN_NAME, q, float, f, 32, 4);
Christophe Lyon269df922011-10-17 15:53:53 +0200131 DUMP_FP(TEST_MSG " FP special (-NaN)", float, 32, 4, PRIx32);
132
Christophe Lyonf2053672014-12-16 10:26:00 +0100133 VDUP(vector, q, float, f, 32, 4, 1.0f);
134 VDUP(vector2, q, float, f, 32, 4, HUGE_VALF);
Christophe Lyon269df922011-10-17 15:53:53 +0200135 TEST_BINARY_OP(INSN_NAME, q, float, f, 32, 4);
136 DUMP_FP(TEST_MSG " FP special (inf)", float, 32, 4, PRIx32);
137
Christophe Lyonf2053672014-12-16 10:26:00 +0100138 VDUP(vector, q, float, f, 32, 4, -HUGE_VALF);
139 VDUP(vector2, q, float, f, 32, 4, 1.0f);
Christophe Lyon269df922011-10-17 15:53:53 +0200140 TEST_BINARY_OP(INSN_NAME, q, float, f, 32, 4);
141 DUMP_FP(TEST_MSG " FP special (-inf)", float, 32, 4, PRIx32);
Christophe Lyonc8aa0f62011-09-26 18:00:27 +0200142
Christophe Lyonf2053672014-12-16 10:26:00 +0100143 VDUP(vector, q, float, f, 32, 4, 0.0f);
144 VDUP(vector2, q, float, f, 32, 4, -0.0f);
Christophe Lyonc8aa0f62011-09-26 18:00:27 +0200145 TEST_BINARY_OP(INSN_NAME, q, float, f, 32, 4);
146 DUMP_FP(TEST_MSG " FP special (-0.0)", float, 32, 4, PRIx32);
147
Christophe Lyonf2053672014-12-16 10:26:00 +0100148 VDUP(vector, q, float, f, 32, 4, -0.0f);
149 VDUP(vector2, q, float, f, 32, 4, 0.0f);
Christophe Lyonc8aa0f62011-09-26 18:00:27 +0200150 TEST_BINARY_OP(INSN_NAME, q, float, f, 32, 4);
151 DUMP_FP(TEST_MSG " FP special (-0.0)", float, 32, 4, PRIx32);
152#endif
Christophe Lyon073831a2011-01-24 17:37:40 +0100153}