Commit 8ddf681a by J"orn Rennecke Committed by Joern Rennecke

hooks.c (hook_bool_rtx_int_false): New function.

	* hooks.c (hook_bool_rtx_int_false): New function.
	* hooks.h (hook_bool_rtx_int_false): Declare.
	* target-def.h (TARGET_COMMUTATIVE_P): Define.
	(TARGET_INITIALIZER): Add TARGET_COMMUTATIVE_P.
	* target.h (struct gcc_target): Add commutative_p member.
	* targhooks.c (hook_bool_rtx_commutative_p): New function.
	* targhooks.h (hook_bool_rtx_commutative_p): Declare.
	* pa.c (TARGET_COMMUTATIVE_P): Redefine.
	(pa_commutative_p): New function.
	* jump.c (target.h): Include.
	(rtx_renumbered_equal_p): Use targetm.commutative_p.
	* doc/tm.texi: Document TARGET_COMMUTATIVE_P.

From-SVN: r101706
parent 6d057022
2005-07-07 J"orn Rennecke <joern.rennecke@st.com>
* hooks.c (hook_bool_rtx_int_false): New function.
* hooks.h (hook_bool_rtx_int_false): Declare.
* target-def.h (TARGET_COMMUTATIVE_P): Define.
(TARGET_INITIALIZER): Add TARGET_COMMUTATIVE_P.
* target.h (struct gcc_target): Add commutative_p member.
* targhooks.c (hook_bool_rtx_commutative_p): New function.
* targhooks.h (hook_bool_rtx_commutative_p): Declare.
* pa.c (TARGET_COMMUTATIVE_P): Redefine.
(pa_commutative_p): New function.
* jump.c (target.h): Include.
(rtx_renumbered_equal_p): Use targetm.commutative_p.
* doc/tm.texi: Document TARGET_COMMUTATIVE_P.
2005-07-07 Adrian Straetling <straetling@de.ibm.com> 2005-07-07 Adrian Straetling <straetling@de.ibm.com>
* config/s390/s390-protos.h (s390_expand_clrmem): Delete. * config/s390/s390-protos.h (s390_expand_clrmem): Delete.
......
...@@ -124,6 +124,7 @@ static void pa_init_builtins (void); ...@@ -124,6 +124,7 @@ static void pa_init_builtins (void);
static rtx hppa_builtin_saveregs (void); static rtx hppa_builtin_saveregs (void);
static tree hppa_gimplify_va_arg_expr (tree, tree, tree *, tree *); static tree hppa_gimplify_va_arg_expr (tree, tree, tree *, tree *);
static bool pa_scalar_mode_supported_p (enum machine_mode); static bool pa_scalar_mode_supported_p (enum machine_mode);
static bool pa_commutative_p (rtx x, int outer_code);
static void copy_fp_args (rtx) ATTRIBUTE_UNUSED; static void copy_fp_args (rtx) ATTRIBUTE_UNUSED;
static int length_fp_args (rtx) ATTRIBUTE_UNUSED; static int length_fp_args (rtx) ATTRIBUTE_UNUSED;
static struct deferred_plabel *get_plabel (rtx) ATTRIBUTE_UNUSED; static struct deferred_plabel *get_plabel (rtx) ATTRIBUTE_UNUSED;
...@@ -226,6 +227,9 @@ static size_t n_deferred_plabels = 0; ...@@ -226,6 +227,9 @@ static size_t n_deferred_plabels = 0;
#undef TARGET_FUNCTION_OK_FOR_SIBCALL #undef TARGET_FUNCTION_OK_FOR_SIBCALL
#define TARGET_FUNCTION_OK_FOR_SIBCALL pa_function_ok_for_sibcall #define TARGET_FUNCTION_OK_FOR_SIBCALL pa_function_ok_for_sibcall
#undef TARGET_COMMUTATIVE_P
#define TARGET_COMMUTATIVE_P pa_commutative_p
#undef TARGET_ASM_OUTPUT_MI_THUNK #undef TARGET_ASM_OUTPUT_MI_THUNK
#define TARGET_ASM_OUTPUT_MI_THUNK pa_asm_output_mi_thunk #define TARGET_ASM_OUTPUT_MI_THUNK pa_asm_output_mi_thunk
#undef TARGET_ASM_CAN_OUTPUT_MI_THUNK #undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
...@@ -7820,6 +7824,17 @@ pa_function_ok_for_sibcall (tree decl, tree exp ATTRIBUTE_UNUSED) ...@@ -7820,6 +7824,17 @@ pa_function_ok_for_sibcall (tree decl, tree exp ATTRIBUTE_UNUSED)
return (decl && !TREE_PUBLIC (decl)); return (decl && !TREE_PUBLIC (decl));
} }
/* ??? Addition is not commutative on the PA due to the weird implicit
space register selection rules for memory addresses. Therefore, we
don't consider a + b == b + a, as this might be inside a MEM. */
static bool
pa_commutative_p (rtx x, int outer_code)
{
return (COMMUTATIVE_P (x)
&& ((outer_code != UNKNOWN && outer_code != MEM)
|| GET_CODE (x) != PLUS));
}
/* Returns 1 if the 6 operands specified in OPERANDS are suitable for /* Returns 1 if the 6 operands specified in OPERANDS are suitable for
use in fmpyadd instructions. */ use in fmpyadd instructions. */
int int
......
...@@ -9445,6 +9445,13 @@ filling of delay slots can result in branches being redirected, and this ...@@ -9445,6 +9445,13 @@ filling of delay slots can result in branches being redirected, and this
may in turn cause a branch offset to overflow. may in turn cause a branch offset to overflow.
@end defmac @end defmac
@deftypefn {Target Hook} bool TARGET_COMMUTATIVE_P (rtx @var{x}, @var{outer_code})
This target hook returns @code{true} if @var{x} is considered to be commutative.
Usually, this is just COMMUTATIVE_P (@var{x}), but the HP PA doesn't consider
PLUS to be commutative inside a MEM. @var{outer_code} is the rtx code
of the enclosing rtl, if known, otherwise it is UNKNOWN.
@end deftypefn
@deftypefn {Target Hook} rtx TARGET_ALLOCATE_INITIAL_VALUE (rtx @var{hard_reg}) @deftypefn {Target Hook} rtx TARGET_ALLOCATE_INITIAL_VALUE (rtx @var{hard_reg})
When the initial value of a hard register has been copied in a pseudo When the initial value of a hard register has been copied in a pseudo
......
...@@ -192,6 +192,12 @@ hook_bool_rtx_false (rtx a ATTRIBUTE_UNUSED) ...@@ -192,6 +192,12 @@ hook_bool_rtx_false (rtx a ATTRIBUTE_UNUSED)
} }
bool bool
hook_bool_rtx_int_false (rtx a ATTRIBUTE_UNUSED, int code ATTRIBUTE_UNUSED)
{
return false;
}
bool
hook_bool_uintp_uintp_false (unsigned int *a ATTRIBUTE_UNUSED, hook_bool_uintp_uintp_false (unsigned int *a ATTRIBUTE_UNUSED,
unsigned int *b ATTRIBUTE_UNUSED) unsigned int *b ATTRIBUTE_UNUSED)
{ {
......
...@@ -35,6 +35,7 @@ extern bool hook_bool_tree_hwi_hwi_tree_false (tree, HOST_WIDE_INT, HOST_WIDE_IN ...@@ -35,6 +35,7 @@ extern bool hook_bool_tree_hwi_hwi_tree_false (tree, HOST_WIDE_INT, HOST_WIDE_IN
extern bool hook_bool_tree_hwi_hwi_tree_true (tree, HOST_WIDE_INT, HOST_WIDE_INT, extern bool hook_bool_tree_hwi_hwi_tree_true (tree, HOST_WIDE_INT, HOST_WIDE_INT,
tree); tree);
extern bool hook_bool_rtx_false (rtx); extern bool hook_bool_rtx_false (rtx);
extern bool hook_bool_rtx_int_false (rtx, int);
extern bool hook_bool_uintp_uintp_false (unsigned int *, unsigned int *); extern bool hook_bool_uintp_uintp_false (unsigned int *, unsigned int *);
extern bool hook_bool_rtx_int_int_intp_false (rtx, int, int, int *); extern bool hook_bool_rtx_int_int_intp_false (rtx, int, int, int *);
extern bool hook_bool_constcharptr_size_t_false (const char *, size_t); extern bool hook_bool_constcharptr_size_t_false (const char *, size_t);
......
...@@ -57,6 +57,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA ...@@ -57,6 +57,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
#include "predict.h" #include "predict.h"
#include "timevar.h" #include "timevar.h"
#include "tree-pass.h" #include "tree-pass.h"
#include "target.h"
/* Optimize jump y; x: ... y: jumpif... x? /* Optimize jump y; x: ... y: jumpif... x?
Don't know if it is worth bothering with. */ Don't know if it is worth bothering with. */
...@@ -1794,15 +1795,7 @@ invert_jump (rtx jump, rtx nlabel, int delete_unused) ...@@ -1794,15 +1795,7 @@ invert_jump (rtx jump, rtx nlabel, int delete_unused)
/* Like rtx_equal_p except that it considers two REGs as equal /* Like rtx_equal_p except that it considers two REGs as equal
if they renumber to the same value and considers two commutative if they renumber to the same value and considers two commutative
operations to be the same if the order of the operands has been operations to be the same if the order of the operands has been
reversed. reversed. */
??? Addition is not commutative on the PA due to the weird implicit
space register selection rules for memory addresses. Therefore, we
don't consider a + b == b + a.
We could/should make this test a little tighter. Possibly only
disabling it on the PA via some backend macro or only disabling this
case when the PLUS is inside a MEM. */
int int
rtx_renumbered_equal_p (rtx x, rtx y) rtx_renumbered_equal_p (rtx x, rtx y)
...@@ -1915,10 +1908,8 @@ rtx_renumbered_equal_p (rtx x, rtx y) ...@@ -1915,10 +1908,8 @@ rtx_renumbered_equal_p (rtx x, rtx y)
return 0; return 0;
/* For commutative operations, the RTX match if the operand match in any /* For commutative operations, the RTX match if the operand match in any
order. Also handle the simple binary and unary cases without a loop. order. Also handle the simple binary and unary cases without a loop. */
if (targetm.commutative_p (x, UNKNOWN))
??? Don't consider PLUS a commutative operator; see comments above. */
if (COMMUTATIVE_P (x) && code != PLUS)
return ((rtx_renumbered_equal_p (XEXP (x, 0), XEXP (y, 0)) return ((rtx_renumbered_equal_p (XEXP (x, 0), XEXP (y, 0))
&& rtx_renumbered_equal_p (XEXP (x, 1), XEXP (y, 1))) && rtx_renumbered_equal_p (XEXP (x, 1), XEXP (y, 1)))
|| (rtx_renumbered_equal_p (XEXP (x, 0), XEXP (y, 1)) || (rtx_renumbered_equal_p (XEXP (x, 0), XEXP (y, 1))
......
...@@ -352,6 +352,7 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -352,6 +352,7 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define TARGET_BRANCH_TARGET_REGISTER_CALLEE_SAVED hook_bool_bool_false #define TARGET_BRANCH_TARGET_REGISTER_CALLEE_SAVED hook_bool_bool_false
#define TARGET_CANNOT_FORCE_CONST_MEM hook_bool_rtx_false #define TARGET_CANNOT_FORCE_CONST_MEM hook_bool_rtx_false
#define TARGET_CANNOT_COPY_INSN_P NULL #define TARGET_CANNOT_COPY_INSN_P NULL
#define TARGET_COMMUTATIVE_P hook_bool_rtx_commutative_p
#define TARGET_DELEGITIMIZE_ADDRESS hook_rtx_rtx_identity #define TARGET_DELEGITIMIZE_ADDRESS hook_rtx_rtx_identity
#define TARGET_FUNCTION_OK_FOR_SIBCALL hook_bool_tree_tree_false #define TARGET_FUNCTION_OK_FOR_SIBCALL hook_bool_tree_tree_false
#define TARGET_COMP_TYPE_ATTRIBUTES hook_int_tree_tree_1 #define TARGET_COMP_TYPE_ATTRIBUTES hook_int_tree_tree_1
...@@ -554,6 +555,7 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -554,6 +555,7 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
TARGET_BRANCH_TARGET_REGISTER_CALLEE_SAVED, \ TARGET_BRANCH_TARGET_REGISTER_CALLEE_SAVED, \
TARGET_CANNOT_FORCE_CONST_MEM, \ TARGET_CANNOT_FORCE_CONST_MEM, \
TARGET_CANNOT_COPY_INSN_P, \ TARGET_CANNOT_COPY_INSN_P, \
TARGET_COMMUTATIVE_P, \
TARGET_DELEGITIMIZE_ADDRESS, \ TARGET_DELEGITIMIZE_ADDRESS, \
TARGET_FUNCTION_OK_FOR_SIBCALL, \ TARGET_FUNCTION_OK_FOR_SIBCALL, \
TARGET_IN_SMALL_DATA_P, \ TARGET_IN_SMALL_DATA_P, \
......
...@@ -393,6 +393,9 @@ struct gcc_target ...@@ -393,6 +393,9 @@ struct gcc_target
/* True if the insn X cannot be duplicated. */ /* True if the insn X cannot be duplicated. */
bool (* cannot_copy_insn_p) (rtx); bool (* cannot_copy_insn_p) (rtx);
/* True if X is considered to be commutative. */
bool (* commutative_p) (rtx, int);
/* Given an address RTX, undo the effects of LEGITIMIZE_ADDRESS. */ /* Given an address RTX, undo the effects of LEGITIMIZE_ADDRESS. */
rtx (* delegitimize_address) (rtx); rtx (* delegitimize_address) (rtx);
......
...@@ -411,4 +411,10 @@ default_hidden_stack_protect_fail (void) ...@@ -411,4 +411,10 @@ default_hidden_stack_protect_fail (void)
#endif #endif
} }
bool
hook_bool_rtx_commutative_p (rtx x, int outer_code ATTRIBUTE_UNUSED)
{
return COMMUTATIVE_P (x);
}
#include "gt-targhooks.h" #include "gt-targhooks.h"
...@@ -66,3 +66,4 @@ extern int hook_int_CUMULATIVE_ARGS_mode_tree_bool_0 ...@@ -66,3 +66,4 @@ extern int hook_int_CUMULATIVE_ARGS_mode_tree_bool_0
(CUMULATIVE_ARGS *, enum machine_mode, tree, bool); (CUMULATIVE_ARGS *, enum machine_mode, tree, bool);
extern const char *hook_invalid_arg_for_unprototyped_fn extern const char *hook_invalid_arg_for_unprototyped_fn
(tree, tree, tree); (tree, tree, tree);
extern bool hook_bool_rtx_commutative_p (rtx, int);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment