From: Richard Sandiford <richard.sandiford@arm.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Richard Earnshaw <richard.earnshaw@arm.com>,
Kyrylo Tkachov <kyrylo.tkachov@arm.com>,
Jason Merrill <jason@redhat.com>,
gcc-patches@gcc.gnu.org
Subject: Re: AArch64 bfloat16 mangling
Date: Fri, 10 Mar 2023 08:43:02 +0000 [thread overview]
Message-ID: <mpth6utyp2h.fsf@arm.com> (raw)
In-Reply-To: <ZArsNWoxC315JyOQ@tucnak> (Jakub Jelinek's message of "Fri, 10 Mar 2023 09:37:09 +0100")
Jakub Jelinek <jakub@redhat.com> writes:
> On Thu, Mar 09, 2023 at 05:14:11PM +0000, Richard Sandiford wrote:
>> We decided to keep the current mangling of __bf16 and use it for
>> std::bfloat16_t too. __bf16 will become a non-standard arithmetic type.
>> This will be an explicit diversion from the Itanium ABI.
>>
>> I think that's equivalent to your (2) without the part about following
>> the Itanium ABI.
>
> I'm afraid I have no idea how can the above work though.
>
> Diversion from the Itanium ABI is doable, we have various examples
> where we mangle things differently, say on powerpc* where
> long double is mangled as g if it is IBM double double format (i.e.
> Itanium __float128) while for long double the spec says e, and
> as u9__ieee128 if it is IEEE quad. __float128 also mangles as
> u9__ieee128 and so does __ieee128.
>
> The problem is if __bf16 needs to be treated differently from
> decltype (0.0bf16) aka std::bfloat16_t (the former being a non-standard
> arithmetic type, the latter being C++23 extended floating-point type,
> then they need to be distinct types. And distinct types need to
> mangle differently. Consider
> #include <stdfloat>
> template <typename T>
> void bar () {}
> void baz ()
> {
> bar<__bf16> ();
> bar<decltype (0.0bf16)> ();
> bar<std::bfloat16_t> ();
> }
> If __bf16 is distinct from the latter two which are the same type,
> then it will instantiate bar twice, for both of those types, but
> if they are mangled the same, will emit two functions with the same
> name and assembler will reject it (or LTO might ICE etc.).
>
> Note, e.g.
> void foo (__float128, __ieee128, long double, _Float128) {}
> template <typename T>
> void bar () {}
> void baz ()
> {
> bar <__float128> ();
> bar <__ieee128> ();
> bar <long double> ();
> }
> works on powerpc64le-linux with -mlong-double-128 -mabi=ieeelongdouble
> because __float128, __ieee128 and long double types are in that case
> the same type, not distinct, so e.g. bar is instantiated just once
> (only _Float128 mangles differently above). With
> -mlong-double-128 -mabi=ibmlongdouble __float128 and __ieee128 are
> the same (non-standard) type, while long double mangles differently
> (g) and _Float128 too, so bar is instantiated twice.
>
> So, either __bf16 should be also extended floating-point type
> like decltype (0.0bf16) and std::bfloat16_t and in that case
> it is fine if it mangles u6__bf16, or __bf16 will be a distinct
> type from the latter two,
Yeah, the former is what I meant. The intention is that __bf16 and
std::bfloat16_t are the same type, not distinct types.
Richard
> __bf16 non-standard arithmetic type
> while the latter two extended floating-point types, but then
> they need to mangle differently, most likely u6__bf16 vs. DF16b.
>
> Jakub
next prev parent reply other threads:[~2023-03-10 8:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-30 9:50 Patch ping Jakub Jelinek
2023-01-30 23:07 ` Richard Sandiford
2023-02-01 10:27 ` AArch64 bfloat16 mangling Jakub Jelinek
2023-03-09 17:14 ` Richard Sandiford
2023-03-10 8:37 ` Jakub Jelinek
2023-03-10 8:43 ` Richard Sandiford [this message]
2023-03-10 11:30 ` Jakub Jelinek
2023-03-10 11:50 ` Richard Sandiford
2023-03-10 15:35 ` Jakub Jelinek
2023-03-10 16:25 ` Richard Sandiford
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=mpth6utyp2h.fsf@arm.com \
--to=richard.sandiford@arm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=jason@redhat.com \
--cc=kyrylo.tkachov@arm.com \
--cc=richard.earnshaw@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).