public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [SPARC] Hookize REGISTER_MOVE_COST
@ 2011-04-17 20:39 Anatoly Sokolov
  2011-04-17 23:18 ` Eric Botcazou
  0 siblings, 1 reply; 2+ messages in thread
From: Anatoly Sokolov @ 2011-04-17 20:39 UTC (permalink / raw)
  To: gcc-patches; +Cc: rth, ebotcazou

 Hello.

  This patch removes obsolete REGISTER_MOVE_COST macro from SPARC back end in 
the GCC and introduces equivalent TARGET_REGISTER_MOVE_COST target hooks.

   Bootstrapped and regression tested on sparc64-unknown-linux-gnu.

  OK to install?

        * config/sparc/sparc.h (GENERAL_OR_I64, REGISTER_MOVE_COST): Remove.
        * config/sparc/sparc.c (TARGET_REGISTER_MOVE_COST): Define.
        (general_or_i64_p, sparc_register_move_cost): New function.

Index: gcc/gcc/config/sparc/sparc.c
===================================================================
--- gcc/gcc/config/sparc/sparc.c        (revision 172245)
+++ gcc/gcc/config/sparc/sparc.c        (working copy)
@@ -422,6 +422,8 @@
 static rtx sparc_tls_got (void);
 static const char *get_some_local_dynamic_name (void);
 static int get_some_local_dynamic_name_1 (rtx *, void *);
+static int sparc_register_move_cost (enum machine_mode,
+                                    reg_class_t, reg_class_t);
 static bool sparc_rtx_costs (rtx, int, int, int *, bool);
 static rtx sparc_function_value (const_tree, const_tree, bool);
 static rtx sparc_libcall_value (enum machine_mode, const_rtx);
@@ -560,6 +562,8 @@
 #define TARGET_RTX_COSTS sparc_rtx_costs
 #undef TARGET_ADDRESS_COST
 #define TARGET_ADDRESS_COST hook_int_rtx_bool_0
+#undef TARGET_REGISTER_MOVE_COST
+#define TARGET_REGISTER_MOVE_COST sparc_register_move_cost
 
 #undef TARGET_PROMOTE_FUNCTION_MODE
 #define TARGET_PROMOTE_FUNCTION_MODE sparc_promote_function_mode
@@ -9124,6 +9128,36 @@
     }
 }
 
+static inline bool
+general_or_i64_p (reg_class_t rclass)
+{
+  return (rclass == GENERAL_REGS || rclass == I64_REGS);
+}
+
+/* Implement TARGET_REGISTER_MOVE_COST.  */
+
+static int
+sparc_register_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED,
+                         reg_class_t from, reg_class_t to)
+{
+  if ((FP_REG_CLASS_P (from) && general_or_i64_p (to))
+      || (general_or_i64_p (from) && FP_REG_CLASS_P (to))
+      || from == FPCC_REGS
+      || to == FPCC_REGS)  
+    {
+      if (sparc_cpu == PROCESSOR_ULTRASPARC
+         || sparc_cpu == PROCESSOR_ULTRASPARC3
+         || sparc_cpu == PROCESSOR_NIAGARA
+         || sparc_cpu == PROCESSOR_NIAGARA2)
+       return 12;
+      else
+       return 6;
+    }
+
+  return 2;
+}
+
+
 /* Emit the sequence of insns SEQ while preserving the registers REG and REG2.
    This is achieved by means of a manual dynamic stack space allocation in
    the current frame.  We make the assumption that SEQ doesn't contain any
Index: gcc/gcc/config/sparc/sparc.h
===================================================================
--- gcc/gcc/config/sparc/sparc.h        (revision 172245)
+++ gcc/gcc/config/sparc/sparc.h        (working copy)
@@ -1715,18 +1715,6 @@
 #define DITF_CONVERSION_LIBFUNCS       0
 #define SUN_INTEGER_MULTIPLY_64        0
 
-/* Compute extra cost of moving data between one register class
-   and another.  */
-#define GENERAL_OR_I64(C) ((C) == GENERAL_REGS || (C) == I64_REGS)
-#define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2)               \
-  (((FP_REG_CLASS_P (CLASS1) && GENERAL_OR_I64 (CLASS2)) \
-    || (GENERAL_OR_I64 (CLASS1) && FP_REG_CLASS_P (CLASS2)) \
-    || (CLASS1) == FPCC_REGS || (CLASS2) == FPCC_REGS)         \
-   ? ((sparc_cpu == PROCESSOR_ULTRASPARC \
-       || sparc_cpu == PROCESSOR_ULTRASPARC3 \
-       || sparc_cpu == PROCESSOR_NIAGARA \
-       || sparc_cpu == PROCESSOR_NIAGARA2) ? 12 : 6) : 2)
-
 /* Provide the cost of a branch.  For pre-v9 processors we use
    a value of 3 to take into account the potential annulling of
    the delay slot (which ends up being a bubble in the pipeline slot)


Anatoly.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [SPARC] Hookize REGISTER_MOVE_COST
  2011-04-17 20:39 [SPARC] Hookize REGISTER_MOVE_COST Anatoly Sokolov
@ 2011-04-17 23:18 ` Eric Botcazou
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Botcazou @ 2011-04-17 23:18 UTC (permalink / raw)
  To: Anatoly Sokolov; +Cc: gcc-patches, rth

>         * config/sparc/sparc.h (GENERAL_OR_I64, REGISTER_MOVE_COST):
> Remove. * config/sparc/sparc.c (TARGET_REGISTER_MOVE_COST): Define.
> (general_or_i64_p, sparc_register_move_cost): New function.

OK modulo:

> @@ -9124,6 +9128,36 @@
>      }
>  }
>
> +static inline bool
> +general_or_i64_p (reg_class_t rclass)
> +{
> +  return (rclass == GENERAL_REGS || rclass == I64_REGS);
> +}

Missing "/* Return true if CLASS is either GENERAL_REGS or I64_REGS.  */"

> +/* Implement TARGET_REGISTER_MOVE_COST.  */
> +
> +static int
> +sparc_register_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED,
> +                         reg_class_t from, reg_class_t to)
> +{
> +  if ((FP_REG_CLASS_P (from) && general_or_i64_p (to))
> +      || (general_or_i64_p (from) && FP_REG_CLASS_P (to))
> +      || from == FPCC_REGS
> +      || to == FPCC_REGS)
> +    {
> +      if (sparc_cpu == PROCESSOR_ULTRASPARC
> +         || sparc_cpu == PROCESSOR_ULTRASPARC3
> +         || sparc_cpu == PROCESSOR_NIAGARA
> +         || sparc_cpu == PROCESSOR_NIAGARA2)
> +       return 12;
> +      else
> +       return 6;
> +    }
> +
> +  return 2;
> +}

Superflous "else".  No need to retest.

-- 
Eric Botcazou

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-04-17 22:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-17 20:39 [SPARC] Hookize REGISTER_MOVE_COST Anatoly Sokolov
2011-04-17 23:18 ` Eric Botcazou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).