[CRIS] Hookize REGISTER_MOVE_COST and MEMORY_MOVE_COST

Anatoly Sokolov aesok@post.ru
Thu Sep 30 03:51:00 GMT 2010


  Hi.

  This patch removes obsolete REGISTER_MOVE_COST and MEMORY_MOVE_COST
macros from the CRIS back end in the GCC and introduces equivalent
TARGET_REGISTER_MOVE_COST and TARGET_MEMORY_MOVE_COST target hooks.

  Regression tested on cris-axis-elf.

  OK to install?

        * config/cris/m32c.c (cris_memory_move_cost): New.
        (cris_register_move_cost): Make static. Change arguments type from
        enum reg_class to reg_class_t.
        (TARGET_REGISTER_MOVE_COST, TARGET_MEMORY_MOVE_COST): Define.
        * config/cris/cris.h (REGISTER_MOVE_COST, MEMORY_MOVE_COST): Remove.
        * config/cris/cris-protos.h (cris_register_move_cost): Remove.

Index: gcc/config/cris/cris.c
===================================================================
--- gcc/config/cris/cris.c      (revision 164725)
+++ gcc/config/cris/cris.c      (working copy)
@@ -121,6 +121,8 @@
 static void cris_file_start (void);
 static void cris_init_libfuncs (void);
 
+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 *, bool);
 static int cris_address_cost (rtx, bool);
 static bool cris_pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode,
@@ -185,6 +187,10 @@
 #undef TARGET_INIT_LIBFUNCS
 #define TARGET_INIT_LIBFUNCS cris_init_libfuncs
 
+#undef TARGET_REGISTER_MOVE_COST
+#define TARGET_REGISTER_MOVE_COST cris_register_move_cost
+#undef TARGET_MEMORY_MOVE_COST
+#define TARGET_MEMORY_MOVE_COST cris_memory_move_cost
 #undef TARGET_RTX_COSTS
 #define TARGET_RTX_COSTS cris_rtx_costs
 #undef TARGET_ADDRESS_COST
@@ -1378,11 +1384,11 @@
   return false;
 }
 
-/* Worker function for REGISTER_MOVE_COST.  */
+/* Worker function for TARGET_REGISTER_MOVE_COST.  */
 
-int
+static int
 cris_register_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED,
-                        enum reg_class from, enum reg_class to) 
+                        reg_class_t from, reg_class_t to) 
 {
   if (!TARGET_V32)
     {
@@ -1424,6 +1430,23 @@
   return 2;
 }
 
+/* Worker function for TARGET_MEMORY_MOVE_COST.
+
+   This isn't strictly correct for v0..3 in buswidth-8bit mode, but should
+   suffice.  */
+
+static int
+cris_memory_move_cost (enum machine_mode mode,
+                       reg_class_t rclass ATTRIBUTE_UNUSED,
+                       bool in ATTRIBUTE_UNUSED)
+{
+  if (mode == QImode
+      || mode   == HImode)
+    return 4;
+  else
+    return 6;
+}
+
 /* Worker for cris_notice_update_cc; handles the "normal" cases.
    FIXME: this code is historical; its functionality should be
    refactored to look at insn attributes and moved to
Index: gcc/config/cris/cris.h
===================================================================
--- gcc/config/cris/cris.h      (revision 164725)
+++ gcc/config/cris/cris.h      (working copy)
@@ -1073,14 +1073,6 @@
 
 /* Node: Costs */
 
-#define REGISTER_MOVE_COST(MODE, FROM, TO)     \
-  cris_register_move_cost (MODE, FROM, TO)
-
-/* This isn't strictly correct for v0..3 in buswidth-8bit mode, but
-   should suffice.  */
-#define MEMORY_MOVE_COST(M, CLASS, IN) \
- (((M) == QImode) ? 4 : ((M) == HImode) ? 4 : 6)
-
 /* Regardless of the presence of delay slots, the default value of 1 for
    BRANCH_COST is the best in the range (1, 2, 3), tested with gcc-2.7.2
    with testcases ipps and gcc, giving smallest and fastest code.  */
Index: gcc/config/cris/cris-protos.h
===================================================================
--- gcc/config/cris/cris-protos.h       (revision 164725)
+++ gcc/config/cris/cris-protos.h       (working copy)
@@ -31,8 +31,6 @@
 extern const char *cris_op_str (rtx);
 extern void cris_notice_update_cc (rtx, rtx);
 extern bool cris_reload_address_legitimized (rtx, enum machine_mode, int, int, int);
-extern int cris_register_move_cost (enum machine_mode, enum reg_class,
-                                   enum reg_class);
 extern int cris_side_effect_mode_ok (enum rtx_code, rtx *, int, int,
                                      int, int, int);
 extern bool cris_cc0_user_requires_cmp (rtx);


Anatoly.



More information about the Gcc-patches mailing list