blob: 6bf70bdc3ada20d74104772aca52d2ea8e88b01f [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 vqadd
27#define TEST_MSG "VQADD/VQADDQ"
28
29/* Extra tests for functions requiring types larger than 64 bits to
30 compute saturation */
31void vqadd_64(void);
32#define EXTRA_TESTS vqadd_64
33
34#include "ref_v_binary_sat_op.c"
35
36void vqadd_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", TEST_MSG);
Christophe Lyon073831a2011-01-24 17:37:40 +010054 TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 64, 1);
55 TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 64, 1);
56 TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 64, 2);
57 TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 64, 2);
58
59 fprintf(ref_file, "\n64 bits saturation:\n");
60 DUMP(TEST_MSG, int, 64, 1, PRIx64);
61 DUMP(TEST_MSG, uint, 64, 1, PRIx64);
62 DUMP(TEST_MSG, int, 64, 2, PRIx64);
63 DUMP(TEST_MSG, uint, 64, 2, PRIx64);
64
65 /* Another set of tests */
Christophe Lyonf2053672014-12-16 10:26:00 +010066 VDUP(vector2, , int, s, 64, 1, 0x44);
67 VDUP(vector2, , uint, u, 64, 1, 0x88);
68 VDUP(vector2, q, int, s, 64, 2, 0x44);
69 VDUP(vector2, q, uint, u, 64, 2, 0x88);
Christophe Lyon073831a2011-01-24 17:37:40 +010070
Christophe Lyon4a6e5cc2014-06-03 22:47:52 +020071 fprintf(ref_file,
72 "\n%s 64 bits saturation cumulative saturation output:\n", TEST_MSG);
Christophe Lyon073831a2011-01-24 17:37:40 +010073 TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 64, 1);
74 TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 64, 1);
75 TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 64, 2);
76 TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 64, 2);
77
78 DUMP(TEST_MSG, int, 64, 1, PRIx64);
79 DUMP(TEST_MSG, uint, 64, 1, PRIx64);
80 DUMP(TEST_MSG, int, 64, 2, PRIx64);
81 DUMP(TEST_MSG, uint, 64, 2, PRIx64);
82
83 /* Another set of tests */
Christophe Lyonf2053672014-12-16 10:26:00 +010084 VDUP(vector2, , int, s, 64, 1, 0x8000000000000003LL);
85 VDUP(vector2, , uint, u, 64, 1, 0x88);
Christophe Lyon073831a2011-01-24 17:37:40 +010086
Christophe Lyonf2053672014-12-16 10:26:00 +010087 VDUP(vector1, q, int, s, 64, 2, 0x4000000000000000LL);
88 VDUP(vector2, q, int, s, 64, 2, 0x4000000000000000LL);
Christophe Lyon073831a2011-01-24 17:37:40 +010089
Christophe Lyonf2053672014-12-16 10:26:00 +010090 VDUP(vector2, q, uint, u, 64, 2, 0x22);
Christophe Lyon073831a2011-01-24 17:37:40 +010091
Christophe Lyon4a6e5cc2014-06-03 22:47:52 +020092 fprintf(ref_file,
93 "\n%s 64 bits saturation cumulative saturation output:\n", TEST_MSG);
Christophe Lyon073831a2011-01-24 17:37:40 +010094 TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 64, 1);
95 TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 64, 1);
96 TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 64, 2);
97 TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 64, 2);
98
99 DUMP(TEST_MSG, int, 64, 1, PRIx64);
100 DUMP(TEST_MSG, uint, 64, 1, PRIx64);
101 DUMP(TEST_MSG, int, 64, 2, PRIx64);
102 DUMP(TEST_MSG, uint, 64, 2, PRIx64);
103
104 /* To improve coverage, check saturation with less than 64 bits too */
Christophe Lyonf2053672014-12-16 10:26:00 +0100105 VDUP(vector2, , int, s, 8, 8, 0x81);
106 VDUP(vector2, , int, s, 16, 4, 0x8001);
107 VDUP(vector2, , int, s, 32, 2, 0x80000001);
108 VDUP(vector2, q, int, s, 8, 16, 0x81);
109 VDUP(vector2, q, int, s, 16, 8, 0x8001);
110 VDUP(vector2, q, int, s, 32, 4, 0x80000001);
Christophe Lyon073831a2011-01-24 17:37:40 +0100111
112 fprintf(ref_file, "\nless than 64 bits saturation:\n");
113 TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 8, 8);
114 TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 16, 4);
115 TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 32, 2);
116 TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 8, 16);
117 TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 16, 8);
118 TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 32, 4);
119
120 DUMP(TEST_MSG, int, 8, 8, PRIx8);
121 DUMP(TEST_MSG, int, 16, 4, PRIx16);
122 DUMP(TEST_MSG, int, 32, 2, PRIx32);
123 DUMP(TEST_MSG, int, 8, 16, PRIx8);
124 DUMP(TEST_MSG, int, 16, 8, PRIx16);
125 DUMP(TEST_MSG, int, 32, 4, PRIx32);
126
Christophe Lyonf2053672014-12-16 10:26:00 +0100127 VDUP(vector1, , uint, u, 8, 8, 0xF0);
128 VDUP(vector1, , uint, u, 16, 4, 0xFFF0);
129 VDUP(vector1, , uint, u, 32, 2, 0xFFFFFFF0);
130 VDUP(vector1, q, uint, u, 8, 16, 0xF0);
131 VDUP(vector1, q, uint, u, 16, 8, 0xFFF0);
132 VDUP(vector1, q, uint, u, 32, 4, 0xFFFFFFF0);
Christophe Lyon073831a2011-01-24 17:37:40 +0100133
Christophe Lyonf2053672014-12-16 10:26:00 +0100134 VDUP(vector2, , uint, u, 8, 8, 0x20);
135 VDUP(vector2, , uint, u, 16, 4, 0x20);
136 VDUP(vector2, , uint, u, 32, 2, 0x20);
137 VDUP(vector2, q, uint, u, 8, 16, 0x20);
138 VDUP(vector2, q, uint, u, 16, 8, 0x20);
139 VDUP(vector2, q, uint, u, 32, 4, 0x20);
Christophe Lyon073831a2011-01-24 17:37:40 +0100140
Christophe Lyon4a6e5cc2014-06-03 22:47:52 +0200141 fprintf(ref_file,
142 "\n%s less than 64 bits saturation cumulative saturation output:\n",
Christophe Lyon073831a2011-01-24 17:37:40 +0100143 TEST_MSG);
144 TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 8, 8);
145 TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 16, 4);
146 TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 32, 2);
147 TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 8, 16);
148 TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 16, 8);
149 TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 32, 4);
150
151 DUMP(TEST_MSG, uint, 8, 8, PRIx8);
152 DUMP(TEST_MSG, uint, 16, 4, PRIx16);
153 DUMP(TEST_MSG, uint, 32, 2, PRIx32);
154 DUMP(TEST_MSG, uint, 8, 16, PRIx8);
155 DUMP(TEST_MSG, uint, 16, 8, PRIx16);
156 DUMP(TEST_MSG, uint, 32, 4, PRIx32);
157}