diff options
author | Ken Werner <ken.werner@de.ibm.com> | 2010-10-08 16:50:55 +0000 |
---|---|---|
committer | Ken Werner <ken.werner@de.ibm.com> | 2010-10-08 16:50:55 +0000 |
commit | 3bdf2bbd3e87625fb26815d48e36fc7fb3656aca (patch) | |
tree | 8cdedd474e475a8c3e7400499b1bd70129574fd1 /gdb/valarith.c | |
parent | 1360ae660fd58c21cb036ed99a76686bd675eecb (diff) | |
download | gdb-3bdf2bbd3e87625fb26815d48e36fc7fb3656aca.zip gdb-3bdf2bbd3e87625fb26815d48e36fc7fb3656aca.tar.gz gdb-3bdf2bbd3e87625fb26815d48e36fc7fb3656aca.tar.bz2 |
gdb:
* valops.c (value_cast): Handle vector types.
* valarith.c (value_binop): Widen scalar to vector if appropriate.
gdb/testsuite:
* gdb.base/gnu_vector.c (ia, ib, fa, fb): New variables.
* gdb.base/gnu_vector.exp: Add tests for scalar to vector widening.
Diffstat (limited to 'gdb/valarith.c')
-rw-r--r-- | gdb/valarith.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/gdb/valarith.c b/gdb/valarith.c index d75fdd2..554c4ff 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -1435,14 +1435,34 @@ vector_binop (struct value *val1, struct value *val2, enum exp_opcode op) struct value * value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) { + struct value *val; struct type *type1 = check_typedef (value_type (arg1)); struct type *type2 = check_typedef (value_type (arg2)); - - if ((TYPE_CODE (type1) == TYPE_CODE_ARRAY && TYPE_VECTOR (type1)) - || (TYPE_CODE (type2) == TYPE_CODE_ARRAY && TYPE_VECTOR (type2))) - return vector_binop (arg1, arg2, op); + int t1_is_vec = (TYPE_CODE (type1) == TYPE_CODE_ARRAY + && TYPE_VECTOR (type1)); + int t2_is_vec = (TYPE_CODE (type2) == TYPE_CODE_ARRAY + && TYPE_VECTOR (type2)); + + if (!t1_is_vec && !t2_is_vec) + val = scalar_binop (arg1, arg2, op); + else if (t1_is_vec && t2_is_vec) + val = vector_binop (arg1, arg2, op); else - return scalar_binop (arg1, arg2, op); + { + /* Widen the scalar operand to a vector. */ + struct value **v = t1_is_vec ? &arg2 : &arg1; + struct type *t = t1_is_vec ? type2 : type1; + + if (TYPE_CODE (t) != TYPE_CODE_FLT + && TYPE_CODE (t) != TYPE_CODE_DECFLOAT + && !is_integral_type (t)) + error (_("Argument to operation not a number or boolean.")); + + *v = value_cast (t1_is_vec ? type1 : type2, *v); + val = vector_binop (arg1, arg2, op); + } + + return val; } /* Simulate the C operator ! -- return 1 if ARG1 contains zero. */ |