[cfe-commits] r41345 - /cfe/trunk/CodeGen/CGComplexExpr.cpp
Chris Lattner
sabre at nondot.org
Thu Aug 23 16:46:33 PDT 2007
Author: lattner
Date: Thu Aug 23 18:46:33 2007
New Revision: 41345
URL: http://llvm.org/viewvc/llvm-project?rev=41345&view=rev
Log:
implement complex subtraction
Modified:
cfe/trunk/CodeGen/CGComplexExpr.cpp
Modified: cfe/trunk/CodeGen/CGComplexExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGComplexExpr.cpp?rev=41345&r1=41344&r2=41345&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CGComplexExpr.cpp (original)
+++ cfe/trunk/CodeGen/CGComplexExpr.cpp Thu Aug 23 18:46:33 2007
@@ -106,7 +106,8 @@
ComplexPairTy VisitBinMul (const BinaryOperator *E);
ComplexPairTy VisitBinAdd (const BinaryOperator *E);
- // FIXME: sub/div/rem
+ ComplexPairTy VisitBinSub (const BinaryOperator *E);
+ // FIXME: div/rem
// GCC rejects and/or/xor for integer complex.
// Logical and/or always return int, never complex.
@@ -225,6 +226,17 @@
return ComplexPairTy(ResR, ResI);
}
+ComplexPairTy ComplexExprEmitter::VisitBinSub(const BinaryOperator *E) {
+ ComplexPairTy LHS = Visit(E->getLHS());
+ ComplexPairTy RHS = Visit(E->getRHS());
+
+ llvm::Value *ResR = Builder.CreateSub(LHS.first, RHS.first, "sub.r");
+ llvm::Value *ResI = Builder.CreateSub(LHS.second, RHS.second, "sub.i");
+
+ return ComplexPairTy(ResR, ResI);
+}
+
+
ComplexPairTy ComplexExprEmitter::VisitBinMul(const BinaryOperator *E) {
ComplexPairTy LHS = Visit(E->getLHS());
ComplexPairTy RHS = Visit(E->getRHS());
More information about the cfe-commits
mailing list