aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-03-08 07:27:57 -0700
committerTom Tromey <tom@tromey.com>2021-03-08 07:28:31 -0700
commit33b79214629c2b1b219e82bb34aed5fb03913634 (patch)
tree940b3b0318b22aa9f19eaf1b5f3da9de3dacc368
parent2492ba36f690fa6ce584132dce3e2f26fbb89f87 (diff)
downloadgdb-33b79214629c2b1b219e82bb34aed5fb03913634.zip
gdb-33b79214629c2b1b219e82bb34aed5fb03913634.tar.gz
gdb-33b79214629c2b1b219e82bb34aed5fb03913634.tar.bz2
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.
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/c-exp.h16
-rw-r--r--gdb/opencl-lang.c28
3 files changed, 50 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 257f881..3c7d683 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
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
parameters.
(evaluate_subexp_opencl): Update.
diff --git a/gdb/c-exp.h b/gdb/c-exp.h
index 1afe2d2..58a16d5 100644
--- a/gdb/c-exp.h
+++ b/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 */
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 8ddcd76..3171639 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -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,