From db68f1bc5a49d4c847543db8245f16466a8889a6 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 26 Aug 2007 03:51:12 +0000 Subject: [PATCH] implement codegen for complex literals. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41414 91177308-0d34-0410-b5e6-96231b3b80d8 --- CodeGen/CGExprComplex.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CodeGen/CGExprComplex.cpp b/CodeGen/CGExprComplex.cpp index b88133e4a4..ce676e93b8 100644 --- a/CodeGen/CGExprComplex.cpp +++ b/CodeGen/CGExprComplex.cpp @@ -68,7 +68,8 @@ public: } ComplexPairTy VisitExpr(Expr *S); ComplexPairTy VisitParenExpr(ParenExpr *PE) { return Visit(PE->getSubExpr());} - + ComplexPairTy VisitImaginaryLiteral(ImaginaryLiteral *IL); + // l-values. ComplexPairTy VisitDeclRefExpr(Expr *E) { return EmitLoadOfLValue(E); } ComplexPairTy VisitArraySubscriptExpr(Expr *E) { return EmitLoadOfLValue(E); } @@ -170,6 +171,12 @@ ComplexPairTy ComplexExprEmitter::VisitExpr(Expr *E) { return ComplexPairTy(U, U); } +ComplexPairTy ComplexExprEmitter::VisitImaginaryLiteral(ImaginaryLiteral *IL) { + llvm::Value *Imag = CGF.EmitScalarExpr(IL->getSubExpr()); + return ComplexPairTy(llvm::Constant::getNullValue(Imag->getType()), Imag); +} + + ComplexPairTy ComplexExprEmitter::VisitCallExpr(const CallExpr *E) { llvm::Value *AggPtr = CGF.EmitCallExpr(E).getAggregateAddr(); return EmitLoadOfComplex(AggPtr, false);