This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] GNU vector unop support

On Thursday, October 07, 2010 1:26:59 am Joel Brobecker wrote:
> > > One question: Is it possible to have a non-array vector type?
> > > In other words, can we just check for TYPE_VECTOR (type) instead
> > > of TYPE_CODE (type) and TYPE_VECTOR (type)?
> > 
> > No, not that I'm aware of. Even a GNU Vector with a single element
> > only is an array underneath. My understanding is that querying the
> > flag_vector is only legal if the type is an array.
> I feel that this makes the check for the TYPE_CODE a little superfluous.
> But at the same time, the code handling vectors then assumes that the
> underlying type is an array.

Ok, I see your point. : ) It seems my statement was incorrect. I missed that 
various backends (e.g. i386-tdep.c:i386_mmx_type or rs6000-
tdep.c:rs6000_builtin_type_vec64) create vectors with TYPE_CODE_UNION for 
their vector registers. Therefore checking the vector flag only may not always 
work as expected.

> > ChangeLog:
> > 
> > 2010-10-04  Ken Werner  <>
> > 
> > 	* valarith.c (value_pos, value_neg, value_complement): Handle
> > 	vector types.
> > 	* valops.c (value_one): Likewise.
> > 
> > testsuite/ChangeLog:
> > 
> > 2010-10-04  Ken Werner  <>
> > 
> > 	* gdb.base/gnu_vector.exp: Add unary operator tests.
> This is OK.

Thanks. I'd prefer to wait with the commit until the lval-issue gets resolved.

> If it was just me, I'd probably wrap the checks for vector types
> inside a function (such as type_is_vector or vector_type_p), with
> a comment explaining the reason why we check for the TYPE_CODE
> despite the fact that, normally, all types with the `vector' flag
> should be arrays.  (this is just a soft suggestion, and to be treated
> as a followup patch, if not ignored)

It would clearly improve the readability of the source code. Giving vectors a 
distinct type code may also be an option.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]