This is an archive of the discontinued LLVM Phabricator instance.

[ItaniumMangle] Refactor long double/__float128 mangling and fix the mangled code
ClosedPublic

Authored by MaskRay on Jul 5 2019, 10:22 PM.

Details

Summary

In gcc PowerPC, long double has 3 mangling schemes:

-mlong-double-64: e
-mlong-double-128 -mabi=ibmlongdouble: g
-mlong-double-128 -mabi=ieeelongdouble: u9__ieee128 (gcc <= 8.1: U10__float128)

The current useFloat128ManglingForLongDouble() bisection is not suitable
when we support -mlong-double-128 in clang (D64277). Replace
useFloat128ManglingForLongDouble() with getLongDoubleMangling() and
getFloat128Mangling() to allow 3 mangling schemes.

I also deleted the getTriple().isOSBinFormatELF() check (the Darwin
support has gone: https://reviews.llvm.org/D50988).

For x86, change the mangled code of __float128 from U10__float128 to g. U10__float128 was wrongly copied from PowerPC.
The test will be added to test/CodeGen/x86-long-double.cpp in D64277.

Diff Detail

Event Timeline

MaskRay created this revision.Jul 5 2019, 10:22 PM
MaskRay updated this revision to Diff 208256.Jul 5 2019, 11:57 PM

Simplify x86_64 Android. Since it doesn't use -mlong-double-64 or -mlong-double-128, just use "g" for it.
In the next -mlong-double-128 patch, we move its getManglingForLongDouble() overload to X86TargetInfo

MaskRay updated this revision to Diff 208294.Jul 7 2019, 9:19 AM
MaskRay edited the summary of this revision. (Show Details)
MaskRay removed a subscriber: wuzish.

"U10float128" -> "u9ieee128"

This is the new mangled type in gcc>8.1

MaskRay updated this revision to Diff 208313.Jul 7 2019, 9:41 PM
MaskRay retitled this revision from [ItaniumMangle] Replace useFloat128ManglingForLongDouble() with getManglingForLongDouble() and getManglingForFloat128() to [ItaniumMangle] Refactor long double/__float128 mangling and fix the mangled code.
MaskRay edited the summary of this revision. (Show Details)

Fix mangled code of __float128 on x86

erichkeane accepted this revision.Jul 8 2019, 6:35 AM

I think the function names are awkward, but otherwise I think this should be acceptable. I'll accept, but give 24 hrs for the other reviewers to get through their mondays.

include/clang/Basic/TargetInfo.h
603

getLongDoubleMangling/getFloat128Mangling seems to make more sense for these names.

This revision is now accepted and ready to land.Jul 8 2019, 6:35 AM
MaskRay updated this revision to Diff 208399.Jul 8 2019, 7:21 AM
MaskRay edited the summary of this revision. (Show Details)

getMangledTypeOfLongDouble -> getLongDoubleMangling
as erichkeane suggested.

MaskRay edited the summary of this revision. (Show Details)Jul 8 2019, 7:26 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 9 2019, 6:32 AM