[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
Thu Feb 6 13:38:12 PST 2020


xingxue created this revision.
xingxue added reviewers: hubert.reinterpretcast, jasonliu, erik.pilkington, uweigand.
xingxue added a project: LLVM.
Herald added subscribers: libcxx-commits, steven.zhang, shchenz, jsji, dexonsmith, christof, aheejin, nemanjai.
Herald added a project: libc++.

This patch is to fix the parsing of `long double` literals on `PowerPC` and `S390`. For `PowerPC`, type code 'e' is used for 64-bit `long double` literals and 'g' is used for 128-bit `long double` literals.  For `S390`, type code 'g' is used for 128-bit `long double` literals. `libcxxabi` test case test_demangle.pass.cpp fails without the fix.


Repository:
  rG LLVM Github Monorepo

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
@@ -3790,9 +3790,15 @@
     ++First;
     return make<NameType>("long double");
   //                ::= g    # __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__)
   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,10 @@
 //
 //===----------------------------------------------------------------------===//
 
+#if defined(__powerpc__) && !defined(__LONG_DOUBLE_128__)
+#error "Demangler must be built in long double 128 mode on PowerPC."
+#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.242989.patch
Type: text/x-patch
Size: 1989 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200206/f1058123/attachment-0001.bin>


More information about the libcxx-commits mailing list