aboutsummaryrefslogtreecommitdiff
path: root/gdb/opencl-lang.c
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 /gdb/opencl-lang.c
parent2492ba36f690fa6ce584132dce3e2f26fbb89f87 (diff)
downloadbinutils-33b79214629c2b1b219e82bb34aed5fb03913634.zip
binutils-33b79214629c2b1b219e82bb34aed5fb03913634.tar.gz
binutils-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.
Diffstat (limited to 'gdb/opencl-lang.c')
-rw-r--r--gdb/opencl-lang.c28
1 files changed, 28 insertions, 0 deletions
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,