diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2021-11-30 09:52:28 +0000 |
---|---|---|
committer | Richard Sandiford <richard.sandiford@arm.com> | 2021-11-30 09:52:28 +0000 |
commit | 6f798618c070e2ca505e39c3fcc0c3ca478ac81b (patch) | |
tree | 868d81e39387ac14d9b90c36a68ae530c235bd1b /gcc/gimple.h | |
parent | 8de7958fbd126528c5a5a95a068c0692f6a643cc (diff) | |
download | gcc-6f798618c070e2ca505e39c3fcc0c3ca478ac81b.zip gcc-6f798618c070e2ca505e39c3fcc0c3ca478ac81b.tar.gz gcc-6f798618c070e2ca505e39c3fcc0c3ca478ac81b.tar.bz2 |
vect: Use generalised accessors to build SLP nodes
This patch adds:
- gimple_num_args
- gimple_arg
- gimple_arg_ptr
for accessing rhs operands of an assignment, call or PHI. This is
similar to the existing gimple_get_lhs.
I guess there's a danger that these routines could be overused,
such as in cases where gimple_assign_rhs1 etc. would be more
appropriate. I think the routines are still worth having though.
These days, most new operations are added as internal functions rather
than tree codes, so it's useful to be able to handle assignments and
calls in a consistent way.
The patch also generalises the way that SLP child nodes map
to gimple stmt operands. This is useful for later patches.
gcc/
* gimple.h (gimple_num_args, gimple_arg, gimple_arg_ptr): New
functions.
* tree-vect-slp.c (cond_expr_maps, arg2_map): New variables.
(vect_get_operand_map): New function.
(vect_get_and_check_slp_defs): Fix outdated comment.
Use vect_get_operand_map and new gimple argument accessors.
(vect_build_slp_tree_2): Likewise.
Diffstat (limited to 'gcc/gimple.h')
-rw-r--r-- | gcc/gimple.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/gcc/gimple.h b/gcc/gimple.h index 3cde3cd..f7fdefc 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -4692,6 +4692,44 @@ gimple_phi_arg_has_location (const gphi *phi, size_t i) return gimple_phi_arg_location (phi, i) != UNKNOWN_LOCATION; } +/* Return the number of arguments that can be accessed by gimple_arg. */ + +static inline unsigned +gimple_num_args (const gimple *gs) +{ + if (auto phi = dyn_cast<const gphi *> (gs)) + return gimple_phi_num_args (phi); + if (auto call = dyn_cast<const gcall *> (gs)) + return gimple_call_num_args (call); + return gimple_num_ops (as_a <const gassign *> (gs)) - 1; +} + +/* GS must be an assignment, a call, or a PHI. + If it's an assignment, return rhs operand I. + If it's a call, return function argument I. + If it's a PHI, return the value of PHI argument I. */ + +static inline tree +gimple_arg (const gimple *gs, unsigned int i) +{ + if (auto phi = dyn_cast<const gphi *> (gs)) + return gimple_phi_arg_def (phi, i); + if (auto call = dyn_cast<const gcall *> (gs)) + return gimple_call_arg (call, i); + return gimple_op (as_a <const gassign *> (gs), i + 1); +} + +/* Return a pointer to gimple_arg (GS, I). */ + +static inline tree * +gimple_arg_ptr (gimple *gs, unsigned int i) +{ + if (auto phi = dyn_cast<gphi *> (gs)) + return gimple_phi_arg_def_ptr (phi, i); + if (auto call = dyn_cast<gcall *> (gs)) + return gimple_call_arg_ptr (call, i); + return gimple_op_ptr (as_a <gassign *> (gs), i + 1); +} /* Return the region number for GIMPLE_RESX RESX_STMT. */ |