[cfe-commits] r41247 - /cfe/trunk/CodeGen/CGComplexExpr.cpp
Chris Lattner
sabre at nondot.org
Tue Aug 21 13:08:24 PDT 2007
Author: lattner
Date: Tue Aug 21 15:08:23 2007
New Revision: 41247
URL: http://llvm.org/viewvc/llvm-project?rev=41247&view=rev
Log:
implement codegen for complex unary +/-
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=41247&r1=41246&r2=41247&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CGComplexExpr.cpp (original)
+++ cfe/trunk/CodeGen/CGComplexExpr.cpp Tue Aug 21 15:08:23 2007
@@ -74,7 +74,10 @@
ComplexPairTy VisitArraySubscriptExpr(Expr *E) { return EmitLoadOfLValue(E); }
// Operators.
- // case Expr::UnaryOperatorClass:
+ ComplexPairTy VisitUnaryPlus (const UnaryOperator *E) {
+ return Visit(E->getSubExpr());
+ }
+ ComplexPairTy VisitUnaryMinus (const UnaryOperator *E);
// case Expr::ImplicitCastExprClass:
// case Expr::CastExprClass:
// case Expr::CallExprClass:
@@ -143,6 +146,14 @@
return ComplexPairTy(U, U);
}
+ComplexPairTy ComplexExprEmitter::VisitUnaryMinus(const UnaryOperator *E) {
+ ComplexPairTy Op = Visit(E->getSubExpr());
+ llvm::Value *ResR = Builder.CreateNeg(Op.first, "neg.r");
+ llvm::Value *ResI = Builder.CreateNeg(Op.second, "neg.i");
+ return ComplexPairTy(ResR, ResI);
+}
+
+
ComplexPairTy ComplexExprEmitter::VisitBinAdd(const BinaryOperator *E) {
ComplexPairTy LHS = Visit(E->getLHS());
ComplexPairTy RHS = Visit(E->getRHS());
More information about the cfe-commits
mailing list