diff mbox

[SH] Hookize PREFERRED_RELOAD_CLASS

Message ID 162716564.20101218145828@post.ru
State New
Headers show

Commit Message

Anatoly Sokolov Dec. 18, 2010, 11:58 a.m. UTC
Hello.

  This patch removes obsolete PREFERRED_RELOAD_CLASS macro from SH back end
in the GCC and introduces equivalent TARGET_PREFERRED_RELOAD_CLASS target 
hook. This patch make sh_secondary_reload function static, also.

  Regression tested on sh-unknown-elf.

  OK to install?

        * config/sh/sh.h (PREFERRED_RELOAD_CLASS): Remove.
        * config/sh/sh-protos.h (secondary_reload_info, sh_secondary_reload):
        Remove forward declaration.
        * config/sh/sh.c (sh_preferred_reload_class): New function.
        (sh_secondary_reload): Make static.
        (TARGET_PREFERRED_RELOAD_CLASS): Define.


Anatoly.

Comments

Kaz Kojima Dec. 18, 2010, 11:35 p.m. UTC | #1
Anatoly Sokolov <aesok@post.ru> wrote:
>   This patch removes obsolete PREFERRED_RELOAD_CLASS macro from SH back end
> in the GCC and introduces equivalent TARGET_PREFERRED_RELOAD_CLASS target 
> hook. This patch make sh_secondary_reload function static, also.
> 
>   Regression tested on sh-unknown-elf.
> 
>   OK to install?
> 
>         * config/sh/sh.h (PREFERRED_RELOAD_CLASS): Remove.
>         * config/sh/sh-protos.h (secondary_reload_info, sh_secondary_reload):
>         Remove forward declaration.
>         * config/sh/sh.c (sh_preferred_reload_class): New function.
>         (sh_secondary_reload): Make static.
>         (TARGET_PREFERRED_RELOAD_CLASS): Define.

OK.  Thanks!

Regards,
	kaz
diff mbox

Patch

Index: gcc/config/sh/sh-protos.h
===================================================================
--- gcc/config/sh/sh-protos.h   (revision 168014)
+++ gcc/config/sh/sh-protos.h   (working copy)
@@ -165,10 +165,6 @@ 
 extern int sh_contains_memref_p (rtx);
 extern int sh_loads_bankedreg_p (rtx);
 extern rtx shmedia_prepare_call_address (rtx fnaddr, int is_sibcall);
-struct secondary_reload_info;
-extern reg_class_t sh_secondary_reload (bool, rtx, reg_class_t,
-                                       enum machine_mode,
-                                       struct secondary_reload_info *);
 extern int sh2a_get_function_vector_number (rtx);
 extern int sh2a_is_function_vector_call (rtx);
 extern void sh_fix_range (const char *);
Index: gcc/config/sh/sh.c
===================================================================
--- gcc/config/sh/sh.c  (revision 168014)
+++ gcc/config/sh/sh.c  (working copy)
@@ -253,6 +253,10 @@ 
 static int sh_address_cost (rtx, bool);
 static int sh_pr_n_sets (void);
 static rtx sh_allocate_initial_value (rtx);
+static reg_class_t sh_preferred_reload_class (rtx, reg_class_t);
+static reg_class_t sh_secondary_reload (bool, rtx, reg_class_t,
+                                        enum machine_mode,
+                                        struct secondary_reload_info *);
 static bool sh_legitimate_address_p (enum machine_mode, rtx, bool);
 static rtx sh_legitimize_address (rtx, rtx, enum machine_mode);
 static rtx sh_delegitimize_address (rtx);
@@ -591,6 +595,9 @@ 
 #undef TARGET_SECONDARY_RELOAD
 #define TARGET_SECONDARY_RELOAD sh_secondary_reload
 
+#undef  TARGET_PREFERRED_RELOAD_CLASS
+#define TARGET_PREFERRED_RELOAD_CLASS sh_preferred_reload_class
+
 #undef TARGET_CONDITIONAL_REGISTER_USAGE
 #define TARGET_CONDITIONAL_REGISTER_USAGE sh_conditional_register_usage
 
@@ -12426,7 +12433,24 @@ 
   return fnaddr;
 }
 
-reg_class_t
+/* Implement TARGET_PREFERRED_RELOAD_CLASS.  */
+
+static reg_class_t
+sh_preferred_reload_class (rtx x, reg_class_t rclass)
+{
+  if (rclass == NO_REGS
+      && TARGET_SHMEDIA
+      && (CONST_DOUBLE_P (x)
+         || GET_CODE (x) == SYMBOL_REF
+         || PIC_ADDR_P (x)))
+    return GENERAL_REGS;
+
+  return rclass;
+}
+
+/* Implement TARGET_SECONDARY_RELOAD.  */
+
+static reg_class_t
 sh_secondary_reload (bool in_p, rtx x, reg_class_t rclass_i,
                     enum machine_mode mode, secondary_reload_info *sri)
 {
Index: gcc/config/sh/sh.h
===================================================================
--- gcc/config/sh/sh.h  (revision 168014)
+++ gcc/config/sh/sh.h  (working copy)
@@ -1213,19 +1213,6 @@ 
 #define CONST_OK_FOR_K08(VALUE) (((HOST_WIDE_INT)(VALUE))>= 0 \
                                 && ((HOST_WIDE_INT)(VALUE)) <= 255)
 
-/* 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) \
-  ((CLASS) == NO_REGS && TARGET_SHMEDIA \
-   && (GET_CODE (X) == CONST_DOUBLE \
-       || GET_CODE (X) == SYMBOL_REF \
-       || PIC_ADDR_P (X)) \
-   ? GENERAL_REGS \
-   : (CLASS)) \
-
 #if 0
 #define SECONDARY_INOUT_RELOAD_CLASS(CLASS,MODE,X,ELSE) \
   ((((REGCLASS_HAS_FP_REG (CLASS)                                      \