From c8b1227fa8c17d9881815e40c04e19334be536f8 Mon Sep 17 00:00:00 2001 From: Nate Begeman Date: Fri, 18 Apr 2008 05:41:31 +0000 Subject: [PATCH] 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 --- include/clang/Basic/TargetInfo.h | 6 ++++-- lib/CodeGen/CodeGenTypes.cpp | 4 +++- 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(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; -- 2.40.0