Message ID | 1459514548.20110201210541@post.ru |
---|---|
State | New |
Headers | show |
There are some subtleties around the hard frame pointer also being used as an incoming argument on Xtensa--it's the source of the most bugs in GCC for Xtensa. So let me run this one through a bit of testing first. Thanks, Sterling On 02/01/2011 10:05 AM, Anatoly Sokolov wrote: > Hello. > > This patch removes obsolete PREFERRED_RELOAD_CLASS and > PREFERRED_OUTPUT_RELOAD_CLASS macros from XTENSA back end in the GCC and > introduces equivalent TARGET_PREFERRED_RELOAD_CLASS and > TARGET_PREFERRED_OUTPUT_RELOAD_CLASS target hooks. This patch make > xtensa_secondary_reload function static, also. > > Not tested. > > OK to install? > > * config/xtensa/xtensa.h (PREFERRED_RELOAD_CLASS, > PREFERRED_OUTPUT_RELOAD_CLASS): Remove. > * config/xtensa/xtensa-protos.h (xtensa_preferred_reload_class, > secondary_reload_info, xtensa_secondary_reload): Remove. > * config/xtensa/xtensa.c (TARGET_PREFERRED_RELOAD_CLASS, > TARGET_PREFERRED_OUTPUT_RELOAD_CLASS): Define. > (xtensa_preferred_reload_class): Make static. Change return and > 'rclass' argument type to reg_class_t. Remove 'isoutput' argument. > Use CONST_DOUBLE_P predicate. > (xtensa_preferred_output_reload_class): New function. > (xtensa_secondary_reload): Make static. > > > Index: gcc/config/xtensa/xtensa.c > =================================================================== > --- gcc/config/xtensa/xtensa.c (revision 169485) > +++ gcc/config/xtensa/xtensa.c (working copy) > @@ -162,6 +162,12 @@ > static void xtensa_trampoline_init (rtx, tree, rtx); > static bool xtensa_output_addr_const_extra (FILE *, rtx); > > +static reg_class_t xtensa_preferred_reload_class (rtx, reg_class_t); > +static reg_class_t xtensa_preferred_output_reload_class (rtx, reg_class_t); > +static reg_class_t xtensa_secondary_reload (bool, rtx, reg_class_t, > + enum machine_mode, > + struct secondary_reload_info *); > + > static bool constantpool_address_p (const_rtx addr); > > static const int reg_nonleaf_alloc_order[FIRST_PSEUDO_REGISTER] = > @@ -260,6 +266,11 @@ > #undef TARGET_EXPAND_BUILTIN > #define TARGET_EXPAND_BUILTIN xtensa_expand_builtin > > +#undef TARGET_PREFERRED_RELOAD_CLASS > +#define TARGET_PREFERRED_RELOAD_CLASS xtensa_preferred_reload_class > +#undef TARGET_PREFERRED_OUTPUT_RELOAD_CLASS > +#define TARGET_PREFERRED_OUTPUT_RELOAD_CLASS xtensa_preferred_output_reload_class > + > #undef TARGET_SECONDARY_RELOAD > #define TARGET_SECONDARY_RELOAD xtensa_secondary_reload > > @@ -3153,11 +3164,12 @@ > return NULL_RTX; > } > > +/* Worker function for TARGET_PREFERRED_RELOAD_CLASS. */ > > -enum reg_class > -xtensa_preferred_reload_class (rtx x, enum reg_class rclass, int isoutput) > +static reg_class_t > +xtensa_preferred_reload_class (rtx x, reg_class_t rclass) > { > - if (!isoutput&& CONSTANT_P (x)&& GET_CODE (x) == CONST_DOUBLE) > + if (CONSTANT_P (x)&& CONST_DOUBLE_P (x)) > return NO_REGS; > > /* Don't use the stack pointer or hard frame pointer for reloads! > @@ -3172,8 +3184,27 @@ > return rclass; > } > > +/* Worker function for TARGET_PREFERRED_OUTPUT_RELOAD_CLASS. */ > > -reg_class_t > +static reg_class_t > +xtensa_preferred_output_reload_class (rtx x ATTRIBUTE_UNUSED, > + reg_class_t rclass) > +{ > + /* Don't use the stack pointer or hard frame pointer for reloads! > + The hard frame pointer would normally be OK except that it may > + briefly hold an incoming argument in the prologue, and reload > + won't know that it is live because the hard frame pointer is > + treated specially. */ > + > + if (rclass == AR_REGS || rclass == GR_REGS) > + return RL_REGS; > + > + return rclass; > +} > + > +/* Worker function for TARGET_SECONDARY_RELOAD. */ > + > +static reg_class_t > xtensa_secondary_reload (bool in_p, rtx x, reg_class_t rclass, > enum machine_mode mode, secondary_reload_info *sri) > { > Index: gcc/config/xtensa/xtensa.h > =================================================================== > --- gcc/config/xtensa/xtensa.h (revision 169485) > +++ gcc/config/xtensa/xtensa.h (working copy) > @@ -455,12 +455,6 @@ > the RTL, as either incoming or outgoing arguments. */ > #define TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P hook_bool_mode_true > > -#define PREFERRED_RELOAD_CLASS(X, CLASS) \ > - xtensa_preferred_reload_class (X, CLASS, 0) > - > -#define PREFERRED_OUTPUT_RELOAD_CLASS(X, CLASS) \ > - xtensa_preferred_reload_class (X, CLASS, 1) > - > /* Return the maximum number of consecutive registers > needed to represent mode MODE in a register of class CLASS. */ > #define CLASS_UNITS(mode, size) \ > Index: gcc/config/xtensa/xtensa-protos.h > =================================================================== > --- gcc/config/xtensa/xtensa-protos.h (revision 169485) > +++ gcc/config/xtensa/xtensa-protos.h (working copy) > @@ -63,11 +63,6 @@ > extern void print_operand_address (FILE *, rtx); > extern void xtensa_output_literal (FILE *, rtx, enum machine_mode, int); > extern rtx xtensa_return_addr (int, rtx); > -extern enum reg_class xtensa_preferred_reload_class (rtx, enum reg_class, int); > -struct secondary_reload_info; > -extern reg_class_t xtensa_secondary_reload (bool, rtx, reg_class_t, > - enum machine_mode, > - struct secondary_reload_info *); > #endif /* RTX_CODE */ > > extern void xtensa_setup_frame_addresses (void); > > > Anatoly. >
Test results show no regressions. Please apply. And Thanks! Sterling On 02/01/2011 10:05 AM, Anatoly Sokolov wrote: > Hello. > > This patch removes obsolete PREFERRED_RELOAD_CLASS and > PREFERRED_OUTPUT_RELOAD_CLASS macros from XTENSA back end in the GCC and > introduces equivalent TARGET_PREFERRED_RELOAD_CLASS and > TARGET_PREFERRED_OUTPUT_RELOAD_CLASS target hooks. This patch make > xtensa_secondary_reload function static, also. > > Not tested. > > OK to install? > > * config/xtensa/xtensa.h (PREFERRED_RELOAD_CLASS, > PREFERRED_OUTPUT_RELOAD_CLASS): Remove. > * config/xtensa/xtensa-protos.h (xtensa_preferred_reload_class, > secondary_reload_info, xtensa_secondary_reload): Remove. > * config/xtensa/xtensa.c (TARGET_PREFERRED_RELOAD_CLASS, > TARGET_PREFERRED_OUTPUT_RELOAD_CLASS): Define. > (xtensa_preferred_reload_class): Make static. Change return and > 'rclass' argument type to reg_class_t. Remove 'isoutput' argument. > Use CONST_DOUBLE_P predicate. > (xtensa_preferred_output_reload_class): New function. > (xtensa_secondary_reload): Make static. > > > Index: gcc/config/xtensa/xtensa.c > =================================================================== > --- gcc/config/xtensa/xtensa.c (revision 169485) > +++ gcc/config/xtensa/xtensa.c (working copy) > @@ -162,6 +162,12 @@ > static void xtensa_trampoline_init (rtx, tree, rtx); > static bool xtensa_output_addr_const_extra (FILE *, rtx); > > +static reg_class_t xtensa_preferred_reload_class (rtx, reg_class_t); > +static reg_class_t xtensa_preferred_output_reload_class (rtx, reg_class_t); > +static reg_class_t xtensa_secondary_reload (bool, rtx, reg_class_t, > + enum machine_mode, > + struct secondary_reload_info *); > + > static bool constantpool_address_p (const_rtx addr); > > static const int reg_nonleaf_alloc_order[FIRST_PSEUDO_REGISTER] = > @@ -260,6 +266,11 @@ > #undef TARGET_EXPAND_BUILTIN > #define TARGET_EXPAND_BUILTIN xtensa_expand_builtin > > +#undef TARGET_PREFERRED_RELOAD_CLASS > +#define TARGET_PREFERRED_RELOAD_CLASS xtensa_preferred_reload_class > +#undef TARGET_PREFERRED_OUTPUT_RELOAD_CLASS > +#define TARGET_PREFERRED_OUTPUT_RELOAD_CLASS xtensa_preferred_output_reload_class > + > #undef TARGET_SECONDARY_RELOAD > #define TARGET_SECONDARY_RELOAD xtensa_secondary_reload > > @@ -3153,11 +3164,12 @@ > return NULL_RTX; > } > > +/* Worker function for TARGET_PREFERRED_RELOAD_CLASS. */ > > -enum reg_class > -xtensa_preferred_reload_class (rtx x, enum reg_class rclass, int isoutput) > +static reg_class_t > +xtensa_preferred_reload_class (rtx x, reg_class_t rclass) > { > - if (!isoutput&& CONSTANT_P (x)&& GET_CODE (x) == CONST_DOUBLE) > + if (CONSTANT_P (x)&& CONST_DOUBLE_P (x)) > return NO_REGS; > > /* Don't use the stack pointer or hard frame pointer for reloads! > @@ -3172,8 +3184,27 @@ > return rclass; > } > > +/* Worker function for TARGET_PREFERRED_OUTPUT_RELOAD_CLASS. */ > > -reg_class_t > +static reg_class_t > +xtensa_preferred_output_reload_class (rtx x ATTRIBUTE_UNUSED, > + reg_class_t rclass) > +{ > + /* Don't use the stack pointer or hard frame pointer for reloads! > + The hard frame pointer would normally be OK except that it may > + briefly hold an incoming argument in the prologue, and reload > + won't know that it is live because the hard frame pointer is > + treated specially. */ > + > + if (rclass == AR_REGS || rclass == GR_REGS) > + return RL_REGS; > + > + return rclass; > +} > + > +/* Worker function for TARGET_SECONDARY_RELOAD. */ > + > +static reg_class_t > xtensa_secondary_reload (bool in_p, rtx x, reg_class_t rclass, > enum machine_mode mode, secondary_reload_info *sri) > { > Index: gcc/config/xtensa/xtensa.h > =================================================================== > --- gcc/config/xtensa/xtensa.h (revision 169485) > +++ gcc/config/xtensa/xtensa.h (working copy) > @@ -455,12 +455,6 @@ > the RTL, as either incoming or outgoing arguments. */ > #define TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P hook_bool_mode_true > > -#define PREFERRED_RELOAD_CLASS(X, CLASS) \ > - xtensa_preferred_reload_class (X, CLASS, 0) > - > -#define PREFERRED_OUTPUT_RELOAD_CLASS(X, CLASS) \ > - xtensa_preferred_reload_class (X, CLASS, 1) > - > /* Return the maximum number of consecutive registers > needed to represent mode MODE in a register of class CLASS. */ > #define CLASS_UNITS(mode, size) \ > Index: gcc/config/xtensa/xtensa-protos.h > =================================================================== > --- gcc/config/xtensa/xtensa-protos.h (revision 169485) > +++ gcc/config/xtensa/xtensa-protos.h (working copy) > @@ -63,11 +63,6 @@ > extern void print_operand_address (FILE *, rtx); > extern void xtensa_output_literal (FILE *, rtx, enum machine_mode, int); > extern rtx xtensa_return_addr (int, rtx); > -extern enum reg_class xtensa_preferred_reload_class (rtx, enum reg_class, int); > -struct secondary_reload_info; > -extern reg_class_t xtensa_secondary_reload (bool, rtx, reg_class_t, > - enum machine_mode, > - struct secondary_reload_info *); > #endif /* RTX_CODE */ > > extern void xtensa_setup_frame_addresses (void); > > > Anatoly. >
Index: gcc/config/xtensa/xtensa.c =================================================================== --- gcc/config/xtensa/xtensa.c (revision 169485) +++ gcc/config/xtensa/xtensa.c (working copy) @@ -162,6 +162,12 @@ static void xtensa_trampoline_init (rtx, tree, rtx); static bool xtensa_output_addr_const_extra (FILE *, rtx); +static reg_class_t xtensa_preferred_reload_class (rtx, reg_class_t); +static reg_class_t xtensa_preferred_output_reload_class (rtx, reg_class_t); +static reg_class_t xtensa_secondary_reload (bool, rtx, reg_class_t, + enum machine_mode, + struct secondary_reload_info *); + static bool constantpool_address_p (const_rtx addr); static const int reg_nonleaf_alloc_order[FIRST_PSEUDO_REGISTER] = @@ -260,6 +266,11 @@ #undef TARGET_EXPAND_BUILTIN #define TARGET_EXPAND_BUILTIN xtensa_expand_builtin +#undef TARGET_PREFERRED_RELOAD_CLASS +#define TARGET_PREFERRED_RELOAD_CLASS xtensa_preferred_reload_class +#undef TARGET_PREFERRED_OUTPUT_RELOAD_CLASS +#define TARGET_PREFERRED_OUTPUT_RELOAD_CLASS xtensa_preferred_output_reload_class + #undef TARGET_SECONDARY_RELOAD #define TARGET_SECONDARY_RELOAD xtensa_secondary_reload @@ -3153,11 +3164,12 @@ return NULL_RTX; } +/* Worker function for TARGET_PREFERRED_RELOAD_CLASS. */ -enum reg_class -xtensa_preferred_reload_class (rtx x, enum reg_class rclass, int isoutput) +static reg_class_t +xtensa_preferred_reload_class (rtx x, reg_class_t rclass) { - if (!isoutput && CONSTANT_P (x) && GET_CODE (x) == CONST_DOUBLE) + if (CONSTANT_P (x) && CONST_DOUBLE_P (x)) return NO_REGS; /* Don't use the stack pointer or hard frame pointer for reloads! @@ -3172,8 +3184,27 @@ return rclass; } +/* Worker function for TARGET_PREFERRED_OUTPUT_RELOAD_CLASS. */ -reg_class_t +static reg_class_t +xtensa_preferred_output_reload_class (rtx x ATTRIBUTE_UNUSED, + reg_class_t rclass) +{ + /* Don't use the stack pointer or hard frame pointer for reloads! + The hard frame pointer would normally be OK except that it may + briefly hold an incoming argument in the prologue, and reload + won't know that it is live because the hard frame pointer is + treated specially. */ + + if (rclass == AR_REGS || rclass == GR_REGS) + return RL_REGS; + + return rclass; +} + +/* Worker function for TARGET_SECONDARY_RELOAD. */ + +static reg_class_t xtensa_secondary_reload (bool in_p, rtx x, reg_class_t rclass, enum machine_mode mode, secondary_reload_info *sri) { Index: gcc/config/xtensa/xtensa.h =================================================================== --- gcc/config/xtensa/xtensa.h (revision 169485) +++ gcc/config/xtensa/xtensa.h (working copy) @@ -455,12 +455,6 @@ the RTL, as either incoming or outgoing arguments. */ #define TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P hook_bool_mode_true -#define PREFERRED_RELOAD_CLASS(X, CLASS) \ - xtensa_preferred_reload_class (X, CLASS, 0) - -#define PREFERRED_OUTPUT_RELOAD_CLASS(X, CLASS) \ - xtensa_preferred_reload_class (X, CLASS, 1) - /* Return the maximum number of consecutive registers needed to represent mode MODE in a register of class CLASS. */ #define CLASS_UNITS(mode, size) \ Index: gcc/config/xtensa/xtensa-protos.h =================================================================== --- gcc/config/xtensa/xtensa-protos.h (revision 169485) +++ gcc/config/xtensa/xtensa-protos.h (working copy) @@ -63,11 +63,6 @@ extern void print_operand_address (FILE *, rtx); extern void xtensa_output_literal (FILE *, rtx, enum machine_mode, int); extern rtx xtensa_return_addr (int, rtx); -extern enum reg_class xtensa_preferred_reload_class (rtx, enum reg_class, int); -struct secondary_reload_info; -extern reg_class_t xtensa_secondary_reload (bool, rtx, reg_class_t, - enum machine_mode, - struct secondary_reload_info *); #endif /* RTX_CODE */ extern void xtensa_setup_frame_addresses (void);