summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.opencl
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite/gdb.opencl')
-rw-r--r--gdb/testsuite/gdb.opencl/Makefile.in17
-rw-r--r--gdb/testsuite/gdb.opencl/convs_casts.cl55
-rw-r--r--gdb/testsuite/gdb.opencl/convs_casts.exp95
-rw-r--r--gdb/testsuite/gdb.opencl/datatypes.cl145
-rw-r--r--gdb/testsuite/gdb.opencl/datatypes.exp471
-rw-r--r--gdb/testsuite/gdb.opencl/operators.cl105
-rw-r--r--gdb/testsuite/gdb.opencl/operators.exp955
-rw-r--r--gdb/testsuite/gdb.opencl/vec_comps.cl59
-rw-r--r--gdb/testsuite/gdb.opencl/vec_comps.exp390
9 files changed, 2292 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.opencl/Makefile.in b/gdb/testsuite/gdb.opencl/Makefile.in
new file mode 100644
index 00000000000..c12aef3e818
--- /dev/null
+++ b/gdb/testsuite/gdb.opencl/Makefile.in
@@ -0,0 +1,17 @@
+VPATH = @srcdir@
+srcdir = @srcdir@
+
+EXECUTABLES = datatypes vec_comps convs_casts operators
+
+all info install-info dvi install uninstall installcheck check:
+ @echo "Nothing to be done for $@..."
+
+clean mostlyclean:
+ -rm -f *~ *.o a.out core corefile gcore.test
+ -rm -f $(EXECUTABLES)
+
+distclean maintainer-clean realclean: clean
+ -rm -f *~ core
+ -rm -f Makefile config.status config.log
+ -rm -f *-init.exp
+ -rm -fr *.log summary detail *.plog *.sum *.psum site.*
diff --git a/gdb/testsuite/gdb.opencl/convs_casts.cl b/gdb/testsuite/gdb.opencl/convs_casts.cl
new file mode 100644
index 00000000000..a024c5140f3
--- /dev/null
+++ b/gdb/testsuite/gdb.opencl/convs_casts.cl
@@ -0,0 +1,55 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2010 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ Contributed by Ken Werner <ken.werner@de.ibm.com> */
+
+int opencl_version = __OPENCL_VERSION__;
+
+#ifdef HAVE_cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+int have_cl_khr_fp64 = 1;
+#else
+int have_cl_khr_fp64 = 0;
+#endif
+
+#ifdef HAVE_cl_khr_fp16
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+int have_cl_khr_fp16 = 1;
+#else
+int have_cl_khr_fp16 = 0;
+#endif
+
+char c = 123;
+uchar uc = 123;
+short s = 123;
+ushort us = 123;
+int i = 123;
+uint ui = 123;
+long l = 123;
+ulong ul = 123;
+#ifdef cl_khr_fp16
+half h = 123.0;
+#endif
+float f = 123.0;
+#ifdef cl_khr_fp64
+double d = 123.0;
+#endif
+
+__kernel void testkernel (__global int *data)
+{
+ data[get_global_id(0)] = 1;
+}
diff --git a/gdb/testsuite/gdb.opencl/convs_casts.exp b/gdb/testsuite/gdb.opencl/convs_casts.exp
new file mode 100644
index 00000000000..34ea635c7c1
--- /dev/null
+++ b/gdb/testsuite/gdb.opencl/convs_casts.exp
@@ -0,0 +1,95 @@
+# Copyright 2010 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>. */
+#
+# Contributed by Ken Werner <ken.werner@de.ibm.com>.
+#
+# Tests GDBs support for OpenCL type conversions and casts.
+
+if $tracelevel {
+ strace $tracelevel
+}
+
+load_lib opencl.exp
+
+if { [skip_opencl_tests] } {
+ return 0
+}
+
+set testfile "convs_casts"
+set clprogram [remote_download target ${srcdir}/${subdir}/${testfile}.cl]
+
+# Compile the generic OpenCL host app
+if { [gdb_compile_opencl_hostapp "${clprogram}" "${testfile}" "" ] != "" } {
+ untested ${testfile}.exp
+ return -1
+}
+
+# Load the OpenCL app
+clean_restart ${testfile}
+
+# Set breakpoint at the OpenCL kernel
+gdb_test_multiple "break testkernel" "set pending breakpoint" {
+ -re ".*Function \"testkernel\" not defined.*Make breakpoint pending.*y or \\\[n\\\]. $" {
+ gdb_test "y" "Breakpoint.*testkernel.*pending." "set pending breakpoint (without symbols)"
+ }
+}
+
+gdb_run_cmd
+gdb_test "" ".*Breakpoint.*1.*testkernel.*" "run"
+
+# Retrieve some information about availability of OpenCL extensions
+set have_cl_khr_fp64 [get_integer_valueof "have_cl_khr_fp64" 0]
+set have_cl_khr_fp16 [get_integer_valueof "have_cl_khr_fp16" 0]
+
+proc vec_casts { name } {
+ global have_cl_khr_fp16 have_cl_khr_fp64
+ set types {"char" "uchar" "short" "ushort" "int" "uint" "long" "ulong" "half" "float" "double"}
+ set len [llength ${types}]
+
+ for {set i 0} {$i < ${len}} {incr i} {
+ set type [lindex ${types} $i]
+
+ gdb_test "print/d (${type}2)${name}" " = \\{123, 123\\}"
+ gdb_test "print/d (${type}3)${name}" " = \\{123, 123, 123\\}"
+ gdb_test "print/d (${type}4)${name}" " = \\{123, 123, 123, 123\\}"
+ gdb_test "print/d (${type}8)${name}" " = \\{123, 123, 123, 123, 123, 123, 123, 123\\}"
+ gdb_test "print/d (${type}16)${name}" " = \\{123 <repeats 16 times>\\}"
+
+ gdb_test "ptype (${type}2)${name}" "${type} \\\[2\\\]"
+ gdb_test "ptype (${type}3)${name}" "${type} \\\[3\\\]"
+ gdb_test "ptype (${type}4)${name}" "${type} \\\[4\\\]"
+ gdb_test "ptype (${type}8)${name}" "${type} \\\[8\\\]"
+ gdb_test "ptype (${type}16)${name}" "${type} \\\[16\\\]"
+ }
+}
+
+vec_casts "c"
+vec_casts "uc"
+vec_casts "s"
+vec_casts "us"
+vec_casts "i"
+vec_casts "ui"
+vec_casts "l"
+vec_casts "ul"
+if { ${have_cl_khr_fp16} } {
+ vec_casts "h"
+}
+vec_casts "f"
+if { ${have_cl_khr_fp64} } {
+ vec_casts "d"
+}
+
+# Delete the OpenCL program source
+remote_file target delete ${clprogram}
diff --git a/gdb/testsuite/gdb.opencl/datatypes.cl b/gdb/testsuite/gdb.opencl/datatypes.cl
new file mode 100644
index 00000000000..c0d2a1eb337
--- /dev/null
+++ b/gdb/testsuite/gdb.opencl/datatypes.cl
@@ -0,0 +1,145 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2010 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ Contributed by Ken Werner <ken.werner@de.ibm.com> */
+
+int opencl_version = __OPENCL_VERSION__;
+
+#ifdef HAVE_cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+int have_cl_khr_fp64 = 1;
+#else
+int have_cl_khr_fp64 = 0;
+#endif
+
+#ifdef HAVE_cl_khr_fp16
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+int have_cl_khr_fp16 = 1;
+#else
+int have_cl_khr_fp16 = 0;
+#endif
+
+bool b = 0;
+
+char c = 1;
+char2 c2 = (char2) (1, 2);
+#ifdef CL_VERSION_1_1
+char3 c3 = (char3) (1, 2, 3);
+#endif
+char4 c4 = (char4) (1, 2, 3, 4);
+char8 c8 = (char8) (1, 2, 3, 4, 5, 6, 7, 8);
+char16 c16 = (char16)(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
+
+uchar uc = 1;
+uchar2 uc2 = (uchar2) (1, 2);
+#ifdef CL_VERSION_1_1
+uchar3 uc3 = (uchar3) (1, 2, 3);
+#endif
+uchar4 uc4 = (uchar4) (1, 2, 3, 4);
+uchar8 uc8 = (uchar8) (1, 2, 3, 4, 5, 6, 7, 8);
+uchar16 uc16 = (uchar16)(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
+
+short s = -1;
+short2 s2 = (short2) (-1, -2);
+#ifdef CL_VERSION_1_1
+short3 s3 = (short3) (-1, -2, -3);
+#endif
+short4 s4 = (short4) (-1, -2, -3, -4);
+short8 s8 = (short8) (-1, -2, -3, -4, -5, -6, -7, -8);
+short16 s16 = (short16)(-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16);
+
+ushort us = 1;
+ushort2 us2 = (ushort2) (1, 2);
+#ifdef CL_VERSION_1_1
+ushort3 us3 = (ushort3) (1, 2, 3);
+#endif
+ushort4 us4 = (ushort4) (1, 2, 3, 4);
+ushort8 us8 = (ushort8) (1, 2, 3, 4, 5, 6, 7, 8);
+ushort16 us16 = (ushort16)(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
+
+int i = -1;
+int2 i2 = (int2) (-1, -2);
+#ifdef CL_VERSION_1_1
+int3 i3 = (int3) (-1, -2, -3);
+#endif
+int4 i4 = (int4) (-1, -2, -3, -4);
+int8 i8 = (int8) (-1, -2, -3, -4, -5, -6, -7, -8);
+int16 i16 = (int16)(-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16);
+
+uint ui = 1;
+uint2 ui2 = (uint2) (1, 2);
+#ifdef CL_VERSION_1_1
+uint3 ui3 = (uint3) (1, 2, 3);
+#endif
+uint4 ui4 = (uint4) (1, 2, 3, 4);
+uint8 ui8 = (uint8) (1, 2, 3, 4, 5, 6, 7, 8);
+uint16 ui16 = (uint16)(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
+
+long l = -1;
+long2 l2 = (long2) (-1, -2);
+#ifdef CL_VERSION_1_1
+long3 l3 = (long3) (-1, -2, -3);
+#endif
+long4 l4 = (long4) (-1, -2, -3, -4);
+long8 l8 = (long8) (-1, -2, -3, -4, -5, -6, -7, -8);
+long16 l16 = (long16)(-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16);
+
+ulong ul = 1;
+ulong2 ul2 = (ulong2) (1, 2);
+#ifdef CL_VERSION_1_1
+ulong3 ul3 = (ulong3) (1, 2, 3);
+#endif
+ulong4 ul4 = (ulong4) (1, 2, 3, 4);
+ulong8 ul8 = (ulong8) (1, 2, 3, 4, 5, 6, 7, 8);
+ulong16 ul16 = (ulong16)(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
+
+half *ph;
+#ifdef cl_khr_fp16
+half h = 1.0;
+half2 h2 = (half2) (1.0, 2.0);
+#ifdef CL_VERSION_1_1
+half3 h3 = (half3) (1.0, 2.0, 3.0);
+#endif
+half4 h4 = (half4) (1.0, 2.0, 3.0, 4.0);
+half8 h8 = (half8) (1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0);
+half16 h16 = (half16)(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0);
+#endif
+
+float f = 1.0;
+float2 f2 = (float2) (1.0, 2.0);
+#ifdef CL_VERSION_1_1
+float3 f3 = (float3) (1.0, 2.0, 3.0);
+#endif
+float4 f4 = (float4) (1.0, 2.0, 3.0, 4.0);
+float8 f8 = (float8) (1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0);
+float16 f16 = (float16)(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0);
+
+#ifdef cl_khr_fp64
+double d = 1.0;
+double2 d2 = (double2) (1.0, 2.0);
+#ifdef CL_VERSION_1_1
+double3 d3 = (double3) (1.0, 2.0, 3.0);
+#endif
+double4 d4 = (double4) (1.0, 2.0, 3.0, 4.0);
+double8 d8 = (double8) (1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0);
+double16 d16 = (double16)(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0);
+#endif
+
+__kernel void testkernel (__global int *data)
+{
+ data[get_global_id(0)] = 1;
+}
diff --git a/gdb/testsuite/gdb.opencl/datatypes.exp b/gdb/testsuite/gdb.opencl/datatypes.exp
new file mode 100644
index 00000000000..45c9e5262fb
--- /dev/null
+++ b/gdb/testsuite/gdb.opencl/datatypes.exp
@@ -0,0 +1,471 @@
+# Copyright 2010 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>. */
+#
+# Contributed by Ken Werner <ken.werner@de.ibm.com>.
+#
+# Tests OpenCL data types.
+
+if $tracelevel {
+ strace $tracelevel
+}
+
+load_lib opencl.exp
+
+if { [skip_opencl_tests] } {
+ return 0
+}
+
+set testfile "datatypes"
+set clprogram [remote_download target ${srcdir}/${subdir}/${testfile}.cl]
+
+# Compile the generic OpenCL host app
+if { [gdb_compile_opencl_hostapp "${clprogram}" "${testfile}" "" ] != "" } {
+ untested ${testfile}.exp
+ return -1
+}
+
+gdb_exit
+gdb_start
+
+# Manually switch the language to opencl
+gdb_test_no_output "set language opencl" "No prompt when setting the language to opencl"
+
+# Check OpenCL data types (GDB)
+gdb_test "whatis bool" "type = bool"
+gdb_test "p sizeof(bool)" " = 4"
+
+gdb_test "whatis char" "type = char"
+gdb_test "p sizeof(char)" " = 1"
+gdb_test "whatis char2" "type = char2"
+gdb_test "p sizeof(char2)" " = 2"
+gdb_test "whatis char3" "type = char3"
+gdb_test "p sizeof(char3)" " = 4"
+gdb_test "whatis char4" "type = char4"
+gdb_test "p sizeof(char4)" " = 4"
+gdb_test "whatis char8" "type = char8"
+gdb_test "p sizeof(char8)" " = 8"
+gdb_test "whatis char16" "type = char16"
+gdb_test "p sizeof(char16)" " = 16"
+
+gdb_test "whatis unsigned char" "type = unsigned char"
+gdb_test "p sizeof(unsigned char)" " = 1"
+gdb_test "whatis uchar" "type = uchar"
+gdb_test "p sizeof(uchar)" " = 1"
+gdb_test "whatis uchar2" "type = uchar2"
+gdb_test "p sizeof(uchar2)" " = 2"
+gdb_test "whatis uchar3" "type = uchar3"
+gdb_test "p sizeof(uchar3)" " = 4"
+gdb_test "whatis uchar4" "type = uchar4"
+gdb_test "p sizeof(uchar4)" " = 4"
+gdb_test "whatis uchar8" "type = uchar8"
+gdb_test "p sizeof(uchar8)" " = 8"
+gdb_test "whatis uchar16" "type = uchar16"
+gdb_test "p sizeof(uchar16)" " = 16"
+
+gdb_test "whatis short" "type = short"
+gdb_test "p sizeof(short)" " = 2"
+gdb_test "whatis short2" "type = short2"
+gdb_test "p sizeof(short2)" " = 4"
+gdb_test "whatis short3" "type = short3"
+gdb_test "p sizeof(short3)" " = 8"
+gdb_test "whatis short4" "type = short4"
+gdb_test "p sizeof(short4)" " = 8"
+gdb_test "whatis short8" "type = short8"
+gdb_test "p sizeof(short8)" " = 16"
+gdb_test "whatis short16" "type = short16"
+gdb_test "p sizeof(short16)" " = 32"
+
+gdb_test "whatis unsigned short" "type = unsigned short"
+gdb_test "p sizeof(unsigned short)" " = 2"
+gdb_test "whatis ushort" "type = ushort"
+gdb_test "p sizeof(ushort)" " = 2"
+gdb_test "whatis ushort2" "type = ushort2"
+gdb_test "p sizeof(ushort2)" " = 4"
+gdb_test "whatis ushort3" "type = ushort3"
+gdb_test "p sizeof(ushort3)" " = 8"
+gdb_test "whatis ushort4" "type = ushort4"
+gdb_test "p sizeof(ushort4)" " = 8"
+gdb_test "whatis ushort8" "type = ushort8"
+gdb_test "p sizeof(ushort8)" " = 16"
+gdb_test "whatis ushort16" "type = ushort16"
+gdb_test "p sizeof(ushort16)" " = 32"
+
+gdb_test "whatis int" "type = int"
+gdb_test "p sizeof(int)" " = 4"
+gdb_test "whatis int2" "type = int2"
+gdb_test "p sizeof(int2)" " = 8"
+gdb_test "whatis int3" "type = int3"
+gdb_test "p sizeof(int3)" " = 16"
+gdb_test "whatis int4" "type = int4"
+gdb_test "p sizeof(int4)" " = 16"
+gdb_test "whatis int8" "type = int8"
+gdb_test "p sizeof(int8)" " = 32"
+gdb_test "whatis int16" "type = int16"
+gdb_test "p sizeof(int16)" " = 64"
+
+gdb_test "whatis unsigned int" "type = unsigned int"
+gdb_test "p sizeof(unsigned int)" " = 4"
+gdb_test "whatis uint" "type = uint"
+gdb_test "p sizeof(uint)" " = 4"
+gdb_test "whatis uint2" "type = uint2"
+gdb_test "p sizeof(uint2)" " = 8"
+gdb_test "whatis uint3" "type = uint3"
+gdb_test "p sizeof(uint3)" " = 16"
+gdb_test "whatis uint4" "type = uint4"
+gdb_test "p sizeof(uint4)" " = 16"
+gdb_test "whatis uint8" "type = uint8"
+gdb_test "p sizeof(uint8)" " = 32"
+gdb_test "whatis uint16" "type = uint16"
+gdb_test "p sizeof(uint16)" " = 64"
+
+gdb_test "whatis long" "type = long"
+gdb_test "p sizeof(long)" " = 8"
+gdb_test "whatis long2" "type = long2"
+gdb_test "p sizeof(long2)" " = 16"
+gdb_test "whatis long3" "type = long3"
+gdb_test "p sizeof(long3)" " = 32"
+gdb_test "whatis long4" "type = long4"
+gdb_test "p sizeof(long4)" " = 32"
+gdb_test "whatis long8" "type = long8"
+gdb_test "p sizeof(long8)" " = 64"
+gdb_test "whatis long16" "type = long16"
+gdb_test "p sizeof(long16)" " = 128"
+
+gdb_test "whatis unsigned long" "type = unsigned long"
+gdb_test "p sizeof(unsigned long)" " = 8"
+gdb_test "whatis ulong" "type = ulong"
+gdb_test "p sizeof(ulong)" " = 8"
+gdb_test "whatis ulong2" "type = ulong2"
+gdb_test "p sizeof(ulong2)" " = 16"
+gdb_test "whatis ulong3" "type = ulong3"
+gdb_test "p sizeof(ulong3)" " = 32"
+gdb_test "whatis ulong4" "type = ulong4"
+gdb_test "p sizeof(ulong4)" " = 32"
+gdb_test "whatis ulong8" "type = ulong8"
+gdb_test "p sizeof(ulong8)" " = 64"
+gdb_test "whatis ulong16" "type = ulong16"
+gdb_test "p sizeof(ulong16)" " = 128"
+
+gdb_test "whatis half" "type = half"
+gdb_test "p sizeof(half)" " = 2"
+gdb_test "whatis half2" "type = half2"
+gdb_test "p sizeof(half2)" " = 4"
+gdb_test "whatis half3" "type = half3"
+gdb_test "p sizeof(half3)" " = 8"
+gdb_test "whatis half4" "type = half4"
+gdb_test "p sizeof(half4)" " = 8"
+gdb_test "whatis half8" "type = half8"
+gdb_test "p sizeof(half8)" " = 16"
+gdb_test "whatis half16" "type = half16"
+gdb_test "p sizeof(half16)" " = 32"
+
+gdb_test "whatis float" "type = float"
+gdb_test "p sizeof(float)" " = 4"
+gdb_test "whatis float2" "type = float2"
+gdb_test "p sizeof(float2)" " = 8"
+gdb_test "whatis float3" "type = float3"
+gdb_test "p sizeof(float3)" " = 16"
+gdb_test "whatis float4" "type = float4"
+gdb_test "p sizeof(float4)" " = 16"
+gdb_test "whatis float8" "type = float8"
+gdb_test "p sizeof(float8)" " = 32"
+gdb_test "whatis float16" "type = float16"
+gdb_test "p sizeof(float16)" " = 64"
+
+gdb_test "whatis double" "type = double"
+gdb_test "p sizeof(double)" " = 8"
+gdb_test "whatis double2" "type = double2"
+gdb_test "p sizeof(double2)" " = 16"
+gdb_test "whatis double3" "type = double3"
+gdb_test "p sizeof(double3)" " = 32"
+gdb_test "whatis double4" "type = double4"
+gdb_test "p sizeof(double4)" " = 32"
+gdb_test "whatis double8" "type = double8"
+gdb_test "p sizeof(double8)" " = 64"
+gdb_test "whatis double16" "type = double16"
+gdb_test "p sizeof(double16)" " = 128"
+
+# Set the language back to the default: "auto; currently c"
+gdb_test_no_output "set language c" "No prompt when setting the language to c"
+gdb_test_no_output "set language auto" "No prompt when setting the language to auto"
+
+# Load the OpenCL app
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${objdir}/${subdir}/${testfile}
+
+# Set breakpoint at the OpenCL kernel
+gdb_test_multiple "break testkernel" "set pending breakpoint" {
+ -re ".*Function \"testkernel\" not defined.*Make breakpoint pending.*y or \\\[n\\\]. $" {
+ gdb_test "y" "Breakpoint.*testkernel.*pending." "set pending breakpoint (without symbols)"
+ }
+}
+
+gdb_run_cmd
+gdb_test "" ".*Breakpoint.*1.*testkernel.*" "run"
+
+# Check if the language was switched to opencl
+gdb_test "show language" "The current source language is \"auto; currently opencl\"\."
+
+# Retrieve some information about the OpenCL version and the availability of extensions
+set opencl_version [get_integer_valueof "opencl_version" 0]
+set have_cl_khr_fp64 [get_integer_valueof "have_cl_khr_fp64" 0]
+set have_cl_khr_fp16 [get_integer_valueof "have_cl_khr_fp16" 0]
+
+# Check OpenCL data types (DWARF)
+gdb_test "whatis b" "type = bool"
+gdb_test "p sizeof(b)" " = 4"
+gdb_test "print b" " = 0"
+
+gdb_test "whatis c" "type = char"
+gdb_test "p sizeof(c)" " = 1"
+gdb_test "print/d c" " = 1"
+gdb_test "whatis c2" "type = char \\\[2\\\]"
+gdb_test "p sizeof(c2)" " = 2"
+gdb_test "print c2" " = \\{1, 2\\}"
+if { ${opencl_version} >= 110 } {
+ gdb_test "whatis c3" "type = char \\\[3\\\]"
+ gdb_test "p sizeof(c3)" " = 4"
+ gdb_test "print c3" " = \\{1, 2, 3\\}"
+}
+gdb_test "whatis c4" "type = char \\\[4\\\]"
+gdb_test "p sizeof(c4)" " = 4"
+gdb_test "print c4" " = \\{1, 2, 3, 4\\}"
+gdb_test "whatis c8" "type = char \\\[8\\\]"
+gdb_test "p sizeof(c8)" " = 8"
+gdb_test "print c8" " = \\{1, 2, 3, 4, 5, 6, 7, 8\\}"
+gdb_test "whatis c16" "type = char \\\[16\\\]"
+gdb_test "p sizeof(c16)" " = 16"
+gdb_test "print c16" " = \\{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16\\}"
+
+gdb_test "whatis uc" "type = (uchar|unsigned char)"
+gdb_test "p sizeof(uc)" " = 1"
+gdb_test "print/d uc" " = 1"
+gdb_test "whatis uc2" "type = (uchar|unsigned char) \\\[2\\\]"
+gdb_test "p sizeof(uc2)" " = 2"
+gdb_test "print uc2" " = \\{1, 2\\}"
+if { ${opencl_version} >= 110 } {
+ gdb_test "whatis uc3" "type = (uchar|unsigned char) \\\[3\\\]"
+ gdb_test "p sizeof(uchar3)" " = 4"
+ gdb_test "print uc3" " = \\{1, 2, 3\\}"
+}
+gdb_test "whatis uc4" "type = (uchar|unsigned char) \\\[4\\\]"
+gdb_test "p sizeof(uc4)" " = 4"
+gdb_test "print uc4" " = \\{1, 2, 3, 4\\}"
+gdb_test "whatis uc8" "type = (uchar|unsigned char) \\\[8\\\]"
+gdb_test "p sizeof(uc8)" " = 8"
+gdb_test "print uc8" " = \\{1, 2, 3, 4, 5, 6, 7, 8\\}"
+gdb_test "whatis uc16" "type = (uchar|unsigned char) \\\[16\\\]"
+gdb_test "p sizeof(uc16)" " = 16"
+gdb_test "print uc16" " = \\{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16\\}"
+
+gdb_test "whatis s" "type = short"
+gdb_test "p sizeof(s)" " = 2"
+gdb_test "print s" " = -1"
+gdb_test "whatis s2" "type = short \\\[2\\\]"
+gdb_test "p sizeof(s2)" " = 4"
+gdb_test "print s2" " = \\{-1, -2\\}"
+if { ${opencl_version} >= 110 } {
+ gdb_test "whatis s3" "type = short \\\[3\\\]"
+ gdb_test "p sizeof(s3)" " = 8"
+ gdb_test "print s3" " = \\{-1, -2, -3\\}"
+}
+gdb_test "whatis s4" "type = short \\\[4\\\]"
+gdb_test "p sizeof(s4)" " = 8"
+gdb_test "print s4" " = \\{-1, -2, -3, -4\\}"
+gdb_test "whatis s8" "type = short \\\[8\\\]"
+gdb_test "p sizeof(s8)" " = 16"
+gdb_test "print s8" " = \\{-1, -2, -3, -4, -5, -6, -7, -8\\}"
+gdb_test "whatis s16" "type = short \\\[16\\\]"
+gdb_test "p sizeof(s16)" " = 32"
+gdb_test "print s16" " = \\{-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16\\}"
+
+gdb_test "whatis us" "type = (ushort|unsigned short)"
+gdb_test "p sizeof(us)" " = 2"
+gdb_test "print us" " = 1"
+gdb_test "whatis us2" "type = (ushort|unsigned short) \\\[2\\\]"
+gdb_test "p sizeof(us2)" " = 4"
+gdb_test "print us2" " = \\{1, 2\\}"
+if { ${opencl_version} >= 110 } {
+ gdb_test "whatis us3" "type = (ushort|unsigned short) \\\[3\\\]"
+ gdb_test "p sizeof(us3)" " = 8"
+ gdb_test "print us3" " = \\{1, 2, 3\\}"
+}
+gdb_test "whatis us4" "type = (ushort|unsigned short) \\\[4\\\]"
+gdb_test "p sizeof(us4)" " = 8"
+gdb_test "print us4" " = \\{1, 2, 3, 4\\}"
+gdb_test "whatis us8" "type = (ushort|unsigned short) \\\[8\\\]"
+gdb_test "p sizeof(us8)" " = 16"
+gdb_test "print us8" " = \\{1, 2, 3, 4, 5, 6, 7, 8\\}"
+gdb_test "whatis us16" "type = (ushort|unsigned short) \\\[16\\\]"
+gdb_test "p sizeof(us16)" " = 32"
+gdb_test "print us16" " = \\{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16\\}"
+
+gdb_test "whatis i" "type = int"
+gdb_test "p sizeof(i)" " = 4"
+gdb_test "print i" " = -1"
+gdb_test "whatis i2" "type = int \\\[2\\\]"
+gdb_test "p sizeof(i2)" " = 8"
+gdb_test "print i2" " = \\{-1, -2\\}"
+if { ${opencl_version} >= 110 } {
+ gdb_test "whatis i3" "type = int \\\[3\\\]"
+ gdb_test "p sizeof(i3)" " = 16"
+ gdb_test "print i3" " = \\{-1, -2, -3\\}"
+}
+gdb_test "whatis i4" "type = int \\\[4\\\]"
+gdb_test "p sizeof(i4)" " = 16"
+gdb_test "print i4" " = \\{-1, -2, -3, -4\\}"
+gdb_test "whatis i8" "type = int \\\[8\\\]"
+gdb_test "p sizeof(i8)" " = 32"
+gdb_test "print i8" " = \\{-1, -2, -3, -4, -5, -6, -7, -8\\}"
+gdb_test "whatis i16" "type = int \\\[16\\\]"
+gdb_test "p sizeof(i16)" " = 64"
+gdb_test "print i16" " = \\{-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16\\}"
+
+gdb_test "whatis ui" "type = (uint|unsigned int)"
+gdb_test "p sizeof(ui)" " = 4"
+gdb_test "print ui" " = 1"
+gdb_test "whatis ui2" "type = (uint|unsigned int) \\\[2\\\]"
+gdb_test "p sizeof(ui2)" " = 8"
+gdb_test "print ui2" " = \\{1, 2\\}"
+if { ${opencl_version} >= 110 } {
+ gdb_test "whatis ui3" "type = (uint|unsigned int) \\\[3\\\]"
+ gdb_test "p sizeof(ui3)" " = 16"
+ gdb_test "print ui3" " = \\{1, 2, 3\\}"
+}
+gdb_test "whatis ui4" "type = (uint|unsigned int) \\\[4\\\]"
+gdb_test "p sizeof(ui4)" " = 16"
+gdb_test "print ui4" " = \\{1, 2, 3, 4\\}"
+gdb_test "whatis ui8" "type = (uint|unsigned int) \\\[8\\\]"
+gdb_test "p sizeof(ui8)" " = 32"
+gdb_test "print ui8" " = \\{1, 2, 3, 4, 5, 6, 7, 8\\}"
+gdb_test "whatis ui16" "type = (uint|unsigned int) \\\[16\\\]"
+gdb_test "p sizeof(ui16)" " = 64"
+gdb_test "print ui16" " = \\{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16\\}"
+
+gdb_test "whatis l" "type = long"
+gdb_test "p sizeof(l)" " = 8"
+gdb_test "print l" " = -1"
+gdb_test "whatis l2" "type = long \\\[2\\\]"
+gdb_test "p sizeof(l2)" " = 16"
+gdb_test "print l2" " = \\{-1, -2\\}"
+if { ${opencl_version} >= 110 } {
+ gdb_test "whatis l3" "type = long \\\[3\\\]"
+ gdb_test "p sizeof(l3)" " = 32"
+ gdb_test "print l3" " = \\{-1, -2, -3\\}"
+}
+gdb_test "whatis l4" "type = long \\\[4\\\]"
+gdb_test "p sizeof(l4)" " = 32"
+gdb_test "print l4" " = \\{-1, -2, -3, -4\\}"
+gdb_test "whatis l8" "type = long \\\[8\\\]"
+gdb_test "p sizeof(l8)" " = 64"
+gdb_test "print l8" " = \\{-1, -2, -3, -4, -5, -6, -7, -8\\}"
+gdb_test "whatis l16" "type = long \\\[16\\\]"
+gdb_test "p sizeof(l16)" " = 128"
+gdb_test "print l16" " = \\{-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16\\}"
+
+gdb_test "whatis ul" "type = (ulong|unsigned long)"
+gdb_test "p sizeof(ul)" " = 8"
+gdb_test "print ul" " = 1"
+gdb_test "whatis ul2" "type = (ulong|unsigned long) \\\[2\\\]"
+gdb_test "p sizeof(ul2)" " = 16"
+gdb_test "print ul2" " = \\{1, 2\\}"
+if { ${opencl_version} >= 110 } {
+ gdb_test "whatis ul3" "type = (ulong|unsigned long) \\\[3\\\]"
+ gdb_test "p sizeof(ul3)" " = 32"
+ gdb_test "print ul3" " = \\{1, 2, 3\\}"
+}
+gdb_test "whatis ul4" "type = (ulong|unsigned long) \\\[4\\\]"
+gdb_test "p sizeof(ul4)" " = 32"
+gdb_test "print ul4" " = \\{1, 2, 3, 4\\}"
+gdb_test "whatis ul8" "type = (ulong|unsigned long) \\\[8\\\]"
+gdb_test "p sizeof(ul8)" " = 64"
+gdb_test "print ul8" " = \\{1, 2, 3, 4, 5, 6, 7, 8\\}"
+gdb_test "whatis ul16" "type = (ulong|unsigned long) \\\[16\\\]"
+gdb_test "p sizeof(ul16)" " = 128"
+gdb_test "print ul16" " = \\{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16\\}"
+
+gdb_test "whatis ph" "type = half *"
+gdb_test "whatis *ph" "type = half"
+gdb_test "p sizeof(*ph)" " = 2"
+
+if { ${have_cl_khr_fp16} } {
+ gdb_test "whatis h" "type = half"
+ gdb_test "p sizeof(h)" " = 2"
+ gdb_test "print h" " = 1"
+ gdb_test "whatis h2" "type = half \\\[2\\\]"
+ gdb_test "p sizeof(h2)" " = 4"
+ gdb_test "print h2" " = \\{1, 2\\}"
+ if { ${opencl_version} >= 110 } {
+ gdb_test "whatis h3" "type = half \\\[3\\\]"
+ gdb_test "p sizeof(h3)" " = 8"
+ gdb_test "print h3" " = \\{1, 2, 3\\}"
+ }
+ gdb_test "whatis h4" "type = half \\\[4\\\]"
+ gdb_test "p sizeof(h4)" " = 8"
+ gdb_test "print h4" " = \\{1, 2, 3, 4\\}"
+ gdb_test "whatis h8" "type = half \\\[8\\\]"
+ gdb_test "p sizeof(h8)" " = 16"
+ gdb_test "print h8" " = \\{1, 2, 3, 4, 5, 6, 7, 8\\}"
+ gdb_test "whatis h16" "type = half \\\[16\\\]"
+ gdb_test "p sizeof(h16)" " = 16"
+ gdb_test "print h16" " = \\{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16\\}"
+}
+
+gdb_test "whatis f" "type = float"
+gdb_test "p sizeof(f)" " = 4"
+gdb_test "print f" " = 1"
+gdb_test "whatis f2" "type = float \\\[2\\\]"
+gdb_test "p sizeof(f2)" " = 8"
+gdb_test "print f2" " = \\{1, 2\\}"
+if { ${opencl_version} >= 110 } {
+ gdb_test "whatis f3" "type = float \\\[3\\\]"
+ gdb_test "p sizeof(f3)" " = 16"
+ gdb_test "print f3" " = \\{1, 2, 3\\}"
+}
+gdb_test "whatis f4" "type = float \\\[4\\\]"
+gdb_test "p sizeof(f4)" " = 16"
+gdb_test "print f4" " = \\{1, 2, 3, 4\\}"
+gdb_test "whatis f8" "type = float \\\[8\\\]"
+gdb_test "p sizeof(f8)" " = 32"
+gdb_test "print f8" " = \\{1, 2, 3, 4, 5, 6, 7, 8\\}"
+gdb_test "whatis f16" "type = float \\\[16\\\]"
+gdb_test "p sizeof(f16)" " = 64"
+gdb_test "print f16" " = \\{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16\\}"
+
+if { ${have_cl_khr_fp64} } {
+ gdb_test "whatis d" "type = double"
+ gdb_test "p sizeof(d)" " = 8"
+ gdb_test "print d" " = 1"
+ gdb_test "whatis d2" "type = double \\\[2\\\]"
+ gdb_test "p sizeof(d2)" " = 16"
+ gdb_test "print d2" " = \\{1, 2\\}"
+ if { ${opencl_version} >= 110 } {
+ gdb_test "whatis d3" "type = double \\\[3\\\]"
+ gdb_test "p sizeof(d3)" " = 32"
+ gdb_test "print d3" " = \\{1, 2, 3\\}"
+ }
+ gdb_test "whatis d4" "type = double \\\[4\\\]"
+ gdb_test "p sizeof(d4)" " = 32"
+ gdb_test "print d4" " = \\{1, 2, 3, 4\\}"
+ gdb_test "whatis d8" "type = double \\\[8\\\]"
+ gdb_test "p sizeof(d8)" " = 64"
+ gdb_test "print d8" " = \\{1, 2, 3, 4, 5, 6, 7, 8\\}"
+ gdb_test "whatis d16" "type = double \\\[16\\\]"
+ gdb_test "p sizeof(d16)" " = 128"
+ gdb_test "print d16" " = \\{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16\\}"
+}
+
+# Delete the OpenCL program source
+remote_file target delete ${clprogram}
diff --git a/gdb/testsuite/gdb.opencl/operators.cl b/gdb/testsuite/gdb.opencl/operators.cl
new file mode 100644
index 00000000000..0974c040d39
--- /dev/null
+++ b/gdb/testsuite/gdb.opencl/operators.cl
@@ -0,0 +1,105 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2010 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ Contributed by Ken Werner <ken.werner@de.ibm.com> */
+
+int opencl_version = __OPENCL_VERSION__;
+
+#ifdef HAVE_cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+int have_cl_khr_fp64 = 1;
+#else
+int have_cl_khr_fp64 = 0;
+#endif
+
+#ifdef HAVE_cl_khr_fp16
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+int have_cl_khr_fp16 = 1;
+#else
+int have_cl_khr_fp16 = 0;
+#endif
+
+char ca = 2;
+char cb = 1;
+uchar uca = 2;
+uchar ucb = 1;
+char4 c4a = (char4) (2, 4, 8, 16);
+char4 c4b = (char4) (1, 2, 8, 4);
+uchar4 uc4a = (uchar4) (2, 4, 8, 16);
+uchar4 uc4b = (uchar4) (1, 2, 8, 4);
+
+short sa = 2;
+short sb = 1;
+ushort usa = 2;
+ushort usb = 1;
+short4 s4a = (short4) (2, 4, 8, 16);
+short4 s4b = (short4) (1, 2, 8, 4);
+ushort4 us4a = (ushort4) (2, 4, 8, 16);
+ushort4 us4b = (ushort4) (1, 2, 8, 4);
+
+int ia = 2;
+int ib = 1;
+uint uia = 2;
+uint uib = 1;
+int4 i4a = (int4) (2, 4, 8, 16);
+int4 i4b = (int4) (1, 2, 8, 4);
+uint4 ui4a = (uint4) (2, 4, 8, 16);
+uint4 ui4b = (uint4) (1, 2, 8, 4);
+
+long la = 2;
+long lb = 1;
+ulong ula = 2;
+ulong ulb = 1;
+long4 l4a = (long4) (2, 4, 8, 16);
+long4 l4b = (long4) (1, 2, 8, 4);
+ulong4 ul4a = (ulong4) (2, 4, 8, 16);
+ulong4 ul4b = (ulong4) (1, 2, 8, 4);
+
+#ifdef cl_khr_fp16
+half ha = 2;
+half hb = 1;
+half4 h4a = (half4) (2, 4, 8, 16);
+half4 h4b = (half4) (1, 2, 8, 4);
+#endif
+
+float fa = 2;
+float fb = 1;
+float4 f4a = (float4) (2, 4, 8, 16);
+float4 f4b = (float4) (1, 2, 8, 4);
+
+#ifdef cl_khr_fp64
+double da = 2;
+double db = 1;
+double4 d4a = (double4) (2, 4, 8, 16);
+double4 d4b = (double4) (1, 2, 8, 4);
+#endif
+
+uint4 ui4 = (uint4) (2, 4, 8, 16);
+int2 i2 = (int2) (1, 2);
+long2 l2 = (long2) (1, 2);
+#ifdef cl_khr_fp16
+half2 h2 = (half2) (1, 2);
+#endif
+float2 f2 = (float2) (1, 2);
+#ifdef cl_khr_fp64
+double2 d2 = (double2) (1, 2);
+#endif
+
+__kernel void testkernel (__global int *data)
+{
+ data[get_global_id(0)] = 1;
+}
diff --git a/gdb/testsuite/gdb.opencl/operators.exp b/gdb/testsuite/gdb.opencl/operators.exp
new file mode 100644
index 00000000000..b60c65c9d3c
--- /dev/null
+++ b/gdb/testsuite/gdb.opencl/operators.exp
@@ -0,0 +1,955 @@
+# Copyright 2010 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>. */
+#
+# Contributed by Ken Werner <ken.werner@de.ibm.com>.
+#
+# Tests GDBs support for OpenCL operators.
+
+if $tracelevel {
+ strace $tracelevel
+}
+
+load_lib opencl.exp
+
+if { [skip_opencl_tests] } {
+ return 0
+}
+
+set testfile "operators"
+set clprogram [remote_download target ${srcdir}/${subdir}/${testfile}.cl]
+
+# Compile the generic OpenCL host app
+if { [gdb_compile_opencl_hostapp "${clprogram}" "${testfile}" "" ] != "" } {
+ untested ${testfile}.exp
+ return -1
+}
+
+# Load the OpenCL app
+clean_restart ${testfile}
+
+# Set breakpoint at the OpenCL kernel
+gdb_test_multiple "break testkernel" "set pending breakpoint" {
+ -re ".*Function \"testkernel\" not defined.*Make breakpoint pending.*y or \\\[n\\\]. $" {
+ gdb_test "y" "Breakpoint.*testkernel.*pending." "set pending breakpoint (without symbols)"
+ }
+}
+
+gdb_run_cmd
+gdb_test "" ".*Breakpoint.*1.*testkernel.*" "run"
+
+# Retrieve some information about availability of OpenCL extensions
+set have_cl_khr_fp64 [get_integer_valueof "have_cl_khr_fp64" 0]
+set have_cl_khr_fp16 [get_integer_valueof "have_cl_khr_fp16" 0]
+
+proc check_basic { name type isfloat } {
+ gdb_test "print/d ${name}a" " = 2"
+ gdb_test "print/d ${name}b" " = 1"
+ gdb_test "print/d ${name}4a" " = \\{2, 4, 8, 16\\}"
+ gdb_test "print/d ${name}4b" " = \\{1, 2, 8, 4\\}"
+
+ gdb_test "ptype ${name}a" "type = ${type}"
+ gdb_test "ptype ${name}b" "type = ${type}"
+ gdb_test "ptype ${name}4a" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4b" "type = ${type} \\\[4\\\]"
+
+ if { ! ${isfloat} } {
+ gdb_test "print/d u${name}a" " = 2"
+ gdb_test "print/d u${name}b" " = 1"
+ gdb_test "print/d u${name}4a" " = \\{2, 4, 8, 16\\}"
+ gdb_test "print/d u${name}4b" " = \\{1, 2, 8, 4\\}"
+ gdb_test "ptype u${name}a" "type = (unsigned ${type}|u${type})"
+ gdb_test "ptype u${name}b" "type = (unsigned ${type}|u${type})"
+ gdb_test "ptype u${name}4a" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ }
+}
+
+# Arithmetic operators
+proc check_arithmetic_ops { name type isfloat size } {
+ # scalar with scalar
+ gdb_test "print/d ${name}a + ${name}b" " = 3"
+ gdb_test "print/d ${name}a - ${name}b" " = 1"
+ gdb_test "print/d ${name}a * ${name}b" " = 2"
+ gdb_test "print/d ${name}a / ${name}b" " = 2"
+ # scalar with vector
+ gdb_test "print/d ${name}a + ${name}4b" " = \\{3, 4, 10, 6\\}"
+ gdb_test "print/d ${name}4a - ${name}b" " = \\{1, 3, 7, 15\\}"
+ gdb_test "print/d ${name}4a * ${name}b" " = \\{2, 4, 8, 16\\}"
+ gdb_test "print/d ${name}a / ${name}4b" " = \\{2, 1, 0, 0\\}"
+ # vector with vector
+ gdb_test "print/d ${name}4a + ${name}4b" " = \\{3, 6, 16, 20\\}"
+ gdb_test "print/d ${name}4a - ${name}4b" " = \\{1, 2, 0, 12\\}"
+ gdb_test "print/d ${name}4a * ${name}4b" " = \\{2, 8, 64, 64\\}"
+ gdb_test "print/d ${name}4a / ${name}4b" " = \\{2, 2, 1, 4\\}"
+
+ # scalar
+ gdb_test "print/d ${name}a++" " = 2"
+ gdb_test "print/d ++${name}a" " = 4"
+ gdb_test "print/d ${name}a--" " = 4"
+ gdb_test "print/d --${name}a" " = 2"
+ gdb_test "print/d +${name}a" " = 2"
+ gdb_test "print/d -${name}a" " = -2"
+ # vector
+ gdb_test "print/d ${name}4a++" " = \\{2, 4, 8, 16\\}"
+ gdb_test "print/d ++${name}4a" " = \\{4, 6, 10, 18\\}"
+ gdb_test "print/d ${name}4a--" " = \\{4, 6, 10, 18\\}"
+ gdb_test "print/d --${name}4a" " = \\{2, 4, 8, 16\\}"
+ gdb_test "print/d +${name}4a" " = \\{2, 4, 8, 16\\}"
+ gdb_test "print/d -${name}4a" " = \\{-2, -4, -8, -16\\}"
+
+ # scalar with vector
+ gdb_test "ptype ${name}a + ${name}4b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4a - ${name}b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}a * ${name}4b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4a / ${name}b" "type = ${type} \\\[4\\\]"
+ # vector with vector
+ gdb_test "ptype ${name}4a + ${name}4b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4a - ${name}4b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4a * ${name}4b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4a / ${name}4b" "type = ${type} \\\[4\\\]"
+
+ # scalar
+ gdb_test "ptype ${name}a++" "type = ${type}"
+ gdb_test "ptype ++${name}a" "type = ${type}"
+ gdb_test "ptype ${name}a--" "type = ${type}"
+ gdb_test "ptype --${name}a" "type = ${type}"
+ # vector
+ gdb_test "ptype ${name}4a++" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ++${name}4a" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4a--" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype --${name}4a" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype +${name}4a" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype -${name}4a" "type = ${type} \\\[4\\\]"
+
+ if { ${isfloat} } {
+ # scalar with scalar
+ gdb_test "ptype ${name}a + ${name}b" "type = ${type}"
+ gdb_test "ptype ${name}a - ${name}b" "type = ${type}"
+ gdb_test "ptype ${name}a * ${name}b" "type = ${type}"
+ gdb_test "ptype ${name}a / ${name}b" "type = ${type}"
+ # scalar
+ gdb_test "ptype +${name}a" "type = ${type}"
+ gdb_test "ptype -${name}a" "type = ${type}"
+ } else {
+ # scalar with scalar
+ gdb_test "print/d ${name}a % ${name}b" " = 0"
+ # scalar with vector
+ gdb_test "print/d ${name}4a % ${name}b" " = \\{0, 0, 0, 0\\}"
+ # vector with vector
+ gdb_test "print/d ${name}4a % ${name}b" " = \\{0, 0, 0, 0\\}"
+
+ # scalar with scalar
+ gdb_test "print/d u${name}a + u${name}b" " = 3"
+ gdb_test "print/d u${name}a - u${name}b" " = 1"
+ gdb_test "print/d u${name}a * u${name}b" " = 2"
+ gdb_test "print/d u${name}a / u${name}b" " = 2"
+ gdb_test "print/d u${name}a % u${name}b" " = 0"
+ # scalar with vector
+ gdb_test "print/d u${name}a + u${name}4b" " = \\{3, 4, 10, 6\\}"
+ gdb_test "print/d u${name}4a - u${name}b" " = \\{1, 3, 7, 15\\}"
+ gdb_test "print/d u${name}4a * u${name}b" " = \\{2, 4, 8, 16\\}"
+ gdb_test "print/d u${name}a / u${name}4b" " = \\{2, 1, 0, 0\\}"
+ gdb_test "print/d u${name}4a % u${name}b" " = \\{0, 0, 0, 0\\}"
+ # vector with vector
+ gdb_test "print/d u${name}4a + u${name}4b" " = \\{3, 6, 16, 20\\}"
+ gdb_test "print/d u${name}4a - u${name}4b" " = \\{1, 2, 0, 12\\}"
+ gdb_test "print/d u${name}4a * u${name}4b" " = \\{2, 8, 64, 64\\}"
+ gdb_test "print/d u${name}4a / u${name}4b" " = \\{2, 2, 1, 4\\}"
+ gdb_test "print/d u${name}4a % u${name}4b" " = \\{0, 0, 0, 0\\}"
+
+ # scalar
+ gdb_test "print/d u${name}a++" " = 2"
+ gdb_test "print/d ++u${name}a" " = 4"
+ gdb_test "print/d u${name}a--" " = 4"
+ gdb_test "print/d --u${name}a" " = 2"
+ gdb_test "print/d +u${name}a" " = 2"
+ gdb_test "print/x -u${name}a" " = 0x.*fe"
+ # vector
+ gdb_test "print/d u${name}4a++" " = \\{2, 4, 8, 16\\}"
+ gdb_test "print/d ++u${name}4a" " = \\{4, 6, 10, 18\\}"
+ gdb_test "print/d u${name}4a--" " = \\{4, 6, 10, 18\\}"
+ gdb_test "print/d --u${name}4a" " = \\{2, 4, 8, 16\\}"
+ gdb_test "print/d +u${name}4a" " = \\{2, 4, 8, 16\\}"
+ gdb_test "print/x -u${name}4a" " = \\{0x.*fe, 0x.*fc, 0x.*f8, 0x.*f0\\}"
+
+ # scalar with scalar
+ if { ${size} < 4 } {
+ gdb_test "ptype ${name}a + ${name}b" "type = int"
+ gdb_test "ptype ${name}a - ${name}b" "type = int"
+ gdb_test "ptype ${name}a * ${name}b" "type = int"
+ gdb_test "ptype ${name}a / ${name}b" "type = int"
+ gdb_test "ptype ${name}a % ${name}b" "type = int"
+ gdb_test "ptype +${name}a" "type = int"
+ gdb_test "ptype -${name}a" "type = int"
+ gdb_test "ptype u${name}a + u${name}b" "type = int"
+ gdb_test "ptype u${name}a - u${name}b" "type = int"
+ gdb_test "ptype u${name}a * u${name}b" "type = int"
+ gdb_test "ptype u${name}a / u${name}b" "type = int"
+ gdb_test "ptype u${name}a % u${name}b" "type = int"
+ gdb_test "ptype +u${name}a" "type = int"
+ gdb_test "ptype -u${name}a" "type = int"
+ } elseif { ${size} == 4 } {
+ gdb_test "ptype ${name}a + ${name}b" "type = int"
+ gdb_test "ptype ${name}a - ${name}b" "type = int"
+ gdb_test "ptype ${name}a * ${name}b" "type = int"
+ gdb_test "ptype ${name}a / ${name}b" "type = int"
+ gdb_test "ptype ${name}a % ${name}b" "type = int"
+ gdb_test "ptype +${name}a" "type = int"
+ gdb_test "ptype -${name}a" "type = int"
+ gdb_test "ptype u${name}a + u${name}b" "type = (unsigned int|uint)"
+ gdb_test "ptype u${name}a - u${name}b" "type = (unsigned int|uint)"
+ gdb_test "ptype u${name}a * u${name}b" "type = (unsigned int|uint)"
+ gdb_test "ptype u${name}a / u${name}b" "type = (unsigned int|uint)"
+ gdb_test "ptype u${name}a % u${name}b" "type = (unsigned int|uint)"
+ gdb_test "ptype +u${name}a" "type = (unsigned int|uint)"
+ gdb_test "ptype -u${name}a" "type = (unsigned int|uint)"
+ } else { # ${size} == 8
+ gdb_test "ptype ${name}a + ${name}b" "type = long"
+ gdb_test "ptype ${name}a - ${name}b" "type = long"
+ gdb_test "ptype ${name}a * ${name}b" "type = long"
+ gdb_test "ptype ${name}a / ${name}b" "type = long"
+ gdb_test "ptype ${name}a % ${name}b" "type = long"
+ gdb_test "ptype +${name}a" "type = long"
+ gdb_test "ptype -${name}a" "type = long"
+ gdb_test "ptype u${name}a + u${name}b" "type = (unsigned long|ulong)"
+ gdb_test "ptype u${name}a - u${name}b" "type = (unsigned long|ulong)"
+ gdb_test "ptype u${name}a * u${name}b" "type = (unsigned long|ulong)"
+ gdb_test "ptype u${name}a / u${name}b" "type = (unsigned long|ulong)"
+ gdb_test "ptype u${name}a % u${name}b" "type = (unsigned long|ulong)"
+ # scalar
+ gdb_test "ptype +u${name}a" "type = (unsigned long|ulong)"
+ gdb_test "ptype -u${name}a" "type = (unsigned long|ulong)"
+ }
+ gdb_test "ptype u${name}a++" "type = (unsigned ${type}|u${type})"
+ gdb_test "ptype ++u${name}a" "type = (unsigned ${type}|u${type})"
+ gdb_test "ptype u${name}a--" "type = (unsigned ${type}|u${type})"
+ gdb_test "ptype --u${name}a" "type = (unsigned ${type}|u${type})"
+ # scalar with vector
+ gdb_test "ptype ${name}a % ${name}4b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype u${name}a + u${name}4b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a - u${name}b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}a * u${name}4b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a / u${name}b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}a % u${name}4b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ # vector with vector
+ gdb_test "ptype ${name}4a % ${name}4b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype u${name}4a + u${name}4b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a - u${name}4b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a * u${name}4b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a / u${name}4b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a % u${name}4b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a++" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype ++u${name}4a" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a--" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype --u${name}4a" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype +u${name}4a" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype -u${name}4a" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ }
+}
+
+# Relational operators
+proc check_relational_ops { name type isfloat size } {
+ # scalar with scalar
+ gdb_test "print/d ${name}a > ${name}b" " = 1"
+ gdb_test "print/d ${name}b < ${name}a" " = 1"
+ gdb_test "print/d ${name}b >= ${name}a" " = 0"
+ gdb_test "print/d ${name}a <= ${name}b" " = 0"
+ # scalar with vector
+ gdb_test "print/d ${name}4a > ${name}b" " = \\{-1, -1, -1, -1\\}"
+ gdb_test "print/d ${name}a < ${name}4b" " = \\{0, 0, -1, -1\\}"
+ gdb_test "print/d ${name}4a >= ${name}b" " = \\{-1, -1, -1, -1\\}"
+ gdb_test "print/d ${name}a <= ${name}4b" " = \\{0, -1, -1, -1\\}"
+ # vector with vector
+ gdb_test "print/d ${name}4a > ${name}4b" " = \\{-1, -1, 0, -1\\}"
+ gdb_test "print/d ${name}4b < ${name}4a" " = \\{-1, -1, 0, -1\\}"
+ gdb_test "print/d ${name}4b >= ${name}4a" " = \\{0, 0, -1, 0\\}"
+ gdb_test "print/d ${name}4a <= ${name}4b" " = \\{0, 0, -1, 0\\}"
+
+ # result type should be int for scalars
+ gdb_test "ptype ${name}a < ${name}b" "type = int"
+ gdb_test "ptype ${name}a > ${name}b" "type = int"
+ gdb_test "ptype ${name}a <= ${name}b" "type = int"
+ gdb_test "ptype ${name}a >= ${name}b" "type = int"
+
+ if { ${isfloat} } {
+ if { ${size} == 2 } {
+ # result type should be short for half precision floating point vectors
+ # scalar with vector
+ gdb_test "ptype ${name}4a > ${name}b" "type = short \\\[4\\\]"
+ gdb_test "ptype ${name}a < ${name}4b" "type = short \\\[4\\\]"
+ gdb_test "ptype ${name}4a >= ${name}b" "type = short \\\[4\\\]"
+ gdb_test "ptype ${name}a <= ${name}4b" "type = short \\\[4\\\]"
+ # vector with vector
+ gdb_test "ptype ${name}4a > ${name}4b" "type = short \\\[4\\\]"
+ gdb_test "ptype ${name}4a < ${name}4b" "type = short \\\[4\\\]"
+ gdb_test "ptype ${name}4a >= ${name}4b" "type = short \\\[4\\\]"
+ gdb_test "ptype ${name}4a <= ${name}4b" "type = short \\\[4\\\]"
+ } elseif { ${size} == 4 } {
+ # result type should be int for single precision floating point vectors
+ # scalar with vector
+ gdb_test "ptype ${name}4a > ${name}b" "type = int \\\[4\\\]"
+ gdb_test "ptype ${name}a < ${name}4b" "type = int \\\[4\\\]"
+ gdb_test "ptype ${name}4a >= ${name}b" "type = int \\\[4\\\]"
+ gdb_test "ptype ${name}a <= ${name}4b" "type = int \\\[4\\\]"
+ # vector with vector
+ gdb_test "ptype ${name}4a > ${name}4b" "type = int \\\[4\\\]"
+ gdb_test "ptype ${name}4a < ${name}4b" "type = int \\\[4\\\]"
+ gdb_test "ptype ${name}4a >= ${name}4b" "type = int \\\[4\\\]"
+ gdb_test "ptype ${name}4a <= ${name}4b" "type = int \\\[4\\\]"
+ } else { # ${size} == 8
+ # result type should be long for double precision floating point vectors
+ # scalar with vector
+ gdb_test "ptype ${name}4a > ${name}b" "type = long \\\[4\\\]"
+ gdb_test "ptype ${name}a < ${name}4b" "type = long \\\[4\\\]"
+ gdb_test "ptype ${name}4a >= ${name}b" "type = long \\\[4\\\]"
+ gdb_test "ptype ${name}a <= ${name}4b" "type = long \\\[4\\\]"
+ # vector with vector
+ gdb_test "ptype ${name}4a > ${name}4b" "type = long \\\[4\\\]"
+ gdb_test "ptype ${name}4a < ${name}4b" "type = long \\\[4\\\]"
+ gdb_test "ptype ${name}4a >= ${name}4b" "type = long \\\[4\\\]"
+ gdb_test "ptype ${name}4a <= ${name}4b" "type = long \\\[4\\\]"
+ }
+ } else {
+ # scalar with scalar
+ gdb_test "print/d u${name}a > u${name}b" " = 1"
+ gdb_test "print/d u${name}b < u${name}a" " = 1"
+ gdb_test "print/d u${name}b >= u${name}a" " = 0"
+ gdb_test "print/d u${name}a <= u${name}b" " = 0"
+ # scalar with vector
+ gdb_test "print/d u${name}4a > u${name}b" " = \\{-1, -1, -1, -1\\}"
+ gdb_test "print/d u${name}a < u${name}4b" " = \\{0, 0, -1, -1\\}"
+ gdb_test "print/d u${name}4a >= u${name}b" " = \\{-1, -1, -1, -1\\}"
+ gdb_test "print/d u${name}a <= u${name}4b" " = \\{0, -1, -1, -1\\}"
+ # vector with vector
+ gdb_test "print/d u${name}4a > u${name}4b" " = \\{-1, -1, 0, -1\\}"
+ gdb_test "print/d u${name}4b < u${name}4a" " = \\{-1, -1, 0, -1\\}"
+ gdb_test "print/d u${name}4b >= u${name}4a" " = \\{0, 0, -1, 0\\}"
+ gdb_test "print/d u${name}4a <= u${name}4b" " = \\{0, 0, -1, 0\\}"
+
+ # result type for unsigned operands is signed
+ # scalar with scalar
+ gdb_test "ptype u${name}a < u${name}b" "type = int"
+ gdb_test "ptype u${name}a > u${name}b" "type = int"
+ gdb_test "ptype u${name}a <= u${name}b" "type = int"
+ gdb_test "ptype u${name}a >= u${name}b" "type = int"
+ # scalar with vector
+ gdb_test "ptype u${name}4a > u${name}b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype u${name}a < u${name}4b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype u${name}4a >= u${name}b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype u${name}a <= u${name}4b" "type = ${type} \\\[4\\\]"
+ # vector with vector
+ gdb_test "ptype u${name}4a > u${name}4b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype u${name}4a < u${name}4b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype u${name}4a >= u${name}4b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype u${name}4a <= u${name}4b" "type = ${type} \\\[4\\\]"
+ }
+}
+
+# Equality operators
+proc check_equality_ops { name type isfloat size } {
+ # scalar with scalar
+ gdb_test "print/d ${name}a == ${name}b" " = 0"
+ gdb_test "print/d ${name}a != ${name}b" " = 1"
+ # scalar with vector
+ gdb_test "print/d ${name}4a == ${name}b" " = \\{0, 0, 0, 0\\}"
+ gdb_test "print/d ${name}a != ${name}4b" " = \\{-1, 0, -1, -1\\}"
+ # vector with vector
+ gdb_test "print/d ${name}4a == ${name}4b" " = \\{0, 0, -1, 0\\}"
+ gdb_test "print/d ${name}4a != ${name}4b" " = \\{-1, -1, 0, -1\\}"
+
+ # scalar with scalar
+ gdb_test "ptype ${name}a == ${name}b" "type = int"
+ gdb_test "ptype ${name}a != ${name}b" "type = int"
+
+ if { ${isfloat} } {
+ if { ${size} == 2 } {
+ # result type should be short for half precision floating point vectors
+ # scalar with vector
+ gdb_test "ptype ${name}4a == ${name}b" "type = short \\\[4\\\]"
+ gdb_test "ptype ${name}a != ${name}4b" "type = short \\\[4\\\]"
+ # vector with vector
+ gdb_test "ptype ${name}4a == ${name}4b" "type = short \\\[4\\\]"
+ gdb_test "ptype ${name}4a != ${name}4b" "type = short \\\[4\\\]"
+ } elseif { ${size} == 4 } {
+ # result type should be int for single precision floating point vectors
+ # scalar with vector
+ gdb_test "ptype ${name}4a == ${name}b" "type = int \\\[4\\\]"
+ gdb_test "ptype ${name}a != ${name}4b" "type = int \\\[4\\\]"
+ # vector with vector
+ gdb_test "ptype ${name}4a == ${name}4b" "type = int \\\[4\\\]"
+ gdb_test "ptype ${name}4a != ${name}4b" "type = int \\\[4\\\]"
+ } else { # ${size} == 8
+ # result type should be long for double precision floating point vectors
+ # scalar with vector
+ gdb_test "ptype ${name}4a == ${name}b" "type = long \\\[4\\\]"
+ gdb_test "ptype ${name}a != ${name}4b" "type = long \\\[4\\\]"
+ # vector with vector
+ gdb_test "ptype ${name}4a == ${name}4b" "type = long \\\[4\\\]"
+ gdb_test "ptype ${name}4a != ${name}4b" "type = long \\\[4\\\]"
+ }
+ } else {
+ # scalar with scalar
+ gdb_test "print/d u${name}a == u${name}b" " = 0"
+ gdb_test "print/d u${name}a != u${name}b" " = 1"
+ # scalar with vector
+ gdb_test "print/d u${name}4a == u${name}b" " = \\{0, 0, 0, 0\\}"
+ gdb_test "print/d u${name}a != u${name}4b" " = \\{-1, 0, -1, -1\\}"
+ # vector with vector
+ gdb_test "print/d u${name}4a == u${name}4b" " = \\{0, 0, -1, 0\\}"
+ gdb_test "print/d u${name}4b != u${name}4a" " = \\{-1, -1, 0, -1\\}"
+
+ # result type for unsigned operands is signed
+ # scalar with scalar
+ gdb_test "ptype u${name}a == u${name}b" "type = int"
+ gdb_test "ptype u${name}a != u${name}b" "type = int"
+ # scalar with vector
+ gdb_test "ptype u${name}4a == u${name}b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype u${name}a != u${name}4b" "type = ${type} \\\[4\\\]"
+ # vector with vector
+ gdb_test "ptype u${name}4a == u${name}4b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype u${name}4a != u${name}4b" "type = ${type} \\\[4\\\]"
+ }
+}
+
+# Shift operators
+proc check_shift_ops { name type size } {
+ # scalar with scalar
+ gdb_test "print/d ${name}a << ${name}b" " = 4"
+ gdb_test "print/d ${name}a >> ${name}b" " = 1"
+ gdb_test "print/d u${name}a << u${name}b" " = 4"
+ gdb_test "print/d u${name}a >> u${name}b" " = 1"
+ # scalar with vector
+ gdb_test "print/d ${name}4a << ${name}b" " = \\{4, 8, 16, 32\\}"
+ gdb_test "print/d ${name}4a >> ${name}b" " = \\{1, 2, 4, 8\\}"
+ gdb_test "print/d u${name}4a << u${name}b" " = \\{4, 8, 16, 32\\}"
+ gdb_test "print/d u${name}4a >> u${name}b" " = \\{1, 2, 4, 8\\}"
+ # vector with vector
+ if { ${size} == 1 } {
+ gdb_test "print/d ${name}4a << ${name}4b" " = \\{4, 16, 0, 0\\}"
+ gdb_test "print/d u${name}4a << u${name}4b" " = \\{4, 16, 0, 0\\}"
+ } else {
+ gdb_test "print/d ${name}4a << ${name}4b" " = \\{4, 16, 2048, 256\\}"
+ gdb_test "print/d u${name}4a << u${name}4b" " = \\{4, 16, 2048, 256\\}"
+ }
+ gdb_test "print/d ${name}4a >> ${name}4b" " = \\{1, 1, 0, 1\\}"
+ gdb_test "print/d u${name}4a >> u${name}4b" " = \\{1, 1, 0, 1\\}"
+
+ # scalar with scalar
+ if { ${size} < 4 } {
+ gdb_test "ptype ${name}a << ${name}b" "type = int"
+ gdb_test "ptype ${name}a >> ${name}b" "type = int"
+ gdb_test "ptype u${name}a << u${name}b" "type = int"
+ gdb_test "ptype u${name}a >> u${name}b" "type = int"
+ } elseif { ${size} == 4 } {
+ gdb_test "ptype ${name}a << ${name}b" "type = int"
+ gdb_test "ptype ${name}a >> ${name}b" "type = int"
+ gdb_test "ptype u${name}a << u${name}b" "type = (unsigned int|uint)"
+ gdb_test "ptype u${name}a >> u${name}b" "type = (unsigned int|uint)"
+ } else { # ${size} == 8
+ gdb_test "ptype ${name}a << ${name}b" "type = long"
+ gdb_test "ptype ${name}a >> ${name}b" "type = long"
+ gdb_test "ptype u${name}a << u${name}b" "type = (unsigned long|ulong)"
+ gdb_test "ptype u${name}a >> u${name}b" "type = (unsigned long|ulong)"
+ }
+ # scalar with vector
+ gdb_test "ptype ${name}4a << ${name}b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4a >> ${name}b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype u${name}4a << u${name}b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a >> u${name}b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ # vector with vector
+ gdb_test "ptype ${name}4a << ${name}4b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4a >> ${name}4b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype u${name}4a << u${name}4b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a >> u${name}4b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+}
+
+# Bitwise operators
+proc check_bitwise_ops { name type size } {
+ # scalar with scalar
+ gdb_test "print/d ${name}a & ${name}b" " = 0"
+ gdb_test "print/d ${name}a | ${name}b" " = 3"
+ gdb_test "print/d ${name}a ^ ${name}b" " = 3"
+ gdb_test "print/d u${name}a & u${name}b" " = 0"
+ gdb_test "print/d u${name}a | u${name}b" " = 3"
+ gdb_test "print/d u${name}a ^ u${name}b" " = 3"
+ # scalar with vector
+ gdb_test "print/d ${name}4a & ${name}b" " = \\{0, 0, 0, 0\\}"
+ gdb_test "print/d ${name}a | ${name}4b" " = \\{3, 2, 10, 6\\}"
+ gdb_test "print/d ${name}4a ^ ${name}b" " = \\{3, 5, 9, 17\\}"
+ gdb_test "print/d u${name}4a & u${name}b" " = \\{0, 0, 0, 0\\}"
+ gdb_test "print/d u${name}a | u${name}4b" " = \\{3, 2, 10, 6\\}"
+ gdb_test "print/d u${name}4a ^ u${name}b" " = \\{3, 5, 9, 17\\}"
+ # vector with vector
+ gdb_test "print/d ${name}4a & ${name}4b" " = \\{0, 0, 8, 0\\}"
+ gdb_test "print/d ${name}4a | ${name}4b" " = \\{3, 6, 8, 20\\}"
+ gdb_test "print/d ${name}4a ^ ${name}4b" " = \\{3, 6, 0, 20\\}"
+ gdb_test "print/d u${name}4a & u${name}4b" " = \\{0, 0, 8, 0\\}"
+ gdb_test "print/d u${name}4a | u${name}4b" " = \\{3, 6, 8, 20\\}"
+ gdb_test "print/d u${name}4a ^ u${name}4b" " = \\{3, 6, 0, 20\\}"
+
+ # scalar with scalar
+ if { ${size} < 4 } {
+ gdb_test "ptype ${name}a & ${name}b" "type = int"
+ gdb_test "ptype ${name}a | ${name}b" "type = int"
+ gdb_test "ptype ${name}a ^ ${name}b" "type = int"
+ gdb_test "ptype u${name}a & u${name}b" "type = int"
+ gdb_test "ptype u${name}a | u${name}b" "type = int"
+ gdb_test "ptype u${name}a ^ u${name}b" "type = int"
+ } elseif { ${size} == 4 } {
+ gdb_test "ptype ${name}a & ${name}b" "type = int"
+ gdb_test "ptype ${name}a | ${name}b" "type = int"
+ gdb_test "ptype ${name}a ^ ${name}b" "type = int"
+ gdb_test "ptype u${name}a & u${name}b" "type = (unsigned int|uint)"
+ gdb_test "ptype u${name}a | u${name}b" "type = (unsigned int|uint)"
+ gdb_test "ptype u${name}a ^ u${name}b" "type = (unsigned int|uint)"
+ } else { # ${size} == 8
+ gdb_test "ptype ${name}a & ${name}b" "type = long"
+ gdb_test "ptype ${name}a | ${name}b" "type = long"
+ gdb_test "ptype ${name}a ^ ${name}b" "type = long"
+ gdb_test "ptype u${name}a & u${name}b" "type = (unsigned long|ulong)"
+ gdb_test "ptype u${name}a | u${name}b" "type = (unsigned long|ulong)"
+ gdb_test "ptype u${name}a ^ u${name}b" "type = (unsigned long|ulong)"
+ }
+ # scalar with vector
+ gdb_test "ptype ${name}4a & ${name}b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}a | ${name}4b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4a ^ ${name}b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype u${name}4a & u${name}b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}a | u${name}4b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a ^ u${name}b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ # vector with vector
+ gdb_test "ptype ${name}4a & ${name}4b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4a | ${name}4b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4a ^ ${name}4b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype u${name}4a & u${name}4b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a | u${name}4b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a ^ u${name}4b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+
+ # scalar
+ if { ${size} < 8 } {
+ gdb_test "print/x ~${name}a" " = 0xfffffffd"
+ gdb_test "print/x ~u${name}a" " = 0xfffffffd"
+ } else {
+ gdb_test "print/x ~${name}a" " = 0xfffffffffffffffd"
+ gdb_test "print/x ~u${name}a" " = 0xfffffffffffffffd"
+ }
+ # vector
+ if { ${size} == 1 } {
+ gdb_test "print/x ~${name}4a" " = \\{0xfd, 0xfb, 0xf7, 0xef\\}"
+ gdb_test "print/x ~u${name}4a" " = \\{0xfd, 0xfb, 0xf7, 0xef\\}"
+ } elseif { ${size} == 2 } {
+ gdb_test "print/x ~${name}4a" " = \\{0xfffd, 0xfffb, 0xfff7, 0xffef\\}"
+ gdb_test "print/x ~u${name}4a" " = \\{0xfffd, 0xfffb, 0xfff7, 0xffef\\}"
+ } elseif { ${size} == 4 } {
+ gdb_test "print/x ~${name}4a" " = \\{0xfffffffd, 0xfffffffb, 0xfffffff7, 0xffffffef\\}"
+ gdb_test "print/x ~u${name}4a" " = \\{0xfffffffd, 0xfffffffb, 0xfffffff7, 0xffffffef\\}"
+ } else { # ${size} == 8
+ gdb_test "print/x ~${name}4a" " = \\{0xfffffffffffffffd, 0xfffffffffffffffb, 0xfffffffffffffff7, 0xffffffffffffffef\\}"
+ gdb_test "print/x ~u${name}4a" " = \\{0xfffffffffffffffd, 0xfffffffffffffffb, 0xfffffffffffffff7, 0xffffffffffffffef\\}"
+ }
+ # scalar
+ if { ${size} < 4 } {
+ gdb_test "ptype ~${name}a" "type = int"
+ gdb_test "ptype ~u${name}a" "type = int"
+ } elseif { ${size} == 4 } {
+ gdb_test "ptype ~${name}a" "type = int"
+ gdb_test "ptype ~u${name}a" "type = (unsigned int|uint)"
+ } else { # ${size} == 8
+ gdb_test "ptype ~${name}a" "type = long"
+ gdb_test "ptype ~u${name}a" "type = (unsigned long|ulong)"
+ }
+ # vector
+ gdb_test "ptype ~${name}4a" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ~u${name}4a" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+}
+
+# Logical operators
+proc check_logical_ops { name type isfloat size } {
+ # scalar
+ gdb_test "print/d !${name}a " " = 0"
+ gdb_test "print/d !!${name}a " " = 1"
+ # vector
+ gdb_test "print/d !${name}4a " " = \\{0, 0, 0, 0\\}"
+ gdb_test "print/d !!${name}4a " " = \\{-1, -1, -1, -1\\}"
+
+ # scalar with scalar
+ gdb_test "print/d ${name}a && ${name}b" " = 1"
+ gdb_test "print/d ${name}a && !${name}b" " = 0"
+ gdb_test "print/d ${name}a || ${name}b" " = 1"
+ gdb_test "print/d ${name}a || !${name}b" " = 1"
+ gdb_test "print/d !${name}a || !${name}b" " = 0"
+
+ # scalar with vector
+ gdb_test "print/d ${name}4a && ${name}b" " = \\{-1, -1, -1, -1\\}"
+ gdb_test "print/d ${name}4a && !${name}b" " = \\{0, 0, 0, 0\\}"
+ gdb_test "print/d ${name}a || ${name}4b" " = \\{-1, -1, -1, -1\\}"
+ gdb_test "print/d ${name}a || !${name}4b" " = \\{-1, -1, -1, -1\\}"
+ gdb_test "print/d !${name}4a || !${name}b" " = \\{0, 0, 0, 0\\}"
+ # vector with vector
+ gdb_test "print/d ${name}4a && ${name}4b" " = \\{-1, -1, -1, -1\\}"
+ gdb_test "print/d ${name}4a || ${name}4b" " = \\{-1, -1, -1, -1\\}"
+
+ # result type should be int for scalars
+ gdb_test "ptype !${name}a" "type = int"
+ gdb_test "ptype ${name}a && ${name}b" "type = int"
+ gdb_test "ptype ${name}a || ${name}b" "type = int"
+
+ if { ${isfloat} } {
+ if { ${size} == 2 } {
+ # result type should be short for half precision floating point vectors
+ # scalar with vector
+ gdb_test "ptype ${name}4a && ${name}b" "type = short \\\[4\\\]"
+ gdb_test "ptype ${name}a || ${name}4b" "type = short \\\[4\\\]"
+ # vector with vector
+ gdb_test "ptype !${name}4a" "type = short \\\[4\\\]"
+ gdb_test "ptype ${name}4a && ${name}4b" "type = short \\\[4\\\]"
+ gdb_test "ptype ${name}4a || ${name}4b" "type = short \\\[4\\\]"
+ } elseif { ${size} == 4 } {
+ # result type should be int for single precision floating point vectors
+ # scalar with vector
+ gdb_test "ptype ${name}4a && ${name}b" "type = int \\\[4\\\]"
+ gdb_test "ptype ${name}a || ${name}4b" "type = int \\\[4\\\]"
+ # vector with vector
+ gdb_test "ptype !${name}4a" "type = int \\\[4\\\]"
+ gdb_test "ptype ${name}4a && ${name}4b" "type = int \\\[4\\\]"
+ gdb_test "ptype ${name}4a || ${name}4b" "type = int \\\[4\\\]"
+ } else { # ${size} == 8
+ # result type should be long for double precision floating point vectors
+ # scalar with vector
+ gdb_test "ptype ${name}4a && ${name}b" "type = long \\\[4\\\]"
+ gdb_test "ptype ${name}a || ${name}4b" "type = long \\\[4\\\]"
+ # vector with vector
+ gdb_test "ptype !${name}4a" "type = long \\\[4\\\]"
+ gdb_test "ptype ${name}4a && ${name}4b" "type = long \\\[4\\\]"
+ gdb_test "ptype ${name}4a || ${name}4b" "type = long \\\[4\\\]"
+ }
+ } else {
+ # unsigned scalar
+ gdb_test "print/d !u${name}a " " = 0"
+ gdb_test "print/d !!u${name}a " " = 1"
+ # unsigned vector
+ gdb_test "print/d !u${name}4a " " = \\{0, 0, 0, 0\\}"
+ gdb_test "print/d !!u${name}4a " " = \\{-1, -1, -1, -1\\}"
+
+ # scalar with scalar
+ gdb_test "print/d u${name}a && u${name}b" " = 1"
+ gdb_test "print/d u${name}a || u${name}b" " = 1"
+ # scalar with vector
+ gdb_test "print/d u${name}4a && u${name}b" " = \\{-1, -1, -1, -1\\}"
+ gdb_test "print/d u${name}a || u${name}4b" " = \\{-1, -1, -1, -1\\}"
+ # vector with vector
+ gdb_test "print/d u${name}4a && u${name}4b" " = \\{-1, -1, -1, -1\\}"
+ gdb_test "print/d u${name}4a || u${name}4b" " = \\{-1, -1, -1, -1\\}"
+
+ # scalar
+ gdb_test "ptype !u${name}a" "type = int"
+ # vector
+ gdb_test "ptype !${name}4a" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype !u${name}4a" "type = ${type} \\\[4\\\]"
+
+ # scalar with vector
+ gdb_test "ptype ${name}4a && ${name}b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}a || ${name}4b" "type = ${type} \\\[4\\\]"
+ # result type for unsigned vector operand is signed
+ gdb_test "ptype u${name}4a && u${name}b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype u${name}a || u${name}4b" "type = ${type} \\\[4\\\]"
+ # vector with vector
+ gdb_test "ptype ${name}4a && ${name}4b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4a || ${name}4b" "type = ${type} \\\[4\\\]"
+ # result type for unsigned vector operand is signed
+ gdb_test "ptype u${name}4a && u${name}4b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype u${name}4a || u${name}4b" "type = ${type} \\\[4\\\]"
+ }
+}
+
+# Conditional operator
+proc check_conditional_op { name type isfloat } {
+ # scalar with scalar
+ gdb_test "print/d ${name}a ? ${name}b : ${name}a" " = 1"
+ gdb_test "print/d !${name}a ? ${name}b : ${name}a" " = 2"
+ # scalar with vector
+ gdb_test "print/d ${name}4a ? ${name}4b : ${name}a" " = \\{1, 2, 8, 4\\}"
+ gdb_test "print/d ${name}4a ? ${name}b : ${name}4a" " = \\{1, 1, 1, 1\\}"
+ gdb_test "print/d ${name}4a > 4 ? 1 : ${name}4a" " = \\{2, 4, 1, 1\\}"
+ gdb_test "print/d ${name}4a > 4 ? ${name}4b : ${name}a" " = \\{2, 2, 8, 4\\}"
+ # vector with vector
+ gdb_test "print/d ${name}4a ? ${name}4b : ${name}4a" " = \\{1, 2, 8, 4\\}"
+ gdb_test "print/d ${name}4a > 4 ? ${name}4b : ${name}4a" " = \\{2, 4, 8, 4\\}"
+
+ # scalar with scalar
+ gdb_test "ptype ${name}a ? ${name}b : ${name}a" "type = ${type}"
+ # scalar with vector
+ gdb_test "ptype ${name}4a ? ${name}4b : ${name}a" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4a ? ${name}b : ${name}4a" "type = ${type} \\\[4\\\]"
+ # vector with vector
+ gdb_test "ptype ${name}4a ? ${name}4b : ${name}4a" "type = ${type} \\\[4\\\]"
+
+ if { !${isfloat} } {
+ # scalar with scalar
+ gdb_test "print/d u${name}a ? u${name}b : u${name}a" " = 1"
+ gdb_test "print/d !u${name}a ? u${name}b : u${name}a" " = 2"
+ # scalar with vector
+ gdb_test "print/d u${name}4a ? u${name}4b : u${name}a" " = \\{1, 2, 8, 4\\}"
+ gdb_test "print/d u${name}4a ? u${name}b : u${name}4a" " = \\{1, 1, 1, 1\\}"
+ gdb_test "print/d u${name}4a > 4 ? 1 : u${name}4a" " = \\{2, 4, 1, 1\\}"
+ gdb_test "print/d u${name}4a > 4 ? u${name}4b : u${name}a" " = \\{2, 2, 8, 4\\}"
+ # vector with vector
+ gdb_test "print/d u${name}4a ? u${name}4b : u${name}4a" " = \\{1, 2, 8, 4\\}"
+ gdb_test "print/d u${name}4a > 4 ? u${name}4b : u${name}4a" " = \\{2, 4, 8, 4\\}"
+
+ # scalar with scalar
+ gdb_test "ptype u${name}a ? u${name}b : u${name}a" "type = (unsigned ${type}|u${type})"
+ # scalar with vector
+ gdb_test "ptype u${name}4a ? u${name}4b : u${name}a" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a ? u${name}b : u${name}4a" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ # vector with vector
+ gdb_test "ptype u${name}4a ? u${name}4b : u${name}4a" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ }
+}
+
+# Assignment operators
+proc check_assignment_ops { name type isfloat size } {
+ # scalar with scalar
+ gdb_test "print/d ${name}a = ${name}b" " = 1"
+ gdb_test "print/d ${name}a = 2" " = 2"
+ gdb_test "print/d ${name}a += ${name}b" " = 3"
+ gdb_test "print/d ${name}a -= ${name}b" " = 2"
+ gdb_test "print/d ${name}b *= ${name}a" " = 2"
+ gdb_test "print/d ${name}b /= ${name}a" " = 1"
+ # scalar with vector
+ gdb_test "print/d ${name}4a = ${name}b" " = \\{1, 1, 1, 1\\}"
+ gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
+ gdb_test "print/d ${name}4a += ${name}b" " = \\{3, 5, 9, 17\\}"
+ gdb_test "print/d ${name}4a -= ${name}b" " = \\{2, 4, 8, 16\\}"
+ gdb_test "print/d ${name}4b *= ${name}a" " = \\{2, 4, 16, 8\\}"
+ gdb_test "print/d ${name}4b /= ${name}a" " = \\{1, 2, 8, 4\\}"
+ # vector with vector
+ gdb_test "print/d ${name}4a = ${name}4b" " = \\{1, 2, 8, 4\\}"
+ gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
+ gdb_test "print/d ${name}4a += ${name}4b" " = \\{3, 6, 16, 20\\}"
+ gdb_test "print/d ${name}4a -= ${name}4b" " = \\{2, 4, 8, 16\\}"
+ gdb_test "print/d ${name}4b *= ${name}4a" " = \\{2, 8, 64, 64\\}"
+ gdb_test "print/d ${name}4b /= ${name}4a" " = \\{1, 2, 8, 4\\}"
+
+ # scalar with scalar
+ gdb_test "ptype ${name}a = ${name}b" "type = ${type}"
+ gdb_test "ptype ${name}a += ${name}b" "type = ${type}"
+ gdb_test "ptype ${name}a -= ${name}b" "type = ${type}"
+ gdb_test "ptype ${name}a *= ${name}b" "type = ${type}"
+ gdb_test "ptype ${name}a /= ${name}b" "type = ${type}"
+ # scalar with vector
+ gdb_test "ptype ${name}4a = ${name}b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4a += ${name}b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4a -= ${name}b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4b *= ${name}a" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4b /= ${name}a" "type = ${type} \\\[4\\\]"
+ # vector with vector
+ gdb_test "ptype ${name}4a = ${name}4b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4a += ${name}4b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4a -= ${name}4b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4b *= ${name}4a" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4b /= ${name}4a" "type = ${type} \\\[4\\\]"
+
+ if { !${isfloat} } {
+ # scalar with scalar
+ gdb_test "print/d ${name}a %= ${name}b" " = 0"
+ gdb_test "print/d ${name}a = 2" " = 2"
+ gdb_test "print/d ${name}a <<= ${name}b" " = 4"
+ gdb_test "print/d ${name}a = 2" " = 2"
+ gdb_test "print/d ${name}a >>= ${name}b" " = 1"
+ gdb_test "print/d ${name}a = 2" " = 2"
+ gdb_test "print/d ${name}a &= ${name}b" " = 0"
+ gdb_test "print/d ${name}a = 2" " = 2"
+ gdb_test "print/d ${name}a |= ${name}b" " = 3"
+ gdb_test "print/d ${name}a = 2" " = 2"
+ gdb_test "print/d ${name}a ^= ${name}b" " = 3"
+ gdb_test "print/d ${name}a = 2" " = 2"
+ # scalar with vector
+ gdb_test "print/d ${name}4b %= ${name}a" " = \\{1, 0, 0, 0\\}"
+ gdb_test "print/d ${name}4b = \{1, 2, 8, 4\}" " = \\{1, 2, 8, 4\\}"
+ gdb_test "print/d ${name}4a <<= ${name}b" " = \\{4, 8, 16, 32\\}"
+ gdb_test "print/d ${name}4a >>= ${name}b" " = \\{2, 4, 8, 16\\}"
+ gdb_test "print/d ${name}4a &= ${name}b" " = \\{0, 0, 0, 0\\}"
+ gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
+ gdb_test "print/d ${name}4a |= ${name}b" " = \\{3, 5, 9, 17\\}"
+ gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
+ gdb_test "print/d ${name}4a ^= ${name}b" " = \\{3, 5, 9, 17\\}"
+ gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
+ # vector with vector
+ gdb_test "print/d ${name}4b %= ${name}4a" " = \\{1, 2, 0, 4\\}"
+ gdb_test "print/d ${name}4b = \{1, 2, 8, 4\}" " = \\{1, 2, 8, 4\\}"
+ if { ${size} == 1 } {
+ gdb_test "print/d ${name}4a <<= ${name}4b" " = \\{4, 16, 0, 0\\}"
+ gdb_test "print/d ${name}4a >>= ${name}4b" " = \\{2, 4, 0, 0\\}"
+ gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
+ } else {
+ gdb_test "print/d ${name}4a <<= ${name}4b" " = \\{4, 16, 2048, 256\\}"
+ gdb_test "print/d ${name}4a >>= ${name}4b" " = \\{2, 4, 8, 16\\}"
+ }
+ gdb_test "print/d ${name}4a &= ${name}4b" " = \\{0, 0, 8, 0\\}"
+ gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
+ gdb_test "print/d ${name}4a |= ${name}4b" " = \\{3, 6, 8, 20\\}"
+ gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
+ gdb_test "print/d ${name}4a ^= ${name}4b" " = \\{3, 6, 0, 20\\}"
+ gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
+
+ # scalar with scalar
+ gdb_test "ptype ${name}a %= ${name}b" "type = ${type}"
+ gdb_test "ptype ${name}a <<= ${name}b" "type = ${type}"
+ gdb_test "ptype ${name}a >>= ${name}b" "type = ${type}"
+ gdb_test "ptype ${name}a &= ${name}b" "type = ${type}"
+ gdb_test "ptype ${name}a |= ${name}b" "type = ${type}"
+ gdb_test "ptype ${name}a ^= ${name}b" "type = ${type}"
+ # scalar with vector
+ gdb_test "ptype ${name}4a %= ${name}b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4a <<= ${name}b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4a >>= ${name}b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4a &= ${name}b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4a |= ${name}b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4a ^= ${name}b" "type = ${type} \\\[4\\\]"
+ # vector with vector
+ gdb_test "ptype ${name}4a %= ${name}4b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4a <<= ${name}4b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4a >>= ${name}4b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4a &= ${name}4b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4a |= ${name}4b" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}4a ^= ${name}4b" "type = ${type} \\\[4\\\]"
+
+ # scalar with scalar
+ gdb_test "print/d u${name}a = u${name}b" " = 1"
+ gdb_test "print/d u${name}a = 2" " = 2"
+ gdb_test "print/d u${name}a += u${name}b" " = 3"
+ gdb_test "print/d u${name}a -= u${name}b" " = 2"
+ gdb_test "print/d u${name}b *= u${name}a" " = 2"
+ gdb_test "print/d u${name}b /= u${name}a" " = 1"
+ gdb_test "print/d u${name}a %= u${name}b" " = 0"
+ gdb_test "print/d u${name}a = 2" " = 2"
+ gdb_test "print/d u${name}a <<= u${name}b" " = 4"
+ gdb_test "print/d u${name}a = 2" " = 2"
+ gdb_test "print/d u${name}a >>= u${name}b" " = 1"
+ gdb_test "print/d u${name}a = 2" " = 2"
+ gdb_test "print/d u${name}a &= u${name}b" " = 0"
+ gdb_test "print/d u${name}a = 2" " = 2"
+ gdb_test "print/d u${name}a |= u${name}b" " = 3"
+ gdb_test "print/d u${name}a = 2" " = 2"
+ gdb_test "print/d u${name}a ^= u${name}b" " = 3"
+ gdb_test "print/d u${name}a = 2" " = 2"
+ # scalar with vector
+ gdb_test "print/d u${name}4a = u${name}b" " = \\{1, 1, 1, 1\\}"
+ gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
+ gdb_test "print/d u${name}4a += u${name}b" " = \\{3, 5, 9, 17\\}"
+ gdb_test "print/d u${name}4a -= u${name}b" " = \\{2, 4, 8, 16\\}"
+ gdb_test "print/d u${name}4b *= u${name}a" " = \\{2, 4, 16, 8\\}"
+ gdb_test "print/d u${name}4b /= u${name}a" " = \\{1, 2, 8, 4\\}"
+ gdb_test "print/d u${name}4b %= u${name}a" " = \\{1, 0, 0, 0\\}"
+ gdb_test "print/d u${name}4b = \{1, 2, 8, 4\}" " = \\{1, 2, 8, 4\\}"
+ gdb_test "print/d u${name}4a <<= u${name}b" " = \\{4, 8, 16, 32\\}"
+ gdb_test "print/d u${name}4a >>= u${name}b" " = \\{2, 4, 8, 16\\}"
+ gdb_test "print/d u${name}4a &= u${name}b" " = \\{0, 0, 0, 0\\}"
+ gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
+ gdb_test "print/d u${name}4a |= u${name}b" " = \\{3, 5, 9, 17\\}"
+ gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
+ gdb_test "print/d u${name}4a ^= u${name}b" " = \\{3, 5, 9, 17\\}"
+ gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
+ # vector with vector
+ gdb_test "print/d u${name}4a = u${name}4b" " = \\{1, 2, 8, 4\\}"
+ gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
+ gdb_test "print/d u${name}4a += u${name}4b" " = \\{3, 6, 16, 20\\}"
+ gdb_test "print/d u${name}4a -= u${name}4b" " = \\{2, 4, 8, 16\\}"
+ gdb_test "print/d u${name}4b *= u${name}4a" " = \\{2, 8, 64, 64\\}"
+ gdb_test "print/d u${name}4b /= u${name}4a" " = \\{1, 2, 8, 4\\}"
+ gdb_test "print/d u${name}4b %= u${name}4a" " = \\{1, 2, 0, 4\\}"
+ gdb_test "print/d u${name}4b = \{1, 2, 8, 4\}" " = \\{1, 2, 8, 4\\}"
+ if { ${size} == 1 } {
+ gdb_test "print/d u${name}4a <<= u${name}4b" " = \\{4, 16, 0, 0\\}"
+ gdb_test "print/d u${name}4a >>= u${name}4b" " = \\{2, 4, 0, 0\\}"
+ gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
+ } else {
+ gdb_test "print/d u${name}4a <<= u${name}4b" " = \\{4, 16, 2048, 256\\}"
+ gdb_test "print/d u${name}4a >>= u${name}4b" " = \\{2, 4, 8, 16\\}"
+ }
+ gdb_test "print/d u${name}4a &= u${name}4b" " = \\{0, 0, 8, 0\\}"
+ gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
+ gdb_test "print/d u${name}4a |= u${name}4b" " = \\{3, 6, 8, 20\\}"
+ gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
+ gdb_test "print/d u${name}4a ^= u${name}4b" " = \\{3, 6, 0, 20\\}"
+ gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" " = \\{2, 4, 8, 16\\}"
+
+ # scalar with scalar
+ gdb_test "ptype u${name}a = u${name}b" "type = (unsigned ${type}|u${type})"
+ gdb_test "ptype u${name}a += u${name}b" "type = (unsigned ${type}|u${type})"
+ gdb_test "ptype u${name}a -= u${name}b" "type = (unsigned ${type}|u${type})"
+ gdb_test "ptype u${name}a *= u${name}b" "type = (unsigned ${type}|u${type})"
+ gdb_test "ptype u${name}a /= u${name}b" "type = (unsigned ${type}|u${type})"
+ gdb_test "ptype u${name}a %= u${name}b" "type = (unsigned ${type}|u${type})"
+ gdb_test "ptype u${name}a <<= u${name}b" "type = (unsigned ${type}|u${type})"
+ gdb_test "ptype u${name}a >>= u${name}b" "type = (unsigned ${type}|u${type})"
+ gdb_test "ptype u${name}a &= u${name}b" "type = (unsigned ${type}|u${type})"
+ gdb_test "ptype u${name}a |= u${name}b" "type = (unsigned ${type}|u${type})"
+ gdb_test "ptype u${name}a ^= u${name}b" "type = (unsigned ${type}|u${type})"
+ # scalar with vector
+ gdb_test "ptype u${name}4a = u${name}b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a += u${name}b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a -= u${name}b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4b *= u${name}a" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4b /= u${name}a" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a %= u${name}b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a <<= u${name}b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a >>= u${name}b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a &= u${name}b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a |= u${name}b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a ^= u${name}b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ # vector with vector
+ gdb_test "ptype u${name}4a = u${name}4b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a += u${name}4b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a -= u${name}4b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4b *= u${name}4a" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4b /= u${name}4a" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a %= u${name}4b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a <<= u${name}4b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a >>= u${name}4b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a &= u${name}4b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a |= u${name}4b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ gdb_test "ptype u${name}4a ^= u${name}4b" "type = (unsigned ${type}|u${type}) \\\[4\\\]"
+ }
+}
+
+proc do_check { name type isfloat size } {
+ check_basic ${name} ${type} ${isfloat}
+ check_arithmetic_ops ${name} ${type} ${isfloat} ${size}
+ check_relational_ops ${name} ${type} ${isfloat} ${size}
+ check_equality_ops ${name} ${type} ${isfloat} ${size}
+ if { !${isfloat} } {
+ check_shift_ops ${name} ${type} ${size}
+ check_bitwise_ops ${name} ${type} ${size}
+ }
+ check_logical_ops ${name} ${type} ${isfloat} ${size}
+ check_conditional_op ${name} ${type} ${isfloat}
+ check_assignment_ops ${name} ${type} ${isfloat} ${size}
+}
+
+do_check "c" "char" 0 1
+do_check "s" "short" 0 2
+do_check "i" "int" 0 4
+do_check "l" "long" 0 8
+if { ${have_cl_khr_fp16} } {
+ do_check "h" "half" 1 2
+}
+do_check "f" "float" 1 4
+if { ${have_cl_khr_fp64} } {
+ do_check "d" "double" 1 8
+}
+# Delete the OpenCL program source
+remote_file target delete ${clprogram}
diff --git a/gdb/testsuite/gdb.opencl/vec_comps.cl b/gdb/testsuite/gdb.opencl/vec_comps.cl
new file mode 100644
index 00000000000..d58f1ba2739
--- /dev/null
+++ b/gdb/testsuite/gdb.opencl/vec_comps.cl
@@ -0,0 +1,59 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2010 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ Contributed by Ken Werner <ken.werner@de.ibm.com> */
+
+int opencl_version = __OPENCL_VERSION__;
+
+#ifdef HAVE_cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+int have_cl_khr_fp64 = 1;
+#else
+int have_cl_khr_fp64 = 0;
+#endif
+
+#ifdef HAVE_cl_khr_fp16
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+int have_cl_khr_fp16 = 1;
+#else
+int have_cl_khr_fp16 = 0;
+#endif
+
+#define CREATE_VEC(TYPE, NAME)\
+ TYPE NAME =\
+ (TYPE) (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
+
+CREATE_VEC(char16, c16)
+CREATE_VEC(uchar16, uc16)
+CREATE_VEC(short16, s16)
+CREATE_VEC(ushort16, us16)
+CREATE_VEC(int16, i16)
+CREATE_VEC(uint16, ui16)
+CREATE_VEC(long16, l16)
+CREATE_VEC(ulong16, ul16)
+#ifdef cl_khr_fp16
+CREATE_VEC(half16, h16)
+#endif
+CREATE_VEC(float16, f16)
+#ifdef cl_khr_fp64
+CREATE_VEC(double16, d16)
+#endif
+
+__kernel void testkernel (__global int *data)
+{
+ data[get_global_id(0)] = 1;
+}
diff --git a/gdb/testsuite/gdb.opencl/vec_comps.exp b/gdb/testsuite/gdb.opencl/vec_comps.exp
new file mode 100644
index 00000000000..e044e96951f
--- /dev/null
+++ b/gdb/testsuite/gdb.opencl/vec_comps.exp
@@ -0,0 +1,390 @@
+# Copyright 2010 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>. */
+#
+# Contributed by Ken Werner <ken.werner@de.ibm.com>.
+#
+# Tests component access of OpenCL vectors.
+
+if $tracelevel {
+ strace $tracelevel
+}
+
+load_lib opencl.exp
+
+if { [skip_opencl_tests] } {
+ return 0
+}
+
+set testfile "vec_comps"
+set clprogram [remote_download target ${srcdir}/${subdir}/${testfile}.cl]
+
+# Compile the generic OpenCL host app
+if { [gdb_compile_opencl_hostapp "${clprogram}" "${testfile}" "" ] != "" } {
+ untested ${testfile}.exp
+ return -1
+}
+
+# Load the OpenCL app
+clean_restart ${testfile}
+
+# Set breakpoint at the OpenCL kernel
+gdb_test_multiple "break testkernel" "set pending breakpoint" {
+ -re ".*Function \"testkernel\" not defined.*Make breakpoint pending.*y or \\\[n\\\]. $" {
+ gdb_test "y" "Breakpoint.*testkernel.*pending." "set pending breakpoint (without symbols)"
+ }
+}
+
+gdb_run_cmd
+gdb_test "" ".*Breakpoint.*1.*testkernel.*" "run"
+
+# Check if the language was switched to opencl
+gdb_test "show language" "The current source language is \"auto; currently opencl\"\."
+
+# Retrieve some information about the OpenCL version and the availability of extensions
+set opencl_version [get_integer_valueof "opencl_version" 0]
+set have_cl_khr_fp64 [get_integer_valueof "have_cl_khr_fp64" 0]
+set have_cl_khr_fp16 [get_integer_valueof "have_cl_khr_fp16" 0]
+
+# Sanity checks
+proc check_basic { name type size } {
+ gdb_test "ptype ${name}" "type = ${type} \\\[16\\\]"
+ gdb_test "p sizeof(${name})" " = [expr ${size} * 16]"
+ gdb_test "print/d ${name}" " = \\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15\\}"
+}
+
+proc check_type { name type alttype } {
+ gdb_test "whatis ${name}.lo" "type = ${type}8"
+ gdb_test "whatis ${name}.hi" "type = ${type}8"
+ gdb_test "whatis ${name}.even" "type = ${type}8"
+ gdb_test "whatis ${name}.odd" "type = ${type}8"
+ gdb_test "whatis ${name}.low" "Invalid OpenCL vector component accessor low"
+ gdb_test "whatis ${name}.high" "Invalid OpenCL vector component accessor high"
+
+ gdb_test "whatis ${name}.hi.even" "type = ${type}4"
+ gdb_test "whatis ${name}.odd.odd.lo" "type = ${type}2"
+ gdb_test "whatis ${name}.even.hi.lo.odd" "type = ${alttype}|${type}"
+
+ gdb_test "whatis ${name}.x" "type = ${alttype}|${type}"
+ gdb_test "whatis ${name}.y" "type = ${alttype}|${type}"
+ gdb_test "whatis ${name}.z" "type = ${alttype}|${type}"
+ gdb_test "whatis ${name}.w" "type = ${alttype}|${type}"
+ gdb_test "whatis ${name}.v" "Invalid OpenCL vector component accessor v"
+
+ gdb_test "whatis ${name}.xy" "type = ${type}2"
+ gdb_test "whatis ${name}.xx" "type = ${type}2"
+ gdb_test "whatis ${name}.wy" "type = ${type}2"
+ gdb_test "whatis ${name}.zv" "Invalid OpenCL vector component accessor zv"
+
+ gdb_test "whatis ${name}.xyz" "type = ${type}3"
+ gdb_test "whatis ${name}.yxy" "type = ${type}3"
+ gdb_test "whatis ${name}.yzx" "type = ${type}3"
+ gdb_test "whatis ${name}.yzv" "Invalid OpenCL vector component accessor yzv"
+
+ gdb_test "whatis ${name}.xywz" "type = ${type}4"
+ gdb_test "whatis ${name}.zzyy" "type = ${type}4"
+ gdb_test "whatis ${name}.wwww" "type = ${type}4"
+ gdb_test "whatis ${name}.yxwv" "Invalid OpenCL vector component accessor yxwv"
+ gdb_test "whatis ${name}.zyxwv" "Invalid OpenCL vector component accessor zyxwv"
+
+ gdb_test "whatis ${name}.xy.x" "type = ${alttype}|${type}"
+ gdb_test "whatis ${name}.wzyx.yy" "type = ${type}2"
+ gdb_test "whatis ${name}.wzyx.yx.x" "type = ${alttype}|${type}"
+ gdb_test "whatis ${name}.xyzw.w" "type = ${alttype}|${type}"
+ gdb_test "whatis ${name}.xy.z" "Invalid OpenCL vector component accessor z"
+
+ gdb_test "whatis ${name}.s0" "type = ${alttype}|${type}"
+ gdb_test "whatis ${name}.s9" "type = ${alttype}|${type}"
+ gdb_test "whatis ${name}.sa" "type = ${alttype}|${type}"
+ gdb_test "whatis ${name}.sf" "type = ${alttype}|${type}"
+ gdb_test "whatis ${name}.sF" "type = ${alttype}|${type}"
+ gdb_test "whatis ${name}.sg" "Invalid OpenCL vector component accessor sg"
+ gdb_test "whatis ${name}.sG" "Invalid OpenCL vector component accessor sG"
+ gdb_test "whatis ${name}.Sg" "Invalid OpenCL vector component accessor Sg"
+ gdb_test "whatis ${name}.SG" "Invalid OpenCL vector component accessor SG"
+
+ gdb_test "whatis ${name}.s01" "type = ${type}2"
+ gdb_test "whatis ${name}.s00" "type = ${type}2"
+ gdb_test "whatis ${name}.sF0" "type = ${type}2"
+ gdb_test "whatis ${name}.S42" "type = ${type}2"
+
+ gdb_test "whatis ${name}.s567" "type = ${type}3"
+ gdb_test "whatis ${name}.S333" "type = ${type}3"
+ gdb_test "whatis ${name}.Sf0A" "type = ${type}3"
+ gdb_test "whatis ${name}.SB1D" "type = ${type}3"
+ gdb_test "whatis ${name}.s01g" "Invalid OpenCL vector component accessor s01g"
+
+ gdb_test "whatis ${name}.s9876" "type = ${type}4"
+ gdb_test "whatis ${name}.sFFFF" "type = ${type}4"
+ gdb_test "whatis ${name}.sCafe" "type = ${type}4"
+ gdb_test "whatis ${name}.Sf001" "type = ${type}4"
+ gdb_test "whatis ${name}.s1fg2" "Invalid OpenCL vector component accessor s1fg2"
+ gdb_test "whatis ${name}.s012345" "Invalid OpenCL vector component accessor s012345"
+
+ gdb_test "whatis ${name}.s00000000" "type = ${type}8"
+ gdb_test "whatis ${name}.s00224466" "type = ${type}8"
+ gdb_test "whatis ${name}.sDEADBEEF" "type = ${type}8"
+ gdb_test "whatis ${name}.Sa628c193" "type = ${type}8"
+
+ gdb_test "whatis ${name}.s876543210" "Invalid OpenCL vector component accessor s876543210"
+ gdb_test "whatis ${name}.s0123456789abcde" "Invalid OpenCL vector component accessor s0123456789abcde"
+
+ gdb_test "whatis ${name}.s0123456789aBcDeF" "type = ${type}16"
+ gdb_test "whatis ${name}.s0022446688AACCFF" "type = ${type}16"
+ gdb_test "whatis ${name}.S0123456776543210" "type = ${type}16"
+ gdb_test "whatis ${name}.sFEDCBA9876543210" "type = ${type}16"
+
+ gdb_test "whatis ${name}.sfedcba98.S0246" "type = ${type}4"
+ gdb_test "whatis ${name}.sfedcba98.S0246.s13" "type = ${type}2"
+ gdb_test "whatis ${name}.sfedcba98.S0246.s13.s0" "type = ${alttype}|${type}"
+ gdb_test "whatis ${name}.s0123456789abcdef.s22" "type = ${type}2"
+
+ gdb_test "whatis ${name}.hi.s7654.wx" "type = ${type}2"
+ gdb_test "whatis ${name}.s0123456789abcdef.even.lo" "type = ${type}4"
+ gdb_test "whatis ${name}.odd.xyzw.s23" "type = ${type}2"
+ gdb_test "whatis ${name}.xyzw.hi.odd" "type = ${alttype}|${type}"
+
+ gdb_test "ptype ${name}.lo" "type = ${type} \\\[8\\\]"
+ gdb_test "ptype ${name}.hi" "type = ${type} \\\[8\\\]"
+ gdb_test "ptype ${name}.even" "type = ${type} \\\[8\\\]"
+ gdb_test "ptype ${name}.odd" "type = ${type} \\\[8\\\]"
+
+ gdb_test "ptype ${name}.hi.even" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}.odd.odd.lo" "type = ${type} \\\[2\\\]"
+ gdb_test "ptype ${name}.even.hi.lo.odd" "type = ${alttype}|${type}"
+
+ gdb_test "ptype ${name}.x" "type = ${alttype}|${type}"
+ gdb_test "ptype ${name}.y" "type = ${alttype}|${type}"
+ gdb_test "ptype ${name}.z" "type = ${alttype}|${type}"
+ gdb_test "ptype ${name}.w" "type = ${alttype}|${type}"
+
+ gdb_test "ptype ${name}.xy" "type = ${type} \\\[2\\\]"
+ gdb_test "ptype ${name}.xx" "type = ${type} \\\[2\\\]"
+ gdb_test "ptype ${name}.wy" "type = ${type} \\\[2\\\]"
+
+ gdb_test "ptype ${name}.xyz" "type = ${type} \\\[3\\\]"
+ gdb_test "ptype ${name}.yxy" "type = ${type} \\\[3\\\]"
+ gdb_test "ptype ${name}.yzx" "type = ${type} \\\[3\\\]"
+
+ gdb_test "ptype ${name}.xywz" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}.zzyy" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}.wwww" "type = ${type} \\\[4\\\]"
+
+ gdb_test "ptype ${name}.xy.x" "type = ${alttype}|${type}"
+ gdb_test "ptype ${name}.wzyx.yy" "type = ${type} \\\[2\\\]"
+ gdb_test "ptype ${name}.wzyx.yx.x" "type = ${alttype}|${type}"
+ gdb_test "ptype ${name}.xyzw.w" "type = ${alttype}|${type}"
+
+ gdb_test "ptype ${name}.s0" "type = ${alttype}|${type}"
+ gdb_test "ptype ${name}.s9" "type = ${alttype}|${type}"
+ gdb_test "ptype ${name}.sa" "type = ${alttype}|${type}"
+ gdb_test "ptype ${name}.sf" "type = ${alttype}|${type}"
+ gdb_test "ptype ${name}.sF" "type = ${alttype}|${type}"
+
+ gdb_test "ptype ${name}.s01" "type = ${type} \\\[2\\\]"
+ gdb_test "ptype ${name}.s00" "type = ${type} \\\[2\\\]"
+ gdb_test "ptype ${name}.sF0" "type = ${type} \\\[2\\\]"
+ gdb_test "ptype ${name}.S42" "type = ${type} \\\[2\\\]"
+
+ gdb_test "ptype ${name}.s567" "type = ${type} \\\[3\\\]"
+ gdb_test "ptype ${name}.S333" "type = ${type} \\\[3\\\]"
+ gdb_test "ptype ${name}.Sf0A" "type = ${type} \\\[3\\\]"
+ gdb_test "ptype ${name}.SB1D" "type = ${type} \\\[3\\\]"
+
+ gdb_test "ptype ${name}.s9876" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}.sFFFF" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}.sCafe" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}.Sf001" "type = ${type} \\\[4\\\]"
+
+ gdb_test "ptype ${name}.s00000000" "type = ${type} \\\[8\\\]"
+ gdb_test "ptype ${name}.s00224466" "type = ${type} \\\[8\\\]"
+ gdb_test "ptype ${name}.sDEADBEEF" "type = ${type} \\\[8\\\]"
+ gdb_test "ptype ${name}.Sa628c193" "type = ${type} \\\[8\\\]"
+
+ gdb_test "ptype ${name}.s0123456789aBcDeF" "type = ${type} \\\[16\\\]"
+ gdb_test "ptype ${name}.s0022446688AACCFF" "type = ${type} \\\[16\\\]"
+ gdb_test "ptype ${name}.S0123456776543210" "type = ${type} \\\[16\\\]"
+ gdb_test "ptype ${name}.sFEDCBA9876543210" "type = ${type} \\\[16\\\]"
+
+ gdb_test "ptype ${name}.sfedcba98.S0246" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}.sfedcba98.S0246.s13" "type = ${type} \\\[2\\\]"
+ gdb_test "ptype ${name}.sfedcba98.S0246.s13.s0" "type = ${alttype}|${type}"
+ gdb_test "ptype ${name}.s0123456789abcdef.s22" "type = ${type} \\\[2\\\]"
+
+ gdb_test "ptype ${name}.hi.s7654.wx" "type = ${type} \\\[2\\\]"
+ gdb_test "ptype ${name}.s0123456789abcdef.even.lo" "type = ${type} \\\[4\\\]"
+ gdb_test "ptype ${name}.odd.xyzw.s23" "type = ${type} \\\[2\\\]"
+ gdb_test "ptype ${name}.xyzw.hi.odd" "type = ${alttype}|${type}"
+}
+
+proc check_sizeof { name size } {
+ gdb_test "print sizeof (${name}.lo)" " = [expr $size * 8]"
+ gdb_test "print sizeof (${name}.hi)" " = [expr $size * 8]"
+ gdb_test "print sizeof (${name}.even)" " = [expr $size * 8]"
+ gdb_test "print sizeof (${name}.odd)" " = [expr $size * 8]"
+
+ gdb_test "print sizeof (${name}.hi.even)" " = [expr $size * 4]"
+ gdb_test "print sizeof (${name}.odd.odd.lo)" " = [expr $size * 2]"
+ gdb_test "print sizeof (${name}.even.hi.lo.odd)" " = $size"
+
+ gdb_test "print sizeof (${name}.x)" " = $size"
+ gdb_test "print sizeof (${name}.xy)" " = [expr $size * 2]"
+ gdb_test "print sizeof (${name}.xyz)" " = [expr $size * 4]"
+ gdb_test "print sizeof (${name}.xyzw)" " = [expr $size * 4]"
+
+ gdb_test "print sizeof (${name}.xy.x)" " = $size"
+ gdb_test "print sizeof (${name}.wzyx.yy)" " = [expr $size * 2]"
+ gdb_test "print sizeof (${name}.wzyx.yx.x)" " = $size"
+ gdb_test "print sizeof (${name}.xyzw.w)" " = $size"
+
+ gdb_test "print sizeof (${name}.s0)" " = $size"
+ gdb_test "print sizeof (${name}.s01)" " = [expr $size * 2]"
+ gdb_test "print sizeof (${name}.s012)" " = [expr $size * 4]"
+ gdb_test "print sizeof (${name}.s0123)" " = [expr $size * 4]"
+ gdb_test "print sizeof (${name}.s01234567)" " = [expr $size * 8]"
+ gdb_test "print sizeof (${name}.s0123456789abcdef)" " = [expr $size * 16]"
+
+ gdb_test "print sizeof (${name}.sfedcba98.S0246)" " = [expr $size * 4]"
+ gdb_test "print sizeof (${name}.sfedcba98.S0246.s13)" " = [expr $size * 2]"
+ gdb_test "print sizeof (${name}.sfedcba98.S0246.s13.s0)" " = $size"
+ gdb_test "print sizeof (${name}.s0123456789abcdef.s22)" " = [expr $size * 2]"
+
+ gdb_test "print sizeof (${name}.hi.s7654.wx)" " = [expr $size * 2]"
+ gdb_test "print sizeof (${name}.s0123456789abcdef.even.lo)" " = [expr $size * 4]"
+ gdb_test "print sizeof (${name}.odd.xyzw.s23)" " = [expr $size * 2]"
+ gdb_test "print sizeof (${name}.xyzw.hi.odd)" " = $size"
+}
+
+# OpenCL vector component access
+proc check_access { name type } {
+ gdb_test "print/d ${name}.lo" " = \\{0, 1, 2, 3, 4, 5, 6, 7\\}"
+ gdb_test "print/d ${name}.hi" " = \\{8, 9, 10, 11, 12, 13, 14, 15\\}"
+ gdb_test "print/d ${name}.even" " = \\{0, 2, 4, 6, 8, 10, 12, 14\\}"
+ gdb_test "print/d ${name}.odd" " = \\{1, 3, 5, 7, 9, 11, 13, 15\\}"
+
+ gdb_test "print/d ${name}.hi.even" " = \\{8, 10, 12, 14\\}"
+ gdb_test "print/d ${name}.odd.odd.lo" " = \\{3, 7\\}"
+ gdb_test "print/d ${name}.even.hi.lo.odd" " = 10"
+
+ gdb_test "print/d ${name}.x" " = 0"
+ gdb_test "print/d ${name}.y" " = 1"
+ gdb_test "print/d ${name}.z" " = 2"
+ gdb_test "print/d ${name}.w" " = 3"
+
+ gdb_test "print/d ${name}.xy" " = \\{0, 1\\}"
+ gdb_test "print/d ${name}.xx" " = \\{0, 0\\}"
+ gdb_test "print/d ${name}.wy" " = \\{3, 1\\}"
+
+ gdb_test "print/d ${name}.xyz" " = \\{0, 1, 2\\}"
+ gdb_test "print/d ${name}.yxy" " = \\{1, 0, 1\\}"
+ gdb_test "print/d ${name}.yzx" " = \\{1, 2, 0\\}"
+
+ gdb_test "print/d ${name}.xywz" " = \\{0, 1, 3, 2\\}"
+ gdb_test "print/d ${name}.zzyy" " = \\{2, 2, 1, 1\\}"
+ gdb_test "print/d ${name}.wwww" " = \\{3, 3, 3, 3\\}"
+
+ gdb_test "print/d ${name}.xy.x" " = 0"
+ gdb_test "print/d ${name}.wzyx.yy" " = \\{2, 2\\}"
+ gdb_test "print/d ${name}.wzyx.yx.x" " = 2"
+ gdb_test "print/d ${name}.xyzw.w" " = 3"
+
+ for {set i 0} {$i < 16} {incr i} {
+ gdb_test "print/d ${name}.s[format "%x" $i]" " = $i"
+ gdb_test "print/d ${name}.S[format "%x" $i]" " = $i"
+ if {$i > 9} {
+ gdb_test "print/d ${name}.s[format "%X" $i]" " = $i"
+ gdb_test "print/d ${name}.S[format "%X" $i]" " = $i"
+ }
+ }
+
+ gdb_test "print/d ${name}.s01" " = \\{0, 1\\}"
+ gdb_test "print/d ${name}.s00" " = \\{0, 0\\}"
+ gdb_test "print/d ${name}.sF0" " = \\{15, 0\\}"
+ gdb_test "print/d ${name}.S42" " = \\{4, 2\\}"
+
+ gdb_test "print/d ${name}.s567" " = \\{5, 6, 7\\}"
+ gdb_test "print/d ${name}.S333" " = \\{3, 3, 3\\}"
+ gdb_test "print/d ${name}.Sf0A" " = \\{15, 0, 10\\}"
+ gdb_test "print/d ${name}.SB1D" " = \\{11, 1, 13\\}"
+
+ gdb_test "print/d ${name}.s9876" " = \\{9, 8, 7, 6\\}"
+ gdb_test "print/d ${name}.sFFFF" " = \\{15, 15, 15, 15\\}"
+ gdb_test "print/d ${name}.sCafe" " = \\{12, 10, 15, 14\\}"
+ gdb_test "print/d ${name}.Sf001" " = \\{15, 0, 0, 1\\}"
+
+ gdb_test "print/d ${name}.s00000000" " = \\{0, 0, 0, 0, 0, 0, 0, 0\\}"
+ gdb_test "print/d ${name}.s00224466" " = \\{0, 0, 2, 2, 4, 4, 6, 6\\}"
+ gdb_test "print/d ${name}.sDEADBEEF" " = \\{13, 14, 10, 13, 11, 14, 14, 15\\}"
+ gdb_test "print/d ${name}.Sa628c193" " = \\{10, 6, 2, 8, 12, 1, 9, 3\\}"
+
+ gdb_test "print/d ${name}.s0123456789aBcDeF" " = \\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15\\}"
+ gdb_test "print/d ${name}.s0022446688AACCEE" " = \\{0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14\\}"
+ gdb_test "print/d ${name}.S0123456776543210" " = \\{0, 1, 2, 3, 4, 5, 6, 7, 7, 6, 5, 4, 3, 2, 1, 0\\}"
+ gdb_test "print/d ${name}.sFEDCBA9876543210" " = \\{15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0\\}"
+
+ gdb_test "print/d ${name}.sfedcba98.S0246" " = \\{15, 13, 11, 9\\}"
+ gdb_test "print/d ${name}.sfedcba98.S0246.s13" " = \\{13, 9\\}"
+ gdb_test "print/d ${name}.sfedcba98.S0246.s13.s0" " = 13"
+ gdb_test "print/d ${name}.s0123456789abcdef.s22" " = \\{2, 2\\}"
+
+ gdb_test "print/d ${name}.hi.s7654.wx" " = \\{12, 15\\}"
+ gdb_test "print/d ${name}.s0123456789abcdef.even.lo" " = \\{0, 2, 4, 6\\}"
+ gdb_test "print/d ${name}.odd.xyzw.s23" " = \\{5, 7\\}"
+ gdb_test "print/d ${name}.xyzw.hi.odd" " = 3"
+
+ # lvalue tests
+ for {set i 0} {$i < 16} {incr i} {
+ gdb_test_no_output "set variable ${name}.s[format "%x" $i] = [expr 15 - $i]"
+ gdb_test "print/d ${name}.s[format "%x" $i]" " = [expr 15 - $i]"
+ }
+ gdb_test "print/d ${name}" " = \\{15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0\\}"
+
+ gdb_test_no_output "set variable ${name}.s02468ace = ${name}.s13579bdf"
+ gdb_test "print/d ${name}" " = \\{14, 14, 12, 12, 10, 10, 8, 8, 6, 6, 4, 4, 2, 2, 0, 0\\}"
+
+ gdb_test_no_output "set variable ${name}.wzyx = ${name}.even.odd"
+ gdb_test "print/d ${name}" " = \\{0, 4, 8, 12, 10, 10, 8, 8, 6, 6, 4, 4, 2, 2, 0, 0\\}"
+
+ gdb_test_no_output "set variable ${name}.odd.lo = ${name}.hi.even"
+ gdb_test "print/d ${name}" " = \\{0, 6, 8, 4, 10, 2, 8, 0, 6, 6, 4, 4, 2, 2, 0, 0\\}"
+
+ gdb_test_no_output "set variable ${name}.hi.hi.hi = ${name}.lo.s1623.lo"
+ gdb_test "print/d ${name}" " = \\{0, 6, 8, 4, 10, 2, 8, 0, 6, 6, 4, 4, 2, 2, 6, 8\\}"
+}
+
+proc do_check { name type alttype size } {
+ check_basic ${name} ${alttype} ${size}
+ check_type ${name} ${type} ${alttype}
+ check_sizeof ${name} ${size}
+ check_access ${name} ${alttype}
+}
+
+do_check "c16" "char" "char" 1
+do_check "uc16" "uchar" "unsigned char" 1
+do_check "s16" "short" "short" 2
+do_check "us16" "ushort" "unsigned short" 2
+do_check "i16" "int" "int" 4
+do_check "ui16" "uint" "unsigned int" 4
+do_check "l16" "long" "long" 8
+do_check "ul16" "ulong" "unsigned long" 8
+if { ${have_cl_khr_fp16} } {
+ do_check "h16" "half" "half" 2
+}
+do_check "f16" "float" "float" 4
+if { ${have_cl_khr_fp64} } {
+ do_check "d16" "double" "double" 8
+}
+
+# Delete the OpenCL program source
+remote_file target delete ${clprogram}