Patchwork [S390] Hookize REGISTER_MOVE_COST and MEMORY_MOVE_COST

login
register
mail settings
Submitter Anatoly Sokolov
Date Jan. 19, 2011, 5:32 p.m.
Message ID <1895370735.20110119203210@post.ru>
Download mbox | patch
Permalink /patch/79499/
State New
Headers show

Comments

Anatoly Sokolov - Jan. 19, 2011, 5:32 p.m.
Hi.

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

  Not tested.

  OK to install?

        * config/s390/s390.h (REGISTER_MOVE_COST, MEMORY_MOVE_COST): Remove.
        * config/s390/s390.c (s390_register_move_cost,
        s390_memory_move_cost): Make static.
        (TARGET_REGISTER_MOVE_COST, TARGET_MEMORY_MOVE_COST): Define.



Anatoly.
Andreas Krebbel - Jan. 20, 2011, 7:38 p.m.
>         * config/s390/s390.h (REGISTER_MOVE_COST, MEMORY_MOVE_COST): Remove.
>         * config/s390/s390.c (s390_register_move_cost,
>         s390_memory_move_cost): Make static.
>         (TARGET_REGISTER_MOVE_COST, TARGET_MEMORY_MOVE_COST): Define.

Regtested on s390x. No problems.
This is ok. Thanks!

Bye,

-Andreas-

Patch

Index: gcc/config/s390/s390.c
===================================================================
--- gcc/config/s390/s390.c      (revision 169002)
+++ gcc/config/s390/s390.c      (working copy)
@@ -2426,7 +2426,32 @@ 
          && value == CONST0_RTX (GET_MODE (value)));
 }
 
+/* Implement TARGET_REGISTER_MOVE_COST.  */
 
+static int
+s390_register_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED,
+                         reg_class_t from, reg_class_t to)
+{
+/* On s390, copy between fprs and gprs is expensive.  */
+  if ((reg_classes_intersect_p (from, GENERAL_REGS)
+       && reg_classes_intersect_p (to, FP_REGS))
+      || (reg_classes_intersect_p (from, FP_REGS)
+         && reg_classes_intersect_p (to, GENERAL_REGS)))
+    return 10;
+
+  return 1;
+}
+
+/* Implement TARGET_MEMORY_MOVE_COST.  */
+
+static int
+s390_memory_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED,
+                      reg_class_t rclass ATTRIBUTE_UNUSED,
+                      bool in ATTRIBUTE_UNUSED)
+{
+  return 1;
+}
+
 /* Compute a (partial) cost for rtx X.  Return true if the complete
    cost has been computed, and false if subexpressions should be
    scanned.  In either case, *TOTAL contains the cost result.
@@ -10640,6 +10665,10 @@ 
 #define TARGET_RTX_COSTS s390_rtx_costs
 #undef TARGET_ADDRESS_COST
 #define TARGET_ADDRESS_COST s390_address_cost
+#undef TARGET_REGISTER_MOVE_COST
+#define TARGET_REGISTER_MOVE_COST s390_register_move_cost
+#undef TARGET_MEMORY_MOVE_COST
+#define TARGET_MEMORY_MOVE_COST s390_memory_move_cost
 
 #undef TARGET_MACHINE_DEPENDENT_REORG
 #define TARGET_MACHINE_DEPENDENT_REORG s390_reorg
Index: gcc/config/s390/s390.h
===================================================================
--- gcc/config/s390/s390.h      (revision 169002)
+++ gcc/config/s390/s390.h      (working copy)
@@ -780,18 +780,6 @@ 
 
 /* Relative costs of operations.  */
 
-/* On s390, copy between fprs and gprs is expensive.  */
-#define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2)                        \
-  ((   (   reg_classes_intersect_p ((CLASS1), GENERAL_REGS)            \
-        && reg_classes_intersect_p ((CLASS2), FP_REGS))                        \
-    || (   reg_classes_intersect_p ((CLASS1), FP_REGS)                 \
-        && reg_classes_intersect_p ((CLASS2), GENERAL_REGS))) ? 10 : 1)
-
-/* A C expression for the cost of moving data of mode M between a
-   register and memory.  A value of 2 is the default; this cost is
-   relative to those in `REGISTER_MOVE_COST'.  */
-#define MEMORY_MOVE_COST(M, C, I) 1
-
 /* A C expression for the cost of a branch instruction.  A value of 1
    is the default; other values are interpreted relative to that.  */
 #define BRANCH_COST(speed_p, predictable_p) 1