make float format handling more regular.

llvm-svn: 48052
This commit is contained in:
Chris Lattner 2008-03-08 08:59:43 +00:00
parent 7570e9c518
commit 1df278669d
2 changed files with 20 additions and 26 deletions

View File

@ -18,25 +18,19 @@
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
using namespace clang; using namespace clang;
// 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. // Out of line virtual dtor for TargetInfo.
TargetInfo::~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;
}
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//

View File

@ -32,16 +32,14 @@ namespace Builtin { struct Info; }
class TargetInfo { class TargetInfo {
std::string Triple; std::string Triple;
protected: 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; bool CharIsSigned;
unsigned WCharWidth, WCharAlign; unsigned WCharWidth, WCharAlign;
const llvm::fltSemantics *FloatFormat, *DoubleFormat, *LongDoubleFormat;
// TargetInfo Constructor. // TargetInfo Constructor. Default initializes all fields.
TargetInfo(const std::string &T) : Triple(T) { TargetInfo(const std::string &T);
// Set defaults. These should be overridden by concrete targets as needed.
CharIsSigned = true;
WCharWidth = WCharAlign = 32;
}
public: public:
/// CreateTargetInfo - Return the target info object for the specified target /// 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'. /// getFloatWidth/Align/Format - Return the size/align/format of 'float'.
unsigned getFloatWidth() const { return 32; } // FIXME unsigned getFloatWidth() const { return 32; } // FIXME
unsigned getFloatAlign() 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'. /// getDoubleWidth/Align/Format - Return the size/align/format of 'double'.
unsigned getDoubleWidth() const { return 64; } // FIXME unsigned getDoubleWidth() const { return 64; } // FIXME
unsigned getDoubleAlign() const { return 32; } // 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 /// getLongDoubleWidth/Align/Format - Return the size/align/format of 'long
/// double'. /// double'.
unsigned getLongDoubleWidth() const { return 64; } // FIXME unsigned getLongDoubleWidth() const { return 64; } // FIXME
unsigned getLongDoubleAlign() 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 /// getIntMaxTWidth - Return the size of intmax_t and uintmax_t for this