public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [patch] initial OpenCL C language support
@ 2010-10-22 17:21 Ken Werner
  2010-10-25 22:41 ` Tom Tromey
  0 siblings, 1 reply; 36+ messages in thread
From: Ken Werner @ 2010-10-22 17:21 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: Text/Plain, Size: 1176 bytes --]

Hi,

This patch implements initial GDB support for the OpenCL C Programming 
Language. Since OpenCL is based on C99 I tried to reuse GDBs C infrastructure 
where possible (expression parser, printing routines, etc). The patch 
basically adds "opencl" to the list of known source level languages. The 
built-in scalar and vector data types specified by OpenCL including the 3-
component vectors defined by version 1.1 as well as the half- and double-
precision floating point data types of the cl_khr_fp16 and cl_khr_fp64 OpenCL 
extensions are implemented. The operators specified by section 6.3 are 
covered. Vector component access as specified by section 6.1.7 of OpenCL 
including the access as lvalue (where possible) is also part of this patch. 
The GDB testsuite has been enhanced to detect OpenCL support and testcases 
have been added to test the features mentioned above. This patch is meant to 
be applied on top of these patches:
  http://sourceware.org/ml/gdb-patches/2010-10/msg00289.html
  http://sourceware.org/ml/gdb-patches/2010-10/msg00031.html
  http://sourceware.org/ml/gdb-patches/2010-10/msg00297.html

Any comments are appreciated.

Regards
Ken Werner

[-- Attachment #2: opencl-lang.patch --]
[-- Type: text/x-patch, Size: 198096 bytes --]

ChangeLog:

2010-10-22  Ken Werner  <ken.werner@de.ibm.com>

	* 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".
	(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.

testsuite/ChangeLog:

2010-10-22  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.


Index: src/gdb/defs.h
===================================================================
--- src.orig/gdb/defs.h	2010-10-22 17:17:33.000000000 +0200
+++ src/gdb/defs.h	2010-10-22 17:18:09.000000000 +0200
@@ -202,6 +202,7 @@ enum language
     language_pascal,		/* Pascal */
     language_ada,		/* Ada */
     language_scm,		/* Guile Scheme */
+    language_opencl,		/* OpenCL */
     language_minimal,		/* All other languages, minimal support only */
     nr_languages
   };
Index: src/gdb/dwarf2read.c
===================================================================
--- src.orig/gdb/dwarf2read.c	2010-10-22 17:18:09.000000000 +0200
+++ src/gdb/dwarf2read.c	2010-10-22 17:18:09.000000000 +0200
@@ -5089,6 +5089,12 @@ read_file_scope (struct die_info *die, s
   if (attr)
     cu->producer = DW_STRING (attr);
 
+  /* The XLCL doesn't generate DW_LANG_OpenCL because this attribute is not
+     standardised yet.  As a workaround for the language detection we fall
+     back to the DW_AT_producer string.  */
+  if (cu->producer && strstr (cu->producer, "IBM XL C for OpenCL") != NULL)
+    cu->language = language_opencl;
+
   /* We assume that we're processing GCC output. */
   processing_gcc_compilation = 2;
 
Index: src/gdb/opencl-lang.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/opencl-lang.c	2010-10-22 17:18:09.000000000 +0200
@@ -0,0 +1,1117 @@
+/* OpenCL language support for GDB, the GNU debugger.
+   Copyright (C) 2010 Free Software Foundation, Inc.
+
+   Contributed by Ken Werner <ken.werner@de.ibm.com>.
+
+   This file is part of GDB.
+
+   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/>.  */
+
+#include <string.h>
+#include "defs.h"
+#include "gdbtypes.h"
+#include "symtab.h"
+#include "expression.h"
+#include "parser-defs.h"
+#include "symtab.h"
+#include "language.h"
+#include "c-lang.h"
+#include "gdb_assert.h"
+
+extern void _initialize_opencl_language (void);
+
+/* This macro generates enum values from a given type.  */
+#define OCL_P_TYPE(TYPE)\
+  opencl_primitive_type_##TYPE,\
+  opencl_primitive_type_##TYPE##2,\
+  opencl_primitive_type_##TYPE##3,\
+  opencl_primitive_type_##TYPE##4,\
+  opencl_primitive_type_##TYPE##8,\
+  opencl_primitive_type_##TYPE##16
+
+enum opencl_primitive_types {
+  OCL_P_TYPE (char),
+  OCL_P_TYPE (uchar),
+  OCL_P_TYPE (short),
+  OCL_P_TYPE (ushort),
+  OCL_P_TYPE (int),
+  OCL_P_TYPE (uint),
+  OCL_P_TYPE (long),
+  OCL_P_TYPE (ulong),
+  OCL_P_TYPE (half),
+  OCL_P_TYPE (float),
+  OCL_P_TYPE (double),
+  opencl_primitive_type_bool,
+  opencl_primitive_type_unsigned_char,
+  opencl_primitive_type_unsigned_short,
+  opencl_primitive_type_unsigned_int,
+  opencl_primitive_type_unsigned_long,
+  opencl_primitive_type_size_t,
+  opencl_primitive_type_ptrdiff_t,
+  opencl_primitive_type_intptr_t,
+  opencl_primitive_type_uintptr_t,
+  opencl_primitive_type_void,
+  nr_opencl_primitive_types
+};
+
+/* This macro generates the type struct declarations from a given type.  */
+#define STRUCT_OCL_TYPE(TYPE)\
+  struct type *builtin_##TYPE;\
+  struct type *builtin_##TYPE##2;\
+  struct type *builtin_##TYPE##3;\
+  struct type *builtin_##TYPE##4;\
+  struct type *builtin_##TYPE##8;\
+  struct type *builtin_##TYPE##16
+
+struct builtin_opencl_type
+{
+  STRUCT_OCL_TYPE (char);
+  STRUCT_OCL_TYPE (uchar);
+  STRUCT_OCL_TYPE (short);
+  STRUCT_OCL_TYPE (ushort);
+  STRUCT_OCL_TYPE (int);
+  STRUCT_OCL_TYPE (uint);
+  STRUCT_OCL_TYPE (long);
+  STRUCT_OCL_TYPE (ulong);
+  STRUCT_OCL_TYPE (half);
+  STRUCT_OCL_TYPE (float);
+  STRUCT_OCL_TYPE (double);
+  struct type *builtin_bool;
+  struct type *builtin_unsigned_char;
+  struct type *builtin_unsigned_short;
+  struct type *builtin_unsigned_int;
+  struct type *builtin_unsigned_long;
+  struct type *builtin_size_t;
+  struct type *builtin_ptrdiff_t;
+  struct type *builtin_intptr_t;
+  struct type *builtin_uintptr_t;
+  struct type *builtin_void;
+};
+
+static struct gdbarch_data *opencl_type_data;
+
+const struct builtin_opencl_type *
+builtin_opencl_type (struct gdbarch *gdbarch)
+{
+  return gdbarch_data (gdbarch, opencl_type_data);
+}
+
+/* Returns the corresponding OpenCL vector type from the given type code,
+   the length of the element type, the unsigned flag and the amount of
+   elements (n).  */
+static struct type *
+lookup_opencl_vector_type (struct gdbarch *gdbarch, enum type_code code,
+			   unsigned int el_length, unsigned int flag_unsigned,
+			   int n)
+{
+  int i;
+  unsigned int length;
+  struct type *type = NULL;
+  struct type **types = (struct type **) builtin_opencl_type (gdbarch);
+
+  /* Check if n describes a valid OpenCL vector size (2, 3, 4, 8, 16).  */
+  if (n != 2 && n != 3 && n != 4 && n != 8 && n != 16)
+    error (_("Invalid OpenCL vector size: %d"), n);
+
+  /* Triple vectors have the size of a quad vector. */
+  length = (n == 3) ?  el_length * 4 : el_length * n;
+
+  for (i = 0; i < nr_opencl_primitive_types; i++)
+    {
+      LONGEST lowb, highb;
+
+      if (TYPE_CODE (types[i]) == TYPE_CODE_ARRAY && TYPE_VECTOR (types[i])
+	  && get_array_bounds (types[i], &lowb, &highb)
+	  && TYPE_CODE (TYPE_TARGET_TYPE (types[i])) == code
+	  && TYPE_UNSIGNED (TYPE_TARGET_TYPE (types[i])) == flag_unsigned
+	  && TYPE_LENGTH (TYPE_TARGET_TYPE (types[i])) == el_length
+	  && TYPE_LENGTH (types[i]) == length
+	  && highb - lowb + 1 == n)
+	{
+	  type = types[i];
+	  break;
+	}
+    }
+
+  return type;
+}
+
+/* Returns whether array contains duplicates or not within the first n number
+   of elements.  */
+static int
+array_has_dups (int arr[], int n)
+{
+  int i, j;
+
+  for (i = 0; i < n; i++)
+    {
+      for (j = i + 1; j < n; j++)
+        {
+          if (arr[i] == arr[j])
+            return 1;
+        }
+    }
+  return 0;
+}
+
+/* The OpenCL component access syntax allows to create lvalues referring to
+   selected elements of an original OpenCL vector in arbitrary order.  This
+   structure holds the information to describe such lvalues.  */
+struct lval_closure
+{
+  /* Reference count.  */
+  int refc;
+  /* The number of indicies.  */
+  int n;
+  /* The element indicies themselves.  */
+  int *indices;
+  /* A pointer to the original value.  */
+  struct value *val;
+};
+
+/* Allocates an instance of struct lval_closure.  */
+static struct lval_closure *
+allocate_lval_closure (int indices[], int n, struct value *val)
+{
+  struct lval_closure *c = XZALLOC (struct lval_closure);
+  c->refc = 1;
+  c->n = n;
+  c->indices = XCALLOC (n, int);
+  memcpy (c->indices, indices, n * sizeof (int));
+  value_incref (val); /* Increment the reference counter of the value.  */
+  c->val = val;
+  return c;
+}
+
+static void
+lval_func_read (struct value *v)
+{
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+  struct type *type = check_typedef (value_type (v));
+  struct type *eltype = TYPE_TARGET_TYPE (check_typedef (value_type (c->val)));
+  int offset = value_offset (v);
+  int elsize = TYPE_LENGTH (eltype);
+  int n, i, j = 0;
+  LONGEST lowb = 0;
+  LONGEST highb = 0;
+
+  if (TYPE_CODE (type) == TYPE_CODE_ARRAY
+      && !get_array_bounds (type, &lowb, &highb))
+    error (_("Could not determine the vector bounds"));
+
+  /* Assume elsize aligned offset.  */
+  gdb_assert (offset % elsize == 0);
+  offset /= elsize;
+  n = offset + highb - lowb + 1;
+  gdb_assert (n <= c->n);
+
+  for (i = offset; i < n; i++)
+    {
+      memcpy (value_contents_raw (v) + j++ * elsize,
+	      value_contents (c->val) + c->indices[i] * elsize,
+	      elsize);
+    }
+}
+
+static void
+lval_func_write (struct value *v, struct value *fromval)
+{
+  struct value *mark = value_mark ();
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+  struct type *type = check_typedef (value_type (v));
+  struct type *eltype = TYPE_TARGET_TYPE (check_typedef (value_type (c->val)));
+  int offset = value_offset (v);
+  int elsize = TYPE_LENGTH (eltype);
+  int n, i, j = 0;
+  LONGEST lowb = 0;
+  LONGEST highb = 0;
+
+  if (TYPE_CODE (type) == TYPE_CODE_ARRAY
+      && !get_array_bounds (type, &lowb, &highb))
+    error (_("Could not determine the vector bounds"));
+
+  /* Assume elsize aligned offset.  */
+  gdb_assert (offset % elsize == 0);
+  offset /= elsize;
+  n = offset + highb - lowb + 1;
+
+  /* Since accesses to the fourth component of a triple vector is undefined we
+     just skip writes to the fourth element.  Imagine something like this:
+       int3 i3 = (int3)(0, 1, 2);
+       i3.hi.hi = 5;
+     In this case n would be 4 (offset=12/4 + 1) while c->n would be 3.  */
+  if (n > c->n)
+    n = c->n;
+
+  for (i = offset; i < n; i++)
+    {
+      struct value *from_elm_val = allocate_value (eltype);
+      struct value *to_elm_val = value_subscript (c->val, c->indices[i]);
+      memcpy (value_contents_writeable (from_elm_val),
+	      value_contents (fromval) + j++ * elsize,
+	      elsize);
+      value_assign (to_elm_val, from_elm_val);
+    }
+  value_free_to_mark (mark);
+}
+
+/* Return 0 if any bit in v within offset and length is invalid, 1 if they are
+   all valid.  */
+static int
+lval_func_check_validity (const struct value *v, int offset, int length)
+{
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+  /* Size of the target type in bits.  */
+  int elsize =
+      TYPE_LENGTH (TYPE_TARGET_TYPE (check_typedef (value_type (c->val)))) * 8;
+  int startrest = offset % elsize;
+  int start = offset / elsize;
+  int endrest = (offset + length) % elsize;
+  int end = (offset + length) / elsize;
+  int i;
+
+  if (endrest)
+    end++;
+
+  if (end > c->n)
+    return 0;
+
+  for (i = start; i < end; i++)
+    {
+      int startoffset = (i == start) ? startrest : 0;
+      int length = (i == end) ? endrest : elsize;
+      if (!value_bits_valid (c->val, c->indices[i] * elsize + startoffset,
+			     length))
+	return 0;
+    }
+  return 1;
+}
+
+/* Return 1 if any bit in v is valid, 0 if they are all invalid.  */
+static int
+lval_func_check_any_valid (const struct value *v)
+{
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+  /* Size of the target type in bits.  */
+  int elsize =
+      TYPE_LENGTH (TYPE_TARGET_TYPE (check_typedef (value_type (c->val)))) * 8;
+  int i;
+
+  for (i = 0; i < c->n; i++)
+    {
+      if (value_bits_valid (c->val, c->indices[i] * elsize, elsize))
+	return 1;
+    }
+  return 0;
+}
+
+static void *
+lval_func_copy_closure (const struct value *v)
+{
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+  ++c->refc;
+  return c;
+}
+
+static void
+lval_func_free_closure (struct value *v)
+{
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+  --c->refc;
+  if (c->refc == 0)
+    {
+      xfree (c->indices);
+      xfree (c);
+      value_free (c->val); /* Decrement the reference counter of the value.  */
+    }
+}
+
+static struct lval_funcs opencl_value_funcs =
+  {
+    lval_func_read,
+    lval_func_write,
+    lval_func_check_validity,
+    lval_func_check_any_valid,
+    lval_func_copy_closure,
+    lval_func_free_closure
+  };
+
+/* Creates a sub-vector from VAL.  The elements are selected by the indices of
+   an array with the length of N.  Supported values for NOSIDE are
+   EVAL_NORMAL and EVAL_AVOID_SIDE_EFFECTS.  */
+static struct value *
+create_value (struct gdbarch *gdbarch, struct value *val, enum noside noside,
+	      int indices[], int n)
+{
+  struct type *type = check_typedef (value_type (val));
+  struct type *elm_type = TYPE_TARGET_TYPE (type);
+  struct value *ret;
+
+  /* Check if a single component of a vector is requested which means
+     the resulting type is a (primitive) scalar type.  */
+  if (n == 1)
+    {
+      if (noside == EVAL_AVOID_SIDE_EFFECTS)
+        ret = value_zero (elm_type, not_lval);
+      else
+        ret = value_subscript (val, indices[0]);
+    }
+  /* Multiple components of the vector are requested which means the
+     resulting type is a vector as well.  */
+  else
+    {
+      struct type *dst_type =
+	lookup_opencl_vector_type (gdbarch, TYPE_CODE (elm_type),
+				   TYPE_LENGTH (elm_type),
+				   TYPE_UNSIGNED (elm_type), n);
+
+      if (dst_type == NULL)
+	dst_type = init_vector_type (elm_type, n);
+
+      make_cv_type (TYPE_CONST (type), TYPE_VOLATILE (type), dst_type, NULL);
+
+      if (noside == EVAL_AVOID_SIDE_EFFECTS)
+	ret = allocate_value (dst_type);
+      else
+	{
+	  /* Check whether to create a lvalue or not.  */
+	  if (VALUE_LVAL (val) != not_lval && !array_has_dups (indices, n))
+	    {
+	      struct lval_closure *c = allocate_lval_closure (indices, n, val);
+	      ret = allocate_computed_value (dst_type, &opencl_value_funcs, c);
+	    }
+	  else
+	    {
+	      int i;
+	      ret = allocate_value (dst_type);
+	      for (i = 0; i < n; i++)
+		{
+		  /* Copy src val contents into the destination value.  */
+		  memcpy (value_contents_writeable (ret)
+			  + (i * TYPE_LENGTH (elm_type)),
+			  value_contents (val)
+			  + (indices[i] * TYPE_LENGTH (elm_type)),
+			  TYPE_LENGTH (elm_type));
+		}
+	    }
+	}
+    }
+  return ret;
+}
+
+/* OpenCL vector component access.  */
+static struct value *
+opencl_component_ref (struct expression *exp, struct value *val, char *comps,
+		      enum noside noside)
+{
+  LONGEST lowb, highb;
+  int src_len;
+  struct value *v;
+  int indices[16], i;
+  int dst_len;
+
+  if (!get_array_bounds (check_typedef (value_type (val)), &lowb, &highb))
+    error (_("Could not determine the vector bounds"));
+
+  src_len = highb - lowb + 1;
+
+  /* Throw an error if the amount of array elements does not fit a
+     valid OpenCL vector size (2, 3, 4, 8, 16).  */
+  if (src_len != 2 && src_len != 3 && src_len != 4 && src_len != 8
+      && src_len != 16)
+    error (_("Invalid OpenCL vector size"));
+
+  if (strcmp (comps, "lo") == 0 )
+    {
+      dst_len = (src_len == 3) ? 2 : src_len / 2;
+      for (i = 0; i < dst_len; i++)
+	indices[i] = i;
+    }
+  else if (strcmp (comps, "hi") == 0)
+    {
+      dst_len = (src_len == 3) ? 2 : src_len / 2;
+      for (i = 0; i < dst_len; i++)
+	indices[i] = dst_len + i;
+    }
+  else if (strcmp (comps, "even") == 0)
+    {
+      dst_len = (src_len == 3) ? 2 : src_len / 2;
+      for (i = 0; i < dst_len; i++)
+	indices[i] = i*2;
+    }
+  else if (strcmp (comps, "odd") == 0)
+    {
+      dst_len = (src_len == 3) ? 2 : src_len / 2;
+      for (i = 0; i < dst_len; i++)
+        indices[i] = i*2+1;
+    }
+  else if (strncasecmp (comps, "s", 1) == 0)
+    {
+#define HEXCHAR_TO_INT(C) ((C >= '0' && C <= '9') ? \
+                           C-'0' : ((C >= 'A' && C <= 'F') ? \
+                           C-'A'+10 : ((C >= 'a' && C <= 'f') ? \
+                           C-'a'+10 : -1)))
+
+      dst_len = strlen (comps);
+      /* Skip the s/S-prefix.  */
+      dst_len--;
+
+      for (i = 0; i < dst_len; i++)
+	{
+	  indices[i] = HEXCHAR_TO_INT(comps[i+1]);
+	  /* Check if the requested component is invalid or exceeds
+	     the vector.  */
+	  if (indices[i] < 0 || indices[i] >= src_len)
+	    error (_("Invalid OpenCL vector component accessor %s"), comps);
+	}
+    }
+  else
+    {
+      dst_len = strlen (comps);
+
+      for (i = 0; i < dst_len; i++)
+	{
+	  /* x, y, z, w */
+	  switch (comps[i])
+	  {
+	  case 'x':
+	    indices[i] = 0;
+	    break;
+	  case 'y':
+	    indices[i] = 1;
+	    break;
+	  case 'z':
+	    if (src_len < 3)
+	      error (_("Invalid OpenCL vector component accessor %s"), comps);
+	    indices[i] = 2;
+	    break;
+	  case 'w':
+	    if (src_len < 4)
+	      error (_("Invalid OpenCL vector component accessor %s"), comps);
+	    indices[i] = 3;
+	    break;
+	  default:
+	    error (_("Invalid OpenCL vector component accessor %s"), comps);
+	    break;
+	  }
+	}
+    }
+
+  /* Throw an error if the amount of requested components does not
+     result in a valid length (1, 2, 3, 4, 8, 16).  */
+  if (dst_len != 1 && dst_len != 2 && dst_len != 3 && dst_len != 4
+      && dst_len != 8 && dst_len != 16)
+    error (_("Invalid OpenCL vector component accessor %s"), comps);
+
+  v = create_value (exp->gdbarch, val, noside, indices, dst_len);
+  return v;
+}
+
+/* Perform the unary logical not (!) operation.  */
+static struct value *
+opencl_logical_not (struct expression *exp, struct value *arg)
+{
+  struct type *type = check_typedef (value_type (arg));
+  struct type *rettype;
+  struct value *ret;
+
+  if (TYPE_CODE (type) == TYPE_CODE_ARRAY && TYPE_VECTOR (type))
+    {
+      struct type *eltype = check_typedef (TYPE_TARGET_TYPE (type));
+      LONGEST lowb, highb;
+      int i;
+
+      if (!get_array_bounds (type, &lowb, &highb))
+	error (_("Could not determine the vector bounds"));
+
+      /* Determine the resulting type of the operation and allocate the
+	 value.  */
+      rettype = lookup_opencl_vector_type (exp->gdbarch, TYPE_CODE_INT,
+					   TYPE_LENGTH (eltype), 0,
+					   highb - lowb + 1);
+      ret = allocate_value (rettype);
+
+      for (i = 0; i < highb - lowb + 1; i++)
+	{
+	  /* For vector types, the unary operator shall return a 0 if the
+	  value of its operand compares unequal to 0, and -1 (i.e. all bits
+	  set) if the value of its operand compares equal to 0.  */
+	  int tmp = value_logical_not (value_subscript (arg, i)) ? -1 : 0;
+	  memset (value_contents_writeable (ret) + i * TYPE_LENGTH (eltype),
+		  tmp, TYPE_LENGTH (eltype));
+	}
+    }
+  else
+    {
+      rettype = language_bool_type (exp->language_defn, exp->gdbarch);
+      ret = value_from_longest (rettype, value_logical_not (arg));
+    }
+  return ret;
+}
+
+/* Perform a relational operation on two scalar operands.  */
+static int
+scalar_relop (struct value *val1, struct value *val2, enum exp_opcode op)
+{
+  int ret;
+  switch (op)
+    {
+    case BINOP_EQUAL:
+      ret = value_equal (val1, val2);
+      break;
+    case BINOP_NOTEQUAL:
+      ret = ! value_equal (val1, val2);
+      break;
+    case BINOP_LESS:
+      ret = value_less (val1, val2);
+      break;
+    case BINOP_GTR:
+      ret = value_less (val2, val1);
+      break;
+    case BINOP_GEQ:
+      ret = value_less (val2, val1) || value_equal (val1, val2);
+      break;
+    case BINOP_LEQ:
+      ret = value_less (val1, val2) || value_equal (val1, val2);
+      break;
+    case BINOP_LOGICAL_AND:
+      ret = !value_logical_not (val1) && !value_logical_not (val2);
+      break;
+    case BINOP_LOGICAL_OR:
+      ret = !value_logical_not (val1) || !value_logical_not (val2);
+      break;
+    default:
+      error (_("Attempt to perform an unsupported operation"));
+      break;
+    }
+  return ret;
+}
+
+/* Perform a relational operation on two vector operands.  */
+static struct value *
+vector_relop (struct expression *exp, struct value *val1, struct value *val2,
+	      enum exp_opcode op)
+{
+  struct value *ret;
+  struct type *type1, *type2, *eltype1, *eltype2, *rettype;
+  int t1_is_vec, t2_is_vec, i;
+  LONGEST lowb1, lowb2, highb1, highb2;
+
+  type1 = check_typedef (value_type (val1));
+  type2 = check_typedef (value_type (val2));
+
+  t1_is_vec = (TYPE_CODE (type1) == TYPE_CODE_ARRAY && TYPE_VECTOR (type1));
+  t2_is_vec = (TYPE_CODE (type2) == TYPE_CODE_ARRAY && TYPE_VECTOR (type2));
+
+  if (!t1_is_vec || !t2_is_vec)
+    error (_("Vector operations are not supported on scalar types"));
+
+  eltype1 = check_typedef (TYPE_TARGET_TYPE (type1));
+  eltype2 = check_typedef (TYPE_TARGET_TYPE (type2));
+
+  if (!get_array_bounds (type1,&lowb1, &highb1)
+      || !get_array_bounds (type2, &lowb2, &highb2))
+    error (_("Could not determine the vector bounds"));
+
+  /* Check whether the vector types are compatible.  */
+  if (TYPE_CODE (eltype1) != TYPE_CODE (eltype2)
+      || TYPE_LENGTH (eltype1) != TYPE_LENGTH (eltype2)
+      || TYPE_UNSIGNED (eltype1) != TYPE_UNSIGNED (eltype2)
+      || lowb1 != lowb2 || highb1 != highb2)
+    error (_("Cannot perform operation on vectors with different types"));
+
+  /* Determine the resulting type of the operation and allocate the value.  */
+  rettype = lookup_opencl_vector_type (exp->gdbarch, TYPE_CODE_INT,
+				       TYPE_LENGTH (eltype1), 0,
+				       highb1 - lowb1 + 1);
+  ret = allocate_value (rettype);
+
+  for (i = 0; i < highb1 - lowb1 + 1; i++)
+    {
+      /* For vector types, the relational, equality and logical operators shall
+	 return 0 if the specified relation is false and -1 (i.e. all bits set)
+	 if the specified relation is true.  */
+      int tmp = scalar_relop (value_subscript (val1, i),
+			      value_subscript (val2, i), op) ? -1 : 0;
+      memset (value_contents_writeable (ret) + i * TYPE_LENGTH (eltype1),
+	      tmp, TYPE_LENGTH (eltype1));
+     }
+
+  return ret;
+}
+
+/* Perform a relational operation on two operands.  */
+static struct value *
+opencl_relop (struct expression *exp, struct value *arg1, struct value *arg2,
+	      enum exp_opcode op)
+{
+  struct value *val;
+  struct type *type1 = check_typedef (value_type (arg1));
+  struct type *type2 = check_typedef (value_type (arg2));
+  int t1_is_vec = (TYPE_CODE (type1) == TYPE_CODE_ARRAY
+		   && TYPE_VECTOR (type1));
+  int t2_is_vec = (TYPE_CODE (type2) == TYPE_CODE_ARRAY
+		   && TYPE_VECTOR (type2));
+
+  if (!t1_is_vec && !t2_is_vec)
+    {
+      int tmp = scalar_relop (arg1, arg2, op);
+      struct type *type =
+	language_bool_type (exp->language_defn, exp->gdbarch);
+      val = value_from_longest (type, tmp);
+    }
+  else if (t1_is_vec && t2_is_vec)
+    {
+      val = vector_relop (exp, arg1, arg2, op);
+    }
+  else
+    {
+      /* Widen the scalar operand to a vector.  */
+      struct value **v = t1_is_vec ? &arg2 : &arg1;
+      struct type *t = t1_is_vec ? type2 : type1;
+
+      if (TYPE_CODE (t) != TYPE_CODE_FLT && !is_integral_type (t))
+	error (_("Argument to operation not a number or boolean."));
+
+      *v = value_cast (t1_is_vec ? type1 : type2, *v);
+      val = vector_relop (exp, arg1, arg2, op);
+    }
+
+  return val;
+}
+
+/* Expression evaluator for the OpenCL.  Most operations are delegated to
+   evaluate_subexp_standard; see that function for a description of the
+   arguments.  */
+static struct value *
+evaluate_subexp_opencl (struct type *expect_type, struct expression *exp,
+		   int *pos, enum noside noside)
+{
+  enum exp_opcode op = exp->elts[*pos].opcode;
+  struct value *arg1 = NULL;
+  struct value *arg2 = NULL;
+  struct type *type1, *type2;
+
+  switch (op)
+    {
+    /* Handle binary relational and equality operators that are either not
+       or differently defined for GNU vectors.  */
+    case BINOP_EQUAL:
+    case BINOP_NOTEQUAL:
+    case BINOP_LESS:
+    case BINOP_GTR:
+    case BINOP_GEQ:
+    case BINOP_LEQ:
+      (*pos)++;
+      arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+      arg2 = evaluate_subexp (value_type (arg1), exp, pos, noside);
+
+      if (noside == EVAL_SKIP)
+	return value_from_longest (builtin_type (exp->gdbarch)->
+				   builtin_int, 1);
+      return opencl_relop (exp, arg1, arg2, op);
+    /* Handle the logical unary operator not(!).  */
+    case UNOP_LOGICAL_NOT:
+      (*pos)++;
+      arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+
+      if (noside == EVAL_SKIP)
+	return value_from_longest (builtin_type (exp->gdbarch)->
+				   builtin_int, 1);
+      return opencl_logical_not (exp, arg1);
+    /* Handle the logical operator and(&&) and or(||).  */
+    case BINOP_LOGICAL_AND:
+    case BINOP_LOGICAL_OR:
+      (*pos)++;
+      arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+
+      if (noside == EVAL_SKIP)
+	{
+	  arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	  return value_from_longest (builtin_type (exp->gdbarch)->
+				     builtin_int, 1);
+	}
+      else
+	{
+	  /* For scalar operations we need to avoid evaluating operands
+	     unecessarily.  However, for vector operations we always need to
+	     evaluate both operands.  Unfortunately we only know which of the
+	     two cases apply after we know the type of the second operand.
+	     Therefore we evaluate it once using EVAL_AVOID_SIDE_EFFECTS.  */
+	  int oldpos = *pos;
+	  arg2 = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
+	  *pos = oldpos;
+	  type1 = check_typedef (value_type (arg1));
+	  type2 = check_typedef (value_type (arg2));
+
+	  if ((TYPE_CODE (type1) == TYPE_CODE_ARRAY && TYPE_VECTOR (type1))
+	      || (TYPE_CODE (type2) == TYPE_CODE_ARRAY && TYPE_VECTOR (type2)))
+	    {
+	      arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	      return opencl_relop (exp, arg1, arg2, op);
+	    }
+	  else
+	    {
+	      /* For scalar built-in types, only evaluate the right
+		 hand operand if the left hand operand compares
+		 unequal(&&)/equal(||) to 0.  */
+	      int res;
+	      int tmp = value_logical_not (arg1);
+
+	      if (op == BINOP_LOGICAL_OR)
+		tmp = !tmp;
+
+	      arg2 = evaluate_subexp (NULL_TYPE, exp, pos,
+				      tmp ? EVAL_SKIP : noside);
+	      type1 = language_bool_type (exp->language_defn, exp->gdbarch);
+
+	      if (op == BINOP_LOGICAL_AND)
+		res = !tmp && !value_logical_not (arg2);
+	      else /* BINOP_LOGICAL_OR */
+		res = tmp || !value_logical_not (arg2);
+
+	      return value_from_longest (type1, res);
+	    }
+	}
+    /* Handle the ternary selection operator.  */
+    case TERNOP_COND:
+      (*pos)++;
+      arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+      type1 = check_typedef (value_type (arg1));
+      if (TYPE_CODE (type1) == TYPE_CODE_ARRAY && TYPE_VECTOR (type1))
+	{
+	  struct value *arg3, *tmp, *ret;
+	  struct type *eltype2, *type3, *eltype3;
+	  int t2_is_vec, t3_is_vec, i;
+	  LONGEST lowb1, lowb2, lowb3, highb1, highb2, highb3;
+
+	  arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	  arg3 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	  type2 = check_typedef (value_type (arg2));
+	  type3 = check_typedef (value_type (arg3));
+	  t2_is_vec
+	    = TYPE_CODE (type2) == TYPE_CODE_ARRAY && TYPE_VECTOR (type2);
+	  t3_is_vec
+	    = TYPE_CODE (type3) == TYPE_CODE_ARRAY && TYPE_VECTOR (type3);
+
+	  /* Widen the scalar operand to a vector if necessary.  */
+	  if (t2_is_vec || !t3_is_vec)
+	    {
+	      arg3 = value_cast (type2, arg3);
+	      type3 = value_type (arg3);
+	    }
+	  else if (!t2_is_vec || t3_is_vec)
+	    {
+	      arg2 = value_cast (type3, arg2);
+	      type2 = value_type (arg2);
+	    }
+	  else if (!t2_is_vec || !t3_is_vec)
+	    {
+	      /* Throw an error if arg2 or arg3 aren't vecors.  */
+	      error (_("\
+Cannot perform conditional operation on incompatible types"));
+	    }
+
+	  eltype2 = check_typedef (TYPE_TARGET_TYPE (type2));
+	  eltype3 = check_typedef (TYPE_TARGET_TYPE (type3));
+
+	  if (!get_array_bounds (type1, &lowb1, &highb1)
+	      || !get_array_bounds (type2, &lowb2, &highb2)
+	      || !get_array_bounds (type3, &lowb3, &highb3))
+	    error (_("Could not determine the vector bounds"));
+
+	  /* Throw an error if the types of arg2 or arg3 are incompatible.  */
+	  if (TYPE_CODE (eltype2) != TYPE_CODE (eltype3)
+	      || TYPE_LENGTH (eltype2) != TYPE_LENGTH (eltype3)
+	      || TYPE_UNSIGNED (eltype2) != TYPE_UNSIGNED (eltype3)
+	      || lowb2 != lowb3 || highb2 != highb3)
+	    error (_("\
+Cannot perform operation on vectors with different types"));
+
+	  /* Throw an error if the sizes of arg1 and arg2/arg3 differ.  */
+	  if (lowb1 != lowb2 || lowb1 != lowb3
+	      || highb1 != highb2 || highb1 != highb3)
+	    error (_("\
+Cannot perform conditional operation on vectors with different sizes"));
+
+	  ret = allocate_value (type2);
+	  for (i = 0; i < highb1 - lowb1 + 1; i++)
+	    {
+	      tmp = value_logical_not (value_subscript (arg1, i)) ?
+		    value_subscript (arg3, i) : value_subscript (arg2, i);
+	      memcpy (value_contents_writeable (ret) +
+		      i * TYPE_LENGTH (eltype2), value_contents_all (tmp),
+		      TYPE_LENGTH (eltype2));
+	    }
+	  return ret;
+	}
+      else
+	{
+	  if (value_logical_not (arg1))
+	    {
+	      /* Skip the second operand.  */
+	      evaluate_subexp (NULL_TYPE, exp, pos, EVAL_SKIP);
+	      return evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	    }
+	  else
+	    {
+	      /* Skip the third operand.  */
+	      arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	      evaluate_subexp (NULL_TYPE, exp, pos, EVAL_SKIP);
+	      return arg2;
+	    }
+	}
+    /* Handle STRUCTOP_STRUCT to allow component access on OpenCL vectors.  */
+    case STRUCTOP_STRUCT:
+      {
+	int pc = (*pos)++;
+	int tem = longest_to_int (exp->elts[pc + 1].longconst);
+
+	(*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
+	arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	type1 = check_typedef (value_type (arg1));
+
+	if (noside == EVAL_SKIP)
+	  {
+	    return value_from_longest (builtin_type (exp->gdbarch)->
+				       builtin_int, 1);
+	  }
+	else if (TYPE_CODE (type1) == TYPE_CODE_ARRAY && TYPE_VECTOR (type1))
+	  {
+	    return opencl_component_ref (exp, arg1, &exp->elts[pc + 2].string,
+					 noside);
+	  }
+	else
+	  {
+	    if (noside == EVAL_AVOID_SIDE_EFFECTS)
+	      return
+		  value_zero (lookup_struct_elt_type
+			      (value_type (arg1),&exp->elts[pc + 2].string, 0),
+			      lval_memory);
+	    else
+	      return value_struct_elt (&arg1, NULL,
+				       &exp->elts[pc + 2].string, NULL,
+				       "structure");
+	  }
+      }
+    default:
+      break;
+    }
+  return evaluate_subexp_standard (expect_type, exp, pos, noside);
+}
+
+void
+opencl_language_arch_info (struct gdbarch *gdbarch,
+		      struct language_arch_info *lai)
+{
+  const struct builtin_opencl_type *builtin = builtin_opencl_type (gdbarch);
+
+  lai->string_char_type = builtin->builtin_char;
+  lai->primitive_type_vector
+    = GDBARCH_OBSTACK_CALLOC (gdbarch, nr_opencl_primitive_types + 1,
+			      struct type *);
+
+/* This macro fills the primitive_type_vector from a given type.  */
+#define FILL_TYPE_VECTOR(LAI, TYPE)\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE]\
+    = builtin->builtin_##TYPE;\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE##2]\
+    = builtin->builtin_##TYPE##2;\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE##3]\
+    = builtin->builtin_##TYPE##3;\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE##4]\
+    = builtin->builtin_##TYPE##4;\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE##8]\
+    = builtin->builtin_##TYPE##8;\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE##16]\
+    = builtin->builtin_##TYPE##16
+
+  FILL_TYPE_VECTOR (lai, char);
+  FILL_TYPE_VECTOR (lai, uchar);
+  FILL_TYPE_VECTOR (lai, short);
+  FILL_TYPE_VECTOR (lai, ushort);
+  FILL_TYPE_VECTOR (lai, int);
+  FILL_TYPE_VECTOR (lai, uint);
+  FILL_TYPE_VECTOR (lai, long);
+  FILL_TYPE_VECTOR (lai, ulong);
+  FILL_TYPE_VECTOR (lai, half);
+  FILL_TYPE_VECTOR (lai, float);
+  FILL_TYPE_VECTOR (lai, double);
+  lai->primitive_type_vector [opencl_primitive_type_bool]
+    = builtin->builtin_bool;
+  lai->primitive_type_vector [opencl_primitive_type_unsigned_char]
+    = builtin->builtin_unsigned_char;
+  lai->primitive_type_vector [opencl_primitive_type_unsigned_short]
+    = builtin->builtin_unsigned_short;
+  lai->primitive_type_vector [opencl_primitive_type_unsigned_int]
+    = builtin->builtin_unsigned_int;
+  lai->primitive_type_vector [opencl_primitive_type_unsigned_long]
+    = builtin->builtin_unsigned_long;
+  lai->primitive_type_vector [opencl_primitive_type_half]
+    = builtin->builtin_half;
+  lai->primitive_type_vector [opencl_primitive_type_size_t]
+    = builtin->builtin_size_t;
+  lai->primitive_type_vector [opencl_primitive_type_ptrdiff_t]
+    = builtin->builtin_ptrdiff_t;
+  lai->primitive_type_vector [opencl_primitive_type_intptr_t]
+    = builtin->builtin_intptr_t;
+  lai->primitive_type_vector [opencl_primitive_type_uintptr_t]
+    = builtin->builtin_uintptr_t;
+  lai->primitive_type_vector [opencl_primitive_type_void]
+    = builtin->builtin_void;
+
+  /* Specifies the return type of logical and relational operations.  */
+  lai->bool_type_symbol = "int";
+  lai->bool_type_default = builtin->builtin_int;
+}
+
+const struct exp_descriptor exp_descriptor_opencl =
+{
+  print_subexp_standard,
+  operator_length_standard,
+  operator_check_standard,
+  op_name_standard,
+  dump_subexp_body_standard,
+  evaluate_subexp_opencl
+};
+
+const struct language_defn opencl_language_defn =
+{
+  "opencl",			/* Language name */
+  language_opencl,
+  range_check_off,
+  type_check_off,
+  case_sensitive_on,
+  array_row_major,
+  macro_expansion_c,
+  &exp_descriptor_opencl,
+  c_parse,
+  c_error,
+  null_post_parser,
+  c_printchar,			/* Print a character constant */
+  c_printstr,			/* Function to print string constant */
+  c_emit_char,			/* Print a single char */
+  c_print_type,			/* Print a type using appropriate syntax */
+  c_print_typedef,		/* Print a typedef using appropriate syntax */
+  c_val_print,			/* Print a value using appropriate syntax */
+  c_value_print,		/* Print a top-level value */
+  NULL,				/* Language specific skip_trampoline */
+  NULL,                         /* name_of_this */
+  basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
+  basic_lookup_transparent_type,/* lookup_transparent_type */
+  NULL,				/* Language specific symbol demangler */
+  NULL,				/* Language specific class_name_from_physname */
+  c_op_print_tab,		/* expression operators for printing */
+  1,				/* c-style arrays */
+  0,				/* String lower bound */
+  default_word_break_characters,
+  default_make_symbol_completion_list,
+  opencl_language_arch_info,
+  default_print_array_index,
+  default_pass_by_reference,
+  c_get_string,
+  LANG_MAGIC
+};
+
+static void *
+build_opencl_types (struct gdbarch *gdbarch)
+{
+  struct builtin_opencl_type *builtin_opencl_type
+    = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct builtin_opencl_type);
+
+/* Helper macro to create strings.  */
+#define STRINGIFY(S) #S
+/* This macro allocates and assigns the type struct pointers
+   for the vector types.  */
+#define BUILD_OCL_VTYPES(TYPE)\
+  builtin_opencl_type->builtin_##TYPE##2\
+    = init_vector_type (builtin_opencl_type->builtin_##TYPE, 2);\
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##2) = STRINGIFY(TYPE ## 2);\
+  builtin_opencl_type->builtin_##TYPE##3\
+    = init_vector_type (builtin_opencl_type->builtin_##TYPE, 3);\
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##3) = STRINGIFY(TYPE ## 3);\
+  TYPE_LENGTH (builtin_opencl_type->builtin_##TYPE##3)\
+    = 4 * TYPE_LENGTH (builtin_opencl_type->builtin_##TYPE);\
+  builtin_opencl_type->builtin_##TYPE##4\
+    = init_vector_type (builtin_opencl_type->builtin_##TYPE, 4);\
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##4) = STRINGIFY(TYPE ## 4);\
+  builtin_opencl_type->builtin_##TYPE##8\
+    = init_vector_type (builtin_opencl_type->builtin_##TYPE, 8);\
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##8) = STRINGIFY(TYPE ## 8);\
+  builtin_opencl_type->builtin_##TYPE##16\
+    = init_vector_type (builtin_opencl_type->builtin_##TYPE, 16);\
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##16) = STRINGIFY(TYPE ## 16)
+
+  builtin_opencl_type->builtin_char
+    = arch_integer_type (gdbarch, 8, 0, "char");
+  BUILD_OCL_VTYPES (char);
+  builtin_opencl_type->builtin_uchar
+    = arch_integer_type (gdbarch, 8, 1, "uchar");
+  BUILD_OCL_VTYPES (uchar);
+  builtin_opencl_type->builtin_short
+    = arch_integer_type (gdbarch, 16, 0, "short");
+  BUILD_OCL_VTYPES (short);
+  builtin_opencl_type->builtin_ushort
+    = arch_integer_type (gdbarch, 16, 1, "ushort");
+  BUILD_OCL_VTYPES (ushort);
+  builtin_opencl_type->builtin_int
+    = arch_integer_type (gdbarch, 32, 0, "int");
+  BUILD_OCL_VTYPES (int);
+  builtin_opencl_type->builtin_uint
+    = arch_integer_type (gdbarch, 32, 1, "uint");
+  BUILD_OCL_VTYPES (uint);
+  builtin_opencl_type->builtin_long
+    = arch_integer_type (gdbarch, 64, 0, "long");
+  BUILD_OCL_VTYPES (long);
+  builtin_opencl_type->builtin_ulong
+    = arch_integer_type (gdbarch, 64, 1, "ulong");
+  BUILD_OCL_VTYPES (ulong);
+  builtin_opencl_type->builtin_half
+    = arch_float_type (gdbarch, 16, "half", floatformats_ieee_half);
+  BUILD_OCL_VTYPES (half);
+  builtin_opencl_type->builtin_float
+    = arch_float_type (gdbarch, 32, "float", floatformats_ieee_single);
+  BUILD_OCL_VTYPES (float);
+  builtin_opencl_type->builtin_double
+    = arch_float_type (gdbarch, 64, "double", floatformats_ieee_double);
+  BUILD_OCL_VTYPES (double);
+  builtin_opencl_type->builtin_bool
+    = arch_boolean_type (gdbarch, 32, 1, "bool");
+  builtin_opencl_type->builtin_unsigned_char
+    = arch_integer_type (gdbarch, 8, 1, "unsigned char");
+  builtin_opencl_type->builtin_unsigned_short
+    = arch_integer_type (gdbarch, 16, 1, "unsigned short");
+  builtin_opencl_type->builtin_unsigned_int
+    = arch_integer_type (gdbarch, 32, 1, "unsigned int");
+  builtin_opencl_type->builtin_unsigned_long
+    = arch_integer_type (gdbarch, 64, 1, "unsigned long");
+  builtin_opencl_type->builtin_size_t
+    = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 1, "size_t");
+  builtin_opencl_type->builtin_ptrdiff_t
+    = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 0, "ptrdiff_t");
+  builtin_opencl_type->builtin_intptr_t
+    = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 0, "intptr_t");
+  builtin_opencl_type->builtin_uintptr_t
+    = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 1, "uintptr_t");
+  builtin_opencl_type->builtin_void
+    = arch_type (gdbarch, TYPE_CODE_VOID, 1, "void");
+  return builtin_opencl_type;
+}
+
+void
+_initialize_opencl_language (void)
+{
+  opencl_type_data = gdbarch_data_register_post_init (build_opencl_types);
+  add_language (&opencl_language_defn);
+}
Index: src/gdb/Makefile.in
===================================================================
--- src.orig/gdb/Makefile.in	2010-10-22 17:17:33.000000000 +0200
+++ src/gdb/Makefile.in	2010-10-22 17:18:09.000000000 +0200
@@ -689,6 +689,7 @@ SFILES = ada-exp.y ada-lang.c ada-typepr
 	mi/mi-common.c \
 	objc-exp.y objc-lang.c \
 	objfiles.c osabi.c observer.c osdata.c \
+	opencl-lang.c \
 	p-exp.y p-lang.c p-typeprint.c p-valprint.c parse.c printcmd.c \
 	proc-service.list progspace.c \
 	prologue-value.c psymtab.c \
@@ -846,7 +847,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $
 	ui-out.o cli-out.o \
 	varobj.o vec.o wrapper.o \
 	jv-lang.o jv-valprint.o jv-typeprint.o \
-	m2-lang.o p-lang.o p-typeprint.o p-valprint.o \
+	m2-lang.o opencl-lang.o p-lang.o p-typeprint.o p-valprint.o \
 	scm-exp.o scm-lang.o scm-valprint.o \
 	sentinel-frame.o \
 	complaints.o typeprint.o \
Index: src/gdb/eval.c
===================================================================
--- src.orig/gdb/eval.c	2010-10-22 17:18:07.000000000 +0200
+++ src/gdb/eval.c	2010-10-22 17:18:09.000000000 +0200
@@ -603,6 +603,7 @@ binop_promote (const struct language_def
 	case language_cplus:
 	case language_asm:
 	case language_objc:
+	case language_opencl:
 	  /* No promotion required.  */
 	  break;
 
@@ -690,7 +691,24 @@ binop_promote (const struct language_def
 			       : builtin->builtin_long_long);
 	    }
 	  break;
-
+	case language_opencl:
+	  if (result_len <= TYPE_LENGTH (lookup_signed_typename
+					 (language, gdbarch, "int")))
+	    {
+	      promoted_type =
+		(unsigned_operation
+		 ? lookup_unsigned_typename (language, gdbarch, "int")
+		 : lookup_signed_typename (language, gdbarch, "int"));
+	    }
+	  else if (result_len <= TYPE_LENGTH (lookup_signed_typename
+					      (language, gdbarch, "long")))
+	    {
+	      promoted_type =
+		(unsigned_operation
+		 ? lookup_unsigned_typename (language, gdbarch, "long")
+		 : lookup_signed_typename (language, gdbarch,"long"));
+	    }
+	  break;
 	default:
 	  /* For other languages the result type is unchanged from gdb
 	     version 6.7 for backward compatibility.
Index: src/gdb/testsuite/gdb.base/default.exp
===================================================================
--- src.orig/gdb/testsuite/gdb.base/default.exp	2010-10-22 17:17:33.000000000 +0200
+++ src/gdb/testsuite/gdb.base/default.exp	2010-10-22 17:18:09.000000000 +0200
@@ -527,7 +527,7 @@ gdb_test "set history size" "Argument re
 #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, scheme." "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, scheme." "set language"
 #test set listsize
 gdb_test "set listsize" "Argument required .integer to set it to.*" "set listsize"
 #test set print "p" abbreviation
Index: src/gdb/testsuite/Makefile.in
===================================================================
--- src.orig/gdb/testsuite/Makefile.in	2010-10-22 17:17:33.000000000 +0200
+++ src/gdb/testsuite/Makefile.in	2010-10-22 17:18:09.000000000 +0200
@@ -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 \
Index: src/gdb/testsuite/configure
===================================================================
--- src.orig/gdb/testsuite/configure	2010-10-22 17:17:33.000000000 +0200
+++ src/gdb/testsuite/configure	2010-10-22 17:18:10.000000000 +0200
@@ -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
Index: src/gdb/testsuite/configure.ac
===================================================================
--- src.orig/gdb/testsuite/configure.ac	2010-10-22 17:17:33.000000000 +0200
+++ src/gdb/testsuite/configure.ac	2010-10-22 17:18:10.000000000 +0200
@@ -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])
Index: src/gdb/testsuite/gdb.opencl/Makefile.in
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/Makefile.in	2010-10-22 17:18:10.000000000 +0200
@@ -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.*
Index: src/gdb/testsuite/gdb.opencl/datatypes.cl
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/datatypes.cl	2010-10-22 17:18:10.000000000 +0200
@@ -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;
+}
Index: src/gdb/testsuite/gdb.opencl/datatypes.exp
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/datatypes.exp	2010-10-22 17:18:10.000000000 +0200
@@ -0,0 +1,475 @@
+# 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 bin ${objdir}/${subdir}/${testfile}
+set clprogram [remote_download target ${srcdir}/${subdir}/${testfile}.cl]
+
+# Increase timeout
+set timeout 60
+verbose "Timeout set to $timeout seconds" 2
+
+# Compile the generic OpenCL host app
+if { [gdb_compile_opencl_hostapp "${clprogram}" "${bin}" "" ] != "" } {
+    untested ${testfile}.exp
+    return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
+# 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)" "\\\$$decimal = 4"
+
+gdb_test "whatis char" "type = char"
+gdb_test "p sizeof(char)" "\\\$$decimal = 1"
+gdb_test "whatis char2" "type = char2"
+gdb_test "p sizeof(char2)" "\\\$$decimal = 2"
+gdb_test "whatis char3" "type = char3"
+gdb_test "p sizeof(char3)" "\\\$$decimal = 4"
+gdb_test "whatis char4" "type = char4"
+gdb_test "p sizeof(char4)" "\\\$$decimal = 4"
+gdb_test "whatis char8" "type = char8"
+gdb_test "p sizeof(char8)" "\\\$$decimal = 8"
+gdb_test "whatis char16" "type = char16"
+gdb_test "p sizeof(char16)" "\\\$$decimal = 16"
+
+gdb_test "whatis unsigned char" "type = unsigned char"
+gdb_test "p sizeof(unsigned char)" "\\\$$decimal = 1"
+gdb_test "whatis uchar" "type = uchar"
+gdb_test "p sizeof(uchar)" "\\\$$decimal = 1"
+gdb_test "whatis uchar2" "type = uchar2"
+gdb_test "p sizeof(uchar2)" "\\\$$decimal = 2"
+gdb_test "whatis uchar3" "type = uchar3"
+gdb_test "p sizeof(uchar3)" "\\\$$decimal = 4"
+gdb_test "whatis uchar4" "type = uchar4"
+gdb_test "p sizeof(uchar4)" "\\\$$decimal = 4"
+gdb_test "whatis uchar8" "type = uchar8"
+gdb_test "p sizeof(uchar8)" "\\\$$decimal = 8"
+gdb_test "whatis uchar16" "type = uchar16"
+gdb_test "p sizeof(uchar16)" "\\\$$decimal = 16"
+
+gdb_test "whatis short" "type = short"
+gdb_test "p sizeof(short)" "\\\$$decimal = 2"
+gdb_test "whatis short2" "type = short2"
+gdb_test "p sizeof(short2)" "\\\$$decimal = 4"
+gdb_test "whatis short3" "type = short3"
+gdb_test "p sizeof(short3)" "\\\$$decimal = 8"
+gdb_test "whatis short4" "type = short4"
+gdb_test "p sizeof(short4)" "\\\$$decimal = 8"
+gdb_test "whatis short8" "type = short8"
+gdb_test "p sizeof(short8)" "\\\$$decimal = 16"
+gdb_test "whatis short16" "type = short16"
+gdb_test "p sizeof(short16)" "\\\$$decimal = 32"
+
+gdb_test "whatis unsigned short" "type = unsigned short"
+gdb_test "p sizeof(unsigned short)" "\\\$$decimal = 2"
+gdb_test "whatis ushort" "type = ushort"
+gdb_test "p sizeof(ushort)" "\\\$$decimal = 2"
+gdb_test "whatis ushort2" "type = ushort2"
+gdb_test "p sizeof(ushort2)" "\\\$$decimal = 4"
+gdb_test "whatis ushort3" "type = ushort3"
+gdb_test "p sizeof(ushort3)" "\\\$$decimal = 8"
+gdb_test "whatis ushort4" "type = ushort4"
+gdb_test "p sizeof(ushort4)" "\\\$$decimal = 8"
+gdb_test "whatis ushort8" "type = ushort8"
+gdb_test "p sizeof(ushort8)" "\\\$$decimal = 16"
+gdb_test "whatis ushort16" "type = ushort16"
+gdb_test "p sizeof(ushort16)" "\\\$$decimal = 32"
+
+gdb_test "whatis int" "type = int"
+gdb_test "p sizeof(int)" "\\\$$decimal = 4"
+gdb_test "whatis int2" "type = int2"
+gdb_test "p sizeof(int2)" "\\\$$decimal = 8"
+gdb_test "whatis int3" "type = int3"
+gdb_test "p sizeof(int3)" "\\\$$decimal = 16"
+gdb_test "whatis int4" "type = int4"
+gdb_test "p sizeof(int4)" "\\\$$decimal = 16"
+gdb_test "whatis int8" "type = int8"
+gdb_test "p sizeof(int8)" "\\\$$decimal = 32"
+gdb_test "whatis int16" "type = int16"
+gdb_test "p sizeof(int16)" "\\\$$decimal = 64"
+
+gdb_test "whatis unsigned int" "type = unsigned int"
+gdb_test "p sizeof(unsigned int)" "\\\$$decimal = 4"
+gdb_test "whatis uint" "type = uint"
+gdb_test "p sizeof(uint)" "\\\$$decimal = 4"
+gdb_test "whatis uint2" "type = uint2"
+gdb_test "p sizeof(uint2)" "\\\$$decimal = 8"
+gdb_test "whatis uint3" "type = uint3"
+gdb_test "p sizeof(uint3)" "\\\$$decimal = 16"
+gdb_test "whatis uint4" "type = uint4"
+gdb_test "p sizeof(uint4)" "\\\$$decimal = 16"
+gdb_test "whatis uint8" "type = uint8"
+gdb_test "p sizeof(uint8)" "\\\$$decimal = 32"
+gdb_test "whatis uint16" "type = uint16"
+gdb_test "p sizeof(uint16)" "\\\$$decimal = 64"
+
+gdb_test "whatis long" "type = long"
+gdb_test "p sizeof(long)" "\\\$$decimal = 8"
+gdb_test "whatis long2" "type = long2"
+gdb_test "p sizeof(long2)" "\\\$$decimal = 16"
+gdb_test "whatis long3" "type = long3"
+gdb_test "p sizeof(long3)" "\\\$$decimal = 32"
+gdb_test "whatis long4" "type = long4"
+gdb_test "p sizeof(long4)" "\\\$$decimal = 32"
+gdb_test "whatis long8" "type = long8"
+gdb_test "p sizeof(long8)" "\\\$$decimal = 64"
+gdb_test "whatis long16" "type = long16"
+gdb_test "p sizeof(long16)" "\\\$$decimal = 128"
+
+gdb_test "whatis unsigned long" "type = unsigned long"
+gdb_test "p sizeof(unsigned long)" "\\\$$decimal = 8"
+gdb_test "whatis ulong" "type = ulong"
+gdb_test "p sizeof(ulong)" "\\\$$decimal = 8"
+gdb_test "whatis ulong2" "type = ulong2"
+gdb_test "p sizeof(ulong2)" "\\\$$decimal = 16"
+gdb_test "whatis ulong3" "type = ulong3"
+gdb_test "p sizeof(ulong3)" "\\\$$decimal = 32"
+gdb_test "whatis ulong4" "type = ulong4"
+gdb_test "p sizeof(ulong4)" "\\\$$decimal = 32"
+gdb_test "whatis ulong8" "type = ulong8"
+gdb_test "p sizeof(ulong8)" "\\\$$decimal = 64"
+gdb_test "whatis ulong16" "type = ulong16"
+gdb_test "p sizeof(ulong16)" "\\\$$decimal = 128"
+
+gdb_test "whatis half" "type = half"
+gdb_test "p sizeof(half)" "\\\$$decimal = 2"
+gdb_test "whatis half2" "type = half2"
+gdb_test "p sizeof(half2)" "\\\$$decimal = 4"
+gdb_test "whatis half3" "type = half3"
+gdb_test "p sizeof(half3)" "\\\$$decimal = 8"
+gdb_test "whatis half4" "type = half4"
+gdb_test "p sizeof(half4)" "\\\$$decimal = 8"
+gdb_test "whatis half8" "type = half8"
+gdb_test "p sizeof(half8)" "\\\$$decimal = 16"
+gdb_test "whatis half16" "type = half16"
+gdb_test "p sizeof(half16)" "\\\$$decimal = 32"
+
+gdb_test "whatis float" "type = float"
+gdb_test "p sizeof(float)" "\\\$$decimal = 4"
+gdb_test "whatis float2" "type = float2"
+gdb_test "p sizeof(float2)" "\\\$$decimal = 8"
+gdb_test "whatis float3" "type = float3"
+gdb_test "p sizeof(float3)" "\\\$$decimal = 16"
+gdb_test "whatis float4" "type = float4"
+gdb_test "p sizeof(float4)" "\\\$$decimal = 16"
+gdb_test "whatis float8" "type = float8"
+gdb_test "p sizeof(float8)" "\\\$$decimal = 32"
+gdb_test "whatis float16" "type = float16"
+gdb_test "p sizeof(float16)" "\\\$$decimal = 64"
+
+gdb_test "whatis double" "type = double"
+gdb_test "p sizeof(double)" "\\\$$decimal = 8"
+gdb_test "whatis double2" "type = double2"
+gdb_test "p sizeof(double2)" "\\\$$decimal = 16"
+gdb_test "whatis double3" "type = double3"
+gdb_test "p sizeof(double3)" "\\\$$decimal = 32"
+gdb_test "whatis double4" "type = double4"
+gdb_test "p sizeof(double4)" "\\\$$decimal = 32"
+gdb_test "whatis double8" "type = double8"
+gdb_test "p sizeof(double8)" "\\\$$decimal = 64"
+gdb_test "whatis double16" "type = double16"
+gdb_test "p sizeof(double16)" "\\\$$decimal = 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_load ${bin}
+
+# 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
+
+# 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)" "\\\$$decimal = 4"
+gdb_test "print b" "\\\$$decimal = 0"
+
+gdb_test "whatis c" "type = char"
+gdb_test "p sizeof(c)" "\\\$$decimal = 1"
+gdb_test "print/d c" "\\\$$decimal = 1"
+gdb_test "whatis c2" "type = char \\\[2\\\]"
+gdb_test "p sizeof(c2)" "\\\$$decimal = 2"
+gdb_test "print c2" "\\\$$decimal = \\{1, 2\\}"
+if { ${opencl_version} >= 110 } {
+  gdb_test "whatis c3" "type = char \\\[3\\\]"
+  gdb_test "p sizeof(c3)" "\\\$$decimal = 4"
+  gdb_test "print c3" "\\\$$decimal = \\{1, 2, 3\\}"
+}
+gdb_test "whatis c4" "type = char \\\[4\\\]"
+gdb_test "p sizeof(c4)" "\\\$$decimal = 4"
+gdb_test "print c4" "\\\$$decimal = \\{1, 2, 3, 4\\}"
+gdb_test "whatis c8" "type = char \\\[8\\\]"
+gdb_test "p sizeof(c8)" "\\\$$decimal = 8"
+gdb_test "print c8" "\\\$$decimal = \\{1, 2, 3, 4, 5, 6, 7, 8\\}"
+gdb_test "whatis c16" "type = char \\\[16\\\]"
+gdb_test "p sizeof(c16)" "\\\$$decimal = 16"
+gdb_test "print c16" "\\\$$decimal = \\{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)" "\\\$$decimal = 1"
+gdb_test "print/d uc" "\\\$$decimal = 1"
+gdb_test "whatis uc2" "type = (uchar|unsigned char) \\\[2\\\]"
+gdb_test "p sizeof(uc2)" "\\\$$decimal = 2"
+gdb_test "print uc2" "\\\$$decimal = \\{1, 2\\}"
+if { ${opencl_version} >= 110 } {
+  gdb_test "whatis uc3" "type = (uchar|unsigned char) \\\[3\\\]"
+  gdb_test "p sizeof(uchar3)" "\\\$$decimal = 4"
+  gdb_test "print uc3" "\\\$$decimal = \\{1, 2, 3\\}"
+}
+gdb_test "whatis uc4" "type = (uchar|unsigned char) \\\[4\\\]"
+gdb_test "p sizeof(uc4)" "\\\$$decimal = 4"
+gdb_test "print uc4" "\\\$$decimal = \\{1, 2, 3, 4\\}"
+gdb_test "whatis uc8" "type = (uchar|unsigned char) \\\[8\\\]"
+gdb_test "p sizeof(uc8)" "\\\$$decimal = 8"
+gdb_test "print uc8" "\\\$$decimal = \\{1, 2, 3, 4, 5, 6, 7, 8\\}"
+gdb_test "whatis uc16" "type = (uchar|unsigned char) \\\[16\\\]"
+gdb_test "p sizeof(uc16)" "\\\$$decimal = 16"
+gdb_test "print uc16" "\\\$$decimal = \\{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)" "\\\$$decimal = 2"
+gdb_test "print s" "\\\$$decimal = -1"
+gdb_test "whatis s2" "type = short \\\[2\\\]"
+gdb_test "p sizeof(s2)" "\\\$$decimal = 4"
+gdb_test "print s2" "\\\$$decimal = \\{-1, -2\\}"
+if { ${opencl_version} >= 110 } {
+  gdb_test "whatis s3" "type = short \\\[3\\\]"
+  gdb_test "p sizeof(s3)" "\\\$$decimal = 8"
+  gdb_test "print s3" "\\\$$decimal = \\{-1, -2, -3\\}"
+}
+gdb_test "whatis s4" "type = short \\\[4\\\]"
+gdb_test "p sizeof(s4)" "\\\$$decimal = 8"
+gdb_test "print s4" "\\\$$decimal = \\{-1, -2, -3, -4\\}"
+gdb_test "whatis s8" "type = short \\\[8\\\]"
+gdb_test "p sizeof(s8)" "\\\$$decimal = 16"
+gdb_test "print s8" "\\\$$decimal = \\{-1, -2, -3, -4, -5, -6, -7, -8\\}"
+gdb_test "whatis s16" "type = short \\\[16\\\]"
+gdb_test "p sizeof(s16)" "\\\$$decimal = 32"
+gdb_test "print s16" "\\\$$decimal = \\{-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)" "\\\$$decimal = 2"
+gdb_test "print us" "\\\$$decimal = 1"
+gdb_test "whatis us2" "type = (ushort|unsigned short) \\\[2\\\]"
+gdb_test "p sizeof(us2)" "\\\$$decimal = 4"
+gdb_test "print us2" "\\\$$decimal = \\{1, 2\\}"
+if { ${opencl_version} >= 110 } {
+  gdb_test "whatis us3" "type = (ushort|unsigned short) \\\[3\\\]"
+  gdb_test "p sizeof(us3)" "\\\$$decimal = 8"
+  gdb_test "print us3" "\\\$$decimal = \\{1, 2, 3\\}"
+}
+gdb_test "whatis us4" "type = (ushort|unsigned short) \\\[4\\\]"
+gdb_test "p sizeof(us4)" "\\\$$decimal = 8"
+gdb_test "print us4" "\\\$$decimal = \\{1, 2, 3, 4\\}"
+gdb_test "whatis us8" "type = (ushort|unsigned short) \\\[8\\\]"
+gdb_test "p sizeof(us8)" "\\\$$decimal = 16"
+gdb_test "print us8" "\\\$$decimal = \\{1, 2, 3, 4, 5, 6, 7, 8\\}"
+gdb_test "whatis us16" "type = (ushort|unsigned short) \\\[16\\\]"
+gdb_test "p sizeof(us16)" "\\\$$decimal = 32"
+gdb_test "print us16" "\\\$$decimal = \\{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)" "\\\$$decimal = 4"
+gdb_test "print i" "\\\$$decimal = -1"
+gdb_test "whatis i2" "type = int \\\[2\\\]"
+gdb_test "p sizeof(i2)" "\\\$$decimal = 8"
+gdb_test "print i2" "\\\$$decimal = \\{-1, -2\\}"
+if { ${opencl_version} >= 110 } {
+  gdb_test "whatis i3" "type = int \\\[3\\\]"
+  gdb_test "p sizeof(i3)" "\\\$$decimal = 16"
+  gdb_test "print i3" "\\\$$decimal = \\{-1, -2, -3\\}"
+}
+gdb_test "whatis i4" "type = int \\\[4\\\]"
+gdb_test "p sizeof(i4)" "\\\$$decimal = 16"
+gdb_test "print i4" "\\\$$decimal = \\{-1, -2, -3, -4\\}"
+gdb_test "whatis i8" "type = int \\\[8\\\]"
+gdb_test "p sizeof(i8)" "\\\$$decimal = 32"
+gdb_test "print i8" "\\\$$decimal = \\{-1, -2, -3, -4, -5, -6, -7, -8\\}"
+gdb_test "whatis i16" "type = int \\\[16\\\]"
+gdb_test "p sizeof(i16)" "\\\$$decimal = 64"
+gdb_test "print i16" "\\\$$decimal = \\{-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)" "\\\$$decimal = 4"
+gdb_test "print ui" "\\\$$decimal = 1"
+gdb_test "whatis ui2" "type = (uint|unsigned int) \\\[2\\\]"
+gdb_test "p sizeof(ui2)" "\\\$$decimal = 8"
+gdb_test "print ui2" "\\\$$decimal = \\{1, 2\\}"
+if { ${opencl_version} >= 110 } {
+  gdb_test "whatis ui3" "type = (uint|unsigned int) \\\[3\\\]"
+  gdb_test "p sizeof(ui3)" "\\\$$decimal = 16"
+  gdb_test "print ui3" "\\\$$decimal = \\{1, 2, 3\\}"
+}
+gdb_test "whatis ui4" "type = (uint|unsigned int) \\\[4\\\]"
+gdb_test "p sizeof(ui4)" "\\\$$decimal = 16"
+gdb_test "print ui4" "\\\$$decimal = \\{1, 2, 3, 4\\}"
+gdb_test "whatis ui8" "type = (uint|unsigned int) \\\[8\\\]"
+gdb_test "p sizeof(ui8)" "\\\$$decimal = 32"
+gdb_test "print ui8" "\\\$$decimal = \\{1, 2, 3, 4, 5, 6, 7, 8\\}"
+gdb_test "whatis ui16" "type = (uint|unsigned int) \\\[16\\\]"
+gdb_test "p sizeof(ui16)" "\\\$$decimal = 64"
+gdb_test "print ui16" "\\\$$decimal = \\{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)" "\\\$$decimal = 8"
+gdb_test "print l" "\\\$$decimal = -1"
+gdb_test "whatis l2" "type = long \\\[2\\\]"
+gdb_test "p sizeof(l2)" "\\\$$decimal = 16"
+gdb_test "print l2" "\\\$$decimal = \\{-1, -2\\}"
+if { ${opencl_version} >= 110 } {
+  gdb_test "whatis l3" "type = long \\\[3\\\]"
+  gdb_test "p sizeof(l3)" "\\\$$decimal = 32"
+  gdb_test "print l3" "\\\$$decimal = \\{-1, -2, -3\\}"
+}
+gdb_test "whatis l4" "type = long \\\[4\\\]"
+gdb_test "p sizeof(l4)" "\\\$$decimal = 32"
+gdb_test "print l4" "\\\$$decimal = \\{-1, -2, -3, -4\\}"
+gdb_test "whatis l8" "type = long \\\[8\\\]"
+gdb_test "p sizeof(l8)" "\\\$$decimal = 64"
+gdb_test "print l8" "\\\$$decimal = \\{-1, -2, -3, -4, -5, -6, -7, -8\\}"
+gdb_test "whatis l16" "type = long \\\[16\\\]"
+gdb_test "p sizeof(l16)" "\\\$$decimal = 128"
+gdb_test "print l16" "\\\$$decimal = \\{-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)" "\\\$$decimal = 8"
+gdb_test "print ul" "\\\$$decimal = 1"
+gdb_test "whatis ul2" "type = (ulong|unsigned long) \\\[2\\\]"
+gdb_test "p sizeof(ul2)" "\\\$$decimal = 16"
+gdb_test "print ul2" "\\\$$decimal = \\{1, 2\\}"
+if { ${opencl_version} >= 110 } {
+  gdb_test "whatis ul3" "type = (ulong|unsigned long) \\\[3\\\]"
+  gdb_test "p sizeof(ul3)" "\\\$$decimal = 32"
+  gdb_test "print ul3" "\\\$$decimal = \\{1, 2, 3\\}"
+}
+gdb_test "whatis ul4" "type = (ulong|unsigned long) \\\[4\\\]"
+gdb_test "p sizeof(ul4)" "\\\$$decimal = 32"
+gdb_test "print ul4" "\\\$$decimal = \\{1, 2, 3, 4\\}"
+gdb_test "whatis ul8" "type = (ulong|unsigned long) \\\[8\\\]"
+gdb_test "p sizeof(ul8)" "\\\$$decimal = 64"
+gdb_test "print ul8" "\\\$$decimal = \\{1, 2, 3, 4, 5, 6, 7, 8\\}"
+gdb_test "whatis ul16" "type = (ulong|unsigned long) \\\[16\\\]"
+gdb_test "p sizeof(ul16)" "\\\$$decimal = 128"
+gdb_test "print ul16" "\\\$$decimal = \\{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)" "\\\$$decimal = 2"
+
+if { ${have_cl_khr_fp16} } {
+  gdb_test "whatis h" "type = half"
+  gdb_test "p sizeof(h)" "\\\$$decimal = 2"
+  gdb_test "print h" "\\\$$decimal = 1"
+  gdb_test "whatis h2" "type = half \\\[2\\\]"
+  gdb_test "p sizeof(h2)" "\\\$$decimal = 4"
+  gdb_test "print h2" "\\\$$decimal = \\{1, 2\\}"
+  if { ${opencl_version} >= 110 } {
+    gdb_test "whatis h3" "type = half \\\[3\\\]"
+    gdb_test "p sizeof(h3)" "\\\$$decimal = 8"
+    gdb_test "print h3" "\\\$$decimal = \\{1, 2, 3\\}"
+  }
+  gdb_test "whatis h4" "type = half \\\[4\\\]"
+  gdb_test "p sizeof(h4)" "\\\$$decimal = 8"
+  gdb_test "print h4" "\\\$$decimal = \\{1, 2, 3, 4\\}"
+  gdb_test "whatis h8" "type = half \\\[8\\\]"
+  gdb_test "p sizeof(h8)" "\\\$$decimal = 16"
+  gdb_test "print h8" "\\\$$decimal = \\{1, 2, 3, 4, 5, 6, 7, 8\\}"
+  gdb_test "whatis h16" "type = half \\\[16\\\]"
+  gdb_test "p sizeof(h16)" "\\\$$decimal = 16"
+  gdb_test "print h16" "\\\$$decimal = \\{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)" "\\\$$decimal = 4"
+gdb_test "print f" "\\\$$decimal = 1"
+gdb_test "whatis f2" "type = float \\\[2\\\]"
+gdb_test "p sizeof(f2)" "\\\$$decimal = 8"
+gdb_test "print f2" "\\\$$decimal = \\{1, 2\\}"
+if { ${opencl_version} >= 110 } {
+  gdb_test "whatis f3" "type = float \\\[3\\\]"
+  gdb_test "p sizeof(f3)" "\\\$$decimal = 16"
+  gdb_test "print f3" "\\\$$decimal = \\{1, 2, 3\\}"
+}
+gdb_test "whatis f4" "type = float \\\[4\\\]"
+gdb_test "p sizeof(f4)" "\\\$$decimal = 16"
+gdb_test "print f4" "\\\$$decimal = \\{1, 2, 3, 4\\}"
+gdb_test "whatis f8" "type = float \\\[8\\\]"
+gdb_test "p sizeof(f8)" "\\\$$decimal = 32"
+gdb_test "print f8" "\\\$$decimal = \\{1, 2, 3, 4, 5, 6, 7, 8\\}"
+gdb_test "whatis f16" "type = float \\\[16\\\]"
+gdb_test "p sizeof(f16)" "\\\$$decimal = 64"
+gdb_test "print f16" "\\\$$decimal = \\{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)" "\\\$$decimal = 8"
+  gdb_test "print d" "\\\$$decimal = 1"
+  gdb_test "whatis d2" "type = double \\\[2\\\]"
+  gdb_test "p sizeof(d2)" "\\\$$decimal = 16"
+  gdb_test "print d2" "\\\$$decimal = \\{1, 2\\}"
+  if { ${opencl_version} >= 110 } {
+    gdb_test "whatis d3" "type = double \\\[3\\\]"
+    gdb_test "p sizeof(d3)" "\\\$$decimal = 32"
+    gdb_test "print d3" "\\\$$decimal = \\{1, 2, 3\\}"
+  }
+  gdb_test "whatis d4" "type = double \\\[4\\\]"
+  gdb_test "p sizeof(d4)" "\\\$$decimal = 32"
+  gdb_test "print d4" "\\\$$decimal = \\{1, 2, 3, 4\\}"
+  gdb_test "whatis d8" "type = double \\\[8\\\]"
+  gdb_test "p sizeof(d8)" "\\\$$decimal = 64"
+  gdb_test "print d8" "\\\$$decimal = \\{1, 2, 3, 4, 5, 6, 7, 8\\}"
+  gdb_test "whatis d16" "type = double \\\[16\\\]"
+  gdb_test "p sizeof(d16)" "\\\$$decimal = 128"
+  gdb_test "print d16" "\\\$$decimal = \\{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}
Index: src/gdb/testsuite/gdb.opencl/operators.cl
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/operators.cl	2010-10-22 17:18:10.000000000 +0200
@@ -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;
+}
Index: src/gdb/testsuite/gdb.opencl/operators.exp
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/operators.exp	2010-10-22 17:18:10.000000000 +0200
@@ -0,0 +1,972 @@
+# 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 bin ${objdir}/${subdir}/${testfile}
+set clprogram [remote_download target ${srcdir}/${subdir}/${testfile}.cl]
+
+# Increase timeout
+set timeout 60
+verbose "Timeout set to $timeout seconds" 2
+
+# Compile the generic OpenCL host app
+if { [gdb_compile_opencl_hostapp "${clprogram}" "${bin}" "" ] != "" } {
+    untested ${testfile}.exp
+    return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
+# Load the OpenCL app
+gdb_load ${bin}
+
+# 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
+
+# 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 } {
+  global decimal
+  gdb_test "print/d ${name}a" "\\\$$decimal = 2"
+  gdb_test "print/d ${name}b" "\\\$$decimal = 1"
+  gdb_test "print/d ${name}4a" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+  gdb_test "print/d ${name}4b" "\\\$$decimal = \\{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" "\\\$$decimal = 2"
+    gdb_test "print/d u${name}b" "\\\$$decimal = 1"
+    gdb_test "print/d u${name}4a" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d u${name}4b" "\\\$$decimal = \\{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 } {
+  global decimal
+  # scalar with scalar
+  gdb_test "print/d ${name}a + ${name}b" "\\\$$decimal = 3"
+  gdb_test "print/d ${name}a - ${name}b" "\\\$$decimal = 1"
+  gdb_test "print/d ${name}a * ${name}b" "\\\$$decimal = 2"
+  gdb_test "print/d ${name}a / ${name}b" "\\\$$decimal = 2"
+  # scalar with vector
+  gdb_test "print/d ${name}a + ${name}4b" "\\\$$decimal = \\{3, 4, 10, 6\\}"
+  gdb_test "print/d ${name}4a - ${name}b" "\\\$$decimal = \\{1, 3, 7, 15\\}"
+  gdb_test "print/d ${name}4a * ${name}b" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+  gdb_test "print/d ${name}a / ${name}4b" "\\\$$decimal = \\{2, 1, 0, 0\\}"
+  # vector with vector
+  gdb_test "print/d ${name}4a + ${name}4b" "\\\$$decimal = \\{3, 6, 16, 20\\}"
+  gdb_test "print/d ${name}4a - ${name}4b" "\\\$$decimal = \\{1, 2, 0, 12\\}"
+  gdb_test "print/d ${name}4a * ${name}4b" "\\\$$decimal = \\{2, 8, 64, 64\\}"
+  gdb_test "print/d ${name}4a / ${name}4b" "\\\$$decimal = \\{2, 2, 1, 4\\}"
+
+  # scalar
+  gdb_test "print/d ${name}a++" "\\\$$decimal = 2"
+  gdb_test "print/d ++${name}a" "\\\$$decimal = 4"
+  gdb_test "print/d ${name}a--" "\\\$$decimal = 4"
+  gdb_test "print/d --${name}a" "\\\$$decimal = 2"
+  gdb_test "print/d +${name}a" "\\\$$decimal = 2"
+  gdb_test "print/d -${name}a" "\\\$$decimal = -2"
+  # vector
+  gdb_test "print/d ${name}4a++" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+  gdb_test "print/d ++${name}4a" "\\\$$decimal = \\{4, 6, 10, 18\\}"
+  gdb_test "print/d ${name}4a--" "\\\$$decimal = \\{4, 6, 10, 18\\}"
+  gdb_test "print/d --${name}4a" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+  gdb_test "print/d +${name}4a" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+  gdb_test "print/d -${name}4a" "\\\$$decimal = \\{-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" "\\\$$decimal = 0"
+    # scalar with vector
+    gdb_test "print/d ${name}4a % ${name}b" "\\\$$decimal = \\{0, 0, 0, 0\\}"
+    # vector with vector
+    gdb_test "print/d ${name}4a % ${name}b" "\\\$$decimal = \\{0, 0, 0, 0\\}"
+
+    # scalar with scalar
+    gdb_test "print/d u${name}a + u${name}b" "\\\$$decimal = 3"
+    gdb_test "print/d u${name}a - u${name}b" "\\\$$decimal = 1"
+    gdb_test "print/d u${name}a * u${name}b" "\\\$$decimal = 2"
+    gdb_test "print/d u${name}a / u${name}b" "\\\$$decimal = 2"
+    gdb_test "print/d u${name}a % u${name}b" "\\\$$decimal = 0"
+    # scalar with vector
+    gdb_test "print/d u${name}a + u${name}4b" "\\\$$decimal = \\{3, 4, 10, 6\\}"
+    gdb_test "print/d u${name}4a - u${name}b" "\\\$$decimal = \\{1, 3, 7, 15\\}"
+    gdb_test "print/d u${name}4a * u${name}b" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d u${name}a / u${name}4b" "\\\$$decimal = \\{2, 1, 0, 0\\}"
+    gdb_test "print/d u${name}4a % u${name}b" "\\\$$decimal = \\{0, 0, 0, 0\\}"
+    # vector with vector
+    gdb_test "print/d u${name}4a + u${name}4b" "\\\$$decimal = \\{3, 6, 16, 20\\}"
+    gdb_test "print/d u${name}4a - u${name}4b" "\\\$$decimal = \\{1, 2, 0, 12\\}"
+    gdb_test "print/d u${name}4a * u${name}4b" "\\\$$decimal = \\{2, 8, 64, 64\\}"
+    gdb_test "print/d u${name}4a / u${name}4b" "\\\$$decimal = \\{2, 2, 1, 4\\}"
+    gdb_test "print/d u${name}4a % u${name}4b" "\\\$$decimal = \\{0, 0, 0, 0\\}"
+
+    # scalar
+    gdb_test "print/d u${name}a++" "\\\$$decimal = 2"
+    gdb_test "print/d ++u${name}a" "\\\$$decimal = 4"
+    gdb_test "print/d u${name}a--" "\\\$$decimal = 4"
+    gdb_test "print/d --u${name}a" "\\\$$decimal = 2"
+    gdb_test "print/d +u${name}a" "\\\$$decimal = 2"
+    gdb_test "print/x -u${name}a" "\\\$$decimal = 0x.*fe"
+    # vector
+    gdb_test "print/d u${name}4a++" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d ++u${name}4a" "\\\$$decimal = \\{4, 6, 10, 18\\}"
+    gdb_test "print/d u${name}4a--" "\\\$$decimal = \\{4, 6, 10, 18\\}"
+    gdb_test "print/d --u${name}4a" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d +u${name}4a" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/x -u${name}4a" "\\\$$decimal = \\{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 } {
+  global decimal
+  # scalar with scalar
+  gdb_test "print/d ${name}a > ${name}b" "\\\$$decimal = 1"
+  gdb_test "print/d ${name}b < ${name}a" "\\\$$decimal = 1"
+  gdb_test "print/d ${name}b >= ${name}a" "\\\$$decimal = 0"
+  gdb_test "print/d ${name}a <= ${name}b" "\\\$$decimal = 0"
+  # scalar with vector
+  gdb_test "print/d ${name}4a > ${name}b" "\\\$$decimal = \\{-1, -1, -1, -1\\}"
+  gdb_test "print/d ${name}a < ${name}4b" "\\\$$decimal = \\{0, 0, -1, -1\\}"
+  gdb_test "print/d ${name}4a >= ${name}b" "\\\$$decimal = \\{-1, -1, -1, -1\\}"
+  gdb_test "print/d ${name}a <= ${name}4b" "\\\$$decimal = \\{0, -1, -1, -1\\}"
+  # vector with vector
+  gdb_test "print/d ${name}4a > ${name}4b" "\\\$$decimal = \\{-1, -1, 0, -1\\}"
+  gdb_test "print/d ${name}4b < ${name}4a" "\\\$$decimal = \\{-1, -1, 0, -1\\}"
+  gdb_test "print/d ${name}4b >= ${name}4a" "\\\$$decimal = \\{0, 0, -1, 0\\}"
+  gdb_test "print/d ${name}4a <= ${name}4b" "\\\$$decimal = \\{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" "\\\$$decimal = 1"
+    gdb_test "print/d u${name}b < u${name}a" "\\\$$decimal = 1"
+    gdb_test "print/d u${name}b >= u${name}a" "\\\$$decimal = 0"
+    gdb_test "print/d u${name}a <= u${name}b" "\\\$$decimal = 0"
+    # scalar with vector
+    gdb_test "print/d u${name}4a > u${name}b" "\\\$$decimal = \\{-1, -1, -1, -1\\}"
+    gdb_test "print/d u${name}a < u${name}4b" "\\\$$decimal = \\{0, 0, -1, -1\\}"
+    gdb_test "print/d u${name}4a >= u${name}b" "\\\$$decimal = \\{-1, -1, -1, -1\\}"
+    gdb_test "print/d u${name}a <= u${name}4b" "\\\$$decimal = \\{0, -1, -1, -1\\}"
+    # vector with vector
+    gdb_test "print/d u${name}4a > u${name}4b" "\\\$$decimal = \\{-1, -1, 0, -1\\}"
+    gdb_test "print/d u${name}4b < u${name}4a" "\\\$$decimal = \\{-1, -1, 0, -1\\}"
+    gdb_test "print/d u${name}4b >= u${name}4a" "\\\$$decimal = \\{0, 0, -1, 0\\}"
+    gdb_test "print/d u${name}4a <= u${name}4b" "\\\$$decimal = \\{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 } {
+  global decimal
+  # scalar with scalar
+  gdb_test "print/d ${name}a == ${name}b" "\\\$$decimal = 0"
+  gdb_test "print/d ${name}a != ${name}b" "\\\$$decimal = 1"
+  # scalar with vector
+  gdb_test "print/d ${name}4a == ${name}b" "\\\$$decimal = \\{0, 0, 0, 0\\}"
+  gdb_test "print/d ${name}a != ${name}4b" "\\\$$decimal = \\{-1, 0, -1, -1\\}"
+  # vector with vector
+  gdb_test "print/d ${name}4a == ${name}4b" "\\\$$decimal = \\{0, 0, -1, 0\\}"
+  gdb_test "print/d ${name}4a != ${name}4b" "\\\$$decimal = \\{-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" "\\\$$decimal = 0"
+    gdb_test "print/d u${name}a != u${name}b" "\\\$$decimal = 1"
+    # scalar with vector
+    gdb_test "print/d u${name}4a == u${name}b" "\\\$$decimal = \\{0, 0, 0, 0\\}"
+    gdb_test "print/d u${name}a != u${name}4b" "\\\$$decimal = \\{-1, 0, -1, -1\\}"
+    # vector with vector
+    gdb_test "print/d u${name}4a == u${name}4b" "\\\$$decimal = \\{0, 0, -1, 0\\}"
+    gdb_test "print/d u${name}4b != u${name}4a" "\\\$$decimal = \\{-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 } {
+  global decimal
+  # scalar with scalar
+  gdb_test "print/d ${name}a << ${name}b" "\\\$$decimal = 4"
+  gdb_test "print/d ${name}a >> ${name}b" "\\\$$decimal = 1"
+  gdb_test "print/d u${name}a << u${name}b" "\\\$$decimal = 4"
+  gdb_test "print/d u${name}a >> u${name}b" "\\\$$decimal = 1"
+  # scalar with vector
+  gdb_test "print/d ${name}4a << ${name}b" "\\\$$decimal = \\{4, 8, 16, 32\\}"
+  gdb_test "print/d ${name}4a >> ${name}b" "\\\$$decimal = \\{1, 2, 4, 8\\}"
+  gdb_test "print/d u${name}4a << u${name}b" "\\\$$decimal = \\{4, 8, 16, 32\\}"
+  gdb_test "print/d u${name}4a >> u${name}b" "\\\$$decimal = \\{1, 2, 4, 8\\}"
+  # vector with vector
+  if { ${size} == 1 } {
+    gdb_test "print/d ${name}4a << ${name}4b" "\\\$$decimal = \\{4, 16, 0, 0\\}"
+    gdb_test "print/d u${name}4a << u${name}4b" "\\\$$decimal = \\{4, 16, 0, 0\\}"
+  } else {
+    gdb_test "print/d ${name}4a << ${name}4b" "\\\$$decimal = \\{4, 16, 2048, 256\\}"
+    gdb_test "print/d u${name}4a << u${name}4b" "\\\$$decimal = \\{4, 16, 2048, 256\\}"
+  }
+  gdb_test "print/d ${name}4a >> ${name}4b" "\\\$$decimal = \\{1, 1, 0, 1\\}"
+  gdb_test "print/d u${name}4a >> u${name}4b" "\\\$$decimal = \\{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 } {
+  global decimal
+  # scalar with scalar
+  gdb_test "print/d ${name}a & ${name}b" "\\\$$decimal = 0"
+  gdb_test "print/d ${name}a | ${name}b" "\\\$$decimal = 3"
+  gdb_test "print/d ${name}a ^ ${name}b" "\\\$$decimal = 3"
+  gdb_test "print/d u${name}a & u${name}b" "\\\$$decimal = 0"
+  gdb_test "print/d u${name}a | u${name}b" "\\\$$decimal = 3"
+  gdb_test "print/d u${name}a ^ u${name}b" "\\\$$decimal = 3"
+  # scalar with vector
+  gdb_test "print/d ${name}4a & ${name}b" "\\\$$decimal = \\{0, 0, 0, 0\\}"
+  gdb_test "print/d ${name}a | ${name}4b" "\\\$$decimal = \\{3, 2, 10, 6\\}"
+  gdb_test "print/d ${name}4a ^ ${name}b" "\\\$$decimal = \\{3, 5, 9, 17\\}"
+  gdb_test "print/d u${name}4a & u${name}b" "\\\$$decimal = \\{0, 0, 0, 0\\}"
+  gdb_test "print/d u${name}a | u${name}4b" "\\\$$decimal = \\{3, 2, 10, 6\\}"
+  gdb_test "print/d u${name}4a ^ u${name}b" "\\\$$decimal = \\{3, 5, 9, 17\\}"
+  # vector with vector
+  gdb_test "print/d ${name}4a & ${name}4b" "\\\$$decimal = \\{0, 0, 8, 0\\}"
+  gdb_test "print/d ${name}4a | ${name}4b" "\\\$$decimal = \\{3, 6, 8, 20\\}"
+  gdb_test "print/d ${name}4a ^ ${name}4b" "\\\$$decimal = \\{3, 6, 0, 20\\}"
+  gdb_test "print/d u${name}4a & u${name}4b" "\\\$$decimal = \\{0, 0, 8, 0\\}"
+  gdb_test "print/d u${name}4a | u${name}4b" "\\\$$decimal = \\{3, 6, 8, 20\\}"
+  gdb_test "print/d u${name}4a ^ u${name}4b" "\\\$$decimal = \\{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" "\\\$$decimal = 0xfffffffd"
+    gdb_test "print/x ~u${name}a" "\\\$$decimal = 0xfffffffd"
+  } else {
+    gdb_test "print/x ~${name}a" "\\\$$decimal = 0xfffffffffffffffd"
+    gdb_test "print/x ~u${name}a" "\\\$$decimal = 0xfffffffffffffffd"
+  }
+  # vector
+  if { ${size} == 1 } {
+    gdb_test "print/x ~${name}4a" "\\\$$decimal = \\{0xfd, 0xfb, 0xf7, 0xef\\}"
+    gdb_test "print/x ~u${name}4a" "\\\$$decimal = \\{0xfd, 0xfb, 0xf7, 0xef\\}"
+  } elseif { ${size} == 2 } {
+    gdb_test "print/x ~${name}4a" "\\\$$decimal = \\{0xfffd, 0xfffb, 0xfff7, 0xffef\\}"
+    gdb_test "print/x ~u${name}4a" "\\\$$decimal = \\{0xfffd, 0xfffb, 0xfff7, 0xffef\\}"
+  } elseif { ${size} == 4 } {
+    gdb_test "print/x ~${name}4a" "\\\$$decimal = \\{0xfffffffd, 0xfffffffb, 0xfffffff7, 0xffffffef\\}"
+    gdb_test "print/x ~u${name}4a" "\\\$$decimal = \\{0xfffffffd, 0xfffffffb, 0xfffffff7, 0xffffffef\\}"
+  } else { # ${size} == 8
+    gdb_test "print/x ~${name}4a" "\\\$$decimal = \\{0xfffffffffffffffd, 0xfffffffffffffffb, 0xfffffffffffffff7, 0xffffffffffffffef\\}"
+    gdb_test "print/x ~u${name}4a" "\\\$$decimal = \\{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 } {
+  global decimal
+  # scalar
+  gdb_test "print/d !${name}a " "\\\$$decimal = 0"
+  gdb_test "print/d !!${name}a " "\\\$$decimal = 1"
+  # vector
+  gdb_test "print/d !${name}4a " "\\\$$decimal = \\{0, 0, 0, 0\\}"
+  gdb_test "print/d !!${name}4a " "\\\$$decimal = \\{-1, -1, -1, -1\\}"
+
+  # scalar with scalar
+  gdb_test "print/d ${name}a && ${name}b" "\\\$$decimal = 1"
+  gdb_test "print/d ${name}a && !${name}b" "\\\$$decimal = 0"
+  gdb_test "print/d ${name}a || ${name}b" "\\\$$decimal = 1"
+  gdb_test "print/d ${name}a || !${name}b" "\\\$$decimal = 1"
+  gdb_test "print/d !${name}a || !${name}b" "\\\$$decimal = 0"
+
+  # scalar with vector
+  gdb_test "print/d ${name}4a && ${name}b" "\\\$$decimal = \\{-1, -1, -1, -1\\}"
+  gdb_test "print/d ${name}4a && !${name}b" "\\\$$decimal = \\{0, 0, 0, 0\\}"
+  gdb_test "print/d ${name}a || ${name}4b" "\\\$$decimal = \\{-1, -1, -1, -1\\}"
+  gdb_test "print/d ${name}a || !${name}4b" "\\\$$decimal = \\{-1, -1, -1, -1\\}"
+  gdb_test "print/d !${name}4a || !${name}b" "\\\$$decimal = \\{0, 0, 0, 0\\}"
+  # vector with vector
+  gdb_test "print/d ${name}4a && ${name}4b" "\\\$$decimal = \\{-1, -1, -1, -1\\}"
+  gdb_test "print/d ${name}4a || ${name}4b" "\\\$$decimal = \\{-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 " "\\\$$decimal = 0"
+    gdb_test "print/d !!u${name}a " "\\\$$decimal = 1"
+    # unsigned vector
+    gdb_test "print/d !u${name}4a " "\\\$$decimal = \\{0, 0, 0, 0\\}"
+    gdb_test "print/d !!u${name}4a " "\\\$$decimal = \\{-1, -1, -1, -1\\}"
+
+    # scalar with scalar
+    gdb_test "print/d u${name}a && u${name}b" "\\\$$decimal = 1"
+    gdb_test "print/d u${name}a || u${name}b" "\\\$$decimal = 1"
+    # scalar with vector
+    gdb_test "print/d u${name}4a && u${name}b" "\\\$$decimal = \\{-1, -1, -1, -1\\}"
+    gdb_test "print/d u${name}a || u${name}4b" "\\\$$decimal = \\{-1, -1, -1, -1\\}"
+    # vector with vector
+    gdb_test "print/d u${name}4a && u${name}4b" "\\\$$decimal = \\{-1, -1, -1, -1\\}"
+    gdb_test "print/d u${name}4a || u${name}4b" "\\\$$decimal = \\{-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 } {
+  global decimal
+  # scalar with scalar
+  gdb_test "print/d ${name}a ? ${name}b : ${name}a" "\\\$$decimal = 1"
+  gdb_test "print/d !${name}a ? ${name}b : ${name}a" "\\\$$decimal = 2"
+  # scalar with vector
+  gdb_test "print/d ${name}4a ? ${name}4b : ${name}a" "\\\$$decimal = \\{1, 2, 8, 4\\}"
+  gdb_test "print/d ${name}4a ? ${name}b : ${name}4a" "\\\$$decimal = \\{1, 1, 1, 1\\}"
+  gdb_test "print/d ${name}4a > 4 ? 1 : ${name}4a" "\\\$$decimal = \\{2, 4, 1, 1\\}"
+  gdb_test "print/d ${name}4a > 4 ? ${name}4b : ${name}a" "\\\$$decimal = \\{2, 2, 8, 4\\}"
+  # vector with vector
+  gdb_test "print/d ${name}4a ? ${name}4b : ${name}4a" "\\\$$decimal = \\{1, 2, 8, 4\\}"
+  gdb_test "print/d ${name}4a > 4 ? ${name}4b : ${name}4a" "\\\$$decimal = \\{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" "\\\$$decimal = 1"
+    gdb_test "print/d !u${name}a ? u${name}b : u${name}a" "\\\$$decimal = 2"
+    # scalar with vector
+    gdb_test "print/d u${name}4a ? u${name}4b : u${name}a" "\\\$$decimal = \\{1, 2, 8, 4\\}"
+    gdb_test "print/d u${name}4a ? u${name}b : u${name}4a" "\\\$$decimal = \\{1, 1, 1, 1\\}"
+    gdb_test "print/d u${name}4a > 4 ? 1 : u${name}4a" "\\\$$decimal = \\{2, 4, 1, 1\\}"
+    gdb_test "print/d u${name}4a > 4 ? u${name}4b : u${name}a" "\\\$$decimal = \\{2, 2, 8, 4\\}"
+    # vector with vector
+    gdb_test "print/d u${name}4a ? u${name}4b : u${name}4a" "\\\$$decimal = \\{1, 2, 8, 4\\}"
+    gdb_test "print/d u${name}4a > 4 ? u${name}4b : u${name}4a" "\\\$$decimal = \\{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 } {
+  global decimal
+  # scalar with scalar
+  gdb_test "print/d ${name}a = ${name}b" "\\\$$decimal = 1"
+  gdb_test "print/d ${name}a = 2" "\\\$$decimal = 2"
+  gdb_test "print/d ${name}a += ${name}b" "\\\$$decimal = 3"
+  gdb_test "print/d ${name}a -= ${name}b" "\\\$$decimal = 2"
+  gdb_test "print/d ${name}b *= ${name}a" "\\\$$decimal = 2"
+  gdb_test "print/d ${name}b /= ${name}a" "\\\$$decimal = 1"
+  # scalar with vector
+  gdb_test "print/d ${name}4a = ${name}b" "\\\$$decimal = \\{1, 1, 1, 1\\}"
+  gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+  gdb_test "print/d ${name}4a += ${name}b" "\\\$$decimal = \\{3, 5, 9, 17\\}"
+  gdb_test "print/d ${name}4a -= ${name}b" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+  gdb_test "print/d ${name}4b *= ${name}a" "\\\$$decimal = \\{2, 4, 16, 8\\}"
+  gdb_test "print/d ${name}4b /= ${name}a" "\\\$$decimal = \\{1, 2, 8, 4\\}"
+  # vector with vector
+  gdb_test "print/d ${name}4a = ${name}4b" "\\\$$decimal = \\{1, 2, 8, 4\\}"
+  gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+  gdb_test "print/d ${name}4a += ${name}4b" "\\\$$decimal = \\{3, 6, 16, 20\\}"
+  gdb_test "print/d ${name}4a -= ${name}4b" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+  gdb_test "print/d ${name}4b *= ${name}4a" "\\\$$decimal = \\{2, 8, 64, 64\\}"
+  gdb_test "print/d ${name}4b /= ${name}4a" "\\\$$decimal = \\{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" "\\\$$decimal = 0"
+    gdb_test "print/d ${name}a = 2" "\\\$$decimal = 2"
+    gdb_test "print/d ${name}a <<= ${name}b" "\\\$$decimal = 4"
+    gdb_test "print/d ${name}a = 2" "\\\$$decimal = 2"
+    gdb_test "print/d ${name}a >>= ${name}b" "\\\$$decimal = 1"
+    gdb_test "print/d ${name}a = 2" "\\\$$decimal = 2"
+    gdb_test "print/d ${name}a &= ${name}b" "\\\$$decimal = 0"
+    gdb_test "print/d ${name}a = 2" "\\\$$decimal = 2"
+    gdb_test "print/d ${name}a |= ${name}b" "\\\$$decimal = 3"
+    gdb_test "print/d ${name}a = 2" "\\\$$decimal = 2"
+    gdb_test "print/d ${name}a ^= ${name}b" "\\\$$decimal = 3"
+    gdb_test "print/d ${name}a = 2" "\\\$$decimal = 2"
+    # scalar with vector
+    gdb_test "print/d ${name}4b %= ${name}a" "\\\$$decimal = \\{1, 0, 0, 0\\}"
+    gdb_test "print/d ${name}4b = \{1, 2, 8, 4\}" "\\\$$decimal = \\{1, 2, 8, 4\\}"
+    gdb_test "print/d ${name}4a <<= ${name}b" "\\\$$decimal = \\{4, 8, 16, 32\\}"
+    gdb_test "print/d ${name}4a >>= ${name}b" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d ${name}4a &= ${name}b" "\\\$$decimal = \\{0, 0, 0, 0\\}"
+    gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d ${name}4a |= ${name}b" "\\\$$decimal = \\{3, 5, 9, 17\\}"
+    gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d ${name}4a ^= ${name}b" "\\\$$decimal = \\{3, 5, 9, 17\\}"
+    gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    # vector with vector
+    gdb_test "print/d ${name}4b %= ${name}4a" "\\\$$decimal = \\{1, 2, 0, 4\\}"
+    gdb_test "print/d ${name}4b = \{1, 2, 8, 4\}" "\\\$$decimal = \\{1, 2, 8, 4\\}"
+    if { ${size} == 1 } {
+      gdb_test "print/d ${name}4a <<= ${name}4b" "\\\$$decimal = \\{4, 16, 0, 0\\}"
+      gdb_test "print/d ${name}4a >>= ${name}4b" "\\\$$decimal = \\{2, 4, 0, 0\\}"
+      gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    } else {
+      gdb_test "print/d ${name}4a <<= ${name}4b" "\\\$$decimal = \\{4, 16, 2048, 256\\}"
+      gdb_test "print/d ${name}4a >>= ${name}4b" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    }
+    gdb_test "print/d ${name}4a &= ${name}4b" "\\\$$decimal = \\{0, 0, 8, 0\\}"
+    gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d ${name}4a |= ${name}4b" "\\\$$decimal = \\{3, 6, 8, 20\\}"
+    gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d ${name}4a ^= ${name}4b" "\\\$$decimal = \\{3, 6, 0, 20\\}"
+    gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{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" "\\\$$decimal = 1"
+    gdb_test "print/d u${name}a = 2" "\\\$$decimal = 2"
+    gdb_test "print/d u${name}a += u${name}b" "\\\$$decimal = 3"
+    gdb_test "print/d u${name}a -= u${name}b" "\\\$$decimal = 2"
+    gdb_test "print/d u${name}b *= u${name}a" "\\\$$decimal = 2"
+    gdb_test "print/d u${name}b /= u${name}a" "\\\$$decimal = 1"
+    gdb_test "print/d u${name}a %= u${name}b" "\\\$$decimal = 0"
+    gdb_test "print/d u${name}a = 2" "\\\$$decimal = 2"
+    gdb_test "print/d u${name}a <<= u${name}b" "\\\$$decimal = 4"
+    gdb_test "print/d u${name}a = 2" "\\\$$decimal = 2"
+    gdb_test "print/d u${name}a >>= u${name}b" "\\\$$decimal = 1"
+    gdb_test "print/d u${name}a = 2" "\\\$$decimal = 2"
+    gdb_test "print/d u${name}a &= u${name}b" "\\\$$decimal = 0"
+    gdb_test "print/d u${name}a = 2" "\\\$$decimal = 2"
+    gdb_test "print/d u${name}a |= u${name}b" "\\\$$decimal = 3"
+    gdb_test "print/d u${name}a = 2" "\\\$$decimal = 2"
+    gdb_test "print/d u${name}a ^= u${name}b" "\\\$$decimal = 3"
+    gdb_test "print/d u${name}a = 2" "\\\$$decimal = 2"
+    # scalar with vector
+    gdb_test "print/d u${name}4a = u${name}b" "\\\$$decimal = \\{1, 1, 1, 1\\}"
+    gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d u${name}4a += u${name}b" "\\\$$decimal = \\{3, 5, 9, 17\\}"
+    gdb_test "print/d u${name}4a -= u${name}b" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d u${name}4b *= u${name}a" "\\\$$decimal = \\{2, 4, 16, 8\\}"
+    gdb_test "print/d u${name}4b /= u${name}a" "\\\$$decimal = \\{1, 2, 8, 4\\}"
+    gdb_test "print/d u${name}4b %= u${name}a" "\\\$$decimal = \\{1, 0, 0, 0\\}"
+    gdb_test "print/d u${name}4b = \{1, 2, 8, 4\}" "\\\$$decimal = \\{1, 2, 8, 4\\}"
+    gdb_test "print/d u${name}4a <<= u${name}b" "\\\$$decimal = \\{4, 8, 16, 32\\}"
+    gdb_test "print/d u${name}4a >>= u${name}b" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d u${name}4a &= u${name}b" "\\\$$decimal = \\{0, 0, 0, 0\\}"
+    gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d u${name}4a |= u${name}b" "\\\$$decimal = \\{3, 5, 9, 17\\}"
+    gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d u${name}4a ^= u${name}b" "\\\$$decimal = \\{3, 5, 9, 17\\}"
+    gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    # vector with vector
+    gdb_test "print/d u${name}4a = u${name}4b" "\\\$$decimal = \\{1, 2, 8, 4\\}"
+    gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d u${name}4a += u${name}4b" "\\\$$decimal = \\{3, 6, 16, 20\\}"
+    gdb_test "print/d u${name}4a -= u${name}4b" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d u${name}4b *= u${name}4a" "\\\$$decimal = \\{2, 8, 64, 64\\}"
+    gdb_test "print/d u${name}4b /= u${name}4a" "\\\$$decimal = \\{1, 2, 8, 4\\}"
+    gdb_test "print/d u${name}4b %= u${name}4a" "\\\$$decimal = \\{1, 2, 0, 4\\}"
+    gdb_test "print/d u${name}4b = \{1, 2, 8, 4\}" "\\\$$decimal = \\{1, 2, 8, 4\\}"
+    if { ${size} == 1 } {
+      gdb_test "print/d u${name}4a <<= u${name}4b" "\\\$$decimal = \\{4, 16, 0, 0\\}"
+      gdb_test "print/d u${name}4a >>= u${name}4b" "\\\$$decimal = \\{2, 4, 0, 0\\}"
+      gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    } else {
+      gdb_test "print/d u${name}4a <<= u${name}4b" "\\\$$decimal = \\{4, 16, 2048, 256\\}"
+      gdb_test "print/d u${name}4a >>= u${name}4b" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    }
+    gdb_test "print/d u${name}4a &= u${name}4b" "\\\$$decimal = \\{0, 0, 8, 0\\}"
+    gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d u${name}4a |= u${name}4b" "\\\$$decimal = \\{3, 6, 8, 20\\}"
+    gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d u${name}4a ^= u${name}4b" "\\\$$decimal = \\{3, 6, 0, 20\\}"
+    gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{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}
Index: src/gdb/testsuite/gdb.opencl/vec_comps.cl
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/vec_comps.cl	2010-10-22 17:18:10.000000000 +0200
@@ -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;
+}
Index: src/gdb/testsuite/gdb.opencl/vec_comps.exp
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/vec_comps.exp	2010-10-22 17:18:10.000000000 +0200
@@ -0,0 +1,402 @@
+# 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 bin ${objdir}/${subdir}/${testfile}
+set clprogram [remote_download target ${srcdir}/${subdir}/${testfile}.cl]
+
+# Increase timeout
+set timeout 60
+verbose "Timeout set to $timeout seconds" 2
+
+# Compile the generic OpenCL host app
+if { [gdb_compile_opencl_hostapp "${clprogram}" "${bin}" "" ] != "" } {
+    untested ${testfile}.exp
+    return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
+# Load the OpenCL app
+gdb_load ${bin}
+
+# 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
+
+# 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 } {
+  global decimal
+  gdb_test "ptype ${name}" "type = ${type} \\\[16\\\]"
+  gdb_test "p sizeof(${name})" "\\\$$decimal = [expr ${size} * 16]"
+  gdb_test "print/d ${name}" "\\\$$decimal = \\{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 } {
+  global decimal
+
+  gdb_test "print sizeof (${name}.lo)" "\\\$$decimal = [expr $size * 8]"
+  gdb_test "print sizeof (${name}.hi)" "\\\$$decimal = [expr $size * 8]"
+  gdb_test "print sizeof (${name}.even)" "\\\$$decimal = [expr $size * 8]"
+  gdb_test "print sizeof (${name}.odd)" "\\\$$decimal = [expr $size * 8]"
+
+  gdb_test "print sizeof (${name}.hi.even)" "\\\$$decimal = [expr $size * 4]"
+  gdb_test "print sizeof (${name}.odd.odd.lo)" "\\\$$decimal = [expr $size * 2]"
+  gdb_test "print sizeof (${name}.even.hi.lo.odd)" "\\\$$decimal = $size"
+
+  gdb_test "print sizeof (${name}.x)" "\\\$$decimal = $size"
+  gdb_test "print sizeof (${name}.xy)" "\\\$$decimal = [expr $size * 2]"
+  gdb_test "print sizeof (${name}.xyz)" "\\\$$decimal = [expr $size * 4]"
+  gdb_test "print sizeof (${name}.xyzw)" "\\\$$decimal = [expr $size * 4]"
+
+  gdb_test "print sizeof (${name}.xy.x)" "\\\$$decimal = $size"
+  gdb_test "print sizeof (${name}.wzyx.yy)" "\\\$$decimal = [expr $size * 2]"
+  gdb_test "print sizeof (${name}.wzyx.yx.x)" "\\\$$decimal = $size"
+  gdb_test "print sizeof (${name}.xyzw.w)" "\\\$$decimal = $size"
+
+  gdb_test "print sizeof (${name}.s0)" "\\\$$decimal = $size"
+  gdb_test "print sizeof (${name}.s01)" "\\\$$decimal = [expr $size * 2]"
+  gdb_test "print sizeof (${name}.s012)" "\\\$$decimal = [expr $size * 4]"
+  gdb_test "print sizeof (${name}.s0123)" "\\\$$decimal = [expr $size * 4]"
+  gdb_test "print sizeof (${name}.s01234567)" "\\\$$decimal = [expr $size * 8]"
+  gdb_test "print sizeof (${name}.s0123456789abcdef)" "\\\$$decimal = [expr $size * 16]"
+
+  gdb_test "print sizeof (${name}.sfedcba98.S0246)" "\\\$$decimal = [expr $size * 4]"
+  gdb_test "print sizeof (${name}.sfedcba98.S0246.s13)" "\\\$$decimal = [expr $size * 2]"
+  gdb_test "print sizeof (${name}.sfedcba98.S0246.s13.s0)" "\\\$$decimal = $size"
+  gdb_test "print sizeof (${name}.s0123456789abcdef.s22)" "\\\$$decimal = [expr $size * 2]"
+
+  gdb_test "print sizeof (${name}.hi.s7654.wx)" "\\\$$decimal = [expr $size * 2]"
+  gdb_test "print sizeof (${name}.s0123456789abcdef.even.lo)" "\\\$$decimal = [expr $size * 4]"
+  gdb_test "print sizeof (${name}.odd.xyzw.s23)" "\\\$$decimal = [expr $size * 2]"
+  gdb_test "print sizeof (${name}.xyzw.hi.odd)" "\\\$$decimal = $size"
+}
+
+# OpenCL vector component access
+proc check_access { name type } {
+  global decimal
+  gdb_test "print/d ${name}.lo" "\\\$$decimal = \\{0, 1, 2, 3, 4, 5, 6, 7\\}"
+  gdb_test "print/d ${name}.hi" "\\\$$decimal = \\{8, 9, 10, 11, 12, 13, 14, 15\\}"
+  gdb_test "print/d ${name}.even" "\\\$$decimal = \\{0, 2, 4, 6, 8, 10, 12, 14\\}"
+  gdb_test "print/d ${name}.odd" "\\\$$decimal = \\{1, 3, 5, 7, 9, 11, 13, 15\\}"
+
+  gdb_test "print/d ${name}.hi.even" "\\\$$decimal = \\{8, 10, 12, 14\\}"
+  gdb_test "print/d ${name}.odd.odd.lo" "\\\$$decimal = \\{3, 7\\}"
+  gdb_test "print/d ${name}.even.hi.lo.odd" "\\\$$decimal = 10"
+
+  gdb_test "print/d ${name}.x" "\\\$$decimal = 0"
+  gdb_test "print/d ${name}.y" "\\\$$decimal = 1"
+  gdb_test "print/d ${name}.z" "\\\$$decimal = 2"
+  gdb_test "print/d ${name}.w" "\\\$$decimal = 3"
+
+  gdb_test "print/d ${name}.xy" "\\\$$decimal = \\{0, 1\\}"
+  gdb_test "print/d ${name}.xx" "\\\$$decimal = \\{0, 0\\}"
+  gdb_test "print/d ${name}.wy" "\\\$$decimal = \\{3, 1\\}"
+
+  gdb_test "print/d ${name}.xyz" "\\\$$decimal = \\{0, 1, 2\\}"
+  gdb_test "print/d ${name}.yxy" "\\\$$decimal = \\{1, 0, 1\\}"
+  gdb_test "print/d ${name}.yzx" "\\\$$decimal = \\{1, 2, 0\\}"
+
+  gdb_test "print/d ${name}.xywz" "\\\$$decimal = \\{0, 1, 3, 2\\}"
+  gdb_test "print/d ${name}.zzyy" "\\\$$decimal = \\{2, 2, 1, 1\\}"
+  gdb_test "print/d ${name}.wwww" "\\\$$decimal = \\{3, 3, 3, 3\\}"
+
+  gdb_test "print/d ${name}.xy.x" "\\\$$decimal = 0"
+  gdb_test "print/d ${name}.wzyx.yy" "\\\$$decimal = \\{2, 2\\}"
+  gdb_test "print/d ${name}.wzyx.yx.x" "\\\$$decimal = 2"
+  gdb_test "print/d ${name}.xyzw.w" "\\\$$decimal = 3"
+
+  for {set i 0} {$i < 16} {incr i} {
+    gdb_test "print/d ${name}.s[format "%x" $i]" "\\\$$decimal = $i"
+    gdb_test "print/d ${name}.S[format "%x" $i]" "\\\$$decimal = $i"
+    if {$i > 9} {
+      gdb_test "print/d ${name}.s[format "%X" $i]" "\\\$$decimal = $i"
+      gdb_test "print/d ${name}.S[format "%X" $i]" "\\\$$decimal = $i"
+    }
+  }
+
+  gdb_test "print/d ${name}.s01" "\\\$$decimal = \\{0, 1\\}"
+  gdb_test "print/d ${name}.s00" "\\\$$decimal = \\{0, 0\\}"
+  gdb_test "print/d ${name}.sF0" "\\\$$decimal = \\{15, 0\\}"
+  gdb_test "print/d ${name}.S42" "\\\$$decimal = \\{4, 2\\}"
+
+  gdb_test "print/d ${name}.s567" "\\\$$decimal = \\{5, 6, 7\\}"
+  gdb_test "print/d ${name}.S333" "\\\$$decimal = \\{3, 3, 3\\}"
+  gdb_test "print/d ${name}.Sf0A" "\\\$$decimal = \\{15, 0, 10\\}"
+  gdb_test "print/d ${name}.SB1D" "\\\$$decimal = \\{11, 1, 13\\}"
+
+  gdb_test "print/d ${name}.s9876" "\\\$$decimal = \\{9, 8, 7, 6\\}"
+  gdb_test "print/d ${name}.sFFFF" "\\\$$decimal = \\{15, 15, 15, 15\\}"
+  gdb_test "print/d ${name}.sCafe" "\\\$$decimal = \\{12, 10, 15, 14\\}"
+  gdb_test "print/d ${name}.Sf001" "\\\$$decimal = \\{15, 0, 0, 1\\}"
+
+  gdb_test "print/d ${name}.s00000000" "\\\$$decimal = \\{0, 0, 0, 0, 0, 0, 0, 0\\}"
+  gdb_test "print/d ${name}.s00224466" "\\\$$decimal = \\{0, 0, 2, 2, 4, 4, 6, 6\\}"
+  gdb_test "print/d ${name}.sDEADBEEF" "\\\$$decimal = \\{13, 14, 10, 13, 11, 14, 14, 15\\}"
+  gdb_test "print/d ${name}.Sa628c193" "\\\$$decimal = \\{10, 6, 2, 8, 12, 1, 9, 3\\}"
+
+  gdb_test "print/d ${name}.s0123456789aBcDeF" "\\\$$decimal = \\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15\\}"
+  gdb_test "print/d ${name}.s0022446688AACCEE" "\\\$$decimal = \\{0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14\\}"
+  gdb_test "print/d ${name}.S0123456776543210" "\\\$$decimal = \\{0, 1, 2, 3, 4, 5, 6, 7, 7, 6, 5, 4, 3, 2, 1, 0\\}"
+  gdb_test "print/d ${name}.sFEDCBA9876543210" "\\\$$decimal = \\{15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0\\}"
+
+  gdb_test "print/d ${name}.sfedcba98.S0246" "\\\$$decimal = \\{15, 13, 11, 9\\}"
+  gdb_test "print/d ${name}.sfedcba98.S0246.s13" "\\\$$decimal = \\{13, 9\\}"
+  gdb_test "print/d ${name}.sfedcba98.S0246.s13.s0" "\\\$$decimal = 13"
+  gdb_test "print/d ${name}.s0123456789abcdef.s22" "\\\$$decimal = \\{2, 2\\}"
+
+  gdb_test "print/d ${name}.hi.s7654.wx" "\\\$$decimal = \\{12, 15\\}"
+  gdb_test "print/d ${name}.s0123456789abcdef.even.lo" "\\\$$decimal = \\{0, 2, 4, 6\\}"
+  gdb_test "print/d ${name}.odd.xyzw.s23" "\\\$$decimal = \\{5, 7\\}"
+  gdb_test "print/d ${name}.xyzw.hi.odd" "\\\$$decimal = 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]" "\\\$$decimal = [expr 15 - $i]"
+  }
+  gdb_test "print/d ${name}" "\\\$$decimal = \\{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}" "\\\$$decimal = \\{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}" "\\\$$decimal = \\{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}" "\\\$$decimal = \\{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}" "\\\$$decimal = \\{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}
Index: src/gdb/testsuite/lib/cl_util.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/lib/cl_util.c	2010-10-22 17:18:10.000000000 +0200
@@ -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);
+}
Index: src/gdb/testsuite/lib/cl_util.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/lib/cl_util.h	2010-10-22 17:18:10.000000000 +0200
@@ -0,0 +1,85 @@
+/* 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.
+   @param filename The file name of the file to be read
+   @param size Returns the size of the file in bytes
+   @return a pointer the data (NULL if the does not exist)
+*/
+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.
+   @param program The program to be saved
+*/
+extern void save_program_binaries (cl_program program);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CL_UTIL_H */
Index: src/gdb/testsuite/lib/opencl.exp
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/lib/opencl.exp	2010-10-22 17:18:10.000000000 +0200
@@ -0,0 +1,85 @@
+# 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 dest options} {
+    global srcdir objdir
+    set src "${srcdir}/lib/cl_util.c ${srcdir}/lib/opencl_hostapp.c"
+    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 $dest "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 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 bin opencltest[pid].x
+
+    verbose "$me:  compiling OpenCL test app" 2
+    set compile_flags {debug nowarnings quiet}
+
+    if { [gdb_compile_opencl_hostapp "${clprogram}" "${bin}" "" ] != "" } {
+        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.
+    gdb_exit
+    gdb_start
+    gdb_reinitialize_dir $srcdir/$subdir
+    gdb_load "$bin"
+    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 $bin
+
+    # 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)
+}
Index: src/gdb/testsuite/lib/opencl_hostapp.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/lib/opencl_hostapp.c	2010-10-22 17:18:10.000000000 +0200
@@ -0,0 +1,169 @@
+/* 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;
+
+  /* Print OpenCL informations  */
+  /*print_clinfo ();*/
+
+  /* init data */
+  data = (cl_int*) calloc (1, size);
+  if (data == NULL)
+    {
+      fprintf (stderr, "calloc failed\n");
+      exit (EXIT_FAILURE);
+    }
+
+  /* init OpenCL */
+  /* 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 the 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 kernel source */
+  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 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 */
+  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;
+}
Index: src/gdb/testsuite/lib/opencl_kernel.cl
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/lib/opencl_kernel.cl	2010-10-22 17:18:10.000000000 +0200
@@ -0,0 +1,5 @@
+/* OpenCL kernel for testing purposes.  */
+__kernel void testkernel (__global int *data)
+{
+  data[get_global_id(0)] = 0x1;
+}
Index: src/gdb/testsuite/gdb.opencl/convs_casts.cl
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/convs_casts.cl	2010-10-22 17:18:10.000000000 +0200
@@ -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;
+}
Index: src/gdb/testsuite/gdb.opencl/convs_casts.exp
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/convs_casts.exp	2010-10-22 17:18:10.000000000 +0200
@@ -0,0 +1,103 @@
+# 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 bin ${objdir}/${subdir}/${testfile}
+set clprogram [remote_download target ${srcdir}/${subdir}/${testfile}.cl]
+
+# Increase timeout
+set timeout 60
+verbose "Timeout set to $timeout seconds" 2
+
+# Compile the generic OpenCL host app
+if { [gdb_compile_opencl_hostapp "${clprogram}" "${bin}" "" ] != "" } {
+    untested ${testfile}.exp
+    return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
+# Load the OpenCL app
+gdb_load ${bin}
+
+# 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
+
+# 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 decimal 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}" "\\\$$decimal = \\{123, 123\\}"
+    gdb_test "print/d (${type}3)${name}" "\\\$$decimal = \\{123, 123, 123\\}"
+    gdb_test "print/d (${type}4)${name}" "\\\$$decimal = \\{123, 123, 123, 123\\}"
+    gdb_test "print/d (${type}8)${name}" "\\\$$decimal = \\{123, 123, 123, 123, 123, 123, 123, 123\\}"
+    gdb_test "print/d (${type}16)${name}" "\\\$$decimal = \\{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}
Index: src/gdb/c-exp.y
===================================================================
--- src.orig/gdb/c-exp.y	2010-10-22 17:17:33.000000000 +0200
+++ src/gdb/c-exp.y	2010-10-22 17:18:10.000000000 +0200
@@ -612,7 +612,9 @@ exp	:	VARIABLE
 
 exp	:	SIZEOF '(' type ')'	%prec UNARY
 			{ write_exp_elt_opcode (OP_LONG);
-			  write_exp_elt_type (parse_type->builtin_int);
+			  write_exp_elt_type (lookup_signed_typename
+					      (parse_language, parse_gdbarch,
+					       "int"));
 			  CHECK_TYPEDEF ($3);
 			  write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
 			  write_exp_elt_opcode (OP_LONG); }
@@ -980,61 +982,117 @@ typebase  /* Implements (approximately):
 	:	TYPENAME
 			{ $$ = $1.type; }
 	|	INT_KEYWORD
-			{ $$ = parse_type->builtin_int; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "int"); }
 	|	LONG
-			{ $$ = parse_type->builtin_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long"); }
 	|	SHORT
-			{ $$ = parse_type->builtin_short; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "short"); }
 	|	LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long"); }
 	|	LONG SIGNED_KEYWORD INT_KEYWORD
-			{ $$ = parse_type->builtin_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long"); }
 	|	LONG SIGNED_KEYWORD
-			{ $$ = parse_type->builtin_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long"); }
 	|	SIGNED_KEYWORD LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long"); }
 	|	UNSIGNED LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long"); }
 	|	LONG UNSIGNED INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long"); }
 	|	LONG UNSIGNED
-			{ $$ = parse_type->builtin_unsigned_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long"); }
 	|	LONG LONG
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	LONG LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	LONG LONG SIGNED_KEYWORD INT_KEYWORD
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	LONG LONG SIGNED_KEYWORD
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	SIGNED_KEYWORD LONG LONG
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	SIGNED_KEYWORD LONG LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	UNSIGNED LONG LONG
-			{ $$ = parse_type->builtin_unsigned_long_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long long"); }
 	|	UNSIGNED LONG LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_long_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long long"); }
 	|	LONG LONG UNSIGNED
-			{ $$ = parse_type->builtin_unsigned_long_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long long"); }
 	|	LONG LONG UNSIGNED INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_long_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long long"); }
 	|	SHORT INT_KEYWORD
-			{ $$ = parse_type->builtin_short; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "short"); }
 	|	SHORT SIGNED_KEYWORD INT_KEYWORD
-			{ $$ = parse_type->builtin_short; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "short"); }
 	|	SHORT SIGNED_KEYWORD
-			{ $$ = parse_type->builtin_short; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "short"); }
 	|	UNSIGNED SHORT INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_short; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "short"); }
 	|	SHORT UNSIGNED 
-			{ $$ = parse_type->builtin_unsigned_short; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "short"); }
 	|	SHORT UNSIGNED INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_short; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "short"); }
 	|	DOUBLE_KEYWORD
-			{ $$ = parse_type->builtin_double; }
+			{ $$ = lookup_typename (parse_language, parse_gdbarch,
+						"double", (struct block *) NULL,
+						0); }
 	|	LONG DOUBLE_KEYWORD
-			{ $$ = parse_type->builtin_long_double; }
+			{ $$ = lookup_typename (parse_language, parse_gdbarch,
+						"long double",
+						(struct block *) NULL, 0); }
 	|	STRUCT name
 			{ $$ = lookup_struct (copy_name ($2),
 					      expression_context_block); }
@@ -1052,13 +1110,17 @@ typebase  /* Implements (approximately):
 							 parse_gdbarch,
 							 TYPE_NAME($2.type)); }
 	|	UNSIGNED
-			{ $$ = parse_type->builtin_unsigned_int; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "int"); }
 	|	SIGNED_KEYWORD typename
 			{ $$ = lookup_signed_typename (parse_language,
 						       parse_gdbarch,
 						       TYPE_NAME($2.type)); }
 	|	SIGNED_KEYWORD
-			{ $$ = parse_type->builtin_int; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "int"); }
                 /* It appears that this rule for templates is never
                    reduced; template recognition happens by lookahead
                    in the token processing code in yylex. */         
@@ -1077,19 +1139,25 @@ typename:	TYPENAME
 		{
 		  $$.stoken.ptr = "int";
 		  $$.stoken.length = 3;
-		  $$.type = parse_type->builtin_int;
+		  $$.type = lookup_signed_typename (parse_language,
+						    parse_gdbarch,
+						    "int");
 		}
 	|	LONG
 		{
 		  $$.stoken.ptr = "long";
 		  $$.stoken.length = 4;
-		  $$.type = parse_type->builtin_long;
+		  $$.type = lookup_signed_typename (parse_language,
+						    parse_gdbarch,
+						    "long");
 		}
 	|	SHORT
 		{
 		  $$.stoken.ptr = "short";
 		  $$.stoken.length = 5;
-		  $$.type = parse_type->builtin_short;
+		  $$.type = lookup_signed_typename (parse_language,
+						    parse_gdbarch,
+						    "short");
 		}
 	;
 
Index: src/gdb/c-lang.h
===================================================================
--- src.orig/gdb/c-lang.h	2010-10-22 17:17:33.000000000 +0200
+++ src/gdb/c-lang.h	2010-10-22 17:18:10.000000000 +0200
@@ -27,6 +27,7 @@ struct language_arch_info;
 
 #include "value.h"
 #include "macroexp.h"
+#include "parser-defs.h"
 
 
 /* The various kinds of C string and character.  Note that these
@@ -93,6 +94,8 @@ extern const struct exp_descriptor exp_d
 extern void c_emit_char (int c, struct type *type,
 			 struct ui_file *stream, int quoter);
 
+extern const struct op_print c_op_print_tab[];
+
 /* These are in c-typeprint.c: */
 
 extern void c_type_print_base (struct type *, struct ui_file *, int, int);

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] initial OpenCL C language support
  2010-10-22 17:21 [patch] initial OpenCL C language support Ken Werner
@ 2010-10-25 22:41 ` Tom Tromey
  2010-10-26 13:05   ` Ken Werner
  0 siblings, 1 reply; 36+ messages in thread
From: Tom Tromey @ 2010-10-25 22:41 UTC (permalink / raw)
  To: Ken Werner; +Cc: gdb-patches

>>>>> "Ken" == Ken Werner <ken@linux.vnet.ibm.com> writes:

Ken> This patch implements initial GDB support for the OpenCL C
Ken> Programming Language. Since OpenCL is based on C99 I tried to reuse
Ken> GDBs C infrastructure where possible (expression parser, printing
Ken> routines, etc).

I have been skimming this patch a bit and I think it is very good.

I don't have time to fully review it right now, as I'm at the GCC
Summit.  But I did notice one thing:

Ken> +/* Expression evaluator for the OpenCL.  Most operations are delegated to
Ken> +   evaluate_subexp_standard; see that function for a description of the
Ken> +   arguments.  */
Ken> +static struct value *
Ken> +evaluate_subexp_opencl (struct type *expect_type, struct expression *exp,
Ken> +		   int *pos, enum noside noside)
[...]
Ken> +  return evaluate_subexp_standard (expect_type, exp, pos, noside);

I think this ought to call the C-specific evaluate_subexp_c.
You'll need to at least make this non-static, maybe even rename it.

I believe that without this some forms of string constants will not work
properly.

Tom

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] initial OpenCL C language support
  2010-10-25 22:41 ` Tom Tromey
@ 2010-10-26 13:05   ` Ken Werner
  2010-10-26 13:44     ` Tom Tromey
  0 siblings, 1 reply; 36+ messages in thread
From: Ken Werner @ 2010-10-26 13:05 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Tuesday, October 26, 2010 12:45:58 am Tom Tromey wrote:
> >>>>> "Ken" == Ken Werner <ken@linux.vnet.ibm.com> writes:
> Ken> This patch implements initial GDB support for the OpenCL C
> Ken> Programming Language. Since OpenCL is based on C99 I tried to reuse
> Ken> GDBs C infrastructure where possible (expression parser, printing
> Ken> routines, etc).
> 
> I have been skimming this patch a bit and I think it is very good.
> 
> I don't have time to fully review it right now, as I'm at the GCC
> Summit.

Thanks for having a look at the patch.
Have fun on the summit! : )

> > But I did notice one thing:
> 
> Ken> +/* Expression evaluator for the OpenCL.  Most operations are
> delegated to Ken> +   evaluate_subexp_standard; see that function for a
> description of the Ken> +   arguments.  */
> Ken> +static struct value *
> Ken> +evaluate_subexp_opencl (struct type *expect_type, struct expression
> *exp, Ken> +		   int *pos, enum noside noside)
> [...]
> Ken> +  return evaluate_subexp_standard (expect_type, exp, pos, noside);
> 
> I think this ought to call the C-specific evaluate_subexp_c.
> You'll need to at least make this non-static, maybe even rename it.
> 
> I believe that without this some forms of string constants will not work
> properly.

My understanding is that the only additional functionality of 
evaluate_subexp_c is to provide wide character support which is not available 
in OpenCL C. Of course calling evaluate_subexp_c won't hurt since 
evaluate_subexp_standard gets called in most cases but I don't see where the 
OpenCL support could benefit from doing so. Do you have an example?

Regards
Ken

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] initial OpenCL C language support
  2010-10-26 13:05   ` Ken Werner
@ 2010-10-26 13:44     ` Tom Tromey
  2010-10-26 16:02       ` Ken Werner
  0 siblings, 1 reply; 36+ messages in thread
From: Tom Tromey @ 2010-10-26 13:44 UTC (permalink / raw)
  To: Ken Werner; +Cc: gdb-patches

>>>>> "Ken" == Ken Werner <ken@linux.vnet.ibm.com> writes:

Ken> My understanding is that the only additional functionality of
Ken> evaluate_subexp_c is to provide wide character support which is not
Ken> available in OpenCL C. Of course calling evaluate_subexp_c won't
Ken> hurt since evaluate_subexp_standard gets called in most cases but I
Ken> don't see where the OpenCL support could benefit from doing so. Do
Ken> you have an example?

c-exp.y emits a different format for OP_STRING than other parsers.  It
uses write_exp_string_vector, not write_exp_string.  So I misspoke
earlier; I think no string constant will work properly without this
change.

Tom

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] initial OpenCL C language support
  2010-10-26 13:44     ` Tom Tromey
@ 2010-10-26 16:02       ` Ken Werner
  2010-10-26 17:49         ` Eli Zaretskii
  2010-10-26 19:58         ` Joel Brobecker
  0 siblings, 2 replies; 36+ messages in thread
From: Ken Werner @ 2010-10-26 16:02 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

[-- Attachment #1: Type: Text/Plain, Size: 602 bytes --]

On Tuesday, October 26, 2010 3:48:15 pm Tom Tromey wrote:
> c-exp.y emits a different format for OP_STRING than other parsers.  It
> uses write_exp_string_vector, not write_exp_string.  So I misspoke
> earlier; I think no string constant will work properly without this
> change.

I see - thanks. The attached patch changes evaluate_subexp_opencl to call the 
now non-static evaluate_subexp_c. I've also moved the OpenCL language 
detection from read_type_unit_scope to read_file_scope. The chunk was moved 
accidentally when I ported this patch from the 7.2 release to the current 
head.

Regards
Ken

[-- Attachment #2: opencl-lang.patch --]
[-- Type: text/x-patch, Size: 199085 bytes --]

ChangeLog:

2010-10-26  Ken Werner  <ken.werner@de.ibm.com>

	* 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.

testsuite/ChangeLog:

2010-10-26  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.


Index: src/gdb/defs.h
===================================================================
--- src.orig/gdb/defs.h	2010-10-26 17:54:58.000000000 +0200
+++ src/gdb/defs.h	2010-10-26 17:55:33.000000000 +0200
@@ -202,6 +202,7 @@ enum language
     language_pascal,		/* Pascal */
     language_ada,		/* Ada */
     language_scm,		/* Guile Scheme */
+    language_opencl,		/* OpenCL */
     language_minimal,		/* All other languages, minimal support only */
     nr_languages
   };
Index: src/gdb/dwarf2read.c
===================================================================
--- src.orig/gdb/dwarf2read.c	2010-10-26 17:55:33.000000000 +0200
+++ src/gdb/dwarf2read.c	2010-10-26 17:55:33.000000000 +0200
@@ -5089,6 +5089,12 @@ read_file_scope (struct die_info *die, s
   if (attr)
     cu->producer = DW_STRING (attr);
 
+  /* The XLCL doesn't generate DW_LANG_OpenCL because this attribute is not
+     standardised yet.  As a workaround for the language detection we fall
+     back to the DW_AT_producer string.  */
+  if (cu->producer && strstr (cu->producer, "IBM XL C for OpenCL") != NULL)
+    cu->language = language_opencl;
+
   /* We assume that we're processing GCC output. */
   processing_gcc_compilation = 2;
 
Index: src/gdb/opencl-lang.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/opencl-lang.c	2010-10-26 17:55:33.000000000 +0200
@@ -0,0 +1,1117 @@
+/* OpenCL language support for GDB, the GNU debugger.
+   Copyright (C) 2010 Free Software Foundation, Inc.
+
+   Contributed by Ken Werner <ken.werner@de.ibm.com>.
+
+   This file is part of GDB.
+
+   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/>.  */
+
+#include <string.h>
+#include "defs.h"
+#include "gdbtypes.h"
+#include "symtab.h"
+#include "expression.h"
+#include "parser-defs.h"
+#include "symtab.h"
+#include "language.h"
+#include "c-lang.h"
+#include "gdb_assert.h"
+
+extern void _initialize_opencl_language (void);
+
+/* This macro generates enum values from a given type.  */
+#define OCL_P_TYPE(TYPE)\
+  opencl_primitive_type_##TYPE,\
+  opencl_primitive_type_##TYPE##2,\
+  opencl_primitive_type_##TYPE##3,\
+  opencl_primitive_type_##TYPE##4,\
+  opencl_primitive_type_##TYPE##8,\
+  opencl_primitive_type_##TYPE##16
+
+enum opencl_primitive_types {
+  OCL_P_TYPE (char),
+  OCL_P_TYPE (uchar),
+  OCL_P_TYPE (short),
+  OCL_P_TYPE (ushort),
+  OCL_P_TYPE (int),
+  OCL_P_TYPE (uint),
+  OCL_P_TYPE (long),
+  OCL_P_TYPE (ulong),
+  OCL_P_TYPE (half),
+  OCL_P_TYPE (float),
+  OCL_P_TYPE (double),
+  opencl_primitive_type_bool,
+  opencl_primitive_type_unsigned_char,
+  opencl_primitive_type_unsigned_short,
+  opencl_primitive_type_unsigned_int,
+  opencl_primitive_type_unsigned_long,
+  opencl_primitive_type_size_t,
+  opencl_primitive_type_ptrdiff_t,
+  opencl_primitive_type_intptr_t,
+  opencl_primitive_type_uintptr_t,
+  opencl_primitive_type_void,
+  nr_opencl_primitive_types
+};
+
+/* This macro generates the type struct declarations from a given type.  */
+#define STRUCT_OCL_TYPE(TYPE)\
+  struct type *builtin_##TYPE;\
+  struct type *builtin_##TYPE##2;\
+  struct type *builtin_##TYPE##3;\
+  struct type *builtin_##TYPE##4;\
+  struct type *builtin_##TYPE##8;\
+  struct type *builtin_##TYPE##16
+
+struct builtin_opencl_type
+{
+  STRUCT_OCL_TYPE (char);
+  STRUCT_OCL_TYPE (uchar);
+  STRUCT_OCL_TYPE (short);
+  STRUCT_OCL_TYPE (ushort);
+  STRUCT_OCL_TYPE (int);
+  STRUCT_OCL_TYPE (uint);
+  STRUCT_OCL_TYPE (long);
+  STRUCT_OCL_TYPE (ulong);
+  STRUCT_OCL_TYPE (half);
+  STRUCT_OCL_TYPE (float);
+  STRUCT_OCL_TYPE (double);
+  struct type *builtin_bool;
+  struct type *builtin_unsigned_char;
+  struct type *builtin_unsigned_short;
+  struct type *builtin_unsigned_int;
+  struct type *builtin_unsigned_long;
+  struct type *builtin_size_t;
+  struct type *builtin_ptrdiff_t;
+  struct type *builtin_intptr_t;
+  struct type *builtin_uintptr_t;
+  struct type *builtin_void;
+};
+
+static struct gdbarch_data *opencl_type_data;
+
+const struct builtin_opencl_type *
+builtin_opencl_type (struct gdbarch *gdbarch)
+{
+  return gdbarch_data (gdbarch, opencl_type_data);
+}
+
+/* Returns the corresponding OpenCL vector type from the given type code,
+   the length of the element type, the unsigned flag and the amount of
+   elements (n).  */
+static struct type *
+lookup_opencl_vector_type (struct gdbarch *gdbarch, enum type_code code,
+			   unsigned int el_length, unsigned int flag_unsigned,
+			   int n)
+{
+  int i;
+  unsigned int length;
+  struct type *type = NULL;
+  struct type **types = (struct type **) builtin_opencl_type (gdbarch);
+
+  /* Check if n describes a valid OpenCL vector size (2, 3, 4, 8, 16).  */
+  if (n != 2 && n != 3 && n != 4 && n != 8 && n != 16)
+    error (_("Invalid OpenCL vector size: %d"), n);
+
+  /* Triple vectors have the size of a quad vector. */
+  length = (n == 3) ?  el_length * 4 : el_length * n;
+
+  for (i = 0; i < nr_opencl_primitive_types; i++)
+    {
+      LONGEST lowb, highb;
+
+      if (TYPE_CODE (types[i]) == TYPE_CODE_ARRAY && TYPE_VECTOR (types[i])
+	  && get_array_bounds (types[i], &lowb, &highb)
+	  && TYPE_CODE (TYPE_TARGET_TYPE (types[i])) == code
+	  && TYPE_UNSIGNED (TYPE_TARGET_TYPE (types[i])) == flag_unsigned
+	  && TYPE_LENGTH (TYPE_TARGET_TYPE (types[i])) == el_length
+	  && TYPE_LENGTH (types[i]) == length
+	  && highb - lowb + 1 == n)
+	{
+	  type = types[i];
+	  break;
+	}
+    }
+
+  return type;
+}
+
+/* Returns whether array contains duplicates or not within the first n number
+   of elements.  */
+static int
+array_has_dups (int arr[], int n)
+{
+  int i, j;
+
+  for (i = 0; i < n; i++)
+    {
+      for (j = i + 1; j < n; j++)
+        {
+          if (arr[i] == arr[j])
+            return 1;
+        }
+    }
+  return 0;
+}
+
+/* The OpenCL component access syntax allows to create lvalues referring to
+   selected elements of an original OpenCL vector in arbitrary order.  This
+   structure holds the information to describe such lvalues.  */
+struct lval_closure
+{
+  /* Reference count.  */
+  int refc;
+  /* The number of indicies.  */
+  int n;
+  /* The element indicies themselves.  */
+  int *indices;
+  /* A pointer to the original value.  */
+  struct value *val;
+};
+
+/* Allocates an instance of struct lval_closure.  */
+static struct lval_closure *
+allocate_lval_closure (int indices[], int n, struct value *val)
+{
+  struct lval_closure *c = XZALLOC (struct lval_closure);
+  c->refc = 1;
+  c->n = n;
+  c->indices = XCALLOC (n, int);
+  memcpy (c->indices, indices, n * sizeof (int));
+  value_incref (val); /* Increment the reference counter of the value.  */
+  c->val = val;
+  return c;
+}
+
+static void
+lval_func_read (struct value *v)
+{
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+  struct type *type = check_typedef (value_type (v));
+  struct type *eltype = TYPE_TARGET_TYPE (check_typedef (value_type (c->val)));
+  int offset = value_offset (v);
+  int elsize = TYPE_LENGTH (eltype);
+  int n, i, j = 0;
+  LONGEST lowb = 0;
+  LONGEST highb = 0;
+
+  if (TYPE_CODE (type) == TYPE_CODE_ARRAY
+      && !get_array_bounds (type, &lowb, &highb))
+    error (_("Could not determine the vector bounds"));
+
+  /* Assume elsize aligned offset.  */
+  gdb_assert (offset % elsize == 0);
+  offset /= elsize;
+  n = offset + highb - lowb + 1;
+  gdb_assert (n <= c->n);
+
+  for (i = offset; i < n; i++)
+    {
+      memcpy (value_contents_raw (v) + j++ * elsize,
+	      value_contents (c->val) + c->indices[i] * elsize,
+	      elsize);
+    }
+}
+
+static void
+lval_func_write (struct value *v, struct value *fromval)
+{
+  struct value *mark = value_mark ();
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+  struct type *type = check_typedef (value_type (v));
+  struct type *eltype = TYPE_TARGET_TYPE (check_typedef (value_type (c->val)));
+  int offset = value_offset (v);
+  int elsize = TYPE_LENGTH (eltype);
+  int n, i, j = 0;
+  LONGEST lowb = 0;
+  LONGEST highb = 0;
+
+  if (TYPE_CODE (type) == TYPE_CODE_ARRAY
+      && !get_array_bounds (type, &lowb, &highb))
+    error (_("Could not determine the vector bounds"));
+
+  /* Assume elsize aligned offset.  */
+  gdb_assert (offset % elsize == 0);
+  offset /= elsize;
+  n = offset + highb - lowb + 1;
+
+  /* Since accesses to the fourth component of a triple vector is undefined we
+     just skip writes to the fourth element.  Imagine something like this:
+       int3 i3 = (int3)(0, 1, 2);
+       i3.hi.hi = 5;
+     In this case n would be 4 (offset=12/4 + 1) while c->n would be 3.  */
+  if (n > c->n)
+    n = c->n;
+
+  for (i = offset; i < n; i++)
+    {
+      struct value *from_elm_val = allocate_value (eltype);
+      struct value *to_elm_val = value_subscript (c->val, c->indices[i]);
+      memcpy (value_contents_writeable (from_elm_val),
+	      value_contents (fromval) + j++ * elsize,
+	      elsize);
+      value_assign (to_elm_val, from_elm_val);
+    }
+  value_free_to_mark (mark);
+}
+
+/* Return 0 if any bit in v within offset and length is invalid, 1 if they are
+   all valid.  */
+static int
+lval_func_check_validity (const struct value *v, int offset, int length)
+{
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+  /* Size of the target type in bits.  */
+  int elsize =
+      TYPE_LENGTH (TYPE_TARGET_TYPE (check_typedef (value_type (c->val)))) * 8;
+  int startrest = offset % elsize;
+  int start = offset / elsize;
+  int endrest = (offset + length) % elsize;
+  int end = (offset + length) / elsize;
+  int i;
+
+  if (endrest)
+    end++;
+
+  if (end > c->n)
+    return 0;
+
+  for (i = start; i < end; i++)
+    {
+      int startoffset = (i == start) ? startrest : 0;
+      int length = (i == end) ? endrest : elsize;
+      if (!value_bits_valid (c->val, c->indices[i] * elsize + startoffset,
+			     length))
+	return 0;
+    }
+  return 1;
+}
+
+/* Return 1 if any bit in v is valid, 0 if they are all invalid.  */
+static int
+lval_func_check_any_valid (const struct value *v)
+{
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+  /* Size of the target type in bits.  */
+  int elsize =
+      TYPE_LENGTH (TYPE_TARGET_TYPE (check_typedef (value_type (c->val)))) * 8;
+  int i;
+
+  for (i = 0; i < c->n; i++)
+    {
+      if (value_bits_valid (c->val, c->indices[i] * elsize, elsize))
+	return 1;
+    }
+  return 0;
+}
+
+static void *
+lval_func_copy_closure (const struct value *v)
+{
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+  ++c->refc;
+  return c;
+}
+
+static void
+lval_func_free_closure (struct value *v)
+{
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+  --c->refc;
+  if (c->refc == 0)
+    {
+      xfree (c->indices);
+      xfree (c);
+      value_free (c->val); /* Decrement the reference counter of the value.  */
+    }
+}
+
+static struct lval_funcs opencl_value_funcs =
+  {
+    lval_func_read,
+    lval_func_write,
+    lval_func_check_validity,
+    lval_func_check_any_valid,
+    lval_func_copy_closure,
+    lval_func_free_closure
+  };
+
+/* Creates a sub-vector from VAL.  The elements are selected by the indices of
+   an array with the length of N.  Supported values for NOSIDE are
+   EVAL_NORMAL and EVAL_AVOID_SIDE_EFFECTS.  */
+static struct value *
+create_value (struct gdbarch *gdbarch, struct value *val, enum noside noside,
+	      int indices[], int n)
+{
+  struct type *type = check_typedef (value_type (val));
+  struct type *elm_type = TYPE_TARGET_TYPE (type);
+  struct value *ret;
+
+  /* Check if a single component of a vector is requested which means
+     the resulting type is a (primitive) scalar type.  */
+  if (n == 1)
+    {
+      if (noside == EVAL_AVOID_SIDE_EFFECTS)
+        ret = value_zero (elm_type, not_lval);
+      else
+        ret = value_subscript (val, indices[0]);
+    }
+  /* Multiple components of the vector are requested which means the
+     resulting type is a vector as well.  */
+  else
+    {
+      struct type *dst_type =
+	lookup_opencl_vector_type (gdbarch, TYPE_CODE (elm_type),
+				   TYPE_LENGTH (elm_type),
+				   TYPE_UNSIGNED (elm_type), n);
+
+      if (dst_type == NULL)
+	dst_type = init_vector_type (elm_type, n);
+
+      make_cv_type (TYPE_CONST (type), TYPE_VOLATILE (type), dst_type, NULL);
+
+      if (noside == EVAL_AVOID_SIDE_EFFECTS)
+	ret = allocate_value (dst_type);
+      else
+	{
+	  /* Check whether to create a lvalue or not.  */
+	  if (VALUE_LVAL (val) != not_lval && !array_has_dups (indices, n))
+	    {
+	      struct lval_closure *c = allocate_lval_closure (indices, n, val);
+	      ret = allocate_computed_value (dst_type, &opencl_value_funcs, c);
+	    }
+	  else
+	    {
+	      int i;
+	      ret = allocate_value (dst_type);
+	      for (i = 0; i < n; i++)
+		{
+		  /* Copy src val contents into the destination value.  */
+		  memcpy (value_contents_writeable (ret)
+			  + (i * TYPE_LENGTH (elm_type)),
+			  value_contents (val)
+			  + (indices[i] * TYPE_LENGTH (elm_type)),
+			  TYPE_LENGTH (elm_type));
+		}
+	    }
+	}
+    }
+  return ret;
+}
+
+/* OpenCL vector component access.  */
+static struct value *
+opencl_component_ref (struct expression *exp, struct value *val, char *comps,
+		      enum noside noside)
+{
+  LONGEST lowb, highb;
+  int src_len;
+  struct value *v;
+  int indices[16], i;
+  int dst_len;
+
+  if (!get_array_bounds (check_typedef (value_type (val)), &lowb, &highb))
+    error (_("Could not determine the vector bounds"));
+
+  src_len = highb - lowb + 1;
+
+  /* Throw an error if the amount of array elements does not fit a
+     valid OpenCL vector size (2, 3, 4, 8, 16).  */
+  if (src_len != 2 && src_len != 3 && src_len != 4 && src_len != 8
+      && src_len != 16)
+    error (_("Invalid OpenCL vector size"));
+
+  if (strcmp (comps, "lo") == 0 )
+    {
+      dst_len = (src_len == 3) ? 2 : src_len / 2;
+      for (i = 0; i < dst_len; i++)
+	indices[i] = i;
+    }
+  else if (strcmp (comps, "hi") == 0)
+    {
+      dst_len = (src_len == 3) ? 2 : src_len / 2;
+      for (i = 0; i < dst_len; i++)
+	indices[i] = dst_len + i;
+    }
+  else if (strcmp (comps, "even") == 0)
+    {
+      dst_len = (src_len == 3) ? 2 : src_len / 2;
+      for (i = 0; i < dst_len; i++)
+	indices[i] = i*2;
+    }
+  else if (strcmp (comps, "odd") == 0)
+    {
+      dst_len = (src_len == 3) ? 2 : src_len / 2;
+      for (i = 0; i < dst_len; i++)
+        indices[i] = i*2+1;
+    }
+  else if (strncasecmp (comps, "s", 1) == 0)
+    {
+#define HEXCHAR_TO_INT(C) ((C >= '0' && C <= '9') ? \
+                           C-'0' : ((C >= 'A' && C <= 'F') ? \
+                           C-'A'+10 : ((C >= 'a' && C <= 'f') ? \
+                           C-'a'+10 : -1)))
+
+      dst_len = strlen (comps);
+      /* Skip the s/S-prefix.  */
+      dst_len--;
+
+      for (i = 0; i < dst_len; i++)
+	{
+	  indices[i] = HEXCHAR_TO_INT(comps[i+1]);
+	  /* Check if the requested component is invalid or exceeds
+	     the vector.  */
+	  if (indices[i] < 0 || indices[i] >= src_len)
+	    error (_("Invalid OpenCL vector component accessor %s"), comps);
+	}
+    }
+  else
+    {
+      dst_len = strlen (comps);
+
+      for (i = 0; i < dst_len; i++)
+	{
+	  /* x, y, z, w */
+	  switch (comps[i])
+	  {
+	  case 'x':
+	    indices[i] = 0;
+	    break;
+	  case 'y':
+	    indices[i] = 1;
+	    break;
+	  case 'z':
+	    if (src_len < 3)
+	      error (_("Invalid OpenCL vector component accessor %s"), comps);
+	    indices[i] = 2;
+	    break;
+	  case 'w':
+	    if (src_len < 4)
+	      error (_("Invalid OpenCL vector component accessor %s"), comps);
+	    indices[i] = 3;
+	    break;
+	  default:
+	    error (_("Invalid OpenCL vector component accessor %s"), comps);
+	    break;
+	  }
+	}
+    }
+
+  /* Throw an error if the amount of requested components does not
+     result in a valid length (1, 2, 3, 4, 8, 16).  */
+  if (dst_len != 1 && dst_len != 2 && dst_len != 3 && dst_len != 4
+      && dst_len != 8 && dst_len != 16)
+    error (_("Invalid OpenCL vector component accessor %s"), comps);
+
+  v = create_value (exp->gdbarch, val, noside, indices, dst_len);
+  return v;
+}
+
+/* Perform the unary logical not (!) operation.  */
+static struct value *
+opencl_logical_not (struct expression *exp, struct value *arg)
+{
+  struct type *type = check_typedef (value_type (arg));
+  struct type *rettype;
+  struct value *ret;
+
+  if (TYPE_CODE (type) == TYPE_CODE_ARRAY && TYPE_VECTOR (type))
+    {
+      struct type *eltype = check_typedef (TYPE_TARGET_TYPE (type));
+      LONGEST lowb, highb;
+      int i;
+
+      if (!get_array_bounds (type, &lowb, &highb))
+	error (_("Could not determine the vector bounds"));
+
+      /* Determine the resulting type of the operation and allocate the
+	 value.  */
+      rettype = lookup_opencl_vector_type (exp->gdbarch, TYPE_CODE_INT,
+					   TYPE_LENGTH (eltype), 0,
+					   highb - lowb + 1);
+      ret = allocate_value (rettype);
+
+      for (i = 0; i < highb - lowb + 1; i++)
+	{
+	  /* For vector types, the unary operator shall return a 0 if the
+	  value of its operand compares unequal to 0, and -1 (i.e. all bits
+	  set) if the value of its operand compares equal to 0.  */
+	  int tmp = value_logical_not (value_subscript (arg, i)) ? -1 : 0;
+	  memset (value_contents_writeable (ret) + i * TYPE_LENGTH (eltype),
+		  tmp, TYPE_LENGTH (eltype));
+	}
+    }
+  else
+    {
+      rettype = language_bool_type (exp->language_defn, exp->gdbarch);
+      ret = value_from_longest (rettype, value_logical_not (arg));
+    }
+  return ret;
+}
+
+/* Perform a relational operation on two scalar operands.  */
+static int
+scalar_relop (struct value *val1, struct value *val2, enum exp_opcode op)
+{
+  int ret;
+  switch (op)
+    {
+    case BINOP_EQUAL:
+      ret = value_equal (val1, val2);
+      break;
+    case BINOP_NOTEQUAL:
+      ret = ! value_equal (val1, val2);
+      break;
+    case BINOP_LESS:
+      ret = value_less (val1, val2);
+      break;
+    case BINOP_GTR:
+      ret = value_less (val2, val1);
+      break;
+    case BINOP_GEQ:
+      ret = value_less (val2, val1) || value_equal (val1, val2);
+      break;
+    case BINOP_LEQ:
+      ret = value_less (val1, val2) || value_equal (val1, val2);
+      break;
+    case BINOP_LOGICAL_AND:
+      ret = !value_logical_not (val1) && !value_logical_not (val2);
+      break;
+    case BINOP_LOGICAL_OR:
+      ret = !value_logical_not (val1) || !value_logical_not (val2);
+      break;
+    default:
+      error (_("Attempt to perform an unsupported operation"));
+      break;
+    }
+  return ret;
+}
+
+/* Perform a relational operation on two vector operands.  */
+static struct value *
+vector_relop (struct expression *exp, struct value *val1, struct value *val2,
+	      enum exp_opcode op)
+{
+  struct value *ret;
+  struct type *type1, *type2, *eltype1, *eltype2, *rettype;
+  int t1_is_vec, t2_is_vec, i;
+  LONGEST lowb1, lowb2, highb1, highb2;
+
+  type1 = check_typedef (value_type (val1));
+  type2 = check_typedef (value_type (val2));
+
+  t1_is_vec = (TYPE_CODE (type1) == TYPE_CODE_ARRAY && TYPE_VECTOR (type1));
+  t2_is_vec = (TYPE_CODE (type2) == TYPE_CODE_ARRAY && TYPE_VECTOR (type2));
+
+  if (!t1_is_vec || !t2_is_vec)
+    error (_("Vector operations are not supported on scalar types"));
+
+  eltype1 = check_typedef (TYPE_TARGET_TYPE (type1));
+  eltype2 = check_typedef (TYPE_TARGET_TYPE (type2));
+
+  if (!get_array_bounds (type1,&lowb1, &highb1)
+      || !get_array_bounds (type2, &lowb2, &highb2))
+    error (_("Could not determine the vector bounds"));
+
+  /* Check whether the vector types are compatible.  */
+  if (TYPE_CODE (eltype1) != TYPE_CODE (eltype2)
+      || TYPE_LENGTH (eltype1) != TYPE_LENGTH (eltype2)
+      || TYPE_UNSIGNED (eltype1) != TYPE_UNSIGNED (eltype2)
+      || lowb1 != lowb2 || highb1 != highb2)
+    error (_("Cannot perform operation on vectors with different types"));
+
+  /* Determine the resulting type of the operation and allocate the value.  */
+  rettype = lookup_opencl_vector_type (exp->gdbarch, TYPE_CODE_INT,
+				       TYPE_LENGTH (eltype1), 0,
+				       highb1 - lowb1 + 1);
+  ret = allocate_value (rettype);
+
+  for (i = 0; i < highb1 - lowb1 + 1; i++)
+    {
+      /* For vector types, the relational, equality and logical operators shall
+	 return 0 if the specified relation is false and -1 (i.e. all bits set)
+	 if the specified relation is true.  */
+      int tmp = scalar_relop (value_subscript (val1, i),
+			      value_subscript (val2, i), op) ? -1 : 0;
+      memset (value_contents_writeable (ret) + i * TYPE_LENGTH (eltype1),
+	      tmp, TYPE_LENGTH (eltype1));
+     }
+
+  return ret;
+}
+
+/* Perform a relational operation on two operands.  */
+static struct value *
+opencl_relop (struct expression *exp, struct value *arg1, struct value *arg2,
+	      enum exp_opcode op)
+{
+  struct value *val;
+  struct type *type1 = check_typedef (value_type (arg1));
+  struct type *type2 = check_typedef (value_type (arg2));
+  int t1_is_vec = (TYPE_CODE (type1) == TYPE_CODE_ARRAY
+		   && TYPE_VECTOR (type1));
+  int t2_is_vec = (TYPE_CODE (type2) == TYPE_CODE_ARRAY
+		   && TYPE_VECTOR (type2));
+
+  if (!t1_is_vec && !t2_is_vec)
+    {
+      int tmp = scalar_relop (arg1, arg2, op);
+      struct type *type =
+	language_bool_type (exp->language_defn, exp->gdbarch);
+      val = value_from_longest (type, tmp);
+    }
+  else if (t1_is_vec && t2_is_vec)
+    {
+      val = vector_relop (exp, arg1, arg2, op);
+    }
+  else
+    {
+      /* Widen the scalar operand to a vector.  */
+      struct value **v = t1_is_vec ? &arg2 : &arg1;
+      struct type *t = t1_is_vec ? type2 : type1;
+
+      if (TYPE_CODE (t) != TYPE_CODE_FLT && !is_integral_type (t))
+	error (_("Argument to operation not a number or boolean."));
+
+      *v = value_cast (t1_is_vec ? type1 : type2, *v);
+      val = vector_relop (exp, arg1, arg2, op);
+    }
+
+  return val;
+}
+
+/* Expression evaluator for the OpenCL.  Most operations are delegated to
+   evaluate_subexp_standard; see that function for a description of the
+   arguments.  */
+static struct value *
+evaluate_subexp_opencl (struct type *expect_type, struct expression *exp,
+		   int *pos, enum noside noside)
+{
+  enum exp_opcode op = exp->elts[*pos].opcode;
+  struct value *arg1 = NULL;
+  struct value *arg2 = NULL;
+  struct type *type1, *type2;
+
+  switch (op)
+    {
+    /* Handle binary relational and equality operators that are either not
+       or differently defined for GNU vectors.  */
+    case BINOP_EQUAL:
+    case BINOP_NOTEQUAL:
+    case BINOP_LESS:
+    case BINOP_GTR:
+    case BINOP_GEQ:
+    case BINOP_LEQ:
+      (*pos)++;
+      arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+      arg2 = evaluate_subexp (value_type (arg1), exp, pos, noside);
+
+      if (noside == EVAL_SKIP)
+	return value_from_longest (builtin_type (exp->gdbarch)->
+				   builtin_int, 1);
+      return opencl_relop (exp, arg1, arg2, op);
+    /* Handle the logical unary operator not(!).  */
+    case UNOP_LOGICAL_NOT:
+      (*pos)++;
+      arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+
+      if (noside == EVAL_SKIP)
+	return value_from_longest (builtin_type (exp->gdbarch)->
+				   builtin_int, 1);
+      return opencl_logical_not (exp, arg1);
+    /* Handle the logical operator and(&&) and or(||).  */
+    case BINOP_LOGICAL_AND:
+    case BINOP_LOGICAL_OR:
+      (*pos)++;
+      arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+
+      if (noside == EVAL_SKIP)
+	{
+	  arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	  return value_from_longest (builtin_type (exp->gdbarch)->
+				     builtin_int, 1);
+	}
+      else
+	{
+	  /* For scalar operations we need to avoid evaluating operands
+	     unecessarily.  However, for vector operations we always need to
+	     evaluate both operands.  Unfortunately we only know which of the
+	     two cases apply after we know the type of the second operand.
+	     Therefore we evaluate it once using EVAL_AVOID_SIDE_EFFECTS.  */
+	  int oldpos = *pos;
+	  arg2 = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
+	  *pos = oldpos;
+	  type1 = check_typedef (value_type (arg1));
+	  type2 = check_typedef (value_type (arg2));
+
+	  if ((TYPE_CODE (type1) == TYPE_CODE_ARRAY && TYPE_VECTOR (type1))
+	      || (TYPE_CODE (type2) == TYPE_CODE_ARRAY && TYPE_VECTOR (type2)))
+	    {
+	      arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	      return opencl_relop (exp, arg1, arg2, op);
+	    }
+	  else
+	    {
+	      /* For scalar built-in types, only evaluate the right
+		 hand operand if the left hand operand compares
+		 unequal(&&)/equal(||) to 0.  */
+	      int res;
+	      int tmp = value_logical_not (arg1);
+
+	      if (op == BINOP_LOGICAL_OR)
+		tmp = !tmp;
+
+	      arg2 = evaluate_subexp (NULL_TYPE, exp, pos,
+				      tmp ? EVAL_SKIP : noside);
+	      type1 = language_bool_type (exp->language_defn, exp->gdbarch);
+
+	      if (op == BINOP_LOGICAL_AND)
+		res = !tmp && !value_logical_not (arg2);
+	      else /* BINOP_LOGICAL_OR */
+		res = tmp || !value_logical_not (arg2);
+
+	      return value_from_longest (type1, res);
+	    }
+	}
+    /* Handle the ternary selection operator.  */
+    case TERNOP_COND:
+      (*pos)++;
+      arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+      type1 = check_typedef (value_type (arg1));
+      if (TYPE_CODE (type1) == TYPE_CODE_ARRAY && TYPE_VECTOR (type1))
+	{
+	  struct value *arg3, *tmp, *ret;
+	  struct type *eltype2, *type3, *eltype3;
+	  int t2_is_vec, t3_is_vec, i;
+	  LONGEST lowb1, lowb2, lowb3, highb1, highb2, highb3;
+
+	  arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	  arg3 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	  type2 = check_typedef (value_type (arg2));
+	  type3 = check_typedef (value_type (arg3));
+	  t2_is_vec
+	    = TYPE_CODE (type2) == TYPE_CODE_ARRAY && TYPE_VECTOR (type2);
+	  t3_is_vec
+	    = TYPE_CODE (type3) == TYPE_CODE_ARRAY && TYPE_VECTOR (type3);
+
+	  /* Widen the scalar operand to a vector if necessary.  */
+	  if (t2_is_vec || !t3_is_vec)
+	    {
+	      arg3 = value_cast (type2, arg3);
+	      type3 = value_type (arg3);
+	    }
+	  else if (!t2_is_vec || t3_is_vec)
+	    {
+	      arg2 = value_cast (type3, arg2);
+	      type2 = value_type (arg2);
+	    }
+	  else if (!t2_is_vec || !t3_is_vec)
+	    {
+	      /* Throw an error if arg2 or arg3 aren't vecors.  */
+	      error (_("\
+Cannot perform conditional operation on incompatible types"));
+	    }
+
+	  eltype2 = check_typedef (TYPE_TARGET_TYPE (type2));
+	  eltype3 = check_typedef (TYPE_TARGET_TYPE (type3));
+
+	  if (!get_array_bounds (type1, &lowb1, &highb1)
+	      || !get_array_bounds (type2, &lowb2, &highb2)
+	      || !get_array_bounds (type3, &lowb3, &highb3))
+	    error (_("Could not determine the vector bounds"));
+
+	  /* Throw an error if the types of arg2 or arg3 are incompatible.  */
+	  if (TYPE_CODE (eltype2) != TYPE_CODE (eltype3)
+	      || TYPE_LENGTH (eltype2) != TYPE_LENGTH (eltype3)
+	      || TYPE_UNSIGNED (eltype2) != TYPE_UNSIGNED (eltype3)
+	      || lowb2 != lowb3 || highb2 != highb3)
+	    error (_("\
+Cannot perform operation on vectors with different types"));
+
+	  /* Throw an error if the sizes of arg1 and arg2/arg3 differ.  */
+	  if (lowb1 != lowb2 || lowb1 != lowb3
+	      || highb1 != highb2 || highb1 != highb3)
+	    error (_("\
+Cannot perform conditional operation on vectors with different sizes"));
+
+	  ret = allocate_value (type2);
+	  for (i = 0; i < highb1 - lowb1 + 1; i++)
+	    {
+	      tmp = value_logical_not (value_subscript (arg1, i)) ?
+		    value_subscript (arg3, i) : value_subscript (arg2, i);
+	      memcpy (value_contents_writeable (ret) +
+		      i * TYPE_LENGTH (eltype2), value_contents_all (tmp),
+		      TYPE_LENGTH (eltype2));
+	    }
+	  return ret;
+	}
+      else
+	{
+	  if (value_logical_not (arg1))
+	    {
+	      /* Skip the second operand.  */
+	      evaluate_subexp (NULL_TYPE, exp, pos, EVAL_SKIP);
+	      return evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	    }
+	  else
+	    {
+	      /* Skip the third operand.  */
+	      arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	      evaluate_subexp (NULL_TYPE, exp, pos, EVAL_SKIP);
+	      return arg2;
+	    }
+	}
+    /* Handle STRUCTOP_STRUCT to allow component access on OpenCL vectors.  */
+    case STRUCTOP_STRUCT:
+      {
+	int pc = (*pos)++;
+	int tem = longest_to_int (exp->elts[pc + 1].longconst);
+
+	(*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
+	arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	type1 = check_typedef (value_type (arg1));
+
+	if (noside == EVAL_SKIP)
+	  {
+	    return value_from_longest (builtin_type (exp->gdbarch)->
+				       builtin_int, 1);
+	  }
+	else if (TYPE_CODE (type1) == TYPE_CODE_ARRAY && TYPE_VECTOR (type1))
+	  {
+	    return opencl_component_ref (exp, arg1, &exp->elts[pc + 2].string,
+					 noside);
+	  }
+	else
+	  {
+	    if (noside == EVAL_AVOID_SIDE_EFFECTS)
+	      return
+		  value_zero (lookup_struct_elt_type
+			      (value_type (arg1),&exp->elts[pc + 2].string, 0),
+			      lval_memory);
+	    else
+	      return value_struct_elt (&arg1, NULL,
+				       &exp->elts[pc + 2].string, NULL,
+				       "structure");
+	  }
+      }
+    default:
+      break;
+    }
+  return evaluate_subexp_c (expect_type, exp, pos, noside);
+}
+
+void
+opencl_language_arch_info (struct gdbarch *gdbarch,
+		      struct language_arch_info *lai)
+{
+  const struct builtin_opencl_type *builtin = builtin_opencl_type (gdbarch);
+
+  lai->string_char_type = builtin->builtin_char;
+  lai->primitive_type_vector
+    = GDBARCH_OBSTACK_CALLOC (gdbarch, nr_opencl_primitive_types + 1,
+			      struct type *);
+
+/* This macro fills the primitive_type_vector from a given type.  */
+#define FILL_TYPE_VECTOR(LAI, TYPE)\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE]\
+    = builtin->builtin_##TYPE;\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE##2]\
+    = builtin->builtin_##TYPE##2;\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE##3]\
+    = builtin->builtin_##TYPE##3;\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE##4]\
+    = builtin->builtin_##TYPE##4;\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE##8]\
+    = builtin->builtin_##TYPE##8;\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE##16]\
+    = builtin->builtin_##TYPE##16
+
+  FILL_TYPE_VECTOR (lai, char);
+  FILL_TYPE_VECTOR (lai, uchar);
+  FILL_TYPE_VECTOR (lai, short);
+  FILL_TYPE_VECTOR (lai, ushort);
+  FILL_TYPE_VECTOR (lai, int);
+  FILL_TYPE_VECTOR (lai, uint);
+  FILL_TYPE_VECTOR (lai, long);
+  FILL_TYPE_VECTOR (lai, ulong);
+  FILL_TYPE_VECTOR (lai, half);
+  FILL_TYPE_VECTOR (lai, float);
+  FILL_TYPE_VECTOR (lai, double);
+  lai->primitive_type_vector [opencl_primitive_type_bool]
+    = builtin->builtin_bool;
+  lai->primitive_type_vector [opencl_primitive_type_unsigned_char]
+    = builtin->builtin_unsigned_char;
+  lai->primitive_type_vector [opencl_primitive_type_unsigned_short]
+    = builtin->builtin_unsigned_short;
+  lai->primitive_type_vector [opencl_primitive_type_unsigned_int]
+    = builtin->builtin_unsigned_int;
+  lai->primitive_type_vector [opencl_primitive_type_unsigned_long]
+    = builtin->builtin_unsigned_long;
+  lai->primitive_type_vector [opencl_primitive_type_half]
+    = builtin->builtin_half;
+  lai->primitive_type_vector [opencl_primitive_type_size_t]
+    = builtin->builtin_size_t;
+  lai->primitive_type_vector [opencl_primitive_type_ptrdiff_t]
+    = builtin->builtin_ptrdiff_t;
+  lai->primitive_type_vector [opencl_primitive_type_intptr_t]
+    = builtin->builtin_intptr_t;
+  lai->primitive_type_vector [opencl_primitive_type_uintptr_t]
+    = builtin->builtin_uintptr_t;
+  lai->primitive_type_vector [opencl_primitive_type_void]
+    = builtin->builtin_void;
+
+  /* Specifies the return type of logical and relational operations.  */
+  lai->bool_type_symbol = "int";
+  lai->bool_type_default = builtin->builtin_int;
+}
+
+const struct exp_descriptor exp_descriptor_opencl =
+{
+  print_subexp_standard,
+  operator_length_standard,
+  operator_check_standard,
+  op_name_standard,
+  dump_subexp_body_standard,
+  evaluate_subexp_opencl
+};
+
+const struct language_defn opencl_language_defn =
+{
+  "opencl",			/* Language name */
+  language_opencl,
+  range_check_off,
+  type_check_off,
+  case_sensitive_on,
+  array_row_major,
+  macro_expansion_c,
+  &exp_descriptor_opencl,
+  c_parse,
+  c_error,
+  null_post_parser,
+  c_printchar,			/* Print a character constant */
+  c_printstr,			/* Function to print string constant */
+  c_emit_char,			/* Print a single char */
+  c_print_type,			/* Print a type using appropriate syntax */
+  c_print_typedef,		/* Print a typedef using appropriate syntax */
+  c_val_print,			/* Print a value using appropriate syntax */
+  c_value_print,		/* Print a top-level value */
+  NULL,				/* Language specific skip_trampoline */
+  NULL,                         /* name_of_this */
+  basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
+  basic_lookup_transparent_type,/* lookup_transparent_type */
+  NULL,				/* Language specific symbol demangler */
+  NULL,				/* Language specific class_name_from_physname */
+  c_op_print_tab,		/* expression operators for printing */
+  1,				/* c-style arrays */
+  0,				/* String lower bound */
+  default_word_break_characters,
+  default_make_symbol_completion_list,
+  opencl_language_arch_info,
+  default_print_array_index,
+  default_pass_by_reference,
+  c_get_string,
+  LANG_MAGIC
+};
+
+static void *
+build_opencl_types (struct gdbarch *gdbarch)
+{
+  struct builtin_opencl_type *builtin_opencl_type
+    = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct builtin_opencl_type);
+
+/* Helper macro to create strings.  */
+#define STRINGIFY(S) #S
+/* This macro allocates and assigns the type struct pointers
+   for the vector types.  */
+#define BUILD_OCL_VTYPES(TYPE)\
+  builtin_opencl_type->builtin_##TYPE##2\
+    = init_vector_type (builtin_opencl_type->builtin_##TYPE, 2);\
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##2) = STRINGIFY(TYPE ## 2);\
+  builtin_opencl_type->builtin_##TYPE##3\
+    = init_vector_type (builtin_opencl_type->builtin_##TYPE, 3);\
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##3) = STRINGIFY(TYPE ## 3);\
+  TYPE_LENGTH (builtin_opencl_type->builtin_##TYPE##3)\
+    = 4 * TYPE_LENGTH (builtin_opencl_type->builtin_##TYPE);\
+  builtin_opencl_type->builtin_##TYPE##4\
+    = init_vector_type (builtin_opencl_type->builtin_##TYPE, 4);\
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##4) = STRINGIFY(TYPE ## 4);\
+  builtin_opencl_type->builtin_##TYPE##8\
+    = init_vector_type (builtin_opencl_type->builtin_##TYPE, 8);\
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##8) = STRINGIFY(TYPE ## 8);\
+  builtin_opencl_type->builtin_##TYPE##16\
+    = init_vector_type (builtin_opencl_type->builtin_##TYPE, 16);\
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##16) = STRINGIFY(TYPE ## 16)
+
+  builtin_opencl_type->builtin_char
+    = arch_integer_type (gdbarch, 8, 0, "char");
+  BUILD_OCL_VTYPES (char);
+  builtin_opencl_type->builtin_uchar
+    = arch_integer_type (gdbarch, 8, 1, "uchar");
+  BUILD_OCL_VTYPES (uchar);
+  builtin_opencl_type->builtin_short
+    = arch_integer_type (gdbarch, 16, 0, "short");
+  BUILD_OCL_VTYPES (short);
+  builtin_opencl_type->builtin_ushort
+    = arch_integer_type (gdbarch, 16, 1, "ushort");
+  BUILD_OCL_VTYPES (ushort);
+  builtin_opencl_type->builtin_int
+    = arch_integer_type (gdbarch, 32, 0, "int");
+  BUILD_OCL_VTYPES (int);
+  builtin_opencl_type->builtin_uint
+    = arch_integer_type (gdbarch, 32, 1, "uint");
+  BUILD_OCL_VTYPES (uint);
+  builtin_opencl_type->builtin_long
+    = arch_integer_type (gdbarch, 64, 0, "long");
+  BUILD_OCL_VTYPES (long);
+  builtin_opencl_type->builtin_ulong
+    = arch_integer_type (gdbarch, 64, 1, "ulong");
+  BUILD_OCL_VTYPES (ulong);
+  builtin_opencl_type->builtin_half
+    = arch_float_type (gdbarch, 16, "half", floatformats_ieee_half);
+  BUILD_OCL_VTYPES (half);
+  builtin_opencl_type->builtin_float
+    = arch_float_type (gdbarch, 32, "float", floatformats_ieee_single);
+  BUILD_OCL_VTYPES (float);
+  builtin_opencl_type->builtin_double
+    = arch_float_type (gdbarch, 64, "double", floatformats_ieee_double);
+  BUILD_OCL_VTYPES (double);
+  builtin_opencl_type->builtin_bool
+    = arch_boolean_type (gdbarch, 32, 1, "bool");
+  builtin_opencl_type->builtin_unsigned_char
+    = arch_integer_type (gdbarch, 8, 1, "unsigned char");
+  builtin_opencl_type->builtin_unsigned_short
+    = arch_integer_type (gdbarch, 16, 1, "unsigned short");
+  builtin_opencl_type->builtin_unsigned_int
+    = arch_integer_type (gdbarch, 32, 1, "unsigned int");
+  builtin_opencl_type->builtin_unsigned_long
+    = arch_integer_type (gdbarch, 64, 1, "unsigned long");
+  builtin_opencl_type->builtin_size_t
+    = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 1, "size_t");
+  builtin_opencl_type->builtin_ptrdiff_t
+    = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 0, "ptrdiff_t");
+  builtin_opencl_type->builtin_intptr_t
+    = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 0, "intptr_t");
+  builtin_opencl_type->builtin_uintptr_t
+    = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 1, "uintptr_t");
+  builtin_opencl_type->builtin_void
+    = arch_type (gdbarch, TYPE_CODE_VOID, 1, "void");
+  return builtin_opencl_type;
+}
+
+void
+_initialize_opencl_language (void)
+{
+  opencl_type_data = gdbarch_data_register_post_init (build_opencl_types);
+  add_language (&opencl_language_defn);
+}
Index: src/gdb/Makefile.in
===================================================================
--- src.orig/gdb/Makefile.in	2010-10-26 17:54:58.000000000 +0200
+++ src/gdb/Makefile.in	2010-10-26 17:55:33.000000000 +0200
@@ -689,6 +689,7 @@ SFILES = ada-exp.y ada-lang.c ada-typepr
 	mi/mi-common.c \
 	objc-exp.y objc-lang.c \
 	objfiles.c osabi.c observer.c osdata.c \
+	opencl-lang.c \
 	p-exp.y p-lang.c p-typeprint.c p-valprint.c parse.c printcmd.c \
 	proc-service.list progspace.c \
 	prologue-value.c psymtab.c \
@@ -846,7 +847,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $
 	ui-out.o cli-out.o \
 	varobj.o vec.o wrapper.o \
 	jv-lang.o jv-valprint.o jv-typeprint.o \
-	m2-lang.o p-lang.o p-typeprint.o p-valprint.o \
+	m2-lang.o opencl-lang.o p-lang.o p-typeprint.o p-valprint.o \
 	scm-exp.o scm-lang.o scm-valprint.o \
 	sentinel-frame.o \
 	complaints.o typeprint.o \
Index: src/gdb/eval.c
===================================================================
--- src.orig/gdb/eval.c	2010-10-26 17:55:32.000000000 +0200
+++ src/gdb/eval.c	2010-10-26 17:55:33.000000000 +0200
@@ -603,6 +603,7 @@ binop_promote (const struct language_def
 	case language_cplus:
 	case language_asm:
 	case language_objc:
+	case language_opencl:
 	  /* No promotion required.  */
 	  break;
 
@@ -690,7 +691,24 @@ binop_promote (const struct language_def
 			       : builtin->builtin_long_long);
 	    }
 	  break;
-
+	case language_opencl:
+	  if (result_len <= TYPE_LENGTH (lookup_signed_typename
+					 (language, gdbarch, "int")))
+	    {
+	      promoted_type =
+		(unsigned_operation
+		 ? lookup_unsigned_typename (language, gdbarch, "int")
+		 : lookup_signed_typename (language, gdbarch, "int"));
+	    }
+	  else if (result_len <= TYPE_LENGTH (lookup_signed_typename
+					      (language, gdbarch, "long")))
+	    {
+	      promoted_type =
+		(unsigned_operation
+		 ? lookup_unsigned_typename (language, gdbarch, "long")
+		 : lookup_signed_typename (language, gdbarch,"long"));
+	    }
+	  break;
 	default:
 	  /* For other languages the result type is unchanged from gdb
 	     version 6.7 for backward compatibility.
Index: src/gdb/testsuite/gdb.base/default.exp
===================================================================
--- src.orig/gdb/testsuite/gdb.base/default.exp	2010-10-26 17:54:59.000000000 +0200
+++ src/gdb/testsuite/gdb.base/default.exp	2010-10-26 17:55:33.000000000 +0200
@@ -527,7 +527,7 @@ gdb_test "set history size" "Argument re
 #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, scheme." "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, scheme." "set language"
 #test set listsize
 gdb_test "set listsize" "Argument required .integer to set it to.*" "set listsize"
 #test set print "p" abbreviation
Index: src/gdb/testsuite/Makefile.in
===================================================================
--- src.orig/gdb/testsuite/Makefile.in	2010-10-26 17:54:58.000000000 +0200
+++ src/gdb/testsuite/Makefile.in	2010-10-26 17:55:33.000000000 +0200
@@ -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 \
Index: src/gdb/testsuite/configure
===================================================================
--- src.orig/gdb/testsuite/configure	2010-10-26 17:54:59.000000000 +0200
+++ src/gdb/testsuite/configure	2010-10-26 17:55:33.000000000 +0200
@@ -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
Index: src/gdb/testsuite/configure.ac
===================================================================
--- src.orig/gdb/testsuite/configure.ac	2010-10-26 17:54:59.000000000 +0200
+++ src/gdb/testsuite/configure.ac	2010-10-26 17:55:33.000000000 +0200
@@ -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])
Index: src/gdb/testsuite/gdb.opencl/Makefile.in
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/Makefile.in	2010-10-26 17:55:33.000000000 +0200
@@ -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.*
Index: src/gdb/testsuite/gdb.opencl/datatypes.cl
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/datatypes.cl	2010-10-26 17:55:33.000000000 +0200
@@ -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;
+}
Index: src/gdb/testsuite/gdb.opencl/datatypes.exp
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/datatypes.exp	2010-10-26 17:55:33.000000000 +0200
@@ -0,0 +1,475 @@
+# 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 bin ${objdir}/${subdir}/${testfile}
+set clprogram [remote_download target ${srcdir}/${subdir}/${testfile}.cl]
+
+# Increase timeout
+set timeout 60
+verbose "Timeout set to $timeout seconds" 2
+
+# Compile the generic OpenCL host app
+if { [gdb_compile_opencl_hostapp "${clprogram}" "${bin}" "" ] != "" } {
+    untested ${testfile}.exp
+    return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
+# 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)" "\\\$$decimal = 4"
+
+gdb_test "whatis char" "type = char"
+gdb_test "p sizeof(char)" "\\\$$decimal = 1"
+gdb_test "whatis char2" "type = char2"
+gdb_test "p sizeof(char2)" "\\\$$decimal = 2"
+gdb_test "whatis char3" "type = char3"
+gdb_test "p sizeof(char3)" "\\\$$decimal = 4"
+gdb_test "whatis char4" "type = char4"
+gdb_test "p sizeof(char4)" "\\\$$decimal = 4"
+gdb_test "whatis char8" "type = char8"
+gdb_test "p sizeof(char8)" "\\\$$decimal = 8"
+gdb_test "whatis char16" "type = char16"
+gdb_test "p sizeof(char16)" "\\\$$decimal = 16"
+
+gdb_test "whatis unsigned char" "type = unsigned char"
+gdb_test "p sizeof(unsigned char)" "\\\$$decimal = 1"
+gdb_test "whatis uchar" "type = uchar"
+gdb_test "p sizeof(uchar)" "\\\$$decimal = 1"
+gdb_test "whatis uchar2" "type = uchar2"
+gdb_test "p sizeof(uchar2)" "\\\$$decimal = 2"
+gdb_test "whatis uchar3" "type = uchar3"
+gdb_test "p sizeof(uchar3)" "\\\$$decimal = 4"
+gdb_test "whatis uchar4" "type = uchar4"
+gdb_test "p sizeof(uchar4)" "\\\$$decimal = 4"
+gdb_test "whatis uchar8" "type = uchar8"
+gdb_test "p sizeof(uchar8)" "\\\$$decimal = 8"
+gdb_test "whatis uchar16" "type = uchar16"
+gdb_test "p sizeof(uchar16)" "\\\$$decimal = 16"
+
+gdb_test "whatis short" "type = short"
+gdb_test "p sizeof(short)" "\\\$$decimal = 2"
+gdb_test "whatis short2" "type = short2"
+gdb_test "p sizeof(short2)" "\\\$$decimal = 4"
+gdb_test "whatis short3" "type = short3"
+gdb_test "p sizeof(short3)" "\\\$$decimal = 8"
+gdb_test "whatis short4" "type = short4"
+gdb_test "p sizeof(short4)" "\\\$$decimal = 8"
+gdb_test "whatis short8" "type = short8"
+gdb_test "p sizeof(short8)" "\\\$$decimal = 16"
+gdb_test "whatis short16" "type = short16"
+gdb_test "p sizeof(short16)" "\\\$$decimal = 32"
+
+gdb_test "whatis unsigned short" "type = unsigned short"
+gdb_test "p sizeof(unsigned short)" "\\\$$decimal = 2"
+gdb_test "whatis ushort" "type = ushort"
+gdb_test "p sizeof(ushort)" "\\\$$decimal = 2"
+gdb_test "whatis ushort2" "type = ushort2"
+gdb_test "p sizeof(ushort2)" "\\\$$decimal = 4"
+gdb_test "whatis ushort3" "type = ushort3"
+gdb_test "p sizeof(ushort3)" "\\\$$decimal = 8"
+gdb_test "whatis ushort4" "type = ushort4"
+gdb_test "p sizeof(ushort4)" "\\\$$decimal = 8"
+gdb_test "whatis ushort8" "type = ushort8"
+gdb_test "p sizeof(ushort8)" "\\\$$decimal = 16"
+gdb_test "whatis ushort16" "type = ushort16"
+gdb_test "p sizeof(ushort16)" "\\\$$decimal = 32"
+
+gdb_test "whatis int" "type = int"
+gdb_test "p sizeof(int)" "\\\$$decimal = 4"
+gdb_test "whatis int2" "type = int2"
+gdb_test "p sizeof(int2)" "\\\$$decimal = 8"
+gdb_test "whatis int3" "type = int3"
+gdb_test "p sizeof(int3)" "\\\$$decimal = 16"
+gdb_test "whatis int4" "type = int4"
+gdb_test "p sizeof(int4)" "\\\$$decimal = 16"
+gdb_test "whatis int8" "type = int8"
+gdb_test "p sizeof(int8)" "\\\$$decimal = 32"
+gdb_test "whatis int16" "type = int16"
+gdb_test "p sizeof(int16)" "\\\$$decimal = 64"
+
+gdb_test "whatis unsigned int" "type = unsigned int"
+gdb_test "p sizeof(unsigned int)" "\\\$$decimal = 4"
+gdb_test "whatis uint" "type = uint"
+gdb_test "p sizeof(uint)" "\\\$$decimal = 4"
+gdb_test "whatis uint2" "type = uint2"
+gdb_test "p sizeof(uint2)" "\\\$$decimal = 8"
+gdb_test "whatis uint3" "type = uint3"
+gdb_test "p sizeof(uint3)" "\\\$$decimal = 16"
+gdb_test "whatis uint4" "type = uint4"
+gdb_test "p sizeof(uint4)" "\\\$$decimal = 16"
+gdb_test "whatis uint8" "type = uint8"
+gdb_test "p sizeof(uint8)" "\\\$$decimal = 32"
+gdb_test "whatis uint16" "type = uint16"
+gdb_test "p sizeof(uint16)" "\\\$$decimal = 64"
+
+gdb_test "whatis long" "type = long"
+gdb_test "p sizeof(long)" "\\\$$decimal = 8"
+gdb_test "whatis long2" "type = long2"
+gdb_test "p sizeof(long2)" "\\\$$decimal = 16"
+gdb_test "whatis long3" "type = long3"
+gdb_test "p sizeof(long3)" "\\\$$decimal = 32"
+gdb_test "whatis long4" "type = long4"
+gdb_test "p sizeof(long4)" "\\\$$decimal = 32"
+gdb_test "whatis long8" "type = long8"
+gdb_test "p sizeof(long8)" "\\\$$decimal = 64"
+gdb_test "whatis long16" "type = long16"
+gdb_test "p sizeof(long16)" "\\\$$decimal = 128"
+
+gdb_test "whatis unsigned long" "type = unsigned long"
+gdb_test "p sizeof(unsigned long)" "\\\$$decimal = 8"
+gdb_test "whatis ulong" "type = ulong"
+gdb_test "p sizeof(ulong)" "\\\$$decimal = 8"
+gdb_test "whatis ulong2" "type = ulong2"
+gdb_test "p sizeof(ulong2)" "\\\$$decimal = 16"
+gdb_test "whatis ulong3" "type = ulong3"
+gdb_test "p sizeof(ulong3)" "\\\$$decimal = 32"
+gdb_test "whatis ulong4" "type = ulong4"
+gdb_test "p sizeof(ulong4)" "\\\$$decimal = 32"
+gdb_test "whatis ulong8" "type = ulong8"
+gdb_test "p sizeof(ulong8)" "\\\$$decimal = 64"
+gdb_test "whatis ulong16" "type = ulong16"
+gdb_test "p sizeof(ulong16)" "\\\$$decimal = 128"
+
+gdb_test "whatis half" "type = half"
+gdb_test "p sizeof(half)" "\\\$$decimal = 2"
+gdb_test "whatis half2" "type = half2"
+gdb_test "p sizeof(half2)" "\\\$$decimal = 4"
+gdb_test "whatis half3" "type = half3"
+gdb_test "p sizeof(half3)" "\\\$$decimal = 8"
+gdb_test "whatis half4" "type = half4"
+gdb_test "p sizeof(half4)" "\\\$$decimal = 8"
+gdb_test "whatis half8" "type = half8"
+gdb_test "p sizeof(half8)" "\\\$$decimal = 16"
+gdb_test "whatis half16" "type = half16"
+gdb_test "p sizeof(half16)" "\\\$$decimal = 32"
+
+gdb_test "whatis float" "type = float"
+gdb_test "p sizeof(float)" "\\\$$decimal = 4"
+gdb_test "whatis float2" "type = float2"
+gdb_test "p sizeof(float2)" "\\\$$decimal = 8"
+gdb_test "whatis float3" "type = float3"
+gdb_test "p sizeof(float3)" "\\\$$decimal = 16"
+gdb_test "whatis float4" "type = float4"
+gdb_test "p sizeof(float4)" "\\\$$decimal = 16"
+gdb_test "whatis float8" "type = float8"
+gdb_test "p sizeof(float8)" "\\\$$decimal = 32"
+gdb_test "whatis float16" "type = float16"
+gdb_test "p sizeof(float16)" "\\\$$decimal = 64"
+
+gdb_test "whatis double" "type = double"
+gdb_test "p sizeof(double)" "\\\$$decimal = 8"
+gdb_test "whatis double2" "type = double2"
+gdb_test "p sizeof(double2)" "\\\$$decimal = 16"
+gdb_test "whatis double3" "type = double3"
+gdb_test "p sizeof(double3)" "\\\$$decimal = 32"
+gdb_test "whatis double4" "type = double4"
+gdb_test "p sizeof(double4)" "\\\$$decimal = 32"
+gdb_test "whatis double8" "type = double8"
+gdb_test "p sizeof(double8)" "\\\$$decimal = 64"
+gdb_test "whatis double16" "type = double16"
+gdb_test "p sizeof(double16)" "\\\$$decimal = 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_load ${bin}
+
+# 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
+
+# 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)" "\\\$$decimal = 4"
+gdb_test "print b" "\\\$$decimal = 0"
+
+gdb_test "whatis c" "type = char"
+gdb_test "p sizeof(c)" "\\\$$decimal = 1"
+gdb_test "print/d c" "\\\$$decimal = 1"
+gdb_test "whatis c2" "type = char \\\[2\\\]"
+gdb_test "p sizeof(c2)" "\\\$$decimal = 2"
+gdb_test "print c2" "\\\$$decimal = \\{1, 2\\}"
+if { ${opencl_version} >= 110 } {
+  gdb_test "whatis c3" "type = char \\\[3\\\]"
+  gdb_test "p sizeof(c3)" "\\\$$decimal = 4"
+  gdb_test "print c3" "\\\$$decimal = \\{1, 2, 3\\}"
+}
+gdb_test "whatis c4" "type = char \\\[4\\\]"
+gdb_test "p sizeof(c4)" "\\\$$decimal = 4"
+gdb_test "print c4" "\\\$$decimal = \\{1, 2, 3, 4\\}"
+gdb_test "whatis c8" "type = char \\\[8\\\]"
+gdb_test "p sizeof(c8)" "\\\$$decimal = 8"
+gdb_test "print c8" "\\\$$decimal = \\{1, 2, 3, 4, 5, 6, 7, 8\\}"
+gdb_test "whatis c16" "type = char \\\[16\\\]"
+gdb_test "p sizeof(c16)" "\\\$$decimal = 16"
+gdb_test "print c16" "\\\$$decimal = \\{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)" "\\\$$decimal = 1"
+gdb_test "print/d uc" "\\\$$decimal = 1"
+gdb_test "whatis uc2" "type = (uchar|unsigned char) \\\[2\\\]"
+gdb_test "p sizeof(uc2)" "\\\$$decimal = 2"
+gdb_test "print uc2" "\\\$$decimal = \\{1, 2\\}"
+if { ${opencl_version} >= 110 } {
+  gdb_test "whatis uc3" "type = (uchar|unsigned char) \\\[3\\\]"
+  gdb_test "p sizeof(uchar3)" "\\\$$decimal = 4"
+  gdb_test "print uc3" "\\\$$decimal = \\{1, 2, 3\\}"
+}
+gdb_test "whatis uc4" "type = (uchar|unsigned char) \\\[4\\\]"
+gdb_test "p sizeof(uc4)" "\\\$$decimal = 4"
+gdb_test "print uc4" "\\\$$decimal = \\{1, 2, 3, 4\\}"
+gdb_test "whatis uc8" "type = (uchar|unsigned char) \\\[8\\\]"
+gdb_test "p sizeof(uc8)" "\\\$$decimal = 8"
+gdb_test "print uc8" "\\\$$decimal = \\{1, 2, 3, 4, 5, 6, 7, 8\\}"
+gdb_test "whatis uc16" "type = (uchar|unsigned char) \\\[16\\\]"
+gdb_test "p sizeof(uc16)" "\\\$$decimal = 16"
+gdb_test "print uc16" "\\\$$decimal = \\{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)" "\\\$$decimal = 2"
+gdb_test "print s" "\\\$$decimal = -1"
+gdb_test "whatis s2" "type = short \\\[2\\\]"
+gdb_test "p sizeof(s2)" "\\\$$decimal = 4"
+gdb_test "print s2" "\\\$$decimal = \\{-1, -2\\}"
+if { ${opencl_version} >= 110 } {
+  gdb_test "whatis s3" "type = short \\\[3\\\]"
+  gdb_test "p sizeof(s3)" "\\\$$decimal = 8"
+  gdb_test "print s3" "\\\$$decimal = \\{-1, -2, -3\\}"
+}
+gdb_test "whatis s4" "type = short \\\[4\\\]"
+gdb_test "p sizeof(s4)" "\\\$$decimal = 8"
+gdb_test "print s4" "\\\$$decimal = \\{-1, -2, -3, -4\\}"
+gdb_test "whatis s8" "type = short \\\[8\\\]"
+gdb_test "p sizeof(s8)" "\\\$$decimal = 16"
+gdb_test "print s8" "\\\$$decimal = \\{-1, -2, -3, -4, -5, -6, -7, -8\\}"
+gdb_test "whatis s16" "type = short \\\[16\\\]"
+gdb_test "p sizeof(s16)" "\\\$$decimal = 32"
+gdb_test "print s16" "\\\$$decimal = \\{-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)" "\\\$$decimal = 2"
+gdb_test "print us" "\\\$$decimal = 1"
+gdb_test "whatis us2" "type = (ushort|unsigned short) \\\[2\\\]"
+gdb_test "p sizeof(us2)" "\\\$$decimal = 4"
+gdb_test "print us2" "\\\$$decimal = \\{1, 2\\}"
+if { ${opencl_version} >= 110 } {
+  gdb_test "whatis us3" "type = (ushort|unsigned short) \\\[3\\\]"
+  gdb_test "p sizeof(us3)" "\\\$$decimal = 8"
+  gdb_test "print us3" "\\\$$decimal = \\{1, 2, 3\\}"
+}
+gdb_test "whatis us4" "type = (ushort|unsigned short) \\\[4\\\]"
+gdb_test "p sizeof(us4)" "\\\$$decimal = 8"
+gdb_test "print us4" "\\\$$decimal = \\{1, 2, 3, 4\\}"
+gdb_test "whatis us8" "type = (ushort|unsigned short) \\\[8\\\]"
+gdb_test "p sizeof(us8)" "\\\$$decimal = 16"
+gdb_test "print us8" "\\\$$decimal = \\{1, 2, 3, 4, 5, 6, 7, 8\\}"
+gdb_test "whatis us16" "type = (ushort|unsigned short) \\\[16\\\]"
+gdb_test "p sizeof(us16)" "\\\$$decimal = 32"
+gdb_test "print us16" "\\\$$decimal = \\{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)" "\\\$$decimal = 4"
+gdb_test "print i" "\\\$$decimal = -1"
+gdb_test "whatis i2" "type = int \\\[2\\\]"
+gdb_test "p sizeof(i2)" "\\\$$decimal = 8"
+gdb_test "print i2" "\\\$$decimal = \\{-1, -2\\}"
+if { ${opencl_version} >= 110 } {
+  gdb_test "whatis i3" "type = int \\\[3\\\]"
+  gdb_test "p sizeof(i3)" "\\\$$decimal = 16"
+  gdb_test "print i3" "\\\$$decimal = \\{-1, -2, -3\\}"
+}
+gdb_test "whatis i4" "type = int \\\[4\\\]"
+gdb_test "p sizeof(i4)" "\\\$$decimal = 16"
+gdb_test "print i4" "\\\$$decimal = \\{-1, -2, -3, -4\\}"
+gdb_test "whatis i8" "type = int \\\[8\\\]"
+gdb_test "p sizeof(i8)" "\\\$$decimal = 32"
+gdb_test "print i8" "\\\$$decimal = \\{-1, -2, -3, -4, -5, -6, -7, -8\\}"
+gdb_test "whatis i16" "type = int \\\[16\\\]"
+gdb_test "p sizeof(i16)" "\\\$$decimal = 64"
+gdb_test "print i16" "\\\$$decimal = \\{-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)" "\\\$$decimal = 4"
+gdb_test "print ui" "\\\$$decimal = 1"
+gdb_test "whatis ui2" "type = (uint|unsigned int) \\\[2\\\]"
+gdb_test "p sizeof(ui2)" "\\\$$decimal = 8"
+gdb_test "print ui2" "\\\$$decimal = \\{1, 2\\}"
+if { ${opencl_version} >= 110 } {
+  gdb_test "whatis ui3" "type = (uint|unsigned int) \\\[3\\\]"
+  gdb_test "p sizeof(ui3)" "\\\$$decimal = 16"
+  gdb_test "print ui3" "\\\$$decimal = \\{1, 2, 3\\}"
+}
+gdb_test "whatis ui4" "type = (uint|unsigned int) \\\[4\\\]"
+gdb_test "p sizeof(ui4)" "\\\$$decimal = 16"
+gdb_test "print ui4" "\\\$$decimal = \\{1, 2, 3, 4\\}"
+gdb_test "whatis ui8" "type = (uint|unsigned int) \\\[8\\\]"
+gdb_test "p sizeof(ui8)" "\\\$$decimal = 32"
+gdb_test "print ui8" "\\\$$decimal = \\{1, 2, 3, 4, 5, 6, 7, 8\\}"
+gdb_test "whatis ui16" "type = (uint|unsigned int) \\\[16\\\]"
+gdb_test "p sizeof(ui16)" "\\\$$decimal = 64"
+gdb_test "print ui16" "\\\$$decimal = \\{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)" "\\\$$decimal = 8"
+gdb_test "print l" "\\\$$decimal = -1"
+gdb_test "whatis l2" "type = long \\\[2\\\]"
+gdb_test "p sizeof(l2)" "\\\$$decimal = 16"
+gdb_test "print l2" "\\\$$decimal = \\{-1, -2\\}"
+if { ${opencl_version} >= 110 } {
+  gdb_test "whatis l3" "type = long \\\[3\\\]"
+  gdb_test "p sizeof(l3)" "\\\$$decimal = 32"
+  gdb_test "print l3" "\\\$$decimal = \\{-1, -2, -3\\}"
+}
+gdb_test "whatis l4" "type = long \\\[4\\\]"
+gdb_test "p sizeof(l4)" "\\\$$decimal = 32"
+gdb_test "print l4" "\\\$$decimal = \\{-1, -2, -3, -4\\}"
+gdb_test "whatis l8" "type = long \\\[8\\\]"
+gdb_test "p sizeof(l8)" "\\\$$decimal = 64"
+gdb_test "print l8" "\\\$$decimal = \\{-1, -2, -3, -4, -5, -6, -7, -8\\}"
+gdb_test "whatis l16" "type = long \\\[16\\\]"
+gdb_test "p sizeof(l16)" "\\\$$decimal = 128"
+gdb_test "print l16" "\\\$$decimal = \\{-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)" "\\\$$decimal = 8"
+gdb_test "print ul" "\\\$$decimal = 1"
+gdb_test "whatis ul2" "type = (ulong|unsigned long) \\\[2\\\]"
+gdb_test "p sizeof(ul2)" "\\\$$decimal = 16"
+gdb_test "print ul2" "\\\$$decimal = \\{1, 2\\}"
+if { ${opencl_version} >= 110 } {
+  gdb_test "whatis ul3" "type = (ulong|unsigned long) \\\[3\\\]"
+  gdb_test "p sizeof(ul3)" "\\\$$decimal = 32"
+  gdb_test "print ul3" "\\\$$decimal = \\{1, 2, 3\\}"
+}
+gdb_test "whatis ul4" "type = (ulong|unsigned long) \\\[4\\\]"
+gdb_test "p sizeof(ul4)" "\\\$$decimal = 32"
+gdb_test "print ul4" "\\\$$decimal = \\{1, 2, 3, 4\\}"
+gdb_test "whatis ul8" "type = (ulong|unsigned long) \\\[8\\\]"
+gdb_test "p sizeof(ul8)" "\\\$$decimal = 64"
+gdb_test "print ul8" "\\\$$decimal = \\{1, 2, 3, 4, 5, 6, 7, 8\\}"
+gdb_test "whatis ul16" "type = (ulong|unsigned long) \\\[16\\\]"
+gdb_test "p sizeof(ul16)" "\\\$$decimal = 128"
+gdb_test "print ul16" "\\\$$decimal = \\{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)" "\\\$$decimal = 2"
+
+if { ${have_cl_khr_fp16} } {
+  gdb_test "whatis h" "type = half"
+  gdb_test "p sizeof(h)" "\\\$$decimal = 2"
+  gdb_test "print h" "\\\$$decimal = 1"
+  gdb_test "whatis h2" "type = half \\\[2\\\]"
+  gdb_test "p sizeof(h2)" "\\\$$decimal = 4"
+  gdb_test "print h2" "\\\$$decimal = \\{1, 2\\}"
+  if { ${opencl_version} >= 110 } {
+    gdb_test "whatis h3" "type = half \\\[3\\\]"
+    gdb_test "p sizeof(h3)" "\\\$$decimal = 8"
+    gdb_test "print h3" "\\\$$decimal = \\{1, 2, 3\\}"
+  }
+  gdb_test "whatis h4" "type = half \\\[4\\\]"
+  gdb_test "p sizeof(h4)" "\\\$$decimal = 8"
+  gdb_test "print h4" "\\\$$decimal = \\{1, 2, 3, 4\\}"
+  gdb_test "whatis h8" "type = half \\\[8\\\]"
+  gdb_test "p sizeof(h8)" "\\\$$decimal = 16"
+  gdb_test "print h8" "\\\$$decimal = \\{1, 2, 3, 4, 5, 6, 7, 8\\}"
+  gdb_test "whatis h16" "type = half \\\[16\\\]"
+  gdb_test "p sizeof(h16)" "\\\$$decimal = 16"
+  gdb_test "print h16" "\\\$$decimal = \\{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)" "\\\$$decimal = 4"
+gdb_test "print f" "\\\$$decimal = 1"
+gdb_test "whatis f2" "type = float \\\[2\\\]"
+gdb_test "p sizeof(f2)" "\\\$$decimal = 8"
+gdb_test "print f2" "\\\$$decimal = \\{1, 2\\}"
+if { ${opencl_version} >= 110 } {
+  gdb_test "whatis f3" "type = float \\\[3\\\]"
+  gdb_test "p sizeof(f3)" "\\\$$decimal = 16"
+  gdb_test "print f3" "\\\$$decimal = \\{1, 2, 3\\}"
+}
+gdb_test "whatis f4" "type = float \\\[4\\\]"
+gdb_test "p sizeof(f4)" "\\\$$decimal = 16"
+gdb_test "print f4" "\\\$$decimal = \\{1, 2, 3, 4\\}"
+gdb_test "whatis f8" "type = float \\\[8\\\]"
+gdb_test "p sizeof(f8)" "\\\$$decimal = 32"
+gdb_test "print f8" "\\\$$decimal = \\{1, 2, 3, 4, 5, 6, 7, 8\\}"
+gdb_test "whatis f16" "type = float \\\[16\\\]"
+gdb_test "p sizeof(f16)" "\\\$$decimal = 64"
+gdb_test "print f16" "\\\$$decimal = \\{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)" "\\\$$decimal = 8"
+  gdb_test "print d" "\\\$$decimal = 1"
+  gdb_test "whatis d2" "type = double \\\[2\\\]"
+  gdb_test "p sizeof(d2)" "\\\$$decimal = 16"
+  gdb_test "print d2" "\\\$$decimal = \\{1, 2\\}"
+  if { ${opencl_version} >= 110 } {
+    gdb_test "whatis d3" "type = double \\\[3\\\]"
+    gdb_test "p sizeof(d3)" "\\\$$decimal = 32"
+    gdb_test "print d3" "\\\$$decimal = \\{1, 2, 3\\}"
+  }
+  gdb_test "whatis d4" "type = double \\\[4\\\]"
+  gdb_test "p sizeof(d4)" "\\\$$decimal = 32"
+  gdb_test "print d4" "\\\$$decimal = \\{1, 2, 3, 4\\}"
+  gdb_test "whatis d8" "type = double \\\[8\\\]"
+  gdb_test "p sizeof(d8)" "\\\$$decimal = 64"
+  gdb_test "print d8" "\\\$$decimal = \\{1, 2, 3, 4, 5, 6, 7, 8\\}"
+  gdb_test "whatis d16" "type = double \\\[16\\\]"
+  gdb_test "p sizeof(d16)" "\\\$$decimal = 128"
+  gdb_test "print d16" "\\\$$decimal = \\{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}
Index: src/gdb/testsuite/gdb.opencl/operators.cl
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/operators.cl	2010-10-26 17:55:33.000000000 +0200
@@ -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;
+}
Index: src/gdb/testsuite/gdb.opencl/operators.exp
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/operators.exp	2010-10-26 17:55:33.000000000 +0200
@@ -0,0 +1,972 @@
+# 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 bin ${objdir}/${subdir}/${testfile}
+set clprogram [remote_download target ${srcdir}/${subdir}/${testfile}.cl]
+
+# Increase timeout
+set timeout 60
+verbose "Timeout set to $timeout seconds" 2
+
+# Compile the generic OpenCL host app
+if { [gdb_compile_opencl_hostapp "${clprogram}" "${bin}" "" ] != "" } {
+    untested ${testfile}.exp
+    return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
+# Load the OpenCL app
+gdb_load ${bin}
+
+# 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
+
+# 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 } {
+  global decimal
+  gdb_test "print/d ${name}a" "\\\$$decimal = 2"
+  gdb_test "print/d ${name}b" "\\\$$decimal = 1"
+  gdb_test "print/d ${name}4a" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+  gdb_test "print/d ${name}4b" "\\\$$decimal = \\{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" "\\\$$decimal = 2"
+    gdb_test "print/d u${name}b" "\\\$$decimal = 1"
+    gdb_test "print/d u${name}4a" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d u${name}4b" "\\\$$decimal = \\{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 } {
+  global decimal
+  # scalar with scalar
+  gdb_test "print/d ${name}a + ${name}b" "\\\$$decimal = 3"
+  gdb_test "print/d ${name}a - ${name}b" "\\\$$decimal = 1"
+  gdb_test "print/d ${name}a * ${name}b" "\\\$$decimal = 2"
+  gdb_test "print/d ${name}a / ${name}b" "\\\$$decimal = 2"
+  # scalar with vector
+  gdb_test "print/d ${name}a + ${name}4b" "\\\$$decimal = \\{3, 4, 10, 6\\}"
+  gdb_test "print/d ${name}4a - ${name}b" "\\\$$decimal = \\{1, 3, 7, 15\\}"
+  gdb_test "print/d ${name}4a * ${name}b" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+  gdb_test "print/d ${name}a / ${name}4b" "\\\$$decimal = \\{2, 1, 0, 0\\}"
+  # vector with vector
+  gdb_test "print/d ${name}4a + ${name}4b" "\\\$$decimal = \\{3, 6, 16, 20\\}"
+  gdb_test "print/d ${name}4a - ${name}4b" "\\\$$decimal = \\{1, 2, 0, 12\\}"
+  gdb_test "print/d ${name}4a * ${name}4b" "\\\$$decimal = \\{2, 8, 64, 64\\}"
+  gdb_test "print/d ${name}4a / ${name}4b" "\\\$$decimal = \\{2, 2, 1, 4\\}"
+
+  # scalar
+  gdb_test "print/d ${name}a++" "\\\$$decimal = 2"
+  gdb_test "print/d ++${name}a" "\\\$$decimal = 4"
+  gdb_test "print/d ${name}a--" "\\\$$decimal = 4"
+  gdb_test "print/d --${name}a" "\\\$$decimal = 2"
+  gdb_test "print/d +${name}a" "\\\$$decimal = 2"
+  gdb_test "print/d -${name}a" "\\\$$decimal = -2"
+  # vector
+  gdb_test "print/d ${name}4a++" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+  gdb_test "print/d ++${name}4a" "\\\$$decimal = \\{4, 6, 10, 18\\}"
+  gdb_test "print/d ${name}4a--" "\\\$$decimal = \\{4, 6, 10, 18\\}"
+  gdb_test "print/d --${name}4a" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+  gdb_test "print/d +${name}4a" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+  gdb_test "print/d -${name}4a" "\\\$$decimal = \\{-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" "\\\$$decimal = 0"
+    # scalar with vector
+    gdb_test "print/d ${name}4a % ${name}b" "\\\$$decimal = \\{0, 0, 0, 0\\}"
+    # vector with vector
+    gdb_test "print/d ${name}4a % ${name}b" "\\\$$decimal = \\{0, 0, 0, 0\\}"
+
+    # scalar with scalar
+    gdb_test "print/d u${name}a + u${name}b" "\\\$$decimal = 3"
+    gdb_test "print/d u${name}a - u${name}b" "\\\$$decimal = 1"
+    gdb_test "print/d u${name}a * u${name}b" "\\\$$decimal = 2"
+    gdb_test "print/d u${name}a / u${name}b" "\\\$$decimal = 2"
+    gdb_test "print/d u${name}a % u${name}b" "\\\$$decimal = 0"
+    # scalar with vector
+    gdb_test "print/d u${name}a + u${name}4b" "\\\$$decimal = \\{3, 4, 10, 6\\}"
+    gdb_test "print/d u${name}4a - u${name}b" "\\\$$decimal = \\{1, 3, 7, 15\\}"
+    gdb_test "print/d u${name}4a * u${name}b" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d u${name}a / u${name}4b" "\\\$$decimal = \\{2, 1, 0, 0\\}"
+    gdb_test "print/d u${name}4a % u${name}b" "\\\$$decimal = \\{0, 0, 0, 0\\}"
+    # vector with vector
+    gdb_test "print/d u${name}4a + u${name}4b" "\\\$$decimal = \\{3, 6, 16, 20\\}"
+    gdb_test "print/d u${name}4a - u${name}4b" "\\\$$decimal = \\{1, 2, 0, 12\\}"
+    gdb_test "print/d u${name}4a * u${name}4b" "\\\$$decimal = \\{2, 8, 64, 64\\}"
+    gdb_test "print/d u${name}4a / u${name}4b" "\\\$$decimal = \\{2, 2, 1, 4\\}"
+    gdb_test "print/d u${name}4a % u${name}4b" "\\\$$decimal = \\{0, 0, 0, 0\\}"
+
+    # scalar
+    gdb_test "print/d u${name}a++" "\\\$$decimal = 2"
+    gdb_test "print/d ++u${name}a" "\\\$$decimal = 4"
+    gdb_test "print/d u${name}a--" "\\\$$decimal = 4"
+    gdb_test "print/d --u${name}a" "\\\$$decimal = 2"
+    gdb_test "print/d +u${name}a" "\\\$$decimal = 2"
+    gdb_test "print/x -u${name}a" "\\\$$decimal = 0x.*fe"
+    # vector
+    gdb_test "print/d u${name}4a++" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d ++u${name}4a" "\\\$$decimal = \\{4, 6, 10, 18\\}"
+    gdb_test "print/d u${name}4a--" "\\\$$decimal = \\{4, 6, 10, 18\\}"
+    gdb_test "print/d --u${name}4a" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d +u${name}4a" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/x -u${name}4a" "\\\$$decimal = \\{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 } {
+  global decimal
+  # scalar with scalar
+  gdb_test "print/d ${name}a > ${name}b" "\\\$$decimal = 1"
+  gdb_test "print/d ${name}b < ${name}a" "\\\$$decimal = 1"
+  gdb_test "print/d ${name}b >= ${name}a" "\\\$$decimal = 0"
+  gdb_test "print/d ${name}a <= ${name}b" "\\\$$decimal = 0"
+  # scalar with vector
+  gdb_test "print/d ${name}4a > ${name}b" "\\\$$decimal = \\{-1, -1, -1, -1\\}"
+  gdb_test "print/d ${name}a < ${name}4b" "\\\$$decimal = \\{0, 0, -1, -1\\}"
+  gdb_test "print/d ${name}4a >= ${name}b" "\\\$$decimal = \\{-1, -1, -1, -1\\}"
+  gdb_test "print/d ${name}a <= ${name}4b" "\\\$$decimal = \\{0, -1, -1, -1\\}"
+  # vector with vector
+  gdb_test "print/d ${name}4a > ${name}4b" "\\\$$decimal = \\{-1, -1, 0, -1\\}"
+  gdb_test "print/d ${name}4b < ${name}4a" "\\\$$decimal = \\{-1, -1, 0, -1\\}"
+  gdb_test "print/d ${name}4b >= ${name}4a" "\\\$$decimal = \\{0, 0, -1, 0\\}"
+  gdb_test "print/d ${name}4a <= ${name}4b" "\\\$$decimal = \\{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" "\\\$$decimal = 1"
+    gdb_test "print/d u${name}b < u${name}a" "\\\$$decimal = 1"
+    gdb_test "print/d u${name}b >= u${name}a" "\\\$$decimal = 0"
+    gdb_test "print/d u${name}a <= u${name}b" "\\\$$decimal = 0"
+    # scalar with vector
+    gdb_test "print/d u${name}4a > u${name}b" "\\\$$decimal = \\{-1, -1, -1, -1\\}"
+    gdb_test "print/d u${name}a < u${name}4b" "\\\$$decimal = \\{0, 0, -1, -1\\}"
+    gdb_test "print/d u${name}4a >= u${name}b" "\\\$$decimal = \\{-1, -1, -1, -1\\}"
+    gdb_test "print/d u${name}a <= u${name}4b" "\\\$$decimal = \\{0, -1, -1, -1\\}"
+    # vector with vector
+    gdb_test "print/d u${name}4a > u${name}4b" "\\\$$decimal = \\{-1, -1, 0, -1\\}"
+    gdb_test "print/d u${name}4b < u${name}4a" "\\\$$decimal = \\{-1, -1, 0, -1\\}"
+    gdb_test "print/d u${name}4b >= u${name}4a" "\\\$$decimal = \\{0, 0, -1, 0\\}"
+    gdb_test "print/d u${name}4a <= u${name}4b" "\\\$$decimal = \\{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 } {
+  global decimal
+  # scalar with scalar
+  gdb_test "print/d ${name}a == ${name}b" "\\\$$decimal = 0"
+  gdb_test "print/d ${name}a != ${name}b" "\\\$$decimal = 1"
+  # scalar with vector
+  gdb_test "print/d ${name}4a == ${name}b" "\\\$$decimal = \\{0, 0, 0, 0\\}"
+  gdb_test "print/d ${name}a != ${name}4b" "\\\$$decimal = \\{-1, 0, -1, -1\\}"
+  # vector with vector
+  gdb_test "print/d ${name}4a == ${name}4b" "\\\$$decimal = \\{0, 0, -1, 0\\}"
+  gdb_test "print/d ${name}4a != ${name}4b" "\\\$$decimal = \\{-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" "\\\$$decimal = 0"
+    gdb_test "print/d u${name}a != u${name}b" "\\\$$decimal = 1"
+    # scalar with vector
+    gdb_test "print/d u${name}4a == u${name}b" "\\\$$decimal = \\{0, 0, 0, 0\\}"
+    gdb_test "print/d u${name}a != u${name}4b" "\\\$$decimal = \\{-1, 0, -1, -1\\}"
+    # vector with vector
+    gdb_test "print/d u${name}4a == u${name}4b" "\\\$$decimal = \\{0, 0, -1, 0\\}"
+    gdb_test "print/d u${name}4b != u${name}4a" "\\\$$decimal = \\{-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 } {
+  global decimal
+  # scalar with scalar
+  gdb_test "print/d ${name}a << ${name}b" "\\\$$decimal = 4"
+  gdb_test "print/d ${name}a >> ${name}b" "\\\$$decimal = 1"
+  gdb_test "print/d u${name}a << u${name}b" "\\\$$decimal = 4"
+  gdb_test "print/d u${name}a >> u${name}b" "\\\$$decimal = 1"
+  # scalar with vector
+  gdb_test "print/d ${name}4a << ${name}b" "\\\$$decimal = \\{4, 8, 16, 32\\}"
+  gdb_test "print/d ${name}4a >> ${name}b" "\\\$$decimal = \\{1, 2, 4, 8\\}"
+  gdb_test "print/d u${name}4a << u${name}b" "\\\$$decimal = \\{4, 8, 16, 32\\}"
+  gdb_test "print/d u${name}4a >> u${name}b" "\\\$$decimal = \\{1, 2, 4, 8\\}"
+  # vector with vector
+  if { ${size} == 1 } {
+    gdb_test "print/d ${name}4a << ${name}4b" "\\\$$decimal = \\{4, 16, 0, 0\\}"
+    gdb_test "print/d u${name}4a << u${name}4b" "\\\$$decimal = \\{4, 16, 0, 0\\}"
+  } else {
+    gdb_test "print/d ${name}4a << ${name}4b" "\\\$$decimal = \\{4, 16, 2048, 256\\}"
+    gdb_test "print/d u${name}4a << u${name}4b" "\\\$$decimal = \\{4, 16, 2048, 256\\}"
+  }
+  gdb_test "print/d ${name}4a >> ${name}4b" "\\\$$decimal = \\{1, 1, 0, 1\\}"
+  gdb_test "print/d u${name}4a >> u${name}4b" "\\\$$decimal = \\{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 } {
+  global decimal
+  # scalar with scalar
+  gdb_test "print/d ${name}a & ${name}b" "\\\$$decimal = 0"
+  gdb_test "print/d ${name}a | ${name}b" "\\\$$decimal = 3"
+  gdb_test "print/d ${name}a ^ ${name}b" "\\\$$decimal = 3"
+  gdb_test "print/d u${name}a & u${name}b" "\\\$$decimal = 0"
+  gdb_test "print/d u${name}a | u${name}b" "\\\$$decimal = 3"
+  gdb_test "print/d u${name}a ^ u${name}b" "\\\$$decimal = 3"
+  # scalar with vector
+  gdb_test "print/d ${name}4a & ${name}b" "\\\$$decimal = \\{0, 0, 0, 0\\}"
+  gdb_test "print/d ${name}a | ${name}4b" "\\\$$decimal = \\{3, 2, 10, 6\\}"
+  gdb_test "print/d ${name}4a ^ ${name}b" "\\\$$decimal = \\{3, 5, 9, 17\\}"
+  gdb_test "print/d u${name}4a & u${name}b" "\\\$$decimal = \\{0, 0, 0, 0\\}"
+  gdb_test "print/d u${name}a | u${name}4b" "\\\$$decimal = \\{3, 2, 10, 6\\}"
+  gdb_test "print/d u${name}4a ^ u${name}b" "\\\$$decimal = \\{3, 5, 9, 17\\}"
+  # vector with vector
+  gdb_test "print/d ${name}4a & ${name}4b" "\\\$$decimal = \\{0, 0, 8, 0\\}"
+  gdb_test "print/d ${name}4a | ${name}4b" "\\\$$decimal = \\{3, 6, 8, 20\\}"
+  gdb_test "print/d ${name}4a ^ ${name}4b" "\\\$$decimal = \\{3, 6, 0, 20\\}"
+  gdb_test "print/d u${name}4a & u${name}4b" "\\\$$decimal = \\{0, 0, 8, 0\\}"
+  gdb_test "print/d u${name}4a | u${name}4b" "\\\$$decimal = \\{3, 6, 8, 20\\}"
+  gdb_test "print/d u${name}4a ^ u${name}4b" "\\\$$decimal = \\{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" "\\\$$decimal = 0xfffffffd"
+    gdb_test "print/x ~u${name}a" "\\\$$decimal = 0xfffffffd"
+  } else {
+    gdb_test "print/x ~${name}a" "\\\$$decimal = 0xfffffffffffffffd"
+    gdb_test "print/x ~u${name}a" "\\\$$decimal = 0xfffffffffffffffd"
+  }
+  # vector
+  if { ${size} == 1 } {
+    gdb_test "print/x ~${name}4a" "\\\$$decimal = \\{0xfd, 0xfb, 0xf7, 0xef\\}"
+    gdb_test "print/x ~u${name}4a" "\\\$$decimal = \\{0xfd, 0xfb, 0xf7, 0xef\\}"
+  } elseif { ${size} == 2 } {
+    gdb_test "print/x ~${name}4a" "\\\$$decimal = \\{0xfffd, 0xfffb, 0xfff7, 0xffef\\}"
+    gdb_test "print/x ~u${name}4a" "\\\$$decimal = \\{0xfffd, 0xfffb, 0xfff7, 0xffef\\}"
+  } elseif { ${size} == 4 } {
+    gdb_test "print/x ~${name}4a" "\\\$$decimal = \\{0xfffffffd, 0xfffffffb, 0xfffffff7, 0xffffffef\\}"
+    gdb_test "print/x ~u${name}4a" "\\\$$decimal = \\{0xfffffffd, 0xfffffffb, 0xfffffff7, 0xffffffef\\}"
+  } else { # ${size} == 8
+    gdb_test "print/x ~${name}4a" "\\\$$decimal = \\{0xfffffffffffffffd, 0xfffffffffffffffb, 0xfffffffffffffff7, 0xffffffffffffffef\\}"
+    gdb_test "print/x ~u${name}4a" "\\\$$decimal = \\{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 } {
+  global decimal
+  # scalar
+  gdb_test "print/d !${name}a " "\\\$$decimal = 0"
+  gdb_test "print/d !!${name}a " "\\\$$decimal = 1"
+  # vector
+  gdb_test "print/d !${name}4a " "\\\$$decimal = \\{0, 0, 0, 0\\}"
+  gdb_test "print/d !!${name}4a " "\\\$$decimal = \\{-1, -1, -1, -1\\}"
+
+  # scalar with scalar
+  gdb_test "print/d ${name}a && ${name}b" "\\\$$decimal = 1"
+  gdb_test "print/d ${name}a && !${name}b" "\\\$$decimal = 0"
+  gdb_test "print/d ${name}a || ${name}b" "\\\$$decimal = 1"
+  gdb_test "print/d ${name}a || !${name}b" "\\\$$decimal = 1"
+  gdb_test "print/d !${name}a || !${name}b" "\\\$$decimal = 0"
+
+  # scalar with vector
+  gdb_test "print/d ${name}4a && ${name}b" "\\\$$decimal = \\{-1, -1, -1, -1\\}"
+  gdb_test "print/d ${name}4a && !${name}b" "\\\$$decimal = \\{0, 0, 0, 0\\}"
+  gdb_test "print/d ${name}a || ${name}4b" "\\\$$decimal = \\{-1, -1, -1, -1\\}"
+  gdb_test "print/d ${name}a || !${name}4b" "\\\$$decimal = \\{-1, -1, -1, -1\\}"
+  gdb_test "print/d !${name}4a || !${name}b" "\\\$$decimal = \\{0, 0, 0, 0\\}"
+  # vector with vector
+  gdb_test "print/d ${name}4a && ${name}4b" "\\\$$decimal = \\{-1, -1, -1, -1\\}"
+  gdb_test "print/d ${name}4a || ${name}4b" "\\\$$decimal = \\{-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 " "\\\$$decimal = 0"
+    gdb_test "print/d !!u${name}a " "\\\$$decimal = 1"
+    # unsigned vector
+    gdb_test "print/d !u${name}4a " "\\\$$decimal = \\{0, 0, 0, 0\\}"
+    gdb_test "print/d !!u${name}4a " "\\\$$decimal = \\{-1, -1, -1, -1\\}"
+
+    # scalar with scalar
+    gdb_test "print/d u${name}a && u${name}b" "\\\$$decimal = 1"
+    gdb_test "print/d u${name}a || u${name}b" "\\\$$decimal = 1"
+    # scalar with vector
+    gdb_test "print/d u${name}4a && u${name}b" "\\\$$decimal = \\{-1, -1, -1, -1\\}"
+    gdb_test "print/d u${name}a || u${name}4b" "\\\$$decimal = \\{-1, -1, -1, -1\\}"
+    # vector with vector
+    gdb_test "print/d u${name}4a && u${name}4b" "\\\$$decimal = \\{-1, -1, -1, -1\\}"
+    gdb_test "print/d u${name}4a || u${name}4b" "\\\$$decimal = \\{-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 } {
+  global decimal
+  # scalar with scalar
+  gdb_test "print/d ${name}a ? ${name}b : ${name}a" "\\\$$decimal = 1"
+  gdb_test "print/d !${name}a ? ${name}b : ${name}a" "\\\$$decimal = 2"
+  # scalar with vector
+  gdb_test "print/d ${name}4a ? ${name}4b : ${name}a" "\\\$$decimal = \\{1, 2, 8, 4\\}"
+  gdb_test "print/d ${name}4a ? ${name}b : ${name}4a" "\\\$$decimal = \\{1, 1, 1, 1\\}"
+  gdb_test "print/d ${name}4a > 4 ? 1 : ${name}4a" "\\\$$decimal = \\{2, 4, 1, 1\\}"
+  gdb_test "print/d ${name}4a > 4 ? ${name}4b : ${name}a" "\\\$$decimal = \\{2, 2, 8, 4\\}"
+  # vector with vector
+  gdb_test "print/d ${name}4a ? ${name}4b : ${name}4a" "\\\$$decimal = \\{1, 2, 8, 4\\}"
+  gdb_test "print/d ${name}4a > 4 ? ${name}4b : ${name}4a" "\\\$$decimal = \\{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" "\\\$$decimal = 1"
+    gdb_test "print/d !u${name}a ? u${name}b : u${name}a" "\\\$$decimal = 2"
+    # scalar with vector
+    gdb_test "print/d u${name}4a ? u${name}4b : u${name}a" "\\\$$decimal = \\{1, 2, 8, 4\\}"
+    gdb_test "print/d u${name}4a ? u${name}b : u${name}4a" "\\\$$decimal = \\{1, 1, 1, 1\\}"
+    gdb_test "print/d u${name}4a > 4 ? 1 : u${name}4a" "\\\$$decimal = \\{2, 4, 1, 1\\}"
+    gdb_test "print/d u${name}4a > 4 ? u${name}4b : u${name}a" "\\\$$decimal = \\{2, 2, 8, 4\\}"
+    # vector with vector
+    gdb_test "print/d u${name}4a ? u${name}4b : u${name}4a" "\\\$$decimal = \\{1, 2, 8, 4\\}"
+    gdb_test "print/d u${name}4a > 4 ? u${name}4b : u${name}4a" "\\\$$decimal = \\{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 } {
+  global decimal
+  # scalar with scalar
+  gdb_test "print/d ${name}a = ${name}b" "\\\$$decimal = 1"
+  gdb_test "print/d ${name}a = 2" "\\\$$decimal = 2"
+  gdb_test "print/d ${name}a += ${name}b" "\\\$$decimal = 3"
+  gdb_test "print/d ${name}a -= ${name}b" "\\\$$decimal = 2"
+  gdb_test "print/d ${name}b *= ${name}a" "\\\$$decimal = 2"
+  gdb_test "print/d ${name}b /= ${name}a" "\\\$$decimal = 1"
+  # scalar with vector
+  gdb_test "print/d ${name}4a = ${name}b" "\\\$$decimal = \\{1, 1, 1, 1\\}"
+  gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+  gdb_test "print/d ${name}4a += ${name}b" "\\\$$decimal = \\{3, 5, 9, 17\\}"
+  gdb_test "print/d ${name}4a -= ${name}b" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+  gdb_test "print/d ${name}4b *= ${name}a" "\\\$$decimal = \\{2, 4, 16, 8\\}"
+  gdb_test "print/d ${name}4b /= ${name}a" "\\\$$decimal = \\{1, 2, 8, 4\\}"
+  # vector with vector
+  gdb_test "print/d ${name}4a = ${name}4b" "\\\$$decimal = \\{1, 2, 8, 4\\}"
+  gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+  gdb_test "print/d ${name}4a += ${name}4b" "\\\$$decimal = \\{3, 6, 16, 20\\}"
+  gdb_test "print/d ${name}4a -= ${name}4b" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+  gdb_test "print/d ${name}4b *= ${name}4a" "\\\$$decimal = \\{2, 8, 64, 64\\}"
+  gdb_test "print/d ${name}4b /= ${name}4a" "\\\$$decimal = \\{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" "\\\$$decimal = 0"
+    gdb_test "print/d ${name}a = 2" "\\\$$decimal = 2"
+    gdb_test "print/d ${name}a <<= ${name}b" "\\\$$decimal = 4"
+    gdb_test "print/d ${name}a = 2" "\\\$$decimal = 2"
+    gdb_test "print/d ${name}a >>= ${name}b" "\\\$$decimal = 1"
+    gdb_test "print/d ${name}a = 2" "\\\$$decimal = 2"
+    gdb_test "print/d ${name}a &= ${name}b" "\\\$$decimal = 0"
+    gdb_test "print/d ${name}a = 2" "\\\$$decimal = 2"
+    gdb_test "print/d ${name}a |= ${name}b" "\\\$$decimal = 3"
+    gdb_test "print/d ${name}a = 2" "\\\$$decimal = 2"
+    gdb_test "print/d ${name}a ^= ${name}b" "\\\$$decimal = 3"
+    gdb_test "print/d ${name}a = 2" "\\\$$decimal = 2"
+    # scalar with vector
+    gdb_test "print/d ${name}4b %= ${name}a" "\\\$$decimal = \\{1, 0, 0, 0\\}"
+    gdb_test "print/d ${name}4b = \{1, 2, 8, 4\}" "\\\$$decimal = \\{1, 2, 8, 4\\}"
+    gdb_test "print/d ${name}4a <<= ${name}b" "\\\$$decimal = \\{4, 8, 16, 32\\}"
+    gdb_test "print/d ${name}4a >>= ${name}b" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d ${name}4a &= ${name}b" "\\\$$decimal = \\{0, 0, 0, 0\\}"
+    gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d ${name}4a |= ${name}b" "\\\$$decimal = \\{3, 5, 9, 17\\}"
+    gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d ${name}4a ^= ${name}b" "\\\$$decimal = \\{3, 5, 9, 17\\}"
+    gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    # vector with vector
+    gdb_test "print/d ${name}4b %= ${name}4a" "\\\$$decimal = \\{1, 2, 0, 4\\}"
+    gdb_test "print/d ${name}4b = \{1, 2, 8, 4\}" "\\\$$decimal = \\{1, 2, 8, 4\\}"
+    if { ${size} == 1 } {
+      gdb_test "print/d ${name}4a <<= ${name}4b" "\\\$$decimal = \\{4, 16, 0, 0\\}"
+      gdb_test "print/d ${name}4a >>= ${name}4b" "\\\$$decimal = \\{2, 4, 0, 0\\}"
+      gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    } else {
+      gdb_test "print/d ${name}4a <<= ${name}4b" "\\\$$decimal = \\{4, 16, 2048, 256\\}"
+      gdb_test "print/d ${name}4a >>= ${name}4b" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    }
+    gdb_test "print/d ${name}4a &= ${name}4b" "\\\$$decimal = \\{0, 0, 8, 0\\}"
+    gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d ${name}4a |= ${name}4b" "\\\$$decimal = \\{3, 6, 8, 20\\}"
+    gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d ${name}4a ^= ${name}4b" "\\\$$decimal = \\{3, 6, 0, 20\\}"
+    gdb_test "print/d ${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{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" "\\\$$decimal = 1"
+    gdb_test "print/d u${name}a = 2" "\\\$$decimal = 2"
+    gdb_test "print/d u${name}a += u${name}b" "\\\$$decimal = 3"
+    gdb_test "print/d u${name}a -= u${name}b" "\\\$$decimal = 2"
+    gdb_test "print/d u${name}b *= u${name}a" "\\\$$decimal = 2"
+    gdb_test "print/d u${name}b /= u${name}a" "\\\$$decimal = 1"
+    gdb_test "print/d u${name}a %= u${name}b" "\\\$$decimal = 0"
+    gdb_test "print/d u${name}a = 2" "\\\$$decimal = 2"
+    gdb_test "print/d u${name}a <<= u${name}b" "\\\$$decimal = 4"
+    gdb_test "print/d u${name}a = 2" "\\\$$decimal = 2"
+    gdb_test "print/d u${name}a >>= u${name}b" "\\\$$decimal = 1"
+    gdb_test "print/d u${name}a = 2" "\\\$$decimal = 2"
+    gdb_test "print/d u${name}a &= u${name}b" "\\\$$decimal = 0"
+    gdb_test "print/d u${name}a = 2" "\\\$$decimal = 2"
+    gdb_test "print/d u${name}a |= u${name}b" "\\\$$decimal = 3"
+    gdb_test "print/d u${name}a = 2" "\\\$$decimal = 2"
+    gdb_test "print/d u${name}a ^= u${name}b" "\\\$$decimal = 3"
+    gdb_test "print/d u${name}a = 2" "\\\$$decimal = 2"
+    # scalar with vector
+    gdb_test "print/d u${name}4a = u${name}b" "\\\$$decimal = \\{1, 1, 1, 1\\}"
+    gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d u${name}4a += u${name}b" "\\\$$decimal = \\{3, 5, 9, 17\\}"
+    gdb_test "print/d u${name}4a -= u${name}b" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d u${name}4b *= u${name}a" "\\\$$decimal = \\{2, 4, 16, 8\\}"
+    gdb_test "print/d u${name}4b /= u${name}a" "\\\$$decimal = \\{1, 2, 8, 4\\}"
+    gdb_test "print/d u${name}4b %= u${name}a" "\\\$$decimal = \\{1, 0, 0, 0\\}"
+    gdb_test "print/d u${name}4b = \{1, 2, 8, 4\}" "\\\$$decimal = \\{1, 2, 8, 4\\}"
+    gdb_test "print/d u${name}4a <<= u${name}b" "\\\$$decimal = \\{4, 8, 16, 32\\}"
+    gdb_test "print/d u${name}4a >>= u${name}b" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d u${name}4a &= u${name}b" "\\\$$decimal = \\{0, 0, 0, 0\\}"
+    gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d u${name}4a |= u${name}b" "\\\$$decimal = \\{3, 5, 9, 17\\}"
+    gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d u${name}4a ^= u${name}b" "\\\$$decimal = \\{3, 5, 9, 17\\}"
+    gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    # vector with vector
+    gdb_test "print/d u${name}4a = u${name}4b" "\\\$$decimal = \\{1, 2, 8, 4\\}"
+    gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d u${name}4a += u${name}4b" "\\\$$decimal = \\{3, 6, 16, 20\\}"
+    gdb_test "print/d u${name}4a -= u${name}4b" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d u${name}4b *= u${name}4a" "\\\$$decimal = \\{2, 8, 64, 64\\}"
+    gdb_test "print/d u${name}4b /= u${name}4a" "\\\$$decimal = \\{1, 2, 8, 4\\}"
+    gdb_test "print/d u${name}4b %= u${name}4a" "\\\$$decimal = \\{1, 2, 0, 4\\}"
+    gdb_test "print/d u${name}4b = \{1, 2, 8, 4\}" "\\\$$decimal = \\{1, 2, 8, 4\\}"
+    if { ${size} == 1 } {
+      gdb_test "print/d u${name}4a <<= u${name}4b" "\\\$$decimal = \\{4, 16, 0, 0\\}"
+      gdb_test "print/d u${name}4a >>= u${name}4b" "\\\$$decimal = \\{2, 4, 0, 0\\}"
+      gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    } else {
+      gdb_test "print/d u${name}4a <<= u${name}4b" "\\\$$decimal = \\{4, 16, 2048, 256\\}"
+      gdb_test "print/d u${name}4a >>= u${name}4b" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    }
+    gdb_test "print/d u${name}4a &= u${name}4b" "\\\$$decimal = \\{0, 0, 8, 0\\}"
+    gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d u${name}4a |= u${name}4b" "\\\$$decimal = \\{3, 6, 8, 20\\}"
+    gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
+    gdb_test "print/d u${name}4a ^= u${name}4b" "\\\$$decimal = \\{3, 6, 0, 20\\}"
+    gdb_test "print/d u${name}4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{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}
Index: src/gdb/testsuite/gdb.opencl/vec_comps.cl
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/vec_comps.cl	2010-10-26 17:55:33.000000000 +0200
@@ -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;
+}
Index: src/gdb/testsuite/gdb.opencl/vec_comps.exp
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/vec_comps.exp	2010-10-26 17:55:33.000000000 +0200
@@ -0,0 +1,402 @@
+# 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 bin ${objdir}/${subdir}/${testfile}
+set clprogram [remote_download target ${srcdir}/${subdir}/${testfile}.cl]
+
+# Increase timeout
+set timeout 60
+verbose "Timeout set to $timeout seconds" 2
+
+# Compile the generic OpenCL host app
+if { [gdb_compile_opencl_hostapp "${clprogram}" "${bin}" "" ] != "" } {
+    untested ${testfile}.exp
+    return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
+# Load the OpenCL app
+gdb_load ${bin}
+
+# 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
+
+# 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 } {
+  global decimal
+  gdb_test "ptype ${name}" "type = ${type} \\\[16\\\]"
+  gdb_test "p sizeof(${name})" "\\\$$decimal = [expr ${size} * 16]"
+  gdb_test "print/d ${name}" "\\\$$decimal = \\{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 } {
+  global decimal
+
+  gdb_test "print sizeof (${name}.lo)" "\\\$$decimal = [expr $size * 8]"
+  gdb_test "print sizeof (${name}.hi)" "\\\$$decimal = [expr $size * 8]"
+  gdb_test "print sizeof (${name}.even)" "\\\$$decimal = [expr $size * 8]"
+  gdb_test "print sizeof (${name}.odd)" "\\\$$decimal = [expr $size * 8]"
+
+  gdb_test "print sizeof (${name}.hi.even)" "\\\$$decimal = [expr $size * 4]"
+  gdb_test "print sizeof (${name}.odd.odd.lo)" "\\\$$decimal = [expr $size * 2]"
+  gdb_test "print sizeof (${name}.even.hi.lo.odd)" "\\\$$decimal = $size"
+
+  gdb_test "print sizeof (${name}.x)" "\\\$$decimal = $size"
+  gdb_test "print sizeof (${name}.xy)" "\\\$$decimal = [expr $size * 2]"
+  gdb_test "print sizeof (${name}.xyz)" "\\\$$decimal = [expr $size * 4]"
+  gdb_test "print sizeof (${name}.xyzw)" "\\\$$decimal = [expr $size * 4]"
+
+  gdb_test "print sizeof (${name}.xy.x)" "\\\$$decimal = $size"
+  gdb_test "print sizeof (${name}.wzyx.yy)" "\\\$$decimal = [expr $size * 2]"
+  gdb_test "print sizeof (${name}.wzyx.yx.x)" "\\\$$decimal = $size"
+  gdb_test "print sizeof (${name}.xyzw.w)" "\\\$$decimal = $size"
+
+  gdb_test "print sizeof (${name}.s0)" "\\\$$decimal = $size"
+  gdb_test "print sizeof (${name}.s01)" "\\\$$decimal = [expr $size * 2]"
+  gdb_test "print sizeof (${name}.s012)" "\\\$$decimal = [expr $size * 4]"
+  gdb_test "print sizeof (${name}.s0123)" "\\\$$decimal = [expr $size * 4]"
+  gdb_test "print sizeof (${name}.s01234567)" "\\\$$decimal = [expr $size * 8]"
+  gdb_test "print sizeof (${name}.s0123456789abcdef)" "\\\$$decimal = [expr $size * 16]"
+
+  gdb_test "print sizeof (${name}.sfedcba98.S0246)" "\\\$$decimal = [expr $size * 4]"
+  gdb_test "print sizeof (${name}.sfedcba98.S0246.s13)" "\\\$$decimal = [expr $size * 2]"
+  gdb_test "print sizeof (${name}.sfedcba98.S0246.s13.s0)" "\\\$$decimal = $size"
+  gdb_test "print sizeof (${name}.s0123456789abcdef.s22)" "\\\$$decimal = [expr $size * 2]"
+
+  gdb_test "print sizeof (${name}.hi.s7654.wx)" "\\\$$decimal = [expr $size * 2]"
+  gdb_test "print sizeof (${name}.s0123456789abcdef.even.lo)" "\\\$$decimal = [expr $size * 4]"
+  gdb_test "print sizeof (${name}.odd.xyzw.s23)" "\\\$$decimal = [expr $size * 2]"
+  gdb_test "print sizeof (${name}.xyzw.hi.odd)" "\\\$$decimal = $size"
+}
+
+# OpenCL vector component access
+proc check_access { name type } {
+  global decimal
+  gdb_test "print/d ${name}.lo" "\\\$$decimal = \\{0, 1, 2, 3, 4, 5, 6, 7\\}"
+  gdb_test "print/d ${name}.hi" "\\\$$decimal = \\{8, 9, 10, 11, 12, 13, 14, 15\\}"
+  gdb_test "print/d ${name}.even" "\\\$$decimal = \\{0, 2, 4, 6, 8, 10, 12, 14\\}"
+  gdb_test "print/d ${name}.odd" "\\\$$decimal = \\{1, 3, 5, 7, 9, 11, 13, 15\\}"
+
+  gdb_test "print/d ${name}.hi.even" "\\\$$decimal = \\{8, 10, 12, 14\\}"
+  gdb_test "print/d ${name}.odd.odd.lo" "\\\$$decimal = \\{3, 7\\}"
+  gdb_test "print/d ${name}.even.hi.lo.odd" "\\\$$decimal = 10"
+
+  gdb_test "print/d ${name}.x" "\\\$$decimal = 0"
+  gdb_test "print/d ${name}.y" "\\\$$decimal = 1"
+  gdb_test "print/d ${name}.z" "\\\$$decimal = 2"
+  gdb_test "print/d ${name}.w" "\\\$$decimal = 3"
+
+  gdb_test "print/d ${name}.xy" "\\\$$decimal = \\{0, 1\\}"
+  gdb_test "print/d ${name}.xx" "\\\$$decimal = \\{0, 0\\}"
+  gdb_test "print/d ${name}.wy" "\\\$$decimal = \\{3, 1\\}"
+
+  gdb_test "print/d ${name}.xyz" "\\\$$decimal = \\{0, 1, 2\\}"
+  gdb_test "print/d ${name}.yxy" "\\\$$decimal = \\{1, 0, 1\\}"
+  gdb_test "print/d ${name}.yzx" "\\\$$decimal = \\{1, 2, 0\\}"
+
+  gdb_test "print/d ${name}.xywz" "\\\$$decimal = \\{0, 1, 3, 2\\}"
+  gdb_test "print/d ${name}.zzyy" "\\\$$decimal = \\{2, 2, 1, 1\\}"
+  gdb_test "print/d ${name}.wwww" "\\\$$decimal = \\{3, 3, 3, 3\\}"
+
+  gdb_test "print/d ${name}.xy.x" "\\\$$decimal = 0"
+  gdb_test "print/d ${name}.wzyx.yy" "\\\$$decimal = \\{2, 2\\}"
+  gdb_test "print/d ${name}.wzyx.yx.x" "\\\$$decimal = 2"
+  gdb_test "print/d ${name}.xyzw.w" "\\\$$decimal = 3"
+
+  for {set i 0} {$i < 16} {incr i} {
+    gdb_test "print/d ${name}.s[format "%x" $i]" "\\\$$decimal = $i"
+    gdb_test "print/d ${name}.S[format "%x" $i]" "\\\$$decimal = $i"
+    if {$i > 9} {
+      gdb_test "print/d ${name}.s[format "%X" $i]" "\\\$$decimal = $i"
+      gdb_test "print/d ${name}.S[format "%X" $i]" "\\\$$decimal = $i"
+    }
+  }
+
+  gdb_test "print/d ${name}.s01" "\\\$$decimal = \\{0, 1\\}"
+  gdb_test "print/d ${name}.s00" "\\\$$decimal = \\{0, 0\\}"
+  gdb_test "print/d ${name}.sF0" "\\\$$decimal = \\{15, 0\\}"
+  gdb_test "print/d ${name}.S42" "\\\$$decimal = \\{4, 2\\}"
+
+  gdb_test "print/d ${name}.s567" "\\\$$decimal = \\{5, 6, 7\\}"
+  gdb_test "print/d ${name}.S333" "\\\$$decimal = \\{3, 3, 3\\}"
+  gdb_test "print/d ${name}.Sf0A" "\\\$$decimal = \\{15, 0, 10\\}"
+  gdb_test "print/d ${name}.SB1D" "\\\$$decimal = \\{11, 1, 13\\}"
+
+  gdb_test "print/d ${name}.s9876" "\\\$$decimal = \\{9, 8, 7, 6\\}"
+  gdb_test "print/d ${name}.sFFFF" "\\\$$decimal = \\{15, 15, 15, 15\\}"
+  gdb_test "print/d ${name}.sCafe" "\\\$$decimal = \\{12, 10, 15, 14\\}"
+  gdb_test "print/d ${name}.Sf001" "\\\$$decimal = \\{15, 0, 0, 1\\}"
+
+  gdb_test "print/d ${name}.s00000000" "\\\$$decimal = \\{0, 0, 0, 0, 0, 0, 0, 0\\}"
+  gdb_test "print/d ${name}.s00224466" "\\\$$decimal = \\{0, 0, 2, 2, 4, 4, 6, 6\\}"
+  gdb_test "print/d ${name}.sDEADBEEF" "\\\$$decimal = \\{13, 14, 10, 13, 11, 14, 14, 15\\}"
+  gdb_test "print/d ${name}.Sa628c193" "\\\$$decimal = \\{10, 6, 2, 8, 12, 1, 9, 3\\}"
+
+  gdb_test "print/d ${name}.s0123456789aBcDeF" "\\\$$decimal = \\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15\\}"
+  gdb_test "print/d ${name}.s0022446688AACCEE" "\\\$$decimal = \\{0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14\\}"
+  gdb_test "print/d ${name}.S0123456776543210" "\\\$$decimal = \\{0, 1, 2, 3, 4, 5, 6, 7, 7, 6, 5, 4, 3, 2, 1, 0\\}"
+  gdb_test "print/d ${name}.sFEDCBA9876543210" "\\\$$decimal = \\{15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0\\}"
+
+  gdb_test "print/d ${name}.sfedcba98.S0246" "\\\$$decimal = \\{15, 13, 11, 9\\}"
+  gdb_test "print/d ${name}.sfedcba98.S0246.s13" "\\\$$decimal = \\{13, 9\\}"
+  gdb_test "print/d ${name}.sfedcba98.S0246.s13.s0" "\\\$$decimal = 13"
+  gdb_test "print/d ${name}.s0123456789abcdef.s22" "\\\$$decimal = \\{2, 2\\}"
+
+  gdb_test "print/d ${name}.hi.s7654.wx" "\\\$$decimal = \\{12, 15\\}"
+  gdb_test "print/d ${name}.s0123456789abcdef.even.lo" "\\\$$decimal = \\{0, 2, 4, 6\\}"
+  gdb_test "print/d ${name}.odd.xyzw.s23" "\\\$$decimal = \\{5, 7\\}"
+  gdb_test "print/d ${name}.xyzw.hi.odd" "\\\$$decimal = 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]" "\\\$$decimal = [expr 15 - $i]"
+  }
+  gdb_test "print/d ${name}" "\\\$$decimal = \\{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}" "\\\$$decimal = \\{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}" "\\\$$decimal = \\{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}" "\\\$$decimal = \\{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}" "\\\$$decimal = \\{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}
Index: src/gdb/testsuite/lib/cl_util.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/lib/cl_util.c	2010-10-26 17:55:33.000000000 +0200
@@ -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);
+}
Index: src/gdb/testsuite/lib/cl_util.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/lib/cl_util.h	2010-10-26 17:55:33.000000000 +0200
@@ -0,0 +1,85 @@
+/* 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.
+   @param filename The file name of the file to be read
+   @param size Returns the size of the file in bytes
+   @return a pointer the data (NULL if the does not exist)
+*/
+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.
+   @param program The program to be saved
+*/
+extern void save_program_binaries (cl_program program);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CL_UTIL_H */
Index: src/gdb/testsuite/lib/opencl.exp
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/lib/opencl.exp	2010-10-26 17:55:33.000000000 +0200
@@ -0,0 +1,85 @@
+# 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 dest options} {
+    global srcdir objdir
+    set src "${srcdir}/lib/cl_util.c ${srcdir}/lib/opencl_hostapp.c"
+    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 $dest "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 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 bin opencltest[pid].x
+
+    verbose "$me:  compiling OpenCL test app" 2
+    set compile_flags {debug nowarnings quiet}
+
+    if { [gdb_compile_opencl_hostapp "${clprogram}" "${bin}" "" ] != "" } {
+        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.
+    gdb_exit
+    gdb_start
+    gdb_reinitialize_dir $srcdir/$subdir
+    gdb_load "$bin"
+    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 $bin
+
+    # 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)
+}
Index: src/gdb/testsuite/lib/opencl_hostapp.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/lib/opencl_hostapp.c	2010-10-26 17:55:33.000000000 +0200
@@ -0,0 +1,169 @@
+/* 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;
+
+  /* Print OpenCL informations  */
+  /*print_clinfo ();*/
+
+  /* init data */
+  data = (cl_int*) calloc (1, size);
+  if (data == NULL)
+    {
+      fprintf (stderr, "calloc failed\n");
+      exit (EXIT_FAILURE);
+    }
+
+  /* init OpenCL */
+  /* 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 the 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 kernel source */
+  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 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 */
+  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;
+}
Index: src/gdb/testsuite/lib/opencl_kernel.cl
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/lib/opencl_kernel.cl	2010-10-26 17:55:33.000000000 +0200
@@ -0,0 +1,5 @@
+/* OpenCL kernel for testing purposes.  */
+__kernel void testkernel (__global int *data)
+{
+  data[get_global_id(0)] = 0x1;
+}
Index: src/gdb/testsuite/gdb.opencl/convs_casts.cl
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/convs_casts.cl	2010-10-26 17:55:33.000000000 +0200
@@ -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;
+}
Index: src/gdb/testsuite/gdb.opencl/convs_casts.exp
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/convs_casts.exp	2010-10-26 17:55:33.000000000 +0200
@@ -0,0 +1,103 @@
+# 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 bin ${objdir}/${subdir}/${testfile}
+set clprogram [remote_download target ${srcdir}/${subdir}/${testfile}.cl]
+
+# Increase timeout
+set timeout 60
+verbose "Timeout set to $timeout seconds" 2
+
+# Compile the generic OpenCL host app
+if { [gdb_compile_opencl_hostapp "${clprogram}" "${bin}" "" ] != "" } {
+    untested ${testfile}.exp
+    return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
+# Load the OpenCL app
+gdb_load ${bin}
+
+# 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
+
+# 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 decimal 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}" "\\\$$decimal = \\{123, 123\\}"
+    gdb_test "print/d (${type}3)${name}" "\\\$$decimal = \\{123, 123, 123\\}"
+    gdb_test "print/d (${type}4)${name}" "\\\$$decimal = \\{123, 123, 123, 123\\}"
+    gdb_test "print/d (${type}8)${name}" "\\\$$decimal = \\{123, 123, 123, 123, 123, 123, 123, 123\\}"
+    gdb_test "print/d (${type}16)${name}" "\\\$$decimal = \\{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}
Index: src/gdb/c-exp.y
===================================================================
--- src.orig/gdb/c-exp.y	2010-10-26 17:54:59.000000000 +0200
+++ src/gdb/c-exp.y	2010-10-26 17:55:33.000000000 +0200
@@ -612,7 +612,9 @@ exp	:	VARIABLE
 
 exp	:	SIZEOF '(' type ')'	%prec UNARY
 			{ write_exp_elt_opcode (OP_LONG);
-			  write_exp_elt_type (parse_type->builtin_int);
+			  write_exp_elt_type (lookup_signed_typename
+					      (parse_language, parse_gdbarch,
+					       "int"));
 			  CHECK_TYPEDEF ($3);
 			  write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
 			  write_exp_elt_opcode (OP_LONG); }
@@ -980,61 +982,117 @@ typebase  /* Implements (approximately):
 	:	TYPENAME
 			{ $$ = $1.type; }
 	|	INT_KEYWORD
-			{ $$ = parse_type->builtin_int; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "int"); }
 	|	LONG
-			{ $$ = parse_type->builtin_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long"); }
 	|	SHORT
-			{ $$ = parse_type->builtin_short; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "short"); }
 	|	LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long"); }
 	|	LONG SIGNED_KEYWORD INT_KEYWORD
-			{ $$ = parse_type->builtin_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long"); }
 	|	LONG SIGNED_KEYWORD
-			{ $$ = parse_type->builtin_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long"); }
 	|	SIGNED_KEYWORD LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long"); }
 	|	UNSIGNED LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long"); }
 	|	LONG UNSIGNED INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long"); }
 	|	LONG UNSIGNED
-			{ $$ = parse_type->builtin_unsigned_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long"); }
 	|	LONG LONG
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	LONG LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	LONG LONG SIGNED_KEYWORD INT_KEYWORD
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	LONG LONG SIGNED_KEYWORD
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	SIGNED_KEYWORD LONG LONG
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	SIGNED_KEYWORD LONG LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	UNSIGNED LONG LONG
-			{ $$ = parse_type->builtin_unsigned_long_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long long"); }
 	|	UNSIGNED LONG LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_long_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long long"); }
 	|	LONG LONG UNSIGNED
-			{ $$ = parse_type->builtin_unsigned_long_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long long"); }
 	|	LONG LONG UNSIGNED INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_long_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long long"); }
 	|	SHORT INT_KEYWORD
-			{ $$ = parse_type->builtin_short; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "short"); }
 	|	SHORT SIGNED_KEYWORD INT_KEYWORD
-			{ $$ = parse_type->builtin_short; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "short"); }
 	|	SHORT SIGNED_KEYWORD
-			{ $$ = parse_type->builtin_short; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "short"); }
 	|	UNSIGNED SHORT INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_short; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "short"); }
 	|	SHORT UNSIGNED 
-			{ $$ = parse_type->builtin_unsigned_short; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "short"); }
 	|	SHORT UNSIGNED INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_short; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "short"); }
 	|	DOUBLE_KEYWORD
-			{ $$ = parse_type->builtin_double; }
+			{ $$ = lookup_typename (parse_language, parse_gdbarch,
+						"double", (struct block *) NULL,
+						0); }
 	|	LONG DOUBLE_KEYWORD
-			{ $$ = parse_type->builtin_long_double; }
+			{ $$ = lookup_typename (parse_language, parse_gdbarch,
+						"long double",
+						(struct block *) NULL, 0); }
 	|	STRUCT name
 			{ $$ = lookup_struct (copy_name ($2),
 					      expression_context_block); }
@@ -1052,13 +1110,17 @@ typebase  /* Implements (approximately):
 							 parse_gdbarch,
 							 TYPE_NAME($2.type)); }
 	|	UNSIGNED
-			{ $$ = parse_type->builtin_unsigned_int; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "int"); }
 	|	SIGNED_KEYWORD typename
 			{ $$ = lookup_signed_typename (parse_language,
 						       parse_gdbarch,
 						       TYPE_NAME($2.type)); }
 	|	SIGNED_KEYWORD
-			{ $$ = parse_type->builtin_int; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "int"); }
                 /* It appears that this rule for templates is never
                    reduced; template recognition happens by lookahead
                    in the token processing code in yylex. */         
@@ -1077,19 +1139,25 @@ typename:	TYPENAME
 		{
 		  $$.stoken.ptr = "int";
 		  $$.stoken.length = 3;
-		  $$.type = parse_type->builtin_int;
+		  $$.type = lookup_signed_typename (parse_language,
+						    parse_gdbarch,
+						    "int");
 		}
 	|	LONG
 		{
 		  $$.stoken.ptr = "long";
 		  $$.stoken.length = 4;
-		  $$.type = parse_type->builtin_long;
+		  $$.type = lookup_signed_typename (parse_language,
+						    parse_gdbarch,
+						    "long");
 		}
 	|	SHORT
 		{
 		  $$.stoken.ptr = "short";
 		  $$.stoken.length = 5;
-		  $$.type = parse_type->builtin_short;
+		  $$.type = lookup_signed_typename (parse_language,
+						    parse_gdbarch,
+						    "short");
 		}
 	;
 
Index: src/gdb/c-lang.h
===================================================================
--- src.orig/gdb/c-lang.h	2010-10-26 17:54:58.000000000 +0200
+++ src/gdb/c-lang.h	2010-10-26 17:55:33.000000000 +0200
@@ -27,6 +27,7 @@ struct language_arch_info;
 
 #include "value.h"
 #include "macroexp.h"
+#include "parser-defs.h"
 
 
 /* The various kinds of C string and character.  Note that these
@@ -78,6 +79,10 @@ extern int c_value_print (struct value *
 
 /* These are in c-lang.c: */
 
+extern struct value * evaluate_subexp_c (struct type *expect_type,
+					 struct expression *exp, int *pos,
+					 enum noside noside);
+
 extern void c_printchar (int, struct type *, struct ui_file *);
 
 extern void c_printstr (struct ui_file * stream, struct type *elttype,
@@ -93,6 +98,8 @@ extern const struct exp_descriptor exp_d
 extern void c_emit_char (int c, struct type *type,
 			 struct ui_file *stream, int quoter);
 
+extern const struct op_print c_op_print_tab[];
+
 /* These are in c-typeprint.c: */
 
 extern void c_type_print_base (struct type *, struct ui_file *, int, int);
Index: src/gdb/c-lang.c
===================================================================
--- src.orig/gdb/c-lang.c	2010-10-26 17:54:58.000000000 +0200
+++ src/gdb/c-lang.c	2010-10-26 17:55:33.000000000 +0200
@@ -933,7 +933,7 @@ parse_one_string (struct obstack *output
    are delegated to evaluate_subexp_standard; see that function for a
    description of the arguments.  */
 
-static struct value *
+struct value *
 evaluate_subexp_c (struct type *expect_type, struct expression *exp,
 		   int *pos, enum noside noside)
 {

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] initial OpenCL C language support
  2010-10-26 16:02       ` Ken Werner
@ 2010-10-26 17:49         ` Eli Zaretskii
  2010-10-26 19:58         ` Joel Brobecker
  1 sibling, 0 replies; 36+ messages in thread
From: Eli Zaretskii @ 2010-10-26 17:49 UTC (permalink / raw)
  To: Ken Werner; +Cc: tromey, gdb-patches

> From: Ken Werner <ken@linux.vnet.ibm.com>
> Date: Tue, 26 Oct 2010 18:00:43 +0200
> Cc: gdb-patches@sourceware.org
> 
> The attached patch changes evaluate_subexp_opencl to call the 
> now non-static evaluate_subexp_c. I've also moved the OpenCL language 
> detection from read_type_unit_scope to read_file_scope. The chunk was moved 
> accidentally when I ported this patch from the 7.2 release to the current 
> head.

Thanks.

I think this is NEWS-worthy.

Also, what people think about adding this to the list of supported
languages in the section "Supported Languages" of the user manual?

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] initial OpenCL C language support
  2010-10-26 16:02       ` Ken Werner
  2010-10-26 17:49         ` Eli Zaretskii
@ 2010-10-26 19:58         ` Joel Brobecker
  2010-10-26 20:03           ` Joel Brobecker
  2010-10-27 19:04           ` Jan Kratochvil
  1 sibling, 2 replies; 36+ messages in thread
From: Joel Brobecker @ 2010-10-26 19:58 UTC (permalink / raw)
  To: Ken Werner; +Cc: Tom Tromey, gdb-patches

> 2010-10-26  Ken Werner  <ken.werner@de.ibm.com>
> 
> 	* 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.
> 
> testsuite/ChangeLog:
> 
> 2010-10-26  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.

I have a few comments, and I feel like most of the changes except maybe
the ones in c-exp.y can go in without a followup review.

> Index: src/gdb/opencl-lang.c
[...]
> +#include <string.h>
> +#include "defs.h"

The include of <string.h> directly should be replaced by an include of
"gdb_string.h". Also, the first include should always be "defs.h".

> +/* Returns the corresponding OpenCL vector type from the given type code,
> +   the length of the element type, the unsigned flag and the amount of
> +   elements (n).  */
> +static struct type *
> +lookup_opencl_vector_type (struct gdbarch *gdbarch, enum type_code code,
> +			   unsigned int el_length, unsigned int flag_unsigned,
> +			   int n)

It's really nice to see someone who documents its code.  Just a tiny nit:
Our coding style require an empty line after the comment, before the
function definition starts (there are other instances of this later,
which I did not point out).

> +/* Returns whether array contains duplicates or not within the first n number
> +   of elements.  */

Another little style nit that I'd love to see fixed in your submission,
even if I'm not personally too fussy about, is to use capital letters
when referring to function parameters.  For instance, your comment above
could be adjusted to:

> /* Returns whether the array ARR contains duplicates or not within
>    the first N elements.  */

Usually, we even write this as:

  /* Returns non-zero if the array ARR contains duplicates within
     the first N elements.  */

> +  /* The number of indicies.  */
                      "indices"
> +  /* The element indicies themselves.  */
                    ^^^^^^^^

> +  /* Assume elsize aligned offset.  */
> +  gdb_assert (offset % elsize == 0);
> +  offset /= elsize;
     ^^^^^^^^^^^^^^^^^ ????

> +  for (i = offset; i < n; i++)
> +    {
> +      struct value *from_elm_val = allocate_value (eltype);
> +      struct value *to_elm_val = value_subscript (c->val, c->indices[i]);
> +      memcpy (value_contents_writeable (from_elm_val),

Another GDB coding style rule: Empty line after local declarations...
Most of the time, you are already following that rule, but there are
a few instance where the empty line is missing.

> +  /* Multiple components of the vector are requested which means the
> +     resulting type is a vector as well.  */
> +  else
> +    {

That's just a personal comment, so feel free to follow or not: I would
move the comment inside the else block.  It would make it more obvious
that the comment only applies to that case.  And it would also avoid
slightly splitting the else part from the associated if block.

> +    case BINOP_NOTEQUAL:
> +      ret = ! value_equal (val1, val2);
              ^^^^^ extra space

> +	      /* Throw an error if arg2 or arg3 aren't vecors.  */
                                                       ^^^^^^ vectors
> +# Increase timeout
> +set timeout 60
> +verbose "Timeout set to $timeout seconds" 2

Is that really necessary? (just curious)

> +gdb_exit
> +gdb_start
> +gdb_reinitialize_dir $srcdir/$subdir
> +
> +# Load the OpenCL app
> +gdb_load ${bin}

Did you know about clean_restart? This is also documented in the testsuite
cookbook.

> +gdb_test "p sizeof(bool)" "\\\$$decimal = 4"

Small remark - the way you wrote the these tests is completely correct,
but most of us don't bother matching the $N part of the output, and
write these kinds of test as:

    gdb_test "p sizeof(bool)" " = 4"

> +gdb_run_cmd

See `Running the Example Program in GDB' in the GDB Testsuite cookbook
(http://sourceware.org/gdb/wiki/GDBTestcaseCookbook): you should add
a test that "swallows" the output from the run command.

> +/* Prints OpenCL information to stdout. */

Missing second space after the period.

> +/* Reads a given file into the memory.
> +   @param filename The file name of the file to be read
> +   @param size Returns the size of the file in bytes
> +   @return a pointer the data (NULL if the does not exist)

The style of the documentation does not follow the GDB style...

> +  /* Print OpenCL informations  */
> +  /*print_clinfo ();*/

This commented-out code should be removed.

> +  /* init data */

IWBN if we followed the GNU Coding Standards for comments, and in
particular if the sentence ended with a period.

>  	|	SHORT INT_KEYWORD
> -			{ $$ = parse_type->builtin_short; }
> +			{ $$ = lookup_signed_typename (parse_language,
> +						       parse_gdbarch,
> +						       "short"); }

Just wondering why this change is necessary (?). Can you explain a
little more?

> +extern struct value * evaluate_subexp_c (struct type *expect_type,
                       ^^ no space after the '*'

-- 
Joel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] initial OpenCL C language support
  2010-10-26 19:58         ` Joel Brobecker
@ 2010-10-26 20:03           ` Joel Brobecker
  2010-10-27 13:36             ` Ken Werner
  2010-10-27 19:04           ` Jan Kratochvil
  1 sibling, 1 reply; 36+ messages in thread
From: Joel Brobecker @ 2010-10-26 20:03 UTC (permalink / raw)
  To: Ken Werner; +Cc: Tom Tromey, gdb-patches

> I have a few comments, and I feel like most of the changes except maybe
> the ones in c-exp.y can go in without a followup review.

Just to clarify a bit what I was trying to say: Most of the comments are
mostly cosmetic, and I don't think we need to verify that you followed
the comments correctly. If this was the only comments I had, I would be
comfortable with pre-approving the patch, particularly since Tom already
looked at it as well.  But before the patch goes in, I'd like to understand
what the reason for the changes in c-exp.y...

-- 
Joel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] initial OpenCL C language support
  2010-10-26 20:03           ` Joel Brobecker
@ 2010-10-27 13:36             ` Ken Werner
  2010-11-02 19:23               ` Joel Brobecker
  0 siblings, 1 reply; 36+ messages in thread
From: Ken Werner @ 2010-10-27 13:36 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Tom Tromey, gdb-patches

[-- Attachment #1: Type: Text/Plain, Size: 1062 bytes --]

On Tuesday, October 26, 2010 10:03:26 pm Joel Brobecker wrote:
> > I have a few comments, and I feel like most of the changes except maybe
> > the ones in c-exp.y can go in without a followup review.

Thanks for your review! Attached is revised patch that incorporates fixes for 
the issues you mentioned.

> Just to clarify a bit what I was trying to say: Most of the comments are
> mostly cosmetic, and I don't think we need to verify that you followed
> the comments correctly. If this was the only comments I had, I would be
> comfortable with pre-approving the patch, particularly since Tom already
> looked at it as well.  But before the patch goes in, I'd like to understand
> what the reason for the changes in c-exp.y...

The reason for looking up the primitive types instead of referring to the 
builtins is that the builtin types may have a wrong type size. The OpenCL type 
long for example is expected to have a size of 8 byte while the size of the 
GDB builtin long is dependant on the current architecture and might be only 4 
bytes.

Regards
Ken

[-- Attachment #2: opencl-lang.patch --]
[-- Type: text/x-patch, Size: 191918 bytes --]

ChangeLog:

2010-10-27  Ken Werner  <ken.werner@de.ibm.com>

	* 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.

testsuite/ChangeLog:

2010-10-27  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.


Index: src/gdb/defs.h
===================================================================
--- src.orig/gdb/defs.h	2010-10-27 14:54:00.000000000 +0200
+++ src/gdb/defs.h	2010-10-27 14:54:29.000000000 +0200
@@ -202,6 +202,7 @@ enum language
     language_pascal,		/* Pascal */
     language_ada,		/* Ada */
     language_scm,		/* Guile Scheme */
+    language_opencl,		/* OpenCL */
     language_minimal,		/* All other languages, minimal support only */
     nr_languages
   };
Index: src/gdb/dwarf2read.c
===================================================================
--- src.orig/gdb/dwarf2read.c	2010-10-27 14:54:00.000000000 +0200
+++ src/gdb/dwarf2read.c	2010-10-27 14:54:29.000000000 +0200
@@ -5089,6 +5089,12 @@ read_file_scope (struct die_info *die, s
   if (attr)
     cu->producer = DW_STRING (attr);
 
+  /* The XLCL doesn't generate DW_LANG_OpenCL because this attribute is not
+     standardised yet.  As a workaround for the language detection we fall
+     back to the DW_AT_producer string.  */
+  if (cu->producer && strstr (cu->producer, "IBM XL C for OpenCL") != NULL)
+    cu->language = language_opencl;
+
   /* We assume that we're processing GCC output. */
   processing_gcc_compilation = 2;
 
Index: src/gdb/opencl-lang.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/opencl-lang.c	2010-10-27 15:22:52.000000000 +0200
@@ -0,0 +1,1165 @@
+/* OpenCL language support for GDB, the GNU debugger.
+   Copyright (C) 2010 Free Software Foundation, Inc.
+
+   Contributed by Ken Werner <ken.werner@de.ibm.com>.
+
+   This file is part of GDB.
+
+   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/>.  */
+
+#include "defs.h"
+#include "gdb_string.h"
+#include "gdbtypes.h"
+#include "symtab.h"
+#include "expression.h"
+#include "parser-defs.h"
+#include "symtab.h"
+#include "language.h"
+#include "c-lang.h"
+#include "gdb_assert.h"
+
+extern void _initialize_opencl_language (void);
+
+/* This macro generates enum values from a given type.  */
+
+#define OCL_P_TYPE(TYPE)\
+  opencl_primitive_type_##TYPE,\
+  opencl_primitive_type_##TYPE##2,\
+  opencl_primitive_type_##TYPE##3,\
+  opencl_primitive_type_##TYPE##4,\
+  opencl_primitive_type_##TYPE##8,\
+  opencl_primitive_type_##TYPE##16
+
+enum opencl_primitive_types {
+  OCL_P_TYPE (char),
+  OCL_P_TYPE (uchar),
+  OCL_P_TYPE (short),
+  OCL_P_TYPE (ushort),
+  OCL_P_TYPE (int),
+  OCL_P_TYPE (uint),
+  OCL_P_TYPE (long),
+  OCL_P_TYPE (ulong),
+  OCL_P_TYPE (half),
+  OCL_P_TYPE (float),
+  OCL_P_TYPE (double),
+  opencl_primitive_type_bool,
+  opencl_primitive_type_unsigned_char,
+  opencl_primitive_type_unsigned_short,
+  opencl_primitive_type_unsigned_int,
+  opencl_primitive_type_unsigned_long,
+  opencl_primitive_type_size_t,
+  opencl_primitive_type_ptrdiff_t,
+  opencl_primitive_type_intptr_t,
+  opencl_primitive_type_uintptr_t,
+  opencl_primitive_type_void,
+  nr_opencl_primitive_types
+};
+
+/* This macro generates the type struct declarations from a given type.  */
+
+#define STRUCT_OCL_TYPE(TYPE)\
+  struct type *builtin_##TYPE;\
+  struct type *builtin_##TYPE##2;\
+  struct type *builtin_##TYPE##3;\
+  struct type *builtin_##TYPE##4;\
+  struct type *builtin_##TYPE##8;\
+  struct type *builtin_##TYPE##16
+
+struct builtin_opencl_type
+{
+  STRUCT_OCL_TYPE (char);
+  STRUCT_OCL_TYPE (uchar);
+  STRUCT_OCL_TYPE (short);
+  STRUCT_OCL_TYPE (ushort);
+  STRUCT_OCL_TYPE (int);
+  STRUCT_OCL_TYPE (uint);
+  STRUCT_OCL_TYPE (long);
+  STRUCT_OCL_TYPE (ulong);
+  STRUCT_OCL_TYPE (half);
+  STRUCT_OCL_TYPE (float);
+  STRUCT_OCL_TYPE (double);
+  struct type *builtin_bool;
+  struct type *builtin_unsigned_char;
+  struct type *builtin_unsigned_short;
+  struct type *builtin_unsigned_int;
+  struct type *builtin_unsigned_long;
+  struct type *builtin_size_t;
+  struct type *builtin_ptrdiff_t;
+  struct type *builtin_intptr_t;
+  struct type *builtin_uintptr_t;
+  struct type *builtin_void;
+};
+
+static struct gdbarch_data *opencl_type_data;
+
+const struct builtin_opencl_type *
+builtin_opencl_type (struct gdbarch *gdbarch)
+{
+  return gdbarch_data (gdbarch, opencl_type_data);
+}
+
+/* Returns the corresponding OpenCL vector type from the given type code,
+   the length of the element type, the unsigned flag and the amount of
+   elements (N).  */
+
+static struct type *
+lookup_opencl_vector_type (struct gdbarch *gdbarch, enum type_code code,
+			   unsigned int el_length, unsigned int flag_unsigned,
+			   int n)
+{
+  int i;
+  unsigned int length;
+  struct type *type = NULL;
+  struct type **types = (struct type **) builtin_opencl_type (gdbarch);
+
+  /* Check if n describes a valid OpenCL vector size (2, 3, 4, 8, 16).  */
+  if (n != 2 && n != 3 && n != 4 && n != 8 && n != 16)
+    error (_("Invalid OpenCL vector size: %d"), n);
+
+  /* Triple vectors have the size of a quad vector. */
+  length = (n == 3) ?  el_length * 4 : el_length * n;
+
+  for (i = 0; i < nr_opencl_primitive_types; i++)
+    {
+      LONGEST lowb, highb;
+
+      if (TYPE_CODE (types[i]) == TYPE_CODE_ARRAY && TYPE_VECTOR (types[i])
+	  && get_array_bounds (types[i], &lowb, &highb)
+	  && TYPE_CODE (TYPE_TARGET_TYPE (types[i])) == code
+	  && TYPE_UNSIGNED (TYPE_TARGET_TYPE (types[i])) == flag_unsigned
+	  && TYPE_LENGTH (TYPE_TARGET_TYPE (types[i])) == el_length
+	  && TYPE_LENGTH (types[i]) == length
+	  && highb - lowb + 1 == n)
+	{
+	  type = types[i];
+	  break;
+	}
+    }
+
+  return type;
+}
+
+/* Returns non-zero if the array ARR contains duplicates within
+     the first N elements.  */
+
+static int
+array_has_dups (int arr[], int n)
+{
+  int i, j;
+
+  for (i = 0; i < n; i++)
+    {
+      for (j = i + 1; j < n; j++)
+        {
+          if (arr[i] == arr[j])
+            return 1;
+        }
+    }
+
+  return 0;
+}
+
+/* The OpenCL component access syntax allows to create lvalues referring to
+   selected elements of an original OpenCL vector in arbitrary order.  This
+   structure holds the information to describe such lvalues.  */
+
+struct lval_closure
+{
+  /* Reference count.  */
+  int refc;
+  /* The number of indices.  */
+  int n;
+  /* The element indices themselves.  */
+  int *indices;
+  /* A pointer to the original value.  */
+  struct value *val;
+};
+
+/* Allocates an instance of struct lval_closure.  */
+
+static struct lval_closure *
+allocate_lval_closure (int indices[], int n, struct value *val)
+{
+  struct lval_closure *c = XZALLOC (struct lval_closure);
+
+  c->refc = 1;
+  c->n = n;
+  c->indices = XCALLOC (n, int);
+  memcpy (c->indices, indices, n * sizeof (int));
+  value_incref (val); /* Increment the reference counter of the value.  */
+  c->val = val;
+
+  return c;
+}
+
+static void
+lval_func_read (struct value *v)
+{
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+  struct type *type = check_typedef (value_type (v));
+  struct type *eltype = TYPE_TARGET_TYPE (check_typedef (value_type (c->val)));
+  int offset = value_offset (v);
+  int elsize = TYPE_LENGTH (eltype);
+  int n, i, j = 0;
+  LONGEST lowb = 0;
+  LONGEST highb = 0;
+
+  if (TYPE_CODE (type) == TYPE_CODE_ARRAY
+      && !get_array_bounds (type, &lowb, &highb))
+    error (_("Could not determine the vector bounds"));
+
+  /* Assume elsize aligned offset.  */
+  gdb_assert (offset % elsize == 0);
+  offset /= elsize;
+  n = offset + highb - lowb + 1;
+  gdb_assert (n <= c->n);
+
+  for (i = offset; i < n; i++)
+    {
+      memcpy (value_contents_raw (v) + j++ * elsize,
+	      value_contents (c->val) + c->indices[i] * elsize,
+	      elsize);
+    }
+}
+
+static void
+lval_func_write (struct value *v, struct value *fromval)
+{
+  struct value *mark = value_mark ();
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+  struct type *type = check_typedef (value_type (v));
+  struct type *eltype = TYPE_TARGET_TYPE (check_typedef (value_type (c->val)));
+  int offset = value_offset (v);
+  int elsize = TYPE_LENGTH (eltype);
+  int n, i, j = 0;
+  LONGEST lowb = 0;
+  LONGEST highb = 0;
+
+  if (TYPE_CODE (type) == TYPE_CODE_ARRAY
+      && !get_array_bounds (type, &lowb, &highb))
+    error (_("Could not determine the vector bounds"));
+
+  /* Assume elsize aligned offset.  */
+  gdb_assert (offset % elsize == 0);
+  offset /= elsize;
+  n = offset + highb - lowb + 1;
+
+  /* Since accesses to the fourth component of a triple vector is undefined we
+     just skip writes to the fourth element.  Imagine something like this:
+       int3 i3 = (int3)(0, 1, 2);
+       i3.hi.hi = 5;
+     In this case n would be 4 (offset=12/4 + 1) while c->n would be 3.  */
+  if (n > c->n)
+    n = c->n;
+
+  for (i = offset; i < n; i++)
+    {
+      struct value *from_elm_val = allocate_value (eltype);
+      struct value *to_elm_val = value_subscript (c->val, c->indices[i]);
+
+      memcpy (value_contents_writeable (from_elm_val),
+	      value_contents (fromval) + j++ * elsize,
+	      elsize);
+      value_assign (to_elm_val, from_elm_val);
+    }
+
+  value_free_to_mark (mark);
+}
+
+/* Return non-zero if all bits in V within OFFSET and LENGTH are valid.  */
+
+static int
+lval_func_check_validity (const struct value *v, int offset, int length)
+{
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+  /* Size of the target type in bits.  */
+  int elsize =
+      TYPE_LENGTH (TYPE_TARGET_TYPE (check_typedef (value_type (c->val)))) * 8;
+  int startrest = offset % elsize;
+  int start = offset / elsize;
+  int endrest = (offset + length) % elsize;
+  int end = (offset + length) / elsize;
+  int i;
+
+  if (endrest)
+    end++;
+
+  if (end > c->n)
+    return 0;
+
+  for (i = start; i < end; i++)
+    {
+      int startoffset = (i == start) ? startrest : 0;
+      int length = (i == end) ? endrest : elsize;
+      if (!value_bits_valid (c->val, c->indices[i] * elsize + startoffset,
+			     length))
+	return 0;
+    }
+
+  return 1;
+}
+
+/* Return non-zero if any bit in V is valid.  */
+
+static int
+lval_func_check_any_valid (const struct value *v)
+{
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+  /* Size of the target type in bits.  */
+  int elsize =
+      TYPE_LENGTH (TYPE_TARGET_TYPE (check_typedef (value_type (c->val)))) * 8;
+  int i;
+
+  for (i = 0; i < c->n; i++)
+    {
+      if (value_bits_valid (c->val, c->indices[i] * elsize, elsize))
+	return 1;
+    }
+
+  return 0;
+}
+
+static void *
+lval_func_copy_closure (const struct value *v)
+{
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+
+  ++c->refc;
+
+  return c;
+}
+
+static void
+lval_func_free_closure (struct value *v)
+{
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+
+  --c->refc;
+
+  if (c->refc == 0)
+    {
+      xfree (c->indices);
+      xfree (c);
+      value_free (c->val); /* Decrement the reference counter of the value.  */
+    }
+}
+
+static struct lval_funcs opencl_value_funcs =
+  {
+    lval_func_read,
+    lval_func_write,
+    lval_func_check_validity,
+    lval_func_check_any_valid,
+    lval_func_copy_closure,
+    lval_func_free_closure
+  };
+
+/* Creates a sub-vector from VAL.  The elements are selected by the indices of
+   an array with the length of N.  Supported values for NOSIDE are
+   EVAL_NORMAL and EVAL_AVOID_SIDE_EFFECTS.  */
+
+static struct value *
+create_value (struct gdbarch *gdbarch, struct value *val, enum noside noside,
+	      int indices[], int n)
+{
+  struct type *type = check_typedef (value_type (val));
+  struct type *elm_type = TYPE_TARGET_TYPE (type);
+  struct value *ret;
+
+  /* Check if a single component of a vector is requested which means
+     the resulting type is a (primitive) scalar type.  */
+  if (n == 1)
+    {
+      if (noside == EVAL_AVOID_SIDE_EFFECTS)
+        ret = value_zero (elm_type, not_lval);
+      else
+        ret = value_subscript (val, indices[0]);
+    }
+  else
+    {
+      /* Multiple components of the vector are requested which means the
+	 resulting type is a vector as well.  */
+      struct type *dst_type =
+	lookup_opencl_vector_type (gdbarch, TYPE_CODE (elm_type),
+				   TYPE_LENGTH (elm_type),
+				   TYPE_UNSIGNED (elm_type), n);
+
+      if (dst_type == NULL)
+	dst_type = init_vector_type (elm_type, n);
+
+      make_cv_type (TYPE_CONST (type), TYPE_VOLATILE (type), dst_type, NULL);
+
+      if (noside == EVAL_AVOID_SIDE_EFFECTS)
+	ret = allocate_value (dst_type);
+      else
+	{
+	  /* Check whether to create a lvalue or not.  */
+	  if (VALUE_LVAL (val) != not_lval && !array_has_dups (indices, n))
+	    {
+	      struct lval_closure *c = allocate_lval_closure (indices, n, val);
+	      ret = allocate_computed_value (dst_type, &opencl_value_funcs, c);
+	    }
+	  else
+	    {
+	      int i;
+
+	      ret = allocate_value (dst_type);
+
+	      for (i = 0; i < n; i++)
+		{
+		  /* Copy src val contents into the destination value.  */
+		  memcpy (value_contents_writeable (ret)
+			  + (i * TYPE_LENGTH (elm_type)),
+			  value_contents (val)
+			  + (indices[i] * TYPE_LENGTH (elm_type)),
+			  TYPE_LENGTH (elm_type));
+		}
+	    }
+	}
+    }
+  return ret;
+}
+
+/* OpenCL vector component access.  */
+
+static struct value *
+opencl_component_ref (struct expression *exp, struct value *val, char *comps,
+		      enum noside noside)
+{
+  LONGEST lowb, highb;
+  int src_len;
+  struct value *v;
+  int indices[16], i;
+  int dst_len;
+
+  if (!get_array_bounds (check_typedef (value_type (val)), &lowb, &highb))
+    error (_("Could not determine the vector bounds"));
+
+  src_len = highb - lowb + 1;
+
+  /* Throw an error if the amount of array elements does not fit a
+     valid OpenCL vector size (2, 3, 4, 8, 16).  */
+  if (src_len != 2 && src_len != 3 && src_len != 4 && src_len != 8
+      && src_len != 16)
+    error (_("Invalid OpenCL vector size"));
+
+  if (strcmp (comps, "lo") == 0 )
+    {
+      dst_len = (src_len == 3) ? 2 : src_len / 2;
+
+      for (i = 0; i < dst_len; i++)
+	indices[i] = i;
+    }
+  else if (strcmp (comps, "hi") == 0)
+    {
+      dst_len = (src_len == 3) ? 2 : src_len / 2;
+
+      for (i = 0; i < dst_len; i++)
+	indices[i] = dst_len + i;
+    }
+  else if (strcmp (comps, "even") == 0)
+    {
+      dst_len = (src_len == 3) ? 2 : src_len / 2;
+
+      for (i = 0; i < dst_len; i++)
+	indices[i] = i*2;
+    }
+  else if (strcmp (comps, "odd") == 0)
+    {
+      dst_len = (src_len == 3) ? 2 : src_len / 2;
+
+      for (i = 0; i < dst_len; i++)
+        indices[i] = i*2+1;
+    }
+  else if (strncasecmp (comps, "s", 1) == 0)
+    {
+#define HEXCHAR_TO_INT(C) ((C >= '0' && C <= '9') ? \
+                           C-'0' : ((C >= 'A' && C <= 'F') ? \
+                           C-'A'+10 : ((C >= 'a' && C <= 'f') ? \
+                           C-'a'+10 : -1)))
+
+      dst_len = strlen (comps);
+      /* Skip the s/S-prefix.  */
+      dst_len--;
+
+      for (i = 0; i < dst_len; i++)
+	{
+	  indices[i] = HEXCHAR_TO_INT(comps[i+1]);
+	  /* Check if the requested component is invalid or exceeds
+	     the vector.  */
+	  if (indices[i] < 0 || indices[i] >= src_len)
+	    error (_("Invalid OpenCL vector component accessor %s"), comps);
+	}
+    }
+  else
+    {
+      dst_len = strlen (comps);
+
+      for (i = 0; i < dst_len; i++)
+	{
+	  /* x, y, z, w */
+	  switch (comps[i])
+	  {
+	  case 'x':
+	    indices[i] = 0;
+	    break;
+	  case 'y':
+	    indices[i] = 1;
+	    break;
+	  case 'z':
+	    if (src_len < 3)
+	      error (_("Invalid OpenCL vector component accessor %s"), comps);
+	    indices[i] = 2;
+	    break;
+	  case 'w':
+	    if (src_len < 4)
+	      error (_("Invalid OpenCL vector component accessor %s"), comps);
+	    indices[i] = 3;
+	    break;
+	  default:
+	    error (_("Invalid OpenCL vector component accessor %s"), comps);
+	    break;
+	  }
+	}
+    }
+
+  /* Throw an error if the amount of requested components does not
+     result in a valid length (1, 2, 3, 4, 8, 16).  */
+  if (dst_len != 1 && dst_len != 2 && dst_len != 3 && dst_len != 4
+      && dst_len != 8 && dst_len != 16)
+    error (_("Invalid OpenCL vector component accessor %s"), comps);
+
+  v = create_value (exp->gdbarch, val, noside, indices, dst_len);
+
+  return v;
+}
+
+/* Perform the unary logical not (!) operation.  */
+
+static struct value *
+opencl_logical_not (struct expression *exp, struct value *arg)
+{
+  struct type *type = check_typedef (value_type (arg));
+  struct type *rettype;
+  struct value *ret;
+
+  if (TYPE_CODE (type) == TYPE_CODE_ARRAY && TYPE_VECTOR (type))
+    {
+      struct type *eltype = check_typedef (TYPE_TARGET_TYPE (type));
+      LONGEST lowb, highb;
+      int i;
+
+      if (!get_array_bounds (type, &lowb, &highb))
+	error (_("Could not determine the vector bounds"));
+
+      /* Determine the resulting type of the operation and allocate the
+	 value.  */
+      rettype = lookup_opencl_vector_type (exp->gdbarch, TYPE_CODE_INT,
+					   TYPE_LENGTH (eltype), 0,
+					   highb - lowb + 1);
+      ret = allocate_value (rettype);
+
+      for (i = 0; i < highb - lowb + 1; i++)
+	{
+	  /* For vector types, the unary operator shall return a 0 if the
+	  value of its operand compares unequal to 0, and -1 (i.e. all bits
+	  set) if the value of its operand compares equal to 0.  */
+	  int tmp = value_logical_not (value_subscript (arg, i)) ? -1 : 0;
+	  memset (value_contents_writeable (ret) + i * TYPE_LENGTH (eltype),
+		  tmp, TYPE_LENGTH (eltype));
+	}
+    }
+  else
+    {
+      rettype = language_bool_type (exp->language_defn, exp->gdbarch);
+      ret = value_from_longest (rettype, value_logical_not (arg));
+    }
+
+  return ret;
+}
+
+/* Perform a relational operation on two scalar operands.  */
+
+static int
+scalar_relop (struct value *val1, struct value *val2, enum exp_opcode op)
+{
+  int ret;
+
+  switch (op)
+    {
+    case BINOP_EQUAL:
+      ret = value_equal (val1, val2);
+      break;
+    case BINOP_NOTEQUAL:
+      ret =! value_equal (val1, val2);
+      break;
+    case BINOP_LESS:
+      ret = value_less (val1, val2);
+      break;
+    case BINOP_GTR:
+      ret = value_less (val2, val1);
+      break;
+    case BINOP_GEQ:
+      ret = value_less (val2, val1) || value_equal (val1, val2);
+      break;
+    case BINOP_LEQ:
+      ret = value_less (val1, val2) || value_equal (val1, val2);
+      break;
+    case BINOP_LOGICAL_AND:
+      ret = !value_logical_not (val1) && !value_logical_not (val2);
+      break;
+    case BINOP_LOGICAL_OR:
+      ret = !value_logical_not (val1) || !value_logical_not (val2);
+      break;
+    default:
+      error (_("Attempt to perform an unsupported operation"));
+      break;
+    }
+  return ret;
+}
+
+/* Perform a relational operation on two vector operands.  */
+
+static struct value *
+vector_relop (struct expression *exp, struct value *val1, struct value *val2,
+	      enum exp_opcode op)
+{
+  struct value *ret;
+  struct type *type1, *type2, *eltype1, *eltype2, *rettype;
+  int t1_is_vec, t2_is_vec, i;
+  LONGEST lowb1, lowb2, highb1, highb2;
+
+  type1 = check_typedef (value_type (val1));
+  type2 = check_typedef (value_type (val2));
+
+  t1_is_vec = (TYPE_CODE (type1) == TYPE_CODE_ARRAY && TYPE_VECTOR (type1));
+  t2_is_vec = (TYPE_CODE (type2) == TYPE_CODE_ARRAY && TYPE_VECTOR (type2));
+
+  if (!t1_is_vec || !t2_is_vec)
+    error (_("Vector operations are not supported on scalar types"));
+
+  eltype1 = check_typedef (TYPE_TARGET_TYPE (type1));
+  eltype2 = check_typedef (TYPE_TARGET_TYPE (type2));
+
+  if (!get_array_bounds (type1,&lowb1, &highb1)
+      || !get_array_bounds (type2, &lowb2, &highb2))
+    error (_("Could not determine the vector bounds"));
+
+  /* Check whether the vector types are compatible.  */
+  if (TYPE_CODE (eltype1) != TYPE_CODE (eltype2)
+      || TYPE_LENGTH (eltype1) != TYPE_LENGTH (eltype2)
+      || TYPE_UNSIGNED (eltype1) != TYPE_UNSIGNED (eltype2)
+      || lowb1 != lowb2 || highb1 != highb2)
+    error (_("Cannot perform operation on vectors with different types"));
+
+  /* Determine the resulting type of the operation and allocate the value.  */
+  rettype = lookup_opencl_vector_type (exp->gdbarch, TYPE_CODE_INT,
+				       TYPE_LENGTH (eltype1), 0,
+				       highb1 - lowb1 + 1);
+  ret = allocate_value (rettype);
+
+  for (i = 0; i < highb1 - lowb1 + 1; i++)
+    {
+      /* For vector types, the relational, equality and logical operators shall
+	 return 0 if the specified relation is false and -1 (i.e. all bits set)
+	 if the specified relation is true.  */
+      int tmp = scalar_relop (value_subscript (val1, i),
+			      value_subscript (val2, i), op) ? -1 : 0;
+      memset (value_contents_writeable (ret) + i * TYPE_LENGTH (eltype1),
+	      tmp, TYPE_LENGTH (eltype1));
+     }
+
+  return ret;
+}
+
+/* Perform a relational operation on two operands.  */
+static struct value *
+opencl_relop (struct expression *exp, struct value *arg1, struct value *arg2,
+	      enum exp_opcode op)
+{
+  struct value *val;
+  struct type *type1 = check_typedef (value_type (arg1));
+  struct type *type2 = check_typedef (value_type (arg2));
+  int t1_is_vec = (TYPE_CODE (type1) == TYPE_CODE_ARRAY
+		   && TYPE_VECTOR (type1));
+  int t2_is_vec = (TYPE_CODE (type2) == TYPE_CODE_ARRAY
+		   && TYPE_VECTOR (type2));
+
+  if (!t1_is_vec && !t2_is_vec)
+    {
+      int tmp = scalar_relop (arg1, arg2, op);
+      struct type *type =
+	language_bool_type (exp->language_defn, exp->gdbarch);
+      val = value_from_longest (type, tmp);
+    }
+  else if (t1_is_vec && t2_is_vec)
+    {
+      val = vector_relop (exp, arg1, arg2, op);
+    }
+  else
+    {
+      /* Widen the scalar operand to a vector.  */
+      struct value **v = t1_is_vec ? &arg2 : &arg1;
+      struct type *t = t1_is_vec ? type2 : type1;
+
+      if (TYPE_CODE (t) != TYPE_CODE_FLT && !is_integral_type (t))
+	error (_("Argument to operation not a number or boolean."));
+
+      *v = value_cast (t1_is_vec ? type1 : type2, *v);
+      val = vector_relop (exp, arg1, arg2, op);
+    }
+
+  return val;
+}
+
+/* Expression evaluator for the OpenCL.  Most operations are delegated to
+   evaluate_subexp_standard; see that function for a description of the
+   arguments.  */
+
+static struct value *
+evaluate_subexp_opencl (struct type *expect_type, struct expression *exp,
+		   int *pos, enum noside noside)
+{
+  enum exp_opcode op = exp->elts[*pos].opcode;
+  struct value *arg1 = NULL;
+  struct value *arg2 = NULL;
+  struct type *type1, *type2;
+
+  switch (op)
+    {
+    /* Handle binary relational and equality operators that are either not
+       or differently defined for GNU vectors.  */
+    case BINOP_EQUAL:
+    case BINOP_NOTEQUAL:
+    case BINOP_LESS:
+    case BINOP_GTR:
+    case BINOP_GEQ:
+    case BINOP_LEQ:
+      (*pos)++;
+      arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+      arg2 = evaluate_subexp (value_type (arg1), exp, pos, noside);
+
+      if (noside == EVAL_SKIP)
+	return value_from_longest (builtin_type (exp->gdbarch)->
+				   builtin_int, 1);
+
+      return opencl_relop (exp, arg1, arg2, op);
+
+    /* Handle the logical unary operator not(!).  */
+    case UNOP_LOGICAL_NOT:
+      (*pos)++;
+      arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+
+      if (noside == EVAL_SKIP)
+	return value_from_longest (builtin_type (exp->gdbarch)->
+				   builtin_int, 1);
+
+      return opencl_logical_not (exp, arg1);
+
+    /* Handle the logical operator and(&&) and or(||).  */
+    case BINOP_LOGICAL_AND:
+    case BINOP_LOGICAL_OR:
+      (*pos)++;
+      arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+
+      if (noside == EVAL_SKIP)
+	{
+	  arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+
+	  return value_from_longest (builtin_type (exp->gdbarch)->
+				     builtin_int, 1);
+	}
+      else
+	{
+	  /* For scalar operations we need to avoid evaluating operands
+	     unecessarily.  However, for vector operations we always need to
+	     evaluate both operands.  Unfortunately we only know which of the
+	     two cases apply after we know the type of the second operand.
+	     Therefore we evaluate it once using EVAL_AVOID_SIDE_EFFECTS.  */
+	  int oldpos = *pos;
+
+	  arg2 = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
+	  *pos = oldpos;
+	  type1 = check_typedef (value_type (arg1));
+	  type2 = check_typedef (value_type (arg2));
+
+	  if ((TYPE_CODE (type1) == TYPE_CODE_ARRAY && TYPE_VECTOR (type1))
+	      || (TYPE_CODE (type2) == TYPE_CODE_ARRAY && TYPE_VECTOR (type2)))
+	    {
+	      arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+
+	      return opencl_relop (exp, arg1, arg2, op);
+	    }
+	  else
+	    {
+	      /* For scalar built-in types, only evaluate the right
+		 hand operand if the left hand operand compares
+		 unequal(&&)/equal(||) to 0.  */
+	      int res;
+	      int tmp = value_logical_not (arg1);
+
+	      if (op == BINOP_LOGICAL_OR)
+		tmp = !tmp;
+
+	      arg2 = evaluate_subexp (NULL_TYPE, exp, pos,
+				      tmp ? EVAL_SKIP : noside);
+	      type1 = language_bool_type (exp->language_defn, exp->gdbarch);
+
+	      if (op == BINOP_LOGICAL_AND)
+		res = !tmp && !value_logical_not (arg2);
+	      else /* BINOP_LOGICAL_OR */
+		res = tmp || !value_logical_not (arg2);
+
+	      return value_from_longest (type1, res);
+	    }
+	}
+
+    /* Handle the ternary selection operator.  */
+    case TERNOP_COND:
+      (*pos)++;
+      arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+      type1 = check_typedef (value_type (arg1));
+      if (TYPE_CODE (type1) == TYPE_CODE_ARRAY && TYPE_VECTOR (type1))
+	{
+	  struct value *arg3, *tmp, *ret;
+	  struct type *eltype2, *type3, *eltype3;
+	  int t2_is_vec, t3_is_vec, i;
+	  LONGEST lowb1, lowb2, lowb3, highb1, highb2, highb3;
+
+	  arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	  arg3 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	  type2 = check_typedef (value_type (arg2));
+	  type3 = check_typedef (value_type (arg3));
+	  t2_is_vec
+	    = TYPE_CODE (type2) == TYPE_CODE_ARRAY && TYPE_VECTOR (type2);
+	  t3_is_vec
+	    = TYPE_CODE (type3) == TYPE_CODE_ARRAY && TYPE_VECTOR (type3);
+
+	  /* Widen the scalar operand to a vector if necessary.  */
+	  if (t2_is_vec || !t3_is_vec)
+	    {
+	      arg3 = value_cast (type2, arg3);
+	      type3 = value_type (arg3);
+	    }
+	  else if (!t2_is_vec || t3_is_vec)
+	    {
+	      arg2 = value_cast (type3, arg2);
+	      type2 = value_type (arg2);
+	    }
+	  else if (!t2_is_vec || !t3_is_vec)
+	    {
+	      /* Throw an error if arg2 or arg3 aren't vectors.  */
+	      error (_("\
+Cannot perform conditional operation on incompatible types"));
+	    }
+
+	  eltype2 = check_typedef (TYPE_TARGET_TYPE (type2));
+	  eltype3 = check_typedef (TYPE_TARGET_TYPE (type3));
+
+	  if (!get_array_bounds (type1, &lowb1, &highb1)
+	      || !get_array_bounds (type2, &lowb2, &highb2)
+	      || !get_array_bounds (type3, &lowb3, &highb3))
+	    error (_("Could not determine the vector bounds"));
+
+	  /* Throw an error if the types of arg2 or arg3 are incompatible.  */
+	  if (TYPE_CODE (eltype2) != TYPE_CODE (eltype3)
+	      || TYPE_LENGTH (eltype2) != TYPE_LENGTH (eltype3)
+	      || TYPE_UNSIGNED (eltype2) != TYPE_UNSIGNED (eltype3)
+	      || lowb2 != lowb3 || highb2 != highb3)
+	    error (_("\
+Cannot perform operation on vectors with different types"));
+
+	  /* Throw an error if the sizes of arg1 and arg2/arg3 differ.  */
+	  if (lowb1 != lowb2 || lowb1 != lowb3
+	      || highb1 != highb2 || highb1 != highb3)
+	    error (_("\
+Cannot perform conditional operation on vectors with different sizes"));
+
+	  ret = allocate_value (type2);
+
+	  for (i = 0; i < highb1 - lowb1 + 1; i++)
+	    {
+	      tmp = value_logical_not (value_subscript (arg1, i)) ?
+		    value_subscript (arg3, i) : value_subscript (arg2, i);
+	      memcpy (value_contents_writeable (ret) +
+		      i * TYPE_LENGTH (eltype2), value_contents_all (tmp),
+		      TYPE_LENGTH (eltype2));
+	    }
+
+	  return ret;
+	}
+      else
+	{
+	  if (value_logical_not (arg1))
+	    {
+	      /* Skip the second operand.  */
+	      evaluate_subexp (NULL_TYPE, exp, pos, EVAL_SKIP);
+
+	      return evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	    }
+	  else
+	    {
+	      /* Skip the third operand.  */
+	      arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	      evaluate_subexp (NULL_TYPE, exp, pos, EVAL_SKIP);
+
+	      return arg2;
+	    }
+	}
+
+    /* Handle STRUCTOP_STRUCT to allow component access on OpenCL vectors.  */
+    case STRUCTOP_STRUCT:
+      {
+	int pc = (*pos)++;
+	int tem = longest_to_int (exp->elts[pc + 1].longconst);
+
+	(*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
+	arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	type1 = check_typedef (value_type (arg1));
+
+	if (noside == EVAL_SKIP)
+	  {
+	    return value_from_longest (builtin_type (exp->gdbarch)->
+				       builtin_int, 1);
+	  }
+	else if (TYPE_CODE (type1) == TYPE_CODE_ARRAY && TYPE_VECTOR (type1))
+	  {
+	    return opencl_component_ref (exp, arg1, &exp->elts[pc + 2].string,
+					 noside);
+	  }
+	else
+	  {
+	    if (noside == EVAL_AVOID_SIDE_EFFECTS)
+	      return
+		  value_zero (lookup_struct_elt_type
+			      (value_type (arg1),&exp->elts[pc + 2].string, 0),
+			      lval_memory);
+	    else
+	      return value_struct_elt (&arg1, NULL,
+				       &exp->elts[pc + 2].string, NULL,
+				       "structure");
+	  }
+      }
+    default:
+      break;
+    }
+
+  return evaluate_subexp_c (expect_type, exp, pos, noside);
+}
+
+void
+opencl_language_arch_info (struct gdbarch *gdbarch,
+		      struct language_arch_info *lai)
+{
+  const struct builtin_opencl_type *builtin = builtin_opencl_type (gdbarch);
+
+  lai->string_char_type = builtin->builtin_char;
+  lai->primitive_type_vector
+    = GDBARCH_OBSTACK_CALLOC (gdbarch, nr_opencl_primitive_types + 1,
+			      struct type *);
+
+/* This macro fills the primitive_type_vector from a given type.  */
+#define FILL_TYPE_VECTOR(LAI, TYPE)\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE]\
+    = builtin->builtin_##TYPE;\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE##2]\
+    = builtin->builtin_##TYPE##2;\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE##3]\
+    = builtin->builtin_##TYPE##3;\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE##4]\
+    = builtin->builtin_##TYPE##4;\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE##8]\
+    = builtin->builtin_##TYPE##8;\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE##16]\
+    = builtin->builtin_##TYPE##16
+
+  FILL_TYPE_VECTOR (lai, char);
+  FILL_TYPE_VECTOR (lai, uchar);
+  FILL_TYPE_VECTOR (lai, short);
+  FILL_TYPE_VECTOR (lai, ushort);
+  FILL_TYPE_VECTOR (lai, int);
+  FILL_TYPE_VECTOR (lai, uint);
+  FILL_TYPE_VECTOR (lai, long);
+  FILL_TYPE_VECTOR (lai, ulong);
+  FILL_TYPE_VECTOR (lai, half);
+  FILL_TYPE_VECTOR (lai, float);
+  FILL_TYPE_VECTOR (lai, double);
+  lai->primitive_type_vector [opencl_primitive_type_bool]
+    = builtin->builtin_bool;
+  lai->primitive_type_vector [opencl_primitive_type_unsigned_char]
+    = builtin->builtin_unsigned_char;
+  lai->primitive_type_vector [opencl_primitive_type_unsigned_short]
+    = builtin->builtin_unsigned_short;
+  lai->primitive_type_vector [opencl_primitive_type_unsigned_int]
+    = builtin->builtin_unsigned_int;
+  lai->primitive_type_vector [opencl_primitive_type_unsigned_long]
+    = builtin->builtin_unsigned_long;
+  lai->primitive_type_vector [opencl_primitive_type_half]
+    = builtin->builtin_half;
+  lai->primitive_type_vector [opencl_primitive_type_size_t]
+    = builtin->builtin_size_t;
+  lai->primitive_type_vector [opencl_primitive_type_ptrdiff_t]
+    = builtin->builtin_ptrdiff_t;
+  lai->primitive_type_vector [opencl_primitive_type_intptr_t]
+    = builtin->builtin_intptr_t;
+  lai->primitive_type_vector [opencl_primitive_type_uintptr_t]
+    = builtin->builtin_uintptr_t;
+  lai->primitive_type_vector [opencl_primitive_type_void]
+    = builtin->builtin_void;
+
+  /* Specifies the return type of logical and relational operations.  */
+  lai->bool_type_symbol = "int";
+  lai->bool_type_default = builtin->builtin_int;
+}
+
+const struct exp_descriptor exp_descriptor_opencl =
+{
+  print_subexp_standard,
+  operator_length_standard,
+  operator_check_standard,
+  op_name_standard,
+  dump_subexp_body_standard,
+  evaluate_subexp_opencl
+};
+
+const struct language_defn opencl_language_defn =
+{
+  "opencl",			/* Language name */
+  language_opencl,
+  range_check_off,
+  type_check_off,
+  case_sensitive_on,
+  array_row_major,
+  macro_expansion_c,
+  &exp_descriptor_opencl,
+  c_parse,
+  c_error,
+  null_post_parser,
+  c_printchar,			/* Print a character constant */
+  c_printstr,			/* Function to print string constant */
+  c_emit_char,			/* Print a single char */
+  c_print_type,			/* Print a type using appropriate syntax */
+  c_print_typedef,		/* Print a typedef using appropriate syntax */
+  c_val_print,			/* Print a value using appropriate syntax */
+  c_value_print,		/* Print a top-level value */
+  NULL,				/* Language specific skip_trampoline */
+  NULL,                         /* name_of_this */
+  basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
+  basic_lookup_transparent_type,/* lookup_transparent_type */
+  NULL,				/* Language specific symbol demangler */
+  NULL,				/* Language specific class_name_from_physname */
+  c_op_print_tab,		/* expression operators for printing */
+  1,				/* c-style arrays */
+  0,				/* String lower bound */
+  default_word_break_characters,
+  default_make_symbol_completion_list,
+  opencl_language_arch_info,
+  default_print_array_index,
+  default_pass_by_reference,
+  c_get_string,
+  LANG_MAGIC
+};
+
+static void *
+build_opencl_types (struct gdbarch *gdbarch)
+{
+  struct builtin_opencl_type *builtin_opencl_type
+    = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct builtin_opencl_type);
+
+/* Helper macro to create strings.  */
+#define STRINGIFY(S) #S
+/* This macro allocates and assigns the type struct pointers
+   for the vector types.  */
+#define BUILD_OCL_VTYPES(TYPE)\
+  builtin_opencl_type->builtin_##TYPE##2\
+    = init_vector_type (builtin_opencl_type->builtin_##TYPE, 2);\
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##2) = STRINGIFY(TYPE ## 2);\
+  builtin_opencl_type->builtin_##TYPE##3\
+    = init_vector_type (builtin_opencl_type->builtin_##TYPE, 3);\
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##3) = STRINGIFY(TYPE ## 3);\
+  TYPE_LENGTH (builtin_opencl_type->builtin_##TYPE##3)\
+    = 4 * TYPE_LENGTH (builtin_opencl_type->builtin_##TYPE);\
+  builtin_opencl_type->builtin_##TYPE##4\
+    = init_vector_type (builtin_opencl_type->builtin_##TYPE, 4);\
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##4) = STRINGIFY(TYPE ## 4);\
+  builtin_opencl_type->builtin_##TYPE##8\
+    = init_vector_type (builtin_opencl_type->builtin_##TYPE, 8);\
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##8) = STRINGIFY(TYPE ## 8);\
+  builtin_opencl_type->builtin_##TYPE##16\
+    = init_vector_type (builtin_opencl_type->builtin_##TYPE, 16);\
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##16) = STRINGIFY(TYPE ## 16)
+
+  builtin_opencl_type->builtin_char
+    = arch_integer_type (gdbarch, 8, 0, "char");
+  BUILD_OCL_VTYPES (char);
+  builtin_opencl_type->builtin_uchar
+    = arch_integer_type (gdbarch, 8, 1, "uchar");
+  BUILD_OCL_VTYPES (uchar);
+  builtin_opencl_type->builtin_short
+    = arch_integer_type (gdbarch, 16, 0, "short");
+  BUILD_OCL_VTYPES (short);
+  builtin_opencl_type->builtin_ushort
+    = arch_integer_type (gdbarch, 16, 1, "ushort");
+  BUILD_OCL_VTYPES (ushort);
+  builtin_opencl_type->builtin_int
+    = arch_integer_type (gdbarch, 32, 0, "int");
+  BUILD_OCL_VTYPES (int);
+  builtin_opencl_type->builtin_uint
+    = arch_integer_type (gdbarch, 32, 1, "uint");
+  BUILD_OCL_VTYPES (uint);
+  builtin_opencl_type->builtin_long
+    = arch_integer_type (gdbarch, 64, 0, "long");
+  BUILD_OCL_VTYPES (long);
+  builtin_opencl_type->builtin_ulong
+    = arch_integer_type (gdbarch, 64, 1, "ulong");
+  BUILD_OCL_VTYPES (ulong);
+  builtin_opencl_type->builtin_half
+    = arch_float_type (gdbarch, 16, "half", floatformats_ieee_half);
+  BUILD_OCL_VTYPES (half);
+  builtin_opencl_type->builtin_float
+    = arch_float_type (gdbarch, 32, "float", floatformats_ieee_single);
+  BUILD_OCL_VTYPES (float);
+  builtin_opencl_type->builtin_double
+    = arch_float_type (gdbarch, 64, "double", floatformats_ieee_double);
+  BUILD_OCL_VTYPES (double);
+  builtin_opencl_type->builtin_bool
+    = arch_boolean_type (gdbarch, 32, 1, "bool");
+  builtin_opencl_type->builtin_unsigned_char
+    = arch_integer_type (gdbarch, 8, 1, "unsigned char");
+  builtin_opencl_type->builtin_unsigned_short
+    = arch_integer_type (gdbarch, 16, 1, "unsigned short");
+  builtin_opencl_type->builtin_unsigned_int
+    = arch_integer_type (gdbarch, 32, 1, "unsigned int");
+  builtin_opencl_type->builtin_unsigned_long
+    = arch_integer_type (gdbarch, 64, 1, "unsigned long");
+  builtin_opencl_type->builtin_size_t
+    = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 1, "size_t");
+  builtin_opencl_type->builtin_ptrdiff_t
+    = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 0, "ptrdiff_t");
+  builtin_opencl_type->builtin_intptr_t
+    = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 0, "intptr_t");
+  builtin_opencl_type->builtin_uintptr_t
+    = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 1, "uintptr_t");
+  builtin_opencl_type->builtin_void
+    = arch_type (gdbarch, TYPE_CODE_VOID, 1, "void");
+
+  return builtin_opencl_type;
+}
+
+void
+_initialize_opencl_language (void)
+{
+  opencl_type_data = gdbarch_data_register_post_init (build_opencl_types);
+  add_language (&opencl_language_defn);
+}
Index: src/gdb/Makefile.in
===================================================================
--- src.orig/gdb/Makefile.in	2010-10-27 14:54:00.000000000 +0200
+++ src/gdb/Makefile.in	2010-10-27 14:54:29.000000000 +0200
@@ -689,6 +689,7 @@ SFILES = ada-exp.y ada-lang.c ada-typepr
 	mi/mi-common.c \
 	objc-exp.y objc-lang.c \
 	objfiles.c osabi.c observer.c osdata.c \
+	opencl-lang.c \
 	p-exp.y p-lang.c p-typeprint.c p-valprint.c parse.c printcmd.c \
 	proc-service.list progspace.c \
 	prologue-value.c psymtab.c \
@@ -846,7 +847,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $
 	ui-out.o cli-out.o \
 	varobj.o vec.o wrapper.o \
 	jv-lang.o jv-valprint.o jv-typeprint.o \
-	m2-lang.o p-lang.o p-typeprint.o p-valprint.o \
+	m2-lang.o opencl-lang.o p-lang.o p-typeprint.o p-valprint.o \
 	scm-exp.o scm-lang.o scm-valprint.o \
 	sentinel-frame.o \
 	complaints.o typeprint.o \
Index: src/gdb/eval.c
===================================================================
--- src.orig/gdb/eval.c	2010-10-27 14:54:00.000000000 +0200
+++ src/gdb/eval.c	2010-10-27 14:54:29.000000000 +0200
@@ -603,6 +603,7 @@ binop_promote (const struct language_def
 	case language_cplus:
 	case language_asm:
 	case language_objc:
+	case language_opencl:
 	  /* No promotion required.  */
 	  break;
 
@@ -690,7 +691,24 @@ binop_promote (const struct language_def
 			       : builtin->builtin_long_long);
 	    }
 	  break;
-
+	case language_opencl:
+	  if (result_len <= TYPE_LENGTH (lookup_signed_typename
+					 (language, gdbarch, "int")))
+	    {
+	      promoted_type =
+		(unsigned_operation
+		 ? lookup_unsigned_typename (language, gdbarch, "int")
+		 : lookup_signed_typename (language, gdbarch, "int"));
+	    }
+	  else if (result_len <= TYPE_LENGTH (lookup_signed_typename
+					      (language, gdbarch, "long")))
+	    {
+	      promoted_type =
+		(unsigned_operation
+		 ? lookup_unsigned_typename (language, gdbarch, "long")
+		 : lookup_signed_typename (language, gdbarch,"long"));
+	    }
+	  break;
 	default:
 	  /* For other languages the result type is unchanged from gdb
 	     version 6.7 for backward compatibility.
Index: src/gdb/testsuite/gdb.base/default.exp
===================================================================
--- src.orig/gdb/testsuite/gdb.base/default.exp	2010-10-27 14:54:01.000000000 +0200
+++ src/gdb/testsuite/gdb.base/default.exp	2010-10-27 14:54:29.000000000 +0200
@@ -527,7 +527,7 @@ gdb_test "set history size" "Argument re
 #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, scheme." "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, scheme." "set language"
 #test set listsize
 gdb_test "set listsize" "Argument required .integer to set it to.*" "set listsize"
 #test set print "p" abbreviation
Index: src/gdb/testsuite/Makefile.in
===================================================================
--- src.orig/gdb/testsuite/Makefile.in	2010-10-27 14:54:00.000000000 +0200
+++ src/gdb/testsuite/Makefile.in	2010-10-27 14:54:29.000000000 +0200
@@ -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 \
Index: src/gdb/testsuite/configure
===================================================================
--- src.orig/gdb/testsuite/configure	2010-10-27 14:54:01.000000000 +0200
+++ src/gdb/testsuite/configure	2010-10-27 14:54:29.000000000 +0200
@@ -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
Index: src/gdb/testsuite/configure.ac
===================================================================
--- src.orig/gdb/testsuite/configure.ac	2010-10-27 14:54:01.000000000 +0200
+++ src/gdb/testsuite/configure.ac	2010-10-27 14:54:29.000000000 +0200
@@ -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])
Index: src/gdb/testsuite/gdb.opencl/Makefile.in
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/Makefile.in	2010-10-27 14:54:29.000000000 +0200
@@ -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.*
Index: src/gdb/testsuite/gdb.opencl/datatypes.cl
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/datatypes.cl	2010-10-27 14:54:29.000000000 +0200
@@ -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;
+}
Index: src/gdb/testsuite/gdb.opencl/datatypes.exp
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/datatypes.exp	2010-10-27 14:54:29.000000000 +0200
@@ -0,0 +1,476 @@
+# 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 bin ${objdir}/${subdir}/${testfile}
+set clprogram [remote_download target ${srcdir}/${subdir}/${testfile}.cl]
+
+# Increase timeout
+set timeout 60
+verbose "Timeout set to $timeout seconds" 2
+
+# Compile the generic OpenCL host app
+if { [gdb_compile_opencl_hostapp "${clprogram}" "${bin}" "" ] != "" } {
+    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 ${bin}
+
+# 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}
Index: src/gdb/testsuite/gdb.opencl/operators.cl
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/operators.cl	2010-10-27 14:54:29.000000000 +0200
@@ -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;
+}
Index: src/gdb/testsuite/gdb.opencl/operators.exp
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/operators.exp	2010-10-27 14:54:29.000000000 +0200
@@ -0,0 +1,960 @@
+# 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 bin ${testfile}
+set clprogram [remote_download target ${srcdir}/${subdir}/${testfile}.cl]
+
+# Increase timeout
+set timeout 60
+verbose "Timeout set to $timeout seconds" 2
+
+# Compile the generic OpenCL host app
+if { [gdb_compile_opencl_hostapp "${clprogram}" "${bin}" "" ] != "" } {
+    untested ${testfile}.exp
+    return -1
+}
+
+# Load the OpenCL app
+clean_restart ${bin}
+
+# 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}
Index: src/gdb/testsuite/gdb.opencl/vec_comps.cl
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/vec_comps.cl	2010-10-27 14:54:29.000000000 +0200
@@ -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;
+}
Index: src/gdb/testsuite/gdb.opencl/vec_comps.exp
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/vec_comps.exp	2010-10-27 14:54:29.000000000 +0200
@@ -0,0 +1,395 @@
+# 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 bin ${testfile}
+set clprogram [remote_download target ${srcdir}/${subdir}/${testfile}.cl]
+
+# Increase timeout
+set timeout 60
+verbose "Timeout set to $timeout seconds" 2
+
+# Compile the generic OpenCL host app
+if { [gdb_compile_opencl_hostapp "${clprogram}" "${bin}" "" ] != "" } {
+    untested ${testfile}.exp
+    return -1
+}
+
+# Load the OpenCL app
+clean_restart ${bin}
+
+# 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}
Index: src/gdb/testsuite/lib/cl_util.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/lib/cl_util.c	2010-10-27 14:54:29.000000000 +0200
@@ -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);
+}
Index: src/gdb/testsuite/lib/cl_util.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/lib/cl_util.h	2010-10-27 14:54:29.000000000 +0200
@@ -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 */
Index: src/gdb/testsuite/lib/opencl.exp
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/lib/opencl.exp	2010-10-27 14:54:29.000000000 +0200
@@ -0,0 +1,82 @@
+# 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 dest options} {
+    global srcdir objdir
+    set src "${srcdir}/lib/cl_util.c ${srcdir}/lib/opencl_hostapp.c"
+    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 $dest "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 bin opencltest[pid].x
+
+    verbose "$me:  compiling OpenCL test app" 2
+    set compile_flags {debug nowarnings quiet}
+
+    if { [gdb_compile_opencl_hostapp "${clprogram}" "${objdir}/${subdir}/${bin}" "" ] != "" } {
+        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 "$bin"
+    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 $bin
+
+    # 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)
+}
Index: src/gdb/testsuite/lib/opencl_hostapp.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/lib/opencl_hostapp.c	2010-10-27 14:54:29.000000000 +0200
@@ -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;
+}
Index: src/gdb/testsuite/lib/opencl_kernel.cl
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/lib/opencl_kernel.cl	2010-10-27 14:54:29.000000000 +0200
@@ -0,0 +1,5 @@
+/* OpenCL kernel for testing purposes.  */
+__kernel void testkernel (__global int *data)
+{
+  data[get_global_id(0)] = 0x1;
+}
Index: src/gdb/testsuite/gdb.opencl/convs_casts.cl
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/convs_casts.cl	2010-10-27 14:54:29.000000000 +0200
@@ -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;
+}
Index: src/gdb/testsuite/gdb.opencl/convs_casts.exp
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/convs_casts.exp	2010-10-27 14:54:29.000000000 +0200
@@ -0,0 +1,100 @@
+# 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 bin ${testfile}
+set clprogram [remote_download target ${srcdir}/${subdir}/${testfile}.cl]
+
+# Increase timeout
+set timeout 60
+verbose "Timeout set to $timeout seconds" 2
+
+# Compile the generic OpenCL host app
+if { [gdb_compile_opencl_hostapp "${clprogram}" "${bin}" "" ] != "" } {
+    untested ${testfile}.exp
+    return -1
+}
+
+# Load the OpenCL app
+clean_restart ${bin}
+
+# 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}
Index: src/gdb/c-exp.y
===================================================================
--- src.orig/gdb/c-exp.y	2010-10-27 14:54:01.000000000 +0200
+++ src/gdb/c-exp.y	2010-10-27 14:54:29.000000000 +0200
@@ -612,7 +612,9 @@ exp	:	VARIABLE
 
 exp	:	SIZEOF '(' type ')'	%prec UNARY
 			{ write_exp_elt_opcode (OP_LONG);
-			  write_exp_elt_type (parse_type->builtin_int);
+			  write_exp_elt_type (lookup_signed_typename
+					      (parse_language, parse_gdbarch,
+					       "int"));
 			  CHECK_TYPEDEF ($3);
 			  write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
 			  write_exp_elt_opcode (OP_LONG); }
@@ -980,61 +982,117 @@ typebase  /* Implements (approximately):
 	:	TYPENAME
 			{ $$ = $1.type; }
 	|	INT_KEYWORD
-			{ $$ = parse_type->builtin_int; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "int"); }
 	|	LONG
-			{ $$ = parse_type->builtin_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long"); }
 	|	SHORT
-			{ $$ = parse_type->builtin_short; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "short"); }
 	|	LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long"); }
 	|	LONG SIGNED_KEYWORD INT_KEYWORD
-			{ $$ = parse_type->builtin_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long"); }
 	|	LONG SIGNED_KEYWORD
-			{ $$ = parse_type->builtin_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long"); }
 	|	SIGNED_KEYWORD LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long"); }
 	|	UNSIGNED LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long"); }
 	|	LONG UNSIGNED INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long"); }
 	|	LONG UNSIGNED
-			{ $$ = parse_type->builtin_unsigned_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long"); }
 	|	LONG LONG
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	LONG LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	LONG LONG SIGNED_KEYWORD INT_KEYWORD
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	LONG LONG SIGNED_KEYWORD
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	SIGNED_KEYWORD LONG LONG
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	SIGNED_KEYWORD LONG LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	UNSIGNED LONG LONG
-			{ $$ = parse_type->builtin_unsigned_long_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long long"); }
 	|	UNSIGNED LONG LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_long_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long long"); }
 	|	LONG LONG UNSIGNED
-			{ $$ = parse_type->builtin_unsigned_long_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long long"); }
 	|	LONG LONG UNSIGNED INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_long_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long long"); }
 	|	SHORT INT_KEYWORD
-			{ $$ = parse_type->builtin_short; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "short"); }
 	|	SHORT SIGNED_KEYWORD INT_KEYWORD
-			{ $$ = parse_type->builtin_short; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "short"); }
 	|	SHORT SIGNED_KEYWORD
-			{ $$ = parse_type->builtin_short; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "short"); }
 	|	UNSIGNED SHORT INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_short; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "short"); }
 	|	SHORT UNSIGNED 
-			{ $$ = parse_type->builtin_unsigned_short; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "short"); }
 	|	SHORT UNSIGNED INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_short; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "short"); }
 	|	DOUBLE_KEYWORD
-			{ $$ = parse_type->builtin_double; }
+			{ $$ = lookup_typename (parse_language, parse_gdbarch,
+						"double", (struct block *) NULL,
+						0); }
 	|	LONG DOUBLE_KEYWORD
-			{ $$ = parse_type->builtin_long_double; }
+			{ $$ = lookup_typename (parse_language, parse_gdbarch,
+						"long double",
+						(struct block *) NULL, 0); }
 	|	STRUCT name
 			{ $$ = lookup_struct (copy_name ($2),
 					      expression_context_block); }
@@ -1052,13 +1110,17 @@ typebase  /* Implements (approximately):
 							 parse_gdbarch,
 							 TYPE_NAME($2.type)); }
 	|	UNSIGNED
-			{ $$ = parse_type->builtin_unsigned_int; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "int"); }
 	|	SIGNED_KEYWORD typename
 			{ $$ = lookup_signed_typename (parse_language,
 						       parse_gdbarch,
 						       TYPE_NAME($2.type)); }
 	|	SIGNED_KEYWORD
-			{ $$ = parse_type->builtin_int; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "int"); }
                 /* It appears that this rule for templates is never
                    reduced; template recognition happens by lookahead
                    in the token processing code in yylex. */         
@@ -1077,19 +1139,25 @@ typename:	TYPENAME
 		{
 		  $$.stoken.ptr = "int";
 		  $$.stoken.length = 3;
-		  $$.type = parse_type->builtin_int;
+		  $$.type = lookup_signed_typename (parse_language,
+						    parse_gdbarch,
+						    "int");
 		}
 	|	LONG
 		{
 		  $$.stoken.ptr = "long";
 		  $$.stoken.length = 4;
-		  $$.type = parse_type->builtin_long;
+		  $$.type = lookup_signed_typename (parse_language,
+						    parse_gdbarch,
+						    "long");
 		}
 	|	SHORT
 		{
 		  $$.stoken.ptr = "short";
 		  $$.stoken.length = 5;
-		  $$.type = parse_type->builtin_short;
+		  $$.type = lookup_signed_typename (parse_language,
+						    parse_gdbarch,
+						    "short");
 		}
 	;
 
Index: src/gdb/c-lang.h
===================================================================
--- src.orig/gdb/c-lang.h	2010-10-27 14:54:00.000000000 +0200
+++ src/gdb/c-lang.h	2010-10-27 14:54:29.000000000 +0200
@@ -27,6 +27,7 @@ struct language_arch_info;
 
 #include "value.h"
 #include "macroexp.h"
+#include "parser-defs.h"
 
 
 /* The various kinds of C string and character.  Note that these
@@ -78,6 +79,10 @@ extern int c_value_print (struct value *
 
 /* These are in c-lang.c: */
 
+extern struct value *evaluate_subexp_c (struct type *expect_type,
+					 struct expression *exp, int *pos,
+					 enum noside noside);
+
 extern void c_printchar (int, struct type *, struct ui_file *);
 
 extern void c_printstr (struct ui_file * stream, struct type *elttype,
@@ -93,6 +98,8 @@ extern const struct exp_descriptor exp_d
 extern void c_emit_char (int c, struct type *type,
 			 struct ui_file *stream, int quoter);
 
+extern const struct op_print c_op_print_tab[];
+
 /* These are in c-typeprint.c: */
 
 extern void c_type_print_base (struct type *, struct ui_file *, int, int);
Index: src/gdb/c-lang.c
===================================================================
--- src.orig/gdb/c-lang.c	2010-10-27 14:54:00.000000000 +0200
+++ src/gdb/c-lang.c	2010-10-27 14:54:29.000000000 +0200
@@ -933,7 +933,7 @@ parse_one_string (struct obstack *output
    are delegated to evaluate_subexp_standard; see that function for a
    description of the arguments.  */
 
-static struct value *
+struct value *
 evaluate_subexp_c (struct type *expect_type, struct expression *exp,
 		   int *pos, enum noside noside)
 {

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] initial OpenCL C language support
  2010-10-26 19:58         ` Joel Brobecker
  2010-10-26 20:03           ` Joel Brobecker
@ 2010-10-27 19:04           ` Jan Kratochvil
  2010-10-27 19:21             ` Pedro Alves
  1 sibling, 1 reply; 36+ messages in thread
From: Jan Kratochvil @ 2010-10-27 19:04 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Ken Werner, Tom Tromey, gdb-patches

On Tue, 26 Oct 2010 15:57:47 -0400, Joel Brobecker wrote:
> > +      ret = ! value_equal (val1, val2);
>               ^^^^^ extra space

GNU Coding Standards contains only this reference to the ! operator:
       if (! fp)

(GDB code contains enough of both cases.)


Regards,
Jan

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] initial OpenCL C language support
  2010-10-27 19:04           ` Jan Kratochvil
@ 2010-10-27 19:21             ` Pedro Alves
  2010-10-27 21:01               ` Ken Werner
  2010-11-02 16:52               ` [doc RFA] Switch to GCC coding style [Re: [patch] initial OpenCL C language support] Jan Kratochvil
  0 siblings, 2 replies; 36+ messages in thread
From: Pedro Alves @ 2010-10-27 19:21 UTC (permalink / raw)
  To: gdb-patches; +Cc: Jan Kratochvil, Joel Brobecker, Ken Werner, Tom Tromey

On Wednesday 27 October 2010 20:04:17, Jan Kratochvil wrote:
> On Tue, 26 Oct 2010 15:57:47 -0400, Joel Brobecker wrote:
> > > +      ret = ! value_equal (val1, val2);
> >               ^^^^^ extra space
> 
> GNU Coding Standards contains only this reference to the ! operator:
>        if (! fp)
> 
> (GDB code contains enough of both cases.)

GCC makes that rule explicit:

http://gcc.gnu.org/codingconventions.html

<quote>
Code in GCC should use the following formatting conventions: 
Use...                     ...instead of
!x                         ! x
~x                         ~ x
-x (unary minus)           - x
(foo) x (cast)             (foo)x
*x (pointer dereference)   * x
</quote>

We tend to follow these already, so I'm of the opinion we should
make them explictily official in gdb too.

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] initial OpenCL C language support
  2010-10-27 19:21             ` Pedro Alves
@ 2010-10-27 21:01               ` Ken Werner
  2010-11-02 16:52               ` [doc RFA] Switch to GCC coding style [Re: [patch] initial OpenCL C language support] Jan Kratochvil
  1 sibling, 0 replies; 36+ messages in thread
From: Ken Werner @ 2010-10-27 21:01 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Jan Kratochvil, Joel Brobecker, Tom Tromey, gdb-patches

On Wednesday, October 27, 2010 9:20:50 pm Pedro Alves wrote:
> On Wednesday 27 October 2010 20:04:17, Jan Kratochvil wrote:
> > On Tue, 26 Oct 2010 15:57:47 -0400, Joel Brobecker wrote:
> > > > +      ret = ! value_equal (val1, val2);
> > > > 
> > >               ^^^^^ extra space
> > 
> > GNU Coding Standards contains only this reference to the ! operator:
> >        if (! fp)
> > 
> > (GDB code contains enough of both cases.)
> 
> GCC makes that rule explicit:
> 
> http://gcc.gnu.org/codingconventions.html
> 
> <quote>
> Code in GCC should use the following formatting conventions:
> Use...                     ...instead of
> !x                         ! x
> ~x                         ~ x
> -x (unary minus)           - x
> (foo) x (cast)             (foo)x
> *x (pointer dereference)   * x
> </quote>
> 
> We tend to follow these already, so I'm of the opinion we should
> make them explictily official in gdb too.

Ok, thanks for clarifying. I have changed the code to look like this:
    case BINOP_NOTEQUAL:
      ret = !value_equal (val1, val2);

Regards
Ken

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [doc RFA] Switch to GCC coding style  [Re: [patch] initial OpenCL C language support]
  2010-10-27 19:21             ` Pedro Alves
  2010-10-27 21:01               ` Ken Werner
@ 2010-11-02 16:52               ` Jan Kratochvil
  2010-11-02 17:04                 ` Doug Evans
  1 sibling, 1 reply; 36+ messages in thread
From: Jan Kratochvil @ 2010-11-02 16:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: Joel Brobecker, Ken Werner, Tom Tromey, Pedro Alves

On Wed, 27 Oct 2010 21:20:50 +0200, Pedro Alves wrote:
> GCC makes that rule explicit:
> 
> http://gcc.gnu.org/codingconventions.html
[...]
> We tend to follow these already,

In such case is this patch OK?

Another question is bfd/, opcodes/ etc.


Thanks,
Jan


gdb/
2010-11-02  Jan Kratochvil  <jan.kratochvil@redhat.com>
	    Pedro Alves  <pedro@codesourcery.com>

	* CONTRIBUTE (Coding Standards): Change to GCC Coding Conventions,
	update URL.

gdb/doc/
2010-11-02  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdbint.texinfo (Coding Standards): Change to GCC Coding
	Conventions, provide URL.  Change `standards' to `conventions'.
	(Testsuite): Change to GCC Coding Conventions.

--- a/gdb/CONTRIBUTE
+++ b/gdb/CONTRIBUTE
@@ -28,7 +28,7 @@ all contributors need to be aware of.
 
 o	Coding Standards
 
-	All contributions must conform to the GNU Coding Standard.
+	All contributions must conform to the GCC Coding Conventions.
 	Submissions which do not conform to the standards will be
 	returned with a request to reformat the changes.
 
@@ -36,7 +36,7 @@ o	Coding Standards
 	requirements are explained in the GDB internals documentation
 	in the gdb/doc directory.
 
-	Ref: http://www.gnu.org/prep/standards_toc.html
+	Ref: http://gcc.gnu.org/codingconventions.html
 
 
 o	Copyright Assignment
--- a/gdb/doc/gdbint.texinfo
+++ b/gdb/doc/gdbint.texinfo
@@ -5765,13 +5765,12 @@ Binary search the array.
 
 @section @value{GDBN} C Coding Standards
 
-@value{GDBN} follows the GNU coding standards, as described in
-@file{etc/standards.texi}.  This file is also available for anonymous
-FTP from GNU archive sites.  @value{GDBN} takes a strict interpretation
-of the standard; in general, when the GNU standard recommends a practice
-but does not require it, @value{GDBN} requires it.
+@value{GDBN} follows the GCC Coding Conventions, available from
+@url{http://gcc.gnu.org/codingconventions.html}.  @value{GDBN} takes a strict
+interpretation of the standard; in general, when the GCC conventions recommend
+a practice but do not require it, @value{GDBN} requires it.
 
-@value{GDBN} follows an additional set of coding standards specific to
+@value{GDBN} follows an additional set of coding conventions specific to
 @value{GDBN}, as described in the following sections.
 
 @subsection ISO C
@@ -5784,7 +5783,7 @@ compiler.
 @subsection Formatting
 
 @cindex source code formatting
-The standard GNU recommendations for formatting must be followed
+The standard GCC recommendations for formatting must be followed
 strictly.
 
 A function declaration should not have its name in column zero.  A
@@ -5831,7 +5830,7 @@ void* foo;
 @subsection Comments
 
 @cindex comment formatting
-The standard GNU requirements on comments must be followed strictly.
+The standard GCC requirements on comments must be followed strictly.
 
 Block comments must appear in the following form, with no @code{/*}- or
 @code{*/}-only lines, and no leading @code{*}:
@@ -7821,7 +7820,7 @@ The source language programs do @emph{not} need to be in a consistent
 style.  Since @value{GDBN} is used to debug programs written in many different
 styles, it's worth having a mix of styles in the testsuite; for
 instance, some @value{GDBN} bugs involving the display of source lines would
-never manifest themselves if the programs used GNU coding style
+never manifest themselves if the programs used GCC Coding Conventions
 uniformly.
 
 @node Hints

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [doc RFA] Switch to GCC coding style [Re: [patch] initial OpenCL C language support]
  2010-11-02 16:52               ` [doc RFA] Switch to GCC coding style [Re: [patch] initial OpenCL C language support] Jan Kratochvil
@ 2010-11-02 17:04                 ` Doug Evans
  2010-11-02 17:23                   ` Jan Kratochvil
  2010-11-02 18:01                   ` Joel Brobecker
  0 siblings, 2 replies; 36+ messages in thread
From: Doug Evans @ 2010-11-02 17:04 UTC (permalink / raw)
  To: Jan Kratochvil
  Cc: gdb-patches, Joel Brobecker, Ken Werner, Tom Tromey, Pedro Alves

On Tue, Nov 2, 2010 at 9:51 AM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
> On Wed, 27 Oct 2010 21:20:50 +0200, Pedro Alves wrote:
>> GCC makes that rule explicit:
>>
>> http://gcc.gnu.org/codingconventions.html
> [...]
>> We tend to follow these already,
>
> In such case is this patch OK?
>
> Another question is bfd/, opcodes/ etc.
>
>
> Thanks,
> Jan
>
>
> gdb/
> 2010-11-02  Jan Kratochvil  <jan.kratochvil@redhat.com>
>            Pedro Alves  <pedro@codesourcery.com>
>
>        * CONTRIBUTE (Coding Standards): Change to GCC Coding Conventions,
>        update URL.
>
> gdb/doc/
> 2010-11-02  Jan Kratochvil  <jan.kratochvil@redhat.com>
>
>        * gdbint.texinfo (Coding Standards): Change to GCC Coding
>        Conventions, provide URL.  Change `standards' to `conventions'.
>        (Testsuite): Change to GCC Coding Conventions.
>
> --- a/gdb/CONTRIBUTE
> +++ b/gdb/CONTRIBUTE
> @@ -28,7 +28,7 @@ all contributors need to be aware of.
>
>  o      Coding Standards
>
> -       All contributions must conform to the GNU Coding Standard.
> +       All contributions must conform to the GCC Coding Conventions.
>        Submissions which do not conform to the standards will be
>        returned with a request to reformat the changes.
>
> @@ -36,7 +36,7 @@ o     Coding Standards
>        requirements are explained in the GDB internals documentation
>        in the gdb/doc directory.
>
> -       Ref: http://www.gnu.org/prep/standards_toc.html
> +       Ref: http://gcc.gnu.org/codingconventions.html
>
>
>  o      Copyright Assignment
> --- a/gdb/doc/gdbint.texinfo
> +++ b/gdb/doc/gdbint.texinfo
> @@ -5765,13 +5765,12 @@ Binary search the array.
>
>  @section @value{GDBN} C Coding Standards
>
> -@value{GDBN} follows the GNU coding standards, as described in
> -@file{etc/standards.texi}.  This file is also available for anonymous
> -FTP from GNU archive sites.  @value{GDBN} takes a strict interpretation
> -of the standard; in general, when the GNU standard recommends a practice
> -but does not require it, @value{GDBN} requires it.
> +@value{GDBN} follows the GCC Coding Conventions, available from
> +@url{http://gcc.gnu.org/codingconventions.html}.  @value{GDBN} takes a strict
> +interpretation of the standard; in general, when the GCC conventions recommend
> +a practice but do not require it, @value{GDBN} requires it.
>
> -@value{GDBN} follows an additional set of coding standards specific to
> +@value{GDBN} follows an additional set of coding conventions specific to
>  @value{GDBN}, as described in the following sections.
>
>  @subsection ISO C
> @@ -5784,7 +5783,7 @@ compiler.
>  @subsection Formatting
>
>  @cindex source code formatting
> -The standard GNU recommendations for formatting must be followed
> +The standard GCC recommendations for formatting must be followed
>  strictly.
>
>  A function declaration should not have its name in column zero.  A
> @@ -5831,7 +5830,7 @@ void* foo;
>  @subsection Comments
>
>  @cindex comment formatting
> -The standard GNU requirements on comments must be followed strictly.
> +The standard GCC requirements on comments must be followed strictly.
>
>  Block comments must appear in the following form, with no @code{/*}- or
>  @code{*/}-only lines, and no leading @code{*}:
> @@ -7821,7 +7820,7 @@ The source language programs do @emph{not} need to be in a consistent
>  style.  Since @value{GDBN} is used to debug programs written in many different
>  styles, it's worth having a mix of styles in the testsuite; for
>  instance, some @value{GDBN} bugs involving the display of source lines would
> -never manifest themselves if the programs used GNU coding style
> +never manifest themselves if the programs used GCC Coding Conventions
>  uniformly.
>
>  @node Hints
>

There are lots of things on the gcc codingconventions page that need
to be converted (e.g., gcc_assert), or revised (e.g., prototypes for
_initialize_foo fns can appear in .c files (and should *only* appear
in .c files)).

I'm not sure, but it might be simpler to just copy over the relevant bits.

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [doc RFA] Switch to GCC coding style [Re: [patch] initial OpenCL C language support]
  2010-11-02 17:04                 ` Doug Evans
@ 2010-11-02 17:23                   ` Jan Kratochvil
  2010-11-02 17:29                     ` Doug Evans
  2010-11-02 19:21                     ` Eli Zaretskii
  2010-11-02 18:01                   ` Joel Brobecker
  1 sibling, 2 replies; 36+ messages in thread
From: Jan Kratochvil @ 2010-11-02 17:23 UTC (permalink / raw)
  To: Doug Evans
  Cc: gdb-patches, Joel Brobecker, Ken Werner, Tom Tromey, Pedro Alves

On Tue, 02 Nov 2010 18:04:39 +0100, Doug Evans wrote:
> There are lots of things on the gcc codingconventions page that need
> to be converted (e.g., gcc_assert),

Done.

> or revised (e.g., prototypes for _initialize_foo fns can appear in .c files
> (and should *only* appear in .c files)).

I do not see a current GDB doc problem with this (+it may be offtopic for this
patch).


Thanks,
Jan


gdb/
2010-11-02  Jan Kratochvil  <jan.kratochvil@redhat.com>
	    Pedro Alves  <pedro@codesourcery.com>

	* CONTRIBUTE (Coding Standards): Change to GCC Coding Conventions,
	update URL.

gdb/doc/
2010-11-02  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdbint.texinfo (Coding Standards): Change to GCC Coding
	Conventions, provide URL.  Change `standards' to `conventions'.
	(C Usage): New paragraph.
	(Testsuite): Change to GCC Coding Conventions.

--- a/gdb/CONTRIBUTE
+++ b/gdb/CONTRIBUTE
@@ -28,7 +28,7 @@ all contributors need to be aware of.
 
 o	Coding Standards
 
-	All contributions must conform to the GNU Coding Standard.
+	All contributions must conform to the GCC Coding Conventions.
 	Submissions which do not conform to the standards will be
 	returned with a request to reformat the changes.
 
@@ -36,7 +36,7 @@ o	Coding Standards
 	requirements are explained in the GDB internals documentation
 	in the gdb/doc directory.
 
-	Ref: http://www.gnu.org/prep/standards_toc.html
+	Ref: http://gcc.gnu.org/codingconventions.html
 
 
 o	Copyright Assignment
--- a/gdb/doc/gdbint.texinfo
+++ b/gdb/doc/gdbint.texinfo
@@ -5765,13 +5765,12 @@ Binary search the array.
 
 @section @value{GDBN} C Coding Standards
 
-@value{GDBN} follows the GNU coding standards, as described in
-@file{etc/standards.texi}.  This file is also available for anonymous
-FTP from GNU archive sites.  @value{GDBN} takes a strict interpretation
-of the standard; in general, when the GNU standard recommends a practice
-but does not require it, @value{GDBN} requires it.
+@value{GDBN} follows the GCC Coding Conventions, available from
+@url{http://gcc.gnu.org/codingconventions.html}.  @value{GDBN} takes a strict
+interpretation of the standard; in general, when the GCC conventions recommend
+a practice but do not require it, @value{GDBN} requires it.
 
-@value{GDBN} follows an additional set of coding standards specific to
+@value{GDBN} follows an additional set of coding conventions specific to
 @value{GDBN}, as described in the following sections.
 
 @subsection ISO C
@@ -5784,7 +5783,7 @@ compiler.
 @subsection Formatting
 
 @cindex source code formatting
-The standard GNU recommendations for formatting must be followed
+The standard GCC recommendations for formatting must be followed
 strictly.
 
 A function declaration should not have its name in column zero.  A
@@ -5831,7 +5830,7 @@ void* foo;
 @subsection Comments
 
 @cindex comment formatting
-The standard GNU requirements on comments must be followed strictly.
+The standard GCC requirements on comments must be followed strictly.
 
 Block comments must appear in the following form, with no @code{/*}- or
 @code{*/}-only lines, and no leading @code{*}:
@@ -5880,6 +5879,11 @@ protected with parentheses.)
 Declarations like @samp{struct foo *} should be used in preference to
 declarations like @samp{typedef struct foo @{ @dots{} @} *foo_ptr}.
 
+@code{gcc_assert} references in GCC Coding Conventions should be replaced by
+@code{gdb_assert}.  @code{gcc_unreachable} should be replaced by
+@code{gdb_assert_not_reached}.  Standard @code{<ctype.h>} header file and its
+functions can and should be used.
+
 @subsection Function Prototypes
 @cindex function prototypes
 
@@ -7821,7 +7825,7 @@ The source language programs do @emph{not} need to be in a consistent
 style.  Since @value{GDBN} is used to debug programs written in many different
 styles, it's worth having a mix of styles in the testsuite; for
 instance, some @value{GDBN} bugs involving the display of source lines would
-never manifest themselves if the programs used GNU coding style
+never manifest themselves if the programs used GCC Coding Conventions
 uniformly.
 
 @node Hints

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [doc RFA] Switch to GCC coding style [Re: [patch] initial OpenCL C language support]
  2010-11-02 17:23                   ` Jan Kratochvil
@ 2010-11-02 17:29                     ` Doug Evans
  2010-11-02 19:21                     ` Eli Zaretskii
  1 sibling, 0 replies; 36+ messages in thread
From: Doug Evans @ 2010-11-02 17:29 UTC (permalink / raw)
  To: Jan Kratochvil
  Cc: gdb-patches, Joel Brobecker, Ken Werner, Tom Tromey, Pedro Alves

On Tue, Nov 2, 2010 at 10:22 AM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
> On Tue, 02 Nov 2010 18:04:39 +0100, Doug Evans wrote:
>> There are lots of things on the gcc codingconventions page that need
>> to be converted (e.g., gcc_assert),
>
> Done.
>
>> or revised (e.g., prototypes for _initialize_foo fns can appear in .c files
>> (and should *only* appear in .c files)).
>
> I do not see a current GDB doc problem with this (+it may be offtopic for this
> patch).

For reference sake I was referring to this text:
"Function prototypes for extern functions should only occur in header files."

But I see that gdbint.texinfo already does mention this exception.
My reason for mentioning it is that I suspect there are more.
Could be wrong of course.

[For reference sake, don't wait for my approval.
I'm just making suggestions (in this particular case :-)).]

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [doc RFA] Switch to GCC coding style [Re: [patch] initial OpenCL C language support]
  2010-11-02 17:04                 ` Doug Evans
  2010-11-02 17:23                   ` Jan Kratochvil
@ 2010-11-02 18:01                   ` Joel Brobecker
  2010-11-02 18:10                     ` [doc RFA] Switch to GCC coding style Jan Kratochvil
  1 sibling, 1 reply; 36+ messages in thread
From: Joel Brobecker @ 2010-11-02 18:01 UTC (permalink / raw)
  To: Doug Evans
  Cc: Jan Kratochvil, gdb-patches, Ken Werner, Tom Tromey, Pedro Alves

> There are lots of things on the gcc codingconventions page that need
> to be converted (e.g., gcc_assert), or revised (e.g., prototypes for
> _initialize_foo fns can appear in .c files (and should *only* appear
> in .c files)).
> 
> I'm not sure, but it might be simpler to just copy over the relevant bits.

This is something I was thinking about as well.  I think we should have
our own Wiki page for conventions.  That way, we can document our own
specific requirements (gdb_assert, etc).

-- 
Joel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [doc RFA] Switch to GCC coding style
  2010-11-02 18:01                   ` Joel Brobecker
@ 2010-11-02 18:10                     ` Jan Kratochvil
  2010-11-02 18:20                       ` Doug Evans
  0 siblings, 1 reply; 36+ messages in thread
From: Jan Kratochvil @ 2010-11-02 18:10 UTC (permalink / raw)
  To: Joel Brobecker
  Cc: Doug Evans, gdb-patches, Ken Werner, Tom Tromey, Pedro Alves

On Tue, 02 Nov 2010 19:01:10 +0100, Joel Brobecker wrote:
> > There are lots of things on the gcc codingconventions page that need
> > to be converted (e.g., gcc_assert), or revised (e.g., prototypes for
> > _initialize_foo fns can appear in .c files (and should *only* appear
> > in .c files)).
> > 
> > I'm not sure, but it might be simpler to just copy over the relevant bits.
> 
> This is something I was thinking about as well.  I think we should have
> our own Wiki page for conventions.  That way, we can document our own
> specific requirements (gdb_assert, etc).

The current code is not strictly compliant to any standard anyway.  And I do
not think GDB wants to needlessly diverge from GCC on GCC Conventions updates
in the future.  These were the reasons why I prefer just referencing GCC
Conventions.


Thanks,
Jan

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [doc RFA] Switch to GCC coding style
  2010-11-02 18:10                     ` [doc RFA] Switch to GCC coding style Jan Kratochvil
@ 2010-11-02 18:20                       ` Doug Evans
  2010-11-02 18:58                         ` Joel Brobecker
  0 siblings, 1 reply; 36+ messages in thread
From: Doug Evans @ 2010-11-02 18:20 UTC (permalink / raw)
  To: Jan Kratochvil
  Cc: Joel Brobecker, gdb-patches, Ken Werner, Tom Tromey, Pedro Alves

On Tue, Nov 2, 2010 at 11:10 AM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
> The current code is not strictly compliant to any standard anyway.

I dunno.  Sure the code deviates here and there, and some things
aren't specified, but there is a standard and where there is one
strictness is pretty much followed.

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [doc RFA] Switch to GCC coding style
  2010-11-02 18:20                       ` Doug Evans
@ 2010-11-02 18:58                         ` Joel Brobecker
  2010-11-02 19:19                           ` Doug Evans
  0 siblings, 1 reply; 36+ messages in thread
From: Joel Brobecker @ 2010-11-02 18:58 UTC (permalink / raw)
  To: Doug Evans
  Cc: Jan Kratochvil, gdb-patches, Ken Werner, Tom Tromey, Pedro Alves

> On Tue, Nov 2, 2010 at 11:10 AM, Jan Kratochvil
> <jan.kratochvil@redhat.com> wrote:
> > The current code is not strictly compliant to any standard anyway.
> 
> I dunno.  Sure the code deviates here and there, and some things
> aren't specified, but there is a standard and where there is one
> strictness is pretty much followed.

I'm personally happy with whatever might might come up. I'd like to
have a link in the Wiki for easy access and update, if at all possible.
If we want to refer to the GCC Coding Conventions and then add our own
difference later, that's fine.  On the other hand, I don't see the
conventions changing all that much over time, so a bit of duplication
to put it all in one page isn't so bad... (IMO)

-- 
Joel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [doc RFA] Switch to GCC coding style
  2010-11-02 18:58                         ` Joel Brobecker
@ 2010-11-02 19:19                           ` Doug Evans
  0 siblings, 0 replies; 36+ messages in thread
From: Doug Evans @ 2010-11-02 19:19 UTC (permalink / raw)
  To: Joel Brobecker
  Cc: Jan Kratochvil, gdb-patches, Ken Werner, Tom Tromey, Pedro Alves

On Tue, Nov 2, 2010 at 11:58 AM, Joel Brobecker <brobecker@adacore.com> wrote:
> I'd like to
> have a link in the Wiki for easy access and update, if at all possible.

For reference sake, the wiki currently refers to text generated from
gdbint.texinfo.

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [doc RFA] Switch to GCC coding style [Re: [patch] initial OpenCL C language support]
  2010-11-02 17:23                   ` Jan Kratochvil
  2010-11-02 17:29                     ` Doug Evans
@ 2010-11-02 19:21                     ` Eli Zaretskii
  2010-11-02 19:29                       ` Joel Brobecker
  2010-11-08 12:50                       ` Jan Kratochvil
  1 sibling, 2 replies; 36+ messages in thread
From: Eli Zaretskii @ 2010-11-02 19:21 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: dje, gdb-patches, brobecker, ken, tromey, pedro

> Date: Tue, 2 Nov 2010 18:22:46 +0100
> From: Jan Kratochvil <jan.kratochvil@redhat.com>
> Cc: gdb-patches@sourceware.org, Joel Brobecker <brobecker@adacore.com>,        Ken Werner <ken@linux.vnet.ibm.com>, Tom Tromey <tromey@redhat.com>,        Pedro Alves <pedro@codesourcery.com>
> 
> On Tue, 02 Nov 2010 18:04:39 +0100, Doug Evans wrote:
> > There are lots of things on the gcc codingconventions page that need
> > to be converted (e.g., gcc_assert),
> 
> Done.
> 
> > or revised (e.g., prototypes for _initialize_foo fns can appear in .c files
> > (and should *only* appear in .c files)).
> 
> I do not see a current GDB doc problem with this (+it may be offtopic for this
> patch).
> 
> 
> Thanks,
> Jan

Are you submitting this for doc review, or will we discuss the issue
first?  Or maybe the issue is already decided?  Please help me out
here.

> -@value{GDBN} follows the GNU coding standards, as described in
> -@file{etc/standards.texi}.  This file is also available for anonymous
> -FTP from GNU archive sites.  @value{GDBN} takes a strict interpretation
> -of the standard; in general, when the GNU standard recommends a practice
> -but does not require it, @value{GDBN} requires it.
> +@value{GDBN} follows the GCC Coding Conventions, available from
> +@url{http://gcc.gnu.org/codingconventions.html}.  @value{GDBN} takes a strict
> +interpretation of the standard; in general, when the GCC conventions recommend
> +a practice but do not require it, @value{GDBN} requires it.

The old text talked about "GNU coding _standards_", so it was
understandable when it later mentioned "interpretation of the
standard".  But you replaced "standards" with "Conventions", so now
"interpretation of the standard" begs the question: "what standard?".

Also, this is actually the first violation in GDB history of the GCC
Conventions, which request to use @uref, not @url for references to
Web pages. ;-)

> -The standard GNU recommendations for formatting must be followed
> +The standard GCC recommendations for formatting must be followed
>  strictly.

There are no "recommendations for formatting" that I could spot in the
GCC Conventions.  At least they are not called that.

> -The standard GNU requirements on comments must be followed strictly.
> +The standard GCC requirements on comments must be followed strictly.

I see no requirements on comments in the GCC Conventions.  But even if
I missed something, why single out only this part?

> +@code{gcc_assert} references in GCC Coding Conventions should be replaced by
> +@code{gdb_assert}.  @code{gcc_unreachable} should be replaced by
> +@code{gdb_assert_not_reached}.  Standard @code{<ctype.h>} header file and its
> +functions can and should be used.

I don't think this is enough, sorry.  The GCC Conventions mention a
lot of details that are utterly inapplicable to GDB.  The exceptions
you mention are just a drop in that sea.  What about references to
ERROR_MARK, RTL, --param arguments, what about fastjar and boehm-gc?
And those are just a few random examples.

On balance, I think we should simply have our own coherent document.
It can copy verbatim all the stuff that is relevant to GDB, but it
should include the above renames, and it should omit everything that
is irrelevant.  Any other way, we will just confuse potential
contributors: it is perhaps easy for us old-timers to distinguish
between the relevant and the rest, but for a newbie contributor it
could be an impossible requirement.  To say nothing of the fact that
they will now have to read two documents instead of 1.

Thanks.

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] initial OpenCL C language support
  2010-10-27 13:36             ` Ken Werner
@ 2010-11-02 19:23               ` Joel Brobecker
  2010-11-03 13:03                 ` Ken Werner
  0 siblings, 1 reply; 36+ messages in thread
From: Joel Brobecker @ 2010-11-02 19:23 UTC (permalink / raw)
  To: Ken Werner; +Cc: Tom Tromey, gdb-patches

> > Just to clarify a bit what I was trying to say: Most of the comments are
> > mostly cosmetic, and I don't think we need to verify that you followed
> > the comments correctly. If this was the only comments I had, I would be
> > comfortable with pre-approving the patch, particularly since Tom already
> > looked at it as well.  But before the patch goes in, I'd like to understand
> > what the reason for the changes in c-exp.y...
> 
> The reason for looking up the primitive types instead of referring to
> the builtins is that the builtin types may have a wrong type size. The
> OpenCL type long for example is expected to have a size of 8 byte
> while the size of the GDB builtin long is dependant on the current
> architecture and might be only 4 bytes.

But you have the gdbarch vector when building the OpenCL long, right?
(see opencl_language_arch_info). For instance, in Ada, we don't know
the size of type "Integer", so we ask the gdbarch what is the size of
int.

  lai->primitive_type_vector [ada_primitive_type_int]
    = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch),
                         0, "integer");

That way, we can use the builtin types directly.  Would that work in
your case?

> +  /* Triple vectors have the size of a quad vector. */
                                                    ^^^ missing second space
> +/* Returns non-zero if the array ARR contains duplicates within
> +     the first N elements.  */

non-zero should be spelled nonzero. I have known that for quite a while
because a friend of mine is really good at spelling, but never really
thought much until I saw this being explicitly mentioned in the GCC
Coding Conventions. Let's try to fix them one at a time...

> +  for (i = offset; i < n; i++)
> +    {
> +      memcpy (value_contents_raw (v) + j++ * elsize,
> +	      value_contents (c->val) + c->indices[i] * elsize,
> +	      elsize);
> +    }

The curly braces are unnecessary in this case.

> +  for (i = start; i < end; i++)
> +    {
> +      int startoffset = (i == start) ? startrest : 0;
> +      int length = (i == end) ? endrest : elsize;
> +      if (!value_bits_valid (c->val, c->indices[i] * elsize + startoffset,
> +			     length))

Missing empty line after variable declarations...

> +  for (i = 0; i < c->n; i++)
> +    {
> +      if (value_bits_valid (c->val, c->indices[i] * elsize, elsize))
> +	return 1;
> +    }

Unecessary curly braces...

> +	      for (i = 0; i < n; i++)
> +		{
> +		  /* Copy src val contents into the destination value.  */
> +		  memcpy (value_contents_writeable (ret)
> +			  + (i * TYPE_LENGTH (elm_type)),
> +			  value_contents (val)
> +			  + (indices[i] * TYPE_LENGTH (elm_type)),
> +			  TYPE_LENGTH (elm_type));
> +		}

Likewise.

> +/* Perform a relational operation on two operands.  */
> +static struct value *
> +opencl_relop (struct expression *exp, struct value *arg1, struct value *arg2,
> +	      enum exp_opcode op)

Missing empty line after the function description.

> +  if (!t1_is_vec && !t2_is_vec)
> +    {
> +      int tmp = scalar_relop (arg1, arg2, op);
> +      struct type *type =
> +	language_bool_type (exp->language_defn, exp->gdbarch);
> +      val = value_from_longest (type, tmp);
> +    }

Missing empty line after variable declarations...

> +# Increase timeout
> +set timeout 60
> +verbose "Timeout set to $timeout seconds" 2

Have we determine why it is necessary to increase the timeout to 60?


-- 
Joel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [doc RFA] Switch to GCC coding style [Re: [patch] initial OpenCL C language support]
  2010-11-02 19:21                     ` Eli Zaretskii
@ 2010-11-02 19:29                       ` Joel Brobecker
  2010-11-08 12:50                       ` Jan Kratochvil
  1 sibling, 0 replies; 36+ messages in thread
From: Joel Brobecker @ 2010-11-02 19:29 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Jan Kratochvil, dje, gdb-patches, ken, tromey, pedro

> On balance, I think we should simply have our own coherent document.
> It can copy verbatim all the stuff that is relevant to GDB, but it
> should include the above renames, and it should omit everything that
> is irrelevant.  Any other way, we will just confuse potential
> contributors: it is perhaps easy for us old-timers to distinguish
> between the relevant and the rest, but for a newbie contributor it
> could be an impossible requirement.  To say nothing of the fact that
> they will now have to read two documents instead of 1.

I really agree with the above.

-- 
Joel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] initial OpenCL C language support
  2010-11-02 19:23               ` Joel Brobecker
@ 2010-11-03 13:03                 ` Ken Werner
  2010-11-03 15:27                   ` Joel Brobecker
  0 siblings, 1 reply; 36+ messages in thread
From: Ken Werner @ 2010-11-03 13:03 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Tom Tromey, gdb-patches

[-- Attachment #1: Type: Text/Plain, Size: 4498 bytes --]

On Tuesday, November 02, 2010 8:23:11 pm Joel Brobecker wrote:
> > > Just to clarify a bit what I was trying to say: Most of the comments
> > > are mostly cosmetic, and I don't think we need to verify that you
> > > followed the comments correctly. If this was the only comments I had,
> > > I would be comfortable with pre-approving the patch, particularly
> > > since Tom already looked at it as well.  But before the patch goes in,
> > > I'd like to understand what the reason for the changes in c-exp.y...
> > 
> > The reason for looking up the primitive types instead of referring to
> > the builtins is that the builtin types may have a wrong type size. The
> > OpenCL type long for example is expected to have a size of 8 byte
> > while the size of the GDB builtin long is dependant on the current
> > architecture and might be only 4 bytes.
> 
> But you have the gdbarch vector when building the OpenCL long, right?
> (see opencl_language_arch_info). For instance, in Ada, we don't know
> the size of type "Integer", so we ask the gdbarch what is the size of
> int.
> 
>   lai->primitive_type_vector [ada_primitive_type_int]
>     = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch),
>                          0, "integer");
> 
> That way, we can use the builtin types directly.  Would that work in
> your case?

In case of C (and probably Ada as well) the lengths of the builtin types 
depend on the architecuter/implementation but for OpenCL C it's kind of the 
other way round. I hard coded the lengths because OpenCL specifies fixed sizes 
of the builtin types:
http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/scalarDataTypes.html
http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/vectorDataTypes.html
Does this sound reasonable?

> > +  /* Triple vectors have the size of a quad vector. */
> 
>                                                     ^^^ missing second
> space

Fixed.

> > +/* Returns non-zero if the array ARR contains duplicates within
> > +     the first N elements.  */
> 
> non-zero should be spelled nonzero. I have known that for quite a while
> because a friend of mine is really good at spelling, but never really
> thought much until I saw this being explicitly mentioned in the GCC
> Coding Conventions. Let's try to fix them one at a time...

Changed.

> > +  for (i = offset; i < n; i++)
> > +    {
> > +      memcpy (value_contents_raw (v) + j++ * elsize,
> > +	      value_contents (c->val) + c->indices[i] * elsize,
> > +	      elsize);
> > +    }
> 
> The curly braces are unnecessary in this case.

Fixed.

> > +  for (i = start; i < end; i++)
> > +    {
> > +      int startoffset = (i == start) ? startrest : 0;
> > +      int length = (i == end) ? endrest : elsize;
> > +      if (!value_bits_valid (c->val, c->indices[i] * elsize +
> > startoffset, +			     length))
> 
> Missing empty line after variable declarations...

Added.

> > +  for (i = 0; i < c->n; i++)
> > +    {
> > +      if (value_bits_valid (c->val, c->indices[i] * elsize, elsize))
> > +	return 1;
> > +    }
> 
> Unecessary curly braces...
> 
> > +	      for (i = 0; i < n; i++)
> > +		{
> > +		  /* Copy src val contents into the destination value.  */
> > +		  memcpy (value_contents_writeable (ret)
> > +			  + (i * TYPE_LENGTH (elm_type)),
> > +			  value_contents (val)
> > +			  + (indices[i] * TYPE_LENGTH (elm_type)),
> > +			  TYPE_LENGTH (elm_type));
> > +		}
> 
> Likewise.

Fixed.

> > +/* Perform a relational operation on two operands.  */
> > +static struct value *
> > +opencl_relop (struct expression *exp, struct value *arg1, struct value
> > *arg2, +	      enum exp_opcode op)
> 
> Missing empty line after the function description.
> 
> > +  if (!t1_is_vec && !t2_is_vec)
> > +    {
> > +      int tmp = scalar_relop (arg1, arg2, op);
> > +      struct type *type =
> > +	language_bool_type (exp->language_defn, exp->gdbarch);
> > +      val = value_from_longest (type, tmp);
> > +    }
> 
> Missing empty line after variable declarations...

Both Added.

> > +# Increase timeout
> > +set timeout 60
> > +verbose "Timeout set to $timeout seconds" 2
> 
> Have we determine why it is necessary to increase the timeout to 60?

I encountered timeouts when running the OpenCL testsuite on a system that is 
busy with other things as well. As the default value of ten seconds is usually 
sufficient I removed the increase and cleaned up some other places as well. 
Thanks for bringing that up again.

An updated patch is attached.

Thanks
Ken

[-- Attachment #2: opencl-lang.patch --]
[-- Type: text/x-patch, Size: 191587 bytes --]

ChangeLog:

2010-11-03  Ken Werner  <ken.werner@de.ibm.com>

	* 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.

testsuite/ChangeLog:

2010-11-03  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.


Index: src/gdb/defs.h
===================================================================
--- src.orig/gdb/defs.h	2010-11-03 11:27:48.000000000 +0100
+++ src/gdb/defs.h	2010-11-03 12:44:07.000000000 +0100
@@ -201,6 +201,7 @@ enum language
     language_asm,		/* Assembly language */
     language_pascal,		/* Pascal */
     language_ada,		/* Ada */
+    language_opencl,		/* OpenCL */
     language_minimal,		/* All other languages, minimal support only */
     nr_languages
   };
Index: src/gdb/dwarf2read.c
===================================================================
--- src.orig/gdb/dwarf2read.c	2010-11-03 12:44:06.000000000 +0100
+++ src/gdb/dwarf2read.c	2010-11-03 12:44:07.000000000 +0100
@@ -5089,6 +5089,12 @@ read_file_scope (struct die_info *die, s
   if (attr)
     cu->producer = DW_STRING (attr);
 
+  /* The XLCL doesn't generate DW_LANG_OpenCL because this attribute is not
+     standardised yet.  As a workaround for the language detection we fall
+     back to the DW_AT_producer string.  */
+  if (cu->producer && strstr (cu->producer, "IBM XL C for OpenCL") != NULL)
+    cu->language = language_opencl;
+
   /* We assume that we're processing GCC output. */
   processing_gcc_compilation = 2;
 
Index: src/gdb/opencl-lang.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/opencl-lang.c	2010-11-03 12:44:07.000000000 +0100
@@ -0,0 +1,1162 @@
+/* OpenCL language support for GDB, the GNU debugger.
+   Copyright (C) 2010 Free Software Foundation, Inc.
+
+   Contributed by Ken Werner <ken.werner@de.ibm.com>.
+
+   This file is part of GDB.
+
+   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/>.  */
+
+#include "defs.h"
+#include "gdb_string.h"
+#include "gdbtypes.h"
+#include "symtab.h"
+#include "expression.h"
+#include "parser-defs.h"
+#include "symtab.h"
+#include "language.h"
+#include "c-lang.h"
+#include "gdb_assert.h"
+
+extern void _initialize_opencl_language (void);
+
+/* This macro generates enum values from a given type.  */
+
+#define OCL_P_TYPE(TYPE)\
+  opencl_primitive_type_##TYPE,\
+  opencl_primitive_type_##TYPE##2,\
+  opencl_primitive_type_##TYPE##3,\
+  opencl_primitive_type_##TYPE##4,\
+  opencl_primitive_type_##TYPE##8,\
+  opencl_primitive_type_##TYPE##16
+
+enum opencl_primitive_types {
+  OCL_P_TYPE (char),
+  OCL_P_TYPE (uchar),
+  OCL_P_TYPE (short),
+  OCL_P_TYPE (ushort),
+  OCL_P_TYPE (int),
+  OCL_P_TYPE (uint),
+  OCL_P_TYPE (long),
+  OCL_P_TYPE (ulong),
+  OCL_P_TYPE (half),
+  OCL_P_TYPE (float),
+  OCL_P_TYPE (double),
+  opencl_primitive_type_bool,
+  opencl_primitive_type_unsigned_char,
+  opencl_primitive_type_unsigned_short,
+  opencl_primitive_type_unsigned_int,
+  opencl_primitive_type_unsigned_long,
+  opencl_primitive_type_size_t,
+  opencl_primitive_type_ptrdiff_t,
+  opencl_primitive_type_intptr_t,
+  opencl_primitive_type_uintptr_t,
+  opencl_primitive_type_void,
+  nr_opencl_primitive_types
+};
+
+/* This macro generates the type struct declarations from a given type.  */
+
+#define STRUCT_OCL_TYPE(TYPE)\
+  struct type *builtin_##TYPE;\
+  struct type *builtin_##TYPE##2;\
+  struct type *builtin_##TYPE##3;\
+  struct type *builtin_##TYPE##4;\
+  struct type *builtin_##TYPE##8;\
+  struct type *builtin_##TYPE##16
+
+struct builtin_opencl_type
+{
+  STRUCT_OCL_TYPE (char);
+  STRUCT_OCL_TYPE (uchar);
+  STRUCT_OCL_TYPE (short);
+  STRUCT_OCL_TYPE (ushort);
+  STRUCT_OCL_TYPE (int);
+  STRUCT_OCL_TYPE (uint);
+  STRUCT_OCL_TYPE (long);
+  STRUCT_OCL_TYPE (ulong);
+  STRUCT_OCL_TYPE (half);
+  STRUCT_OCL_TYPE (float);
+  STRUCT_OCL_TYPE (double);
+  struct type *builtin_bool;
+  struct type *builtin_unsigned_char;
+  struct type *builtin_unsigned_short;
+  struct type *builtin_unsigned_int;
+  struct type *builtin_unsigned_long;
+  struct type *builtin_size_t;
+  struct type *builtin_ptrdiff_t;
+  struct type *builtin_intptr_t;
+  struct type *builtin_uintptr_t;
+  struct type *builtin_void;
+};
+
+static struct gdbarch_data *opencl_type_data;
+
+const struct builtin_opencl_type *
+builtin_opencl_type (struct gdbarch *gdbarch)
+{
+  return gdbarch_data (gdbarch, opencl_type_data);
+}
+
+/* Returns the corresponding OpenCL vector type from the given type code,
+   the length of the element type, the unsigned flag and the amount of
+   elements (N).  */
+
+static struct type *
+lookup_opencl_vector_type (struct gdbarch *gdbarch, enum type_code code,
+			   unsigned int el_length, unsigned int flag_unsigned,
+			   int n)
+{
+  int i;
+  unsigned int length;
+  struct type *type = NULL;
+  struct type **types = (struct type **) builtin_opencl_type (gdbarch);
+
+  /* Check if n describes a valid OpenCL vector size (2, 3, 4, 8, 16).  */
+  if (n != 2 && n != 3 && n != 4 && n != 8 && n != 16)
+    error (_("Invalid OpenCL vector size: %d"), n);
+
+  /* Triple vectors have the size of a quad vector.  */
+  length = (n == 3) ?  el_length * 4 : el_length * n;
+
+  for (i = 0; i < nr_opencl_primitive_types; i++)
+    {
+      LONGEST lowb, highb;
+
+      if (TYPE_CODE (types[i]) == TYPE_CODE_ARRAY && TYPE_VECTOR (types[i])
+	  && get_array_bounds (types[i], &lowb, &highb)
+	  && TYPE_CODE (TYPE_TARGET_TYPE (types[i])) == code
+	  && TYPE_UNSIGNED (TYPE_TARGET_TYPE (types[i])) == flag_unsigned
+	  && TYPE_LENGTH (TYPE_TARGET_TYPE (types[i])) == el_length
+	  && TYPE_LENGTH (types[i]) == length
+	  && highb - lowb + 1 == n)
+	{
+	  type = types[i];
+	  break;
+	}
+    }
+
+  return type;
+}
+
+/* Returns nonzero if the array ARR contains duplicates within
+     the first N elements.  */
+
+static int
+array_has_dups (int *arr, int n)
+{
+  int i, j;
+
+  for (i = 0; i < n; i++)
+    {
+      for (j = i + 1; j < n; j++)
+        {
+          if (arr[i] == arr[j])
+            return 1;
+        }
+    }
+
+  return 0;
+}
+
+/* The OpenCL component access syntax allows to create lvalues referring to
+   selected elements of an original OpenCL vector in arbitrary order.  This
+   structure holds the information to describe such lvalues.  */
+
+struct lval_closure
+{
+  /* Reference count.  */
+  int refc;
+  /* The number of indices.  */
+  int n;
+  /* The element indices themselves.  */
+  int *indices;
+  /* A pointer to the original value.  */
+  struct value *val;
+};
+
+/* Allocates an instance of struct lval_closure.  */
+
+static struct lval_closure *
+allocate_lval_closure (int *indices, int n, struct value *val)
+{
+  struct lval_closure *c = XZALLOC (struct lval_closure);
+
+  c->refc = 1;
+  c->n = n;
+  c->indices = XCALLOC (n, int);
+  memcpy (c->indices, indices, n * sizeof (int));
+  value_incref (val); /* Increment the reference counter of the value.  */
+  c->val = val;
+
+  return c;
+}
+
+static void
+lval_func_read (struct value *v)
+{
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+  struct type *type = check_typedef (value_type (v));
+  struct type *eltype = TYPE_TARGET_TYPE (check_typedef (value_type (c->val)));
+  int offset = value_offset (v);
+  int elsize = TYPE_LENGTH (eltype);
+  int n, i, j = 0;
+  LONGEST lowb = 0;
+  LONGEST highb = 0;
+
+  if (TYPE_CODE (type) == TYPE_CODE_ARRAY
+      && !get_array_bounds (type, &lowb, &highb))
+    error (_("Could not determine the vector bounds"));
+
+  /* Assume elsize aligned offset.  */
+  gdb_assert (offset % elsize == 0);
+  offset /= elsize;
+  n = offset + highb - lowb + 1;
+  gdb_assert (n <= c->n);
+
+  for (i = offset; i < n; i++)
+    memcpy (value_contents_raw (v) + j++ * elsize,
+	    value_contents (c->val) + c->indices[i] * elsize,
+	    elsize);
+}
+
+static void
+lval_func_write (struct value *v, struct value *fromval)
+{
+  struct value *mark = value_mark ();
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+  struct type *type = check_typedef (value_type (v));
+  struct type *eltype = TYPE_TARGET_TYPE (check_typedef (value_type (c->val)));
+  int offset = value_offset (v);
+  int elsize = TYPE_LENGTH (eltype);
+  int n, i, j = 0;
+  LONGEST lowb = 0;
+  LONGEST highb = 0;
+
+  if (TYPE_CODE (type) == TYPE_CODE_ARRAY
+      && !get_array_bounds (type, &lowb, &highb))
+    error (_("Could not determine the vector bounds"));
+
+  /* Assume elsize aligned offset.  */
+  gdb_assert (offset % elsize == 0);
+  offset /= elsize;
+  n = offset + highb - lowb + 1;
+
+  /* Since accesses to the fourth component of a triple vector is undefined we
+     just skip writes to the fourth element.  Imagine something like this:
+       int3 i3 = (int3)(0, 1, 2);
+       i3.hi.hi = 5;
+     In this case n would be 4 (offset=12/4 + 1) while c->n would be 3.  */
+  if (n > c->n)
+    n = c->n;
+
+  for (i = offset; i < n; i++)
+    {
+      struct value *from_elm_val = allocate_value (eltype);
+      struct value *to_elm_val = value_subscript (c->val, c->indices[i]);
+
+      memcpy (value_contents_writeable (from_elm_val),
+	      value_contents (fromval) + j++ * elsize,
+	      elsize);
+      value_assign (to_elm_val, from_elm_val);
+    }
+
+  value_free_to_mark (mark);
+}
+
+/* Return nonzero if all bits in V within OFFSET and LENGTH are valid.  */
+
+static int
+lval_func_check_validity (const struct value *v, int offset, int length)
+{
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+  /* Size of the target type in bits.  */
+  int elsize =
+      TYPE_LENGTH (TYPE_TARGET_TYPE (check_typedef (value_type (c->val)))) * 8;
+  int startrest = offset % elsize;
+  int start = offset / elsize;
+  int endrest = (offset + length) % elsize;
+  int end = (offset + length) / elsize;
+  int i;
+
+  if (endrest)
+    end++;
+
+  if (end > c->n)
+    return 0;
+
+  for (i = start; i < end; i++)
+    {
+      int startoffset = (i == start) ? startrest : 0;
+      int length = (i == end) ? endrest : elsize;
+
+      if (!value_bits_valid (c->val, c->indices[i] * elsize + startoffset,
+			     length))
+	return 0;
+    }
+
+  return 1;
+}
+
+/* Return nonzero if any bit in V is valid.  */
+
+static int
+lval_func_check_any_valid (const struct value *v)
+{
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+  /* Size of the target type in bits.  */
+  int elsize =
+      TYPE_LENGTH (TYPE_TARGET_TYPE (check_typedef (value_type (c->val)))) * 8;
+  int i;
+
+  for (i = 0; i < c->n; i++)
+    if (value_bits_valid (c->val, c->indices[i] * elsize, elsize))
+      return 1;
+
+  return 0;
+}
+
+static void *
+lval_func_copy_closure (const struct value *v)
+{
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+
+  ++c->refc;
+
+  return c;
+}
+
+static void
+lval_func_free_closure (struct value *v)
+{
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+
+  --c->refc;
+
+  if (c->refc == 0)
+    {
+      xfree (c->indices);
+      xfree (c);
+      value_free (c->val); /* Decrement the reference counter of the value.  */
+    }
+}
+
+static struct lval_funcs opencl_value_funcs =
+  {
+    lval_func_read,
+    lval_func_write,
+    lval_func_check_validity,
+    lval_func_check_any_valid,
+    lval_func_copy_closure,
+    lval_func_free_closure
+  };
+
+/* Creates a sub-vector from VAL.  The elements are selected by the indices of
+   an array with the length of N.  Supported values for NOSIDE are
+   EVAL_NORMAL and EVAL_AVOID_SIDE_EFFECTS.  */
+
+static struct value *
+create_value (struct gdbarch *gdbarch, struct value *val, enum noside noside,
+	      int *indices, int n)
+{
+  struct type *type = check_typedef (value_type (val));
+  struct type *elm_type = TYPE_TARGET_TYPE (type);
+  struct value *ret;
+
+  /* Check if a single component of a vector is requested which means
+     the resulting type is a (primitive) scalar type.  */
+  if (n == 1)
+    {
+      if (noside == EVAL_AVOID_SIDE_EFFECTS)
+        ret = value_zero (elm_type, not_lval);
+      else
+        ret = value_subscript (val, indices[0]);
+    }
+  else
+    {
+      /* Multiple components of the vector are requested which means the
+	 resulting type is a vector as well.  */
+      struct type *dst_type =
+	lookup_opencl_vector_type (gdbarch, TYPE_CODE (elm_type),
+				   TYPE_LENGTH (elm_type),
+				   TYPE_UNSIGNED (elm_type), n);
+
+      if (dst_type == NULL)
+	dst_type = init_vector_type (elm_type, n);
+
+      make_cv_type (TYPE_CONST (type), TYPE_VOLATILE (type), dst_type, NULL);
+
+      if (noside == EVAL_AVOID_SIDE_EFFECTS)
+	ret = allocate_value (dst_type);
+      else
+	{
+	  /* Check whether to create a lvalue or not.  */
+	  if (VALUE_LVAL (val) != not_lval && !array_has_dups (indices, n))
+	    {
+	      struct lval_closure *c = allocate_lval_closure (indices, n, val);
+	      ret = allocate_computed_value (dst_type, &opencl_value_funcs, c);
+	    }
+	  else
+	    {
+	      int i;
+
+	      ret = allocate_value (dst_type);
+
+	      /* Copy src val contents into the destination value.  */
+	      for (i = 0; i < n; i++)
+		memcpy (value_contents_writeable (ret)
+			+ (i * TYPE_LENGTH (elm_type)),
+			value_contents (val)
+			+ (indices[i] * TYPE_LENGTH (elm_type)),
+			TYPE_LENGTH (elm_type));
+	    }
+	}
+    }
+  return ret;
+}
+
+/* OpenCL vector component access.  */
+
+static struct value *
+opencl_component_ref (struct expression *exp, struct value *val, char *comps,
+		      enum noside noside)
+{
+  LONGEST lowb, highb;
+  int src_len;
+  struct value *v;
+  int indices[16], i;
+  int dst_len;
+
+  if (!get_array_bounds (check_typedef (value_type (val)), &lowb, &highb))
+    error (_("Could not determine the vector bounds"));
+
+  src_len = highb - lowb + 1;
+
+  /* Throw an error if the amount of array elements does not fit a
+     valid OpenCL vector size (2, 3, 4, 8, 16).  */
+  if (src_len != 2 && src_len != 3 && src_len != 4 && src_len != 8
+      && src_len != 16)
+    error (_("Invalid OpenCL vector size"));
+
+  if (strcmp (comps, "lo") == 0 )
+    {
+      dst_len = (src_len == 3) ? 2 : src_len / 2;
+
+      for (i = 0; i < dst_len; i++)
+	indices[i] = i;
+    }
+  else if (strcmp (comps, "hi") == 0)
+    {
+      dst_len = (src_len == 3) ? 2 : src_len / 2;
+
+      for (i = 0; i < dst_len; i++)
+	indices[i] = dst_len + i;
+    }
+  else if (strcmp (comps, "even") == 0)
+    {
+      dst_len = (src_len == 3) ? 2 : src_len / 2;
+
+      for (i = 0; i < dst_len; i++)
+	indices[i] = i*2;
+    }
+  else if (strcmp (comps, "odd") == 0)
+    {
+      dst_len = (src_len == 3) ? 2 : src_len / 2;
+
+      for (i = 0; i < dst_len; i++)
+        indices[i] = i*2+1;
+    }
+  else if (strncasecmp (comps, "s", 1) == 0)
+    {
+#define HEXCHAR_TO_INT(C) ((C >= '0' && C <= '9') ? \
+                           C-'0' : ((C >= 'A' && C <= 'F') ? \
+                           C-'A'+10 : ((C >= 'a' && C <= 'f') ? \
+                           C-'a'+10 : -1)))
+
+      dst_len = strlen (comps);
+      /* Skip the s/S-prefix.  */
+      dst_len--;
+
+      for (i = 0; i < dst_len; i++)
+	{
+	  indices[i] = HEXCHAR_TO_INT(comps[i+1]);
+	  /* Check if the requested component is invalid or exceeds
+	     the vector.  */
+	  if (indices[i] < 0 || indices[i] >= src_len)
+	    error (_("Invalid OpenCL vector component accessor %s"), comps);
+	}
+    }
+  else
+    {
+      dst_len = strlen (comps);
+
+      for (i = 0; i < dst_len; i++)
+	{
+	  /* x, y, z, w */
+	  switch (comps[i])
+	  {
+	  case 'x':
+	    indices[i] = 0;
+	    break;
+	  case 'y':
+	    indices[i] = 1;
+	    break;
+	  case 'z':
+	    if (src_len < 3)
+	      error (_("Invalid OpenCL vector component accessor %s"), comps);
+	    indices[i] = 2;
+	    break;
+	  case 'w':
+	    if (src_len < 4)
+	      error (_("Invalid OpenCL vector component accessor %s"), comps);
+	    indices[i] = 3;
+	    break;
+	  default:
+	    error (_("Invalid OpenCL vector component accessor %s"), comps);
+	    break;
+	  }
+	}
+    }
+
+  /* Throw an error if the amount of requested components does not
+     result in a valid length (1, 2, 3, 4, 8, 16).  */
+  if (dst_len != 1 && dst_len != 2 && dst_len != 3 && dst_len != 4
+      && dst_len != 8 && dst_len != 16)
+    error (_("Invalid OpenCL vector component accessor %s"), comps);
+
+  v = create_value (exp->gdbarch, val, noside, indices, dst_len);
+
+  return v;
+}
+
+/* Perform the unary logical not (!) operation.  */
+
+static struct value *
+opencl_logical_not (struct expression *exp, struct value *arg)
+{
+  struct type *type = check_typedef (value_type (arg));
+  struct type *rettype;
+  struct value *ret;
+
+  if (TYPE_CODE (type) == TYPE_CODE_ARRAY && TYPE_VECTOR (type))
+    {
+      struct type *eltype = check_typedef (TYPE_TARGET_TYPE (type));
+      LONGEST lowb, highb;
+      int i;
+
+      if (!get_array_bounds (type, &lowb, &highb))
+	error (_("Could not determine the vector bounds"));
+
+      /* Determine the resulting type of the operation and allocate the
+	 value.  */
+      rettype = lookup_opencl_vector_type (exp->gdbarch, TYPE_CODE_INT,
+					   TYPE_LENGTH (eltype), 0,
+					   highb - lowb + 1);
+      ret = allocate_value (rettype);
+
+      for (i = 0; i < highb - lowb + 1; i++)
+	{
+	  /* For vector types, the unary operator shall return a 0 if the
+	  value of its operand compares unequal to 0, and -1 (i.e. all bits
+	  set) if the value of its operand compares equal to 0.  */
+	  int tmp = value_logical_not (value_subscript (arg, i)) ? -1 : 0;
+	  memset (value_contents_writeable (ret) + i * TYPE_LENGTH (eltype),
+		  tmp, TYPE_LENGTH (eltype));
+	}
+    }
+  else
+    {
+      rettype = language_bool_type (exp->language_defn, exp->gdbarch);
+      ret = value_from_longest (rettype, value_logical_not (arg));
+    }
+
+  return ret;
+}
+
+/* Perform a relational operation on two scalar operands.  */
+
+static int
+scalar_relop (struct value *val1, struct value *val2, enum exp_opcode op)
+{
+  int ret;
+
+  switch (op)
+    {
+    case BINOP_EQUAL:
+      ret = value_equal (val1, val2);
+      break;
+    case BINOP_NOTEQUAL:
+      ret = !value_equal (val1, val2);
+      break;
+    case BINOP_LESS:
+      ret = value_less (val1, val2);
+      break;
+    case BINOP_GTR:
+      ret = value_less (val2, val1);
+      break;
+    case BINOP_GEQ:
+      ret = value_less (val2, val1) || value_equal (val1, val2);
+      break;
+    case BINOP_LEQ:
+      ret = value_less (val1, val2) || value_equal (val1, val2);
+      break;
+    case BINOP_LOGICAL_AND:
+      ret = !value_logical_not (val1) && !value_logical_not (val2);
+      break;
+    case BINOP_LOGICAL_OR:
+      ret = !value_logical_not (val1) || !value_logical_not (val2);
+      break;
+    default:
+      error (_("Attempt to perform an unsupported operation"));
+      break;
+    }
+  return ret;
+}
+
+/* Perform a relational operation on two vector operands.  */
+
+static struct value *
+vector_relop (struct expression *exp, struct value *val1, struct value *val2,
+	      enum exp_opcode op)
+{
+  struct value *ret;
+  struct type *type1, *type2, *eltype1, *eltype2, *rettype;
+  int t1_is_vec, t2_is_vec, i;
+  LONGEST lowb1, lowb2, highb1, highb2;
+
+  type1 = check_typedef (value_type (val1));
+  type2 = check_typedef (value_type (val2));
+
+  t1_is_vec = (TYPE_CODE (type1) == TYPE_CODE_ARRAY && TYPE_VECTOR (type1));
+  t2_is_vec = (TYPE_CODE (type2) == TYPE_CODE_ARRAY && TYPE_VECTOR (type2));
+
+  if (!t1_is_vec || !t2_is_vec)
+    error (_("Vector operations are not supported on scalar types"));
+
+  eltype1 = check_typedef (TYPE_TARGET_TYPE (type1));
+  eltype2 = check_typedef (TYPE_TARGET_TYPE (type2));
+
+  if (!get_array_bounds (type1,&lowb1, &highb1)
+      || !get_array_bounds (type2, &lowb2, &highb2))
+    error (_("Could not determine the vector bounds"));
+
+  /* Check whether the vector types are compatible.  */
+  if (TYPE_CODE (eltype1) != TYPE_CODE (eltype2)
+      || TYPE_LENGTH (eltype1) != TYPE_LENGTH (eltype2)
+      || TYPE_UNSIGNED (eltype1) != TYPE_UNSIGNED (eltype2)
+      || lowb1 != lowb2 || highb1 != highb2)
+    error (_("Cannot perform operation on vectors with different types"));
+
+  /* Determine the resulting type of the operation and allocate the value.  */
+  rettype = lookup_opencl_vector_type (exp->gdbarch, TYPE_CODE_INT,
+				       TYPE_LENGTH (eltype1), 0,
+				       highb1 - lowb1 + 1);
+  ret = allocate_value (rettype);
+
+  for (i = 0; i < highb1 - lowb1 + 1; i++)
+    {
+      /* For vector types, the relational, equality and logical operators shall
+	 return 0 if the specified relation is false and -1 (i.e. all bits set)
+	 if the specified relation is true.  */
+      int tmp = scalar_relop (value_subscript (val1, i),
+			      value_subscript (val2, i), op) ? -1 : 0;
+      memset (value_contents_writeable (ret) + i * TYPE_LENGTH (eltype1),
+	      tmp, TYPE_LENGTH (eltype1));
+     }
+
+  return ret;
+}
+
+/* Perform a relational operation on two operands.  */
+
+static struct value *
+opencl_relop (struct expression *exp, struct value *arg1, struct value *arg2,
+	      enum exp_opcode op)
+{
+  struct value *val;
+  struct type *type1 = check_typedef (value_type (arg1));
+  struct type *type2 = check_typedef (value_type (arg2));
+  int t1_is_vec = (TYPE_CODE (type1) == TYPE_CODE_ARRAY
+		   && TYPE_VECTOR (type1));
+  int t2_is_vec = (TYPE_CODE (type2) == TYPE_CODE_ARRAY
+		   && TYPE_VECTOR (type2));
+
+  if (!t1_is_vec && !t2_is_vec)
+    {
+      int tmp = scalar_relop (arg1, arg2, op);
+      struct type *type =
+	language_bool_type (exp->language_defn, exp->gdbarch);
+
+      val = value_from_longest (type, tmp);
+    }
+  else if (t1_is_vec && t2_is_vec)
+    {
+      val = vector_relop (exp, arg1, arg2, op);
+    }
+  else
+    {
+      /* Widen the scalar operand to a vector.  */
+      struct value **v = t1_is_vec ? &arg2 : &arg1;
+      struct type *t = t1_is_vec ? type2 : type1;
+
+      if (TYPE_CODE (t) != TYPE_CODE_FLT && !is_integral_type (t))
+	error (_("Argument to operation not a number or boolean."));
+
+      *v = value_cast (t1_is_vec ? type1 : type2, *v);
+      val = vector_relop (exp, arg1, arg2, op);
+    }
+
+  return val;
+}
+
+/* Expression evaluator for the OpenCL.  Most operations are delegated to
+   evaluate_subexp_standard; see that function for a description of the
+   arguments.  */
+
+static struct value *
+evaluate_subexp_opencl (struct type *expect_type, struct expression *exp,
+		   int *pos, enum noside noside)
+{
+  enum exp_opcode op = exp->elts[*pos].opcode;
+  struct value *arg1 = NULL;
+  struct value *arg2 = NULL;
+  struct type *type1, *type2;
+
+  switch (op)
+    {
+    /* Handle binary relational and equality operators that are either not
+       or differently defined for GNU vectors.  */
+    case BINOP_EQUAL:
+    case BINOP_NOTEQUAL:
+    case BINOP_LESS:
+    case BINOP_GTR:
+    case BINOP_GEQ:
+    case BINOP_LEQ:
+      (*pos)++;
+      arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+      arg2 = evaluate_subexp (value_type (arg1), exp, pos, noside);
+
+      if (noside == EVAL_SKIP)
+	return value_from_longest (builtin_type (exp->gdbarch)->
+				   builtin_int, 1);
+
+      return opencl_relop (exp, arg1, arg2, op);
+
+    /* Handle the logical unary operator not(!).  */
+    case UNOP_LOGICAL_NOT:
+      (*pos)++;
+      arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+
+      if (noside == EVAL_SKIP)
+	return value_from_longest (builtin_type (exp->gdbarch)->
+				   builtin_int, 1);
+
+      return opencl_logical_not (exp, arg1);
+
+    /* Handle the logical operator and(&&) and or(||).  */
+    case BINOP_LOGICAL_AND:
+    case BINOP_LOGICAL_OR:
+      (*pos)++;
+      arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+
+      if (noside == EVAL_SKIP)
+	{
+	  arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+
+	  return value_from_longest (builtin_type (exp->gdbarch)->
+				     builtin_int, 1);
+	}
+      else
+	{
+	  /* For scalar operations we need to avoid evaluating operands
+	     unecessarily.  However, for vector operations we always need to
+	     evaluate both operands.  Unfortunately we only know which of the
+	     two cases apply after we know the type of the second operand.
+	     Therefore we evaluate it once using EVAL_AVOID_SIDE_EFFECTS.  */
+	  int oldpos = *pos;
+
+	  arg2 = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
+	  *pos = oldpos;
+	  type1 = check_typedef (value_type (arg1));
+	  type2 = check_typedef (value_type (arg2));
+
+	  if ((TYPE_CODE (type1) == TYPE_CODE_ARRAY && TYPE_VECTOR (type1))
+	      || (TYPE_CODE (type2) == TYPE_CODE_ARRAY && TYPE_VECTOR (type2)))
+	    {
+	      arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+
+	      return opencl_relop (exp, arg1, arg2, op);
+	    }
+	  else
+	    {
+	      /* For scalar built-in types, only evaluate the right
+		 hand operand if the left hand operand compares
+		 unequal(&&)/equal(||) to 0.  */
+	      int res;
+	      int tmp = value_logical_not (arg1);
+
+	      if (op == BINOP_LOGICAL_OR)
+		tmp = !tmp;
+
+	      arg2 = evaluate_subexp (NULL_TYPE, exp, pos,
+				      tmp ? EVAL_SKIP : noside);
+	      type1 = language_bool_type (exp->language_defn, exp->gdbarch);
+
+	      if (op == BINOP_LOGICAL_AND)
+		res = !tmp && !value_logical_not (arg2);
+	      else /* BINOP_LOGICAL_OR */
+		res = tmp || !value_logical_not (arg2);
+
+	      return value_from_longest (type1, res);
+	    }
+	}
+
+    /* Handle the ternary selection operator.  */
+    case TERNOP_COND:
+      (*pos)++;
+      arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+      type1 = check_typedef (value_type (arg1));
+      if (TYPE_CODE (type1) == TYPE_CODE_ARRAY && TYPE_VECTOR (type1))
+	{
+	  struct value *arg3, *tmp, *ret;
+	  struct type *eltype2, *type3, *eltype3;
+	  int t2_is_vec, t3_is_vec, i;
+	  LONGEST lowb1, lowb2, lowb3, highb1, highb2, highb3;
+
+	  arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	  arg3 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	  type2 = check_typedef (value_type (arg2));
+	  type3 = check_typedef (value_type (arg3));
+	  t2_is_vec
+	    = TYPE_CODE (type2) == TYPE_CODE_ARRAY && TYPE_VECTOR (type2);
+	  t3_is_vec
+	    = TYPE_CODE (type3) == TYPE_CODE_ARRAY && TYPE_VECTOR (type3);
+
+	  /* Widen the scalar operand to a vector if necessary.  */
+	  if (t2_is_vec || !t3_is_vec)
+	    {
+	      arg3 = value_cast (type2, arg3);
+	      type3 = value_type (arg3);
+	    }
+	  else if (!t2_is_vec || t3_is_vec)
+	    {
+	      arg2 = value_cast (type3, arg2);
+	      type2 = value_type (arg2);
+	    }
+	  else if (!t2_is_vec || !t3_is_vec)
+	    {
+	      /* Throw an error if arg2 or arg3 aren't vectors.  */
+	      error (_("\
+Cannot perform conditional operation on incompatible types"));
+	    }
+
+	  eltype2 = check_typedef (TYPE_TARGET_TYPE (type2));
+	  eltype3 = check_typedef (TYPE_TARGET_TYPE (type3));
+
+	  if (!get_array_bounds (type1, &lowb1, &highb1)
+	      || !get_array_bounds (type2, &lowb2, &highb2)
+	      || !get_array_bounds (type3, &lowb3, &highb3))
+	    error (_("Could not determine the vector bounds"));
+
+	  /* Throw an error if the types of arg2 or arg3 are incompatible.  */
+	  if (TYPE_CODE (eltype2) != TYPE_CODE (eltype3)
+	      || TYPE_LENGTH (eltype2) != TYPE_LENGTH (eltype3)
+	      || TYPE_UNSIGNED (eltype2) != TYPE_UNSIGNED (eltype3)
+	      || lowb2 != lowb3 || highb2 != highb3)
+	    error (_("\
+Cannot perform operation on vectors with different types"));
+
+	  /* Throw an error if the sizes of arg1 and arg2/arg3 differ.  */
+	  if (lowb1 != lowb2 || lowb1 != lowb3
+	      || highb1 != highb2 || highb1 != highb3)
+	    error (_("\
+Cannot perform conditional operation on vectors with different sizes"));
+
+	  ret = allocate_value (type2);
+
+	  for (i = 0; i < highb1 - lowb1 + 1; i++)
+	    {
+	      tmp = value_logical_not (value_subscript (arg1, i)) ?
+		    value_subscript (arg3, i) : value_subscript (arg2, i);
+	      memcpy (value_contents_writeable (ret) +
+		      i * TYPE_LENGTH (eltype2), value_contents_all (tmp),
+		      TYPE_LENGTH (eltype2));
+	    }
+
+	  return ret;
+	}
+      else
+	{
+	  if (value_logical_not (arg1))
+	    {
+	      /* Skip the second operand.  */
+	      evaluate_subexp (NULL_TYPE, exp, pos, EVAL_SKIP);
+
+	      return evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	    }
+	  else
+	    {
+	      /* Skip the third operand.  */
+	      arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	      evaluate_subexp (NULL_TYPE, exp, pos, EVAL_SKIP);
+
+	      return arg2;
+	    }
+	}
+
+    /* Handle STRUCTOP_STRUCT to allow component access on OpenCL vectors.  */
+    case STRUCTOP_STRUCT:
+      {
+	int pc = (*pos)++;
+	int tem = longest_to_int (exp->elts[pc + 1].longconst);
+
+	(*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
+	arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	type1 = check_typedef (value_type (arg1));
+
+	if (noside == EVAL_SKIP)
+	  {
+	    return value_from_longest (builtin_type (exp->gdbarch)->
+				       builtin_int, 1);
+	  }
+	else if (TYPE_CODE (type1) == TYPE_CODE_ARRAY && TYPE_VECTOR (type1))
+	  {
+	    return opencl_component_ref (exp, arg1, &exp->elts[pc + 2].string,
+					 noside);
+	  }
+	else
+	  {
+	    if (noside == EVAL_AVOID_SIDE_EFFECTS)
+	      return
+		  value_zero (lookup_struct_elt_type
+			      (value_type (arg1),&exp->elts[pc + 2].string, 0),
+			      lval_memory);
+	    else
+	      return value_struct_elt (&arg1, NULL,
+				       &exp->elts[pc + 2].string, NULL,
+				       "structure");
+	  }
+      }
+    default:
+      break;
+    }
+
+  return evaluate_subexp_c (expect_type, exp, pos, noside);
+}
+
+void
+opencl_language_arch_info (struct gdbarch *gdbarch,
+		      struct language_arch_info *lai)
+{
+  const struct builtin_opencl_type *builtin = builtin_opencl_type (gdbarch);
+
+  lai->string_char_type = builtin->builtin_char;
+  lai->primitive_type_vector
+    = GDBARCH_OBSTACK_CALLOC (gdbarch, nr_opencl_primitive_types + 1,
+			      struct type *);
+
+/* This macro fills the primitive_type_vector from a given type.  */
+#define FILL_TYPE_VECTOR(LAI, TYPE)\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE]\
+    = builtin->builtin_##TYPE;\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE##2]\
+    = builtin->builtin_##TYPE##2;\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE##3]\
+    = builtin->builtin_##TYPE##3;\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE##4]\
+    = builtin->builtin_##TYPE##4;\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE##8]\
+    = builtin->builtin_##TYPE##8;\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE##16]\
+    = builtin->builtin_##TYPE##16
+
+  FILL_TYPE_VECTOR (lai, char);
+  FILL_TYPE_VECTOR (lai, uchar);
+  FILL_TYPE_VECTOR (lai, short);
+  FILL_TYPE_VECTOR (lai, ushort);
+  FILL_TYPE_VECTOR (lai, int);
+  FILL_TYPE_VECTOR (lai, uint);
+  FILL_TYPE_VECTOR (lai, long);
+  FILL_TYPE_VECTOR (lai, ulong);
+  FILL_TYPE_VECTOR (lai, half);
+  FILL_TYPE_VECTOR (lai, float);
+  FILL_TYPE_VECTOR (lai, double);
+  lai->primitive_type_vector [opencl_primitive_type_bool]
+    = builtin->builtin_bool;
+  lai->primitive_type_vector [opencl_primitive_type_unsigned_char]
+    = builtin->builtin_unsigned_char;
+  lai->primitive_type_vector [opencl_primitive_type_unsigned_short]
+    = builtin->builtin_unsigned_short;
+  lai->primitive_type_vector [opencl_primitive_type_unsigned_int]
+    = builtin->builtin_unsigned_int;
+  lai->primitive_type_vector [opencl_primitive_type_unsigned_long]
+    = builtin->builtin_unsigned_long;
+  lai->primitive_type_vector [opencl_primitive_type_half]
+    = builtin->builtin_half;
+  lai->primitive_type_vector [opencl_primitive_type_size_t]
+    = builtin->builtin_size_t;
+  lai->primitive_type_vector [opencl_primitive_type_ptrdiff_t]
+    = builtin->builtin_ptrdiff_t;
+  lai->primitive_type_vector [opencl_primitive_type_intptr_t]
+    = builtin->builtin_intptr_t;
+  lai->primitive_type_vector [opencl_primitive_type_uintptr_t]
+    = builtin->builtin_uintptr_t;
+  lai->primitive_type_vector [opencl_primitive_type_void]
+    = builtin->builtin_void;
+
+  /* Specifies the return type of logical and relational operations.  */
+  lai->bool_type_symbol = "int";
+  lai->bool_type_default = builtin->builtin_int;
+}
+
+const struct exp_descriptor exp_descriptor_opencl =
+{
+  print_subexp_standard,
+  operator_length_standard,
+  operator_check_standard,
+  op_name_standard,
+  dump_subexp_body_standard,
+  evaluate_subexp_opencl
+};
+
+const struct language_defn opencl_language_defn =
+{
+  "opencl",			/* Language name */
+  language_opencl,
+  range_check_off,
+  type_check_off,
+  case_sensitive_on,
+  array_row_major,
+  macro_expansion_c,
+  &exp_descriptor_opencl,
+  c_parse,
+  c_error,
+  null_post_parser,
+  c_printchar,			/* Print a character constant */
+  c_printstr,			/* Function to print string constant */
+  c_emit_char,			/* Print a single char */
+  c_print_type,			/* Print a type using appropriate syntax */
+  c_print_typedef,		/* Print a typedef using appropriate syntax */
+  c_val_print,			/* Print a value using appropriate syntax */
+  c_value_print,		/* Print a top-level value */
+  NULL,				/* Language specific skip_trampoline */
+  NULL,                         /* name_of_this */
+  basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
+  basic_lookup_transparent_type,/* lookup_transparent_type */
+  NULL,				/* Language specific symbol demangler */
+  NULL,				/* Language specific class_name_from_physname */
+  c_op_print_tab,		/* expression operators for printing */
+  1,				/* c-style arrays */
+  0,				/* String lower bound */
+  default_word_break_characters,
+  default_make_symbol_completion_list,
+  opencl_language_arch_info,
+  default_print_array_index,
+  default_pass_by_reference,
+  c_get_string,
+  LANG_MAGIC
+};
+
+static void *
+build_opencl_types (struct gdbarch *gdbarch)
+{
+  struct builtin_opencl_type *builtin_opencl_type
+    = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct builtin_opencl_type);
+
+/* Helper macro to create strings.  */
+#define STRINGIFY(S) #S
+/* This macro allocates and assigns the type struct pointers
+   for the vector types.  */
+#define BUILD_OCL_VTYPES(TYPE)\
+  builtin_opencl_type->builtin_##TYPE##2\
+    = init_vector_type (builtin_opencl_type->builtin_##TYPE, 2);\
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##2) = STRINGIFY(TYPE ## 2);\
+  builtin_opencl_type->builtin_##TYPE##3\
+    = init_vector_type (builtin_opencl_type->builtin_##TYPE, 3);\
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##3) = STRINGIFY(TYPE ## 3);\
+  TYPE_LENGTH (builtin_opencl_type->builtin_##TYPE##3)\
+    = 4 * TYPE_LENGTH (builtin_opencl_type->builtin_##TYPE);\
+  builtin_opencl_type->builtin_##TYPE##4\
+    = init_vector_type (builtin_opencl_type->builtin_##TYPE, 4);\
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##4) = STRINGIFY(TYPE ## 4);\
+  builtin_opencl_type->builtin_##TYPE##8\
+    = init_vector_type (builtin_opencl_type->builtin_##TYPE, 8);\
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##8) = STRINGIFY(TYPE ## 8);\
+  builtin_opencl_type->builtin_##TYPE##16\
+    = init_vector_type (builtin_opencl_type->builtin_##TYPE, 16);\
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##16) = STRINGIFY(TYPE ## 16)
+
+  builtin_opencl_type->builtin_char
+    = arch_integer_type (gdbarch, 8, 0, "char");
+  BUILD_OCL_VTYPES (char);
+  builtin_opencl_type->builtin_uchar
+    = arch_integer_type (gdbarch, 8, 1, "uchar");
+  BUILD_OCL_VTYPES (uchar);
+  builtin_opencl_type->builtin_short
+    = arch_integer_type (gdbarch, 16, 0, "short");
+  BUILD_OCL_VTYPES (short);
+  builtin_opencl_type->builtin_ushort
+    = arch_integer_type (gdbarch, 16, 1, "ushort");
+  BUILD_OCL_VTYPES (ushort);
+  builtin_opencl_type->builtin_int
+    = arch_integer_type (gdbarch, 32, 0, "int");
+  BUILD_OCL_VTYPES (int);
+  builtin_opencl_type->builtin_uint
+    = arch_integer_type (gdbarch, 32, 1, "uint");
+  BUILD_OCL_VTYPES (uint);
+  builtin_opencl_type->builtin_long
+    = arch_integer_type (gdbarch, 64, 0, "long");
+  BUILD_OCL_VTYPES (long);
+  builtin_opencl_type->builtin_ulong
+    = arch_integer_type (gdbarch, 64, 1, "ulong");
+  BUILD_OCL_VTYPES (ulong);
+  builtin_opencl_type->builtin_half
+    = arch_float_type (gdbarch, 16, "half", floatformats_ieee_half);
+  BUILD_OCL_VTYPES (half);
+  builtin_opencl_type->builtin_float
+    = arch_float_type (gdbarch, 32, "float", floatformats_ieee_single);
+  BUILD_OCL_VTYPES (float);
+  builtin_opencl_type->builtin_double
+    = arch_float_type (gdbarch, 64, "double", floatformats_ieee_double);
+  BUILD_OCL_VTYPES (double);
+  builtin_opencl_type->builtin_bool
+    = arch_boolean_type (gdbarch, 32, 1, "bool");
+  builtin_opencl_type->builtin_unsigned_char
+    = arch_integer_type (gdbarch, 8, 1, "unsigned char");
+  builtin_opencl_type->builtin_unsigned_short
+    = arch_integer_type (gdbarch, 16, 1, "unsigned short");
+  builtin_opencl_type->builtin_unsigned_int
+    = arch_integer_type (gdbarch, 32, 1, "unsigned int");
+  builtin_opencl_type->builtin_unsigned_long
+    = arch_integer_type (gdbarch, 64, 1, "unsigned long");
+  builtin_opencl_type->builtin_size_t
+    = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 1, "size_t");
+  builtin_opencl_type->builtin_ptrdiff_t
+    = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 0, "ptrdiff_t");
+  builtin_opencl_type->builtin_intptr_t
+    = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 0, "intptr_t");
+  builtin_opencl_type->builtin_uintptr_t
+    = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 1, "uintptr_t");
+  builtin_opencl_type->builtin_void
+    = arch_type (gdbarch, TYPE_CODE_VOID, 1, "void");
+
+  return builtin_opencl_type;
+}
+
+void
+_initialize_opencl_language (void)
+{
+  opencl_type_data = gdbarch_data_register_post_init (build_opencl_types);
+  add_language (&opencl_language_defn);
+}
Index: src/gdb/Makefile.in
===================================================================
--- src.orig/gdb/Makefile.in	2010-11-03 11:27:48.000000000 +0100
+++ src/gdb/Makefile.in	2010-11-03 12:44:07.000000000 +0100
@@ -689,6 +689,7 @@ SFILES = ada-exp.y ada-lang.c ada-typepr
 	mi/mi-common.c \
 	objc-exp.y objc-lang.c \
 	objfiles.c osabi.c observer.c osdata.c \
+	opencl-lang.c \
 	p-exp.y p-lang.c p-typeprint.c p-valprint.c parse.c printcmd.c \
 	proc-service.list progspace.c \
 	prologue-value.c psymtab.c \
@@ -845,7 +846,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $
 	ui-out.o cli-out.o \
 	varobj.o vec.o wrapper.o \
 	jv-lang.o jv-valprint.o jv-typeprint.o \
-	m2-lang.o p-lang.o p-typeprint.o p-valprint.o \
+	m2-lang.o opencl-lang.o p-lang.o p-typeprint.o p-valprint.o \
 	sentinel-frame.o \
 	complaints.o typeprint.o \
 	ada-typeprint.o c-typeprint.o f-typeprint.o m2-typeprint.o \
Index: src/gdb/eval.c
===================================================================
--- src.orig/gdb/eval.c	2010-11-03 12:44:03.000000000 +0100
+++ src/gdb/eval.c	2010-11-03 12:44:07.000000000 +0100
@@ -603,6 +603,7 @@ binop_promote (const struct language_def
 	case language_cplus:
 	case language_asm:
 	case language_objc:
+	case language_opencl:
 	  /* No promotion required.  */
 	  break;
 
@@ -690,7 +691,24 @@ binop_promote (const struct language_def
 			       : builtin->builtin_long_long);
 	    }
 	  break;
-
+	case language_opencl:
+	  if (result_len <= TYPE_LENGTH (lookup_signed_typename
+					 (language, gdbarch, "int")))
+	    {
+	      promoted_type =
+		(unsigned_operation
+		 ? lookup_unsigned_typename (language, gdbarch, "int")
+		 : lookup_signed_typename (language, gdbarch, "int"));
+	    }
+	  else if (result_len <= TYPE_LENGTH (lookup_signed_typename
+					      (language, gdbarch, "long")))
+	    {
+	      promoted_type =
+		(unsigned_operation
+		 ? lookup_unsigned_typename (language, gdbarch, "long")
+		 : lookup_signed_typename (language, gdbarch,"long"));
+	    }
+	  break;
 	default:
 	  /* For other languages the result type is unchanged from gdb
 	     version 6.7 for backward compatibility.
Index: src/gdb/testsuite/gdb.base/default.exp
===================================================================
--- src.orig/gdb/testsuite/gdb.base/default.exp	2010-11-03 11:27:48.000000000 +0100
+++ src/gdb/testsuite/gdb.base/default.exp	2010-11-03 12:44:07.000000000 +0100
@@ -527,7 +527,7 @@ gdb_test "set history size" "Argument re
 #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
Index: src/gdb/testsuite/Makefile.in
===================================================================
--- src.orig/gdb/testsuite/Makefile.in	2010-11-03 11:27:48.000000000 +0100
+++ src/gdb/testsuite/Makefile.in	2010-11-03 12:44:07.000000000 +0100
@@ -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 \
Index: src/gdb/testsuite/configure
===================================================================
--- src.orig/gdb/testsuite/configure	2010-11-03 11:27:48.000000000 +0100
+++ src/gdb/testsuite/configure	2010-11-03 12:44:07.000000000 +0100
@@ -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
Index: src/gdb/testsuite/configure.ac
===================================================================
--- src.orig/gdb/testsuite/configure.ac	2010-11-03 11:27:48.000000000 +0100
+++ src/gdb/testsuite/configure.ac	2010-11-03 12:44:07.000000000 +0100
@@ -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])
Index: src/gdb/testsuite/gdb.opencl/Makefile.in
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/Makefile.in	2010-11-03 12:44:07.000000000 +0100
@@ -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.*
Index: src/gdb/testsuite/gdb.opencl/datatypes.cl
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/datatypes.cl	2010-11-03 12:44:07.000000000 +0100
@@ -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;
+}
Index: src/gdb/testsuite/gdb.opencl/datatypes.exp
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/datatypes.exp	2010-11-03 13:10:45.000000000 +0100
@@ -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}
Index: src/gdb/testsuite/gdb.opencl/operators.cl
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/operators.cl	2010-11-03 12:44:07.000000000 +0100
@@ -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;
+}
Index: src/gdb/testsuite/gdb.opencl/operators.exp
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/operators.exp	2010-11-03 13:10:55.000000000 +0100
@@ -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}
Index: src/gdb/testsuite/gdb.opencl/vec_comps.cl
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/vec_comps.cl	2010-11-03 12:44:07.000000000 +0100
@@ -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;
+}
Index: src/gdb/testsuite/gdb.opencl/vec_comps.exp
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/vec_comps.exp	2010-11-03 13:11:01.000000000 +0100
@@ -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}
Index: src/gdb/testsuite/lib/cl_util.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/lib/cl_util.c	2010-11-03 12:44:07.000000000 +0100
@@ -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);
+}
Index: src/gdb/testsuite/lib/cl_util.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/lib/cl_util.h	2010-11-03 12:44:07.000000000 +0100
@@ -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 */
Index: src/gdb/testsuite/lib/opencl.exp
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/lib/opencl.exp	2010-11-03 12:44:07.000000000 +0100
@@ -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)
+}
Index: src/gdb/testsuite/lib/opencl_hostapp.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/lib/opencl_hostapp.c	2010-11-03 12:44:07.000000000 +0100
@@ -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;
+}
Index: src/gdb/testsuite/lib/opencl_kernel.cl
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/lib/opencl_kernel.cl	2010-11-03 12:44:07.000000000 +0100
@@ -0,0 +1,5 @@
+/* OpenCL kernel for testing purposes.  */
+__kernel void testkernel (__global int *data)
+{
+  data[get_global_id(0)] = 0x1;
+}
Index: src/gdb/testsuite/gdb.opencl/convs_casts.cl
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/convs_casts.cl	2010-11-03 12:44:07.000000000 +0100
@@ -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;
+}
Index: src/gdb/testsuite/gdb.opencl/convs_casts.exp
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/convs_casts.exp	2010-11-03 13:10:36.000000000 +0100
@@ -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}
Index: src/gdb/c-exp.y
===================================================================
--- src.orig/gdb/c-exp.y	2010-11-03 11:27:48.000000000 +0100
+++ src/gdb/c-exp.y	2010-11-03 12:44:07.000000000 +0100
@@ -612,7 +612,9 @@ exp	:	VARIABLE
 
 exp	:	SIZEOF '(' type ')'	%prec UNARY
 			{ write_exp_elt_opcode (OP_LONG);
-			  write_exp_elt_type (parse_type->builtin_int);
+			  write_exp_elt_type (lookup_signed_typename
+					      (parse_language, parse_gdbarch,
+					       "int"));
 			  CHECK_TYPEDEF ($3);
 			  write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
 			  write_exp_elt_opcode (OP_LONG); }
@@ -980,61 +982,117 @@ typebase  /* Implements (approximately):
 	:	TYPENAME
 			{ $$ = $1.type; }
 	|	INT_KEYWORD
-			{ $$ = parse_type->builtin_int; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "int"); }
 	|	LONG
-			{ $$ = parse_type->builtin_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long"); }
 	|	SHORT
-			{ $$ = parse_type->builtin_short; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "short"); }
 	|	LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long"); }
 	|	LONG SIGNED_KEYWORD INT_KEYWORD
-			{ $$ = parse_type->builtin_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long"); }
 	|	LONG SIGNED_KEYWORD
-			{ $$ = parse_type->builtin_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long"); }
 	|	SIGNED_KEYWORD LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long"); }
 	|	UNSIGNED LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long"); }
 	|	LONG UNSIGNED INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long"); }
 	|	LONG UNSIGNED
-			{ $$ = parse_type->builtin_unsigned_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long"); }
 	|	LONG LONG
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	LONG LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	LONG LONG SIGNED_KEYWORD INT_KEYWORD
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	LONG LONG SIGNED_KEYWORD
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	SIGNED_KEYWORD LONG LONG
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	SIGNED_KEYWORD LONG LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	UNSIGNED LONG LONG
-			{ $$ = parse_type->builtin_unsigned_long_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long long"); }
 	|	UNSIGNED LONG LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_long_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long long"); }
 	|	LONG LONG UNSIGNED
-			{ $$ = parse_type->builtin_unsigned_long_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long long"); }
 	|	LONG LONG UNSIGNED INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_long_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long long"); }
 	|	SHORT INT_KEYWORD
-			{ $$ = parse_type->builtin_short; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "short"); }
 	|	SHORT SIGNED_KEYWORD INT_KEYWORD
-			{ $$ = parse_type->builtin_short; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "short"); }
 	|	SHORT SIGNED_KEYWORD
-			{ $$ = parse_type->builtin_short; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "short"); }
 	|	UNSIGNED SHORT INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_short; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "short"); }
 	|	SHORT UNSIGNED 
-			{ $$ = parse_type->builtin_unsigned_short; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "short"); }
 	|	SHORT UNSIGNED INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_short; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "short"); }
 	|	DOUBLE_KEYWORD
-			{ $$ = parse_type->builtin_double; }
+			{ $$ = lookup_typename (parse_language, parse_gdbarch,
+						"double", (struct block *) NULL,
+						0); }
 	|	LONG DOUBLE_KEYWORD
-			{ $$ = parse_type->builtin_long_double; }
+			{ $$ = lookup_typename (parse_language, parse_gdbarch,
+						"long double",
+						(struct block *) NULL, 0); }
 	|	STRUCT name
 			{ $$ = lookup_struct (copy_name ($2),
 					      expression_context_block); }
@@ -1052,13 +1110,17 @@ typebase  /* Implements (approximately):
 							 parse_gdbarch,
 							 TYPE_NAME($2.type)); }
 	|	UNSIGNED
-			{ $$ = parse_type->builtin_unsigned_int; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "int"); }
 	|	SIGNED_KEYWORD typename
 			{ $$ = lookup_signed_typename (parse_language,
 						       parse_gdbarch,
 						       TYPE_NAME($2.type)); }
 	|	SIGNED_KEYWORD
-			{ $$ = parse_type->builtin_int; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "int"); }
                 /* It appears that this rule for templates is never
                    reduced; template recognition happens by lookahead
                    in the token processing code in yylex. */         
@@ -1077,19 +1139,25 @@ typename:	TYPENAME
 		{
 		  $$.stoken.ptr = "int";
 		  $$.stoken.length = 3;
-		  $$.type = parse_type->builtin_int;
+		  $$.type = lookup_signed_typename (parse_language,
+						    parse_gdbarch,
+						    "int");
 		}
 	|	LONG
 		{
 		  $$.stoken.ptr = "long";
 		  $$.stoken.length = 4;
-		  $$.type = parse_type->builtin_long;
+		  $$.type = lookup_signed_typename (parse_language,
+						    parse_gdbarch,
+						    "long");
 		}
 	|	SHORT
 		{
 		  $$.stoken.ptr = "short";
 		  $$.stoken.length = 5;
-		  $$.type = parse_type->builtin_short;
+		  $$.type = lookup_signed_typename (parse_language,
+						    parse_gdbarch,
+						    "short");
 		}
 	;
 
Index: src/gdb/c-lang.h
===================================================================
--- src.orig/gdb/c-lang.h	2010-11-03 11:27:48.000000000 +0100
+++ src/gdb/c-lang.h	2010-11-03 12:44:07.000000000 +0100
@@ -27,6 +27,7 @@ struct language_arch_info;
 
 #include "value.h"
 #include "macroexp.h"
+#include "parser-defs.h"
 
 
 /* The various kinds of C string and character.  Note that these
@@ -78,6 +79,10 @@ extern int c_value_print (struct value *
 
 /* These are in c-lang.c: */
 
+extern struct value *evaluate_subexp_c (struct type *expect_type,
+					 struct expression *exp, int *pos,
+					 enum noside noside);
+
 extern void c_printchar (int, struct type *, struct ui_file *);
 
 extern void c_printstr (struct ui_file * stream, struct type *elttype,
@@ -93,6 +98,8 @@ extern const struct exp_descriptor exp_d
 extern void c_emit_char (int c, struct type *type,
 			 struct ui_file *stream, int quoter);
 
+extern const struct op_print c_op_print_tab[];
+
 /* These are in c-typeprint.c: */
 
 extern void c_type_print_base (struct type *, struct ui_file *, int, int);
Index: src/gdb/c-lang.c
===================================================================
--- src.orig/gdb/c-lang.c	2010-11-03 11:27:48.000000000 +0100
+++ src/gdb/c-lang.c	2010-11-03 12:44:07.000000000 +0100
@@ -933,7 +933,7 @@ parse_one_string (struct obstack *output
    are delegated to evaluate_subexp_standard; see that function for a
    description of the arguments.  */
 
-static struct value *
+struct value *
 evaluate_subexp_c (struct type *expect_type, struct expression *exp,
 		   int *pos, enum noside noside)
 {

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] initial OpenCL C language support
  2010-11-03 13:03                 ` Ken Werner
@ 2010-11-03 15:27                   ` Joel Brobecker
  2010-11-04 15:39                     ` Ken Werner
  2010-11-05 14:39                     ` Ken Werner
  0 siblings, 2 replies; 36+ messages in thread
From: Joel Brobecker @ 2010-11-03 15:27 UTC (permalink / raw)
  To: Ken Werner; +Cc: Tom Tromey, gdb-patches

> In case of C (and probably Ada as well) the lengths of the builtin
> types depend on the architecuter/implementation but for OpenCL C it's
> kind of the other way round. I hard coded the lengths because OpenCL
> specifies fixed sizes of the builtin types:
> http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/scalarDataTypes.html
> http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/vectorDataTypes.html
> Does this sound reasonable?

It took me a while to understand the distinction in the GDB code
between builtin types and primitive types, but I get it, now, and
I understand the reason for the changes - thank you!

Patch looks good to me, at this point. It needs documentation
(doc/gdb.texinfo) and a NEWS entry.  Can you send a separate patch
for this portion.  Once the documentation is approved, you may commit
this patch as well.

Thank you,
-- 
Joel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] initial OpenCL C language support
  2010-11-03 15:27                   ` Joel Brobecker
@ 2010-11-04 15:39                     ` Ken Werner
  2010-11-04 17:48                       ` Eli Zaretskii
  2010-11-05 14:39                     ` Ken Werner
  1 sibling, 1 reply; 36+ messages in thread
From: Ken Werner @ 2010-11-04 15:39 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Tom Tromey, Eli Zaretskii, gdb-patches

[-- Attachment #1: Type: Text/Plain, Size: 523 bytes --]

On Wednesday, November 03, 2010 4:27:23 pm Joel Brobecker wrote:
> Patch looks good to me, at this point. It needs documentation
> (doc/gdb.texinfo) and a NEWS entry.  Can you send a separate patch
> for this portion.  Once the documentation is approved, you may commit
> this patch as well.

Ok, sounds good.
This was also brought up by Eli Zaretskii a few days ago:
http://sourceware.org/ml/gdb-patches/2010-10/msg00373.html

Attached is a patch that adds a few bits to the documentation and the NEWS 
file.

Regards
Ken

[-- Attachment #2: opencl-lang-doc.patch --]
[-- Type: text/x-patch, Size: 3417 bytes --]

ChangeLog:

2010-11-04  Ken Werner  <ken.werner@de.ibm.com>

	* NEWS: Mention OpenCL C language support.

doc/ChangeLog:

2010-11-04  Ken Werner  <ken.werner@de.ibm.com>

	* gdb.texinfo: (Summary) Add mention about OpenCL C language support.
	(OpenCL C): New node.


Index: src/gdb/doc/gdb.texinfo
===================================================================
--- src.orig/gdb/doc/gdb.texinfo	2010-11-03 17:06:48.000000000 +0100
+++ src/gdb/doc/gdb.texinfo	2010-11-04 14:46:30.000000000 +0100
@@ -221,6 +221,9 @@ Support for D is partial.  For informati
 Support for Modula-2 is partial.  For information on Modula-2, see
 @ref{Modula-2,,Modula-2}.
 
+Support for OpenCL C is partial.  For information on OpenCL C, see
+@ref{OpenCL C,,OpenCL C}.
+
 @cindex Pascal
 Debugging Pascal programs which use sets, subranges, file variables, or
 nested functions does not currently work.  @value{GDBN} does not support
@@ -11611,7 +11614,7 @@ being set automatically by @value{GDBN}.
 @node Supported Languages
 @section Supported Languages
 
-@value{GDBN} supports C, C@t{++}, D, Objective-C, Fortran, Java, Pascal,
+@value{GDBN} supports C, C@t{++}, D, Objective-C, Fortran, Java, OpenCL C, Pascal,
 assembly, Modula-2, and Ada.
 @c This is false ...
 Some @value{GDBN} features may be used in expressions regardless of the
@@ -11632,6 +11635,7 @@ language reference or tutorial.
 * C::                           C and C@t{++}
 * D::                           D
 * Objective-C::                 Objective-C
+* OpenCL C::                    OpenCL C
 * Fortran::                     Fortran
 * Pascal::                      Pascal
 * Modula-2::                    Modula-2
@@ -12278,6 +12282,42 @@ the description of an object.  However,
 with certain Objective-C libraries that have a particular hook
 function, @code{_NSPrintForDebugger}, defined.
 
+@node OpenCL C
+@subsection OpenCL C
+
+@cindex OpenCL C
+This section provides information about @value{GDBN}s OpenCL C support.
+
+@menu
+* OpenCL C Datatypes::
+* OpenCL C Expressions::
+* OpenCL C Operators::
+@end menu
+
+@node OpenCL C Datatypes
+@subsubsection OpenCL C Datatypes
+
+@cindex OpenCL C Datatypes
+@value{GDBN} supports the builtin scalar and vector datatypes specified
+by OpenCL 1.1.  In addition the half- and double-precision floating point
+data types of the cl_khr_fp16 and cl_khr_fp64 OpenCL extensions are also
+known to @value{GDBN}.
+
+@node OpenCL C Expressions
+@subsubsection OpenCL C Expressions
+
+@cindex OpenCL C Expressions
+@value{GDBN} supports accesses to vector components including the access as
+lvalue where possible. Since OpenCL C is based on C99 most C expressions
+supported by @value{GDBN} can be used as well.
+
+@node OpenCL C Operators
+@subsubsection OpenCL C Operators
+
+@cindex OpenCL C Operators
+@value{GDBN} supports the operators specified by OpenCL 1.1 for scalar and
+vector data types.
+
 @node Fortran
 @subsection Fortran
 @cindex Fortran-specific support in @value{GDBN}
Index: src/gdb/NEWS
===================================================================
--- src.orig/gdb/NEWS	2010-11-04 14:14:25.000000000 +0100
+++ src/gdb/NEWS	2010-11-04 14:18:33.000000000 +0100
@@ -3,6 +3,9 @@
 
 *** Changes since GDB 7.2
 
+* OpenCL C
+  Initial support for the OpenCL C language has been integrated into GDB.
+
 * Python scripting
 
   ** GDB values in Python are now callable if the value represents a

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] initial OpenCL C language support
  2010-11-04 15:39                     ` Ken Werner
@ 2010-11-04 17:48                       ` Eli Zaretskii
  2010-11-05 14:21                         ` Ken Werner
  0 siblings, 1 reply; 36+ messages in thread
From: Eli Zaretskii @ 2010-11-04 17:48 UTC (permalink / raw)
  To: Ken Werner; +Cc: brobecker, tromey, gdb-patches

> From: Ken Werner <ken@linux.vnet.ibm.com>
> Date: Thu, 4 Nov 2010 16:38:45 +0100
> Cc: Tom Tromey <tromey@redhat.com>, Eli Zaretskii <eliz@gnu.org>,
>         gdb-patches@sourceware.org
> 
> Attached is a patch that adds a few bits to the documentation and the NEWS 
> file.

Thanks.

> +by OpenCL 1.1.  In addition the half- and double-precision floating point
> +data types of the cl_khr_fp16 and cl_khr_fp64 OpenCL extensions are also
> +known to @value{GDBN}.

cl_khr_fp16 and cl_khr_fp64 should probably be in @code.

> +@value{GDBN} supports accesses to vector components including the access as
> +lvalue where possible. Since OpenCL C is based on C99 most C expressions
                        ^^
Two spaces, please.

> --- src.orig/gdb/NEWS	2010-11-04 14:14:25.000000000 +0100
> +++ src/gdb/NEWS	2010-11-04 14:18:33.000000000 +0100
> @@ -3,6 +3,9 @@
>  
>  *** Changes since GDB 7.2
>  
> +* OpenCL C
> +  Initial support for the OpenCL C language has been integrated into GDB.
> +

This part is fine, but I'd suggest to add a link to the OpenCL site
here.

Okay with those changes.

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] initial OpenCL C language support
  2010-11-04 17:48                       ` Eli Zaretskii
@ 2010-11-05 14:21                         ` Ken Werner
  0 siblings, 0 replies; 36+ messages in thread
From: Ken Werner @ 2010-11-05 14:21 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: brobecker, tromey, gdb-patches

[-- Attachment #1: Type: Text/Plain, Size: 1469 bytes --]

On Thursday, November 04, 2010 6:48:07 pm Eli Zaretskii wrote:
> > From: Ken Werner <ken@linux.vnet.ibm.com>
> > Date: Thu, 4 Nov 2010 16:38:45 +0100
> > Cc: Tom Tromey <tromey@redhat.com>, Eli Zaretskii <eliz@gnu.org>,
> > 
> >         gdb-patches@sourceware.org
> > 
> > Attached is a patch that adds a few bits to the documentation and the
> > NEWS file.
> 
> Thanks.
> 
> > +by OpenCL 1.1.  In addition the half- and double-precision floating
> > point +data types of the cl_khr_fp16 and cl_khr_fp64 OpenCL extensions
> > are also +known to @value{GDBN}.
> 
> cl_khr_fp16 and cl_khr_fp64 should probably be in @code.

Done.

> > +@value{GDBN} supports accesses to vector components including the access
> > as +lvalue where possible. Since OpenCL C is based on C99 most C
> > expressions
> 
>                         ^^
> Two spaces, please.

Fixed.

> > --- src.orig/gdb/NEWS	2010-11-04 14:14:25.000000000 +0100
> > +++ src/gdb/NEWS	2010-11-04 14:18:33.000000000 +0100
> > @@ -3,6 +3,9 @@
> > 
> >  *** Changes since GDB 7.2
> > 
> > +* OpenCL C
> > +  Initial support for the OpenCL C language has been integrated into
> > GDB. +
> 
> This part is fine, but I'd suggest to add a link to the OpenCL site
> here.

Added.

> Okay with those changes.

Thanks. Attached is the updated patch.
I think the documentation patch should be checked in together with the main 
OpenCL C language patch. I'll merge this one into the main patch prior to 
commiting.

Regards
Ken

[-- Attachment #2: opencl-lang-doc.patch --]
[-- Type: text/x-patch, Size: 3468 bytes --]

ChangeLog:

2010-11-05  Ken Werner  <ken.werner@de.ibm.com>

	* NEWS: Mention OpenCL C language support.

doc/ChangeLog:

2010-11-05  Ken Werner  <ken.werner@de.ibm.com>

	* gdb.texinfo: (Summary) Add mention about OpenCL C language support.
	(OpenCL C): New node.


Index: src/gdb/doc/gdb.texinfo
===================================================================
--- src.orig/gdb/doc/gdb.texinfo	2010-11-04 16:34:08.265495001 +0100
+++ src/gdb/doc/gdb.texinfo	2010-11-05 12:30:42.000000000 +0100
@@ -221,6 +221,9 @@ Support for D is partial.  For informati
 Support for Modula-2 is partial.  For information on Modula-2, see
 @ref{Modula-2,,Modula-2}.
 
+Support for OpenCL C is partial.  For information on OpenCL C, see
+@ref{OpenCL C,,OpenCL C}.
+
 @cindex Pascal
 Debugging Pascal programs which use sets, subranges, file variables, or
 nested functions does not currently work.  @value{GDBN} does not support
@@ -11611,7 +11614,7 @@ being set automatically by @value{GDBN}.
 @node Supported Languages
 @section Supported Languages
 
-@value{GDBN} supports C, C@t{++}, D, Objective-C, Fortran, Java, Pascal,
+@value{GDBN} supports C, C@t{++}, D, Objective-C, Fortran, Java, OpenCL C, Pascal,
 assembly, Modula-2, and Ada.
 @c This is false ...
 Some @value{GDBN} features may be used in expressions regardless of the
@@ -11632,6 +11635,7 @@ language reference or tutorial.
 * C::                           C and C@t{++}
 * D::                           D
 * Objective-C::                 Objective-C
+* OpenCL C::                    OpenCL C
 * Fortran::                     Fortran
 * Pascal::                      Pascal
 * Modula-2::                    Modula-2
@@ -12278,6 +12282,42 @@ the description of an object.  However,
 with certain Objective-C libraries that have a particular hook
 function, @code{_NSPrintForDebugger}, defined.
 
+@node OpenCL C
+@subsection OpenCL C
+
+@cindex OpenCL C
+This section provides information about @value{GDBN}s OpenCL C support.
+
+@menu
+* OpenCL C Datatypes::
+* OpenCL C Expressions::
+* OpenCL C Operators::
+@end menu
+
+@node OpenCL C Datatypes
+@subsubsection OpenCL C Datatypes
+
+@cindex OpenCL C Datatypes
+@value{GDBN} supports the builtin scalar and vector datatypes specified
+by OpenCL 1.1.  In addition the half- and double-precision floating point
+data types of the @code{cl_khr_fp16} and @code{cl_khr_fp64} OpenCL
+extensions are also known to @value{GDBN}.
+
+@node OpenCL C Expressions
+@subsubsection OpenCL C Expressions
+
+@cindex OpenCL C Expressions
+@value{GDBN} supports accesses to vector components including the access as
+lvalue where possible.  Since OpenCL C is based on C99 most C expressions
+supported by @value{GDBN} can be used as well.
+
+@node OpenCL C Operators
+@subsubsection OpenCL C Operators
+
+@cindex OpenCL C Operators
+@value{GDBN} supports the operators specified by OpenCL 1.1 for scalar and
+vector data types.
+
 @node Fortran
 @subsection Fortran
 @cindex Fortran-specific support in @value{GDBN}
Index: src/gdb/NEWS
===================================================================
--- src.orig/gdb/NEWS	2010-11-04 16:34:08.000000000 +0100
+++ src/gdb/NEWS	2010-11-05 12:33:55.000000000 +0100
@@ -3,6 +3,10 @@
 
 *** Changes since GDB 7.2
 
+* OpenCL C
+  Initial support for the OpenCL C language (http://www.khronos.org/opencl)
+  has been integrated into GDB.
+
 * Python scripting
 
   ** GDB values in Python are now callable if the value represents a

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [patch] initial OpenCL C language support
  2010-11-03 15:27                   ` Joel Brobecker
  2010-11-04 15:39                     ` Ken Werner
@ 2010-11-05 14:39                     ` Ken Werner
  1 sibling, 0 replies; 36+ messages in thread
From: Ken Werner @ 2010-11-05 14:39 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Tom Tromey, Eli Zaretskii, gdb-patches

[-- Attachment #1: Type: Text/Plain, Size: 591 bytes --]

On Wednesday, November 03, 2010 4:27:23 pm Joel Brobecker wrote:
> Patch looks good to me, at this point. It needs documentation
> (doc/gdb.texinfo) and a NEWS entry.  Can you send a separate patch
> for this portion.  Once the documentation is approved, you may commit
> this patch as well.

Thanks for your time reviewing my patches. I've merged the patch that adds the 
documentation (http://sourceware.org/ml/gdb-patches/2010-11/msg00103.html) 
into the OpenCL C language patch and committed the attached patch:
http://sourceware.org/ml/gdb-cvs/2010-11/msg00030.html

Regards
Ken Werner

[-- Attachment #2: opencl-lang.patch --]
[-- Type: text/x-patch, Size: 194992 bytes --]

ChangeLog:

2010-11-05  Ken Werner  <ken.werner@de.ibm.com>

	* 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.

testsuite/ChangeLog:

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.

doc/ChangeLog:

2010-11-05  Ken Werner  <ken.werner@de.ibm.com>

	* gdb.texinfo: (Summary) Add mention about OpenCL C language support.
	(OpenCL C): New node.


Index: src/gdb/defs.h
===================================================================
--- src.orig/gdb/defs.h	2010-11-05 12:40:03.000000000 +0100
+++ src/gdb/defs.h	2010-11-05 13:25:02.000000000 +0100
@@ -201,6 +201,7 @@ enum language
     language_asm,		/* Assembly language */
     language_pascal,		/* Pascal */
     language_ada,		/* Ada */
+    language_opencl,		/* OpenCL */
     language_minimal,		/* All other languages, minimal support only */
     nr_languages
   };
Index: src/gdb/dwarf2read.c
===================================================================
--- src.orig/gdb/dwarf2read.c	2010-11-05 12:40:03.000000000 +0100
+++ src/gdb/dwarf2read.c	2010-11-05 13:25:02.000000000 +0100
@@ -5089,6 +5089,12 @@ read_file_scope (struct die_info *die, s
   if (attr)
     cu->producer = DW_STRING (attr);
 
+  /* The XLCL doesn't generate DW_LANG_OpenCL because this attribute is not
+     standardised yet.  As a workaround for the language detection we fall
+     back to the DW_AT_producer string.  */
+  if (cu->producer && strstr (cu->producer, "IBM XL C for OpenCL") != NULL)
+    cu->language = language_opencl;
+
   /* We assume that we're processing GCC output. */
   processing_gcc_compilation = 2;
 
Index: src/gdb/opencl-lang.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/opencl-lang.c	2010-11-05 13:25:02.000000000 +0100
@@ -0,0 +1,1162 @@
+/* OpenCL language support for GDB, the GNU debugger.
+   Copyright (C) 2010 Free Software Foundation, Inc.
+
+   Contributed by Ken Werner <ken.werner@de.ibm.com>.
+
+   This file is part of GDB.
+
+   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/>.  */
+
+#include "defs.h"
+#include "gdb_string.h"
+#include "gdbtypes.h"
+#include "symtab.h"
+#include "expression.h"
+#include "parser-defs.h"
+#include "symtab.h"
+#include "language.h"
+#include "c-lang.h"
+#include "gdb_assert.h"
+
+extern void _initialize_opencl_language (void);
+
+/* This macro generates enum values from a given type.  */
+
+#define OCL_P_TYPE(TYPE)\
+  opencl_primitive_type_##TYPE,\
+  opencl_primitive_type_##TYPE##2,\
+  opencl_primitive_type_##TYPE##3,\
+  opencl_primitive_type_##TYPE##4,\
+  opencl_primitive_type_##TYPE##8,\
+  opencl_primitive_type_##TYPE##16
+
+enum opencl_primitive_types {
+  OCL_P_TYPE (char),
+  OCL_P_TYPE (uchar),
+  OCL_P_TYPE (short),
+  OCL_P_TYPE (ushort),
+  OCL_P_TYPE (int),
+  OCL_P_TYPE (uint),
+  OCL_P_TYPE (long),
+  OCL_P_TYPE (ulong),
+  OCL_P_TYPE (half),
+  OCL_P_TYPE (float),
+  OCL_P_TYPE (double),
+  opencl_primitive_type_bool,
+  opencl_primitive_type_unsigned_char,
+  opencl_primitive_type_unsigned_short,
+  opencl_primitive_type_unsigned_int,
+  opencl_primitive_type_unsigned_long,
+  opencl_primitive_type_size_t,
+  opencl_primitive_type_ptrdiff_t,
+  opencl_primitive_type_intptr_t,
+  opencl_primitive_type_uintptr_t,
+  opencl_primitive_type_void,
+  nr_opencl_primitive_types
+};
+
+/* This macro generates the type struct declarations from a given type.  */
+
+#define STRUCT_OCL_TYPE(TYPE)\
+  struct type *builtin_##TYPE;\
+  struct type *builtin_##TYPE##2;\
+  struct type *builtin_##TYPE##3;\
+  struct type *builtin_##TYPE##4;\
+  struct type *builtin_##TYPE##8;\
+  struct type *builtin_##TYPE##16
+
+struct builtin_opencl_type
+{
+  STRUCT_OCL_TYPE (char);
+  STRUCT_OCL_TYPE (uchar);
+  STRUCT_OCL_TYPE (short);
+  STRUCT_OCL_TYPE (ushort);
+  STRUCT_OCL_TYPE (int);
+  STRUCT_OCL_TYPE (uint);
+  STRUCT_OCL_TYPE (long);
+  STRUCT_OCL_TYPE (ulong);
+  STRUCT_OCL_TYPE (half);
+  STRUCT_OCL_TYPE (float);
+  STRUCT_OCL_TYPE (double);
+  struct type *builtin_bool;
+  struct type *builtin_unsigned_char;
+  struct type *builtin_unsigned_short;
+  struct type *builtin_unsigned_int;
+  struct type *builtin_unsigned_long;
+  struct type *builtin_size_t;
+  struct type *builtin_ptrdiff_t;
+  struct type *builtin_intptr_t;
+  struct type *builtin_uintptr_t;
+  struct type *builtin_void;
+};
+
+static struct gdbarch_data *opencl_type_data;
+
+const struct builtin_opencl_type *
+builtin_opencl_type (struct gdbarch *gdbarch)
+{
+  return gdbarch_data (gdbarch, opencl_type_data);
+}
+
+/* Returns the corresponding OpenCL vector type from the given type code,
+   the length of the element type, the unsigned flag and the amount of
+   elements (N).  */
+
+static struct type *
+lookup_opencl_vector_type (struct gdbarch *gdbarch, enum type_code code,
+			   unsigned int el_length, unsigned int flag_unsigned,
+			   int n)
+{
+  int i;
+  unsigned int length;
+  struct type *type = NULL;
+  struct type **types = (struct type **) builtin_opencl_type (gdbarch);
+
+  /* Check if n describes a valid OpenCL vector size (2, 3, 4, 8, 16).  */
+  if (n != 2 && n != 3 && n != 4 && n != 8 && n != 16)
+    error (_("Invalid OpenCL vector size: %d"), n);
+
+  /* Triple vectors have the size of a quad vector.  */
+  length = (n == 3) ?  el_length * 4 : el_length * n;
+
+  for (i = 0; i < nr_opencl_primitive_types; i++)
+    {
+      LONGEST lowb, highb;
+
+      if (TYPE_CODE (types[i]) == TYPE_CODE_ARRAY && TYPE_VECTOR (types[i])
+	  && get_array_bounds (types[i], &lowb, &highb)
+	  && TYPE_CODE (TYPE_TARGET_TYPE (types[i])) == code
+	  && TYPE_UNSIGNED (TYPE_TARGET_TYPE (types[i])) == flag_unsigned
+	  && TYPE_LENGTH (TYPE_TARGET_TYPE (types[i])) == el_length
+	  && TYPE_LENGTH (types[i]) == length
+	  && highb - lowb + 1 == n)
+	{
+	  type = types[i];
+	  break;
+	}
+    }
+
+  return type;
+}
+
+/* Returns nonzero if the array ARR contains duplicates within
+     the first N elements.  */
+
+static int
+array_has_dups (int *arr, int n)
+{
+  int i, j;
+
+  for (i = 0; i < n; i++)
+    {
+      for (j = i + 1; j < n; j++)
+        {
+          if (arr[i] == arr[j])
+            return 1;
+        }
+    }
+
+  return 0;
+}
+
+/* The OpenCL component access syntax allows to create lvalues referring to
+   selected elements of an original OpenCL vector in arbitrary order.  This
+   structure holds the information to describe such lvalues.  */
+
+struct lval_closure
+{
+  /* Reference count.  */
+  int refc;
+  /* The number of indices.  */
+  int n;
+  /* The element indices themselves.  */
+  int *indices;
+  /* A pointer to the original value.  */
+  struct value *val;
+};
+
+/* Allocates an instance of struct lval_closure.  */
+
+static struct lval_closure *
+allocate_lval_closure (int *indices, int n, struct value *val)
+{
+  struct lval_closure *c = XZALLOC (struct lval_closure);
+
+  c->refc = 1;
+  c->n = n;
+  c->indices = XCALLOC (n, int);
+  memcpy (c->indices, indices, n * sizeof (int));
+  value_incref (val); /* Increment the reference counter of the value.  */
+  c->val = val;
+
+  return c;
+}
+
+static void
+lval_func_read (struct value *v)
+{
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+  struct type *type = check_typedef (value_type (v));
+  struct type *eltype = TYPE_TARGET_TYPE (check_typedef (value_type (c->val)));
+  int offset = value_offset (v);
+  int elsize = TYPE_LENGTH (eltype);
+  int n, i, j = 0;
+  LONGEST lowb = 0;
+  LONGEST highb = 0;
+
+  if (TYPE_CODE (type) == TYPE_CODE_ARRAY
+      && !get_array_bounds (type, &lowb, &highb))
+    error (_("Could not determine the vector bounds"));
+
+  /* Assume elsize aligned offset.  */
+  gdb_assert (offset % elsize == 0);
+  offset /= elsize;
+  n = offset + highb - lowb + 1;
+  gdb_assert (n <= c->n);
+
+  for (i = offset; i < n; i++)
+    memcpy (value_contents_raw (v) + j++ * elsize,
+	    value_contents (c->val) + c->indices[i] * elsize,
+	    elsize);
+}
+
+static void
+lval_func_write (struct value *v, struct value *fromval)
+{
+  struct value *mark = value_mark ();
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+  struct type *type = check_typedef (value_type (v));
+  struct type *eltype = TYPE_TARGET_TYPE (check_typedef (value_type (c->val)));
+  int offset = value_offset (v);
+  int elsize = TYPE_LENGTH (eltype);
+  int n, i, j = 0;
+  LONGEST lowb = 0;
+  LONGEST highb = 0;
+
+  if (TYPE_CODE (type) == TYPE_CODE_ARRAY
+      && !get_array_bounds (type, &lowb, &highb))
+    error (_("Could not determine the vector bounds"));
+
+  /* Assume elsize aligned offset.  */
+  gdb_assert (offset % elsize == 0);
+  offset /= elsize;
+  n = offset + highb - lowb + 1;
+
+  /* Since accesses to the fourth component of a triple vector is undefined we
+     just skip writes to the fourth element.  Imagine something like this:
+       int3 i3 = (int3)(0, 1, 2);
+       i3.hi.hi = 5;
+     In this case n would be 4 (offset=12/4 + 1) while c->n would be 3.  */
+  if (n > c->n)
+    n = c->n;
+
+  for (i = offset; i < n; i++)
+    {
+      struct value *from_elm_val = allocate_value (eltype);
+      struct value *to_elm_val = value_subscript (c->val, c->indices[i]);
+
+      memcpy (value_contents_writeable (from_elm_val),
+	      value_contents (fromval) + j++ * elsize,
+	      elsize);
+      value_assign (to_elm_val, from_elm_val);
+    }
+
+  value_free_to_mark (mark);
+}
+
+/* Return nonzero if all bits in V within OFFSET and LENGTH are valid.  */
+
+static int
+lval_func_check_validity (const struct value *v, int offset, int length)
+{
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+  /* Size of the target type in bits.  */
+  int elsize =
+      TYPE_LENGTH (TYPE_TARGET_TYPE (check_typedef (value_type (c->val)))) * 8;
+  int startrest = offset % elsize;
+  int start = offset / elsize;
+  int endrest = (offset + length) % elsize;
+  int end = (offset + length) / elsize;
+  int i;
+
+  if (endrest)
+    end++;
+
+  if (end > c->n)
+    return 0;
+
+  for (i = start; i < end; i++)
+    {
+      int startoffset = (i == start) ? startrest : 0;
+      int length = (i == end) ? endrest : elsize;
+
+      if (!value_bits_valid (c->val, c->indices[i] * elsize + startoffset,
+			     length))
+	return 0;
+    }
+
+  return 1;
+}
+
+/* Return nonzero if any bit in V is valid.  */
+
+static int
+lval_func_check_any_valid (const struct value *v)
+{
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+  /* Size of the target type in bits.  */
+  int elsize =
+      TYPE_LENGTH (TYPE_TARGET_TYPE (check_typedef (value_type (c->val)))) * 8;
+  int i;
+
+  for (i = 0; i < c->n; i++)
+    if (value_bits_valid (c->val, c->indices[i] * elsize, elsize))
+      return 1;
+
+  return 0;
+}
+
+static void *
+lval_func_copy_closure (const struct value *v)
+{
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+
+  ++c->refc;
+
+  return c;
+}
+
+static void
+lval_func_free_closure (struct value *v)
+{
+  struct lval_closure *c = (struct lval_closure *) value_computed_closure (v);
+
+  --c->refc;
+
+  if (c->refc == 0)
+    {
+      xfree (c->indices);
+      xfree (c);
+      value_free (c->val); /* Decrement the reference counter of the value.  */
+    }
+}
+
+static struct lval_funcs opencl_value_funcs =
+  {
+    lval_func_read,
+    lval_func_write,
+    lval_func_check_validity,
+    lval_func_check_any_valid,
+    lval_func_copy_closure,
+    lval_func_free_closure
+  };
+
+/* Creates a sub-vector from VAL.  The elements are selected by the indices of
+   an array with the length of N.  Supported values for NOSIDE are
+   EVAL_NORMAL and EVAL_AVOID_SIDE_EFFECTS.  */
+
+static struct value *
+create_value (struct gdbarch *gdbarch, struct value *val, enum noside noside,
+	      int *indices, int n)
+{
+  struct type *type = check_typedef (value_type (val));
+  struct type *elm_type = TYPE_TARGET_TYPE (type);
+  struct value *ret;
+
+  /* Check if a single component of a vector is requested which means
+     the resulting type is a (primitive) scalar type.  */
+  if (n == 1)
+    {
+      if (noside == EVAL_AVOID_SIDE_EFFECTS)
+        ret = value_zero (elm_type, not_lval);
+      else
+        ret = value_subscript (val, indices[0]);
+    }
+  else
+    {
+      /* Multiple components of the vector are requested which means the
+	 resulting type is a vector as well.  */
+      struct type *dst_type =
+	lookup_opencl_vector_type (gdbarch, TYPE_CODE (elm_type),
+				   TYPE_LENGTH (elm_type),
+				   TYPE_UNSIGNED (elm_type), n);
+
+      if (dst_type == NULL)
+	dst_type = init_vector_type (elm_type, n);
+
+      make_cv_type (TYPE_CONST (type), TYPE_VOLATILE (type), dst_type, NULL);
+
+      if (noside == EVAL_AVOID_SIDE_EFFECTS)
+	ret = allocate_value (dst_type);
+      else
+	{
+	  /* Check whether to create a lvalue or not.  */
+	  if (VALUE_LVAL (val) != not_lval && !array_has_dups (indices, n))
+	    {
+	      struct lval_closure *c = allocate_lval_closure (indices, n, val);
+	      ret = allocate_computed_value (dst_type, &opencl_value_funcs, c);
+	    }
+	  else
+	    {
+	      int i;
+
+	      ret = allocate_value (dst_type);
+
+	      /* Copy src val contents into the destination value.  */
+	      for (i = 0; i < n; i++)
+		memcpy (value_contents_writeable (ret)
+			+ (i * TYPE_LENGTH (elm_type)),
+			value_contents (val)
+			+ (indices[i] * TYPE_LENGTH (elm_type)),
+			TYPE_LENGTH (elm_type));
+	    }
+	}
+    }
+  return ret;
+}
+
+/* OpenCL vector component access.  */
+
+static struct value *
+opencl_component_ref (struct expression *exp, struct value *val, char *comps,
+		      enum noside noside)
+{
+  LONGEST lowb, highb;
+  int src_len;
+  struct value *v;
+  int indices[16], i;
+  int dst_len;
+
+  if (!get_array_bounds (check_typedef (value_type (val)), &lowb, &highb))
+    error (_("Could not determine the vector bounds"));
+
+  src_len = highb - lowb + 1;
+
+  /* Throw an error if the amount of array elements does not fit a
+     valid OpenCL vector size (2, 3, 4, 8, 16).  */
+  if (src_len != 2 && src_len != 3 && src_len != 4 && src_len != 8
+      && src_len != 16)
+    error (_("Invalid OpenCL vector size"));
+
+  if (strcmp (comps, "lo") == 0 )
+    {
+      dst_len = (src_len == 3) ? 2 : src_len / 2;
+
+      for (i = 0; i < dst_len; i++)
+	indices[i] = i;
+    }
+  else if (strcmp (comps, "hi") == 0)
+    {
+      dst_len = (src_len == 3) ? 2 : src_len / 2;
+
+      for (i = 0; i < dst_len; i++)
+	indices[i] = dst_len + i;
+    }
+  else if (strcmp (comps, "even") == 0)
+    {
+      dst_len = (src_len == 3) ? 2 : src_len / 2;
+
+      for (i = 0; i < dst_len; i++)
+	indices[i] = i*2;
+    }
+  else if (strcmp (comps, "odd") == 0)
+    {
+      dst_len = (src_len == 3) ? 2 : src_len / 2;
+
+      for (i = 0; i < dst_len; i++)
+        indices[i] = i*2+1;
+    }
+  else if (strncasecmp (comps, "s", 1) == 0)
+    {
+#define HEXCHAR_TO_INT(C) ((C >= '0' && C <= '9') ? \
+                           C-'0' : ((C >= 'A' && C <= 'F') ? \
+                           C-'A'+10 : ((C >= 'a' && C <= 'f') ? \
+                           C-'a'+10 : -1)))
+
+      dst_len = strlen (comps);
+      /* Skip the s/S-prefix.  */
+      dst_len--;
+
+      for (i = 0; i < dst_len; i++)
+	{
+	  indices[i] = HEXCHAR_TO_INT(comps[i+1]);
+	  /* Check if the requested component is invalid or exceeds
+	     the vector.  */
+	  if (indices[i] < 0 || indices[i] >= src_len)
+	    error (_("Invalid OpenCL vector component accessor %s"), comps);
+	}
+    }
+  else
+    {
+      dst_len = strlen (comps);
+
+      for (i = 0; i < dst_len; i++)
+	{
+	  /* x, y, z, w */
+	  switch (comps[i])
+	  {
+	  case 'x':
+	    indices[i] = 0;
+	    break;
+	  case 'y':
+	    indices[i] = 1;
+	    break;
+	  case 'z':
+	    if (src_len < 3)
+	      error (_("Invalid OpenCL vector component accessor %s"), comps);
+	    indices[i] = 2;
+	    break;
+	  case 'w':
+	    if (src_len < 4)
+	      error (_("Invalid OpenCL vector component accessor %s"), comps);
+	    indices[i] = 3;
+	    break;
+	  default:
+	    error (_("Invalid OpenCL vector component accessor %s"), comps);
+	    break;
+	  }
+	}
+    }
+
+  /* Throw an error if the amount of requested components does not
+     result in a valid length (1, 2, 3, 4, 8, 16).  */
+  if (dst_len != 1 && dst_len != 2 && dst_len != 3 && dst_len != 4
+      && dst_len != 8 && dst_len != 16)
+    error (_("Invalid OpenCL vector component accessor %s"), comps);
+
+  v = create_value (exp->gdbarch, val, noside, indices, dst_len);
+
+  return v;
+}
+
+/* Perform the unary logical not (!) operation.  */
+
+static struct value *
+opencl_logical_not (struct expression *exp, struct value *arg)
+{
+  struct type *type = check_typedef (value_type (arg));
+  struct type *rettype;
+  struct value *ret;
+
+  if (TYPE_CODE (type) == TYPE_CODE_ARRAY && TYPE_VECTOR (type))
+    {
+      struct type *eltype = check_typedef (TYPE_TARGET_TYPE (type));
+      LONGEST lowb, highb;
+      int i;
+
+      if (!get_array_bounds (type, &lowb, &highb))
+	error (_("Could not determine the vector bounds"));
+
+      /* Determine the resulting type of the operation and allocate the
+	 value.  */
+      rettype = lookup_opencl_vector_type (exp->gdbarch, TYPE_CODE_INT,
+					   TYPE_LENGTH (eltype), 0,
+					   highb - lowb + 1);
+      ret = allocate_value (rettype);
+
+      for (i = 0; i < highb - lowb + 1; i++)
+	{
+	  /* For vector types, the unary operator shall return a 0 if the
+	  value of its operand compares unequal to 0, and -1 (i.e. all bits
+	  set) if the value of its operand compares equal to 0.  */
+	  int tmp = value_logical_not (value_subscript (arg, i)) ? -1 : 0;
+	  memset (value_contents_writeable (ret) + i * TYPE_LENGTH (eltype),
+		  tmp, TYPE_LENGTH (eltype));
+	}
+    }
+  else
+    {
+      rettype = language_bool_type (exp->language_defn, exp->gdbarch);
+      ret = value_from_longest (rettype, value_logical_not (arg));
+    }
+
+  return ret;
+}
+
+/* Perform a relational operation on two scalar operands.  */
+
+static int
+scalar_relop (struct value *val1, struct value *val2, enum exp_opcode op)
+{
+  int ret;
+
+  switch (op)
+    {
+    case BINOP_EQUAL:
+      ret = value_equal (val1, val2);
+      break;
+    case BINOP_NOTEQUAL:
+      ret = !value_equal (val1, val2);
+      break;
+    case BINOP_LESS:
+      ret = value_less (val1, val2);
+      break;
+    case BINOP_GTR:
+      ret = value_less (val2, val1);
+      break;
+    case BINOP_GEQ:
+      ret = value_less (val2, val1) || value_equal (val1, val2);
+      break;
+    case BINOP_LEQ:
+      ret = value_less (val1, val2) || value_equal (val1, val2);
+      break;
+    case BINOP_LOGICAL_AND:
+      ret = !value_logical_not (val1) && !value_logical_not (val2);
+      break;
+    case BINOP_LOGICAL_OR:
+      ret = !value_logical_not (val1) || !value_logical_not (val2);
+      break;
+    default:
+      error (_("Attempt to perform an unsupported operation"));
+      break;
+    }
+  return ret;
+}
+
+/* Perform a relational operation on two vector operands.  */
+
+static struct value *
+vector_relop (struct expression *exp, struct value *val1, struct value *val2,
+	      enum exp_opcode op)
+{
+  struct value *ret;
+  struct type *type1, *type2, *eltype1, *eltype2, *rettype;
+  int t1_is_vec, t2_is_vec, i;
+  LONGEST lowb1, lowb2, highb1, highb2;
+
+  type1 = check_typedef (value_type (val1));
+  type2 = check_typedef (value_type (val2));
+
+  t1_is_vec = (TYPE_CODE (type1) == TYPE_CODE_ARRAY && TYPE_VECTOR (type1));
+  t2_is_vec = (TYPE_CODE (type2) == TYPE_CODE_ARRAY && TYPE_VECTOR (type2));
+
+  if (!t1_is_vec || !t2_is_vec)
+    error (_("Vector operations are not supported on scalar types"));
+
+  eltype1 = check_typedef (TYPE_TARGET_TYPE (type1));
+  eltype2 = check_typedef (TYPE_TARGET_TYPE (type2));
+
+  if (!get_array_bounds (type1,&lowb1, &highb1)
+      || !get_array_bounds (type2, &lowb2, &highb2))
+    error (_("Could not determine the vector bounds"));
+
+  /* Check whether the vector types are compatible.  */
+  if (TYPE_CODE (eltype1) != TYPE_CODE (eltype2)
+      || TYPE_LENGTH (eltype1) != TYPE_LENGTH (eltype2)
+      || TYPE_UNSIGNED (eltype1) != TYPE_UNSIGNED (eltype2)
+      || lowb1 != lowb2 || highb1 != highb2)
+    error (_("Cannot perform operation on vectors with different types"));
+
+  /* Determine the resulting type of the operation and allocate the value.  */
+  rettype = lookup_opencl_vector_type (exp->gdbarch, TYPE_CODE_INT,
+				       TYPE_LENGTH (eltype1), 0,
+				       highb1 - lowb1 + 1);
+  ret = allocate_value (rettype);
+
+  for (i = 0; i < highb1 - lowb1 + 1; i++)
+    {
+      /* For vector types, the relational, equality and logical operators shall
+	 return 0 if the specified relation is false and -1 (i.e. all bits set)
+	 if the specified relation is true.  */
+      int tmp = scalar_relop (value_subscript (val1, i),
+			      value_subscript (val2, i), op) ? -1 : 0;
+      memset (value_contents_writeable (ret) + i * TYPE_LENGTH (eltype1),
+	      tmp, TYPE_LENGTH (eltype1));
+     }
+
+  return ret;
+}
+
+/* Perform a relational operation on two operands.  */
+
+static struct value *
+opencl_relop (struct expression *exp, struct value *arg1, struct value *arg2,
+	      enum exp_opcode op)
+{
+  struct value *val;
+  struct type *type1 = check_typedef (value_type (arg1));
+  struct type *type2 = check_typedef (value_type (arg2));
+  int t1_is_vec = (TYPE_CODE (type1) == TYPE_CODE_ARRAY
+		   && TYPE_VECTOR (type1));
+  int t2_is_vec = (TYPE_CODE (type2) == TYPE_CODE_ARRAY
+		   && TYPE_VECTOR (type2));
+
+  if (!t1_is_vec && !t2_is_vec)
+    {
+      int tmp = scalar_relop (arg1, arg2, op);
+      struct type *type =
+	language_bool_type (exp->language_defn, exp->gdbarch);
+
+      val = value_from_longest (type, tmp);
+    }
+  else if (t1_is_vec && t2_is_vec)
+    {
+      val = vector_relop (exp, arg1, arg2, op);
+    }
+  else
+    {
+      /* Widen the scalar operand to a vector.  */
+      struct value **v = t1_is_vec ? &arg2 : &arg1;
+      struct type *t = t1_is_vec ? type2 : type1;
+
+      if (TYPE_CODE (t) != TYPE_CODE_FLT && !is_integral_type (t))
+	error (_("Argument to operation not a number or boolean."));
+
+      *v = value_cast (t1_is_vec ? type1 : type2, *v);
+      val = vector_relop (exp, arg1, arg2, op);
+    }
+
+  return val;
+}
+
+/* Expression evaluator for the OpenCL.  Most operations are delegated to
+   evaluate_subexp_standard; see that function for a description of the
+   arguments.  */
+
+static struct value *
+evaluate_subexp_opencl (struct type *expect_type, struct expression *exp,
+		   int *pos, enum noside noside)
+{
+  enum exp_opcode op = exp->elts[*pos].opcode;
+  struct value *arg1 = NULL;
+  struct value *arg2 = NULL;
+  struct type *type1, *type2;
+
+  switch (op)
+    {
+    /* Handle binary relational and equality operators that are either not
+       or differently defined for GNU vectors.  */
+    case BINOP_EQUAL:
+    case BINOP_NOTEQUAL:
+    case BINOP_LESS:
+    case BINOP_GTR:
+    case BINOP_GEQ:
+    case BINOP_LEQ:
+      (*pos)++;
+      arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+      arg2 = evaluate_subexp (value_type (arg1), exp, pos, noside);
+
+      if (noside == EVAL_SKIP)
+	return value_from_longest (builtin_type (exp->gdbarch)->
+				   builtin_int, 1);
+
+      return opencl_relop (exp, arg1, arg2, op);
+
+    /* Handle the logical unary operator not(!).  */
+    case UNOP_LOGICAL_NOT:
+      (*pos)++;
+      arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+
+      if (noside == EVAL_SKIP)
+	return value_from_longest (builtin_type (exp->gdbarch)->
+				   builtin_int, 1);
+
+      return opencl_logical_not (exp, arg1);
+
+    /* Handle the logical operator and(&&) and or(||).  */
+    case BINOP_LOGICAL_AND:
+    case BINOP_LOGICAL_OR:
+      (*pos)++;
+      arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+
+      if (noside == EVAL_SKIP)
+	{
+	  arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+
+	  return value_from_longest (builtin_type (exp->gdbarch)->
+				     builtin_int, 1);
+	}
+      else
+	{
+	  /* For scalar operations we need to avoid evaluating operands
+	     unecessarily.  However, for vector operations we always need to
+	     evaluate both operands.  Unfortunately we only know which of the
+	     two cases apply after we know the type of the second operand.
+	     Therefore we evaluate it once using EVAL_AVOID_SIDE_EFFECTS.  */
+	  int oldpos = *pos;
+
+	  arg2 = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
+	  *pos = oldpos;
+	  type1 = check_typedef (value_type (arg1));
+	  type2 = check_typedef (value_type (arg2));
+
+	  if ((TYPE_CODE (type1) == TYPE_CODE_ARRAY && TYPE_VECTOR (type1))
+	      || (TYPE_CODE (type2) == TYPE_CODE_ARRAY && TYPE_VECTOR (type2)))
+	    {
+	      arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+
+	      return opencl_relop (exp, arg1, arg2, op);
+	    }
+	  else
+	    {
+	      /* For scalar built-in types, only evaluate the right
+		 hand operand if the left hand operand compares
+		 unequal(&&)/equal(||) to 0.  */
+	      int res;
+	      int tmp = value_logical_not (arg1);
+
+	      if (op == BINOP_LOGICAL_OR)
+		tmp = !tmp;
+
+	      arg2 = evaluate_subexp (NULL_TYPE, exp, pos,
+				      tmp ? EVAL_SKIP : noside);
+	      type1 = language_bool_type (exp->language_defn, exp->gdbarch);
+
+	      if (op == BINOP_LOGICAL_AND)
+		res = !tmp && !value_logical_not (arg2);
+	      else /* BINOP_LOGICAL_OR */
+		res = tmp || !value_logical_not (arg2);
+
+	      return value_from_longest (type1, res);
+	    }
+	}
+
+    /* Handle the ternary selection operator.  */
+    case TERNOP_COND:
+      (*pos)++;
+      arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+      type1 = check_typedef (value_type (arg1));
+      if (TYPE_CODE (type1) == TYPE_CODE_ARRAY && TYPE_VECTOR (type1))
+	{
+	  struct value *arg3, *tmp, *ret;
+	  struct type *eltype2, *type3, *eltype3;
+	  int t2_is_vec, t3_is_vec, i;
+	  LONGEST lowb1, lowb2, lowb3, highb1, highb2, highb3;
+
+	  arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	  arg3 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	  type2 = check_typedef (value_type (arg2));
+	  type3 = check_typedef (value_type (arg3));
+	  t2_is_vec
+	    = TYPE_CODE (type2) == TYPE_CODE_ARRAY && TYPE_VECTOR (type2);
+	  t3_is_vec
+	    = TYPE_CODE (type3) == TYPE_CODE_ARRAY && TYPE_VECTOR (type3);
+
+	  /* Widen the scalar operand to a vector if necessary.  */
+	  if (t2_is_vec || !t3_is_vec)
+	    {
+	      arg3 = value_cast (type2, arg3);
+	      type3 = value_type (arg3);
+	    }
+	  else if (!t2_is_vec || t3_is_vec)
+	    {
+	      arg2 = value_cast (type3, arg2);
+	      type2 = value_type (arg2);
+	    }
+	  else if (!t2_is_vec || !t3_is_vec)
+	    {
+	      /* Throw an error if arg2 or arg3 aren't vectors.  */
+	      error (_("\
+Cannot perform conditional operation on incompatible types"));
+	    }
+
+	  eltype2 = check_typedef (TYPE_TARGET_TYPE (type2));
+	  eltype3 = check_typedef (TYPE_TARGET_TYPE (type3));
+
+	  if (!get_array_bounds (type1, &lowb1, &highb1)
+	      || !get_array_bounds (type2, &lowb2, &highb2)
+	      || !get_array_bounds (type3, &lowb3, &highb3))
+	    error (_("Could not determine the vector bounds"));
+
+	  /* Throw an error if the types of arg2 or arg3 are incompatible.  */
+	  if (TYPE_CODE (eltype2) != TYPE_CODE (eltype3)
+	      || TYPE_LENGTH (eltype2) != TYPE_LENGTH (eltype3)
+	      || TYPE_UNSIGNED (eltype2) != TYPE_UNSIGNED (eltype3)
+	      || lowb2 != lowb3 || highb2 != highb3)
+	    error (_("\
+Cannot perform operation on vectors with different types"));
+
+	  /* Throw an error if the sizes of arg1 and arg2/arg3 differ.  */
+	  if (lowb1 != lowb2 || lowb1 != lowb3
+	      || highb1 != highb2 || highb1 != highb3)
+	    error (_("\
+Cannot perform conditional operation on vectors with different sizes"));
+
+	  ret = allocate_value (type2);
+
+	  for (i = 0; i < highb1 - lowb1 + 1; i++)
+	    {
+	      tmp = value_logical_not (value_subscript (arg1, i)) ?
+		    value_subscript (arg3, i) : value_subscript (arg2, i);
+	      memcpy (value_contents_writeable (ret) +
+		      i * TYPE_LENGTH (eltype2), value_contents_all (tmp),
+		      TYPE_LENGTH (eltype2));
+	    }
+
+	  return ret;
+	}
+      else
+	{
+	  if (value_logical_not (arg1))
+	    {
+	      /* Skip the second operand.  */
+	      evaluate_subexp (NULL_TYPE, exp, pos, EVAL_SKIP);
+
+	      return evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	    }
+	  else
+	    {
+	      /* Skip the third operand.  */
+	      arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	      evaluate_subexp (NULL_TYPE, exp, pos, EVAL_SKIP);
+
+	      return arg2;
+	    }
+	}
+
+    /* Handle STRUCTOP_STRUCT to allow component access on OpenCL vectors.  */
+    case STRUCTOP_STRUCT:
+      {
+	int pc = (*pos)++;
+	int tem = longest_to_int (exp->elts[pc + 1].longconst);
+
+	(*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
+	arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	type1 = check_typedef (value_type (arg1));
+
+	if (noside == EVAL_SKIP)
+	  {
+	    return value_from_longest (builtin_type (exp->gdbarch)->
+				       builtin_int, 1);
+	  }
+	else if (TYPE_CODE (type1) == TYPE_CODE_ARRAY && TYPE_VECTOR (type1))
+	  {
+	    return opencl_component_ref (exp, arg1, &exp->elts[pc + 2].string,
+					 noside);
+	  }
+	else
+	  {
+	    if (noside == EVAL_AVOID_SIDE_EFFECTS)
+	      return
+		  value_zero (lookup_struct_elt_type
+			      (value_type (arg1),&exp->elts[pc + 2].string, 0),
+			      lval_memory);
+	    else
+	      return value_struct_elt (&arg1, NULL,
+				       &exp->elts[pc + 2].string, NULL,
+				       "structure");
+	  }
+      }
+    default:
+      break;
+    }
+
+  return evaluate_subexp_c (expect_type, exp, pos, noside);
+}
+
+void
+opencl_language_arch_info (struct gdbarch *gdbarch,
+		      struct language_arch_info *lai)
+{
+  const struct builtin_opencl_type *builtin = builtin_opencl_type (gdbarch);
+
+  lai->string_char_type = builtin->builtin_char;
+  lai->primitive_type_vector
+    = GDBARCH_OBSTACK_CALLOC (gdbarch, nr_opencl_primitive_types + 1,
+			      struct type *);
+
+/* This macro fills the primitive_type_vector from a given type.  */
+#define FILL_TYPE_VECTOR(LAI, TYPE)\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE]\
+    = builtin->builtin_##TYPE;\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE##2]\
+    = builtin->builtin_##TYPE##2;\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE##3]\
+    = builtin->builtin_##TYPE##3;\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE##4]\
+    = builtin->builtin_##TYPE##4;\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE##8]\
+    = builtin->builtin_##TYPE##8;\
+  LAI->primitive_type_vector [opencl_primitive_type_##TYPE##16]\
+    = builtin->builtin_##TYPE##16
+
+  FILL_TYPE_VECTOR (lai, char);
+  FILL_TYPE_VECTOR (lai, uchar);
+  FILL_TYPE_VECTOR (lai, short);
+  FILL_TYPE_VECTOR (lai, ushort);
+  FILL_TYPE_VECTOR (lai, int);
+  FILL_TYPE_VECTOR (lai, uint);
+  FILL_TYPE_VECTOR (lai, long);
+  FILL_TYPE_VECTOR (lai, ulong);
+  FILL_TYPE_VECTOR (lai, half);
+  FILL_TYPE_VECTOR (lai, float);
+  FILL_TYPE_VECTOR (lai, double);
+  lai->primitive_type_vector [opencl_primitive_type_bool]
+    = builtin->builtin_bool;
+  lai->primitive_type_vector [opencl_primitive_type_unsigned_char]
+    = builtin->builtin_unsigned_char;
+  lai->primitive_type_vector [opencl_primitive_type_unsigned_short]
+    = builtin->builtin_unsigned_short;
+  lai->primitive_type_vector [opencl_primitive_type_unsigned_int]
+    = builtin->builtin_unsigned_int;
+  lai->primitive_type_vector [opencl_primitive_type_unsigned_long]
+    = builtin->builtin_unsigned_long;
+  lai->primitive_type_vector [opencl_primitive_type_half]
+    = builtin->builtin_half;
+  lai->primitive_type_vector [opencl_primitive_type_size_t]
+    = builtin->builtin_size_t;
+  lai->primitive_type_vector [opencl_primitive_type_ptrdiff_t]
+    = builtin->builtin_ptrdiff_t;
+  lai->primitive_type_vector [opencl_primitive_type_intptr_t]
+    = builtin->builtin_intptr_t;
+  lai->primitive_type_vector [opencl_primitive_type_uintptr_t]
+    = builtin->builtin_uintptr_t;
+  lai->primitive_type_vector [opencl_primitive_type_void]
+    = builtin->builtin_void;
+
+  /* Specifies the return type of logical and relational operations.  */
+  lai->bool_type_symbol = "int";
+  lai->bool_type_default = builtin->builtin_int;
+}
+
+const struct exp_descriptor exp_descriptor_opencl =
+{
+  print_subexp_standard,
+  operator_length_standard,
+  operator_check_standard,
+  op_name_standard,
+  dump_subexp_body_standard,
+  evaluate_subexp_opencl
+};
+
+const struct language_defn opencl_language_defn =
+{
+  "opencl",			/* Language name */
+  language_opencl,
+  range_check_off,
+  type_check_off,
+  case_sensitive_on,
+  array_row_major,
+  macro_expansion_c,
+  &exp_descriptor_opencl,
+  c_parse,
+  c_error,
+  null_post_parser,
+  c_printchar,			/* Print a character constant */
+  c_printstr,			/* Function to print string constant */
+  c_emit_char,			/* Print a single char */
+  c_print_type,			/* Print a type using appropriate syntax */
+  c_print_typedef,		/* Print a typedef using appropriate syntax */
+  c_val_print,			/* Print a value using appropriate syntax */
+  c_value_print,		/* Print a top-level value */
+  NULL,				/* Language specific skip_trampoline */
+  NULL,                         /* name_of_this */
+  basic_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
+  basic_lookup_transparent_type,/* lookup_transparent_type */
+  NULL,				/* Language specific symbol demangler */
+  NULL,				/* Language specific class_name_from_physname */
+  c_op_print_tab,		/* expression operators for printing */
+  1,				/* c-style arrays */
+  0,				/* String lower bound */
+  default_word_break_characters,
+  default_make_symbol_completion_list,
+  opencl_language_arch_info,
+  default_print_array_index,
+  default_pass_by_reference,
+  c_get_string,
+  LANG_MAGIC
+};
+
+static void *
+build_opencl_types (struct gdbarch *gdbarch)
+{
+  struct builtin_opencl_type *builtin_opencl_type
+    = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct builtin_opencl_type);
+
+/* Helper macro to create strings.  */
+#define STRINGIFY(S) #S
+/* This macro allocates and assigns the type struct pointers
+   for the vector types.  */
+#define BUILD_OCL_VTYPES(TYPE)\
+  builtin_opencl_type->builtin_##TYPE##2\
+    = init_vector_type (builtin_opencl_type->builtin_##TYPE, 2);\
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##2) = STRINGIFY(TYPE ## 2);\
+  builtin_opencl_type->builtin_##TYPE##3\
+    = init_vector_type (builtin_opencl_type->builtin_##TYPE, 3);\
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##3) = STRINGIFY(TYPE ## 3);\
+  TYPE_LENGTH (builtin_opencl_type->builtin_##TYPE##3)\
+    = 4 * TYPE_LENGTH (builtin_opencl_type->builtin_##TYPE);\
+  builtin_opencl_type->builtin_##TYPE##4\
+    = init_vector_type (builtin_opencl_type->builtin_##TYPE, 4);\
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##4) = STRINGIFY(TYPE ## 4);\
+  builtin_opencl_type->builtin_##TYPE##8\
+    = init_vector_type (builtin_opencl_type->builtin_##TYPE, 8);\
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##8) = STRINGIFY(TYPE ## 8);\
+  builtin_opencl_type->builtin_##TYPE##16\
+    = init_vector_type (builtin_opencl_type->builtin_##TYPE, 16);\
+  TYPE_NAME (builtin_opencl_type->builtin_##TYPE##16) = STRINGIFY(TYPE ## 16)
+
+  builtin_opencl_type->builtin_char
+    = arch_integer_type (gdbarch, 8, 0, "char");
+  BUILD_OCL_VTYPES (char);
+  builtin_opencl_type->builtin_uchar
+    = arch_integer_type (gdbarch, 8, 1, "uchar");
+  BUILD_OCL_VTYPES (uchar);
+  builtin_opencl_type->builtin_short
+    = arch_integer_type (gdbarch, 16, 0, "short");
+  BUILD_OCL_VTYPES (short);
+  builtin_opencl_type->builtin_ushort
+    = arch_integer_type (gdbarch, 16, 1, "ushort");
+  BUILD_OCL_VTYPES (ushort);
+  builtin_opencl_type->builtin_int
+    = arch_integer_type (gdbarch, 32, 0, "int");
+  BUILD_OCL_VTYPES (int);
+  builtin_opencl_type->builtin_uint
+    = arch_integer_type (gdbarch, 32, 1, "uint");
+  BUILD_OCL_VTYPES (uint);
+  builtin_opencl_type->builtin_long
+    = arch_integer_type (gdbarch, 64, 0, "long");
+  BUILD_OCL_VTYPES (long);
+  builtin_opencl_type->builtin_ulong
+    = arch_integer_type (gdbarch, 64, 1, "ulong");
+  BUILD_OCL_VTYPES (ulong);
+  builtin_opencl_type->builtin_half
+    = arch_float_type (gdbarch, 16, "half", floatformats_ieee_half);
+  BUILD_OCL_VTYPES (half);
+  builtin_opencl_type->builtin_float
+    = arch_float_type (gdbarch, 32, "float", floatformats_ieee_single);
+  BUILD_OCL_VTYPES (float);
+  builtin_opencl_type->builtin_double
+    = arch_float_type (gdbarch, 64, "double", floatformats_ieee_double);
+  BUILD_OCL_VTYPES (double);
+  builtin_opencl_type->builtin_bool
+    = arch_boolean_type (gdbarch, 32, 1, "bool");
+  builtin_opencl_type->builtin_unsigned_char
+    = arch_integer_type (gdbarch, 8, 1, "unsigned char");
+  builtin_opencl_type->builtin_unsigned_short
+    = arch_integer_type (gdbarch, 16, 1, "unsigned short");
+  builtin_opencl_type->builtin_unsigned_int
+    = arch_integer_type (gdbarch, 32, 1, "unsigned int");
+  builtin_opencl_type->builtin_unsigned_long
+    = arch_integer_type (gdbarch, 64, 1, "unsigned long");
+  builtin_opencl_type->builtin_size_t
+    = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 1, "size_t");
+  builtin_opencl_type->builtin_ptrdiff_t
+    = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 0, "ptrdiff_t");
+  builtin_opencl_type->builtin_intptr_t
+    = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 0, "intptr_t");
+  builtin_opencl_type->builtin_uintptr_t
+    = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 1, "uintptr_t");
+  builtin_opencl_type->builtin_void
+    = arch_type (gdbarch, TYPE_CODE_VOID, 1, "void");
+
+  return builtin_opencl_type;
+}
+
+void
+_initialize_opencl_language (void)
+{
+  opencl_type_data = gdbarch_data_register_post_init (build_opencl_types);
+  add_language (&opencl_language_defn);
+}
Index: src/gdb/Makefile.in
===================================================================
--- src.orig/gdb/Makefile.in	2010-11-05 12:40:03.000000000 +0100
+++ src/gdb/Makefile.in	2010-11-05 13:25:02.000000000 +0100
@@ -689,6 +689,7 @@ SFILES = ada-exp.y ada-lang.c ada-typepr
 	mi/mi-common.c \
 	objc-exp.y objc-lang.c \
 	objfiles.c osabi.c observer.c osdata.c \
+	opencl-lang.c \
 	p-exp.y p-lang.c p-typeprint.c p-valprint.c parse.c printcmd.c \
 	proc-service.list progspace.c \
 	prologue-value.c psymtab.c \
@@ -845,7 +846,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $
 	ui-out.o cli-out.o \
 	varobj.o vec.o wrapper.o \
 	jv-lang.o jv-valprint.o jv-typeprint.o \
-	m2-lang.o p-lang.o p-typeprint.o p-valprint.o \
+	m2-lang.o opencl-lang.o p-lang.o p-typeprint.o p-valprint.o \
 	sentinel-frame.o \
 	complaints.o typeprint.o \
 	ada-typeprint.o c-typeprint.o f-typeprint.o m2-typeprint.o \
Index: src/gdb/eval.c
===================================================================
--- src.orig/gdb/eval.c	2010-11-05 12:40:03.000000000 +0100
+++ src/gdb/eval.c	2010-11-05 13:25:02.000000000 +0100
@@ -603,6 +603,7 @@ binop_promote (const struct language_def
 	case language_cplus:
 	case language_asm:
 	case language_objc:
+	case language_opencl:
 	  /* No promotion required.  */
 	  break;
 
@@ -690,7 +691,24 @@ binop_promote (const struct language_def
 			       : builtin->builtin_long_long);
 	    }
 	  break;
-
+	case language_opencl:
+	  if (result_len <= TYPE_LENGTH (lookup_signed_typename
+					 (language, gdbarch, "int")))
+	    {
+	      promoted_type =
+		(unsigned_operation
+		 ? lookup_unsigned_typename (language, gdbarch, "int")
+		 : lookup_signed_typename (language, gdbarch, "int"));
+	    }
+	  else if (result_len <= TYPE_LENGTH (lookup_signed_typename
+					      (language, gdbarch, "long")))
+	    {
+	      promoted_type =
+		(unsigned_operation
+		 ? lookup_unsigned_typename (language, gdbarch, "long")
+		 : lookup_signed_typename (language, gdbarch,"long"));
+	    }
+	  break;
 	default:
 	  /* For other languages the result type is unchanged from gdb
 	     version 6.7 for backward compatibility.
Index: src/gdb/testsuite/gdb.base/default.exp
===================================================================
--- src.orig/gdb/testsuite/gdb.base/default.exp	2010-11-05 12:40:03.000000000 +0100
+++ src/gdb/testsuite/gdb.base/default.exp	2010-11-05 13:25:02.000000000 +0100
@@ -527,7 +527,7 @@ gdb_test "set history size" "Argument re
 #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
Index: src/gdb/testsuite/Makefile.in
===================================================================
--- src.orig/gdb/testsuite/Makefile.in	2010-11-05 12:40:03.000000000 +0100
+++ src/gdb/testsuite/Makefile.in	2010-11-05 13:25:02.000000000 +0100
@@ -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 \
Index: src/gdb/testsuite/configure
===================================================================
--- src.orig/gdb/testsuite/configure	2010-11-05 12:40:03.000000000 +0100
+++ src/gdb/testsuite/configure	2010-11-05 13:25:02.000000000 +0100
@@ -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
Index: src/gdb/testsuite/configure.ac
===================================================================
--- src.orig/gdb/testsuite/configure.ac	2010-11-05 12:40:03.000000000 +0100
+++ src/gdb/testsuite/configure.ac	2010-11-05 13:25:02.000000000 +0100
@@ -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])
Index: src/gdb/testsuite/gdb.opencl/Makefile.in
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/Makefile.in	2010-11-05 13:25:02.000000000 +0100
@@ -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.*
Index: src/gdb/testsuite/gdb.opencl/datatypes.cl
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/datatypes.cl	2010-11-05 13:25:02.000000000 +0100
@@ -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;
+}
Index: src/gdb/testsuite/gdb.opencl/datatypes.exp
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/datatypes.exp	2010-11-05 13:25:02.000000000 +0100
@@ -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}
Index: src/gdb/testsuite/gdb.opencl/operators.cl
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/operators.cl	2010-11-05 13:25:02.000000000 +0100
@@ -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;
+}
Index: src/gdb/testsuite/gdb.opencl/operators.exp
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/operators.exp	2010-11-05 13:25:02.000000000 +0100
@@ -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}
Index: src/gdb/testsuite/gdb.opencl/vec_comps.cl
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/vec_comps.cl	2010-11-05 13:25:02.000000000 +0100
@@ -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;
+}
Index: src/gdb/testsuite/gdb.opencl/vec_comps.exp
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/vec_comps.exp	2010-11-05 13:25:02.000000000 +0100
@@ -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}
Index: src/gdb/testsuite/lib/cl_util.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/lib/cl_util.c	2010-11-05 13:25:02.000000000 +0100
@@ -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);
+}
Index: src/gdb/testsuite/lib/cl_util.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/lib/cl_util.h	2010-11-05 13:25:02.000000000 +0100
@@ -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 */
Index: src/gdb/testsuite/lib/opencl.exp
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/lib/opencl.exp	2010-11-05 13:25:02.000000000 +0100
@@ -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)
+}
Index: src/gdb/testsuite/lib/opencl_hostapp.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/lib/opencl_hostapp.c	2010-11-05 13:25:02.000000000 +0100
@@ -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;
+}
Index: src/gdb/testsuite/lib/opencl_kernel.cl
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/lib/opencl_kernel.cl	2010-11-05 13:25:02.000000000 +0100
@@ -0,0 +1,5 @@
+/* OpenCL kernel for testing purposes.  */
+__kernel void testkernel (__global int *data)
+{
+  data[get_global_id(0)] = 0x1;
+}
Index: src/gdb/testsuite/gdb.opencl/convs_casts.cl
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/convs_casts.cl	2010-11-05 13:25:02.000000000 +0100
@@ -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;
+}
Index: src/gdb/testsuite/gdb.opencl/convs_casts.exp
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/testsuite/gdb.opencl/convs_casts.exp	2010-11-05 13:25:02.000000000 +0100
@@ -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}
Index: src/gdb/c-exp.y
===================================================================
--- src.orig/gdb/c-exp.y	2010-11-05 12:40:03.000000000 +0100
+++ src/gdb/c-exp.y	2010-11-05 13:25:02.000000000 +0100
@@ -612,7 +612,9 @@ exp	:	VARIABLE
 
 exp	:	SIZEOF '(' type ')'	%prec UNARY
 			{ write_exp_elt_opcode (OP_LONG);
-			  write_exp_elt_type (parse_type->builtin_int);
+			  write_exp_elt_type (lookup_signed_typename
+					      (parse_language, parse_gdbarch,
+					       "int"));
 			  CHECK_TYPEDEF ($3);
 			  write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
 			  write_exp_elt_opcode (OP_LONG); }
@@ -980,61 +982,117 @@ typebase  /* Implements (approximately):
 	:	TYPENAME
 			{ $$ = $1.type; }
 	|	INT_KEYWORD
-			{ $$ = parse_type->builtin_int; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "int"); }
 	|	LONG
-			{ $$ = parse_type->builtin_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long"); }
 	|	SHORT
-			{ $$ = parse_type->builtin_short; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "short"); }
 	|	LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long"); }
 	|	LONG SIGNED_KEYWORD INT_KEYWORD
-			{ $$ = parse_type->builtin_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long"); }
 	|	LONG SIGNED_KEYWORD
-			{ $$ = parse_type->builtin_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long"); }
 	|	SIGNED_KEYWORD LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long"); }
 	|	UNSIGNED LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long"); }
 	|	LONG UNSIGNED INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long"); }
 	|	LONG UNSIGNED
-			{ $$ = parse_type->builtin_unsigned_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long"); }
 	|	LONG LONG
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	LONG LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	LONG LONG SIGNED_KEYWORD INT_KEYWORD
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	LONG LONG SIGNED_KEYWORD
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	SIGNED_KEYWORD LONG LONG
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	SIGNED_KEYWORD LONG LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_long_long; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "long long"); }
 	|	UNSIGNED LONG LONG
-			{ $$ = parse_type->builtin_unsigned_long_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long long"); }
 	|	UNSIGNED LONG LONG INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_long_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long long"); }
 	|	LONG LONG UNSIGNED
-			{ $$ = parse_type->builtin_unsigned_long_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long long"); }
 	|	LONG LONG UNSIGNED INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_long_long; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "long long"); }
 	|	SHORT INT_KEYWORD
-			{ $$ = parse_type->builtin_short; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "short"); }
 	|	SHORT SIGNED_KEYWORD INT_KEYWORD
-			{ $$ = parse_type->builtin_short; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "short"); }
 	|	SHORT SIGNED_KEYWORD
-			{ $$ = parse_type->builtin_short; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "short"); }
 	|	UNSIGNED SHORT INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_short; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "short"); }
 	|	SHORT UNSIGNED 
-			{ $$ = parse_type->builtin_unsigned_short; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "short"); }
 	|	SHORT UNSIGNED INT_KEYWORD
-			{ $$ = parse_type->builtin_unsigned_short; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "short"); }
 	|	DOUBLE_KEYWORD
-			{ $$ = parse_type->builtin_double; }
+			{ $$ = lookup_typename (parse_language, parse_gdbarch,
+						"double", (struct block *) NULL,
+						0); }
 	|	LONG DOUBLE_KEYWORD
-			{ $$ = parse_type->builtin_long_double; }
+			{ $$ = lookup_typename (parse_language, parse_gdbarch,
+						"long double",
+						(struct block *) NULL, 0); }
 	|	STRUCT name
 			{ $$ = lookup_struct (copy_name ($2),
 					      expression_context_block); }
@@ -1052,13 +1110,17 @@ typebase  /* Implements (approximately):
 							 parse_gdbarch,
 							 TYPE_NAME($2.type)); }
 	|	UNSIGNED
-			{ $$ = parse_type->builtin_unsigned_int; }
+			{ $$ = lookup_unsigned_typename (parse_language,
+							 parse_gdbarch,
+							 "int"); }
 	|	SIGNED_KEYWORD typename
 			{ $$ = lookup_signed_typename (parse_language,
 						       parse_gdbarch,
 						       TYPE_NAME($2.type)); }
 	|	SIGNED_KEYWORD
-			{ $$ = parse_type->builtin_int; }
+			{ $$ = lookup_signed_typename (parse_language,
+						       parse_gdbarch,
+						       "int"); }
                 /* It appears that this rule for templates is never
                    reduced; template recognition happens by lookahead
                    in the token processing code in yylex. */         
@@ -1077,19 +1139,25 @@ typename:	TYPENAME
 		{
 		  $$.stoken.ptr = "int";
 		  $$.stoken.length = 3;
-		  $$.type = parse_type->builtin_int;
+		  $$.type = lookup_signed_typename (parse_language,
+						    parse_gdbarch,
+						    "int");
 		}
 	|	LONG
 		{
 		  $$.stoken.ptr = "long";
 		  $$.stoken.length = 4;
-		  $$.type = parse_type->builtin_long;
+		  $$.type = lookup_signed_typename (parse_language,
+						    parse_gdbarch,
+						    "long");
 		}
 	|	SHORT
 		{
 		  $$.stoken.ptr = "short";
 		  $$.stoken.length = 5;
-		  $$.type = parse_type->builtin_short;
+		  $$.type = lookup_signed_typename (parse_language,
+						    parse_gdbarch,
+						    "short");
 		}
 	;
 
Index: src/gdb/c-lang.h
===================================================================
--- src.orig/gdb/c-lang.h	2010-11-05 12:40:03.000000000 +0100
+++ src/gdb/c-lang.h	2010-11-05 13:25:02.000000000 +0100
@@ -27,6 +27,7 @@ struct language_arch_info;
 
 #include "value.h"
 #include "macroexp.h"
+#include "parser-defs.h"
 
 
 /* The various kinds of C string and character.  Note that these
@@ -78,6 +79,10 @@ extern int c_value_print (struct value *
 
 /* These are in c-lang.c: */
 
+extern struct value *evaluate_subexp_c (struct type *expect_type,
+					 struct expression *exp, int *pos,
+					 enum noside noside);
+
 extern void c_printchar (int, struct type *, struct ui_file *);
 
 extern void c_printstr (struct ui_file * stream, struct type *elttype,
@@ -93,6 +98,8 @@ extern const struct exp_descriptor exp_d
 extern void c_emit_char (int c, struct type *type,
 			 struct ui_file *stream, int quoter);
 
+extern const struct op_print c_op_print_tab[];
+
 /* These are in c-typeprint.c: */
 
 extern void c_type_print_base (struct type *, struct ui_file *, int, int);
Index: src/gdb/c-lang.c
===================================================================
--- src.orig/gdb/c-lang.c	2010-11-05 12:40:03.000000000 +0100
+++ src/gdb/c-lang.c	2010-11-05 13:25:02.000000000 +0100
@@ -933,7 +933,7 @@ parse_one_string (struct obstack *output
    are delegated to evaluate_subexp_standard; see that function for a
    description of the arguments.  */
 
-static struct value *
+struct value *
 evaluate_subexp_c (struct type *expect_type, struct expression *exp,
 		   int *pos, enum noside noside)
 {
Index: src/gdb/NEWS
===================================================================
--- src.orig/gdb/NEWS	2010-11-05 13:26:38.000000000 +0100
+++ src/gdb/NEWS	2010-11-05 13:26:50.000000000 +0100
@@ -3,6 +3,10 @@
 
 *** Changes since GDB 7.2
 
+* OpenCL C
+  Initial support for the OpenCL C language (http://www.khronos.org/opencl)
+  has been integrated into GDB.
+
 * Python scripting
 
   ** GDB values in Python are now callable if the value represents a
Index: src/gdb/doc/gdb.texinfo
===================================================================
--- src.orig/gdb/doc/gdb.texinfo	2010-11-05 13:26:38.000000000 +0100
+++ src/gdb/doc/gdb.texinfo	2010-11-05 13:26:50.000000000 +0100
@@ -221,6 +221,9 @@ Support for D is partial.  For informati
 Support for Modula-2 is partial.  For information on Modula-2, see
 @ref{Modula-2,,Modula-2}.
 
+Support for OpenCL C is partial.  For information on OpenCL C, see
+@ref{OpenCL C,,OpenCL C}.
+
 @cindex Pascal
 Debugging Pascal programs which use sets, subranges, file variables, or
 nested functions does not currently work.  @value{GDBN} does not support
@@ -11611,7 +11614,7 @@ being set automatically by @value{GDBN}.
 @node Supported Languages
 @section Supported Languages
 
-@value{GDBN} supports C, C@t{++}, D, Objective-C, Fortran, Java, Pascal,
+@value{GDBN} supports C, C@t{++}, D, Objective-C, Fortran, Java, OpenCL C, Pascal,
 assembly, Modula-2, and Ada.
 @c This is false ...
 Some @value{GDBN} features may be used in expressions regardless of the
@@ -11632,6 +11635,7 @@ language reference or tutorial.
 * C::                           C and C@t{++}
 * D::                           D
 * Objective-C::                 Objective-C
+* OpenCL C::                    OpenCL C
 * Fortran::                     Fortran
 * Pascal::                      Pascal
 * Modula-2::                    Modula-2
@@ -12278,6 +12282,42 @@ the description of an object.  However,
 with certain Objective-C libraries that have a particular hook
 function, @code{_NSPrintForDebugger}, defined.
 
+@node OpenCL C
+@subsection OpenCL C
+
+@cindex OpenCL C
+This section provides information about @value{GDBN}s OpenCL C support.
+
+@menu
+* OpenCL C Datatypes::
+* OpenCL C Expressions::
+* OpenCL C Operators::
+@end menu
+
+@node OpenCL C Datatypes
+@subsubsection OpenCL C Datatypes
+
+@cindex OpenCL C Datatypes
+@value{GDBN} supports the builtin scalar and vector datatypes specified
+by OpenCL 1.1.  In addition the half- and double-precision floating point
+data types of the @code{cl_khr_fp16} and @code{cl_khr_fp64} OpenCL
+extensions are also known to @value{GDBN}.
+
+@node OpenCL C Expressions
+@subsubsection OpenCL C Expressions
+
+@cindex OpenCL C Expressions
+@value{GDBN} supports accesses to vector components including the access as
+lvalue where possible.  Since OpenCL C is based on C99 most C expressions
+supported by @value{GDBN} can be used as well.
+
+@node OpenCL C Operators
+@subsubsection OpenCL C Operators
+
+@cindex OpenCL C Operators
+@value{GDBN} supports the operators specified by OpenCL 1.1 for scalar and
+vector data types.
+
 @node Fortran
 @subsection Fortran
 @cindex Fortran-specific support in @value{GDBN}

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [doc RFA] Switch to GCC coding style [Re: [patch] initial OpenCL C language support]
  2010-11-02 19:21                     ` Eli Zaretskii
  2010-11-02 19:29                       ` Joel Brobecker
@ 2010-11-08 12:50                       ` Jan Kratochvil
  2010-11-08 16:11                         ` Joel Brobecker
  1 sibling, 1 reply; 36+ messages in thread
From: Jan Kratochvil @ 2010-11-08 12:50 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: dje, gdb-patches, brobecker, ken, tromey, pedro

On Tue, 02 Nov 2010 20:20:32 +0100, Eli Zaretskii wrote:
> Are you submitting this for doc review, or will we discuss the issue
> first?

I thought about it as a quick fix as currently the code follows different
rules ("!" - GCC) than what states gdbint.texinfo ("! " - GNU).  At least
Pedro says "We tend to follow these already".


> I don't think this is enough, sorry.  The GCC Conventions mention a
> lot of details that are utterly inapplicable to GDB.  The exceptions
> you mention are just a drop in that sea.  What about references to
> ERROR_MARK, RTL, --param arguments, what about fastjar and boehm-gc?
> And those are just a few random examples.
> 
> On balance, I think we should simply have our own coherent document.

Yes, it would be better.  But I am not going to spend the time on it myself.


> Any other way, we will just confuse potential contributors:

They are already confused now (at least I have been confused by "!" vs. "! "
so far myself) and IMO the proposed patch reduces the confusion.


> To say nothing of the fact that they will now have to read two documents
> instead of 1.

3 instead of 2 (besides GNU Coding Standards and gdbint.texinfo Coding
Standards proposing also GCC Coding Conventions).


Regards,
Jan

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [doc RFA] Switch to GCC coding style [Re: [patch] initial OpenCL C language support]
  2010-11-08 12:50                       ` Jan Kratochvil
@ 2010-11-08 16:11                         ` Joel Brobecker
  2010-11-08 16:38                           ` Mark Kettenis
  0 siblings, 1 reply; 36+ messages in thread
From: Joel Brobecker @ 2010-11-08 16:11 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Eli Zaretskii, dje, gdb-patches, ken, tromey, pedro

> Yes, it would be better.  But I am not going to spend the time on it myself.

As a first step, I don't mind duplicating the GCC Conventions Wiki page
onto ours, and then removing all the GCC-specific parts.  I just want
to make sure that we're all happy to go that way.

> > To say nothing of the fact that they will now have to read two documents
> > instead of 1.
> 
> 3 instead of 2 (besides GNU Coding Standards and gdbint.texinfo Coding
> Standards proposing also GCC Coding Conventions).

I agree that 1 document would be better, even if we end up duplicating
some information in GCS. It's just simpler for everyone.

-- 
Joel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [doc RFA] Switch to GCC coding style [Re: [patch] initial OpenCL C language support]
  2010-11-08 16:11                         ` Joel Brobecker
@ 2010-11-08 16:38                           ` Mark Kettenis
  2010-11-08 16:43                             ` Joel Brobecker
  2010-11-08 16:54                             ` Pedro Alves
  0 siblings, 2 replies; 36+ messages in thread
From: Mark Kettenis @ 2010-11-08 16:38 UTC (permalink / raw)
  To: brobecker; +Cc: jan.kratochvil, eliz, dje, gdb-patches, ken, tromey, pedro

> Date: Mon, 8 Nov 2010 08:11:21 -0800
> From: Joel Brobecker <brobecker@adacore.com>
> 
> > Yes, it would be better.  But I am not going to spend the time on it myself.
> 
> As a first step, I don't mind duplicating the GCC Conventions Wiki page
> onto ours, and then removing all the GCC-specific parts.  I just want
> to make sure that we're all happy to go that way.
> 
> > > To say nothing of the fact that they will now have to read two documents
> > > instead of 1.
> > 
> > 3 instead of 2 (besides GNU Coding Standards and gdbint.texinfo Coding
> > Standards proposing also GCC Coding Conventions).
> 
> I agree that 1 document would be better, even if we end up duplicating
> some information in GCS. It's just simpler for everyone.

Not sure about that.  Quite a few people are already familliar with
the GNU Coding standards.  Having a document that describes just the
additional bits means there is less material to read through, and less
likely for people to miss the GDB-specific bits.

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [doc RFA] Switch to GCC coding style [Re: [patch] initial OpenCL C language support]
  2010-11-08 16:38                           ` Mark Kettenis
@ 2010-11-08 16:43                             ` Joel Brobecker
  2010-11-08 16:54                             ` Pedro Alves
  1 sibling, 0 replies; 36+ messages in thread
From: Joel Brobecker @ 2010-11-08 16:43 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: jan.kratochvil, eliz, dje, gdb-patches, ken, tromey, pedro

> > I agree that 1 document would be better, even if we end up duplicating
> > some information in GCS. It's just simpler for everyone.
> 
> Not sure about that.  Quite a few people are already familliar with
> the GNU Coding standards.  Having a document that describes just the
> additional bits means there is less material to read through, and less
> likely for people to miss the GDB-specific bits.

OK - so how about 2 sections:

  1. Coding Conventions from the GCS
  2. The other Coding Conventions used in GDB

Have a link that allows to jump directly to (2)?

-- 
Joel

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [doc RFA] Switch to GCC coding style [Re: [patch] initial OpenCL C language support]
  2010-11-08 16:38                           ` Mark Kettenis
  2010-11-08 16:43                             ` Joel Brobecker
@ 2010-11-08 16:54                             ` Pedro Alves
  2010-11-08 18:36                               ` Joel Brobecker
  1 sibling, 1 reply; 36+ messages in thread
From: Pedro Alves @ 2010-11-08 16:54 UTC (permalink / raw)
  To: gdb-patches
  Cc: Mark Kettenis, brobecker, jan.kratochvil, eliz, dje, ken, tromey

Mark Kettenis wrote:

> > I agree that 1 document would be better, even if we end up duplicating
> > some information in GCS. It's just simpler for everyone.
> 
> Not sure about that.  Quite a few people are already familliar with
> the GNU Coding standards.  Having a document that describes just the
> additional bits means there is less material to read through, and less
> likely for people to miss the GDB-specific bits.
> 

I'm quite behind on reading gdb-patches@, but I agree.

Currently, the "C Coding Standards" section in gdbint.exp reads:

> "@section @value{GDBN} C Coding Standards

> @value{GDBN} follows the GNU coding standards, as described in
> @file{etc/standards.texi}.  This file is also available for anonymous
> FTP from GNU archive sites.  @value{GDBN} takes a strict interpretation
> of the standard; in general, when the GNU standard recommends a practice
> but does not require it, @value{GDBN} requires it.

> @value{GDBN} follows an additional set of coding standards specific to
> @value{GDBN}, as described in the following sections."
..

So we're already describing that we're stricter than the GNU coding standards,
and that we follow an _additional_ set of coding.  It appears to me that
we should just list the extra rules quoted above in the "Formatting"
subsection;

> @subsection Formatting

> @cindex source code formatting
> The standard GNU recommendations for formatting must be followed
> strictly.

> A function declaration should not have its name in column zero.  A
> function definition should have its name in column zero.

by just saying that the recommendations must be followed strictly, and
and a sentence saying something to the effect of "the following list of extra 
GDB specific rules apply" (the ones I quoted from GCC earlier):

Code in GDB should use the following formatting conventions: 
Use...                     ...instead of
!x                         ! x
~x                         ~ x
-x (unary minus)           - x
(foo) x (cast)             (foo)x
*x (pointer dereference)   * x

This is all I was suggesting before.  Really.

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [doc RFA] Switch to GCC coding style [Re: [patch] initial OpenCL C language support]
  2010-11-08 16:54                             ` Pedro Alves
@ 2010-11-08 18:36                               ` Joel Brobecker
  0 siblings, 0 replies; 36+ messages in thread
From: Joel Brobecker @ 2010-11-08 18:36 UTC (permalink / raw)
  To: Pedro Alves
  Cc: gdb-patches, Mark Kettenis, jan.kratochvil, eliz, dje, ken, tromey

> Currently, the "C Coding Standards" section in gdbint.exp reads:
[...]
> by just saying that the recommendations must be followed strictly, and
> and a sentence saying something to the effect of "the following list of extra 
> GDB specific rules apply" (the ones I quoted from GCC earlier):
> 
> Code in GDB should use the following formatting conventions: 
> Use...                     ...instead of
> !x                         ! x
> ~x                         ~ x
> -x (unary minus)           - x
> (foo) x (cast)             (foo)x
> *x (pointer dereference)   * x
> 
> This is all I was suggesting before.  Really.

That works for me, at least as a first step.

We're fragmented between gdbint and Wiki in terms of documentation.
But, somehow, it seems more natural to me to have the coding conventions
available on the Wiki (for one thing, it would allow a hyperlink to
the GCS, which is not available right now when you read this section
in gdbint).

-- 
Joel

^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2010-11-08 18:36 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-22 17:21 [patch] initial OpenCL C language support Ken Werner
2010-10-25 22:41 ` Tom Tromey
2010-10-26 13:05   ` Ken Werner
2010-10-26 13:44     ` Tom Tromey
2010-10-26 16:02       ` Ken Werner
2010-10-26 17:49         ` Eli Zaretskii
2010-10-26 19:58         ` Joel Brobecker
2010-10-26 20:03           ` Joel Brobecker
2010-10-27 13:36             ` Ken Werner
2010-11-02 19:23               ` Joel Brobecker
2010-11-03 13:03                 ` Ken Werner
2010-11-03 15:27                   ` Joel Brobecker
2010-11-04 15:39                     ` Ken Werner
2010-11-04 17:48                       ` Eli Zaretskii
2010-11-05 14:21                         ` Ken Werner
2010-11-05 14:39                     ` Ken Werner
2010-10-27 19:04           ` Jan Kratochvil
2010-10-27 19:21             ` Pedro Alves
2010-10-27 21:01               ` Ken Werner
2010-11-02 16:52               ` [doc RFA] Switch to GCC coding style [Re: [patch] initial OpenCL C language support] Jan Kratochvil
2010-11-02 17:04                 ` Doug Evans
2010-11-02 17:23                   ` Jan Kratochvil
2010-11-02 17:29                     ` Doug Evans
2010-11-02 19:21                     ` Eli Zaretskii
2010-11-02 19:29                       ` Joel Brobecker
2010-11-08 12:50                       ` Jan Kratochvil
2010-11-08 16:11                         ` Joel Brobecker
2010-11-08 16:38                           ` Mark Kettenis
2010-11-08 16:43                             ` Joel Brobecker
2010-11-08 16:54                             ` Pedro Alves
2010-11-08 18:36                               ` Joel Brobecker
2010-11-02 18:01                   ` Joel Brobecker
2010-11-02 18:10                     ` [doc RFA] Switch to GCC coding style Jan Kratochvil
2010-11-02 18:20                       ` Doug Evans
2010-11-02 18:58                         ` Joel Brobecker
2010-11-02 19:19                           ` Doug Evans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).