[cfe-commits] r42236 - in /cfe/trunk: AST/Expr.cpp AST/StmtDumper.cpp AST/StmtPrinter.cpp CodeGen/CGExprScalar.cpp include/clang/AST/Expr.h

Chris Lattner sabre at nondot.org
Sat Sep 22 11:47:26 PDT 2007


Author: lattner
Date: Sat Sep 22 13:47:25 2007
New Revision: 42236

URL: http://llvm.org/viewvc/llvm-project?rev=42236&view=rev
Log:
further apfloat'ize the front-end, allowing codegen to pass 
APFloat straight through to LLVM now.

Modified:
    cfe/trunk/AST/Expr.cpp
    cfe/trunk/AST/StmtDumper.cpp
    cfe/trunk/AST/StmtPrinter.cpp
    cfe/trunk/CodeGen/CGExprScalar.cpp
    cfe/trunk/include/clang/AST/Expr.h

Modified: cfe/trunk/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Expr.cpp?rev=42236&r1=42235&r2=42236&view=diff

==============================================================================
--- cfe/trunk/AST/Expr.cpp (original)
+++ cfe/trunk/AST/Expr.cpp Sat Sep 22 13:47:25 2007
@@ -741,7 +741,7 @@
     
     if (const FloatingLiteral *FL = dyn_cast<FloatingLiteral>(Operand)) {
       // FIXME: Evaluate this correctly!
-      Result = (int)FL->getValue();
+      Result = (int)FL->getValueAsDouble();
       break;
     }
     if (Loc) *Loc = Operand->getLocStart();

Modified: cfe/trunk/AST/StmtDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/StmtDumper.cpp?rev=42236&r1=42235&r2=42236&view=diff

==============================================================================
--- cfe/trunk/AST/StmtDumper.cpp (original)
+++ cfe/trunk/AST/StmtDumper.cpp Sat Sep 22 13:47:25 2007
@@ -307,7 +307,7 @@
 }
 void StmtDumper::VisitFloatingLiteral(FloatingLiteral *Node) {
   DumpExpr(Node);
-  fprintf(F, " %f", Node->getValue());
+  fprintf(F, " %f", Node->getValueAsDouble());
 }
 
 void StmtDumper::VisitStringLiteral(StringLiteral *Str) {

Modified: cfe/trunk/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/StmtPrinter.cpp?rev=42236&r1=42235&r2=42236&view=diff

==============================================================================
--- cfe/trunk/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/AST/StmtPrinter.cpp Sat Sep 22 13:47:25 2007
@@ -408,7 +408,7 @@
 }
 void StmtPrinter::VisitFloatingLiteral(FloatingLiteral *Node) {
   // FIXME: print value more precisely.
-  OS << Node->getValue();
+  OS << Node->getValueAsDouble();
 }
 
 void StmtPrinter::VisitImaginaryLiteral(ImaginaryLiteral *Node) {

Modified: cfe/trunk/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGExprScalar.cpp?rev=42236&r1=42235&r2=42236&view=diff

==============================================================================
--- cfe/trunk/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/CodeGen/CGExprScalar.cpp Sat Sep 22 13:47:25 2007
@@ -93,13 +93,7 @@
     return llvm::ConstantInt::get(E->getValue());
   }
   Value *VisitFloatingLiteral(const FloatingLiteral *E) {
-    double V = E->getValue();
-    // FIXME: Change this when FloatingLiteral uses an APFloat internally.
-    const llvm::Type *Ty = ConvertType(E->getType());
-    if (Ty == llvm::Type::FloatTy)
-      return llvm::ConstantFP::get(Ty, llvm::APFloat((float)V));
-    assert(Ty == llvm::Type::DoubleTy && "Unknown float type!");
-    return llvm::ConstantFP::get(Ty, llvm::APFloat((double)V));
+    return llvm::ConstantFP::get(ConvertType(E->getType()), E->getValue());
   }
   Value *VisitCharacterLiteral(const CharacterLiteral *E) {
     return llvm::ConstantInt::get(ConvertType(E->getType()), E->getValue());

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=42236&r1=42235&r2=42236&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Sat Sep 22 13:47:25 2007
@@ -223,7 +223,9 @@
   FloatingLiteral(const llvm::APFloat &V, QualType Type, SourceLocation L)
     : Expr(FloatingLiteralClass, Type), Value(V), Loc(L) {} 
 
-  float getValue() const { 
+  const llvm::APFloat &getValue() const { return Value; }
+
+  double getValueAsDouble() const { 
     if (cast<BuiltinType>(getType())->getKind() == BuiltinType::Float)
       return Value.convertToFloat();
     else





More information about the cfe-commits mailing list