[cfe-commits] r41376 - in /cfe/trunk: CodeGen/CGExprScalar.cpp test/CodeGen/complex.c
Chris Lattner
sabre at nondot.org
Fri Aug 24 14:20:17 PDT 2007
Author: lattner
Date: Fri Aug 24 16:20:17 2007
New Revision: 41376
URL: http://llvm.org/viewvc/llvm-project?rev=41376&view=rev
Log:
implement codegen for real/imag. TODO: imag of non-complex.
Modified:
cfe/trunk/CodeGen/CGExprScalar.cpp
cfe/trunk/test/CodeGen/complex.c
Modified: cfe/trunk/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGExprScalar.cpp?rev=41376&r1=41375&r2=41376&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/CodeGen/CGExprScalar.cpp Fri Aug 24 16:20:17 2007
@@ -147,7 +147,8 @@
}
Value *EmitSizeAlignOf(QualType TypeToSize, QualType RetType,
bool isSizeOf);
- // FIXME: Real,Imag.
+ Value *VisitUnaryReal (const UnaryOperator *E);
+ Value *VisitUnaryImag (const UnaryOperator *E);
Value *VisitUnaryExtension(const UnaryOperator *E) {
return Visit(E->getSubExpr());
}
@@ -363,7 +364,7 @@
/// EmitSizeAlignOf - Return the size or alignment of the 'TypeToSize' type as
/// an integer (RetType).
Value *ScalarExprEmitter::EmitSizeAlignOf(QualType TypeToSize,
- QualType RetType,bool isSizeOf){
+ QualType RetType,bool isSizeOf){
/// FIXME: This doesn't handle VLAs yet!
std::pair<uint64_t, unsigned> Info =
CGF.getContext().getTypeInfo(TypeToSize, SourceLocation());
@@ -377,6 +378,22 @@
return llvm::ConstantInt::get(llvm::APInt(ResultWidth, Val));
}
+Value *ScalarExprEmitter::VisitUnaryReal(const UnaryOperator *E) {
+ Expr *Op = E->getSubExpr();
+ if (Op->getType()->isComplexType())
+ return CGF.EmitComplexExpr(Op).first;
+ return Visit(Op);
+}
+Value *ScalarExprEmitter::VisitUnaryImag(const UnaryOperator *E) {
+ Expr *Op = E->getSubExpr();
+ if (Op->getType()->isComplexType())
+ return CGF.EmitComplexExpr(Op).second;
+
+ // FIXME: does this evaluate the subexpr??
+ return 0; // FIXME: Return zero of the right int/fp type.
+}
+
+
//===----------------------------------------------------------------------===//
// Binary Operators
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/test/CodeGen/complex.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/complex.c?rev=41376&r1=41375&r2=41376&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/complex.c (original)
+++ cfe/trunk/test/CodeGen/complex.c Fri Aug 24 16:20:17 2007
@@ -26,4 +26,6 @@
g1 = g1 - g2;
g1 = g1 * g2;
g1 = +-~g1;
+
+ double Gr = __real g1;
}
More information about the cfe-commits
mailing list