[cfe-dev] improved vector bool/pixel support
Anton Yartsev
anton.yartsev at gmail.com
Thu Aug 5 12:01:01 PDT 2010
On 05.08.2010 15:12, Douglas Gregor wrote:
> On Aug 5, 2010, at 1:52 AM, Anton Yartsev wrote:
>
>> Added code for an implicit conversion between GCC and AltiVec vectors to Sema. Also attached tests with the relaxed vector conversions turned off. Please review.
>>
> Index: lib/Sema/SemaExpr.cpp
> ===================================================================
> --- lib/Sema/SemaExpr.cpp (revision 110284)
> +++ lib/Sema/SemaExpr.cpp (working copy)
> @@ -4751,13 +4751,18 @@
> }
>
> if (lhsType->isVectorType() || rhsType->isVectorType()) {
> - // If we are allowing lax vector conversions, and LHS and RHS are both
> - // vectors, the total size only needs to be the same. This is a bitcast;
> - // no bits are changed but the result type is different.
> - if (getLangOptions().LaxVectorConversions&&
> - lhsType->isVectorType()&& rhsType->isVectorType()) {
> - if (Context.getTypeSize(lhsType) == Context.getTypeSize(rhsType))
> + if (lhsType->isVectorType()&& rhsType->isVectorType()) {
> + // If we are allowing lax vector conversions, and LHS and RHS are both
> + // vectors, the total size only needs to be the same. This is a bitcast;
> + // no bits are changed but the result type is different.
> + if (getLangOptions().LaxVectorConversions&&
> + (Context.getTypeSize(lhsType) == Context.getTypeSize(rhsType)))
> return IncompatibleVectors;
> +
> + // Allow assignments of an AltiVec vector type to an equivalent GCC
> + // vector type and vice versa
> + if (Context.areCompatibleVectorTypes(lhsType, rhsType))
> + return IncompatibleVectors;
> }
>
> I don't think that you want a warning when converting between AltiVec and GCC vector types, do you? If no, the "return IncompatibleVectors;" should be "return Compatible;".
>
> Why does the C++ test use __attribute__((overloadable))? Actually, why does the C test use it? It doesn't seem necessary in either case.
>
> It might make sense to test the ? : operator, which often gives us trouble with conversions.
>
> - Doug
Changed "return IncompatibleVectors" to "return Compatible".
Hmm.. The attribute is absolutely useless in both cases..
I used it in the C test to reach the IsVectorConversion() finction in
SemaOverloaded.cpp, but there should be at least two overloaded
candidates to reach the desired code.
Added "?:" operator to tests, no troubles.
--
Anton
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Altivec_GCC_compat.patch
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100805/38d72c34/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test.c
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100805/38d72c34/attachment.c>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test.cpp
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100805/38d72c34/attachment-0001.ksh>
More information about the cfe-dev
mailing list