diff mbox series

[50/52] pa: New hook implementation pa_c_mode_for_floating_type

Message ID 90f8ca6a30d4c01e0acd358b271a348daebbdc64.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
pa_c_mode_for_floating_type, as we remove defines in
defaults.h for {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE, this
also defines them in pa.h but with PA_ prefix since
we poison {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE.

gcc/ChangeLog:

	* config/pa/pa.cc (pa_c_mode_for_floating_type): New function.
	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
	(pa_scalar_mode_supported_p): Rename FLOAT_TYPE_SIZE to
	PA_FLOAT_TYPE_SIZE, rename DOUBLE_TYPE_SIZE to PA_DOUBLE_TYPE_SIZE
	and rename LONG_DOUBLE_TYPE_SIZE to PA_LONG_DOUBLE_TYPE_SIZE.
	* config/pa/pa.h (PA_FLOAT_TYPE_SIZE): New macro.
	(PA_DOUBLE_TYPE_SIZE): Likewise.
	(PA_LONG_DOUBLE_TYPE_SIZE): Likewise.
	* config/pa/pa-64.h (FLOAT_TYPE_SIZE): Rename to ...
	(PA_FLOAT_TYPE_SIZE): ... this.
	(DOUBLE_TYPE_SIZE): Rename to ...
	(PA_DOUBLE_TYPE_SIZE): ... this.
	(LONG_DOUBLE_TYPE_SIZE): Rename to ...
	(PA_LONG_DOUBLE_TYPE_SIZE): ... this.
	* config/pa/pa-hpux.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
	(PA_LONG_DOUBLE_TYPE_SIZE): ... this.
---
 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 ++++++
 4 files changed, 32 insertions(+), 10 deletions(-)

Comments

John David Anglin June 4, 2024, 6:55 p.m. UTC | #1
Okay.

Dave

On 2024-06-02 11:01 p.m., Kewen Lin wrote:
> This is to add new port specific hook implementation
> pa_c_mode_for_floating_type, as we remove defines in
> defaults.h for {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE, this
> also defines them in pa.h but with PA_ prefix since
> we poison {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE.
>
> gcc/ChangeLog:
>
> 	* config/pa/pa.cc (pa_c_mode_for_floating_type): New function.
> 	(TARGET_C_MODE_FOR_FLOATING_TYPE): New macro.
> 	(pa_scalar_mode_supported_p): Rename FLOAT_TYPE_SIZE to
> 	PA_FLOAT_TYPE_SIZE, rename DOUBLE_TYPE_SIZE to PA_DOUBLE_TYPE_SIZE
> 	and rename LONG_DOUBLE_TYPE_SIZE to PA_LONG_DOUBLE_TYPE_SIZE.
> 	* config/pa/pa.h (PA_FLOAT_TYPE_SIZE): New macro.
> 	(PA_DOUBLE_TYPE_SIZE): Likewise.
> 	(PA_LONG_DOUBLE_TYPE_SIZE): Likewise.
> 	* config/pa/pa-64.h (FLOAT_TYPE_SIZE): Rename to ...
> 	(PA_FLOAT_TYPE_SIZE): ... this.
> 	(DOUBLE_TYPE_SIZE): Rename to ...
> 	(PA_DOUBLE_TYPE_SIZE): ... this.
> 	(LONG_DOUBLE_TYPE_SIZE): Rename to ...
> 	(PA_LONG_DOUBLE_TYPE_SIZE): ... this.
> 	* config/pa/pa-hpux.h (LONG_DOUBLE_TYPE_SIZE): Rename to ...
> 	(PA_LONG_DOUBLE_TYPE_SIZE): ... this.
> ---
>   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 ++++++
>   4 files changed, 32 insertions(+), 10 deletions(-)
>
> diff --git a/gcc/config/pa/pa-64.h b/gcc/config/pa/pa-64.h
> index ea9d86ee7d4..b676468d2ce 100644
> --- a/gcc/config/pa/pa-64.h
> +++ b/gcc/config/pa/pa-64.h
> @@ -58,12 +58,12 @@ along with GCC; see the file COPYING3.  If not see
>   #define LONG_TYPE_SIZE 64
>   #undef LONG_LONG_TYPE_SIZE
>   #define LONG_LONG_TYPE_SIZE 64
> -#undef FLOAT_TYPE_SIZE
> -#define FLOAT_TYPE_SIZE 32
> -#undef DOUBLE_TYPE_SIZE
> -#define DOUBLE_TYPE_SIZE 64
> -#undef LONG_DOUBLE_TYPE_SIZE
> -#define LONG_DOUBLE_TYPE_SIZE 128
> +#undef PA_FLOAT_TYPE_SIZE
> +#define PA_FLOAT_TYPE_SIZE 32
> +#undef PA_DOUBLE_TYPE_SIZE
> +#define PA_DOUBLE_TYPE_SIZE 64
> +#undef PA_LONG_DOUBLE_TYPE_SIZE
> +#define PA_LONG_DOUBLE_TYPE_SIZE 128
>   
>   /* ?!? This needs to be made compile-time selectable.
>   
> diff --git a/gcc/config/pa/pa-hpux.h b/gcc/config/pa/pa-hpux.h
> index a7421d68ca0..accef447523 100644
> --- a/gcc/config/pa/pa-hpux.h
> +++ b/gcc/config/pa/pa-hpux.h
> @@ -34,7 +34,8 @@ along with GCC; see the file COPYING3.  If not see
>   #define SIZE_TYPE "unsigned int"
>   #define PTRDIFF_TYPE "int"
>   
> -#define LONG_DOUBLE_TYPE_SIZE 128
> +#undef PA_LONG_DOUBLE_TYPE_SIZE
> +#define PA_LONG_DOUBLE_TYPE_SIZE 128
>   #define FLOAT_LIB_COMPARE_RETURNS_BOOL(MODE, COMPARISON) ((MODE) == TFmode)
>   
>   /* GCC always defines __STDC__.  HP C++ compilers don't define it.  This
> diff --git a/gcc/config/pa/pa.cc b/gcc/config/pa/pa.cc
> index a7af6b8c121..ab4bfc5d0c2 100644
> --- a/gcc/config/pa/pa.cc
> +++ b/gcc/config/pa/pa.cc
> @@ -194,6 +194,7 @@ static rtx pa_internal_arg_pointer (void);
>   static bool pa_can_eliminate (const int, const int);
>   static void pa_conditional_register_usage (void);
>   static machine_mode pa_c_mode_for_suffix (char);
> +static machine_mode pa_c_mode_for_floating_type (enum tree_index);
>   static section *pa_function_section (tree, enum node_frequency, bool, bool);
>   static bool pa_cannot_force_const_mem (machine_mode, rtx);
>   static bool pa_legitimate_constant_p (machine_mode, rtx);
> @@ -398,6 +399,8 @@ static size_t n_deferred_plabels = 0;
>   #define TARGET_CONDITIONAL_REGISTER_USAGE pa_conditional_register_usage
>   #undef TARGET_C_MODE_FOR_SUFFIX
>   #define TARGET_C_MODE_FOR_SUFFIX pa_c_mode_for_suffix
> +#undef TARGET_C_MODE_FOR_FLOATING_TYPE
> +#define TARGET_C_MODE_FOR_FLOATING_TYPE pa_c_mode_for_floating_type
>   #undef TARGET_ASM_FUNCTION_SECTION
>   #define TARGET_ASM_FUNCTION_SECTION pa_function_section
>   
> @@ -6728,11 +6731,11 @@ pa_scalar_mode_supported_p (scalar_mode mode)
>         return false;
>   
>       case MODE_FLOAT:
> -      if (precision == FLOAT_TYPE_SIZE)
> +      if (precision == PA_FLOAT_TYPE_SIZE)
>   	return true;
> -      if (precision == DOUBLE_TYPE_SIZE)
> +      if (precision == PA_DOUBLE_TYPE_SIZE)
>   	return true;
> -      if (precision == LONG_DOUBLE_TYPE_SIZE)
> +      if (precision == PA_LONG_DOUBLE_TYPE_SIZE)
>   	return true;
>         return false;
>   
> @@ -10808,6 +10811,18 @@ pa_c_mode_for_suffix (char suffix)
>     return VOIDmode;
>   }
>   
> +/* 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
> +pa_c_mode_for_floating_type (enum tree_index ti)
> +{
> +  if (ti == TI_LONG_DOUBLE_TYPE)
> +    return PA_LONG_DOUBLE_TYPE_SIZE == 64 ? DFmode : TFmode;
> +  return default_mode_for_floating_type (ti);
> +}
> +
>   /* Target hook for function_section.  */
>   
>   static section *
> diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h
> index 127a0d1966d..7e45c358895 100644
> --- a/gcc/config/pa/pa.h
> +++ b/gcc/config/pa/pa.h
> @@ -1306,3 +1306,9 @@ do {									     \
>   /* An integer expression for the size in bits of the largest integer machine
>      mode that should actually be used.  We allow pairs of registers.  */
>   #define MAX_FIXED_MODE_SIZE GET_MODE_BITSIZE (TARGET_64BIT ? TImode : DImode)
> +
> +/* Define these macros as default for all subtargets, add PA_ prefix
> +   as {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE get poisoned.  */
> +#define PA_FLOAT_TYPE_SIZE BITS_PER_WORD
> +#define PA_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
> +#define PA_LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
diff mbox series

Patch

diff --git a/gcc/config/pa/pa-64.h b/gcc/config/pa/pa-64.h
index ea9d86ee7d4..b676468d2ce 100644
--- a/gcc/config/pa/pa-64.h
+++ b/gcc/config/pa/pa-64.h
@@ -58,12 +58,12 @@  along with GCC; see the file COPYING3.  If not see
 #define LONG_TYPE_SIZE 64
 #undef LONG_LONG_TYPE_SIZE
 #define LONG_LONG_TYPE_SIZE 64
-#undef FLOAT_TYPE_SIZE
-#define FLOAT_TYPE_SIZE 32
-#undef DOUBLE_TYPE_SIZE
-#define DOUBLE_TYPE_SIZE 64
-#undef LONG_DOUBLE_TYPE_SIZE
-#define LONG_DOUBLE_TYPE_SIZE 128
+#undef PA_FLOAT_TYPE_SIZE
+#define PA_FLOAT_TYPE_SIZE 32
+#undef PA_DOUBLE_TYPE_SIZE
+#define PA_DOUBLE_TYPE_SIZE 64
+#undef PA_LONG_DOUBLE_TYPE_SIZE
+#define PA_LONG_DOUBLE_TYPE_SIZE 128
 
 /* ?!? This needs to be made compile-time selectable.
 
diff --git a/gcc/config/pa/pa-hpux.h b/gcc/config/pa/pa-hpux.h
index a7421d68ca0..accef447523 100644
--- a/gcc/config/pa/pa-hpux.h
+++ b/gcc/config/pa/pa-hpux.h
@@ -34,7 +34,8 @@  along with GCC; see the file COPYING3.  If not see
 #define SIZE_TYPE "unsigned int"
 #define PTRDIFF_TYPE "int"
 
-#define LONG_DOUBLE_TYPE_SIZE 128
+#undef PA_LONG_DOUBLE_TYPE_SIZE
+#define PA_LONG_DOUBLE_TYPE_SIZE 128
 #define FLOAT_LIB_COMPARE_RETURNS_BOOL(MODE, COMPARISON) ((MODE) == TFmode)
 
 /* GCC always defines __STDC__.  HP C++ compilers don't define it.  This
diff --git a/gcc/config/pa/pa.cc b/gcc/config/pa/pa.cc
index a7af6b8c121..ab4bfc5d0c2 100644
--- a/gcc/config/pa/pa.cc
+++ b/gcc/config/pa/pa.cc
@@ -194,6 +194,7 @@  static rtx pa_internal_arg_pointer (void);
 static bool pa_can_eliminate (const int, const int);
 static void pa_conditional_register_usage (void);
 static machine_mode pa_c_mode_for_suffix (char);
+static machine_mode pa_c_mode_for_floating_type (enum tree_index);
 static section *pa_function_section (tree, enum node_frequency, bool, bool);
 static bool pa_cannot_force_const_mem (machine_mode, rtx);
 static bool pa_legitimate_constant_p (machine_mode, rtx);
@@ -398,6 +399,8 @@  static size_t n_deferred_plabels = 0;
 #define TARGET_CONDITIONAL_REGISTER_USAGE pa_conditional_register_usage
 #undef TARGET_C_MODE_FOR_SUFFIX
 #define TARGET_C_MODE_FOR_SUFFIX pa_c_mode_for_suffix
+#undef TARGET_C_MODE_FOR_FLOATING_TYPE
+#define TARGET_C_MODE_FOR_FLOATING_TYPE pa_c_mode_for_floating_type
 #undef TARGET_ASM_FUNCTION_SECTION
 #define TARGET_ASM_FUNCTION_SECTION pa_function_section
 
@@ -6728,11 +6731,11 @@  pa_scalar_mode_supported_p (scalar_mode mode)
       return false;
 
     case MODE_FLOAT:
-      if (precision == FLOAT_TYPE_SIZE)
+      if (precision == PA_FLOAT_TYPE_SIZE)
 	return true;
-      if (precision == DOUBLE_TYPE_SIZE)
+      if (precision == PA_DOUBLE_TYPE_SIZE)
 	return true;
-      if (precision == LONG_DOUBLE_TYPE_SIZE)
+      if (precision == PA_LONG_DOUBLE_TYPE_SIZE)
 	return true;
       return false;
 
@@ -10808,6 +10811,18 @@  pa_c_mode_for_suffix (char suffix)
   return VOIDmode;
 }
 
+/* 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
+pa_c_mode_for_floating_type (enum tree_index ti)
+{
+  if (ti == TI_LONG_DOUBLE_TYPE)
+    return PA_LONG_DOUBLE_TYPE_SIZE == 64 ? DFmode : TFmode;
+  return default_mode_for_floating_type (ti);
+}
+
 /* Target hook for function_section.  */
 
 static section *
diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h
index 127a0d1966d..7e45c358895 100644
--- a/gcc/config/pa/pa.h
+++ b/gcc/config/pa/pa.h
@@ -1306,3 +1306,9 @@  do {									     \
 /* An integer expression for the size in bits of the largest integer machine
    mode that should actually be used.  We allow pairs of registers.  */
 #define MAX_FIXED_MODE_SIZE GET_MODE_BITSIZE (TARGET_64BIT ? TImode : DImode)
+
+/* Define these macros as default for all subtargets, add PA_ prefix
+   as {FLOAT,{,LONG_}DOUBLE}_TYPE_SIZE get poisoned.  */
+#define PA_FLOAT_TYPE_SIZE BITS_PER_WORD
+#define PA_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
+#define PA_LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)