+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
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;
@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})
@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
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;
/* Iterator object for GIMPLE statement sequences. */
-typedef struct
+struct gimple_stmt_iterator_d
{
/* Sequence node holding the current statement. */
gimple_seq_node ptr;
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. */
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,
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,
"",
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