Rename gdb/ChangeLog to gdb/ChangeLog-2021
[binutils-gdb.git] / gdb / testsuite / gdb.opencl / operators.exp
blobeea44659ebb01f686de94d886ef80bfaa93a301e
1 # Copyright 2010-2021 Free Software Foundation, Inc.
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.
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.
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/>. */
16 # Contributed by Ken Werner <ken.werner@de.ibm.com>.
18 # Tests GDBs support for OpenCL operators.
20 load_lib opencl.exp
22 if { [skip_opencl_tests] } {
23 unsupported "OpenCL support not detected"
24 return 0
27 set testfile "operators"
28 set clprogram [remote_download target ${srcdir}/${subdir}/${testfile}.cl]
30 # Compile the generic OpenCL host app
31 if { [gdb_compile_opencl_hostapp "${clprogram}" "${testfile}" "" ] != "" } {
32 untested "failed to compile"
33 return -1
36 # Load the OpenCL app
37 clean_restart ${testfile}
39 # Set breakpoint at the OpenCL kernel
40 gdb_test "tbreak testkernel" \
41 "" \
42 "Set pending breakpoint" \
43 ".*Function \"testkernel\" not defined.*Make breakpoint pending.*y or \\\[n\\\]. $" \
44 "y"
46 gdb_run_cmd
47 gdb_test "" ".*reakpoint.*1.*testkernel.*" "run"
49 # Continue to the marker
50 gdb_breakpoint [gdb_get_line_number "marker" "${clprogram}"]
51 gdb_continue_to_breakpoint "marker"
53 # Retrieve some information about availability of OpenCL extensions
54 set have_cl_khr_fp64 [get_integer_valueof "have_cl_khr_fp64" 0]
55 set have_cl_khr_fp16 [get_integer_valueof "have_cl_khr_fp16" 0]
57 proc check_basic { name type isfloat } {
58 gdb_test "print/d ${name}a" " = 2"
59 gdb_test "print/d ${name}b" " = 1"
60 gdb_test "print/d ${name}4a" " = \\{2, 4, 8, 16\\}"
61 gdb_test "print/d ${name}4b" " = \\{1, 2, 8, 4\\}"
63 gdb_test "ptype ${name}a" "type = ${type}"
64 gdb_test "ptype ${name}b" "type = ${type}"
65 gdb_test "ptype ${name}4a" "type = ${type}4"
66 gdb_test "ptype ${name}4b" "type = ${type}4"
68 if { ! ${isfloat} } {
69 gdb_test "print/d u${name}a" " = 2"
70 gdb_test "print/d u${name}b" " = 1"
71 gdb_test "print/d u${name}4a" " = \\{2, 4, 8, 16\\}"
72 gdb_test "print/d u${name}4b" " = \\{1, 2, 8, 4\\}"
73 gdb_test "ptype u${name}a" "type = (unsigned ${type}|u${type})"
74 gdb_test "ptype u${name}b" "type = (unsigned ${type}|u${type})"
75 gdb_test "ptype u${name}4a" "type = u${type}4"
76 gdb_test "ptype u${name}4b" "type = u${type}4"
80 # Arithmetic operators
81 proc check_arithmetic_ops { name type isfloat size } {
82 # scalar with scalar
83 gdb_test "print/d ${name}a + ${name}b" " = 3"
84 gdb_test "print/d ${name}a - ${name}b" " = 1"
85 gdb_test "print/d ${name}a * ${name}b" " = 2"
86 gdb_test "print/d ${name}a / ${name}b" " = 2"
87 # scalar with vector
88 gdb_test "print/d ${name}a + ${name}4b" " = \\{3, 4, 10, 6\\}"
89 gdb_test "print/d ${name}4a - ${name}b" " = \\{1, 3, 7, 15\\}"
90 gdb_test "print/d ${name}4a * ${name}b" " = \\{2, 4, 8, 16\\}"
91 gdb_test "print/d ${name}a / ${name}4b" " = \\{2, 1, 0, 0\\}"
92 # vector with vector
93 gdb_test "print/d ${name}4a + ${name}4b" " = \\{3, 6, 16, 20\\}"
94 gdb_test "print/d ${name}4a - ${name}4b" " = \\{1, 2, 0, 12\\}"
95 gdb_test "print/d ${name}4a * ${name}4b" " = \\{2, 8, 64, 64\\}"
96 gdb_test "print/d ${name}4a / ${name}4b" " = \\{2, 2, 1, 4\\}"
98 # scalar
99 gdb_test "print/d ${name}a++" " = 2"
100 gdb_test "print/d ++${name}a" " = 4"
101 gdb_test "print/d ${name}a--" " = 4"
102 gdb_test "print/d --${name}a" " = 2"
103 gdb_test "print/d +${name}a" " = 2"
104 gdb_test "print/d -${name}a" " = -2"
105 # vector
106 gdb_test "print/d ${name}4a++" " = \\{2, 4, 8, 16\\}"
107 gdb_test "print/d ++${name}4a" " = \\{4, 6, 10, 18\\}"
108 gdb_test "print/d ${name}4a--" " = \\{4, 6, 10, 18\\}"
109 gdb_test "print/d --${name}4a" " = \\{2, 4, 8, 16\\}"
110 gdb_test "print/d +${name}4a" " = \\{2, 4, 8, 16\\}"
111 gdb_test "print/d -${name}4a" " = \\{-2, -4, -8, -16\\}"
113 # scalar with vector
114 gdb_test "ptype ${name}a + ${name}4b" "type = ${type}4"
115 gdb_test "ptype ${name}4a - ${name}b" "type = ${type}4"
116 gdb_test "ptype ${name}a * ${name}4b" "type = ${type}4"
117 gdb_test "ptype ${name}4a / ${name}b" "type = ${type}4"
118 # vector with vector
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 gdb_test "ptype ${name}4a / ${name}4b" "type = ${type}4"
124 # scalar
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 gdb_test "ptype --${name}a" "type = ${type}"
129 # vector
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 gdb_test "ptype -${name}4a" "type = ${type}4"
137 if { ${isfloat} } {
138 # scalar with scalar
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 gdb_test "ptype ${name}a / ${name}b" "type = ${type}"
143 # scalar
144 gdb_test "ptype +${name}a" "type = ${type}"
145 gdb_test "ptype -${name}a" "type = ${type}"
146 } else {
147 # scalar with scalar
148 gdb_test "print/d ${name}a % ${name}b" " = 0"
149 # scalar with vector
150 gdb_test "print/d ${name}4a % ${name}b" " = \\{0, 0, 0, 0\\}"
151 # vector with vector
152 gdb_test "print/d ${name}4a % ${name}b" " = \\{0, 0, 0, 0\\}"
154 # scalar with scalar
155 gdb_test "print/d u${name}a + u${name}b" " = 3"
156 gdb_test "print/d u${name}a - u${name}b" " = 1"
157 gdb_test "print/d u${name}a * u${name}b" " = 2"
158 gdb_test "print/d u${name}a / u${name}b" " = 2"
159 gdb_test "print/d u${name}a % u${name}b" " = 0"
160 # scalar with vector
161 gdb_test "print/d u${name}a + u${name}4b" " = \\{3, 4, 10, 6\\}"
162 gdb_test "print/d u${name}4a - u${name}b" " = \\{1, 3, 7, 15\\}"
163 gdb_test "print/d u${name}4a * u${name}b" " = \\{2, 4, 8, 16\\}"
164 gdb_test "print/d u${name}a / u${name}4b" " = \\{2, 1, 0, 0\\}"
165 gdb_test "print/d u${name}4a % u${name}b" " = \\{0, 0, 0, 0\\}"
166 # vector with vector
167 gdb_test "print/d u${name}4a + u${name}4b" " = \\{3, 6, 16, 20\\}"
168 gdb_test "print/d u${name}4a - u${name}4b" " = \\{1, 2, 0, 12\\}"
169 gdb_test "print/d u${name}4a * u${name}4b" " = \\{2, 8, 64, 64\\}"
170 gdb_test "print/d u${name}4a / u${name}4b" " = \\{2, 2, 1, 4\\}"
171 gdb_test "print/d u${name}4a % u${name}4b" " = \\{0, 0, 0, 0\\}"
173 # scalar
174 gdb_test "print/d u${name}a++" " = 2"
175 gdb_test "print/d ++u${name}a" " = 4"
176 gdb_test "print/d u${name}a--" " = 4"
177 gdb_test "print/d --u${name}a" " = 2"
178 gdb_test "print/d +u${name}a" " = 2"
179 gdb_test "print/x -u${name}a" " = 0x.*fe"
180 # vector
181 gdb_test "print/d u${name}4a++" " = \\{2, 4, 8, 16\\}"
182 gdb_test "print/d ++u${name}4a" " = \\{4, 6, 10, 18\\}"
183 gdb_test "print/d u${name}4a--" " = \\{4, 6, 10, 18\\}"
184 gdb_test "print/d --u${name}4a" " = \\{2, 4, 8, 16\\}"
185 gdb_test "print/d +u${name}4a" " = \\{2, 4, 8, 16\\}"
186 gdb_test "print/x -u${name}4a" " = \\{0x.*fe, 0x.*fc, 0x.*f8, 0x.*f0\\}"
188 # scalar with scalar
189 if { ${size} < 4 } {
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 % ${name}b" "type = int"
195 gdb_test "ptype +${name}a" "type = int"
196 gdb_test "ptype -${name}a" "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 % u${name}b" "type = int"
202 gdb_test "ptype +u${name}a" "type = int"
203 gdb_test "ptype -u${name}a" "type = int"
204 } elseif { ${size} == 4 } {
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 % ${name}b" "type = int"
210 gdb_test "ptype +${name}a" "type = int"
211 gdb_test "ptype -${name}a" "type = int"
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 % u${name}b" "type = (unsigned int|uint)"
217 gdb_test "ptype +u${name}a" "type = (unsigned int|uint)"
218 gdb_test "ptype -u${name}a" "type = (unsigned int|uint)"
219 } else { # ${size} == 8
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 % ${name}b" "type = long"
225 gdb_test "ptype +${name}a" "type = long"
226 gdb_test "ptype -${name}a" "type = long"
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 gdb_test "ptype u${name}a % u${name}b" "type = (unsigned long|ulong)"
232 # scalar
233 gdb_test "ptype +u${name}a" "type = (unsigned long|ulong)"
234 gdb_test "ptype -u${name}a" "type = (unsigned long|ulong)"
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 gdb_test "ptype --u${name}a" "type = (unsigned ${type}|u${type})"
240 # scalar with vector
241 gdb_test "ptype ${name}a % ${name}4b" "type = ${type}4"
242 gdb_test "ptype u${name}a + u${name}4b" "type = u${type}4"
243 gdb_test "ptype u${name}4a - u${name}b" "type = u${type}4"
244 gdb_test "ptype u${name}a * u${name}4b" "type = u${type}4"
245 gdb_test "ptype u${name}4a / u${name}b" "type = u${type}4"
246 gdb_test "ptype u${name}a % u${name}4b" "type = u${type}4"
247 # vector with vector
248 gdb_test "ptype ${name}4a % ${name}4b" "type = ${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 % u${name}4b" "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 gdb_test "ptype -u${name}4a" "type = u${type}4"
263 # Relational operators
264 proc check_relational_ops { name type isfloat size } {
265 # scalar with scalar
266 gdb_test "print/d ${name}a > ${name}b" " = 1"
267 gdb_test "print/d ${name}b < ${name}a" " = 1"
268 gdb_test "print/d ${name}b >= ${name}a" " = 0"
269 gdb_test "print/d ${name}a <= ${name}b" " = 0"
270 # scalar with vector
271 gdb_test "print/d ${name}4a > ${name}b" " = \\{-1, -1, -1, -1\\}"
272 gdb_test "print/d ${name}a < ${name}4b" " = \\{0, 0, -1, -1\\}"
273 gdb_test "print/d ${name}4a >= ${name}b" " = \\{-1, -1, -1, -1\\}"
274 gdb_test "print/d ${name}a <= ${name}4b" " = \\{0, -1, -1, -1\\}"
275 # vector with vector
276 gdb_test "print/d ${name}4a > ${name}4b" " = \\{-1, -1, 0, -1\\}"
277 gdb_test "print/d ${name}4b < ${name}4a" " = \\{-1, -1, 0, -1\\}"
278 gdb_test "print/d ${name}4b >= ${name}4a" " = \\{0, 0, -1, 0\\}"
279 gdb_test "print/d ${name}4a <= ${name}4b" " = \\{0, 0, -1, 0\\}"
281 # result type should be int for scalars
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 gdb_test "ptype ${name}a >= ${name}b" "type = int"
287 if { ${isfloat} } {
288 if { ${size} == 2 } {
289 # result type should be short for half precision floating point vectors
290 # scalar with vector
291 gdb_test "ptype ${name}4a > ${name}b" "type = short4"
292 gdb_test "ptype ${name}a < ${name}4b" "type = short4"
293 gdb_test "ptype ${name}4a >= ${name}b" "type = short4"
294 gdb_test "ptype ${name}a <= ${name}4b" "type = short4"
295 # vector with vector
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 gdb_test "ptype ${name}4a <= ${name}4b" "type = short4"
300 } elseif { ${size} == 4 } {
301 # result type should be int for single precision floating point vectors
302 # scalar with vector
303 gdb_test "ptype ${name}4a > ${name}b" "type = int4"
304 gdb_test "ptype ${name}a < ${name}4b" "type = int4"
305 gdb_test "ptype ${name}4a >= ${name}b" "type = int4"
306 gdb_test "ptype ${name}a <= ${name}4b" "type = int4"
307 # vector with vector
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 gdb_test "ptype ${name}4a <= ${name}4b" "type = int4"
312 } else { # ${size} == 8
313 # result type should be long for double precision floating point vectors
314 # scalar with vector
315 gdb_test "ptype ${name}4a > ${name}b" "type = long4"
316 gdb_test "ptype ${name}a < ${name}4b" "type = long4"
317 gdb_test "ptype ${name}4a >= ${name}b" "type = long4"
318 gdb_test "ptype ${name}a <= ${name}4b" "type = long4"
319 # vector with vector
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 gdb_test "ptype ${name}4a <= ${name}4b" "type = long4"
325 } else {
326 # scalar with scalar
327 gdb_test "print/d u${name}a > u${name}b" " = 1"
328 gdb_test "print/d u${name}b < u${name}a" " = 1"
329 gdb_test "print/d u${name}b >= u${name}a" " = 0"
330 gdb_test "print/d u${name}a <= u${name}b" " = 0"
331 # scalar with vector
332 gdb_test "print/d u${name}4a > u${name}b" " = \\{-1, -1, -1, -1\\}"
333 gdb_test "print/d u${name}a < u${name}4b" " = \\{0, 0, -1, -1\\}"
334 gdb_test "print/d u${name}4a >= u${name}b" " = \\{-1, -1, -1, -1\\}"
335 gdb_test "print/d u${name}a <= u${name}4b" " = \\{0, -1, -1, -1\\}"
336 # vector with vector
337 gdb_test "print/d u${name}4a > u${name}4b" " = \\{-1, -1, 0, -1\\}"
338 gdb_test "print/d u${name}4b < u${name}4a" " = \\{-1, -1, 0, -1\\}"
339 gdb_test "print/d u${name}4b >= u${name}4a" " = \\{0, 0, -1, 0\\}"
340 gdb_test "print/d u${name}4a <= u${name}4b" " = \\{0, 0, -1, 0\\}"
342 # result type for unsigned operands is signed
343 # scalar with scalar
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 gdb_test "ptype u${name}a >= u${name}b" "type = int"
348 # scalar with vector
349 gdb_test "ptype u${name}4a > u${name}b" "type = ${type}4"
350 gdb_test "ptype u${name}a < u${name}4b" "type = ${type}4"
351 gdb_test "ptype u${name}4a >= u${name}b" "type = ${type}4"
352 gdb_test "ptype u${name}a <= u${name}4b" "type = ${type}4"
353 # vector with vector
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 gdb_test "ptype u${name}4a <= u${name}4b" "type = ${type}4"
361 # Equality operators
362 proc check_equality_ops { name type isfloat size } {
363 # scalar with scalar
364 gdb_test "print/d ${name}a == ${name}b" " = 0"
365 gdb_test "print/d ${name}a != ${name}b" " = 1"
366 # scalar with vector
367 gdb_test "print/d ${name}4a == ${name}b" " = \\{0, 0, 0, 0\\}"
368 gdb_test "print/d ${name}a != ${name}4b" " = \\{-1, 0, -1, -1\\}"
369 # vector with vector
370 gdb_test "print/d ${name}4a == ${name}4b" " = \\{0, 0, -1, 0\\}"
371 gdb_test "print/d ${name}4a != ${name}4b" " = \\{-1, -1, 0, -1\\}"
373 # scalar with scalar
374 gdb_test "ptype ${name}a == ${name}b" "type = int"
375 gdb_test "ptype ${name}a != ${name}b" "type = int"
377 if { ${isfloat} } {
378 if { ${size} == 2 } {
379 # result type should be short for half precision floating point vectors
380 # scalar with vector
381 gdb_test "ptype ${name}4a == ${name}b" "type = short4"
382 gdb_test "ptype ${name}a != ${name}4b" "type = short4"
383 # vector with vector
384 gdb_test "ptype ${name}4a == ${name}4b" "type = short4"
385 gdb_test "ptype ${name}4a != ${name}4b" "type = short4"
386 } elseif { ${size} == 4 } {
387 # result type should be int for single precision floating point vectors
388 # scalar with vector
389 gdb_test "ptype ${name}4a == ${name}b" "type = int4"
390 gdb_test "ptype ${name}a != ${name}4b" "type = int4"
391 # vector with vector
392 gdb_test "ptype ${name}4a == ${name}4b" "type = int4"
393 gdb_test "ptype ${name}4a != ${name}4b" "type = int4"
394 } else { # ${size} == 8
395 # result type should be long for double precision floating point vectors
396 # scalar with vector
397 gdb_test "ptype ${name}4a == ${name}b" "type = long4"
398 gdb_test "ptype ${name}a != ${name}4b" "type = long4"
399 # vector with vector
400 gdb_test "ptype ${name}4a == ${name}4b" "type = long4"
401 gdb_test "ptype ${name}4a != ${name}4b" "type = long4"
403 } else {
404 # scalar with scalar
405 gdb_test "print/d u${name}a == u${name}b" " = 0"
406 gdb_test "print/d u${name}a != u${name}b" " = 1"
407 # scalar with vector
408 gdb_test "print/d u${name}4a == u${name}b" " = \\{0, 0, 0, 0\\}"
409 gdb_test "print/d u${name}a != u${name}4b" " = \\{-1, 0, -1, -1\\}"
410 # vector with vector
411 gdb_test "print/d u${name}4a == u${name}4b" " = \\{0, 0, -1, 0\\}"
412 gdb_test "print/d u${name}4b != u${name}4a" " = \\{-1, -1, 0, -1\\}"
414 # result type for unsigned operands is signed
415 # scalar with scalar
416 gdb_test "ptype u${name}a == u${name}b" "type = int"
417 gdb_test "ptype u${name}a != u${name}b" "type = int"
418 # scalar with vector
419 gdb_test "ptype u${name}4a == u${name}b" "type = ${type}4"
420 gdb_test "ptype u${name}a != u${name}4b" "type = ${type}4"
421 # vector with vector
422 gdb_test "ptype u${name}4a == u${name}4b" "type = ${type}4"
423 gdb_test "ptype u${name}4a != u${name}4b" "type = ${type}4"
427 # Shift operators
428 proc check_shift_ops { name type size } {
429 # scalar with scalar
430 gdb_test "print/d ${name}a << ${name}b" " = 4"
431 gdb_test "print/d ${name}a >> ${name}b" " = 1"
432 gdb_test "print/d u${name}a << u${name}b" " = 4"
433 gdb_test "print/d u${name}a >> u${name}b" " = 1"
434 # scalar with vector
435 gdb_test "print/d ${name}4a << ${name}b" " = \\{4, 8, 16, 32\\}"
436 gdb_test "print/d ${name}4a >> ${name}b" " = \\{1, 2, 4, 8\\}"
437 gdb_test "print/d u${name}4a << u${name}b" " = \\{4, 8, 16, 32\\}"
438 gdb_test "print/d u${name}4a >> u${name}b" " = \\{1, 2, 4, 8\\}"
439 # vector with vector
440 if { ${size} == 1 } {
441 gdb_test "print/d ${name}4a << ${name}4b" " = \\{4, 16, 0, 0\\}"
442 gdb_test "print/d u${name}4a << u${name}4b" " = \\{4, 16, 0, 0\\}"
443 } else {
444 gdb_test "print/d ${name}4a << ${name}4b" " = \\{4, 16, 2048, 256\\}"
445 gdb_test "print/d u${name}4a << u${name}4b" " = \\{4, 16, 2048, 256\\}"
447 gdb_test "print/d ${name}4a >> ${name}4b" " = \\{1, 1, 0, 1\\}"
448 gdb_test "print/d u${name}4a >> u${name}4b" " = \\{1, 1, 0, 1\\}"
450 # scalar with scalar
451 if { ${size} < 4 } {
452 gdb_test "ptype ${name}a << ${name}b" "type = int"
453 gdb_test "ptype ${name}a >> ${name}b" "type = int"
454 gdb_test "ptype u${name}a << u${name}b" "type = int"
455 gdb_test "ptype u${name}a >> u${name}b" "type = int"
456 } elseif { ${size} == 4 } {
457 gdb_test "ptype ${name}a << ${name}b" "type = int"
458 gdb_test "ptype ${name}a >> ${name}b" "type = int"
459 gdb_test "ptype u${name}a << u${name}b" "type = (unsigned int|uint)"
460 gdb_test "ptype u${name}a >> u${name}b" "type = (unsigned int|uint)"
461 } else { # ${size} == 8
462 gdb_test "ptype ${name}a << ${name}b" "type = long"
463 gdb_test "ptype ${name}a >> ${name}b" "type = long"
464 gdb_test "ptype u${name}a << u${name}b" "type = (unsigned long|ulong)"
465 gdb_test "ptype u${name}a >> u${name}b" "type = (unsigned long|ulong)"
467 # scalar with vector
468 gdb_test "ptype ${name}4a << ${name}b" "type = ${type}4"
469 gdb_test "ptype ${name}4a >> ${name}b" "type = ${type}4"
470 gdb_test "ptype u${name}4a << u${name}b" "type = u${type}4"
471 gdb_test "ptype u${name}4a >> u${name}b" "type = u${type}4"
472 # vector with vector
473 gdb_test "ptype ${name}4a << ${name}4b" "type = ${type}4"
474 gdb_test "ptype ${name}4a >> ${name}4b" "type = ${type}4"
475 gdb_test "ptype u${name}4a << u${name}4b" "type = u${type}4"
476 gdb_test "ptype u${name}4a >> u${name}4b" "type = u${type}4"
479 # Bitwise operators
480 proc check_bitwise_ops { name type size } {
481 # scalar with scalar
482 gdb_test "print/d ${name}a & ${name}b" " = 0"
483 gdb_test "print/d ${name}a | ${name}b" " = 3"
484 gdb_test "print/d ${name}a ^ ${name}b" " = 3"
485 gdb_test "print/d u${name}a & u${name}b" " = 0"
486 gdb_test "print/d u${name}a | u${name}b" " = 3"
487 gdb_test "print/d u${name}a ^ u${name}b" " = 3"
488 # scalar with vector
489 gdb_test "print/d ${name}4a & ${name}b" " = \\{0, 0, 0, 0\\}"
490 gdb_test "print/d ${name}a | ${name}4b" " = \\{3, 2, 10, 6\\}"
491 gdb_test "print/d ${name}4a ^ ${name}b" " = \\{3, 5, 9, 17\\}"
492 gdb_test "print/d u${name}4a & u${name}b" " = \\{0, 0, 0, 0\\}"
493 gdb_test "print/d u${name}a | u${name}4b" " = \\{3, 2, 10, 6\\}"
494 gdb_test "print/d u${name}4a ^ u${name}b" " = \\{3, 5, 9, 17\\}"
495 # vector with vector
496 gdb_test "print/d ${name}4a & ${name}4b" " = \\{0, 0, 8, 0\\}"
497 gdb_test "print/d ${name}4a | ${name}4b" " = \\{3, 6, 8, 20\\}"
498 gdb_test "print/d ${name}4a ^ ${name}4b" " = \\{3, 6, 0, 20\\}"
499 gdb_test "print/d u${name}4a & u${name}4b" " = \\{0, 0, 8, 0\\}"
500 gdb_test "print/d u${name}4a | u${name}4b" " = \\{3, 6, 8, 20\\}"
501 gdb_test "print/d u${name}4a ^ u${name}4b" " = \\{3, 6, 0, 20\\}"
503 # scalar with scalar
504 if { ${size} < 4 } {
505 gdb_test "ptype ${name}a & ${name}b" "type = int"
506 gdb_test "ptype ${name}a | ${name}b" "type = int"
507 gdb_test "ptype ${name}a ^ ${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 gdb_test "ptype u${name}a ^ u${name}b" "type = int"
511 } elseif { ${size} == 4 } {
512 gdb_test "ptype ${name}a & ${name}b" "type = int"
513 gdb_test "ptype ${name}a | ${name}b" "type = int"
514 gdb_test "ptype ${name}a ^ ${name}b" "type = int"
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 gdb_test "ptype u${name}a ^ u${name}b" "type = (unsigned int|uint)"
518 } else { # ${size} == 8
519 gdb_test "ptype ${name}a & ${name}b" "type = long"
520 gdb_test "ptype ${name}a | ${name}b" "type = long"
521 gdb_test "ptype ${name}a ^ ${name}b" "type = long"
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 gdb_test "ptype u${name}a ^ u${name}b" "type = (unsigned long|ulong)"
526 # scalar with vector
527 gdb_test "ptype ${name}4a & ${name}b" "type = ${type}4"
528 gdb_test "ptype ${name}a | ${name}4b" "type = ${type}4"
529 gdb_test "ptype ${name}4a ^ ${name}b" "type = ${type}4"
530 gdb_test "ptype u${name}4a & u${name}b" "type = u${type}4"
531 gdb_test "ptype u${name}a | u${name}4b" "type = u${type}4"
532 gdb_test "ptype u${name}4a ^ u${name}b" "type = u${type}4"
533 # vector with vector
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 ${name}4a ^ ${name}4b" "type = ${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 gdb_test "ptype u${name}4a ^ u${name}4b" "type = u${type}4"
541 # scalar
542 if { ${size} < 8 } {
543 gdb_test "print/x ~${name}a" " = 0xfffffffd"
544 gdb_test "print/x ~u${name}a" " = 0xfffffffd"
545 } else {
546 gdb_test "print/x ~${name}a" " = 0xfffffffffffffffd"
547 gdb_test "print/x ~u${name}a" " = 0xfffffffffffffffd"
549 # vector
550 if { ${size} == 1 } {
551 gdb_test "print/x ~${name}4a" " = \\{0xfd, 0xfb, 0xf7, 0xef\\}"
552 gdb_test "print/x ~u${name}4a" " = \\{0xfd, 0xfb, 0xf7, 0xef\\}"
553 } elseif { ${size} == 2 } {
554 gdb_test "print/x ~${name}4a" " = \\{0xfffd, 0xfffb, 0xfff7, 0xffef\\}"
555 gdb_test "print/x ~u${name}4a" " = \\{0xfffd, 0xfffb, 0xfff7, 0xffef\\}"
556 } elseif { ${size} == 4 } {
557 gdb_test "print/x ~${name}4a" " = \\{0xfffffffd, 0xfffffffb, 0xfffffff7, 0xffffffef\\}"
558 gdb_test "print/x ~u${name}4a" " = \\{0xfffffffd, 0xfffffffb, 0xfffffff7, 0xffffffef\\}"
559 } else { # ${size} == 8
560 gdb_test "print/x ~${name}4a" " = \\{0xfffffffffffffffd, 0xfffffffffffffffb, 0xfffffffffffffff7, 0xffffffffffffffef\\}"
561 gdb_test "print/x ~u${name}4a" " = \\{0xfffffffffffffffd, 0xfffffffffffffffb, 0xfffffffffffffff7, 0xffffffffffffffef\\}"
563 # scalar
564 if { ${size} < 4 } {
565 gdb_test "ptype ~${name}a" "type = int"
566 gdb_test "ptype ~u${name}a" "type = int"
567 } elseif { ${size} == 4 } {
568 gdb_test "ptype ~${name}a" "type = int"
569 gdb_test "ptype ~u${name}a" "type = (unsigned int|uint)"
570 } else { # ${size} == 8
571 gdb_test "ptype ~${name}a" "type = long"
572 gdb_test "ptype ~u${name}a" "type = (unsigned long|ulong)"
574 # vector
575 gdb_test "ptype ~${name}4a" "type = ${type}4"
576 gdb_test "ptype ~u${name}4a" "type = u${type}4"
579 # Logical operators
580 proc check_logical_ops { name type isfloat size } {
581 # scalar
582 gdb_test "print/d !${name}a " " = 0"
583 gdb_test "print/d !!${name}a " " = 1"
584 # vector
585 gdb_test "print/d !${name}4a " " = \\{0, 0, 0, 0\\}"
586 gdb_test "print/d !!${name}4a " " = \\{-1, -1, -1, -1\\}"
588 # scalar with scalar
589 gdb_test "print/d ${name}a && ${name}b" " = 1"
590 gdb_test "print/d ${name}a && !${name}b" " = 0"
591 gdb_test "print/d ${name}a || ${name}b" " = 1"
592 gdb_test "print/d ${name}a || !${name}b" " = 1"
593 gdb_test "print/d !${name}a || !${name}b" " = 0"
595 # scalar with vector
596 gdb_test "print/d ${name}4a && ${name}b" " = \\{-1, -1, -1, -1\\}"
597 gdb_test "print/d ${name}4a && !${name}b" " = \\{0, 0, 0, 0\\}"
598 gdb_test "print/d ${name}a || ${name}4b" " = \\{-1, -1, -1, -1\\}"
599 gdb_test "print/d ${name}a || !${name}4b" " = \\{-1, -1, -1, -1\\}"
600 gdb_test "print/d !${name}4a || !${name}b" " = \\{0, 0, 0, 0\\}"
601 # vector with vector
602 gdb_test "print/d ${name}4a && ${name}4b" " = \\{-1, -1, -1, -1\\}"
603 gdb_test "print/d ${name}4a || ${name}4b" " = \\{-1, -1, -1, -1\\}"
605 # result type should be int for scalars
606 gdb_test "ptype !${name}a" "type = int"
607 gdb_test "ptype ${name}a && ${name}b" "type = int"
608 gdb_test "ptype ${name}a || ${name}b" "type = int"
610 if { ${isfloat} } {
611 if { ${size} == 2 } {
612 # result type should be short for half precision floating point vectors
613 # scalar with vector
614 gdb_test "ptype ${name}4a && ${name}b" "type = short4"
615 gdb_test "ptype ${name}a || ${name}4b" "type = short4"
616 # vector with vector
617 gdb_test "ptype !${name}4a" "type = short4"
618 gdb_test "ptype ${name}4a && ${name}4b" "type = short4"
619 gdb_test "ptype ${name}4a || ${name}4b" "type = short4"
620 } elseif { ${size} == 4 } {
621 # result type should be int for single precision floating point vectors
622 # scalar with vector
623 gdb_test "ptype ${name}4a && ${name}b" "type = int4"
624 gdb_test "ptype ${name}a || ${name}4b" "type = int4"
625 # vector with vector
626 gdb_test "ptype !${name}4a" "type = int4"
627 gdb_test "ptype ${name}4a && ${name}4b" "type = int4"
628 gdb_test "ptype ${name}4a || ${name}4b" "type = int4"
629 } else { # ${size} == 8
630 # result type should be long for double precision floating point vectors
631 # scalar with vector
632 gdb_test "ptype ${name}4a && ${name}b" "type = long4"
633 gdb_test "ptype ${name}a || ${name}4b" "type = long4"
634 # vector with vector
635 gdb_test "ptype !${name}4a" "type = long4"
636 gdb_test "ptype ${name}4a && ${name}4b" "type = long4"
637 gdb_test "ptype ${name}4a || ${name}4b" "type = long4"
639 } else {
640 # unsigned scalar
641 gdb_test "print/d !u${name}a " " = 0"
642 gdb_test "print/d !!u${name}a " " = 1"
643 # unsigned vector
644 gdb_test "print/d !u${name}4a " " = \\{0, 0, 0, 0\\}"
645 gdb_test "print/d !!u${name}4a " " = \\{-1, -1, -1, -1\\}"
647 # scalar with scalar
648 gdb_test "print/d u${name}a && u${name}b" " = 1"
649 gdb_test "print/d u${name}a || u${name}b" " = 1"
650 # scalar with vector
651 gdb_test "print/d u${name}4a && u${name}b" " = \\{-1, -1, -1, -1\\}"
652 gdb_test "print/d u${name}a || u${name}4b" " = \\{-1, -1, -1, -1\\}"
653 # vector with vector
654 gdb_test "print/d u${name}4a && u${name}4b" " = \\{-1, -1, -1, -1\\}"
655 gdb_test "print/d u${name}4a || u${name}4b" " = \\{-1, -1, -1, -1\\}"
657 # scalar
658 gdb_test "ptype !u${name}a" "type = int"
659 # vector
660 gdb_test "ptype !${name}4a" "type = ${type}4"
661 gdb_test "ptype !u${name}4a" "type = ${type}4"
663 # scalar with vector
664 gdb_test "ptype ${name}4a && ${name}b" "type = ${type}4"
665 gdb_test "ptype ${name}a || ${name}4b" "type = ${type}4"
666 # result type for unsigned vector operand is signed
667 gdb_test "ptype u${name}4a && u${name}b" "type = ${type}4"
668 gdb_test "ptype u${name}a || u${name}4b" "type = ${type}4"
669 # vector with vector
670 gdb_test "ptype ${name}4a && ${name}4b" "type = ${type}4"
671 gdb_test "ptype ${name}4a || ${name}4b" "type = ${type}4"
672 # result type for unsigned vector operand is signed
673 gdb_test "ptype u${name}4a && u${name}4b" "type = ${type}4"
674 gdb_test "ptype u${name}4a || u${name}4b" "type = ${type}4"
678 # Conditional operator
679 proc check_conditional_op { name type isfloat } {
680 # scalar with scalar
681 gdb_test "print/d ${name}a ? ${name}b : ${name}a" " = 1"
682 gdb_test "print/d !${name}a ? ${name}b : ${name}a" " = 2"
683 # scalar with vector
684 gdb_test "print/d ${name}4a ? ${name}4b : ${name}a" " = \\{1, 2, 8, 4\\}"
685 gdb_test "print/d ${name}4a ? ${name}b : ${name}4a" " = \\{1, 1, 1, 1\\}"
686 gdb_test "print/d ${name}4a > 4 ? 1 : ${name}4a" " = \\{2, 4, 1, 1\\}"
687 gdb_test "print/d ${name}4a > 4 ? ${name}4b : ${name}a" " = \\{2, 2, 8, 4\\}"
688 # vector with vector
689 gdb_test "print/d ${name}4a ? ${name}4b : ${name}4a" " = \\{1, 2, 8, 4\\}"
690 gdb_test "print/d ${name}4a > 4 ? ${name}4b : ${name}4a" " = \\{2, 4, 8, 4\\}"
692 # scalar with scalar
693 gdb_test "ptype ${name}a ? ${name}b : ${name}a" "type = ${type}"
694 # scalar with vector
695 gdb_test "ptype ${name}4a ? ${name}4b : ${name}a" "type = ${type}4"
696 gdb_test "ptype ${name}4a ? ${name}b : ${name}4a" "type = ${type}4"
697 # vector with vector
698 gdb_test "ptype ${name}4a ? ${name}4b : ${name}4a" "type = ${type}4"
700 if { !${isfloat} } {
701 # scalar with scalar
702 gdb_test "print/d u${name}a ? u${name}b : u${name}a" " = 1"
703 gdb_test "print/d !u${name}a ? u${name}b : u${name}a" " = 2"
704 # scalar with vector
705 gdb_test "print/d u${name}4a ? u${name}4b : u${name}a" " = \\{1, 2, 8, 4\\}"
706 gdb_test "print/d u${name}4a ? u${name}b : u${name}4a" " = \\{1, 1, 1, 1\\}"
707 gdb_test "print/d u${name}4a > 4 ? 1 : u${name}4a" " = \\{2, 4, 1, 1\\}"
708 gdb_test "print/d u${name}4a > 4 ? u${name}4b : u${name}a" " = \\{2, 2, 8, 4\\}"
709 # vector with vector
710 gdb_test "print/d u${name}4a ? u${name}4b : u${name}4a" " = \\{1, 2, 8, 4\\}"
711 gdb_test "print/d u${name}4a > 4 ? u${name}4b : u${name}4a" " = \\{2, 4, 8, 4\\}"
713 # scalar with scalar
714 gdb_test "ptype u${name}a ? u${name}b : u${name}a" "type = (unsigned ${type}|u${type})"
715 # scalar with vector
716 gdb_test "ptype u${name}4a ? u${name}4b : u${name}a" "type = u${type}4"
717 gdb_test "ptype u${name}4a ? u${name}b : u${name}4a" "type = u${type}4"
718 # vector with vector
719 gdb_test "ptype u${name}4a ? u${name}4b : u${name}4a" "type = u${type}4"
723 # Assignment operators
724 proc check_assignment_ops { name type isfloat size } {
725 # scalar with scalar
726 gdb_test "print/d ${name}a = ${name}b" " = 1"
727 gdb_test "print/d ${name}a = 2" " = 2"
728 gdb_test "print/d ${name}a += ${name}b" " = 3"
729 gdb_test "print/d ${name}a -= ${name}b" " = 2"
730 gdb_test "print/d ${name}b *= ${name}a" " = 2"
731 gdb_test "print/d ${name}b /= ${name}a" " = 1"
732 # scalar with vector
733 gdb_test "print/d ${name}4a = ${name}b" " = \\{1, 1, 1, 1\\}"
734 gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
735 gdb_test "print/d ${name}4a += ${name}b" " = \\{3, 5, 9, 17\\}"
736 gdb_test "print/d ${name}4a -= ${name}b" " = \\{2, 4, 8, 16\\}"
737 gdb_test "print/d ${name}4b *= ${name}a" " = \\{2, 4, 16, 8\\}"
738 gdb_test "print/d ${name}4b /= ${name}a" " = \\{1, 2, 8, 4\\}"
739 # vector with vector
740 gdb_test "print/d ${name}4a = ${name}4b" " = \\{1, 2, 8, 4\\}"
741 gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
742 gdb_test "print/d ${name}4a += ${name}4b" " = \\{3, 6, 16, 20\\}"
743 gdb_test "print/d ${name}4a -= ${name}4b" " = \\{2, 4, 8, 16\\}"
744 gdb_test "print/d ${name}4b *= ${name}4a" " = \\{2, 8, 64, 64\\}"
745 gdb_test "print/d ${name}4b /= ${name}4a" " = \\{1, 2, 8, 4\\}"
747 # scalar with scalar
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 gdb_test "ptype ${name}a /= ${name}b" "type = ${type}"
753 # scalar with vector
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}4a -= ${name}b" "type = ${type}4"
757 gdb_test "ptype ${name}4b *= ${name}a" "type = ${type}4"
758 gdb_test "ptype ${name}4b /= ${name}a" "type = ${type}4"
759 # vector with vector
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}4a -= ${name}4b" "type = ${type}4"
763 gdb_test "ptype ${name}4b *= ${name}4a" "type = ${type}4"
764 gdb_test "ptype ${name}4b /= ${name}4a" "type = ${type}4"
766 if { !${isfloat} } {
767 # scalar with scalar
768 gdb_test "print/d ${name}a %= ${name}b" " = 0"
769 gdb_test "print/d ${name}a = 2" " = 2"
770 gdb_test "print/d ${name}a <<= ${name}b" " = 4"
771 gdb_test "print/d ${name}a = 2" " = 2"
772 gdb_test "print/d ${name}a >>= ${name}b" " = 1"
773 gdb_test "print/d ${name}a = 2" " = 2"
774 gdb_test "print/d ${name}a &= ${name}b" " = 0"
775 gdb_test "print/d ${name}a = 2" " = 2"
776 gdb_test "print/d ${name}a |= ${name}b" " = 3"
777 gdb_test "print/d ${name}a = 2" " = 2"
778 gdb_test "print/d ${name}a ^= ${name}b" " = 3"
779 gdb_test "print/d ${name}a = 2" " = 2"
780 # scalar with vector
781 gdb_test "print/d ${name}4b %= ${name}a" " = \\{1, 0, 0, 0\\}"
782 gdb_test "print/d ${name}4b = \{1, 2, 8, 4\}" " = \\{1, 2, 8, 4\\}"
783 gdb_test "print/d ${name}4a <<= ${name}b" " = \\{4, 8, 16, 32\\}"
784 gdb_test "print/d ${name}4a >>= ${name}b" " = \\{2, 4, 8, 16\\}"
785 gdb_test "print/d ${name}4a &= ${name}b" " = \\{0, 0, 0, 0\\}"
786 gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
787 gdb_test "print/d ${name}4a |= ${name}b" " = \\{3, 5, 9, 17\\}"
788 gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
789 gdb_test "print/d ${name}4a ^= ${name}b" " = \\{3, 5, 9, 17\\}"
790 gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
791 # vector with vector
792 gdb_test "print/d ${name}4b %= ${name}4a" " = \\{1, 2, 0, 4\\}"
793 gdb_test "print/d ${name}4b = \{1, 2, 8, 4\}" " = \\{1, 2, 8, 4\\}"
794 if { ${size} == 1 } {
795 gdb_test "print/d ${name}4a <<= ${name}4b" " = \\{4, 16, 0, 0\\}"
796 gdb_test "print/d ${name}4a >>= ${name}4b" " = \\{2, 4, 0, 0\\}"
797 gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
798 } else {
799 gdb_test "print/d ${name}4a <<= ${name}4b" " = \\{4, 16, 2048, 256\\}"
800 gdb_test "print/d ${name}4a >>= ${name}4b" " = \\{2, 4, 8, 16\\}"
802 gdb_test "print/d ${name}4a &= ${name}4b" " = \\{0, 0, 8, 0\\}"
803 gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
804 gdb_test "print/d ${name}4a |= ${name}4b" " = \\{3, 6, 8, 20\\}"
805 gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
806 gdb_test "print/d ${name}4a ^= ${name}4b" " = \\{3, 6, 0, 20\\}"
807 gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
809 # scalar with scalar
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 gdb_test "ptype ${name}a ^= ${name}b" "type = ${type}"
816 # scalar with vector
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 gdb_test "ptype ${name}4a ^= ${name}b" "type = ${type}4"
823 # vector with vector
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 gdb_test "ptype ${name}4a ^= ${name}4b" "type = ${type}4"
831 # scalar with scalar
832 gdb_test "print/d u${name}a = u${name}b" " = 1"
833 gdb_test "print/d u${name}a = 2" " = 2"
834 gdb_test "print/d u${name}a += u${name}b" " = 3"
835 gdb_test "print/d u${name}a -= u${name}b" " = 2"
836 gdb_test "print/d u${name}b *= u${name}a" " = 2"
837 gdb_test "print/d u${name}b /= u${name}a" " = 1"
838 gdb_test "print/d u${name}a %= u${name}b" " = 0"
839 gdb_test "print/d u${name}a = 2" " = 2"
840 gdb_test "print/d u${name}a <<= u${name}b" " = 4"
841 gdb_test "print/d u${name}a = 2" " = 2"
842 gdb_test "print/d u${name}a >>= u${name}b" " = 1"
843 gdb_test "print/d u${name}a = 2" " = 2"
844 gdb_test "print/d u${name}a &= u${name}b" " = 0"
845 gdb_test "print/d u${name}a = 2" " = 2"
846 gdb_test "print/d u${name}a |= u${name}b" " = 3"
847 gdb_test "print/d u${name}a = 2" " = 2"
848 gdb_test "print/d u${name}a ^= u${name}b" " = 3"
849 gdb_test "print/d u${name}a = 2" " = 2"
850 # scalar with vector
851 gdb_test "print/d u${name}4a = u${name}b" " = \\{1, 1, 1, 1\\}"
852 gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
853 gdb_test "print/d u${name}4a += u${name}b" " = \\{3, 5, 9, 17\\}"
854 gdb_test "print/d u${name}4a -= u${name}b" " = \\{2, 4, 8, 16\\}"
855 gdb_test "print/d u${name}4b *= u${name}a" " = \\{2, 4, 16, 8\\}"
856 gdb_test "print/d u${name}4b /= u${name}a" " = \\{1, 2, 8, 4\\}"
857 gdb_test "print/d u${name}4b %= u${name}a" " = \\{1, 0, 0, 0\\}"
858 gdb_test "print/d u${name}4b = \{1, 2, 8, 4\}" " = \\{1, 2, 8, 4\\}"
859 gdb_test "print/d u${name}4a <<= u${name}b" " = \\{4, 8, 16, 32\\}"
860 gdb_test "print/d u${name}4a >>= u${name}b" " = \\{2, 4, 8, 16\\}"
861 gdb_test "print/d u${name}4a &= u${name}b" " = \\{0, 0, 0, 0\\}"
862 gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
863 gdb_test "print/d u${name}4a |= u${name}b" " = \\{3, 5, 9, 17\\}"
864 gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
865 gdb_test "print/d u${name}4a ^= u${name}b" " = \\{3, 5, 9, 17\\}"
866 gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
867 # vector with vector
868 gdb_test "print/d u${name}4a = u${name}4b" " = \\{1, 2, 8, 4\\}"
869 gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
870 gdb_test "print/d u${name}4a += u${name}4b" " = \\{3, 6, 16, 20\\}"
871 gdb_test "print/d u${name}4a -= u${name}4b" " = \\{2, 4, 8, 16\\}"
872 gdb_test "print/d u${name}4b *= u${name}4a" " = \\{2, 8, 64, 64\\}"
873 gdb_test "print/d u${name}4b /= u${name}4a" " = \\{1, 2, 8, 4\\}"
874 gdb_test "print/d u${name}4b %= u${name}4a" " = \\{1, 2, 0, 4\\}"
875 gdb_test "print/d u${name}4b = \{1, 2, 8, 4\}" " = \\{1, 2, 8, 4\\}"
876 if { ${size} == 1 } {
877 gdb_test "print/d u${name}4a <<= u${name}4b" " = \\{4, 16, 0, 0\\}"
878 gdb_test "print/d u${name}4a >>= u${name}4b" " = \\{2, 4, 0, 0\\}"
879 gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
880 } else {
881 gdb_test "print/d u${name}4a <<= u${name}4b" " = \\{4, 16, 2048, 256\\}"
882 gdb_test "print/d u${name}4a >>= u${name}4b" " = \\{2, 4, 8, 16\\}"
884 gdb_test "print/d u${name}4a &= u${name}4b" " = \\{0, 0, 8, 0\\}"
885 gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
886 gdb_test "print/d u${name}4a |= u${name}4b" " = \\{3, 6, 8, 20\\}"
887 gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
888 gdb_test "print/d u${name}4a ^= u${name}4b" " = \\{3, 6, 0, 20\\}"
889 gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
891 # scalar with scalar
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 gdb_test "ptype u${name}a ^= u${name}b" "type = (unsigned ${type}|u${type})"
903 # scalar with vector
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}4a -= u${name}b" "type = u${type}4"
907 gdb_test "ptype u${name}4b *= u${name}a" "type = u${type}4"
908 gdb_test "ptype u${name}4b /= u${name}a" "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 gdb_test "ptype u${name}4a ^= u${name}b" "type = u${type}4"
915 # vector with vector
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}4a -= u${name}4b" "type = u${type}4"
919 gdb_test "ptype u${name}4b *= u${name}4a" "type = u${type}4"
920 gdb_test "ptype u${name}4b /= u${name}4a" "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 gdb_test "ptype u${name}4a ^= u${name}4b" "type = u${type}4"
930 proc do_check { name type isfloat size } {
931 check_basic ${name} ${type} ${isfloat}
932 check_arithmetic_ops ${name} ${type} ${isfloat} ${size}
933 check_relational_ops ${name} ${type} ${isfloat} ${size}
934 check_equality_ops ${name} ${type} ${isfloat} ${size}
935 if { !${isfloat} } {
936 check_shift_ops ${name} ${type} ${size}
937 check_bitwise_ops ${name} ${type} ${size}
939 check_logical_ops ${name} ${type} ${isfloat} ${size}
940 check_conditional_op ${name} ${type} ${isfloat}
941 check_assignment_ops ${name} ${type} ${isfloat} ${size}
944 do_check "c" "char" 0 1
945 do_check "s" "short" 0 2
946 do_check "i" "int" 0 4
947 do_check "l" "long" 0 8
948 if { ${have_cl_khr_fp16} } {
949 do_check "h" "half" 1 2
951 do_check "f" "float" 1 4
952 if { ${have_cl_khr_fp64} } {
953 do_check "d" "double" 1 8
955 # Delete the OpenCL program source
956 remote_file target delete ${clprogram}