diff mbox

[BFIN] Hookize REGISTER_MOVE_COST and MEMORY_MOVE_COST

Message ID 11810052402.20111223225551@post.ru
State New
Headers show

Commit Message

Anatoly Sokolov Dec. 23, 2011, 6:55 p.m. UTC
Hi.

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

  Untested.

  OK to install?

        * config/bfin/bfin.h (REGISTER_MOVE_COST, MEMORY_MOVE_COST): Remove.
        * config/bfin/bfin-protos.h (bfin_register_move_cost,
        bfin_memory_move_cost): Remove. 
        * config/bfin/bfin.c (bfin_register_move_cost,
        bfin_memory_move_cost): Make static. Change arguments type from
        enum reg_class to reg_class_t and from int to bool.
        (TARGET_REGISTER_MOVE_COST, TARGET_MEMORY_MOVE_COST): Define.



Anatoly.

Comments

Richard Henderson Dec. 23, 2011, 7:44 p.m. UTC | #1
On 12/23/2011 10:55 AM, Anatoly Sokolov wrote:
>         * config/bfin/bfin.h (REGISTER_MOVE_COST, MEMORY_MOVE_COST): Remove.
>         * config/bfin/bfin-protos.h (bfin_register_move_cost,
>         bfin_memory_move_cost): Remove. 
>         * config/bfin/bfin.c (bfin_register_move_cost,
>         bfin_memory_move_cost): Make static. Change arguments type from
>         enum reg_class to reg_class_t and from int to bool.
>         (TARGET_REGISTER_MOVE_COST, TARGET_MEMORY_MOVE_COST): Define.

Ok.


r~
Jie Zhang Dec. 23, 2011, 9:53 p.m. UTC | #2
Hi Anatoly,

I cannot apply your patch to a lean tree. I tried to save your email
as a text file, copy from thunderbird, copy from gmail, copy from the
mailing list archive. But neither works.

Regards,
Jie

