aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorKen Werner <ken.werner@de.ibm.com>2010-11-05 14:31:30 +0000
committerKen Werner <ken.werner@de.ibm.com>2010-11-05 14:31:30 +0000
commitf4b8a18de7f165283091323b11e9e363dadb8b62 (patch)
tree5e42a431d5add30b82af29bebc879a9c49f6ef07 /gdb/testsuite
parentaa291e2d99dd5e6be27b43c721fa92edae076138 (diff)
downloadbinutils-f4b8a18de7f165283091323b11e9e363dadb8b62.zip
binutils-f4b8a18de7f165283091323b11e9e363dadb8b62.tar.gz
binutils-f4b8a18de7f165283091323b11e9e363dadb8b62.tar.bz2
gdb:
* NEWS: Mention OpenCL C language support. * Makefile.in (SFILES): Add opencl-lang.c. (COMMON_OBS): Add opencl-lang.o. * opencl-lang.c: New File * defs.h (enum language): Add language_opencl. * dwarf2read.c (read_file_scope): Handle DW_AT_producer for the IBM XL C OpenCL compiler. * c-lang.h: Include "parser-defs.h". (evaluate_subexp_c): Declare. * c-lang.c (evaluate_subexp_c): Remove the static qualifier. (c_op_print_tab): Add declaration. * eval.c (binop_promote): Handle language_opencl. * c-exp.y: Lookup the primitive types instead of referring to the builtins. gdb/testsuite: * Makefile.in (ALL_SUBDIRS): Add gdb.opencl. * configure.ac (AC_OUTPUT): Add gdb.opencl/Makefile. * configure: Regenerate. * gdb.opencl/Makefile.in: New File. * gdb.opencl/datatypes.exp: Likewise. * gdb.opencl/datatypes.cl: Likewise. * gdb.opencl/operators.exp: Likewise. * gdb.opencl/operators.cl: Likewise. * gdb.opencl/vec_comps.exp: Likewise. * gdb.opencl/vec_comps.cl: Likewise. * gdb.opencl/convs_casts.exp: Likewise. * gdb.opencl/convs_casts.cl: Likewise. * lib/opencl.exp: Likewise. * lib/opencl_hostapp.c: Likewise. * lib/opencl_kernel.cl: Likewise. * lib/cl_util.c: Likewise. * lib/cl_util.c: Likewise. * gdb.base/default.exp (set language): Add "opencl" to the list of languages. gdb/doc: * gdb.texinfo: (Summary) Add mention about OpenCL C language support. (OpenCL C): New node.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog22
-rw-r--r--gdb/testsuite/Makefile.in4
-rwxr-xr-xgdb/testsuite/configure3
-rw-r--r--gdb/testsuite/configure.ac2
-rw-r--r--gdb/testsuite/gdb.base/default.exp2
-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
-rw-r--r--gdb/testsuite/lib/cl_util.c519
-rw-r--r--gdb/testsuite/lib/cl_util.h88
-rw-r--r--gdb/testsuite/lib/opencl.exp83
-rw-r--r--gdb/testsuite/lib/opencl_hostapp.c168
-rw-r--r--gdb/testsuite/lib/opencl_kernel.cl5
19 files changed, 3183 insertions, 5 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index d68e850..1a2dde5 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,25 @@
+2010-11-05 Ken Werner <ken.werner@de.ibm.com>
+
+ * Makefile.in (ALL_SUBDIRS): Add gdb.opencl.
+ * configure.ac (AC_OUTPUT): Add gdb.opencl/Makefile.
+ * configure: Regenerate.
+ * gdb.opencl/Makefile.in: New File.
+ * gdb.opencl/datatypes.exp: Likewise.
+ * gdb.opencl/datatypes.cl: Likewise.
+ * gdb.opencl/operators.exp: Likewise.
+ * gdb.opencl/operators.cl: Likewise.
+ * gdb.opencl/vec_comps.exp: Likewise.
+ * gdb.opencl/vec_comps.cl: Likewise.
+ * gdb.opencl/convs_casts.exp: Likewise.
+ * gdb.opencl/convs_casts.cl: Likewise.
+ * lib/opencl.exp: Likewise.
+ * lib/opencl_hostapp.c: Likewise.
+ * lib/opencl_kernel.cl: Likewise.
+ * lib/cl_util.c: Likewise.
+ * lib/cl_util.c: Likewise.
+ * gdb.base/default.exp (set language): Add "opencl" to the list of
+ languages.
+
2010-11-04 Sami Wagiaalla <swagiaal@redhat.com>
* gdb.cp/overload.exp: Added test for inheritance overload.
diff --git a/gdb/testsuite/Makefile.in b/gdb/testsuite/Makefile.in
index 8d8d704..d02689b 100644
--- a/gdb/testsuite/Makefile.in
+++ b/gdb/testsuite/Makefile.in
@@ -36,8 +36,8 @@ RPATH_ENVVAR = @RPATH_ENVVAR@
ALL_SUBDIRS = gdb.ada gdb.arch gdb.asm gdb.base gdb.cp gdb.disasm \
gdb.dwarf2 \
gdb.fortran gdb.server gdb.java gdb.mi gdb.multi \
- gdb.objc gdb.opt gdb.pascal gdb.python gdb.threads gdb.trace \
- gdb.xml \
+ gdb.objc gdb.opencl gdb.opt gdb.pascal gdb.python gdb.threads \
+ gdb.trace gdb.xml \
$(SUBDIRS)
EXPECT = `if [ -f $${rootme}/../../expect/expect ] ; then \
diff --git a/gdb/testsuite/configure b/gdb/testsuite/configure
index 7b1248a..b523d1b 100755
--- a/gdb/testsuite/configure
+++ b/gdb/testsuite/configure
@@ -3515,7 +3515,7 @@ done
-ac_config_files="$ac_config_files Makefile gdb.ada/Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile gdb.server/Makefile gdb.java/Makefile gdb.mi/Makefile gdb.modula2/Makefile gdb.multi/Makefile gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.python/Makefile gdb.reverse/Makefile gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile"
+ac_config_files="$ac_config_files Makefile gdb.ada/Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile gdb.server/Makefile gdb.java/Makefile gdb.mi/Makefile gdb.modula2/Makefile gdb.multi/Makefile gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.python/Makefile gdb.reverse/Makefile gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile gdb.opencl/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@@ -4237,6 +4237,7 @@ do
"gdb.threads/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.threads/Makefile" ;;
"gdb.trace/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.trace/Makefile" ;;
"gdb.xml/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.xml/Makefile" ;;
+ "gdb.opencl/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.opencl/Makefile" ;;
*) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
esac
diff --git a/gdb/testsuite/configure.ac b/gdb/testsuite/configure.ac
index c8668e5..2748108 100644
--- a/gdb/testsuite/configure.ac
+++ b/gdb/testsuite/configure.ac
@@ -144,6 +144,6 @@ AC_OUTPUT([Makefile \
gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile \
gdb.fortran/Makefile gdb.server/Makefile gdb.java/Makefile \
gdb.mi/Makefile gdb.modula2/Makefile gdb.multi/Makefile \
- gdb.objc/Makefile gdb.opt/Makefile gdb.pascal/Makefile \
+ gdb.objc/Makefile gdb.opencl/Makefile gdb.opt/Makefile gdb.pascal/Makefile \
gdb.python/Makefile gdb.reverse/Makefile \
gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile])
diff --git a/gdb/testsuite/gdb.base/default.exp b/gdb/testsuite/gdb.base/default.exp
index 7afa865..b6ecdcb 100644
--- a/gdb/testsuite/gdb.base/default.exp
+++ b/gdb/testsuite/gdb.base/default.exp
@@ -527,7 +527,7 @@ gdb_test "set history size" "Argument required .integer to set it to.*" "set his
#test set history
gdb_test "set history" "\"set history\" must be followed by the name of a history subcommand.(\[^\r\n\]*\[\r\n\])+List of set history subcommands:(\[^\r\n\]*\[\r\n\])+set history expansion -- Set history expansion on command input(\[^\r\n\]*\[\r\n\])+set history filename -- Set the filename in which to record the command history(\[^\r\n\]*\[\r\n\])+set history save -- Set saving of the history record on exit(\[^\r\n\]*\[\r\n\])+set history size -- Set the size of the command history(\[^\r\n\]*\[\r\n\])+Type \"help set history\" followed by set history subcommand name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous." "set history"
#test set language
-gdb_test "set language" "Requires an argument. Valid arguments are auto, local, unknown, ada, c, c.., asm, minimal, d, fortran, objective-c, java, modula-2, pascal." "set language"
+gdb_test "set language" "Requires an argument. Valid arguments are auto, local, unknown, ada, c, c.., asm, minimal, d, fortran, objective-c, java, modula-2, opencl, pascal." "set language"
#test set listsize
gdb_test "set listsize" "Argument required .integer to set it to.*" "set listsize"
#test set print "p" abbreviation
diff --git a/gdb/testsuite/gdb.opencl/Makefile.in b/gdb/testsuite/gdb.opencl/Makefile.in
new file mode 100644
index 0000000..c12aef3
--- /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 0000000..a024c51
--- /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 0000000..34ea635
--- /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 0000000..c0d2a1e
--- /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 0000000..45c9e52
--- /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 0000000..0974c04
--- /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 0000000..b60c65c
--- /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 0000000..d58f1ba
--- /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 0000000..e044e96
--- /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}
diff --git a/gdb/testsuite/lib/cl_util.c b/gdb/testsuite/lib/cl_util.c
new file mode 100644
index 0000000..5b731b2
--- /dev/null
+++ b/gdb/testsuite/lib/cl_util.c
@@ -0,0 +1,519 @@
+/* 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> */
+
+/* Utility macros and functions for OpenCL applications. */
+
+#include "cl_util.h"
+
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <string.h>
+
+const char *get_clerror_string (int errcode)
+{
+ switch (errcode)
+ {
+ case CL_SUCCESS:
+ return "CL_SUCCESS";
+ case CL_DEVICE_NOT_FOUND:
+ return "CL_DEVICE_NOT_FOUND";
+ case CL_DEVICE_NOT_AVAILABLE:
+ return "CL_DEVICE_NOT_AVAILABLE";
+ case CL_COMPILER_NOT_AVAILABLE:
+ return "CL_COMPILER_NOT_AVAILABLE";
+ case CL_MEM_OBJECT_ALLOCATION_FAILURE:
+ return "CL_MEM_OBJECT_ALLOCATION_FAILURE";
+ case CL_OUT_OF_RESOURCES:
+ return "CL_OUT_OF_RESOURCES";
+ case CL_OUT_OF_HOST_MEMORY:
+ return "CL_OUT_OF_HOST_MEMORY";
+ case CL_PROFILING_INFO_NOT_AVAILABLE:
+ return "CL_PROFILING_INFO_NOT_AVAILABLE";
+ case CL_MEM_COPY_OVERLAP:
+ return "CL_MEM_COPY_OVERLAP";
+ case CL_IMAGE_FORMAT_MISMATCH:
+ return "CL_IMAGE_FORMAT_MISMATCH";
+ case CL_IMAGE_FORMAT_NOT_SUPPORTED:
+ return "CL_IMAGE_FORMAT_NOT_SUPPORTED";
+ case CL_BUILD_PROGRAM_FAILURE:
+ return "CL_BUILD_PROGRAM_FAILURE";
+ case CL_MAP_FAILURE:
+ return "CL_MAP_FAILURE";
+ case CL_INVALID_VALUE:
+ return "CL_INVALID_VALUE";
+ case CL_INVALID_DEVICE_TYPE:
+ return "CL_INVALID_DEVICE_TYPE";
+ case CL_INVALID_PLATFORM:
+ return "CL_INVALID_PLATFORM";
+ case CL_INVALID_DEVICE:
+ return "CL_INVALID_DEVICE";
+ case CL_INVALID_CONTEXT:
+ return "CL_INVALID_CONTEXT";
+ case CL_INVALID_QUEUE_PROPERTIES:
+ return "CL_INVALID_QUEUE_PROPERTIES";
+ case CL_INVALID_COMMAND_QUEUE:
+ return "CL_INVALID_COMMAND_QUEUE";
+ case CL_INVALID_HOST_PTR:
+ return "CL_INVALID_HOST_PTR";
+ case CL_INVALID_MEM_OBJECT:
+ return "CL_INVALID_MEM_OBJECT";
+ case CL_INVALID_IMAGE_FORMAT_DESCRIPTOR:
+ return "CL_INVALID_IMAGE_FORMAT_DESCRIPTOR";
+ case CL_INVALID_IMAGE_SIZE:
+ return "CL_INVALID_IMAGE_SIZE";
+ case CL_INVALID_SAMPLER:
+ return "CL_INVALID_SAMPLER";
+ case CL_INVALID_BINARY:
+ return "CL_INVALID_BINARY";
+ case CL_INVALID_BUILD_OPTIONS:
+ return "CL_INVALID_BUILD_OPTIONS";
+ case CL_INVALID_PROGRAM:
+ return "CL_INVALID_PROGRAM";
+ case CL_INVALID_PROGRAM_EXECUTABLE:
+ return "CL_INVALID_PROGRAM_EXECUTABLE";
+ case CL_INVALID_KERNEL_NAME:
+ return "CL_INVALID_KERNEL_NAME";
+ case CL_INVALID_KERNEL_DEFINITION:
+ return "CL_INVALID_KERNEL_DEFINITION";
+ case CL_INVALID_KERNEL:
+ return "CL_INVALID_KERNEL";
+ case CL_INVALID_ARG_INDEX:
+ return "CL_INVALID_ARG_INDEX";
+ case CL_INVALID_ARG_VALUE:
+ return "CL_INVALID_ARG_VALUE";
+ case CL_INVALID_ARG_SIZE:
+ return "CL_INVALID_ARG_SIZE";
+ case CL_INVALID_KERNEL_ARGS:
+ return "CL_INVALID_KERNEL_ARGS";
+ case CL_INVALID_WORK_DIMENSION:
+ return "CL_INVALID_WORK_DIMENSION";
+ case CL_INVALID_WORK_GROUP_SIZE:
+ return "CL_INVALID_WORK_GROUP_SIZE";
+ case CL_INVALID_WORK_ITEM_SIZE:
+ return "CL_INVALID_WORK_ITEM_SIZE";
+ case CL_INVALID_GLOBAL_OFFSET:
+ return "CL_INVALID_GLOBAL_OFFSET";
+ case CL_INVALID_EVENT_WAIT_LIST:
+ return "CL_INVALID_EVENT_WAIT_LIST";
+ case CL_INVALID_EVENT:
+ return "CL_INVALID_EVENT";
+ case CL_INVALID_OPERATION:
+ return "CL_INVALID_OPERATION";
+ case CL_INVALID_GL_OBJECT:
+ return "CL_INVALID_GL_OBJECT";
+ case CL_INVALID_BUFFER_SIZE:
+ return "CL_INVALID_BUFFER_SIZE";
+ case CL_INVALID_MIP_LEVEL:
+ return "CL_INVALID_MIP_LEVEL";
+#ifndef CL_PLATFORM_NVIDIA
+ case CL_INVALID_GLOBAL_WORK_SIZE:
+ return "CL_INVALID_GLOBAL_WORK_SIZE";
+#endif
+ default:
+ return "Unknown";
+ };
+}
+
+
+void print_clinfo ()
+{
+ char *s = NULL;
+ size_t len;
+ unsigned i, j;
+ cl_uint platform_count;
+ cl_platform_id *platforms;
+
+ /* Determine number of OpenCL Platforms available. */
+ clGetPlatformIDs (0, NULL, &platform_count);
+ printf ("number of OpenCL Platforms available:\t%d\n", platform_count);
+ /* Get platforms. */
+ platforms
+ = (cl_platform_id*) malloc (sizeof (cl_platform_id) * platform_count);
+ if (platforms == NULL)
+ {
+ fprintf (stderr, "malloc failed\n");
+ exit (EXIT_FAILURE);
+ }
+ clGetPlatformIDs (platform_count, platforms, NULL);
+
+ /* Querying platforms. */
+ for (i = 0; i < platform_count; i++)
+ {
+ cl_device_id *devices;
+ cl_uint device_count;
+ cl_device_id default_dev;
+ printf (" OpenCL Platform: %d\n", i);
+
+#define PRINT_PF_INFO(PARM)\
+ clGetPlatformInfo (platforms[i], PARM, 0, NULL, &len); \
+ s = realloc (s, len); \
+ clGetPlatformInfo (platforms[i], PARM, len, s, NULL); \
+ printf (" %-36s%s\n", #PARM ":", s);
+
+ PRINT_PF_INFO (CL_PLATFORM_PROFILE)
+ PRINT_PF_INFO (CL_PLATFORM_VERSION)
+ PRINT_PF_INFO (CL_PLATFORM_NAME)
+ PRINT_PF_INFO (CL_PLATFORM_VENDOR)
+ PRINT_PF_INFO (CL_PLATFORM_EXTENSIONS)
+#undef PRINT_PF_INFO
+
+ clGetDeviceIDs (platforms[i], CL_DEVICE_TYPE_DEFAULT, 1, &default_dev,
+ NULL);
+ clGetDeviceInfo (default_dev, CL_DEVICE_NAME, 0, NULL, &len);
+ s = realloc (s, len);
+ clGetDeviceInfo (default_dev, CL_DEVICE_NAME, len, s, NULL);
+ printf (" CL_DEVICE_TYPE_DEFAULT: %s\n", s);
+
+ /* Determine number of devices. */
+ clGetDeviceIDs (platforms[i], CL_DEVICE_TYPE_ALL, 0, NULL, &device_count);
+ printf ("\n number of OpenCL Devices available: %d\n", device_count);
+ /* Get devices. */
+ devices = (cl_device_id*) malloc (sizeof (cl_device_id) * device_count);
+ if (devices == NULL)
+ {
+ fprintf (stderr, "malloc failed\n");
+ exit (EXIT_FAILURE);
+ }
+ clGetDeviceIDs (platforms[i], CL_DEVICE_TYPE_ALL, device_count, devices,
+ NULL);
+
+ /* Querying devices. */
+ for (j = 0; j < device_count; j++)
+ {
+ cl_device_type dtype;
+ cl_device_mem_cache_type mctype;
+ cl_device_local_mem_type mtype;
+ cl_device_fp_config fpcfg;
+ cl_device_exec_capabilities xcap;
+ cl_command_queue_properties qprops;
+ cl_bool clbool;
+ cl_uint cluint;
+ cl_ulong clulong;
+ size_t sizet;
+ size_t workitem_size[3];
+ printf (" OpenCL Device: %d\n", j);
+
+#define PRINT_DEV_INFO(PARM)\
+ clGetDeviceInfo (devices[j], PARM, 0, NULL, &len); \
+ s = realloc (s, len); \
+ clGetDeviceInfo (devices[j], PARM, len, s, NULL); \
+ printf (" %-41s%s\n", #PARM ":", s);
+
+ PRINT_DEV_INFO (CL_DEVICE_NAME)
+ PRINT_DEV_INFO (CL_DRIVER_VERSION)
+ PRINT_DEV_INFO (CL_DEVICE_VENDOR)
+ clGetDeviceInfo (devices[j], CL_DEVICE_VENDOR_ID, sizeof (cluint),
+ &cluint, NULL);
+ printf (" CL_DEVICE_VENDOR_ID: %d\n", cluint);
+
+ clGetDeviceInfo (devices[j], CL_DEVICE_TYPE, sizeof (dtype), &dtype, NULL);
+ if (dtype & CL_DEVICE_TYPE_CPU)
+ printf (" CL_DEVICE_TYPE: CL_DEVICE_TYPE_CPU\n");
+ if (dtype & CL_DEVICE_TYPE_GPU)
+ printf (" CL_DEVICE_TYPE: CL_DEVICE_TYPE_GPU\n");
+ if (dtype & CL_DEVICE_TYPE_ACCELERATOR)
+ printf (" CL_DEVICE_TYPE: CL_DEVICE_TYPE_ACCELERATOR\n");
+ if (dtype & CL_DEVICE_TYPE_DEFAULT)
+ printf (" CL_DEVICE_TYPE: CL_DEVICE_TYPE_DEFAULT\n");
+
+ clGetDeviceInfo (devices[j], CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof (cluint), &cluint, NULL);
+ printf (" CL_DEVICE_MAX_CLOCK_FREQUENCY: %d\n", cluint);
+
+ PRINT_DEV_INFO (CL_DEVICE_PROFILE)
+ PRINT_DEV_INFO (CL_DEVICE_EXTENSIONS)
+
+ clGetDeviceInfo (devices[j], CL_DEVICE_AVAILABLE, sizeof (clbool), &clbool, NULL);
+ if (clbool == CL_TRUE)
+ printf (" CL_DEVICE_AVAILABLE: CL_TRUE\n");
+ else
+ printf (" CL_DEVICE_AVAILABLE: CL_FALSE\n");
+ clGetDeviceInfo (devices[j], CL_DEVICE_ENDIAN_LITTLE, sizeof (clbool), &clbool, NULL);
+ if (clbool == CL_TRUE)
+ printf (" CL_DEVICE_ENDIAN_LITTLE: CL_TRUE\n");
+ else
+ printf (" CL_DEVICE_ENDIAN_LITTLE: CL_FALSE\n");
+
+ clGetDeviceInfo (devices[j], CL_DEVICE_MAX_COMPUTE_UNITS, sizeof (cluint), &cluint, NULL);
+ printf (" CL_DEVICE_MAX_COMPUTE_UNITS: %d\n", cluint);
+ clGetDeviceInfo (devices[j], CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof (sizet), &sizet, NULL);
+ printf (" CL_DEVICE_MAX_WORK_GROUP_SIZE: %d\n", sizet);
+ clGetDeviceInfo (devices[j], CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, sizeof (cluint), &cluint, NULL);
+ printf (" CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS: %d\n", cluint);
+ clGetDeviceInfo (devices[j], CL_DEVICE_MAX_WORK_ITEM_SIZES, sizeof (workitem_size), &workitem_size, NULL);
+ printf (" CL_DEVICE_MAX_WORK_ITEM_SIZES: %d / %d / %d\n", workitem_size[0], workitem_size[1], workitem_size[2]);
+
+ clGetDeviceInfo (devices[j], CL_DEVICE_ADDRESS_BITS, sizeof (cluint), &cluint, NULL);
+ printf (" CL_DEVICE_ADDRESS_BITS: %d\n", cluint);
+
+ clGetDeviceInfo (devices[j], CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof (clulong), &clulong, NULL);
+ printf (" CL_DEVICE_MAX_MEM_ALLOC_SIZE: %llu\n", clulong);
+ clGetDeviceInfo (devices[j], CL_DEVICE_MEM_BASE_ADDR_ALIGN, sizeof (cluint), &cluint, NULL);
+ printf (" CL_DEVICE_MEM_BASE_ADDR_ALIGN: %d\n", cluint);
+ clGetDeviceInfo(devices[j], CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, sizeof (cluint), &cluint, NULL);
+ printf (" CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE: %d\n", cluint);
+ clGetDeviceInfo(devices[j], CL_DEVICE_MAX_PARAMETER_SIZE, sizeof (sizet), &sizet, NULL);
+ printf (" CL_DEVICE_MAX_PARAMETER_SIZE: %d\n", sizet);
+ clGetDeviceInfo(devices[j], CL_DEVICE_GLOBAL_MEM_SIZE, sizeof (clulong), &clulong, NULL);
+ printf (" CL_DEVICE_GLOBAL_MEM_SIZE: %llu\n", clulong);
+
+ clGetDeviceInfo (devices[j], CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, sizeof (mctype), &mctype, NULL);
+ if (mctype & CL_NONE)
+ printf (" CL_DEVICE_GLOBAL_MEM_CACHE_TYPE: CL_NONE\n");
+ if (mctype & CL_READ_ONLY_CACHE)
+ printf (" CL_DEVICE_GLOBAL_MEM_CACHE_TYPE: CL_READ_ONLY_CACHE\n");
+ if (mctype & CL_READ_WRITE_CACHE)
+ printf (" CL_DEVICE_GLOBAL_MEM_CACHE_TYPE: CL_READ_WRITE_CACHE\n");
+
+ clGetDeviceInfo (devices[j], CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, sizeof (clulong), &clulong, NULL);
+ printf (" CL_DEVICE_GLOBAL_MEM_CACHE_SIZE: %llu\n", clulong);
+ clGetDeviceInfo (devices[j], CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, sizeof (cluint), &cluint, NULL);
+ printf (" CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE: %d\n", cluint);
+
+ clGetDeviceInfo (devices[j], CL_DEVICE_LOCAL_MEM_TYPE, sizeof (mtype), &mtype, NULL);
+ if (mtype & CL_LOCAL)
+ printf (" CL_DEVICE_LOCAL_MEM_TYPE: CL_LOCAL\n");
+ if (mtype & CL_GLOBAL)
+ printf (" CL_DEVICE_LOCAL_MEM_TYPE: CL_GLOBAL\n");
+
+ clGetDeviceInfo (devices[j], CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, sizeof (cluint), &cluint, NULL);
+ printf (" CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE: %d\n", cluint);
+ clGetDeviceInfo (devices[j], CL_DEVICE_MEM_BASE_ADDR_ALIGN, sizeof (cluint), &cluint, NULL);
+ printf (" CL_DEVICE_MEM_BASE_ADDR_ALIGN: %d\n", cluint);
+ clGetDeviceInfo (devices[j], CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, sizeof (cluint), &cluint, NULL);
+ printf (" CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR: %d\n", cluint);
+ clGetDeviceInfo (devices[j], CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, sizeof (cluint), &cluint, NULL);
+ printf (" CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT: %d\n", cluint);
+ clGetDeviceInfo (devices[j], CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, sizeof (cluint), &cluint, NULL);
+ printf (" CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT: %d\n", cluint);
+ clGetDeviceInfo (devices[j], CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, sizeof (cluint), &cluint, NULL);
+ printf (" CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG: %d\n", cluint);
+ clGetDeviceInfo (devices[j], CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, sizeof (cluint), &cluint, NULL);
+ printf (" CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT: %d\n", cluint);
+ clGetDeviceInfo (devices[j], CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, sizeof (cluint), &cluint, NULL);
+ printf (" CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE: %d\n", cluint);
+
+ clGetDeviceInfo (devices[j], CL_DEVICE_SINGLE_FP_CONFIG, sizeof (fpcfg), &fpcfg, NULL);
+ if (fpcfg & CL_FP_DENORM)
+ printf (" CL_DEVICE_SINGLE_FP_CONFIG: CL_FP_DENORM\n");
+ if (fpcfg & CL_FP_INF_NAN)
+ printf (" CL_DEVICE_SINGLE_FP_CONFIG: CL_FP_INF_NAN\n");
+ if (fpcfg & CL_FP_ROUND_TO_NEAREST)
+ printf (" CL_DEVICE_SINGLE_FP_CONFIG: CL_FP_ROUND_TO_NEAREST\n");
+ if (fpcfg & CL_FP_ROUND_TO_ZERO)
+ printf (" CL_DEVICE_SINGLE_FP_CONFIG: CL_FP_ROUND_TO_ZERO\n");
+
+ clGetDeviceInfo (devices[j], CL_DEVICE_EXECUTION_CAPABILITIES, sizeof (xcap), &xcap, NULL);
+ if (xcap & CL_EXEC_KERNEL )
+ printf (" CL_DEVICE_EXECUTION_CAPABILITIES: CL_EXEC_KERNEL\n");
+ if (xcap & CL_EXEC_NATIVE_KERNEL)
+ printf (" CL_DEVICE_EXECUTION_CAPABILITIES: CL_EXEC_NATIVE_KERNEL\n");
+
+ clGetDeviceInfo (devices[j], CL_DEVICE_QUEUE_PROPERTIES, sizeof (qprops), &qprops, NULL);
+ if (qprops & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE)
+ printf (" CL_DEVICE_QUEUE_PROPERTIES: CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE\n");
+ if (qprops & CL_QUEUE_PROFILING_ENABLE)
+ printf (" CL_DEVICE_QUEUE_PROPERTIES: CL_QUEUE_PROFILING_ENABLE\n");
+
+ clGetDeviceInfo (devices[j], CL_DEVICE_PROFILING_TIMER_RESOLUTION, sizeof (sizet), &sizet, NULL);
+ printf (" CL_DEVICE_PROFILING_TIMER_RESOLUTION: %d\n", sizet);
+
+ clGetDeviceInfo (devices[j], CL_DEVICE_COMPILER_AVAILABLE, sizeof (clbool), &clbool, NULL);
+ if (clbool == CL_TRUE)
+ printf (" CL_DEVICE_COMPILER_AVAILABLE: CL_TRUE\n");
+ else
+ printf (" CL_DEVICE_COMPILER_AVAILABLE: CL_FALSE\n");
+ clGetDeviceInfo (devices[j], CL_DEVICE_ERROR_CORRECTION_SUPPORT, sizeof (clbool), &clbool, NULL);
+ if (clbool == CL_TRUE)
+ printf (" CL_DEVICE_ERROR_CORRECTION_SUPPORT: CL_TRUE\n");
+ else
+ printf (" CL_DEVICE_ERROR_CORRECTION_SUPPORT: CL_FALSE\n");
+
+ clGetDeviceInfo (devices[j], CL_DEVICE_IMAGE_SUPPORT, sizeof (clbool), &clbool, NULL);
+ if (clbool == CL_FALSE)
+ {
+ printf (" CL_DEVICE_IMAGE_SUPPORT: CL_FALSE\n");
+ }
+ else
+ {
+ printf (" CL_DEVICE_IMAGE_SUPPORT: CL_TRUE\n");
+ clGetDeviceInfo (devices[j], CL_DEVICE_MAX_SAMPLERS, sizeof (cluint), &cluint, NULL);
+ printf (" CL_DEVICE_MAX_SAMPLERS: %d\n", cluint);
+ clGetDeviceInfo (devices[j], CL_DEVICE_MAX_READ_IMAGE_ARGS, sizeof (cluint), &cluint, NULL);
+ printf (" CL_DEVICE_MAX_READ_IMAGE_ARGS: %d\n", cluint);
+ clGetDeviceInfo (devices[j], CL_DEVICE_MAX_WRITE_IMAGE_ARGS, sizeof (cluint), &cluint, NULL);
+ printf (" CL_DEVICE_MAX_WRITE_IMAGE_ARGS: %d\n", cluint);
+ clGetDeviceInfo (devices[j], CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof (sizet), &sizet, NULL);
+ printf (" CL_DEVICE_IMAGE2D_MAX_WIDTH: %d\n", sizet);
+ clGetDeviceInfo (devices[j], CL_DEVICE_IMAGE2D_MAX_HEIGHT, sizeof (sizet), &sizet, NULL);
+ printf (" CL_DEVICE_IMAGE2D_MAX_HEIGHT: %d\n", sizet);
+ clGetDeviceInfo (devices[j], CL_DEVICE_IMAGE3D_MAX_WIDTH, sizeof (sizet), &sizet, NULL);
+ printf (" CL_DEVICE_IMAGE3D_MAX_WIDTH: %d\n", sizet);
+ clGetDeviceInfo (devices[j], CL_DEVICE_IMAGE3D_MAX_HEIGHT, sizeof (sizet), &sizet, NULL);
+ printf (" CL_DEVICE_IMAGE3D_MAX_HEIGHT: %d\n", sizet);
+ clGetDeviceInfo (devices[j], CL_DEVICE_IMAGE3D_MAX_DEPTH, sizeof (sizet), &sizet, NULL);
+ printf (" CL_DEVICE_IMAGE3D_MAX_DEPTH: %d\n", sizet);
+ }
+#undef PRINT_DEV_INFO
+ } /* devices */
+ free (devices);
+ } /* platforms */
+ free (s);
+ free (platforms);
+}
+
+
+const char *
+read_file (const char * const filename, size_t *size)
+{
+ char *buf = NULL;
+ FILE *fd;
+ struct stat st;
+ if (stat (filename, &st) == -1)
+ {
+ /* Check if the file exists. */
+ if (errno == ENOENT)
+ return buf;
+ perror ("stat failed");
+ exit (EXIT_FAILURE);
+ }
+ buf = (char *) malloc (st.st_size);
+ if (buf == NULL)
+ {
+ fprintf (stderr, "malloc failed\n");
+ exit (EXIT_FAILURE);
+ }
+ fd = fopen (filename, "r");
+ if (fd == NULL)
+ {
+ perror ("fopen failed");
+ free (buf);
+ exit (EXIT_FAILURE);
+ }
+ if (fread (buf, st.st_size, 1, fd) != 1)
+ {
+ fprintf (stderr, "fread failed\n");
+ free (buf);
+ fclose (fd);
+ exit (EXIT_FAILURE);
+ }
+ fclose (fd);
+ *size = st.st_size;
+ return buf;
+}
+
+
+void
+save_program_binaries (cl_program program)
+{
+ cl_device_id *devices;
+ cl_uint device_count;
+ size_t *sizes;
+ unsigned char **binaries;
+ unsigned i, j;
+
+ /* Query the amount of devices for the given program. */
+ CHK (clGetProgramInfo (program, CL_PROGRAM_NUM_DEVICES, sizeof (cl_uint),
+ &device_count, NULL));
+
+ /* Get the sizes of the binaries. */
+ sizes = (size_t*) malloc (sizeof (size_t) * device_count);
+ if (sizes == NULL)
+ {
+ fprintf (stderr, "malloc failed\n");
+ exit (EXIT_FAILURE);
+ }
+ CHK (clGetProgramInfo (program, CL_PROGRAM_BINARY_SIZES, sizeof (sizes),
+ sizes, NULL));
+
+ /* Get the binaries. */
+ binaries
+ = (unsigned char **) malloc (sizeof (unsigned char *) * device_count);
+ if (binaries == NULL)
+ {
+ fprintf (stderr, "malloc failed\n");
+ exit (EXIT_FAILURE);
+ }
+ for (i = 0; i < device_count; i++)
+ {
+ binaries[i] = (unsigned char *) malloc (sizes[i]);
+ if (binaries[i] == NULL)
+ {
+ fprintf (stderr, "malloc failed\n");
+ exit (EXIT_FAILURE);
+ }
+ }
+ CHK (clGetProgramInfo (program, CL_PROGRAM_BINARIES, sizeof (binaries),
+ binaries, NULL));
+
+ /* Get the devices for the given program to extract the file names. */
+ devices = (cl_device_id*) malloc (sizeof (cl_device_id) * device_count);
+ if (devices == NULL)
+ {
+ fprintf (stderr, "malloc failed\n");
+ exit (EXIT_FAILURE);
+ }
+ CHK (clGetProgramInfo (program, CL_PROGRAM_DEVICES, sizeof (devices),
+ devices, NULL));
+
+ for (i = 0; i < device_count; i++)
+ {
+ FILE *fd;
+ char *dev_name = NULL;
+ size_t len;
+ CHK (clGetDeviceInfo (devices[i], CL_DEVICE_NAME, 0, NULL, &len));
+ dev_name = malloc (len);
+ if (dev_name == NULL)
+ {
+ fprintf (stderr, "malloc failed\n");
+ exit (EXIT_FAILURE);
+ }
+ CHK (clGetDeviceInfo (devices[i], CL_DEVICE_NAME, len, dev_name, NULL));
+ /* Convert spaces to underscores. */
+ for (j = 0; j < strlen (dev_name); j++)
+ {
+ if (dev_name[j] == ' ')
+ dev_name[j] = '_';
+ }
+
+ /* Save the binaries. */
+ printf ("saving program binary for device: %s\n", dev_name);
+ /* Save binaries[i]. */
+ fd = fopen (dev_name, "w");
+ if (fd == NULL)
+ {
+ perror ("fopen failed");
+ exit (EXIT_FAILURE);
+ }
+ if (fwrite (binaries[i], sizes[i], 1, fd) != 1)
+ {
+ fprintf (stderr, "fwrite failed\n");
+ for (j = i; j < device_count; j++)
+ free (binaries[j]);
+ fclose (fd);
+ exit (EXIT_FAILURE);
+ }
+ fclose (fd);
+ free (binaries[i]);
+ free (dev_name);
+ free (sizes);
+ }
+ free (devices);
+ free (binaries);
+}
diff --git a/gdb/testsuite/lib/cl_util.h b/gdb/testsuite/lib/cl_util.h
new file mode 100644
index 0000000..acdbc5d
--- /dev/null
+++ b/gdb/testsuite/lib/cl_util.h
@@ -0,0 +1,88 @@
+/* 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> */
+
+/* Utility macros and functions for OpenCL applications. */
+
+#ifndef CL_UTIL_H
+#define CL_UTIL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __APPLE__
+#include <OpenCL/opencl.h>
+#else
+#include <CL/cl.h>
+#endif
+#include <stdio.h>
+
+/* Executes the given OpenCL function and checks its return value.
+ In case of failure (rc != CL_SUCCESS) an error string will be
+ printed to stderr and the program will be terminated. This Macro
+ is only intended for OpenCL routines which return cl_int. */
+
+#define CHK(func)\
+{\
+ int rc = (func);\
+ CHK_ERR (#func, rc);\
+}
+
+/* Macro that checks an OpenCL error code. In case of failure
+ (err != CL_SUCCESS) an error string will be printed to stderr
+ including the prefix and the program will be terminated. This
+ Macro is only intended to use in conjunction with OpenCL routines
+ which take a pointer to a cl_int as an argument to place their
+ error code. */
+
+#define CHK_ERR(prefix, err)\
+if (err != CL_SUCCESS)\
+ {\
+ fprintf (stderr, "CHK_ERR (%s, %d)\n", prefix, err);\
+ fprintf (stderr, "%s:%d error: %s\n", __FILE__, __LINE__,\
+ get_clerror_string (err));\
+ exit (EXIT_FAILURE);\
+ };
+
+/* Return a pointer to a string that describes the error code specified
+ by the errcode argument. */
+
+extern const char *get_clerror_string (int errcode);
+
+/* Prints OpenCL information to stdout. */
+
+extern void print_clinfo ();
+
+/* Reads a given file into the memory and returns a pointer to the data or NULL
+ if the file does not exist. FILENAME specifies the location of the file to
+ be read. SIZE is an output parameter that returns the size of the file in
+ bytes. */
+
+extern const char *read_file (const char * const filename, size_t *size);
+
+/* Saves all program binaries of the given OpenCL PROGRAM. The file
+ names are extracted from the devices. */
+
+extern void save_program_binaries (cl_program program);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CL_UTIL_H */
diff --git a/gdb/testsuite/lib/opencl.exp b/gdb/testsuite/lib/opencl.exp
new file mode 100644
index 0000000..33d3688
--- /dev/null
+++ b/gdb/testsuite/lib/opencl.exp
@@ -0,0 +1,83 @@
+# 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>.
+#
+# Support library for testing OpenCL GDB features
+
+# Compile OpenCL programs using a generic host app.
+proc gdb_compile_opencl_hostapp {clsource executable options} {
+ global srcdir objdir subdir
+ set src "${srcdir}/lib/cl_util.c ${srcdir}/lib/opencl_hostapp.c"
+ set binfile ${objdir}/${subdir}/${executable}
+ set compile_flags [concat additional_flags=-I${srcdir}/lib/ additional_flags=-DCL_SOURCE=$clsource]
+ set options_opencl [concat {debug} $compile_flags $options [list libs=-lOpenCL]]
+ return [gdb_compile ${src} ${binfile} "executable" ${options_opencl}]
+}
+
+# Run a test on the target to check if it supports OpenCL. Return 0 if so, 1 if
+# it does not.
+proc skip_opencl_tests {} {
+ global skip_opencl_tests_saved srcdir objdir subdir gdb_prompt
+
+ # Use the cached value, if it exists. Cache value per "board" to handle
+ # runs with multiple options (e.g. unix/{-m32,-64}) correctly.
+ set me "skip_opencl_tests"
+ set board [target_info name]
+ if [info exists skip_opencl_tests_saved($board)] {
+ verbose "$me: returning saved $skip_opencl_tests_saved($board)" 2
+ return $skip_opencl_tests_saved($board)
+ }
+
+ # Set up, compile, and execute an OpenCL program. Include the current
+ # process ID in the file name of the executable to prevent conflicts with
+ # invocations for multiple testsuites.
+ set clprogram [remote_download target ${srcdir}/lib/opencl_kernel.cl]
+ set executable opencltest[pid].x
+
+ verbose "$me: compiling OpenCL test app" 2
+ set compile_flags {debug nowarnings quiet}
+
+ if { [gdb_compile_opencl_hostapp "${clprogram}" "${executable}" "" ] != "" } {
+ verbose "$me: compiling OpenCL binary failed, returning 1" 2
+ return [set skip_opencl_tests_saved($board) 1]
+ }
+
+ # Compilation succeeded so now run it via gdb.
+ clean_restart "$executable"
+ gdb_run_cmd
+ gdb_expect 30 {
+ -re ".*Program exited normally.*${gdb_prompt} $" {
+ verbose -log "\n$me: OpenCL support detected"
+ set skip_opencl_tests_saved($board) 0
+ }
+ -re ".*Program exited with code.*${gdb_prompt} $" {
+ verbose -log "\n$me: OpenCL support not detected"
+ set skip_opencl_tests_saved($board) 1
+ }
+ default {
+ verbose -log "\n$me OpenCL support not detected (default case)"
+ set skip_opencl_tests_saved($board) 1
+ }
+ }
+ gdb_exit
+ remote_file build delete $executable
+
+ # Delete the OpenCL program source file.
+ remote_file target delete ${clprogram}
+
+ verbose "$me: returning $skip_opencl_tests_saved($board)" 2
+ return $skip_opencl_tests_saved($board)
+}
diff --git a/gdb/testsuite/lib/opencl_hostapp.c b/gdb/testsuite/lib/opencl_hostapp.c
new file mode 100644
index 0000000..4bc9658
--- /dev/null
+++ b/gdb/testsuite/lib/opencl_hostapp.c
@@ -0,0 +1,168 @@
+/* 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> */
+
+/* Simple OpenCL application that executes a kernel on the default device
+ in a data parallel fashion. The filename of the OpenCL program source
+ should be specified using the CL_SOURCE define. The name of the kernel
+ routine is expected to be "testkernel". */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <CL/cl.h>
+#include "cl_util.h"
+
+#ifndef CL_SOURCE
+#error "Please specify the OpenCL source file using the CL_SOURCE define"
+#endif
+
+#define STRINGIFY(S) _STRINGIFY(S)
+#define _STRINGIFY(S) #S
+
+#define SIZE 16
+
+int
+main ()
+{
+ int err, i;
+ cl_platform_id platform;
+ cl_device_id device;
+ cl_context context;
+ cl_context_properties context_props[3];
+ cl_command_queue queue;
+ cl_program program;
+ cl_kernel kernel;
+ cl_mem buffer;
+
+ size_t len;
+ const char *program_source = NULL;
+ char *device_extensions = NULL;
+ char kernel_build_opts[256];
+ size_t size = sizeof (cl_int) * SIZE;
+ const size_t global_work_size[] = {SIZE, 0, 0}; /* size of each dimension */
+ cl_int *data;
+
+ /* In order to see which devices the OpenCL implementation on your platform
+ provides you may issue a call to the print_clinfo () fuction. */
+
+ /* Initialize the data the OpenCl program operates on. */
+ data = (cl_int*) calloc (1, size);
+ if (data == NULL)
+ {
+ fprintf (stderr, "calloc failed\n");
+ exit (EXIT_FAILURE);
+ }
+
+ /* Pick the first platform. */
+ CHK (clGetPlatformIDs (1, &platform, NULL));
+ /* Get the default device and create context. */
+ CHK (clGetDeviceIDs (platform, CL_DEVICE_TYPE_DEFAULT, 1, &device, NULL));
+ context_props[0] = CL_CONTEXT_PLATFORM;
+ context_props[1] = (cl_context_properties) platform;
+ context_props[2] = 0;
+ context = clCreateContext (context_props, 1, &device, NULL, NULL, &err);
+ CHK_ERR ("clCreateContext", err);
+ queue = clCreateCommandQueue (context, device, 0, &err);
+ CHK_ERR ("clCreateCommandQueue", err);
+
+ /* Query OpenCL extensions of that device. */
+ CHK (clGetDeviceInfo (device, CL_DEVICE_EXTENSIONS, 0, NULL, &len));
+ device_extensions = (char *) malloc (len);
+ CHK (clGetDeviceInfo (device, CL_DEVICE_EXTENSIONS, len, device_extensions,
+ NULL));
+ strcpy (kernel_build_opts, "-Werror -cl-opt-disable");
+ if (strstr (device_extensions, "cl_khr_fp64") != NULL)
+ strcpy (kernel_build_opts + strlen (kernel_build_opts),
+ " -D HAVE_cl_khr_fp64");
+ if (strstr (device_extensions, "cl_khr_fp16") != NULL)
+ strcpy (kernel_build_opts + strlen (kernel_build_opts),
+ " -D HAVE_cl_khr_fp16");
+
+ /* Read the OpenCL kernel source into the main memory. */
+ program_source = read_file (STRINGIFY (CL_SOURCE), &len);
+ if (program_source == NULL)
+ {
+ fprintf (stderr, "file does not exist: %s\n", STRINGIFY (CL_SOURCE));
+ exit (EXIT_FAILURE);
+ }
+
+ /* Build the OpenCL kernel. */
+ program = clCreateProgramWithSource (context, 1, &program_source,
+ &len, &err);
+ free ((void*) program_source);
+ CHK_ERR ("clCreateProgramWithSource", err);
+ err = clBuildProgram (program, 0, NULL, kernel_build_opts, NULL,
+ NULL);
+ if (err != CL_SUCCESS)
+ {
+ size_t len;
+ char *clbuild_log = NULL;
+ CHK (clGetProgramBuildInfo (program, device, CL_PROGRAM_BUILD_LOG, 0,
+ NULL, &len));
+ clbuild_log = malloc (len);
+ if (clbuild_log)
+ {
+ CHK (clGetProgramBuildInfo (program, device, CL_PROGRAM_BUILD_LOG,
+ len, clbuild_log, NULL));
+ fprintf (stderr, "clBuildProgram failed with:\n%s\n", clbuild_log);
+ free (clbuild_log);
+ }
+ exit (EXIT_FAILURE);
+ }
+
+ /* In some cases it might be handy to save the OpenCL program binaries to do
+ further analysis on them. In order to do so you may call the following
+ function: save_program_binaries (program);. */
+
+ kernel = clCreateKernel (program, "testkernel", &err);
+ CHK_ERR ("clCreateKernel", err);
+
+ /* Setup the input data for the kernel. */
+ buffer = clCreateBuffer (context, CL_MEM_USE_HOST_PTR, size, data, &err);
+ CHK_ERR ("clCreateBuffer", err);
+
+ /* Execute the kernel (data parallel). */
+ CHK (clSetKernelArg (kernel, 0, sizeof (buffer), &buffer));
+ CHK (clEnqueueNDRangeKernel (queue, kernel, 1, NULL, global_work_size, NULL,
+ 0, NULL, NULL));
+
+ /* Fetch the results (blocking). */
+ CHK (clEnqueueReadBuffer (queue, buffer, CL_TRUE, 0, size, data, 0, NULL,
+ NULL));
+
+ /* Compare the results. */
+ for (i = 0; i < SIZE; i++)
+ {
+ if (data[i] != 0x1)
+ {
+ fprintf (stderr, "error: data[%d]: %d != 0x1\n", i, data[i]);
+ exit (EXIT_FAILURE);
+ }
+ }
+
+ /* Cleanup. */
+ CHK (clReleaseMemObject (buffer));
+ CHK (clReleaseKernel (kernel));
+ CHK (clReleaseProgram (program));
+ CHK (clReleaseCommandQueue (queue));
+ CHK (clReleaseContext (context));
+ free (data);
+
+ return 0;
+}
diff --git a/gdb/testsuite/lib/opencl_kernel.cl b/gdb/testsuite/lib/opencl_kernel.cl
new file mode 100644
index 0000000..32cba64
--- /dev/null
+++ b/gdb/testsuite/lib/opencl_kernel.cl
@@ -0,0 +1,5 @@
+/* OpenCL kernel for testing purposes. */
+__kernel void testkernel (__global int *data)
+{
+ data[get_global_id(0)] = 0x1;
+}