-#define BUILD_OCL_VTYPES(TYPE)\
- types[opencl_primitive_type_##TYPE##2] \
- = init_vector_type (types[opencl_primitive_type_##TYPE], 2); \
- TYPE_NAME (types[opencl_primitive_type_##TYPE##2]) = OCL_STRING(TYPE ## 2); \
- types[opencl_primitive_type_##TYPE##3] \
- = init_vector_type (types[opencl_primitive_type_##TYPE], 3); \
- TYPE_NAME (types[opencl_primitive_type_##TYPE##3]) = OCL_STRING(TYPE ## 3); \
- TYPE_LENGTH (types[opencl_primitive_type_##TYPE##3]) \
- = 4 * TYPE_LENGTH (types[opencl_primitive_type_##TYPE]); \
- types[opencl_primitive_type_##TYPE##4] \
- = init_vector_type (types[opencl_primitive_type_##TYPE], 4); \
- TYPE_NAME (types[opencl_primitive_type_##TYPE##4]) = OCL_STRING(TYPE ## 4); \
- types[opencl_primitive_type_##TYPE##8] \
- = init_vector_type (types[opencl_primitive_type_##TYPE], 8); \
- TYPE_NAME (types[opencl_primitive_type_##TYPE##8]) = OCL_STRING(TYPE ## 8); \
- types[opencl_primitive_type_##TYPE##16] \
- = init_vector_type (types[opencl_primitive_type_##TYPE], 16); \
- TYPE_NAME (types[opencl_primitive_type_##TYPE##16]) = OCL_STRING(TYPE ## 16)
-
- types[opencl_primitive_type_char]
- = arch_integer_type (gdbarch, 8, 0, "char");
- BUILD_OCL_VTYPES (char);
- types[opencl_primitive_type_uchar]
- = arch_integer_type (gdbarch, 8, 1, "uchar");
- BUILD_OCL_VTYPES (uchar);
- types[opencl_primitive_type_short]
- = arch_integer_type (gdbarch, 16, 0, "short");
- BUILD_OCL_VTYPES (short);
- types[opencl_primitive_type_ushort]
- = arch_integer_type (gdbarch, 16, 1, "ushort");
- BUILD_OCL_VTYPES (ushort);
- types[opencl_primitive_type_int]
- = arch_integer_type (gdbarch, 32, 0, "int");
- BUILD_OCL_VTYPES (int);
- types[opencl_primitive_type_uint]
- = arch_integer_type (gdbarch, 32, 1, "uint");
- BUILD_OCL_VTYPES (uint);
- types[opencl_primitive_type_long]
- = arch_integer_type (gdbarch, 64, 0, "long");
- BUILD_OCL_VTYPES (long);
- types[opencl_primitive_type_ulong]
- = arch_integer_type (gdbarch, 64, 1, "ulong");
- BUILD_OCL_VTYPES (ulong);
- types[opencl_primitive_type_half]
- = arch_float_type (gdbarch, 16, "half", floatformats_ieee_half);
- BUILD_OCL_VTYPES (half);
- types[opencl_primitive_type_float]
- = arch_float_type (gdbarch, 32, "float", floatformats_ieee_single);
- BUILD_OCL_VTYPES (float);
- types[opencl_primitive_type_double]
- = arch_float_type (gdbarch, 64, "double", floatformats_ieee_double);
- BUILD_OCL_VTYPES (double);
- types[opencl_primitive_type_bool]
- = arch_boolean_type (gdbarch, 8, 1, "bool");
- types[opencl_primitive_type_unsigned_char]
- = arch_integer_type (gdbarch, 8, 1, "unsigned char");
- types[opencl_primitive_type_unsigned_short]
- = arch_integer_type (gdbarch, 16, 1, "unsigned short");
- types[opencl_primitive_type_unsigned_int]
- = arch_integer_type (gdbarch, 32, 1, "unsigned int");
- types[opencl_primitive_type_unsigned_long]
- = arch_integer_type (gdbarch, 64, 1, "unsigned long");
- types[opencl_primitive_type_size_t]
- = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 1, "size_t");
- types[opencl_primitive_type_ptrdiff_t]
- = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 0, "ptrdiff_t");
- types[opencl_primitive_type_intptr_t]
- = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 0, "intptr_t");
- types[opencl_primitive_type_uintptr_t]
- = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 1, "uintptr_t");
- types[opencl_primitive_type_void]
- = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
-
- return types;
-}
+#define BUILD_OCL_VTYPES(TYPE, ELEMENT_TYPE) \
+ do \
+ { \
+ struct type *tmp; \
+ tmp = add (init_vector_type (ELEMENT_TYPE, 2)); \
+ tmp->set_name (OCL_STRING(TYPE ## 2)); \
+ tmp = add (init_vector_type (ELEMENT_TYPE, 3)); \
+ tmp->set_name (OCL_STRING(TYPE ## 3)); \
+ TYPE_LENGTH (tmp) = 4 * TYPE_LENGTH (ELEMENT_TYPE); \
+ tmp = add (init_vector_type (ELEMENT_TYPE, 4)); \
+ tmp->set_name (OCL_STRING(TYPE ## 4)); \
+ tmp = add (init_vector_type (ELEMENT_TYPE, 8)); \
+ tmp->set_name (OCL_STRING(TYPE ## 8)); \
+ tmp = init_vector_type (ELEMENT_TYPE, 16); \
+ tmp->set_name (OCL_STRING(TYPE ## 16)); \
+ } \
+ while (false)
+
+ struct type *el_type, *char_type, *int_type;
+
+ char_type = el_type = add (arch_integer_type (gdbarch, 8, 0, "char"));
+ BUILD_OCL_VTYPES (char, el_type);
+ el_type = add (arch_integer_type (gdbarch, 8, 1, "uchar"));
+ BUILD_OCL_VTYPES (uchar, el_type);
+ el_type = add (arch_integer_type (gdbarch, 16, 0, "short"));
+ BUILD_OCL_VTYPES (short, el_type);
+ el_type = add (arch_integer_type (gdbarch, 16, 1, "ushort"));
+ BUILD_OCL_VTYPES (ushort, el_type);
+ int_type = el_type = add (arch_integer_type (gdbarch, 32, 0, "int"));
+ BUILD_OCL_VTYPES (int, el_type);
+ el_type = add (arch_integer_type (gdbarch, 32, 1, "uint"));
+ BUILD_OCL_VTYPES (uint, el_type);
+ el_type = add (arch_integer_type (gdbarch, 64, 0, "long"));
+ BUILD_OCL_VTYPES (long, el_type);
+ el_type = add (arch_integer_type (gdbarch, 64, 1, "ulong"));
+ BUILD_OCL_VTYPES (ulong, el_type);
+ el_type = add (arch_float_type (gdbarch, 16, "half", floatformats_ieee_half));
+ BUILD_OCL_VTYPES (half, el_type);
+ el_type = add (arch_float_type (gdbarch, 32, "float", floatformats_ieee_single));
+ BUILD_OCL_VTYPES (float, el_type);
+ el_type = add (arch_float_type (gdbarch, 64, "double", floatformats_ieee_double));
+ BUILD_OCL_VTYPES (double, el_type);
+
+ add (arch_boolean_type (gdbarch, 8, 1, "bool"));
+ add (arch_integer_type (gdbarch, 8, 1, "unsigned char"));
+ add (arch_integer_type (gdbarch, 16, 1, "unsigned short"));
+ add (arch_integer_type (gdbarch, 32, 1, "unsigned int"));
+ add (arch_integer_type (gdbarch, 64, 1, "unsigned long"));
+ add (arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 1, "size_t"));
+ add (arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 0, "ptrdiff_t"));
+ add (arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 0, "intptr_t"));
+ add (arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 1, "uintptr_t"));
+ add (arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"));
+
+ /* Type of elements of strings. */
+ lai->set_string_char_type (char_type);
+
+ /* Specifies the return type of logical and relational operations. */
+ lai->set_bool_type (int_type, "int");
+ }
+
+ /* See language.h. */
+
+ void print_type (struct type *type, const char *varstring,
+ struct ui_file *stream, int show, int level,
+ const struct type_print_options *flags) const override
+ {
+ /* We nearly always defer to C type printing, except that vector types
+ are considered primitive in OpenCL, and should always be printed
+ using their TYPE_NAME. */
+ if (show > 0)
+ {
+ type = check_typedef (type);
+ if (type->code () == TYPE_CODE_ARRAY && type->is_vector ()
+ && type->name () != NULL)
+ show = 0;
+ }