Message ID | 907093179.20110208010659@post.ru |
---|---|
State | New |
Headers | show |
Approved. Please apply. Thanks! Sterling On 02/07/2011 02:06 PM, Anatoly Sokolov wrote: > Hi. > > This patch removes obsolete REGISTER_MOVE_COST and MEMORY_MOVE_COST > macros from the XTENSA 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/xtensa/xtensa.h (REGISTER_MOVE_COST, MEMORY_MOVE_COST): > Remove macros. > * config/xtensa/xtensa.c (xtensa_register_move_cost, > xtensa_memory_move_cost): New functions. > (TARGET_REGISTER_MOVE_COST, TARGET_REGISTER_MOVE_COST): Define. > > Index: gcc/config/xtensa/xtensa.c > =================================================================== > --- gcc/config/xtensa/xtensa.c (revision 169904) > +++ gcc/config/xtensa/xtensa.c (working copy) > @@ -137,6 +137,9 @@ > static section *xtensa_select_rtx_section (enum machine_mode, rtx, > unsigned HOST_WIDE_INT); > static bool xtensa_rtx_costs (rtx, int, int, int *, bool); > +static int xtensa_register_move_cost (enum machine_mode, reg_class_t, > + reg_class_t); > +static int xtensa_memory_move_cost (enum machine_mode, reg_class_t, bool); > static tree xtensa_build_builtin_va_list (void); > static bool xtensa_return_in_memory (const_tree, const_tree); > static tree xtensa_gimplify_va_arg_expr (tree, tree, gimple_seq *, > @@ -213,6 +216,10 @@ > #undef TARGET_MODE_DEPENDENT_ADDRESS_P > #define TARGET_MODE_DEPENDENT_ADDRESS_P xtensa_mode_dependent_address_p > > +#undef TARGET_REGISTER_MOVE_COST > +#define TARGET_REGISTER_MOVE_COST xtensa_register_move_cost > +#undef TARGET_MEMORY_MOVE_COST > +#define TARGET_MEMORY_MOVE_COST xtensa_memory_move_cost > #undef TARGET_RTX_COSTS > #define TARGET_RTX_COSTS xtensa_rtx_costs > #undef TARGET_ADDRESS_COST > @@ -3307,7 +3314,35 @@ > return function_section (current_function_decl); > } > > +/* Worker function for TARGET_REGISTER_MOVE_COST. */ > > +static int > +xtensa_register_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED, > + reg_class_t from, reg_class_t to) > +{ > + if (from == to&& from != BR_REGS&& to != BR_REGS) > + return 2; > + else if (reg_class_subset_p (from, AR_REGS) > +&& reg_class_subset_p (to, AR_REGS)) > + return 2; > + else if (reg_class_subset_p (from, AR_REGS)&& to == ACC_REG) > + return 3; > + else if (from == ACC_REG&& reg_class_subset_p (to, AR_REGS)) > + return 3; > + else > + return 10; > +} > + > +/* Worker function for TARGET_MEMORY_MOVE_COST. */ > + > +static int > +xtensa_memory_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED, > + reg_class_t rclass ATTRIBUTE_UNUSED, > + bool in ATTRIBUTE_UNUSED) > +{ > + return 4; > +} > + > /* 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. */ > Index: gcc/config/xtensa/xtensa.h > =================================================================== > --- gcc/config/xtensa/xtensa.h (revision 169904) > +++ gcc/config/xtensa/xtensa.h (working copy) > @@ -723,26 +723,6 @@ > indexing purposes) so give the MEM rtx a words's mode. */ > #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. */ > -#define REGISTER_MOVE_COST(MODE, FROM, TO) \ > - (((FROM) == (TO)&& (FROM) != BR_REGS&& (TO) != BR_REGS) \ > - ? 2 \ > - : (reg_class_subset_p ((FROM), AR_REGS) \ > -&& reg_class_subset_p ((TO), AR_REGS) \ > - ? 2 \ > - : (reg_class_subset_p ((FROM), AR_REGS) \ > -&& (TO) == ACC_REG \ > - ? 3 \ > - : ((FROM) == ACC_REG \ > -&& reg_class_subset_p ((TO), AR_REGS) \ > - ? 3 \ > - : 10)))) > - > -#define MEMORY_MOVE_COST(MODE, CLASS, IN) 4 > - > #define BRANCH_COST(speed_p, predictable_p) 3 > > /* How to refer to registers in assembler output. > > > Anatoly. >
Index: gcc/config/xtensa/xtensa.c =================================================================== --- gcc/config/xtensa/xtensa.c (revision 169904) +++ gcc/config/xtensa/xtensa.c (working copy) @@ -137,6 +137,9 @@ static section *xtensa_select_rtx_section (enum machine_mode, rtx, unsigned HOST_WIDE_INT); static bool xtensa_rtx_costs (rtx, int, int, int *, bool); +static int xtensa_register_move_cost (enum machine_mode, reg_class_t, + reg_class_t); +static int xtensa_memory_move_cost (enum machine_mode, reg_class_t, bool); static tree xtensa_build_builtin_va_list (void); static bool xtensa_return_in_memory (const_tree, const_tree); static tree xtensa_gimplify_va_arg_expr (tree, tree, gimple_seq *, @@ -213,6 +216,10 @@ #undef TARGET_MODE_DEPENDENT_ADDRESS_P #define TARGET_MODE_DEPENDENT_ADDRESS_P xtensa_mode_dependent_address_p +#undef TARGET_REGISTER_MOVE_COST +#define TARGET_REGISTER_MOVE_COST xtensa_register_move_cost +#undef TARGET_MEMORY_MOVE_COST +#define TARGET_MEMORY_MOVE_COST xtensa_memory_move_cost #undef TARGET_RTX_COSTS #define TARGET_RTX_COSTS xtensa_rtx_costs #undef TARGET_ADDRESS_COST @@ -3307,7 +3314,35 @@ return function_section (current_function_decl); } +/* Worker function for TARGET_REGISTER_MOVE_COST. */ +static int +xtensa_register_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED, + reg_class_t from, reg_class_t to) +{ + if (from == to && from != BR_REGS && to != BR_REGS) + return 2; + else if (reg_class_subset_p (from, AR_REGS) + && reg_class_subset_p (to, AR_REGS)) + return 2; + else if (reg_class_subset_p (from, AR_REGS) && to == ACC_REG) + return 3; + else if (from == ACC_REG && reg_class_subset_p (to, AR_REGS)) + return 3; + else + return 10; +} + +/* Worker function for TARGET_MEMORY_MOVE_COST. */ + +static int +xtensa_memory_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED, + reg_class_t rclass ATTRIBUTE_UNUSED, + bool in ATTRIBUTE_UNUSED) +{ + return 4; +} + /* 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. */ Index: gcc/config/xtensa/xtensa.h =================================================================== --- gcc/config/xtensa/xtensa.h (revision 169904) +++ gcc/config/xtensa/xtensa.h (working copy) @@ -723,26 +723,6 @@ indexing purposes) so give the MEM rtx a words's mode. */ #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. */ -#define REGISTER_MOVE_COST(MODE, FROM, TO) \ - (((FROM) == (TO) && (FROM) != BR_REGS && (TO) != BR_REGS) \ - ? 2 \ - : (reg_class_subset_p ((FROM), AR_REGS) \ - && reg_class_subset_p ((TO), AR_REGS) \ - ? 2 \ - : (reg_class_subset_p ((FROM), AR_REGS) \ - && (TO) == ACC_REG \ - ? 3 \ - : ((FROM) == ACC_REG \ - && reg_class_subset_p ((TO), AR_REGS) \ - ? 3 \ - : 10)))) - -#define MEMORY_MOVE_COST(MODE, CLASS, IN) 4 - #define BRANCH_COST(speed_p, predictable_p) 3 /* How to refer to registers in assembler output.