From faa832a76d086cd6fdbfc2b3a2b859f4f3aab5ef Mon Sep 17 00:00:00 2001
From: Anatoly Sokolov <aesok@post.ru>
Date: Sun, 15 Aug 2010 01:46:11 +0400
Subject: [PATCH] reload.h (register_move_cost, [...]): Adjust prototype.

	* reload.h (register_move_cost, memory_move_secondary_cost,
	secondary_reload_class): Adjust prototype.
	* rtl.h (reg_class_subset_p): Adjust prototype.
	* reload.c (secondary_reload_class): Change arguments type from
	enum reg_class to reg_class_t. Change result type to reg_class_t.
	* reginfo.c (register_move_cost, reg_class_subset_p): Change
	arguments type from enum reg_class to reg_class_t.
	(memory_move_secondary_cost): Change arguments type from
	enum reg_class to reg_class_t. Change type of saved_flags to
	reg_class_t.

	* config/mips/mips.h (REGISTER_MOVE_COST, MEMORY_MOVE_COST):
	Remove macros.
	(mips_cost): Remove.
	(struct mips_rtx_cost_data): Moved to mips.c.
	* config/mips/mips-protos.h (mips_register_move_cost): Remove.
	* config/mips/mips.c (struct mips_rtx_cost_data): Moved from mips.h.
	(mips_cost): Make static.
	(mips_canonicalize_move_class): Change argument type to reg_class_t.
	Change result type to reg_class_t.
	(mips_move_to_gpr_cost, mips_move_from_gpr_cost): Change arguments
	type from enum reg_class to reg_class_t.
	(mips_register_move_cost): Make static. Change arguments
	type from enum reg_class to reg_class_t.
	(mips_memory_move_cost): New function.
	(TARGET_REGISTER_MOVE_COST, TARGET_MEMORY_MOVE_COST): Define.

From-SVN: r163252
---
 gcc/ChangeLog                 | 29 ++++++++++++++++++++
 gcc/config/mips/mips-protos.h |  2 --
 gcc/config/mips/mips.c        | 50 ++++++++++++++++++++++++++++-------
 gcc/config/mips/mips.h        | 41 ----------------------------
 gcc/reginfo.c                 |  9 +++----
 gcc/reload.c                  |  6 ++---
 gcc/reload.h                  | 10 +++----
 gcc/rtl.h                     |  2 +-
 8 files changed, 82 insertions(+), 67 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3987c900f2ef..df2c197faeda 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,32 @@
+2010-08-14  Anatoly Sokolov  <aesok@post.ru>
+
+	* reload.h (register_move_cost, memory_move_secondary_cost,
+	secondary_reload_class): Adjust prototype.
+	* rtl.h (reg_class_subset_p): Adjust prototype.
+	* reload.c (secondary_reload_class): Change arguments type from
+	enum reg_class to reg_class_t. Change result type to reg_class_t.
+	* reginfo.c (register_move_cost, reg_class_subset_p): Change
+	arguments type from enum reg_class to reg_class_t.
+	(memory_move_secondary_cost): Change arguments type from
+	enum reg_class to reg_class_t. Change type of saved_flags to
+	reg_class_t.
+
+	* config/mips/mips.h (REGISTER_MOVE_COST, MEMORY_MOVE_COST): 
+	Remove macros.
+	(mips_cost): Remove.
+	(struct mips_rtx_cost_data): Moved to mips.c.
+	* config/mips/mips-protos.h (mips_register_move_cost): Remove.
+	* config/mips/mips.c (struct mips_rtx_cost_data): Moved from mips.h.
+	(mips_cost): Make static.
+	(mips_canonicalize_move_class): Change argument type to reg_class_t.
+	Change result type to reg_class_t.
+	(mips_move_to_gpr_cost, mips_move_from_gpr_cost): Change arguments
+	type from enum reg_class to reg_class_t.
+	(mips_register_move_cost): Make static. Change arguments
+	type from enum reg_class to reg_class_t.
+	(mips_memory_move_cost): New function.
+	(TARGET_REGISTER_MOVE_COST, TARGET_MEMORY_MOVE_COST): Define.
+
 2010-08-14  Richard Sandiford  <rdsandiford@googlemail.com>
 
 	PR rtl-optimization/43358
