diff mbox series

[38/52] avr: New hook implementation avr_c_mode_for_floating_type

Message ID 12403c7d266445af989c6f15f72ce05f335eed0d.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 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(-)

Comments

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

Patch

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