]> granicus.if.org Git - clang/commitdiff
make float format handling more regular.
authorChris Lattner <sabre@nondot.org>
Sat, 8 Mar 2008 08:59:43 +0000 (08:59 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 8 Mar 2008 08:59:43 +0000 (08:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48052 91177308-0d34-0410-b5e6-96231b3b80d8

Basic/TargetInfo.cpp
include/clang/Basic/TargetInfo.h

index 5364affe589c045b477b1578448fbe7c3352faaa..8d4488a7777fabf25e8bb0211b63eb8366c25e70 100644 (file)
 #include "llvm/ADT/STLExtras.h"
 using namespace clang;
 
-// Out of line virtual dtor for TargetInfo.
-TargetInfo::~TargetInfo() {}
-
-//===----------------------------------------------------------------------===//
-// FIXME: These are temporary hacks.
-
-const llvm::fltSemantics *TargetInfo::getFloatFormat() const {
-  return &llvm::APFloat::IEEEsingle;
-}
-const llvm::fltSemantics *TargetInfo::getDoubleFormat() const {
-  return &llvm::APFloat::IEEEdouble;
-}
-const llvm::fltSemantics *TargetInfo::getLongDoubleFormat() const {
-  //Size = 80; Align = 32;  // FIXME: implement correctly.
-  //Format = &llvm::APFloat::x87DoubleExtended;
-  return &llvm::APFloat::IEEEdouble;
+// TargetInfo Constructor.
+TargetInfo::TargetInfo(const std::string &T) : Triple(T) {
+  // Set defaults.  These should be overridden by concrete targets as needed.
+  CharIsSigned = true;
+  WCharWidth = WCharAlign = 32;
+  FloatFormat = &llvm::APFloat::IEEEsingle;
+  DoubleFormat = &llvm::APFloat::IEEEdouble;
+  LongDoubleFormat = &llvm::APFloat::IEEEdouble;
 }
 
+// Out of line virtual dtor for TargetInfo.
+TargetInfo::~TargetInfo() {}
 
 //===----------------------------------------------------------------------===//
 
index 2d2aca5698b64a72dd0a2b6eb9392f2ec1150358..017f6d6f292496bb6d51d559fc2a070b7f4465b3 100644 (file)
@@ -32,16 +32,14 @@ namespace Builtin { struct Info; }
 class TargetInfo {
   std::string Triple;
 protected:
-  /// These are all caches for target values.
+  // Target values set by the ctor of the actual target implementation.  Default
+  // values are specified by the TargetInfo constructor.
   bool CharIsSigned;
   unsigned WCharWidth, WCharAlign;
+  const llvm::fltSemantics *FloatFormat, *DoubleFormat, *LongDoubleFormat;
 
-  // TargetInfo Constructor.
-  TargetInfo(const std::string &T) : Triple(T) {
-    // Set defaults.  These should be overridden by concrete targets as needed.
-    CharIsSigned = true;
-    WCharWidth = WCharAlign = 32;
-  }
+  // TargetInfo Constructor.  Default initializes all fields.
+  TargetInfo(const std::string &T);
   
 public:  
   /// CreateTargetInfo - Return the target info object for the specified target
@@ -106,18 +104,20 @@ public:
   /// getFloatWidth/Align/Format - Return the size/align/format of 'float'.
   unsigned getFloatWidth() const { return 32; } // FIXME
   unsigned getFloatAlign() const { return 32; } // FIXME
-  const llvm::fltSemantics *getFloatFormat() const;
+  const llvm::fltSemantics *getFloatFormat() const { return FloatFormat; }
 
   /// getDoubleWidth/Align/Format - Return the size/align/format of 'double'.
   unsigned getDoubleWidth() const { return 64; } // FIXME
   unsigned getDoubleAlign() const { return 32; } // FIXME
-  const llvm::fltSemantics *getDoubleFormat() const;
+  const llvm::fltSemantics *getDoubleFormat() const { return DoubleFormat; }
 
   /// getLongDoubleWidth/Align/Format - Return the size/align/format of 'long
   /// double'.
   unsigned getLongDoubleWidth() const { return 64; } // FIXME
   unsigned getLongDoubleAlign() const { return 64; } // FIXME
-  const llvm::fltSemantics *getLongDoubleFormat() const;
+  const llvm::fltSemantics *getLongDoubleFormat() const {
+    return LongDoubleFormat;
+  }
   
 
   /// getIntMaxTWidth - Return the size of intmax_t and uintmax_t for this