On Tue, 2 Feb 2021, Patrick McGehearty via Gcc-patches wrote:

>         if (mode == TYPE_MODE (double_type_node))
> -         ; /* Empty suffix correct.  */
> +         {
> +           ; /* Empty suffix correct.  */
> +           memcpy (modename, "DBL", 4);
> +         }
>         else if (mode == TYPE_MODE (float_type_node))
> -         suffix[0] = 'f';
> +         {
> +           suffix[0] = 'f';
> +           memcpy (modename, "FLT", 4);
> +         }
>         else if (mode == TYPE_MODE (long_double_type_node))
> -         suffix[0] = 'l';
> +         {
> +           suffix[0] = 'l';
> +           memcpy (modename, "LDBL", 4);
> +         }
>         else
>           {
>             bool found_suffix = false;
> @@ -1305,6 +1316,8 @@ c_cpp_builtins (cpp_reader *pfile)
>                   sprintf (suffix, "f%d%s", floatn_nx_types[i].n,
>                            floatn_nx_types[i].extended ? "x" : "");
>                   found_suffix = true;
> +                 sprintf (modename, "FLT%d%s", floatn_nx_types[i].n,
> +                          floatn_nx_types[i].extended ? "X" : "");
>                   break;
>                 }
>             gcc_assert (found_suffix);

Here you're properly computing the mapping from mode to float.h macro 
prefix (though I think "modename" is a confusing name for the variable 
used for float.h macro prefixes; to me, "modename" suggests the names such 
as SF or DF, which are actually "name" here, and something like 
"float_h_prefix" would be better than "modename").

> +       if ((mode == TYPE_MODE (float_type_node))
> +           || (mode == TYPE_MODE (double_type_node))
> +           || (mode == TYPE_MODE (long_double_type_node)))

But then here you still have the check for the mode matching one of those 
three types, which defeats the point of computing the prefix in a way that 
works for *all* floating-point modes supported in libgcc.  (The above 
"gcc_assert (found_suffix)" asserts that the relevant mapping did get 
found.)

To be able to use the __LIBGCC_* macros in libgcc in all cases, they 
should be defined, using the modename (or float_h_prefix) found above, 
whether or not the mode matches one of float, double and long double.

>  #elif defined(L_multc3) || defined(L_divtc3)
>  # define MTYPE       TFtype
>  # define CTYPE       TCtype
>  # define MODE        tc
>  # define CEXT        __LIBGCC_TF_FUNC_EXT__
>  # define NOTRUNC (!__LIBGCC_TF_EXCESS_PRECISION__)
> +#if defined(__LIBGCC_TF_MIN__)
> +# define RBIG        ((__LIBGCC_TF_MAX__)/2)
> +# define RMIN        (__LIBGCC_TF_MIN__)
> +# define RMIN2       (__LIBGCC_TF_EPSILON__)
> +# define RMINSCAL (1/__LIBGCC_TF_EPSILON__)
> +#else
> +# define RBIG        ((__LIBGCC_XF_MAX__)/2)
> +# define RMIN        (__LIBGCC_XF_MIN__)
> +# define RMIN2       (__LIBGCC_XF_EPSILON__)
> +# define RMINSCAL (1/__LIBGCC_XF_EPSILON__)
> +#endif

Once you've removed the unnecessary conditional above, you don't need this 
conditional on __LIBGCC_TF_MIN__ being defined either; the *TF* macros 
will always be defined when TFmode is supported in libgcc, so you never 
need to use *XF* macros instead when building TFmode code.

-- 
Joseph S. Myers
jos...@codesourcery.com

Reply via email to