]> granicus.if.org Git - clang/commitdiff
further apfloat'ize the front-end, allowing codegen to pass
authorChris Lattner <sabre@nondot.org>
Sat, 22 Sep 2007 18:47:25 +0000 (18:47 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 22 Sep 2007 18:47:25 +0000 (18:47 +0000)
APFloat straight through to LLVM now.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42236 91177308-0d34-0410-b5e6-96231b3b80d8

AST/Expr.cpp
AST/StmtDumper.cpp
AST/StmtPrinter.cpp
CodeGen/CGExprScalar.cpp
include/clang/AST/Expr.h

index e5a128247eecdd0960be5d3aff960beb59b6e180..01c563bdc2c86591950e641967dfd61db2afe4ee 100644 (file)
@@ -741,7 +741,7 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx,
     
     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();
index 09909d841945ae5f1d3da18f4c95988f5da22a3f..6f25e129a3c4392f1c7e421c6729d167b61a5683 100644 (file)
@@ -307,7 +307,7 @@ void StmtDumper::VisitIntegerLiteral(IntegerLiteral *Node) {
 }
 void StmtDumper::VisitFloatingLiteral(FloatingLiteral *Node) {
   DumpExpr(Node);
-  fprintf(F, " %f", Node->getValue());
+  fprintf(F, " %f", Node->getValueAsDouble());
 }
 
 void StmtDumper::VisitStringLiteral(StringLiteral *Str) {
index 11dd2ef7677b96d922c1457bb1da8953dd500cb2..f878ca8137282e4114397502c500ec029e192467 100644 (file)
@@ -408,7 +408,7 @@ void StmtPrinter::VisitIntegerLiteral(IntegerLiteral *Node) {
 }
 void StmtPrinter::VisitFloatingLiteral(FloatingLiteral *Node) {
   // FIXME: print value more precisely.
-  OS << Node->getValue();
+  OS << Node->getValueAsDouble();
 }
 
 void StmtPrinter::VisitImaginaryLiteral(ImaginaryLiteral *Node) {
index 319ca82bf89ed5bbe832495a61b7aae57c139ca6..155cf3b31341cbc11ae188356d283fc03e4e14e5 100644 (file)
@@ -93,13 +93,7 @@ public:
     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());
index 54228696eff31b8e8f1a408bd1e5862ad267b537..94c02aa3e99b2840bc535823f58e7cf18b14b69b 100644 (file)
@@ -223,7 +223,9 @@ public:
   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