[3/7] Tidy IRA move costs

2012-05-30 Thread Richard Sandiford
After the preceding patch, only ira_init_register_move_cost uses
the regclass costs directly.  This patch moves them to IRA and makes
init_move_cost static to it.

This is just a stepping stone to make the later patches easier to review.

Richard


gcc/
* regs.h (move_table, move_cost, may_move_in_cost, may_move_out_cost):
Move these definitions and associated target_globals fields to...
* ira-int.h: ...here.
* rtl.h (init_move_cost): Delete.
* reginfo.c (last_mode_for_init_move_cost, init_move_cost): Move to...
* ira.c: ...here, making the latter static.

Index: gcc/regs.h
===
--- gcc/regs.h  2012-05-29 19:11:06.079795522 +0100
+++ gcc/regs.h  2012-05-29 19:27:41.214766589 +0100
@@ -240,8 +240,6 @@ #define HARD_REGNO_CALLER_SAVE_MODE(REGN
 #define HARD_REGNO_CALL_PART_CLOBBERED(REGNO, MODE) 0
 #endif
 
-typedef unsigned short move_table[N_REG_CLASSES];
-
 /* Target-dependent globals.  */
 struct target_regs {
   /* For each starting hard register, the number of consecutive hard
@@ -261,21 +259,6 @@ struct target_regs {
   /* 1 if the corresponding class contains a register of the given mode.  */
   char x_contains_reg_of_mode[N_REG_CLASSES][MAX_MACHINE_MODE];
 
-  /* Maximum cost of moving from a register in one class to a register
- in another class.  Based on TARGET_REGISTER_MOVE_COST.  */
-  move_table *x_move_cost[MAX_MACHINE_MODE];
-
-  /* Similar, but here we don't have to move if the first index is a
- subset of the second so in that case the cost is zero.  */
-  move_table *x_may_move_in_cost[MAX_MACHINE_MODE];
-
-  /* Similar, but here we don't have to move if the first index is a
- superset of the second so in that case the cost is zero.  */
-  move_table *x_may_move_out_cost[MAX_MACHINE_MODE];
-
-  /* Keep track of the last mode we initialized move costs for.  */
-  int x_last_mode_for_init_move_cost;
-
   /* Record for each mode whether we can move a register directly to or
  from an object of that mode in memory.  If we can't, we won't try
  to use that mode directly when accessing a field of that mode.  */
@@ -301,12 +284,6 @@ #define have_regs_of_mode \
   (this_target_regs-x_have_regs_of_mode)
 #define contains_reg_of_mode \
   (this_target_regs-x_contains_reg_of_mode)
-#define move_cost \
-  (this_target_regs-x_move_cost)
-#define may_move_in_cost \
-  (this_target_regs-x_may_move_in_cost)
-#define may_move_out_cost \
-  (this_target_regs-x_may_move_out_cost)
 #define direct_load \
   (this_target_regs-x_direct_load)
 #define direct_store \
Index: gcc/ira-int.h
===
--- gcc/ira-int.h   2012-05-29 19:11:06.079795522 +0100
+++ gcc/ira-int.h   2012-05-29 19:27:41.207766589 +0100
@@ -75,6 +75,8 @@ DEF_VEC_ALLOC_P(ira_copy_t, heap);
 /* Typedef for pointer to the subsequent structure.  */
 typedef struct ira_loop_tree_node *ira_loop_tree_node_t;
 
+typedef unsigned short move_table[N_REG_CLASSES];
+
 /* In general case, IRA is a regional allocator.  The regions are
nested and form a tree.  Currently regions are natural loops.  The
following structure describes loop tree node (representing basic
@@ -767,6 +769,21 @@ struct target_ira_int {
   HARD_REG_SET (x_ira_reg_mode_hard_regset
[FIRST_PSEUDO_REGISTER][NUM_MACHINE_MODES]);
 
+  /* Maximum cost of moving from a register in one class to a register
+ in another class.  Based on TARGET_REGISTER_MOVE_COST.  */
+  move_table *x_move_cost[MAX_MACHINE_MODE];
+
+  /* Similar, but here we don't have to move if the first index is a
+ subset of the second so in that case the cost is zero.  */
+  move_table *x_may_move_in_cost[MAX_MACHINE_MODE];
+
+  /* Similar, but here we don't have to move if the first index is a
+ superset of the second so in that case the cost is zero.  */
+  move_table *x_may_move_out_cost[MAX_MACHINE_MODE];
+
+  /* Keep track of the last mode we initialized move costs for.  */
+  int x_last_mode_for_init_move_cost;
+
   /* Array based on TARGET_REGISTER_MOVE_COST.  Don't use
  ira_register_move_cost directly.  Use function of
  ira_get_may_move_cost instead.  */
@@ -888,6 +905,12 @@ #define this_target_ira_int (default_ta
 
 #define ira_reg_mode_hard_regset \
   (this_target_ira_int-x_ira_reg_mode_hard_regset)
+#define move_cost \
+  (this_target_ira_int-x_move_cost)
+#define may_move_in_cost \
+  (this_target_ira_int-x_may_move_in_cost)
+#define may_move_out_cost \
+  (this_target_ira_int-x_may_move_out_cost)
 #define ira_register_move_cost \
   (this_target_ira_int-x_ira_register_move_cost)
 #define ira_max_memory_move_cost \
Index: gcc/rtl.h
===
--- gcc/rtl.h   2012-05-29 19:11:06.080795522 +0100
+++ gcc/rtl.h   2012-05-29 19:27:41.216766589 +0100
@@ -2045,8 +2045,6 @@ extern rtx remove_free_EXPR_LIST_node (r
 
 /* 

Re: [3/7] Tidy IRA move costs

2012-05-30 Thread Vladimir Makarov

On 05/30/2012 02:24 PM, Richard Sandiford wrote:

After the preceding patch, only ira_init_register_move_cost uses
the regclass costs directly.  This patch moves them to IRA and makes
init_move_cost static to it.

This is just a stepping stone to make the later patches easier to review.

Richard


gcc/
* regs.h (move_table, move_cost, may_move_in_cost, may_move_out_cost):
Move these definitions and associated target_globals fields to...
* ira-int.h: ...here.
* rtl.h (init_move_cost): Delete.
* reginfo.c (last_mode_for_init_move_cost, init_move_cost): Move to...
* ira.c: ...here, making the latter static.



Ok.  Thanks for code improving, Richard.