Some minor fixes for complex IRGen.

llvm-svn: 67501
This commit is contained in:
Eli Friedman 2009-03-23 04:08:46 +00:00
parent 3138f7a781
commit 31a20d680a
1 changed files with 16 additions and 23 deletions

View File

@ -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;
}