[cfe-commits] r41464 - /cfe/trunk/CodeGen/CGExprScalar.cpp
Chris Lattner
sabre at nondot.org
Sun Aug 26 15:37:41 PDT 2007
Author: lattner
Date: Sun Aug 26 17:37:40 2007
New Revision: 41464
URL: http://llvm.org/viewvc/llvm-project?rev=41464&view=rev
Log:
Implement compound assignment operators whose LHS is scalar but RHS is complex.
Modified:
cfe/trunk/CodeGen/CGExprScalar.cpp
Modified: cfe/trunk/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGExprScalar.cpp?rev=41464&r1=41463&r2=41464&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/CodeGen/CGExprScalar.cpp Sun Aug 26 17:37:40 2007
@@ -554,21 +554,31 @@
// Load the LHS and RHS operands.
LValue LHSLV = EmitLValue(E->getLHS());
OpInfo.LHS = EmitLoadOfLValue(LHSLV, LHSTy);
+
+ // Determine the computation type. If the RHS is complex, then this is one of
+ // the add/sub/mul/div operators. All of these operators can be computed in
+ // with just their real component even though the computation domain really is
+ // complex.
+ QualType ComputeType = E->getComputationType();
- // FIXME: It is possible for the RHS to be complex.
- OpInfo.RHS = Visit(E->getRHS());
+ // If the computation type is complex, then the RHS is complex. Emit the RHS.
+ if (const ComplexType *CT = ComputeType->getAsComplexType()) {
+ ComputeType = CT->getElementType();
+
+ // Emit the RHS, only keeping the real component.
+ OpInfo.RHS = CGF.EmitComplexExpr(E->getRHS()).first;
+ RHSTy = RHSTy->getAsComplexType()->getElementType();
+ } else {
+ // Otherwise the RHS is a simple scalar value.
+ OpInfo.RHS = Visit(E->getRHS());
+ }
// Convert the LHS/RHS values to the computation type.
- QualType ComputeType = E->getComputationType();
-
- // FIXME: it's possible for the computation type to be complex if the RHS
- // is complex. Handle this!
OpInfo.LHS = EmitScalarConversion(OpInfo.LHS, LHSTy, ComputeType);
// Do not merge types for -= where the LHS is a pointer.
if (E->getOpcode() != BinaryOperator::SubAssign ||
!E->getLHS()->getType()->isPointerType()) {
- // FIXME: the computation type may be complex.
OpInfo.RHS = EmitScalarConversion(OpInfo.RHS, RHSTy, ComputeType);
}
OpInfo.Ty = ComputeType;
More information about the cfe-commits
mailing list