gcc/gcc/tree-inline.h

161 lines
5.1 KiB
C
Raw Normal View History

/* Tree inlining hooks and declarations.
Copyright 2001, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
Contributed by Alexandre Oliva <aoliva@redhat.com>
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#ifndef GCC_TREE_INLINE_H
#define GCC_TREE_INLINE_H
#include "varray.h"
#include "pointer-set.h"
/* Data required for function body duplication. */
typedef struct copy_body_data
{
/* FUNCTION_DECL for function being inlined, or in general the
source function providing the original trees. */
tree src_fn;
/* FUNCTION_DECL for function being inlined into, or in general
the destination function receiving the new trees. */
tree dst_fn;
/* Callgraph node of the source function. */
struct cgraph_node *src_node;
/* Callgraph node of the destination function. */
struct cgraph_node *dst_node;
/* struct function for function being inlined. Usually this is the same
as DECL_STRUCT_FUNCTION (src_fn), but can be different if saved_cfg
and saved_eh are in use. */
struct function *src_cfun;
/* The VAR_DECL for the return value. */
tree retvar;
/* The map from local declarations in the inlined function to
equivalents in the function into which it is being inlined. */
struct pointer_map_t *decl_map;
/* Create a new decl to replace DECL in the destination function. */
tree (*copy_decl) (tree, struct copy_body_data *);
/* Current BLOCK. */
tree block;
/* CALL_EXPR if va arg parameter packs should be expanded or NULL
is not. */
tree call_expr;
/* Exception region the inlined call lie in. */
int eh_region;
/* Take region number in the function being copied, add this value and
get eh region number of the duplicate in the function we inline into. */
int eh_region_offset;
/* We use the same mechanism do all sorts of different things. Rather
than enumerating the different cases, we categorize the behavior
in the various situations. */
/* Indicate the desired behavior wrt call graph edges. We can either
duplicate the edge (inlining, cloning), move the edge (versioning,
parallelization), or move the edges of the clones (saving). */
enum copy_body_cge_which {
CB_CGE_DUPLICATE,
CB_CGE_MOVE,
CB_CGE_MOVE_CLONES
} transform_call_graph_edges;
/* True if a new CFG should be created. False for inlining, true for
everything else. */
bool transform_new_cfg;
/* True if RETURN_EXPRs should be transformed to just the contained
MODIFY_EXPR. The branch semantics of the return will be handled
by manipulating the CFG rather than a statement. */
bool transform_return_to_modify;
/* True if lang_hooks.decls.insert_block should be invoked when
duplicating BLOCK nodes. */
bool transform_lang_insert_block;
/* Statements that might be possibly folded. */
struct pointer_set_t *statements_to_fold;
} copy_body_data;
tree-ssa-loop-unswitch.c: Include tree-inline.h. * tree-ssa-loop-unswitch.c: Include tree-inline.h. (tree_unswitch_single_loop): Pass eni_size_weights to tree_num_loop_insns. * tree-ssa-loop-manip.c: Include tree-inline.h. (can_unroll_loop_p): Pass eni_size_weights to tree_num_loop_insns. * tree-ssa-loop-ch.c (should_duplicate_loop_header_p): Pass eni_size_weights to estimate_num_insns. * tree.h (init_inline_once): Export. * toplev.c (backend_init): Call init_inline_once. * cgraphunit.c (cgraph_process_new_functions, cgraph_analyze_function): Pass eni_inlining_weights to estimate_num_insns. * ipa-inline.c (compute_inline_parameters): Ditto. * tree-ssa-loop-ivcanon.c (tree_num_loop_insns): Pass weights to estimate_num_insns. (try_unroll_loop_completely): Pass eni_size_weights to tree_num_loop_insns. * tree-eh.c (decide_copy_try_finally): Pass eni_size_weights ot estimate_num_insns. * tree-ssa-loop-prefetch.c: Include tree-inline.h. (loop_prefetch_arrays): Pass eni_time_weights to tree_num_loop_insns. * tree-inline.c (eni_inlining_weights, eni_size_weights, eni_time_weights): New variables. (init_inline_once): Initialize them. (struct eni_data): Mew. (estimate_num_insns_1, estimate_num_insns): Use weights. * tree-inline.h (struct eni_weights_d): New. (eni_inlining_weights, eni_size_weights, eni_time_weights): Declare. (estimate_num_insns): Declaration changed. * cfgloop.h (tree_num_loop_insns): Declaration changed. * Makefile.in (tree-ssa-loop-unswitch.o, tree-ssa-loop-prefetch.o, tree-ssa-loop-manip.o): Add TREE_INLINE_H dependency. * gcc.dg/tree-ssa/loop-23.c: New test. From-SVN: r121260
2007-01-28 18:40:38 +01:00
/* Weights of constructions for estimate_num_insns. */
typedef struct eni_weights_d
{
/* Cost per call. */
unsigned call_cost;
/* Cost per call to a target specific builtin */
unsigned target_builtin_call_cost;
tree-ssa-loop-unswitch.c: Include tree-inline.h. * tree-ssa-loop-unswitch.c: Include tree-inline.h. (tree_unswitch_single_loop): Pass eni_size_weights to tree_num_loop_insns. * tree-ssa-loop-manip.c: Include tree-inline.h. (can_unroll_loop_p): Pass eni_size_weights to tree_num_loop_insns. * tree-ssa-loop-ch.c (should_duplicate_loop_header_p): Pass eni_size_weights to estimate_num_insns. * tree.h (init_inline_once): Export. * toplev.c (backend_init): Call init_inline_once. * cgraphunit.c (cgraph_process_new_functions, cgraph_analyze_function): Pass eni_inlining_weights to estimate_num_insns. * ipa-inline.c (compute_inline_parameters): Ditto. * tree-ssa-loop-ivcanon.c (tree_num_loop_insns): Pass weights to estimate_num_insns. (try_unroll_loop_completely): Pass eni_size_weights to tree_num_loop_insns. * tree-eh.c (decide_copy_try_finally): Pass eni_size_weights ot estimate_num_insns. * tree-ssa-loop-prefetch.c: Include tree-inline.h. (loop_prefetch_arrays): Pass eni_time_weights to tree_num_loop_insns. * tree-inline.c (eni_inlining_weights, eni_size_weights, eni_time_weights): New variables. (init_inline_once): Initialize them. (struct eni_data): Mew. (estimate_num_insns_1, estimate_num_insns): Use weights. * tree-inline.h (struct eni_weights_d): New. (eni_inlining_weights, eni_size_weights, eni_time_weights): Declare. (estimate_num_insns): Declaration changed. * cfgloop.h (tree_num_loop_insns): Declaration changed. * Makefile.in (tree-ssa-loop-unswitch.o, tree-ssa-loop-prefetch.o, tree-ssa-loop-manip.o): Add TREE_INLINE_H dependency. * gcc.dg/tree-ssa/loop-23.c: New test. From-SVN: r121260
2007-01-28 18:40:38 +01:00
/* Cost of "expensive" div and mod operations. */
unsigned div_mod_cost;
/* Cost of switch statement. */
unsigned switch_cost;
/* Cost for omp construct. */
unsigned omp_cost;
} eni_weights;
/* Weights that estimate_num_insns uses for heuristics in inlining. */
extern eni_weights eni_inlining_weights;
/* Weights that estimate_num_insns uses to estimate the size of the
produced code. */
extern eni_weights eni_size_weights;
/* Weights that estimate_num_insns uses to estimate the time necessary
to execute the produced code. */
extern eni_weights eni_time_weights;
/* Function prototypes. */
extern tree copy_body_r (tree *, int *, void *);
extern void insert_decl_map (copy_body_data *, tree, tree);
cgraph.h (cgraph_decide_inlining_incrementally): Kill. * cgraph.h (cgraph_decide_inlining_incrementally): Kill. * tree-pass.h: Reorder to make IPA passes appear toegher. (pass_early_inline, pass_inline_parameters, pass_apply_inline): Declare. * cgraphunit.c (cgraph_finalize_function): Do not compute inling parameters, do not call early inliner. * ipa-inline.c: Update comments. Include tree-flow.h (cgraph_decide_inlining): Do not compute inlining parameters. (cgraph_decide_inlining_incrementally): Return TODOs; assume to be called with function context set up. (pass_ipa_inline): Remove unreachable functions before pass. (cgraph_early_inlining): Simplify assuming to be called from the PM as local pass. (pass_early_inline): New pass. (cgraph_gate_ipa_early_inlining): New gate. (pass_ipa_early_inline): Turn into simple wrapper. (compute_inline_parameters): New function. (gate_inline_passes): New gate. (pass_inline_parameters): New pass. (apply_inline): Move here from tree-optimize.c (pass_apply_inline): New pass. * ipa.c (cgraph_remove_unreachable_nodes): Verify cgraph after transforming. * tree-inline.c (optimize_inline_calls): Return TODOs rather than doing them by hand. (tree_function_versioning): Do not allocate dummy struct function. * tree-inline.h (optimize_inline_calls): Update prototype. * tree-optimize.c (execute_fixup_cfg): Export. (pass_fixup_cfg): Remove (tree_rest_of_compilation): Do not apply inlines. * tree-flow.h (execute_fixup_cfg): Declare. * Makefile.in (gt-passes.c): New. * passes.c: Include gt-passes.h (init_optimization_passes): New passes. (nnodes, order): New static vars. (do_per_function_toporder): New function. (execute_one_pass): Dump current pass here. (execute_ipa_pass_list): Don't dump current pass here. From-SVN: r120835
2007-01-16 22:30:54 +01:00
unsigned int optimize_inline_calls (tree);
tree.h (DID_INLINE_FUNC): Remove macro. 2003-08-05 Steven Bosscher <steven@gcc.gnu.org> * tree.h (DID_INLINE_FUNC): Remove macro. (DECL_DECLARED_INLINE_P): Move from c-tree.h and cp/cp-tree.h, add tree check for FUNCTION_DECL. (DECL_ESTIMATED_INSNS): Move from c-common.h and java/java-tree.h. (struct tree_decl): Rename inlined_function_flag to declared_inline_flag. * c-common.h (c_lang_decl): Remove. (DECL_ESTIMATED_INSNS): Remove. * c-tree.h (struct lang_decl): Don't include c_lang_decl. (DECL_DECLARED_INLINE_P): Remove. * c-decl.c (grokdeclarator): Update comment. With -finline-functions, do not reset DECL_DECLARED_INLINE_P. Don't use DID_INLINE_FUNC. (finish_function): Make uninlinable a bool. Fixup call to tree_inlinable_function_p() and fix some code style issues. * cgraph.h (disgread_inline_limits): Fix spelling: `disregard'. * cgraph.c (dump_cgraph): Likewise. * cgraphunit.c (cgraph_decide_inlining): Likewise (cgraph_finalize_compilation_unit): Likewise. Also update call to tree_inlinable_function_p(). (cgraph_default_inline_p): Don't use DID_INLINE_FUNC. Instead look at DECL_DECLARED_INLINE and reverse logic. * print-tree.c (print_node): Likewise. * toplev.c (rest_of_handle_inlining): Don't use DID_INLINE_FUNC. * tree-inline.h (tree_inlinable_function_p): Make a bool. Update prototype. * tree-inline.c (inlinable_function_p): Split up in this function to check for basic inlining inhibiting conditions, and new limits_allow_inlining() function. Warn if inlining is impossible because the inline candidate calls alloca or uses sjlj exceptions. (limits_allow_inlining): this new function to check if the inlining limits are satisfied. Throttle from currfn_max_inline_insns, not from MAX_INLINE_INSNS_SINGLE. The latter only makes sense if MAX_INLINE_INSNS_AUTO and MAX_INLINE_INSNS_SINGLE are equal. Update prototypes. (tree_inlinable_function_p): Make a bool. Update call to inlinable_function_p (expand_call_inline): Use limits_allow_inlining() when not in unit-at-a-time mode to decide on inlining. Don't use DID_INLINE_FUNC, instead see if the function was declared `inline'. cp/ * cp-tree.h (struct lang_decl): Don't include c_lang_decl. (DECL_DECLARED_INLINE_P): Remove. * decl2.c (import_export_decl): Only look at DECL_DECLARED_INLINE_P if decl is a FUNCTION_DECL. This never made sense, but now it is required to avoid a tree check failure. * decl.c (grokfndecl): Don't touch DID_INLINE_FUNC. * optimize.c (maybe_clone_body): Likewise. java/ * java-tree.h (DECL_ESTIMATED_INSNS): Remove. From-SVN: r70174
2003-08-05 16:11:53 +02:00
bool tree_inlinable_function_p (tree);
tree copy_tree_r (tree *, int *, void *);
void clone_body (tree, tree, void *);
cgraph.h (cgraph_node): Add 'lowered' state. * cgraph.h (cgraph_node): Add 'lowered' state. (cgraph_lower_function): Declare. * cgraphunit.c (cgraph_finalize_function): Initialize lowered flag. (cgraph_lower_function): New function. (cgraph_create_edges): Deal with lowered function bodies. (verify_cgraph_node): Likewise. (cgraph_analyze_function): Do lowering job. (cgraph_build_static_cdtor): Likewise. * function.h (struct function): Add saved_eh and saved_cfg. * integrate.c (copy_decl_for_inlining): Kill LABEL_DECL_UID field. * tree-cfg.c (fold_cond_expr_cond): Export. * tree-flow.h (fold_cond_expr_cond): Declare. * tree-inline.c: Include basic-block, ggc, tree-flow, except.h and pointer-set. (struct_inline_data): Kill fnd, first_inlined_fn, ret_label, in_target_cleanup_p, tree_pruner, tsi; add callee, caller and callee_cfun, block, eh_region, eh_region_offset. (inlining_p): New predicate. (remap_decl): Update for new inline_data; declare newly created inline vars in low gimple way. (copy_body_r): Update for new datastructure, simplify some of handling when we are in gimple; remap LABEL_DECLs for EH; copy TREE_BLOCK; deal with RESX_EXPRs. (copy_bb): New. (copy_edges_for_bb): Likewise. (remap_decl_1): New. (copy_cfg_body): New. (copy_generic_body): Rewrite to work on low gimple. (copy_body): Turn into simple wrapper around copy_cfg_body. (setup_one_parameter): Insert new statements into given basic block. (initialize_initialized_parameters): Likewise, reorganize way things are gimplified. (declare_return_variable): Update for new inline data datastructure. (inline_forbidden_p): Work on low gimple. (estimate_num_insns): Likewise. (expand_call_inline): Work on CFG. (push_cfun, pop_cfun): New functions. (cfun_stack): New stack. (add_lexical_block): New function. (gimple_expand_calls_inline): Work on basic block. (optimize_inline_calls): Likewise. (clone_body, save_body, unsave_ewpr_now): Update for new datastructures. (declare_inline_vars): Work on block instead of bind_expr. (inlining_p): New predicate. * tree-inline.h (push_cfun, pop_cfun): Declare. * tree-optimize.c: Include except.h (all_lowering_passes): New variable. (execute_fixup_cfg, pass_fixup_cfg): New pass. (init_tree_optimization_passes): Move some to all_lowering_passes. (tree_lowering_passes): New function. (tree_rest_of_compilation): Register cfg hooks; save/unsave eh. Co-Authored-By: Dale Johannesen <dalej@apple.com> Co-Authored-By: Jan Hubicka <jh@suse.cz> Co-Authored-By: Stuart Hastings <stuart@apple.com> From-SVN: r99840
2005-05-17 18:56:32 +02:00
void save_body (tree, tree *, tree *);
int estimate_move_cost (tree type);
tree-ssa-loop-unswitch.c: Include tree-inline.h. * tree-ssa-loop-unswitch.c: Include tree-inline.h. (tree_unswitch_single_loop): Pass eni_size_weights to tree_num_loop_insns. * tree-ssa-loop-manip.c: Include tree-inline.h. (can_unroll_loop_p): Pass eni_size_weights to tree_num_loop_insns. * tree-ssa-loop-ch.c (should_duplicate_loop_header_p): Pass eni_size_weights to estimate_num_insns. * tree.h (init_inline_once): Export. * toplev.c (backend_init): Call init_inline_once. * cgraphunit.c (cgraph_process_new_functions, cgraph_analyze_function): Pass eni_inlining_weights to estimate_num_insns. * ipa-inline.c (compute_inline_parameters): Ditto. * tree-ssa-loop-ivcanon.c (tree_num_loop_insns): Pass weights to estimate_num_insns. (try_unroll_loop_completely): Pass eni_size_weights to tree_num_loop_insns. * tree-eh.c (decide_copy_try_finally): Pass eni_size_weights ot estimate_num_insns. * tree-ssa-loop-prefetch.c: Include tree-inline.h. (loop_prefetch_arrays): Pass eni_time_weights to tree_num_loop_insns. * tree-inline.c (eni_inlining_weights, eni_size_weights, eni_time_weights): New variables. (init_inline_once): Initialize them. (struct eni_data): Mew. (estimate_num_insns_1, estimate_num_insns): Use weights. * tree-inline.h (struct eni_weights_d): New. (eni_inlining_weights, eni_size_weights, eni_time_weights): Declare. (estimate_num_insns): Declaration changed. * cfgloop.h (tree_num_loop_insns): Declaration changed. * Makefile.in (tree-ssa-loop-unswitch.o, tree-ssa-loop-prefetch.o, tree-ssa-loop-manip.o): Add TREE_INLINE_H dependency. * gcc.dg/tree-ssa/loop-23.c: New test. From-SVN: r121260
2007-01-28 18:40:38 +01:00
int estimate_num_insns (tree expr, eni_weights *);
bool tree_versionable_function_p (tree);
void tree_function_versioning (tree, tree, varray_type, bool);
extern tree remap_decl (tree decl, copy_body_data *id);
extern tree remap_type (tree type, copy_body_data *id);
extern HOST_WIDE_INT estimated_stack_frame_size (void);
/* 0 if we should not perform inlining.
1 if we should expand functions calls inline at the tree level.
2 if we should consider *all* functions to be inline
candidates. */
extern int flag_inline_trees;
#endif /* GCC_TREE_INLINE_H */