34 #define OCL_P_TYPE(TYPE)\
35 opencl_primitive_type_##TYPE,\
36 opencl_primitive_type_##TYPE##2,\
37 opencl_primitive_type_##TYPE##3,\
38 opencl_primitive_type_##TYPE##4,\
39 opencl_primitive_type_##TYPE##8,\
40 opencl_primitive_type_##TYPE##16
81 unsigned int el_length,
unsigned int flag_unsigned,
90 if (n != 2 && n != 3 && n != 4 && n != 8 && n != 16)
91 error (
_(
"Invalid OpenCL vector size: %d"), n);
94 length = (n == 3) ? el_length * 4 : el_length * n;
106 && highb - lowb + 1 == n)
124 for (i = 0; i < n; i++)
126 for (j = i + 1; j < n; j++)
128 if (arr[i] == arr[j])
161 c->
indices = XCNEWVEC (
int, n);
162 memcpy (c->
indices, indices, n * sizeof (
int));
183 error (
_(
"Could not determine the vector bounds"));
188 n = offset + highb - lowb + 1;
191 for (i = offset; i < n; i++)
212 error (
_(
"Could not determine the vector bounds"));
217 n = offset + highb - lowb + 1;
227 for (i = offset; i < n; i++)
252 int startrest = offset % elsize;
253 int start = offset / elsize;
254 int endrest = (offset + length) % elsize;
255 int end = (offset + length) / elsize;
264 for (i = start; i < end; i++)
266 int comp_offset = (i == start) ? startrest : 0;
267 int comp_length = (i == end) ? endrest : elsize;
270 c->
indices[i] * elsize + comp_offset,
318 static struct value *
339 struct type *dst_type =
344 if (dst_type == NULL)
366 for (i = 0; i <
n; i++)
380 static struct value *
391 error (
_(
"Could not determine the vector bounds"));
393 src_len = highb - lowb + 1;
397 if (src_len != 2 && src_len != 3 && src_len != 4 && src_len != 8
399 error (
_(
"Invalid OpenCL vector size"));
401 if (strcmp (comps,
"lo") == 0 )
403 dst_len = (src_len == 3) ? 2 : src_len / 2;
405 for (i = 0; i < dst_len; i++)
408 else if (strcmp (comps,
"hi") == 0)
410 dst_len = (src_len == 3) ? 2 : src_len / 2;
412 for (i = 0; i < dst_len; i++)
413 indices[i] = dst_len + i;
415 else if (strcmp (comps,
"even") == 0)
417 dst_len = (src_len == 3) ? 2 : src_len / 2;
419 for (i = 0; i < dst_len; i++)
422 else if (strcmp (comps,
"odd") == 0)
424 dst_len = (src_len == 3) ? 2 : src_len / 2;
426 for (i = 0; i < dst_len; i++)
429 else if (strncasecmp (comps,
"s", 1) == 0)
431 #define HEXCHAR_TO_INT(C) ((C >= '0' && C <= '9') ? \
432 C-'0' : ((C >= 'A' && C <= 'F') ? \
433 C-'A'+10 : ((C >= 'a' && C <= 'f') ? \
436 dst_len = strlen (comps);
440 for (i = 0; i < dst_len; i++)
445 if (indices[i] < 0 || indices[i] >= src_len)
446 error (
_(
"Invalid OpenCL vector component accessor %s"), comps);
451 dst_len = strlen (comps);
453 for (i = 0; i < dst_len; i++)
466 error (
_(
"Invalid OpenCL vector component accessor %s"), comps);
471 error (
_(
"Invalid OpenCL vector component accessor %s"), comps);
475 error (
_(
"Invalid OpenCL vector component accessor %s"), comps);
483 if (dst_len != 1 && dst_len != 2 && dst_len != 3 && dst_len != 4
484 && dst_len != 8 && dst_len != 16)
485 error (
_(
"Invalid OpenCL vector component accessor %s"), comps);
494 static struct value *
498 struct type *rettype;
508 error (
_(
"Could not determine the vector bounds"));
517 for (i = 0; i < highb - lowb + 1; i++)
563 case BINOP_LOGICAL_AND:
566 case BINOP_LOGICAL_OR:
570 error (
_(
"Attempt to perform an unsupported operation"));
578 static struct value *
583 struct type *type1, *type2, *eltype1, *eltype2, *rettype;
584 int t1_is_vec, t2_is_vec, i;
585 LONGEST lowb1, lowb2, highb1, highb2;
593 if (!t1_is_vec || !t2_is_vec)
594 error (
_(
"Vector operations are not supported on scalar types"));
601 error (
_(
"Could not determine the vector bounds"));
607 || lowb1 != lowb2 || highb1 != highb2)
608 error (
_(
"Cannot perform operation on vectors with different types"));
616 for (i = 0; i < highb1 - lowb1 + 1; i++)
635 static struct value *
646 struct type *to_type;
684 static struct value *
696 if (!t1_is_vec && !t2_is_vec)
704 else if (t1_is_vec && t2_is_vec)
711 struct value **v = t1_is_vec ? &arg2 : &arg1;
712 struct type *t = t1_is_vec ? type2 : type1;
715 error (
_(
"Argument to operation not a number or boolean."));
728 static struct value *
733 struct value *arg1 = NULL;
734 struct value *arg2 = NULL;
735 struct type *type1, *type2;
798 case UNOP_LOGICAL_NOT:
809 case BINOP_LOGICAL_AND:
810 case BINOP_LOGICAL_OR:
851 if (op == BINOP_LOGICAL_OR)
858 if (op == BINOP_LOGICAL_AND)
874 struct value *arg3, *tmp, *ret;
875 struct type *eltype2, *type3, *eltype3;
876 int t2_is_vec, t3_is_vec, i;
877 LONGEST lowb1, lowb2, lowb3, highb1, highb2, highb3;
889 if (t2_is_vec || !t3_is_vec)
894 else if (!t2_is_vec || t3_is_vec)
899 else if (!t2_is_vec || !t3_is_vec)
903 Cannot perform conditional operation on incompatible types"));
912 error (
_(
"Could not determine the vector bounds"));
918 || lowb2 != lowb3 || highb2 != highb3)
920 Cannot perform operation on vectors with different types"));
923 if (lowb1 != lowb2 || lowb1 != lowb3
924 || highb1 != highb2 || highb1 != highb3)
926 Cannot perform conditional operation on vectors with different sizes"));
930 for (i = 0; i < highb1 - lowb1 + 1; i++)
961 case STRUCTOP_STRUCT:
1002 struct ui_file *stream,
int show,
int level,
1016 c_print_type (type, varstring, stream, show, level, flags);
1078 default_make_symbol_completion_list,
1099 #define OCL_STRING(S) #S
1102 #define BUILD_OCL_VTYPES(TYPE)\
1103 types[opencl_primitive_type_##TYPE##2] \
1104 = init_vector_type (types[opencl_primitive_type_##TYPE], 2); \
1105 TYPE_NAME (types[opencl_primitive_type_##TYPE##2]) = OCL_STRING(TYPE ## 2); \
1106 types[opencl_primitive_type_##TYPE##3] \
1107 = init_vector_type (types[opencl_primitive_type_##TYPE], 3); \
1108 TYPE_NAME (types[opencl_primitive_type_##TYPE##3]) = OCL_STRING(TYPE ## 3); \
1109 TYPE_LENGTH (types[opencl_primitive_type_##TYPE##3]) \
1110 = 4 * TYPE_LENGTH (types[opencl_primitive_type_##TYPE]); \
1111 types[opencl_primitive_type_##TYPE##4] \
1112 = init_vector_type (types[opencl_primitive_type_##TYPE], 4); \
1113 TYPE_NAME (types[opencl_primitive_type_##TYPE##4]) = OCL_STRING(TYPE ## 4); \
1114 types[opencl_primitive_type_##TYPE##8] \
1115 = init_vector_type (types[opencl_primitive_type_##TYPE], 8); \
1116 TYPE_NAME (types[opencl_primitive_type_##TYPE##8]) = OCL_STRING(TYPE ## 8); \
1117 types[opencl_primitive_type_##TYPE##16] \
1118 = init_vector_type (types[opencl_primitive_type_##TYPE], 16); \
1119 TYPE_NAME (types[opencl_primitive_type_##TYPE##16]) = OCL_STRING(TYPE ## 16)
1121 types[opencl_primitive_type_char]
1124 types[opencl_primitive_type_uchar]
1127 types[opencl_primitive_type_short]
1130 types[opencl_primitive_type_ushort]
1133 types[opencl_primitive_type_int]
1136 types[opencl_primitive_type_uint]
1139 types[opencl_primitive_type_long]
1142 types[opencl_primitive_type_ulong]
1145 types[opencl_primitive_type_half]
1148 types[opencl_primitive_type_float]
1151 types[opencl_primitive_type_double]
struct value * value_zero(struct type *type, enum lval_type lv)
union exp_element elts[1]
const struct op_print c_op_print_tab[]
struct value * value_mark(void)
struct value * evaluate_subexp_c(struct type *expect_type, struct expression *exp, int *pos, enum noside noside)
void value_free_to_mark(struct value *mark)
struct value * value_subscript(struct value *array, LONGEST index)
static void lval_func_free_closure(struct value *v)
const struct floatformat * floatformats_ieee_double[BFD_ENDIAN_UNKNOWN]
int value_offset(const struct value *value)
struct type * arch_boolean_type(struct gdbarch *gdbarch, int bit, int unsigned_p, char *name)
#define GDBARCH_OBSTACK_CALLOC(GDBARCH, NR, TYPE)
#define TYPE_NAME(thistype)
void value_incref(struct value *val)
#define HEXCHAR_TO_INT(C)
int gdbarch_ptr_bit(struct gdbarch *gdbarch)
struct type * arch_float_type(struct gdbarch *gdbarch, int bit, char *name, const struct floatformat **floatformats)
void * gdbarch_data(struct gdbarch *gdbarch, struct gdbarch_data *data)
void * value_computed_closure(const struct value *v)
const struct language_defn * language_defn
void c_val_print(struct type *, const gdb_byte *, int, CORE_ADDR, struct ui_file *, int, const struct value *, const struct value_print_options *)
struct value * default_read_var_value(struct symbol *var, struct frame_info *frame)
struct value * coerce_ref(struct value *arg)
void value_free(struct value *val)
const struct floatformat * floatformats_ieee_half[BFD_ENDIAN_UNKNOWN]
static struct gdbarch_data * opencl_type_data
struct type * string_char_type
static struct value * evaluate_subexp_opencl(struct type *expect_type, struct expression *exp, int *pos, enum noside noside)
static int array_has_dups(int *arr, int n)
#define BYTES_TO_EXP_ELEM(bytes)
struct value * allocate_value(struct type *type)
static int lval_func_check_synthetic_pointer(const struct value *v, int offset, int length)
void add_language(const struct language_defn *lang)
void c_get_string(struct value *value, gdb_byte **buffer, int *length, struct type **char_type, const char **charset)
int longest_to_int(LONGEST)
mach_port_t kern_return_t mach_port_t msgports mach_port_t kern_return_t pid_t pid mach_port_t kern_return_t mach_port_t task mach_port_t kern_return_t int flags
char * default_word_break_characters(void)
struct value * value_struct_elt(struct value **argp, struct value **args, const char *name, int *static_memfuncp, const char *err)
struct type * check_typedef(struct type *type)
const gdb_byte * value_contents(struct value *value)
struct type * bool_type_default
void null_post_parser(struct expression **exp, int void_context_p)
void initialize_file_ftype(void)
struct value * allocate_computed_value(struct type *type, const struct lval_funcs *funcs, void *closure)
void c_emit_char(int c, struct type *type, struct ui_file *stream, int quoter)
const gdb_byte * value_contents_all(struct value *value)
int is_integral_type(struct type *t)
#define BUILD_OCL_VTYPES(TYPE)
const char * bool_type_symbol
int default_pass_by_reference(struct type *type)
struct type * basic_lookup_transparent_type(const char *name)
static int scalar_relop(struct value *val1, struct value *val2, enum exp_opcode op)
struct type * init_vector_type(struct type *elt_type, int n)
gdb_byte * value_contents_writeable(struct value *value)
struct value * value_assign(struct value *toval, struct value *fromval)
int dump_subexp_body_standard(struct expression *exp, struct ui_file *stream, int elt)
static struct type ** builtin_opencl_type(struct gdbarch *gdbarch)
struct type * language_bool_type(const struct language_defn *la, struct gdbarch *gdbarch)
static void * build_opencl_types(struct gdbarch *gdbarch)
struct value * value_from_longest(struct type *type, LONGEST num)
void iterate_over_symbols(const struct block *block, const char *name, const domain_enum domain, symbol_found_callback_ftype *callback, void *data)
struct value * value_cast(struct type *type, struct value *arg2)
static struct value * create_value(struct gdbarch *gdbarch, struct value *val, enum noside noside, int *indices, int n)
static struct value * opencl_value_cast(struct type *type, struct value *arg)
void default_print_array_index(struct value *index_value, struct ui_file *stream, const struct value_print_options *options)
const struct exp_descriptor exp_descriptor_opencl
struct type * arch_integer_type(struct gdbarch *gdbarch, int bit, int unsigned_p, char *name)
int deprecated_value_modifiable(struct value *value)
char * op_name_standard(enum exp_opcode opcode)
void c_print_typedef(struct type *, struct symbol *, struct ui_file *)
int value_equal(struct value *arg1, struct value *arg2)
int c_parse(struct parser_state *par_state)
static struct value * opencl_component_ref(struct expression *exp, struct value *val, char *comps, enum noside noside)
static struct type * lookup_opencl_vector_type(struct gdbarch *gdbarch, enum type_code code, unsigned int el_length, unsigned int flag_unsigned, int n)
static void lval_func_read(struct value *v)
void c_printstr(struct ui_file *stream, struct type *type, const gdb_byte *string, unsigned int length, const char *user_encoding, int force_ellipses, const struct value_print_options *options)
const struct floatformat * floatformats_ieee_single[BFD_ENDIAN_UNKNOWN]
int value_bits_synthetic_pointer(const struct value *value, int offset, int length)
static struct value * opencl_relop(struct expression *exp, struct value *arg1, struct value *arg2, enum exp_opcode op)
static void opencl_print_type(struct type *type, const char *varstring, struct ui_file *stream, int show, int level, const struct type_print_options *flags)
struct type * make_cv_type(int cnst, int voltl, struct type *type, struct type **typeptr)
#define TYPE_TARGET_TYPE(thistype)
initialize_file_ftype _initialize_opencl_language
void print_subexp_standard(struct expression *exp, int *pos, struct ui_file *stream, enum precedence prec)
#define TYPE_CODE(thistype)
#define default_varobj_ops
void c_print_type(struct type *, const char *, struct ui_file *, int, int, const struct type_print_options *)
int operator_check_standard(struct expression *exp, int pos, int(*objfile_func)(struct objfile *objfile, void *data), void *data)
int value_less(struct value *arg1, struct value *arg2)
struct value * evaluate_subexp(struct type *expect_type, struct expression *exp, int *pos, enum noside noside)
static struct value * vector_relop(struct expression *exp, struct value *val1, struct value *val2, enum exp_opcode op)
#define CHECK_TYPEDEF(TYPE)
int value_logical_not(struct value *arg1)
struct value * value_vector_widen(struct value *scalar_value, struct type *vector_type)
void operator_length_standard(const struct expression *expr, int endpos, int *oplenp, int *argsp)
struct symbol * basic_lookup_symbol_nonlocal(const struct language_defn *langdef, const char *name, const struct block *block, const domain_enum domain)
struct type * value_type(const struct value *value)
void c_printchar(int c, struct type *type, struct ui_file *stream)
static void * lval_func_copy_closure(const struct value *v)
gdb_byte * value_contents_raw(struct value *value)
#define TYPE_LENGTH(thistype)
static void opencl_language_arch_info(struct gdbarch *gdbarch, struct language_arch_info *lai)
struct type * arch_type(struct gdbarch *gdbarch, enum type_code code, int length, char *name)
struct type ** primitive_type_vector
int get_array_bounds(struct type *type, LONGEST *low_bound, LONGEST *high_bound)
void c_value_print(struct value *, struct ui_file *, const struct value_print_options *)
void error(const char *fmt,...)
struct gdbarch_data * gdbarch_data_register_post_init(gdbarch_data_post_init_ftype *post_init)
static void lval_func_write(struct value *v, struct value *fromval)
static struct lval_closure * allocate_lval_closure(int *indices, int n, struct value *val)
static struct value * opencl_logical_not(struct expression *exp, struct value *arg)