hooks.c (hook_bool_rtx_int_false): New function.
authorJ"orn Rennecke <joern.rennecke@st.com>
Thu, 7 Jul 2005 11:48:15 +0000 (11:48 +0000)
committerJoern Rennecke <amylaar@gcc.gnu.org>
Thu, 7 Jul 2005 11:48:15 +0000 (12:48 +0100)
* 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

gcc/ChangeLog
gcc/config/pa/pa.c
gcc/doc/tm.texi
gcc/hooks.c
gcc/hooks.h
gcc/jump.c
gcc/target-def.h
gcc/target.h
gcc/targhooks.c
gcc/targhooks.h

index 6fc9d8f..93e9f33 100644 (file)
@@ -1,3 +1,18 @@
+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.
index 60eb3ba..d0c2f93 100644 (file)
@@ -124,6 +124,7 @@ static void pa_init_builtins (void);
 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;
@@ -226,6 +227,9 @@ static size_t n_deferred_plabels = 0;
 #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
@@ -7820,6 +7824,17 @@ pa_function_ok_for_sibcall (tree decl, tree exp ATTRIBUTE_UNUSED)
   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
index 2c51ef2..8768b74 100644 (file)
@@ -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.
 @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
index 78871a4..2ebd071 100644 (file)
@@ -192,6 +192,12 @@ hook_bool_rtx_false (rtx a ATTRIBUTE_UNUSED)
 }
 
 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)
 {
index eebda9a..1ca909a 100644 (file)
@@ -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,
                                       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);
index de5686d..e3e2cda 100644 (file)
@@ -57,6 +57,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
 #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.  */
@@ -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
    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)
@@ -1915,10 +1908,8 @@ 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))
index 18e3040..6f8470e 100644 (file)
@@ -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_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
@@ -554,6 +555,7 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
   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,                      \
index b3c6ee9..1b3aaf0 100644 (file)
@@ -393,6 +393,9 @@ struct gcc_target
   /* 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);
 
index 0664f2c..4fc6e10 100644 (file)
@@ -411,4 +411,10 @@ default_hidden_stack_protect_fail (void)
 #endif
 }
 
+bool
+hook_bool_rtx_commutative_p (rtx x, int outer_code ATTRIBUTE_UNUSED)
+{
+  return COMMUTATIVE_P (x);
+}
+
 #include "gt-targhooks.h"
index 80c49c8..ad52648 100644 (file)
@@ -66,3 +66,4 @@ extern int hook_int_CUMULATIVE_ARGS_mode_tree_bool_0
   (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);