aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-03-23 04:08:46 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-03-23 04:08:46 +0000
commitc110c545810670871f54d0e999b5384ca0d6519d (patch)
tree41e4dcc7ff9fa4358510078b0266d7b305221d5c
parentf52bbeb1ce55aa10b4519024258b8962777fa8d4 (diff)
Some minor fixes for complex IRGen.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67501 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/CGExprComplex.cpp39
1 files changed, 16 insertions, 23 deletions
diff --git a/lib/CodeGen/CGExprComplex.cpp b/lib/CodeGen/CGExprComplex.cpp
index e970ba2561..3e4410611c 100644
--- a/lib/CodeGen/CGExprComplex.cpp
+++ b/lib/CodeGen/CGExprComplex.cpp
@@ -47,8 +47,7 @@ public:
/// 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 @@ ComplexPairTy ComplexExprEmitter::EmitCast(Expr *Op, QualType DestTy) {
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::EmitCast(Expr *Op, QualType DestTy) {
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 ComplexExprEmitter::VisitPrePostIncDec(const UnaryOperator *E,
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 @@ EmitCompoundAssign(const CompoundAssignOperator *E,
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 @@ EmitCompoundAssign(const CompoundAssignOperator *E,
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 @@ ComplexPairTy ComplexExprEmitter::VisitBinAssign(const BinaryOperator *E) {
LValue LHS = CGF.EmitLValue(E->getLHS());
// Store into it.
- // FIXME: Volatility!
- EmitStoreOfComplex(Val, LHS.getAddress(), false);
+ EmitStoreOfComplex(Val, LHS.getAddress(), LHS.isVolatileQualified());
return Val;
}