Add a class to represent a gimple match result

Programming / Compilers / GCC - rsandifo [138bc75d-0d04-0410-961f-82ee72b054a4] - 24 May 2018 08:02 EDT

Gimple match results are represented by a code_helper for the operation, a tree for the type, and an array of three trees for the operands. This patch wraps them up in a class so that they don't need to be passed around individually.

The main reason for doing this is to make it easier to increase the number of operands (for calls) or to support more complicated kinds of operation. But passing around fewer operands also helps to reduce the size of gimple-match.o (about 7% for development builds and 4% for release builds).

2018-05-24 Richard Sandiford

gcc/
- gimple-match.h (gimple_match_op): New class. (mprts_hook): Replace parameters with a gimple_match_op *. (maybe_build_generic_op): Likewise. (gimple_simplified_result_is_gimple_val): Replace parameters with a const gimple_match_op *. (gimple_simplify): Replace code_helper * and tree * parameters with a gimple_match_op * parameter. (gimple_resimplify1): Replace code_helper *, tree and tree * parameters with a gimple_match_op * parameter. (gimple_resimplify2): Likewise. (gimple_resimplify3): Likewise. (maybe_push_res_to_seq): Replace code_helper, tree and tree * parameters with a gimple_match_op * parameter.
- gimple-match-head.c (gimple_simplify): Change prototypes of auto-generated functions to take a gimple_match_op * instead of separate code_helper * and tree * parameters. Make the same change in the top-level overload and update calls to the gimple_resimplify routines. Update calls to the auto-generated functions and to maybe_push_res_to_seq in the publicly-facing operation-specific gimple_simplify overloads. (gimple_match_op::MAX_NUM_OPS): Define. (gimple_resimplify1): Replace rcode and ops with a single res_op parameter. Update call to gimple_simplify. (gimple_resimplify2): Likewise. (gimple_resimplify3): Likewise. (mprts_hook): Replace parameters with a gimple_match_op *. (maybe_build_generic_op): Likewise. (build_call_internal): Replace type, nargs and ops with a gimple_match_op *. (maybe_push_res_to_seq): Replace res_code, type and ops parameters with a single gimple_match_op *. Update calls to mprts_hook, build_call_internal and gimple_simplified_result_is_gimple_val. Factor out code that is common to the tree_code and combined_fn cases.
- genmatch.c (expr::gen_transform): Replace tem_code and tem_ops with a gimple_match_op called tem_op. Update calls to the gimple_resimplify functions and maybe_push_res_to_seq. (dt_simplify::gen_1): Manipulate res_op instead of res_code and res_ops. Update call to the gimple_resimplify functions. (dt_simplify::gen): Pass res_op instead of res_code and res_ops. (decision_tree::gen): Make the functions take a gimple_match_op * called res_op instead of separate res_code and res_ops parameters. Update call accordingly.
- gimple-fold.c (replace_stmt_with_simplification): Replace rcode and ops with a single res_op parameter. Update calls to maybe_build_generic_op and maybe_push_res_to_seq. (fold_stmt_1): Update calls to gimple_simplify and replace_stmt_with_simplification. (gimple_fold_stmt_to_constant_1): Update calls to gimple_simplify and gimple_simplified_result_is_gimple_val.
- tree-cfgcleanup.c (cleanup_control_expr_graph): Update call to gimple_simplify.
- tree-ssa-sccvn.c (vn_lookup_simplify_result): Replace parameters with a gimple_match_op *. (vn_nary_build_or_lookup): Likewise. Update call to
vn_nary_build_or_lookup_1. (vn_nary_build_or_lookup_1): Replace rcode, type and ops with a gimple_match_op *. Update calls to the gimple_resimplify routines and to gimple_simplified_result_is_gimple_val. (vn_nary_simplify): Update call to vn_nary_build_or_lookup_1. Use gimple_match_op::MAX_NUM_OPS instead of a hard-coded 3. (vn_reference_lookup_3): Update call to vn_nary_build_or_lookup. (visit_nary_op): Likewise. (visit_reference_op_load): Likewise.

49446baa459 Add a class to represent a gimple match result
gcc/ChangeLog | 66 ++++++++
gcc/genmatch.c | 63 ++++----
gcc/gimple-fold.c | 98 +++++-------
gcc/gimple-match-head.c | 410 +++++++++++++++++++++---------------------------
gcc/gimple-match.h | 170 +++++++++++++++++---
gcc/tree-cfgcleanup.c | 9 +-
gcc/tree-ssa-sccvn.c | 91 +++++------
7 files changed, 522 insertions(+), 385 deletions(-)

Upstream: gcc.gnu.org


  • Share