Introduce opencl_structop_operation
This adds class opencl_structop_operation, which implements STRUCTOP_STRUCT for OpenCL. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * opencl-lang.c (opencl_structop_operation::evaluate): New method. * c-exp.h (class opencl_structop_operation): New.
This commit is contained in:
parent
2492ba36f6
commit
33b7921462
@ -1,3 +1,9 @@
|
||||
2021-03-08 Tom Tromey <tom@tromey.com>
|
||||
|
||||
* opencl-lang.c (opencl_structop_operation::evaluate): New
|
||||
method.
|
||||
* c-exp.h (class opencl_structop_operation): New.
|
||||
|
||||
2021-03-08 Tom Tromey <tom@tromey.com>
|
||||
|
||||
* opencl-lang.c (opencl_logical_not): No longer static. Change
|
||||
|
||||
16
gdb/c-exp.h
16
gdb/c-exp.h
@ -170,6 +170,22 @@ using opencl_leq_operation = opencl_binop_operation<BINOP_LEQ,
|
||||
using opencl_not_operation = unop_operation<UNOP_LOGICAL_NOT,
|
||||
opencl_logical_not>;
|
||||
|
||||
/* STRUCTOP_STRUCT implementation for OpenCL. */
|
||||
class opencl_structop_operation
|
||||
: public structop_base_operation
|
||||
{
|
||||
public:
|
||||
|
||||
using structop_base_operation::structop_base_operation;
|
||||
|
||||
value *evaluate (struct type *expect_type,
|
||||
struct expression *exp,
|
||||
enum noside noside) override;
|
||||
|
||||
enum exp_opcode opcode () const override
|
||||
{ return STRUCTOP_STRUCT; }
|
||||
};
|
||||
|
||||
}/* namespace expr */
|
||||
|
||||
#endif /* C_EXP_H */
|
||||
|
||||
@ -958,6 +958,34 @@ Cannot perform conditional operation on vectors with different sizes"));
|
||||
return evaluate_subexp_c (expect_type, exp, pos, noside);
|
||||
}
|
||||
|
||||
namespace expr
|
||||
{
|
||||
|
||||
value *
|
||||
opencl_structop_operation::evaluate (struct type *expect_type,
|
||||
struct expression *exp,
|
||||
enum noside noside)
|
||||
{
|
||||
value *arg1 = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
|
||||
struct type *type1 = check_typedef (value_type (arg1));
|
||||
|
||||
if (type1->code () == TYPE_CODE_ARRAY && type1->is_vector ())
|
||||
return opencl_component_ref (exp, arg1, std::get<1> (m_storage).c_str (),
|
||||
noside);
|
||||
else
|
||||
{
|
||||
struct value *v = value_struct_elt (&arg1, NULL,
|
||||
std::get<1> (m_storage).c_str (),
|
||||
NULL, "structure");
|
||||
|
||||
if (noside == EVAL_AVOID_SIDE_EFFECTS)
|
||||
v = value_zero (value_type (v), VALUE_LVAL (v));
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
} /* namespace expr */
|
||||
|
||||
const struct exp_descriptor exp_descriptor_opencl =
|
||||
{
|
||||
print_subexp_standard,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user