diff options
author | Nemanja Ivanovic <nemanja.i.ibm@gmail.com> | 2016-05-09 08:52:33 +0000 |
---|---|---|
committer | Nemanja Ivanovic <nemanja.i.ibm@gmail.com> | 2016-05-09 08:52:33 +0000 |
commit | bb1ea2d6139a72340b426e114510c46d938645a6 (patch) | |
tree | be829c4bed58e4b64889d398ce23371f295bfac4 /clang/lib/Basic/Targets.cpp | |
parent | 0f450b6b9a85a63021bfb1f7aed263e19d3743f2 (diff) | |
download | bcm5719-llvm-bb1ea2d6139a72340b426e114510c46d938645a6.tar.gz bcm5719-llvm-bb1ea2d6139a72340b426e114510c46d938645a6.zip |
Enable support for __float128 in Clang and enable it on pertinent platforms
This patch corresponds to reviews:
http://reviews.llvm.org/D15120
http://reviews.llvm.org/D19125
It adds support for the __float128 keyword, literals and target feature to
enable it. Based on the latter of the two aforementioned reviews, this feature
is enabled on Linux on i386/X86 as well as SystemZ.
This is also the second attempt in commiting this feature. The first attempt
did not enable it on required platforms which caused failures when compiling
type_traits with -std=gnu++11.
If you see failures with compiling this header on your platform after this
commit, it is likely that your platform needs to have this feature enabled.
llvm-svn: 268898
Diffstat (limited to 'clang/lib/Basic/Targets.cpp')
-rw-r--r-- | clang/lib/Basic/Targets.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index 6b26d14dc5a..4dac1046e67 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -427,6 +427,8 @@ protected: Builder.defineMacro("_REENTRANT"); if (Opts.CPlusPlus) Builder.defineMacro("_GNU_SOURCE"); + if (this->HasFloat128) + Builder.defineMacro("__FLOAT128__"); } public: LinuxTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) @@ -441,6 +443,11 @@ public: case llvm::Triple::ppc64le: this->MCountName = "_mcount"; break; + case llvm::Triple::x86: + case llvm::Triple::x86_64: + case llvm::Triple::systemz: + this->HasFloat128 = true; + break; } } @@ -1096,6 +1103,8 @@ bool PPCTargetInfo::handleTargetFeatures(std::vector<std::string> &Features, HasQPX = true; } else if (Feature == "+htm") { HasHTM = true; + } else if (Feature == "+float128") { + HasFloat128 = true; } // TODO: Finish this list and add an assert that we've handled them // all. @@ -1253,6 +1262,8 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts, Builder.defineMacro("__CRYPTO__"); if (HasHTM) Builder.defineMacro("__HTM__"); + if (HasFloat128) + Builder.defineMacro("__FLOAT128__"); Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1"); Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2"); @@ -1303,6 +1314,13 @@ static bool ppcUserFeaturesCheck(DiagnosticsEngine &Diags, << "-mno-vsx"; return false; } + + if (std::find(FeaturesVec.begin(), FeaturesVec.end(), "+float128") != + FeaturesVec.end()) { + Diags.Report(diag::err_opt_not_valid_with_opt) << "-mfloat128" + << "-mno-vsx"; + return false; + } } return true; @@ -1371,6 +1389,7 @@ bool PPCTargetInfo::hasFeature(StringRef Feature) const { .Case("htm", HasHTM) .Case("bpermd", HasBPERMD) .Case("extdiv", HasExtDiv) + .Case("float128", HasFloat128) .Default(false); } @@ -1380,19 +1399,19 @@ void PPCTargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features, // as well. Do the inverse if we're disabling vsx. We'll diagnose any user // incompatible options. if (Enabled) { - if (Name == "vsx") { - Features[Name] = true; - } else if (Name == "direct-move") { + if (Name == "direct-move") { Features[Name] = Features["vsx"] = true; } else if (Name == "power8-vector") { Features[Name] = Features["vsx"] = true; + } else if (Name == "float128") { + Features[Name] = Features["vsx"] = true; } else { Features[Name] = true; } } else { if (Name == "vsx") { Features[Name] = Features["direct-move"] = Features["power8-vector"] = - false; + Features["float128"] = false; } else { Features[Name] = false; } |