From: Pekka Jaaskelainen Date: Wed, 18 Dec 2013 18:15:03 +0000 (+0000) Subject: OpenCL: Do not force 64 bit floats for (embedded) targets with only 32bit floats. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4799606af56230890ff7d248adb4ac921d75d8c7;p=clang OpenCL: Do not force 64 bit floats for (embedded) targets with only 32bit floats. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197592 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/TargetInfo.cpp b/lib/Basic/TargetInfo.cpp index d0ed6e6b16..7ee2706d3e 100644 --- a/lib/Basic/TargetInfo.cpp +++ b/lib/Basic/TargetInfo.cpp @@ -244,7 +244,14 @@ void TargetInfo::setForcedLangOptions(LangOptions &Opts) { LongLongWidth = LongLongAlign = 128; HalfWidth = HalfAlign = 16; FloatWidth = FloatAlign = 32; - DoubleWidth = DoubleAlign = 64; + + // Embedded 32-bit targets (OpenCL EP) might have double C type + // defined as float. Let's not override this as it might lead + // to generating illegal code that uses 64bit doubles. + if (DoubleWidth != FloatWidth) { + DoubleWidth = DoubleAlign = 64; + DoubleFormat = &llvm::APFloat::IEEEdouble; + } LongDoubleWidth = LongDoubleAlign = 128; assert(PointerWidth == 32 || PointerWidth == 64); @@ -259,7 +266,6 @@ void TargetInfo::setForcedLangOptions(LangOptions &Opts) { HalfFormat = &llvm::APFloat::IEEEhalf; FloatFormat = &llvm::APFloat::IEEEsingle; - DoubleFormat = &llvm::APFloat::IEEEdouble; LongDoubleFormat = &llvm::APFloat::IEEEquad; } }