From: chenxiaolong <chenxiaolong@loongson.cn>
To: Joseph Myers <joseph@codesourcery.com>, Xi Ruoyao <xry111@xry111.site>
Cc: gcc-patches@gcc.gnu.org, i@xen0n.name, xuchenghua@loongson.cn,
chenglulu@loongson.cn
Subject: Re: [PATCH v3] LoongArch:Implement 128-bit floating point functions in gcc.
Date: Fri, 18 Aug 2023 14:39:50 +0800 [thread overview]
Message-ID: <e0d390590a125510845f3349e1aea0a2e464a17b.camel@loongson.cn> (raw)
In-Reply-To: <8e88bba4-377a-93fb-6e7b-fafcf1a6f028@codesourcery.com>
在 2023-08-17四的 15:08 +0000,Joseph Myers写道:
> On Thu, 17 Aug 2023, Xi Ruoyao via Gcc-patches wrote:
>
> > So I guess we just need
> >
> > builtin_define ("__builtin_fabsq=__builtin_fabsf128");
> > builtin_define ("__builtin_nanq=__builtin_nanf128");
> >
> > etc. to map the "q" builtins to "f128" builtins if we really need
> > the
> > "q" builtins.
> >
> > Joseph: the problem here is many customers of LoongArch CPUs wish
> > to
> > compile their old code with minimal change. Is it acceptable to
> > add
> > these builtin_define's like rs6000-c.cc? Note "a new architecture"
> > does
> > not mean we'll only compile post-C2x-era programs onto it.
>
> The powerpc support for __float128 started in GCC 6, predating the
> support
> for _FloatN type names, built-in functions etc. in GCC 7 - that's
> why
> there's such backwards compatibility support there. That name only
> exists
> on a few architectures.
>
> If people really want to compile code using the old __float128 names
> for
> LoongArch I suppose you could have such #defines, but it would be
> better
> for people to make their code use the standard names (as supported
> from
> GCC 7 onwards, though only from GCC 13 in C++) and then put
> backwards
> compatibility in their code for using the __float128 names if they
> want to
> support the type with older GCC (GCC 6 or before for C; GCC 12 or
> before
> for C++) on x86_64 / i386 / powerpc / ia64. Such backwards
> compatibility
> in user code is more likely to be relevant for C++ than for C, given
> how
> the C++ support was added to GCC much more recently. (Note: I
> haven't
> checked when other compilers added support for the _Float128 name or
> associated built-in functions, whether for C or for C++, which might
> also
> affect when user code wants such compatibility.)
>
Thank you for your valuable comments. On the LoongArch architecture,
the "__float128" type is associated with float128_type_node and the "q"
suffix function is mapped to the "f128" function. This allows
compatibility with both "__float128" and "_Float128" types in the GCC
compiler. The new code is modified as follows:
Add the following to the loongarch-builtins.c file:
+lang_hooks.types.register_builtin_type (float128_type_node,
"__float128");
Add the following to the loongarch-c.c file:
+builtin_define ("__builtin_fabsq=__builtin_fabsf128");
+builtin_define ("__builtin_copysignq=__builtin_copysignf128");
+builtin_define ("__builtin_nanq=__builtin_nanf128");
+builtin_define ("__builtin_nansq=__builtin_nansf128");
+builtin_define ("__builtin_infq=__builtin_inff128");
+builtin_define ("__builtin_huge_valq=__builtin_huge_valf128");
The regression tests of the six functions were added without problems.
However, the implementation of the __builtin_nansq() function does not
get the result we want. The questions are as follows:
x86_64:
_Float128 ret=__builtin_nansf128("NAN");
compiled to (with gcc test.c -O2 ):
.cfi_offset 1, -8
bl %plt(__builtin_nansf128)
..
LoongArch:
_Float128 ret=__builtin_nansf128("NAN");
compiled to (with gcc test.c -O2 ):
.cfi_offset 1, -8
bl %plt(__builtin_nansf128)
..
Obviously, there may have been legacy issues with the implementation
when "_Float128 __builtin_nansf128()" was first supported.
Architectures including LoongArch, x86_64, arm, etc. are no longer
supported, and some of the remaining architectures are unproven.
I will continue to follow up the implementation of the builtin
function and complete the function.
next prev parent reply other threads:[~2023-08-18 6:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-15 10:39 chenxiaolong
2023-08-15 10:48 ` Xi Ruoyao
2023-08-17 6:56 ` chenxiaolong
2023-08-15 20:03 ` Joseph Myers
2023-08-16 10:08 ` chenxiaolong
2023-08-16 13:16 ` Joseph Myers
2023-08-17 3:44 ` Xi Ruoyao
2023-08-17 15:08 ` Joseph Myers
2023-08-18 6:39 ` chenxiaolong [this message]
2023-08-18 6:58 ` Xi Ruoyao
2023-08-18 7:05 ` Xi Ruoyao
2023-08-18 7:19 ` Xi Ruoyao
2023-08-18 7:52 ` chenxiaolong
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=e0d390590a125510845f3349e1aea0a2e464a17b.camel@loongson.cn \
--to=chenxiaolong@loongson.cn \
--cc=chenglulu@loongson.cn \
--cc=gcc-patches@gcc.gnu.org \
--cc=i@xen0n.name \
--cc=joseph@codesourcery.com \
--cc=xry111@xry111.site \
--cc=xuchenghua@loongson.cn \
/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).