[cfe-commits] r67501 - /cfe/trunk/lib/CodeGen/CGExprComplex.cpp
Eli Friedman
eli.friedman at gmail.com
Sun Mar 22 21:08:48 PDT 2009
Author: efriedma
Date: Sun Mar 22 23:08:46 2009
New Revision: 67501
URL: http://llvm.org/viewvc/llvm-project?rev=67501&view=rev
Log:
Some minor fixes for complex IRGen.
Modified:
cfe/trunk/lib/CodeGen/CGExprComplex.cpp
Modified: cfe/trunk/lib/CodeGen/CGExprComplex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprComplex.cpp?rev=67501&r1=67500&r2=67501&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprComplex.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprComplex.cpp Sun Mar 22 23:08:46 2009
@@ -47,8 +47,7 @@
/// and returns the result.
ComplexPairTy EmitLoadOfLValue(const Expr *E) {
LValue LV = CGF.EmitLValue(E);
- // FIXME: Volatile
- return EmitLoadOfComplex(LV.getAddress(), false);
+ return EmitLoadOfComplex(LV.getAddress(), LV.isVolatileQualified());
}
/// EmitLoadOfComplex - Given a pointer to a complex value, emit code to load
@@ -285,7 +284,7 @@
return EmitComplexToComplexCast(Visit(Op), Op->getType(), DestTy);
// C99 6.3.1.7: When a value of real type is converted to a complex type, the
- // real part of the complex result value is determined by the rules of
+ // real part of the complex result value is determined by the rules of
// conversion to the corresponding real type and the imaginary part of the
// complex result value is a positive zero or an unsigned zero.
llvm::Value *Elt = CGF.EmitScalarExpr(Op);
@@ -301,23 +300,18 @@
ComplexPairTy ComplexExprEmitter::VisitPrePostIncDec(const UnaryOperator *E,
bool isInc, bool isPre) {
LValue LV = CGF.EmitLValue(E->getSubExpr());
- // FIXME: Handle volatile!
- ComplexPairTy InVal = EmitLoadOfComplex(LV.getAddress(), false);
-
- uint64_t AmountVal = isInc ? 1 : -1;
+ ComplexPairTy InVal = EmitLoadOfComplex(LV.getAddress(), LV.isVolatileQualified());
llvm::Value *NextVal;
- if (isa<llvm::IntegerType>(InVal.first->getType()))
- NextVal = llvm::ConstantInt::get(InVal.first->getType(), AmountVal);
- else if (InVal.first->getType() == llvm::Type::FloatTy)
- // FIXME: Handle long double.
- NextVal =
- llvm::ConstantFP::get(llvm::APFloat(static_cast<float>(AmountVal)));
- else {
- // FIXME: Handle long double.
- assert(InVal.first->getType() == llvm::Type::DoubleTy);
- NextVal =
- llvm::ConstantFP::get(llvm::APFloat(static_cast<double>(AmountVal)));
+ if (isa<llvm::IntegerType>(InVal.first->getType())) {
+ uint64_t AmountVal = isInc ? 1 : -1;
+ NextVal = llvm::ConstantInt::get(InVal.first->getType(), AmountVal, true);
+ } else {
+ QualType ElemTy = E->getType()->getAsComplexType()->getElementType();
+ llvm::APFloat FVal(CGF.getContext().getFloatTypeSemantics(ElemTy), 1);
+ if (!isInc)
+ FVal.changeSign();
+ NextVal = llvm::ConstantFP::get(FVal);
}
// Add the inc/dec to the real part.
@@ -326,7 +320,7 @@
ComplexPairTy IncVal(NextVal, InVal.second);
// Store the updated result through the lvalue.
- EmitStoreOfComplex(IncVal, LV.getAddress(), false); /* FIXME: Volatile */
+ EmitStoreOfComplex(IncVal, LV.getAddress(), LV.isVolatileQualified());
// If this is a postinc, return the value read from memory, otherwise use the
// updated value.
@@ -428,7 +422,7 @@
OpInfo.Ty = E->getComputationType();
// We know the LHS is a complex lvalue.
- OpInfo.LHS = EmitLoadOfComplex(LHSLV.getAddress(), false);// FIXME: Volatile.
+ OpInfo.LHS = EmitLoadOfComplex(LHSLV.getAddress(), LHSLV.isVolatileQualified());
OpInfo.LHS = EmitComplexToComplexCast(OpInfo.LHS, LHSTy, OpInfo.Ty);
// It is possible for the RHS to be complex or scalar.
@@ -441,7 +435,7 @@
Result = EmitComplexToComplexCast(Result, OpInfo.Ty, LHSTy);
// Store the result value into the LHS lvalue.
- EmitStoreOfComplex(Result, LHSLV.getAddress(), false); // FIXME: VOLATILE
+ EmitStoreOfComplex(Result, LHSLV.getAddress(), LHSLV.isVolatileQualified());
return Result;
}
@@ -456,8 +450,7 @@
LValue LHS = CGF.EmitLValue(E->getLHS());
// Store into it.
- // FIXME: Volatility!
- EmitStoreOfComplex(Val, LHS.getAddress(), false);
+ EmitStoreOfComplex(Val, LHS.getAddress(), LHS.isVolatileQualified());
return Val;
}
More information about the cfe-commits
mailing list