diff mbox series

[07/52] darwin: Replace use of LONG_DOUBLE_TYPE_SIZE

Message ID 909a932023fd8e3df3bb6a92071e098ce4fc108d.1717134752.git.linkw@linux.ibm.com
State New
Headers show
Series Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook | expand

Commit Message

Kewen.Lin June 3, 2024, 3 a.m. UTC
Joseph pointed out "floating types should have their mode,
not a poorly defined precision value" in the discussion[1],
as he and Richi suggested, the existing macros
{FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE will be replaced with a
hook mode_for_floating_type.  To be prepared for that, this
patch is to replace use of LONG_DOUBLE_TYPE_SIZE in darwin.c
with TYPE_PRECISION of long_double_type_node.

[1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html

gcc/ChangeLog:

	* config/darwin.cc (darwin_patch_builtins): Use TYPE_PRECISION of
	long_double_type_node to replace LONG_DOUBLE_TYPE_SIZE.
---
 gcc/config/darwin.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Iain Sandoe June 4, 2024, 6:21 a.m. UTC | #1
Hi Kewen,

> On 3 Jun 2024, at 04:00, Kewen Lin <linkw@linux.ibm.com> wrote:
> 
> Joseph pointed out "floating types should have their mode,
> not a poorly defined precision value" in the discussion[1],
> as he and Richi suggested, the existing macros
> {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE will be replaced with a
> hook mode_for_floating_type.  To be prepared for that, this
> patch is to replace use of LONG_DOUBLE_TYPE_SIZE in darwin.c
> with TYPE_PRECISION of long_double_type_node.
> 
> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
> 
> gcc/ChangeLog:
> 
> 	* config/darwin.cc (darwin_patch_builtins): Use TYPE_PRECISION of
> 	long_double_type_node to replace LONG_DOUBLE_TYPE_SIZE.
> ---
> gcc/config/darwin.cc | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc
> index 63b8c509405..9129378be37 100644
> --- a/gcc/config/darwin.cc
> +++ b/gcc/config/darwin.cc
> @@ -3620,7 +3620,7 @@ darwin_patch_builtin (enum built_in_function fncode)
> void
> darwin_patch_builtins (void)
> {
> -  if (LONG_DOUBLE_TYPE_SIZE != 128)
> +  if (TYPE_PRECISION (long_double_type_node) != 128)
>     return;

Darwin (at this revision) supports  long-double-{64,128}, but the support is limited
to ibm128 for the 128b case.

The purpose of this code is to adjust the libc function name in response to the
{64,128} for the long double type - when that is 128.

It seems that the revised version should be no less fragile than the original (since
we now have potentially two 128b long double formats, although IEEE754 is not yet 
implemented for < p7 so should not (yet) be relevant).

So, OK for the Darwin parts.
thanks,
Iain


> 
> #define PATCH_BUILTIN(fncode) darwin_patch_builtin (fncode);
> -- 
> 2.43.0
>
Kewen.Lin June 5, 2024, 9:29 a.m. UTC | #2
Hi Iain,

on 2024/6/4 14:21, Iain Sandoe wrote:
> Hi Kewen,
> 
>> On 3 Jun 2024, at 04:00, Kewen Lin <linkw@linux.ibm.com> wrote:
>>
>> Joseph pointed out "floating types should have their mode,
>> not a poorly defined precision value" in the discussion[1],
>> as he and Richi suggested, the existing macros
>> {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE will be replaced with a
>> hook mode_for_floating_type.  To be prepared for that, this
>> patch is to replace use of LONG_DOUBLE_TYPE_SIZE in darwin.c
>> with TYPE_PRECISION of long_double_type_node.
>>
>> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
>>
>> gcc/ChangeLog:
>>
>> 	* config/darwin.cc (darwin_patch_builtins): Use TYPE_PRECISION of
>> 	long_double_type_node to replace LONG_DOUBLE_TYPE_SIZE.
>> ---
>> gcc/config/darwin.cc | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc
>> index 63b8c509405..9129378be37 100644
>> --- a/gcc/config/darwin.cc
>> +++ b/gcc/config/darwin.cc
>> @@ -3620,7 +3620,7 @@ darwin_patch_builtin (enum built_in_function fncode)
>> void
>> darwin_patch_builtins (void)
>> {
>> -  if (LONG_DOUBLE_TYPE_SIZE != 128)
>> +  if (TYPE_PRECISION (long_double_type_node) != 128)
>>     return;
> 
> Darwin (at this revision) supports  long-double-{64,128}, but the support is limited
> to ibm128 for the 128b case.
> 
> The purpose of this code is to adjust the libc function name in response to the
> {64,128} for the long double type - when that is 128.
> 
> It seems that the revised version should be no less fragile than the original (since
> we now have potentially two 128b long double formats, although IEEE754 is not yet 
> implemented for < p7 so should not (yet) be relevant).

Thanks for the information, yes, from what's in build_common_tree_nodes, both
LONG_DOUBLE_TYPE_SIZE and TYPE_PRECISION (long_double_type_node) should be the same.

> 
> So, OK for the Darwin parts.

Pushed as r15-1034, thanks!

BR,
Kewen

> thanks,
> Iain
> 
> 
>>
>> #define PATCH_BUILTIN(fncode) darwin_patch_builtin (fncode);
>> -- 
>> 2.43.0
>>
>
diff mbox series

Patch

diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc
index 63b8c509405..9129378be37 100644
--- a/gcc/config/darwin.cc
+++ b/gcc/config/darwin.cc
@@ -3620,7 +3620,7 @@  darwin_patch_builtin (enum built_in_function fncode)
 void
 darwin_patch_builtins (void)
 {
-  if (LONG_DOUBLE_TYPE_SIZE != 128)
+  if (TYPE_PRECISION (long_double_type_node) != 128)
     return;
 
 #define PATCH_BUILTIN(fncode) darwin_patch_builtin (fncode);