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); >> >> #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