[clang] 4aa510b - Allow __ieee128 as an alias to __float128 on ppc
via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 15 10:29:01 PDT 2021
Author: serge-sans-paille
Date: 2021-03-15T18:28:26+01:00
New Revision: 4aa510be78a75a4da82657fe433016f00dad0784
URL: https://github.com/llvm/llvm-project/commit/4aa510be78a75a4da82657fe433016f00dad0784
DIFF: https://github.com/llvm/llvm-project/commit/4aa510be78a75a4da82657fe433016f00dad0784.diff
LOG: Allow __ieee128 as an alias to __float128 on ppc
This matches gcc behavior.
Differential Revision: https://reviews.llvm.org/D97846
Added:
Modified:
clang/include/clang/Basic/LangOptions.def
clang/lib/Basic/IdentifierTable.cpp
clang/lib/Basic/Targets/PPC.cpp
clang/test/Sema/128bitfloat.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def
index 620b0899507a2..7efc661002fe7 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -109,6 +109,7 @@ LANGOPT(Bool , 1, 0, "bool, true, and false keywords")
LANGOPT(Half , 1, 0, "half keyword")
LANGOPT(WChar , 1, CPlusPlus, "wchar_t keyword")
LANGOPT(Char8 , 1, 0, "char8_t keyword")
+LANGOPT(IEEE128 , 1, 0, "__ieee128 keyword")
LANGOPT(DeclSpecKeyword , 1, 0, "__declspec keyword")
BENIGN_LANGOPT(DollarIdents , 1, 1, "'$' in identifiers")
BENIGN_LANGOPT(AsmPreprocessor, 1, 0, "preprocessor in asm mode")
diff --git a/clang/lib/Basic/IdentifierTable.cpp b/clang/lib/Basic/IdentifierTable.cpp
index 51c6e02e2e2e0..cedc94a935504 100644
--- a/clang/lib/Basic/IdentifierTable.cpp
+++ b/clang/lib/Basic/IdentifierTable.cpp
@@ -227,6 +227,9 @@ void IdentifierTable::AddKeywords(const LangOptions &LangOpts) {
if (LangOpts.DeclSpecKeyword)
AddKeyword("__declspec", tok::kw___declspec, KEYALL, LangOpts, *this);
+ if (LangOpts.IEEE128)
+ AddKeyword("__ieee128", tok::kw___float128, KEYALL, LangOpts, *this);
+
// Add the 'import' contextual keyword.
get("import").setModulesImport(true);
}
diff --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 73ecc05f20154..78397abfe1f5e 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -566,6 +566,7 @@ void PPCTargetInfo::adjust(LangOptions &Opts) {
LongDoubleFormat = Opts.PPCIEEELongDouble
? &llvm::APFloat::IEEEquad()
: &llvm::APFloat::PPCDoubleDouble();
+ Opts.IEEE128 = 1;
}
ArrayRef<Builtin::Info> PPCTargetInfo::getTargetBuiltins() const {
diff --git a/clang/test/Sema/128bitfloat.cpp b/clang/test/Sema/128bitfloat.cpp
index 4a826b479d017..6a9ae743c6f06 100644
--- a/clang/test/Sema/128bitfloat.cpp
+++ b/clang/test/Sema/128bitfloat.cpp
@@ -6,6 +6,13 @@
// RUN: %clang_cc1 -triple x86_64-windows-msvc -verify -std=c++11 %s
#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
+
+#if defined(__ppc__)
+template <typename> struct __is_float128 { static constexpr bool value = false; };
+template <> struct __is_float128<__float128> { static constexpr bool value = true; };
+static_assert(__is_float128<__ieee128>::value, "__ieee128 aliases to __float128");
+#endif
+
__float128 f;
template<typename> struct __is_floating_point_helper {};
template<> struct __is_floating_point_helper<__float128> {};
More information about the cfe-commits
mailing list