2011/12/23 Anatoly Sokolov <aesok@post.ru>:
>  Hi.
>
>  This patch removes obsolete REGISTER_MOVE_COST and MEMORY_MOVE_COST
> macros from the Blackfin back end in the GCC and introduces equivalent
> TARGET_REGISTER_MOVE_COST and TARGET_MEMORY_MOVE_COST target hooks.
>
>  Untested.
>
>  OK to install?
>
>        * config/bfin/bfin.h (REGISTER_MOVE_COST, MEMORY_MOVE_COST): Remove.
>        * config/bfin/bfin-protos.h (bfin_register_move_cost,
>        bfin_memory_move_cost): Remove.
>        * config/bfin/bfin.c (bfin_register_move_cost,
>        bfin_memory_move_cost): Make static. Change arguments type from
>        enum reg_class to reg_class_t and from int to bool.
>        (TARGET_REGISTER_MOVE_COST, TARGET_MEMORY_MOVE_COST): Define.
>
> Index: gcc/config/bfin/bfin-protos.h
> ===================================================================
> --- gcc/config/bfin/bfin-protos.h       (revision 182658)
> +++ gcc/config/bfin/bfin-protos.h       (working copy)
> @@ -85,9 +85,6 @@ extern bool bfin_longcall_p (rtx, int);
>  extern bool bfin_dsp_memref_p (rtx);
>  extern bool bfin_expand_movmem (rtx, rtx, rtx, rtx);
>
> -extern int bfin_register_move_cost (enum machine_mode, enum reg_class,
> -                                   enum reg_class);
> -extern int bfin_memory_move_cost (enum machine_mode, enum reg_class, int in);
>  extern enum reg_class secondary_input_reload_class (enum reg_class,
>                                                    enum machine_mode,
>                                                    rtx);
> Index: gcc/config/bfin/bfin.c
> ===================================================================
> --- gcc/config/bfin/bfin.c      (revision 182658)
> +++ gcc/config/bfin/bfin.c      (working copy)
> @@ -2149,12 +2149,11 @@ bfin_vector_mode_supported_p (enum machi
>   return mode == V2HImode;
>  }
>
> -/* Return the cost of moving data from a register in class CLASS1 to
> -   one in class CLASS2.  A cost of 2 is the default.  */
> +/* Worker function for TARGET_REGISTER_MOVE_COST.  */
>
> -int
> +static int
>  bfin_register_move_cost (enum machine_mode mode,
> -                        enum reg_class class1, enum reg_class class2)
> +                        reg_class_t class1, reg_class_t class2)
>  {
>   /* These need secondary reloads, so they're more expensive.  */
>   if ((class1 == CCREGS && !reg_class_subset_p (class2, DREGS))
> @@ -2177,18 +2176,16 @@ bfin_register_move_cost (enum machine_mo
>   return 2;
>  }
>
> -/* Return 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'.
> +/* Worker function for TARGET_MEMORY_MOVE_COST.
>
>    ??? In theory L1 memory has single-cycle latency.  We should add a switch
>    that tells the compiler whether we expect to use only L1 memory for the
>    program; it'll make the costs more accurate.  */
>
> -int
> +static int
>  bfin_memory_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED,
> -                      enum reg_class rclass,
> -                      int in ATTRIBUTE_UNUSED)
> +                      reg_class_t rclass,
> +                      bool in ATTRIBUTE_UNUSED)
>  {
>   /* Make memory accesses slightly more expensive than any register-register
>      move.  Also, penalize non-DP registers, since they need secondary
> @@ -5703,6 +5700,12 @@ bfin_conditional_register_usage (void)
>  #undef  TARGET_ADDRESS_COST
>  #define TARGET_ADDRESS_COST bfin_address_cost
>
> +#undef TARGET_REGISTER_MOVE_COST
> +#define TARGET_REGISTER_MOVE_COST bfin_register_move_cost
> +
> +#undef TARGET_MEMORY_MOVE_COST
> +#define TARGET_MEMORY_MOVE_COST bfin_memory_move_cost
> +
>  #undef  TARGET_ASM_INTEGER
>  #define TARGET_ASM_INTEGER bfin_assemble_integer
>
> Index: gcc/config/bfin/bfin.h
> ===================================================================
> --- gcc/config/bfin/bfin.h      (revision 182658)
> +++ gcc/config/bfin/bfin.h      (working copy)
> @@ -975,29 +975,6 @@ typedef struct {
>  /* Do not put function addr into constant pool */
>  #define NO_FUNCTION_CSE 1
>
> -/* 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.  */
> -
> -#define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2) \
> -   bfin_register_move_cost ((MODE), (CLASS1), (CLASS2))
> -
> -/* 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'.
> -
> -   If moving between registers and memory is more expensive than
> -   between two registers, you should define this macro to express the
> -   relative cost.  */
> -
> -#define MEMORY_MOVE_COST(MODE, CLASS, IN)      \
> -  bfin_memory_move_cost ((MODE), (CLASS), (IN))
> -
>  /* Specify the machine mode that this machine uses
>    for the index in the tablejump instruction.  */
>  #define CASE_VECTOR_MODE SImode
>
>
> Anatoly.
>
Georg-Johann Lay Dec. 27, 2011, 12:03 a.m. UTC | #3
Anatoly Sokolov schrieb:
>   Hi.
> 
>   This patch removes obsolete REGISTER_MOVE_COST and MEMORY_MOVE_COST

Why are they obsolete?

The internals do not say they are obsolete and the PRINT_* hoohs 
documentation does not mention a replacement.  There is not even a 
documentation for target hooks

TARGET_PRINT_OPERAND
TARGET_PRINT_OPERAND_ADDRESS
TARGET_PRINT_OPERAND_PUNCT_VALID_P

Johann

> macros from the Blackfin back end in the GCC and introduces equivalent
> TARGET_REGISTER_MOVE_COST and TARGET_MEMORY_MOVE_COST target hooks.
> 
> [...]
> 
> Anatoly.
diff mbox

Patch

Index: gcc/config/bfin/bfin-protos.h
===================================================================
--- gcc/config/bfin/bfin-protos.h       (revision 182658)
+++ gcc/config/bfin/bfin-protos.h       (working copy)
@@ -85,9 +85,6 @@  extern bool bfin_longcall_p (rtx, int);
 extern bool bfin_dsp_memref_p (rtx);
 extern bool bfin_expand_movmem (rtx, rtx, rtx, rtx);
 
-extern int bfin_register_move_cost (enum machine_mode, enum reg_class,
-                                   enum reg_class);
-extern int bfin_memory_move_cost (enum machine_mode, enum reg_class, int in);
 extern enum reg_class secondary_input_reload_class (enum reg_class,
                                                    enum machine_mode,
                                                    rtx);
Index: gcc/config/bfin/bfin.c
===================================================================
--- gcc/config/bfin/bfin.c      (revision 182658)
+++ gcc/config/bfin/bfin.c      (working copy)
@@ -2149,12 +2149,11 @@  bfin_vector_mode_supported_p (enum machi
   return mode == V2HImode;
 }
 
-/* Return the cost of moving data from a register in class CLASS1 to
-   one in class CLASS2.  A cost of 2 is the default.  */
+/* Worker function for TARGET_REGISTER_MOVE_COST.  */
 
-int
+static int
 bfin_register_move_cost (enum machine_mode mode,
-                        enum reg_class class1, enum reg_class class2)
+                        reg_class_t class1, reg_class_t class2)
 {
   /* These need secondary reloads, so they're more expensive.  */
   if ((class1 == CCREGS && !reg_class_subset_p (class2, DREGS))
@@ -2177,18 +2176,16 @@  bfin_register_move_cost (enum machine_mo
   return 2;
 }
 
-/* Return 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'.
+/* Worker function for TARGET_MEMORY_MOVE_COST.
 
    ??? In theory L1 memory has single-cycle latency.  We should add a switch
    that tells the compiler whether we expect to use only L1 memory for the
    program; it'll make the costs more accurate.  */
 
-int
+static int
 bfin_memory_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED,
-                      enum reg_class rclass,
-                      int in ATTRIBUTE_UNUSED)
+                      reg_class_t rclass,
+                      bool in ATTRIBUTE_UNUSED)
 {
   /* Make memory accesses slightly more expensive than any register-register
      move.  Also, penalize non-DP registers, since they need secondary
@@ -5703,6 +5700,12 @@  bfin_conditional_register_usage (void)
 #undef  TARGET_ADDRESS_COST
 #define TARGET_ADDRESS_COST bfin_address_cost
 
+#undef TARGET_REGISTER_MOVE_COST
+#define TARGET_REGISTER_MOVE_COST bfin_register_move_cost
+
+#undef TARGET_MEMORY_MOVE_COST
+#define TARGET_MEMORY_MOVE_COST bfin_memory_move_cost
+
 #undef  TARGET_ASM_INTEGER
 #define TARGET_ASM_INTEGER bfin_assemble_integer
 
Index: gcc/config/bfin/bfin.h
===================================================================
--- gcc/config/bfin/bfin.h      (revision 182658)
+++ gcc/config/bfin/bfin.h      (working copy)
@@ -975,29 +975,6 @@  typedef struct {
 /* Do not put function addr into constant pool */
 #define NO_FUNCTION_CSE 1
 
-/* 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.  */
-
-#define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2) \
-   bfin_register_move_cost ((MODE), (CLASS1), (CLASS2))
-
-/* 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'.
-
-   If moving between registers and memory is more expensive than
-   between two registers, you should define this macro to express the
-   relative cost.  */
-
-#define MEMORY_MOVE_COST(MODE, CLASS, IN)      \
-  bfin_memory_move_cost ((MODE), (CLASS), (IN))
-
 /* Specify the machine mode that this machine uses
    for the index in the tablejump instruction.  */
 #define CASE_VECTOR_MODE SImode