diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-12-28 19:48:30 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-12-28 19:48:30 +0000 |
commit | 80d4b55db94db2172a04617d1a80feca6bbcea5c (patch) | |
tree | 04bad08faed06c04c4580572a8de2b877768a108 /lib/CodeGen/CGExprScalar.cpp | |
parent | 0e743b1582d53d3ebb2074da881e00bfb759f250 (diff) |
Small refactoring and simplification of constant evaluation and some of its
clients. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147318 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprScalar.cpp')
-rw-r--r-- | lib/CodeGen/CGExprScalar.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index e7620af24d..c2aec36ee8 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -801,13 +801,13 @@ Value *ScalarExprEmitter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) { return Builder.CreateShuffleVector(V1, V2, SV, "shuffle"); } Value *ScalarExprEmitter::VisitMemberExpr(MemberExpr *E) { - Expr::EvalResult Result; - if (E->EvaluateAsRValue(Result, CGF.getContext()) && Result.Val.isInt()) { + llvm::APSInt Value; + if (E->EvaluateAsInt(Value, CGF.getContext(), Expr::SE_AllowSideEffects)) { if (E->isArrow()) CGF.EmitScalarExpr(E->getBase()); else EmitLValue(E->getBase()); - return Builder.getInt(Result.Val.getInt()); + return Builder.getInt(Value); } // Emit debug info for aggregate now, if it was delayed to reduce @@ -1466,9 +1466,9 @@ Value *ScalarExprEmitter::VisitUnaryLNot(const UnaryOperator *E) { Value *ScalarExprEmitter::VisitOffsetOfExpr(OffsetOfExpr *E) { // Try folding the offsetof to a constant. - Expr::EvalResult EvalResult; - if (E->EvaluateAsRValue(EvalResult, CGF.getContext())) - return Builder.getInt(EvalResult.Val.getInt()); + llvm::APSInt Value; + if (E->EvaluateAsInt(Value, CGF.getContext())) + return Builder.getInt(Value); // Loop over the components of the offsetof to compute the value. unsigned n = E->getNumComponents(); @@ -1589,9 +1589,7 @@ ScalarExprEmitter::VisitUnaryExprOrTypeTraitExpr( // If this isn't sizeof(vla), the result must be constant; use the constant // folding logic so we don't have to duplicate it here. - Expr::EvalResult Result; - E->EvaluateAsRValue(Result, CGF.getContext()); - return Builder.getInt(Result.Val.getInt()); + return Builder.getInt(E->EvaluateKnownConstInt(CGF.getContext())); } Value *ScalarExprEmitter::VisitUnaryReal(const UnaryOperator *E) { |