]> git.ipfire.org Git - thirdparty/gcc.git/commit
arm, csky: Fix C++ ICEs with _Float16 and __fp16 [PR107080]
authorJakub Jelinek <jakub@redhat.com>
Fri, 30 Sep 2022 19:54:08 +0000 (21:54 +0200)
committerJakub Jelinek <jakub@redhat.com>
Fri, 30 Sep 2022 19:55:39 +0000 (21:55 +0200)
commit61786edf7a82ffb4979207b43a8204ebc2a7671d
treec73f8b1e2396c1856a61e5de5cab1b055843158d
parentb52b99b62df8fc9b3a3010cb0a8cf49bc35037f0
arm, csky: Fix C++ ICEs with _Float16 and __fp16 [PR107080]

On Fri, Sep 30, 2022 at 09:54:49AM -0400, Jason Merrill wrote:
> > Note, there is one further problem on aarch64/arm, types with HFmode
> > (_Float16 and __fp16) are there mangled as Dh (which is standard
> > Itanium mangling:
> >                   ::= Dh # IEEE 754r half-precision floating point (16 bits)
> >                   ::= DF <number> _ # ISO/IEC TS 18661 binary floating point type _FloatN (N bits)
> > so in theory is also ok, but DF16_ is more specific.  Should we just
> > change Dh to DF16_ in those backends, or should __fp16 there be distinct
> > type from _Float16 where __fp16 would mangle Dh and _Float16 DF16_ ?
>
> You argued for keeping __float128 separate from _Float128, does the same
> argument not apply to this case?

Actually, they already were distinct types that just mangled the same.
So the same issue that had to be solved on i?86, ia64 and rs6000 for
_Float64x vs. long double is a problem on arm and aarch64 with _Float16
vs. __fp16.
The following patch fixes it for arm after aarch64 has been changed
already before.

> > And there is csky, which mangles __fp16 (but only if type's name is __fp16,
> > not _Float16) as __fp16, that looks clearly invalid to me as it isn't
> > valid in the mangling grammar.  So perhaps just nuke csky's mangle_type
> > and have it mangled as DF16_ by the generic code?

And seems even on csky __fp16 is distinct type from _Float16 (which is a
good thing for consistency, these 3 targets are the only ones that have
__fp16 type), so instead the patch handles it the same as on arm/aarch64,
Dh mangling for __fp16 and DF16_ for _Float16.

2022-09-30  Jakub Jelinek  <jakub@redhat.com>

PR c++/107080
* config/arm/arm.cc (arm_mangle_type): Mangle just __fp16 as Dh
and _Float16 as DF16_.
* config/csky/csky.cc (csky_init_builtins): Fix a comment typo.
(csky_mangle_type): Mangle __fp16 as Dh and _Float16 as DF16_
rather than mangling __fp16 as __fp16.

* g++.target/arm/pr107080.C: New test.
gcc/config/arm/arm.cc
gcc/config/csky/csky.cc
gcc/testsuite/g++.target/arm/pr107080.C [new file with mode: 0644]