Patchwork [CRIS] Hookize PREFERRED_RELOAD_CLASS

login
register
mail settings
Submitter Anatoly Sokolov
Date Oct. 9, 2011, 1:47 p.m.
Message ID <534795702.20111009174722@post.ru>
Download mbox | patch
Permalink /patch/118587/
State New
Headers show

Comments

Anatoly Sokolov - Oct. 9, 2011, 1:47 p.m.
Hello.

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

  Regression tested on cris-axis-elf.

  OK to install?

        * config/cris/cris.c (cris_preferred_reload_class): New function.
        (TARGET_PREFERRED_RELOAD_CLASS): Define.
        * config/cris/cris.h (OUTPUT_ADDR_CONST_EXTRA): Remove.



Anatoly.

Patch

Index: gcc/config/cris/cris.c
===================================================================
--- gcc/config/cris/cris.c      (revision 179721)
+++ gcc/config/cris/cris.c      (working copy)
@@ -123,6 +123,8 @@ 
 static void cris_file_start (void);
 static void cris_init_libfuncs (void);
 
+static reg_class_t cris_preferred_reload_class (rtx, reg_class_t);
+
 static int cris_register_move_cost (enum machine_mode, reg_class_t, reg_class_t);
 static int cris_memory_move_cost (enum machine_mode, reg_class_t, bool);
 static bool cris_rtx_costs (rtx, int, int, int, int *, bool);
@@ -198,6 +200,9 @@ 
 #undef TARGET_INIT_LIBFUNCS
 #define TARGET_INIT_LIBFUNCS cris_init_libfuncs
 
+#undef TARGET_PREFERRED_RELOAD_CLASS
+#define TARGET_PREFERRED_RELOAD_CLASS cris_preferred_reload_class
+
 #undef TARGET_REGISTER_MOVE_COST
 #define TARGET_REGISTER_MOVE_COST cris_register_move_cost
 #undef TARGET_MEMORY_MOVE_COST
@@ -1342,6 +1347,31 @@ 
   return false;
 }
 
+
+/* Worker function for TARGET_PREFERRED_RELOAD_CLASS.
+
+   It seems like gcc (2.7.2 and 2.9x of 2000-03-22) may send "NO_REGS" as
+   the class for a constant (testcase: __Mul in arit.c).  To avoid forcing
+   out a constant into the constant pool, we will trap this case and
+   return something a bit more sane.  FIXME: Check if this is a bug.
+   Beware that we must not "override" classes that can be specified as
+   constraint letters, or else asm operands using them will fail when
+   they need to be reloaded.  FIXME: Investigate whether that constitutes
+   a bug.  */
+
+static reg_class_t
+cris_preferred_reload_class (rtx x ATTRIBUTE_UNUSED, reg_class_t rclass)
+{
+  if (rclass != ACR_REGS
+      && rclass != MOF_REGS
+      && rclass != SRP_REGS
+      && rclass != CC0_REGS
+      && rclass != SPECIAL_REGS)
+    return GENERAL_REGS;
+
+  return rclass;
+}
+
 /* Worker function for TARGET_REGISTER_MOVE_COST.  */
 
 static int
Index: gcc/config/cris/cris.h
===================================================================
--- gcc/config/cris/cris.h      (revision 179721)
+++ gcc/config/cris/cris.h      (working copy)
@@ -583,22 +583,6 @@ 
 /* See REGNO_OK_FOR_BASE_P.  */
 #define REGNO_OK_FOR_INDEX_P(REGNO) REGNO_OK_FOR_BASE_P(REGNO)
 
-/* It seems like gcc (2.7.2 and 2.9x of 2000-03-22) may send "NO_REGS" as
-   the class for a constant (testcase: __Mul in arit.c).  To avoid forcing
-   out a constant into the constant pool, we will trap this case and
-   return something a bit more sane.  FIXME: Check if this is a bug.
-   Beware that we must not "override" classes that can be specified as
-   constraint letters, or else asm operands using them will fail when
-   they need to be reloaded.  FIXME: Investigate whether that constitutes
-   a bug.  */
-#define PREFERRED_RELOAD_CLASS(X, CLASS)       \
- ((CLASS) != ACR_REGS                          \
-  && (CLASS) != MOF_REGS                       \
-  && (CLASS) != SRP_REGS                       \
-  && (CLASS) != CC0_REGS                       \
-  && (CLASS) != SPECIAL_REGS                   \
-  ? GENERAL_REGS : (CLASS))
-
 /* We can't move special registers to and from memory in smaller than
    word_mode.  We also can't move between special registers.  Luckily,
    -1, as returned by true_regnum for non-sub/registers, is valid as a