Message ID | 35df84c1002156995ee9d88f4743fc4050b8004c.1717134752.git.linkw@linux.ibm.com |
---|---|
State | New |
Headers | show |
Series | Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook | expand |
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
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