-
-static void *
-build_opencl_types (struct gdbarch *gdbarch)
-{
- struct type **types
- = GDBARCH_OBSTACK_CALLOC (gdbarch, nr_opencl_primitive_types + 1,
- struct type *);
-
-/* Helper macro to create strings. */
-#define OCL_STRING(S) #S
-/* This macro allocates and assigns the type struct pointers
- for the vector types. */
-#define BUILD_OCL_VTYPES(TYPE)\
- types[opencl_primitive_type_##TYPE##2] \
- = init_vector_type (types[opencl_primitive_type_##TYPE], 2); \
- types[opencl_primitive_type_##TYPE##2]->set_name (OCL_STRING(TYPE ## 2)); \
- types[opencl_primitive_type_##TYPE##3] \
- = init_vector_type (types[opencl_primitive_type_##TYPE], 3); \
- types[opencl_primitive_type_##TYPE##3]->set_name (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); \
- types[opencl_primitive_type_##TYPE##4]->set_name (OCL_STRING(TYPE ## 4)); \
- types[opencl_primitive_type_##TYPE##8] \
- = init_vector_type (types[opencl_primitive_type_##TYPE], 8); \
- types[opencl_primitive_type_##TYPE##8]->set_name (OCL_STRING(TYPE ## 8)); \
- types[opencl_primitive_type_##TYPE##16] \
- = init_vector_type (types[opencl_primitive_type_##TYPE], 16); \
- types[opencl_primitive_type_##TYPE##16]->set_name (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;
-}
-
-void _initialize_opencl_language ();
-void
-_initialize_opencl_language ()
-{
- opencl_type_data = gdbarch_data_register_post_init (build_opencl_types);
-}