38 unsigned int el_length,
unsigned int flag_unsigned,
44 if (n != 2 && n != 3 && n != 4 && n != 8 && n != 16)
45 error (_(
"Invalid OpenCL vector size: %d"), n);
48 length = (n == 3) ? el_length * 4 : el_length * n;
50 auto filter = [&] (
struct type *
type)
60 && highb - lowb + 1 == n);
74 for (i = 0; i < n; i++)
76 for (j = i + 1; j < n; j++)
126 LONGEST elsize = eltype->
length ();
131 if (
type->
code () == TYPE_CODE_ARRAY
133 error (_(
"Could not determine the vector bounds"));
136 gdb_assert (offset % elsize == 0);
138 n = offset + highb - lowb + 1;
139 gdb_assert (n <= c->n);
141 for (i = offset; i < n; i++)
156 LONGEST elsize = eltype->
length ();
161 if (
type->
code () == TYPE_CODE_ARRAY
163 error (_(
"Could not determine the vector bounds"));
166 gdb_assert (offset % elsize == 0);
168 n = offset + highb - lowb + 1;
178 for (i = offset; i < n; i++)
195 LONGEST
offset,
int length)
201 int startrest = offset % elsize;
202 int start = offset / elsize;
203 int endrest = (offset + length) % elsize;
204 int end = (offset + length) / elsize;
213 for (i = start; i < end; i++)
215 int comp_offset = (i == start) ? startrest : 0;
216 int comp_length = (i == end) ? endrest : elsize;
219 c->
indices[i] * elsize + comp_offset,
289 struct type *dst_type =
294 if (dst_type == NULL)
316 for (i = 0; i <
n; i++)
318 + (i * elm_type->
length ()),
341 error (_(
"Could not determine the vector bounds"));
343 src_len = highb - lowb + 1;
347 if (src_len != 2 && src_len != 3 && src_len != 4 && src_len != 8
349 error (_(
"Invalid OpenCL vector size"));
351 if (strcmp (comps,
"lo") == 0 )
353 dst_len = (src_len == 3) ? 2 : src_len / 2;
355 for (i = 0; i < dst_len; i++)
358 else if (strcmp (comps,
"hi") == 0)
360 dst_len = (src_len == 3) ? 2 : src_len / 2;
362 for (i = 0; i < dst_len; i++)
363 indices[i] = dst_len + i;
365 else if (strcmp (comps,
"even") == 0)
367 dst_len = (src_len == 3) ? 2 : src_len / 2;
369 for (i = 0; i < dst_len; i++)
372 else if (strcmp (comps,
"odd") == 0)
374 dst_len = (src_len == 3) ? 2 : src_len / 2;
376 for (i = 0; i < dst_len; i++)
379 else if (strncasecmp (comps,
"s", 1) == 0)
381#define HEXCHAR_TO_INT(C) ((C >= '0' && C <= '9') ? \
382 C-'0' : ((C >= 'A' && C <= 'F') ? \
383 C-'A'+10 : ((C >= 'a' && C <= 'f') ? \
386 dst_len = strlen (comps);
390 for (i = 0; i < dst_len; i++)
395 if (indices[i] < 0 || indices[i] >= src_len)
396 error (_(
"Invalid OpenCL vector component accessor %s"), comps);
401 dst_len = strlen (comps);
403 for (i = 0; i < dst_len; i++)
416 error (_(
"Invalid OpenCL vector component accessor %s"), comps);
421 error (_(
"Invalid OpenCL vector component accessor %s"), comps);
425 error (_(
"Invalid OpenCL vector component accessor %s"), comps);
433 if (dst_len != 1 && dst_len != 2 && dst_len != 3 && dst_len != 4
434 && dst_len != 8 && dst_len != 16)
435 error (_(
"Invalid OpenCL vector component accessor %s"), comps);
450 struct type *rettype;
460 error (_(
"Could not determine the vector bounds"));
469 for (i = 0; i < highb - lowb + 1; i++)
516 case BINOP_LOGICAL_AND:
519 case BINOP_LOGICAL_OR:
523 error (_(
"Attempt to perform an unsupported operation"));
536 struct type *type1, *type2, *eltype1, *eltype2, *rettype;
537 int t1_is_vec, t2_is_vec, i;
538 LONGEST lowb1, lowb2, highb1, highb2;
543 t1_is_vec = (type1->
code () == TYPE_CODE_ARRAY && type1->
is_vector ());
544 t2_is_vec = (type2->
code () == TYPE_CODE_ARRAY && type2->
is_vector ());
546 if (!t1_is_vec || !t2_is_vec)
547 error (_(
"Vector operations are not supported on scalar types"));
554 error (_(
"Could not determine the vector bounds"));
557 if (eltype1->
code () != eltype2->
code ()
560 || lowb1 != lowb2 || highb1 != highb2)
561 error (_(
"Cannot perform operation on vectors with different types"));
569 for (i = 0; i < highb1 - lowb1 + 1; i++)
577 + i * eltype1->
length ()),
600 struct type *to_type;
605 code1 = to_type->
code ();
608 if (code2 == TYPE_CODE_REF)
611 scalar = (code2 == TYPE_CODE_INT || code2 == TYPE_CODE_BOOL
612 || code2 == TYPE_CODE_CHAR || code2 == TYPE_CODE_FLT
613 || code2 == TYPE_CODE_DECFLOAT || code2 == TYPE_CODE_ENUM
614 || code2 == TYPE_CODE_RANGE);
616 if (code1 == TYPE_CODE_ARRAY && to_type->
is_vector () && scalar)
646 int t1_is_vec = (type1->
code () == TYPE_CODE_ARRAY
648 int t2_is_vec = (type2->
code () == TYPE_CODE_ARRAY
651 if (!t1_is_vec && !t2_is_vec)
659 else if (t1_is_vec && t2_is_vec)
666 struct value **v = t1_is_vec ? &arg2 : &arg1;
667 struct type *t = t1_is_vec ? type2 : type1;
670 error (_(
"Argument to operation not a number or boolean."));
708 if (type1->
code () == TYPE_CODE_ARRAY && type1->
is_vector ())
741 if ((type1->
code () == TYPE_CODE_ARRAY && type1->
is_vector ())
742 || (type2->
code () == TYPE_CODE_ARRAY && type2->
is_vector ()))
755 if (op == BINOP_LOGICAL_OR)
762 if (op == BINOP_LOGICAL_OR)
778 if (type1->
code () == TYPE_CODE_ARRAY && type1->
is_vector ())
780 struct value *arg2, *arg3, *tmp, *ret;
781 struct type *eltype2, *type2, *type3, *eltype3;
782 int t2_is_vec, t3_is_vec, i;
783 LONGEST lowb1, lowb2, lowb3, highb1, highb2, highb3;
795 if (t2_is_vec || !t3_is_vec)
800 else if (!t2_is_vec || t3_is_vec)
805 else if (!t2_is_vec || !t3_is_vec)
809Cannot perform conditional operation on incompatible types"));
818 error (_(
"Could not determine the vector bounds"));
821 if (eltype2->
code () != eltype3->
code ()
824 || lowb2 != lowb3 || highb2 != highb3)
826Cannot perform operation on vectors with different types"));
829 if (lowb1 != lowb2 || lowb1 != lowb3
830 || highb1 != highb2 || highb1 != highb3)
832Cannot perform conditional operation on vectors with different sizes"));
836 for (i = 0; i < highb1 - lowb1 + 1; i++)
869 const char *
name ()
const override
875 {
return "OpenCL C"; }
882 auto add = [&] (
struct type * t) ->
struct type *
889#define OCL_STRING(S) #S
893#define BUILD_OCL_VTYPES(TYPE, ELEMENT_TYPE) \
897 tmp = add (init_vector_type (ELEMENT_TYPE, 2)); \
898 tmp->set_name (OCL_STRING(TYPE ## 2)); \
899 tmp = add (init_vector_type (ELEMENT_TYPE, 3)); \
900 tmp->set_name (OCL_STRING(TYPE ## 3)); \
901 tmp->set_length (4 * (ELEMENT_TYPE)->length ()); \
902 tmp = add (init_vector_type (ELEMENT_TYPE, 4)); \
903 tmp->set_name (OCL_STRING(TYPE ## 4)); \
904 tmp = add (init_vector_type (ELEMENT_TYPE, 8)); \
905 tmp->set_name (OCL_STRING(TYPE ## 8)); \
906 tmp = init_vector_type (ELEMENT_TYPE, 16); \
907 tmp->set_name (OCL_STRING(TYPE ## 16)); \
911 struct type *el_type, *char_type, *int_type;
964 struct ui_file *stream,
int show,
int level,
struct value * opencl_value_cast(struct type *type, struct value *arg)
struct value * opencl_relop(struct type *expect_type, struct expression *exp, enum noside noside, enum exp_opcode op, struct value *arg1, struct value *arg2)
void c_print_type(struct type *type, const char *varstring, struct ui_file *stream, int show, int level, enum language language, const struct type_print_options *flags)
value * evaluate(struct type *expect_type, struct expression *exp, enum noside noside) override
value * evaluate(struct type *expect_type, struct expression *exp, enum noside noside) override
value * evaluate(struct type *expect_type, struct expression *exp, enum noside noside) override
std::tuple< Arg... > m_storage
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
bool can_print_type_offsets() const override
void language_arch_info(struct gdbarch *gdbarch, struct language_arch_info *lai) const override
const char * natural_name() const override
const char * name() const override
enum macro_expansion macro_expansion() const override
@ EVAL_AVOID_SIDE_EFFECTS
int gdbarch_ptr_bit(struct gdbarch *gdbarch)
int is_integral_type(struct type *t)
struct type * make_cv_type(int cnst, int voltl, struct type *type, struct type **typeptr)
struct type * init_vector_type(struct type *elt_type, int n)
struct type * arch_type(struct gdbarch *gdbarch, enum type_code code, int bit, const char *name)
struct type * arch_boolean_type(struct gdbarch *gdbarch, int bit, int unsigned_p, const char *name)
const struct floatformat * floatformats_ieee_single[BFD_ENDIAN_UNKNOWN]
struct type * arch_float_type(struct gdbarch *gdbarch, int bit, const char *name, const struct floatformat **floatformats)
bool get_array_bounds(struct type *type, LONGEST *low_bound, LONGEST *high_bound)
const struct floatformat * floatformats_ieee_half[BFD_ENDIAN_UNKNOWN]
const struct floatformat * floatformats_ieee_double[BFD_ENDIAN_UNKNOWN]
struct type * arch_integer_type(struct gdbarch *gdbarch, int bit, int unsigned_p, const char *name)
struct type * check_typedef(struct type *type)
mach_port_t kern_return_t mach_port_t mach_msg_type_name_t msgportsPoly 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
const struct language_defn * language_def(enum language lang)
struct type * language_lookup_primitive_type(const struct language_defn *la, struct gdbarch *gdbarch, const char *name)
struct type * language_bool_type(const struct language_defn *la, struct gdbarch *gdbarch)
struct value * opencl_value_cast(struct type *type, struct value *arg)
struct value * opencl_relop(struct type *expect_type, struct expression *exp, enum noside noside, enum exp_opcode op, struct value *arg1, struct value *arg2)
static struct lval_closure * allocate_lval_closure(int *indices, int n, struct value *val)
#define HEXCHAR_TO_INT(C)
struct value * opencl_logical_not(struct type *expect_type, struct expression *exp, enum noside noside, enum exp_opcode op, struct value *arg)
static void lval_func_write(struct value *v, struct value *fromval)
#define BUILD_OCL_VTYPES(TYPE, ELEMENT_TYPE)
static void lval_func_free_closure(struct value *v)
static struct value * vector_relop(struct expression *exp, struct value *val1, struct value *val2, enum exp_opcode op)
static struct value * opencl_component_ref(struct expression *exp, struct value *val, const char *comps, enum noside noside)
struct value * eval_opencl_assign(struct type *expect_type, struct expression *exp, enum noside noside, enum exp_opcode op, struct value *arg1, struct value *arg2)
static void lval_func_read(struct value *v)
static const struct lval_funcs opencl_value_funcs
static void * lval_func_copy_closure(const struct value *v)
static int array_has_dups(int *arr, int n)
static struct value * create_value(struct gdbarch *gdbarch, struct value *val, enum noside noside, int *indices, int n)
static int scalar_relop(struct value *val1, struct value *val2, enum exp_opcode op)
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 int lval_func_check_synthetic_pointer(const struct value *v, LONGEST offset, int length)
static opencl_language opencl_language_defn
const struct language_defn * language_defn
void set_string_char_type(struct type *type)
void add_primitive_type(struct type *type)
void set_bool_type(struct type *type, const char *name=nullptr)
enum language la_language
struct type * target_type() const
const char * name() const
bool value_logical_not(struct value *arg1)
struct value * value_subscript(struct value *array, LONGEST index)
struct value * value_vector_widen(struct value *scalar_value, struct type *vector_type)
int value_equal(struct value *arg1, struct value *arg2)
int value_less(struct value *arg1, struct value *arg2)
struct value * value_struct_elt(struct value **argp, gdb::optional< gdb::array_view< value * > > args, const char *name, int *static_memfuncp, const char *err)
struct value * value_cast(struct type *type, struct value *arg2)
struct value * value_assign(struct value *toval, struct value *fromval)
struct type * value_type(const struct value *value)
struct value * value_zero(struct type *type, enum lval_type lv)
LONGEST value_offset(const struct value *value)
gdb::array_view< const gdb_byte > value_contents_all(struct value *value)
struct value * allocate_value(struct type *type)
struct value * value_from_longest(struct type *type, LONGEST num)
gdb::array_view< gdb_byte > value_contents_raw(struct value *value)
struct value * coerce_ref(struct value *arg)
gdb::array_view< const gdb_byte > value_contents(struct value *value)
gdb::array_view< gdb_byte > value_contents_writeable(struct value *value)
void value_incref(struct value *val)
struct value * allocate_computed_value(struct type *type, const struct lval_funcs *funcs, void *closure)
int deprecated_value_modifiable(const struct value *value)
int value_bits_synthetic_pointer(const struct value *value, LONGEST offset, LONGEST length)
void * value_computed_closure(const struct value *v)
void value_decref(struct value *val)