diff options
author | Chris Lattner <sabre@nondot.org> | 2010-01-09 21:40:03 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-01-09 21:40:03 +0000 |
commit | dd36d328730d8c02915d0884541b45ec6ca0049d (patch) | |
tree | 5e5f93d9eb7ae26d7c94b81d6e327a64e4d97721 /lib/CodeGen/CGExprComplex.cpp | |
parent | 031421bc8f641dcfea110eda1492fe13e1292d1e (diff) |
refactor pre/postinc logic into CGF and require the caller to pass in the
lvalue to poke, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93075 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprComplex.cpp')
-rw-r--r-- | lib/CodeGen/CGExprComplex.cpp | 39 |
1 files changed, 4 insertions, 35 deletions
diff --git a/lib/CodeGen/CGExprComplex.cpp b/lib/CodeGen/CGExprComplex.cpp index be2239ffb6..5ec336ce79 100644 --- a/lib/CodeGen/CGExprComplex.cpp +++ b/lib/CodeGen/CGExprComplex.cpp @@ -145,7 +145,10 @@ public: // Operators. ComplexPairTy VisitPrePostIncDec(const UnaryOperator *E, - bool isInc, bool isPre); + bool isInc, bool isPre) { + LValue LV = CGF.EmitLValue(E->getSubExpr()); + return CGF.EmitComplexPrePostIncDec(E, LV, isInc, isPre); + } ComplexPairTy VisitUnaryPostDec(const UnaryOperator *E) { return VisitPrePostIncDec(E, false, false); } @@ -355,40 +358,6 @@ ComplexPairTy ComplexExprEmitter::EmitCast(Expr *Op, QualType DestTy) { return ComplexPairTy(Elt, llvm::Constant::getNullValue(Elt->getType())); } -ComplexPairTy ComplexExprEmitter::VisitPrePostIncDec(const UnaryOperator *E, - bool isInc, bool isPre) { - LValue LV = CGF.EmitLValue(E->getSubExpr()); - ComplexPairTy InVal = EmitLoadOfComplex(LV.getAddress(), - LV.isVolatileQualified()); - - llvm::Value *NextVal; - if (isa<llvm::IntegerType>(InVal.first->getType())) { - uint64_t AmountVal = isInc ? 1 : -1; - NextVal = llvm::ConstantInt::get(InVal.first->getType(), AmountVal, true); - - // Add the inc/dec to the real part. - NextVal = Builder.CreateAdd(InVal.first, NextVal, isInc ? "inc" : "dec"); - } else { - QualType ElemTy = E->getType()->getAs<ComplexType>()->getElementType(); - llvm::APFloat FVal(CGF.getContext().getFloatTypeSemantics(ElemTy), 1); - if (!isInc) - FVal.changeSign(); - NextVal = llvm::ConstantFP::get(CGF.getLLVMContext(), FVal); - - // Add the inc/dec to the real part. - NextVal = Builder.CreateFAdd(InVal.first, NextVal, isInc ? "inc" : "dec"); - } - - ComplexPairTy IncVal(NextVal, InVal.second); - - // Store the updated result through the lvalue. - EmitStoreOfComplex(IncVal, LV.getAddress(), LV.isVolatileQualified()); - - // If this is a postinc, return the value read from memory, otherwise use the - // updated value. - return isPre ? IncVal : InVal; -} - ComplexPairTy ComplexExprEmitter::VisitUnaryMinus(const UnaryOperator *E) { TestAndClearIgnoreReal(); TestAndClearIgnoreImag(); |