Enable __float128 for mingw for GCC compatibility and define __SIZEOF_FLOAT128__ on x86

GCC defines __FLOAT128__ on Power and __SIZEOF_FLOAT128__ on x86. We're
just following the inconsistency for now so users have some way to test.

Effectively merges this patch as requested by Martell Malone:
https://github.com/Alexpux/MINGW-packages/blob/master/mingw-w64-clang/0107-enable-__float128-for-X86-MinGW.patch

llvm-svn: 304012
This commit is contained in:
Reid Kleckner 2017-05-26 17:38:15 +00:00
parent 1f9cab6b1c
commit 9eabbb6066
3 changed files with 13 additions and 4 deletions

View File

@ -4644,7 +4644,9 @@ static void addMinGWDefines(const LangOptions &Opts, MacroBuilder &Builder) {
class MinGWX86_32TargetInfo : public WindowsX86_32TargetInfo {
public:
MinGWX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
: WindowsX86_32TargetInfo(Triple, Opts) {}
: WindowsX86_32TargetInfo(Triple, Opts) {
HasFloat128 = true;
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
WindowsX86_32TargetInfo::getTargetDefines(Opts, Builder);
@ -4936,6 +4938,7 @@ public:
// with x86 FP ops. Weird.
LongDoubleWidth = LongDoubleAlign = 128;
LongDoubleFormat = &llvm::APFloat::x87DoubleExtended();
HasFloat128 = true;
}
void getTargetDefines(const LangOptions &Opts,

View File

@ -750,6 +750,8 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
TI.getTypeWidth(TI.getWIntType()), TI, Builder);
if (TI.hasInt128Type())
DefineTypeSizeof("__SIZEOF_INT128__", 128, TI, Builder);
if (TI.hasFloat128Type())
DefineTypeSizeof("__SIZEOF_FLOAT128__", 128, TI, Builder);
DefineType("__INTMAX_TYPE__", TI.getIntMaxType(), Builder);
DefineFmt("__INTMAX", TI.getIntMaxType(), TI, Builder);

View File

@ -1,7 +1,11 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=gnu++11 %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
// RUN: %clang_cc1 -verify -std=gnu++11 %s
// RUN: %clang_cc1 -verify -std=c++11 %s
// RUN: %clang_cc1 -triple powerpc64-linux -verify -std=c++11 %s
// RUN: %clang_cc1 -triple i686-windows-gnu -verify -std=c++11 %s
// RUN: %clang_cc1 -triple x86_64-windows-gnu -verify -std=c++11 %s
// RUN: %clang_cc1 -triple x86_64-windows-msvc -verify -std=c++11 %s
#ifdef __FLOAT128__
#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
__float128 f;
template<typename> struct __is_floating_point_helper {};
template<> struct __is_floating_point_helper<__float128> {};