aboutsummaryrefslogtreecommitdiff
path: root/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
commitd62ca370b03b8c6ad58002d3399383baf744e32b (patch)
treee805e191aff3cb11f988da468e4b84a594d29562 /lib/AST/ExprConstant.cpp
parent1e821e9eba7c48f375c7cb5c9e19c489e17ec58a (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145981 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ExprConstant.cpp')
-rw-r--r--lib/AST/ExprConstant.cpp32
1 files changed, 1 insertions, 31 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index 438bef5de8..6a290a6c83 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/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);
}