"Kewen.Lin" <[email protected]> writes:
> Hi Gaius,
>
>>> static tree
>>> build_m2_short_real_node (void)
>>> {
>>> - tree c;
>>> -
>>> - /* Define `REAL'. */
>>> -
>>> - c = make_node (REAL_TYPE);
>>> - TYPE_PRECISION (c) = FLOAT_TYPE_SIZE;
>>> - layout_type (c);
>>> - return c;
>>> + /* Define `SHORTREAL'. */
>>> + layout_type (float_type_node);
>>
>> It looks that float_type_node, double_type_node, float128_type_node and
>> long_double_type_node have been called with layout_type when they are
>> being initialized in function build_common_tree_nodes, maybe we can just
>> assert their TYPE_SIZE.
>
> I just noticed that latest trunk still has {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> in gcc/m2 and realized that my comment above was misleading, sorry about that.
> It meant TYPE_SIZE (float_type_node) etc. instead of
> {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE,
> as this patch series would like to get rid of
> {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE.
>
> I adjusted them as below patch, does this look good to you?
Hi Kewen,
ah yes indeed, lgtm,
regards,
Gaius
>
> BR,
> Kewen
> -----
>
> [PATCH] m2: Remove uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
>
> 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 remove uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> in m2. Currently they are used for assertion and can be
> replaced with TYPE_SIZE check on the corresponding type node,
> since we dropped the call to layout_type which would early
> return once TYPE_SIZE is set and this assertion ensures it's
> safe to drop that call.
>
> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
>
> gcc/m2/ChangeLog:
>
> * gm2-gcc/m2type.cc (build_m2_short_real_node): Adjust assertion with
> TYPE_SIZE check.
> (build_m2_real_node): Likewise.
> (build_m2_long_real_node): Add assertion with TYPE_SIZE check.
> ---
> gcc/m2/gm2-gcc/m2type.cc | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/m2/gm2-gcc/m2type.cc b/gcc/m2/gm2-gcc/m2type.cc
> index 5773a5cbd19..7ed184518cb 100644
> --- a/gcc/m2/gm2-gcc/m2type.cc
> +++ b/gcc/m2/gm2-gcc/m2type.cc
> @@ -1416,7 +1416,7 @@ static tree
> build_m2_short_real_node (void)
> {
> /* Define `SHORTREAL'. */
> - ASSERT_CONDITION (TYPE_PRECISION (float_type_node) == FLOAT_TYPE_SIZE);
> + ASSERT_CONDITION (TYPE_SIZE (float_type_node));
> return float_type_node;
> }
>
> @@ -1424,7 +1424,7 @@ static tree
> build_m2_real_node (void)
> {
> /* Define `REAL'. */
> - ASSERT_CONDITION (TYPE_PRECISION (double_type_node) == DOUBLE_TYPE_SIZE);
> + ASSERT_CONDITION (TYPE_SIZE (double_type_node));
> return double_type_node;
> }
>
> @@ -1432,12 +1432,13 @@ static tree
> build_m2_long_real_node (void)
> {
> tree longreal;
> -
> +
> /* Define `LONGREAL'. */
> if (M2Options_GetIEEELongDouble ())
> longreal = float128_type_node;
> else
> longreal = long_double_type_node;
> + ASSERT_CONDITION (TYPE_SIZE (longreal));
> return longreal;
> }
>
> --
> 2.43.0