public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook
@ 2024-06-03  3:00 Kewen Lin
  2024-06-03  3:00 ` [PATCH 01/52] ada: Replace use of LONG_DOUBLE_TYPE_SIZE Kewen Lin
                   ` (51 more replies)
  0 siblings, 52 replies; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:00 UTC (permalink / raw)
  To: gcc-patches
  Cc: linkw, josmyers, richard.guenther, segher, bergner,
	richard.sandiford, jakub, jeffreyalaw

Hi,

Currently how we determine which mode will be used for a
floating point type is that for a given type precision
(size) call mode_for_size to get the first mode which has
this size in the specified class.  On Powerpc, we have
three modes (TF/KF/IF) having the same mode precision 128
(see[1]), so the processing forces us to have to place TF
at the first place, it would require us to make more
adjustment in some generic code to avoid some unexpected
mode conversions and it would be even worse if we get rid
of TF eventually one day.  And as Joseph pointed out in [2],
"floating types should have their mode, not a poorly
defined precision value", as Joseph and Richi suggested,
this patch is to introduce one hook mode_for_floating_type
which returns the corresponding mode for type float, double
or long double.  The default implementation returns SFmode
for float and DFmode for double or long double.  For ports
which need special treatment, there are some other patches
for their own port specific implementation (referring to
how {,LONG_}DOUBLE_TYPE_SIZE get used there).  For all
generic uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE, depending
on the context, some of them are replaced with TYPE_PRECISION
of the according type node, some other are replaced with
GET_MODE_PRECISION on the mode from mode_for_floating_type.
This patch also poisons {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE,
so most defines of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE in port
specific are removed, but there are still some which are
required to be re-defined in subtargets, or used in other
macro defines, so it would be good to keep them as before
but rename them with port specific prefix.

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

- Subpatch 1-8 are prepared for this new hook change by
  replacing uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with
  TYPE_PRECISION of {float,{,long_}double}_type_node.
- Subpatch 9 is the main one to introduce the new hook
  mode_for_floating_type with default implementation.
- Subpatch 10 is to replace some uses in jit with this
  new hook.
- From subpatch 11 to 52, they are target specific.
- Subpatch 11-34 is to remove useless macros
  {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE in target code.
- Subpatch 35-45 is to add target own specific hook
  implementation, also remove useless macros if there are.
- Subpatch 46-51 is to add target own specific hook
  implementation, remove useless macros and rename them
  with target prefix if they are still needed.
- Subpatch 52 is to remove useless LONG_DOUBLE_TYPE_SIZE
  and rename {FLOAT,DOUBLE}_TYPE_SIZE for bfin.

As previous testing on RFC/PATCH, this is bootstrapped
& regtested on powerpc64{,le}-linux-gnu with all langs
on, cross cc1 built well for affected ports at least
one available triple.

Kewen Lin (52):
  ada: Replace use of LONG_DOUBLE_TYPE_SIZE
  d: Replace use of LONG_DOUBLE_TYPE_SIZE
  fortran: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  go: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  rust: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  m2: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  darwin: Replace use of LONG_DOUBLE_TYPE_SIZE
  vms: Replace use of LONG_DOUBLE_TYPE_SIZE
  Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook mode_for_floating_type
  jit: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  arc: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  bpf: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  epiphany: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  fr30: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  frv: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  ft32: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  gcn: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  iq2000: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  lm32: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  m32c: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  m32r: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  microblaze: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  mmix: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  moxie: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  msp430: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  nds32: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  nios2: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  nvptx: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  or1k: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  pdp11: Remove macro LONG_DOUBLE_TYPE_SIZE
  pru: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  stormy16: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  visium: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  xtensa: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  rs6000: New hook implementation rs6000_c_mode_for_floating_type
  aarch64: New hook implementation aarch64_c_mode_for_floating_type
  alpha: New hook implementation alpha_c_mode_for_floating_type
  avr: New hook implementation avr_c_mode_for_floating_type
  i386: New hook implementation ix86_c_mode_for_floating_type
  ia64: New hook implementation ia64_c_mode_for_floating_type
  riscv: New hook implementation riscv_c_mode_for_floating_type
  rl78: New hook implementation rl78_c_mode_for_floating_type
  rx: New hook implementation rx_c_mode_for_floating_type
  s390: New hook implementation s390_c_mode_for_floating_type
  sh: New hook implementation sh_c_mode_for_floating_type
  h8300: New hook implementation h8300_c_mode_for_floating_type
  loongarch: New hook implementation loongarch_c_mode_for_floating_type
  m68k: New hook implementation m68k_c_mode_for_floating_type
  mips: New hook implementation mips_c_mode_for_floating_type
  pa: New hook implementation pa_c_mode_for_floating_type
  sparc: New hook implementation sparc_c_mode_for_floating_type
  bfin: Rename macros {FLOAT,DOUBLE}_TYPE_SIZE

 gcc/ada/gcc-interface/decl.cc      |  3 ++-
 gcc/config/aarch64/aarch64.cc      | 15 ++++++++++++++
 gcc/config/aarch64/aarch64.h       |  6 ------
 gcc/config/alpha/alpha.cc          | 17 ++++++++++++++-
 gcc/config/alpha/alpha.h           |  8 --------
 gcc/config/arc/arc.h               |  3 ---
 gcc/config/avr/avr.cc              | 17 +++++++++++++++
 gcc/config/avr/avr.h               |  3 ---
 gcc/config/bfin/bfin.h             | 11 +++++-----
 gcc/config/bpf/bpf.h               |  3 ---
 gcc/config/darwin.cc               |  2 +-
 gcc/config/epiphany/epiphany.h     |  3 ---
 gcc/config/fr30/fr30.h             |  3 ---
 gcc/config/frv/frv.h               |  3 ---
 gcc/config/ft32/ft32.h             |  4 ----
 gcc/config/gcn/gcn.h               |  3 ---
 gcc/config/h8300/h8300.cc          | 15 ++++++++++++++
 gcc/config/h8300/h8300.h           |  4 +---
 gcc/config/h8300/linux.h           |  4 ++--
 gcc/config/i386/i386.cc            | 15 ++++++++++++++
 gcc/config/i386/i386.h             |  4 ----
 gcc/config/ia64/ia64.cc            | 18 ++++++++++++++++
 gcc/config/ia64/ia64.h             | 12 -----------
 gcc/config/iq2000/iq2000.h         |  3 ---
 gcc/config/lm32/lm32.h             |  4 ----
 gcc/config/loongarch/loongarch.cc  | 15 ++++++++++++++
 gcc/config/loongarch/loongarch.h   | 13 ++++++------
 gcc/config/m32c/m32c.h             |  4 ----
 gcc/config/m32r/m32r.h             |  3 ---
 gcc/config/m68k/m68k.cc            | 16 +++++++++++++++
 gcc/config/m68k/m68k.h             |  4 ++--
 gcc/config/m68k/netbsd-elf.h       |  4 ++--
 gcc/config/microblaze/microblaze.h |  3 ---
 gcc/config/mips/mips.cc            | 14 +++++++++++++
 gcc/config/mips/mips.h             | 13 ++++++------
 gcc/config/mips/n32-elf.h          |  4 ++--
 gcc/config/mmix/mmix.h             |  4 ----
 gcc/config/moxie/moxie.h           |  4 ----
 gcc/config/msp430/msp430.h         |  4 ----
 gcc/config/nds32/nds32.h           |  4 ----
 gcc/config/nios2/nios2.h           |  3 ---
 gcc/config/nvptx/nvptx.h           |  3 ---
 gcc/config/or1k/or1k.h             |  3 ---
 gcc/config/pa/pa-64.h              | 12 +++++------
 gcc/config/pa/pa-hpux.h            |  3 ++-
 gcc/config/pa/pa.cc                | 21 ++++++++++++++++---
 gcc/config/pa/pa.h                 |  6 ++++++
 gcc/config/pdp11/pdp11.h           | 11 ----------
 gcc/config/pru/pru.h               |  3 ---
 gcc/config/riscv/riscv.cc          | 15 ++++++++++++++
 gcc/config/riscv/riscv.h           |  4 ----
 gcc/config/rl78/rl78.cc            | 15 ++++++++++++++
 gcc/config/rl78/rl78.h             |  4 ----
 gcc/config/rs6000/rs6000.cc        | 16 +++++++++++++++
 gcc/config/rs6000/rs6000.h         | 14 -------------
 gcc/config/rx/rx.cc                | 15 ++++++++++++++
 gcc/config/rx/rx.h                 |  4 ----
 gcc/config/s390/s390.cc            | 15 ++++++++++++++
 gcc/config/s390/s390.h             |  3 ---
 gcc/config/sh/sh.cc                | 18 ++++++++++++++++
 gcc/config/sh/sh.h                 | 10 ---------
 gcc/config/sparc/freebsd.h         |  4 ++--
 gcc/config/sparc/linux.h           |  2 +-
 gcc/config/sparc/linux64.h         |  4 ++--
 gcc/config/sparc/netbsd-elf.h      | 12 +++++------
 gcc/config/sparc/openbsd64.h       |  4 ++--
 gcc/config/sparc/sol2.h            |  2 +-
 gcc/config/sparc/sp-elf.h          |  4 ++--
 gcc/config/sparc/sp64-elf.h        |  4 ++--
 gcc/config/sparc/sparc.cc          | 31 ++++++++++++++++++----------
 gcc/config/sparc/sparc.h           |  9 ++++----
 gcc/config/stormy16/stormy16.h     |  6 ------
 gcc/config/visium/visium.h         | 29 ++++++--------------------
 gcc/config/vms/vms.cc              |  5 +++--
 gcc/config/xtensa/xtensa.h         |  3 ---
 gcc/coretypes.h                    |  1 +
 gcc/d/d-target.cc                  |  3 ++-
 gcc/defaults.h                     | 12 -----------
 gcc/doc/rtl.texi                   |  2 +-
 gcc/doc/tm.texi                    | 33 ++++++++++++------------------
 gcc/doc/tm.texi.in                 | 27 +++++++-----------------
 gcc/emit-rtl.cc                    |  3 ++-
 gcc/fortran/trans-intrinsic.cc     |  3 ++-
 gcc/fortran/trans-types.cc         | 10 +++++----
 gcc/go/go-gcc.cc                   | 12 +++++------
 gcc/jit/jit-recording.cc           | 12 +++++++----
 gcc/m2/gm2-gcc/m2type.cc           |  6 +++---
 gcc/real.h                         |  7 ++++---
 gcc/rust/rust-gcc.cc               |  6 +++---
 gcc/system.h                       |  3 ++-
 gcc/target.def                     |  9 ++++++++
 gcc/targhooks.cc                   | 18 +++++++++++++---
 gcc/targhooks.h                    |  1 +
 gcc/tree-core.h                    | 13 ++++++------
 gcc/tree.cc                        | 18 +++++++++++++---
 95 files changed, 455 insertions(+), 353 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 01/52] ada: Replace use of LONG_DOUBLE_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
@ 2024-06-03  3:00 ` Kewen Lin
  2024-06-03  8:51   ` Eric Botcazou
  2024-06-03  3:00 ` [PATCH 02/52] d: " Kewen Lin
                   ` (50 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:00 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, charlet, ebotcazou, poulhies, derodat

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 ada
with TYPE_PRECISION of long_double_type_node.

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

gcc/ada/ChangeLog:

	* gcc-interface/decl.cc (gnat_to_gnu_entity): Use TYPE_PRECISION of
	long_double_type_node to replace LONG_DOUBLE_TYPE_SIZE.
---
 gcc/ada/gcc-interface/decl.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index f6a4c0631b6..8b72c96c439 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -520,7 +520,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
 	  esize = UI_To_Int (Esize (gnat_entity));
 
 	  if (IN (kind, Float_Kind))
-	    max_esize = fp_prec_to_size (LONG_DOUBLE_TYPE_SIZE);
+	    max_esize
+	      = fp_prec_to_size (TYPE_PRECISION (long_double_type_node));
 	  else if (IN (kind, Access_Kind))
 	    max_esize = POINTER_SIZE * 2;
 	  else
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 02/52] d: Replace use of LONG_DOUBLE_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
  2024-06-03  3:00 ` [PATCH 01/52] ada: Replace use of LONG_DOUBLE_TYPE_SIZE Kewen Lin
@ 2024-06-03  3:00 ` Kewen Lin
  2024-06-03  8:40   ` Iain Buclaw
  2024-06-03  3:00 ` [PATCH 03/52] fortran: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE Kewen Lin
                   ` (49 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:00 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, ibuclaw

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 d with
TYPE_PRECISION of long_double_type_node.

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

gcc/d/ChangeLog:

	* d-target.cc (Target::_init): Use TYPE_PRECISION of
	long_double_type_node to replace LONG_DOUBLE_TYPE_SIZE.
---
 gcc/d/d-target.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/d/d-target.cc b/gcc/d/d-target.cc
index 127b9d7ce7c..079731f68ab 100644
--- a/gcc/d/d-target.cc
+++ b/gcc/d/d-target.cc
@@ -163,7 +163,8 @@ Target::_init (const Param &)
   this->c.intsize = (INT_TYPE_SIZE / BITS_PER_UNIT);
   this->c.longsize = (LONG_TYPE_SIZE / BITS_PER_UNIT);
   this->c.long_longsize = (LONG_LONG_TYPE_SIZE / BITS_PER_UNIT);
-  this->c.long_doublesize = (LONG_DOUBLE_TYPE_SIZE / BITS_PER_UNIT);
+  this->c.long_doublesize
+    = (TYPE_PRECISION (long_double_type_node) / BITS_PER_UNIT);
   this->c.wchar_tsize = (WCHAR_TYPE_SIZE / BITS_PER_UNIT);
 
   this->c.bitFieldStyle = targetm.ms_bitfield_layout_p (unknown_type_node)
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 03/52] fortran: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
  2024-06-03  3:00 ` [PATCH 01/52] ada: Replace use of LONG_DOUBLE_TYPE_SIZE Kewen Lin
  2024-06-03  3:00 ` [PATCH 02/52] d: " Kewen Lin
@ 2024-06-03  3:00 ` Kewen Lin
  2024-06-03 20:01   ` [PATCH 03/52] fortran: Replace uses of {FLOAT, {, LONG_}DOUBLE}_TYPE_SIZE Harald Anlauf
  2024-06-03  3:00 ` [PATCH 04/52] go: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE Kewen Lin
                   ` (48 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:00 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, fortran, mikael, anlauf

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;
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 04/52] go: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (2 preceding siblings ...)
  2024-06-03  3:00 ` [PATCH 03/52] fortran: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE Kewen Lin
@ 2024-06-03  3:00 ` Kewen Lin
  2024-06-12  9:33   ` Kewen.Lin
  2024-06-03  3:00 ` [PATCH 05/52] rust: " Kewen Lin
                   ` (47 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:00 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, ian

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 go with TYPE_PRECISION of {float,{,long_}double}_type_node.

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

gcc/go/ChangeLog:

	* go-gcc.cc (Gcc_backend::float_type): Use TYPE_PRECISION of
	{float,double,long_double}_type_node to replace
	{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE.
	(Gcc_backend::complex_type): Likewise.
---
 gcc/go/go-gcc.cc | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/go/go-gcc.cc b/gcc/go/go-gcc.cc
index bc9732c3db3..6aa751f9f30 100644
--- a/gcc/go/go-gcc.cc
+++ b/gcc/go/go-gcc.cc
@@ -993,11 +993,11 @@ Btype*
 Gcc_backend::float_type(int bits)
 {
   tree type;
-  if (bits == FLOAT_TYPE_SIZE)
+  if (bits == TYPE_PRECISION (float_type_node))
     type = float_type_node;
-  else if (bits == DOUBLE_TYPE_SIZE)
+  else if (bits == TYPE_PRECISION (double_type_node))
     type = double_type_node;
-  else if (bits == LONG_DOUBLE_TYPE_SIZE)
+  else if (bits == TYPE_PRECISION (long_double_type_node))
     type = long_double_type_node;
   else
     {
@@ -1014,11 +1014,11 @@ Btype*
 Gcc_backend::complex_type(int bits)
 {
   tree type;
-  if (bits == FLOAT_TYPE_SIZE * 2)
+  if (bits == TYPE_PRECISION (float_type_node) * 2)
     type = complex_float_type_node;
-  else if (bits == DOUBLE_TYPE_SIZE * 2)
+  else if (bits == TYPE_PRECISION (double_type_node) * 2)
     type = complex_double_type_node;
-  else if (bits == LONG_DOUBLE_TYPE_SIZE * 2)
+  else if (bits == TYPE_PRECISION (long_double_type_node) * 2)
     type = complex_long_double_type_node;
   else
     {
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 05/52] rust: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (3 preceding siblings ...)
  2024-06-03  3:00 ` [PATCH 04/52] go: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE Kewen Lin
@ 2024-06-03  3:00 ` Kewen Lin
  2024-06-12  9:35   ` PING^1 " Kewen.Lin
  2024-06-21 10:17   ` Arthur Cohen
  2024-06-03  3:00 ` [PATCH 06/52] m2: " Kewen Lin
                   ` (46 subsequent siblings)
  51 siblings, 2 replies; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:00 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, arthur.cohen, herron.philip

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 rust with TYPE_PRECISION of {float,{,long_}double}_type_node.

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

gcc/rust/ChangeLog:

	* rust-gcc.cc (float_type): Use TYPE_PRECISION of
	{float,double,long_double}_type_node to replace
	{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE.
---
 gcc/rust/rust-gcc.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
index f17e19a2dfc..38169c08985 100644
--- a/gcc/rust/rust-gcc.cc
+++ b/gcc/rust/rust-gcc.cc
@@ -411,11 +411,11 @@ tree
 float_type (int bits)
 {
   tree type;
-  if (bits == FLOAT_TYPE_SIZE)
+  if (bits == TYPE_PRECISION (float_type_node))
     type = float_type_node;
-  else if (bits == DOUBLE_TYPE_SIZE)
+  else if (bits == TYPE_PRECISION (double_type_node))
     type = double_type_node;
-  else if (bits == LONG_DOUBLE_TYPE_SIZE)
+  else if (bits == TYPE_PRECISION (long_double_type_node))
     type = long_double_type_node;
   else
     {
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 06/52] m2: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (4 preceding siblings ...)
  2024-06-03  3:00 ` [PATCH 05/52] rust: " Kewen Lin
@ 2024-06-03  3:00 ` Kewen Lin
  2024-06-03 12:42   ` Gaius Mulley
  2024-06-03 18:02   ` Joseph Myers
  2024-06-03  3:00 ` [PATCH 07/52] darwin: Replace use of LONG_DOUBLE_TYPE_SIZE Kewen Lin
                   ` (45 subsequent siblings)
  51 siblings, 2 replies; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:00 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, gaiusmod2

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 m2 with TYPE_PRECISION of {float,{,long_}double}_type_node.

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

gcc/m2/ChangeLog:

	* gm2-gcc/m2type.cc (build_m2_short_real_node): Use TYPE_PRECISION of
	float_type_node to replace FLOAT_TYPE_SIZE.
	(build_m2_real_node): Use TYPE_PRECISION of double_type_node to
	replace DOUBLE_TYPE_SIZE.
	(build_m2_long_real_node): Use TYPE_PRECISION of
	long_double_type_node to replace LONG_DOUBLE_TYPE_SIZE.
---
 gcc/m2/gm2-gcc/m2type.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/m2/gm2-gcc/m2type.cc b/gcc/m2/gm2-gcc/m2type.cc
index 571923c08ef..d52cbdf0b99 100644
--- a/gcc/m2/gm2-gcc/m2type.cc
+++ b/gcc/m2/gm2-gcc/m2type.cc
@@ -1420,7 +1420,7 @@ build_m2_short_real_node (void)
   /* Define `REAL'.  */
 
   c = make_node (REAL_TYPE);
-  TYPE_PRECISION (c) = FLOAT_TYPE_SIZE;
+  TYPE_PRECISION (c) = TYPE_PRECISION (float_type_node);
   layout_type (c);
   return c;
 }
@@ -1433,7 +1433,7 @@ build_m2_real_node (void)
   /* Define `REAL'.  */
 
   c = make_node (REAL_TYPE);
-  TYPE_PRECISION (c) = DOUBLE_TYPE_SIZE;
+  TYPE_PRECISION (c) = TYPE_PRECISION (double_type_node);
   layout_type (c);
   return c;
 }
@@ -1447,7 +1447,7 @@ build_m2_long_real_node (void)
   if (M2Options_GetIBMLongDouble ())
     {
       longreal = make_node (REAL_TYPE);
-      TYPE_PRECISION (longreal) = LONG_DOUBLE_TYPE_SIZE;
+      TYPE_PRECISION (longreal) = TYPE_PRECISION (long_double_type_node);
     }
   else if (M2Options_GetIEEELongDouble ())
     longreal = float128_type_node;
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 07/52] darwin: Replace use of LONG_DOUBLE_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (5 preceding siblings ...)
  2024-06-03  3:00 ` [PATCH 06/52] m2: " Kewen Lin
@ 2024-06-03  3:00 ` Kewen Lin
  2024-06-04  6:21   ` Iain Sandoe
  2024-06-03  3:00 ` [PATCH 08/52] vms: " Kewen Lin
                   ` (44 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:00 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, iain, mikestump

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;
 
 #define PATCH_BUILTIN(fncode) darwin_patch_builtin (fncode);
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 08/52] vms: Replace use of LONG_DOUBLE_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (6 preceding siblings ...)
  2024-06-03  3:00 ` [PATCH 07/52] darwin: Replace use of LONG_DOUBLE_TYPE_SIZE Kewen Lin
@ 2024-06-03  3:00 ` Kewen Lin
  2024-06-12  9:36   ` PING^1 " Kewen.Lin
  2024-06-03  3:00 ` [PATCH 09/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook mode_for_floating_type Kewen Lin
                   ` (43 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:00 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, douglas.b.rupp, tgingold

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 vms port
with TYPE_PRECISION of long_double_type_node.

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

gcc/ChangeLog:

	* config/vms/vms.cc (vms_patch_builtins): Use TYPE_PRECISION of
	long_double_type_node to replace LONG_DOUBLE_TYPE_SIZE.
---
 gcc/config/vms/vms.cc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/config/vms/vms.cc b/gcc/config/vms/vms.cc
index d468c79e559..2fcc673c8a9 100644
--- a/gcc/config/vms/vms.cc
+++ b/gcc/config/vms/vms.cc
@@ -141,6 +141,7 @@ vms_patch_builtins (void)
   if (builtin_decl_implicit_p (BUILT_IN_FWRITE_UNLOCKED))
     set_builtin_decl_implicit_p (BUILT_IN_FWRITE_UNLOCKED, false);
 
+  unsigned long_double_type_size = TYPE_PRECISION (long_double_type_node);
   /* Define aliases for names.  */
   for (i = 0; i < NBR_CRTL_NAMES; i++)
     {
@@ -179,7 +180,7 @@ vms_patch_builtins (void)
 	  vms_add_crtl_xlat (alt, nlen + 1, res, rlen);
 
 	  /* Long double version.  */
-	  res[rlen - 1] = (LONG_DOUBLE_TYPE_SIZE == 128 ? 'X' : 'T');
+	  res[rlen - 1] = (long_double_type_size == 128 ? 'X' : 'T');
 	  alt[nlen] = 'l';
 	  vms_add_crtl_xlat (alt, nlen + 1, res, rlen);
 
@@ -223,7 +224,7 @@ vms_patch_builtins (void)
       if (n->flags & VMS_CRTL_FLOAT64)
         res[rlen++] = 't';
 
-      if ((n->flags & VMS_CRTL_FLOAT128) && LONG_DOUBLE_TYPE_SIZE == 128)
+      if ((n->flags & VMS_CRTL_FLOAT128) && long_double_type_size == 128)
         res[rlen++] = 'x';
 
       memcpy (res + rlen, n->name, nlen);
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 09/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook mode_for_floating_type
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (7 preceding siblings ...)
  2024-06-03  3:00 ` [PATCH 08/52] vms: " Kewen Lin
@ 2024-06-03  3:00 ` Kewen Lin
  2024-06-03  6:49   ` Richard Biener
  2024-06-03 17:59   ` [PATCH 09/52] Replace {FLOAT, {, LONG_}DOUBLE}_TYPE_SIZE " Joseph Myers
  2024-06-03  3:01 ` [PATCH 10/52] jit: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE Kewen Lin
                   ` (42 subsequent siblings)
  51 siblings, 2 replies; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:00 UTC (permalink / raw)
  To: gcc-patches
  Cc: linkw, josmyers, richard.guenther, segher, bergner,
	richard.sandiford, jakub, jeffreyalaw

Currently how we determine which mode will be used for a
floating point type is that for a given type precision
(size) call mode_for_size to get the first mode which has
this size in the specified class.  On Powerpc, we have
three modes (TF/KF/IF) having the same mode precision 128
(see[1]), so the processing forces us to have to place TF
at the first place, it would require us to make more
adjustment in some generic code to avoid some unexpected
mode conversions and it would be even worse if we get rid
of TF eventually one day.  And as Joseph pointed out in [2],
"floating types should have their mode, not a poorly
defined precision value", as Joseph and Richi suggested,
this patch is to introduce one hook mode_for_floating_type
which returns the corresponding mode for type float, double
or long double.  The default implementation returns SFmode
for float and DFmode for double or long double.  For ports
which need special treatment, there are some other patches
for their own port specific implementation (referring to
how {,LONG_}DOUBLE_TYPE_SIZE get used there).  For all
generic uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE, depending
on the context, some of them are replaced with TYPE_PRECISION
of the according type node, some other are replaced with
GET_MODE_PRECISION on the mode from mode_for_floating_type.
This patch also poisons {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE,
so most defines of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE in port
specific are removed, but there are still some which are
good to be kept for readability then they get renamed with
port specific prefix.

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

gcc/ChangeLog:

	* coretypes.h (enum tree_index): Forward declaration.
	* defaults.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
	* doc/rtl.texi: Update document by replacing {FLOAT,DOUBLE}_TYPE_SIZE
	with C type {float,double}.
	* doc/tm.texi.in: Document new hook mode_for_floating_type, remove
	document entries for {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE and
	update document for WIDEST_HARDWARE_FP_SIZE.
	* doc/tm.texi: Regenerate.
	* emit-rtl.cc (init_emit_once): Replace DOUBLE_TYPE_SIZE by
	calling targetm.c.mode_for_floating_type with TI_DOUBLE_TYPE.
	* real.h (REAL_VALUE_TO_TARGET_LONG_DOUBLE): Use TYPE_PRECISION of
	long_double_type_node to replace LONG_DOUBLE_TYPE_SIZE.
	* system.h (FLOAT_TYPE_SIZE): Poison.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
	* target.def (mode_for_floating_type): New hook.
	* targhooks.cc (default_mode_for_floating_type): New function.
	(default_scalar_mode_supported_p): Update macros
	{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE by calling
	targetm.c.mode_for_floating_type with
	TI_{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE.
	* targhooks.h (default_mode_for_floating_type): New declaration.
	* tree-core.h (enum tree_index): Specify underlying type unsigned
	to sync with forward declaration in coretypes.h.
	(NUM_FLOATN_TYPES): Explicitly convert to int.
	(NUM_FLOATNX_TYPES): Likewise.
	(NUM_FLOATN_NX_TYPES): Likewise.
	* tree.cc (build_common_tree_nodes): Update macros
	{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE by calling
	targetm.c.mode_for_floating_type with
	TI_{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE and set type mode accordingly.
---
 gcc/coretypes.h    |  1 +
 gcc/defaults.h     | 12 ------------
 gcc/doc/rtl.texi   |  2 +-
 gcc/doc/tm.texi    | 33 +++++++++++++--------------------
 gcc/doc/tm.texi.in | 27 +++++++--------------------
 gcc/emit-rtl.cc    |  3 ++-
 gcc/real.h         |  7 ++++---
 gcc/system.h       |  3 ++-
 gcc/target.def     |  9 +++++++++
 gcc/targhooks.cc   | 18 +++++++++++++++---
 gcc/targhooks.h    |  1 +
 gcc/tree-core.h    | 13 +++++++------
 gcc/tree.cc        | 18 +++++++++++++++---
 13 files changed, 77 insertions(+), 70 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 1ac6f0abea3..00c1c58bd8c 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -100,6 +100,7 @@ struct gimple;
 typedef gimple *gimple_seq;
 struct gimple_stmt_iterator;
 class code_helper;
+enum tree_index : unsigned;
 
 /* Forward declare rtx_code, so that we can use it in target hooks without
    needing to pull in rtl.h.  */
diff --git a/gcc/defaults.h b/gcc/defaults.h
index 92f3e07f742..ac2d25852ab 100644
--- a/gcc/defaults.h
+++ b/gcc/defaults.h
@@ -513,18 +513,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
 #endif
 
-#ifndef FLOAT_TYPE_SIZE
-#define FLOAT_TYPE_SIZE BITS_PER_WORD
-#endif
-
-#ifndef DOUBLE_TYPE_SIZE
-#define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
-#endif
-
-#ifndef LONG_DOUBLE_TYPE_SIZE
-#define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
-#endif
-
 #ifndef DECIMAL32_TYPE_SIZE
 #define DECIMAL32_TYPE_SIZE 32
 #endif
diff --git a/gcc/doc/rtl.texi b/gcc/doc/rtl.texi
index aa10b5235b5..d85b6dcbf1a 100644
--- a/gcc/doc/rtl.texi
+++ b/gcc/doc/rtl.texi
@@ -1326,7 +1326,7 @@ whose size is @code{BITS_PER_WORD}, @code{SImode} on 32-bit machines.
 
 The only modes which a machine description @i{must} support are
 @code{QImode}, and the modes corresponding to @code{BITS_PER_WORD},
-@code{FLOAT_TYPE_SIZE} and @code{DOUBLE_TYPE_SIZE}.
+C type @code{float} and C type type @code{double}.
 The compiler will attempt to use @code{DImode} for 8-byte structures and
 unions, but this can be prevented by overriding the definition of
 @code{MAX_FIXED_MODE_SIZE}.  Alternatively, you can have the compiler
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index cd50078227d..07bf8ed9e0e 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -1044,6 +1044,14 @@ are zero or sign extended depending on if it is
 @code{GET_MODE_ALIGNMENT (info->limb_mode)}.
 @end deftypefn
 
+@deftypefn {Target Hook} machine_mode TARGET_C_MODE_FOR_FLOATING_TYPE (enum tree_index @var{ti})
+Return machine mode for a C floating point type which is indicated by
+ a given @code{enum tree_index} @var{ti}, @var{ti} should be
+ @code{TI_FLOAT_TYPE}, @code{TI_DOUBLE_TYPE} or @code{TI_LONG_DOUBLE_TYPE}.
+ The default implementation returns @code{SFmode} for @code{TI_FLOAT_TYPE},
+ and @code{DFmode} for @code{TI_DOUBLE_TYPE} or @code{TI_LONG_DOUBLE_TYPE}.
+@end deftypefn
+
 @deftypefn {Target Hook} machine_mode TARGET_PROMOTE_FUNCTION_MODE (const_tree @var{type}, machine_mode @var{mode}, int *@var{punsignedp}, const_tree @var{funtype}, int @var{for_return})
 Like @code{PROMOTE_MODE}, but it is applied to outgoing function arguments or
 function return values.  The target hook should return the new mode
@@ -1610,23 +1618,6 @@ C99 type @code{_Bool} on the target machine.  If you don't define
 this, and you probably shouldn't, the default is @code{CHAR_TYPE_SIZE}.
 @end defmac
 
-@defmac FLOAT_TYPE_SIZE
-A C expression for the size in bits of the type @code{float} on the
-target machine.  If you don't define this, the default is one word.
-@end defmac
-
-@defmac DOUBLE_TYPE_SIZE
-A C expression for the size in bits of the type @code{double} on the
-target machine.  If you don't define this, the default is two
-words.
-@end defmac
-
-@defmac LONG_DOUBLE_TYPE_SIZE
-A C expression for the size in bits of the type @code{long double} on
-the target machine.  If you don't define this, the default is two
-words.
-@end defmac
-
 @defmac SHORT_FRACT_TYPE_SIZE
 A C expression for the size in bits of the type @code{short _Fract} on
 the target machine.  If you don't define this, the default is
@@ -1687,9 +1678,11 @@ the libgcc @file{config.host}.
 @defmac WIDEST_HARDWARE_FP_SIZE
 A C expression for the size in bits of the widest floating-point format
 supported by the hardware.  If you define this macro, you must specify a
-value less than or equal to the value of @code{LONG_DOUBLE_TYPE_SIZE}.
-If you do not define this macro, the value of @code{LONG_DOUBLE_TYPE_SIZE}
-is the default.
+value less than or equal to mode precision of the mode used for C type
+@code{long double} (from hook @code{targetm.c.mode_for_floating_type}
+with tree_index TI_LONG_DOUBLE_TYPE).  If you do not define this macro,
+mode precision of the mode used for C type @code{long double} is the
+default.
 @end defmac
 
 @defmac DEFAULT_SIGNED_CHAR
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index 058bd56487a..f6e2372f262 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -947,6 +947,8 @@ applied.
 
 @hook TARGET_C_BITINT_TYPE_INFO
 
+@hook TARGET_C_MODE_FOR_FLOATING_TYPE
+
 @hook TARGET_PROMOTE_FUNCTION_MODE
 
 @defmac PARM_BOUNDARY
@@ -1351,23 +1353,6 @@ C99 type @code{_Bool} on the target machine.  If you don't define
 this, and you probably shouldn't, the default is @code{CHAR_TYPE_SIZE}.
 @end defmac
 
-@defmac FLOAT_TYPE_SIZE
-A C expression for the size in bits of the type @code{float} on the
-target machine.  If you don't define this, the default is one word.
-@end defmac
-
-@defmac DOUBLE_TYPE_SIZE
-A C expression for the size in bits of the type @code{double} on the
-target machine.  If you don't define this, the default is two
-words.
-@end defmac
-
-@defmac LONG_DOUBLE_TYPE_SIZE
-A C expression for the size in bits of the type @code{long double} on
-the target machine.  If you don't define this, the default is two
-words.
-@end defmac
-
 @defmac SHORT_FRACT_TYPE_SIZE
 A C expression for the size in bits of the type @code{short _Fract} on
 the target machine.  If you don't define this, the default is
@@ -1428,9 +1413,11 @@ the libgcc @file{config.host}.
 @defmac WIDEST_HARDWARE_FP_SIZE
 A C expression for the size in bits of the widest floating-point format
 supported by the hardware.  If you define this macro, you must specify a
-value less than or equal to the value of @code{LONG_DOUBLE_TYPE_SIZE}.
-If you do not define this macro, the value of @code{LONG_DOUBLE_TYPE_SIZE}
-is the default.
+value less than or equal to mode precision of the mode used for C type
+@code{long double} (from hook @code{targetm.c.mode_for_floating_type}
+with tree_index TI_LONG_DOUBLE_TYPE).  If you do not define this macro,
+mode precision of the mode used for C type @code{long double} is the
+default.
 @end defmac
 
 @defmac DEFAULT_SIGNED_CHAR
diff --git a/gcc/emit-rtl.cc b/gcc/emit-rtl.cc
index 1856fa4884f..cb04aa1a8c6 100644
--- a/gcc/emit-rtl.cc
+++ b/gcc/emit-rtl.cc
@@ -6366,7 +6366,8 @@ init_emit_once (void)
   else
     const_true_rtx = gen_rtx_CONST_INT (VOIDmode, STORE_FLAG_VALUE);
 
-  double_mode = float_mode_for_size (DOUBLE_TYPE_SIZE).require ();
+  mode = targetm.c.mode_for_floating_type (TI_DOUBLE_TYPE);
+  double_mode = as_a<scalar_float_mode> (mode);
 
   real_from_integer (&dconst0, double_mode, 0, SIGNED);
   real_from_integer (&dconst1, double_mode, 1, SIGNED);
diff --git a/gcc/real.h b/gcc/real.h
index 2e40817a2d7..f28022769b3 100644
--- a/gcc/real.h
+++ b/gcc/real.h
@@ -406,9 +406,10 @@ extern const struct real_format arm_bfloat_half_format;
 #define REAL_VALUE_MINUS_ZERO(x)	real_isnegzero (&(x))
 
 /* IN is a REAL_VALUE_TYPE.  OUT is an array of longs.  */
-#define REAL_VALUE_TO_TARGET_LONG_DOUBLE(IN, OUT)			\
-  real_to_target (OUT, &(IN),						\
-		  float_mode_for_size (LONG_DOUBLE_TYPE_SIZE).require ())
+#define REAL_VALUE_TO_TARGET_LONG_DOUBLE(IN, OUT)			   \
+  real_to_target (OUT, &(IN),						   \
+		  float_mode_for_size (TYPE_PRECISION			   \
+				       (long_double_type_node)).require ())
 
 #define REAL_VALUE_TO_TARGET_DOUBLE(IN, OUT) \
   real_to_target (OUT, &(IN), float_mode_for_size (64).require ())
diff --git a/gcc/system.h b/gcc/system.h
index 1028dcb1eb3..cbb14fb167d 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -1000,7 +1000,8 @@ extern void fancy_abort (const char *, int, const char *)
 	HARD_REGNO_NREGS SECONDARY_MEMORY_NEEDED_MODE			\
 	SECONDARY_MEMORY_NEEDED CANNOT_CHANGE_MODE_CLASS		\
 	TRULY_NOOP_TRUNCATION FUNCTION_ARG_OFFSET CONSTANT_ALIGNMENT	\
-	STARTING_FRAME_OFFSET
+	STARTING_FRAME_OFFSET FLOAT_TYPE_SIZE DOUBLE_TYPE_SIZE		\
+	LONG_DOUBLE_TYPE_SIZE
 
 /* Target macros only used for code built for the target, that have
    moved to libgcc-tm.h or have never been present elsewhere.  */
diff --git a/gcc/target.def b/gcc/target.def
index c27df8095be..4780ba9c15b 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -6370,6 +6370,15 @@ are zero or sign extended depending on if it is\n\
  bool, (int n, struct bitint_info *info),
  default_bitint_type_info)
 
+DEFHOOK
+(mode_for_floating_type,
+"Return machine mode for a C floating point type which is indicated by\n\
+ a given @code{enum tree_index} @var{ti}, @var{ti} should be\n\
+ @code{TI_FLOAT_TYPE}, @code{TI_DOUBLE_TYPE} or @code{TI_LONG_DOUBLE_TYPE}.\n\
+ The default implementation returns @code{SFmode} for @code{TI_FLOAT_TYPE},\n\
+ and @code{DFmode} for @code{TI_DOUBLE_TYPE} or @code{TI_LONG_DOUBLE_TYPE}.",
+ machine_mode, (enum tree_index ti), default_mode_for_floating_type)
+
 HOOK_VECTOR_END (c)
 
 /* Functions specific to the C++ frontend.  */
diff --git a/gcc/targhooks.cc b/gcc/targhooks.cc
index fb339bf75dd..5111e069f0c 100644
--- a/gcc/targhooks.cc
+++ b/gcc/targhooks.cc
@@ -298,6 +298,18 @@ default_mode_for_suffix (char suffix ATTRIBUTE_UNUSED)
   return VOIDmode;
 }
 
+/* Return machine mode for a floating type which is indicated
+   by the given enum tree_index.  */
+
+machine_mode
+default_mode_for_floating_type (enum tree_index ti)
+{
+  if (ti == TI_FLOAT_TYPE)
+    return SFmode;
+  gcc_assert (ti == TI_DOUBLE_TYPE || ti == TI_LONG_DOUBLE_TYPE);
+  return DFmode;
+}
+
 /* The generic C++ ABI specifies this is a 64-bit value.  */
 tree
 default_cxx_guard_type (void)
@@ -449,11 +461,11 @@ default_scalar_mode_supported_p (scalar_mode mode)
       return false;
 
     case MODE_FLOAT:
-      if (precision == FLOAT_TYPE_SIZE)
+      if (mode == targetm.c.mode_for_floating_type (TI_FLOAT_TYPE))
 	return true;
-      if (precision == DOUBLE_TYPE_SIZE)
+      if (mode == targetm.c.mode_for_floating_type (TI_DOUBLE_TYPE))
 	return true;
-      if (precision == LONG_DOUBLE_TYPE_SIZE)
+      if (mode == targetm.c.mode_for_floating_type (TI_LONG_DOUBLE_TYPE))
 	return true;
       return false;
 
diff --git a/gcc/targhooks.h b/gcc/targhooks.h
index 85f3817c176..fdc17c3b7c0 100644
--- a/gcc/targhooks.h
+++ b/gcc/targhooks.h
@@ -289,6 +289,7 @@ extern unsigned int default_min_arithmetic_precision (void);
 extern enum flt_eval_method
 default_excess_precision (enum excess_precision_type ATTRIBUTE_UNUSED);
 extern bool default_bitint_type_info (int, struct bitint_info *);
+extern machine_mode default_mode_for_floating_type (enum tree_index);
 extern HOST_WIDE_INT default_stack_clash_protection_alloca_probe_range (void);
 extern void default_select_early_remat_modes (sbitmap);
 extern tree default_preferred_else_value (unsigned, tree, unsigned, tree *);
diff --git a/gcc/tree-core.h b/gcc/tree-core.h
index 9fa74342919..0b5000acb80 100644
--- a/gcc/tree-core.h
+++ b/gcc/tree-core.h
@@ -624,7 +624,7 @@ enum cv_qualifier {
 };
 
 /* Standard named or nameless data types of the C compiler.  */
-enum tree_index {
+enum tree_index : unsigned {
   TI_ERROR_MARK,
   TI_INTQI_TYPE,
   TI_INTHI_TYPE,
@@ -691,17 +691,18 @@ enum tree_index {
   TI_FLOAT64_TYPE,
   TI_FLOAT128_TYPE,
   TI_FLOATN_TYPE_LAST = TI_FLOAT128_TYPE,
-#define NUM_FLOATN_TYPES (TI_FLOATN_TYPE_LAST - TI_FLOATN_TYPE_FIRST + 1)
+#define NUM_FLOATN_TYPES ((int) (TI_FLOATN_TYPE_LAST		\
+				 - TI_FLOATN_TYPE_FIRST + 1))
   TI_FLOAT32X_TYPE,
   TI_FLOATNX_TYPE_FIRST = TI_FLOAT32X_TYPE,
   TI_FLOAT64X_TYPE,
   TI_FLOAT128X_TYPE,
   TI_FLOATNX_TYPE_LAST = TI_FLOAT128X_TYPE,
   TI_FLOATN_NX_TYPE_LAST = TI_FLOAT128X_TYPE,
-#define NUM_FLOATNX_TYPES (TI_FLOATNX_TYPE_LAST - TI_FLOATNX_TYPE_FIRST + 1)
-#define NUM_FLOATN_NX_TYPES (TI_FLOATN_NX_TYPE_LAST		\
-			     - TI_FLOATN_NX_TYPE_FIRST		\
-			     + 1)
+#define NUM_FLOATNX_TYPES ((int) (TI_FLOATNX_TYPE_LAST		\
+				  - TI_FLOATNX_TYPE_FIRST + 1))
+#define NUM_FLOATN_NX_TYPES ((int) (TI_FLOATN_NX_TYPE_LAST	\
+				  - TI_FLOATN_NX_TYPE_FIRST + 1))
 
   /* Type used by certain backends for __float128, which in C++ should be
      distinct type from _Float128 for backwards compatibility reasons.  */
diff --git a/gcc/tree.cc b/gcc/tree.cc
index 6564b002dc1..bc5175f591e 100644
--- a/gcc/tree.cc
+++ b/gcc/tree.cc
@@ -9596,15 +9596,27 @@ build_common_tree_nodes (bool signed_char)
   pointer_sized_int_node = build_nonstandard_integer_type (POINTER_SIZE, 1);
 
   float_type_node = make_node (REAL_TYPE);
-  TYPE_PRECISION (float_type_node) = FLOAT_TYPE_SIZE;
+  machine_mode float_type_mode
+    = targetm.c.mode_for_floating_type (TI_FLOAT_TYPE);
+  SET_TYPE_MODE (float_type_node, float_type_mode);
+  TYPE_PRECISION (float_type_node)
+    = GET_MODE_PRECISION (float_type_mode).to_constant ();
   layout_type (float_type_node);
 
   double_type_node = make_node (REAL_TYPE);
-  TYPE_PRECISION (double_type_node) = DOUBLE_TYPE_SIZE;
+  machine_mode double_type_mode
+    = targetm.c.mode_for_floating_type (TI_DOUBLE_TYPE);
+  SET_TYPE_MODE (double_type_node, double_type_mode);
+  TYPE_PRECISION (double_type_node)
+    = GET_MODE_PRECISION (double_type_mode).to_constant ();
   layout_type (double_type_node);
 
   long_double_type_node = make_node (REAL_TYPE);
-  TYPE_PRECISION (long_double_type_node) = LONG_DOUBLE_TYPE_SIZE;
+  machine_mode long_double_type_mode
+    = targetm.c.mode_for_floating_type (TI_LONG_DOUBLE_TYPE);
+  SET_TYPE_MODE (long_double_type_node, long_double_type_mode);
+  TYPE_PRECISION (long_double_type_node)
+    = GET_MODE_PRECISION (long_double_type_mode).to_constant ();
   layout_type (long_double_type_node);
 
   for (i = 0; i < NUM_FLOATN_NX_TYPES; i++)
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 10/52] jit: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (8 preceding siblings ...)
  2024-06-03  3:00 ` [PATCH 09/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook mode_for_floating_type Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-13  7:14   ` PING^1 " Kewen.Lin
  2024-06-13 13:44   ` David Malcolm
  2024-06-03  3:01 ` [PATCH 11/52] arc: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE Kewen Lin
                   ` (41 subsequent siblings)
  51 siblings, 2 replies; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, dmalcolm

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.  Unlike the other FEs, for the
uses in recording::memento_of_get_type::get_size, since
{float,{,long_}double}_type_node haven't been initialized
yet, this is to replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
with calling hook targetm.c.mode_for_floating_type.

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

gcc/jit/ChangeLog:

	* jit-recording.cc (recording::memento_of_get_type::get_size): Update
	macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE by calling
	targetm.c.mode_for_floating_type with
	TI_{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE.
---
 gcc/jit/jit-recording.cc | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc
index 68a2e860c1f..7719b898e57 100644
--- a/gcc/jit/jit-recording.cc
+++ b/gcc/jit/jit-recording.cc
@@ -21,7 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
-#include "tm.h"
+#include "target.h"
 #include "pretty-print.h"
 #include "toplev.h"
 
@@ -2353,6 +2353,7 @@ size_t
 recording::memento_of_get_type::get_size ()
 {
   int size;
+  machine_mode m;
   switch (m_kind)
     {
     case GCC_JIT_TYPE_VOID:
@@ -2399,13 +2400,16 @@ recording::memento_of_get_type::get_size ()
       size = 128;
       break;
     case GCC_JIT_TYPE_FLOAT:
-      size = FLOAT_TYPE_SIZE;
+      m = targetm.c.mode_for_floating_type (TI_FLOAT_TYPE);
+      size = GET_MODE_PRECISION (m).to_constant ();
       break;
     case GCC_JIT_TYPE_DOUBLE:
-      size = DOUBLE_TYPE_SIZE;
+      m = targetm.c.mode_for_floating_type (TI_DOUBLE_TYPE);
+      size = GET_MODE_PRECISION (m).to_constant ();
       break;
     case GCC_JIT_TYPE_LONG_DOUBLE:
-      size = LONG_DOUBLE_TYPE_SIZE;
+      m = targetm.c.mode_for_floating_type (TI_LONG_DOUBLE_TYPE);
+      size = GET_MODE_PRECISION (m).to_constant ();
       break;
     case GCC_JIT_TYPE_SIZE_T:
       size = MAX_BITS_PER_WORD;
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 11/52] arc: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (9 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 10/52] jit: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-13  7:14   ` PING^1 " Kewen.Lin
  2024-06-03  3:01 ` [PATCH 12/52] bpf: " Kewen Lin
                   ` (40 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, claziss

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in arc port.

gcc/ChangeLog:

	* config/arc/arc.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/arc/arc.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/gcc/config/arc/arc.h b/gcc/config/arc/arc.h
index f3b43882671..0a1ecb71d89 100644
--- a/gcc/config/arc/arc.h
+++ b/gcc/config/arc/arc.h
@@ -296,9 +296,6 @@ if (GET_MODE_CLASS (MODE) == MODE_INT		\
 #define INT_TYPE_SIZE		32
 #define LONG_TYPE_SIZE		32
 #define LONG_LONG_TYPE_SIZE	64
-#define FLOAT_TYPE_SIZE		32
-#define DOUBLE_TYPE_SIZE	64
-#define LONG_DOUBLE_TYPE_SIZE	64
 
 /* Define this as 1 if `char' should by default be signed; else as 0.  */
 #define DEFAULT_SIGNED_CHAR 0
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 12/52] bpf: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (10 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 11/52] arc: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-13  7:15   ` PING^1 " Kewen.Lin
  2024-06-03  3:01 ` [PATCH 13/52] epiphany: " Kewen Lin
                   ` (39 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, jose.marchesi, david.faust

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in bpf port.

gcc/ChangeLog:

	* config/bpf/bpf.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/bpf/bpf.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/gcc/config/bpf/bpf.h b/gcc/config/bpf/bpf.h
index e163fbf688d..2298e5b05af 100644
--- a/gcc/config/bpf/bpf.h
+++ b/gcc/config/bpf/bpf.h
@@ -90,9 +90,6 @@
 #define LONG_TYPE_SIZE        64
 #define LONG_LONG_TYPE_SIZE   64
 #define CHAR_TYPE_SIZE         8
-#define FLOAT_TYPE_SIZE       32
-#define DOUBLE_TYPE_SIZE      64
-#define LONG_DOUBLE_TYPE_SIZE 64
 
 #define INTPTR_TYPE	"long int"
 #define UINTPTR_TYPE	"long unsigned int"
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 13/52] epiphany: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (11 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 12/52] bpf: " Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-13  7:15   ` PING^1 " Kewen.Lin
  2024-06-03  3:01 ` [PATCH 14/52] fr30: " Kewen Lin
                   ` (38 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, jeffreyalaw

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in epiphany port.

gcc/ChangeLog:

	* config/epiphany/epiphany.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/epiphany/epiphany.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/gcc/config/epiphany/epiphany.h b/gcc/config/epiphany/epiphany.h
index 1df9eeecd0e..aa4715bfe10 100644
--- a/gcc/config/epiphany/epiphany.h
+++ b/gcc/config/epiphany/epiphany.h
@@ -188,9 +188,6 @@ along with GCC; see the file COPYING3.  If not see
 #define INT_TYPE_SIZE		32
 #define LONG_TYPE_SIZE		32
 #define LONG_LONG_TYPE_SIZE	64
-#define FLOAT_TYPE_SIZE		32
-#define DOUBLE_TYPE_SIZE	64
-#define LONG_DOUBLE_TYPE_SIZE	64
 
 /* Define this as 1 if `char' should by default be signed; else as 0.  */
 #define DEFAULT_SIGNED_CHAR 0
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 14/52] fr30: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (12 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 13/52] epiphany: " Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-03 11:43   ` Nick Clifton
  2024-06-03  3:01 ` [PATCH 15/52] frv: " Kewen Lin
                   ` (37 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, nickc

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in fr30 port.

gcc/ChangeLog:

	* config/fr30/fr30.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/fr30/fr30.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/gcc/config/fr30/fr30.h b/gcc/config/fr30/fr30.h
index 2a2674ca29e..19020fbbd36 100644
--- a/gcc/config/fr30/fr30.h
+++ b/gcc/config/fr30/fr30.h
@@ -99,9 +99,6 @@ along with GCC; see the file COPYING3.  If not see
 #define INT_TYPE_SIZE 		32
 #define LONG_TYPE_SIZE 		32
 #define LONG_LONG_TYPE_SIZE 	64
-#define FLOAT_TYPE_SIZE 	32
-#define DOUBLE_TYPE_SIZE 	64
-#define LONG_DOUBLE_TYPE_SIZE 	64
 
 #define DEFAULT_SIGNED_CHAR 1
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 15/52] frv: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (13 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 14/52] fr30: " Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-03 13:31   ` Nick Clifton
  2024-06-03  3:01 ` [PATCH 16/52] ft32: " Kewen Lin
                   ` (36 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, nickc, aoliva

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in frv port.

gcc/ChangeLog:

	* config/frv/frv.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/frv/frv.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/gcc/config/frv/frv.h b/gcc/config/frv/frv.h
index 60225ee8230..b16103afff5 100644
--- a/gcc/config/frv/frv.h
+++ b/gcc/config/frv/frv.h
@@ -366,9 +366,6 @@
 #define INT_TYPE_SIZE         32
 #define LONG_TYPE_SIZE        32
 #define LONG_LONG_TYPE_SIZE   64
-#define FLOAT_TYPE_SIZE       32
-#define DOUBLE_TYPE_SIZE      64
-#define LONG_DOUBLE_TYPE_SIZE 64
 
 /* An expression whose value is 1 or 0, according to whether the type `char'
    should be signed or unsigned by default.  The user can always override this
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 16/52] ft32: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (14 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 15/52] frv: " Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-13  7:15   ` PING^1 " Kewen.Lin
  2024-06-03  3:01 ` [PATCH 17/52] gcn: " Kewen Lin
                   ` (35 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, james.bowman

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in ft32 port.

gcc/ChangeLog:

	* config/ft32/ft32.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/ft32/ft32.h | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/gcc/config/ft32/ft32.h b/gcc/config/ft32/ft32.h
index 6d892a5ab8e..1803d5b6be0 100644
--- a/gcc/config/ft32/ft32.h
+++ b/gcc/config/ft32/ft32.h
@@ -53,10 +53,6 @@
 #define LONG_TYPE_SIZE 32
 #define LONG_LONG_TYPE_SIZE 64
 
-#define FLOAT_TYPE_SIZE 32
-#define DOUBLE_TYPE_SIZE 64
-#define LONG_DOUBLE_TYPE_SIZE 64
-
 #define DEFAULT_SIGNED_CHAR 1
 
 #undef  SIZE_TYPE
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 17/52] gcn: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (15 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 16/52] ft32: " Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-03  9:14   ` [PATCH 17/52] gcn: Remove macros {FLOAT, DOUBLE, LONG_DOUBLE}_TYPE_SIZE Andrew Stubbs
  2024-06-03  3:01 ` [PATCH 18/52] iq2000: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE Kewen Lin
                   ` (34 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, julian, ams

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in gcn port.

gcc/ChangeLog:

	* config/gcn/gcn.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/gcn/gcn.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/gcc/config/gcn/gcn.h b/gcc/config/gcn/gcn.h
index afa615320ca..e3bfd29c17d 100644
--- a/gcc/config/gcn/gcn.h
+++ b/gcc/config/gcn/gcn.h
@@ -111,9 +111,6 @@
 #define INT_TYPE_SIZE		  32
 #define LONG_TYPE_SIZE		  64
 #define LONG_LONG_TYPE_SIZE	  64
-#define FLOAT_TYPE_SIZE		  32
-#define DOUBLE_TYPE_SIZE	  64
-#define LONG_DOUBLE_TYPE_SIZE	  64
 #define DEFAULT_SIGNED_CHAR	  1
 #define PCC_BITFIELD_TYPE_MATTERS 1
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 18/52] iq2000: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (16 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 17/52] gcn: " Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-03 13:32   ` Nick Clifton
  2024-06-03  3:01 ` [PATCH 19/52] lm32: " Kewen Lin
                   ` (33 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, nickc

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in iq2000 port.

gcc/ChangeLog:

	* config/iq2000/iq2000.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/iq2000/iq2000.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/gcc/config/iq2000/iq2000.h b/gcc/config/iq2000/iq2000.h
index 88e87c6f603..c3562be0fb9 100644
--- a/gcc/config/iq2000/iq2000.h
+++ b/gcc/config/iq2000/iq2000.h
@@ -112,9 +112,6 @@
 #define LONG_TYPE_SIZE 		32
 #define LONG_LONG_TYPE_SIZE 	64
 #define CHAR_TYPE_SIZE		BITS_PER_UNIT
-#define FLOAT_TYPE_SIZE 	32
-#define DOUBLE_TYPE_SIZE 	64
-#define LONG_DOUBLE_TYPE_SIZE	64
 #define DEFAULT_SIGNED_CHAR	1
 
 #undef  SIZE_TYPE
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 19/52] lm32: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (17 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 18/52] iq2000: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-13  7:15   ` PING^1 " Kewen.Lin
  2024-06-03  3:01 ` [PATCH 20/52] m32c: " Kewen Lin
                   ` (32 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, sebastien

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in lm32 port.

gcc/ChangeLog:

	* config/lm32/lm32.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/lm32/lm32.h | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/gcc/config/lm32/lm32.h b/gcc/config/lm32/lm32.h
index 1d2c8adadfe..e761e14dcc5 100644
--- a/gcc/config/lm32/lm32.h
+++ b/gcc/config/lm32/lm32.h
@@ -122,10 +122,6 @@ do {                                                    \
 #define LONG_TYPE_SIZE		    32
 #define LONG_LONG_TYPE_SIZE	    64
 
-#define FLOAT_TYPE_SIZE		    32
-#define DOUBLE_TYPE_SIZE	    64
-#define LONG_DOUBLE_TYPE_SIZE       64
-
 #define DEFAULT_SIGNED_CHAR         0
 
 #define SIZE_TYPE "unsigned int"
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 20/52] m32c: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (18 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 19/52] lm32: " Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-03 13:33   ` Nick Clifton
  2024-06-03  3:01 ` [PATCH 21/52] m32r: " Kewen Lin
                   ` (31 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, nickc, jeffreyalaw

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in m32c port.

gcc/ChangeLog:

	* config/m32c/m32c.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/m32c/m32c.h | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/gcc/config/m32c/m32c.h b/gcc/config/m32c/m32c.h
index 247b4358cf9..a956c507d8d 100644
--- a/gcc/config/m32c/m32c.h
+++ b/gcc/config/m32c/m32c.h
@@ -180,10 +180,6 @@ machine_function;
 #define LONG_TYPE_SIZE 32
 #define LONG_LONG_TYPE_SIZE 64
 
-#define FLOAT_TYPE_SIZE 32
-#define DOUBLE_TYPE_SIZE 64
-#define LONG_DOUBLE_TYPE_SIZE 64
-
 #define DEFAULT_SIGNED_CHAR 1
 
 #undef PTRDIFF_TYPE
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 21/52] m32r: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (19 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 20/52] m32c: " Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-03 13:33   ` Nick Clifton
  2024-06-03  3:01 ` [PATCH 22/52] microblaze: " Kewen Lin
                   ` (30 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, nickc, jeffreyalaw

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in m32r port.

gcc/ChangeLog:

	* config/m32r/m32r.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/m32r/m32r.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/gcc/config/m32r/m32r.h b/gcc/config/m32r/m32r.h
index 4a400d1654f..7be8dfd7916 100644
--- a/gcc/config/m32r/m32r.h
+++ b/gcc/config/m32r/m32r.h
@@ -279,9 +279,6 @@
 #define INT_TYPE_SIZE		32
 #define LONG_TYPE_SIZE		32
 #define LONG_LONG_TYPE_SIZE	64
-#define FLOAT_TYPE_SIZE		32
-#define DOUBLE_TYPE_SIZE	64
-#define LONG_DOUBLE_TYPE_SIZE	64
 
 /* Define this as 1 if `char' should by default be signed; else as 0.  */
 #define DEFAULT_SIGNED_CHAR 1
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 22/52] microblaze: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (20 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 21/52] m32r: " Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-13  7:16   ` PING^1 " Kewen.Lin
  2024-06-03  3:01 ` [PATCH 23/52] mmix: " Kewen Lin
                   ` (29 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, eager

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in microblaze port.

gcc/ChangeLog:

	* config/microblaze/microblaze.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/microblaze/microblaze.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
index c88a87c12e2..5d28abf9741 100644
--- a/gcc/config/microblaze/microblaze.h
+++ b/gcc/config/microblaze/microblaze.h
@@ -216,9 +216,6 @@ extern enum pipeline_type microblaze_pipe;
 #define SHORT_TYPE_SIZE         16
 #define LONG_TYPE_SIZE          32
 #define LONG_LONG_TYPE_SIZE     64
-#define FLOAT_TYPE_SIZE         32
-#define DOUBLE_TYPE_SIZE        64
-#define LONG_DOUBLE_TYPE_SIZE   64
 #define POINTER_SIZE            32
 #define PARM_BOUNDARY           32
 #define FUNCTION_BOUNDARY       32
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 23/52] mmix: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (21 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 22/52] microblaze: " Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-06  1:41   ` Hans-Peter Nilsson
  2024-06-03  3:01 ` [PATCH 24/52] moxie: " Kewen Lin
                   ` (28 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, hp

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in mmix port.

gcc/ChangeLog:

	* config/mmix/mmix.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/mmix/mmix.h | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/gcc/config/mmix/mmix.h b/gcc/config/mmix/mmix.h
index c3c5a2a69c9..e20bca1d363 100644
--- a/gcc/config/mmix/mmix.h
+++ b/gcc/config/mmix/mmix.h
@@ -195,10 +195,6 @@ struct GTY(()) machine_function
 #define SHORT_TYPE_SIZE 16
 #define LONG_LONG_TYPE_SIZE 64
 
-#define FLOAT_TYPE_SIZE 32
-#define DOUBLE_TYPE_SIZE 64
-#define LONG_DOUBLE_TYPE_SIZE 64
-
 #define DEFAULT_SIGNED_CHAR 1
 
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 24/52] moxie: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (22 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 23/52] mmix: " Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-13  7:16   ` PING^1 " Kewen.Lin
  2024-06-03  3:01 ` [PATCH 25/52] msp430: " Kewen Lin
                   ` (27 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, green

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in moxie port.

gcc/ChangeLog:

	* config/moxie/moxie.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/moxie/moxie.h | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/gcc/config/moxie/moxie.h b/gcc/config/moxie/moxie.h
index 066c2566d84..4857c92890f 100644
--- a/gcc/config/moxie/moxie.h
+++ b/gcc/config/moxie/moxie.h
@@ -55,10 +55,6 @@
 #define LONG_TYPE_SIZE 32
 #define LONG_LONG_TYPE_SIZE 64
 
-#define FLOAT_TYPE_SIZE 32
-#define DOUBLE_TYPE_SIZE 64
-#define LONG_DOUBLE_TYPE_SIZE 64
-
 #define DEFAULT_SIGNED_CHAR 0
 
 #undef  SIZE_TYPE
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 25/52] msp430: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (23 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 24/52] moxie: " Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-03 13:34   ` Nick Clifton
  2024-06-03  3:01 ` [PATCH 26/52] nds32: " Kewen Lin
                   ` (26 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, nickc

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in msp430 port.

gcc/ChangeLog:

	* config/msp430/msp430.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/msp430/msp430.h | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/gcc/config/msp430/msp430.h b/gcc/config/msp430/msp430.h
index 5c856ee6997..f20309c65ac 100644
--- a/gcc/config/msp430/msp430.h
+++ b/gcc/config/msp430/msp430.h
@@ -178,10 +178,6 @@ extern const char *msp430_get_linker_devices_include_path (int, const char **);
 #define LONG_TYPE_SIZE			32
 #define LONG_LONG_TYPE_SIZE		64
 
-#define FLOAT_TYPE_SIZE 		32
-#define DOUBLE_TYPE_SIZE 		64
-#define LONG_DOUBLE_TYPE_SIZE		64 /*DOUBLE_TYPE_SIZE*/
-
 #define DEFAULT_SIGNED_CHAR		0
 
 #define STRICT_ALIGNMENT 		1
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 26/52] nds32: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (24 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 25/52] msp430: " Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-13  7:16   ` PING^1 " Kewen.Lin
  2024-06-03  3:01 ` [PATCH 27/52] nios2: " Kewen Lin
                   ` (25 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, jasonwucj, shiva0217

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in nds32 port.

gcc/ChangeLog:

	* config/nds32/nds32.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/nds32/nds32.h | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/gcc/config/nds32/nds32.h b/gcc/config/nds32/nds32.h
index 03cf7a9aa56..4c02302c785 100644
--- a/gcc/config/nds32/nds32.h
+++ b/gcc/config/nds32/nds32.h
@@ -1061,10 +1061,6 @@ enum nds32_builtins
 #define LONG_TYPE_SIZE          32
 #define LONG_LONG_TYPE_SIZE     64
 
-#define FLOAT_TYPE_SIZE         32
-#define DOUBLE_TYPE_SIZE        64
-#define LONG_DOUBLE_TYPE_SIZE   64
-
 #define DEFAULT_SIGNED_CHAR 1
 
 #define SIZE_TYPE "long unsigned int"
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 27/52] nios2: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (25 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 26/52] nds32: " Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-06 16:23   ` Sandra Loosemore
  2024-06-03  3:01 ` [PATCH 28/52] nvptx: " Kewen Lin
                   ` (24 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, cltang, sloosemore

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in nios2 port.

gcc/ChangeLog:

	* config/nios2/nios2.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/nios2/nios2.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/gcc/config/nios2/nios2.h b/gcc/config/nios2/nios2.h
index 767f56e95b1..bad726713eb 100644
--- a/gcc/config/nios2/nios2.h
+++ b/gcc/config/nios2/nios2.h
@@ -100,9 +100,6 @@
 #define SHORT_TYPE_SIZE 16
 #define LONG_TYPE_SIZE 32
 #define LONG_LONG_TYPE_SIZE 64
-#define FLOAT_TYPE_SIZE 32
-#define DOUBLE_TYPE_SIZE 64
-#define LONG_DOUBLE_TYPE_SIZE DOUBLE_TYPE_SIZE
 
 #undef SIZE_TYPE
 #define SIZE_TYPE "unsigned int"
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 28/52] nvptx: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (26 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 27/52] nios2: " Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-13  7:16   ` PING^1 " Kewen.Lin
  2024-06-03  3:01 ` [PATCH 29/52] or1k: " Kewen Lin
                   ` (23 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, tdevries, tschwinge

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in nvptx port.

gcc/ChangeLog:

	* config/nvptx/nvptx.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/nvptx/nvptx.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/gcc/config/nvptx/nvptx.h b/gcc/config/nvptx/nvptx.h
index e282aad1b73..f6077c09e9b 100644
--- a/gcc/config/nvptx/nvptx.h
+++ b/gcc/config/nvptx/nvptx.h
@@ -75,9 +75,6 @@
 #define INT_TYPE_SIZE 32
 #define LONG_TYPE_SIZE (TARGET_ABI64 ? 64 : 32)
 #define LONG_LONG_TYPE_SIZE 64
-#define FLOAT_TYPE_SIZE 32
-#define DOUBLE_TYPE_SIZE 64
-#define LONG_DOUBLE_TYPE_SIZE 64
 #define TARGET_SUPPORTS_WIDE_INT 1
 
 #undef SIZE_TYPE
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 29/52] or1k: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (27 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 28/52] nvptx: " Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-13  7:16   ` PING^1 " Kewen.Lin
  2024-06-03  3:01 ` [PATCH 30/52] pdp11: Remove macro LONG_DOUBLE_TYPE_SIZE Kewen Lin
                   ` (22 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, shorne

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in or1k port.

gcc/ChangeLog:

	* config/or1k/or1k.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/or1k/or1k.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/gcc/config/or1k/or1k.h b/gcc/config/or1k/or1k.h
index 0ff73df33e7..a55509f9f32 100644
--- a/gcc/config/or1k/or1k.h
+++ b/gcc/config/or1k/or1k.h
@@ -67,9 +67,6 @@
 #define SHORT_TYPE_SIZE 16
 #define LONG_TYPE_SIZE 32
 #define LONG_LONG_TYPE_SIZE 64
-#define FLOAT_TYPE_SIZE 32
-#define DOUBLE_TYPE_SIZE 64
-#define LONG_DOUBLE_TYPE_SIZE 64
 #define WCHAR_TYPE_SIZE 32
 
 #undef SIZE_TYPE
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 30/52] pdp11: Remove macro LONG_DOUBLE_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (28 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 29/52] or1k: " Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-13  7:16   ` PING^1 " Kewen.Lin
  2024-06-03  3:01 ` [PATCH 31/52] pru: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE Kewen Lin
                   ` (21 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, ni1d

This is to remove macro LONG_DOUBLE_TYPE_SIZE define
in pdp11 port.

gcc/ChangeLog:

	* config/pdp11/pdp11.h (LONG_DOUBLE_TYPE_SIZE): Remove.
---
 gcc/config/pdp11/pdp11.h | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/gcc/config/pdp11/pdp11.h b/gcc/config/pdp11/pdp11.h
index 2446fea0b58..6c8e045bc57 100644
--- a/gcc/config/pdp11/pdp11.h
+++ b/gcc/config/pdp11/pdp11.h
@@ -71,17 +71,6 @@ along with GCC; see the file COPYING3.  If not see
 #define LONG_TYPE_SIZE		32
 #define LONG_LONG_TYPE_SIZE	64     
 
-/* In earlier versions, FLOAT_TYPE_SIZE was selectable as 32 or 64,
-   but that conflicts with Fortran language rules.  Since there is no
-   obvious reason why we should have that feature -- other targets
-   generally don't have float and double the same size -- I've removed
-   it.  Note that it continues to be true (for now) that arithmetic is
-   always done with 64-bit values, i.e., the FPU is always in "double"
-   mode.  */
-#define FLOAT_TYPE_SIZE		32
-#define DOUBLE_TYPE_SIZE	64
-#define LONG_DOUBLE_TYPE_SIZE	64
-
 /* machine types from ansi */
 #define SIZE_TYPE "short unsigned int" 	/* definition of size_t */
 #define WCHAR_TYPE "short int" 		/* or long int???? */
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 31/52] pru: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (29 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 30/52] pdp11: Remove macro LONG_DOUBLE_TYPE_SIZE Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-03 15:59   ` Dimitar Dimitrov
  2024-06-03  3:01 ` [PATCH 32/52] stormy16: " Kewen Lin
                   ` (20 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, dimitar

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in pru port.

gcc/ChangeLog:

	* config/pru/pru.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/pru/pru.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/gcc/config/pru/pru.h b/gcc/config/pru/pru.h
index 28aeb603178..7aee2861871 100644
--- a/gcc/config/pru/pru.h
+++ b/gcc/config/pru/pru.h
@@ -107,9 +107,6 @@
 #define SHORT_TYPE_SIZE 16
 #define LONG_TYPE_SIZE 32
 #define LONG_LONG_TYPE_SIZE 64
-#define FLOAT_TYPE_SIZE 32
-#define DOUBLE_TYPE_SIZE 64
-#define LONG_DOUBLE_TYPE_SIZE DOUBLE_TYPE_SIZE
 
 #undef SIZE_TYPE
 #define SIZE_TYPE "unsigned int"
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 32/52] stormy16: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (30 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 31/52] pru: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-03 13:35   ` Nick Clifton
  2024-06-03  3:01 ` [PATCH 33/52] visium: " Kewen Lin
                   ` (19 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, nickc

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in stormy16 port.

gcc/ChangeLog:

	* config/stormy16/stormy16.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/stormy16/stormy16.h | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/gcc/config/stormy16/stormy16.h b/gcc/config/stormy16/stormy16.h
index 2503f234c6a..3d5e21d644d 100644
--- a/gcc/config/stormy16/stormy16.h
+++ b/gcc/config/stormy16/stormy16.h
@@ -101,12 +101,6 @@
 
 #define LONG_LONG_TYPE_SIZE 64
 
-#define FLOAT_TYPE_SIZE 32
-
-#define DOUBLE_TYPE_SIZE 64
-
-#define LONG_DOUBLE_TYPE_SIZE 64
-
 #define DEFAULT_SIGNED_CHAR 0
 
 #define SIZE_TYPE "unsigned int"
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 33/52] visium: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (31 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 32/52] stormy16: " Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-13  7:17   ` PING^1 " Kewen.Lin
  2024-06-03  3:01 ` [PATCH 34/52] xtensa: " Kewen Lin
                   ` (18 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in visium port.

gcc/ChangeLog:

	* config/visium/visium.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/visium/visium.h | 29 ++++++-----------------------
 1 file changed, 6 insertions(+), 23 deletions(-)

diff --git a/gcc/config/visium/visium.h b/gcc/config/visium/visium.h
index 69e25523e05..afeb68f84cc 100644
--- a/gcc/config/visium/visium.h
+++ b/gcc/config/visium/visium.h
@@ -330,33 +330,16 @@
    it is rounded up to one unit.) */
 #define CHAR_TYPE_SIZE  8
 
-/* `FLOAT_TYPE_SIZE'
-
-   A C expression for the size in bits of the type `float' on the
-   target machine.  If you don't define this, the default is one word. */
-#define FLOAT_TYPE_SIZE  32
-
-/* `DOUBLE_TYPE_SIZE'
-
-   A C expression for the size in bits of the type `double' on the
-   target machine.  If you don't define this, the default is two
-   words. */
-#define DOUBLE_TYPE_SIZE  64
-
-/* `LONG_DOUBLE_TYPE_SIZE'
-
-   A C expression for the size in bits of the type `long double' on
-   the target machine.  If you don't define this, the default is two
-   words. */
-#define LONG_DOUBLE_TYPE_SIZE   DOUBLE_TYPE_SIZE
-
 /* `WIDEST_HARDWARE_FP_SIZE'
 
    A C expression for the size in bits of the widest floating-point
    format supported by the hardware.  If you define this macro, you
-   must specify a value less than or equal to the value of
-   `LONG_DOUBLE_TYPE_SIZE'.  If you do not define this macro, the
-   value of `LONG_DOUBLE_TYPE_SIZE' is the default. */
+   must specify a value less than or equal to mode precision of the
+   mode used for C type long double (from hook
+   targetm.c.mode_for_floating_type with tree_index
+   TI_LONG_DOUBLE_TYPE).  If you do not define this macro, mode
+   precision of the mode used for C type long double is the
+   default.  */
 
 /* `DEFAULT_SIGNED_CHAR'
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 34/52] xtensa: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (32 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 33/52] visium: " Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-03 21:08   ` augustine.sterling
  2024-06-03  3:01 ` [PATCH 35/52] rs6000: New hook implementation rs6000_c_mode_for_floating_type Kewen Lin
                   ` (17 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, augustine.sterling, jcmvbkbc

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in xtensa port.

gcc/ChangeLog:

	* config/xtensa/xtensa.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/xtensa/xtensa.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/gcc/config/xtensa/xtensa.h b/gcc/config/xtensa/xtensa.h
index 9591b3d4b40..06f1e24f7b7 100644
--- a/gcc/config/xtensa/xtensa.h
+++ b/gcc/config/xtensa/xtensa.h
@@ -120,9 +120,6 @@ along with GCC; see the file COPYING3.  If not see
 #define SHORT_TYPE_SIZE 16
 #define LONG_TYPE_SIZE 32
 #define LONG_LONG_TYPE_SIZE 64
-#define FLOAT_TYPE_SIZE 32
-#define DOUBLE_TYPE_SIZE 64
-#define LONG_DOUBLE_TYPE_SIZE 64
 
 /* Allocation boundary (in *bits*) for storing pointers in memory.  */
 #define POINTER_BOUNDARY 32
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 35/52] rs6000: New hook implementation rs6000_c_mode_for_floating_type
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (33 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 34/52] xtensa: " Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-03  3:01 ` [PATCH 36/52] aarch64: New hook implementation aarch64_c_mode_for_floating_type Kewen Lin
                   ` (16 subsequent siblings)
  51 siblings, 0 replies; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, dje.gcc, segher

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in rs6000 port, and add new port specific hook
implementation rs6000_c_mode_for_floating_type.

gcc/ChangeLog:

	* config/rs6000/rs6000.cc (TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
	(rs6000_c_mode_for_floating_type): New function.
	* config/rs6000/rs6000.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/rs6000/rs6000.cc | 16 ++++++++++++++++
 gcc/config/rs6000/rs6000.h  | 14 --------------
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index e4dc629ddcc..d2fbbaddda7 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -1707,6 +1707,9 @@ static const scoped_attribute_specs *const rs6000_attribute_table[] =
 #undef TARGET_C_MODE_FOR_SUFFIX
 #define TARGET_C_MODE_FOR_SUFFIX rs6000_c_mode_for_suffix
 
+#undef TARGET_C_MODE_FOR_FLOATING_TYPE
+#define TARGET_C_MODE_FOR_FLOATING_TYPE rs6000_c_mode_for_floating_type
+
 #undef TARGET_INVALID_BINARY_OP
 #define TARGET_INVALID_BINARY_OP rs6000_invalid_binary_op
 
@@ -24365,6 +24368,19 @@ rs6000_c_mode_for_suffix (char suffix)
   return VOIDmode;
 }
 
+/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return TFmode for
+   TI_LONG_DOUBLE_TYPE which is for long double type, go with the default
+   one for the others.  */
+
+static machine_mode
+rs6000_c_mode_for_floating_type (enum tree_index ti)
+{
+  if (ti == TI_LONG_DOUBLE_TYPE)
+    return rs6000_long_double_type_size == FLOAT_PRECISION_TFmode ? TFmode
+								  : DFmode;
+  return default_mode_for_floating_type (ti);
+}
+
 /* Target hook for invalid_arg_for_unprototyped_fn. */
 static const char *
 invalid_arg_for_unprototyped_fn (const_tree typelist, const_tree funcdecl, const_tree val)
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index 2cde2e329b0..9211f91740a 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -693,20 +693,6 @@ extern unsigned char rs6000_recip_bits[];
    words.  */
 #define LONG_LONG_TYPE_SIZE 64
 
-/* A C expression for the size in bits of the type `float' on the
-   target machine.  If you don't define this, the default is one
-   word.  */
-#define FLOAT_TYPE_SIZE 32
-
-/* A C expression for the size in bits of the type `double' on the
-   target machine.  If you don't define this, the default is two
-   words.  */
-#define DOUBLE_TYPE_SIZE 64
-
-/* A C expression for the size in bits of the type `long double' on the target
-   machine.  If you don't define this, the default is two words.  */
-#define LONG_DOUBLE_TYPE_SIZE rs6000_long_double_type_size
-
 /* Work around rs6000_long_double_type_size dependency in ada/targtyps.cc.  */
 #define WIDEST_HARDWARE_FP_SIZE 64
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 36/52] aarch64: New hook implementation aarch64_c_mode_for_floating_type
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (34 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 35/52] rs6000: New hook implementation rs6000_c_mode_for_floating_type Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-03 10:32   ` Richard Sandiford
  2024-06-03  3:01 ` [PATCH 37/52] alpha: New hook implementation alpha_c_mode_for_floating_type Kewen Lin
                   ` (15 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches
  Cc: linkw, richard.earnshaw, richard.sandiford, marcus.shawcroft, ktkachov

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in aarch64 port, and add new port specific hook
implementation aarch64_c_mode_for_floating_type.

gcc/ChangeLog:

	* config/aarch64/aarch64.cc (aarch64_c_mode_for_floating_type):
	New function.
	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
	* config/aarch64/aarch64.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/aarch64/aarch64.cc | 15 +++++++++++++++
 gcc/config/aarch64/aarch64.h  |  6 ------
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index ee12d8897a8..1c1c278fd69 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -28427,6 +28427,18 @@ aarch64_bitint_type_info (int n, struct bitint_info *info)
   return true;
 }
 
+/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return TFmode for
+   TI_LONG_DOUBLE_TYPE which is for long double type, go with the default
+   one for the others.  */
+
+static machine_mode
+aarch64_c_mode_for_floating_type (enum tree_index ti)
+{
+  if (ti == TI_LONG_DOUBLE_TYPE)
+    return TFmode;
+  return default_mode_for_floating_type (ti);
+}
+
 /* Implement TARGET_SCHED_CAN_SPECULATE_INSN.  Return true if INSN can be
    scheduled for speculative execution.  Reject the long-running division
    and square-root instructions.  */
@@ -30554,6 +30566,9 @@ aarch64_run_selftests (void)
 #undef TARGET_C_BITINT_TYPE_INFO
 #define TARGET_C_BITINT_TYPE_INFO aarch64_bitint_type_info
 
+#undef TARGET_C_MODE_FOR_FLOATING_TYPE
+#define TARGET_C_MODE_FOR_FLOATING_TYPE aarch64_c_mode_for_floating_type
+
 #undef  TARGET_EXPAND_BUILTIN
 #define TARGET_EXPAND_BUILTIN aarch64_expand_builtin
 
diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
index bbf11faaf4b..2064c23f961 100644
--- a/gcc/config/aarch64/aarch64.h
+++ b/gcc/config/aarch64/aarch64.h
@@ -96,12 +96,6 @@
 
 #define LONG_LONG_TYPE_SIZE	64
 
-#define FLOAT_TYPE_SIZE		32
-
-#define DOUBLE_TYPE_SIZE	64
-
-#define LONG_DOUBLE_TYPE_SIZE	128
-
 /* This value is the amount of bytes a caller is allowed to drop the stack
    before probing has to be done for stack clash protection.  */
 #define STACK_CLASH_CALLER_GUARD 1024
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 37/52] alpha: New hook implementation alpha_c_mode_for_floating_type
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (35 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 36/52] aarch64: New hook implementation aarch64_c_mode_for_floating_type Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-13  7:42   ` PING^1 " Kewen.Lin
  2024-06-03  3:01 ` [PATCH 38/52] avr: New hook implementation avr_c_mode_for_floating_type Kewen Lin
                   ` (14 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, rth

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in alpha port, and add new port specific hook
implementation alpha_c_mode_for_floating_type.

gcc/ChangeLog:

	* config/alpha/alpha.cc (alpha_c_mode_for_floating_type): New
	function.
	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
	* config/alpha/alpha.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/alpha/alpha.cc | 17 ++++++++++++++++-
 gcc/config/alpha/alpha.h  |  8 --------
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/gcc/config/alpha/alpha.cc b/gcc/config/alpha/alpha.cc
index 1126cea1f7b..a6fe95e7177 100644
--- a/gcc/config/alpha/alpha.cc
+++ b/gcc/config/alpha/alpha.cc
@@ -9916,7 +9916,19 @@ alpha_can_change_mode_class (machine_mode from, machine_mode to,
   return (GET_MODE_SIZE (from) == GET_MODE_SIZE (to)
 	  || !reg_classes_intersect_p (FLOAT_REGS, rclass));
 }
-\f
+
+/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return TFmode or DFmode
+   for TI_LONG_DOUBLE_TYPE which is for long double type, go with the
+   default one for the others.  */
+
+static machine_mode
+alpha_c_mode_for_floating_type (enum tree_index ti)
+{
+  if (ti == TI_LONG_DOUBLE_TYPE)
+    return TARGET_LONG_DOUBLE_128 ? TFmode : DFmode;
+  return default_mode_for_floating_type (ti);
+}
+
 /* Initialize the GCC target structure.  */
 #if TARGET_ABI_OPEN_VMS
 # undef TARGET_ATTRIBUTE_TABLE
@@ -10123,6 +10135,9 @@ alpha_can_change_mode_class (machine_mode from, machine_mode to,
 #undef TARGET_CAN_CHANGE_MODE_CLASS
 #define TARGET_CAN_CHANGE_MODE_CLASS alpha_can_change_mode_class
 
+#undef TARGET_C_MODE_FOR_FLOATING_TYPE
+#define TARGET_C_MODE_FOR_FLOATING_TYPE alpha_c_mode_for_floating_type
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 \f
diff --git a/gcc/config/alpha/alpha.h b/gcc/config/alpha/alpha.h
index 25ccfce96b8..ee9e0918038 100644
--- a/gcc/config/alpha/alpha.h
+++ b/gcc/config/alpha/alpha.h
@@ -195,14 +195,6 @@ extern enum alpha_fp_trap_mode alpha_fptm;
 /* Define the size of `long long'.  The default is the twice the word size.  */
 #define LONG_LONG_TYPE_SIZE 64
 
-/* The two floating-point formats we support are S-floating, which is
-   4 bytes, and T-floating, which is 8 bytes.  `float' is S and `double'
-   and `long double' are T.  */
-
-#define FLOAT_TYPE_SIZE 32
-#define DOUBLE_TYPE_SIZE 64
-#define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
-
 /* Work around target_flags dependency in ada/targtyps.cc.  */
 #define WIDEST_HARDWARE_FP_SIZE 64
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 38/52] avr: New hook implementation avr_c_mode_for_floating_type
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (36 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 37/52] alpha: New hook implementation alpha_c_mode_for_floating_type Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-13  7:42   ` PING^1 " Kewen.Lin
  2024-06-03  3:01 ` [PATCH 39/52] i386: New hook implementation ix86_c_mode_for_floating_type Kewen Lin
                   ` (13 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, chertykov

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in avr port, and add new port specific hook
implementation avr_c_mode_for_floating_type.

gcc/ChangeLog:

	* config/avr/avr.cc (avr_c_mode_for_floating_type): New
	function.
	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
	* config/avr/avr.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/avr/avr.cc | 17 +++++++++++++++++
 gcc/config/avr/avr.h  |  3 ---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc
index 74924ab0565..61c325f2497 100644
--- a/gcc/config/avr/avr.cc
+++ b/gcc/config/avr/avr.cc
@@ -6930,6 +6930,20 @@ avr_canonicalize_comparison (int *icode, rtx *op0, rtx *op1, bool op0_fixed)
     }
 }
 
+/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return SFmode or DFmode
+   for TI_{LONG_,}DOUBLE_TYPE which is for {long,} double type, go with
+   the default one for the others.  */
+
+static machine_mode
+avr_c_mode_for_floating_type (enum tree_index ti)
+{
+  if (ti == TI_DOUBLE_TYPE)
+    return avr_double == 32 ? SFmode : DFmode;
+  if (ti == TI_LONG_DOUBLE_TYPE)
+    return avr_long_double == 32 ? SFmode : DFmode;
+  return default_mode_for_floating_type (ti);
+}
+
 
 /* Output compare instruction
 
@@ -16411,6 +16425,9 @@ avr_float_lib_compare_returns_bool (machine_mode mode, enum rtx_code)
 #undef  TARGET_HAVE_SPECULATION_SAFE_VALUE
 #define TARGET_HAVE_SPECULATION_SAFE_VALUE speculation_safe_value_not_needed
 
+#undef TARGET_C_MODE_FOR_FLOATING_TYPE
+#define TARGET_C_MODE_FOR_FLOATING_TYPE avr_c_mode_for_floating_type
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 \f
diff --git a/gcc/config/avr/avr.h b/gcc/config/avr/avr.h
index 56211fa9cd0..4977e15eeed 100644
--- a/gcc/config/avr/avr.h
+++ b/gcc/config/avr/avr.h
@@ -143,9 +143,6 @@ FIXME: DRIVER_SELF_SPECS has changed.
 #define SHORT_TYPE_SIZE (INT_TYPE_SIZE == 8 ? INT_TYPE_SIZE : 16)
 #define LONG_TYPE_SIZE (INT_TYPE_SIZE == 8 ? 16 : 32)
 #define LONG_LONG_TYPE_SIZE (INT_TYPE_SIZE == 8 ? 32 : 64)
-#define FLOAT_TYPE_SIZE 32
-#define DOUBLE_TYPE_SIZE (avr_double)
-#define LONG_DOUBLE_TYPE_SIZE (avr_long_double)
 
 #define LONG_LONG_ACCUM_TYPE_SIZE 64
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 39/52] i386: New hook implementation ix86_c_mode_for_floating_type
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (37 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 38/52] avr: New hook implementation avr_c_mode_for_floating_type Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-03  7:12   ` Uros Bizjak
  2024-06-03  3:01 ` [PATCH 40/52] ia64: New hook implementation ia64_c_mode_for_floating_type Kewen Lin
                   ` (12 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, ubizjak, hubicka

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in i386 port, and add new port specific hook
implementation ix86_c_mode_for_floating_type.

gcc/ChangeLog:

	* config/i386/i386.cc (ix86_c_mode_for_floating_type): New
	function.
	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
	* config/i386/i386.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/i386/i386.cc | 15 +++++++++++++++
 gcc/config/i386/i386.h  |  4 ----
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 3e2a3a194f1..6abb6d7a1ca 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -25794,6 +25794,19 @@ ix86_bitint_type_info (int n, struct bitint_info *info)
   return true;
 }
 
+/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return DFmode, TFmode
+   or XFmode for TI_LONG_DOUBLE_TYPE which is for long double type,
+   based on long double bits, go with the default one for the others.  */
+
+static machine_mode
+ix86_c_mode_for_floating_type (enum tree_index ti)
+{
+  if (ti == TI_LONG_DOUBLE_TYPE)
+    return (TARGET_LONG_DOUBLE_64 ? DFmode
+				  : (TARGET_LONG_DOUBLE_128 ? TFmode : XFmode));
+  return default_mode_for_floating_type (ti);
+}
+
 /* Returns modified FUNCTION_TYPE for cdtor callabi.  */
 tree
 ix86_cxx_adjust_cdtor_callabi_fntype (tree fntype)
@@ -26419,6 +26432,8 @@ static const scoped_attribute_specs *const ix86_attribute_table[] =
 #define TARGET_C_EXCESS_PRECISION ix86_get_excess_precision
 #undef TARGET_C_BITINT_TYPE_INFO
 #define TARGET_C_BITINT_TYPE_INFO ix86_bitint_type_info
+#undef TARGET_C_MODE_FOR_FLOATING_TYPE
+#define TARGET_C_MODE_FOR_FLOATING_TYPE ix86_c_mode_for_floating_type
 #undef TARGET_CXX_ADJUST_CDTOR_CALLABI_FNTYPE
 #define TARGET_CXX_ADJUST_CDTOR_CALLABI_FNTYPE ix86_cxx_adjust_cdtor_callabi_fntype
 #undef TARGET_PROMOTE_PROTOTYPES
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index 359a8408263..fad434c10d6 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -675,10 +675,6 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
 #define LONG_TYPE_SIZE (TARGET_X32 ? 32 : BITS_PER_WORD)
 #define POINTER_SIZE (TARGET_X32 ? 32 : BITS_PER_WORD)
 #define LONG_LONG_TYPE_SIZE 64
-#define FLOAT_TYPE_SIZE 32
-#define DOUBLE_TYPE_SIZE 64
-#define LONG_DOUBLE_TYPE_SIZE \
-  (TARGET_LONG_DOUBLE_64 ? 64 : (TARGET_LONG_DOUBLE_128 ? 128 : 80))
 
 #define WIDEST_HARDWARE_FP_SIZE 80
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 40/52] ia64: New hook implementation ia64_c_mode_for_floating_type
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (38 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 39/52] i386: New hook implementation ix86_c_mode_for_floating_type Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-13  7:42   ` PING^1 " Kewen.Lin
  2024-06-03  3:01 ` [PATCH 41/52] riscv: New hook implementation riscv_c_mode_for_floating_type Kewen Lin
                   ` (11 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, jeffreyalaw, richard.guenther

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in ia64 port, and add new port specific hook
implementation ia64_c_mode_for_floating_type.

gcc/ChangeLog:

	* config/ia64/ia64.cc (ia64_c_mode_for_floating_type): New
	function.
	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
	* config/ia64/ia64.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/ia64/ia64.cc | 18 ++++++++++++++++++
 gcc/config/ia64/ia64.h  | 12 ------------
 2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/gcc/config/ia64/ia64.cc b/gcc/config/ia64/ia64.cc
index ac3d56073ac..cd6ed895211 100644
--- a/gcc/config/ia64/ia64.cc
+++ b/gcc/config/ia64/ia64.cc
@@ -321,6 +321,7 @@ static const char *ia64_invalid_conversion (const_tree, const_tree);
 static const char *ia64_invalid_unary_op (int, const_tree);
 static const char *ia64_invalid_binary_op (int, const_tree, const_tree);
 static machine_mode ia64_c_mode_for_suffix (char);
+static machine_mode ia64_c_mode_for_floating_type (enum tree_index);
 static void ia64_trampoline_init (rtx, tree, rtx);
 static void ia64_override_options_after_change (void);
 static bool ia64_member_type_forces_blk (const_tree, machine_mode);
@@ -637,6 +638,9 @@ static const scoped_attribute_specs *const ia64_attribute_table[] =
 #undef TARGET_C_MODE_FOR_SUFFIX
 #define TARGET_C_MODE_FOR_SUFFIX ia64_c_mode_for_suffix
 
+#undef TARGET_C_MODE_FOR_FLOATING_TYPE
+#define TARGET_C_MODE_FOR_FLOATING_TYPE ia64_c_mode_for_floating_type
+
 #undef TARGET_CAN_ELIMINATE
 #define TARGET_CAN_ELIMINATE ia64_can_eliminate
 
@@ -11329,6 +11333,20 @@ ia64_c_mode_for_suffix (char suffix)
   return VOIDmode;
 }
 
+/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return DFmode, XFmode
+   or TFmode for TI_LONG_DOUBLE_TYPE which is for long double type,
+   go with the default one for the others.  */
+
+static machine_mode
+ia64_c_mode_for_floating_type (enum tree_index ti)
+{
+  /* long double is XFmode normally, and TFmode for HPUX.  It should be
+     TFmode for VMS as well but we only support up to DFmode now.  */
+  if (ti == TI_LONG_DOUBLE_TYPE)
+    return TARGET_HPUX ? TFmode : (TARGET_ABI_OPEN_VMS ? DFmode : XFmode);
+  return default_mode_for_floating_type (ti);
+}
+
 static GTY(()) rtx ia64_dconst_0_5_rtx;
 
 rtx
diff --git a/gcc/config/ia64/ia64.h b/gcc/config/ia64/ia64.h
index b7f9d654f90..763b1c3ed48 100644
--- a/gcc/config/ia64/ia64.h
+++ b/gcc/config/ia64/ia64.h
@@ -236,18 +236,6 @@ while (0)
 
 #define LONG_LONG_TYPE_SIZE 64
 
-#define FLOAT_TYPE_SIZE 32
-
-#define DOUBLE_TYPE_SIZE 64
-
-/* long double is XFmode normally, and TFmode for HPUX.  It should be
-   TFmode for VMS as well but we only support up to DFmode now.  */
-#define LONG_DOUBLE_TYPE_SIZE \
-  (TARGET_HPUX ? 128 \
-   : TARGET_ABI_OPEN_VMS ? 64 \
-   : 80)
-
-
 #define DEFAULT_SIGNED_CHAR 1
 
 /* A C expression for a string describing the name of the data type to use for
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 41/52] riscv: New hook implementation riscv_c_mode_for_floating_type
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (39 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 40/52] ia64: New hook implementation ia64_c_mode_for_floating_type Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-03  5:14   ` Kito Cheng
  2024-06-03  3:01 ` [PATCH 42/52] rl78: New hook implementation rl78_c_mode_for_floating_type Kewen Lin
                   ` (10 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, kito.cheng, palmer, andrew, jim.wilson.gcc

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in riscv port, and add new port specific hook
implementation riscv_c_mode_for_floating_type.

gcc/ChangeLog:

	* config/riscv/riscv.cc (riscv_c_mode_for_floating_type): New function.
	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
	* config/riscv/riscv.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/riscv/riscv.cc | 15 +++++++++++++++
 gcc/config/riscv/riscv.h  |  4 ----
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index 92935275aaa..b011344cabe 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -11449,6 +11449,18 @@ riscv_expand_usadd (rtx dest, rtx x, rtx y)
   emit_move_insn (dest, gen_lowpart (mode, xmode_dest));
 }
 
+/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return TFmode for
+   TI_LONG_DOUBLE_TYPE which is for long double type, go with the
+   default one for the others.  */
+
+static machine_mode
+riscv_c_mode_for_floating_type (enum tree_index ti)
+{
+  if (ti == TI_LONG_DOUBLE_TYPE)
+    return TFmode;
+  return default_mode_for_floating_type (ti);
+}
+
 /* Initialize the GCC target structure.  */
 #undef TARGET_ASM_ALIGNED_HI_OP
 #define TARGET_ASM_ALIGNED_HI_OP "\t.half\t"
@@ -11804,6 +11816,9 @@ riscv_expand_usadd (rtx dest, rtx x, rtx y)
 #undef TARGET_GET_RAW_RESULT_MODE
 #define TARGET_GET_RAW_RESULT_MODE riscv_get_raw_result_mode
 
+#undef TARGET_C_MODE_FOR_FLOATING_TYPE
+#define TARGET_C_MODE_FOR_FLOATING_TYPE riscv_c_mode_for_floating_type
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-riscv.h"
diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h
index d6b14c4d620..83c4677c6a1 100644
--- a/gcc/config/riscv/riscv.h
+++ b/gcc/config/riscv/riscv.h
@@ -188,10 +188,6 @@ ASM_MISA_SPEC
 #define POINTER_SIZE (riscv_abi >= ABI_LP64 ? 64 : 32)
 #define LONG_TYPE_SIZE POINTER_SIZE
 
-#define FLOAT_TYPE_SIZE 32
-#define DOUBLE_TYPE_SIZE 64
-#define LONG_DOUBLE_TYPE_SIZE 128
-
 /* Allocation boundary (in *bits*) for storing arguments in argument list.  */
 #define PARM_BOUNDARY BITS_PER_WORD
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 42/52] rl78: New hook implementation rl78_c_mode_for_floating_type
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (40 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 41/52] riscv: New hook implementation riscv_c_mode_for_floating_type Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-13  7:42   ` PING^1 " Kewen.Lin
  2024-06-03  3:01 ` [PATCH 43/52] rx: New hook implementation rx_c_mode_for_floating_type Kewen Lin
                   ` (9 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, jeffreyalaw, richard.guenther

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in rl78 port, and add new port specific hook
implementation rl78_c_mode_for_floating_type.

gcc/ChangeLog:

	* config/rl78/rl78.cc (TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
	(rl78_c_mode_for_floating_type): New function.
	* config/rl78/rl78.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/rl78/rl78.cc | 15 +++++++++++++++
 gcc/config/rl78/rl78.h  |  4 ----
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/gcc/config/rl78/rl78.cc b/gcc/config/rl78/rl78.cc
index e5345bfa9dd..ccb1c4f3867 100644
--- a/gcc/config/rl78/rl78.cc
+++ b/gcc/config/rl78/rl78.cc
@@ -4971,6 +4971,21 @@ rl78_preferred_reload_class (rtx x ATTRIBUTE_UNUSED, reg_class_t rclass)
   return rclass;
 }
 
+#undef TARGET_C_MODE_FOR_FLOATING_TYPE
+#define TARGET_C_MODE_FOR_FLOATING_TYPE rl78_c_mode_for_floating_type
+
+/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return SFmode for
+   TI_DOUBLE_TYPE which is for double type, go with the default
+   one for the others.  */
+
+static machine_mode
+rl78_c_mode_for_floating_type (enum tree_index ti)
+{
+  if (ti == TI_DOUBLE_TYPE)
+    return SFmode;
+  return default_mode_for_floating_type (ti);
+}
+
 \f
 /* The strub runtime uses asms, and physical register allocation won't
    deal with them, so disable it.  */
diff --git a/gcc/config/rl78/rl78.h b/gcc/config/rl78/rl78.h
index cfff98df6bc..a960aee3931 100644
--- a/gcc/config/rl78/rl78.h
+++ b/gcc/config/rl78/rl78.h
@@ -113,10 +113,6 @@
 #define LONG_TYPE_SIZE			32
 #define LONG_LONG_TYPE_SIZE		64
 
-#define FLOAT_TYPE_SIZE 		32
-#define DOUBLE_TYPE_SIZE 		32 /*64*/
-#define LONG_DOUBLE_TYPE_SIZE		64 /*DOUBLE_TYPE_SIZE*/
-
 #define DEFAULT_SIGNED_CHAR		0
 
 #define STRICT_ALIGNMENT 		1
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 43/52] rx: New hook implementation rx_c_mode_for_floating_type
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (41 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 42/52] rl78: New hook implementation rl78_c_mode_for_floating_type Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-03 13:36   ` Nick Clifton
  2024-06-03  3:01 ` [PATCH 44/52] s390: New hook implementation s390_c_mode_for_floating_type Kewen Lin
                   ` (8 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, nickc

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in rx port, and add new port specific hook
implementation rx_c_mode_for_floating_type.

gcc/ChangeLog:

	* config/rx/rx.cc (rx_c_mode_for_floating_type): New function.
	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
	* config/rx/rx.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/rx/rx.cc | 15 +++++++++++++++
 gcc/config/rx/rx.h  |  4 ----
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/gcc/config/rx/rx.cc b/gcc/config/rx/rx.cc
index 9bf9d87fed1..8048cc98708 100644
--- a/gcc/config/rx/rx.cc
+++ b/gcc/config/rx/rx.cc
@@ -3648,6 +3648,18 @@ rx_modes_tieable_p (machine_mode mode1, machine_mode mode2)
 	  == (GET_MODE_CLASS (mode2) == MODE_FLOAT
 	      || GET_MODE_CLASS (mode2) == MODE_COMPLEX_FLOAT));
 }
+
+/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return SFmode or DFmode
+   for TI_{LONG_,}DOUBLE_TYPE which is for {long,} double type, go with
+   the default one for the others.  */
+
+static machine_mode
+rx_c_mode_for_floating_type (enum tree_index ti)
+{
+  if (ti == TI_DOUBLE_TYPE || ti == TI_LONG_DOUBLE_TYPE)
+    return TARGET_64BIT_DOUBLES ? DFmode : SFmode;
+  return default_mode_for_floating_type (ti);
+}
 \f
 #undef  TARGET_NARROW_VOLATILE_BITFIELD
 #define TARGET_NARROW_VOLATILE_BITFIELD		rx_narrow_volatile_bitfield
@@ -3807,6 +3819,9 @@ rx_modes_tieable_p (machine_mode mode1, machine_mode mode2)
 #undef  TARGET_HAVE_SPECULATION_SAFE_VALUE
 #define TARGET_HAVE_SPECULATION_SAFE_VALUE speculation_safe_value_not_needed
 
+#undef TARGET_C_MODE_FOR_FLOATING_TYPE
+#define TARGET_C_MODE_FOR_FLOATING_TYPE rx_c_mode_for_floating_type
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-rx.h"
diff --git a/gcc/config/rx/rx.h b/gcc/config/rx/rx.h
index ff445df49a3..15d6d2503e7 100644
--- a/gcc/config/rx/rx.h
+++ b/gcc/config/rx/rx.h
@@ -132,10 +132,6 @@
 #define LONG_TYPE_SIZE			32
 #define LONG_LONG_TYPE_SIZE		64
 
-#define FLOAT_TYPE_SIZE 		32
-#define DOUBLE_TYPE_SIZE 		(TARGET_64BIT_DOUBLES ? 64 : 32)
-#define LONG_DOUBLE_TYPE_SIZE		DOUBLE_TYPE_SIZE
-
 #define DEFAULT_SIGNED_CHAR		0
 
 /* RX load/store instructions can handle unaligned addresses.  */
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 44/52] s390: New hook implementation s390_c_mode_for_floating_type
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (42 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 43/52] rx: New hook implementation rx_c_mode_for_floating_type Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-13  7:43   ` PING^1 " Kewen.Lin
  2024-06-03  3:01 ` [PATCH 45/52] sh: New hook implementation sh_c_mode_for_floating_type Kewen Lin
                   ` (7 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, uweigand, krebbel

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in s390 port, and add new port specific hook
implementation s390_c_mode_for_floating_type.

gcc/ChangeLog:

	* config/s390/s390.cc (s390_c_mode_for_floating_type): New function.
	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
	* config/s390/s390.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/s390/s390.cc | 15 +++++++++++++++
 gcc/config/s390/s390.h  |  3 ---
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc
index fa517bd3e77..117da36b3c0 100644
--- a/gcc/config/s390/s390.cc
+++ b/gcc/config/s390/s390.cc
@@ -18066,6 +18066,18 @@ s390_noce_conversion_profitable_p (rtx_insn *seq, struct noce_if_info *if_info)
   return default_noce_conversion_profitable_p (seq, if_info);
 }
 
+/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return TFmode or DFmode
+   for TI_LONG_DOUBLE_TYPE which is for long double type, go with the
+   default one for the others.  */
+
+static machine_mode
+s390_c_mode_for_floating_type (enum tree_index ti)
+{
+  if (ti == TI_LONG_DOUBLE_TYPE)
+    return TARGET_LONG_DOUBLE_128 ? TFmode : DFmode;
+  return default_mode_for_floating_type (ti);
+}
+
 /* Initialize GCC target structure.  */
 
 #undef  TARGET_ASM_ALIGNED_HI_OP
@@ -18382,6 +18394,9 @@ s390_noce_conversion_profitable_p (rtx_insn *seq, struct noce_if_info *if_info)
 #undef TARGET_NOCE_CONVERSION_PROFITABLE_P
 #define TARGET_NOCE_CONVERSION_PROFITABLE_P s390_noce_conversion_profitable_p
 
+#undef TARGET_C_MODE_FOR_FLOATING_TYPE
+#define TARGET_C_MODE_FOR_FLOATING_TYPE s390_c_mode_for_floating_type
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-s390.h"
diff --git a/gcc/config/s390/s390.h b/gcc/config/s390/s390.h
index 0e6666a8802..4a4dde1a9ba 100644
--- a/gcc/config/s390/s390.h
+++ b/gcc/config/s390/s390.h
@@ -396,9 +396,6 @@ extern const char *s390_host_detect_local_cpu (int argc, const char **argv);
 #define INT_TYPE_SIZE 32
 #define LONG_TYPE_SIZE (TARGET_64BIT ? 64 : 32)
 #define LONG_LONG_TYPE_SIZE 64
-#define FLOAT_TYPE_SIZE 32
-#define DOUBLE_TYPE_SIZE 64
-#define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
 
 /* Work around target_flags dependency in ada/targtyps.cc.  */
 #define WIDEST_HARDWARE_FP_SIZE 64
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 45/52] sh: New hook implementation sh_c_mode_for_floating_type
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (43 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 44/52] s390: New hook implementation s390_c_mode_for_floating_type Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-03  3:16   ` Oleg Endo
  2024-06-03  3:01 ` [PATCH 46/52] h8300: New hook implementation h8300_c_mode_for_floating_type Kewen Lin
                   ` (6 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, aoliva, olegendo

This is to remove macro LONG_DOUBLE_TYPE_SIZE define in
sh port, and add new port specific hook implementation
sh_c_mode_for_floating_type.

gcc/ChangeLog:

	* config/sh/sh.cc (sh_c_mode_for_floating_type): New function.
	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
	* config/sh/sh.h (LONG_DOUBLE_TYPE_SIZE): Remove.
---
 gcc/config/sh/sh.cc | 18 ++++++++++++++++++
 gcc/config/sh/sh.h  | 10 ----------
 2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/gcc/config/sh/sh.cc b/gcc/config/sh/sh.cc
index ef3c2e6791d..bc017420381 100644
--- a/gcc/config/sh/sh.cc
+++ b/gcc/config/sh/sh.cc
@@ -328,6 +328,7 @@ static unsigned int sh_hard_regno_nregs (unsigned int, machine_mode);
 static bool sh_hard_regno_mode_ok (unsigned int, machine_mode);
 static bool sh_modes_tieable_p (machine_mode, machine_mode);
 static bool sh_can_change_mode_class (machine_mode, machine_mode, reg_class_t);
+static machine_mode sh_c_mode_for_floating_type (enum tree_index);
 \f
 TARGET_GNU_ATTRIBUTES (sh_attribute_table,
 {
@@ -664,6 +665,9 @@ TARGET_GNU_ATTRIBUTES (sh_attribute_table,
 #undef  TARGET_HAVE_SPECULATION_SAFE_VALUE
 #define TARGET_HAVE_SPECULATION_SAFE_VALUE speculation_safe_value_not_needed
 
+#undef TARGET_C_MODE_FOR_FLOATING_TYPE
+#define TARGET_C_MODE_FOR_FLOATING_TYPE sh_c_mode_for_floating_type
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 \f
 
@@ -10674,6 +10678,20 @@ sh_can_change_mode_class (machine_mode from, machine_mode to,
   return true;
 }
 
+/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return SFmode or DFmode
+   for TI_DOUBLE_TYPE which is for double type, go with the default one
+   for the others.  */
+
+static machine_mode
+sh_c_mode_for_floating_type (enum tree_index ti)
+{
+  /* Since the SH2e has only `float' support, it is desirable to make all
+     floating point types equivalent to `float'.  */
+  if (ti == TI_DOUBLE_TYPE)
+    return TARGET_FPU_SINGLE_ONLY ? SFmode : DFmode;
+  return default_mode_for_floating_type (ti);
+}
+
 /* Return true if registers in machine mode MODE will likely be
    allocated to registers in small register classes.  */
 bool
diff --git a/gcc/config/sh/sh.h b/gcc/config/sh/sh.h
index 7d3a3f08338..53cad85d122 100644
--- a/gcc/config/sh/sh.h
+++ b/gcc/config/sh/sh.h
@@ -425,9 +425,6 @@ extern const sh_atomic_model& selected_atomic_model (void);
 /* Width in bits of a `long long'.  */
 #define LONG_LONG_TYPE_SIZE 64
 
-/* Width in bits of a `long double'.  */
-#define LONG_DOUBLE_TYPE_SIZE 64
-
 /* Width of a word, in units (bytes).  */
 #define UNITS_PER_WORD	(4)
 #define MIN_UNITS_PER_WORD 4
@@ -1433,13 +1430,6 @@ extern bool current_function_interrupt;
    Do not define this if the table should contain absolute addresses.  */
 #define CASE_VECTOR_PC_RELATIVE 1
 
-/* Define it here, so that it doesn't get bumped to 64-bits on SHmedia.  */
-#define FLOAT_TYPE_SIZE 32
-
-/* Since the SH2e has only `float' support, it is desirable to make all
-   floating point types equivalent to `float'.  */
-#define DOUBLE_TYPE_SIZE (TARGET_FPU_SINGLE_ONLY ? 32 : 64)
-
 /* 'char' is signed by default.  */
 #define DEFAULT_SIGNED_CHAR  1
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 46/52] h8300: New hook implementation h8300_c_mode_for_floating_type
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (44 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 45/52] sh: New hook implementation sh_c_mode_for_floating_type Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-13  7:43   ` PING^1 " Kewen.Lin
  2024-06-03  3:01 ` [PATCH 47/52] loongarch: New hook implementation loongarch_c_mode_for_floating_type Kewen Lin
                   ` (5 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, jeffreyalaw

This is to add new port specific hook implementation
h8300_c_mode_for_floating_type, remove useless macro
defines for {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE and add
new macro DOUBLE_TYPE_MODE which some subtarget can
redefine.

gcc/ChangeLog:

	* config/h8300/h8300.cc (h8300_c_mode_for_floating_type): New
	function.
	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
	* config/h8300/h8300.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Remove.
	(LONG_DOUBLE_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_MODE): New macro.
	* config/h8300/linux.h (DOUBLE_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_MODE): New macro.
---
 gcc/config/h8300/h8300.cc | 15 +++++++++++++++
 gcc/config/h8300/h8300.h  |  4 +---
 gcc/config/h8300/linux.h  |  4 ++--
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/gcc/config/h8300/h8300.cc b/gcc/config/h8300/h8300.cc
index 9ac6d52f9d6..7ab26f2b7f9 100644
--- a/gcc/config/h8300/h8300.cc
+++ b/gcc/config/h8300/h8300.cc
@@ -5601,6 +5601,18 @@ h8300_ok_for_sibcall_p (tree fndecl, tree)
   return 1;
 }
 
+/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return SFmode or DFmode
+   for TI_{LONG_,}DOUBLE_TYPE which is for {long,} double type, go with
+   the default one for the others.  */
+
+static machine_mode
+h8300_c_mode_for_floating_type (enum tree_index ti)
+{
+  if (ti == TI_DOUBLE_TYPE || ti == TI_LONG_DOUBLE_TYPE)
+    return DOUBLE_TYPE_MODE;
+  return default_mode_for_floating_type (ti);
+}
+
 /* Return TRUE if OP is a PRE_INC or PRE_DEC
    instruction using REG, FALSE otherwise.  */
 
@@ -5721,4 +5733,7 @@ pre_incdec_with_reg (rtx op, unsigned int reg)
 #undef TARGET_FUNCTION_OK_FOR_SIBCALL
 #define TARGET_FUNCTION_OK_FOR_SIBCALL h8300_ok_for_sibcall_p
 
+#undef TARGET_C_MODE_FOR_FLOATING_TYPE
+#define TARGET_C_MODE_FOR_FLOATING_TYPE h8300_c_mode_for_floating_type
+
 struct gcc_target targetm = TARGET_INITIALIZER;
diff --git a/gcc/config/h8300/h8300.h b/gcc/config/h8300/h8300.h
index bb0bf7404e0..d25689ccec8 100644
--- a/gcc/config/h8300/h8300.h
+++ b/gcc/config/h8300/h8300.h
@@ -149,9 +149,7 @@ extern const char * const *h8_reg_names;
 #define INT_TYPE_SIZE		(TARGET_INT32 ? 32 : 16)
 #define LONG_TYPE_SIZE		32
 #define LONG_LONG_TYPE_SIZE	64
-#define FLOAT_TYPE_SIZE	32
-#define DOUBLE_TYPE_SIZE	32
-#define LONG_DOUBLE_TYPE_SIZE	DOUBLE_TYPE_SIZE
+#define DOUBLE_TYPE_MODE	SFmode
 
 #define MAX_FIXED_MODE_SIZE	32
 
diff --git a/gcc/config/h8300/linux.h b/gcc/config/h8300/linux.h
index 326c481b512..6e21db37655 100644
--- a/gcc/config/h8300/linux.h
+++ b/gcc/config/h8300/linux.h
@@ -36,8 +36,8 @@ along with GCC; see the file COPYING3.  If not see
 #define TARGET_DEFAULT (MASK_QUICKCALL | MASK_INT32 | MASK_H8300H)
 
 /* Width of a word, in units (bytes).  */
-#undef DOUBLE_TYPE_SIZE
-#define DOUBLE_TYPE_SIZE	64
+#undef DOUBLE_TYPE_MODE
+#define DOUBLE_TYPE_MODE	DFmode
 
 #undef DEFAULT_SIGNED_CHAR
 #define DEFAULT_SIGNED_CHAR 1
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 47/52] loongarch: New hook implementation loongarch_c_mode_for_floating_type
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (45 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 46/52] h8300: New hook implementation h8300_c_mode_for_floating_type Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-04  1:45   ` Lulu Cheng
  2024-06-03  3:01 ` [PATCH 48/52] m68k: New hook implementation m68k_c_mode_for_floating_type Kewen Lin
                   ` (4 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, xuchenghua, chenglulu

This is to add new port specific hook implementation
loongarch_c_mode_for_floating_type, remove macro
defines for FLOAT_TYPE_SIZE and DOUBLE_TYPE_SIZE, and
rename LONG_DOUBLE_TYPE_SIZE to LA_LONG_DOUBLE_TYPE_SIZE
as we poison LONG_DOUBLE_TYPE_SIZE but some macros need
LONG_DOUBLE_TYPE_SIZE.

gcc/ChangeLog:

	* config/loongarch/loongarch.cc (loongarch_c_mode_for_floating_type):
	New function.
	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
	* config/loongarch/loongarch.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Remove.
	(LONG_DOUBLE_TYPE_SIZE): Rename to ...
	(LA_LONG_DOUBLE_TYPE_SIZE): ... this.
	(UNITS_PER_FPVALUE): Replace LONG_DOUBLE_TYPE_SIZE with
	LA_LONG_DOUBLE_TYPE_SIZE.
	(MAX_FIXED_MODE_SIZE): Likewise.
	(STRUCTURE_SIZE_BOUNDARY): Likewise.
	(BIGGEST_ALIGNMENT): Likewise.
---
 gcc/config/loongarch/loongarch.cc | 15 +++++++++++++++
 gcc/config/loongarch/loongarch.h  | 13 ++++++-------
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
index e7835ae34ae..e4a51303d22 100644
--- a/gcc/config/loongarch/loongarch.cc
+++ b/gcc/config/loongarch/loongarch.cc
@@ -10946,6 +10946,18 @@ loongarch_builtin_support_vector_misalignment (machine_mode mode,
 						      is_packed);
 }
 
+/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return TFmode or DFmode
+   for TI_LONG_DOUBLE_TYPE which is for long double type, go with the
+   default one for the others.  */
+
+static machine_mode
+loongarch_c_mode_for_floating_type (enum tree_index ti)
+{
+  if (ti == TI_LONG_DOUBLE_TYPE)
+    return TARGET_64BIT ? TFmode : DFmode;
+  return default_mode_for_floating_type (ti);
+}
+
 static bool
 use_rsqrt_p (void)
 {
@@ -11256,6 +11268,9 @@ loongarch_asm_code_end (void)
 #define TARGET_VECTORIZE_SUPPORT_VECTOR_MISALIGNMENT \
   loongarch_builtin_support_vector_misalignment
 
+#undef TARGET_C_MODE_FOR_FLOATING_TYPE
+#define TARGET_C_MODE_FOR_FLOATING_TYPE loongarch_c_mode_for_floating_type
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-loongarch.h"
diff --git a/gcc/config/loongarch/loongarch.h b/gcc/config/loongarch/loongarch.h
index f7fe950f333..b9323aba394 100644
--- a/gcc/config/loongarch/loongarch.h
+++ b/gcc/config/loongarch/loongarch.h
@@ -151,7 +151,7 @@ along with GCC; see the file COPYING3.  If not see
 #define UNITS_PER_FPVALUE \
   (TARGET_SOFT_FLOAT ? 0 \
    : TARGET_SINGLE_FLOAT ? UNITS_PER_FP_REG \
-			 : LONG_DOUBLE_TYPE_SIZE / BITS_PER_UNIT)
+			 : LA_LONG_DOUBLE_TYPE_SIZE / BITS_PER_UNIT)
 
 /* The number of bytes in a double.  */
 #define UNITS_PER_DOUBLE (TYPE_PRECISION (double_type_node) / BITS_PER_UNIT)
@@ -162,9 +162,8 @@ along with GCC; see the file COPYING3.  If not see
 #define LONG_TYPE_SIZE (TARGET_64BIT ? 64 : 32)
 #define LONG_LONG_TYPE_SIZE 64
 
-#define FLOAT_TYPE_SIZE 32
-#define DOUBLE_TYPE_SIZE 64
-#define LONG_DOUBLE_TYPE_SIZE (TARGET_64BIT ? 128 : 64)
+/* LONG_DOUBLE_TYPE_SIZE get poisoned, so add LA_ prefix.  */
+#define LA_LONG_DOUBLE_TYPE_SIZE (TARGET_64BIT ? 128 : 64)
 
 /* Define the sizes of fixed-point types.  */
 #define SHORT_FRACT_TYPE_SIZE 8
@@ -179,7 +178,7 @@ along with GCC; see the file COPYING3.  If not see
 
 /* long double is not a fixed mode, but the idea is that, if we
    support long double, we also want a 128-bit integer type.  */
-#define MAX_FIXED_MODE_SIZE LONG_DOUBLE_TYPE_SIZE
+#define MAX_FIXED_MODE_SIZE LA_LONG_DOUBLE_TYPE_SIZE
 
 /* Width in bits of a pointer.  */
 #ifndef POINTER_SIZE
@@ -200,11 +199,11 @@ along with GCC; see the file COPYING3.  If not see
 #define STRUCTURE_SIZE_BOUNDARY 8
 
 /* There is no point aligning anything to a rounder boundary than
-   LONG_DOUBLE_TYPE_SIZE, unless under LSX/LASX the bigggest alignment is
+   LA_LONG_DOUBLE_TYPE_SIZE, unless under LSX/LASX the bigggest alignment is
    BITS_PER_LSX_REG/BITS_PER_LASX_REG/..  */
 #define BIGGEST_ALIGNMENT \
   (ISA_HAS_LASX? BITS_PER_LASX_REG \
-   : (ISA_HAS_LSX ? BITS_PER_LSX_REG : LONG_DOUBLE_TYPE_SIZE))
+   : (ISA_HAS_LSX ? BITS_PER_LSX_REG : LA_LONG_DOUBLE_TYPE_SIZE))
 
 /* All accesses must be aligned.  */
 #define STRICT_ALIGNMENT (TARGET_STRICT_ALIGN)
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 48/52] m68k: New hook implementation m68k_c_mode_for_floating_type
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (46 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 47/52] loongarch: New hook implementation loongarch_c_mode_for_floating_type Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-13  7:43   ` PING^1 " Kewen.Lin
  2024-06-03  3:01 ` [PATCH 49/52] mips: New hook implementation mips_c_mode_for_floating_type Kewen Lin
                   ` (3 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, jeffreyalaw, schwab, phdm

This is to add new port specific hook implementation
m68k_c_mode_for_floating_type, remove macro
LONG_DOUBLE_TYPE_SIZE and add new macro
LONG_DOUBLE_TYPE_MODE which some subtarget can redefine.

gcc/ChangeLog:

	* config/m68k/m68k.cc (m68k_c_mode_for_floating_type): New function.
	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
	* config/m68k/m68k.h (LONG_DOUBLE_TYPE_SIZE): Remove.
	(LONG_DOUBLE_TYPE_MODE): New macro.
	* config/m68k/netbsd-elf.h (LONG_DOUBLE_TYPE_SIZE): Remove.
	(LONG_DOUBLE_TYPE_MODE): New macro.
---
 gcc/config/m68k/m68k.cc      | 16 ++++++++++++++++
 gcc/config/m68k/m68k.h       |  4 ++--
 gcc/config/m68k/netbsd-elf.h |  4 ++--
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/gcc/config/m68k/m68k.cc b/gcc/config/m68k/m68k.cc
index b1c9238949f..79ba4d5343c 100644
--- a/gcc/config/m68k/m68k.cc
+++ b/gcc/config/m68k/m68k.cc
@@ -198,6 +198,7 @@ static machine_mode m68k_promote_function_mode (const_tree, machine_mode,
 						int *, const_tree, int);
 static void m68k_asm_final_postscan_insn (FILE *, rtx_insn *insn, rtx [], int);
 static HARD_REG_SET m68k_zero_call_used_regs (HARD_REG_SET);
+static machine_mode m68k_c_mode_for_floating_type (enum tree_index);
 \f
 /* Initialize the GCC target structure.  */
 
@@ -365,6 +366,9 @@ static HARD_REG_SET m68k_zero_call_used_regs (HARD_REG_SET);
 #undef TARGET_ZERO_CALL_USED_REGS
 #define TARGET_ZERO_CALL_USED_REGS m68k_zero_call_used_regs
 
+#undef TARGET_C_MODE_FOR_FLOATING_TYPE
+#define TARGET_C_MODE_FOR_FLOATING_TYPE m68k_c_mode_for_floating_type
+
 TARGET_GNU_ATTRIBUTES (m68k_attribute_table,
 {
   /* { name, min_len, max_len, decl_req, type_req, fn_type_req,
@@ -7212,4 +7216,16 @@ m68k_zero_call_used_regs (HARD_REG_SET need_zeroed_hardregs)
   return need_zeroed_hardregs;
 }
 
+/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return XFmode or DFmode
+   for TI_LONG_DOUBLE_TYPE which is for long double type, go with the
+   default one for the others.  */
+
+static machine_mode
+m68k_c_mode_for_floating_type (enum tree_index ti)
+{
+  if (ti == TI_LONG_DOUBLE_TYPE)
+    return LONG_DOUBLE_TYPE_MODE;
+  return default_mode_for_floating_type (ti);
+}
+
 #include "gt-m68k.h"
diff --git a/gcc/config/m68k/m68k.h b/gcc/config/m68k/m68k.h
index 1aa89f1789b..0d571997143 100644
--- a/gcc/config/m68k/m68k.h
+++ b/gcc/config/m68k/m68k.h
@@ -278,8 +278,8 @@ along with GCC; see the file COPYING3.  If not see
 /* "long double" is the same as "double" on ColdFire and fido
    targets.  */
 
-#define LONG_DOUBLE_TYPE_SIZE			\
-  ((TARGET_COLDFIRE || TARGET_FIDOA) ? 64 : 80)
+#define LONG_DOUBLE_TYPE_MODE			\
+  ((TARGET_COLDFIRE || TARGET_FIDOA) ? DFmode : XFmode)
 
 #define BITS_BIG_ENDIAN 1
 #define BYTES_BIG_ENDIAN 1
diff --git a/gcc/config/m68k/netbsd-elf.h b/gcc/config/m68k/netbsd-elf.h
index 5239f09b4cc..6fc5ad1a0a6 100644
--- a/gcc/config/m68k/netbsd-elf.h
+++ b/gcc/config/m68k/netbsd-elf.h
@@ -36,8 +36,8 @@ along with GCC; see the file COPYING3.  If not see
   while (0)
 
 /* Don't try using XFmode on the 68010.  */ 
-#undef LONG_DOUBLE_TYPE_SIZE
-#define LONG_DOUBLE_TYPE_SIZE (TARGET_68020 ? 80 : 64)
+#undef LONG_DOUBLE_TYPE_MODE
+#define LONG_DOUBLE_TYPE_MODE (TARGET_68020 ? XFmode : DFmode)
 
 #undef SUBTARGET_EXTRA_SPECS
 #define SUBTARGET_EXTRA_SPECS \
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 49/52] mips: New hook implementation mips_c_mode_for_floating_type
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (47 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 48/52] m68k: New hook implementation m68k_c_mode_for_floating_type Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-04  1:16   ` YunQiang Su
  2024-06-03  3:01 ` [PATCH 50/52] pa: New hook implementation pa_c_mode_for_floating_type Kewen Lin
                   ` (2 subsequent siblings)
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, syq

This is to add new port specific hook implementation
mips_c_mode_for_floating_type, remove macros FLOAT_TYPE_SIZE
and DOUBLE_TYPE_SIZE, rename LONG_DOUBLE_TYPE_SIZE to
MIPS_LONG_DOUBLE_TYPE_SIZE since we poison LONG_DOUBLE_TYPE_SIZE
but some subtarget wants to redefine it and some macro defines
need it.

gcc/ChangeLog:

	* config/mips/mips.cc (mips_c_mode_for_floating_type): New function.
	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
	* config/mips/mips.h (UNITS_PER_FPVALUE): Replace LONG_DOUBLE_TYPE_SIZE
	with MIPS_LONG_DOUBLE_TYPE_SIZE.
	(MAX_FIXED_MODE_SIZE): Likewise.
	(STRUCTURE_SIZE_BOUNDARY): Likewise.
	(BIGGEST_ALIGNMENT): Likewise.
	(FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Remove.
	(LONG_DOUBLE_TYPE_SIZE): Rename to ...
	(MIPS_LONG_DOUBLE_TYPE_SIZE): ... this.
	* config/mips/n32-elf.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
	(MIPS_LONG_DOUBLE_TYPE_SIZE): ... this.
---
 gcc/config/mips/mips.cc   | 14 ++++++++++++++
 gcc/config/mips/mips.h    | 13 ++++++-------
 gcc/config/mips/n32-elf.h |  4 ++--
 3 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/gcc/config/mips/mips.cc b/gcc/config/mips/mips.cc
index b63d40a357b..3e5035a385c 100644
--- a/gcc/config/mips/mips.cc
+++ b/gcc/config/mips/mips.cc
@@ -22972,6 +22972,18 @@ mips_asm_file_end (void)
     file_end_indicate_exec_stack ();
 }
 
+/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return TFmode or DFmode
+   for TI_LONG_DOUBLE_TYPE which is for long double type, go with the
+   default one for the others.  */
+
+static machine_mode
+mips_c_mode_for_floating_type (enum tree_index ti)
+{
+  if (ti == TI_LONG_DOUBLE_TYPE)
+    return MIPS_LONG_DOUBLE_TYPE_SIZE == 64 ? DFmode : TFmode;
+  return default_mode_for_floating_type (ti);
+}
+
 void
 mips_bit_clear_info (enum machine_mode mode, unsigned HOST_WIDE_INT m,
 		      int *start_pos, int *size)
@@ -23340,6 +23352,8 @@ mips_bit_clear_p (enum machine_mode mode, unsigned HOST_WIDE_INT m)
 #undef TARGET_ASM_FILE_END
 #define TARGET_ASM_FILE_END mips_asm_file_end
 
+#undef TARGET_C_MODE_FOR_FLOATING_TYPE
+#define TARGET_C_MODE_FOR_FLOATING_TYPE mips_c_mode_for_floating_type
 
 struct gcc_target targetm = TARGET_INITIALIZER;
 \f
diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h
index 9d965966f2f..7a9b18c8096 100644
--- a/gcc/config/mips/mips.h
+++ b/gcc/config/mips/mips.h
@@ -1654,7 +1654,7 @@ FP_ASM_SPEC "\
 #define UNITS_PER_FPVALUE			\
   (TARGET_SOFT_FLOAT_ABI ? 0			\
    : TARGET_SINGLE_FLOAT ? UNITS_PER_FPREG	\
-   : LONG_DOUBLE_TYPE_SIZE / BITS_PER_UNIT)
+   : MIPS_LONG_DOUBLE_TYPE_SIZE / BITS_PER_UNIT)
 
 /* The number of bytes in a double.  */
 #define UNITS_PER_DOUBLE (TYPE_PRECISION (double_type_node) / BITS_PER_UNIT)
@@ -1665,9 +1665,8 @@ FP_ASM_SPEC "\
 #define LONG_TYPE_SIZE (TARGET_LONG64 ? 64 : 32)
 #define LONG_LONG_TYPE_SIZE 64
 
-#define FLOAT_TYPE_SIZE 32
-#define DOUBLE_TYPE_SIZE 64
-#define LONG_DOUBLE_TYPE_SIZE (TARGET_NEWABI ? 128 : 64)
+/* LONG_DOUBLE_TYPE_SIZE gets poisoned, so add MIPS_ prefix.  */
+#define MIPS_LONG_DOUBLE_TYPE_SIZE (TARGET_NEWABI ? 128 : 64)
 
 /* Define the sizes of fixed-point types.  */
 #define SHORT_FRACT_TYPE_SIZE 8
@@ -1684,7 +1683,7 @@ FP_ASM_SPEC "\
 
 /* long double is not a fixed mode, but the idea is that, if we
    support long double, we also want a 128-bit integer type.  */
-#define MAX_FIXED_MODE_SIZE LONG_DOUBLE_TYPE_SIZE
+#define MAX_FIXED_MODE_SIZE MIPS_LONG_DOUBLE_TYPE_SIZE
 
 /* Width in bits of a pointer.  */
 #ifndef POINTER_SIZE
@@ -1705,10 +1704,10 @@ FP_ASM_SPEC "\
 #define STRUCTURE_SIZE_BOUNDARY 8
 
 /* There is no point aligning anything to a rounder boundary than
-   LONG_DOUBLE_TYPE_SIZE, unless under MSA the bigggest alignment is
+   MIPS_LONG_DOUBLE_TYPE_SIZE, unless under MSA the bigggest alignment is
    BITS_PER_MSA_REG.  */
 #define BIGGEST_ALIGNMENT \
-  (ISA_HAS_MSA ? BITS_PER_MSA_REG : LONG_DOUBLE_TYPE_SIZE)
+  (ISA_HAS_MSA ? BITS_PER_MSA_REG : MIPS_LONG_DOUBLE_TYPE_SIZE)
 
 /* All accesses must be aligned.  */
 #define STRICT_ALIGNMENT (!ISA_HAS_UNALIGNED_ACCESS)
diff --git a/gcc/config/mips/n32-elf.h b/gcc/config/mips/n32-elf.h
index 94a90d847f0..01c8a852539 100644
--- a/gcc/config/mips/n32-elf.h
+++ b/gcc/config/mips/n32-elf.h
@@ -26,5 +26,5 @@ along with GCC; see the file COPYING3.  If not see
 #define NO_DOLLAR_IN_LABEL
 
 /* Force n32 to use 64-bit long doubles.  */
-#undef LONG_DOUBLE_TYPE_SIZE
-#define LONG_DOUBLE_TYPE_SIZE 64
+#undef MIPS_LONG_DOUBLE_TYPE_SIZE
+#define MIPS_LONG_DOUBLE_TYPE_SIZE 64
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 50/52] pa: New hook implementation pa_c_mode_for_floating_type
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (48 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 49/52] mips: New hook implementation mips_c_mode_for_floating_type Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-04 18:55   ` John David Anglin
  2024-06-03  3:01 ` [PATCH 51/52] sparc: New hook implementation sparc_c_mode_for_floating_type Kewen Lin
  2024-06-03  3:01 ` [PATCH 52/52] bfin: Rename macros {FLOAT,DOUBLE}_TYPE_SIZE Kewen Lin
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, jeffreyalaw, dave.anglin

This is to add new port specific hook implementation
pa_c_mode_for_floating_type, as we remove defines in
defaults.h for {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE, this
also defines them in pa.h but with PA_ prefix since
we poison {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE.

gcc/ChangeLog:

	* config/pa/pa.cc (pa_c_mode_for_floating_type): New function.
	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
	(pa_scalar_mode_supported_p): Rename FLOAT_TYPE_SIZE to
	PA_FLOAT_TYPE_SIZE, rename DOUBLE_TYPE_SIZE to PA_DOUBLE_TYPE_SIZE
	and rename LONG_DOUBLE_TYPE_SIZE to PA_LONG_DOUBLE_TYPE_SIZE.
	* config/pa/pa.h (PA_FLOAT_TYPE_SIZE): New macro.
	(PA_DOUBLE_TYPE_SIZE): Likewise.
	(PA_LONG_DOUBLE_TYPE_SIZE): Likewise.
	* config/pa/pa-64.h (FLOAT_TYPE_SIZE): Rename to ...
	(PA_FLOAT_TYPE_SIZE): ... this.
	(DOUBLE_TYPE_SIZE): Rename to ...
	(PA_DOUBLE_TYPE_SIZE): ... this.
	(LONG_DOUBLE_TYPE_SIZE): Rename to ...
	(PA_LONG_DOUBLE_TYPE_SIZE): ... this.
	* config/pa/pa-hpux.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
	(PA_LONG_DOUBLE_TYPE_SIZE): ... this.
---
 gcc/config/pa/pa-64.h   | 12 ++++++------
 gcc/config/pa/pa-hpux.h |  3 ++-
 gcc/config/pa/pa.cc     | 21 ++++++++++++++++++---
 gcc/config/pa/pa.h      |  6 ++++++
 4 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/gcc/config/pa/pa-64.h b/gcc/config/pa/pa-64.h
index ea9d86ee7d4..b676468d2ce 100644
--- a/gcc/config/pa/pa-64.h
+++ b/gcc/config/pa/pa-64.h
@@ -58,12 +58,12 @@ along with GCC; see the file COPYING3.  If not see
 #define LONG_TYPE_SIZE 64
 #undef LONG_LONG_TYPE_SIZE
 #define LONG_LONG_TYPE_SIZE 64
-#undef FLOAT_TYPE_SIZE
-#define FLOAT_TYPE_SIZE 32
-#undef DOUBLE_TYPE_SIZE
-#define DOUBLE_TYPE_SIZE 64
-#undef LONG_DOUBLE_TYPE_SIZE
-#define LONG_DOUBLE_TYPE_SIZE 128
+#undef PA_FLOAT_TYPE_SIZE
+#define PA_FLOAT_TYPE_SIZE 32
+#undef PA_DOUBLE_TYPE_SIZE
+#define PA_DOUBLE_TYPE_SIZE 64
+#undef PA_LONG_DOUBLE_TYPE_SIZE
+#define PA_LONG_DOUBLE_TYPE_SIZE 128
 
 /* ?!? This needs to be made compile-time selectable.
 
diff --git a/gcc/config/pa/pa-hpux.h b/gcc/config/pa/pa-hpux.h
index a7421d68ca0..accef447523 100644
--- a/gcc/config/pa/pa-hpux.h
+++ b/gcc/config/pa/pa-hpux.h
@@ -34,7 +34,8 @@ along with GCC; see the file COPYING3.  If not see
 #define SIZE_TYPE "unsigned int"
 #define PTRDIFF_TYPE "int"
 
-#define LONG_DOUBLE_TYPE_SIZE 128
+#undef PA_LONG_DOUBLE_TYPE_SIZE
+#define PA_LONG_DOUBLE_TYPE_SIZE 128
 #define FLOAT_LIB_COMPARE_RETURNS_BOOL(MODE, COMPARISON) ((MODE) == TFmode)
 
 /* GCC always defines __STDC__.  HP C++ compilers don't define it.  This
diff --git a/gcc/config/pa/pa.cc b/gcc/config/pa/pa.cc
index a7af6b8c121..ab4bfc5d0c2 100644
--- a/gcc/config/pa/pa.cc
+++ b/gcc/config/pa/pa.cc
@@ -194,6 +194,7 @@ static rtx pa_internal_arg_pointer (void);
 static bool pa_can_eliminate (const int, const int);
 static void pa_conditional_register_usage (void);
 static machine_mode pa_c_mode_for_suffix (char);
+static machine_mode pa_c_mode_for_floating_type (enum tree_index);
 static section *pa_function_section (tree, enum node_frequency, bool, bool);
 static bool pa_cannot_force_const_mem (machine_mode, rtx);
 static bool pa_legitimate_constant_p (machine_mode, rtx);
@@ -398,6 +399,8 @@ static size_t n_deferred_plabels = 0;
 #define TARGET_CONDITIONAL_REGISTER_USAGE pa_conditional_register_usage
 #undef TARGET_C_MODE_FOR_SUFFIX
 #define TARGET_C_MODE_FOR_SUFFIX pa_c_mode_for_suffix
+#undef TARGET_C_MODE_FOR_FLOATING_TYPE
+#define TARGET_C_MODE_FOR_FLOATING_TYPE pa_c_mode_for_floating_type
 #undef TARGET_ASM_FUNCTION_SECTION
 #define TARGET_ASM_FUNCTION_SECTION pa_function_section
 
@@ -6728,11 +6731,11 @@ pa_scalar_mode_supported_p (scalar_mode mode)
       return false;
 
     case MODE_FLOAT:
-      if (precision == FLOAT_TYPE_SIZE)
+      if (precision == PA_FLOAT_TYPE_SIZE)
 	return true;
-      if (precision == DOUBLE_TYPE_SIZE)
+      if (precision == PA_DOUBLE_TYPE_SIZE)
 	return true;
-      if (precision == LONG_DOUBLE_TYPE_SIZE)
+      if (precision == PA_LONG_DOUBLE_TYPE_SIZE)
 	return true;
       return false;
 
@@ -10808,6 +10811,18 @@ pa_c_mode_for_suffix (char suffix)
   return VOIDmode;
 }
 
+/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return TFmode or DFmode
+   for TI_LONG_DOUBLE_TYPE which is for long double type, go with the
+   default one for the others.  */
+
+static machine_mode
+pa_c_mode_for_floating_type (enum tree_index ti)
+{
+  if (ti == TI_LONG_DOUBLE_TYPE)
+    return PA_LONG_DOUBLE_TYPE_SIZE == 64 ? DFmode : TFmode;
+  return default_mode_for_floating_type (ti);
+}
+
 /* Target hook for function_section.  */
 
 static section *
diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h
index 127a0d1966d..7e45c358895 100644
--- a/gcc/config/pa/pa.h
+++ b/gcc/config/pa/pa.h
@@ -1306,3 +1306,9 @@ do {									     \
 /* An integer expression for the size in bits of the largest integer machine
    mode that should actually be used.  We allow pairs of registers.  */
 #define MAX_FIXED_MODE_SIZE GET_MODE_BITSIZE (TARGET_64BIT ? TImode : DImode)
+
+/* Define these macros as default for all subtargets, add PA_ prefix
+   as {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE get poisoned.  */
+#define PA_FLOAT_TYPE_SIZE BITS_PER_WORD
+#define PA_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
+#define PA_LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 51/52] sparc: New hook implementation sparc_c_mode_for_floating_type
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (49 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 50/52] pa: New hook implementation pa_c_mode_for_floating_type Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-03  9:02   ` Eric Botcazou
  2024-06-03  3:01 ` [PATCH 52/52] bfin: Rename macros {FLOAT,DOUBLE}_TYPE_SIZE Kewen Lin
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, davem, ebotcazou

This is to add new port specific hook implementation
sparc_c_mode_for_floating_type, remove macros
{FLOAT,DOUBLE}_TYPE_SIZE defines and rename
LONG_DOUBLE_TYPE_SIZE to SPARC_LONG_DOUBLE_TYPE_SIZE
as we poison LONG_DOUBLE_TYPE_SIZE and some subtargets
still want to re-define it.

gcc/ChangeLog:

	* config/sparc/sparc.cc (sparc_c_mode_for_floating_type): New function.
	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
	(FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Rename to ...
	(SPARC_LONG_DOUBLE_TYPE_SIZE): ... this.
	(sparc_type_code): Replace FLOAT_TYPE_SIZE with TYPE_PRECISION of
	float_type_node.
	* config/sparc/sparc.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Remove.
	* config/sparc/freebsd.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
	(SPARC_LONG_DOUBLE_TYPE_SIZE): ... this.
	* config/sparc/linux.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
	(SPARC_LONG_DOUBLE_TYPE_SIZE): ... this.
	* config/sparc/linux64.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
	(SPARC_LONG_DOUBLE_TYPE_SIZE): ... this.
	* config/sparc/netbsd-elf.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
	(SPARC_LONG_DOUBLE_TYPE_SIZE): ... this.
	* config/sparc/openbsd64.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
	(SPARC_LONG_DOUBLE_TYPE_SIZE): ... this.
	* config/sparc/sol2.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
	(SPARC_LONG_DOUBLE_TYPE_SIZE): ... this.
	* config/sparc/sp-elf.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
	(SPARC_LONG_DOUBLE_TYPE_SIZE): ... this.
	* config/sparc/sp64-elf.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
	(SPARC_LONG_DOUBLE_TYPE_SIZE): ... this.
---
 gcc/config/sparc/freebsd.h    |  4 ++--
 gcc/config/sparc/linux.h      |  2 +-
 gcc/config/sparc/linux64.h    |  4 ++--
 gcc/config/sparc/netbsd-elf.h | 12 ++++++------
 gcc/config/sparc/openbsd64.h  |  4 ++--
 gcc/config/sparc/sol2.h       |  2 +-
 gcc/config/sparc/sp-elf.h     |  4 ++--
 gcc/config/sparc/sp64-elf.h   |  4 ++--
 gcc/config/sparc/sparc.cc     | 31 ++++++++++++++++++++-----------
 gcc/config/sparc/sparc.h      |  9 ++++-----
 10 files changed, 42 insertions(+), 34 deletions(-)

diff --git a/gcc/config/sparc/freebsd.h b/gcc/config/sparc/freebsd.h
index 3f00a083c1d..5396b32c405 100644
--- a/gcc/config/sparc/freebsd.h
+++ b/gcc/config/sparc/freebsd.h
@@ -68,8 +68,8 @@ along with GCC; see the file COPYING3.  If not see
 
 /* Define for support of TFmode long double.
    SPARC ABI says that long double is 4 words.  */
-#undef  LONG_DOUBLE_TYPE_SIZE
-#define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
+#undef  SPARC_LONG_DOUBLE_TYPE_SIZE
+#define SPARC_LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
 
 /* Definitions for 64-bit SPARC running systems with ELF. */
 
diff --git a/gcc/config/sparc/linux.h b/gcc/config/sparc/linux.h
index 9646fa9c41e..8cc53899193 100644
--- a/gcc/config/sparc/linux.h
+++ b/gcc/config/sparc/linux.h
@@ -115,7 +115,7 @@ do {									\
 \f
 /* Define for support of TFmode long double.
    SPARC ABI says that long double is 4 words.  */
-#define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
+#define SPARC_LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
 
 #undef DITF_CONVERSION_LIBFUNCS
 #define DITF_CONVERSION_LIBFUNCS 1
diff --git a/gcc/config/sparc/linux64.h b/gcc/config/sparc/linux64.h
index 1e2e4aef2ad..66426d8f5fe 100644
--- a/gcc/config/sparc/linux64.h
+++ b/gcc/config/sparc/linux64.h
@@ -61,8 +61,8 @@ along with GCC; see the file COPYING3.  If not see
 
 /* Define for support of TFmode long double.
    SPARC ABI says that long double is 4 words.  */
-#undef LONG_DOUBLE_TYPE_SIZE
-#define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
+#undef SPARC_LONG_DOUBLE_TYPE_SIZE
+#define SPARC_LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
 
 #undef CPP_SUBTARGET_SPEC
 #define CPP_SUBTARGET_SPEC "\
diff --git a/gcc/config/sparc/netbsd-elf.h b/gcc/config/sparc/netbsd-elf.h
index 2cf85dd7096..3bb05c55278 100644
--- a/gcc/config/sparc/netbsd-elf.h
+++ b/gcc/config/sparc/netbsd-elf.h
@@ -160,8 +160,8 @@ along with GCC; see the file COPYING3.  If not see
 
 #ifdef SPARC_BI_ARCH
 
-#undef LONG_DOUBLE_TYPE_SIZE
-#define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
+#undef SPARC_LONG_DOUBLE_TYPE_SIZE
+#define SPARC_LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
 
 #undef  CC1_SPEC
 #if DEFAULT_ARCH32_P
@@ -181,8 +181,8 @@ along with GCC; see the file COPYING3.  If not see
 #if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
  || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
 
-#undef LONG_DOUBLE_TYPE_SIZE
-#define LONG_DOUBLE_TYPE_SIZE 128
+#undef SPARC_LONG_DOUBLE_TYPE_SIZE
+#define SPARC_LONG_DOUBLE_TYPE_SIZE 128
 
 #undef  CC1_SPEC
 #define CC1_SPEC CC1_SPEC64
@@ -193,8 +193,8 @@ along with GCC; see the file COPYING3.  If not see
 /* A 32-bit only compiler.  NetBSD don't support 128 bit `long double'
    for 32-bit code, unlike Solaris.  */
 
-#undef LONG_DOUBLE_TYPE_SIZE
-#define LONG_DOUBLE_TYPE_SIZE 64
+#undef SPARC_LONG_DOUBLE_TYPE_SIZE
+#define SPARC_LONG_DOUBLE_TYPE_SIZE 64
 
 #undef  CC1_SPEC
 #define CC1_SPEC CC1_SPEC32
diff --git a/gcc/config/sparc/openbsd64.h b/gcc/config/sparc/openbsd64.h
index 9cd23f29b35..19cc20e69cd 100644
--- a/gcc/config/sparc/openbsd64.h
+++ b/gcc/config/sparc/openbsd64.h
@@ -54,8 +54,8 @@ along with GCC; see the file COPYING3.  If not see
 #undef WCHAR_TYPE_SIZE
 #define WCHAR_TYPE_SIZE 32
 
-#undef LONG_DOUBLE_TYPE_SIZE
-#define LONG_DOUBLE_TYPE_SIZE 128
+#undef SPARC_LONG_DOUBLE_TYPE_SIZE
+#define SPARC_LONG_DOUBLE_TYPE_SIZE 128
 
 #undef LINK_SPEC
 #define LINK_SPEC \
diff --git a/gcc/config/sparc/sol2.h b/gcc/config/sparc/sol2.h
index 552f58b2cc8..5de312551a5 100644
--- a/gcc/config/sparc/sol2.h
+++ b/gcc/config/sparc/sol2.h
@@ -437,7 +437,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
 
 /* Define for support of TFmode long double.
    SPARC ABI says that long double is 4 words.  */
-#define LONG_DOUBLE_TYPE_SIZE 128
+#define SPARC_LONG_DOUBLE_TYPE_SIZE 128
 
 /* Solaris's _Qp_* library routine implementation clobbers the output
    memory before the inputs are fully consumed.  */
diff --git a/gcc/config/sparc/sp-elf.h b/gcc/config/sparc/sp-elf.h
index aa7982a9141..cc64d5dd58e 100644
--- a/gcc/config/sparc/sp-elf.h
+++ b/gcc/config/sparc/sp-elf.h
@@ -63,5 +63,5 @@ along with GCC; see the file COPYING3.  If not see
 #define WCHAR_TYPE_SIZE BITS_PER_WORD
 
 /* ??? until fixed.  */
-#undef LONG_DOUBLE_TYPE_SIZE
-#define LONG_DOUBLE_TYPE_SIZE 64
+#undef SPARC_LONG_DOUBLE_TYPE_SIZE
+#define SPARC_LONG_DOUBLE_TYPE_SIZE 64
diff --git a/gcc/config/sparc/sp64-elf.h b/gcc/config/sparc/sp64-elf.h
index a9c53cb6d4f..6eb5b86ddce 100644
--- a/gcc/config/sparc/sp64-elf.h
+++ b/gcc/config/sparc/sp64-elf.h
@@ -69,5 +69,5 @@ along with GCC; see the file COPYING3.  If not see
 #undef WCHAR_TYPE_SIZE
 #define WCHAR_TYPE_SIZE 16
 
-#undef LONG_DOUBLE_TYPE_SIZE
-#define LONG_DOUBLE_TYPE_SIZE 128
+#undef SPARC_LONG_DOUBLE_TYPE_SIZE
+#define SPARC_LONG_DOUBLE_TYPE_SIZE 128
diff --git a/gcc/config/sparc/sparc.cc b/gcc/config/sparc/sparc.cc
index 8a5f76c8885..6cecdd8e065 100644
--- a/gcc/config/sparc/sparc.cc
+++ b/gcc/config/sparc/sparc.cc
@@ -718,6 +718,7 @@ static bool sparc_vectorize_vec_perm_const (machine_mode, machine_mode,
 					    const vec_perm_indices &);
 static bool sparc_can_follow_jump (const rtx_insn *, const rtx_insn *);
 static HARD_REG_SET sparc_zero_call_used_regs (HARD_REG_SET);
+static machine_mode sparc_c_mode_for_floating_type (enum tree_index);
 \f
 #ifdef SUBTARGET_ATTRIBUTE_TABLE
 /* Table of valid machine attributes.  */
@@ -971,6 +972,9 @@ char sparc_hard_reg_printed[8];
 #undef TARGET_ZERO_CALL_USED_REGS
 #define TARGET_ZERO_CALL_USED_REGS sparc_zero_call_used_regs
 
+#undef TARGET_C_MODE_FOR_FLOATING_TYPE
+#define TARGET_C_MODE_FOR_FLOATING_TYPE sparc_c_mode_for_floating_type
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 /* Return the memory reference contained in X if any, zero otherwise.  */
@@ -9824,16 +9828,9 @@ sparc_assemble_integer (rtx x, unsigned int size, int aligned_p)
 #define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2)
 #endif
 
-#ifndef FLOAT_TYPE_SIZE
-#define FLOAT_TYPE_SIZE BITS_PER_WORD
-#endif
-
-#ifndef DOUBLE_TYPE_SIZE
-#define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
-#endif
-
-#ifndef LONG_DOUBLE_TYPE_SIZE
-#define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
+/* LONG_DOUBLE_TYPE_SIZE get poisoned, so add SPARC_ prefix.  */
+#ifndef SPARC_LONG_LONG_TYPE_SIZE
+#define SPARC_LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
 #endif
 
 unsigned long
@@ -9920,7 +9917,7 @@ sparc_type_code (tree type)
 	  /* Carefully distinguish all the standard types of C,
 	     without messing up if the language is not C.  */
 
-	  if (TYPE_PRECISION (type) == FLOAT_TYPE_SIZE)
+	  if (TYPE_PRECISION (type) == TYPE_PRECISION (float_type_node))
 	    return (qualifiers | 6);
 
 	  else
@@ -13984,4 +13981,16 @@ sparc_zero_call_used_regs (HARD_REG_SET need_zeroed_hardregs)
   return need_zeroed_hardregs;
 }
 
+/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return TFmode or DFmode
+   for TI_LONG_DOUBLE_TYPE which is for long double type, go with the
+   default one for the others.  */
+
+static machine_mode
+sparc_c_mode_for_floating_type (enum tree_index ti)
+{
+  if (ti == TI_LONG_DOUBLE_TYPE)
+    return SPARC_LONG_DOUBLE_TYPE_SIZE == 128 ? TFmode : DFmode;
+  return default_mode_for_floating_type (ti);
+}
+
 #include "gt-sparc.h"
diff --git a/gcc/config/sparc/sparc.h b/gcc/config/sparc/sparc.h
index 232ecb30ddc..8612832a03e 100644
--- a/gcc/config/sparc/sparc.h
+++ b/gcc/config/sparc/sparc.h
@@ -489,12 +489,11 @@ along with GCC; see the file COPYING3.  If not see
 #define INT_TYPE_SIZE		32
 #define LONG_TYPE_SIZE		(TARGET_ARCH64 ? 64 : 32)
 #define LONG_LONG_TYPE_SIZE	64
-#define FLOAT_TYPE_SIZE		32
-#define DOUBLE_TYPE_SIZE	64
 
-/* LONG_DOUBLE_TYPE_SIZE is defined per OS even though the
-   SPARC ABI says that it is 128-bit wide.  */
-/* #define LONG_DOUBLE_TYPE_SIZE	128 */
+/* SPARC_LONG_DOUBLE_TYPE_SIZE is defined per OS even though the
+   SPARC ABI says that it is 128-bit wide.  LONG_DOUBLE_TYPE_SIZE
+   get poisoned, so add SPARC_ prefix.  */
+/* #define SPARC_LONG_DOUBLE_TYPE_SIZE	128 */
 
 /* The widest floating-point format really supported by the hardware.  */
 #define WIDEST_HARDWARE_FP_SIZE 64
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 52/52] bfin: Rename macros {FLOAT,DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
                   ` (50 preceding siblings ...)
  2024-06-03  3:01 ` [PATCH 51/52] sparc: New hook implementation sparc_c_mode_for_floating_type Kewen Lin
@ 2024-06-03  3:01 ` Kewen Lin
  2024-06-13  7:43   ` PING^1 " Kewen.Lin
  51 siblings, 1 reply; 149+ messages in thread
From: Kewen Lin @ 2024-06-03  3:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: linkw, jzhang918

This patch is to remove LONG_DOUBLE_TYPE_SIZE and
rename macros {FLOAT,DOUBLE}_TYPE_SIZE with prefix
BFIN_ as some macro defines want to use them, keeping
them can have better code readability.

gcc/ChangeLog:

	* config/bfin/bfin.h (FLOAT_TYPE_SIZE): Rename to ...
	(BFIN_FLOAT_TYPE_SIZE): ... this.
	(DOUBLE_TYPE_SIZE): Rename to ...
	(BFIN_DOUBLE_TYPE_SIZE): ... this.
	(LONG_DOUBLE_TYPE_SIZE): Remove.
	(UNITS_PER_FLOAT): Replace FLOAT_TYPE_SIZE with BFIN_FLOAT_TYPE_SIZE.
	(UNITS_PER_DOUBLE): Replace DOUBLE_TYPE_SIZE with
	BFIN_DOUBLE_TYPE_SIZE.
---
 gcc/config/bfin/bfin.h | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/gcc/config/bfin/bfin.h b/gcc/config/bfin/bfin.h
index e6ac8e3206c..e957c31a788 100644
--- a/gcc/config/bfin/bfin.h
+++ b/gcc/config/bfin/bfin.h
@@ -862,10 +862,10 @@ typedef struct {
  *  really cause some alignment problem
  */
 
-#define UNITS_PER_FLOAT  ((FLOAT_TYPE_SIZE  + BITS_PER_UNIT - 1) / \
+#define UNITS_PER_FLOAT  ((BFIN_FLOAT_TYPE_SIZE  + BITS_PER_UNIT - 1) / \
 			   BITS_PER_UNIT)
 
-#define UNITS_PER_DOUBLE ((DOUBLE_TYPE_SIZE + BITS_PER_UNIT - 1) / \
+#define UNITS_PER_DOUBLE ((BFIN_DOUBLE_TYPE_SIZE + BITS_PER_UNIT - 1) / \
  			   BITS_PER_UNIT)
 
 
@@ -874,7 +874,8 @@ typedef struct {
 
 /* Define this as 1 if `char' should by default be signed; else as 0.  */
 #define DEFAULT_SIGNED_CHAR 1
-#define FLOAT_TYPE_SIZE BITS_PER_WORD
+/* FLOAT_TYPE_SIZE get poisoned, so add BFIN_ prefix.  */
+#define BFIN_FLOAT_TYPE_SIZE BITS_PER_WORD
 #define SHORT_TYPE_SIZE 16 
 #define CHAR_TYPE_SIZE	8
 #define INT_TYPE_SIZE	32
@@ -890,8 +891,8 @@ typedef struct {
  * #define DOUBLES_ARE_FLOATS 1
  */
 
-#define DOUBLE_TYPE_SIZE	64
-#define LONG_DOUBLE_TYPE_SIZE	64
+/* DOUBLE_TYPE_SIZE get poisoned, so add BFIN_ prefix.  */
+#define BFIN_DOUBLE_TYPE_SIZE	64
 
 /* `PROMOTE_MODE (M, UNSIGNEDP, TYPE)'
      A macro to update M and UNSIGNEDP when an object whose type is
-- 
2.43.0


^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 45/52] sh: New hook implementation sh_c_mode_for_floating_type
  2024-06-03  3:01 ` [PATCH 45/52] sh: New hook implementation sh_c_mode_for_floating_type Kewen Lin
@ 2024-06-03  3:16   ` Oleg Endo
  0 siblings, 0 replies; 149+ messages in thread
From: Oleg Endo @ 2024-06-03  3:16 UTC (permalink / raw)
  To: Kewen Lin, gcc-patches; +Cc: aoliva, olegendo


Hi!

On Sun, 2024-06-02 at 22:01 -0500, Kewen Lin wrote:
> This is to remove macro LONG_DOUBLE_TYPE_SIZE define in
> sh port, and add new port specific hook implementation
> sh_c_mode_for_floating_type.
> 

The SH parts look OK to me.

Best regards,
Oleg Endo


> gcc/ChangeLog:
> 
> 	* config/sh/sh.cc (sh_c_mode_for_floating_type): New function.
> 	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
> 	* config/sh/sh.h (LONG_DOUBLE_TYPE_SIZE): Remove.
> ---
>  gcc/config/sh/sh.cc | 18 ++++++++++++++++++
>  gcc/config/sh/sh.h  | 10 ----------
>  2 files changed, 18 insertions(+), 10 deletions(-)
> 
> diff --git a/gcc/config/sh/sh.cc b/gcc/config/sh/sh.cc
> index ef3c2e6791d..bc017420381 100644
> --- a/gcc/config/sh/sh.cc
> +++ b/gcc/config/sh/sh.cc
> @@ -328,6 +328,7 @@ static unsigned int sh_hard_regno_nregs (unsigned int, machine_mode);
>  static bool sh_hard_regno_mode_ok (unsigned int, machine_mode);
>  static bool sh_modes_tieable_p (machine_mode, machine_mode);
>  static bool sh_can_change_mode_class (machine_mode, machine_mode, reg_class_t);
> +static machine_mode sh_c_mode_for_floating_type (enum tree_index);
>  \f
>  TARGET_GNU_ATTRIBUTES (sh_attribute_table,
>  {
> @@ -664,6 +665,9 @@ TARGET_GNU_ATTRIBUTES (sh_attribute_table,
>  #undef  TARGET_HAVE_SPECULATION_SAFE_VALUE
>  #define TARGET_HAVE_SPECULATION_SAFE_VALUE speculation_safe_value_not_needed
>  
> +#undef TARGET_C_MODE_FOR_FLOATING_TYPE
> +#define TARGET_C_MODE_FOR_FLOATING_TYPE sh_c_mode_for_floating_type
> +
>  struct gcc_target targetm = TARGET_INITIALIZER;
>  \f
>  
> @@ -10674,6 +10678,20 @@ sh_can_change_mode_class (machine_mode from, machine_mode to,
>    return true;
>  }
>  
> +/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return SFmode or DFmode
> +   for TI_DOUBLE_TYPE which is for double type, go with the default one
> +   for the others.  */
> +
> +static machine_mode
> +sh_c_mode_for_floating_type (enum tree_index ti)
> +{
> +  /* Since the SH2e has only `float' support, it is desirable to make all
> +     floating point types equivalent to `float'.  */
> +  if (ti == TI_DOUBLE_TYPE)
> +    return TARGET_FPU_SINGLE_ONLY ? SFmode : DFmode;
> +  return default_mode_for_floating_type (ti);
> +}
> +
>  /* Return true if registers in machine mode MODE will likely be
>     allocated to registers in small register classes.  */
>  bool
> diff --git a/gcc/config/sh/sh.h b/gcc/config/sh/sh.h
> index 7d3a3f08338..53cad85d122 100644
> --- a/gcc/config/sh/sh.h
> +++ b/gcc/config/sh/sh.h
> @@ -425,9 +425,6 @@ extern const sh_atomic_model& selected_atomic_model (void);
>  /* Width in bits of a `long long'.  */
>  #define LONG_LONG_TYPE_SIZE 64
>  
> -/* Width in bits of a `long double'.  */
> -#define LONG_DOUBLE_TYPE_SIZE 64
> -
>  /* Width of a word, in units (bytes).  */
>  #define UNITS_PER_WORD	(4)
>  #define MIN_UNITS_PER_WORD 4
> @@ -1433,13 +1430,6 @@ extern bool current_function_interrupt;
>     Do not define this if the table should contain absolute addresses.  */
>  #define CASE_VECTOR_PC_RELATIVE 1
>  
> -/* Define it here, so that it doesn't get bumped to 64-bits on SHmedia.  */
> -#define FLOAT_TYPE_SIZE 32
> -
> -/* Since the SH2e has only `float' support, it is desirable to make all
> -   floating point types equivalent to `float'.  */
> -#define DOUBLE_TYPE_SIZE (TARGET_FPU_SINGLE_ONLY ? 32 : 64)
> -
>  /* 'char' is signed by default.  */
>  #define DEFAULT_SIGNED_CHAR  1
>  
> -- 
> 2.43.0
> 

^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 41/52] riscv: New hook implementation riscv_c_mode_for_floating_type
  2024-06-03  3:01 ` [PATCH 41/52] riscv: New hook implementation riscv_c_mode_for_floating_type Kewen Lin
@ 2024-06-03  5:14   ` Kito Cheng
  0 siblings, 0 replies; 149+ messages in thread
From: Kito Cheng @ 2024-06-03  5:14 UTC (permalink / raw)
  To: Kewen Lin; +Cc: gcc-patches, palmer, andrew, jim.wilson.gcc

LGTM from RISC-V, thanks :)

On Mon, Jun 3, 2024 at 11:08 AM Kewen Lin <linkw@linux.ibm.com> wrote:
>
> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in riscv port, and add new port specific hook
> implementation riscv_c_mode_for_floating_type.
>
> gcc/ChangeLog:
>
>         * config/riscv/riscv.cc (riscv_c_mode_for_floating_type): New function.
>         (TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
>         * config/riscv/riscv.h (FLOAT_TYPE_SIZE): Remove.
>         (DOUBLE_TYPE_SIZE): Likewise.
>         (LONG_DOUBLE_TYPE_SIZE): Likewise.
> ---
>  gcc/config/riscv/riscv.cc | 15 +++++++++++++++
>  gcc/config/riscv/riscv.h  |  4 ----
>  2 files changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
> index 92935275aaa..b011344cabe 100644
> --- a/gcc/config/riscv/riscv.cc
> +++ b/gcc/config/riscv/riscv.cc
> @@ -11449,6 +11449,18 @@ riscv_expand_usadd (rtx dest, rtx x, rtx y)
>    emit_move_insn (dest, gen_lowpart (mode, xmode_dest));
>  }
>
> +/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return TFmode for
> +   TI_LONG_DOUBLE_TYPE which is for long double type, go with the
> +   default one for the others.  */
> +
> +static machine_mode
> +riscv_c_mode_for_floating_type (enum tree_index ti)
> +{
> +  if (ti == TI_LONG_DOUBLE_TYPE)
> +    return TFmode;
> +  return default_mode_for_floating_type (ti);
> +}
> +
>  /* Initialize the GCC target structure.  */
>  #undef TARGET_ASM_ALIGNED_HI_OP
>  #define TARGET_ASM_ALIGNED_HI_OP "\t.half\t"
> @@ -11804,6 +11816,9 @@ riscv_expand_usadd (rtx dest, rtx x, rtx y)
>  #undef TARGET_GET_RAW_RESULT_MODE
>  #define TARGET_GET_RAW_RESULT_MODE riscv_get_raw_result_mode
>
> +#undef TARGET_C_MODE_FOR_FLOATING_TYPE
> +#define TARGET_C_MODE_FOR_FLOATING_TYPE riscv_c_mode_for_floating_type
> +
>  struct gcc_target targetm = TARGET_INITIALIZER;
>
>  #include "gt-riscv.h"
> diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h
> index d6b14c4d620..83c4677c6a1 100644
> --- a/gcc/config/riscv/riscv.h
> +++ b/gcc/config/riscv/riscv.h
> @@ -188,10 +188,6 @@ ASM_MISA_SPEC
>  #define POINTER_SIZE (riscv_abi >= ABI_LP64 ? 64 : 32)
>  #define LONG_TYPE_SIZE POINTER_SIZE
>
> -#define FLOAT_TYPE_SIZE 32
> -#define DOUBLE_TYPE_SIZE 64
> -#define LONG_DOUBLE_TYPE_SIZE 128
> -
>  /* Allocation boundary (in *bits*) for storing arguments in argument list.  */
>  #define PARM_BOUNDARY BITS_PER_WORD
>
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 09/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook mode_for_floating_type
  2024-06-03  3:00 ` [PATCH 09/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook mode_for_floating_type Kewen Lin
@ 2024-06-03  6:49   ` Richard Biener
  2024-06-03  9:36     ` Kewen.Lin
  2024-06-03 17:59   ` [PATCH 09/52] Replace {FLOAT, {, LONG_}DOUBLE}_TYPE_SIZE " Joseph Myers
  1 sibling, 1 reply; 149+ messages in thread
From: Richard Biener @ 2024-06-03  6:49 UTC (permalink / raw)
  To: Kewen Lin
  Cc: gcc-patches, josmyers, segher, bergner, richard.sandiford, jakub,
	jeffreyalaw

On Mon, Jun 3, 2024 at 5:02 AM Kewen Lin <linkw@linux.ibm.com> wrote:
>
> Currently how we determine which mode will be used for a
> floating point type is that for a given type precision
> (size) call mode_for_size to get the first mode which has
> this size in the specified class.  On Powerpc, we have
> three modes (TF/KF/IF) having the same mode precision 128
> (see[1]), so the processing forces us to have to place TF
> at the first place, it would require us to make more
> adjustment in some generic code to avoid some unexpected
> mode conversions and it would be even worse if we get rid
> of TF eventually one day.  And as Joseph pointed out in [2],
> "floating types should have their mode, not a poorly
> defined precision value", as Joseph and Richi suggested,
> this patch is to introduce one hook mode_for_floating_type
> which returns the corresponding mode for type float, double
> or long double.  The default implementation returns SFmode
> for float and DFmode for double or long double.  For ports
> which need special treatment, there are some other patches
> for their own port specific implementation (referring to
> how {,LONG_}DOUBLE_TYPE_SIZE get used there).  For all
> generic uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE, depending
> on the context, some of them are replaced with TYPE_PRECISION
> of the according type node, some other are replaced with
> GET_MODE_PRECISION on the mode from mode_for_floating_type.
> This patch also poisons {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE,
> so most defines of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE in port
> specific are removed, but there are still some which are
> good to be kept for readability then they get renamed with
> port specific prefix.
>
> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651017.html
> [2] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
>
> gcc/ChangeLog:
>
>         * coretypes.h (enum tree_index): Forward declaration.
>         * defaults.h (FLOAT_TYPE_SIZE): Remove.
>         (DOUBLE_TYPE_SIZE): Likewise.
>         (LONG_DOUBLE_TYPE_SIZE): Likewise.
>         * doc/rtl.texi: Update document by replacing {FLOAT,DOUBLE}_TYPE_SIZE
>         with C type {float,double}.
>         * doc/tm.texi.in: Document new hook mode_for_floating_type, remove
>         document entries for {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE and
>         update document for WIDEST_HARDWARE_FP_SIZE.
>         * doc/tm.texi: Regenerate.
>         * emit-rtl.cc (init_emit_once): Replace DOUBLE_TYPE_SIZE by
>         calling targetm.c.mode_for_floating_type with TI_DOUBLE_TYPE.
>         * real.h (REAL_VALUE_TO_TARGET_LONG_DOUBLE): Use TYPE_PRECISION of
>         long_double_type_node to replace LONG_DOUBLE_TYPE_SIZE.
>         * system.h (FLOAT_TYPE_SIZE): Poison.
>         (DOUBLE_TYPE_SIZE): Likewise.
>         (LONG_DOUBLE_TYPE_SIZE): Likewise.
>         * target.def (mode_for_floating_type): New hook.
>         * targhooks.cc (default_mode_for_floating_type): New function.
>         (default_scalar_mode_supported_p): Update macros
>         {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE by calling
>         targetm.c.mode_for_floating_type with
>         TI_{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE.
>         * targhooks.h (default_mode_for_floating_type): New declaration.
>         * tree-core.h (enum tree_index): Specify underlying type unsigned
>         to sync with forward declaration in coretypes.h.
>         (NUM_FLOATN_TYPES): Explicitly convert to int.
>         (NUM_FLOATNX_TYPES): Likewise.
>         (NUM_FLOATN_NX_TYPES): Likewise.
>         * tree.cc (build_common_tree_nodes): Update macros
>         {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE by calling
>         targetm.c.mode_for_floating_type with
>         TI_{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE and set type mode accordingly.
> ---
>  gcc/coretypes.h    |  1 +
>  gcc/defaults.h     | 12 ------------
>  gcc/doc/rtl.texi   |  2 +-
>  gcc/doc/tm.texi    | 33 +++++++++++++--------------------
>  gcc/doc/tm.texi.in | 27 +++++++--------------------
>  gcc/emit-rtl.cc    |  3 ++-
>  gcc/real.h         |  7 ++++---
>  gcc/system.h       |  3 ++-
>  gcc/target.def     |  9 +++++++++
>  gcc/targhooks.cc   | 18 +++++++++++++++---
>  gcc/targhooks.h    |  1 +
>  gcc/tree-core.h    | 13 +++++++------
>  gcc/tree.cc        | 18 +++++++++++++++---
>  13 files changed, 77 insertions(+), 70 deletions(-)
>
> diff --git a/gcc/coretypes.h b/gcc/coretypes.h
> index 1ac6f0abea3..00c1c58bd8c 100644
> --- a/gcc/coretypes.h
> +++ b/gcc/coretypes.h
> @@ -100,6 +100,7 @@ struct gimple;
>  typedef gimple *gimple_seq;
>  struct gimple_stmt_iterator;
>  class code_helper;
> +enum tree_index : unsigned;
>
>  /* Forward declare rtx_code, so that we can use it in target hooks without
>     needing to pull in rtl.h.  */
> diff --git a/gcc/defaults.h b/gcc/defaults.h
> index 92f3e07f742..ac2d25852ab 100644
> --- a/gcc/defaults.h
> +++ b/gcc/defaults.h
> @@ -513,18 +513,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
>  #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
>  #endif
>
> -#ifndef FLOAT_TYPE_SIZE
> -#define FLOAT_TYPE_SIZE BITS_PER_WORD
> -#endif
> -
> -#ifndef DOUBLE_TYPE_SIZE
> -#define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
> -#endif
> -
> -#ifndef LONG_DOUBLE_TYPE_SIZE
> -#define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
> -#endif
> -
>  #ifndef DECIMAL32_TYPE_SIZE
>  #define DECIMAL32_TYPE_SIZE 32
>  #endif
> diff --git a/gcc/doc/rtl.texi b/gcc/doc/rtl.texi
> index aa10b5235b5..d85b6dcbf1a 100644
> --- a/gcc/doc/rtl.texi
> +++ b/gcc/doc/rtl.texi
> @@ -1326,7 +1326,7 @@ whose size is @code{BITS_PER_WORD}, @code{SImode} on 32-bit machines.
>
>  The only modes which a machine description @i{must} support are
>  @code{QImode}, and the modes corresponding to @code{BITS_PER_WORD},
> -@code{FLOAT_TYPE_SIZE} and @code{DOUBLE_TYPE_SIZE}.
> +C type @code{float} and C type type @code{double}.

type type

OK with that fixed and no comments from others.

Richard.

>  The compiler will attempt to use @code{DImode} for 8-byte structures and
>  unions, but this can be prevented by overriding the definition of
>  @code{MAX_FIXED_MODE_SIZE}.  Alternatively, you can have the compiler
> diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
> index cd50078227d..07bf8ed9e0e 100644
> --- a/gcc/doc/tm.texi
> +++ b/gcc/doc/tm.texi
> @@ -1044,6 +1044,14 @@ are zero or sign extended depending on if it is
>  @code{GET_MODE_ALIGNMENT (info->limb_mode)}.
>  @end deftypefn
>
> +@deftypefn {Target Hook} machine_mode TARGET_C_MODE_FOR_FLOATING_TYPE (enum tree_index @var{ti})
> +Return machine mode for a C floating point type which is indicated by
> + a given @code{enum tree_index} @var{ti}, @var{ti} should be
> + @code{TI_FLOAT_TYPE}, @code{TI_DOUBLE_TYPE} or @code{TI_LONG_DOUBLE_TYPE}.
> + The default implementation returns @code{SFmode} for @code{TI_FLOAT_TYPE},
> + and @code{DFmode} for @code{TI_DOUBLE_TYPE} or @code{TI_LONG_DOUBLE_TYPE}.
> +@end deftypefn
> +
>  @deftypefn {Target Hook} machine_mode TARGET_PROMOTE_FUNCTION_MODE (const_tree @var{type}, machine_mode @var{mode}, int *@var{punsignedp}, const_tree @var{funtype}, int @var{for_return})
>  Like @code{PROMOTE_MODE}, but it is applied to outgoing function arguments or
>  function return values.  The target hook should return the new mode
> @@ -1610,23 +1618,6 @@ C99 type @code{_Bool} on the target machine.  If you don't define
>  this, and you probably shouldn't, the default is @code{CHAR_TYPE_SIZE}.
>  @end defmac
>
> -@defmac FLOAT_TYPE_SIZE
> -A C expression for the size in bits of the type @code{float} on the
> -target machine.  If you don't define this, the default is one word.
> -@end defmac
> -
> -@defmac DOUBLE_TYPE_SIZE
> -A C expression for the size in bits of the type @code{double} on the
> -target machine.  If you don't define this, the default is two
> -words.
> -@end defmac
> -
> -@defmac LONG_DOUBLE_TYPE_SIZE
> -A C expression for the size in bits of the type @code{long double} on
> -the target machine.  If you don't define this, the default is two
> -words.
> -@end defmac
> -
>  @defmac SHORT_FRACT_TYPE_SIZE
>  A C expression for the size in bits of the type @code{short _Fract} on
>  the target machine.  If you don't define this, the default is
> @@ -1687,9 +1678,11 @@ the libgcc @file{config.host}.
>  @defmac WIDEST_HARDWARE_FP_SIZE
>  A C expression for the size in bits of the widest floating-point format
>  supported by the hardware.  If you define this macro, you must specify a
> -value less than or equal to the value of @code{LONG_DOUBLE_TYPE_SIZE}.
> -If you do not define this macro, the value of @code{LONG_DOUBLE_TYPE_SIZE}
> -is the default.
> +value less than or equal to mode precision of the mode used for C type
> +@code{long double} (from hook @code{targetm.c.mode_for_floating_type}
> +with tree_index TI_LONG_DOUBLE_TYPE).  If you do not define this macro,
> +mode precision of the mode used for C type @code{long double} is the
> +default.
>  @end defmac
>
>  @defmac DEFAULT_SIGNED_CHAR
> diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
> index 058bd56487a..f6e2372f262 100644
> --- a/gcc/doc/tm.texi.in
> +++ b/gcc/doc/tm.texi.in
> @@ -947,6 +947,8 @@ applied.
>
>  @hook TARGET_C_BITINT_TYPE_INFO
>
> +@hook TARGET_C_MODE_FOR_FLOATING_TYPE
> +
>  @hook TARGET_PROMOTE_FUNCTION_MODE
>
>  @defmac PARM_BOUNDARY
> @@ -1351,23 +1353,6 @@ C99 type @code{_Bool} on the target machine.  If you don't define
>  this, and you probably shouldn't, the default is @code{CHAR_TYPE_SIZE}.
>  @end defmac
>
> -@defmac FLOAT_TYPE_SIZE
> -A C expression for the size in bits of the type @code{float} on the
> -target machine.  If you don't define this, the default is one word.
> -@end defmac
> -
> -@defmac DOUBLE_TYPE_SIZE
> -A C expression for the size in bits of the type @code{double} on the
> -target machine.  If you don't define this, the default is two
> -words.
> -@end defmac
> -
> -@defmac LONG_DOUBLE_TYPE_SIZE
> -A C expression for the size in bits of the type @code{long double} on
> -the target machine.  If you don't define this, the default is two
> -words.
> -@end defmac
> -
>  @defmac SHORT_FRACT_TYPE_SIZE
>  A C expression for the size in bits of the type @code{short _Fract} on
>  the target machine.  If you don't define this, the default is
> @@ -1428,9 +1413,11 @@ the libgcc @file{config.host}.
>  @defmac WIDEST_HARDWARE_FP_SIZE
>  A C expression for the size in bits of the widest floating-point format
>  supported by the hardware.  If you define this macro, you must specify a
> -value less than or equal to the value of @code{LONG_DOUBLE_TYPE_SIZE}.
> -If you do not define this macro, the value of @code{LONG_DOUBLE_TYPE_SIZE}
> -is the default.
> +value less than or equal to mode precision of the mode used for C type
> +@code{long double} (from hook @code{targetm.c.mode_for_floating_type}
> +with tree_index TI_LONG_DOUBLE_TYPE).  If you do not define this macro,
> +mode precision of the mode used for C type @code{long double} is the
> +default.
>  @end defmac
>
>  @defmac DEFAULT_SIGNED_CHAR
> diff --git a/gcc/emit-rtl.cc b/gcc/emit-rtl.cc
> index 1856fa4884f..cb04aa1a8c6 100644
> --- a/gcc/emit-rtl.cc
> +++ b/gcc/emit-rtl.cc
> @@ -6366,7 +6366,8 @@ init_emit_once (void)
>    else
>      const_true_rtx = gen_rtx_CONST_INT (VOIDmode, STORE_FLAG_VALUE);
>
> -  double_mode = float_mode_for_size (DOUBLE_TYPE_SIZE).require ();
> +  mode = targetm.c.mode_for_floating_type (TI_DOUBLE_TYPE);
> +  double_mode = as_a<scalar_float_mode> (mode);
>
>    real_from_integer (&dconst0, double_mode, 0, SIGNED);
>    real_from_integer (&dconst1, double_mode, 1, SIGNED);
> diff --git a/gcc/real.h b/gcc/real.h
> index 2e40817a2d7..f28022769b3 100644
> --- a/gcc/real.h
> +++ b/gcc/real.h
> @@ -406,9 +406,10 @@ extern const struct real_format arm_bfloat_half_format;
>  #define REAL_VALUE_MINUS_ZERO(x)       real_isnegzero (&(x))
>
>  /* IN is a REAL_VALUE_TYPE.  OUT is an array of longs.  */
> -#define REAL_VALUE_TO_TARGET_LONG_DOUBLE(IN, OUT)                      \
> -  real_to_target (OUT, &(IN),                                          \
> -                 float_mode_for_size (LONG_DOUBLE_TYPE_SIZE).require ())
> +#define REAL_VALUE_TO_TARGET_LONG_DOUBLE(IN, OUT)                         \
> +  real_to_target (OUT, &(IN),                                             \
> +                 float_mode_for_size (TYPE_PRECISION                      \
> +                                      (long_double_type_node)).require ())
>
>  #define REAL_VALUE_TO_TARGET_DOUBLE(IN, OUT) \
>    real_to_target (OUT, &(IN), float_mode_for_size (64).require ())
> diff --git a/gcc/system.h b/gcc/system.h
> index 1028dcb1eb3..cbb14fb167d 100644
> --- a/gcc/system.h
> +++ b/gcc/system.h
> @@ -1000,7 +1000,8 @@ extern void fancy_abort (const char *, int, const char *)
>         HARD_REGNO_NREGS SECONDARY_MEMORY_NEEDED_MODE                   \
>         SECONDARY_MEMORY_NEEDED CANNOT_CHANGE_MODE_CLASS                \
>         TRULY_NOOP_TRUNCATION FUNCTION_ARG_OFFSET CONSTANT_ALIGNMENT    \
> -       STARTING_FRAME_OFFSET
> +       STARTING_FRAME_OFFSET FLOAT_TYPE_SIZE DOUBLE_TYPE_SIZE          \
> +       LONG_DOUBLE_TYPE_SIZE
>
>  /* Target macros only used for code built for the target, that have
>     moved to libgcc-tm.h or have never been present elsewhere.  */
> diff --git a/gcc/target.def b/gcc/target.def
> index c27df8095be..4780ba9c15b 100644
> --- a/gcc/target.def
> +++ b/gcc/target.def
> @@ -6370,6 +6370,15 @@ are zero or sign extended depending on if it is\n\
>   bool, (int n, struct bitint_info *info),
>   default_bitint_type_info)
>
> +DEFHOOK
> +(mode_for_floating_type,
> +"Return machine mode for a C floating point type which is indicated by\n\
> + a given @code{enum tree_index} @var{ti}, @var{ti} should be\n\
> + @code{TI_FLOAT_TYPE}, @code{TI_DOUBLE_TYPE} or @code{TI_LONG_DOUBLE_TYPE}.\n\
> + The default implementation returns @code{SFmode} for @code{TI_FLOAT_TYPE},\n\
> + and @code{DFmode} for @code{TI_DOUBLE_TYPE} or @code{TI_LONG_DOUBLE_TYPE}.",
> + machine_mode, (enum tree_index ti), default_mode_for_floating_type)
> +
>  HOOK_VECTOR_END (c)
>
>  /* Functions specific to the C++ frontend.  */
> diff --git a/gcc/targhooks.cc b/gcc/targhooks.cc
> index fb339bf75dd..5111e069f0c 100644
> --- a/gcc/targhooks.cc
> +++ b/gcc/targhooks.cc
> @@ -298,6 +298,18 @@ default_mode_for_suffix (char suffix ATTRIBUTE_UNUSED)
>    return VOIDmode;
>  }
>
> +/* Return machine mode for a floating type which is indicated
> +   by the given enum tree_index.  */
> +
> +machine_mode
> +default_mode_for_floating_type (enum tree_index ti)
> +{
> +  if (ti == TI_FLOAT_TYPE)
> +    return SFmode;
> +  gcc_assert (ti == TI_DOUBLE_TYPE || ti == TI_LONG_DOUBLE_TYPE);
> +  return DFmode;
> +}
> +
>  /* The generic C++ ABI specifies this is a 64-bit value.  */
>  tree
>  default_cxx_guard_type (void)
> @@ -449,11 +461,11 @@ default_scalar_mode_supported_p (scalar_mode mode)
>        return false;
>
>      case MODE_FLOAT:
> -      if (precision == FLOAT_TYPE_SIZE)
> +      if (mode == targetm.c.mode_for_floating_type (TI_FLOAT_TYPE))
>         return true;
> -      if (precision == DOUBLE_TYPE_SIZE)
> +      if (mode == targetm.c.mode_for_floating_type (TI_DOUBLE_TYPE))
>         return true;
> -      if (precision == LONG_DOUBLE_TYPE_SIZE)
> +      if (mode == targetm.c.mode_for_floating_type (TI_LONG_DOUBLE_TYPE))
>         return true;
>        return false;
>
> diff --git a/gcc/targhooks.h b/gcc/targhooks.h
> index 85f3817c176..fdc17c3b7c0 100644
> --- a/gcc/targhooks.h
> +++ b/gcc/targhooks.h
> @@ -289,6 +289,7 @@ extern unsigned int default_min_arithmetic_precision (void);
>  extern enum flt_eval_method
>  default_excess_precision (enum excess_precision_type ATTRIBUTE_UNUSED);
>  extern bool default_bitint_type_info (int, struct bitint_info *);
> +extern machine_mode default_mode_for_floating_type (enum tree_index);
>  extern HOST_WIDE_INT default_stack_clash_protection_alloca_probe_range (void);
>  extern void default_select_early_remat_modes (sbitmap);
>  extern tree default_preferred_else_value (unsigned, tree, unsigned, tree *);
> diff --git a/gcc/tree-core.h b/gcc/tree-core.h
> index 9fa74342919..0b5000acb80 100644
> --- a/gcc/tree-core.h
> +++ b/gcc/tree-core.h
> @@ -624,7 +624,7 @@ enum cv_qualifier {
>  };
>
>  /* Standard named or nameless data types of the C compiler.  */
> -enum tree_index {
> +enum tree_index : unsigned {
>    TI_ERROR_MARK,
>    TI_INTQI_TYPE,
>    TI_INTHI_TYPE,
> @@ -691,17 +691,18 @@ enum tree_index {
>    TI_FLOAT64_TYPE,
>    TI_FLOAT128_TYPE,
>    TI_FLOATN_TYPE_LAST = TI_FLOAT128_TYPE,
> -#define NUM_FLOATN_TYPES (TI_FLOATN_TYPE_LAST - TI_FLOATN_TYPE_FIRST + 1)
> +#define NUM_FLOATN_TYPES ((int) (TI_FLOATN_TYPE_LAST           \
> +                                - TI_FLOATN_TYPE_FIRST + 1))
>    TI_FLOAT32X_TYPE,
>    TI_FLOATNX_TYPE_FIRST = TI_FLOAT32X_TYPE,
>    TI_FLOAT64X_TYPE,
>    TI_FLOAT128X_TYPE,
>    TI_FLOATNX_TYPE_LAST = TI_FLOAT128X_TYPE,
>    TI_FLOATN_NX_TYPE_LAST = TI_FLOAT128X_TYPE,
> -#define NUM_FLOATNX_TYPES (TI_FLOATNX_TYPE_LAST - TI_FLOATNX_TYPE_FIRST + 1)
> -#define NUM_FLOATN_NX_TYPES (TI_FLOATN_NX_TYPE_LAST            \
> -                            - TI_FLOATN_NX_TYPE_FIRST          \
> -                            + 1)
> +#define NUM_FLOATNX_TYPES ((int) (TI_FLOATNX_TYPE_LAST         \
> +                                 - TI_FLOATNX_TYPE_FIRST + 1))
> +#define NUM_FLOATN_NX_TYPES ((int) (TI_FLOATN_NX_TYPE_LAST     \
> +                                 - TI_FLOATN_NX_TYPE_FIRST + 1))
>
>    /* Type used by certain backends for __float128, which in C++ should be
>       distinct type from _Float128 for backwards compatibility reasons.  */
> diff --git a/gcc/tree.cc b/gcc/tree.cc
> index 6564b002dc1..bc5175f591e 100644
> --- a/gcc/tree.cc
> +++ b/gcc/tree.cc
> @@ -9596,15 +9596,27 @@ build_common_tree_nodes (bool signed_char)
>    pointer_sized_int_node = build_nonstandard_integer_type (POINTER_SIZE, 1);
>
>    float_type_node = make_node (REAL_TYPE);
> -  TYPE_PRECISION (float_type_node) = FLOAT_TYPE_SIZE;
> +  machine_mode float_type_mode
> +    = targetm.c.mode_for_floating_type (TI_FLOAT_TYPE);
> +  SET_TYPE_MODE (float_type_node, float_type_mode);
> +  TYPE_PRECISION (float_type_node)
> +    = GET_MODE_PRECISION (float_type_mode).to_constant ();
>    layout_type (float_type_node);
>
>    double_type_node = make_node (REAL_TYPE);
> -  TYPE_PRECISION (double_type_node) = DOUBLE_TYPE_SIZE;
> +  machine_mode double_type_mode
> +    = targetm.c.mode_for_floating_type (TI_DOUBLE_TYPE);
> +  SET_TYPE_MODE (double_type_node, double_type_mode);
> +  TYPE_PRECISION (double_type_node)
> +    = GET_MODE_PRECISION (double_type_mode).to_constant ();
>    layout_type (double_type_node);
>
>    long_double_type_node = make_node (REAL_TYPE);
> -  TYPE_PRECISION (long_double_type_node) = LONG_DOUBLE_TYPE_SIZE;
> +  machine_mode long_double_type_mode
> +    = targetm.c.mode_for_floating_type (TI_LONG_DOUBLE_TYPE);
> +  SET_TYPE_MODE (long_double_type_node, long_double_type_mode);
> +  TYPE_PRECISION (long_double_type_node)
> +    = GET_MODE_PRECISION (long_double_type_mode).to_constant ();
>    layout_type (long_double_type_node);
>
>    for (i = 0; i < NUM_FLOATN_NX_TYPES; i++)
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 39/52] i386: New hook implementation ix86_c_mode_for_floating_type
  2024-06-03  3:01 ` [PATCH 39/52] i386: New hook implementation ix86_c_mode_for_floating_type Kewen Lin
@ 2024-06-03  7:12   ` Uros Bizjak
  0 siblings, 0 replies; 149+ messages in thread
From: Uros Bizjak @ 2024-06-03  7:12 UTC (permalink / raw)
  To: Kewen Lin; +Cc: gcc-patches, hubicka

On Mon, Jun 3, 2024 at 5:02 AM Kewen Lin <linkw@linux.ibm.com> wrote:
>
> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in i386 port, and add new port specific hook
> implementation ix86_c_mode_for_floating_type.
>
> gcc/ChangeLog:
>
>         * config/i386/i386.cc (ix86_c_mode_for_floating_type): New
>         function.
>         (TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
>         * config/i386/i386.h (FLOAT_TYPE_SIZE): Remove.
>         (DOUBLE_TYPE_SIZE): Likewise.
>         (LONG_DOUBLE_TYPE_SIZE): Likewise.

OK.

Thanks,
Uros.

> ---
>  gcc/config/i386/i386.cc | 15 +++++++++++++++
>  gcc/config/i386/i386.h  |  4 ----
>  2 files changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
> index 3e2a3a194f1..6abb6d7a1ca 100644
> --- a/gcc/config/i386/i386.cc
> +++ b/gcc/config/i386/i386.cc
> @@ -25794,6 +25794,19 @@ ix86_bitint_type_info (int n, struct bitint_info *info)
>    return true;
>  }
>
> +/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return DFmode, TFmode
> +   or XFmode for TI_LONG_DOUBLE_TYPE which is for long double type,
> +   based on long double bits, go with the default one for the others.  */
> +
> +static machine_mode
> +ix86_c_mode_for_floating_type (enum tree_index ti)
> +{
> +  if (ti == TI_LONG_DOUBLE_TYPE)
> +    return (TARGET_LONG_DOUBLE_64 ? DFmode
> +                                 : (TARGET_LONG_DOUBLE_128 ? TFmode : XFmode));
> +  return default_mode_for_floating_type (ti);
> +}
> +
>  /* Returns modified FUNCTION_TYPE for cdtor callabi.  */
>  tree
>  ix86_cxx_adjust_cdtor_callabi_fntype (tree fntype)
> @@ -26419,6 +26432,8 @@ static const scoped_attribute_specs *const ix86_attribute_table[] =
>  #define TARGET_C_EXCESS_PRECISION ix86_get_excess_precision
>  #undef TARGET_C_BITINT_TYPE_INFO
>  #define TARGET_C_BITINT_TYPE_INFO ix86_bitint_type_info
> +#undef TARGET_C_MODE_FOR_FLOATING_TYPE
> +#define TARGET_C_MODE_FOR_FLOATING_TYPE ix86_c_mode_for_floating_type
>  #undef TARGET_CXX_ADJUST_CDTOR_CALLABI_FNTYPE
>  #define TARGET_CXX_ADJUST_CDTOR_CALLABI_FNTYPE ix86_cxx_adjust_cdtor_callabi_fntype
>  #undef TARGET_PROMOTE_PROTOTYPES
> diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
> index 359a8408263..fad434c10d6 100644
> --- a/gcc/config/i386/i386.h
> +++ b/gcc/config/i386/i386.h
> @@ -675,10 +675,6 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
>  #define LONG_TYPE_SIZE (TARGET_X32 ? 32 : BITS_PER_WORD)
>  #define POINTER_SIZE (TARGET_X32 ? 32 : BITS_PER_WORD)
>  #define LONG_LONG_TYPE_SIZE 64
> -#define FLOAT_TYPE_SIZE 32
> -#define DOUBLE_TYPE_SIZE 64
> -#define LONG_DOUBLE_TYPE_SIZE \
> -  (TARGET_LONG_DOUBLE_64 ? 64 : (TARGET_LONG_DOUBLE_128 ? 128 : 80))
>
>  #define WIDEST_HARDWARE_FP_SIZE 80
>
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 02/52] d: Replace use of LONG_DOUBLE_TYPE_SIZE
  2024-06-03  3:00 ` [PATCH 02/52] d: " Kewen Lin
@ 2024-06-03  8:40   ` Iain Buclaw
  2024-06-03  8:57     ` Kewen.Lin
  0 siblings, 1 reply; 149+ messages in thread
From: Iain Buclaw @ 2024-06-03  8:40 UTC (permalink / raw)
  To: gcc-patches, Kewen Lin

Excerpts from Kewen Lin's message of Juni 3, 2024 5:00 am:
> 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 d with
> TYPE_PRECISION of long_double_type_node.
> 
> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
> 

Thanks, one question though: Is TYPE_PRECISION really equivalent to
LONG_DOUBLE_TYPE_SIZE?

Unless LONG_DOUBLE_TYPE_SIZE was poorly named to begin with, I'd assume
the answer to be "no".

i.e: TYPE_PRECISION = 80, but LONG_DOUBLE_TYPE_SIZE = 96 or 128.

Iain.

^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 01/52] ada: Replace use of LONG_DOUBLE_TYPE_SIZE
  2024-06-03  3:00 ` [PATCH 01/52] ada: Replace use of LONG_DOUBLE_TYPE_SIZE Kewen Lin
@ 2024-06-03  8:51   ` Eric Botcazou
  2024-06-05  9:32     ` Kewen.Lin
  0 siblings, 1 reply; 149+ messages in thread
From: Eric Botcazou @ 2024-06-03  8:51 UTC (permalink / raw)
  To: Kewen Lin; +Cc: gcc-patches, linkw, charlet, poulhies, derodat

> 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 ada
> with TYPE_PRECISION of long_double_type_node.
> 
> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
> 
> gcc/ada/ChangeLog:
> 
> 	* gcc-interface/decl.cc (gnat_to_gnu_entity): Use TYPE_PRECISION of
> 	long_double_type_node to replace LONG_DOUBLE_TYPE_SIZE.

OK, thanks.

-- 
Eric Botcazou



^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 02/52] d: Replace use of LONG_DOUBLE_TYPE_SIZE
  2024-06-03  8:40   ` Iain Buclaw
@ 2024-06-03  8:57     ` Kewen.Lin
  2024-06-03 14:39       ` Iain Buclaw
  0 siblings, 1 reply; 149+ messages in thread
From: Kewen.Lin @ 2024-06-03  8:57 UTC (permalink / raw)
  To: Iain Buclaw; +Cc: gcc-patches

Hi Iain,

on 2024/6/3 16:40, Iain Buclaw wrote:
> Excerpts from Kewen Lin's message of Juni 3, 2024 5:00 am:
>> 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 d with
>> TYPE_PRECISION of long_double_type_node.
>>
>> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
>>
> 
> Thanks, one question though: Is TYPE_PRECISION really equivalent to
> LONG_DOUBLE_TYPE_SIZE?

Yes, it's guaranteed by the code in build_common_tree_nodes:

  long_double_type_node = make_node (REAL_TYPE);
  TYPE_PRECISION (long_double_type_node) = LONG_DOUBLE_TYPE_SIZE;
  layout_type (long_double_type_node);

, the macro LONG_DOUBLE_TYPE_SIZE is assigned to TYPE_PRECISION of
long_double_type_node, layout_type will only pick up one mode as
the given precision and won't change it.

> 
> Unless LONG_DOUBLE_TYPE_SIZE was poorly named to begin with, I'd assume
> the answer to be "no".

I'm afraid it's poorly named before.

> 
> i.e: TYPE_PRECISION = 80, but LONG_DOUBLE_TYPE_SIZE = 96 or 128.

From what I interpreted from the code, it should never happen.

BR,
Kewen


^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 51/52] sparc: New hook implementation sparc_c_mode_for_floating_type
  2024-06-03  3:01 ` [PATCH 51/52] sparc: New hook implementation sparc_c_mode_for_floating_type Kewen Lin
@ 2024-06-03  9:02   ` Eric Botcazou
  2024-06-03  9:37     ` Kewen.Lin
  0 siblings, 1 reply; 149+ messages in thread
From: Eric Botcazou @ 2024-06-03  9:02 UTC (permalink / raw)
  To: Kewen Lin; +Cc: gcc-patches, linkw, davem

> 	* config/sparc/sparc.cc (sparc_c_mode_for_floating_type): New
> 	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
> 	(FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Rename to ...
> 	(SPARC_LONG_DOUBLE_TYPE_SIZE): ... this.
> 	(sparc_type_code): Replace FLOAT_TYPE_SIZE with TYPE_PRECISION of
> 	float_type_node.
> 	* config/sparc/sparc.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Remove.
> 	* config/sparc/freebsd.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
> 	(SPARC_LONG_DOUBLE_TYPE_SIZE): ... this.
> 	* config/sparc/linux.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
> 	(SPARC_LONG_DOUBLE_TYPE_SIZE): ... this.
> 	* config/sparc/linux64.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
> 	(SPARC_LONG_DOUBLE_TYPE_SIZE): ... this.
> 	* config/sparc/netbsd-elf.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
> 	(SPARC_LONG_DOUBLE_TYPE_SIZE): ... this.
> 	* config/sparc/openbsd64.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
> 	(SPARC_LONG_DOUBLE_TYPE_SIZE): ... this.
> 	* config/sparc/sol2.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
> 	(SPARC_LONG_DOUBLE_TYPE_SIZE): ... this.
> 	* config/sparc/sp-elf.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
> 	(SPARC_LONG_DOUBLE_TYPE_SIZE): ... this.
> 	* config/sparc/sp64-elf.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
> 	(SPARC_LONG_DOUBLE_TYPE_SIZE): ... this.

OK, modulo the following tweaks:

> --- a/gcc/config/sparc/sparc.cc
> +++ b/gcc/config/sparc/sparc.cc
> @@ -718,6 +718,7 @@ static bool sparc_vectorize_vec_perm_const
> (machine_mode, machine_mode, const vec_perm_indices &);
>  static bool sparc_can_follow_jump (const rtx_insn *, const rtx_insn *);
>  static HARD_REG_SET sparc_zero_call_used_regs (HARD_REG_SET);
> +static machine_mode sparc_c_mode_for_floating_type (enum tree_index);
>  \f
>  #ifdef SUBTARGET_ATTRIBUTE_TABLE
>  /* Table of valid machine attributes.  */
> @@ -971,6 +972,9 @@ char sparc_hard_reg_printed[8];
>  #undef TARGET_ZERO_CALL_USED_REGS
>  #define TARGET_ZERO_CALL_USED_REGS sparc_zero_call_used_regs
> 
> +#undef TARGET_C_MODE_FOR_FLOATING_TYPE
> +#define TARGET_C_MODE_FOR_FLOATING_TYPE sparc_c_mode_for_floating_type
> +
>  struct gcc_target targetm = TARGET_INITIALIZER;
> 
>  /* Return the memory reference contained in X if any, zero otherwise.  */
> @@ -9824,16 +9828,9 @@ sparc_assemble_integer (rtx x, unsigned int size, int
> aligned_p) #define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2)
>  #endif
> 
> -#ifndef FLOAT_TYPE_SIZE
> -#define FLOAT_TYPE_SIZE BITS_PER_WORD
> -#endif
> -
> -#ifndef DOUBLE_TYPE_SIZE
> -#define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
> -#endif
> -
> -#ifndef LONG_DOUBLE_TYPE_SIZE
> -#define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
> +/* LONG_DOUBLE_TYPE_SIZE get poisoned, so add SPARC_ prefix.  */
> +#ifndef SPARC_LONG_LONG_TYPE_SIZE
> +#define SPARC_LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
>  #endif
> 
>  unsigned long

You can delete {SPARC_}LONG_DOUBLE_TYPE_SIZE too.

> @@ -9920,7 +9917,7 @@ sparc_type_code (tree type)
>  	  /* Carefully distinguish all the standard types of C,
>  	     without messing up if the language is not C.  */
> 
> -	  if (TYPE_PRECISION (type) == FLOAT_TYPE_SIZE)
> +	  if (TYPE_PRECISION (type) == TYPE_PRECISION (float_type_node))
>  	    return (qualifiers | 6);
> 
>  	  else
> @@ -13984,4 +13981,16 @@ sparc_zero_call_used_regs (HARD_REG_SET
> need_zeroed_hardregs) return need_zeroed_hardregs;
>  }
> 
> +/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return TFmode or DFmode
> +   for TI_LONG_DOUBLE_TYPE which is for long double type, go with the
> +   default one for the others.  */
> +
> +static machine_mode
> +sparc_c_mode_for_floating_type (enum tree_index ti)
> +{
> +  if (ti == TI_LONG_DOUBLE_TYPE)
> +    return SPARC_LONG_DOUBLE_TYPE_SIZE == 128 ? TFmode : DFmode;
> +  return default_mode_for_floating_type (ti);
> +}
> +
>  #include "gt-sparc.h"

I think that TI_LONG_DOUBLE_TYPE is self-explanatory so just:

/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return TFmode or DFmode
   for TI_LONG_DOUBLE_TYPE and the default for others.

-- 
Eric Botcazou



^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 17/52] gcn: Remove macros {FLOAT, DOUBLE, LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:01 ` [PATCH 17/52] gcn: " Kewen Lin
@ 2024-06-03  9:14   ` Andrew Stubbs
  2024-06-03  9:41     ` Kewen.Lin
  0 siblings, 1 reply; 149+ messages in thread
From: Andrew Stubbs @ 2024-06-03  9:14 UTC (permalink / raw)
  To: Kewen Lin, gcc-patches

On 03/06/2024 04:01, Kewen Lin wrote:
> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in gcn port.
> 
> gcc/ChangeLog:
> 
> 	* config/gcn/gcn.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.


Assuming that this does not enable some long-double mode support that 
wasn't present before then this LGTM.

GCN does have some partially implemented support for HFmode ... do I 
need to do something new for that to work?

Andrew

> ---
>   gcc/config/gcn/gcn.h | 3 ---
>   1 file changed, 3 deletions(-)
> 
> diff --git a/gcc/config/gcn/gcn.h b/gcc/config/gcn/gcn.h
> index afa615320ca..e3bfd29c17d 100644
> --- a/gcc/config/gcn/gcn.h
> +++ b/gcc/config/gcn/gcn.h
> @@ -111,9 +111,6 @@
>   #define INT_TYPE_SIZE		  32
>   #define LONG_TYPE_SIZE		  64
>   #define LONG_LONG_TYPE_SIZE	  64
> -#define FLOAT_TYPE_SIZE		  32
> -#define DOUBLE_TYPE_SIZE	  64
> -#define LONG_DOUBLE_TYPE_SIZE	  64
>   #define DEFAULT_SIGNED_CHAR	  1
>   #define PCC_BITFIELD_TYPE_MATTERS 1
>   


^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 09/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook mode_for_floating_type
  2024-06-03  6:49   ` Richard Biener
@ 2024-06-03  9:36     ` Kewen.Lin
  0 siblings, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-03  9:36 UTC (permalink / raw)
  To: Richard Biener
  Cc: gcc-patches, josmyers, segher, bergner, richard.sandiford, jakub,
	jeffreyalaw

Hi Richi,

on 2024/6/3 14:49, Richard Biener wrote:
> On Mon, Jun 3, 2024 at 5:02 AM Kewen Lin <linkw@linux.ibm.com> wrote:
>>
>> Currently how we determine which mode will be used for a
>> floating point type is that for a given type precision
>> (size) call mode_for_size to get the first mode which has
>> this size in the specified class.  On Powerpc, we have
>> three modes (TF/KF/IF) having the same mode precision 128
>> (see[1]), so the processing forces us to have to place TF
>> at the first place, it would require us to make more
>> adjustment in some generic code to avoid some unexpected
>> mode conversions and it would be even worse if we get rid
>> of TF eventually one day.  And as Joseph pointed out in [2],
>> "floating types should have their mode, not a poorly
>> defined precision value", as Joseph and Richi suggested,
>> this patch is to introduce one hook mode_for_floating_type
>> which returns the corresponding mode for type float, double
>> or long double.  The default implementation returns SFmode
>> for float and DFmode for double or long double.  For ports
>> which need special treatment, there are some other patches
>> for their own port specific implementation (referring to
>> how {,LONG_}DOUBLE_TYPE_SIZE get used there).  For all
>> generic uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE, depending
>> on the context, some of them are replaced with TYPE_PRECISION
>> of the according type node, some other are replaced with
>> GET_MODE_PRECISION on the mode from mode_for_floating_type.
>> This patch also poisons {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE,
>> so most defines of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE in port
>> specific are removed, but there are still some which are
>> good to be kept for readability then they get renamed with
>> port specific prefix.
>>
>> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651017.html
>> [2] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
>>
>> gcc/ChangeLog:
>>
>>         * coretypes.h (enum tree_index): Forward declaration.
>>         * defaults.h (FLOAT_TYPE_SIZE): Remove.
>>         (DOUBLE_TYPE_SIZE): Likewise.
>>         (LONG_DOUBLE_TYPE_SIZE): Likewise.
>>         * doc/rtl.texi: Update document by replacing {FLOAT,DOUBLE}_TYPE_SIZE
>>         with C type {float,double}.
>>         * doc/tm.texi.in: Document new hook mode_for_floating_type, remove
>>         document entries for {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE and
>>         update document for WIDEST_HARDWARE_FP_SIZE.
>>         * doc/tm.texi: Regenerate.
>>         * emit-rtl.cc (init_emit_once): Replace DOUBLE_TYPE_SIZE by
>>         calling targetm.c.mode_for_floating_type with TI_DOUBLE_TYPE.
>>         * real.h (REAL_VALUE_TO_TARGET_LONG_DOUBLE): Use TYPE_PRECISION of
>>         long_double_type_node to replace LONG_DOUBLE_TYPE_SIZE.
>>         * system.h (FLOAT_TYPE_SIZE): Poison.
>>         (DOUBLE_TYPE_SIZE): Likewise.
>>         (LONG_DOUBLE_TYPE_SIZE): Likewise.
>>         * target.def (mode_for_floating_type): New hook.
>>         * targhooks.cc (default_mode_for_floating_type): New function.
>>         (default_scalar_mode_supported_p): Update macros
>>         {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE by calling
>>         targetm.c.mode_for_floating_type with
>>         TI_{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE.
>>         * targhooks.h (default_mode_for_floating_type): New declaration.
>>         * tree-core.h (enum tree_index): Specify underlying type unsigned
>>         to sync with forward declaration in coretypes.h.
>>         (NUM_FLOATN_TYPES): Explicitly convert to int.
>>         (NUM_FLOATNX_TYPES): Likewise.
>>         (NUM_FLOATN_NX_TYPES): Likewise.
>>         * tree.cc (build_common_tree_nodes): Update macros
>>         {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE by calling
>>         targetm.c.mode_for_floating_type with
>>         TI_{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE and set type mode accordingly.
>> ---
>>  gcc/coretypes.h    |  1 +
>>  gcc/defaults.h     | 12 ------------
>>  gcc/doc/rtl.texi   |  2 +-
>>  gcc/doc/tm.texi    | 33 +++++++++++++--------------------
>>  gcc/doc/tm.texi.in | 27 +++++++--------------------
>>  gcc/emit-rtl.cc    |  3 ++-
>>  gcc/real.h         |  7 ++++---
>>  gcc/system.h       |  3 ++-
>>  gcc/target.def     |  9 +++++++++
>>  gcc/targhooks.cc   | 18 +++++++++++++++---
>>  gcc/targhooks.h    |  1 +
>>  gcc/tree-core.h    | 13 +++++++------
>>  gcc/tree.cc        | 18 +++++++++++++++---
>>  13 files changed, 77 insertions(+), 70 deletions(-)
>>
>> diff --git a/gcc/coretypes.h b/gcc/coretypes.h
>> index 1ac6f0abea3..00c1c58bd8c 100644
>> --- a/gcc/coretypes.h
>> +++ b/gcc/coretypes.h
>> @@ -100,6 +100,7 @@ struct gimple;
>>  typedef gimple *gimple_seq;
>>  struct gimple_stmt_iterator;
>>  class code_helper;
>> +enum tree_index : unsigned;
>>
>>  /* Forward declare rtx_code, so that we can use it in target hooks without
>>     needing to pull in rtl.h.  */
>> diff --git a/gcc/defaults.h b/gcc/defaults.h
>> index 92f3e07f742..ac2d25852ab 100644
>> --- a/gcc/defaults.h
>> +++ b/gcc/defaults.h
>> @@ -513,18 +513,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
>>  #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
>>  #endif
>>
>> -#ifndef FLOAT_TYPE_SIZE
>> -#define FLOAT_TYPE_SIZE BITS_PER_WORD
>> -#endif
>> -
>> -#ifndef DOUBLE_TYPE_SIZE
>> -#define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
>> -#endif
>> -
>> -#ifndef LONG_DOUBLE_TYPE_SIZE
>> -#define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
>> -#endif
>> -
>>  #ifndef DECIMAL32_TYPE_SIZE
>>  #define DECIMAL32_TYPE_SIZE 32
>>  #endif
>> diff --git a/gcc/doc/rtl.texi b/gcc/doc/rtl.texi
>> index aa10b5235b5..d85b6dcbf1a 100644
>> --- a/gcc/doc/rtl.texi
>> +++ b/gcc/doc/rtl.texi
>> @@ -1326,7 +1326,7 @@ whose size is @code{BITS_PER_WORD}, @code{SImode} on 32-bit machines.
>>
>>  The only modes which a machine description @i{must} support are
>>  @code{QImode}, and the modes corresponding to @code{BITS_PER_WORD},
>> -@code{FLOAT_TYPE_SIZE} and @code{DOUBLE_TYPE_SIZE}.
>> +C type @code{float} and C type type @code{double}.
> 
> type type

Oops, thanks for catching, will fix it.

> 
> OK with that fixed and no comments from others.

Thanks!

BR,
Kewen

^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 51/52] sparc: New hook implementation sparc_c_mode_for_floating_type
  2024-06-03  9:02   ` Eric Botcazou
@ 2024-06-03  9:37     ` Kewen.Lin
  0 siblings, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-03  9:37 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: gcc-patches, davem

Hi Eric,

on 2024/6/3 17:02, Eric Botcazou wrote:
>> 	* config/sparc/sparc.cc (sparc_c_mode_for_floating_type): New
>> 	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
>> 	(FLOAT_TYPE_SIZE): Remove.
>> 	(DOUBLE_TYPE_SIZE): Likewise.
>> 	(LONG_DOUBLE_TYPE_SIZE): Rename to ...
>> 	(SPARC_LONG_DOUBLE_TYPE_SIZE): ... this.
>> 	(sparc_type_code): Replace FLOAT_TYPE_SIZE with TYPE_PRECISION of
>> 	float_type_node.
>> 	* config/sparc/sparc.h (FLOAT_TYPE_SIZE): Remove.
>> 	(DOUBLE_TYPE_SIZE): Remove.
>> 	* config/sparc/freebsd.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
>> 	(SPARC_LONG_DOUBLE_TYPE_SIZE): ... this.
>> 	* config/sparc/linux.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
>> 	(SPARC_LONG_DOUBLE_TYPE_SIZE): ... this.
>> 	* config/sparc/linux64.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
>> 	(SPARC_LONG_DOUBLE_TYPE_SIZE): ... this.
>> 	* config/sparc/netbsd-elf.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
>> 	(SPARC_LONG_DOUBLE_TYPE_SIZE): ... this.
>> 	* config/sparc/openbsd64.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
>> 	(SPARC_LONG_DOUBLE_TYPE_SIZE): ... this.
>> 	* config/sparc/sol2.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
>> 	(SPARC_LONG_DOUBLE_TYPE_SIZE): ... this.
>> 	* config/sparc/sp-elf.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
>> 	(SPARC_LONG_DOUBLE_TYPE_SIZE): ... this.
>> 	* config/sparc/sp64-elf.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
>> 	(SPARC_LONG_DOUBLE_TYPE_SIZE): ... this.
> 
> OK, modulo the following tweaks:

Thanks for the review!

> 
>> --- a/gcc/config/sparc/sparc.cc
>> +++ b/gcc/config/sparc/sparc.cc
>> @@ -718,6 +718,7 @@ static bool sparc_vectorize_vec_perm_const
>> (machine_mode, machine_mode, const vec_perm_indices &);
>>  static bool sparc_can_follow_jump (const rtx_insn *, const rtx_insn *);
>>  static HARD_REG_SET sparc_zero_call_used_regs (HARD_REG_SET);
>> +static machine_mode sparc_c_mode_for_floating_type (enum tree_index);
>>  \f
>>  #ifdef SUBTARGET_ATTRIBUTE_TABLE
>>  /* Table of valid machine attributes.  */
>> @@ -971,6 +972,9 @@ char sparc_hard_reg_printed[8];
>>  #undef TARGET_ZERO_CALL_USED_REGS
>>  #define TARGET_ZERO_CALL_USED_REGS sparc_zero_call_used_regs
>>
>> +#undef TARGET_C_MODE_FOR_FLOATING_TYPE
>> +#define TARGET_C_MODE_FOR_FLOATING_TYPE sparc_c_mode_for_floating_type
>> +
>>  struct gcc_target targetm = TARGET_INITIALIZER;
>>
>>  /* Return the memory reference contained in X if any, zero otherwise.  */
>> @@ -9824,16 +9828,9 @@ sparc_assemble_integer (rtx x, unsigned int size, int
>> aligned_p) #define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2)
>>  #endif
>>
>> -#ifndef FLOAT_TYPE_SIZE
>> -#define FLOAT_TYPE_SIZE BITS_PER_WORD
>> -#endif
>> -
>> -#ifndef DOUBLE_TYPE_SIZE
>> -#define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
>> -#endif
>> -
>> -#ifndef LONG_DOUBLE_TYPE_SIZE
>> -#define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
>> +/* LONG_DOUBLE_TYPE_SIZE get poisoned, so add SPARC_ prefix.  */
>> +#ifndef SPARC_LONG_LONG_TYPE_SIZE
>> +#define SPARC_LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
>>  #endif
>>
>>  unsigned long
> 
> You can delete {SPARC_}LONG_DOUBLE_TYPE_SIZE too.

Good point, sparc.h already defines the default.

> 
>> @@ -9920,7 +9917,7 @@ sparc_type_code (tree type)
>>  	  /* Carefully distinguish all the standard types of C,
>>  	     without messing up if the language is not C.  */
>>
>> -	  if (TYPE_PRECISION (type) == FLOAT_TYPE_SIZE)
>> +	  if (TYPE_PRECISION (type) == TYPE_PRECISION (float_type_node))
>>  	    return (qualifiers | 6);
>>
>>  	  else
>> @@ -13984,4 +13981,16 @@ sparc_zero_call_used_regs (HARD_REG_SET
>> need_zeroed_hardregs) return need_zeroed_hardregs;
>>  }
>>
>> +/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return TFmode or DFmode
>> +   for TI_LONG_DOUBLE_TYPE which is for long double type, go with the
>> +   default one for the others.  */
>> +
>> +static machine_mode
>> +sparc_c_mode_for_floating_type (enum tree_index ti)
>> +{
>> +  if (ti == TI_LONG_DOUBLE_TYPE)
>> +    return SPARC_LONG_DOUBLE_TYPE_SIZE == 128 ? TFmode : DFmode;
>> +  return default_mode_for_floating_type (ti);
>> +}
>> +
>>  #include "gt-sparc.h"
> 
> I think that TI_LONG_DOUBLE_TYPE is self-explanatory so just:
> 
> /* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return TFmode or DFmode
>    for TI_LONG_DOUBLE_TYPE and the default for others.
> 

Will adjust it, thanks!

BR,
Kewen


^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 17/52] gcn: Remove macros {FLOAT, DOUBLE, LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  9:14   ` [PATCH 17/52] gcn: Remove macros {FLOAT, DOUBLE, LONG_DOUBLE}_TYPE_SIZE Andrew Stubbs
@ 2024-06-03  9:41     ` Kewen.Lin
  2024-06-03  9:57       ` Jakub Jelinek
  0 siblings, 1 reply; 149+ messages in thread
From: Kewen.Lin @ 2024-06-03  9:41 UTC (permalink / raw)
  To: Andrew Stubbs; +Cc: gcc-patches

Hi Andrew,

on 2024/6/3 17:14, Andrew Stubbs wrote:
> On 03/06/2024 04:01, Kewen Lin wrote:
>> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
>> defines in gcn port.
>>
>> gcc/ChangeLog:
>>
>>     * config/gcn/gcn.h (FLOAT_TYPE_SIZE): Remove.
>>     (DOUBLE_TYPE_SIZE): Likewise.
>>     (LONG_DOUBLE_TYPE_SIZE): Likewise.
> 
> 
> Assuming that this does not enable some long-double mode support that wasn't present before then this LGTM.

Thanks!  Yes, it doesn't, as the default hook implementation returns DFmode for long double type.

> 
> GCN does have some partially implemented support for HFmode ... do I need to do something new for that to work?

For this hook, no, as it's mainly for float, double and long double types (C language supported non decimal floating
point types).  If you are referring to _Float16, I guess you may be interested in another hook TARGET_FLOATN_MODE
which is for FloatN types.

BR,
Kewen

> 
> Andrew
> 
>> ---
>>   gcc/config/gcn/gcn.h | 3 ---
>>   1 file changed, 3 deletions(-)
>>
>> diff --git a/gcc/config/gcn/gcn.h b/gcc/config/gcn/gcn.h
>> index afa615320ca..e3bfd29c17d 100644
>> --- a/gcc/config/gcn/gcn.h
>> +++ b/gcc/config/gcn/gcn.h
>> @@ -111,9 +111,6 @@
>>   #define INT_TYPE_SIZE          32
>>   #define LONG_TYPE_SIZE          64
>>   #define LONG_LONG_TYPE_SIZE      64
>> -#define FLOAT_TYPE_SIZE          32
>> -#define DOUBLE_TYPE_SIZE      64
>> -#define LONG_DOUBLE_TYPE_SIZE      64
>>   #define DEFAULT_SIGNED_CHAR      1
>>   #define PCC_BITFIELD_TYPE_MATTERS 1
>>   
> 


^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 17/52] gcn: Remove macros {FLOAT, DOUBLE, LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  9:41     ` Kewen.Lin
@ 2024-06-03  9:57       ` Jakub Jelinek
  0 siblings, 0 replies; 149+ messages in thread
From: Jakub Jelinek @ 2024-06-03  9:57 UTC (permalink / raw)
  To: Kewen.Lin; +Cc: Andrew Stubbs, gcc-patches

On Mon, Jun 03, 2024 at 05:41:11PM +0800, Kewen.Lin wrote:
> > GCN does have some partially implemented support for HFmode ... do I need to do something new for that to work?
> 
> For this hook, no, as it's mainly for float, double and long double types (C language supported non decimal floating
> point types).  If you are referring to _Float16, I guess you may be interested in another hook TARGET_FLOATN_MODE
> which is for FloatN types.

You don't need a new hook for that, the current _FloatNN discovery code is all
that is needed.  There should be just one mode for the IEEE compliant
implementations for each size (there is the _Float16 vs. __bf16 but the
latter isn't IEEE compliant, or just IEEE like), so tree.cc should figure
everything out together with the current langhooks.

	Jakub


^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 36/52] aarch64: New hook implementation aarch64_c_mode_for_floating_type
  2024-06-03  3:01 ` [PATCH 36/52] aarch64: New hook implementation aarch64_c_mode_for_floating_type Kewen Lin
@ 2024-06-03 10:32   ` Richard Sandiford
  0 siblings, 0 replies; 149+ messages in thread
From: Richard Sandiford @ 2024-06-03 10:32 UTC (permalink / raw)
  To: Kewen Lin; +Cc: gcc-patches, richard.earnshaw, marcus.shawcroft, ktkachov

Kewen Lin <linkw@linux.ibm.com> writes:
> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in aarch64 port, and add new port specific hook
> implementation aarch64_c_mode_for_floating_type.
>
> gcc/ChangeLog:
>
> 	* config/aarch64/aarch64.cc (aarch64_c_mode_for_floating_type):
> 	New function.
> 	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
> 	* config/aarch64/aarch64.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.

OK, thanks.

Richard

> ---
>  gcc/config/aarch64/aarch64.cc | 15 +++++++++++++++
>  gcc/config/aarch64/aarch64.h  |  6 ------
>  2 files changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
> index ee12d8897a8..1c1c278fd69 100644
> --- a/gcc/config/aarch64/aarch64.cc
> +++ b/gcc/config/aarch64/aarch64.cc
> @@ -28427,6 +28427,18 @@ aarch64_bitint_type_info (int n, struct bitint_info *info)
>    return true;
>  }
>  
> +/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return TFmode for
> +   TI_LONG_DOUBLE_TYPE which is for long double type, go with the default
> +   one for the others.  */
> +
> +static machine_mode
> +aarch64_c_mode_for_floating_type (enum tree_index ti)
> +{
> +  if (ti == TI_LONG_DOUBLE_TYPE)
> +    return TFmode;
> +  return default_mode_for_floating_type (ti);
> +}
> +
>  /* Implement TARGET_SCHED_CAN_SPECULATE_INSN.  Return true if INSN can be
>     scheduled for speculative execution.  Reject the long-running division
>     and square-root instructions.  */
> @@ -30554,6 +30566,9 @@ aarch64_run_selftests (void)
>  #undef TARGET_C_BITINT_TYPE_INFO
>  #define TARGET_C_BITINT_TYPE_INFO aarch64_bitint_type_info
>  
> +#undef TARGET_C_MODE_FOR_FLOATING_TYPE
> +#define TARGET_C_MODE_FOR_FLOATING_TYPE aarch64_c_mode_for_floating_type
> +
>  #undef  TARGET_EXPAND_BUILTIN
>  #define TARGET_EXPAND_BUILTIN aarch64_expand_builtin
>  
> diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
> index bbf11faaf4b..2064c23f961 100644
> --- a/gcc/config/aarch64/aarch64.h
> +++ b/gcc/config/aarch64/aarch64.h
> @@ -96,12 +96,6 @@
>  
>  #define LONG_LONG_TYPE_SIZE	64
>  
> -#define FLOAT_TYPE_SIZE		32
> -
> -#define DOUBLE_TYPE_SIZE	64
> -
> -#define LONG_DOUBLE_TYPE_SIZE	128
> -
>  /* This value is the amount of bytes a caller is allowed to drop the stack
>     before probing has to be done for stack clash protection.  */
>  #define STACK_CLASH_CALLER_GUARD 1024

^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 14/52] fr30: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:01 ` [PATCH 14/52] fr30: " Kewen Lin
@ 2024-06-03 11:43   ` Nick Clifton
  0 siblings, 0 replies; 149+ messages in thread
From: Nick Clifton @ 2024-06-03 11:43 UTC (permalink / raw)
  To: Kewen Lin, gcc-patches

Hi Kewen,
> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in fr30 port.
> 
> gcc/ChangeLog:
> 
> 	* config/fr30/fr30.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.
> 
Approved - please apply.

Cheers
   Nick



^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 06/52] m2: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 ` [PATCH 06/52] m2: " Kewen Lin
@ 2024-06-03 12:42   ` Gaius Mulley
  2024-06-03 18:02   ` Joseph Myers
  1 sibling, 0 replies; 149+ messages in thread
From: Gaius Mulley @ 2024-06-03 12:42 UTC (permalink / raw)
  To: Kewen Lin; +Cc: gcc-patches

Kewen Lin <linkw@linux.ibm.com> writes:

> 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 m2 with TYPE_PRECISION of {float,{,long_}double}_type_node.
>
> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
>
> gcc/m2/ChangeLog:
>
> 	* gm2-gcc/m2type.cc (build_m2_short_real_node): Use TYPE_PRECISION of
> 	float_type_node to replace FLOAT_TYPE_SIZE.
> 	(build_m2_real_node): Use TYPE_PRECISION of double_type_node to
> 	replace DOUBLE_TYPE_SIZE.
> 	(build_m2_long_real_node): Use TYPE_PRECISION of
> 	long_double_type_node to replace LONG_DOUBLE_TYPE_SIZE.

> ---
>  gcc/m2/gm2-gcc/m2type.cc | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/m2/gm2-gcc/m2type.cc b/gcc/m2/gm2-gcc/m2type.cc
> index 571923c08ef..d52cbdf0b99 100644
> --- a/gcc/m2/gm2-gcc/m2type.cc
> +++ b/gcc/m2/gm2-gcc/m2type.cc
> @@ -1420,7 +1420,7 @@ build_m2_short_real_node (void)
>    /* Define `REAL'.  */
>  
>    c = make_node (REAL_TYPE);
> -  TYPE_PRECISION (c) = FLOAT_TYPE_SIZE;
> +  TYPE_PRECISION (c) = TYPE_PRECISION (float_type_node);
>    layout_type (c);
>    return c;
>  }
> @@ -1433,7 +1433,7 @@ build_m2_real_node (void)
>    /* Define `REAL'.  */
>  
>    c = make_node (REAL_TYPE);
> -  TYPE_PRECISION (c) = DOUBLE_TYPE_SIZE;
> +  TYPE_PRECISION (c) = TYPE_PRECISION (double_type_node);
>    layout_type (c);
>    return c;
>  }
> @@ -1447,7 +1447,7 @@ build_m2_long_real_node (void)
>    if (M2Options_GetIBMLongDouble ())
>      {
>        longreal = make_node (REAL_TYPE);
> -      TYPE_PRECISION (longreal) = LONG_DOUBLE_TYPE_SIZE;
> +      TYPE_PRECISION (longreal) = TYPE_PRECISION (long_double_type_node);
>      }
>    else if (M2Options_GetIEEELongDouble ())
>      longreal = float128_type_node;

all look good to me thanks,

regards,
Gaius

^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 15/52] frv: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:01 ` [PATCH 15/52] frv: " Kewen Lin
@ 2024-06-03 13:31   ` Nick Clifton
  0 siblings, 0 replies; 149+ messages in thread
From: Nick Clifton @ 2024-06-03 13:31 UTC (permalink / raw)
  To: Kewen Lin, gcc-patches; +Cc: aoliva

Hi Kewen,

> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in frv port.
> 
> gcc/ChangeLog:
> 
> 	* config/frv/frv.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.

Approved - please apply.

Cheers
   Nick



^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 18/52] iq2000: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:01 ` [PATCH 18/52] iq2000: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE Kewen Lin
@ 2024-06-03 13:32   ` Nick Clifton
  0 siblings, 0 replies; 149+ messages in thread
From: Nick Clifton @ 2024-06-03 13:32 UTC (permalink / raw)
  To: Kewen Lin, gcc-patches

Hi Kewen,

> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in iq2000 port.
> 
> gcc/ChangeLog:
> 
> 	* config/iq2000/iq2000.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.

Approved - please apply.

Cheers
   Nick



^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 20/52] m32c: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:01 ` [PATCH 20/52] m32c: " Kewen Lin
@ 2024-06-03 13:33   ` Nick Clifton
  0 siblings, 0 replies; 149+ messages in thread
From: Nick Clifton @ 2024-06-03 13:33 UTC (permalink / raw)
  To: Kewen Lin, gcc-patches; +Cc: jeffreyalaw

Hi Kewen,

> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in m32c port.
> 
> gcc/ChangeLog:
> 
> 	* config/m32c/m32c.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.

Approved - please apply.

Cheers
   Nick



^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 21/52] m32r: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:01 ` [PATCH 21/52] m32r: " Kewen Lin
@ 2024-06-03 13:33   ` Nick Clifton
  0 siblings, 0 replies; 149+ messages in thread
From: Nick Clifton @ 2024-06-03 13:33 UTC (permalink / raw)
  To: Kewen Lin, gcc-patches; +Cc: jeffreyalaw

Hi Kewen,

> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in m32r port.
> 
> gcc/ChangeLog:
> 
> 	* config/m32r/m32r.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.

Approved - please apply.

Cheers
   Nick



^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 25/52] msp430: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:01 ` [PATCH 25/52] msp430: " Kewen Lin
@ 2024-06-03 13:34   ` Nick Clifton
  0 siblings, 0 replies; 149+ messages in thread
From: Nick Clifton @ 2024-06-03 13:34 UTC (permalink / raw)
  To: Kewen Lin, gcc-patches

Hi Kewen,

> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in msp430 port.
> 
> gcc/ChangeLog:
> 
> 	* config/msp430/msp430.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.

Approved - please apply.

Cheers
   Nick



^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 32/52] stormy16: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:01 ` [PATCH 32/52] stormy16: " Kewen Lin
@ 2024-06-03 13:35   ` Nick Clifton
  0 siblings, 0 replies; 149+ messages in thread
From: Nick Clifton @ 2024-06-03 13:35 UTC (permalink / raw)
  To: Kewen Lin, gcc-patches

Hi Kewen,

> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in stormy16 port.
> 
> gcc/ChangeLog:
> 
> 	* config/stormy16/stormy16.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.

Approved - please apply.

Cheers
   Nick



^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 43/52] rx: New hook implementation rx_c_mode_for_floating_type
  2024-06-03  3:01 ` [PATCH 43/52] rx: New hook implementation rx_c_mode_for_floating_type Kewen Lin
@ 2024-06-03 13:36   ` Nick Clifton
  0 siblings, 0 replies; 149+ messages in thread
From: Nick Clifton @ 2024-06-03 13:36 UTC (permalink / raw)
  To: Kewen Lin, gcc-patches

Hi Kewen,

> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in rx port, and add new port specific hook
> implementation rx_c_mode_for_floating_type.
> 
> gcc/ChangeLog:
> 
> 	* config/rx/rx.cc (rx_c_mode_for_floating_type): New function.
> 	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
> 	* config/rx/rx.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.

Approved - please apply.

Cheers
   Nick



^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 02/52] d: Replace use of LONG_DOUBLE_TYPE_SIZE
  2024-06-03  8:57     ` Kewen.Lin
@ 2024-06-03 14:39       ` Iain Buclaw
  2024-06-04  3:17         ` [PATCH 02/52 v2] " Kewen.Lin
  0 siblings, 1 reply; 149+ messages in thread
From: Iain Buclaw @ 2024-06-03 14:39 UTC (permalink / raw)
  To: Kewen.Lin; +Cc: gcc-patches

Excerpts from Kewen.Lin's message of Juni 3, 2024 10:57 am:
> Hi Iain,
> 
> on 2024/6/3 16:40, Iain Buclaw wrote:
>> Excerpts from Kewen Lin's message of Juni 3, 2024 5:00 am:
>>> 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 d with
>>> TYPE_PRECISION of long_double_type_node.
>>>
>>> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
>>>
>> 
>> Thanks, one question though: Is TYPE_PRECISION really equivalent to
>> LONG_DOUBLE_TYPE_SIZE?
> 
> Yes, it's guaranteed by the code in build_common_tree_nodes:
> 
>   long_double_type_node = make_node (REAL_TYPE);
>   TYPE_PRECISION (long_double_type_node) = LONG_DOUBLE_TYPE_SIZE;
>   layout_type (long_double_type_node);
> 
> , the macro LONG_DOUBLE_TYPE_SIZE is assigned to TYPE_PRECISION of
> long_double_type_node, layout_type will only pick up one mode as
> the given precision and won't change it.
> 
>> 
>> Unless LONG_DOUBLE_TYPE_SIZE was poorly named to begin with, I'd assume
>> the answer to be "no".
> 
> I'm afraid it's poorly named before.
> 

Thanks for confirming Kewen.

I suspect then that this code is incorrectly using this macro, and it
should instead be using:

int_size_in_bytes(long_double_type_node)

as any padding should be considered as part of the overall type size for
the purpose that this field serves in the D part of the front-end.

Are you able to update the patch this way instead? Otherwise I'm happy
to push the change instead.

Thanks again,
Iain.

^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 31/52] pru: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:01 ` [PATCH 31/52] pru: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE Kewen Lin
@ 2024-06-03 15:59   ` Dimitar Dimitrov
  0 siblings, 0 replies; 149+ messages in thread
From: Dimitar Dimitrov @ 2024-06-03 15:59 UTC (permalink / raw)
  To: Kewen Lin; +Cc: gcc-patches

On Sun, Jun 02, 2024 at 10:01:21PM -0500, Kewen Lin wrote:
> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in pru port.
> 
> gcc/ChangeLog:
> 
> 	* config/pru/pru.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.
> ---
>  gcc/config/pru/pru.h | 3 ---
>  1 file changed, 3 deletions(-)
> 

OK, thanks.

Dimitar

^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 09/52] Replace {FLOAT, {, LONG_}DOUBLE}_TYPE_SIZE with new hook mode_for_floating_type
  2024-06-03  3:00 ` [PATCH 09/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook mode_for_floating_type Kewen Lin
  2024-06-03  6:49   ` Richard Biener
@ 2024-06-03 17:59   ` Joseph Myers
  2024-06-04  3:27     ` [PATCH 09/52 v2] " Kewen.Lin
  1 sibling, 1 reply; 149+ messages in thread
From: Joseph Myers @ 2024-06-03 17:59 UTC (permalink / raw)
  To: Kewen Lin
  Cc: gcc-patches, richard.guenther, segher, bergner,
	richard.sandiford, jakub, jeffreyalaw

On Sun, 2 Jun 2024, Kewen Lin wrote:

> +value less than or equal to mode precision of the mode used for C type
> +@code{long double} (from hook @code{targetm.c.mode_for_floating_type}
> +with tree_index TI_LONG_DOUBLE_TYPE).  If you do not define this macro,
> +mode precision of the mode used for C type @code{long double} is the
> +default.

Identifiers such as tree_index and TI_LONG_DOUBLE_TYPE should be enclosed 
in @code{} in documentation (in this case it would be better to say "with 
argument @code{TI_LONG_DOUBLE_TYPE}" rather than mentioning the tree_index 
type of the argument).

> @@ -1428,9 +1413,11 @@ the libgcc @file{config.host}.
>  @defmac WIDEST_HARDWARE_FP_SIZE
>  A C expression for the size in bits of the widest floating-point format
>  supported by the hardware.  If you define this macro, you must specify a
> -value less than or equal to the value of @code{LONG_DOUBLE_TYPE_SIZE}.
> -If you do not define this macro, the value of @code{LONG_DOUBLE_TYPE_SIZE}
> -is the default.
> +value less than or equal to mode precision of the mode used for C type
> +@code{long double} (from hook @code{targetm.c.mode_for_floating_type}
> +with tree_index TI_LONG_DOUBLE_TYPE).  If you do not define this macro,
> +mode precision of the mode used for C type @code{long double} is the
> +default.

Likewise.

-- 
Joseph S. Myers
josmyers@redhat.com


^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 06/52] m2: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 ` [PATCH 06/52] m2: " Kewen Lin
  2024-06-03 12:42   ` Gaius Mulley
@ 2024-06-03 18:02   ` Joseph Myers
  2024-06-04  3:19     ` Kewen.Lin
  1 sibling, 1 reply; 149+ messages in thread
From: Joseph Myers @ 2024-06-03 18:02 UTC (permalink / raw)
  To: Kewen Lin; +Cc: gcc-patches, gaiusmod2

On Sun, 2 Jun 2024, Kewen Lin wrote:

> diff --git a/gcc/m2/gm2-gcc/m2type.cc b/gcc/m2/gm2-gcc/m2type.cc
> index 571923c08ef..d52cbdf0b99 100644
> --- a/gcc/m2/gm2-gcc/m2type.cc
> +++ b/gcc/m2/gm2-gcc/m2type.cc
> @@ -1420,7 +1420,7 @@ build_m2_short_real_node (void)
>    /* Define `REAL'.  */
>  
>    c = make_node (REAL_TYPE);
> -  TYPE_PRECISION (c) = FLOAT_TYPE_SIZE;
> +  TYPE_PRECISION (c) = TYPE_PRECISION (float_type_node);
>    layout_type (c);
>    return c;
>  }
> @@ -1433,7 +1433,7 @@ build_m2_real_node (void)
>    /* Define `REAL'.  */
>  
>    c = make_node (REAL_TYPE);
> -  TYPE_PRECISION (c) = DOUBLE_TYPE_SIZE;
> +  TYPE_PRECISION (c) = TYPE_PRECISION (double_type_node);
>    layout_type (c);
>    return c;
>  }
> @@ -1447,7 +1447,7 @@ build_m2_long_real_node (void)
>    if (M2Options_GetIBMLongDouble ())
>      {
>        longreal = make_node (REAL_TYPE);
> -      TYPE_PRECISION (longreal) = LONG_DOUBLE_TYPE_SIZE;
> +      TYPE_PRECISION (longreal) = TYPE_PRECISION (long_double_type_node);

This looks rather like m2 would still have the same problem the generic 
code previously had: going via precision when that might not uniquely 
determine the desired machine mode.  And so making sure to use the right 
machine mode as done when setting up long_double_type_node etc. would be 
better than keeping this code copying TYPE_PRECISION and hoping to 
determine a machine mode from that.  It certainly looks like this code 
wants to match float, double and long double, rather than possibly getting 
a different mode with possibly the same TYPE_PRECISION.

(I don't know if the M2Options_GetIBMLongDouble call would be needed at 
all once you use the machine mode for long double in a reliable way, or 
whether this code could be further simplified.)

-- 
Joseph S. Myers
josmyers@redhat.com


^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 03/52] fortran: Replace uses of {FLOAT, {, LONG_}DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 ` [PATCH 03/52] fortran: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE Kewen Lin
@ 2024-06-03 20:01   ` Harald Anlauf
  2024-06-03 20:01     ` Harald Anlauf
  2024-06-05  9:30     ` Kewen.Lin
  0 siblings, 2 replies; 149+ messages in thread
From: Harald Anlauf @ 2024-06-03 20:01 UTC (permalink / raw)
  To: Kewen Lin, gcc-patches; +Cc: fortran, mikael

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


^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 03/52] fortran: Replace uses of {FLOAT, {, LONG_}DOUBLE}_TYPE_SIZE
  2024-06-03 20:01   ` [PATCH 03/52] fortran: Replace uses of {FLOAT, {, LONG_}DOUBLE}_TYPE_SIZE Harald Anlauf
@ 2024-06-03 20:01     ` Harald Anlauf
  2024-06-05  9:30     ` Kewen.Lin
  1 sibling, 0 replies; 149+ messages in thread
From: Harald Anlauf @ 2024-06-03 20:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: fortran

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



^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 34/52] xtensa: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:01 ` [PATCH 34/52] xtensa: " Kewen Lin
@ 2024-06-03 21:08   ` augustine.sterling
  0 siblings, 0 replies; 149+ messages in thread
From: augustine.sterling @ 2024-06-03 21:08 UTC (permalink / raw)
  To: Kewen Lin; +Cc: gcc-patches, jcmvbkbc

[-- Attachment #1: Type: text/plain, Size: 1020 bytes --]

Approved

On Sun, Jun 2, 2024 at 8:02 PM Kewen Lin <linkw@linux.ibm.com> wrote:

> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in xtensa port.
>
> gcc/ChangeLog:
>
>         * config/xtensa/xtensa.h (FLOAT_TYPE_SIZE): Remove.
>         (DOUBLE_TYPE_SIZE): Likewise.
>         (LONG_DOUBLE_TYPE_SIZE): Likewise.
> ---
>  gcc/config/xtensa/xtensa.h | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/gcc/config/xtensa/xtensa.h b/gcc/config/xtensa/xtensa.h
> index 9591b3d4b40..06f1e24f7b7 100644
> --- a/gcc/config/xtensa/xtensa.h
> +++ b/gcc/config/xtensa/xtensa.h
> @@ -120,9 +120,6 @@ along with GCC; see the file COPYING3.  If not see
>  #define SHORT_TYPE_SIZE 16
>  #define LONG_TYPE_SIZE 32
>  #define LONG_LONG_TYPE_SIZE 64
> -#define FLOAT_TYPE_SIZE 32
> -#define DOUBLE_TYPE_SIZE 64
> -#define LONG_DOUBLE_TYPE_SIZE 64
>
>  /* Allocation boundary (in *bits*) for storing pointers in memory.  */
>  #define POINTER_BOUNDARY 32
> --
> 2.43.0
>
>

^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 49/52] mips: New hook implementation mips_c_mode_for_floating_type
  2024-06-03  3:01 ` [PATCH 49/52] mips: New hook implementation mips_c_mode_for_floating_type Kewen Lin
@ 2024-06-04  1:16   ` YunQiang Su
  0 siblings, 0 replies; 149+ messages in thread
From: YunQiang Su @ 2024-06-04  1:16 UTC (permalink / raw)
  To: Kewen Lin; +Cc: gcc-patches

Kewen Lin <linkw@linux.ibm.com> 于2024年6月3日周一 11:03写道:
>
> This is to add new port specific hook implementation
> mips_c_mode_for_floating_type, remove macros FLOAT_TYPE_SIZE
> and DOUBLE_TYPE_SIZE, rename LONG_DOUBLE_TYPE_SIZE to
> MIPS_LONG_DOUBLE_TYPE_SIZE since we poison LONG_DOUBLE_TYPE_SIZE
> but some subtarget wants to redefine it and some macro defines
> need it.
>

Good for me if the framework is approved.

> gcc/ChangeLog:
>
>         * config/mips/mips.cc (mips_c_mode_for_floating_type): New function.
>         (TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
>         * config/mips/mips.h (UNITS_PER_FPVALUE): Replace LONG_DOUBLE_TYPE_SIZE
>         with MIPS_LONG_DOUBLE_TYPE_SIZE.
>         (MAX_FIXED_MODE_SIZE): Likewise.
>         (STRUCTURE_SIZE_BOUNDARY): Likewise.
>         (BIGGEST_ALIGNMENT): Likewise.
>         (FLOAT_TYPE_SIZE): Remove.
>         (DOUBLE_TYPE_SIZE): Remove.
>         (LONG_DOUBLE_TYPE_SIZE): Rename to ...
>         (MIPS_LONG_DOUBLE_TYPE_SIZE): ... this.
>         * config/mips/n32-elf.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
>         (MIPS_LONG_DOUBLE_TYPE_SIZE): ... this.
> ---
>  gcc/config/mips/mips.cc   | 14 ++++++++++++++
>  gcc/config/mips/mips.h    | 13 ++++++-------
>  gcc/config/mips/n32-elf.h |  4 ++--
>  3 files changed, 22 insertions(+), 9 deletions(-)
>
> diff --git a/gcc/config/mips/mips.cc b/gcc/config/mips/mips.cc
> index b63d40a357b..3e5035a385c 100644
> --- a/gcc/config/mips/mips.cc
> +++ b/gcc/config/mips/mips.cc
> @@ -22972,6 +22972,18 @@ mips_asm_file_end (void)
>      file_end_indicate_exec_stack ();
>  }
>
> +/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return TFmode or DFmode
> +   for TI_LONG_DOUBLE_TYPE which is for long double type, go with the
> +   default one for the others.  */
> +
> +static machine_mode
> +mips_c_mode_for_floating_type (enum tree_index ti)
> +{
> +  if (ti == TI_LONG_DOUBLE_TYPE)
> +    return MIPS_LONG_DOUBLE_TYPE_SIZE == 64 ? DFmode : TFmode;
> +  return default_mode_for_floating_type (ti);
> +}
> +
>  void
>  mips_bit_clear_info (enum machine_mode mode, unsigned HOST_WIDE_INT m,
>                       int *start_pos, int *size)
> @@ -23340,6 +23352,8 @@ mips_bit_clear_p (enum machine_mode mode, unsigned HOST_WIDE_INT m)
>  #undef TARGET_ASM_FILE_END
>  #define TARGET_ASM_FILE_END mips_asm_file_end
>
> +#undef TARGET_C_MODE_FOR_FLOATING_TYPE
> +#define TARGET_C_MODE_FOR_FLOATING_TYPE mips_c_mode_for_floating_type
>
>  struct gcc_target targetm = TARGET_INITIALIZER;
>
> diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h
> index 9d965966f2f..7a9b18c8096 100644
> --- a/gcc/config/mips/mips.h
> +++ b/gcc/config/mips/mips.h
> @@ -1654,7 +1654,7 @@ FP_ASM_SPEC "\
>  #define UNITS_PER_FPVALUE                      \
>    (TARGET_SOFT_FLOAT_ABI ? 0                   \
>     : TARGET_SINGLE_FLOAT ? UNITS_PER_FPREG     \
> -   : LONG_DOUBLE_TYPE_SIZE / BITS_PER_UNIT)
> +   : MIPS_LONG_DOUBLE_TYPE_SIZE / BITS_PER_UNIT)
>
>  /* The number of bytes in a double.  */
>  #define UNITS_PER_DOUBLE (TYPE_PRECISION (double_type_node) / BITS_PER_UNIT)
> @@ -1665,9 +1665,8 @@ FP_ASM_SPEC "\
>  #define LONG_TYPE_SIZE (TARGET_LONG64 ? 64 : 32)
>  #define LONG_LONG_TYPE_SIZE 64
>
> -#define FLOAT_TYPE_SIZE 32
> -#define DOUBLE_TYPE_SIZE 64
> -#define LONG_DOUBLE_TYPE_SIZE (TARGET_NEWABI ? 128 : 64)
> +/* LONG_DOUBLE_TYPE_SIZE gets poisoned, so add MIPS_ prefix.  */
> +#define MIPS_LONG_DOUBLE_TYPE_SIZE (TARGET_NEWABI ? 128 : 64)
>
>  /* Define the sizes of fixed-point types.  */
>  #define SHORT_FRACT_TYPE_SIZE 8
> @@ -1684,7 +1683,7 @@ FP_ASM_SPEC "\
>
>  /* long double is not a fixed mode, but the idea is that, if we
>     support long double, we also want a 128-bit integer type.  */
> -#define MAX_FIXED_MODE_SIZE LONG_DOUBLE_TYPE_SIZE
> +#define MAX_FIXED_MODE_SIZE MIPS_LONG_DOUBLE_TYPE_SIZE
>
>  /* Width in bits of a pointer.  */
>  #ifndef POINTER_SIZE
> @@ -1705,10 +1704,10 @@ FP_ASM_SPEC "\
>  #define STRUCTURE_SIZE_BOUNDARY 8
>
>  /* There is no point aligning anything to a rounder boundary than
> -   LONG_DOUBLE_TYPE_SIZE, unless under MSA the bigggest alignment is
> +   MIPS_LONG_DOUBLE_TYPE_SIZE, unless under MSA the bigggest alignment is
>     BITS_PER_MSA_REG.  */
>  #define BIGGEST_ALIGNMENT \
> -  (ISA_HAS_MSA ? BITS_PER_MSA_REG : LONG_DOUBLE_TYPE_SIZE)
> +  (ISA_HAS_MSA ? BITS_PER_MSA_REG : MIPS_LONG_DOUBLE_TYPE_SIZE)
>
>  /* All accesses must be aligned.  */
>  #define STRICT_ALIGNMENT (!ISA_HAS_UNALIGNED_ACCESS)
> diff --git a/gcc/config/mips/n32-elf.h b/gcc/config/mips/n32-elf.h
> index 94a90d847f0..01c8a852539 100644
> --- a/gcc/config/mips/n32-elf.h
> +++ b/gcc/config/mips/n32-elf.h
> @@ -26,5 +26,5 @@ along with GCC; see the file COPYING3.  If not see
>  #define NO_DOLLAR_IN_LABEL
>
>  /* Force n32 to use 64-bit long doubles.  */
> -#undef LONG_DOUBLE_TYPE_SIZE
> -#define LONG_DOUBLE_TYPE_SIZE 64
> +#undef MIPS_LONG_DOUBLE_TYPE_SIZE
> +#define MIPS_LONG_DOUBLE_TYPE_SIZE 64
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 47/52] loongarch: New hook implementation loongarch_c_mode_for_floating_type
  2024-06-03  3:01 ` [PATCH 47/52] loongarch: New hook implementation loongarch_c_mode_for_floating_type Kewen Lin
@ 2024-06-04  1:45   ` Lulu Cheng
  0 siblings, 0 replies; 149+ messages in thread
From: Lulu Cheng @ 2024-06-04  1:45 UTC (permalink / raw)
  To: Kewen Lin, gcc-patches; +Cc: xuchenghua

Ok! Thanks!

Lulu Cheng

在 2024/6/3 上午11:01, Kewen Lin 写道:
> This is to add new port specific hook implementation
> loongarch_c_mode_for_floating_type, remove macro
> defines for FLOAT_TYPE_SIZE and DOUBLE_TYPE_SIZE, and
> rename LONG_DOUBLE_TYPE_SIZE to LA_LONG_DOUBLE_TYPE_SIZE
> as we poison LONG_DOUBLE_TYPE_SIZE but some macros need
> LONG_DOUBLE_TYPE_SIZE.
>
> gcc/ChangeLog:
>
> 	* config/loongarch/loongarch.cc (loongarch_c_mode_for_floating_type):
> 	New function.
> 	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
> 	* config/loongarch/loongarch.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Remove.
> 	(LONG_DOUBLE_TYPE_SIZE): Rename to ...
> 	(LA_LONG_DOUBLE_TYPE_SIZE): ... this.
> 	(UNITS_PER_FPVALUE): Replace LONG_DOUBLE_TYPE_SIZE with
> 	LA_LONG_DOUBLE_TYPE_SIZE.
> 	(MAX_FIXED_MODE_SIZE): Likewise.
> 	(STRUCTURE_SIZE_BOUNDARY): Likewise.
> 	(BIGGEST_ALIGNMENT): Likewise.
> ---
>   gcc/config/loongarch/loongarch.cc | 15 +++++++++++++++
>   gcc/config/loongarch/loongarch.h  | 13 ++++++-------
>   2 files changed, 21 insertions(+), 7 deletions(-)
>
> diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
> index e7835ae34ae..e4a51303d22 100644
> --- a/gcc/config/loongarch/loongarch.cc
> +++ b/gcc/config/loongarch/loongarch.cc
> @@ -10946,6 +10946,18 @@ loongarch_builtin_support_vector_misalignment (machine_mode mode,
>   						      is_packed);
>   }
>   
> +/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return TFmode or DFmode
> +   for TI_LONG_DOUBLE_TYPE which is for long double type, go with the
> +   default one for the others.  */
> +
> +static machine_mode
> +loongarch_c_mode_for_floating_type (enum tree_index ti)
> +{
> +  if (ti == TI_LONG_DOUBLE_TYPE)
> +    return TARGET_64BIT ? TFmode : DFmode;
> +  return default_mode_for_floating_type (ti);
> +}
> +
>   static bool
>   use_rsqrt_p (void)
>   {
> @@ -11256,6 +11268,9 @@ loongarch_asm_code_end (void)
>   #define TARGET_VECTORIZE_SUPPORT_VECTOR_MISALIGNMENT \
>     loongarch_builtin_support_vector_misalignment
>   
> +#undef TARGET_C_MODE_FOR_FLOATING_TYPE
> +#define TARGET_C_MODE_FOR_FLOATING_TYPE loongarch_c_mode_for_floating_type
> +
>   struct gcc_target targetm = TARGET_INITIALIZER;
>   
>   #include "gt-loongarch.h"
> diff --git a/gcc/config/loongarch/loongarch.h b/gcc/config/loongarch/loongarch.h
> index f7fe950f333..b9323aba394 100644
> --- a/gcc/config/loongarch/loongarch.h
> +++ b/gcc/config/loongarch/loongarch.h
> @@ -151,7 +151,7 @@ along with GCC; see the file COPYING3.  If not see
>   #define UNITS_PER_FPVALUE \
>     (TARGET_SOFT_FLOAT ? 0 \
>      : TARGET_SINGLE_FLOAT ? UNITS_PER_FP_REG \
> -			 : LONG_DOUBLE_TYPE_SIZE / BITS_PER_UNIT)
> +			 : LA_LONG_DOUBLE_TYPE_SIZE / BITS_PER_UNIT)
>   
>   /* The number of bytes in a double.  */
>   #define UNITS_PER_DOUBLE (TYPE_PRECISION (double_type_node) / BITS_PER_UNIT)
> @@ -162,9 +162,8 @@ along with GCC; see the file COPYING3.  If not see
>   #define LONG_TYPE_SIZE (TARGET_64BIT ? 64 : 32)
>   #define LONG_LONG_TYPE_SIZE 64
>   
> -#define FLOAT_TYPE_SIZE 32
> -#define DOUBLE_TYPE_SIZE 64
> -#define LONG_DOUBLE_TYPE_SIZE (TARGET_64BIT ? 128 : 64)
> +/* LONG_DOUBLE_TYPE_SIZE get poisoned, so add LA_ prefix.  */
> +#define LA_LONG_DOUBLE_TYPE_SIZE (TARGET_64BIT ? 128 : 64)
>   
>   /* Define the sizes of fixed-point types.  */
>   #define SHORT_FRACT_TYPE_SIZE 8
> @@ -179,7 +178,7 @@ along with GCC; see the file COPYING3.  If not see
>   
>   /* long double is not a fixed mode, but the idea is that, if we
>      support long double, we also want a 128-bit integer type.  */
> -#define MAX_FIXED_MODE_SIZE LONG_DOUBLE_TYPE_SIZE
> +#define MAX_FIXED_MODE_SIZE LA_LONG_DOUBLE_TYPE_SIZE
>   
>   /* Width in bits of a pointer.  */
>   #ifndef POINTER_SIZE
> @@ -200,11 +199,11 @@ along with GCC; see the file COPYING3.  If not see
>   #define STRUCTURE_SIZE_BOUNDARY 8
>   
>   /* There is no point aligning anything to a rounder boundary than
> -   LONG_DOUBLE_TYPE_SIZE, unless under LSX/LASX the bigggest alignment is
> +   LA_LONG_DOUBLE_TYPE_SIZE, unless under LSX/LASX the bigggest alignment is
>      BITS_PER_LSX_REG/BITS_PER_LASX_REG/..  */
>   #define BIGGEST_ALIGNMENT \
>     (ISA_HAS_LASX? BITS_PER_LASX_REG \
> -   : (ISA_HAS_LSX ? BITS_PER_LSX_REG : LONG_DOUBLE_TYPE_SIZE))
> +   : (ISA_HAS_LSX ? BITS_PER_LSX_REG : LA_LONG_DOUBLE_TYPE_SIZE))
>   
>   /* All accesses must be aligned.  */
>   #define STRICT_ALIGNMENT (TARGET_STRICT_ALIGN)


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 02/52 v2] d: Replace use of LONG_DOUBLE_TYPE_SIZE
  2024-06-03 14:39       ` Iain Buclaw
@ 2024-06-04  3:17         ` Kewen.Lin
  2024-06-04 11:35           ` Iain Buclaw
  0 siblings, 1 reply; 149+ messages in thread
From: Kewen.Lin @ 2024-06-04  3:17 UTC (permalink / raw)
  To: Iain Buclaw; +Cc: gcc-patches

Hi Iain,

on 2024/6/3 22:39, Iain Buclaw wrote:
> Excerpts from Kewen.Lin's message of Juni 3, 2024 10:57 am:
>> Hi Iain,
>>
>> on 2024/6/3 16:40, Iain Buclaw wrote:
>>> Excerpts from Kewen Lin's message of Juni 3, 2024 5:00 am:
>>>> 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 d with
>>>> TYPE_PRECISION of long_double_type_node.
>>>>
>>>> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
>>>>
>>>
>>> Thanks, one question though: Is TYPE_PRECISION really equivalent to
>>> LONG_DOUBLE_TYPE_SIZE?
>>
>> Yes, it's guaranteed by the code in build_common_tree_nodes:
>>
>>   long_double_type_node = make_node (REAL_TYPE);
>>   TYPE_PRECISION (long_double_type_node) = LONG_DOUBLE_TYPE_SIZE;
>>   layout_type (long_double_type_node);
>>
>> , the macro LONG_DOUBLE_TYPE_SIZE is assigned to TYPE_PRECISION of
>> long_double_type_node, layout_type will only pick up one mode as
>> the given precision and won't change it.
>>
>>>
>>> Unless LONG_DOUBLE_TYPE_SIZE was poorly named to begin with, I'd assume
>>> the answer to be "no".
>>
>> I'm afraid it's poorly named before.
>>
> 
> Thanks for confirming Kewen.
> 
> I suspect then that this code is incorrectly using this macro, and it
> should instead be using:
> 
> int_size_in_bytes(long_double_type_node)
> 
> as any padding should be considered as part of the overall type size for
> the purpose that this field serves in the D part of the front-end.

Got it, thanks for the explanation and suggestion.

> 
> Are you able to update the patch this way instead? Otherwise I'm happy
> to push the change instead.

Sure, updated as below:

Subject: [PATCH 02/52] d: Replace use of 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 the only one use of LONG_DOUBLE_TYPE_SIZE
in d.  Iain found that LONG_DOUBLE_TYPE_SIZE is poorly named
and used incorrectly before, so this patch follows his advice
with int_size_in_bytes.

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

Co-authored-by: Iain Buclaw <ibuclaw@gdcproject.org>

gcc/d/ChangeLog:

	* d-target.cc (Target::_init): Use int_size_in_bytes of
	long_double_type_node to replace the expression with
	LONG_DOUBLE_TYPE_SIZE for c.long_doublesize assignment.
---
 gcc/d/d-target.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/d/d-target.cc b/gcc/d/d-target.cc
index 127b9d7ce7c..dd46e535891 100644
--- a/gcc/d/d-target.cc
+++ b/gcc/d/d-target.cc
@@ -163,7 +163,7 @@ Target::_init (const Param &)
   this->c.intsize = (INT_TYPE_SIZE / BITS_PER_UNIT);
   this->c.longsize = (LONG_TYPE_SIZE / BITS_PER_UNIT);
   this->c.long_longsize = (LONG_LONG_TYPE_SIZE / BITS_PER_UNIT);
-  this->c.long_doublesize = (LONG_DOUBLE_TYPE_SIZE / BITS_PER_UNIT);
+  this->c.long_doublesize = int_size_in_bytes (long_double_type_node);
   this->c.wchar_tsize = (WCHAR_TYPE_SIZE / BITS_PER_UNIT);

   this->c.bitFieldStyle = targetm.ms_bitfield_layout_p (unknown_type_node)
--
2.43.0

BR,
Kewen

^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 06/52] m2: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  2024-06-03 18:02   ` Joseph Myers
@ 2024-06-04  3:19     ` Kewen.Lin
  2024-06-05 14:22       ` Gaius Mulley
  0 siblings, 1 reply; 149+ messages in thread
From: Kewen.Lin @ 2024-06-04  3:19 UTC (permalink / raw)
  To: Joseph Myers; +Cc: gcc-patches, gaiusmod2

Hi Joseph and Gaius,

on 2024/6/4 02:02, Joseph Myers wrote:
> On Sun, 2 Jun 2024, Kewen Lin wrote:
> 
>> diff --git a/gcc/m2/gm2-gcc/m2type.cc b/gcc/m2/gm2-gcc/m2type.cc
>> index 571923c08ef..d52cbdf0b99 100644
>> --- a/gcc/m2/gm2-gcc/m2type.cc
>> +++ b/gcc/m2/gm2-gcc/m2type.cc
>> @@ -1420,7 +1420,7 @@ build_m2_short_real_node (void)
>>    /* Define `REAL'.  */
>>  
>>    c = make_node (REAL_TYPE);
>> -  TYPE_PRECISION (c) = FLOAT_TYPE_SIZE;
>> +  TYPE_PRECISION (c) = TYPE_PRECISION (float_type_node);
>>    layout_type (c);
>>    return c;
>>  }
>> @@ -1433,7 +1433,7 @@ build_m2_real_node (void)
>>    /* Define `REAL'.  */
>>  
>>    c = make_node (REAL_TYPE);
>> -  TYPE_PRECISION (c) = DOUBLE_TYPE_SIZE;
>> +  TYPE_PRECISION (c) = TYPE_PRECISION (double_type_node);
>>    layout_type (c);
>>    return c;
>>  }
>> @@ -1447,7 +1447,7 @@ build_m2_long_real_node (void)
>>    if (M2Options_GetIBMLongDouble ())
>>      {
>>        longreal = make_node (REAL_TYPE);
>> -      TYPE_PRECISION (longreal) = LONG_DOUBLE_TYPE_SIZE;
>> +      TYPE_PRECISION (longreal) = TYPE_PRECISION (long_double_type_node);
> 
> This looks rather like m2 would still have the same problem the generic 
> code previously had: going via precision when that might not uniquely 
> determine the desired machine mode.  And so making sure to use the right 
> machine mode as done when setting up long_double_type_node etc. would be 
> better than keeping this code copying TYPE_PRECISION and hoping to 
> determine a machine mode from that.  It certainly looks like this code 
> wants to match float, double and long double, rather than possibly getting 
> a different mode with possibly the same TYPE_PRECISION.

Good point, sorry that I just did a replacement without checking the context.
If the above holds (Gaius can confirm or clarify), SET_TYPE_MODE would be
also applied here, that is:

diff --git a/gcc/m2/gm2-gcc/m2type.cc b/gcc/m2/gm2-gcc/m2type.cc
index d52cbdf0b99..5ff02a18876 100644
--- a/gcc/m2/gm2-gcc/m2type.cc
+++ b/gcc/m2/gm2-gcc/m2type.cc
@@ -1421,6 +1421,7 @@ build_m2_short_real_node (void)

   c = make_node (REAL_TYPE);
   TYPE_PRECISION (c) = TYPE_PRECISION (float_type_node);
+  SET_TYPE_MODE (c, TYPE_MODE (float_type_node));
   layout_type (c);
   return c;
 }
@@ -1434,6 +1435,7 @@ build_m2_real_node (void)

   c = make_node (REAL_TYPE);
   TYPE_PRECISION (c) = TYPE_PRECISION (double_type_node);
+  SET_TYPE_MODE (c, TYPE_MODE (double_type_node));
   layout_type (c);
   return c;
 }

I'm not sure and curious why the above builds new nodes for short real and
real but re-use float128_type_node or long_double_type_node for some cases,
some special needs cause the former ones should have separated nodes?

> 
> (I don't know if the M2Options_GetIBMLongDouble call would be needed at 
> all once you use the machine mode for long double in a reliable way, or 
> whether this code could be further simplified.)

long_double_type_node should already take care of ibmlongdouble, IIUC it
would be like:

@@ -1443,13 +1445,7 @@ build_m2_long_real_node (void)
 {
   tree longreal;

-  /* Define `LONGREAL'.  */
-  if (M2Options_GetIBMLongDouble ())
-    {
-      longreal = make_node (REAL_TYPE);
-      TYPE_PRECISION (longreal) = TYPE_PRECISION (long_double_type_node);
-    }
-  else if (M2Options_GetIEEELongDouble ())
+  if (M2Options_GetIEEELongDouble ())
     longreal = float128_type_node;
   else
     longreal = long_double_type_node;

unless there is some special need requiring one different node for
ibmlongdouble, then:

diff --git a/gcc/m2/gm2-gcc/m2type.cc b/gcc/m2/gm2-gcc/m2type.cc
index c808e3e8dbb..5e479e4bbce 100644
--- a/gcc/m2/gm2-gcc/m2type.cc
+++ b/gcc/m2/gm2-gcc/m2type.cc
@@ -1450,6 +1450,7 @@ build_m2_long_real_node (void)
     {
       longreal = make_node (REAL_TYPE);
       TYPE_PRECISION (longreal) = TYPE_PRECISION (long_double_type_node);
+      SET_TYPE_MODE (longreal, TYPE_MODE (long_double_type_node));
     }
   else if (M2Options_GetIEEELongDouble ())
     longreal = float128_type_node;

BR,
Kewen


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 09/52 v2] Replace {FLOAT, {, LONG_}DOUBLE}_TYPE_SIZE with new hook mode_for_floating_type
  2024-06-03 17:59   ` [PATCH 09/52] Replace {FLOAT, {, LONG_}DOUBLE}_TYPE_SIZE " Joseph Myers
@ 2024-06-04  3:27     ` Kewen.Lin
  2024-06-25  5:20       ` Kewen.Lin
  0 siblings, 1 reply; 149+ messages in thread
From: Kewen.Lin @ 2024-06-04  3:27 UTC (permalink / raw)
  To: Joseph Myers
  Cc: gcc-patches, richard.guenther, segher, bergner,
	richard.sandiford, jakub, jeffreyalaw

Hi Joseph,

on 2024/6/4 01:59, Joseph Myers wrote:
> On Sun, 2 Jun 2024, Kewen Lin wrote:
> 
>> +value less than or equal to mode precision of the mode used for C type
>> +@code{long double} (from hook @code{targetm.c.mode_for_floating_type}
>> +with tree_index TI_LONG_DOUBLE_TYPE).  If you do not define this macro,
>> +mode precision of the mode used for C type @code{long double} is the
>> +default.
> 
> Identifiers such as tree_index and TI_LONG_DOUBLE_TYPE should be enclosed 
> in @code{} in documentation (in this case it would be better to say "with 
> argument @code{TI_LONG_DOUBLE_TYPE}" rather than mentioning the tree_index 
> type of the argument).

Thanks for the review, updated as v2 (also incorporating Richi's comments on
"type type" typo):

Subject: [PATCH 09/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook
 mode_for_floating_type

Currently how we determine which mode will be used for a
floating point type is that for a given type precision
(size) call mode_for_size to get the first mode which has
this size in the specified class.  On Powerpc, we have
three modes (TF/KF/IF) having the same mode precision 128
(see[1]), so the processing forces us to have to place TF
at the first place, it would require us to make more
adjustment in some generic code to avoid some unexpected
mode conversions and it would be even worse if we get rid
of TF eventually one day.  And as Joseph pointed out in [2],
"floating types should have their mode, not a poorly
defined precision value", as Joseph and Richi suggested,
this patch is to introduce one hook mode_for_floating_type
which returns the corresponding mode for type float, double
or long double.  The default implementation returns SFmode
for float and DFmode for double or long double.  For ports
which need special treatment, there are some other patches
for their own port specific implementation (referring to
how {,LONG_}DOUBLE_TYPE_SIZE get used there).  For all
generic uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE, depending
on the context, some of them are replaced with TYPE_PRECISION
of the according type node, some other are replaced with
GET_MODE_PRECISION on the mode from mode_for_floating_type.
This patch also poisons {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE,
so most defines of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE in port
specific are removed, but there are still some which are
good to be kept for readability then they get renamed with
port specific prefix.

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

gcc/ChangeLog:

	* coretypes.h (enum tree_index): Forward declaration.
	* defaults.h (FLOAT_TYPE_SIZE): Remove.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
	* doc/rtl.texi: Update document by replacing {FLOAT,DOUBLE}_TYPE_SIZE
	with C type {float,double}.
	* doc/tm.texi.in: Document new hook mode_for_floating_type, remove
	document entries for {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE and
	update document for WIDEST_HARDWARE_FP_SIZE.
	* doc/tm.texi: Regenerate.
	* emit-rtl.cc (init_emit_once): Replace DOUBLE_TYPE_SIZE by
	calling targetm.c.mode_for_floating_type with TI_DOUBLE_TYPE.
	* real.h (REAL_VALUE_TO_TARGET_LONG_DOUBLE): Use TYPE_PRECISION of
	long_double_type_node to replace LONG_DOUBLE_TYPE_SIZE.
	* system.h (FLOAT_TYPE_SIZE): Poison.
	(DOUBLE_TYPE_SIZE): Likewise.
	(LONG_DOUBLE_TYPE_SIZE): Likewise.
	* target.def (mode_for_floating_type): New hook.
	* targhooks.cc (default_mode_for_floating_type): New function.
	(default_scalar_mode_supported_p): Update macros
	{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE by calling
	targetm.c.mode_for_floating_type with
	TI_{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE.
	* targhooks.h (default_mode_for_floating_type): New declaration.
	* tree-core.h (enum tree_index): Specify underlying type unsigned
	to sync with forward declaration in coretypes.h.
	(NUM_FLOATN_TYPES): Explicitly convert to int.
	(NUM_FLOATNX_TYPES): Likewise.
	(NUM_FLOATN_NX_TYPES): Likewise.
	* tree.cc (build_common_tree_nodes): Update macros
	{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE by calling
	targetm.c.mode_for_floating_type with
	TI_{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE and set type mode accordingly.
---
 gcc/coretypes.h    |  1 +
 gcc/defaults.h     | 12 ------------
 gcc/doc/rtl.texi   |  2 +-
 gcc/doc/tm.texi    | 33 +++++++++++++--------------------
 gcc/doc/tm.texi.in | 27 +++++++--------------------
 gcc/emit-rtl.cc    |  3 ++-
 gcc/real.h         |  7 ++++---
 gcc/system.h       |  3 ++-
 gcc/target.def     |  9 +++++++++
 gcc/targhooks.cc   | 18 +++++++++++++++---
 gcc/targhooks.h    |  1 +
 gcc/tree-core.h    | 13 +++++++------
 gcc/tree.cc        | 18 +++++++++++++++---
 13 files changed, 77 insertions(+), 70 deletions(-)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 1ac6f0abea3..00c1c58bd8c 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -100,6 +100,7 @@ struct gimple;
 typedef gimple *gimple_seq;
 struct gimple_stmt_iterator;
 class code_helper;
+enum tree_index : unsigned;

 /* Forward declare rtx_code, so that we can use it in target hooks without
    needing to pull in rtl.h.  */
diff --git a/gcc/defaults.h b/gcc/defaults.h
index 92f3e07f742..ac2d25852ab 100644
--- a/gcc/defaults.h
+++ b/gcc/defaults.h
@@ -513,18 +513,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
 #endif

-#ifndef FLOAT_TYPE_SIZE
-#define FLOAT_TYPE_SIZE BITS_PER_WORD
-#endif
-
-#ifndef DOUBLE_TYPE_SIZE
-#define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
-#endif
-
-#ifndef LONG_DOUBLE_TYPE_SIZE
-#define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
-#endif
-
 #ifndef DECIMAL32_TYPE_SIZE
 #define DECIMAL32_TYPE_SIZE 32
 #endif
diff --git a/gcc/doc/rtl.texi b/gcc/doc/rtl.texi
index aa10b5235b5..61981ae5a41 100644
--- a/gcc/doc/rtl.texi
+++ b/gcc/doc/rtl.texi
@@ -1326,7 +1326,7 @@ whose size is @code{BITS_PER_WORD}, @code{SImode} on 32-bit machines.

 The only modes which a machine description @i{must} support are
 @code{QImode}, and the modes corresponding to @code{BITS_PER_WORD},
-@code{FLOAT_TYPE_SIZE} and @code{DOUBLE_TYPE_SIZE}.
+C type @code{float} and C type @code{double}.
 The compiler will attempt to use @code{DImode} for 8-byte structures and
 unions, but this can be prevented by overriding the definition of
 @code{MAX_FIXED_MODE_SIZE}.  Alternatively, you can have the compiler
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index cd50078227d..305c4f3aed2 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -1044,6 +1044,14 @@ are zero or sign extended depending on if it is
 @code{GET_MODE_ALIGNMENT (info->limb_mode)}.
 @end deftypefn

+@deftypefn {Target Hook} machine_mode TARGET_C_MODE_FOR_FLOATING_TYPE (enum tree_index @var{ti})
+Return machine mode for a C floating point type which is indicated by
+ a given @code{enum tree_index} @var{ti}, @var{ti} should be
+ @code{TI_FLOAT_TYPE}, @code{TI_DOUBLE_TYPE} or @code{TI_LONG_DOUBLE_TYPE}.
+ The default implementation returns @code{SFmode} for @code{TI_FLOAT_TYPE},
+ and @code{DFmode} for @code{TI_DOUBLE_TYPE} or @code{TI_LONG_DOUBLE_TYPE}.
+@end deftypefn
+
 @deftypefn {Target Hook} machine_mode TARGET_PROMOTE_FUNCTION_MODE (const_tree @var{type}, machine_mode @var{mode}, int *@var{punsignedp}, const_tree @var{funtype}, int @var{for_return})
 Like @code{PROMOTE_MODE}, but it is applied to outgoing function arguments or
 function return values.  The target hook should return the new mode
@@ -1610,23 +1618,6 @@ C99 type @code{_Bool} on the target machine.  If you don't define
 this, and you probably shouldn't, the default is @code{CHAR_TYPE_SIZE}.
 @end defmac

-@defmac FLOAT_TYPE_SIZE
-A C expression for the size in bits of the type @code{float} on the
-target machine.  If you don't define this, the default is one word.
-@end defmac
-
-@defmac DOUBLE_TYPE_SIZE
-A C expression for the size in bits of the type @code{double} on the
-target machine.  If you don't define this, the default is two
-words.
-@end defmac
-
-@defmac LONG_DOUBLE_TYPE_SIZE
-A C expression for the size in bits of the type @code{long double} on
-the target machine.  If you don't define this, the default is two
-words.
-@end defmac
-
 @defmac SHORT_FRACT_TYPE_SIZE
 A C expression for the size in bits of the type @code{short _Fract} on
 the target machine.  If you don't define this, the default is
@@ -1687,9 +1678,11 @@ the libgcc @file{config.host}.
 @defmac WIDEST_HARDWARE_FP_SIZE
 A C expression for the size in bits of the widest floating-point format
 supported by the hardware.  If you define this macro, you must specify a
-value less than or equal to the value of @code{LONG_DOUBLE_TYPE_SIZE}.
-If you do not define this macro, the value of @code{LONG_DOUBLE_TYPE_SIZE}
-is the default.
+value less than or equal to mode precision of the mode used for C type
+@code{long double} (from hook @code{targetm.c.mode_for_floating_type}
+with argument @code{TI_LONG_DOUBLE_TYPE}).  If you do not define this
+macro, mode precision of the mode used for C type @code{long double} is
+the default.
 @end defmac

 @defmac DEFAULT_SIGNED_CHAR
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index 058bd56487a..8de7e393a70 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -947,6 +947,8 @@ applied.

 @hook TARGET_C_BITINT_TYPE_INFO

+@hook TARGET_C_MODE_FOR_FLOATING_TYPE
+
 @hook TARGET_PROMOTE_FUNCTION_MODE

 @defmac PARM_BOUNDARY
@@ -1351,23 +1353,6 @@ C99 type @code{_Bool} on the target machine.  If you don't define
 this, and you probably shouldn't, the default is @code{CHAR_TYPE_SIZE}.
 @end defmac

-@defmac FLOAT_TYPE_SIZE
-A C expression for the size in bits of the type @code{float} on the
-target machine.  If you don't define this, the default is one word.
-@end defmac
-
-@defmac DOUBLE_TYPE_SIZE
-A C expression for the size in bits of the type @code{double} on the
-target machine.  If you don't define this, the default is two
-words.
-@end defmac
-
-@defmac LONG_DOUBLE_TYPE_SIZE
-A C expression for the size in bits of the type @code{long double} on
-the target machine.  If you don't define this, the default is two
-words.
-@end defmac
-
 @defmac SHORT_FRACT_TYPE_SIZE
 A C expression for the size in bits of the type @code{short _Fract} on
 the target machine.  If you don't define this, the default is
@@ -1428,9 +1413,11 @@ the libgcc @file{config.host}.
 @defmac WIDEST_HARDWARE_FP_SIZE
 A C expression for the size in bits of the widest floating-point format
 supported by the hardware.  If you define this macro, you must specify a
-value less than or equal to the value of @code{LONG_DOUBLE_TYPE_SIZE}.
-If you do not define this macro, the value of @code{LONG_DOUBLE_TYPE_SIZE}
-is the default.
+value less than or equal to mode precision of the mode used for C type
+@code{long double} (from hook @code{targetm.c.mode_for_floating_type}
+with argument @code{TI_LONG_DOUBLE_TYPE}).  If you do not define this
+macro, mode precision of the mode used for C type @code{long double} is
+the default.
 @end defmac

 @defmac DEFAULT_SIGNED_CHAR
diff --git a/gcc/emit-rtl.cc b/gcc/emit-rtl.cc
index 1856fa4884f..cb04aa1a8c6 100644
--- a/gcc/emit-rtl.cc
+++ b/gcc/emit-rtl.cc
@@ -6366,7 +6366,8 @@ init_emit_once (void)
   else
     const_true_rtx = gen_rtx_CONST_INT (VOIDmode, STORE_FLAG_VALUE);

-  double_mode = float_mode_for_size (DOUBLE_TYPE_SIZE).require ();
+  mode = targetm.c.mode_for_floating_type (TI_DOUBLE_TYPE);
+  double_mode = as_a<scalar_float_mode> (mode);

   real_from_integer (&dconst0, double_mode, 0, SIGNED);
   real_from_integer (&dconst1, double_mode, 1, SIGNED);
diff --git a/gcc/real.h b/gcc/real.h
index 2e40817a2d7..f28022769b3 100644
--- a/gcc/real.h
+++ b/gcc/real.h
@@ -406,9 +406,10 @@ extern const struct real_format arm_bfloat_half_format;
 #define REAL_VALUE_MINUS_ZERO(x)	real_isnegzero (&(x))

 /* IN is a REAL_VALUE_TYPE.  OUT is an array of longs.  */
-#define REAL_VALUE_TO_TARGET_LONG_DOUBLE(IN, OUT)			\
-  real_to_target (OUT, &(IN),						\
-		  float_mode_for_size (LONG_DOUBLE_TYPE_SIZE).require ())
+#define REAL_VALUE_TO_TARGET_LONG_DOUBLE(IN, OUT)			   \
+  real_to_target (OUT, &(IN),						   \
+		  float_mode_for_size (TYPE_PRECISION			   \
+				       (long_double_type_node)).require ())

 #define REAL_VALUE_TO_TARGET_DOUBLE(IN, OUT) \
   real_to_target (OUT, &(IN), float_mode_for_size (64).require ())
diff --git a/gcc/system.h b/gcc/system.h
index 1028dcb1eb3..cbb14fb167d 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -1000,7 +1000,8 @@ extern void fancy_abort (const char *, int, const char *)
 	HARD_REGNO_NREGS SECONDARY_MEMORY_NEEDED_MODE			\
 	SECONDARY_MEMORY_NEEDED CANNOT_CHANGE_MODE_CLASS		\
 	TRULY_NOOP_TRUNCATION FUNCTION_ARG_OFFSET CONSTANT_ALIGNMENT	\
-	STARTING_FRAME_OFFSET
+	STARTING_FRAME_OFFSET FLOAT_TYPE_SIZE DOUBLE_TYPE_SIZE		\
+	LONG_DOUBLE_TYPE_SIZE

 /* Target macros only used for code built for the target, that have
    moved to libgcc-tm.h or have never been present elsewhere.  */
diff --git a/gcc/target.def b/gcc/target.def
index c27df8095be..4780ba9c15b 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -6370,6 +6370,15 @@ are zero or sign extended depending on if it is\n\
  bool, (int n, struct bitint_info *info),
  default_bitint_type_info)

+DEFHOOK
+(mode_for_floating_type,
+"Return machine mode for a C floating point type which is indicated by\n\
+ a given @code{enum tree_index} @var{ti}, @var{ti} should be\n\
+ @code{TI_FLOAT_TYPE}, @code{TI_DOUBLE_TYPE} or @code{TI_LONG_DOUBLE_TYPE}.\n\
+ The default implementation returns @code{SFmode} for @code{TI_FLOAT_TYPE},\n\
+ and @code{DFmode} for @code{TI_DOUBLE_TYPE} or @code{TI_LONG_DOUBLE_TYPE}.",
+ machine_mode, (enum tree_index ti), default_mode_for_floating_type)
+
 HOOK_VECTOR_END (c)

 /* Functions specific to the C++ frontend.  */
diff --git a/gcc/targhooks.cc b/gcc/targhooks.cc
index fb339bf75dd..5111e069f0c 100644
--- a/gcc/targhooks.cc
+++ b/gcc/targhooks.cc
@@ -298,6 +298,18 @@ default_mode_for_suffix (char suffix ATTRIBUTE_UNUSED)
   return VOIDmode;
 }

+/* Return machine mode for a floating type which is indicated
+   by the given enum tree_index.  */
+
+machine_mode
+default_mode_for_floating_type (enum tree_index ti)
+{
+  if (ti == TI_FLOAT_TYPE)
+    return SFmode;
+  gcc_assert (ti == TI_DOUBLE_TYPE || ti == TI_LONG_DOUBLE_TYPE);
+  return DFmode;
+}
+
 /* The generic C++ ABI specifies this is a 64-bit value.  */
 tree
 default_cxx_guard_type (void)
@@ -449,11 +461,11 @@ default_scalar_mode_supported_p (scalar_mode mode)
       return false;

     case MODE_FLOAT:
-      if (precision == FLOAT_TYPE_SIZE)
+      if (mode == targetm.c.mode_for_floating_type (TI_FLOAT_TYPE))
 	return true;
-      if (precision == DOUBLE_TYPE_SIZE)
+      if (mode == targetm.c.mode_for_floating_type (TI_DOUBLE_TYPE))
 	return true;
-      if (precision == LONG_DOUBLE_TYPE_SIZE)
+      if (mode == targetm.c.mode_for_floating_type (TI_LONG_DOUBLE_TYPE))
 	return true;
       return false;

diff --git a/gcc/targhooks.h b/gcc/targhooks.h
index 85f3817c176..fdc17c3b7c0 100644
--- a/gcc/targhooks.h
+++ b/gcc/targhooks.h
@@ -289,6 +289,7 @@ extern unsigned int default_min_arithmetic_precision (void);
 extern enum flt_eval_method
 default_excess_precision (enum excess_precision_type ATTRIBUTE_UNUSED);
 extern bool default_bitint_type_info (int, struct bitint_info *);
+extern machine_mode default_mode_for_floating_type (enum tree_index);
 extern HOST_WIDE_INT default_stack_clash_protection_alloca_probe_range (void);
 extern void default_select_early_remat_modes (sbitmap);
 extern tree default_preferred_else_value (unsigned, tree, unsigned, tree *);
diff --git a/gcc/tree-core.h b/gcc/tree-core.h
index 9fa74342919..0b5000acb80 100644
--- a/gcc/tree-core.h
+++ b/gcc/tree-core.h
@@ -624,7 +624,7 @@ enum cv_qualifier {
 };

 /* Standard named or nameless data types of the C compiler.  */
-enum tree_index {
+enum tree_index : unsigned {
   TI_ERROR_MARK,
   TI_INTQI_TYPE,
   TI_INTHI_TYPE,
@@ -691,17 +691,18 @@ enum tree_index {
   TI_FLOAT64_TYPE,
   TI_FLOAT128_TYPE,
   TI_FLOATN_TYPE_LAST = TI_FLOAT128_TYPE,
-#define NUM_FLOATN_TYPES (TI_FLOATN_TYPE_LAST - TI_FLOATN_TYPE_FIRST + 1)
+#define NUM_FLOATN_TYPES ((int) (TI_FLOATN_TYPE_LAST		\
+				 - TI_FLOATN_TYPE_FIRST + 1))
   TI_FLOAT32X_TYPE,
   TI_FLOATNX_TYPE_FIRST = TI_FLOAT32X_TYPE,
   TI_FLOAT64X_TYPE,
   TI_FLOAT128X_TYPE,
   TI_FLOATNX_TYPE_LAST = TI_FLOAT128X_TYPE,
   TI_FLOATN_NX_TYPE_LAST = TI_FLOAT128X_TYPE,
-#define NUM_FLOATNX_TYPES (TI_FLOATNX_TYPE_LAST - TI_FLOATNX_TYPE_FIRST + 1)
-#define NUM_FLOATN_NX_TYPES (TI_FLOATN_NX_TYPE_LAST		\
-			     - TI_FLOATN_NX_TYPE_FIRST		\
-			     + 1)
+#define NUM_FLOATNX_TYPES ((int) (TI_FLOATNX_TYPE_LAST		\
+				  - TI_FLOATNX_TYPE_FIRST + 1))
+#define NUM_FLOATN_NX_TYPES ((int) (TI_FLOATN_NX_TYPE_LAST	\
+				  - TI_FLOATN_NX_TYPE_FIRST + 1))

   /* Type used by certain backends for __float128, which in C++ should be
      distinct type from _Float128 for backwards compatibility reasons.  */
diff --git a/gcc/tree.cc b/gcc/tree.cc
index 6564b002dc1..bc5175f591e 100644
--- a/gcc/tree.cc
+++ b/gcc/tree.cc
@@ -9596,15 +9596,27 @@ build_common_tree_nodes (bool signed_char)
   pointer_sized_int_node = build_nonstandard_integer_type (POINTER_SIZE, 1);

   float_type_node = make_node (REAL_TYPE);
-  TYPE_PRECISION (float_type_node) = FLOAT_TYPE_SIZE;
+  machine_mode float_type_mode
+    = targetm.c.mode_for_floating_type (TI_FLOAT_TYPE);
+  SET_TYPE_MODE (float_type_node, float_type_mode);
+  TYPE_PRECISION (float_type_node)
+    = GET_MODE_PRECISION (float_type_mode).to_constant ();
   layout_type (float_type_node);

   double_type_node = make_node (REAL_TYPE);
-  TYPE_PRECISION (double_type_node) = DOUBLE_TYPE_SIZE;
+  machine_mode double_type_mode
+    = targetm.c.mode_for_floating_type (TI_DOUBLE_TYPE);
+  SET_TYPE_MODE (double_type_node, double_type_mode);
+  TYPE_PRECISION (double_type_node)
+    = GET_MODE_PRECISION (double_type_mode).to_constant ();
   layout_type (double_type_node);

   long_double_type_node = make_node (REAL_TYPE);
-  TYPE_PRECISION (long_double_type_node) = LONG_DOUBLE_TYPE_SIZE;
+  machine_mode long_double_type_mode
+    = targetm.c.mode_for_floating_type (TI_LONG_DOUBLE_TYPE);
+  SET_TYPE_MODE (long_double_type_node, long_double_type_mode);
+  TYPE_PRECISION (long_double_type_node)
+    = GET_MODE_PRECISION (long_double_type_mode).to_constant ();
   layout_type (long_double_type_node);

   for (i = 0; i < NUM_FLOATN_NX_TYPES; i++)
--
2.43.0

BR,
Kewen


^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 07/52] darwin: Replace use of LONG_DOUBLE_TYPE_SIZE
  2024-06-03  3:00 ` [PATCH 07/52] darwin: Replace use of LONG_DOUBLE_TYPE_SIZE Kewen Lin
@ 2024-06-04  6:21   ` Iain Sandoe
  2024-06-05  9:29     ` Kewen.Lin
  0 siblings, 1 reply; 149+ messages in thread
From: Iain Sandoe @ 2024-06-04  6:21 UTC (permalink / raw)
  To: Kewen Lin; +Cc: GCC Patches, Mike Stump

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
> 


^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 02/52 v2] d: Replace use of LONG_DOUBLE_TYPE_SIZE
  2024-06-04  3:17         ` [PATCH 02/52 v2] " Kewen.Lin
@ 2024-06-04 11:35           ` Iain Buclaw
  2024-06-05  9:32             ` Kewen.Lin
  0 siblings, 1 reply; 149+ messages in thread
From: Iain Buclaw @ 2024-06-04 11:35 UTC (permalink / raw)
  To: Kewen.Lin; +Cc: gcc-patches

Excerpts from Kewen.Lin's message of Juni 4, 2024 5:17 am:
> Hi Iain,
> 
> on 2024/6/3 22:39, Iain Buclaw wrote:
>> Excerpts from Kewen.Lin's message of Juni 3, 2024 10:57 am:
>>> Hi Iain,
>>>
>>> on 2024/6/3 16:40, Iain Buclaw wrote:
>>>> Excerpts from Kewen Lin's message of Juni 3, 2024 5:00 am:
>>>>> 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 d with
>>>>> TYPE_PRECISION of long_double_type_node.
>>>>>
>>>>> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
>>>>>
>>>>
>>>> Thanks, one question though: Is TYPE_PRECISION really equivalent to
>>>> LONG_DOUBLE_TYPE_SIZE?
>>>
>>> Yes, it's guaranteed by the code in build_common_tree_nodes:
>>>
>>>   long_double_type_node = make_node (REAL_TYPE);
>>>   TYPE_PRECISION (long_double_type_node) = LONG_DOUBLE_TYPE_SIZE;
>>>   layout_type (long_double_type_node);
>>>
>>> , the macro LONG_DOUBLE_TYPE_SIZE is assigned to TYPE_PRECISION of
>>> long_double_type_node, layout_type will only pick up one mode as
>>> the given precision and won't change it.
>>>
>>>>
>>>> Unless LONG_DOUBLE_TYPE_SIZE was poorly named to begin with, I'd assume
>>>> the answer to be "no".
>>>
>>> I'm afraid it's poorly named before.
>>>
>> 
>> Thanks for confirming Kewen.
>> 
>> I suspect then that this code is incorrectly using this macro, and it
>> should instead be using:
>> 
>> int_size_in_bytes(long_double_type_node)
>> 
>> as any padding should be considered as part of the overall type size for
>> the purpose that this field serves in the D part of the front-end.
> 
> Got it, thanks for the explanation and suggestion.
> 
>> 
>> Are you able to update the patch this way instead? Otherwise I'm happy
>> to push the change instead.
> 
> Sure, updated as below:
> 

Thanks!

This is OK to apply any time.

Iain.

^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 50/52] pa: New hook implementation pa_c_mode_for_floating_type
  2024-06-03  3:01 ` [PATCH 50/52] pa: New hook implementation pa_c_mode_for_floating_type Kewen Lin
@ 2024-06-04 18:55   ` John David Anglin
  0 siblings, 0 replies; 149+ messages in thread
From: John David Anglin @ 2024-06-04 18:55 UTC (permalink / raw)
  To: Kewen Lin, gcc-patches; +Cc: jeffreyalaw

Okay.

Dave

On 2024-06-02 11:01 p.m., Kewen Lin wrote:
> This is to add new port specific hook implementation
> pa_c_mode_for_floating_type, as we remove defines in
> defaults.h for {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE, this
> also defines them in pa.h but with PA_ prefix since
> we poison {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE.
>
> gcc/ChangeLog:
>
> 	* config/pa/pa.cc (pa_c_mode_for_floating_type): New function.
> 	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
> 	(pa_scalar_mode_supported_p): Rename FLOAT_TYPE_SIZE to
> 	PA_FLOAT_TYPE_SIZE, rename DOUBLE_TYPE_SIZE to PA_DOUBLE_TYPE_SIZE
> 	and rename LONG_DOUBLE_TYPE_SIZE to PA_LONG_DOUBLE_TYPE_SIZE.
> 	* config/pa/pa.h (PA_FLOAT_TYPE_SIZE): New macro.
> 	(PA_DOUBLE_TYPE_SIZE): Likewise.
> 	(PA_LONG_DOUBLE_TYPE_SIZE): Likewise.
> 	* config/pa/pa-64.h (FLOAT_TYPE_SIZE): Rename to ...
> 	(PA_FLOAT_TYPE_SIZE): ... this.
> 	(DOUBLE_TYPE_SIZE): Rename to ...
> 	(PA_DOUBLE_TYPE_SIZE): ... this.
> 	(LONG_DOUBLE_TYPE_SIZE): Rename to ...
> 	(PA_LONG_DOUBLE_TYPE_SIZE): ... this.
> 	* config/pa/pa-hpux.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
> 	(PA_LONG_DOUBLE_TYPE_SIZE): ... this.
> ---
>   gcc/config/pa/pa-64.h   | 12 ++++++------
>   gcc/config/pa/pa-hpux.h |  3 ++-
>   gcc/config/pa/pa.cc     | 21 ++++++++++++++++++---
>   gcc/config/pa/pa.h      |  6 ++++++
>   4 files changed, 32 insertions(+), 10 deletions(-)
>
> diff --git a/gcc/config/pa/pa-64.h b/gcc/config/pa/pa-64.h
> index ea9d86ee7d4..b676468d2ce 100644
> --- a/gcc/config/pa/pa-64.h
> +++ b/gcc/config/pa/pa-64.h
> @@ -58,12 +58,12 @@ along with GCC; see the file COPYING3.  If not see
>   #define LONG_TYPE_SIZE 64
>   #undef LONG_LONG_TYPE_SIZE
>   #define LONG_LONG_TYPE_SIZE 64
> -#undef FLOAT_TYPE_SIZE
> -#define FLOAT_TYPE_SIZE 32
> -#undef DOUBLE_TYPE_SIZE
> -#define DOUBLE_TYPE_SIZE 64
> -#undef LONG_DOUBLE_TYPE_SIZE
> -#define LONG_DOUBLE_TYPE_SIZE 128
> +#undef PA_FLOAT_TYPE_SIZE
> +#define PA_FLOAT_TYPE_SIZE 32
> +#undef PA_DOUBLE_TYPE_SIZE
> +#define PA_DOUBLE_TYPE_SIZE 64
> +#undef PA_LONG_DOUBLE_TYPE_SIZE
> +#define PA_LONG_DOUBLE_TYPE_SIZE 128
>   
>   /* ?!? This needs to be made compile-time selectable.
>   
> diff --git a/gcc/config/pa/pa-hpux.h b/gcc/config/pa/pa-hpux.h
> index a7421d68ca0..accef447523 100644
> --- a/gcc/config/pa/pa-hpux.h
> +++ b/gcc/config/pa/pa-hpux.h
> @@ -34,7 +34,8 @@ along with GCC; see the file COPYING3.  If not see
>   #define SIZE_TYPE "unsigned int"
>   #define PTRDIFF_TYPE "int"
>   
> -#define LONG_DOUBLE_TYPE_SIZE 128
> +#undef PA_LONG_DOUBLE_TYPE_SIZE
> +#define PA_LONG_DOUBLE_TYPE_SIZE 128
>   #define FLOAT_LIB_COMPARE_RETURNS_BOOL(MODE, COMPARISON) ((MODE) == TFmode)
>   
>   /* GCC always defines __STDC__.  HP C++ compilers don't define it.  This
> diff --git a/gcc/config/pa/pa.cc b/gcc/config/pa/pa.cc
> index a7af6b8c121..ab4bfc5d0c2 100644
> --- a/gcc/config/pa/pa.cc
> +++ b/gcc/config/pa/pa.cc
> @@ -194,6 +194,7 @@ static rtx pa_internal_arg_pointer (void);
>   static bool pa_can_eliminate (const int, const int);
>   static void pa_conditional_register_usage (void);
>   static machine_mode pa_c_mode_for_suffix (char);
> +static machine_mode pa_c_mode_for_floating_type (enum tree_index);
>   static section *pa_function_section (tree, enum node_frequency, bool, bool);
>   static bool pa_cannot_force_const_mem (machine_mode, rtx);
>   static bool pa_legitimate_constant_p (machine_mode, rtx);
> @@ -398,6 +399,8 @@ static size_t n_deferred_plabels = 0;
>   #define TARGET_CONDITIONAL_REGISTER_USAGE pa_conditional_register_usage
>   #undef TARGET_C_MODE_FOR_SUFFIX
>   #define TARGET_C_MODE_FOR_SUFFIX pa_c_mode_for_suffix
> +#undef TARGET_C_MODE_FOR_FLOATING_TYPE
> +#define TARGET_C_MODE_FOR_FLOATING_TYPE pa_c_mode_for_floating_type
>   #undef TARGET_ASM_FUNCTION_SECTION
>   #define TARGET_ASM_FUNCTION_SECTION pa_function_section
>   
> @@ -6728,11 +6731,11 @@ pa_scalar_mode_supported_p (scalar_mode mode)
>         return false;
>   
>       case MODE_FLOAT:
> -      if (precision == FLOAT_TYPE_SIZE)
> +      if (precision == PA_FLOAT_TYPE_SIZE)
>   	return true;
> -      if (precision == DOUBLE_TYPE_SIZE)
> +      if (precision == PA_DOUBLE_TYPE_SIZE)
>   	return true;
> -      if (precision == LONG_DOUBLE_TYPE_SIZE)
> +      if (precision == PA_LONG_DOUBLE_TYPE_SIZE)
>   	return true;
>         return false;
>   
> @@ -10808,6 +10811,18 @@ pa_c_mode_for_suffix (char suffix)
>     return VOIDmode;
>   }
>   
> +/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return TFmode or DFmode
> +   for TI_LONG_DOUBLE_TYPE which is for long double type, go with the
> +   default one for the others.  */
> +
> +static machine_mode
> +pa_c_mode_for_floating_type (enum tree_index ti)
> +{
> +  if (ti == TI_LONG_DOUBLE_TYPE)
> +    return PA_LONG_DOUBLE_TYPE_SIZE == 64 ? DFmode : TFmode;
> +  return default_mode_for_floating_type (ti);
> +}
> +
>   /* Target hook for function_section.  */
>   
>   static section *
> diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h
> index 127a0d1966d..7e45c358895 100644
> --- a/gcc/config/pa/pa.h
> +++ b/gcc/config/pa/pa.h
> @@ -1306,3 +1306,9 @@ do {									     \
>   /* An integer expression for the size in bits of the largest integer machine
>      mode that should actually be used.  We allow pairs of registers.  */
>   #define MAX_FIXED_MODE_SIZE GET_MODE_BITSIZE (TARGET_64BIT ? TImode : DImode)
> +
> +/* Define these macros as default for all subtargets, add PA_ prefix
> +   as {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE get poisoned.  */
> +#define PA_FLOAT_TYPE_SIZE BITS_PER_WORD
> +#define PA_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
> +#define PA_LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)


-- 
John David Anglin  dave.anglin@bell.net


^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 07/52] darwin: Replace use of LONG_DOUBLE_TYPE_SIZE
  2024-06-04  6:21   ` Iain Sandoe
@ 2024-06-05  9:29     ` Kewen.Lin
  0 siblings, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-05  9:29 UTC (permalink / raw)
  To: Iain Sandoe; +Cc: GCC Patches, Mike Stump

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
>>
> 


^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 03/52] fortran: Replace uses of {FLOAT, {, LONG_}DOUBLE}_TYPE_SIZE
  2024-06-03 20:01   ` [PATCH 03/52] fortran: Replace uses of {FLOAT, {, LONG_}DOUBLE}_TYPE_SIZE Harald Anlauf
  2024-06-03 20:01     ` Harald Anlauf
@ 2024-06-05  9:30     ` Kewen.Lin
  1 sibling, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-05  9:30 UTC (permalink / raw)
  To: Harald Anlauf; +Cc: fortran, mikael, gcc-patches

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


^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 02/52 v2] d: Replace use of LONG_DOUBLE_TYPE_SIZE
  2024-06-04 11:35           ` Iain Buclaw
@ 2024-06-05  9:32             ` Kewen.Lin
  0 siblings, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-05  9:32 UTC (permalink / raw)
  To: Iain Buclaw; +Cc: gcc-patches

Hi Iain,

on 2024/6/4 19:35, Iain Buclaw wrote:
> Excerpts from Kewen.Lin's message of Juni 4, 2024 5:17 am:
>> Hi Iain,
>>
>> on 2024/6/3 22:39, Iain Buclaw wrote:
>>> Excerpts from Kewen.Lin's message of Juni 3, 2024 10:57 am:
>>>> Hi Iain,
>>>>
>>>> on 2024/6/3 16:40, Iain Buclaw wrote:
>>>>> Excerpts from Kewen Lin's message of Juni 3, 2024 5:00 am:
>>>>>> 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 d with
>>>>>> TYPE_PRECISION of long_double_type_node.
>>>>>>
>>>>>> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
>>>>>>
>>>>>
>>>>> Thanks, one question though: Is TYPE_PRECISION really equivalent to
>>>>> LONG_DOUBLE_TYPE_SIZE?
>>>>
>>>> Yes, it's guaranteed by the code in build_common_tree_nodes:
>>>>
>>>>   long_double_type_node = make_node (REAL_TYPE);
>>>>   TYPE_PRECISION (long_double_type_node) = LONG_DOUBLE_TYPE_SIZE;
>>>>   layout_type (long_double_type_node);
>>>>
>>>> , the macro LONG_DOUBLE_TYPE_SIZE is assigned to TYPE_PRECISION of
>>>> long_double_type_node, layout_type will only pick up one mode as
>>>> the given precision and won't change it.
>>>>
>>>>>
>>>>> Unless LONG_DOUBLE_TYPE_SIZE was poorly named to begin with, I'd assume
>>>>> the answer to be "no".
>>>>
>>>> I'm afraid it's poorly named before.
>>>>
>>>
>>> Thanks for confirming Kewen.
>>>
>>> I suspect then that this code is incorrectly using this macro, and it
>>> should instead be using:
>>>
>>> int_size_in_bytes(long_double_type_node)
>>>
>>> as any padding should be considered as part of the overall type size for
>>> the purpose that this field serves in the D part of the front-end.
>>
>> Got it, thanks for the explanation and suggestion.
>>
>>>
>>> Are you able to update the patch this way instead? Otherwise I'm happy
>>> to push the change instead.
>>
>> Sure, updated as below:
>>
> 
> Thanks!
> 
> This is OK to apply any time.

Pushed as r15-1032, thanks!

BR,
Kewen


^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 01/52] ada: Replace use of LONG_DOUBLE_TYPE_SIZE
  2024-06-03  8:51   ` Eric Botcazou
@ 2024-06-05  9:32     ` Kewen.Lin
  0 siblings, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-05  9:32 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: gcc-patches, charlet, poulhies, derodat

Hi Eric,

on 2024/6/3 16:51, Eric Botcazou 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 ada
>> with TYPE_PRECISION of long_double_type_node.
>>
>> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
>>
>> gcc/ada/ChangeLog:
>>
>> 	* gcc-interface/decl.cc (gnat_to_gnu_entity): Use TYPE_PRECISION of
>> 	long_double_type_node to replace LONG_DOUBLE_TYPE_SIZE.
> 
> OK, thanks.
> 

Pushed as r15-1031, thanks!

BR,
Kewen


^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 06/52] m2: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  2024-06-04  3:19     ` Kewen.Lin
@ 2024-06-05 14:22       ` Gaius Mulley
  2024-06-06  5:15         ` Kewen.Lin
  0 siblings, 1 reply; 149+ messages in thread
From: Gaius Mulley @ 2024-06-05 14:22 UTC (permalink / raw)
  To: Kewen.Lin; +Cc: Joseph Myers, gcc-patches

"Kewen.Lin" <linkw@linux.ibm.com> writes:

> Hi Joseph and Gaius,
>
> on 2024/6/4 02:02, Joseph Myers wrote:
>> On Sun, 2 Jun 2024, Kewen Lin wrote:
>> 
>>> diff --git a/gcc/m2/gm2-gcc/m2type.cc b/gcc/m2/gm2-gcc/m2type.cc
>>> index 571923c08ef..d52cbdf0b99 100644
>>> --- a/gcc/m2/gm2-gcc/m2type.cc
>>> +++ b/gcc/m2/gm2-gcc/m2type.cc
>>> @@ -1420,7 +1420,7 @@ build_m2_short_real_node (void)
>>>    /* Define `REAL'.  */
>>>  
>>>    c = make_node (REAL_TYPE);
>>> -  TYPE_PRECISION (c) = FLOAT_TYPE_SIZE;
>>> +  TYPE_PRECISION (c) = TYPE_PRECISION (float_type_node);
>>>    layout_type (c);
>>>    return c;
>>>  }
>>> @@ -1433,7 +1433,7 @@ build_m2_real_node (void)
>>>    /* Define `REAL'.  */
>>>  
>>>    c = make_node (REAL_TYPE);
>>> -  TYPE_PRECISION (c) = DOUBLE_TYPE_SIZE;
>>> +  TYPE_PRECISION (c) = TYPE_PRECISION (double_type_node);
>>>    layout_type (c);
>>>    return c;
>>>  }
>>> @@ -1447,7 +1447,7 @@ build_m2_long_real_node (void)
>>>    if (M2Options_GetIBMLongDouble ())
>>>      {
>>>        longreal = make_node (REAL_TYPE);
>>> -      TYPE_PRECISION (longreal) = LONG_DOUBLE_TYPE_SIZE;
>>> +      TYPE_PRECISION (longreal) = TYPE_PRECISION (long_double_type_node);
>> 
>> This looks rather like m2 would still have the same problem the generic 
>> code previously had: going via precision when that might not uniquely 
>> determine the desired machine mode.  And so making sure to use the right 
>> machine mode as done when setting up long_double_type_node etc. would be 
>> better than keeping this code copying TYPE_PRECISION and hoping to 
>> determine a machine mode from that.  It certainly looks like this code 
>> wants to match float, double and long double, rather than possibly getting 
>> a different mode with possibly the same TYPE_PRECISION.
>
> Good point, sorry that I just did a replacement without checking the context.
> If the above holds (Gaius can confirm or clarify), SET_TYPE_MODE would be
> also applied here, that is:

Hi Kewen and Joseph,

yes the code is attempting to create nodes SHORTREAL, REAL, LONGREAL
mapping onto the C float, double, long double nodes.

> diff --git a/gcc/m2/gm2-gcc/m2type.cc b/gcc/m2/gm2-gcc/m2type.cc
> index d52cbdf0b99..5ff02a18876 100644
> --- a/gcc/m2/gm2-gcc/m2type.cc
> +++ b/gcc/m2/gm2-gcc/m2type.cc
> @@ -1421,6 +1421,7 @@ build_m2_short_real_node (void)
>
>    c = make_node (REAL_TYPE);
>    TYPE_PRECISION (c) = TYPE_PRECISION (float_type_node);
> +  SET_TYPE_MODE (c, TYPE_MODE (float_type_node));
>    layout_type (c);
>    return c;
>  }
> @@ -1434,6 +1435,7 @@ build_m2_real_node (void)
>
>    c = make_node (REAL_TYPE);
>    TYPE_PRECISION (c) = TYPE_PRECISION (double_type_node);
> +  SET_TYPE_MODE (c, TYPE_MODE (double_type_node));
>    layout_type (c);
>    return c;
>  }
>
> I'm not sure and curious why the above builds new nodes for short real and
> real but re-use float128_type_node or long_double_type_node for some cases,
> some special needs cause the former ones should have separated nodes?

good point - there is no need to create new nodes.

>> (I don't know if the M2Options_GetIBMLongDouble call would be needed at 
>> all once you use the machine mode for long double in a reliable way, or 
>> whether this code could be further simplified.)
>
> long_double_type_node should already take care of ibmlongdouble, IIUC it
> would be like:
>
> @@ -1443,13 +1445,7 @@ build_m2_long_real_node (void)
>  {
>    tree longreal;
>
> -  /* Define `LONGREAL'.  */
> -  if (M2Options_GetIBMLongDouble ())
> -    {
> -      longreal = make_node (REAL_TYPE);
> -      TYPE_PRECISION (longreal) = TYPE_PRECISION (long_double_type_node);
> -    }
> -  else if (M2Options_GetIEEELongDouble ())
> +  if (M2Options_GetIEEELongDouble ())
>      longreal = float128_type_node;
>    else
>      longreal = long_double_type_node;

yes indeed and the above patch is fine, all bootstrapped and regression
tested on ppc64le (cfarm120).  I've also bootstrapped and regression tested
the following patch on ppc64le and aarch64:

diff --git a/gcc/m2/gm2-gcc/m2type.cc b/gcc/m2/gm2-gcc/m2type.cc
index 571923c08ef..ce53130e2a9 100644
--- a/gcc/m2/gm2-gcc/m2type.cc
+++ b/gcc/m2/gm2-gcc/m2type.cc
@@ -1415,41 +1415,26 @@ build_m2_char_node (void)
 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);
+  return float_type_node;
 }
 
 static tree
 build_m2_real_node (void)
 {
-  tree c;
-
   /* Define `REAL'.  */
-
-  c = make_node (REAL_TYPE);
-  TYPE_PRECISION (c) = DOUBLE_TYPE_SIZE;
-  layout_type (c);
-  return c;
+  layout_type (double_type_node);
+  return double_type_node;
 }
 
 static tree
 build_m2_long_real_node (void)
 {
   tree longreal;
-
+  
   /* Define `LONGREAL'.  */
-  if (M2Options_GetIBMLongDouble ())
-    {
-      longreal = make_node (REAL_TYPE);
-      TYPE_PRECISION (longreal) = LONG_DOUBLE_TYPE_SIZE;
-    }
-  else if (M2Options_GetIEEELongDouble ())
+  if (M2Options_GetIEEELongDouble ())
     longreal = float128_type_node;
   else
     longreal = long_double_type_node;


regards,
Gaius


^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 23/52] mmix: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:01 ` [PATCH 23/52] mmix: " Kewen Lin
@ 2024-06-06  1:41   ` Hans-Peter Nilsson
  2024-06-06  2:11     ` Kewen.Lin
  0 siblings, 1 reply; 149+ messages in thread
From: Hans-Peter Nilsson @ 2024-06-06  1:41 UTC (permalink / raw)
  To: Kewen Lin; +Cc: gcc-patches

On Sun, 2 Jun 2024, Kewen Lin wrote:

> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in mmix port.

This is fine once prerequisites are in place.

If I may add a nit: In these target change commit messages, add 
a hint as to which defaulted hook or macro the removed macro now 
corresponds to, like "these now correspond to the default values 
of the new target hook mode_for_floating_type".  Else when doing 
port archaeology, from the commit message it looks like the 
context has not changed, you just removed some definitions.

> 
> gcc/ChangeLog:
> 
> 	* config/mmix/mmix.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.
> ---
>  gcc/config/mmix/mmix.h | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/gcc/config/mmix/mmix.h b/gcc/config/mmix/mmix.h
> index c3c5a2a69c9..e20bca1d363 100644
> --- a/gcc/config/mmix/mmix.h
> +++ b/gcc/config/mmix/mmix.h
> @@ -195,10 +195,6 @@ struct GTY(()) machine_function
>  #define SHORT_TYPE_SIZE 16
>  #define LONG_LONG_TYPE_SIZE 64
>  
> -#define FLOAT_TYPE_SIZE 32
> -#define DOUBLE_TYPE_SIZE 64
> -#define LONG_DOUBLE_TYPE_SIZE 64
> -
>  #define DEFAULT_SIGNED_CHAR 1
>  
>  
> -- 
> 2.43.0
> 
> 

^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 23/52] mmix: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-06  1:41   ` Hans-Peter Nilsson
@ 2024-06-06  2:11     ` Kewen.Lin
  0 siblings, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-06  2:11 UTC (permalink / raw)
  To: Hans-Peter Nilsson; +Cc: gcc-patches

Hi Hans-Peter,

on 2024/6/6 09:41, Hans-Peter Nilsson wrote:
> On Sun, 2 Jun 2024, Kewen Lin wrote:
> 
>> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
>> defines in mmix port.
> 
> This is fine once prerequisites are in place.
> 
> If I may add a nit: In these target change commit messages, add 
> a hint as to which defaulted hook or macro the removed macro now 
> corresponds to, like "these now correspond to the default values 
> of the new target hook mode_for_floating_type".  Else when doing 
> port archaeology, from the commit message it looks like the 
> context has not changed, you just removed some definitions.

Thanks for the comments!  Sorry I didn't point out that once all
sub-patches after 09/52 are approved, I'll squash all port specific
sub-patches (after 09/52) onto 09/52, as that one poisoned these
macros and all sub-patches after that can not be committed separately.
As they would be in the same commit eventually, I think the context
would not be the concern then.

BR,
Kewen

> 
>>
>> gcc/ChangeLog:
>>
>> 	* config/mmix/mmix.h (FLOAT_TYPE_SIZE): Remove.
>> 	(DOUBLE_TYPE_SIZE): Likewise.
>> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.
>> ---
>>  gcc/config/mmix/mmix.h | 4 ----
>>  1 file changed, 4 deletions(-)
>>
>> diff --git a/gcc/config/mmix/mmix.h b/gcc/config/mmix/mmix.h
>> index c3c5a2a69c9..e20bca1d363 100644
>> --- a/gcc/config/mmix/mmix.h
>> +++ b/gcc/config/mmix/mmix.h
>> @@ -195,10 +195,6 @@ struct GTY(()) machine_function
>>  #define SHORT_TYPE_SIZE 16
>>  #define LONG_LONG_TYPE_SIZE 64
>>  
>> -#define FLOAT_TYPE_SIZE 32
>> -#define DOUBLE_TYPE_SIZE 64
>> -#define LONG_DOUBLE_TYPE_SIZE 64
>> -
>>  #define DEFAULT_SIGNED_CHAR 1
>>  
>>  
>> -- 
>> 2.43.0
>>
>>


^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 06/52] m2: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  2024-06-05 14:22       ` Gaius Mulley
@ 2024-06-06  5:15         ` Kewen.Lin
  2024-06-06 18:31           ` Gaius Mulley
  2024-06-12  9:31           ` Kewen.Lin
  0 siblings, 2 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-06  5:15 UTC (permalink / raw)
  To: Gaius Mulley; +Cc: Joseph Myers, gcc-patches

Hi Gaius,

on 2024/6/5 22:22, Gaius Mulley wrote:
> "Kewen.Lin" <linkw@linux.ibm.com> writes:
> 
>> Hi Joseph and Gaius,
>>
>> on 2024/6/4 02:02, Joseph Myers wrote:
>>> On Sun, 2 Jun 2024, Kewen Lin wrote:
>>>
>>>> diff --git a/gcc/m2/gm2-gcc/m2type.cc b/gcc/m2/gm2-gcc/m2type.cc
>>>> index 571923c08ef..d52cbdf0b99 100644
>>>> --- a/gcc/m2/gm2-gcc/m2type.cc
>>>> +++ b/gcc/m2/gm2-gcc/m2type.cc
>>>> @@ -1420,7 +1420,7 @@ build_m2_short_real_node (void)
>>>>    /* Define `REAL'.  */
>>>>  
>>>>    c = make_node (REAL_TYPE);
>>>> -  TYPE_PRECISION (c) = FLOAT_TYPE_SIZE;
>>>> +  TYPE_PRECISION (c) = TYPE_PRECISION (float_type_node);
>>>>    layout_type (c);
>>>>    return c;
>>>>  }
>>>> @@ -1433,7 +1433,7 @@ build_m2_real_node (void)
>>>>    /* Define `REAL'.  */
>>>>  
>>>>    c = make_node (REAL_TYPE);
>>>> -  TYPE_PRECISION (c) = DOUBLE_TYPE_SIZE;
>>>> +  TYPE_PRECISION (c) = TYPE_PRECISION (double_type_node);
>>>>    layout_type (c);
>>>>    return c;
>>>>  }
>>>> @@ -1447,7 +1447,7 @@ build_m2_long_real_node (void)
>>>>    if (M2Options_GetIBMLongDouble ())
>>>>      {
>>>>        longreal = make_node (REAL_TYPE);
>>>> -      TYPE_PRECISION (longreal) = LONG_DOUBLE_TYPE_SIZE;
>>>> +      TYPE_PRECISION (longreal) = TYPE_PRECISION (long_double_type_node);
>>>
>>> This looks rather like m2 would still have the same problem the generic 
>>> code previously had: going via precision when that might not uniquely 
>>> determine the desired machine mode.  And so making sure to use the right 
>>> machine mode as done when setting up long_double_type_node etc. would be 
>>> better than keeping this code copying TYPE_PRECISION and hoping to 
>>> determine a machine mode from that.  It certainly looks like this code 
>>> wants to match float, double and long double, rather than possibly getting 
>>> a different mode with possibly the same TYPE_PRECISION.
>>
>> Good point, sorry that I just did a replacement without checking the context.
>> If the above holds (Gaius can confirm or clarify), SET_TYPE_MODE would be
>> also applied here, that is:
> 
> Hi Kewen and Joseph,
> 
> yes the code is attempting to create nodes SHORTREAL, REAL, LONGREAL
> mapping onto the C float, double, long double nodes.
> 
>> diff --git a/gcc/m2/gm2-gcc/m2type.cc b/gcc/m2/gm2-gcc/m2type.cc
>> index d52cbdf0b99..5ff02a18876 100644
>> --- a/gcc/m2/gm2-gcc/m2type.cc
>> +++ b/gcc/m2/gm2-gcc/m2type.cc
>> @@ -1421,6 +1421,7 @@ build_m2_short_real_node (void)
>>
>>    c = make_node (REAL_TYPE);
>>    TYPE_PRECISION (c) = TYPE_PRECISION (float_type_node);
>> +  SET_TYPE_MODE (c, TYPE_MODE (float_type_node));
>>    layout_type (c);
>>    return c;
>>  }
>> @@ -1434,6 +1435,7 @@ build_m2_real_node (void)
>>
>>    c = make_node (REAL_TYPE);
>>    TYPE_PRECISION (c) = TYPE_PRECISION (double_type_node);
>> +  SET_TYPE_MODE (c, TYPE_MODE (double_type_node));
>>    layout_type (c);
>>    return c;
>>  }
>>
>> I'm not sure and curious why the above builds new nodes for short real and
>> real but re-use float128_type_node or long_double_type_node for some cases,
>> some special needs cause the former ones should have separated nodes?
> 
> good point - there is no need to create new nodes.

ah, ok, thanks for clarifying!

> 
>>> (I don't know if the M2Options_GetIBMLongDouble call would be needed at 
>>> all once you use the machine mode for long double in a reliable way, or 
>>> whether this code could be further simplified.)
>>
>> long_double_type_node should already take care of ibmlongdouble, IIUC it
>> would be like:
>>
>> @@ -1443,13 +1445,7 @@ build_m2_long_real_node (void)
>>  {
>>    tree longreal;
>>
>> -  /* Define `LONGREAL'.  */
>> -  if (M2Options_GetIBMLongDouble ())
>> -    {
>> -      longreal = make_node (REAL_TYPE);
>> -      TYPE_PRECISION (longreal) = TYPE_PRECISION (long_double_type_node);
>> -    }
>> -  else if (M2Options_GetIEEELongDouble ())
>> +  if (M2Options_GetIEEELongDouble ())
>>      longreal = float128_type_node;
>>    else
>>      longreal = long_double_type_node;
> 
> yes indeed and the above patch is fine, all bootstrapped and regression
> tested on ppc64le (cfarm120).  I've also bootstrapped and regression tested
> the following patch on ppc64le and aarch64:

Nice!  Looking forward to you pushing this new one (I'm withdrawing the original
patch).

> 
> diff --git a/gcc/m2/gm2-gcc/m2type.cc b/gcc/m2/gm2-gcc/m2type.cc
> index 571923c08ef..ce53130e2a9 100644
> --- a/gcc/m2/gm2-gcc/m2type.cc
> +++ b/gcc/m2/gm2-gcc/m2type.cc
> @@ -1415,41 +1415,26 @@ build_m2_char_node (void)
>  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.

BR,
Kewen

> +  return float_type_node;
>  }
>  
>  static tree
>  build_m2_real_node (void)
>  {
> -  tree c;
> -
>    /* Define `REAL'.  */
> -
> -  c = make_node (REAL_TYPE);
> -  TYPE_PRECISION (c) = DOUBLE_TYPE_SIZE;
> -  layout_type (c);
> -  return c;
> +  layout_type (double_type_node);
> +  return double_type_node;
>  }
>  
>  static tree
>  build_m2_long_real_node (void)
>  {
>    tree longreal;
> -
> +  
>    /* Define `LONGREAL'.  */
> -  if (M2Options_GetIBMLongDouble ())
> -    {
> -      longreal = make_node (REAL_TYPE);
> -      TYPE_PRECISION (longreal) = LONG_DOUBLE_TYPE_SIZE;
> -    }
> -  else if (M2Options_GetIEEELongDouble ())
> +  if (M2Options_GetIEEELongDouble ())
>      longreal = float128_type_node;
>    else
>      longreal = long_double_type_node;
> 
> 
> regards,
> Gaius
> 


^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 27/52] nios2: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:01 ` [PATCH 27/52] nios2: " Kewen Lin
@ 2024-06-06 16:23   ` Sandra Loosemore
  0 siblings, 0 replies; 149+ messages in thread
From: Sandra Loosemore @ 2024-06-06 16:23 UTC (permalink / raw)
  To: Kewen Lin, gcc-patches; +Cc: cltang

On 6/2/24 21:01, Kewen Lin wrote:
> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in nios2 port.
> 
> gcc/ChangeLog:
> 
> 	* config/nios2/nios2.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.

Fine with me, but somewhat redundant since I'm still planning to remove 
the entire nios2 back end this release cycle.

-Sandra


^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 06/52] m2: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  2024-06-06  5:15         ` Kewen.Lin
@ 2024-06-06 18:31           ` Gaius Mulley
  2024-06-12  9:31           ` Kewen.Lin
  1 sibling, 0 replies; 149+ messages in thread
From: Gaius Mulley @ 2024-06-06 18:31 UTC (permalink / raw)
  To: Kewen.Lin; +Cc: Joseph Myers, gcc-patches

"Kewen.Lin" <linkw@linux.ibm.com> writes:

Hi Kewen,

> Nice!  Looking forward to you pushing this new one (I'm withdrawing the original
> patch).

all pushed now - thanks for the original patch!

regards,
Gaius

^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 06/52] m2: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  2024-06-06  5:15         ` Kewen.Lin
  2024-06-06 18:31           ` Gaius Mulley
@ 2024-06-12  9:31           ` Kewen.Lin
  2024-06-15  5:00             ` Gaius Mulley
  1 sibling, 1 reply; 149+ messages in thread
From: Kewen.Lin @ 2024-06-12  9:31 UTC (permalink / raw)
  To: Gaius Mulley; +Cc: Joseph Myers, gcc-patches

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?

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

^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 04/52] go: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 ` [PATCH 04/52] go: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE Kewen Lin
@ 2024-06-12  9:33   ` Kewen.Lin
  2024-06-12 12:32     ` Ian Lance Taylor
  0 siblings, 1 reply; 149+ messages in thread
From: Kewen.Lin @ 2024-06-12  9:33 UTC (permalink / raw)
  To: gcc-patches; +Cc: ian, Ian Lance Taylor

Hi,

Gentle ping:

https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653387.html

BR,
Kewen

on 2024/6/3 11:00, Kewen Lin 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 {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> in go with TYPE_PRECISION of {float,{,long_}double}_type_node.
> 
> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
> 
> gcc/go/ChangeLog:
> 
> 	* go-gcc.cc (Gcc_backend::float_type): Use TYPE_PRECISION of
> 	{float,double,long_double}_type_node to replace
> 	{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE.
> 	(Gcc_backend::complex_type): Likewise.
> ---
>  gcc/go/go-gcc.cc | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/gcc/go/go-gcc.cc b/gcc/go/go-gcc.cc
> index bc9732c3db3..6aa751f9f30 100644
> --- a/gcc/go/go-gcc.cc
> +++ b/gcc/go/go-gcc.cc
> @@ -993,11 +993,11 @@ Btype*
>  Gcc_backend::float_type(int bits)
>  {
>    tree type;
> -  if (bits == FLOAT_TYPE_SIZE)
> +  if (bits == TYPE_PRECISION (float_type_node))
>      type = float_type_node;
> -  else if (bits == DOUBLE_TYPE_SIZE)
> +  else if (bits == TYPE_PRECISION (double_type_node))
>      type = double_type_node;
> -  else if (bits == LONG_DOUBLE_TYPE_SIZE)
> +  else if (bits == TYPE_PRECISION (long_double_type_node))
>      type = long_double_type_node;
>    else
>      {
> @@ -1014,11 +1014,11 @@ Btype*
>  Gcc_backend::complex_type(int bits)
>  {
>    tree type;
> -  if (bits == FLOAT_TYPE_SIZE * 2)
> +  if (bits == TYPE_PRECISION (float_type_node) * 2)
>      type = complex_float_type_node;
> -  else if (bits == DOUBLE_TYPE_SIZE * 2)
> +  else if (bits == TYPE_PRECISION (double_type_node) * 2)
>      type = complex_double_type_node;
> -  else if (bits == LONG_DOUBLE_TYPE_SIZE * 2)
> +  else if (bits == TYPE_PRECISION (long_double_type_node) * 2)
>      type = complex_long_double_type_node;
>    else
>      {


^ permalink raw reply	[flat|nested] 149+ messages in thread

* PING^1 [PATCH 05/52] rust: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 ` [PATCH 05/52] rust: " Kewen Lin
@ 2024-06-12  9:35   ` Kewen.Lin
  2024-06-21  1:48     ` PING^2 " Kewen.Lin
  2024-06-21 10:17   ` Arthur Cohen
  1 sibling, 1 reply; 149+ messages in thread
From: Kewen.Lin @ 2024-06-12  9:35 UTC (permalink / raw)
  To: gcc-patches; +Cc: arthur.cohen, herron.philip, gcc-rust

Hi,

Gentle ping:

https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653339.html

BR,
Kewen

on 2024/6/3 11:00, Kewen Lin 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 {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> in rust with TYPE_PRECISION of {float,{,long_}double}_type_node.
> 
> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
> 
> gcc/rust/ChangeLog:
> 
> 	* rust-gcc.cc (float_type): Use TYPE_PRECISION of
> 	{float,double,long_double}_type_node to replace
> 	{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE.
> ---
>  gcc/rust/rust-gcc.cc | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
> index f17e19a2dfc..38169c08985 100644
> --- a/gcc/rust/rust-gcc.cc
> +++ b/gcc/rust/rust-gcc.cc
> @@ -411,11 +411,11 @@ tree
>  float_type (int bits)
>  {
>    tree type;
> -  if (bits == FLOAT_TYPE_SIZE)
> +  if (bits == TYPE_PRECISION (float_type_node))
>      type = float_type_node;
> -  else if (bits == DOUBLE_TYPE_SIZE)
> +  else if (bits == TYPE_PRECISION (double_type_node))
>      type = double_type_node;
> -  else if (bits == LONG_DOUBLE_TYPE_SIZE)
> +  else if (bits == TYPE_PRECISION (long_double_type_node))
>      type = long_double_type_node;
>    else
>      {


^ permalink raw reply	[flat|nested] 149+ messages in thread

* PING^1 [PATCH 08/52] vms: Replace use of LONG_DOUBLE_TYPE_SIZE
  2024-06-03  3:00 ` [PATCH 08/52] vms: " Kewen Lin
@ 2024-06-12  9:36   ` Kewen.Lin
  0 siblings, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-12  9:36 UTC (permalink / raw)
  To: gcc-patches; +Cc: douglas.b.rupp, tgingold

Hi,

Gentle ping:

https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653342.html

BR,
Kewen

on 2024/6/3 11:00, Kewen Lin 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 vms port
> with TYPE_PRECISION of long_double_type_node.
> 
> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
> 
> gcc/ChangeLog:
> 
> 	* config/vms/vms.cc (vms_patch_builtins): Use TYPE_PRECISION of
> 	long_double_type_node to replace LONG_DOUBLE_TYPE_SIZE.
> ---
>  gcc/config/vms/vms.cc | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/gcc/config/vms/vms.cc b/gcc/config/vms/vms.cc
> index d468c79e559..2fcc673c8a9 100644
> --- a/gcc/config/vms/vms.cc
> +++ b/gcc/config/vms/vms.cc
> @@ -141,6 +141,7 @@ vms_patch_builtins (void)
>    if (builtin_decl_implicit_p (BUILT_IN_FWRITE_UNLOCKED))
>      set_builtin_decl_implicit_p (BUILT_IN_FWRITE_UNLOCKED, false);
>  
> +  unsigned long_double_type_size = TYPE_PRECISION (long_double_type_node);
>    /* Define aliases for names.  */
>    for (i = 0; i < NBR_CRTL_NAMES; i++)
>      {
> @@ -179,7 +180,7 @@ vms_patch_builtins (void)
>  	  vms_add_crtl_xlat (alt, nlen + 1, res, rlen);
>  
>  	  /* Long double version.  */
> -	  res[rlen - 1] = (LONG_DOUBLE_TYPE_SIZE == 128 ? 'X' : 'T');
> +	  res[rlen - 1] = (long_double_type_size == 128 ? 'X' : 'T');
>  	  alt[nlen] = 'l';
>  	  vms_add_crtl_xlat (alt, nlen + 1, res, rlen);
>  
> @@ -223,7 +224,7 @@ vms_patch_builtins (void)
>        if (n->flags & VMS_CRTL_FLOAT64)
>          res[rlen++] = 't';
>  
> -      if ((n->flags & VMS_CRTL_FLOAT128) && LONG_DOUBLE_TYPE_SIZE == 128)
> +      if ((n->flags & VMS_CRTL_FLOAT128) && long_double_type_size == 128)
>          res[rlen++] = 'x';
>  
>        memcpy (res + rlen, n->name, nlen);


^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 04/52] go: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  2024-06-12  9:33   ` Kewen.Lin
@ 2024-06-12 12:32     ` Ian Lance Taylor
  2024-06-25  5:38       ` Kewen.Lin
  0 siblings, 1 reply; 149+ messages in thread
From: Ian Lance Taylor @ 2024-06-12 12:32 UTC (permalink / raw)
  To: Kewen.Lin; +Cc: gcc-patches, Ian Lance Taylor

"Kewen.Lin" <linkw@linux.ibm.com> writes:

> Hi,
>
> Gentle ping:
>
> https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653387.html
>
> BR,
> Kewen
>
> on 2024/6/3 11:00, Kewen Lin 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 {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
>> in go with TYPE_PRECISION of {float,{,long_}double}_type_node.
>> 
>> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
>> 
>> gcc/go/ChangeLog:
>> 
>> 	* go-gcc.cc (Gcc_backend::float_type): Use TYPE_PRECISION of
>> 	{float,double,long_double}_type_node to replace
>> 	{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE.
>> 	(Gcc_backend::complex_type): Likewise.

This is fine if the other parts of the patch are accepted.

Thanks.

Ian

^ permalink raw reply	[flat|nested] 149+ messages in thread

* PING^1 [PATCH 10/52] jit: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  2024-06-03  3:01 ` [PATCH 10/52] jit: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE Kewen Lin
@ 2024-06-13  7:14   ` Kewen.Lin
  2024-06-13 13:44   ` David Malcolm
  1 sibling, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-13  7:14 UTC (permalink / raw)
  To: gcc-patches; +Cc: dmalcolm

Hi,

Gentle ping:

https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653346.html

BR,
Kewen

on 2024/6/3 11:01, Kewen Lin 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.  Unlike the other FEs, for the
> uses in recording::memento_of_get_type::get_size, since
> {float,{,long_}double}_type_node haven't been initialized
> yet, this is to replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> with calling hook targetm.c.mode_for_floating_type.
> 
> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
> 
> gcc/jit/ChangeLog:
> 
> 	* jit-recording.cc (recording::memento_of_get_type::get_size): Update
> 	macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE by calling
> 	targetm.c.mode_for_floating_type with
> 	TI_{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE.
> ---
>  gcc/jit/jit-recording.cc | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc
> index 68a2e860c1f..7719b898e57 100644
> --- a/gcc/jit/jit-recording.cc
> +++ b/gcc/jit/jit-recording.cc
> @@ -21,7 +21,7 @@ along with GCC; see the file COPYING3.  If not see
>  #include "config.h"
>  #include "system.h"
>  #include "coretypes.h"
> -#include "tm.h"
> +#include "target.h"
>  #include "pretty-print.h"
>  #include "toplev.h"
>  
> @@ -2353,6 +2353,7 @@ size_t
>  recording::memento_of_get_type::get_size ()
>  {
>    int size;
> +  machine_mode m;
>    switch (m_kind)
>      {
>      case GCC_JIT_TYPE_VOID:
> @@ -2399,13 +2400,16 @@ recording::memento_of_get_type::get_size ()
>        size = 128;
>        break;
>      case GCC_JIT_TYPE_FLOAT:
> -      size = FLOAT_TYPE_SIZE;
> +      m = targetm.c.mode_for_floating_type (TI_FLOAT_TYPE);
> +      size = GET_MODE_PRECISION (m).to_constant ();
>        break;
>      case GCC_JIT_TYPE_DOUBLE:
> -      size = DOUBLE_TYPE_SIZE;
> +      m = targetm.c.mode_for_floating_type (TI_DOUBLE_TYPE);
> +      size = GET_MODE_PRECISION (m).to_constant ();
>        break;
>      case GCC_JIT_TYPE_LONG_DOUBLE:
> -      size = LONG_DOUBLE_TYPE_SIZE;
> +      m = targetm.c.mode_for_floating_type (TI_LONG_DOUBLE_TYPE);
> +      size = GET_MODE_PRECISION (m).to_constant ();
>        break;
>      case GCC_JIT_TYPE_SIZE_T:
>        size = MAX_BITS_PER_WORD;


^ permalink raw reply	[flat|nested] 149+ messages in thread

* PING^1 [PATCH 11/52] arc: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:01 ` [PATCH 11/52] arc: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE Kewen Lin
@ 2024-06-13  7:14   ` Kewen.Lin
  0 siblings, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-13  7:14 UTC (permalink / raw)
  To: gcc-patches; +Cc: claziss, claziss

Hi,

Gentle ping:

https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653345.html

BR,
Kewen

on 2024/6/3 11:01, Kewen Lin wrote:
> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in arc port.
> 
> gcc/ChangeLog:
> 
> 	* config/arc/arc.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.
> ---
>  gcc/config/arc/arc.h | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/gcc/config/arc/arc.h b/gcc/config/arc/arc.h
> index f3b43882671..0a1ecb71d89 100644
> --- a/gcc/config/arc/arc.h
> +++ b/gcc/config/arc/arc.h
> @@ -296,9 +296,6 @@ if (GET_MODE_CLASS (MODE) == MODE_INT		\
>  #define INT_TYPE_SIZE		32
>  #define LONG_TYPE_SIZE		32
>  #define LONG_LONG_TYPE_SIZE	64
> -#define FLOAT_TYPE_SIZE		32
> -#define DOUBLE_TYPE_SIZE	64
> -#define LONG_DOUBLE_TYPE_SIZE	64
>  
>  /* Define this as 1 if `char' should by default be signed; else as 0.  */
>  #define DEFAULT_SIGNED_CHAR 0

^ permalink raw reply	[flat|nested] 149+ messages in thread

* PING^1 [PATCH 12/52] bpf: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:01 ` [PATCH 12/52] bpf: " Kewen Lin
@ 2024-06-13  7:15   ` Kewen.Lin
  0 siblings, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-13  7:15 UTC (permalink / raw)
  To: gcc-patches; +Cc: jose.marchesi, david.faust

Hi,

Gentle ping:

https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653343.html

BR,
Kewen

on 2024/6/3 11:01, Kewen Lin wrote:
> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in bpf port.
> 
> gcc/ChangeLog:
> 
> 	* config/bpf/bpf.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.
> ---
>  gcc/config/bpf/bpf.h | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/gcc/config/bpf/bpf.h b/gcc/config/bpf/bpf.h
> index e163fbf688d..2298e5b05af 100644
> --- a/gcc/config/bpf/bpf.h
> +++ b/gcc/config/bpf/bpf.h
> @@ -90,9 +90,6 @@
>  #define LONG_TYPE_SIZE        64
>  #define LONG_LONG_TYPE_SIZE   64
>  #define CHAR_TYPE_SIZE         8
> -#define FLOAT_TYPE_SIZE       32
> -#define DOUBLE_TYPE_SIZE      64
> -#define LONG_DOUBLE_TYPE_SIZE 64
>  
>  #define INTPTR_TYPE	"long int"
>  #define UINTPTR_TYPE	"long unsigned int"




^ permalink raw reply	[flat|nested] 149+ messages in thread

* PING^1 [PATCH 13/52] epiphany: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:01 ` [PATCH 13/52] epiphany: " Kewen Lin
@ 2024-06-13  7:15   ` Kewen.Lin
  0 siblings, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-13  7:15 UTC (permalink / raw)
  To: gcc-patches; +Cc: jeffreyalaw, Jeff Law

Hi,

Gentle ping:

https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653344.html

BR,
Kewen

on 2024/6/3 11:01, Kewen Lin wrote:
> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in epiphany port.
> 
> gcc/ChangeLog:
> 
> 	* config/epiphany/epiphany.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.
> ---
>  gcc/config/epiphany/epiphany.h | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/gcc/config/epiphany/epiphany.h b/gcc/config/epiphany/epiphany.h
> index 1df9eeecd0e..aa4715bfe10 100644
> --- a/gcc/config/epiphany/epiphany.h
> +++ b/gcc/config/epiphany/epiphany.h
> @@ -188,9 +188,6 @@ along with GCC; see the file COPYING3.  If not see
>  #define INT_TYPE_SIZE		32
>  #define LONG_TYPE_SIZE		32
>  #define LONG_LONG_TYPE_SIZE	64
> -#define FLOAT_TYPE_SIZE		32
> -#define DOUBLE_TYPE_SIZE	64
> -#define LONG_DOUBLE_TYPE_SIZE	64
>  
>  /* Define this as 1 if `char' should by default be signed; else as 0.  */
>  #define DEFAULT_SIGNED_CHAR 0

^ permalink raw reply	[flat|nested] 149+ messages in thread

* PING^1 [PATCH 16/52] ft32: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:01 ` [PATCH 16/52] ft32: " Kewen Lin
@ 2024-06-13  7:15   ` Kewen.Lin
  0 siblings, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-13  7:15 UTC (permalink / raw)
  To: gcc-patches; +Cc: james.bowman, Jeff Law, Jeff Law

Hi,

Gentle ping:

https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653350.html

BR,
Kewen

on 2024/6/3 11:01, Kewen Lin wrote:
> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in ft32 port.
> 
> gcc/ChangeLog:
> 
> 	* config/ft32/ft32.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.
> ---
>  gcc/config/ft32/ft32.h | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/gcc/config/ft32/ft32.h b/gcc/config/ft32/ft32.h
> index 6d892a5ab8e..1803d5b6be0 100644
> --- a/gcc/config/ft32/ft32.h
> +++ b/gcc/config/ft32/ft32.h
> @@ -53,10 +53,6 @@
>  #define LONG_TYPE_SIZE 32
>  #define LONG_LONG_TYPE_SIZE 64
>  
> -#define FLOAT_TYPE_SIZE 32
> -#define DOUBLE_TYPE_SIZE 64
> -#define LONG_DOUBLE_TYPE_SIZE 64
> -
>  #define DEFAULT_SIGNED_CHAR 1
>  
>  #undef  SIZE_TYPE


^ permalink raw reply	[flat|nested] 149+ messages in thread

* PING^1 [PATCH 19/52] lm32: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:01 ` [PATCH 19/52] lm32: " Kewen Lin
@ 2024-06-13  7:15   ` Kewen.Lin
  0 siblings, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-13  7:15 UTC (permalink / raw)
  To: gcc-patches; +Cc: sebastien, Jeff Law, Jeff Law

Hi,

Gentle ping:

https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653354.html

BR,
Kewen

on 2024/6/3 11:01, Kewen Lin wrote:
> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in lm32 port.
> 
> gcc/ChangeLog:
> 
> 	* config/lm32/lm32.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.
> ---
>  gcc/config/lm32/lm32.h | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/gcc/config/lm32/lm32.h b/gcc/config/lm32/lm32.h
> index 1d2c8adadfe..e761e14dcc5 100644
> --- a/gcc/config/lm32/lm32.h
> +++ b/gcc/config/lm32/lm32.h
> @@ -122,10 +122,6 @@ do {                                                    \
>  #define LONG_TYPE_SIZE		    32
>  #define LONG_LONG_TYPE_SIZE	    64
>  
> -#define FLOAT_TYPE_SIZE		    32
> -#define DOUBLE_TYPE_SIZE	    64
> -#define LONG_DOUBLE_TYPE_SIZE       64
> -
>  #define DEFAULT_SIGNED_CHAR         0
>  
>  #define SIZE_TYPE "unsigned int"


^ permalink raw reply	[flat|nested] 149+ messages in thread

* PING^1 [PATCH 22/52] microblaze: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:01 ` [PATCH 22/52] microblaze: " Kewen Lin
@ 2024-06-13  7:16   ` Kewen.Lin
  2024-06-13 17:37     ` Michael Eager
  0 siblings, 1 reply; 149+ messages in thread
From: Kewen.Lin @ 2024-06-13  7:16 UTC (permalink / raw)
  To: gcc-patches; +Cc: eager, Jeff Law, Jeff Law

Hi,

Gentle ping:

https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653355.html

BR,
Kewen

on 2024/6/3 11:01, Kewen Lin wrote:
> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in microblaze port.
> 
> gcc/ChangeLog:
> 
> 	* config/microblaze/microblaze.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.
> ---
>  gcc/config/microblaze/microblaze.h | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
> index c88a87c12e2..5d28abf9741 100644
> --- a/gcc/config/microblaze/microblaze.h
> +++ b/gcc/config/microblaze/microblaze.h
> @@ -216,9 +216,6 @@ extern enum pipeline_type microblaze_pipe;
>  #define SHORT_TYPE_SIZE         16
>  #define LONG_TYPE_SIZE          32
>  #define LONG_LONG_TYPE_SIZE     64
> -#define FLOAT_TYPE_SIZE         32
> -#define DOUBLE_TYPE_SIZE        64
> -#define LONG_DOUBLE_TYPE_SIZE   64
>  #define POINTER_SIZE            32
>  #define PARM_BOUNDARY           32
>  #define FUNCTION_BOUNDARY       32



^ permalink raw reply	[flat|nested] 149+ messages in thread

* PING^1 [PATCH 24/52] moxie: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:01 ` [PATCH 24/52] moxie: " Kewen Lin
@ 2024-06-13  7:16   ` Kewen.Lin
  0 siblings, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-13  7:16 UTC (permalink / raw)
  To: gcc-patches; +Cc: green, Jeff Law, Jeff Law

Hi,

Gentle ping:

https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653360.html

BR,
Kewen

on 2024/6/3 11:01, Kewen Lin wrote:
> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in moxie port.
> 
> gcc/ChangeLog:
> 
> 	* config/moxie/moxie.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.
> ---
>  gcc/config/moxie/moxie.h | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/gcc/config/moxie/moxie.h b/gcc/config/moxie/moxie.h
> index 066c2566d84..4857c92890f 100644
> --- a/gcc/config/moxie/moxie.h
> +++ b/gcc/config/moxie/moxie.h
> @@ -55,10 +55,6 @@
>  #define LONG_TYPE_SIZE 32
>  #define LONG_LONG_TYPE_SIZE 64
>  
> -#define FLOAT_TYPE_SIZE 32
> -#define DOUBLE_TYPE_SIZE 64
> -#define LONG_DOUBLE_TYPE_SIZE 64
> -
>  #define DEFAULT_SIGNED_CHAR 0
>  
>  #undef  SIZE_TYPE




^ permalink raw reply	[flat|nested] 149+ messages in thread

* PING^1 [PATCH 26/52] nds32: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:01 ` [PATCH 26/52] nds32: " Kewen Lin
@ 2024-06-13  7:16   ` Kewen.Lin
  0 siblings, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-13  7:16 UTC (permalink / raw)
  To: gcc-patches; +Cc: jasonwucj, shiva0217, Jeff Law, Jeff Law

Hi,

Gentle ping:

https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653358.html

BR,
Kewen

on 2024/6/3 11:01, Kewen Lin wrote:
> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in nds32 port.
> 
> gcc/ChangeLog:
> 
> 	* config/nds32/nds32.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.
> ---
>  gcc/config/nds32/nds32.h | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/gcc/config/nds32/nds32.h b/gcc/config/nds32/nds32.h
> index 03cf7a9aa56..4c02302c785 100644
> --- a/gcc/config/nds32/nds32.h
> +++ b/gcc/config/nds32/nds32.h
> @@ -1061,10 +1061,6 @@ enum nds32_builtins
>  #define LONG_TYPE_SIZE          32
>  #define LONG_LONG_TYPE_SIZE     64
>  
> -#define FLOAT_TYPE_SIZE         32
> -#define DOUBLE_TYPE_SIZE        64
> -#define LONG_DOUBLE_TYPE_SIZE   64
> -
>  #define DEFAULT_SIGNED_CHAR 1
>  
>  #define SIZE_TYPE "long unsigned int"


^ permalink raw reply	[flat|nested] 149+ messages in thread

* PING^1 [PATCH 28/52] nvptx: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:01 ` [PATCH 28/52] nvptx: " Kewen Lin
@ 2024-06-13  7:16   ` Kewen.Lin
  0 siblings, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-13  7:16 UTC (permalink / raw)
  To: gcc-patches; +Cc: tdevries, tschwinge

Hi,

Gentle ping:

https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653361.html

BR,
Kewen

on 2024/6/3 11:01, Kewen Lin wrote:
> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in nvptx port.
> 
> gcc/ChangeLog:
> 
> 	* config/nvptx/nvptx.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.
> ---
>  gcc/config/nvptx/nvptx.h | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/gcc/config/nvptx/nvptx.h b/gcc/config/nvptx/nvptx.h
> index e282aad1b73..f6077c09e9b 100644
> --- a/gcc/config/nvptx/nvptx.h
> +++ b/gcc/config/nvptx/nvptx.h
> @@ -75,9 +75,6 @@
>  #define INT_TYPE_SIZE 32
>  #define LONG_TYPE_SIZE (TARGET_ABI64 ? 64 : 32)
>  #define LONG_LONG_TYPE_SIZE 64
> -#define FLOAT_TYPE_SIZE 32
> -#define DOUBLE_TYPE_SIZE 64
> -#define LONG_DOUBLE_TYPE_SIZE 64
>  #define TARGET_SUPPORTS_WIDE_INT 1
>  
>  #undef SIZE_TYPE



^ permalink raw reply	[flat|nested] 149+ messages in thread

* PING^1 [PATCH 29/52] or1k: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:01 ` [PATCH 29/52] or1k: " Kewen Lin
@ 2024-06-13  7:16   ` Kewen.Lin
  2024-06-20 14:18     ` Stafford Horne
  0 siblings, 1 reply; 149+ messages in thread
From: Kewen.Lin @ 2024-06-13  7:16 UTC (permalink / raw)
  To: gcc-patches; +Cc: shorne, Jeff Law, Jeff Law

Hi,

Gentle ping:

https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653363.html

BR,
Kewen

on 2024/6/3 11:01, Kewen Lin wrote:
> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in or1k port.
> 
> gcc/ChangeLog:
> 
> 	* config/or1k/or1k.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.
> ---
>  gcc/config/or1k/or1k.h | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/gcc/config/or1k/or1k.h b/gcc/config/or1k/or1k.h
> index 0ff73df33e7..a55509f9f32 100644
> --- a/gcc/config/or1k/or1k.h
> +++ b/gcc/config/or1k/or1k.h
> @@ -67,9 +67,6 @@
>  #define SHORT_TYPE_SIZE 16
>  #define LONG_TYPE_SIZE 32
>  #define LONG_LONG_TYPE_SIZE 64
> -#define FLOAT_TYPE_SIZE 32
> -#define DOUBLE_TYPE_SIZE 64
> -#define LONG_DOUBLE_TYPE_SIZE 64
>  #define WCHAR_TYPE_SIZE 32
>  
>  #undef SIZE_TYPE


^ permalink raw reply	[flat|nested] 149+ messages in thread

* PING^1 [PATCH 30/52] pdp11: Remove macro LONG_DOUBLE_TYPE_SIZE
  2024-06-03  3:01 ` [PATCH 30/52] pdp11: Remove macro LONG_DOUBLE_TYPE_SIZE Kewen Lin
@ 2024-06-13  7:16   ` Kewen.Lin
  2024-06-13 20:07     ` Paul Koning
  0 siblings, 1 reply; 149+ messages in thread
From: Kewen.Lin @ 2024-06-13  7:16 UTC (permalink / raw)
  To: gcc-patches; +Cc: ni1d, Jeff Law, Jeff Law

Hi,

Gentle ping:

https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653368.html

BR,
Kewen

on 2024/6/3 11:01, Kewen Lin wrote:
> This is to remove macro LONG_DOUBLE_TYPE_SIZE define
> in pdp11 port.
> 
> gcc/ChangeLog:
> 
> 	* config/pdp11/pdp11.h (LONG_DOUBLE_TYPE_SIZE): Remove.
> ---
>  gcc/config/pdp11/pdp11.h | 11 -----------
>  1 file changed, 11 deletions(-)
> 
> diff --git a/gcc/config/pdp11/pdp11.h b/gcc/config/pdp11/pdp11.h
> index 2446fea0b58..6c8e045bc57 100644
> --- a/gcc/config/pdp11/pdp11.h
> +++ b/gcc/config/pdp11/pdp11.h
> @@ -71,17 +71,6 @@ along with GCC; see the file COPYING3.  If not see
>  #define LONG_TYPE_SIZE		32
>  #define LONG_LONG_TYPE_SIZE	64     
>  
> -/* In earlier versions, FLOAT_TYPE_SIZE was selectable as 32 or 64,
> -   but that conflicts with Fortran language rules.  Since there is no
> -   obvious reason why we should have that feature -- other targets
> -   generally don't have float and double the same size -- I've removed
> -   it.  Note that it continues to be true (for now) that arithmetic is
> -   always done with 64-bit values, i.e., the FPU is always in "double"
> -   mode.  */
> -#define FLOAT_TYPE_SIZE		32
> -#define DOUBLE_TYPE_SIZE	64
> -#define LONG_DOUBLE_TYPE_SIZE	64
> -
>  /* machine types from ansi */
>  #define SIZE_TYPE "short unsigned int" 	/* definition of size_t */
>  #define WCHAR_TYPE "short int" 		/* or long int???? */




^ permalink raw reply	[flat|nested] 149+ messages in thread

* PING^1 [PATCH 33/52] visium: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-03  3:01 ` [PATCH 33/52] visium: " Kewen Lin
@ 2024-06-13  7:17   ` Kewen.Lin
  0 siblings, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-13  7:17 UTC (permalink / raw)
  To: GCC Patches; +Cc: Jeff Law, Jeff Law

Hi,

Gentle ping:

https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653365.html

BR,
Kewen

on 2024/6/3 11:01, Kewen Lin wrote:
> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in visium port.
> 
> gcc/ChangeLog:
> 
> 	* config/visium/visium.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.
> ---
>  gcc/config/visium/visium.h | 29 ++++++-----------------------
>  1 file changed, 6 insertions(+), 23 deletions(-)
> 
> diff --git a/gcc/config/visium/visium.h b/gcc/config/visium/visium.h
> index 69e25523e05..afeb68f84cc 100644
> --- a/gcc/config/visium/visium.h
> +++ b/gcc/config/visium/visium.h
> @@ -330,33 +330,16 @@
>     it is rounded up to one unit.) */
>  #define CHAR_TYPE_SIZE  8
>  
> -/* `FLOAT_TYPE_SIZE'
> -
> -   A C expression for the size in bits of the type `float' on the
> -   target machine.  If you don't define this, the default is one word. */
> -#define FLOAT_TYPE_SIZE  32
> -
> -/* `DOUBLE_TYPE_SIZE'
> -
> -   A C expression for the size in bits of the type `double' on the
> -   target machine.  If you don't define this, the default is two
> -   words. */
> -#define DOUBLE_TYPE_SIZE  64
> -
> -/* `LONG_DOUBLE_TYPE_SIZE'
> -
> -   A C expression for the size in bits of the type `long double' on
> -   the target machine.  If you don't define this, the default is two
> -   words. */
> -#define LONG_DOUBLE_TYPE_SIZE   DOUBLE_TYPE_SIZE
> -
>  /* `WIDEST_HARDWARE_FP_SIZE'
>  
>     A C expression for the size in bits of the widest floating-point
>     format supported by the hardware.  If you define this macro, you
> -   must specify a value less than or equal to the value of
> -   `LONG_DOUBLE_TYPE_SIZE'.  If you do not define this macro, the
> -   value of `LONG_DOUBLE_TYPE_SIZE' is the default. */
> +   must specify a value less than or equal to mode precision of the
> +   mode used for C type long double (from hook
> +   targetm.c.mode_for_floating_type with tree_index
> +   TI_LONG_DOUBLE_TYPE).  If you do not define this macro, mode
> +   precision of the mode used for C type long double is the
> +   default.  */
>  
>  /* `DEFAULT_SIGNED_CHAR'
>  


^ permalink raw reply	[flat|nested] 149+ messages in thread

* PING^1 [PATCH 37/52] alpha: New hook implementation alpha_c_mode_for_floating_type
  2024-06-03  3:01 ` [PATCH 37/52] alpha: New hook implementation alpha_c_mode_for_floating_type Kewen Lin
@ 2024-06-13  7:42   ` Kewen.Lin
  0 siblings, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-13  7:42 UTC (permalink / raw)
  To: gcc-patches; +Cc: rth, Jeff Law, Jeff Law

Hi,

Gentle ping:

https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653370.html

BR,
Kewen

on 2024/6/3 11:01, Kewen Lin wrote:
> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in alpha port, and add new port specific hook
> implementation alpha_c_mode_for_floating_type.
> 
> gcc/ChangeLog:
> 
> 	* config/alpha/alpha.cc (alpha_c_mode_for_floating_type): New
> 	function.
> 	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
> 	* config/alpha/alpha.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.
> ---
>  gcc/config/alpha/alpha.cc | 17 ++++++++++++++++-
>  gcc/config/alpha/alpha.h  |  8 --------
>  2 files changed, 16 insertions(+), 9 deletions(-)
> 
> diff --git a/gcc/config/alpha/alpha.cc b/gcc/config/alpha/alpha.cc
> index 1126cea1f7b..a6fe95e7177 100644
> --- a/gcc/config/alpha/alpha.cc
> +++ b/gcc/config/alpha/alpha.cc
> @@ -9916,7 +9916,19 @@ alpha_can_change_mode_class (machine_mode from, machine_mode to,
>    return (GET_MODE_SIZE (from) == GET_MODE_SIZE (to)
>  	  || !reg_classes_intersect_p (FLOAT_REGS, rclass));
>  }
> -\f
> +
> +/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return TFmode or DFmode
> +   for TI_LONG_DOUBLE_TYPE which is for long double type, go with the
> +   default one for the others.  */
> +
> +static machine_mode
> +alpha_c_mode_for_floating_type (enum tree_index ti)
> +{
> +  if (ti == TI_LONG_DOUBLE_TYPE)
> +    return TARGET_LONG_DOUBLE_128 ? TFmode : DFmode;
> +  return default_mode_for_floating_type (ti);
> +}
> +
>  /* Initialize the GCC target structure.  */
>  #if TARGET_ABI_OPEN_VMS
>  # undef TARGET_ATTRIBUTE_TABLE
> @@ -10123,6 +10135,9 @@ alpha_can_change_mode_class (machine_mode from, machine_mode to,
>  #undef TARGET_CAN_CHANGE_MODE_CLASS
>  #define TARGET_CAN_CHANGE_MODE_CLASS alpha_can_change_mode_class
>  
> +#undef TARGET_C_MODE_FOR_FLOATING_TYPE
> +#define TARGET_C_MODE_FOR_FLOATING_TYPE alpha_c_mode_for_floating_type
> +
>  struct gcc_target targetm = TARGET_INITIALIZER;
>  
>  \f
> diff --git a/gcc/config/alpha/alpha.h b/gcc/config/alpha/alpha.h
> index 25ccfce96b8..ee9e0918038 100644
> --- a/gcc/config/alpha/alpha.h
> +++ b/gcc/config/alpha/alpha.h
> @@ -195,14 +195,6 @@ extern enum alpha_fp_trap_mode alpha_fptm;
>  /* Define the size of `long long'.  The default is the twice the word size.  */
>  #define LONG_LONG_TYPE_SIZE 64
>  
> -/* The two floating-point formats we support are S-floating, which is
> -   4 bytes, and T-floating, which is 8 bytes.  `float' is S and `double'
> -   and `long double' are T.  */
> -
> -#define FLOAT_TYPE_SIZE 32
> -#define DOUBLE_TYPE_SIZE 64
> -#define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
> -
>  /* Work around target_flags dependency in ada/targtyps.cc.  */
>  #define WIDEST_HARDWARE_FP_SIZE 64
>  


^ permalink raw reply	[flat|nested] 149+ messages in thread

* PING^1 [PATCH 38/52] avr: New hook implementation avr_c_mode_for_floating_type
  2024-06-03  3:01 ` [PATCH 38/52] avr: New hook implementation avr_c_mode_for_floating_type Kewen Lin
@ 2024-06-13  7:42   ` Kewen.Lin
  0 siblings, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-13  7:42 UTC (permalink / raw)
  To: gcc-patches; +Cc: chertykov, Jeff Law, Jeff Law

Hi,

Gentle ping:

https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653375.html

BR,
Kewen

on 2024/6/3 11:01, Kewen Lin wrote:
> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in avr port, and add new port specific hook
> implementation avr_c_mode_for_floating_type.
> 
> gcc/ChangeLog:
> 
> 	* config/avr/avr.cc (avr_c_mode_for_floating_type): New
> 	function.
> 	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
> 	* config/avr/avr.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.
> ---
>  gcc/config/avr/avr.cc | 17 +++++++++++++++++
>  gcc/config/avr/avr.h  |  3 ---
>  2 files changed, 17 insertions(+), 3 deletions(-)
> 
> diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc
> index 74924ab0565..61c325f2497 100644
> --- a/gcc/config/avr/avr.cc
> +++ b/gcc/config/avr/avr.cc
> @@ -6930,6 +6930,20 @@ avr_canonicalize_comparison (int *icode, rtx *op0, rtx *op1, bool op0_fixed)
>      }
>  }
>  
> +/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return SFmode or DFmode
> +   for TI_{LONG_,}DOUBLE_TYPE which is for {long,} double type, go with
> +   the default one for the others.  */
> +
> +static machine_mode
> +avr_c_mode_for_floating_type (enum tree_index ti)
> +{
> +  if (ti == TI_DOUBLE_TYPE)
> +    return avr_double == 32 ? SFmode : DFmode;
> +  if (ti == TI_LONG_DOUBLE_TYPE)
> +    return avr_long_double == 32 ? SFmode : DFmode;
> +  return default_mode_for_floating_type (ti);
> +}
> +
>  
>  /* Output compare instruction
>  
> @@ -16411,6 +16425,9 @@ avr_float_lib_compare_returns_bool (machine_mode mode, enum rtx_code)
>  #undef  TARGET_HAVE_SPECULATION_SAFE_VALUE
>  #define TARGET_HAVE_SPECULATION_SAFE_VALUE speculation_safe_value_not_needed
>  
> +#undef TARGET_C_MODE_FOR_FLOATING_TYPE
> +#define TARGET_C_MODE_FOR_FLOATING_TYPE avr_c_mode_for_floating_type
> +
>  struct gcc_target targetm = TARGET_INITIALIZER;
>  
>  \f
> diff --git a/gcc/config/avr/avr.h b/gcc/config/avr/avr.h
> index 56211fa9cd0..4977e15eeed 100644
> --- a/gcc/config/avr/avr.h
> +++ b/gcc/config/avr/avr.h
> @@ -143,9 +143,6 @@ FIXME: DRIVER_SELF_SPECS has changed.
>  #define SHORT_TYPE_SIZE (INT_TYPE_SIZE == 8 ? INT_TYPE_SIZE : 16)
>  #define LONG_TYPE_SIZE (INT_TYPE_SIZE == 8 ? 16 : 32)
>  #define LONG_LONG_TYPE_SIZE (INT_TYPE_SIZE == 8 ? 32 : 64)
> -#define FLOAT_TYPE_SIZE 32
> -#define DOUBLE_TYPE_SIZE (avr_double)
> -#define LONG_DOUBLE_TYPE_SIZE (avr_long_double)
>  
>  #define LONG_LONG_ACCUM_TYPE_SIZE 64
>  


^ permalink raw reply	[flat|nested] 149+ messages in thread

* PING^1 [PATCH 40/52] ia64: New hook implementation ia64_c_mode_for_floating_type
  2024-06-03  3:01 ` [PATCH 40/52] ia64: New hook implementation ia64_c_mode_for_floating_type Kewen Lin
@ 2024-06-13  7:42   ` Kewen.Lin
  0 siblings, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-13  7:42 UTC (permalink / raw)
  To: gcc-patches; +Cc: jeffreyalaw, richard.guenther

Hi,

Gentle ping:

https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653374.html

BR,
Kewen

on 2024/6/3 11:01, Kewen Lin wrote:
> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in ia64 port, and add new port specific hook
> implementation ia64_c_mode_for_floating_type.
> 
> gcc/ChangeLog:
> 
> 	* config/ia64/ia64.cc (ia64_c_mode_for_floating_type): New
> 	function.
> 	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
> 	* config/ia64/ia64.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.
> ---
>  gcc/config/ia64/ia64.cc | 18 ++++++++++++++++++
>  gcc/config/ia64/ia64.h  | 12 ------------
>  2 files changed, 18 insertions(+), 12 deletions(-)
> 
> diff --git a/gcc/config/ia64/ia64.cc b/gcc/config/ia64/ia64.cc
> index ac3d56073ac..cd6ed895211 100644
> --- a/gcc/config/ia64/ia64.cc
> +++ b/gcc/config/ia64/ia64.cc
> @@ -321,6 +321,7 @@ static const char *ia64_invalid_conversion (const_tree, const_tree);
>  static const char *ia64_invalid_unary_op (int, const_tree);
>  static const char *ia64_invalid_binary_op (int, const_tree, const_tree);
>  static machine_mode ia64_c_mode_for_suffix (char);
> +static machine_mode ia64_c_mode_for_floating_type (enum tree_index);
>  static void ia64_trampoline_init (rtx, tree, rtx);
>  static void ia64_override_options_after_change (void);
>  static bool ia64_member_type_forces_blk (const_tree, machine_mode);
> @@ -637,6 +638,9 @@ static const scoped_attribute_specs *const ia64_attribute_table[] =
>  #undef TARGET_C_MODE_FOR_SUFFIX
>  #define TARGET_C_MODE_FOR_SUFFIX ia64_c_mode_for_suffix
>  
> +#undef TARGET_C_MODE_FOR_FLOATING_TYPE
> +#define TARGET_C_MODE_FOR_FLOATING_TYPE ia64_c_mode_for_floating_type
> +
>  #undef TARGET_CAN_ELIMINATE
>  #define TARGET_CAN_ELIMINATE ia64_can_eliminate
>  
> @@ -11329,6 +11333,20 @@ ia64_c_mode_for_suffix (char suffix)
>    return VOIDmode;
>  }
>  
> +/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return DFmode, XFmode
> +   or TFmode for TI_LONG_DOUBLE_TYPE which is for long double type,
> +   go with the default one for the others.  */
> +
> +static machine_mode
> +ia64_c_mode_for_floating_type (enum tree_index ti)
> +{
> +  /* long double is XFmode normally, and TFmode for HPUX.  It should be
> +     TFmode for VMS as well but we only support up to DFmode now.  */
> +  if (ti == TI_LONG_DOUBLE_TYPE)
> +    return TARGET_HPUX ? TFmode : (TARGET_ABI_OPEN_VMS ? DFmode : XFmode);
> +  return default_mode_for_floating_type (ti);
> +}
> +
>  static GTY(()) rtx ia64_dconst_0_5_rtx;
>  
>  rtx
> diff --git a/gcc/config/ia64/ia64.h b/gcc/config/ia64/ia64.h
> index b7f9d654f90..763b1c3ed48 100644
> --- a/gcc/config/ia64/ia64.h
> +++ b/gcc/config/ia64/ia64.h
> @@ -236,18 +236,6 @@ while (0)
>  
>  #define LONG_LONG_TYPE_SIZE 64
>  
> -#define FLOAT_TYPE_SIZE 32
> -
> -#define DOUBLE_TYPE_SIZE 64
> -
> -/* long double is XFmode normally, and TFmode for HPUX.  It should be
> -   TFmode for VMS as well but we only support up to DFmode now.  */
> -#define LONG_DOUBLE_TYPE_SIZE \
> -  (TARGET_HPUX ? 128 \
> -   : TARGET_ABI_OPEN_VMS ? 64 \
> -   : 80)
> -
> -
>  #define DEFAULT_SIGNED_CHAR 1
>  
>  /* A C expression for a string describing the name of the data type to use for



^ permalink raw reply	[flat|nested] 149+ messages in thread

* PING^1 [PATCH 42/52] rl78: New hook implementation rl78_c_mode_for_floating_type
  2024-06-03  3:01 ` [PATCH 42/52] rl78: New hook implementation rl78_c_mode_for_floating_type Kewen Lin
@ 2024-06-13  7:42   ` Kewen.Lin
  2024-06-13  7:46     ` Richard Biener
  0 siblings, 1 reply; 149+ messages in thread
From: Kewen.Lin @ 2024-06-13  7:42 UTC (permalink / raw)
  To: gcc-patches; +Cc: jeffreyalaw, richard.guenther, Jeff Law

Hi,

Gentle ping:

https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653376.html

BR,
Kewen

on 2024/6/3 11:01, Kewen Lin wrote:
> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in rl78 port, and add new port specific hook
> implementation rl78_c_mode_for_floating_type.
> 
> gcc/ChangeLog:
> 
> 	* config/rl78/rl78.cc (TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
> 	(rl78_c_mode_for_floating_type): New function.
> 	* config/rl78/rl78.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.
> ---
>  gcc/config/rl78/rl78.cc | 15 +++++++++++++++
>  gcc/config/rl78/rl78.h  |  4 ----
>  2 files changed, 15 insertions(+), 4 deletions(-)
> 
> diff --git a/gcc/config/rl78/rl78.cc b/gcc/config/rl78/rl78.cc
> index e5345bfa9dd..ccb1c4f3867 100644
> --- a/gcc/config/rl78/rl78.cc
> +++ b/gcc/config/rl78/rl78.cc
> @@ -4971,6 +4971,21 @@ rl78_preferred_reload_class (rtx x ATTRIBUTE_UNUSED, reg_class_t rclass)
>    return rclass;
>  }
>  
> +#undef TARGET_C_MODE_FOR_FLOATING_TYPE
> +#define TARGET_C_MODE_FOR_FLOATING_TYPE rl78_c_mode_for_floating_type
> +
> +/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return SFmode for
> +   TI_DOUBLE_TYPE which is for double type, go with the default
> +   one for the others.  */
> +
> +static machine_mode
> +rl78_c_mode_for_floating_type (enum tree_index ti)
> +{
> +  if (ti == TI_DOUBLE_TYPE)
> +    return SFmode;
> +  return default_mode_for_floating_type (ti);
> +}
> +
>  \f
>  /* The strub runtime uses asms, and physical register allocation won't
>     deal with them, so disable it.  */
> diff --git a/gcc/config/rl78/rl78.h b/gcc/config/rl78/rl78.h
> index cfff98df6bc..a960aee3931 100644
> --- a/gcc/config/rl78/rl78.h
> +++ b/gcc/config/rl78/rl78.h
> @@ -113,10 +113,6 @@
>  #define LONG_TYPE_SIZE			32
>  #define LONG_LONG_TYPE_SIZE		64
>  
> -#define FLOAT_TYPE_SIZE 		32
> -#define DOUBLE_TYPE_SIZE 		32 /*64*/
> -#define LONG_DOUBLE_TYPE_SIZE		64 /*DOUBLE_TYPE_SIZE*/
> -
>  #define DEFAULT_SIGNED_CHAR		0
>  
>  #define STRICT_ALIGNMENT 		1




^ permalink raw reply	[flat|nested] 149+ messages in thread

* PING^1 [PATCH 44/52] s390: New hook implementation s390_c_mode_for_floating_type
  2024-06-03  3:01 ` [PATCH 44/52] s390: New hook implementation s390_c_mode_for_floating_type Kewen Lin
@ 2024-06-13  7:43   ` Kewen.Lin
  2024-06-14  5:40     ` Andreas Krebbel
  0 siblings, 1 reply; 149+ messages in thread
From: Kewen.Lin @ 2024-06-13  7:43 UTC (permalink / raw)
  To: gcc-patches; +Cc: uweigand, krebbel

Hi,

Gentle ping:

https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653382.html

BR,
Kewen

on 2024/6/3 11:01, Kewen Lin wrote:
> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in s390 port, and add new port specific hook
> implementation s390_c_mode_for_floating_type.
> 
> gcc/ChangeLog:
> 
> 	* config/s390/s390.cc (s390_c_mode_for_floating_type): New function.
> 	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
> 	* config/s390/s390.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.
> ---
>  gcc/config/s390/s390.cc | 15 +++++++++++++++
>  gcc/config/s390/s390.h  |  3 ---
>  2 files changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc
> index fa517bd3e77..117da36b3c0 100644
> --- a/gcc/config/s390/s390.cc
> +++ b/gcc/config/s390/s390.cc
> @@ -18066,6 +18066,18 @@ s390_noce_conversion_profitable_p (rtx_insn *seq, struct noce_if_info *if_info)
>    return default_noce_conversion_profitable_p (seq, if_info);
>  }
>  
> +/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return TFmode or DFmode
> +   for TI_LONG_DOUBLE_TYPE which is for long double type, go with the
> +   default one for the others.  */
> +
> +static machine_mode
> +s390_c_mode_for_floating_type (enum tree_index ti)
> +{
> +  if (ti == TI_LONG_DOUBLE_TYPE)
> +    return TARGET_LONG_DOUBLE_128 ? TFmode : DFmode;
> +  return default_mode_for_floating_type (ti);
> +}
> +
>  /* Initialize GCC target structure.  */
>  
>  #undef  TARGET_ASM_ALIGNED_HI_OP
> @@ -18382,6 +18394,9 @@ s390_noce_conversion_profitable_p (rtx_insn *seq, struct noce_if_info *if_info)
>  #undef TARGET_NOCE_CONVERSION_PROFITABLE_P
>  #define TARGET_NOCE_CONVERSION_PROFITABLE_P s390_noce_conversion_profitable_p
>  
> +#undef TARGET_C_MODE_FOR_FLOATING_TYPE
> +#define TARGET_C_MODE_FOR_FLOATING_TYPE s390_c_mode_for_floating_type
> +
>  struct gcc_target targetm = TARGET_INITIALIZER;
>  
>  #include "gt-s390.h"
> diff --git a/gcc/config/s390/s390.h b/gcc/config/s390/s390.h
> index 0e6666a8802..4a4dde1a9ba 100644
> --- a/gcc/config/s390/s390.h
> +++ b/gcc/config/s390/s390.h
> @@ -396,9 +396,6 @@ extern const char *s390_host_detect_local_cpu (int argc, const char **argv);
>  #define INT_TYPE_SIZE 32
>  #define LONG_TYPE_SIZE (TARGET_64BIT ? 64 : 32)
>  #define LONG_LONG_TYPE_SIZE 64
> -#define FLOAT_TYPE_SIZE 32
> -#define DOUBLE_TYPE_SIZE 64
> -#define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
>  
>  /* Work around target_flags dependency in ada/targtyps.cc.  */
>  #define WIDEST_HARDWARE_FP_SIZE 64


^ permalink raw reply	[flat|nested] 149+ messages in thread

* PING^1 [PATCH 46/52] h8300: New hook implementation h8300_c_mode_for_floating_type
  2024-06-03  3:01 ` [PATCH 46/52] h8300: New hook implementation h8300_c_mode_for_floating_type Kewen Lin
@ 2024-06-13  7:43   ` Kewen.Lin
  0 siblings, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-13  7:43 UTC (permalink / raw)
  To: gcc-patches; +Cc: jeffreyalaw, Jeff Law

Hi,

Gentle ping:

https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653379.html

BR,
Kewen

on 2024/6/3 11:01, Kewen Lin wrote:
> This is to add new port specific hook implementation
> h8300_c_mode_for_floating_type, remove useless macro
> defines for {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE and add
> new macro DOUBLE_TYPE_MODE which some subtarget can
> redefine.
> 
> gcc/ChangeLog:
> 
> 	* config/h8300/h8300.cc (h8300_c_mode_for_floating_type): New
> 	function.
> 	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
> 	* config/h8300/h8300.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Remove.
> 	(LONG_DOUBLE_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_MODE): New macro.
> 	* config/h8300/linux.h (DOUBLE_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_MODE): New macro.
> ---
>  gcc/config/h8300/h8300.cc | 15 +++++++++++++++
>  gcc/config/h8300/h8300.h  |  4 +---
>  gcc/config/h8300/linux.h  |  4 ++--
>  3 files changed, 18 insertions(+), 5 deletions(-)
> 
> diff --git a/gcc/config/h8300/h8300.cc b/gcc/config/h8300/h8300.cc
> index 9ac6d52f9d6..7ab26f2b7f9 100644
> --- a/gcc/config/h8300/h8300.cc
> +++ b/gcc/config/h8300/h8300.cc
> @@ -5601,6 +5601,18 @@ h8300_ok_for_sibcall_p (tree fndecl, tree)
>    return 1;
>  }
>  
> +/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return SFmode or DFmode
> +   for TI_{LONG_,}DOUBLE_TYPE which is for {long,} double type, go with
> +   the default one for the others.  */
> +
> +static machine_mode
> +h8300_c_mode_for_floating_type (enum tree_index ti)
> +{
> +  if (ti == TI_DOUBLE_TYPE || ti == TI_LONG_DOUBLE_TYPE)
> +    return DOUBLE_TYPE_MODE;
> +  return default_mode_for_floating_type (ti);
> +}
> +
>  /* Return TRUE if OP is a PRE_INC or PRE_DEC
>     instruction using REG, FALSE otherwise.  */
>  
> @@ -5721,4 +5733,7 @@ pre_incdec_with_reg (rtx op, unsigned int reg)
>  #undef TARGET_FUNCTION_OK_FOR_SIBCALL
>  #define TARGET_FUNCTION_OK_FOR_SIBCALL h8300_ok_for_sibcall_p
>  
> +#undef TARGET_C_MODE_FOR_FLOATING_TYPE
> +#define TARGET_C_MODE_FOR_FLOATING_TYPE h8300_c_mode_for_floating_type
> +
>  struct gcc_target targetm = TARGET_INITIALIZER;
> diff --git a/gcc/config/h8300/h8300.h b/gcc/config/h8300/h8300.h
> index bb0bf7404e0..d25689ccec8 100644
> --- a/gcc/config/h8300/h8300.h
> +++ b/gcc/config/h8300/h8300.h
> @@ -149,9 +149,7 @@ extern const char * const *h8_reg_names;
>  #define INT_TYPE_SIZE		(TARGET_INT32 ? 32 : 16)
>  #define LONG_TYPE_SIZE		32
>  #define LONG_LONG_TYPE_SIZE	64
> -#define FLOAT_TYPE_SIZE	32
> -#define DOUBLE_TYPE_SIZE	32
> -#define LONG_DOUBLE_TYPE_SIZE	DOUBLE_TYPE_SIZE
> +#define DOUBLE_TYPE_MODE	SFmode
>  
>  #define MAX_FIXED_MODE_SIZE	32
>  
> diff --git a/gcc/config/h8300/linux.h b/gcc/config/h8300/linux.h
> index 326c481b512..6e21db37655 100644
> --- a/gcc/config/h8300/linux.h
> +++ b/gcc/config/h8300/linux.h
> @@ -36,8 +36,8 @@ along with GCC; see the file COPYING3.  If not see
>  #define TARGET_DEFAULT (MASK_QUICKCALL | MASK_INT32 | MASK_H8300H)
>  
>  /* Width of a word, in units (bytes).  */
> -#undef DOUBLE_TYPE_SIZE
> -#define DOUBLE_TYPE_SIZE	64
> +#undef DOUBLE_TYPE_MODE
> +#define DOUBLE_TYPE_MODE	DFmode
>  
>  #undef DEFAULT_SIGNED_CHAR
>  #define DEFAULT_SIGNED_CHAR 1


^ permalink raw reply	[flat|nested] 149+ messages in thread

* PING^1 [PATCH 48/52] m68k: New hook implementation m68k_c_mode_for_floating_type
  2024-06-03  3:01 ` [PATCH 48/52] m68k: New hook implementation m68k_c_mode_for_floating_type Kewen Lin
@ 2024-06-13  7:43   ` Kewen.Lin
  0 siblings, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-13  7:43 UTC (permalink / raw)
  To: gcc-patches; +Cc: jeffreyalaw, schwab, phdm

Hi,

Gentle ping:

https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653381.html

BR,
Kewen

on 2024/6/3 11:01, Kewen Lin wrote:
> This is to add new port specific hook implementation
> m68k_c_mode_for_floating_type, remove macro
> LONG_DOUBLE_TYPE_SIZE and add new macro
> LONG_DOUBLE_TYPE_MODE which some subtarget can redefine.
> 
> gcc/ChangeLog:
> 
> 	* config/m68k/m68k.cc (m68k_c_mode_for_floating_type): New function.
> 	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
> 	* config/m68k/m68k.h (LONG_DOUBLE_TYPE_SIZE): Remove.
> 	(LONG_DOUBLE_TYPE_MODE): New macro.
> 	* config/m68k/netbsd-elf.h (LONG_DOUBLE_TYPE_SIZE): Remove.
> 	(LONG_DOUBLE_TYPE_MODE): New macro.
> ---
>  gcc/config/m68k/m68k.cc      | 16 ++++++++++++++++
>  gcc/config/m68k/m68k.h       |  4 ++--
>  gcc/config/m68k/netbsd-elf.h |  4 ++--
>  3 files changed, 20 insertions(+), 4 deletions(-)
> 
> diff --git a/gcc/config/m68k/m68k.cc b/gcc/config/m68k/m68k.cc
> index b1c9238949f..79ba4d5343c 100644
> --- a/gcc/config/m68k/m68k.cc
> +++ b/gcc/config/m68k/m68k.cc
> @@ -198,6 +198,7 @@ static machine_mode m68k_promote_function_mode (const_tree, machine_mode,
>  						int *, const_tree, int);
>  static void m68k_asm_final_postscan_insn (FILE *, rtx_insn *insn, rtx [], int);
>  static HARD_REG_SET m68k_zero_call_used_regs (HARD_REG_SET);
> +static machine_mode m68k_c_mode_for_floating_type (enum tree_index);
>  \f
>  /* Initialize the GCC target structure.  */
>  
> @@ -365,6 +366,9 @@ static HARD_REG_SET m68k_zero_call_used_regs (HARD_REG_SET);
>  #undef TARGET_ZERO_CALL_USED_REGS
>  #define TARGET_ZERO_CALL_USED_REGS m68k_zero_call_used_regs
>  
> +#undef TARGET_C_MODE_FOR_FLOATING_TYPE
> +#define TARGET_C_MODE_FOR_FLOATING_TYPE m68k_c_mode_for_floating_type
> +
>  TARGET_GNU_ATTRIBUTES (m68k_attribute_table,
>  {
>    /* { name, min_len, max_len, decl_req, type_req, fn_type_req,
> @@ -7212,4 +7216,16 @@ m68k_zero_call_used_regs (HARD_REG_SET need_zeroed_hardregs)
>    return need_zeroed_hardregs;
>  }
>  
> +/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return XFmode or DFmode
> +   for TI_LONG_DOUBLE_TYPE which is for long double type, go with the
> +   default one for the others.  */
> +
> +static machine_mode
> +m68k_c_mode_for_floating_type (enum tree_index ti)
> +{
> +  if (ti == TI_LONG_DOUBLE_TYPE)
> +    return LONG_DOUBLE_TYPE_MODE;
> +  return default_mode_for_floating_type (ti);
> +}
> +
>  #include "gt-m68k.h"
> diff --git a/gcc/config/m68k/m68k.h b/gcc/config/m68k/m68k.h
> index 1aa89f1789b..0d571997143 100644
> --- a/gcc/config/m68k/m68k.h
> +++ b/gcc/config/m68k/m68k.h
> @@ -278,8 +278,8 @@ along with GCC; see the file COPYING3.  If not see
>  /* "long double" is the same as "double" on ColdFire and fido
>     targets.  */
>  
> -#define LONG_DOUBLE_TYPE_SIZE			\
> -  ((TARGET_COLDFIRE || TARGET_FIDOA) ? 64 : 80)
> +#define LONG_DOUBLE_TYPE_MODE			\
> +  ((TARGET_COLDFIRE || TARGET_FIDOA) ? DFmode : XFmode)
>  
>  #define BITS_BIG_ENDIAN 1
>  #define BYTES_BIG_ENDIAN 1
> diff --git a/gcc/config/m68k/netbsd-elf.h b/gcc/config/m68k/netbsd-elf.h
> index 5239f09b4cc..6fc5ad1a0a6 100644
> --- a/gcc/config/m68k/netbsd-elf.h
> +++ b/gcc/config/m68k/netbsd-elf.h
> @@ -36,8 +36,8 @@ along with GCC; see the file COPYING3.  If not see
>    while (0)
>  
>  /* Don't try using XFmode on the 68010.  */ 
> -#undef LONG_DOUBLE_TYPE_SIZE
> -#define LONG_DOUBLE_TYPE_SIZE (TARGET_68020 ? 80 : 64)
> +#undef LONG_DOUBLE_TYPE_MODE
> +#define LONG_DOUBLE_TYPE_MODE (TARGET_68020 ? XFmode : DFmode)
>  
>  #undef SUBTARGET_EXTRA_SPECS
>  #define SUBTARGET_EXTRA_SPECS \


^ permalink raw reply	[flat|nested] 149+ messages in thread

* PING^1 [PATCH 52/52] bfin: Rename macros {FLOAT,DOUBLE}_TYPE_SIZE
  2024-06-03  3:01 ` [PATCH 52/52] bfin: Rename macros {FLOAT,DOUBLE}_TYPE_SIZE Kewen Lin
@ 2024-06-13  7:43   ` Kewen.Lin
  0 siblings, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-13  7:43 UTC (permalink / raw)
  To: gcc-patches; +Cc: jzhang918, Jeff Law, Jeff Law

Hi,

Gentle ping:

https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653386.html

BR,
Kewen

on 2024/6/3 11:01, Kewen Lin wrote:
> This patch is to remove LONG_DOUBLE_TYPE_SIZE and
> rename macros {FLOAT,DOUBLE}_TYPE_SIZE with prefix
> BFIN_ as some macro defines want to use them, keeping
> them can have better code readability.
> 
> gcc/ChangeLog:
> 
> 	* config/bfin/bfin.h (FLOAT_TYPE_SIZE): Rename to ...
> 	(BFIN_FLOAT_TYPE_SIZE): ... this.
> 	(DOUBLE_TYPE_SIZE): Rename to ...
> 	(BFIN_DOUBLE_TYPE_SIZE): ... this.
> 	(LONG_DOUBLE_TYPE_SIZE): Remove.
> 	(UNITS_PER_FLOAT): Replace FLOAT_TYPE_SIZE with BFIN_FLOAT_TYPE_SIZE.
> 	(UNITS_PER_DOUBLE): Replace DOUBLE_TYPE_SIZE with
> 	BFIN_DOUBLE_TYPE_SIZE.
> ---
>  gcc/config/bfin/bfin.h | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/gcc/config/bfin/bfin.h b/gcc/config/bfin/bfin.h
> index e6ac8e3206c..e957c31a788 100644
> --- a/gcc/config/bfin/bfin.h
> +++ b/gcc/config/bfin/bfin.h
> @@ -862,10 +862,10 @@ typedef struct {
>   *  really cause some alignment problem
>   */
>  
> -#define UNITS_PER_FLOAT  ((FLOAT_TYPE_SIZE  + BITS_PER_UNIT - 1) / \
> +#define UNITS_PER_FLOAT  ((BFIN_FLOAT_TYPE_SIZE  + BITS_PER_UNIT - 1) / \
>  			   BITS_PER_UNIT)
>  
> -#define UNITS_PER_DOUBLE ((DOUBLE_TYPE_SIZE + BITS_PER_UNIT - 1) / \
> +#define UNITS_PER_DOUBLE ((BFIN_DOUBLE_TYPE_SIZE + BITS_PER_UNIT - 1) / \
>   			   BITS_PER_UNIT)
>  
>  
> @@ -874,7 +874,8 @@ typedef struct {
>  
>  /* Define this as 1 if `char' should by default be signed; else as 0.  */
>  #define DEFAULT_SIGNED_CHAR 1
> -#define FLOAT_TYPE_SIZE BITS_PER_WORD
> +/* FLOAT_TYPE_SIZE get poisoned, so add BFIN_ prefix.  */
> +#define BFIN_FLOAT_TYPE_SIZE BITS_PER_WORD
>  #define SHORT_TYPE_SIZE 16 
>  #define CHAR_TYPE_SIZE	8
>  #define INT_TYPE_SIZE	32
> @@ -890,8 +891,8 @@ typedef struct {
>   * #define DOUBLES_ARE_FLOATS 1
>   */
>  
> -#define DOUBLE_TYPE_SIZE	64
> -#define LONG_DOUBLE_TYPE_SIZE	64
> +/* DOUBLE_TYPE_SIZE get poisoned, so add BFIN_ prefix.  */
> +#define BFIN_DOUBLE_TYPE_SIZE	64
>  
>  /* `PROMOTE_MODE (M, UNSIGNEDP, TYPE)'
>       A macro to update M and UNSIGNEDP when an object whose type is



^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: PING^1 [PATCH 42/52] rl78: New hook implementation rl78_c_mode_for_floating_type
  2024-06-13  7:42   ` PING^1 " Kewen.Lin
@ 2024-06-13  7:46     ` Richard Biener
  0 siblings, 0 replies; 149+ messages in thread
From: Richard Biener @ 2024-06-13  7:46 UTC (permalink / raw)
  To: Kewen.Lin; +Cc: gcc-patches, jeffreyalaw, Jeff Law

On Thu, Jun 13, 2024 at 9:43 AM Kewen.Lin <linkw@linux.ibm.com> wrote:
>
> Hi,
>
> Gentle ping:
>
> https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653376.html

The remaining target changes are all OK if the rest of the series is
approved.

Richard.

> BR,
> Kewen
>
> on 2024/6/3 11:01, Kewen Lin wrote:
> > This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> > defines in rl78 port, and add new port specific hook
> > implementation rl78_c_mode_for_floating_type.
> >
> > gcc/ChangeLog:
> >
> >       * config/rl78/rl78.cc (TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
> >       (rl78_c_mode_for_floating_type): New function.
> >       * config/rl78/rl78.h (FLOAT_TYPE_SIZE): Remove.
> >       (DOUBLE_TYPE_SIZE): Likewise.
> >       (LONG_DOUBLE_TYPE_SIZE): Likewise.
> > ---
> >  gcc/config/rl78/rl78.cc | 15 +++++++++++++++
> >  gcc/config/rl78/rl78.h  |  4 ----
> >  2 files changed, 15 insertions(+), 4 deletions(-)
> >
> > diff --git a/gcc/config/rl78/rl78.cc b/gcc/config/rl78/rl78.cc
> > index e5345bfa9dd..ccb1c4f3867 100644
> > --- a/gcc/config/rl78/rl78.cc
> > +++ b/gcc/config/rl78/rl78.cc
> > @@ -4971,6 +4971,21 @@ rl78_preferred_reload_class (rtx x ATTRIBUTE_UNUSED, reg_class_t rclass)
> >    return rclass;
> >  }
> >
> > +#undef TARGET_C_MODE_FOR_FLOATING_TYPE
> > +#define TARGET_C_MODE_FOR_FLOATING_TYPE rl78_c_mode_for_floating_type
> > +
> > +/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return SFmode for
> > +   TI_DOUBLE_TYPE which is for double type, go with the default
> > +   one for the others.  */
> > +
> > +static machine_mode
> > +rl78_c_mode_for_floating_type (enum tree_index ti)
> > +{
> > +  if (ti == TI_DOUBLE_TYPE)
> > +    return SFmode;
> > +  return default_mode_for_floating_type (ti);
> > +}
> > +
> >
> >  /* The strub runtime uses asms, and physical register allocation won't
> >     deal with them, so disable it.  */
> > diff --git a/gcc/config/rl78/rl78.h b/gcc/config/rl78/rl78.h
> > index cfff98df6bc..a960aee3931 100644
> > --- a/gcc/config/rl78/rl78.h
> > +++ b/gcc/config/rl78/rl78.h
> > @@ -113,10 +113,6 @@
> >  #define LONG_TYPE_SIZE                       32
> >  #define LONG_LONG_TYPE_SIZE          64
> >
> > -#define FLOAT_TYPE_SIZE              32
> > -#define DOUBLE_TYPE_SIZE             32 /*64*/
> > -#define LONG_DOUBLE_TYPE_SIZE                64 /*DOUBLE_TYPE_SIZE*/
> > -
> >  #define DEFAULT_SIGNED_CHAR          0
> >
> >  #define STRICT_ALIGNMENT             1
>
>
>

^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 10/52] jit: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  2024-06-03  3:01 ` [PATCH 10/52] jit: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE Kewen Lin
  2024-06-13  7:14   ` PING^1 " Kewen.Lin
@ 2024-06-13 13:44   ` David Malcolm
  2024-06-14  2:16     ` Kewen.Lin
  1 sibling, 1 reply; 149+ messages in thread
From: David Malcolm @ 2024-06-13 13:44 UTC (permalink / raw)
  To: Kewen Lin, gcc-patches, jit

On Sun, 2024-06-02 at 22:01 -0500, Kewen Lin 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.  Unlike the other FEs, for the
> uses in recording::memento_of_get_type::get_size, since
> {float,{,long_}double}_type_node haven't been initialized
> yet, this is to replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> with calling hook targetm.c.mode_for_floating_type.
> 
> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
> 
> gcc/jit/ChangeLog:
> 
>         * jit-recording.cc
> (recording::memento_of_get_type::get_size): Update
>         macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE by calling
>         targetm.c.mode_for_floating_type with
>         TI_{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE.
> ---
>  gcc/jit/jit-recording.cc | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc
> index 68a2e860c1f..7719b898e57 100644
> --- a/gcc/jit/jit-recording.cc
> +++ b/gcc/jit/jit-recording.cc
> @@ -21,7 +21,7 @@ along with GCC; see the file COPYING3.  If not see
>  #include "config.h"
>  #include "system.h"
>  #include "coretypes.h"
> -#include "tm.h"
> +#include "target.h"
>  #include "pretty-print.h"
>  #include "toplev.h"
>  
> @@ -2353,6 +2353,7 @@ size_t
>  recording::memento_of_get_type::get_size ()
>  {
>    int size;
> +  machine_mode m;
>    switch (m_kind)
>      {
>      case GCC_JIT_TYPE_VOID:
> @@ -2399,13 +2400,16 @@ recording::memento_of_get_type::get_size ()
>        size = 128;
>        break;
>      case GCC_JIT_TYPE_FLOAT:
> -      size = FLOAT_TYPE_SIZE;
> +      m = targetm.c.mode_for_floating_type (TI_FLOAT_TYPE);
> +      size = GET_MODE_PRECISION (m).to_constant ();
>        break;
>      case GCC_JIT_TYPE_DOUBLE:
> -      size = DOUBLE_TYPE_SIZE;
> +      m = targetm.c.mode_for_floating_type (TI_DOUBLE_TYPE);
> +      size = GET_MODE_PRECISION (m).to_constant ();
>        break;
>      case GCC_JIT_TYPE_LONG_DOUBLE:
> -      size = LONG_DOUBLE_TYPE_SIZE;
> +      m = targetm.c.mode_for_floating_type (TI_LONG_DOUBLE_TYPE);
> +      size = GET_MODE_PRECISION (m).to_constant ();
>        break;
>      case GCC_JIT_TYPE_SIZE_T:
>        size = MAX_BITS_PER_WORD;

[CCing jit mailing list]

Thanks for the patch; sorry for the delay in responding.

Did your testing include jit?  Note that --enable-languages=all does
*not* include it (due to it needing --enable-host-shared).

The jit::recording code runs *very* early - before toplev::main.  For
example, a call to gcc_jit_type_get_size can trigger the above code
path before toplev::main has run.

target.h says each target should have a:

  struct gcc_target targetm = TARGET_INITIALIZER;

Has targetm.c.mode_for_floating_type been initialized enough by that
static initialization?  Could the mode_for_floating_type hook be
relying on some target-specific dynamic initialization that hasn't run
yet?  (e.g. taking account of command-line options?)

Dave


^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: PING^1 [PATCH 22/52] microblaze: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-13  7:16   ` PING^1 " Kewen.Lin
@ 2024-06-13 17:37     ` Michael Eager
  0 siblings, 0 replies; 149+ messages in thread
From: Michael Eager @ 2024-06-13 17:37 UTC (permalink / raw)
  To: Kewen.Lin, gcc-patches; +Cc: Jeff Law, Jeff Law

OK with me.

On 6/13/24 00:16, Kewen.Lin wrote:
> Hi,
> 
> Gentle ping:
> 
> https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653355.html
> 
> BR,
> Kewen
> 
> on 2024/6/3 11:01, Kewen Lin wrote:
>> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
>> defines in microblaze port.
>>
>> gcc/ChangeLog:
>>
>> 	* config/microblaze/microblaze.h (FLOAT_TYPE_SIZE): Remove.
>> 	(DOUBLE_TYPE_SIZE): Likewise.
>> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.
>> ---
>>   gcc/config/microblaze/microblaze.h | 3 ---
>>   1 file changed, 3 deletions(-)
>>
>> diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
>> index c88a87c12e2..5d28abf9741 100644
>> --- a/gcc/config/microblaze/microblaze.h
>> +++ b/gcc/config/microblaze/microblaze.h
>> @@ -216,9 +216,6 @@ extern enum pipeline_type microblaze_pipe;
>>   #define SHORT_TYPE_SIZE         16
>>   #define LONG_TYPE_SIZE          32
>>   #define LONG_LONG_TYPE_SIZE     64
>> -#define FLOAT_TYPE_SIZE         32
>> -#define DOUBLE_TYPE_SIZE        64
>> -#define LONG_DOUBLE_TYPE_SIZE   64
>>   #define POINTER_SIZE            32
>>   #define PARM_BOUNDARY           32
>>   #define FUNCTION_BOUNDARY       32
> 
> 

-- 
Michael Eager

^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: PING^1 [PATCH 30/52] pdp11: Remove macro LONG_DOUBLE_TYPE_SIZE
  2024-06-13  7:16   ` PING^1 " Kewen.Lin
@ 2024-06-13 20:07     ` Paul Koning
  2024-06-14  3:22       ` [PATCH 30/52 v2] pdp11: Remove macro {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE Kewen.Lin
  0 siblings, 1 reply; 149+ messages in thread
From: Paul Koning @ 2024-06-13 20:07 UTC (permalink / raw)
  To: Kewen.Lin; +Cc: gcc-patches, ni1d, Jeff Law, Jeff Law

What is the effect of this change?  The original code intended to have "float" mean a 32 bit value, and "double" a 64 bit value.  There aren't any larger floats, so I defined the long double size as 64 also.  Is the right answer not to define it?

That part I understand, but why does the patch also remove FLOAT_TYPE_SIZE and DOUBLE_TYPE_SIZE without explanation and without mention in the changelog?

	paul

> On Jun 13, 2024, at 3:16 AM, Kewen.Lin <linkw@linux.ibm.com> wrote:
> 
> Hi,
> 
> Gentle ping:
> 
> https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653368.html
> 
> BR,
> Kewen
> 
> on 2024/6/3 11:01, Kewen Lin wrote:
>> This is to remove macro LONG_DOUBLE_TYPE_SIZE define
>> in pdp11 port.
>> 
>> gcc/ChangeLog:
>> 
>> 	* config/pdp11/pdp11.h (LONG_DOUBLE_TYPE_SIZE): Remove.
>> ---
>> gcc/config/pdp11/pdp11.h | 11 -----------
>> 1 file changed, 11 deletions(-)
>> 
>> diff --git a/gcc/config/pdp11/pdp11.h b/gcc/config/pdp11/pdp11.h
>> index 2446fea0b58..6c8e045bc57 100644
>> --- a/gcc/config/pdp11/pdp11.h
>> +++ b/gcc/config/pdp11/pdp11.h
>> @@ -71,17 +71,6 @@ along with GCC; see the file COPYING3.  If not see
>> #define LONG_TYPE_SIZE		32
>> #define LONG_LONG_TYPE_SIZE	64     
>> 
>> -/* In earlier versions, FLOAT_TYPE_SIZE was selectable as 32 or 64,
>> -   but that conflicts with Fortran language rules.  Since there is no
>> -   obvious reason why we should have that feature -- other targets
>> -   generally don't have float and double the same size -- I've removed
>> -   it.  Note that it continues to be true (for now) that arithmetic is
>> -   always done with 64-bit values, i.e., the FPU is always in "double"
>> -   mode.  */
>> -#define FLOAT_TYPE_SIZE		32
>> -#define DOUBLE_TYPE_SIZE	64
>> -#define LONG_DOUBLE_TYPE_SIZE	64
>> -
>> /* machine types from ansi */
>> #define SIZE_TYPE "short unsigned int" 	/* definition of size_t */
>> #define WCHAR_TYPE "short int" 		/* or long int???? */
> 
> 
> 


^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 10/52] jit: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  2024-06-13 13:44   ` David Malcolm
@ 2024-06-14  2:16     ` Kewen.Lin
  2024-06-24  6:23       ` Kewen.Lin
  2024-06-24 22:25       ` David Malcolm
  0 siblings, 2 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-14  2:16 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches, jit, Richard Biener, Joseph Myers

Hi David,

on 2024/6/13 21:44, David Malcolm wrote:
> On Sun, 2024-06-02 at 22:01 -0500, Kewen Lin 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.  Unlike the other FEs, for the
>> uses in recording::memento_of_get_type::get_size, since
>> {float,{,long_}double}_type_node haven't been initialized
>> yet, this is to replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
>> with calling hook targetm.c.mode_for_floating_type.
>>
>> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
>>
>> gcc/jit/ChangeLog:
>>
>>         * jit-recording.cc
>> (recording::memento_of_get_type::get_size): Update
>>         macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE by calling
>>         targetm.c.mode_for_floating_type with
>>         TI_{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE.
>> ---
>>  gcc/jit/jit-recording.cc | 12 ++++++++----
>>  1 file changed, 8 insertions(+), 4 deletions(-)
>>
>> diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc
>> index 68a2e860c1f..7719b898e57 100644
>> --- a/gcc/jit/jit-recording.cc
>> +++ b/gcc/jit/jit-recording.cc
>> @@ -21,7 +21,7 @@ along with GCC; see the file COPYING3.  If not see
>>  #include "config.h"
>>  #include "system.h"
>>  #include "coretypes.h"
>> -#include "tm.h"
>> +#include "target.h"
>>  #include "pretty-print.h"
>>  #include "toplev.h"
>>  
>> @@ -2353,6 +2353,7 @@ size_t
>>  recording::memento_of_get_type::get_size ()
>>  {
>>    int size;
>> +  machine_mode m;
>>    switch (m_kind)
>>      {
>>      case GCC_JIT_TYPE_VOID:
>> @@ -2399,13 +2400,16 @@ recording::memento_of_get_type::get_size ()
>>        size = 128;
>>        break;
>>      case GCC_JIT_TYPE_FLOAT:
>> -      size = FLOAT_TYPE_SIZE;
>> +      m = targetm.c.mode_for_floating_type (TI_FLOAT_TYPE);
>> +      size = GET_MODE_PRECISION (m).to_constant ();
>>        break;
>>      case GCC_JIT_TYPE_DOUBLE:
>> -      size = DOUBLE_TYPE_SIZE;
>> +      m = targetm.c.mode_for_floating_type (TI_DOUBLE_TYPE);
>> +      size = GET_MODE_PRECISION (m).to_constant ();
>>        break;
>>      case GCC_JIT_TYPE_LONG_DOUBLE:
>> -      size = LONG_DOUBLE_TYPE_SIZE;
>> +      m = targetm.c.mode_for_floating_type (TI_LONG_DOUBLE_TYPE);
>> +      size = GET_MODE_PRECISION (m).to_constant ();
>>        break;
>>      case GCC_JIT_TYPE_SIZE_T:
>>        size = MAX_BITS_PER_WORD;
> 
> [CCing jit mailing list]
> 
> Thanks for the patch; sorry for the delay in responding.
> 
> Did your testing include jit?  Note that --enable-languages=all does
> *not* include it (due to it needing --enable-host-shared).

Thanks for the hints!  Yes, as noted in the cover letter, I did test jit.
Initially I used TYPE_PRECISION ({float,{long_,}double_type_node) to
replace these just like what I proposed for the other FE changes, but the
testing showed some failures on test-combination.c etc., by looking into
them, I realized that this call recording::memento_of_get_type::get_size
can happen before when we set up those type nodes.  Then I had to use the
current approach with the new hook, it made all failures gone (no
regressions).  btw, test result comparison showed some more lines with
"NA->PASS: test-threads.c.exe", since it's positive, I didn't look into
it.

> 
> The jit::recording code runs *very* early - before toplev::main.  For
> example, a call to gcc_jit_type_get_size can trigger the above code
> path before toplev::main has run.
> 
> target.h says each target should have a:
> 
>   struct gcc_target targetm = TARGET_INITIALIZER;
> 
> Has targetm.c.mode_for_floating_type been initialized enough by that
> static initialization?  

It depends on how to define "enough".  The hook has been initialized
as you pointed out, I just debugged it and confirmed target specific
hook was called as expected (rs6000_c_mode_for_floating_type on Power)
when this jit::recording function gets called.  If "enough" refers to
something like command line options, it's not ready.

> Could the mode_for_floating_type hook be
> relying on some target-specific dynamic initialization that hasn't run
> yet?  (e.g. taking account of command-line options?)
> 

Yes, it could.  Like rs6000 port, the hook checks rs6000_long_double_type_size
for long double (it's related to command line option -mlong-double-x) and
some other targets like i386, also would like to check TARGET_LONG_DOUBLE_64
and TARGET_LONG_DOUBLE_128.  But I think it isn't worse than before, without
this change (with the previous macro), we used to define the macro with
the things related to this command line options, which are still not ready.

#define LONG_DOUBLE_TYPE_SIZE rs6000_long_double_type_size

I debugged the code, jit::recording will see rs6000_long_double_type_size
with the static initialized value zero, it means that the function 
recording::memento_of_get_type::get_size would get zero byte size for the
type (I assume that it's unexpected for the code?).  With this new hook,
although it can provide not exact type size (can be off from the one
specified by command line), it returns a reasonable size (comparing with
the zero size).  From this perspective, it's slightly better?

+  if (ti == TI_LONG_DOUBLE_TYPE)
+    return rs6000_long_double_type_size == FLOAT_PRECISION_TFmode ? TFmode
+								  : DFmode;

BR,
Kewen


^ permalink raw reply	[flat|nested] 149+ messages in thread

* [PATCH 30/52 v2] pdp11: Remove macro {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-13 20:07     ` Paul Koning
@ 2024-06-14  3:22       ` Kewen.Lin
  2024-06-14 15:20         ` Paul Koning
  0 siblings, 1 reply; 149+ messages in thread
From: Kewen.Lin @ 2024-06-14  3:22 UTC (permalink / raw)
  To: Paul Koning; +Cc: gcc-patches, ni1d, Jeff Law, Jeff Law

Hi Paul,

on 2024/6/14 04:07, Paul Koning wrote:
> What is the effect of this change?  The original code intended to have "float" mean a 32 bit value, and "double" a 64 bit value.  There aren't any larger floats, so I defined the long double size as 64 also.  Is the right answer not to define it?

Since sub-patch 09/52 will poison {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE, target code building will fail
if it still has these macros.  As I'd like to squash these target changes onto 09/52, so I didn't note
the background/context here, sorry about that.

> 
> That part I understand, but why does the patch also remove FLOAT_TYPE_SIZE and DOUBLE_TYPE_SIZE without explanation and without mention in the changelog?

Oops, thanks for catching!  I just noticed this sub-patch has inconsistent subject & changelog, I should
have noticed this as it has a quite different subject from the others. :(  With your finding, I just
re-visited all the other sub-patches, luckily they are consistent.

The below is the updated revision, hope it looks good to you.  Thanks again.

BR,
Kewen
-----

Subject: [PATCH] pdp11: Remove macro {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE

This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
defines in pdp11 port, as we want to replace these macros
with hook mode_for_floating_type and poison them.

gcc/ChangeLog:

        * config/pdp11/pdp11.h (FLOAT_TYPE_SIZE): Remove.
        (DOUBLE_TYPE_SIZE): Likewise.
        (LONG_DOUBLE_TYPE_SIZE): Likewise.
---
 gcc/config/pdp11/pdp11.h | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/gcc/config/pdp11/pdp11.h b/gcc/config/pdp11/pdp11.h
index 2446fea0b58..6c8e045bc57 100644
--- a/gcc/config/pdp11/pdp11.h
+++ b/gcc/config/pdp11/pdp11.h
@@ -71,17 +71,6 @@ along with GCC; see the file COPYING3.  If not see
 #define LONG_TYPE_SIZE         32
 #define LONG_LONG_TYPE_SIZE    64

-/* In earlier versions, FLOAT_TYPE_SIZE was selectable as 32 or 64,
-   but that conflicts with Fortran language rules.  Since there is no
-   obvious reason why we should have that feature -- other targets
-   generally don't have float and double the same size -- I've removed
-   it.  Note that it continues to be true (for now) that arithmetic is
-   always done with 64-bit values, i.e., the FPU is always in "double"
-   mode.  */
-#define FLOAT_TYPE_SIZE                32
-#define DOUBLE_TYPE_SIZE       64
-#define LONG_DOUBLE_TYPE_SIZE  64
-
 /* machine types from ansi */
 #define SIZE_TYPE "short unsigned int"         /* definition of size_t */
 #define WCHAR_TYPE "short int"                 /* or long int???? */
--
2.43.0



^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: PING^1 [PATCH 44/52] s390: New hook implementation s390_c_mode_for_floating_type
  2024-06-13  7:43   ` PING^1 " Kewen.Lin
@ 2024-06-14  5:40     ` Andreas Krebbel
  0 siblings, 0 replies; 149+ messages in thread
From: Andreas Krebbel @ 2024-06-14  5:40 UTC (permalink / raw)
  To: Kewen.Lin, gcc-patches; +Cc: uweigand

On 6/13/24 09:43, Kewen.Lin wrote:
> Hi,
>
> Gentle ping:
>
> https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653382.html
>
> BR,
> Kewen
>
> on 2024/6/3 11:01, Kewen Lin wrote:
>> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
>> defines in s390 port, and add new port specific hook
>> implementation s390_c_mode_for_floating_type.
>>
>> gcc/ChangeLog:
>>
>> 	* config/s390/s390.cc (s390_c_mode_for_floating_type): New function.
>> 	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
>> 	* config/s390/s390.h (FLOAT_TYPE_SIZE): Remove.
>> 	(DOUBLE_TYPE_SIZE): Likewise.
>> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.

Ok. Thanks!


Andreas



>> ---
>>   gcc/config/s390/s390.cc | 15 +++++++++++++++
>>   gcc/config/s390/s390.h  |  3 ---
>>   2 files changed, 15 insertions(+), 3 deletions(-)
>>
>> diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc
>> index fa517bd3e77..117da36b3c0 100644
>> --- a/gcc/config/s390/s390.cc
>> +++ b/gcc/config/s390/s390.cc
>> @@ -18066,6 +18066,18 @@ s390_noce_conversion_profitable_p (rtx_insn *seq, struct noce_if_info *if_info)
>>     return default_noce_conversion_profitable_p (seq, if_info);
>>   }
>>   
>> +/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE.  Return TFmode or DFmode
>> +   for TI_LONG_DOUBLE_TYPE which is for long double type, go with the
>> +   default one for the others.  */
>> +
>> +static machine_mode
>> +s390_c_mode_for_floating_type (enum tree_index ti)
>> +{
>> +  if (ti == TI_LONG_DOUBLE_TYPE)
>> +    return TARGET_LONG_DOUBLE_128 ? TFmode : DFmode;
>> +  return default_mode_for_floating_type (ti);
>> +}
>> +
>>   /* Initialize GCC target structure.  */
>>   
>>   #undef  TARGET_ASM_ALIGNED_HI_OP
>> @@ -18382,6 +18394,9 @@ s390_noce_conversion_profitable_p (rtx_insn *seq, struct noce_if_info *if_info)
>>   #undef TARGET_NOCE_CONVERSION_PROFITABLE_P
>>   #define TARGET_NOCE_CONVERSION_PROFITABLE_P s390_noce_conversion_profitable_p
>>   
>> +#undef TARGET_C_MODE_FOR_FLOATING_TYPE
>> +#define TARGET_C_MODE_FOR_FLOATING_TYPE s390_c_mode_for_floating_type
>> +
>>   struct gcc_target targetm = TARGET_INITIALIZER;
>>   
>>   #include "gt-s390.h"
>> diff --git a/gcc/config/s390/s390.h b/gcc/config/s390/s390.h
>> index 0e6666a8802..4a4dde1a9ba 100644
>> --- a/gcc/config/s390/s390.h
>> +++ b/gcc/config/s390/s390.h
>> @@ -396,9 +396,6 @@ extern const char *s390_host_detect_local_cpu (int argc, const char **argv);
>>   #define INT_TYPE_SIZE 32
>>   #define LONG_TYPE_SIZE (TARGET_64BIT ? 64 : 32)
>>   #define LONG_LONG_TYPE_SIZE 64
>> -#define FLOAT_TYPE_SIZE 32
>> -#define DOUBLE_TYPE_SIZE 64
>> -#define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
>>   
>>   /* Work around target_flags dependency in ada/targtyps.cc.  */
>>   #define WIDEST_HARDWARE_FP_SIZE 64

^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 30/52 v2] pdp11: Remove macro {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-14  3:22       ` [PATCH 30/52 v2] pdp11: Remove macro {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE Kewen.Lin
@ 2024-06-14 15:20         ` Paul Koning
  2024-06-17  2:01           ` Kewen.Lin
  0 siblings, 1 reply; 149+ messages in thread
From: Paul Koning @ 2024-06-14 15:20 UTC (permalink / raw)
  To: Kewen.Lin; +Cc: GCC Patches, ni1d, Jeff Law, Jeff Law

Ok, I understand better now.  But if those macros are supposed to be replaced by hook functions, could you make that replacement part of the proposed patch?

	paul

> On Jun 13, 2024, at 11:22 PM, Kewen.Lin <linkw@linux.ibm.com> wrote:
> 
> Hi Paul,
> 
> on 2024/6/14 04:07, Paul Koning wrote:
>> What is the effect of this change?  The original code intended to have "float" mean a 32 bit value, and "double" a 64 bit value.  There aren't any larger floats, so I defined the long double size as 64 also.  Is the right answer not to define it?
> 
> Since sub-patch 09/52 will poison {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE, target code building will fail
> if it still has these macros.  As I'd like to squash these target changes onto 09/52, so I didn't note
> the background/context here, sorry about that.
> 
>> 
>> That part I understand, but why does the patch also remove FLOAT_TYPE_SIZE and DOUBLE_TYPE_SIZE without explanation and without mention in the changelog?
> 
> Oops, thanks for catching!  I just noticed this sub-patch has inconsistent subject & changelog, I should
> have noticed this as it has a quite different subject from the others. :(  With your finding, I just
> re-visited all the other sub-patches, luckily they are consistent.
> 
> The below is the updated revision, hope it looks good to you.  Thanks again.
> 
> BR,
> Kewen
> -----
> 
> Subject: [PATCH] pdp11: Remove macro {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
> 
> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> defines in pdp11 port, as we want to replace these macros
> with hook mode_for_floating_type and poison them.
> 
> gcc/ChangeLog:
> 
>        * config/pdp11/pdp11.h (FLOAT_TYPE_SIZE): Remove.
>        (DOUBLE_TYPE_SIZE): Likewise.
>        (LONG_DOUBLE_TYPE_SIZE): Likewise.
> ---
> gcc/config/pdp11/pdp11.h | 11 -----------
> 1 file changed, 11 deletions(-)
> 
> diff --git a/gcc/config/pdp11/pdp11.h b/gcc/config/pdp11/pdp11.h
> index 2446fea0b58..6c8e045bc57 100644
> --- a/gcc/config/pdp11/pdp11.h
> +++ b/gcc/config/pdp11/pdp11.h
> @@ -71,17 +71,6 @@ along with GCC; see the file COPYING3.  If not see
> #define LONG_TYPE_SIZE         32
> #define LONG_LONG_TYPE_SIZE    64
> 
> -/* In earlier versions, FLOAT_TYPE_SIZE was selectable as 32 or 64,
> -   but that conflicts with Fortran language rules.  Since there is no
> -   obvious reason why we should have that feature -- other targets
> -   generally don't have float and double the same size -- I've removed
> -   it.  Note that it continues to be true (for now) that arithmetic is
> -   always done with 64-bit values, i.e., the FPU is always in "double"
> -   mode.  */
> -#define FLOAT_TYPE_SIZE                32
> -#define DOUBLE_TYPE_SIZE       64
> -#define LONG_DOUBLE_TYPE_SIZE  64
> -
> /* machine types from ansi */
> #define SIZE_TYPE "short unsigned int"         /* definition of size_t */
> #define WCHAR_TYPE "short int"                 /* or long int???? */
> --
> 2.43.0
> 
> 


^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 06/52] m2: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  2024-06-12  9:31           ` Kewen.Lin
@ 2024-06-15  5:00             ` Gaius Mulley
  2024-06-17  6:07               ` Kewen.Lin
  0 siblings, 1 reply; 149+ messages in thread
From: Gaius Mulley @ 2024-06-15  5:00 UTC (permalink / raw)
  To: Kewen.Lin; +Cc: Joseph Myers, gcc-patches

"Kewen.Lin" <linkw@linux.ibm.com> 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

^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 30/52 v2] pdp11: Remove macro {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-14 15:20         ` Paul Koning
@ 2024-06-17  2:01           ` Kewen.Lin
  2024-06-17 18:05             ` Paul Koning
  0 siblings, 1 reply; 149+ messages in thread
From: Kewen.Lin @ 2024-06-17  2:01 UTC (permalink / raw)
  To: Paul Koning; +Cc: GCC Patches, ni1d, Jeff Law, Jeff Law

Hi Paul,

on 2024/6/14 23:20, Paul Koning wrote:
> Ok, I understand better now.  But if those macros are supposed to be replaced by hook functions, could you make that replacement part of the proposed patch?

The default implementation of the introduced hook mode_for_floating_type
returns SFmode for float and DFmode for double or long double, which matches
what pdp11 port requires, so there is no need to add its own hook implementation.
This patch series only re-define this hook macro with the customized hook
implementation for those ports which need something beyond the default.

BR,
Kewen

> 
> 	paul
> 
>> On Jun 13, 2024, at 11:22 PM, Kewen.Lin <linkw@linux.ibm.com> wrote:
>>
>> Hi Paul,
>>
>> on 2024/6/14 04:07, Paul Koning wrote:
>>> What is the effect of this change?  The original code intended to have "float" mean a 32 bit value, and "double" a 64 bit value.  There aren't any larger floats, so I defined the long double size as 64 also.  Is the right answer not to define it?
>>
>> Since sub-patch 09/52 will poison {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE, target code building will fail
>> if it still has these macros.  As I'd like to squash these target changes onto 09/52, so I didn't note
>> the background/context here, sorry about that.
>>
>>>
>>> That part I understand, but why does the patch also remove FLOAT_TYPE_SIZE and DOUBLE_TYPE_SIZE without explanation and without mention in the changelog?
>>
>> Oops, thanks for catching!  I just noticed this sub-patch has inconsistent subject & changelog, I should
>> have noticed this as it has a quite different subject from the others. :(  With your finding, I just
>> re-visited all the other sub-patches, luckily they are consistent.
>>
>> The below is the updated revision, hope it looks good to you.  Thanks again.
>>
>> BR,
>> Kewen
>> -----
>>
>> Subject: [PATCH] pdp11: Remove macro {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
>>
>> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
>> defines in pdp11 port, as we want to replace these macros
>> with hook mode_for_floating_type and poison them.
>>
>> gcc/ChangeLog:
>>
>>        * config/pdp11/pdp11.h (FLOAT_TYPE_SIZE): Remove.
>>        (DOUBLE_TYPE_SIZE): Likewise.
>>        (LONG_DOUBLE_TYPE_SIZE): Likewise.
>> ---
>> gcc/config/pdp11/pdp11.h | 11 -----------
>> 1 file changed, 11 deletions(-)
>>
>> diff --git a/gcc/config/pdp11/pdp11.h b/gcc/config/pdp11/pdp11.h
>> index 2446fea0b58..6c8e045bc57 100644
>> --- a/gcc/config/pdp11/pdp11.h
>> +++ b/gcc/config/pdp11/pdp11.h
>> @@ -71,17 +71,6 @@ along with GCC; see the file COPYING3.  If not see
>> #define LONG_TYPE_SIZE         32
>> #define LONG_LONG_TYPE_SIZE    64
>>
>> -/* In earlier versions, FLOAT_TYPE_SIZE was selectable as 32 or 64,
>> -   but that conflicts with Fortran language rules.  Since there is no
>> -   obvious reason why we should have that feature -- other targets
>> -   generally don't have float and double the same size -- I've removed
>> -   it.  Note that it continues to be true (for now) that arithmetic is
>> -   always done with 64-bit values, i.e., the FPU is always in "double"
>> -   mode.  */
>> -#define FLOAT_TYPE_SIZE                32
>> -#define DOUBLE_TYPE_SIZE       64
>> -#define LONG_DOUBLE_TYPE_SIZE  64
>> -
>> /* machine types from ansi */
>> #define SIZE_TYPE "short unsigned int"         /* definition of size_t */
>> #define WCHAR_TYPE "short int"                 /* or long int???? */
>> --
>> 2.43.0
>>
>>
> 


^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 06/52] m2: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  2024-06-15  5:00             ` Gaius Mulley
@ 2024-06-17  6:07               ` Kewen.Lin
  0 siblings, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-17  6:07 UTC (permalink / raw)
  To: Gaius Mulley; +Cc: Joseph Myers, gcc-patches

on 2024/6/15 13:00, Gaius Mulley wrote:
> "Kewen.Lin" <linkw@linux.ibm.com> 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,

Thanks Gaius!  Pushed as r15-1362-g96fe23eb8a9eba.

BR,
Kewen

^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 30/52 v2] pdp11: Remove macro {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-17  2:01           ` Kewen.Lin
@ 2024-06-17 18:05             ` Paul Koning
  0 siblings, 0 replies; 149+ messages in thread
From: Paul Koning @ 2024-06-17 18:05 UTC (permalink / raw)
  To: Kewen.Lin; +Cc: GCC Patches, ni1d, Jeff Law, Jeff Law

Thanks Kewen.

Given that background, the patch is OK.

	paul

> On Jun 16, 2024, at 10:01 PM, Kewen.Lin <linkw@linux.ibm.com> wrote:
> 
> Hi Paul,
> 
> on 2024/6/14 23:20, Paul Koning wrote:
>> Ok, I understand better now.  But if those macros are supposed to be replaced by hook functions, could you make that replacement part of the proposed patch?
> 
> The default implementation of the introduced hook mode_for_floating_type
> returns SFmode for float and DFmode for double or long double, which matches
> what pdp11 port requires, so there is no need to add its own hook implementation.
> This patch series only re-define this hook macro with the customized hook
> implementation for those ports which need something beyond the default.
> 
> BR,
> Kewen
> 
>> 
>> 	paul
>> 
>>> On Jun 13, 2024, at 11:22 PM, Kewen.Lin <linkw@linux.ibm.com> wrote:
>>> 
>>> Hi Paul,
>>> 
>>> on 2024/6/14 04:07, Paul Koning wrote:
>>>> What is the effect of this change?  The original code intended to have "float" mean a 32 bit value, and "double" a 64 bit value.  There aren't any larger floats, so I defined the long double size as 64 also.  Is the right answer not to define it?
>>> 
>>> Since sub-patch 09/52 will poison {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE, target code building will fail
>>> if it still has these macros.  As I'd like to squash these target changes onto 09/52, so I didn't note
>>> the background/context here, sorry about that.
>>> 
>>>> 
>>>> That part I understand, but why does the patch also remove FLOAT_TYPE_SIZE and DOUBLE_TYPE_SIZE without explanation and without mention in the changelog?
>>> 
>>> Oops, thanks for catching!  I just noticed this sub-patch has inconsistent subject & changelog, I should
>>> have noticed this as it has a quite different subject from the others. :(  With your finding, I just
>>> re-visited all the other sub-patches, luckily they are consistent.
>>> 
>>> The below is the updated revision, hope it looks good to you.  Thanks again.
>>> 
>>> BR,
>>> Kewen
>>> -----
>>> 
>>> Subject: [PATCH] pdp11: Remove macro {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
>>> 
>>> This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
>>> defines in pdp11 port, as we want to replace these macros
>>> with hook mode_for_floating_type and poison them.
>>> 
>>> gcc/ChangeLog:
>>> 
>>>       * config/pdp11/pdp11.h (FLOAT_TYPE_SIZE): Remove.
>>>       (DOUBLE_TYPE_SIZE): Likewise.
>>>       (LONG_DOUBLE_TYPE_SIZE): Likewise.
>>> ---
>>> gcc/config/pdp11/pdp11.h | 11 -----------
>>> 1 file changed, 11 deletions(-)
>>> 
>>> diff --git a/gcc/config/pdp11/pdp11.h b/gcc/config/pdp11/pdp11.h
>>> index 2446fea0b58..6c8e045bc57 100644
>>> --- a/gcc/config/pdp11/pdp11.h
>>> +++ b/gcc/config/pdp11/pdp11.h
>>> @@ -71,17 +71,6 @@ along with GCC; see the file COPYING3.  If not see
>>> #define LONG_TYPE_SIZE         32
>>> #define LONG_LONG_TYPE_SIZE    64
>>> 
>>> -/* In earlier versions, FLOAT_TYPE_SIZE was selectable as 32 or 64,
>>> -   but that conflicts with Fortran language rules.  Since there is no
>>> -   obvious reason why we should have that feature -- other targets
>>> -   generally don't have float and double the same size -- I've removed
>>> -   it.  Note that it continues to be true (for now) that arithmetic is
>>> -   always done with 64-bit values, i.e., the FPU is always in "double"
>>> -   mode.  */
>>> -#define FLOAT_TYPE_SIZE                32
>>> -#define DOUBLE_TYPE_SIZE       64
>>> -#define LONG_DOUBLE_TYPE_SIZE  64
>>> -
>>> /* machine types from ansi */
>>> #define SIZE_TYPE "short unsigned int"         /* definition of size_t */
>>> #define WCHAR_TYPE "short int"                 /* or long int???? */
>>> --
>>> 2.43.0
>>> 
>>> 
>> 
> 


^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: PING^1 [PATCH 29/52] or1k: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE
  2024-06-13  7:16   ` PING^1 " Kewen.Lin
@ 2024-06-20 14:18     ` Stafford Horne
  0 siblings, 0 replies; 149+ messages in thread
From: Stafford Horne @ 2024-06-20 14:18 UTC (permalink / raw)
  To: Kewen.Lin; +Cc: gcc-patches, Jeff Law, Jeff Law

On Thu, Jun 13, 2024 at 03:16:44PM +0800, Kewen.Lin wrote:
> Hi,
> 
> Gentle ping:
> 
> https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653363.html

Hello since this is a treewide update I am not the best person to approve just
this single patch.  But it does look good to me as this is what you are doing to
all other architectures.

-Stafford

> BR,
> Kewen
> 
> on 2024/6/3 11:01, Kewen Lin wrote:
> > This is to remove macros {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> > defines in or1k port.
> > 
> > gcc/ChangeLog:
> > 
> > 	* config/or1k/or1k.h (FLOAT_TYPE_SIZE): Remove.
> > 	(DOUBLE_TYPE_SIZE): Likewise.
> > 	(LONG_DOUBLE_TYPE_SIZE): Likewise.
> > ---
> >  gcc/config/or1k/or1k.h | 3 ---
> >  1 file changed, 3 deletions(-)
> > 
> > diff --git a/gcc/config/or1k/or1k.h b/gcc/config/or1k/or1k.h
> > index 0ff73df33e7..a55509f9f32 100644
> > --- a/gcc/config/or1k/or1k.h
> > +++ b/gcc/config/or1k/or1k.h
> > @@ -67,9 +67,6 @@
> >  #define SHORT_TYPE_SIZE 16
> >  #define LONG_TYPE_SIZE 32
> >  #define LONG_LONG_TYPE_SIZE 64
> > -#define FLOAT_TYPE_SIZE 32
> > -#define DOUBLE_TYPE_SIZE 64
> > -#define LONG_DOUBLE_TYPE_SIZE 64
> >  #define WCHAR_TYPE_SIZE 32
> >  
> >  #undef SIZE_TYPE
> 

^ permalink raw reply	[flat|nested] 149+ messages in thread

* PING^2 [PATCH 05/52] rust: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  2024-06-12  9:35   ` PING^1 " Kewen.Lin
@ 2024-06-21  1:48     ` Kewen.Lin
  0 siblings, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-21  1:48 UTC (permalink / raw)
  To: arthur.cohen, gcc-rust; +Cc: herron.philip, gcc-patches

Hi!

Gentle ping^2:

https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653339.html

BR,
Kewen

on 2024/6/12 17:35, Kewen.Lin wrote:
> Hi,
> 
> Gentle ping:
> 
> https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653339.html
> 
> BR,
> Kewen
> 
> on 2024/6/3 11:00, Kewen Lin 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 {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
>> in rust with TYPE_PRECISION of {float,{,long_}double}_type_node.
>>
>> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
>>
>> gcc/rust/ChangeLog:
>>
>> 	* rust-gcc.cc (float_type): Use TYPE_PRECISION of
>> 	{float,double,long_double}_type_node to replace
>> 	{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE.
>> ---
>>  gcc/rust/rust-gcc.cc | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
>> index f17e19a2dfc..38169c08985 100644
>> --- a/gcc/rust/rust-gcc.cc
>> +++ b/gcc/rust/rust-gcc.cc
>> @@ -411,11 +411,11 @@ tree
>>  float_type (int bits)
>>  {
>>    tree type;
>> -  if (bits == FLOAT_TYPE_SIZE)
>> +  if (bits == TYPE_PRECISION (float_type_node))
>>      type = float_type_node;
>> -  else if (bits == DOUBLE_TYPE_SIZE)
>> +  else if (bits == TYPE_PRECISION (double_type_node))
>>      type = double_type_node;
>> -  else if (bits == LONG_DOUBLE_TYPE_SIZE)
>> +  else if (bits == TYPE_PRECISION (long_double_type_node))
>>      type = long_double_type_node;
>>    else
>>      {
> 


^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 05/52] rust: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  2024-06-03  3:00 ` [PATCH 05/52] rust: " Kewen Lin
  2024-06-12  9:35   ` PING^1 " Kewen.Lin
@ 2024-06-21 10:17   ` Arthur Cohen
  2024-06-21 10:36     ` Kewen.Lin
  1 sibling, 1 reply; 149+ messages in thread
From: Arthur Cohen @ 2024-06-21 10:17 UTC (permalink / raw)
  To: Kewen Lin, gcc-patches; +Cc: herron.philip

Hi,

Sorry about the delay in my answer! The patch looks good to me :) Will 
you push it as part of your patchset?

Kindly,

Arthur

On 6/3/24 05:00, Kewen Lin 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 {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> in rust with TYPE_PRECISION of {float,{,long_}double}_type_node.
> 
> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
> 
> gcc/rust/ChangeLog:
> 
> 	* rust-gcc.cc (float_type): Use TYPE_PRECISION of
> 	{float,double,long_double}_type_node to replace
> 	{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE.
> ---
>   gcc/rust/rust-gcc.cc | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
> index f17e19a2dfc..38169c08985 100644
> --- a/gcc/rust/rust-gcc.cc
> +++ b/gcc/rust/rust-gcc.cc
> @@ -411,11 +411,11 @@ tree
>   float_type (int bits)
>   {
>     tree type;
> -  if (bits == FLOAT_TYPE_SIZE)
> +  if (bits == TYPE_PRECISION (float_type_node))
>       type = float_type_node;
> -  else if (bits == DOUBLE_TYPE_SIZE)
> +  else if (bits == TYPE_PRECISION (double_type_node))
>       type = double_type_node;
> -  else if (bits == LONG_DOUBLE_TYPE_SIZE)
> +  else if (bits == TYPE_PRECISION (long_double_type_node))
>       type = long_double_type_node;
>     else
>       {

^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 05/52] rust: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  2024-06-21 10:17   ` Arthur Cohen
@ 2024-06-21 10:36     ` Kewen.Lin
  2024-06-25  5:42       ` Kewen.Lin
  2024-06-25 10:14       ` Arthur Cohen
  0 siblings, 2 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-21 10:36 UTC (permalink / raw)
  To: Arthur Cohen; +Cc: herron.philip, gcc-patches

Hi Arthur,

on 2024/6/21 18:17, Arthur Cohen wrote:
> Hi,
> 
> Sorry about the delay in my answer! The patch looks good to me :) Will you push it as part of your patchset?
> 

Thanks for the review!  Since this one doesn't necessarily depend on
"09/52 Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook
mode_for_floating_type", I'm going to push this before that (just like
the other FE changes excepting for the jit one 10/52 which depends on
the new hook 09/52).  btw, all after 09/52 would be merged into 09/52
when committing. :)

Does it sound good to you?

BR,
Kewen

> Kindly,
> 
> Arthur
> 
> On 6/3/24 05:00, Kewen Lin 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 {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
>> in rust with TYPE_PRECISION of {float,{,long_}double}_type_node.
>>
>> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
>>
>> gcc/rust/ChangeLog:
>>
>>     * rust-gcc.cc (float_type): Use TYPE_PRECISION of
>>     {float,double,long_double}_type_node to replace
>>     {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE.
>> ---
>>   gcc/rust/rust-gcc.cc | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
>> index f17e19a2dfc..38169c08985 100644
>> --- a/gcc/rust/rust-gcc.cc
>> +++ b/gcc/rust/rust-gcc.cc
>> @@ -411,11 +411,11 @@ tree
>>   float_type (int bits)
>>   {
>>     tree type;
>> -  if (bits == FLOAT_TYPE_SIZE)
>> +  if (bits == TYPE_PRECISION (float_type_node))
>>       type = float_type_node;
>> -  else if (bits == DOUBLE_TYPE_SIZE)
>> +  else if (bits == TYPE_PRECISION (double_type_node))
>>       type = double_type_node;
>> -  else if (bits == LONG_DOUBLE_TYPE_SIZE)
>> +  else if (bits == TYPE_PRECISION (long_double_type_node))
>>       type = long_double_type_node;
>>     else
>>       {

^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 10/52] jit: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  2024-06-14  2:16     ` Kewen.Lin
@ 2024-06-24  6:23       ` Kewen.Lin
  2024-06-24 22:25       ` David Malcolm
  1 sibling, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-24  6:23 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches, jit, Richard Biener, Joseph Myers

Hi Dave,

May I ask if you still have some concerns on this patch with some
replies to your previous questions?

BR,
Kewen

on 2024/6/14 10:16, Kewen.Lin wrote:
> Hi David,
> 
> on 2024/6/13 21:44, David Malcolm wrote:
>> On Sun, 2024-06-02 at 22:01 -0500, Kewen Lin 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.  Unlike the other FEs, for the
>>> uses in recording::memento_of_get_type::get_size, since
>>> {float,{,long_}double}_type_node haven't been initialized
>>> yet, this is to replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
>>> with calling hook targetm.c.mode_for_floating_type.
>>>
>>> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
>>>
>>> gcc/jit/ChangeLog:
>>>
>>>         * jit-recording.cc
>>> (recording::memento_of_get_type::get_size): Update
>>>         macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE by calling
>>>         targetm.c.mode_for_floating_type with
>>>         TI_{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE.
>>> ---
>>>  gcc/jit/jit-recording.cc | 12 ++++++++----
>>>  1 file changed, 8 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc
>>> index 68a2e860c1f..7719b898e57 100644
>>> --- a/gcc/jit/jit-recording.cc
>>> +++ b/gcc/jit/jit-recording.cc
>>> @@ -21,7 +21,7 @@ along with GCC; see the file COPYING3.  If not see
>>>  #include "config.h"
>>>  #include "system.h"
>>>  #include "coretypes.h"
>>> -#include "tm.h"
>>> +#include "target.h"
>>>  #include "pretty-print.h"
>>>  #include "toplev.h"
>>>  
>>> @@ -2353,6 +2353,7 @@ size_t
>>>  recording::memento_of_get_type::get_size ()
>>>  {
>>>    int size;
>>> +  machine_mode m;
>>>    switch (m_kind)
>>>      {
>>>      case GCC_JIT_TYPE_VOID:
>>> @@ -2399,13 +2400,16 @@ recording::memento_of_get_type::get_size ()
>>>        size = 128;
>>>        break;
>>>      case GCC_JIT_TYPE_FLOAT:
>>> -      size = FLOAT_TYPE_SIZE;
>>> +      m = targetm.c.mode_for_floating_type (TI_FLOAT_TYPE);
>>> +      size = GET_MODE_PRECISION (m).to_constant ();
>>>        break;
>>>      case GCC_JIT_TYPE_DOUBLE:
>>> -      size = DOUBLE_TYPE_SIZE;
>>> +      m = targetm.c.mode_for_floating_type (TI_DOUBLE_TYPE);
>>> +      size = GET_MODE_PRECISION (m).to_constant ();
>>>        break;
>>>      case GCC_JIT_TYPE_LONG_DOUBLE:
>>> -      size = LONG_DOUBLE_TYPE_SIZE;
>>> +      m = targetm.c.mode_for_floating_type (TI_LONG_DOUBLE_TYPE);
>>> +      size = GET_MODE_PRECISION (m).to_constant ();
>>>        break;
>>>      case GCC_JIT_TYPE_SIZE_T:
>>>        size = MAX_BITS_PER_WORD;
>>
>> [CCing jit mailing list]
>>
>> Thanks for the patch; sorry for the delay in responding.
>>
>> Did your testing include jit?  Note that --enable-languages=all does
>> *not* include it (due to it needing --enable-host-shared).
> 
> Thanks for the hints!  Yes, as noted in the cover letter, I did test jit.
> Initially I used TYPE_PRECISION ({float,{long_,}double_type_node) to
> replace these just like what I proposed for the other FE changes, but the
> testing showed some failures on test-combination.c etc., by looking into
> them, I realized that this call recording::memento_of_get_type::get_size
> can happen before when we set up those type nodes.  Then I had to use the
> current approach with the new hook, it made all failures gone (no
> regressions).  btw, test result comparison showed some more lines with
> "NA->PASS: test-threads.c.exe", since it's positive, I didn't look into
> it.
> 
>>
>> The jit::recording code runs *very* early - before toplev::main.  For
>> example, a call to gcc_jit_type_get_size can trigger the above code
>> path before toplev::main has run.
>>
>> target.h says each target should have a:
>>
>>   struct gcc_target targetm = TARGET_INITIALIZER;
>>
>> Has targetm.c.mode_for_floating_type been initialized enough by that
>> static initialization?  
> 
> It depends on how to define "enough".  The hook has been initialized
> as you pointed out, I just debugged it and confirmed target specific
> hook was called as expected (rs6000_c_mode_for_floating_type on Power)
> when this jit::recording function gets called.  If "enough" refers to
> something like command line options, it's not ready.
> 
>> Could the mode_for_floating_type hook be
>> relying on some target-specific dynamic initialization that hasn't run
>> yet?  (e.g. taking account of command-line options?)
>>
> 
> Yes, it could.  Like rs6000 port, the hook checks rs6000_long_double_type_size
> for long double (it's related to command line option -mlong-double-x) and
> some other targets like i386, also would like to check TARGET_LONG_DOUBLE_64
> and TARGET_LONG_DOUBLE_128.  But I think it isn't worse than before, without
> this change (with the previous macro), we used to define the macro with
> the things related to this command line options, which are still not ready.
> 
> #define LONG_DOUBLE_TYPE_SIZE rs6000_long_double_type_size
> 
> I debugged the code, jit::recording will see rs6000_long_double_type_size
> with the static initialized value zero, it means that the function 
> recording::memento_of_get_type::get_size would get zero byte size for the
> type (I assume that it's unexpected for the code?).  With this new hook,
> although it can provide not exact type size (can be off from the one
> specified by command line), it returns a reasonable size (comparing with
> the zero size).  From this perspective, it's slightly better?
> 
> +  if (ti == TI_LONG_DOUBLE_TYPE)
> +    return rs6000_long_double_type_size == FLOAT_PRECISION_TFmode ? TFmode
> +								  : DFmode;
> 
> BR,
> Kewen
> 

^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 10/52] jit: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  2024-06-14  2:16     ` Kewen.Lin
  2024-06-24  6:23       ` Kewen.Lin
@ 2024-06-24 22:25       ` David Malcolm
  1 sibling, 0 replies; 149+ messages in thread
From: David Malcolm @ 2024-06-24 22:25 UTC (permalink / raw)
  To: Kewen.Lin; +Cc: gcc-patches, jit, Richard Biener, Joseph Myers

On Fri, 2024-06-14 at 10:16 +0800, Kewen.Lin wrote:
> Hi David,
> 
> on 2024/6/13 21:44, David Malcolm wrote:
> > On Sun, 2024-06-02 at 22:01 -0500, Kewen Lin 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.  Unlike the other FEs, for the
> > > uses in recording::memento_of_get_type::get_size, since
> > > {float,{,long_}double}_type_node haven't been initialized
> > > yet, this is to replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
> > > with calling hook targetm.c.mode_for_floating_type.
> > > 
> > > [1]
> > > https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
> > > 
> > > gcc/jit/ChangeLog:
> > > 
> > >         * jit-recording.cc
> > > (recording::memento_of_get_type::get_size): Update
> > >         macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE by calling
> > >         targetm.c.mode_for_floating_type with
> > >         TI_{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE.
> > > ---
> > >  gcc/jit/jit-recording.cc | 12 ++++++++----
> > >  1 file changed, 8 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc
> > > index 68a2e860c1f..7719b898e57 100644
> > > --- a/gcc/jit/jit-recording.cc
> > > +++ b/gcc/jit/jit-recording.cc
> > > @@ -21,7 +21,7 @@ along with GCC; see the file COPYING3.  If not
> > > see
> > >  #include "config.h"
> > >  #include "system.h"
> > >  #include "coretypes.h"
> > > -#include "tm.h"
> > > +#include "target.h"
> > >  #include "pretty-print.h"
> > >  #include "toplev.h"
> > >  
> > > @@ -2353,6 +2353,7 @@ size_t
> > >  recording::memento_of_get_type::get_size ()
> > >  {
> > >    int size;
> > > +  machine_mode m;
> > >    switch (m_kind)
> > >      {
> > >      case GCC_JIT_TYPE_VOID:
> > > @@ -2399,13 +2400,16 @@ recording::memento_of_get_type::get_size
> > > ()
> > >        size = 128;
> > >        break;
> > >      case GCC_JIT_TYPE_FLOAT:
> > > -      size = FLOAT_TYPE_SIZE;
> > > +      m = targetm.c.mode_for_floating_type (TI_FLOAT_TYPE);
> > > +      size = GET_MODE_PRECISION (m).to_constant ();
> > >        break;
> > >      case GCC_JIT_TYPE_DOUBLE:
> > > -      size = DOUBLE_TYPE_SIZE;
> > > +      m = targetm.c.mode_for_floating_type (TI_DOUBLE_TYPE);
> > > +      size = GET_MODE_PRECISION (m).to_constant ();
> > >        break;
> > >      case GCC_JIT_TYPE_LONG_DOUBLE:
> > > -      size = LONG_DOUBLE_TYPE_SIZE;
> > > +      m = targetm.c.mode_for_floating_type
> > > (TI_LONG_DOUBLE_TYPE);
> > > +      size = GET_MODE_PRECISION (m).to_constant ();
> > >        break;
> > >      case GCC_JIT_TYPE_SIZE_T:
> > >        size = MAX_BITS_PER_WORD;
> > 
> > [CCing jit mailing list]
> > 
> > Thanks for the patch; sorry for the delay in responding.
> > 
> > Did your testing include jit?  Note that --enable-languages=all
> > does
> > *not* include it (due to it needing --enable-host-shared).
> 
> Thanks for the hints!  Yes, as noted in the cover letter, I did test
> jit.
> Initially I used TYPE_PRECISION ({float,{long_,}double_type_node) to
> replace these just like what I proposed for the other FE changes, but
> the
> testing showed some failures on test-combination.c etc., by looking
> into
> them, I realized that this call
> recording::memento_of_get_type::get_size
> can happen before when we set up those type nodes.  Then I had to use
> the
> current approach with the new hook, it made all failures gone (no
> regressions).  btw, test result comparison showed some more lines
> with
> "NA->PASS: test-threads.c.exe", since it's positive, I didn't look
> into
> it.
> 
> > 
> > The jit::recording code runs *very* early - before toplev::main. 
> > For
> > example, a call to gcc_jit_type_get_size can trigger the above code
> > path before toplev::main has run.
> > 
> > target.h says each target should have a:
> > 
> >   struct gcc_target targetm = TARGET_INITIALIZER;
> > 
> > Has targetm.c.mode_for_floating_type been initialized enough by
> > that
> > static initialization?  
> 
> It depends on how to define "enough".  The hook has been initialized
> as you pointed out, I just debugged it and confirmed target specific
> hook was called as expected (rs6000_c_mode_for_floating_type on
> Power)
> when this jit::recording function gets called.  If "enough" refers to
> something like command line options, it's not ready.
> 
> > Could the mode_for_floating_type hook be
> > relying on some target-specific dynamic initialization that hasn't
> > run
> > yet?  (e.g. taking account of command-line options?)
> > 
> 
> Yes, it could.  Like rs6000 port, the hook checks
> rs6000_long_double_type_size
> for long double (it's related to command line option -mlong-double-x)
> and
> some other targets like i386, also would like to check
> TARGET_LONG_DOUBLE_64
> and TARGET_LONG_DOUBLE_128.  But I think it isn't worse than before,
> without
> this change (with the previous macro), we used to define the macro
> with
> the things related to this command line options, which are still not
> ready.
> 
> #define LONG_DOUBLE_TYPE_SIZE rs6000_long_double_type_size
> 
> I debugged the code, jit::recording will see
> rs6000_long_double_type_size
> with the static initialized value zero, it means that the function 
> recording::memento_of_get_type::get_size would get zero byte size for
> the
> type (I assume that it's unexpected for the code?).  With this new
> hook,
> although it can provide not exact type size (can be off from the one
> specified by command line), it returns a reasonable size (comparing
> with
> the zero size).  From this perspective, it's slightly better?
> 
> +  if (ti == TI_LONG_DOUBLE_TYPE)
> +    return rs6000_long_double_type_size == FLOAT_PRECISION_TFmode ?
> TFmode
> +                                                                 :
> DFmode;

Thanks for looking into it.

Given the various points you make above, the patch is OK.

Thanks
Dave


^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 09/52 v2] Replace {FLOAT, {, LONG_}DOUBLE}_TYPE_SIZE with new hook mode_for_floating_type
  2024-06-04  3:27     ` [PATCH 09/52 v2] " Kewen.Lin
@ 2024-06-25  5:20       ` Kewen.Lin
  0 siblings, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-25  5:20 UTC (permalink / raw)
  To: gcc-patches
  Cc: richard.guenther, segher, bergner, richard.sandiford, jakub,
	jeffreyalaw, Joseph S. Myers, Dave Malcolm, Nick Clifton,
	Andrew Stubbs, eager, Hans-Peter Nilsson, sloosemore, shorne,
	Paul Koning, dimitar, augustine.sterling, Uros Bizjak,
	kito.cheng, Andreas Krebbel, Oleg Endo, chenglulu, syq,
	dave.anglin, Eric Botcazou

Hi all,

I just pushed this 09/52 v2 with its following target changes
as r15-1594, thanks a lot for your comments/reviews/approvals!

BR,
Kewen

> Subject: [PATCH 09/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook
>  mode_for_floating_type
> 
> Currently how we determine which mode will be used for a
> floating point type is that for a given type precision
> (size) call mode_for_size to get the first mode which has
> this size in the specified class.  On Powerpc, we have
> three modes (TF/KF/IF) having the same mode precision 128
> (see[1]), so the processing forces us to have to place TF
> at the first place, it would require us to make more
> adjustment in some generic code to avoid some unexpected
> mode conversions and it would be even worse if we get rid
> of TF eventually one day.  And as Joseph pointed out in [2],
> "floating types should have their mode, not a poorly
> defined precision value", as Joseph and Richi suggested,
> this patch is to introduce one hook mode_for_floating_type
> which returns the corresponding mode for type float, double
> or long double.  The default implementation returns SFmode
> for float and DFmode for double or long double.  For ports
> which need special treatment, there are some other patches
> for their own port specific implementation (referring to
> how {,LONG_}DOUBLE_TYPE_SIZE get used there).  For all
> generic uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE, depending
> on the context, some of them are replaced with TYPE_PRECISION
> of the according type node, some other are replaced with
> GET_MODE_PRECISION on the mode from mode_for_floating_type.
> This patch also poisons {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE,
> so most defines of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE in port
> specific are removed, but there are still some which are
> good to be kept for readability then they get renamed with
> port specific prefix.
> 
> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651017.html
> [2] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
> 
> gcc/ChangeLog:
> 
> 	* coretypes.h (enum tree_index): Forward declaration.
> 	* defaults.h (FLOAT_TYPE_SIZE): Remove.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.
> 	* doc/rtl.texi: Update document by replacing {FLOAT,DOUBLE}_TYPE_SIZE
> 	with C type {float,double}.
> 	* doc/tm.texi.in: Document new hook mode_for_floating_type, remove
> 	document entries for {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE and
> 	update document for WIDEST_HARDWARE_FP_SIZE.
> 	* doc/tm.texi: Regenerate.
> 	* emit-rtl.cc (init_emit_once): Replace DOUBLE_TYPE_SIZE by
> 	calling targetm.c.mode_for_floating_type with TI_DOUBLE_TYPE.
> 	* real.h (REAL_VALUE_TO_TARGET_LONG_DOUBLE): Use TYPE_PRECISION of
> 	long_double_type_node to replace LONG_DOUBLE_TYPE_SIZE.
> 	* system.h (FLOAT_TYPE_SIZE): Poison.
> 	(DOUBLE_TYPE_SIZE): Likewise.
> 	(LONG_DOUBLE_TYPE_SIZE): Likewise.
> 	* target.def (mode_for_floating_type): New hook.
> 	* targhooks.cc (default_mode_for_floating_type): New function.
> 	(default_scalar_mode_supported_p): Update macros
> 	{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE by calling
> 	targetm.c.mode_for_floating_type with
> 	TI_{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE.
> 	* targhooks.h (default_mode_for_floating_type): New declaration.
> 	* tree-core.h (enum tree_index): Specify underlying type unsigned
> 	to sync with forward declaration in coretypes.h.
> 	(NUM_FLOATN_TYPES): Explicitly convert to int.
> 	(NUM_FLOATNX_TYPES): Likewise.
> 	(NUM_FLOATN_NX_TYPES): Likewise.
> 	* tree.cc (build_common_tree_nodes): Update macros
> 	{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE by calling
> 	targetm.c.mode_for_floating_type with
> 	TI_{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE and set type mode accordingly.
> ---
>  gcc/coretypes.h    |  1 +
>  gcc/defaults.h     | 12 ------------
>  gcc/doc/rtl.texi   |  2 +-
>  gcc/doc/tm.texi    | 33 +++++++++++++--------------------
>  gcc/doc/tm.texi.in | 27 +++++++--------------------
>  gcc/emit-rtl.cc    |  3 ++-
>  gcc/real.h         |  7 ++++---
>  gcc/system.h       |  3 ++-
>  gcc/target.def     |  9 +++++++++
>  gcc/targhooks.cc   | 18 +++++++++++++++---
>  gcc/targhooks.h    |  1 +
>  gcc/tree-core.h    | 13 +++++++------
>  gcc/tree.cc        | 18 +++++++++++++++---
>  13 files changed, 77 insertions(+), 70 deletions(-)
> 
> diff --git a/gcc/coretypes.h b/gcc/coretypes.h
> index 1ac6f0abea3..00c1c58bd8c 100644
> --- a/gcc/coretypes.h
> +++ b/gcc/coretypes.h
> @@ -100,6 +100,7 @@ struct gimple;
>  typedef gimple *gimple_seq;
>  struct gimple_stmt_iterator;
>  class code_helper;
> +enum tree_index : unsigned;
> 
>  /* Forward declare rtx_code, so that we can use it in target hooks without
>     needing to pull in rtl.h.  */
> diff --git a/gcc/defaults.h b/gcc/defaults.h
> index 92f3e07f742..ac2d25852ab 100644
> --- a/gcc/defaults.h
> +++ b/gcc/defaults.h
> @@ -513,18 +513,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
>  #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
>  #endif
> 
> -#ifndef FLOAT_TYPE_SIZE
> -#define FLOAT_TYPE_SIZE BITS_PER_WORD
> -#endif
> -
> -#ifndef DOUBLE_TYPE_SIZE
> -#define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
> -#endif
> -
> -#ifndef LONG_DOUBLE_TYPE_SIZE
> -#define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
> -#endif
> -
>  #ifndef DECIMAL32_TYPE_SIZE
>  #define DECIMAL32_TYPE_SIZE 32
>  #endif
> diff --git a/gcc/doc/rtl.texi b/gcc/doc/rtl.texi
> index aa10b5235b5..61981ae5a41 100644
> --- a/gcc/doc/rtl.texi
> +++ b/gcc/doc/rtl.texi
> @@ -1326,7 +1326,7 @@ whose size is @code{BITS_PER_WORD}, @code{SImode} on 32-bit machines.
> 
>  The only modes which a machine description @i{must} support are
>  @code{QImode}, and the modes corresponding to @code{BITS_PER_WORD},
> -@code{FLOAT_TYPE_SIZE} and @code{DOUBLE_TYPE_SIZE}.
> +C type @code{float} and C type @code{double}.
>  The compiler will attempt to use @code{DImode} for 8-byte structures and
>  unions, but this can be prevented by overriding the definition of
>  @code{MAX_FIXED_MODE_SIZE}.  Alternatively, you can have the compiler
> diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
> index cd50078227d..305c4f3aed2 100644
> --- a/gcc/doc/tm.texi
> +++ b/gcc/doc/tm.texi
> @@ -1044,6 +1044,14 @@ are zero or sign extended depending on if it is
>  @code{GET_MODE_ALIGNMENT (info->limb_mode)}.
>  @end deftypefn
> 
> +@deftypefn {Target Hook} machine_mode TARGET_C_MODE_FOR_FLOATING_TYPE (enum tree_index @var{ti})
> +Return machine mode for a C floating point type which is indicated by
> + a given @code{enum tree_index} @var{ti}, @var{ti} should be
> + @code{TI_FLOAT_TYPE}, @code{TI_DOUBLE_TYPE} or @code{TI_LONG_DOUBLE_TYPE}.
> + The default implementation returns @code{SFmode} for @code{TI_FLOAT_TYPE},
> + and @code{DFmode} for @code{TI_DOUBLE_TYPE} or @code{TI_LONG_DOUBLE_TYPE}.
> +@end deftypefn
> +
>  @deftypefn {Target Hook} machine_mode TARGET_PROMOTE_FUNCTION_MODE (const_tree @var{type}, machine_mode @var{mode}, int *@var{punsignedp}, const_tree @var{funtype}, int @var{for_return})
>  Like @code{PROMOTE_MODE}, but it is applied to outgoing function arguments or
>  function return values.  The target hook should return the new mode
> @@ -1610,23 +1618,6 @@ C99 type @code{_Bool} on the target machine.  If you don't define
>  this, and you probably shouldn't, the default is @code{CHAR_TYPE_SIZE}.
>  @end defmac
> 
> -@defmac FLOAT_TYPE_SIZE
> -A C expression for the size in bits of the type @code{float} on the
> -target machine.  If you don't define this, the default is one word.
> -@end defmac
> -
> -@defmac DOUBLE_TYPE_SIZE
> -A C expression for the size in bits of the type @code{double} on the
> -target machine.  If you don't define this, the default is two
> -words.
> -@end defmac
> -
> -@defmac LONG_DOUBLE_TYPE_SIZE
> -A C expression for the size in bits of the type @code{long double} on
> -the target machine.  If you don't define this, the default is two
> -words.
> -@end defmac
> -
>  @defmac SHORT_FRACT_TYPE_SIZE
>  A C expression for the size in bits of the type @code{short _Fract} on
>  the target machine.  If you don't define this, the default is
> @@ -1687,9 +1678,11 @@ the libgcc @file{config.host}.
>  @defmac WIDEST_HARDWARE_FP_SIZE
>  A C expression for the size in bits of the widest floating-point format
>  supported by the hardware.  If you define this macro, you must specify a
> -value less than or equal to the value of @code{LONG_DOUBLE_TYPE_SIZE}.
> -If you do not define this macro, the value of @code{LONG_DOUBLE_TYPE_SIZE}
> -is the default.
> +value less than or equal to mode precision of the mode used for C type
> +@code{long double} (from hook @code{targetm.c.mode_for_floating_type}
> +with argument @code{TI_LONG_DOUBLE_TYPE}).  If you do not define this
> +macro, mode precision of the mode used for C type @code{long double} is
> +the default.
>  @end defmac
> 
>  @defmac DEFAULT_SIGNED_CHAR
> diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
> index 058bd56487a..8de7e393a70 100644
> --- a/gcc/doc/tm.texi.in
> +++ b/gcc/doc/tm.texi.in
> @@ -947,6 +947,8 @@ applied.
> 
>  @hook TARGET_C_BITINT_TYPE_INFO
> 
> +@hook TARGET_C_MODE_FOR_FLOATING_TYPE
> +
>  @hook TARGET_PROMOTE_FUNCTION_MODE
> 
>  @defmac PARM_BOUNDARY
> @@ -1351,23 +1353,6 @@ C99 type @code{_Bool} on the target machine.  If you don't define
>  this, and you probably shouldn't, the default is @code{CHAR_TYPE_SIZE}.
>  @end defmac
> 
> -@defmac FLOAT_TYPE_SIZE
> -A C expression for the size in bits of the type @code{float} on the
> -target machine.  If you don't define this, the default is one word.
> -@end defmac
> -
> -@defmac DOUBLE_TYPE_SIZE
> -A C expression for the size in bits of the type @code{double} on the
> -target machine.  If you don't define this, the default is two
> -words.
> -@end defmac
> -
> -@defmac LONG_DOUBLE_TYPE_SIZE
> -A C expression for the size in bits of the type @code{long double} on
> -the target machine.  If you don't define this, the default is two
> -words.
> -@end defmac
> -
>  @defmac SHORT_FRACT_TYPE_SIZE
>  A C expression for the size in bits of the type @code{short _Fract} on
>  the target machine.  If you don't define this, the default is
> @@ -1428,9 +1413,11 @@ the libgcc @file{config.host}.
>  @defmac WIDEST_HARDWARE_FP_SIZE
>  A C expression for the size in bits of the widest floating-point format
>  supported by the hardware.  If you define this macro, you must specify a
> -value less than or equal to the value of @code{LONG_DOUBLE_TYPE_SIZE}.
> -If you do not define this macro, the value of @code{LONG_DOUBLE_TYPE_SIZE}
> -is the default.
> +value less than or equal to mode precision of the mode used for C type
> +@code{long double} (from hook @code{targetm.c.mode_for_floating_type}
> +with argument @code{TI_LONG_DOUBLE_TYPE}).  If you do not define this
> +macro, mode precision of the mode used for C type @code{long double} is
> +the default.
>  @end defmac
> 
>  @defmac DEFAULT_SIGNED_CHAR
> diff --git a/gcc/emit-rtl.cc b/gcc/emit-rtl.cc
> index 1856fa4884f..cb04aa1a8c6 100644
> --- a/gcc/emit-rtl.cc
> +++ b/gcc/emit-rtl.cc
> @@ -6366,7 +6366,8 @@ init_emit_once (void)
>    else
>      const_true_rtx = gen_rtx_CONST_INT (VOIDmode, STORE_FLAG_VALUE);
> 
> -  double_mode = float_mode_for_size (DOUBLE_TYPE_SIZE).require ();
> +  mode = targetm.c.mode_for_floating_type (TI_DOUBLE_TYPE);
> +  double_mode = as_a<scalar_float_mode> (mode);
> 
>    real_from_integer (&dconst0, double_mode, 0, SIGNED);
>    real_from_integer (&dconst1, double_mode, 1, SIGNED);
> diff --git a/gcc/real.h b/gcc/real.h
> index 2e40817a2d7..f28022769b3 100644
> --- a/gcc/real.h
> +++ b/gcc/real.h
> @@ -406,9 +406,10 @@ extern const struct real_format arm_bfloat_half_format;
>  #define REAL_VALUE_MINUS_ZERO(x)	real_isnegzero (&(x))
> 
>  /* IN is a REAL_VALUE_TYPE.  OUT is an array of longs.  */
> -#define REAL_VALUE_TO_TARGET_LONG_DOUBLE(IN, OUT)			\
> -  real_to_target (OUT, &(IN),						\
> -		  float_mode_for_size (LONG_DOUBLE_TYPE_SIZE).require ())
> +#define REAL_VALUE_TO_TARGET_LONG_DOUBLE(IN, OUT)			   \
> +  real_to_target (OUT, &(IN),						   \
> +		  float_mode_for_size (TYPE_PRECISION			   \
> +				       (long_double_type_node)).require ())
> 
>  #define REAL_VALUE_TO_TARGET_DOUBLE(IN, OUT) \
>    real_to_target (OUT, &(IN), float_mode_for_size (64).require ())
> diff --git a/gcc/system.h b/gcc/system.h
> index 1028dcb1eb3..cbb14fb167d 100644
> --- a/gcc/system.h
> +++ b/gcc/system.h
> @@ -1000,7 +1000,8 @@ extern void fancy_abort (const char *, int, const char *)
>  	HARD_REGNO_NREGS SECONDARY_MEMORY_NEEDED_MODE			\
>  	SECONDARY_MEMORY_NEEDED CANNOT_CHANGE_MODE_CLASS		\
>  	TRULY_NOOP_TRUNCATION FUNCTION_ARG_OFFSET CONSTANT_ALIGNMENT	\
> -	STARTING_FRAME_OFFSET
> +	STARTING_FRAME_OFFSET FLOAT_TYPE_SIZE DOUBLE_TYPE_SIZE		\
> +	LONG_DOUBLE_TYPE_SIZE
> 
>  /* Target macros only used for code built for the target, that have
>     moved to libgcc-tm.h or have never been present elsewhere.  */
> diff --git a/gcc/target.def b/gcc/target.def
> index c27df8095be..4780ba9c15b 100644
> --- a/gcc/target.def
> +++ b/gcc/target.def
> @@ -6370,6 +6370,15 @@ are zero or sign extended depending on if it is\n\
>   bool, (int n, struct bitint_info *info),
>   default_bitint_type_info)
> 
> +DEFHOOK
> +(mode_for_floating_type,
> +"Return machine mode for a C floating point type which is indicated by\n\
> + a given @code{enum tree_index} @var{ti}, @var{ti} should be\n\
> + @code{TI_FLOAT_TYPE}, @code{TI_DOUBLE_TYPE} or @code{TI_LONG_DOUBLE_TYPE}.\n\
> + The default implementation returns @code{SFmode} for @code{TI_FLOAT_TYPE},\n\
> + and @code{DFmode} for @code{TI_DOUBLE_TYPE} or @code{TI_LONG_DOUBLE_TYPE}.",
> + machine_mode, (enum tree_index ti), default_mode_for_floating_type)
> +
>  HOOK_VECTOR_END (c)
> 
>  /* Functions specific to the C++ frontend.  */
> diff --git a/gcc/targhooks.cc b/gcc/targhooks.cc
> index fb339bf75dd..5111e069f0c 100644
> --- a/gcc/targhooks.cc
> +++ b/gcc/targhooks.cc
> @@ -298,6 +298,18 @@ default_mode_for_suffix (char suffix ATTRIBUTE_UNUSED)
>    return VOIDmode;
>  }
> 
> +/* Return machine mode for a floating type which is indicated
> +   by the given enum tree_index.  */
> +
> +machine_mode
> +default_mode_for_floating_type (enum tree_index ti)
> +{
> +  if (ti == TI_FLOAT_TYPE)
> +    return SFmode;
> +  gcc_assert (ti == TI_DOUBLE_TYPE || ti == TI_LONG_DOUBLE_TYPE);
> +  return DFmode;
> +}
> +
>  /* The generic C++ ABI specifies this is a 64-bit value.  */
>  tree
>  default_cxx_guard_type (void)
> @@ -449,11 +461,11 @@ default_scalar_mode_supported_p (scalar_mode mode)
>        return false;
> 
>      case MODE_FLOAT:
> -      if (precision == FLOAT_TYPE_SIZE)
> +      if (mode == targetm.c.mode_for_floating_type (TI_FLOAT_TYPE))
>  	return true;
> -      if (precision == DOUBLE_TYPE_SIZE)
> +      if (mode == targetm.c.mode_for_floating_type (TI_DOUBLE_TYPE))
>  	return true;
> -      if (precision == LONG_DOUBLE_TYPE_SIZE)
> +      if (mode == targetm.c.mode_for_floating_type (TI_LONG_DOUBLE_TYPE))
>  	return true;
>        return false;
> 
> diff --git a/gcc/targhooks.h b/gcc/targhooks.h
> index 85f3817c176..fdc17c3b7c0 100644
> --- a/gcc/targhooks.h
> +++ b/gcc/targhooks.h
> @@ -289,6 +289,7 @@ extern unsigned int default_min_arithmetic_precision (void);
>  extern enum flt_eval_method
>  default_excess_precision (enum excess_precision_type ATTRIBUTE_UNUSED);
>  extern bool default_bitint_type_info (int, struct bitint_info *);
> +extern machine_mode default_mode_for_floating_type (enum tree_index);
>  extern HOST_WIDE_INT default_stack_clash_protection_alloca_probe_range (void);
>  extern void default_select_early_remat_modes (sbitmap);
>  extern tree default_preferred_else_value (unsigned, tree, unsigned, tree *);
> diff --git a/gcc/tree-core.h b/gcc/tree-core.h
> index 9fa74342919..0b5000acb80 100644
> --- a/gcc/tree-core.h
> +++ b/gcc/tree-core.h
> @@ -624,7 +624,7 @@ enum cv_qualifier {
>  };
> 
>  /* Standard named or nameless data types of the C compiler.  */
> -enum tree_index {
> +enum tree_index : unsigned {
>    TI_ERROR_MARK,
>    TI_INTQI_TYPE,
>    TI_INTHI_TYPE,
> @@ -691,17 +691,18 @@ enum tree_index {
>    TI_FLOAT64_TYPE,
>    TI_FLOAT128_TYPE,
>    TI_FLOATN_TYPE_LAST = TI_FLOAT128_TYPE,
> -#define NUM_FLOATN_TYPES (TI_FLOATN_TYPE_LAST - TI_FLOATN_TYPE_FIRST + 1)
> +#define NUM_FLOATN_TYPES ((int) (TI_FLOATN_TYPE_LAST		\
> +				 - TI_FLOATN_TYPE_FIRST + 1))
>    TI_FLOAT32X_TYPE,
>    TI_FLOATNX_TYPE_FIRST = TI_FLOAT32X_TYPE,
>    TI_FLOAT64X_TYPE,
>    TI_FLOAT128X_TYPE,
>    TI_FLOATNX_TYPE_LAST = TI_FLOAT128X_TYPE,
>    TI_FLOATN_NX_TYPE_LAST = TI_FLOAT128X_TYPE,
> -#define NUM_FLOATNX_TYPES (TI_FLOATNX_TYPE_LAST - TI_FLOATNX_TYPE_FIRST + 1)
> -#define NUM_FLOATN_NX_TYPES (TI_FLOATN_NX_TYPE_LAST		\
> -			     - TI_FLOATN_NX_TYPE_FIRST		\
> -			     + 1)
> +#define NUM_FLOATNX_TYPES ((int) (TI_FLOATNX_TYPE_LAST		\
> +				  - TI_FLOATNX_TYPE_FIRST + 1))
> +#define NUM_FLOATN_NX_TYPES ((int) (TI_FLOATN_NX_TYPE_LAST	\
> +				  - TI_FLOATN_NX_TYPE_FIRST + 1))
> 
>    /* Type used by certain backends for __float128, which in C++ should be
>       distinct type from _Float128 for backwards compatibility reasons.  */
> diff --git a/gcc/tree.cc b/gcc/tree.cc
> index 6564b002dc1..bc5175f591e 100644
> --- a/gcc/tree.cc
> +++ b/gcc/tree.cc
> @@ -9596,15 +9596,27 @@ build_common_tree_nodes (bool signed_char)
>    pointer_sized_int_node = build_nonstandard_integer_type (POINTER_SIZE, 1);
> 
>    float_type_node = make_node (REAL_TYPE);
> -  TYPE_PRECISION (float_type_node) = FLOAT_TYPE_SIZE;
> +  machine_mode float_type_mode
> +    = targetm.c.mode_for_floating_type (TI_FLOAT_TYPE);
> +  SET_TYPE_MODE (float_type_node, float_type_mode);
> +  TYPE_PRECISION (float_type_node)
> +    = GET_MODE_PRECISION (float_type_mode).to_constant ();
>    layout_type (float_type_node);
> 
>    double_type_node = make_node (REAL_TYPE);
> -  TYPE_PRECISION (double_type_node) = DOUBLE_TYPE_SIZE;
> +  machine_mode double_type_mode
> +    = targetm.c.mode_for_floating_type (TI_DOUBLE_TYPE);
> +  SET_TYPE_MODE (double_type_node, double_type_mode);
> +  TYPE_PRECISION (double_type_node)
> +    = GET_MODE_PRECISION (double_type_mode).to_constant ();
>    layout_type (double_type_node);
> 
>    long_double_type_node = make_node (REAL_TYPE);
> -  TYPE_PRECISION (long_double_type_node) = LONG_DOUBLE_TYPE_SIZE;
> +  machine_mode long_double_type_mode
> +    = targetm.c.mode_for_floating_type (TI_LONG_DOUBLE_TYPE);
> +  SET_TYPE_MODE (long_double_type_node, long_double_type_mode);
> +  TYPE_PRECISION (long_double_type_node)
> +    = GET_MODE_PRECISION (long_double_type_mode).to_constant ();
>    layout_type (long_double_type_node);
> 
>    for (i = 0; i < NUM_FLOATN_NX_TYPES; i++)
> --
> 2.43.0
> 

^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 04/52] go: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  2024-06-12 12:32     ` Ian Lance Taylor
@ 2024-06-25  5:38       ` Kewen.Lin
  0 siblings, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-25  5:38 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-patches, Ian Lance Taylor

on 2024/6/12 20:32, Ian Lance Taylor wrote:
> "Kewen.Lin" <linkw@linux.ibm.com> writes:
> 
>> Hi,
>>
>> Gentle ping:
>>
>> https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653387.html
>>
>> BR,
>> Kewen
>>
>> on 2024/6/3 11:00, Kewen Lin 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 {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
>>> in go with TYPE_PRECISION of {float,{,long_}double}_type_node.
>>>
>>> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
>>>
>>> gcc/go/ChangeLog:
>>>
>>> 	* go-gcc.cc (Gcc_backend::float_type): Use TYPE_PRECISION of
>>> 	{float,double,long_double}_type_node to replace
>>> 	{FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE.
>>> 	(Gcc_backend::complex_type): Likewise.
> 
> This is fine if the other parts of the patch are accepted.

Thanks, pushed as r15-1591-gfafd87830937d5.

BR,
Kewen


^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 05/52] rust: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  2024-06-21 10:36     ` Kewen.Lin
@ 2024-06-25  5:42       ` Kewen.Lin
  2024-06-25 10:14       ` Arthur Cohen
  1 sibling, 0 replies; 149+ messages in thread
From: Kewen.Lin @ 2024-06-25  5:42 UTC (permalink / raw)
  To: Arthur Cohen; +Cc: herron.philip, gcc-patches

on 2024/6/21 18:36, Kewen.Lin wrote:
> Hi Arthur,
> 
> on 2024/6/21 18:17, Arthur Cohen wrote:
>> Hi,
>>
>> Sorry about the delay in my answer! The patch looks good to me :) Will you push it as part of your patchset?
>>
> 
> Thanks for the review!  Since this one doesn't necessarily depend on
> "09/52 Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook
> mode_for_floating_type", I'm going to push this before that (just like
> the other FE changes excepting for the jit one 10/52 which depends on
> the new hook 09/52).  btw, all after 09/52 would be merged into 09/52
> when committing. :)

Pushed as r15-1592-gbcd1b7a097031d, thanks!

BR,
Kewen

^ permalink raw reply	[flat|nested] 149+ messages in thread

* Re: [PATCH 05/52] rust: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
  2024-06-21 10:36     ` Kewen.Lin
  2024-06-25  5:42       ` Kewen.Lin
@ 2024-06-25 10:14       ` Arthur Cohen
  1 sibling, 0 replies; 149+ messages in thread
From: Arthur Cohen @ 2024-06-25 10:14 UTC (permalink / raw)
  To: Kewen.Lin; +Cc: herron.philip, gcc-patches

Hi Kewen,

Sorry for not answering earlier - yes, this sounds good to me :) thanks 
for taking care of that.

Best,

Arthur

On 6/21/24 12:36, Kewen.Lin wrote:
> Hi Arthur,
> 
> on 2024/6/21 18:17, Arthur Cohen wrote:
>> Hi,
>>
>> Sorry about the delay in my answer! The patch looks good to me :) Will you push it as part of your patchset?
>>
> 
> Thanks for the review!  Since this one doesn't necessarily depend on
> "09/52 Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook
> mode_for_floating_type", I'm going to push this before that (just like
> the other FE changes excepting for the jit one 10/52 which depends on
> the new hook 09/52).  btw, all after 09/52 would be merged into 09/52
> when committing. :)
> 
> Does it sound good to you?
> 
> BR,
> Kewen
> 
>> Kindly,
>>
>> Arthur
>>
>> On 6/3/24 05:00, Kewen Lin 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 {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE
>>> in rust with TYPE_PRECISION of {float,{,long_}double}_type_node.
>>>
>>> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-May/651209.html
>>>
>>> gcc/rust/ChangeLog:
>>>
>>>      * rust-gcc.cc (float_type): Use TYPE_PRECISION of
>>>      {float,double,long_double}_type_node to replace
>>>      {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE.
>>> ---
>>>    gcc/rust/rust-gcc.cc | 6 +++---
>>>    1 file changed, 3 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
>>> index f17e19a2dfc..38169c08985 100644
>>> --- a/gcc/rust/rust-gcc.cc
>>> +++ b/gcc/rust/rust-gcc.cc
>>> @@ -411,11 +411,11 @@ tree
>>>    float_type (int bits)
>>>    {
>>>      tree type;
>>> -  if (bits == FLOAT_TYPE_SIZE)
>>> +  if (bits == TYPE_PRECISION (float_type_node))
>>>        type = float_type_node;
>>> -  else if (bits == DOUBLE_TYPE_SIZE)
>>> +  else if (bits == TYPE_PRECISION (double_type_node))
>>>        type = double_type_node;
>>> -  else if (bits == LONG_DOUBLE_TYPE_SIZE)
>>> +  else if (bits == TYPE_PRECISION (long_double_type_node))
>>>        type = long_double_type_node;
>>>      else
>>>        {

^ permalink raw reply	[flat|nested] 149+ messages in thread

end of thread, other threads:[~2024-06-25  8:41 UTC | newest]

Thread overview: 149+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-03  3:00 [PATCH 00/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook Kewen Lin
2024-06-03  3:00 ` [PATCH 01/52] ada: Replace use of LONG_DOUBLE_TYPE_SIZE Kewen Lin
2024-06-03  8:51   ` Eric Botcazou
2024-06-05  9:32     ` Kewen.Lin
2024-06-03  3:00 ` [PATCH 02/52] d: " Kewen Lin
2024-06-03  8:40   ` Iain Buclaw
2024-06-03  8:57     ` Kewen.Lin
2024-06-03 14:39       ` Iain Buclaw
2024-06-04  3:17         ` [PATCH 02/52 v2] " Kewen.Lin
2024-06-04 11:35           ` Iain Buclaw
2024-06-05  9:32             ` Kewen.Lin
2024-06-03  3:00 ` [PATCH 03/52] fortran: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE Kewen Lin
2024-06-03 20:01   ` [PATCH 03/52] fortran: Replace uses of {FLOAT, {, LONG_}DOUBLE}_TYPE_SIZE Harald Anlauf
2024-06-03 20:01     ` Harald Anlauf
2024-06-05  9:30     ` Kewen.Lin
2024-06-03  3:00 ` [PATCH 04/52] go: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE Kewen Lin
2024-06-12  9:33   ` Kewen.Lin
2024-06-12 12:32     ` Ian Lance Taylor
2024-06-25  5:38       ` Kewen.Lin
2024-06-03  3:00 ` [PATCH 05/52] rust: " Kewen Lin
2024-06-12  9:35   ` PING^1 " Kewen.Lin
2024-06-21  1:48     ` PING^2 " Kewen.Lin
2024-06-21 10:17   ` Arthur Cohen
2024-06-21 10:36     ` Kewen.Lin
2024-06-25  5:42       ` Kewen.Lin
2024-06-25 10:14       ` Arthur Cohen
2024-06-03  3:00 ` [PATCH 06/52] m2: " Kewen Lin
2024-06-03 12:42   ` Gaius Mulley
2024-06-03 18:02   ` Joseph Myers
2024-06-04  3:19     ` Kewen.Lin
2024-06-05 14:22       ` Gaius Mulley
2024-06-06  5:15         ` Kewen.Lin
2024-06-06 18:31           ` Gaius Mulley
2024-06-12  9:31           ` Kewen.Lin
2024-06-15  5:00             ` Gaius Mulley
2024-06-17  6:07               ` Kewen.Lin
2024-06-03  3:00 ` [PATCH 07/52] darwin: Replace use of LONG_DOUBLE_TYPE_SIZE Kewen Lin
2024-06-04  6:21   ` Iain Sandoe
2024-06-05  9:29     ` Kewen.Lin
2024-06-03  3:00 ` [PATCH 08/52] vms: " Kewen Lin
2024-06-12  9:36   ` PING^1 " Kewen.Lin
2024-06-03  3:00 ` [PATCH 09/52] Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook mode_for_floating_type Kewen Lin
2024-06-03  6:49   ` Richard Biener
2024-06-03  9:36     ` Kewen.Lin
2024-06-03 17:59   ` [PATCH 09/52] Replace {FLOAT, {, LONG_}DOUBLE}_TYPE_SIZE " Joseph Myers
2024-06-04  3:27     ` [PATCH 09/52 v2] " Kewen.Lin
2024-06-25  5:20       ` Kewen.Lin
2024-06-03  3:01 ` [PATCH 10/52] jit: Replace uses of {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE Kewen Lin
2024-06-13  7:14   ` PING^1 " Kewen.Lin
2024-06-13 13:44   ` David Malcolm
2024-06-14  2:16     ` Kewen.Lin
2024-06-24  6:23       ` Kewen.Lin
2024-06-24 22:25       ` David Malcolm
2024-06-03  3:01 ` [PATCH 11/52] arc: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE Kewen Lin
2024-06-13  7:14   ` PING^1 " Kewen.Lin
2024-06-03  3:01 ` [PATCH 12/52] bpf: " Kewen Lin
2024-06-13  7:15   ` PING^1 " Kewen.Lin
2024-06-03  3:01 ` [PATCH 13/52] epiphany: " Kewen Lin
2024-06-13  7:15   ` PING^1 " Kewen.Lin
2024-06-03  3:01 ` [PATCH 14/52] fr30: " Kewen Lin
2024-06-03 11:43   ` Nick Clifton
2024-06-03  3:01 ` [PATCH 15/52] frv: " Kewen Lin
2024-06-03 13:31   ` Nick Clifton
2024-06-03  3:01 ` [PATCH 16/52] ft32: " Kewen Lin
2024-06-13  7:15   ` PING^1 " Kewen.Lin
2024-06-03  3:01 ` [PATCH 17/52] gcn: " Kewen Lin
2024-06-03  9:14   ` [PATCH 17/52] gcn: Remove macros {FLOAT, DOUBLE, LONG_DOUBLE}_TYPE_SIZE Andrew Stubbs
2024-06-03  9:41     ` Kewen.Lin
2024-06-03  9:57       ` Jakub Jelinek
2024-06-03  3:01 ` [PATCH 18/52] iq2000: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE Kewen Lin
2024-06-03 13:32   ` Nick Clifton
2024-06-03  3:01 ` [PATCH 19/52] lm32: " Kewen Lin
2024-06-13  7:15   ` PING^1 " Kewen.Lin
2024-06-03  3:01 ` [PATCH 20/52] m32c: " Kewen Lin
2024-06-03 13:33   ` Nick Clifton
2024-06-03  3:01 ` [PATCH 21/52] m32r: " Kewen Lin
2024-06-03 13:33   ` Nick Clifton
2024-06-03  3:01 ` [PATCH 22/52] microblaze: " Kewen Lin
2024-06-13  7:16   ` PING^1 " Kewen.Lin
2024-06-13 17:37     ` Michael Eager
2024-06-03  3:01 ` [PATCH 23/52] mmix: " Kewen Lin
2024-06-06  1:41   ` Hans-Peter Nilsson
2024-06-06  2:11     ` Kewen.Lin
2024-06-03  3:01 ` [PATCH 24/52] moxie: " Kewen Lin
2024-06-13  7:16   ` PING^1 " Kewen.Lin
2024-06-03  3:01 ` [PATCH 25/52] msp430: " Kewen Lin
2024-06-03 13:34   ` Nick Clifton
2024-06-03  3:01 ` [PATCH 26/52] nds32: " Kewen Lin
2024-06-13  7:16   ` PING^1 " Kewen.Lin
2024-06-03  3:01 ` [PATCH 27/52] nios2: " Kewen Lin
2024-06-06 16:23   ` Sandra Loosemore
2024-06-03  3:01 ` [PATCH 28/52] nvptx: " Kewen Lin
2024-06-13  7:16   ` PING^1 " Kewen.Lin
2024-06-03  3:01 ` [PATCH 29/52] or1k: " Kewen Lin
2024-06-13  7:16   ` PING^1 " Kewen.Lin
2024-06-20 14:18     ` Stafford Horne
2024-06-03  3:01 ` [PATCH 30/52] pdp11: Remove macro LONG_DOUBLE_TYPE_SIZE Kewen Lin
2024-06-13  7:16   ` PING^1 " Kewen.Lin
2024-06-13 20:07     ` Paul Koning
2024-06-14  3:22       ` [PATCH 30/52 v2] pdp11: Remove macro {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE Kewen.Lin
2024-06-14 15:20         ` Paul Koning
2024-06-17  2:01           ` Kewen.Lin
2024-06-17 18:05             ` Paul Koning
2024-06-03  3:01 ` [PATCH 31/52] pru: Remove macros {FLOAT,DOUBLE,LONG_DOUBLE}_TYPE_SIZE Kewen Lin
2024-06-03 15:59   ` Dimitar Dimitrov
2024-06-03  3:01 ` [PATCH 32/52] stormy16: " Kewen Lin
2024-06-03 13:35   ` Nick Clifton
2024-06-03  3:01 ` [PATCH 33/52] visium: " Kewen Lin
2024-06-13  7:17   ` PING^1 " Kewen.Lin
2024-06-03  3:01 ` [PATCH 34/52] xtensa: " Kewen Lin
2024-06-03 21:08   ` augustine.sterling
2024-06-03  3:01 ` [PATCH 35/52] rs6000: New hook implementation rs6000_c_mode_for_floating_type Kewen Lin
2024-06-03  3:01 ` [PATCH 36/52] aarch64: New hook implementation aarch64_c_mode_for_floating_type Kewen Lin
2024-06-03 10:32   ` Richard Sandiford
2024-06-03  3:01 ` [PATCH 37/52] alpha: New hook implementation alpha_c_mode_for_floating_type Kewen Lin
2024-06-13  7:42   ` PING^1 " Kewen.Lin
2024-06-03  3:01 ` [PATCH 38/52] avr: New hook implementation avr_c_mode_for_floating_type Kewen Lin
2024-06-13  7:42   ` PING^1 " Kewen.Lin
2024-06-03  3:01 ` [PATCH 39/52] i386: New hook implementation ix86_c_mode_for_floating_type Kewen Lin
2024-06-03  7:12   ` Uros Bizjak
2024-06-03  3:01 ` [PATCH 40/52] ia64: New hook implementation ia64_c_mode_for_floating_type Kewen Lin
2024-06-13  7:42   ` PING^1 " Kewen.Lin
2024-06-03  3:01 ` [PATCH 41/52] riscv: New hook implementation riscv_c_mode_for_floating_type Kewen Lin
2024-06-03  5:14   ` Kito Cheng
2024-06-03  3:01 ` [PATCH 42/52] rl78: New hook implementation rl78_c_mode_for_floating_type Kewen Lin
2024-06-13  7:42   ` PING^1 " Kewen.Lin
2024-06-13  7:46     ` Richard Biener
2024-06-03  3:01 ` [PATCH 43/52] rx: New hook implementation rx_c_mode_for_floating_type Kewen Lin
2024-06-03 13:36   ` Nick Clifton
2024-06-03  3:01 ` [PATCH 44/52] s390: New hook implementation s390_c_mode_for_floating_type Kewen Lin
2024-06-13  7:43   ` PING^1 " Kewen.Lin
2024-06-14  5:40     ` Andreas Krebbel
2024-06-03  3:01 ` [PATCH 45/52] sh: New hook implementation sh_c_mode_for_floating_type Kewen Lin
2024-06-03  3:16   ` Oleg Endo
2024-06-03  3:01 ` [PATCH 46/52] h8300: New hook implementation h8300_c_mode_for_floating_type Kewen Lin
2024-06-13  7:43   ` PING^1 " Kewen.Lin
2024-06-03  3:01 ` [PATCH 47/52] loongarch: New hook implementation loongarch_c_mode_for_floating_type Kewen Lin
2024-06-04  1:45   ` Lulu Cheng
2024-06-03  3:01 ` [PATCH 48/52] m68k: New hook implementation m68k_c_mode_for_floating_type Kewen Lin
2024-06-13  7:43   ` PING^1 " Kewen.Lin
2024-06-03  3:01 ` [PATCH 49/52] mips: New hook implementation mips_c_mode_for_floating_type Kewen Lin
2024-06-04  1:16   ` YunQiang Su
2024-06-03  3:01 ` [PATCH 50/52] pa: New hook implementation pa_c_mode_for_floating_type Kewen Lin
2024-06-04 18:55   ` John David Anglin
2024-06-03  3:01 ` [PATCH 51/52] sparc: New hook implementation sparc_c_mode_for_floating_type Kewen Lin
2024-06-03  9:02   ` Eric Botcazou
2024-06-03  9:37     ` Kewen.Lin
2024-06-03  3:01 ` [PATCH 52/52] bfin: Rename macros {FLOAT,DOUBLE}_TYPE_SIZE Kewen Lin
2024-06-13  7:43   ` PING^1 " Kewen.Lin

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).