diff options
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 be2239f..5ec336c 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(); |