* 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
+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>
* config/s390/s390-protos.h (s390_expand_clrmem): Delete.
static rtx hppa_builtin_saveregs (void);
static tree hppa_gimplify_va_arg_expr (tree, tree, tree *, tree *);
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 int length_fp_args (rtx) ATTRIBUTE_UNUSED;
static struct deferred_plabel *get_plabel (rtx) ATTRIBUTE_UNUSED;
#undef TARGET_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
#define TARGET_ASM_OUTPUT_MI_THUNK pa_asm_output_mi_thunk
#undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
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
use in fmpyadd instructions. */
int
may in turn cause a branch offset to overflow.
@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})
When the initial value of a hard register has been copied in a pseudo
}
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,
unsigned int *b ATTRIBUTE_UNUSED)
{
extern bool hook_bool_tree_hwi_hwi_tree_true (tree, HOST_WIDE_INT, HOST_WIDE_INT,
tree);
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_rtx_int_int_intp_false (rtx, int, int, int *);
extern bool hook_bool_constcharptr_size_t_false (const char *, size_t);
#include "predict.h"
#include "timevar.h"
#include "tree-pass.h"
+#include "target.h"
/* Optimize jump y; x: ... y: jumpif... x?
Don't know if it is worth bothering with. */
/* Like rtx_equal_p except that it considers two REGs as equal
if they renumber to the same value and considers two commutative
operations to be the same if the order of the operands has been
- 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. */
+ reversed. */
int
rtx_renumbered_equal_p (rtx x, rtx y)
return 0;
/* For commutative operations, the RTX match if the operand match in any
- order. Also handle the simple binary and unary cases without a loop.
-
- ??? Don't consider PLUS a commutative operator; see comments above. */
- if (COMMUTATIVE_P (x) && code != PLUS)
+ order. Also handle the simple binary and unary cases without a loop. */
+ if (targetm.commutative_p (x, UNKNOWN))
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, 0), XEXP (y, 1))
#define TARGET_BRANCH_TARGET_REGISTER_CALLEE_SAVED hook_bool_bool_false
#define TARGET_CANNOT_FORCE_CONST_MEM hook_bool_rtx_false
#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_FUNCTION_OK_FOR_SIBCALL hook_bool_tree_tree_false
#define TARGET_COMP_TYPE_ATTRIBUTES hook_int_tree_tree_1
TARGET_BRANCH_TARGET_REGISTER_CALLEE_SAVED, \
TARGET_CANNOT_FORCE_CONST_MEM, \
TARGET_CANNOT_COPY_INSN_P, \
+ TARGET_COMMUTATIVE_P, \
TARGET_DELEGITIMIZE_ADDRESS, \
TARGET_FUNCTION_OK_FOR_SIBCALL, \
TARGET_IN_SMALL_DATA_P, \
/* True if the insn X cannot be duplicated. */
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. */
rtx (* delegitimize_address) (rtx);
#endif
}
+bool
+hook_bool_rtx_commutative_p (rtx x, int outer_code ATTRIBUTE_UNUSED)
+{
+ return COMMUTATIVE_P (x);
+}
+
#include "gt-targhooks.h"
(CUMULATIVE_ARGS *, enum machine_mode, tree, bool);
extern const char *hook_invalid_arg_for_unprototyped_fn
(tree, tree, tree);
+extern bool hook_bool_rtx_commutative_p (rtx, int);