[libcxx-commits] [PATCH] D74163: [demangler] Fix the parsing of long double literals for PowerPC and S390

Xing Xue via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Feb 7 10:45:10 PST 2020


xingxue updated this revision to Diff 243223.
xingxue edited the summary of this revision.
xingxue added a comment.

Addressed comments:

- Guard against building with `__LONG_DOUBLE_IEEE128__` on `PowerPC` so that it only builds in the double-double 128-bit `long double` mode.
- Treat type code 'e' as 64-bit `long double` on `S390` as well.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74163/new/

https://reviews.llvm.org/D74163

Files:
  libcxxabi/src/cxa_demangle.cpp
  libcxxabi/src/demangle/ItaniumDemangle.h


Index: libcxxabi/src/demangle/ItaniumDemangle.h
===================================================================
--- libcxxabi/src/demangle/ItaniumDemangle.h
+++ libcxxabi/src/demangle/ItaniumDemangle.h
@@ -3789,10 +3789,16 @@
   case 'e':
     ++First;
     return make<NameType>("long double");
-  //                ::= g    # __float128
+  //                ::= g    # long double, __float128
+#if defined(__powerpc__) || defined(__s390__)
+  case 'g':
+    ++First;
+    return make<NameType>("long double");
+#else
   case 'g':
     ++First;
     return make<NameType>("__float128");
+#endif
   //                ::= z    # ellipsis
   case 'z':
     ++First;
@@ -4223,7 +4229,16 @@
   case 'd':
     ++First;
     return getDerived().template parseFloatingLiteral<double>();
+#if defined(__powerpc__) || defined(__s390__)
   case 'e':
+    ++First;
+    return getDerived().template parseFloatingLiteral<double>();
+#else
+  case 'e':
+    ++First;
+    return getDerived().template parseFloatingLiteral<long double>();
+#endif
+  case 'g':
     ++First;
     return getDerived().template parseFloatingLiteral<long double>();
   case '_':
@@ -5167,7 +5182,7 @@
 struct FloatData<long double>
 {
 #if defined(__mips__) && defined(__mips_n64) || defined(__aarch64__) || \
-    defined(__wasm__)
+    defined(__wasm__) || defined(__powerpc__) || defined(__s390__)
     static const size_t mangled_size = 32;
 #elif defined(__arm__) || defined(__mips__) || defined(__hexagon__)
     static const size_t mangled_size = 16;
Index: libcxxabi/src/cxa_demangle.cpp
===================================================================
--- libcxxabi/src/cxa_demangle.cpp
+++ libcxxabi/src/cxa_demangle.cpp
@@ -6,6 +6,11 @@
 //
 //===----------------------------------------------------------------------===//
 
+#if defined(__powerpc__) && \
+    (!defined(__LONG_DOUBLE_128__) || defined(__LONG_DOUBLE_IEEE128__))
+#error "Demangler must be built in double-double long double 128 mode on PPC."
+#endif
+
 // FIXME: (possibly) incomplete list of features that clang mangles that this
 // file does not yet support:
 //   - C++ modules TS


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74163.243223.patch
Type: text/x-patch
Size: 2135 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200207/f19cce56/attachment-0001.bin>


More information about the libcxx-commits mailing list