[M32R] Hookize REGISTER_MOVE_COST and MEMORY_MOVE_COST

Anatoly Sokolov aesok@post.ru
Sun Sep 5 21:27:00 GMT 2010


   Hi.

  This patch removes obsolete REGISTER_MOVE_COST and MEMORY_MOVE_COST
macros from the M32R back end in the GCC and introduces equivalent
TARGET_MEMORY_MOVE_COST target hook. Since REGISTER_MOVE_COST is defined as
default value 2 the default version of the TARGET_REGISTER_MOVE_COST is used.

  Regression tested on m32r-unknown-elf.

  OK to install?

        * config/m32r/m32r.h (REGISTER_MOVE_COST, MEMORY_MOVE_COST): Remove.
        * config/m32r/m32r.c (TARGET_MEMORY_MOVE_COSTS): Define.
        (m32r_memory_move_cost): New function


Index: gcc/config/m32r/m32r.c
===================================================================
--- gcc/config/m32r/m32r.c      (revision 163882)
+++ gcc/config/m32r/m32r.c      (working copy)
@@ -89,6 +89,7 @@
                                         tree, int *, int);
 static void init_idents (void);
 static bool m32r_rtx_costs (rtx, int, int, int *, bool speed);
+static int m32r_memory_move_cost (enum machine_mode, reg_class_t, bool);
 static bool m32r_pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode,
                                    const_tree, bool);
 static int m32r_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode,
@@ -152,6 +153,9 @@
 #undef  TARGET_IN_SMALL_DATA_P
 #define TARGET_IN_SMALL_DATA_P m32r_in_small_data_p
 
+
+#undef  TARGET_MEMORY_MOVE_COSTS
+#define TARGET_MEMORY_MOVE_COSTS m32r_memory_move_costs
 #undef  TARGET_RTX_COSTS
 #define TARGET_RTX_COSTS m32r_rtx_costs
 #undef  TARGET_ADDRESS_COST
@@ -1366,6 +1370,22 @@
 

 /* Cost functions.  */
 
+/* Implement TARGET_HANDLE_OPTION.
+
+   Memory is 3 times as expensive as registers.
+   ??? Is that the right way to look at it?  */
+
+static int
+m32r_memory_move_cost (enum machine_mode mode,
+                      reg_class_t rclass ATTRIBUTE_UNUSED,
+                      bool in ATTRIBUTE_UNUSED)
+{
+  if (GET_MODE_SIZE (mode) <= UNITS_PER_WORD)
+    return 6;
+  else
+    return 12;
+}
+
 static bool
 m32r_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, int *total,
                bool speed ATTRIBUTE_UNUSED)
Index: gcc/config/m32r/m32r.h
===================================================================
--- gcc/config/m32r/m32r.h      (revision 163882)
+++ gcc/config/m32r/m32r.h      (working copy)
@@ -1067,16 +1067,6 @@
 

 /* Costs.  */
 
-/* Compute extra cost of moving data between one register class
-   and another.  */
-#define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2) 2
-
-/* Compute the cost of moving data between registers and memory.  */
-/* Memory is 3 times as expensive as registers.
-   ??? Is that the right way to look at it?  */
-#define MEMORY_MOVE_COST(MODE,CLASS,IN_P) \
-(GET_MODE_SIZE (MODE) <= UNITS_PER_WORD ? 6 : 12)
-
 /* The cost of a branch insn.  */
 /* A value of 2 here causes GCC to avoid using branches in comparisons like
    while (a < N && a).  Branches aren't that expensive on the M32R so

Anatoly.



More information about the Gcc-patches mailing list