blob: dc445053035ed9a82aa83164f2df4805ea876e5e [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
26#define INSN_NAME vqsub
27#define TEST_MSG "VQSUB/VQSUBQ"
28
29/* Extra tests for functions requiring types larger than 64 bits to
30 compute saturation */
31void vqsub_64(void);
32#define EXTRA_TESTS vqsub_64
33
34#include "ref_v_binary_sat_op.c"
35
36void vqsub_64(void)
37{
38 int i;
39
40 DECL_VARIABLE_ALL_VARIANTS(vector1);
41 DECL_VARIABLE_ALL_VARIANTS(vector2);
42 DECL_VARIABLE_ALL_VARIANTS(vector_res);
43
44 /* Initialize input "vector1" from "buffer" */
Christophe Lyonf2053672014-12-16 10:26:00 +010045 TEST_MACRO_ALL_VARIANTS_2_5(VLOAD, vector1, buffer);
Christophe Lyon073831a2011-01-24 17:37:40 +010046
Christophe Lyonf2053672014-12-16 10:26:00 +010047 VDUP(vector2, , int, s, 64, 1, 0x0);
48 VDUP(vector2, , uint, u, 64, 1, 0x0);
49 VDUP(vector2, q, int, s, 64, 2, 0x0);
50 VDUP(vector2, q, uint, u, 64, 2, 0x0);
Christophe Lyon073831a2011-01-24 17:37:40 +010051
Christophe Lyon4a6e5cc2014-06-03 22:47:52 +020052 fprintf(ref_file,
53 "\n%s 64 bits saturation cumulative saturation output:\n",
54 TEST_MSG);
Christophe Lyon073831a2011-01-24 17:37:40 +010055 TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 64, 1);
56 TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 64, 1);
57 TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 64, 2);
58 TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 64, 2);
59
60 fprintf(ref_file, "\n64 bits saturation:\n");
61 DUMP(TEST_MSG, int, 64, 1, PRIx64);
62 DUMP(TEST_MSG, uint, 64, 1, PRIx64);
63 DUMP(TEST_MSG, int, 64, 2, PRIx64);
64 DUMP(TEST_MSG, uint, 64, 2, PRIx64);
65
66 /* Another set of tests */
Christophe Lyonf2053672014-12-16 10:26:00 +010067 VDUP(vector2, , int, s, 64, 1, 0x44);
68 VDUP(vector2, , uint, u, 64, 1, 0x88);
69 VDUP(vector2, q, int, s, 64, 2, 0x44);
70 VDUP(vector2, q, uint, u, 64, 2, 0x88);
Christophe Lyon073831a2011-01-24 17:37:40 +010071
Christophe Lyon4a6e5cc2014-06-03 22:47:52 +020072 fprintf(ref_file,
73 "\n%s 64 bits saturation cumulative saturation output:\n",
74 TEST_MSG);
Christophe Lyon073831a2011-01-24 17:37:40 +010075 TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 64, 1);
76 TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 64, 1);
77 TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 64, 2);
78 TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 64, 2);
79
80 DUMP(TEST_MSG, int, 64, 1, PRIx64);
81 DUMP(TEST_MSG, uint, 64, 1, PRIx64);
82 DUMP(TEST_MSG, int, 64, 2, PRIx64);
83 DUMP(TEST_MSG, uint, 64, 2, PRIx64);
84
85 /* Another set of tests */
Christophe Lyonf2053672014-12-16 10:26:00 +010086 VDUP(vector2, , int, s, 64, 1, 0x7fffffffffffffffLL);
87 VDUP(vector2, , uint, u, 64, 1, 0xffffffffffffffffULL);
Christophe Lyon073831a2011-01-24 17:37:40 +010088
89 /* To check positive saturation, we need to write a positive value
90 in vector1 */
Christophe Lyonf2053672014-12-16 10:26:00 +010091 VDUP(vector1, q, int, s, 64, 2, 0x3fffffffffffffffLL);
92 VDUP(vector2, q, int, s, 64, 2, 0x8000000000000000LL);
Christophe Lyon073831a2011-01-24 17:37:40 +010093
Christophe Lyonf2053672014-12-16 10:26:00 +010094 VDUP(vector2, q, uint, u, 64, 2, 0xffffffffffffffffULL);
Christophe Lyon073831a2011-01-24 17:37:40 +010095
Christophe Lyon4a6e5cc2014-06-03 22:47:52 +020096 fprintf(ref_file,
97 "\n%s 64 bits saturation cumulative saturation output:\n",
98 TEST_MSG);
Christophe Lyon073831a2011-01-24 17:37:40 +010099 TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 64, 1);
100 TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 64, 1);
101 TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 64, 2);
102 TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 64, 2);
103
104 DUMP(TEST_MSG, int, 64, 1, PRIx64);
105 DUMP(TEST_MSG, uint, 64, 1, PRIx64);
106 DUMP(TEST_MSG, int, 64, 2, PRIx64);
107 DUMP(TEST_MSG, uint, 64, 2, PRIx64);
108
109 /* To improve coverage, check saturation with less than 64 bits too */
110 fprintf(ref_file, "\nless than 64 bits saturation:\n");
Christophe Lyonf2053672014-12-16 10:26:00 +0100111 VDUP(vector2, , int, s, 8, 8, 0x7F);
112 VDUP(vector2, , int, s, 16, 4, 0x7FFF);
113 VDUP(vector2, , int, s, 32, 2, 0x7FFFFFFF);
114 VDUP(vector2, q, int, s, 8, 16, 0x7F);
115 VDUP(vector2, q, int, s, 16, 8, 0x7FFF);
116 VDUP(vector2, q, int, s, 32, 4, 0x7FFFFFFF);
Christophe Lyon073831a2011-01-24 17:37:40 +0100117
118 TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 8, 8);
119 TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 16, 4);
120 TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 32, 2);
121 TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 8, 16);
122 TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 16, 8);
123 TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 32, 4);
124
125 DUMP(TEST_MSG, int, 8, 8, PRIx8);
126 DUMP(TEST_MSG, int, 16, 4, PRIx16);
127 DUMP(TEST_MSG, int, 32, 2, PRIx32);
128 DUMP(TEST_MSG, int, 8, 16, PRIx8);
129 DUMP(TEST_MSG, int, 16, 8, PRIx16);
130 DUMP(TEST_MSG, int, 32, 4, PRIx32);
131
132
Christophe Lyonf2053672014-12-16 10:26:00 +0100133 VDUP(vector1, , uint, u, 8, 8, 0x10);
134 VDUP(vector1, , uint, u, 16, 4, 0x10);
135 VDUP(vector1, , uint, u, 32, 2, 0x10);
136 VDUP(vector1, q, uint, u, 8, 16, 0x10);
137 VDUP(vector1, q, uint, u, 16, 8, 0x10);
138 VDUP(vector1, q, uint, u, 32, 4, 0x10);
Christophe Lyon073831a2011-01-24 17:37:40 +0100139
Christophe Lyonf2053672014-12-16 10:26:00 +0100140 VDUP(vector2, , uint, u, 8, 8, 0x20);
141 VDUP(vector2, , uint, u, 16, 4, 0x20);
142 VDUP(vector2, , uint, u, 32, 2, 0x20);
143 VDUP(vector2, q, uint, u, 8, 16, 0x20);
144 VDUP(vector2, q, uint, u, 16, 8, 0x20);
145 VDUP(vector2, q, uint, u, 32, 4, 0x20);
Christophe Lyon073831a2011-01-24 17:37:40 +0100146
Christophe Lyon4a6e5cc2014-06-03 22:47:52 +0200147 fprintf(ref_file,
148 "\n%s less than 64 bits saturation cumulative saturation output:\n",
Christophe Lyon073831a2011-01-24 17:37:40 +0100149 TEST_MSG);
150 TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 8, 8);
151 TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 16, 4);
152 TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 32, 2);
153 TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 8, 16);
154 TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 16, 8);
155 TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 32, 4);
156
157 DUMP(TEST_MSG, uint, 8, 8, PRIx8);
158 DUMP(TEST_MSG, uint, 16, 4, PRIx16);
159 DUMP(TEST_MSG, uint, 32, 2, PRIx32);
160 DUMP(TEST_MSG, uint, 8, 16, PRIx8);
161 DUMP(TEST_MSG, uint, 16, 8, PRIx16);
162 DUMP(TEST_MSG, uint, 32, 4, PRIx32);
163}