Patchwork [MN10300] Hookize PREFERRED_RELOAD_CLASS and PREFERRED_OUTPUT_RELOAD_CLASS

login
register
mail settings
Submitter Anatoly Sokolov
Date Nov. 15, 2010, 5:25 p.m.
Message ID <651247317.20101115202548@post.ru>
Download mbox | patch
Permalink /patch/71254/
State New
Headers show

Comments

Anatoly Sokolov - Nov. 15, 2010, 5:25 p.m.
Hello.

  This patch removes obsolete PREFERRED_RELOAD_CLASS and 
PREFERRED_OUTPUT_RELOAD_CLASS macros from MN10300 back end in the GCC and 
introduces equivalent TARGET_PREFERRED_RELOAD_CLASS and 
TARGET_PREFERRED_OUTPUT_RELOAD_CLASS target hooks.

  Regression tested on mn10300-unknown-elf.

  OK to install?

        * config/mn10300/mn10300.h (PREFERRED_RELOAD_CLASS,
        PREFERRED_OUTPUT_RELOAD_CLASS): Remove.
        * config/mn10300/mn10300.c (TARGET_PREFERRED_RELOAD_CLASS,
        TARGET_PREFERRED_OUTPUT_RELOAD_CLASS): Define.
        (mn10300_preferred_reload_class,
        mn10300_preferred_output_reload_class): New functions.



Anatoly.
Richard Henderson - Nov. 15, 2010, 8:18 p.m.
On 11/15/2010 09:25 AM, Anatoly Sokolov wrote:
>         * config/mn10300/mn10300.h (PREFERRED_RELOAD_CLASS,
>         PREFERRED_OUTPUT_RELOAD_CLASS): Remove.
>         * config/mn10300/mn10300.c (TARGET_PREFERRED_RELOAD_CLASS,
>         TARGET_PREFERRED_OUTPUT_RELOAD_CLASS): Define.
>         (mn10300_preferred_reload_class,
>         mn10300_preferred_output_reload_class): New functions.

Ok.


r~

Patch

Index: gcc/config/mn10300/mn10300.c
===================================================================
--- gcc/config/mn10300/mn10300.c        (revision 166759)
+++ gcc/config/mn10300/mn10300.c        (working copy)
@@ -1270,6 +1270,35 @@ 
   return mask;
 }
 
+/* Implement TARGET_PREFERRED_RELOAD_CLASS.  */
+
+static reg_class_t
+mn10300_preferred_reload_class (rtx x, reg_class_t rclass)
+{
+  if (x == stack_pointer_rtx && rclass != SP_REGS)
+     return ADDRESS_OR_EXTENDED_REGS;
+   else if (MEM_P (x)
+           || (REG_P (x) 
+               && !HARD_REGISTER_P (x))
+           || (GET_CODE (x) == SUBREG
+               && REG_P (SUBREG_REG (x))
+               && !HARD_REGISTER_P (SUBREG_REG (x))))
+    return LIMIT_RELOAD_CLASS (GET_MODE (x), rclass);
+  else
+    return rclass;
+}
+
+/* Implement TARGET_PREFERRED_OUTPUT_RELOAD_CLASS.  */
+
+static reg_class_t
+mn10300_preferred_output_reload_class (rtx x, reg_class_t rclass)
+{
+  if (x == stack_pointer_rtx && rclass != SP_REGS)
+    return ADDRESS_OR_EXTENDED_REGS;
+
+  return rclass;
+}
+
 /* What (if any) secondary registers are needed to move IN with mode
    MODE into a register in register class RCLASS.
 
@@ -2460,6 +2489,11 @@ 
 #undef  TARGET_LEGITIMATE_ADDRESS_P
 #define TARGET_LEGITIMATE_ADDRESS_P    mn10300_legitimate_address_p
 
+#undef  TARGET_PREFERRED_RELOAD_CLASS
+#define TARGET_PREFERRED_RELOAD_CLASS mn10300_preferred_reload_class
+#undef  TARGET_PREFERRED_OUTPUT_RELOAD_CLASS
+#define TARGET_PREFERRED_OUTPUT_RELOAD_CLASS mn10300_preferred_output_reload_class
+
 #undef  TARGET_ASM_TRAMPOLINE_TEMPLATE
 #define TARGET_ASM_TRAMPOLINE_TEMPLATE mn10300_asm_trampoline_template
 #undef  TARGET_TRAMPOLINE_INIT
Index: gcc/config/mn10300/mn10300.h
===================================================================
--- gcc/config/mn10300/mn10300.h        (revision 166759)
+++ gcc/config/mn10300/mn10300.h        (working copy)
@@ -422,27 +422,6 @@ 
 #define REG_OK_FOR_INDEX_P(X) \
   (REGNO_OK_FOR_INDEX_P (REGNO (X)))
 
-/* 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.  */
-
-#define PREFERRED_RELOAD_CLASS(X,CLASS)                                \
-  ((X) == stack_pointer_rtx && (CLASS) != SP_REGS              \
-   ? ADDRESS_OR_EXTENDED_REGS                                  \
-   : (MEM_P (X)                                                        \
-      || (REG_P (X)                                            \
-         && REGNO (X) >= FIRST_PSEUDO_REGISTER)                \
-      || (GET_CODE (X) == SUBREG                               \
-         && REG_P (SUBREG_REG (X))                             \
-         && REGNO (SUBREG_REG (X)) >= FIRST_PSEUDO_REGISTER)   \
-      ? LIMIT_RELOAD_CLASS (GET_MODE (X), CLASS)               \
-      : (CLASS)))
-
-#define PREFERRED_OUTPUT_RELOAD_CLASS(X,CLASS) \
-  (X == stack_pointer_rtx && CLASS != SP_REGS \
-   ? ADDRESS_OR_EXTENDED_REGS : CLASS)
-
 #define LIMIT_RELOAD_CLASS(MODE, CLASS) \
   (!TARGET_AM33 && (MODE == QImode || MODE == HImode) ? DATA_REGS : CLASS)