diff --git a/gcc/config/mips/mips-protos.h b/gcc/config/mips/mips-protos.h
index dd928e3dc8ff..71b59fed9e55 100644
--- a/gcc/config/mips/mips-protos.h
+++ b/gcc/config/mips/mips-protos.h
@@ -295,8 +295,6 @@ extern enum reg_class mips_secondary_reload_class (enum reg_class,
 						   enum machine_mode,
 						   rtx, bool);
 extern int mips_class_max_nregs (enum reg_class, enum machine_mode);
-extern int mips_register_move_cost (enum machine_mode, enum reg_class,
-				    enum reg_class);
 
 extern int mips_adjust_insn_length (rtx, int);
 extern void mips_output_load_label (rtx);
diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index b0aaab5cb21f..5fc78c1fc354 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -474,6 +474,23 @@ struct mips16e_save_restore_info {
   HOST_WIDE_INT size;
 };
 
+/* Costs of various operations on the different architectures.  */
+
+struct mips_rtx_cost_data
+{
+  unsigned short fp_add;
+  unsigned short fp_mult_sf;
+  unsigned short fp_mult_df;
+  unsigned short fp_div_sf;
+  unsigned short fp_div_df;
+  unsigned short int_mult_si;
+  unsigned short int_mult_di;
+  unsigned short int_div_si;
+  unsigned short int_div_di;
+  unsigned short branch_cost;
+  unsigned short memory_latency;
+};
+
 /* Global variables for machine-dependent things.  */
 
 /* The -G setting, or the configuration's default small-data limit if
@@ -522,7 +539,7 @@ static const struct mips_cpu_info *mips_isa_option_info;
 int mips_abi = MIPS_ABI_DEFAULT;
 
 /* Which cost information to use.  */
-const struct mips_rtx_cost_data *mips_cost;
+static const struct mips_rtx_cost_data *mips_cost;
 
 /* The ambient target flags, excluding MASK_MIPS16.  */
 static int mips_base_target_flags;
@@ -1167,6 +1184,8 @@ static const struct mips_rtx_cost_data
 };
 
 static rtx mips_find_pic_call_symbol (rtx, rtx);
+static int mips_register_move_cost (enum machine_mode, reg_class_t,
+				    reg_class_t);
 
 /* This hash table keeps track of implicit "mips16" and "nomips16" attributes
    for -mflip_mips16.  It maps decl names onto a boolean mode setting.  */
@@ -10809,8 +10828,8 @@ mips_preferred_reload_class (rtx x, enum reg_class rclass)
 /* RCLASS is a class involved in a REGISTER_MOVE_COST calculation.
    Return a "canonical" class to represent it in later calculations.  */
 
