[cfe-dev] improved vector bool/pixel support
Douglas Gregor
dgregor at apple.com
Thu Aug 5 04:12:48 PDT 2010
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
More information about the cfe-dev
mailing list