[PATCH] D15120: Add support for __float128 type to be used by targets that support it

Hubert Tong via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 2 08:39:00 PST 2016

hubert.reinterpretcast added inline comments.

Comment at: lib/Sema/SemaOverload.cpp:1658
@@ -1657,1 +1657,3 @@
   } else if (FromType->isRealFloatingType() && ToType->isRealFloatingType()) {
+    // FIXME: disable conversions between long double and __float128 if
+    // their representation is different until there is back end support
nemanjai wrote:
> hubert.reinterpretcast wrote:
> > The update to check the case where the representation of `long double` is the same as that of `double` is missing.
> Yes, I missed this. Thanks for noticing. I'll update the comment and change the body of the if to:
>     if (&S.Context.getFloatTypeSemantics(FromType) !=
>         &S.Context.getFloatTypeSemantics(ToType)) {
>       bool Float128AndLongDouble = ((FromType == S.Context.Float128Ty &&
>                                     ToType == S.Context.LongDoubleTy) ||
>                                    (FromType == S.Context.LongDoubleTy &&
>                                     ToType == S.Context.Float128Ty));
>       if (Float128AndLongDouble &&
>           (&S.Context.getFloatTypeSemantics(S.Context.LongDoubleTy) !=
>            &llvm::APFloat::IEEEdouble))
>         return false;
>     }
I'm not a fan of redundant parentheses, but that looks okay.

Comment at: lib/Sema/SemaOverload.cpp:1966-1967
@@ -1955,4 +1965,4 @@
       // C99
       //   When a float is promoted to double or long double, or a
       //   double is promoted to long double [...].
       if (!getLangOpts().CPlusPlus &&
nemanjai wrote:
> hubert.reinterpretcast wrote:
> > @rsmith; this is the discussion on floating-point "promotions" in "C" that I was asking you about.
> I can certainly remove this if the agreement is that I should do so.
Richard had requested to allow "promoting" `long double` to `__float128`, and at the time, implicitly converting from `long double` to `__float128` was something I was not convinced we should do at the time. At this time, I believe that adding this "promotion" is consistent with the rest of the patch; however, I am still not sure what this code is meant to implement (again, C11 does not have floating-point promotions).



More information about the cfe-commits mailing list