]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Mid-end] Add TARGET_GIMPLE_FOLD_BUILTIN target hook.
authorJames Greenhalgh <james.greenhalgh@arm.com>
Mon, 22 Apr 2013 14:50:32 +0000 (14:50 +0000)
committerJames Greenhalgh <jgreenhalgh@gcc.gnu.org>
Mon, 22 Apr 2013 14:50:32 +0000 (14:50 +0000)
gcc/

* coretypes.h (gimple_stmt_iterator_d): Forward declare.
(gimple_stmt_iterator): New typedef.
* gimple.h (gimple_stmt_iterator): Rename to...
(gimple_stmt_iterator_d): ... This.
* doc/tm.texi.in (TARGET_FOLD_BUILTIN): Detail restriction that
trees be valid for GIMPLE and GENERIC.
(TARGET_GIMPLE_FOLD_BUILTIN): New.
* gimple-fold.c (gimple_fold_call): Call target hook
gimple_fold_builtin.
* hooks.c (hook_bool_gsiptr_false): New.
* hooks.h (hook_bool_gsiptr_false): New.
* target.def (fold_stmt): New.
* doc/tm.texi: Regenerate.

From-SVN: r198142

gcc/ChangeLog
gcc/coretypes.h
gcc/doc/tm.texi
gcc/doc/tm.texi.in
gcc/gimple-fold.c
gcc/gimple.h
gcc/hooks.c
gcc/hooks.h
gcc/target.def

index 3e930b47039ae27c8ba0deaf8fcaf501285c1b7e..6932a535fd69545397f5e62c34d5288584ba46ff 100644 (file)
@@ -1,3 +1,19 @@
+2013-04-22  James Greenhalgh  <james.greenhalgh@arm.com>
+
+       * coretypes.h (gimple_stmt_iterator_d): Forward declare.
+       (gimple_stmt_iterator): New typedef.
+       * gimple.h (gimple_stmt_iterator): Rename to...
+       (gimple_stmt_iterator_d): ... This.
+       * doc/tm.texi.in (TARGET_FOLD_BUILTIN): Detail restriction that
+       trees be valid for GIMPLE and GENERIC.
+       (TARGET_GIMPLE_FOLD_BUILTIN): New.
+       * gimple-fold.c (gimple_fold_call): Call target hook
+       gimple_fold_builtin.
+       * hooks.c (hook_bool_gsiptr_false): New.
+       * hooks.h (hook_bool_gsiptr_false): New.
+       * target.def (fold_stmt): New.
+       * doc/tm.texi: Regenerate.
+
 2013-04-22  Vladimir Makarov  <vmakarov@redhat.com>
 
        PR target/57018
index 320b4dd5d6054003679322fb8d4e7647b4bf78da..76fc4aabc8adefab3cb12c0c54cdd574fe686ae3 100644 (file)
@@ -62,6 +62,8 @@ union gimple_statement_d;
 typedef union gimple_statement_d *gimple;
 typedef const union gimple_statement_d *const_gimple;
 typedef gimple gimple_seq;
+struct gimple_stmt_iterator_d;
+typedef gimple_stmt_iterator_d gimple_stmt_iterator;
 union section;
 typedef union section section;
 struct gcc_options;
index c88a89f28c3a65738f878f71fdc5c5feee2a884f..ec7ef758086f5300d59d29cfedff3d01e4905f4a 100644 (file)
@@ -10931,8 +10931,16 @@ Fold a call to a machine specific built-in function that was set up by
 @samp{TARGET_INIT_BUILTINS}.  @var{fndecl} is the declaration of the
 built-in function.  @var{n_args} is the number of arguments passed to
 the function; the arguments themselves are pointed to by @var{argp}.
-The result is another tree containing a simplified expression for the
-call's result.  If @var{ignore} is true the value will be ignored.
+The result is another tree, valid for both GIMPLE and GENERIC,
+containing a simplified expression for the call's result.  If
+@var{ignore} is true the value will be ignored.
+@end deftypefn
+
+@deftypefn {Target Hook} bool TARGET_GIMPLE_FOLD_BUILTIN (gimple_stmt_iterator *@var{gsi})
+Fold a call to a machine specific built-in function that was set up
+by @samp{TARGET_INIT_BUILTINS}.  @var{gsi} points to the gimple
+statement holding the function call.  Returns true if any change
+was made to the GIMPLE stream.
 @end deftypefn
 
 @deftypefn {Target Hook} int TARGET_COMPARE_VERSION_PRIORITY (tree @var{decl1}, tree @var{decl2})
index d70ce4cfd36984ccb39ddb4919f0c40be2b97427..a4187335b627c29b218f0217a82a4947a3228aa6 100644 (file)
@@ -10775,10 +10775,13 @@ Fold a call to a machine specific built-in function that was set up by
 @samp{TARGET_INIT_BUILTINS}.  @var{fndecl} is the declaration of the
 built-in function.  @var{n_args} is the number of arguments passed to
 the function; the arguments themselves are pointed to by @var{argp}.
