Re: [SPARC] Hookize PREFERRED_RELOAD_CLASS

2011-04-03 Thread Eric Botcazou
> * config/sparc/sparc.h (PREFERRED_RELOAD_CLASS): Remove.
> * config/sparc/sparc.c (TARGET_PREFERRED_RELOAD_CLASS): Define.
> (sparc_preferred_reload_class): New function.

OK, modulo

> +  if (FP_REG_CLASS_P (rclass)
> + || rclass == GENERAL_OR_FP_REGS
> + || rclass == GENERAL_OR_EXTRA_FP_REGS
> + || (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT && ! TARGET_FPU)
> + || (GET_MODE (x) == TFmode && ! const_zero_operand (x, TFmode)))
> +   return NO_REGS;
> +  else if (!FP_REG_CLASS_P (rclass)
> +  && GET_MODE_CLASS (GET_MODE (x)) == MODE_INT)
> +   return GENERAL_REGS;

Drop the else and the useless !FP_REG_CLASS_P (rclass) test:

+  if (FP_REG_CLASS_P (rclass)
+ || rclass == GENERAL_OR_FP_REGS
+ || rclass == GENERAL_OR_EXTRA_FP_REGS
+ || (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT && ! TARGET_FPU)
+ || (GET_MODE (x) == TFmode && ! const_zero_operand (x, TFmode)))
+   return NO_REGS;
+
+  if (GET_MODE_CLASS (GET_MODE (x)) == MODE_INT)
+   return GENERAL_REGS;

No need to retest, just make sure this compiles and install, thanks.

-- 
Eric Botcazou


[SPARC] Hookize PREFERRED_RELOAD_CLASS

2011-04-03 Thread Anatoly Sokolov
 Hello.

  This patch removes obsolete PREFERRED_RELOAD_CLASS macro from SPARC back end
in the GCC and introduces equivalent TARGET_PREFERRED_RELOAD_CLASS target 
hooks.

   Bootstrapped and regression tested on sparc64-unknown-linux-gnu.

  OK to install?

* config/sparc/sparc.h (PREFERRED_RELOAD_CLASS): Remove.
* config/sparc/sparc.c (TARGET_PREFERRED_RELOAD_CLASS): Define.
(sparc_preferred_reload_class): New function.

Index: gcc/gcc/config/sparc/sparc.c
===
--- gcc/gcc/config/sparc/sparc.c(revision 171581)
+++ gcc/gcc/config/sparc/sparc.c(working copy)
@@ -467,6 +467,7 @@
 #endif
 static void sparc_trampoline_init (rtx, tree, rtx);
 static enum machine_mode sparc_preferred_simd_mode (enum machine_mode);
+static reg_class_t sparc_preferred_reload_class (rtx x, reg_class_t rclass);
 
 #ifdef SUBTARGET_ATTRIBUTE_TABLE
 /* Table of valid machine attributes.  */
@@ -660,6 +661,8 @@
 
 #undef TARGET_CAN_ELIMINATE
 #define TARGET_CAN_ELIMINATE sparc_can_eliminate
+#undef  TARGET_PREFERRED_RELOAD_CLASS
+#define TARGET_PREFERRED_RELOAD_CLASS sparc_preferred_reload_class
 
 #undef TARGET_CONDITIONAL_REGISTER_USAGE
 #define TARGET_CONDITIONAL_REGISTER_USAGE sparc_conditional_register_usage
@@ -9769,4 +9772,33 @@
 fixed_regs[4] = 0;
 }
 
+/* Implement TARGET_PREFERRED_RELOAD_CLASS
+
+   - We can't load constants into FP registers.
+   - We can't load FP constants into integer registers when soft-float,
+ because there is no soft-float pattern with a r/F constraint.
+   - We can't load FP constants into integer registers for TFmode unless
+ it is 0.0L, because there is no movtf pattern with a r/F constraint.
+   - Try and reload integer constants (symbolic or otherwise) back into
+ registers directly, rather than having them dumped to memory.  */
+
+static reg_class_t
+sparc_preferred_reload_class (rtx x, reg_class_t rclass)
+{
+  if (CONSTANT_P (x))
+{
+  if (FP_REG_CLASS_P (rclass)
+ || rclass == GENERAL_OR_FP_REGS
+ || rclass == GENERAL_OR_EXTRA_FP_REGS
+ || (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT && ! TARGET_FPU)
+ || (GET_MODE (x) == TFmode && ! const_zero_operand (x, TFmode)))
+   return NO_REGS;
+  else if (!FP_REG_CLASS_P (rclass)
+  && GET_MODE_CLASS (GET_MODE (x)) == MODE_INT)
+   return GENERAL_REGS;
+}
+
+  return rclass;
+}
+
 #include "gt-sparc.h"
Index: gcc/gcc/config/sparc/sparc.h
===
--- gcc/gcc/config/sparc/sparc.h(revision 171581)
+++ gcc/gcc/config/sparc/sparc.h(working copy)
@@ -1153,34 +1153,6 @@
 #define SPARC_SETHI32_P(X) \
   (SPARC_SETHI_P ((unsigned HOST_WIDE_INT) (X) & GET_MODE_MASK (SImode)))
 
-/* Given an rtx X being reloaded into a reg required to be
-   in class CLASS, return the class of reg to actually use.
-   In general this is just CLASS; but on some machines
-   in some cases it is preferable to use a more restrictive class.  */
-/* - We can't load constants into FP registers.
-   - We can't load FP constants into integer registers when soft-float,
- because there is no soft-float pattern with a r/F constraint.
-   - We can't load FP constants into integer registers for TFmode unless
- it is 0.0L, because there is no movtf pattern with a r/F constraint.
-   - Try and reload integer constants (symbolic or otherwise) back into
- registers directly, rather than having them dumped to memory.  */
-
-#define PREFERRED_RELOAD_CLASS(X,CLASS)\
-  (CONSTANT_P (X)  \
-   ? ((FP_REG_CLASS_P (CLASS)  \
-   || (CLASS) == GENERAL_OR_FP_REGS\
-   || (CLASS) == GENERAL_OR_EXTRA_FP_REGS  \
-   || (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \
-  && ! TARGET_FPU) \
-   || (GET_MODE (X) == TFmode  \
-  && ! const_zero_operand (X, TFmode)))\
-  ? NO_REGS\
-  : (!FP_REG_CLASS_P (CLASS)   \
- && GET_MODE_CLASS (GET_MODE (X)) == MODE_INT) \
-  ? GENERAL_REGS   \
-  : (CLASS))   \
-   : (CLASS))
-
 /* Return the register class of a scratch register needed to load IN into
a register of class CLASS in MODE.
 

Anatoly.