Message ID | 1866bf880d193a7ff86b4673fe17a5d3e9ab6a96.1717134752.git.linkw@linux.ibm.com |
---|---|
State | New |
Headers | show |
Series | Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook | expand |
Hi, Am 03.06.24 um 05:00 schrieb Kewen Lin: > 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 {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE > in fortran with TYPE_PRECISION of > {float,{,long_}double}_type_node. > > [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html > > gcc/fortran/ChangeLog: > > * trans-intrinsic.cc (build_round_expr): Use TYPE_PRECISION of > long_double_type_node to replace LONG_DOUBLE_TYPE_SIZE. > * trans-types.cc (gfc_build_real_type): Use TYPE_PRECISION of > {float,double,long_double}_type_node to replace > {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE. > --- > gcc/fortran/trans-intrinsic.cc | 3 ++- > gcc/fortran/trans-types.cc | 10 ++++++---- > 2 files changed, 8 insertions(+), 5 deletions(-) > > diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc > index 912c1000e18..96839705112 100644 > --- a/gcc/fortran/trans-intrinsic.cc > +++ b/gcc/fortran/trans-intrinsic.cc > @@ -395,7 +395,8 @@ build_round_expr (tree arg, tree restype) > don't have an appropriate function that converts directly to the integer > type (such as kind == 16), just use ROUND, and then convert the result to > an integer. We might also need to convert the result afterwards. */ > - if (resprec <= INT_TYPE_SIZE && argprec <= LONG_DOUBLE_TYPE_SIZE) > + if (resprec <= INT_TYPE_SIZE > + && argprec <= TYPE_PRECISION (long_double_type_node)) > fn = builtin_decl_for_precision (BUILT_IN_IROUND, argprec); > else if (resprec <= LONG_TYPE_SIZE) > fn = builtin_decl_for_precision (BUILT_IN_LROUND, argprec); > diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc > index 8466c595e06..0ef67723fcd 100644 > --- a/gcc/fortran/trans-types.cc > +++ b/gcc/fortran/trans-types.cc > @@ -873,13 +873,15 @@ gfc_build_real_type (gfc_real_info *info) > int mode_precision = info->mode_precision; > tree new_type; > > - if (mode_precision == FLOAT_TYPE_SIZE) > + if (mode_precision == TYPE_PRECISION (float_type_node)) > info->c_float = 1; > - if (mode_precision == DOUBLE_TYPE_SIZE) > + if (mode_precision == TYPE_PRECISION (double_type_node)) > info->c_double = 1; > - if (mode_precision == LONG_DOUBLE_TYPE_SIZE && !info->c_float128) > + if (mode_precision == TYPE_PRECISION (long_double_type_node) > + && !info->c_float128) > info->c_long_double = 1; > - if (mode_precision != LONG_DOUBLE_TYPE_SIZE && mode_precision == 128) > + if (mode_precision != TYPE_PRECISION (long_double_type_node) > + && mode_precision == 128) > { > /* TODO: see PR101835. */ > info->c_float128 = 1; the Fortran part looks good to me. Thanks, Harald
Hi Harald, on 2024/6/4 04:01, Harald Anlauf wrote: > Hi, > > Am 03.06.24 um 05:00 schrieb Kewen Lin: >> 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 {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE >> in fortran with TYPE_PRECISION of >> {float,{,long_}double}_type_node. >> >> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html >> >> gcc/fortran/ChangeLog: >> >> * trans-intrinsic.cc (build_round_expr): Use TYPE_PRECISION of >> long_double_type_node to replace LONG_DOUBLE_TYPE_SIZE. >> * trans-types.cc (gfc_build_real_type): Use TYPE_PRECISION of >> {float,double,long_double}_type_node to replace >> {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE. >> --- >> gcc/fortran/trans-intrinsic.cc | 3 ++- >> gcc/fortran/trans-types.cc | 10 ++++++---- >> 2 files changed, 8 insertions(+), 5 deletions(-) >> >> diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc >> index 912c1000e18..96839705112 100644 >> --- a/gcc/fortran/trans-intrinsic.cc >> +++ b/gcc/fortran/trans-intrinsic.cc >> @@ -395,7 +395,8 @@ build_round_expr (tree arg, tree restype) >> don't have an appropriate function that converts directly to the integer >> type (such as kind == 16), just use ROUND, and then convert the result to >> an integer. We might also need to convert the result afterwards. */ >> - if (resprec <= INT_TYPE_SIZE && argprec <= LONG_DOUBLE_TYPE_SIZE) >> + if (resprec <= INT_TYPE_SIZE >> + && argprec <= TYPE_PRECISION (long_double_type_node)) >> fn = builtin_decl_for_precision (BUILT_IN_IROUND, argprec); >> else if (resprec <= LONG_TYPE_SIZE) >> fn = builtin_decl_for_precision (BUILT_IN_LROUND, argprec); >> diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc >> index 8466c595e06..0ef67723fcd 100644 >> --- a/gcc/fortran/trans-types.cc >> +++ b/gcc/fortran/trans-types.cc >> @@ -873,13 +873,15 @@ gfc_build_real_type (gfc_real_info *info) >> int mode_precision = info->mode_precision; >> tree new_type; >> >> - if (mode_precision == FLOAT_TYPE_SIZE) >> + if (mode_precision == TYPE_PRECISION (float_type_node)) >> info->c_float = 1; >> - if (mode_precision == DOUBLE_TYPE_SIZE) >> + if (mode_precision == TYPE_PRECISION (double_type_node)) >> info->c_double = 1; >> - if (mode_precision == LONG_DOUBLE_TYPE_SIZE && !info->c_float128) >> + if (mode_precision == TYPE_PRECISION (long_double_type_node) >> + && !info->c_float128) >> info->c_long_double = 1; >> - if (mode_precision != LONG_DOUBLE_TYPE_SIZE && mode_precision == 128) >> + if (mode_precision != TYPE_PRECISION (long_double_type_node) >> + && mode_precision == 128) >> { >> /* TODO: see PR101835. */ >> info->c_float128 = 1; > > the Fortran part looks good to me. Pushed as r15-1033, thanks! BR, Kewen
diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc index 912c1000e18..96839705112 100644 --- a/gcc/fortran/trans-intrinsic.cc +++ b/gcc/fortran/trans-intrinsic.cc @@ -395,7 +395,8 @@ build_round_expr (tree arg, tree restype) don't have an appropriate function that converts directly to the integer type (such as kind == 16), just use ROUND, and then convert the result to an integer. We might also need to convert the result afterwards. */ - if (resprec <= INT_TYPE_SIZE && argprec <= LONG_DOUBLE_TYPE_SIZE) + if (resprec <= INT_TYPE_SIZE + && argprec <= TYPE_PRECISION (long_double_type_node)) fn = builtin_decl_for_precision (BUILT_IN_IROUND, argprec); else if (resprec <= LONG_TYPE_SIZE) fn = builtin_decl_for_precision (BUILT_IN_LROUND, argprec); diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc index 8466c595e06..0ef67723fcd 100644 --- a/gcc/fortran/trans-types.cc +++ b/gcc/fortran/trans-types.cc @@ -873,13 +873,15 @@ gfc_build_real_type (gfc_real_info *info) int mode_precision = info->mode_precision; tree new_type; - if (mode_precision == FLOAT_TYPE_SIZE) + if (mode_precision == TYPE_PRECISION (float_type_node)) info->c_float = 1; - if (mode_precision == DOUBLE_TYPE_SIZE) + if (mode_precision == TYPE_PRECISION (double_type_node)) info->c_double = 1; - if (mode_precision == LONG_DOUBLE_TYPE_SIZE && !info->c_float128) + if (mode_precision == TYPE_PRECISION (long_double_type_node) + && !info->c_float128) info->c_long_double = 1; - if (mode_precision != LONG_DOUBLE_TYPE_SIZE && mode_precision == 128) + if (mode_precision != TYPE_PRECISION (long_double_type_node) + && mode_precision == 128) { /* TODO: see PR101835. */ info->c_float128 = 1;