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