MaskRay created this revision.
MaskRay added reviewers: awilfox, echristo, erichkeane, hfinkel, majnemer, rnk, 
rsmith.
Herald added subscribers: cfe-commits, erik.pilkington, jdoerfert, jsji, 
kbarton, nemanjai.
Herald added a project: clang.

On PowerPC, long double has 3 mangling schemes:

-mlong-double-64: "e"
-mlong-double-128 -mabi=ibmlongdouble: "g"
-mlong-double-128 -mabi=ieeelongdouble: "U10__float128"

The current bisection is not suitable when we add -mlong-double-128.
Replace useFloat128ManglingForLongDouble() with
getManglingForLongDouble() and getManglingForFloat128() to allow 3
mangling schemes.

This change is a no-op on X86 and SystemZ.
I deleted `getTriple().isOSBinFormatELF()` because the Darwin support
has gone: https://reviews.llvm.org/D50988


Repository:
  rC Clang

https://reviews.llvm.org/D64276

Files:
  include/clang/Basic/TargetInfo.h
  lib/AST/ItaniumMangle.cpp
  lib/Basic/Targets/PPC.h
  lib/Basic/Targets/SystemZ.h
  lib/Basic/Targets/X86.h

Index: lib/Basic/Targets/X86.h
===================================================================
--- lib/Basic/Targets/X86.h
+++ lib/Basic/Targets/X86.h
@@ -848,7 +848,12 @@
     LongDoubleFormat = &llvm::APFloat::IEEEquad();
   }
 
-  bool useFloat128ManglingForLongDouble() const override { return true; }
+  const char *getManglingForLongDouble() const override {
+    return LongDoubleWidth == 128 ? "g" : "e";
+  }
+  const char *getManglingForFloat128() const override {
+    return "U10__float128";
+  }
 };
 } // namespace targets
 } // namespace clang
Index: lib/Basic/Targets/SystemZ.h
===================================================================
--- lib/Basic/Targets/SystemZ.h
+++ lib/Basic/Targets/SystemZ.h
@@ -141,7 +141,7 @@
     return "";
   }
 
-  bool useFloat128ManglingForLongDouble() const override { return true; }
+  const char *getManglingForLongDouble() const override { return "g"; }
 };
 } // namespace targets
 } // namespace clang
Index: lib/Basic/Targets/PPC.h
===================================================================
--- lib/Basic/Targets/PPC.h
+++ lib/Basic/Targets/PPC.h
@@ -314,10 +314,15 @@
 
   bool hasSjLjLowering() const override { return true; }
 
-  bool useFloat128ManglingForLongDouble() const override {
-    return LongDoubleWidth == 128 &&
-           LongDoubleFormat == &llvm::APFloat::PPCDoubleDouble() &&
-           getTriple().isOSBinFormatELF();
+  const char *getManglingForLongDouble() const override {
+    if (LongDoubleWidth == 64)
+      return "e";
+    return LongDoubleFormat == &llvm::APFloat::PPCDoubleDouble()
+               ? "g"
+               : "U10__float128";
+  }
+  const char *getManglingForFloat128() const override {
+    return "U10__float128";
   }
 };
 
Index: lib/AST/ItaniumMangle.cpp
===================================================================
--- lib/AST/ItaniumMangle.cpp
+++ lib/AST/ItaniumMangle.cpp
@@ -2608,30 +2608,19 @@
     Out << 'd';
     break;
   case BuiltinType::LongDouble: {
-    bool UseFloat128Mangling =
-        getASTContext().getTargetInfo().useFloat128ManglingForLongDouble();
-    if (getASTContext().getLangOpts().OpenMP &&
-        getASTContext().getLangOpts().OpenMPIsDevice) {
-      UseFloat128Mangling = getASTContext()
-                                .getAuxTargetInfo()
-                                ->useFloat128ManglingForLongDouble();
-    }
-    Out << (UseFloat128Mangling ? 'g' : 'e');
+    const TargetInfo *TI = getASTContext().getLangOpts().OpenMP &&
+                                   getASTContext().getLangOpts().OpenMPIsDevice
+                               ? getASTContext().getAuxTargetInfo()
+                               : &getASTContext().getTargetInfo();
+    Out << TI->getManglingForLongDouble();
     break;
   }
   case BuiltinType::Float128: {
-    bool UseFloat128Mangling =
-        getASTContext().getTargetInfo().useFloat128ManglingForLongDouble();
-    if (getASTContext().getLangOpts().OpenMP &&
-        getASTContext().getLangOpts().OpenMPIsDevice) {
-      UseFloat128Mangling = getASTContext()
-                                .getAuxTargetInfo()
-                                ->useFloat128ManglingForLongDouble();
-    }
-    if (UseFloat128Mangling)
-      Out << "U10__float128"; // Match the GCC mangling
-    else
-      Out << 'g';
+    const TargetInfo *TI = getASTContext().getLangOpts().OpenMP &&
+                                   getASTContext().getLangOpts().OpenMPIsDevice
+                               ? getASTContext().getAuxTargetInfo()
+                               : &getASTContext().getTargetInfo();
+    Out << TI->getManglingForFloat128();
     break;
   }
   case BuiltinType::NullPtr:
Index: include/clang/Basic/TargetInfo.h
===================================================================
--- include/clang/Basic/TargetInfo.h
+++ include/clang/Basic/TargetInfo.h
@@ -599,9 +599,11 @@
     return *Float128Format;
   }
 
-  /// Return true if the 'long double' type should be mangled like
-  /// __float128.
-  virtual bool useFloat128ManglingForLongDouble() const { return false; }
+  /// Return the mangled type of long double.
+  virtual const char *getManglingForLongDouble() const { return "e"; }
+
+  /// Return the mangled type of __float128.
+  virtual const char *getManglingForFloat128() const { return "g"; }
 
   /// Return the value for the C99 FLT_EVAL_METHOD macro.
   virtual unsigned getFloatEvalMethod() const { return 0; }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to