summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-08-06 10:14:59 +0000
committerDouglas Gregor <dgregor@apple.com>2010-08-06 10:14:59 +0000
commit59e8b3bd7bf2c9efc8d9b74e98eee13684cfc75b (patch)
tree48d7c964024ab9f0ba907fe6a5be74c0c6b8c60e /clang/lib/Sema/SemaExpr.cpp
parent249179cd732ca82bda2de128ac1eaab6159273e0 (diff)
downloadbcm5719-llvm-59e8b3bd7bf2c9efc8d9b74e98eee13684cfc75b.tar.gz
bcm5719-llvm-59e8b3bd7bf2c9efc8d9b74e98eee13684cfc75b.zip
Introduce implicit conversions between AltiVec vectors and GCC
vectors, from Anton Yartsev! llvm-svn: 110437
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 28b2e995375..46c5a65f75d 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -4731,13 +4731,18 @@ Sema::CheckAssignmentConstraints(QualType lhsType, QualType 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 &&
- 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 Compatible;
}
return Incompatible;
}
@@ -5012,6 +5017,13 @@ QualType Sema::CheckVectorOperands(SourceLocation Loc, Expr *&lex, Expr *&rex) {
}
}
+ // Handle the case of equivalent AltiVec and GCC vector types
+ if (lhsType->isVectorType() && rhsType->isVectorType() &&
+ Context.areCompatibleVectorTypes(lhsType, rhsType)) {
+ ImpCastExprToType(lex, rhsType, CastExpr::CK_BitCast);
+ return rhsType;
+ }
+
// Canonicalize the ExtVector to the LHS, remember if we swapped so we can
// swap back (so that we don't reverse the inputs to a subtract, for instance.
bool swapped = false;
OpenPOWER on IntegriCloud