aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNate Begeman <natebegeman@mac.com>2008-04-18 05:41:31 +0000
committerNate Begeman <natebegeman@mac.com>2008-04-18 05:41:31 +0000
commitc8b1227fa8c17d9881815e40c04e19334be536f8 (patch)
tree7ec287cfe0e7cf879e52767b4a4753d69ff9a439
parentbef5c8bf65bf9a1ae7bf0d6630e17cf3eeae8cc4 (diff)
Allow targets to override double size, alignment, and semantics, and tie this
information into the IR type codegen. This allows a target to codegen the C 'double' type as either double or float. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49898 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/TargetInfo.h6
-rw-r--r--lib/CodeGen/CodeGenTypes.cpp4
2 files changed, 7 insertions, 3 deletions
diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h
index ca8ac8c6a0..cd71759440 100644
--- a/include/clang/Basic/TargetInfo.h
+++ b/include/clang/Basic/TargetInfo.h
@@ -36,6 +36,8 @@ protected:
// values are specified by the TargetInfo constructor.
bool CharIsSigned;
unsigned WCharWidth, WCharAlign;
+ unsigned DoubleWidth, DoubleAlign;
+
const llvm::fltSemantics *FloatFormat, *DoubleFormat, *LongDoubleFormat;
// TargetInfo Constructor. Default initializes all fields.
@@ -103,8 +105,8 @@ public:
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
+ unsigned getDoubleWidth() const { return DoubleWidth; }
+ unsigned getDoubleAlign() const { return DoubleAlign; }
const llvm::fltSemantics *getDoubleFormat() const { return DoubleFormat; }
/// getLongDoubleWidth/Align/Format - Return the size/align/format of 'long
diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp
index d594cbc735..2fcdb1530f 100644
--- a/lib/CodeGen/CodeGenTypes.cpp
+++ b/lib/CodeGen/CodeGenTypes.cpp
@@ -215,7 +215,9 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
static_cast<unsigned>(Context.getTypeSize(T)));
case BuiltinType::Float: return llvm::Type::FloatTy;
- case BuiltinType::Double: return llvm::Type::DoubleTy;
+ case BuiltinType::Double:
+ return (Context.Target.getDoubleFormat() == &llvm::APFloat::IEEEdouble) ?
+ llvm::Type::DoubleTy : llvm::Type::FloatTy;
case BuiltinType::LongDouble:
// FIXME: mapping long double onto double.
return llvm::Type::DoubleTy;