diff options
author | ed <ed@FreeBSD.org> | 2009-06-27 10:45:02 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2009-06-27 10:45:02 +0000 |
commit | c1ff020ff2d3e7ba86f7ab986ac7569c34f2ab1a (patch) | |
tree | 2c5a83521a20c02e7805581a174008aa9bc23579 /lib/AST/ExprConstant.cpp | |
parent | 14660dbe9881f68a6cc2b9f014e1fb7b7228bca4 (diff) | |
download | FreeBSD-src-c1ff020ff2d3e7ba86f7ab986ac7569c34f2ab1a.zip FreeBSD-src-c1ff020ff2d3e7ba86f7ab986ac7569c34f2ab1a.tar.gz |
Import Clang r74383.
Diffstat (limited to 'lib/AST/ExprConstant.cpp')
-rw-r--r-- | lib/AST/ExprConstant.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 4815ae5..9d76592 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -486,12 +486,28 @@ static bool EvaluateVector(const Expr* E, APValue& Result, EvalInfo &Info) { APValue VectorExprEvaluator::VisitCastExpr(const CastExpr* E) { const Expr* SE = E->getSubExpr(); + QualType SETy = SE->getType(); + APValue Result = APValue(); - // Check for vector->vector bitcast. - if (SE->getType()->isVectorType()) + // Check for vector->vector bitcast and scalar->vector splat. + if (SETy->isVectorType()) { return this->Visit(const_cast<Expr*>(SE)); + } else if (SETy->isIntegerType()) { + APSInt IntResult; + if (EvaluateInteger(SE, IntResult, Info)) + Result = APValue(IntResult); + } else if (SETy->isRealFloatingType()) { + APFloat F(0.0); + if (EvaluateFloat(SE, F, Info)) + Result = APValue(F); + } - return APValue(); + if (Result.isInt() || Result.isFloat()) { + unsigned NumElts = E->getType()->getAsVectorType()->getNumElements(); + llvm::SmallVector<APValue, 4> Elts(NumElts, Result); + Result = APValue(&Elts[0], Elts.size()); + } + return Result; } APValue |