-The result is another tree containing a simplified expression for the
-call's result.  If @var{ignore} is true the value will be ignored.
+The result is another tree, valid for both GIMPLE and GENERIC,
+containing a simplified expression for the call's result.  If
+@var{ignore} is true the value will be ignored.
 @end deftypefn
 
+@hook TARGET_GIMPLE_FOLD_BUILTIN
+
 @hook TARGET_COMPARE_VERSION_PRIORITY
 This hook is used to compare the target attributes in two functions to
 determine which function's features get higher priority.  This is used
index b9211a9add2716a78e1a946637256e7a308e6938..738d7fddd4c97bc78eca043ff47bb60df9a9efdc 100644 (file)
@@ -1143,6 +1143,8 @@ gimple_fold_call (gimple_stmt_iterator *gsi, bool inplace)
            gimplify_and_update_call_from_tree (gsi, result);
          changed = true;
        }
+      else if (DECL_BUILT_IN_CLASS (callee) == BUILT_IN_MD)
+       changed |= targetm.gimple_fold_builtin (gsi);
     }
 
   return changed;
index 3a65e3ccace7758e625fec3a8fe7aa839f56f104..76da6d2bcd7dd3963430d162a4d637df3c7729a2 100644 (file)
@@ -139,7 +139,7 @@ enum plf_mask {
 
 /* Iterator object for GIMPLE statement sequences.  */
 
-typedef struct
+struct gimple_stmt_iterator_d
 {
   /* Sequence node holding the current statement.  */
   gimple_seq_node ptr;
@@ -150,8 +150,7 @@ typedef struct
      block/sequence is removed.  */
   gimple_seq *seq;
   basic_block bb;
-} gimple_stmt_iterator;
-
+};
 
 /* Data structure definitions for GIMPLE tuples.  NOTE: word markers
    are for 64 bit hosts.  */
index 3b54dfa5430d26271e251d58d027731d0d2dfd98..3259658e4f4f9562bd93e2a66c24cf554a135169 100644 (file)
@@ -147,6 +147,14 @@ hook_bool_FILEptr_rtx_false (FILE *a ATTRIBUTE_UNUSED,
   return false;
 }
 
+/* Generic hook that takes (gimple_stmt_iterator *) and returns
+   false.  */
+bool
+hook_bool_gsiptr_false (gimple_stmt_iterator *a ATTRIBUTE_UNUSED)
+{
+  return false;
+}
+
 /* Used for the TARGET_ASM_CAN_OUTPUT_MI_THUNK hook.  */
 bool
 hook_bool_const_tree_hwi_hwi_const_tree_false (const_tree a ATTRIBUTE_UNUSED,
index 50bcc6afc7e89f51183fc84a1109e99ac5b5c798..eaf4b03ebbb9d325f353c538e7633b99f67cad90 100644 (file)
@@ -42,6 +42,7 @@ extern bool hook_bool_tree_false (tree);
 extern bool hook_bool_const_tree_false (const_tree);
 extern bool hook_bool_tree_true (tree);
 extern bool hook_bool_const_tree_true (const_tree);
+extern bool hook_bool_gsiptr_false (gimple_stmt_iterator *);
 extern bool hook_bool_const_tree_hwi_hwi_const_tree_false (const_tree,
                                                           HOST_WIDE_INT,
                                                           HOST_WIDE_INT,
index db742732e340799edfd1cfdca8b56148c35f3271..a8306b258897a09c0f932f006354bf5444e505cf 100644 (file)
@@ -1289,13 +1289,24 @@ DEFHOOK
  "",
  tree, (unsigned int /*location_t*/ loc, tree fndecl, void *arglist), NULL)
 
-/* Fold a target-specific builtin.  */
+/* Fold a target-specific builtin to a tree valid for both GIMPLE
+   and GENERIC.  */
 DEFHOOK
 (fold_builtin,
  "",
  tree, (tree fndecl, int n_args, tree *argp, bool ignore),
  hook_tree_tree_int_treep_bool_null)
 
+/* Fold a target-specific builtin to a valid GIMPLE tree.  */
+DEFHOOK
+(gimple_fold_builtin,
+ "Fold a call to a machine specific built-in function that was set up\n\
+by @samp{TARGET_INIT_BUILTINS}.  @var{gsi} points to the gimple\n\
+statement holding the function call.  Returns true if any change\n\
+was made to the GIMPLE stream.",
+ bool, (gimple_stmt_iterator *gsi),
+ hook_bool_gsiptr_false)
+
 /* Target hook is used to compare the target attributes in two functions to
    determine which function's features get higher priority.  This is used
    during function multi-versioning to figure out the order in which two