This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch] Scalar to vector widening
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: ken at linux dot vnet dot ibm dot com (Ken Werner)
- Cc: gdb-patches at sourceware dot org
- Date: Tue, 5 Oct 2010 20:08:07 +0200 (CEST)
- Subject: Re: [patch] Scalar to vector widening
Ken Werner wrote:
> This patch adds support for widening scalars to vectors to allow binary
> operations with mixed operand types. It mainly extends the binop_promote
> function to call widen_scalar_to_vector if required. No regressions on i686-*-
> linux-gnu.
> * value.h (widen_scalar_to_vector): Declare.
> * valops.c (widen_scalar_to_vector): New function.
> (value_assign): Add call to widen_scalar_to_vector.
> * eval.c (binop_promote, evaluate_subexp_standard)
> <BINOP_ASSIGN_MODIFY, BINOP_LSH, BINOP_RSH>: Likewise.
I've been thinking about this a bit. One piece that's missing here
is support for explicit casts. For OpenCL vectors (and that seems
like a useful extension in general), you can use an explicit type
cast operation to widen a scalar value to a vector, e.g. like
float f = 1.0f;
float4 v = (float4) f;
I think it would be better to change your patch to perform the
operation you're doing in the new widen_scalar_to_vector routine
simply in value_cast instead (if the source is a scalar and the
target type a vector type).
This would support the above-mentioned OpenCL language feature,
and it would also simplify implict widening for operators. Note
that e.g. both binop_promote and value_assign already call
value_cast in their regular operation; it's just a matter of
using the appropriate target type ...
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com