This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Support -mabi=ieeelongdouble and -mabi=ibmlongdouble
ClosedPublic

Authored by MaskRay on Jul 6 2019, 3:56 AM.

Details

Summary

gcc PowerPC supports 3 representations of long double:

  • -mlong-double-64

    long double has the same representation of double but is mangled as e. In clang, this is the default on AIX, FreeBSD and Linux musl.
  • -mlong-double-128

    long double has 2 possible 128-bit floating point representations:

    + -mabi=ibmlongdouble IBM extended double format. Mangled as g In clang, this is the default on Linux glibc. + -mabi=ieeelongdouble IEEE 754 quadruple-precision format. Mangled as u9__ieee128 (U10__float128 before gcc 8.2) This is currently unavailable.

This patch adds -mabi=ibmlongdouble and -mabi=ieeelongdouble, and thus
makes the IEEE 754 quadruple-precision long double available for
languages supported by clang.

Diff Detail

Event Timeline

MaskRay created this revision.Jul 6 2019, 3:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2019, 3:56 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
MaskRay updated this revision to Diff 208315.Jul 7 2019, 9:55 PM
MaskRay edited the summary of this revision. (Show Details)

Update description.

Fix the mangled code: U10float128 -> u9ieee128

Ah, fun with overloaded, legacy command-line options...

lib/Driver/ToolChains/Clang.cpp
1836

This seems like an unintentional behavior change on top of the existing behavior (which may have also been not quite right). As best I can tell, we're trying to set ABIName equal to the last ABI type specified, unless that type is "altivec", in which case the ABI name should be its default value (either a nullptr or something like "elfv2"). With this change, we'll now take the first ABI name seen, not the last (as we'll get SeenOther to true after the first name).

Maybe we should loop over the list multiple times, once to get the long-double format, once to get the basic ABI name (where we save the default, and then if the last name found is "altivec", then reset to the default)?

MaskRay marked an inline comment as done.Jul 9 2019, 8:06 PM
MaskRay added inline comments.
lib/Driver/ToolChains/Clang.cpp
1836

My understanding (could be wrong) is that "ibmlongdouble", "ieeelongdouble", and "altivec" cannot be ABIName, so I write it this way (filtered_reverse + SeenLongDouble + SeenOther).

e.g. with -mabi=elfv2 -mabi=ieeelongdouble, ABIName should be "elfv2". With -mabi=elfv1 -mabi=ieeelongdouble, ABIName should be "elfv1" (no local entry). This matches the behavior I observed from powerpc64le-linux-gnu-gcc.

Before the change, ABIName is "ieeelongdouble". I think that is not desired.

MaskRay updated this revision to Diff 208875.Jul 9 2019, 8:27 PM
MaskRay edited the summary of this revision. (Show Details)

Add another test: -mabi=elfv2 -mabi=elfv1 -mabi=ibmlongdouble -mabi=ieeelongdouble

Try fixing the markdown in the description

MaskRay edited the summary of this revision. (Show Details)Jul 9 2019, 8:28 PM
MaskRay updated this revision to Diff 209114.Jul 10 2019, 7:03 PM

Make -mabi=ieeelongdouble a pure CC1 option so that we can simplify the -mabi= loop

MaskRay marked an inline comment as done.Jul 10 2019, 7:03 PM

Woohoo, this is the last :)

This revision is now accepted and ready to land.Jul 14 2019, 10:18 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 15 2019, 12:24 AM