Remove DEF_VECs from symtab.h
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.opencl / operators.exp
1 # Copyright 2010-2018 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>. */
15 #
16 # Contributed by Ken Werner <ken.werner@de.ibm.com>.
17 #
18 # Tests GDBs support for OpenCL operators.
19
20 load_lib opencl.exp
21
22 if { [skip_opencl_tests] } {
23 return 0
24 }
25
26 set testfile "operators"
27 set clprogram [remote_download target ${srcdir}/${subdir}/${testfile}.cl]
28
29 # Compile the generic OpenCL host app
30 if { [gdb_compile_opencl_hostapp "${clprogram}" "${testfile}" "" ] != "" } {
31 untested "failed to compile"
32 return -1
33 }
34
35 # Load the OpenCL app
36 clean_restart ${testfile}
37
38 # Set breakpoint at the OpenCL kernel
39 gdb_test "tbreak testkernel" \
40 "" \
41 "Set pending breakpoint" \
42 ".*Function \"testkernel\" not defined.*Make breakpoint pending.*y or \\\[n\\\]. $" \
43 "y"
44
45 gdb_run_cmd
46 gdb_test "" ".*reakpoint.*1.*testkernel.*" "run"
47
48 # Continue to the marker
49 gdb_breakpoint [gdb_get_line_number "marker" "${clprogram}"]
50 gdb_continue_to_breakpoint "marker"
51
52 # Retrieve some information about availability of OpenCL extensions
53 set have_cl_khr_fp64 [get_integer_valueof "have_cl_khr_fp64" 0]
54 set have_cl_khr_fp16 [get_integer_valueof "have_cl_khr_fp16" 0]
55
56 proc check_basic { name type isfloat } {
57 gdb_test "print/d ${name}a" " = 2"
58 gdb_test "print/d ${name}b" " = 1"
59 gdb_test "print/d ${name}4a" " = \\{2, 4, 8, 16\\}"
60 gdb_test "print/d ${name}4b" " = \\{1, 2, 8, 4\\}"
61
62 gdb_test "ptype ${name}a" "type = ${type}"
63 gdb_test "ptype ${name}b" "type = ${type}"
64 gdb_test "ptype ${name}4a" "type = ${type}4"
65 gdb_test "ptype ${name}4b" "type = ${type}4"
66
67 if { ! ${isfloat} } {
68 gdb_test "print/d u${name}a" " = 2"
69 gdb_test "print/d u${name}b" " = 1"
70 gdb_test "print/d u${name}4a" " = \\{2, 4, 8, 16\\}"
71 gdb_test "print/d u${name}4b" " = \\{1, 2, 8, 4\\}"
72 gdb_test "ptype u${name}a" "type = (unsigned ${type}|u${type})"
73 gdb_test "ptype u${name}b" "type = (unsigned ${type}|u${type})"
74 gdb_test "ptype u${name}4a" "type = u${type}4"
75 gdb_test "ptype u${name}4b" "type = u${type}4"
76 }
77 }
78
79 # Arithmetic operators
80 proc check_arithmetic_ops { name type isfloat size } {
81 # scalar with scalar
82 gdb_test "print/d ${name}a + ${name}b" " = 3"
83 gdb_test "print/d ${name}a - ${name}b" " = 1"
84 gdb_test "print/d ${name}a * ${name}b" " = 2"
85 gdb_test "print/d ${name}a / ${name}b" " = 2"
86 # scalar with vector
87 gdb_test "print/d ${name}a + ${name}4b" " = \\{3, 4, 10, 6\\}"
88 gdb_test "print/d ${name}4a - ${name}b" " = \\{1, 3, 7, 15\\}"
89 gdb_test "print/d ${name}4a * ${name}b" " = \\{2, 4, 8, 16\\}"
90 gdb_test "print/d ${name}a / ${name}4b" " = \\{2, 1, 0, 0\\}"
91 # vector with vector
92 gdb_test "print/d ${name}4a + ${name}4b" " = \\{3, 6, 16, 20\\}"
93 gdb_test "print/d ${name}4a - ${name}4b" " = \\{1, 2, 0, 12\\}"
94 gdb_test "print/d ${name}4a * ${name}4b" " = \\{2, 8, 64, 64\\}"
95 gdb_test "print/d ${name}4a / ${name}4b" " = \\{2, 2, 1, 4\\}"
96
97 # scalar
98 gdb_test "print/d ${name}a++" " = 2"
99 gdb_test "print/d ++${name}a" " = 4"
100 gdb_test "print/d ${name}a--" " = 4"
101 gdb_test "print/d --${name}a" " = 2"
102 gdb_test "print/d +${name}a" " = 2"
103 gdb_test "print/d -${name}a" " = -2"
104 # vector
105 gdb_test "print/d ${name}4a++" " = \\{2, 4, 8, 16\\}"
106 gdb_test "print/d ++${name}4a" " = \\{4, 6, 10, 18\\}"
107 gdb_test "print/d ${name}4a--" " = \\{4, 6, 10, 18\\}"
108 gdb_test "print/d --${name}4a" " = \\{2, 4, 8, 16\\}"
109 gdb_test "print/d +${name}4a" " = \\{2, 4, 8, 16\\}"
110 gdb_test "print/d -${name}4a" " = \\{-2, -4, -8, -16\\}"
111
112 # scalar with vector
113 gdb_test "ptype ${name}a + ${name}4b" "type = ${type}4"
114 gdb_test "ptype ${name}4a - ${name}b" "type = ${type}4"
115 gdb_test "ptype ${name}a * ${name}4b" "type = ${type}4"
116 gdb_test "ptype ${name}4a / ${name}b" "type = ${type}4"
117 # vector with vector
118 gdb_test "ptype ${name}4a + ${name}4b" "type = ${type}4"
119 gdb_test "ptype ${name}4a - ${name}4b" "type = ${type}4"
120 gdb_test "ptype ${name}4a * ${name}4b" "type = ${type}4"
121 gdb_test "ptype ${name}4a / ${name}4b" "type = ${type}4"
122
123 # scalar
124 gdb_test "ptype ${name}a++" "type = ${type}"
125 gdb_test "ptype ++${name}a" "type = ${type}"
126 gdb_test "ptype ${name}a--" "type = ${type}"
127 gdb_test "ptype --${name}a" "type = ${type}"
128 # vector
129 gdb_test "ptype ${name}4a++" "type = ${type}4"
130 gdb_test "ptype ++${name}4a" "type = ${type}4"
131 gdb_test "ptype ${name}4a--" "type = ${type}4"
132 gdb_test "ptype --${name}4a" "type = ${type}4"
133 gdb_test "ptype +${name}4a" "type = ${type}4"
134 gdb_test "ptype -${name}4a" "type = ${type}4"
135
136 if { ${isfloat} } {
137 # scalar with scalar
138 gdb_test "ptype ${name}a + ${name}b" "type = ${type}"
139 gdb_test "ptype ${name}a - ${name}b" "type = ${type}"
140 gdb_test "ptype ${name}a * ${name}b" "type = ${type}"
141 gdb_test "ptype ${name}a / ${name}b" "type = ${type}"
142 # scalar
143 gdb_test "ptype +${name}a" "type = ${type}"
144 gdb_test "ptype -${name}a" "type = ${type}"
145 } else {
146 # scalar with scalar
147 gdb_test "print/d ${name}a % ${name}b" " = 0"
148 # scalar with vector
149 gdb_test "print/d ${name}4a % ${name}b" " = \\{0, 0, 0, 0\\}"
150 # vector with vector
151 gdb_test "print/d ${name}4a % ${name}b" " = \\{0, 0, 0, 0\\}"
152
153 # scalar with scalar
154 gdb_test "print/d u${name}a + u${name}b" " = 3"
155 gdb_test "print/d u${name}a - u${name}b" " = 1"
156 gdb_test "print/d u${name}a * u${name}b" " = 2"
157 gdb_test "print/d u${name}a / u${name}b" " = 2"
158 gdb_test "print/d u${name}a % u${name}b" " = 0"
159 # scalar with vector
160 gdb_test "print/d u${name}a + u${name}4b" " = \\{3, 4, 10, 6\\}"
161 gdb_test "print/d u${name}4a - u${name}b" " = \\{1, 3, 7, 15\\}"
162 gdb_test "print/d u${name}4a * u${name}b" " = \\{2, 4, 8, 16\\}"
163 gdb_test "print/d u${name}a / u${name}4b" " = \\{2, 1, 0, 0\\}"
164 gdb_test "print/d u${name}4a % u${name}b" " = \\{0, 0, 0, 0\\}"
165 # vector with vector
166 gdb_test "print/d u${name}4a + u${name}4b" " = \\{3, 6, 16, 20\\}"
167 gdb_test "print/d u${name}4a - u${name}4b" " = \\{1, 2, 0, 12\\}"
168 gdb_test "print/d u${name}4a * u${name}4b" " = \\{2, 8, 64, 64\\}"
169 gdb_test "print/d u${name}4a / u${name}4b" " = \\{2, 2, 1, 4\\}"
170 gdb_test "print/d u${name}4a % u${name}4b" " = \\{0, 0, 0, 0\\}"
171
172 # scalar
173 gdb_test "print/d u${name}a++" " = 2"
174 gdb_test "print/d ++u${name}a" " = 4"
175 gdb_test "print/d u${name}a--" " = 4"
176 gdb_test "print/d --u${name}a" " = 2"
177 gdb_test "print/d +u${name}a" " = 2"
178 gdb_test "print/x -u${name}a" " = 0x.*fe"
179 # vector
180 gdb_test "print/d u${name}4a++" " = \\{2, 4, 8, 16\\}"
181 gdb_test "print/d ++u${name}4a" " = \\{4, 6, 10, 18\\}"
182 gdb_test "print/d u${name}4a--" " = \\{4, 6, 10, 18\\}"
183 gdb_test "print/d --u${name}4a" " = \\{2, 4, 8, 16\\}"
184 gdb_test "print/d +u${name}4a" " = \\{2, 4, 8, 16\\}"
185 gdb_test "print/x -u${name}4a" " = \\{0x.*fe, 0x.*fc, 0x.*f8, 0x.*f0\\}"
186
187 # scalar with scalar
188 if { ${size} < 4 } {
189 gdb_test "ptype ${name}a + ${name}b" "type = int"
190 gdb_test "ptype ${name}a - ${name}b" "type = int"
191 gdb_test "ptype ${name}a * ${name}b" "type = int"
192 gdb_test "ptype ${name}a / ${name}b" "type = int"
193 gdb_test "ptype ${name}a % ${name}b" "type = int"
194 gdb_test "ptype +${name}a" "type = int"
195 gdb_test "ptype -${name}a" "type = int"
196 gdb_test "ptype u${name}a + u${name}b" "type = int"
197 gdb_test "ptype u${name}a - u${name}b" "type = int"
198 gdb_test "ptype u${name}a * u${name}b" "type = int"
199 gdb_test "ptype u${name}a / u${name}b" "type = int"
200 gdb_test "ptype u${name}a % u${name}b" "type = int"
201 gdb_test "ptype +u${name}a" "type = int"
202 gdb_test "ptype -u${name}a" "type = int"
203 } elseif { ${size} == 4 } {
204 gdb_test "ptype ${name}a + ${name}b" "type = int"
205 gdb_test "ptype ${name}a - ${name}b" "type = int"
206 gdb_test "ptype ${name}a * ${name}b" "type = int"
207 gdb_test "ptype ${name}a / ${name}b" "type = int"
208 gdb_test "ptype ${name}a % ${name}b" "type = int"
209 gdb_test "ptype +${name}a" "type = int"
210 gdb_test "ptype -${name}a" "type = int"
211 gdb_test "ptype u${name}a + u${name}b" "type = (unsigned int|uint)"
212 gdb_test "ptype u${name}a - u${name}b" "type = (unsigned int|uint)"
213 gdb_test "ptype u${name}a * u${name}b" "type = (unsigned int|uint)"
214 gdb_test "ptype u${name}a / u${name}b" "type = (unsigned int|uint)"
215 gdb_test "ptype u${name}a % u${name}b" "type = (unsigned int|uint)"
216 gdb_test "ptype +u${name}a" "type = (unsigned int|uint)"
217 gdb_test "ptype -u${name}a" "type = (unsigned int|uint)"
218 } else { # ${size} == 8
219 gdb_test "ptype ${name}a + ${name}b" "type = long"
220 gdb_test "ptype ${name}a - ${name}b" "type = long"
221 gdb_test "ptype ${name}a * ${name}b" "type = long"
222 gdb_test "ptype ${name}a / ${name}b" "type = long"
223 gdb_test "ptype ${name}a % ${name}b" "type = long"
224 gdb_test "ptype +${name}a" "type = long"
225 gdb_test "ptype -${name}a" "type = long"
226 gdb_test "ptype u${name}a + u${name}b" "type = (unsigned long|ulong)"
227 gdb_test "ptype u${name}a - u${name}b" "type = (unsigned long|ulong)"
228 gdb_test "ptype u${name}a * u${name}b" "type = (unsigned long|ulong)"
229 gdb_test "ptype u${name}a / u${name}b" "type = (unsigned long|ulong)"
230 gdb_test "ptype u${name}a % u${name}b" "type = (unsigned long|ulong)"
231 # scalar
232 gdb_test "ptype +u${name}a" "type = (unsigned long|ulong)"
233 gdb_test "ptype -u${name}a" "type = (unsigned long|ulong)"
234 }
235 gdb_test "ptype u${name}a++" "type = (unsigned ${type}|u${type})"
236 gdb_test "ptype ++u${name}a" "type = (unsigned ${type}|u${type})"
237 gdb_test "ptype u${name}a--" "type = (unsigned ${type}|u${type})"
238 gdb_test "ptype --u${name}a" "type = (unsigned ${type}|u${type})"
239 # scalar with vector
240 gdb_test "ptype ${name}a % ${name}4b" "type = ${type}4"
241 gdb_test "ptype u${name}a + u${name}4b" "type = u${type}4"
242 gdb_test "ptype u${name}4a - u${name}b" "type = u${type}4"
243 gdb_test "ptype u${name}a * u${name}4b" "type = u${type}4"
244 gdb_test "ptype u${name}4a / u${name}b" "type = u${type}4"
245 gdb_test "ptype u${name}a % u${name}4b" "type = u${type}4"
246 # vector with vector
247 gdb_test "ptype ${name}4a % ${name}4b" "type = ${type}4"
248 gdb_test "ptype u${name}4a + u${name}4b" "type = u${type}4"
249 gdb_test "ptype u${name}4a - u${name}4b" "type = u${type}4"
250 gdb_test "ptype u${name}4a * u${name}4b" "type = u${type}4"
251 gdb_test "ptype u${name}4a / u${name}4b" "type = u${type}4"
252 gdb_test "ptype u${name}4a % u${name}4b" "type = u${type}4"
253 gdb_test "ptype u${name}4a++" "type = u${type}4"
254 gdb_test "ptype ++u${name}4a" "type = u${type}4"
255 gdb_test "ptype u${name}4a--" "type = u${type}4"
256 gdb_test "ptype --u${name}4a" "type = u${type}4"
257 gdb_test "ptype +u${name}4a" "type = u${type}4"
258 gdb_test "ptype -u${name}4a" "type = u${type}4"
259 }
260 }
261
262 # Relational operators
263 proc check_relational_ops { name type isfloat size } {
264 # scalar with scalar
265 gdb_test "print/d ${name}a > ${name}b" " = 1"
266 gdb_test "print/d ${name}b < ${name}a" " = 1"
267 gdb_test "print/d ${name}b >= ${name}a" " = 0"
268 gdb_test "print/d ${name}a <= ${name}b" " = 0"
269 # scalar with vector
270 gdb_test "print/d ${name}4a > ${name}b" " = \\{-1, -1, -1, -1\\}"
271 gdb_test "print/d ${name}a < ${name}4b" " = \\{0, 0, -1, -1\\}"
272 gdb_test "print/d ${name}4a >= ${name}b" " = \\{-1, -1, -1, -1\\}"
273 gdb_test "print/d ${name}a <= ${name}4b" " = \\{0, -1, -1, -1\\}"
274 # vector with vector
275 gdb_test "print/d ${name}4a > ${name}4b" " = \\{-1, -1, 0, -1\\}"
276 gdb_test "print/d ${name}4b < ${name}4a" " = \\{-1, -1, 0, -1\\}"
277 gdb_test "print/d ${name}4b >= ${name}4a" " = \\{0, 0, -1, 0\\}"
278 gdb_test "print/d ${name}4a <= ${name}4b" " = \\{0, 0, -1, 0\\}"
279
280 # result type should be int for scalars
281 gdb_test "ptype ${name}a < ${name}b" "type = int"
282 gdb_test "ptype ${name}a > ${name}b" "type = int"
283 gdb_test "ptype ${name}a <= ${name}b" "type = int"
284 gdb_test "ptype ${name}a >= ${name}b" "type = int"
285
286 if { ${isfloat} } {
287 if { ${size} == 2 } {
288 # result type should be short for half precision floating point vectors
289 # scalar with vector
290 gdb_test "ptype ${name}4a > ${name}b" "type = short4"
291 gdb_test "ptype ${name}a < ${name}4b" "type = short4"
292 gdb_test "ptype ${name}4a >= ${name}b" "type = short4"
293 gdb_test "ptype ${name}a <= ${name}4b" "type = short4"
294 # vector with vector
295 gdb_test "ptype ${name}4a > ${name}4b" "type = short4"
296 gdb_test "ptype ${name}4a < ${name}4b" "type = short4"
297 gdb_test "ptype ${name}4a >= ${name}4b" "type = short4"
298 gdb_test "ptype ${name}4a <= ${name}4b" "type = short4"
299 } elseif { ${size} == 4 } {
300 # result type should be int for single precision floating point vectors
301 # scalar with vector
302 gdb_test "ptype ${name}4a > ${name}b" "type = int4"
303 gdb_test "ptype ${name}a < ${name}4b" "type = int4"
304 gdb_test "ptype ${name}4a >= ${name}b" "type = int4"
305 gdb_test "ptype ${name}a <= ${name}4b" "type = int4"
306 # vector with vector
307 gdb_test "ptype ${name}4a > ${name}4b" "type = int4"
308 gdb_test "ptype ${name}4a < ${name}4b" "type = int4"
309 gdb_test "ptype ${name}4a >= ${name}4b" "type = int4"
310 gdb_test "ptype ${name}4a <= ${name}4b" "type = int4"
311 } else { # ${size} == 8
312 # result type should be long for double precision floating point vectors
313 # scalar with vector
314 gdb_test "ptype ${name}4a > ${name}b" "type = long4"
315 gdb_test "ptype ${name}a < ${name}4b" "type = long4"
316 gdb_test "ptype ${name}4a >= ${name}b" "type = long4"
317 gdb_test "ptype ${name}a <= ${name}4b" "type = long4"
318 # vector with vector
319 gdb_test "ptype ${name}4a > ${name}4b" "type = long4"
320 gdb_test "ptype ${name}4a < ${name}4b" "type = long4"
321 gdb_test "ptype ${name}4a >= ${name}4b" "type = long4"
322 gdb_test "ptype ${name}4a <= ${name}4b" "type = long4"
323 }
324 } else {
325 # scalar with scalar
326 gdb_test "print/d u${name}a > u${name}b" " = 1"
327 gdb_test "print/d u${name}b < u${name}a" " = 1"
328 gdb_test "print/d u${name}b >= u${name}a" " = 0"
329 gdb_test "print/d u${name}a <= u${name}b" " = 0"
330 # scalar with vector
331 gdb_test "print/d u${name}4a > u${name}b" " = \\{-1, -1, -1, -1\\}"
332 gdb_test "print/d u${name}a < u${name}4b" " = \\{0, 0, -1, -1\\}"
333 gdb_test "print/d u${name}4a >= u${name}b" " = \\{-1, -1, -1, -1\\}"
334 gdb_test "print/d u${name}a <= u${name}4b" " = \\{0, -1, -1, -1\\}"
335 # vector with vector
336 gdb_test "print/d u${name}4a > u${name}4b" " = \\{-1, -1, 0, -1\\}"
337 gdb_test "print/d u${name}4b < u${name}4a" " = \\{-1, -1, 0, -1\\}"
338 gdb_test "print/d u${name}4b >= u${name}4a" " = \\{0, 0, -1, 0\\}"
339 gdb_test "print/d u${name}4a <= u${name}4b" " = \\{0, 0, -1, 0\\}"
340
341 # result type for unsigned operands is signed
342 # scalar with scalar
343 gdb_test "ptype u${name}a < u${name}b" "type = int"
344 gdb_test "ptype u${name}a > u${name}b" "type = int"
345 gdb_test "ptype u${name}a <= u${name}b" "type = int"
346 gdb_test "ptype u${name}a >= u${name}b" "type = int"
347 # scalar with vector
348 gdb_test "ptype u${name}4a > u${name}b" "type = ${type}4"
349 gdb_test "ptype u${name}a < u${name}4b" "type = ${type}4"
350 gdb_test "ptype u${name}4a >= u${name}b" "type = ${type}4"
351 gdb_test "ptype u${name}a <= u${name}4b" "type = ${type}4"
352 # vector with vector
353 gdb_test "ptype u${name}4a > u${name}4b" "type = ${type}4"
354 gdb_test "ptype u${name}4a < u${name}4b" "type = ${type}4"
355 gdb_test "ptype u${name}4a >= u${name}4b" "type = ${type}4"
356 gdb_test "ptype u${name}4a <= u${name}4b" "type = ${type}4"
357 }
358 }
359
360 # Equality operators
361 proc check_equality_ops { name type isfloat size } {
362 # scalar with scalar
363 gdb_test "print/d ${name}a == ${name}b" " = 0"
364 gdb_test "print/d ${name}a != ${name}b" " = 1"
365 # scalar with vector
366 gdb_test "print/d ${name}4a == ${name}b" " = \\{0, 0, 0, 0\\}"
367 gdb_test "print/d ${name}a != ${name}4b" " = \\{-1, 0, -1, -1\\}"
368 # vector with vector
369 gdb_test "print/d ${name}4a == ${name}4b" " = \\{0, 0, -1, 0\\}"
370 gdb_test "print/d ${name}4a != ${name}4b" " = \\{-1, -1, 0, -1\\}"
371
372 # scalar with scalar
373 gdb_test "ptype ${name}a == ${name}b" "type = int"
374 gdb_test "ptype ${name}a != ${name}b" "type = int"
375
376 if { ${isfloat} } {
377 if { ${size} == 2 } {
378 # result type should be short for half precision floating point vectors
379 # scalar with vector
380 gdb_test "ptype ${name}4a == ${name}b" "type = short4"
381 gdb_test "ptype ${name}a != ${name}4b" "type = short4"
382 # vector with vector
383 gdb_test "ptype ${name}4a == ${name}4b" "type = short4"
384 gdb_test "ptype ${name}4a != ${name}4b" "type = short4"
385 } elseif { ${size} == 4 } {
386 # result type should be int for single precision floating point vectors
387 # scalar with vector
388 gdb_test "ptype ${name}4a == ${name}b" "type = int4"
389 gdb_test "ptype ${name}a != ${name}4b" "type = int4"
390 # vector with vector
391 gdb_test "ptype ${name}4a == ${name}4b" "type = int4"
392 gdb_test "ptype ${name}4a != ${name}4b" "type = int4"
393 } else { # ${size} == 8
394 # result type should be long for double precision floating point vectors
395 # scalar with vector
396 gdb_test "ptype ${name}4a == ${name}b" "type = long4"
397 gdb_test "ptype ${name}a != ${name}4b" "type = long4"
398 # vector with vector
399 gdb_test "ptype ${name}4a == ${name}4b" "type = long4"
400 gdb_test "ptype ${name}4a != ${name}4b" "type = long4"
401 }
402 } else {
403 # scalar with scalar
404 gdb_test "print/d u${name}a == u${name}b" " = 0"
405 gdb_test "print/d u${name}a != u${name}b" " = 1"
406 # scalar with vector
407 gdb_test "print/d u${name}4a == u${name}b" " = \\{0, 0, 0, 0\\}"
408 gdb_test "print/d u${name}a != u${name}4b" " = \\{-1, 0, -1, -1\\}"
409 # vector with vector
410 gdb_test "print/d u${name}4a == u${name}4b" " = \\{0, 0, -1, 0\\}"
411 gdb_test "print/d u${name}4b != u${name}4a" " = \\{-1, -1, 0, -1\\}"
412
413 # result type for unsigned operands is signed
414 # scalar with scalar
415 gdb_test "ptype u${name}a == u${name}b" "type = int"
416 gdb_test "ptype u${name}a != u${name}b" "type = int"
417 # scalar with vector
418 gdb_test "ptype u${name}4a == u${name}b" "type = ${type}4"
419 gdb_test "ptype u${name}a != u${name}4b" "type = ${type}4"
420 # vector with vector
421 gdb_test "ptype u${name}4a == u${name}4b" "type = ${type}4"
422 gdb_test "ptype u${name}4a != u${name}4b" "type = ${type}4"
423 }
424 }
425
426 # Shift operators
427 proc check_shift_ops { name type size } {
428 # scalar with scalar
429 gdb_test "print/d ${name}a << ${name}b" " = 4"
430 gdb_test "print/d ${name}a >> ${name}b" " = 1"
431 gdb_test "print/d u${name}a << u${name}b" " = 4"
432 gdb_test "print/d u${name}a >> u${name}b" " = 1"
433 # scalar with vector
434 gdb_test "print/d ${name}4a << ${name}b" " = \\{4, 8, 16, 32\\}"
435 gdb_test "print/d ${name}4a >> ${name}b" " = \\{1, 2, 4, 8\\}"
436 gdb_test "print/d u${name}4a << u${name}b" " = \\{4, 8, 16, 32\\}"
437 gdb_test "print/d u${name}4a >> u${name}b" " = \\{1, 2, 4, 8\\}"
438 # vector with vector
439 if { ${size} == 1 } {
440 gdb_test "print/d ${name}4a << ${name}4b" " = \\{4, 16, 0, 0\\}"
441 gdb_test "print/d u${name}4a << u${name}4b" " = \\{4, 16, 0, 0\\}"
442 } else {
443 gdb_test "print/d ${name}4a << ${name}4b" " = \\{4, 16, 2048, 256\\}"
444 gdb_test "print/d u${name}4a << u${name}4b" " = \\{4, 16, 2048, 256\\}"
445 }
446 gdb_test "print/d ${name}4a >> ${name}4b" " = \\{1, 1, 0, 1\\}"
447 gdb_test "print/d u${name}4a >> u${name}4b" " = \\{1, 1, 0, 1\\}"
448
449 # scalar with scalar
450 if { ${size} < 4 } {
451 gdb_test "ptype ${name}a << ${name}b" "type = int"
452 gdb_test "ptype ${name}a >> ${name}b" "type = int"
453 gdb_test "ptype u${name}a << u${name}b" "type = int"
454 gdb_test "ptype u${name}a >> u${name}b" "type = int"
455 } elseif { ${size} == 4 } {
456 gdb_test "ptype ${name}a << ${name}b" "type = int"
457 gdb_test "ptype ${name}a >> ${name}b" "type = int"
458 gdb_test "ptype u${name}a << u${name}b" "type = (unsigned int|uint)"
459 gdb_test "ptype u${name}a >> u${name}b" "type = (unsigned int|uint)"
460 } else { # ${size} == 8
461 gdb_test "ptype ${name}a << ${name}b" "type = long"
462 gdb_test "ptype ${name}a >> ${name}b" "type = long"
463 gdb_test "ptype u${name}a << u${name}b" "type = (unsigned long|ulong)"
464 gdb_test "ptype u${name}a >> u${name}b" "type = (unsigned long|ulong)"
465 }
466 # scalar with vector
467 gdb_test "ptype ${name}4a << ${name}b" "type = ${type}4"
468 gdb_test "ptype ${name}4a >> ${name}b" "type = ${type}4"
469 gdb_test "ptype u${name}4a << u${name}b" "type = u${type}4"
470 gdb_test "ptype u${name}4a >> u${name}b" "type = u${type}4"
471 # vector with vector
472 gdb_test "ptype ${name}4a << ${name}4b" "type = ${type}4"
473 gdb_test "ptype ${name}4a >> ${name}4b" "type = ${type}4"
474 gdb_test "ptype u${name}4a << u${name}4b" "type = u${type}4"
475 gdb_test "ptype u${name}4a >> u${name}4b" "type = u${type}4"
476 }
477
478 # Bitwise operators
479 proc check_bitwise_ops { name type size } {
480 # scalar with scalar
481 gdb_test "print/d ${name}a & ${name}b" " = 0"
482 gdb_test "print/d ${name}a | ${name}b" " = 3"
483 gdb_test "print/d ${name}a ^ ${name}b" " = 3"
484 gdb_test "print/d u${name}a & u${name}b" " = 0"
485 gdb_test "print/d u${name}a | u${name}b" " = 3"
486 gdb_test "print/d u${name}a ^ u${name}b" " = 3"
487 # scalar with vector
488 gdb_test "print/d ${name}4a & ${name}b" " = \\{0, 0, 0, 0\\}"
489 gdb_test "print/d ${name}a | ${name}4b" " = \\{3, 2, 10, 6\\}"
490 gdb_test "print/d ${name}4a ^ ${name}b" " = \\{3, 5, 9, 17\\}"
491 gdb_test "print/d u${name}4a & u${name}b" " = \\{0, 0, 0, 0\\}"
492 gdb_test "print/d u${name}a | u${name}4b" " = \\{3, 2, 10, 6\\}"
493 gdb_test "print/d u${name}4a ^ u${name}b" " = \\{3, 5, 9, 17\\}"
494 # vector with vector
495 gdb_test "print/d ${name}4a & ${name}4b" " = \\{0, 0, 8, 0\\}"
496 gdb_test "print/d ${name}4a | ${name}4b" " = \\{3, 6, 8, 20\\}"
497 gdb_test "print/d ${name}4a ^ ${name}4b" " = \\{3, 6, 0, 20\\}"
498 gdb_test "print/d u${name}4a & u${name}4b" " = \\{0, 0, 8, 0\\}"
499 gdb_test "print/d u${name}4a | u${name}4b" " = \\{3, 6, 8, 20\\}"
500 gdb_test "print/d u${name}4a ^ u${name}4b" " = \\{3, 6, 0, 20\\}"
501
502 # scalar with scalar
503 if { ${size} < 4 } {
504 gdb_test "ptype ${name}a & ${name}b" "type = int"
505 gdb_test "ptype ${name}a | ${name}b" "type = int"
506 gdb_test "ptype ${name}a ^ ${name}b" "type = int"
507 gdb_test "ptype u${name}a & u${name}b" "type = int"
508 gdb_test "ptype u${name}a | u${name}b" "type = int"
509 gdb_test "ptype u${name}a ^ u${name}b" "type = int"
510 } elseif { ${size} == 4 } {
511 gdb_test "ptype ${name}a & ${name}b" "type = int"
512 gdb_test "ptype ${name}a | ${name}b" "type = int"
513 gdb_test "ptype ${name}a ^ ${name}b" "type = int"
514 gdb_test "ptype u${name}a & u${name}b" "type = (unsigned int|uint)"
515 gdb_test "ptype u${name}a | u${name}b" "type = (unsigned int|uint)"
516 gdb_test "ptype u${name}a ^ u${name}b" "type = (unsigned int|uint)"
517 } else { # ${size} == 8
518 gdb_test "ptype ${name}a & ${name}b" "type = long"
519 gdb_test "ptype ${name}a | ${name}b" "type = long"
520 gdb_test "ptype ${name}a ^ ${name}b" "type = long"
521 gdb_test "ptype u${name}a & u${name}b" "type = (unsigned long|ulong)"
522 gdb_test "ptype u${name}a | u${name}b" "type = (unsigned long|ulong)"
523 gdb_test "ptype u${name}a ^ u${name}b" "type = (unsigned long|ulong)"
524 }
525 # scalar with vector
526 gdb_test "ptype ${name}4a & ${name}b" "type = ${type}4"
527 gdb_test "ptype ${name}a | ${name}4b" "type = ${type}4"
528 gdb_test "ptype ${name}4a ^ ${name}b" "type = ${type}4"
529 gdb_test "ptype u${name}4a & u${name}b" "type = u${type}4"
530 gdb_test "ptype u${name}a | u${name}4b" "type = u${type}4"
531 gdb_test "ptype u${name}4a ^ u${name}b" "type = u${type}4"
532 # vector with vector
533 gdb_test "ptype ${name}4a & ${name}4b" "type = ${type}4"
534 gdb_test "ptype ${name}4a | ${name}4b" "type = ${type}4"
535 gdb_test "ptype ${name}4a ^ ${name}4b" "type = ${type}4"
536 gdb_test "ptype u${name}4a & u${name}4b" "type = u${type}4"
537 gdb_test "ptype u${name}4a | u${name}4b" "type = u${type}4"
538 gdb_test "ptype u${name}4a ^ u${name}4b" "type = u${type}4"
539
540 # scalar
541 if { ${size} < 8 } {
542 gdb_test "print/x ~${name}a" " = 0xfffffffd"
543 gdb_test "print/x ~u${name}a" " = 0xfffffffd"
544 } else {
545 gdb_test "print/x ~${name}a" " = 0xfffffffffffffffd"
546 gdb_test "print/x ~u${name}a" " = 0xfffffffffffffffd"
547 }
548 # vector
549 if { ${size} == 1 } {
550 gdb_test "print/x ~${name}4a" " = \\{0xfd, 0xfb, 0xf7, 0xef\\}"
551 gdb_test "print/x ~u${name}4a" " = \\{0xfd, 0xfb, 0xf7, 0xef\\}"
552 } elseif { ${size} == 2 } {
553 gdb_test "print/x ~${name}4a" " = \\{0xfffd, 0xfffb, 0xfff7, 0xffef\\}"
554 gdb_test "print/x ~u${name}4a" " = \\{0xfffd, 0xfffb, 0xfff7, 0xffef\\}"
555 } elseif { ${size} == 4 } {
556 gdb_test "print/x ~${name}4a" " = \\{0xfffffffd, 0xfffffffb, 0xfffffff7, 0xffffffef\\}"
557 gdb_test "print/x ~u${name}4a" " = \\{0xfffffffd, 0xfffffffb, 0xfffffff7, 0xffffffef\\}"
558 } else { # ${size} == 8
559 gdb_test "print/x ~${name}4a" " = \\{0xfffffffffffffffd, 0xfffffffffffffffb, 0xfffffffffffffff7, 0xffffffffffffffef\\}"
560 gdb_test "print/x ~u${name}4a" " = \\{0xfffffffffffffffd, 0xfffffffffffffffb, 0xfffffffffffffff7, 0xffffffffffffffef\\}"
561 }
562 # scalar
563 if { ${size} < 4 } {
564 gdb_test "ptype ~${name}a" "type = int"
565 gdb_test "ptype ~u${name}a" "type = int"
566 } elseif { ${size} == 4 } {
567 gdb_test "ptype ~${name}a" "type = int"
568 gdb_test "ptype ~u${name}a" "type = (unsigned int|uint)"
569 } else { # ${size} == 8
570 gdb_test "ptype ~${name}a" "type = long"
571 gdb_test "ptype ~u${name}a" "type = (unsigned long|ulong)"
572 }
573 # vector
574 gdb_test "ptype ~${name}4a" "type = ${type}4"
575 gdb_test "ptype ~u${name}4a" "type = u${type}4"
576 }
577
578 # Logical operators
579 proc check_logical_ops { name type isfloat size } {
580 # scalar
581 gdb_test "print/d !${name}a " " = 0"
582 gdb_test "print/d !!${name}a " " = 1"
583 # vector
584 gdb_test "print/d !${name}4a " " = \\{0, 0, 0, 0\\}"
585 gdb_test "print/d !!${name}4a " " = \\{-1, -1, -1, -1\\}"
586
587 # scalar with scalar
588 gdb_test "print/d ${name}a && ${name}b" " = 1"
589 gdb_test "print/d ${name}a && !${name}b" " = 0"
590 gdb_test "print/d ${name}a || ${name}b" " = 1"
591 gdb_test "print/d ${name}a || !${name}b" " = 1"
592 gdb_test "print/d !${name}a || !${name}b" " = 0"
593
594 # scalar with vector
595 gdb_test "print/d ${name}4a && ${name}b" " = \\{-1, -1, -1, -1\\}"
596 gdb_test "print/d ${name}4a && !${name}b" " = \\{0, 0, 0, 0\\}"
597 gdb_test "print/d ${name}a || ${name}4b" " = \\{-1, -1, -1, -1\\}"
598 gdb_test "print/d ${name}a || !${name}4b" " = \\{-1, -1, -1, -1\\}"
599 gdb_test "print/d !${name}4a || !${name}b" " = \\{0, 0, 0, 0\\}"
600 # vector with vector
601 gdb_test "print/d ${name}4a && ${name}4b" " = \\{-1, -1, -1, -1\\}"
602 gdb_test "print/d ${name}4a || ${name}4b" " = \\{-1, -1, -1, -1\\}"
603
604 # result type should be int for scalars
605 gdb_test "ptype !${name}a" "type = int"
606 gdb_test "ptype ${name}a && ${name}b" "type = int"
607 gdb_test "ptype ${name}a || ${name}b" "type = int"
608
609 if { ${isfloat} } {
610 if { ${size} == 2 } {
611 # result type should be short for half precision floating point vectors
612 # scalar with vector
613 gdb_test "ptype ${name}4a && ${name}b" "type = short4"
614 gdb_test "ptype ${name}a || ${name}4b" "type = short4"
615 # vector with vector
616 gdb_test "ptype !${name}4a" "type = short4"
617 gdb_test "ptype ${name}4a && ${name}4b" "type = short4"
618 gdb_test "ptype ${name}4a || ${name}4b" "type = short4"
619 } elseif { ${size} == 4 } {
620 # result type should be int for single precision floating point vectors
621 # scalar with vector
622 gdb_test "ptype ${name}4a && ${name}b" "type = int4"
623 gdb_test "ptype ${name}a || ${name}4b" "type = int4"
624 # vector with vector
625 gdb_test "ptype !${name}4a" "type = int4"
626 gdb_test "ptype ${name}4a && ${name}4b" "type = int4"
627 gdb_test "ptype ${name}4a || ${name}4b" "type = int4"
628 } else { # ${size} == 8
629 # result type should be long for double precision floating point vectors
630 # scalar with vector
631 gdb_test "ptype ${name}4a && ${name}b" "type = long4"
632 gdb_test "ptype ${name}a || ${name}4b" "type = long4"
633 # vector with vector
634 gdb_test "ptype !${name}4a" "type = long4"
635 gdb_test "ptype ${name}4a && ${name}4b" "type = long4"
636 gdb_test "ptype ${name}4a || ${name}4b" "type = long4"
637 }
638 } else {
639 # unsigned scalar
640 gdb_test "print/d !u${name}a " " = 0"
641 gdb_test "print/d !!u${name}a " " = 1"
642 # unsigned vector
643 gdb_test "print/d !u${name}4a " " = \\{0, 0, 0, 0\\}"
644 gdb_test "print/d !!u${name}4a " " = \\{-1, -1, -1, -1\\}"
645
646 # scalar with scalar
647 gdb_test "print/d u${name}a && u${name}b" " = 1"
648 gdb_test "print/d u${name}a || u${name}b" " = 1"
649 # scalar with vector
650 gdb_test "print/d u${name}4a && u${name}b" " = \\{-1, -1, -1, -1\\}"
651 gdb_test "print/d u${name}a || u${name}4b" " = \\{-1, -1, -1, -1\\}"
652 # vector with vector
653 gdb_test "print/d u${name}4a && u${name}4b" " = \\{-1, -1, -1, -1\\}"
654 gdb_test "print/d u${name}4a || u${name}4b" " = \\{-1, -1, -1, -1\\}"
655
656 # scalar
657 gdb_test "ptype !u${name}a" "type = int"
658 # vector
659 gdb_test "ptype !${name}4a" "type = ${type}4"
660 gdb_test "ptype !u${name}4a" "type = ${type}4"
661
662 # scalar with vector
663 gdb_test "ptype ${name}4a && ${name}b" "type = ${type}4"
664 gdb_test "ptype ${name}a || ${name}4b" "type = ${type}4"
665 # result type for unsigned vector operand is signed
666 gdb_test "ptype u${name}4a && u${name}b" "type = ${type}4"
667 gdb_test "ptype u${name}a || u${name}4b" "type = ${type}4"
668 # vector with vector
669 gdb_test "ptype ${name}4a && ${name}4b" "type = ${type}4"
670 gdb_test "ptype ${name}4a || ${name}4b" "type = ${type}4"
671 # result type for unsigned vector operand is signed
672 gdb_test "ptype u${name}4a && u${name}4b" "type = ${type}4"
673 gdb_test "ptype u${name}4a || u${name}4b" "type = ${type}4"
674 }
675 }
676
677 # Conditional operator
678 proc check_conditional_op { name type isfloat } {
679 # scalar with scalar
680 gdb_test "print/d ${name}a ? ${name}b : ${name}a" " = 1"
681 gdb_test "print/d !${name}a ? ${name}b : ${name}a" " = 2"
682 # scalar with vector
683 gdb_test "print/d ${name}4a ? ${name}4b : ${name}a" " = \\{1, 2, 8, 4\\}"
684 gdb_test "print/d ${name}4a ? ${name}b : ${name}4a" " = \\{1, 1, 1, 1\\}"
685 gdb_test "print/d ${name}4a > 4 ? 1 : ${name}4a" " = \\{2, 4, 1, 1\\}"
686 gdb_test "print/d ${name}4a > 4 ? ${name}4b : ${name}a" " = \\{2, 2, 8, 4\\}"
687 # vector with vector
688 gdb_test "print/d ${name}4a ? ${name}4b : ${name}4a" " = \\{1, 2, 8, 4\\}"
689 gdb_test "print/d ${name}4a > 4 ? ${name}4b : ${name}4a" " = \\{2, 4, 8, 4\\}"
690
691 # scalar with scalar
692 gdb_test "ptype ${name}a ? ${name}b : ${name}a" "type = ${type}"
693 # scalar with vector
694 gdb_test "ptype ${name}4a ? ${name}4b : ${name}a" "type = ${type}4"
695 gdb_test "ptype ${name}4a ? ${name}b : ${name}4a" "type = ${type}4"
696 # vector with vector
697 gdb_test "ptype ${name}4a ? ${name}4b : ${name}4a" "type = ${type}4"
698
699 if { !${isfloat} } {
700 # scalar with scalar
701 gdb_test "print/d u${name}a ? u${name}b : u${name}a" " = 1"
702 gdb_test "print/d !u${name}a ? u${name}b : u${name}a" " = 2"
703 # scalar with vector
704 gdb_test "print/d u${name}4a ? u${name}4b : u${name}a" " = \\{1, 2, 8, 4\\}"
705 gdb_test "print/d u${name}4a ? u${name}b : u${name}4a" " = \\{1, 1, 1, 1\\}"
706 gdb_test "print/d u${name}4a > 4 ? 1 : u${name}4a" " = \\{2, 4, 1, 1\\}"
707 gdb_test "print/d u${name}4a > 4 ? u${name}4b : u${name}a" " = \\{2, 2, 8, 4\\}"
708 # vector with vector
709 gdb_test "print/d u${name}4a ? u${name}4b : u${name}4a" " = \\{1, 2, 8, 4\\}"
710 gdb_test "print/d u${name}4a > 4 ? u${name}4b : u${name}4a" " = \\{2, 4, 8, 4\\}"
711
712 # scalar with scalar
713 gdb_test "ptype u${name}a ? u${name}b : u${name}a" "type = (unsigned ${type}|u${type})"
714 # scalar with vector
715 gdb_test "ptype u${name}4a ? u${name}4b : u${name}a" "type = u${type}4"
716 gdb_test "ptype u${name}4a ? u${name}b : u${name}4a" "type = u${type}4"
717 # vector with vector
718 gdb_test "ptype u${name}4a ? u${name}4b : u${name}4a" "type = u${type}4"
719 }
720 }
721
722 # Assignment operators
723 proc check_assignment_ops { name type isfloat size } {
724 # scalar with scalar
725 gdb_test "print/d ${name}a = ${name}b" " = 1"
726 gdb_test "print/d ${name}a = 2" " = 2"
727 gdb_test "print/d ${name}a += ${name}b" " = 3"
728 gdb_test "print/d ${name}a -= ${name}b" " = 2"
729 gdb_test "print/d ${name}b *= ${name}a" " = 2"
730 gdb_test "print/d ${name}b /= ${name}a" " = 1"
731 # scalar with vector
732 gdb_test "print/d ${name}4a = ${name}b" " = \\{1, 1, 1, 1\\}"
733 gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
734 gdb_test "print/d ${name}4a += ${name}b" " = \\{3, 5, 9, 17\\}"
735 gdb_test "print/d ${name}4a -= ${name}b" " = \\{2, 4, 8, 16\\}"
736 gdb_test "print/d ${name}4b *= ${name}a" " = \\{2, 4, 16, 8\\}"
737 gdb_test "print/d ${name}4b /= ${name}a" " = \\{1, 2, 8, 4\\}"
738 # vector with vector
739 gdb_test "print/d ${name}4a = ${name}4b" " = \\{1, 2, 8, 4\\}"
740 gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
741 gdb_test "print/d ${name}4a += ${name}4b" " = \\{3, 6, 16, 20\\}"
742 gdb_test "print/d ${name}4a -= ${name}4b" " = \\{2, 4, 8, 16\\}"
743 gdb_test "print/d ${name}4b *= ${name}4a" " = \\{2, 8, 64, 64\\}"
744 gdb_test "print/d ${name}4b /= ${name}4a" " = \\{1, 2, 8, 4\\}"
745
746 # scalar with scalar
747 gdb_test "ptype ${name}a = ${name}b" "type = ${type}"
748 gdb_test "ptype ${name}a += ${name}b" "type = ${type}"
749 gdb_test "ptype ${name}a -= ${name}b" "type = ${type}"
750 gdb_test "ptype ${name}a *= ${name}b" "type = ${type}"
751 gdb_test "ptype ${name}a /= ${name}b" "type = ${type}"
752 # scalar with vector
753 gdb_test "ptype ${name}4a = ${name}b" "type = ${type}4"
754 gdb_test "ptype ${name}4a += ${name}b" "type = ${type}4"
755 gdb_test "ptype ${name}4a -= ${name}b" "type = ${type}4"
756 gdb_test "ptype ${name}4b *= ${name}a" "type = ${type}4"
757 gdb_test "ptype ${name}4b /= ${name}a" "type = ${type}4"
758 # vector with vector
759 gdb_test "ptype ${name}4a = ${name}4b" "type = ${type}4"
760 gdb_test "ptype ${name}4a += ${name}4b" "type = ${type}4"
761 gdb_test "ptype ${name}4a -= ${name}4b" "type = ${type}4"
762 gdb_test "ptype ${name}4b *= ${name}4a" "type = ${type}4"
763 gdb_test "ptype ${name}4b /= ${name}4a" "type = ${type}4"
764
765 if { !${isfloat} } {
766 # scalar with scalar
767 gdb_test "print/d ${name}a %= ${name}b" " = 0"
768 gdb_test "print/d ${name}a = 2" " = 2"
769 gdb_test "print/d ${name}a <<= ${name}b" " = 4"
770 gdb_test "print/d ${name}a = 2" " = 2"
771 gdb_test "print/d ${name}a >>= ${name}b" " = 1"
772 gdb_test "print/d ${name}a = 2" " = 2"
773 gdb_test "print/d ${name}a &= ${name}b" " = 0"
774 gdb_test "print/d ${name}a = 2" " = 2"
775 gdb_test "print/d ${name}a |= ${name}b" " = 3"
776 gdb_test "print/d ${name}a = 2" " = 2"
777 gdb_test "print/d ${name}a ^= ${name}b" " = 3"
778 gdb_test "print/d ${name}a = 2" " = 2"
779 # scalar with vector
780 gdb_test "print/d ${name}4b %= ${name}a" " = \\{1, 0, 0, 0\\}"
781 gdb_test "print/d ${name}4b = \{1, 2, 8, 4\}" " = \\{1, 2, 8, 4\\}"
782 gdb_test "print/d ${name}4a <<= ${name}b" " = \\{4, 8, 16, 32\\}"
783 gdb_test "print/d ${name}4a >>= ${name}b" " = \\{2, 4, 8, 16\\}"
784 gdb_test "print/d ${name}4a &= ${name}b" " = \\{0, 0, 0, 0\\}"
785 gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
786 gdb_test "print/d ${name}4a |= ${name}b" " = \\{3, 5, 9, 17\\}"
787 gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
788 gdb_test "print/d ${name}4a ^= ${name}b" " = \\{3, 5, 9, 17\\}"
789 gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
790 # vector with vector
791 gdb_test "print/d ${name}4b %= ${name}4a" " = \\{1, 2, 0, 4\\}"
792 gdb_test "print/d ${name}4b = \{1, 2, 8, 4\}" " = \\{1, 2, 8, 4\\}"
793 if { ${size} == 1 } {
794 gdb_test "print/d ${name}4a <<= ${name}4b" " = \\{4, 16, 0, 0\\}"
795 gdb_test "print/d ${name}4a >>= ${name}4b" " = \\{2, 4, 0, 0\\}"
796 gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
797 } else {
798 gdb_test "print/d ${name}4a <<= ${name}4b" " = \\{4, 16, 2048, 256\\}"
799 gdb_test "print/d ${name}4a >>= ${name}4b" " = \\{2, 4, 8, 16\\}"
800 }
801 gdb_test "print/d ${name}4a &= ${name}4b" " = \\{0, 0, 8, 0\\}"
802 gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
803 gdb_test "print/d ${name}4a |= ${name}4b" " = \\{3, 6, 8, 20\\}"
804 gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
805 gdb_test "print/d ${name}4a ^= ${name}4b" " = \\{3, 6, 0, 20\\}"
806 gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
807
808 # scalar with scalar
809 gdb_test "ptype ${name}a %= ${name}b" "type = ${type}"
810 gdb_test "ptype ${name}a <<= ${name}b" "type = ${type}"
811 gdb_test "ptype ${name}a >>= ${name}b" "type = ${type}"
812 gdb_test "ptype ${name}a &= ${name}b" "type = ${type}"
813 gdb_test "ptype ${name}a |= ${name}b" "type = ${type}"
814 gdb_test "ptype ${name}a ^= ${name}b" "type = ${type}"
815 # scalar with vector
816 gdb_test "ptype ${name}4a %= ${name}b" "type = ${type}4"
817 gdb_test "ptype ${name}4a <<= ${name}b" "type = ${type}4"
818 gdb_test "ptype ${name}4a >>= ${name}b" "type = ${type}4"
819 gdb_test "ptype ${name}4a &= ${name}b" "type = ${type}4"
820 gdb_test "ptype ${name}4a |= ${name}b" "type = ${type}4"
821 gdb_test "ptype ${name}4a ^= ${name}b" "type = ${type}4"
822 # vector with vector
823 gdb_test "ptype ${name}4a %= ${name}4b" "type = ${type}4"
824 gdb_test "ptype ${name}4a <<= ${name}4b" "type = ${type}4"
825 gdb_test "ptype ${name}4a >>= ${name}4b" "type = ${type}4"
826 gdb_test "ptype ${name}4a &= ${name}4b" "type = ${type}4"
827 gdb_test "ptype ${name}4a |= ${name}4b" "type = ${type}4"
828 gdb_test "ptype ${name}4a ^= ${name}4b" "type = ${type}4"
829
830 # scalar with scalar
831 gdb_test "print/d u${name}a = u${name}b" " = 1"
832 gdb_test "print/d u${name}a = 2" " = 2"
833 gdb_test "print/d u${name}a += u${name}b" " = 3"
834 gdb_test "print/d u${name}a -= u${name}b" " = 2"
835 gdb_test "print/d u${name}b *= u${name}a" " = 2"
836 gdb_test "print/d u${name}b /= u${name}a" " = 1"
837 gdb_test "print/d u${name}a %= u${name}b" " = 0"
838 gdb_test "print/d u${name}a = 2" " = 2"
839 gdb_test "print/d u${name}a <<= u${name}b" " = 4"
840 gdb_test "print/d u${name}a = 2" " = 2"
841 gdb_test "print/d u${name}a >>= u${name}b" " = 1"
842 gdb_test "print/d u${name}a = 2" " = 2"
843 gdb_test "print/d u${name}a &= u${name}b" " = 0"
844 gdb_test "print/d u${name}a = 2" " = 2"
845 gdb_test "print/d u${name}a |= u${name}b" " = 3"
846 gdb_test "print/d u${name}a = 2" " = 2"
847 gdb_test "print/d u${name}a ^= u${name}b" " = 3"
848 gdb_test "print/d u${name}a = 2" " = 2"
849 # scalar with vector
850 gdb_test "print/d u${name}4a = u${name}b" " = \\{1, 1, 1, 1\\}"
851 gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
852 gdb_test "print/d u${name}4a += u${name}b" " = \\{3, 5, 9, 17\\}"
853 gdb_test "print/d u${name}4a -= u${name}b" " = \\{2, 4, 8, 16\\}"
854 gdb_test "print/d u${name}4b *= u${name}a" " = \\{2, 4, 16, 8\\}"
855 gdb_test "print/d u${name}4b /= u${name}a" " = \\{1, 2, 8, 4\\}"
856 gdb_test "print/d u${name}4b %= u${name}a" " = \\{1, 0, 0, 0\\}"
857 gdb_test "print/d u${name}4b = \{1, 2, 8, 4\}" " = \\{1, 2, 8, 4\\}"
858 gdb_test "print/d u${name}4a <<= u${name}b" " = \\{4, 8, 16, 32\\}"
859 gdb_test "print/d u${name}4a >>= u${name}b" " = \\{2, 4, 8, 16\\}"
860 gdb_test "print/d u${name}4a &= u${name}b" " = \\{0, 0, 0, 0\\}"
861 gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
862 gdb_test "print/d u${name}4a |= u${name}b" " = \\{3, 5, 9, 17\\}"
863 gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
864 gdb_test "print/d u${name}4a ^= u${name}b" " = \\{3, 5, 9, 17\\}"
865 gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
866 # vector with vector
867 gdb_test "print/d u${name}4a = u${name}4b" " = \\{1, 2, 8, 4\\}"
868 gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
869 gdb_test "print/d u${name}4a += u${name}4b" " = \\{3, 6, 16, 20\\}"
870 gdb_test "print/d u${name}4a -= u${name}4b" " = \\{2, 4, 8, 16\\}"
871 gdb_test "print/d u${name}4b *= u${name}4a" " = \\{2, 8, 64, 64\\}"
872 gdb_test "print/d u${name}4b /= u${name}4a" " = \\{1, 2, 8, 4\\}"
873 gdb_test "print/d u${name}4b %= u${name}4a" " = \\{1, 2, 0, 4\\}"
874 gdb_test "print/d u${name}4b = \{1, 2, 8, 4\}" " = \\{1, 2, 8, 4\\}"
875 if { ${size} == 1 } {
876 gdb_test "print/d u${name}4a <<= u${name}4b" " = \\{4, 16, 0, 0\\}"
877 gdb_test "print/d u${name}4a >>= u${name}4b" " = \\{2, 4, 0, 0\\}"
878 gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
879 } else {
880 gdb_test "print/d u${name}4a <<= u${name}4b" " = \\{4, 16, 2048, 256\\}"
881 gdb_test "print/d u${name}4a >>= u${name}4b" " = \\{2, 4, 8, 16\\}"
882 }
883 gdb_test "print/d u${name}4a &= u${name}4b" " = \\{0, 0, 8, 0\\}"
884 gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
885 gdb_test "print/d u${name}4a |= u${name}4b" " = \\{3, 6, 8, 20\\}"
886 gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
887 gdb_test "print/d u${name}4a ^= u${name}4b" " = \\{3, 6, 0, 20\\}"
888 gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
889
890 # scalar with scalar
891 gdb_test "ptype u${name}a = u${name}b" "type = (unsigned ${type}|u${type})"
892 gdb_test "ptype u${name}a += u${name}b" "type = (unsigned ${type}|u${type})"
893 gdb_test "ptype u${name}a -= u${name}b" "type = (unsigned ${type}|u${type})"
894 gdb_test "ptype u${name}a *= u${name}b" "type = (unsigned ${type}|u${type})"
895 gdb_test "ptype u${name}a /= u${name}b" "type = (unsigned ${type}|u${type})"
896 gdb_test "ptype u${name}a %= u${name}b" "type = (unsigned ${type}|u${type})"
897 gdb_test "ptype u${name}a <<= u${name}b" "type = (unsigned ${type}|u${type})"
898 gdb_test "ptype u${name}a >>= u${name}b" "type = (unsigned ${type}|u${type})"
899 gdb_test "ptype u${name}a &= u${name}b" "type = (unsigned ${type}|u${type})"
900 gdb_test "ptype u${name}a |= u${name}b" "type = (unsigned ${type}|u${type})"
901 gdb_test "ptype u${name}a ^= u${name}b" "type = (unsigned ${type}|u${type})"
902 # scalar with vector
903 gdb_test "ptype u${name}4a = u${name}b" "type = u${type}4"
904 gdb_test "ptype u${name}4a += u${name}b" "type = u${type}4"
905 gdb_test "ptype u${name}4a -= u${name}b" "type = u${type}4"
906 gdb_test "ptype u${name}4b *= u${name}a" "type = u${type}4"
907 gdb_test "ptype u${name}4b /= u${name}a" "type = u${type}4"
908 gdb_test "ptype u${name}4a %= u${name}b" "type = u${type}4"
909 gdb_test "ptype u${name}4a <<= u${name}b" "type = u${type}4"
910 gdb_test "ptype u${name}4a >>= u${name}b" "type = u${type}4"
911 gdb_test "ptype u${name}4a &= u${name}b" "type = u${type}4"
912 gdb_test "ptype u${name}4a |= u${name}b" "type = u${type}4"
913 gdb_test "ptype u${name}4a ^= u${name}b" "type = u${type}4"
914 # vector with vector
915 gdb_test "ptype u${name}4a = u${name}4b" "type = u${type}4"
916 gdb_test "ptype u${name}4a += u${name}4b" "type = u${type}4"
917 gdb_test "ptype u${name}4a -= u${name}4b" "type = u${type}4"
918 gdb_test "ptype u${name}4b *= u${name}4a" "type = u${type}4"
919 gdb_test "ptype u${name}4b /= u${name}4a" "type = u${type}4"
920 gdb_test "ptype u${name}4a %= u${name}4b" "type = u${type}4"
921 gdb_test "ptype u${name}4a <<= u${name}4b" "type = u${type}4"
922 gdb_test "ptype u${name}4a >>= u${name}4b" "type = u${type}4"
923 gdb_test "ptype u${name}4a &= u${name}4b" "type = u${type}4"
924 gdb_test "ptype u${name}4a |= u${name}4b" "type = u${type}4"
925 gdb_test "ptype u${name}4a ^= u${name}4b" "type = u${type}4"
926 }
927 }
928
929 proc do_check { name type isfloat size } {
930 check_basic ${name} ${type} ${isfloat}
931 check_arithmetic_ops ${name} ${type} ${isfloat} ${size}
932 check_relational_ops ${name} ${type} ${isfloat} ${size}
933 check_equality_ops ${name} ${type} ${isfloat} ${size}
934 if { !${isfloat} } {
935 check_shift_ops ${name} ${type} ${size}
936 check_bitwise_ops ${name} ${type} ${size}
937 }
938 check_logical_ops ${name} ${type} ${isfloat} ${size}
939 check_conditional_op ${name} ${type} ${isfloat}
940 check_assignment_ops ${name} ${type} ${isfloat} ${size}
941 }
942
943 do_check "c" "char" 0 1
944 do_check "s" "short" 0 2
945 do_check "i" "int" 0 4
946 do_check "l" "long" 0 8
947 if { ${have_cl_khr_fp16} } {
948 do_check "h" "half" 1 2
949 }
950 do_check "f" "float" 1 4
951 if { ${have_cl_khr_fp64} } {
952 do_check "d" "double" 1 8
953 }
954 # Delete the OpenCL program source
955 remote_file target delete ${clprogram}
This page took 0.059158 seconds and 4 git commands to generate.