-static enum reg_class
-mips_canonicalize_move_class (enum reg_class rclass)
+static reg_class_t
+mips_canonicalize_move_class (reg_class_t rclass)
 {
   /* All moves involving accumulator registers have the same cost.  */
   if (reg_class_subset_p (rclass, ACC_REGS))
@@ -10832,7 +10851,7 @@ mips_canonicalize_move_class (enum reg_class rclass)
 
 static int
 mips_move_to_gpr_cost (enum machine_mode mode ATTRIBUTE_UNUSED,
-		       enum reg_class from)
+		       reg_class_t from)
 {
   switch (from)
     {
@@ -10868,7 +10887,7 @@ mips_move_to_gpr_cost (enum machine_mode mode ATTRIBUTE_UNUSED,
    other classes handled by this function.  */
 
 static int
-mips_move_from_gpr_cost (enum machine_mode mode, enum reg_class to)
+mips_move_from_gpr_cost (enum machine_mode mode, reg_class_t to)
 {
   switch (to)
     {
@@ -10900,15 +10919,15 @@ mips_move_from_gpr_cost (enum machine_mode mode, enum reg_class to)
     }
 }
 
-/* Implement REGISTER_MOVE_COST.  Return 0 for classes that are the
+/* Implement TARGET_REGISTER_MOVE_COST.  Return 0 for classes that are the
    maximum of the move costs for subclasses; regclass will work out
    the maximum for us.  */
 
-int
+static int
 mips_register_move_cost (enum machine_mode mode,
-			 enum reg_class from, enum reg_class to)
+			 reg_class_t from, reg_class_t to)
 {
-  enum reg_class dregs;
+  reg_class_t dregs;
   int cost1, cost2;
 
   from = mips_canonicalize_move_class (from);
@@ -10944,6 +10963,15 @@ mips_register_move_cost (enum machine_mode mode,
   return 0;
 }
 
+/* Implement TARGET_MEMORY_MOVE_COST.  */
+
+static int
+mips_memory_move_cost (enum machine_mode mode, reg_class_t rclass, bool in)
+{
+  return (mips_cost->memory_latency
+	  + memory_move_secondary_cost (mode, rclass, in));
+} 
+
 /* Implement TARGET_IRA_COVER_CLASSES.  */
 
 static const reg_class_t *
@@ -16376,6 +16404,10 @@ void mips_function_profiler (FILE *file)
 
 #undef TARGET_VALID_POINTER_MODE
 #define TARGET_VALID_POINTER_MODE mips_valid_pointer_mode
+#undef TARGET_REGISTER_MOVE_COST
+#define TARGET_REGISTER_MOVE_COST mips_register_move_cost
+#undef TARGET_MEMORY_MOVE_COST
+#define TARGET_MEMORY_MOVE_COST mips_memory_move_cost
 #undef TARGET_RTX_COSTS
 #define TARGET_RTX_COSTS mips_rtx_costs
 #undef TARGET_ADDRESS_COST
diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h
index ff36a90301a4..e30d03e32e99 100644
--- a/gcc/config/mips/mips.h
+++ b/gcc/config/mips/mips.h
@@ -28,23 +28,6 @@ along with GCC; see the file COPYING3.  If not see
 
 /* MIPS external variables defined in mips.c.  */
 
-/* Costs of various operations on the different architectures.  */
-
-struct mips_rtx_cost_data
-{
-  unsigned short fp_add;
-  unsigned short fp_mult_sf;
-  unsigned short fp_mult_df;
-  unsigned short fp_div_sf;
-  unsigned short fp_div_df;
-  unsigned short int_mult_si;
-  unsigned short int_mult_di;
-  unsigned short int_div_si;
-  unsigned short int_div_di;
-  unsigned short branch_cost;
-  unsigned short memory_latency;
-};
-
 /* Which ABI to use.  ABI_32 (original 32, or o32), ABI_N32 (n32),
    ABI_64 (n64) are all defined by SGI.  ABI_O64 is o32 extended
    to work on a 64-bit machine.  */
@@ -2487,29 +2470,6 @@ typedef struct mips_args {
 #define FUNCTION_MODE SImode
 
 
-/* A C expression for the cost of moving data from a register in
-   class FROM to one in class TO.  The classes are expressed using
-   the enumeration values such as `GENERAL_REGS'.  A value of 2 is
-   the default; other values are interpreted relative to that.
-
-   It is not required that the cost always equal 2 when FROM is the
-   same as TO; on some machines it is expensive to move between
-   registers if they are not general registers.
-
-   If reload sees an insn consisting of a single `set' between two
-   hard registers, and if `REGISTER_MOVE_COST' applied to their
-   classes returns a value of 2, reload does not check to ensure
-   that the constraints of the insn are met.  Setting a cost of
-   other than 2 will allow reload to verify that the constraints are
-   met.  You should do this if the `movM' pattern's constraints do
-   not allow such copying.  */
-
-#define REGISTER_MOVE_COST(MODE, FROM, TO)				\
-  mips_register_move_cost (MODE, FROM, TO)
-
-#define MEMORY_MOVE_COST(MODE,CLASS,TO_P) \
-  (mips_cost->memory_latency	      		\
-   + memory_move_secondary_cost ((MODE), (CLASS), (TO_P)))
 
 /* Define if copies to/from condition code registers should be avoided.
 
@@ -3019,7 +2979,6 @@ extern int mips_isa;			/* architectural level */
 extern int mips_abi;			/* which ABI to use */
 extern const struct mips_cpu_info *mips_arch_info;
 extern const struct mips_cpu_info *mips_tune_info;
-extern const struct mips_rtx_cost_data *mips_cost;
 extern bool mips_base_mips16;
 extern enum mips_code_readable_setting mips_code_readable;
 extern GTY(()) struct target_globals *mips16_globals;
diff --git a/gcc/reginfo.c b/gcc/reginfo.c
index 0fc86d3627fa..55d2b5b6f9d4 100644
--- a/gcc/reginfo.c
+++ b/gcc/reginfo.c
@@ -628,8 +628,7 @@ init_fake_stack_mems (void)
    TO, using MODE.  */
 
 int
-register_move_cost (enum machine_mode mode, enum reg_class from,
-                    enum reg_class to)
+register_move_cost (enum machine_mode mode, reg_class_t from, reg_class_t to)
 {
   return targetm.register_move_cost (mode, from, to);
 }
@@ -644,10 +643,10 @@ memory_move_cost (enum machine_mode mode, enum reg_class rclass, bool in)
 /* Compute extra cost of moving registers to/from memory due to reloads.
    Only needed if secondary reloads are required for memory moves.  */
 int
-memory_move_secondary_cost (enum machine_mode mode, enum reg_class rclass,
+memory_move_secondary_cost (enum machine_mode mode, reg_class_t rclass,
 			    bool in)
 {
-  enum reg_class altclass;
+  reg_class_t altclass;
   int partial_cost = 0;
   /* We need a memory reference to feed to SECONDARY... macros.  */
   /* mem may be unused even if the SECONDARY_ macros are defined.  */
@@ -1174,7 +1173,7 @@ reg_scan_mark_refs (rtx x, rtx insn)
 /* Return nonzero if C1 is a subset of C2, i.e., if every register in C1
    is also in C2.  */
 int
-reg_class_subset_p (enum reg_class c1, enum reg_class c2)
+reg_class_subset_p (reg_class_t c1, reg_class_t c2)
 {
   return (c1 == c2
 	  || c2 == ALL_REGS
diff --git a/gcc/reload.c b/gcc/reload.c
index 98aaa2362005..75fb000647b8 100644
--- a/gcc/reload.c
+++ b/gcc/reload.c
@@ -518,9 +518,9 @@ push_secondary_reload (int in_p, rtx x, int opnum, int optional,
 /* If a secondary reload is needed, return its class.  If both an intermediate
    register and a scratch register is needed, we return the class of the
    intermediate register.  */
-enum reg_class
-secondary_reload_class (bool in_p, enum reg_class rclass,
-			enum machine_mode mode, rtx x)
+reg_class_t
+secondary_reload_class (bool in_p, reg_class_t rclass, enum machine_mode mode,
+			rtx x)
 {
   enum insn_code icode;
   secondary_reload_info sri;
diff --git a/gcc/reload.h b/gcc/reload.h
index 01bbfb1bbc61..340f81d514ec 100644
--- a/gcc/reload.h
+++ b/gcc/reload.h
@@ -30,11 +30,9 @@ along with GCC; see the file COPYING3.  If not see
   SECONDARY_RELOAD_CLASS (CLASS, MODE, X)
 #endif
 
-extern int register_move_cost (enum machine_mode, enum reg_class,
-			       enum reg_class);
+extern int register_move_cost (enum machine_mode, reg_class_t, reg_class_t);
 extern int memory_move_cost (enum machine_mode, enum reg_class, bool);
-extern int memory_move_secondary_cost (enum machine_mode, enum reg_class,
-				       bool);
+extern int memory_move_secondary_cost (enum machine_mode, reg_class_t, bool);
 
 /* Maximum number of reloads we can need.  */
 #define MAX_RELOADS (2 * MAX_RECOG_OPERANDS * (MAX_REGS_PER_ADDRESS + 1))
@@ -292,8 +290,8 @@ extern void compute_use_by_pseudos (HARD_REG_SET *, bitmap);
 
 /* Functions from reload.c:  */
 
-extern enum reg_class secondary_reload_class (bool, enum reg_class,
-					      enum machine_mode, rtx);
+extern reg_class_t secondary_reload_class (bool, reg_class_t,
+					   enum machine_mode, rtx);
 
 #ifdef GCC_INSN_CODES_H
 extern enum reg_class scratch_reload_class (enum insn_code);
diff --git a/gcc/rtl.h b/gcc/rtl.h
index bb8735840574..873c79255bfd 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2371,7 +2371,7 @@ extern void mark_elimination (int, int);
 
 /* In reginfo.c */
 extern int reg_classes_intersect_p (reg_class_t, reg_class_t);
-extern int reg_class_subset_p (enum reg_class, enum reg_class);
+extern int reg_class_subset_p (reg_class_t, reg_class_t);
 extern void globalize_reg (int);
 extern void init_reg_modes_target (void);
 extern void init_regs (void);
-- 
GitLab