diff mbox series

[48/52] m68k: New hook implementation m68k_c_mode_for_floating_type

Message ID bfcb14af620582691682729cc2e75fb0cb3bb961.1717134752.git.linkw@linux.ibm.com
State New
Headers show
Series Replace {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE with new hook | expand

Commit Message

Kewen.Lin June 3, 2024, 3:01 a.m. UTC
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(-)

Comments

Kewen.Lin June 13, 2024, 7:43 a.m. UTC | #1
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);
>  
>  /* 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 \
diff mbox series

Patch

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);
 
 /* 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 \