summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ExprConstant.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2011-12-06 22:44:34 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2011-12-06 22:44:34 +0000
commit161f09abd7df2c92f994bb0e41f4fde14b235c7e (patch)
tree26e8fa791158f25250ae6948e8d0c41dae506197 /clang/lib/AST/ExprConstant.cpp
parentcc6bfa8e79fce0143f48568193b3584e9f189556 (diff)
downloadbcm5719-llvm-161f09abd7df2c92f994bb0e41f4fde14b235c7e.tar.gz
bcm5719-llvm-161f09abd7df2c92f994bb0e41f4fde14b235c7e.zip
Move vector bitcast handling in constant expressions from the expression
evaluator into constant initializer handling / IRGen. The practical consequence of this is that the bitcast now lives in the constant's definition, rather than in its uses. The code in the constant expression evaluator was producing vectors of the wrong type and size (and possibly of the wrong value for a big-endian int-to-vector bitcast). We were getting away with this only because we don't yet support constant-folding of any expressions which inspect vector values. llvm-svn: 145981
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r--clang/lib/AST/ExprConstant.cpp32
1 files changed, 1 insertions, 31 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 438bef5de87..6a290a6c834 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -2502,11 +2502,9 @@ static bool EvaluateVector(const Expr* E, APValue& Result, EvalInfo &Info) {
bool VectorExprEvaluator::VisitCastExpr(const CastExpr* E) {
const VectorType *VTy = E->getType()->castAs<VectorType>();
- QualType EltTy = VTy->getElementType();
unsigned NElts = VTy->getNumElements();
- unsigned EltWidth = Info.Ctx.getTypeSize(EltTy);
- const Expr* SE = E->getSubExpr();
+ const Expr *SE = E->getSubExpr();
QualType SETy = SE->getType();
switch (E->getCastKind()) {
@@ -2530,34 +2528,6 @@ bool VectorExprEvaluator::VisitCastExpr(const CastExpr* E) {
SmallVector<APValue, 4> Elts(NElts, Val);
return Success(Elts, E);
}
- case CK_BitCast: {
- // FIXME: this is wrong for any cast other than a no-op cast.
- if (SETy->isVectorType())
- return Visit(SE);
-
- if (!SETy->isIntegerType())
- return Error(E);
-
- APSInt Init;
- if (!EvaluateInteger(SE, Init, Info))
- return Error(E);
-
- assert((EltTy->isIntegerType() || EltTy->isRealFloatingType()) &&
- "Vectors must be composed of ints or floats");
-
- SmallVector<APValue, 4> Elts;
- for (unsigned i = 0; i != NElts; ++i) {
- APSInt Tmp = Init.extOrTrunc(EltWidth);
-
- if (EltTy->isIntegerType())
- Elts.push_back(APValue(Tmp));
- else
- Elts.push_back(APValue(APFloat(Tmp)));
-
- Init >>= EltWidth;
- }
- return Success(Elts, E);
- }
default:
return ExprEvaluatorBaseTy::VisitCastExpr(E);
}
OpenPOWER on IntegriCloud