From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id BBAE03858C5E for ; Fri, 10 Mar 2023 08:43:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BBAE03858C5E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 05DA71515; Fri, 10 Mar 2023 00:43:48 -0800 (PST) Received: from localhost (e121540-lin.manchester.arm.com [10.32.110.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id ABEF53F67D; Fri, 10 Mar 2023 00:43:03 -0800 (PST) From: Richard Sandiford To: Jakub Jelinek Mail-Followup-To: Jakub Jelinek ,Richard Earnshaw , Kyrylo Tkachov , Jason Merrill , gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Cc: Richard Earnshaw , Kyrylo Tkachov , Jason Merrill , gcc-patches@gcc.gnu.org Subject: Re: AArch64 bfloat16 mangling References: Date: Fri, 10 Mar 2023 08:43:02 +0000 In-Reply-To: (Jakub Jelinek's message of "Fri, 10 Mar 2023 09:37:09 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-27.5 required=5.0 tests=BAYES_00,KAM_DMARC_NONE,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Jakub Jelinek 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 > template > void bar () {} > void baz () > { > bar<__bf16> (); > bar (); > bar (); > } > 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 > void bar () {} > void baz () > { > bar <__float128> (); > bar <__ieee128> (); > bar (); > } > 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