diff options
author | James Greenhalgh <james.greenhalgh@arm.com> | 2013-04-22 14:50:32 +0000 |
---|---|---|
committer | James Greenhalgh <jgreenhalgh@gcc.gnu.org> | 2013-04-22 14:50:32 +0000 |
commit | ea679d553f0c8791b2df470c138c6505a3be1cfc (patch) | |
tree | fdeb1da3b93237197679dcc3174d6e1b4a44b8cb /gcc | |
parent | 9191d7a84aa904ae21bd4b8dd98100977e3b10a2 (diff) | |
download | gcc-ea679d553f0c8791b2df470c138c6505a3be1cfc.zip gcc-ea679d553f0c8791b2df470c138c6505a3be1cfc.tar.gz gcc-ea679d553f0c8791b2df470c138c6505a3be1cfc.tar.bz2 |
[Mid-end] Add TARGET_GIMPLE_FOLD_BUILTIN target hook.
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 16 | ||||
-rw-r--r-- | gcc/coretypes.h | 2 | ||||
-rw-r--r-- | gcc/doc/tm.texi | 12 | ||||
-rw-r--r-- | gcc/doc/tm.texi.in | 7 | ||||
-rw-r--r-- | gcc/gimple-fold.c | 2 | ||||
-rw-r--r-- | gcc/gimple.h | 5 | ||||
-rw-r--r-- | gcc/hooks.c | 8 | ||||
-rw-r--r-- | gcc/hooks.h | 1 | ||||
-rw-r--r-- | gcc/target.def | 13 |
9 files changed, 58 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3e930b4..6932a53 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/coretypes.h b/gcc/coretypes.h index 320b4dd..76fc4aa 100644 --- a/gcc/coretypes.h +++ b/gcc/coretypes.h @@ -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; diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index c88a89f..ec7ef75 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -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}) diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index d70ce4c..a418733 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -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 diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index b9211a9..738d7fd 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -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; diff --git a/gcc/gimple.h b/gcc/gimple.h index 3a65e3c..76da6d2 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -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. */ diff --git a/gcc/hooks.c b/gcc/hooks.c index 3b54dfa..3259658 100644 --- a/gcc/hooks.c +++ b/gcc/hooks.c @@ -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, diff --git a/gcc/hooks.h b/gcc/hooks.h index 50bcc6a..eaf4b03 100644 --- a/gcc/hooks.h +++ b/gcc/hooks.h @@ -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, diff --git a/gcc/target.def b/gcc/target.def index db74273..a8306b2 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -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 |