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 6fc9d8f25edab70347dbb8389da6796c6ad692f1..93e9f334a1b0759f855c550f73e5f6899dc1f33f 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 60eb3ba0581a2c0de39501848c090097d9005751..d0c2f93b49570e4bac5cdb514c0cc0e9f6e392ac 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 2c51ef2fe37ed5f84145d4458148eee1915810cb..8768b74c1025894603d1ba657191acbd1d1ccafb 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 78871a47858b83c2157b7fb9fa61d8f78056e800..2ebd0718618828196cc5407bc4114ab3fd072c66 100644 (file)
@@ -191,6 +191,12 @@ hook_bool_rtx_false (rtx a ATTRIBUTE_UNUSED)
   return false;
 }
 
+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 eebda9a41fda0897ef46037a803bf14dba86ffe8..1ca909ae2fd1b22bb02b6ac4331ef9f36592d279 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 de5686d8fd5c4643ebe9f3a9b823b5abc7915ef8..e3e2cdaa501b9efcfa439a0915946365269725ae 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 18e3040874e996f1ed2d5ff08e949f0b0863ce61..6f8470e4aec52b9b21a4b6e681cdcbd0cb7ddcef 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 b3c6ee9d78a458f9e01e5e8fabf4e050e771b677..1b3aaf0cfc0ed9fdb967a5f029be5601440e274b 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 0664f2cfed670ac22a691f50efcdf8bb70854ea9..4fc6e10a30b38c86369d566f2b083d5fff9a33df 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 80c49c8764b27a399f8fb2cc60532ac13434c5b8..ad526482ff2f5c113d3b4536ca1c58b03a0afa9e 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);