Commit 9ff420f1 by Paolo Bonzini Committed by Paolo Bonzini

tree-inline.c (copy_generic_body, [...]): Export.

2007-03-09  Paolo Bonzini  <bonzini@gnu.org>

	* tree-inline.c (copy_generic_body, copy_decl_no_change): Export.
	(remap_block): Call id->transform_lang_insert_block instead
	of langhook.
	(optimize_inline_calls, unsave_expr_now, tree_function_versioning):
	Set id.transform_lang_insert_block to NULL.
	(clone_body): Move to cp/optimize.c
	* tree-inline.h (struct copy_body_data): Change
	transform_lang_insert_block to function pointer.
	(copy_generic_body, copy_decl_no_change): Export.
	* langhooks.h (struct lang_hooks_for_decls): Kill insert_block.
	* langhooks-def.h (LANG_HOOKS_INSERT_BLOCK): Kill.
	(LANG_HOOKS_DECLS): Remove LANG_HOOKS_INSERT_BLOCK.

	* c-tree.h (insert_block): Kill.
	* c-decl.c (insert_block): Kill.

cp:
2007-03-09  Paolo Bonzini  <bonzini@gnu.org>

	* optimize.c (clone_body): New, from tree-inline.c.

ada:
2007-03-09  Paolo Bonzini  <bonzini@gnu.org>

	* gigi.h (insert_block): Kill.
	* utils.c (insert_block): Kill.

java:
2007-03-09  Paolo Bonzini  <bonzini@gnu.org>

	* java-tree.h (insert_block): Kill.
	* decl.c (insert_block): Kill.

fortran:
2007-03-09  Paolo Bonzini  <bonzini@gnu.org>

	* f95-lang.c (insert_block): Kill.

From-SVN: r133861
parent d2784db4
2008-04-03 Paolo Bonzini <bonzini@gnu.org> 2008-04-03 Paolo Bonzini <bonzini@gnu.org>
* tree-inline.c (copy_generic_body, copy_decl_no_change): Export.
(remap_block): Call id->transform_lang_insert_block instead
of langhook.
(optimize_inline_calls, unsave_expr_now, tree_function_versioning):
Set id.transform_lang_insert_block to NULL.
(clone_body): Move to cp/optimize.c
* tree-inline.h (struct copy_body_data): Change
transform_lang_insert_block to function pointer.
(copy_generic_body, copy_decl_no_change): Export.
* langhooks.h (struct lang_hooks_for_decls): Kill insert_block.
* langhooks-def.h (LANG_HOOKS_INSERT_BLOCK): Kill.
(LANG_HOOKS_DECLS): Remove LANG_HOOKS_INSERT_BLOCK.
* c-tree.h (insert_block): Kill.
* c-decl.c (insert_block): Kill.
2008-04-03 Paolo Bonzini <bonzini@gnu.org>
* c-objc-common.h (LANG_HOOKS_FUNCTION_ENTER_NESTED, * c-objc-common.h (LANG_HOOKS_FUNCTION_ENTER_NESTED,
LANG_HOOKS_FUNCTION_LEAVE_NESTED): Delete. LANG_HOOKS_FUNCTION_LEAVE_NESTED): Delete.
* c-tree.h (c_push_function_context, c_pop_function_context): Remove * c-tree.h (c_push_function_context, c_pop_function_context): Remove
......
2008-04-03 Paolo Bonzini <bonzini@gnu.org>
* gigi.h (insert_block): Kill.
* utils.c (insert_block): Kill.
2008-04-02 Eric Botcazou <ebotcazou@adacore.com> 2008-04-02 Eric Botcazou <ebotcazou@adacore.com>
* decl.c (gnat_to_gnu_entity) <object>: For a constant object whose * decl.c (gnat_to_gnu_entity) <object>: For a constant object whose
...@@ -442,11 +442,6 @@ extern void set_block_jmpbuf_decl (tree decl); ...@@ -442,11 +442,6 @@ extern void set_block_jmpbuf_decl (tree decl);
/* Get the setjmp_decl, if any, for the current binding level. */ /* Get the setjmp_decl, if any, for the current binding level. */
extern tree get_block_jmpbuf_decl (void); extern tree get_block_jmpbuf_decl (void);
/* Insert BLOCK at the end of the list of subblocks of the
current binding level. This is used when a BIND_EXPR is expanded,
to handle the BLOCK node inside the BIND_EXPR. */
extern void insert_block (tree block);
/* Records a ..._DECL node DECL as belonging to the current lexical scope /* Records a ..._DECL node DECL as belonging to the current lexical scope
and uses GNAT_NODE for location information. */ and uses GNAT_NODE for location information. */
extern void gnat_pushdecl (tree decl, Node_Id gnat_node); extern void gnat_pushdecl (tree decl, Node_Id gnat_node);
......
...@@ -382,17 +382,6 @@ gnat_poplevel () ...@@ -382,17 +382,6 @@ gnat_poplevel ()
free_binding_level = level; free_binding_level = level;
} }
/* Insert BLOCK at the end of the list of subblocks of the
current binding level. This is used when a BIND_EXPR is expanded,
to handle the BLOCK node inside the BIND_EXPR. */
void
insert_block (tree block)
{
TREE_USED (block) = 1;
TREE_CHAIN (block) = BLOCK_SUBBLOCKS (current_binding_level->block);
BLOCK_SUBBLOCKS (current_binding_level->block) = block;
}
/* Records a ..._DECL node DECL as belonging to the current lexical scope /* Records a ..._DECL node DECL as belonging to the current lexical scope
and uses GNAT_NODE for location information and propagating flags. */ and uses GNAT_NODE for location information and propagating flags. */
......
...@@ -931,16 +931,6 @@ pop_file_scope (void) ...@@ -931,16 +931,6 @@ pop_file_scope (void)
cgraph_finalize_compilation_unit (); cgraph_finalize_compilation_unit ();
} }
/* Insert BLOCK at the end of the list of subblocks of the current
scope. This is used when a BIND_EXPR is expanded, to handle the
BLOCK node inside the BIND_EXPR. */
void
insert_block (tree block)
{
TREE_USED (block) = 1;
SCOPE_LIST_APPEND (current_scope, blocks, block);
}
/* Push a definition or a declaration of struct, union or enum tag "name". /* Push a definition or a declaration of struct, union or enum tag "name".
"type" should be the type node. "type" should be the type node.
......
...@@ -455,7 +455,6 @@ extern tree c_cont_label; ...@@ -455,7 +455,6 @@ extern tree c_cont_label;
extern int global_bindings_p (void); extern int global_bindings_p (void);
extern void push_scope (void); extern void push_scope (void);
extern tree pop_scope (void); extern tree pop_scope (void);
extern void insert_block (tree);
extern void c_init_decl_processing (void); extern void c_init_decl_processing (void);
extern void c_dup_lang_specific_decl (tree); extern void c_dup_lang_specific_decl (tree);
......
2008-04-03 Paolo Bonzini <bonzini@gnu.org> 2008-04-03 Paolo Bonzini <bonzini@gnu.org>
* optimize.c (clone_body): New, from tree-inline.c.
2008-04-03 Paolo Bonzini <bonzini@gnu.org>
* method.c (synthesize_method): Use {push,pop}_function_context. * method.c (synthesize_method): Use {push,pop}_function_context.
* name-lookup.c (push_to_top_level): Likewise. * name-lookup.c (push_to_top_level): Likewise.
......
...@@ -72,6 +72,37 @@ update_cloned_parm (tree parm, tree cloned_parm, bool first) ...@@ -72,6 +72,37 @@ update_cloned_parm (tree parm, tree cloned_parm, bool first)
DECL_GIMPLE_REG_P (cloned_parm) = DECL_GIMPLE_REG_P (parm); DECL_GIMPLE_REG_P (cloned_parm) = DECL_GIMPLE_REG_P (parm);
} }
/* FN is a function that has a complete body, and CLONE is a function whose
body is to be set to a copy of FN, mapping argument declarations according
to the ARG_MAP splay_tree. */
static void
clone_body (tree clone, tree fn, void *arg_map)
{
copy_body_data id;
/* Clone the body, as if we were making an inline call. But, remap the
parameters in the callee to the parameters of caller. */
memset (&id, 0, sizeof (id));
id.src_fn = fn;
id.dst_fn = clone;
id.src_cfun = DECL_STRUCT_FUNCTION (fn);
id.decl_map = (struct pointer_map_t *)arg_map;
id.copy_decl = copy_decl_no_change;
id.transform_call_graph_edges = CB_CGE_DUPLICATE;
id.transform_new_cfg = true;
id.transform_return_to_modify = false;
id.transform_lang_insert_block = insert_block;
/* We're not inside any EH region. */
id.eh_region = -1;
/* Actually copy the body. */
append_to_statement_list_force (copy_generic_body (&id),
&DECL_SAVED_TREE (clone));
}
/* FN is a function that has a complete body. Clone the body as /* FN is a function that has a complete body. Clone the body as
necessary. Returns nonzero if there's no longer any need to necessary. Returns nonzero if there's no longer any need to
process the main body. */ process the main body. */
......
2008-04-03 Paolo Bonzini <bonzini@gnu.org>
* f95-lang.c (insert_block): Kill.
2008-04-01 George Helffrich <george@gcc.gnu.org> 2008-04-01 George Helffrich <george@gcc.gnu.org>
* trans-common.c (create_common): Add decl to function * trans-common.c (create_common): Add decl to function
......
...@@ -95,7 +95,6 @@ static void gfc_print_identifier (FILE *, tree, int); ...@@ -95,7 +95,6 @@ static void gfc_print_identifier (FILE *, tree, int);
static bool gfc_mark_addressable (tree); static bool gfc_mark_addressable (tree);
void do_function_end (void); void do_function_end (void);
int global_bindings_p (void); int global_bindings_p (void);
void insert_block (tree);
static void clear_binding_stack (void); static void clear_binding_stack (void);
static void gfc_be_parse_file (int); static void gfc_be_parse_file (int);
static alias_set_type gfc_get_alias_set (tree); static alias_set_type gfc_get_alias_set (tree);
...@@ -473,19 +472,6 @@ poplevel (int keep, int reverse, int functionbody) ...@@ -473,19 +472,6 @@ poplevel (int keep, int reverse, int functionbody)
} }
/* Insert BLOCK at the end of the list of subblocks of the
current binding level. This is used when a BIND_EXPR is expanded,
to handle the BLOCK node inside the BIND_EXPR. */
void
insert_block (tree block)
{
TREE_USED (block) = 1;
current_binding_level->blocks
= chainon (current_binding_level->blocks, block);
}
/* Records a ..._DECL node DECL as belonging to the current lexical scope. /* Records a ..._DECL node DECL as belonging to the current lexical scope.
Returns the ..._DECL node. */ Returns the ..._DECL node. */
......
2008-04-03 Paolo Bonzini <bonzini@gnu.org>
* java-tree.h (insert_block): Kill.
* decl.c (insert_block): Kill.
2008-04-01 Joseph Myers <joseph@codesourcery.com> 2008-04-01 Joseph Myers <joseph@codesourcery.com>
* gcj.texi: Include gpl_v3.texi instead of gpl.texi * gcj.texi: Include gpl_v3.texi instead of gpl.texi
......
...@@ -1581,18 +1581,6 @@ force_poplevels (int start_pc) ...@@ -1581,18 +1581,6 @@ force_poplevels (int start_pc)
} }
} }
/* Insert BLOCK at the end of the list of subblocks of the
current binding level. This is used when a BIND_EXPR is expanded,
to handle the BLOCK node inside the BIND_EXPR. */
void
insert_block (tree block)
{
TREE_USED (block) = 1;
current_binding_level->blocks
= chainon (current_binding_level->blocks, block);
}
/* integrate_decl_tree calls this function. */ /* integrate_decl_tree calls this function. */
void void
......
...@@ -1051,7 +1051,6 @@ extern int global_bindings_p (void); ...@@ -1051,7 +1051,6 @@ extern int global_bindings_p (void);
extern tree getdecls (void); extern tree getdecls (void);
extern void pushlevel (int); extern void pushlevel (int);
extern tree poplevel (int,int, int); extern tree poplevel (int,int, int);
extern void insert_block (tree);
extern tree pushdecl (tree); extern tree pushdecl (tree);
extern void java_init_decl_processing (void); extern void java_init_decl_processing (void);
extern void java_dup_lang_specific_decl (tree); extern void java_dup_lang_specific_decl (tree);
......
...@@ -196,7 +196,6 @@ extern tree lhd_make_node (enum tree_code); ...@@ -196,7 +196,6 @@ extern tree lhd_make_node (enum tree_code);
/* Declaration hooks. */ /* Declaration hooks. */
#define LANG_HOOKS_GLOBAL_BINDINGS_P global_bindings_p #define LANG_HOOKS_GLOBAL_BINDINGS_P global_bindings_p
#define LANG_HOOKS_INSERT_BLOCK insert_block
#define LANG_HOOKS_PUSHDECL pushdecl #define LANG_HOOKS_PUSHDECL pushdecl
#define LANG_HOOKS_GETDECLS getdecls #define LANG_HOOKS_GETDECLS getdecls
#define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL lhd_warn_unused_global_decl #define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL lhd_warn_unused_global_decl
...@@ -214,7 +213,6 @@ extern tree lhd_make_node (enum tree_code); ...@@ -214,7 +213,6 @@ extern tree lhd_make_node (enum tree_code);
#define LANG_HOOKS_DECLS { \ #define LANG_HOOKS_DECLS { \
LANG_HOOKS_GLOBAL_BINDINGS_P, \ LANG_HOOKS_GLOBAL_BINDINGS_P, \
LANG_HOOKS_INSERT_BLOCK, \
LANG_HOOKS_PUSHDECL, \ LANG_HOOKS_PUSHDECL, \
LANG_HOOKS_GETDECLS, \ LANG_HOOKS_GETDECLS, \
LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL, \ LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL, \
......
...@@ -158,11 +158,6 @@ struct lang_hooks_for_decls ...@@ -158,11 +158,6 @@ struct lang_hooks_for_decls
returns -1 for an undocumented reason used in stor-layout.c. */ returns -1 for an undocumented reason used in stor-layout.c. */
int (*global_bindings_p) (void); int (*global_bindings_p) (void);
/* Insert BLOCK at the end of the list of subblocks of the
current binding level. This is used when a BIND_EXPR is expanded,
to handle the BLOCK node inside the BIND_EXPR. */
void (*insert_block) (tree);
/* Function to add a decl to the current scope level. Takes one /* Function to add a decl to the current scope level. Takes one
argument, a decl to add. Returns that decl, or, if the same argument, a decl to add. Returns that decl, or, if the same
symbol is already declared, may return a different decl for that symbol is already declared, may return a different decl for that
......
...@@ -127,7 +127,6 @@ eni_weights eni_time_weights; ...@@ -127,7 +127,6 @@ eni_weights eni_time_weights;
/* Prototypes. */ /* Prototypes. */
static tree declare_return_variable (copy_body_data *, tree, tree, tree *); static tree declare_return_variable (copy_body_data *, tree, tree, tree *);
static tree copy_generic_body (copy_body_data *);
static bool inlinable_function_p (tree); static bool inlinable_function_p (tree);
static void remap_block (tree *, copy_body_data *); static void remap_block (tree *, copy_body_data *);
static tree remap_decls (tree, copy_body_data *); static tree remap_decls (tree, copy_body_data *);
...@@ -140,7 +139,6 @@ static void remap_save_expr (tree *, void *, int *); ...@@ -140,7 +139,6 @@ static void remap_save_expr (tree *, void *, int *);
static void add_lexical_block (tree current_block, tree new_block); static void add_lexical_block (tree current_block, tree new_block);
static tree copy_decl_to_var (tree, copy_body_data *); static tree copy_decl_to_var (tree, copy_body_data *);
static tree copy_result_decl_to_var (tree, copy_body_data *); static tree copy_result_decl_to_var (tree, copy_body_data *);
static tree copy_decl_no_change (tree, copy_body_data *);
static tree copy_decl_maybe_to_var (tree, copy_body_data *); static tree copy_decl_maybe_to_var (tree, copy_body_data *);
/* Insert a tree->tree mapping for ID. Despite the name suggests /* Insert a tree->tree mapping for ID. Despite the name suggests
...@@ -498,7 +496,7 @@ remap_block (tree *block, copy_body_data *id) ...@@ -498,7 +496,7 @@ remap_block (tree *block, copy_body_data *id)
fn = id->dst_fn; fn = id->dst_fn;
if (id->transform_lang_insert_block) if (id->transform_lang_insert_block)
lang_hooks.decls.insert_block (new_block); id->transform_lang_insert_block (new_block);
/* Remember the remapped block. */ /* Remember the remapped block. */
insert_decl_map (id, old_block, new_block); insert_decl_map (id, old_block, new_block);
...@@ -1394,7 +1392,7 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency, ...@@ -1394,7 +1392,7 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency,
/* Make a copy of the body of FN so that it can be inserted inline in /* Make a copy of the body of FN so that it can be inserted inline in
another function. */ another function. */
static tree tree
copy_generic_body (copy_body_data *id) copy_generic_body (copy_body_data *id)
{ {
tree body; tree body;
...@@ -3024,7 +3022,7 @@ optimize_inline_calls (tree fn) ...@@ -3024,7 +3022,7 @@ optimize_inline_calls (tree fn)
id.transform_call_graph_edges = CB_CGE_DUPLICATE; id.transform_call_graph_edges = CB_CGE_DUPLICATE;
id.transform_new_cfg = false; id.transform_new_cfg = false;
id.transform_return_to_modify = true; id.transform_return_to_modify = true;
id.transform_lang_insert_block = false; id.transform_lang_insert_block = NULL;
id.statements_to_fold = pointer_set_create (); id.statements_to_fold = pointer_set_create ();
push_gimplify_context (); push_gimplify_context ();
...@@ -3079,36 +3077,6 @@ optimize_inline_calls (tree fn) ...@@ -3079,36 +3077,6 @@ optimize_inline_calls (tree fn)
| (profile_status != PROFILE_ABSENT ? TODO_rebuild_frequencies : 0)); | (profile_status != PROFILE_ABSENT ? TODO_rebuild_frequencies : 0));
} }
/* FN is a function that has a complete body, and CLONE is a function whose
body is to be set to a copy of FN, mapping argument declarations according
to the ARG_MAP splay_tree. */
void
clone_body (tree clone, tree fn, void *arg_map)
{
copy_body_data id;
/* Clone the body, as if we were making an inline call. But, remap the
parameters in the callee to the parameters of caller. */
memset (&id, 0, sizeof (id));
id.src_fn = fn;
id.dst_fn = clone;
id.src_cfun = DECL_STRUCT_FUNCTION (fn);
id.decl_map = (struct pointer_map_t *)arg_map;
id.copy_decl = copy_decl_no_change;
id.transform_call_graph_edges = CB_CGE_DUPLICATE;
id.transform_new_cfg = true;
id.transform_return_to_modify = false;
id.transform_lang_insert_block = true;
/* We're not inside any EH region. */
id.eh_region = -1;
/* Actually copy the body. */
append_to_statement_list_force (copy_generic_body (&id), &DECL_SAVED_TREE (clone));
}
/* Passed to walk_tree. Copies the node pointed to, if appropriate. */ /* Passed to walk_tree. Copies the node pointed to, if appropriate. */
tree tree
...@@ -3329,7 +3297,7 @@ unsave_expr_now (tree expr) ...@@ -3329,7 +3297,7 @@ unsave_expr_now (tree expr)
id.transform_call_graph_edges = CB_CGE_DUPLICATE; id.transform_call_graph_edges = CB_CGE_DUPLICATE;
id.transform_new_cfg = false; id.transform_new_cfg = false;
id.transform_return_to_modify = false; id.transform_return_to_modify = false;
id.transform_lang_insert_block = false; id.transform_lang_insert_block = NULL;
/* Walk the tree once to find local labels. */ /* Walk the tree once to find local labels. */
walk_tree_without_duplicates (&expr, mark_local_for_remap_r, &id); walk_tree_without_duplicates (&expr, mark_local_for_remap_r, &id);
...@@ -3475,7 +3443,7 @@ copy_result_decl_to_var (tree decl, copy_body_data *id) ...@@ -3475,7 +3443,7 @@ copy_result_decl_to_var (tree decl, copy_body_data *id)
} }
static tree tree
copy_decl_no_change (tree decl, copy_body_data *id) copy_decl_no_change (tree decl, copy_body_data *id)
{ {
tree copy; tree copy;
...@@ -3611,7 +3579,7 @@ tree_function_versioning (tree old_decl, tree new_decl, varray_type tree_map, ...@@ -3611,7 +3579,7 @@ tree_function_versioning (tree old_decl, tree new_decl, varray_type tree_map,
= update_clones ? CB_CGE_MOVE_CLONES : CB_CGE_MOVE; = update_clones ? CB_CGE_MOVE_CLONES : CB_CGE_MOVE;
id.transform_new_cfg = true; id.transform_new_cfg = true;
id.transform_return_to_modify = false; id.transform_return_to_modify = false;
id.transform_lang_insert_block = false; id.transform_lang_insert_block = NULL;
current_function_decl = new_decl; current_function_decl = new_decl;
old_entry_block = ENTRY_BLOCK_PTR_FOR_FUNCTION old_entry_block = ENTRY_BLOCK_PTR_FOR_FUNCTION
......
...@@ -88,16 +88,15 @@ typedef struct copy_body_data ...@@ -88,16 +88,15 @@ typedef struct copy_body_data
by manipulating the CFG rather than a statement. */ by manipulating the CFG rather than a statement. */
bool transform_return_to_modify; bool transform_return_to_modify;
/* True if lang_hooks.decls.insert_block should be invoked when
duplicating BLOCK nodes. */
bool transform_lang_insert_block;
/* True if this statement will need to be regimplified. */ /* True if this statement will need to be regimplified. */
bool regimplify; bool regimplify;
/* > 0 if we are remapping a type currently. */ /* > 0 if we are remapping a type currently. */
int remapping_type_depth; int remapping_type_depth;
/* A function to be called when duplicating BLOCK nodes. */
void (*transform_lang_insert_block) (tree);
/* Statements that might be possibly folded. */ /* Statements that might be possibly folded. */
struct pointer_set_t *statements_to_fold; struct pointer_set_t *statements_to_fold;
...@@ -144,7 +143,8 @@ extern void insert_decl_map (copy_body_data *, tree, tree); ...@@ -144,7 +143,8 @@ extern void insert_decl_map (copy_body_data *, tree, tree);
unsigned int optimize_inline_calls (tree); unsigned int optimize_inline_calls (tree);
bool tree_inlinable_function_p (tree); bool tree_inlinable_function_p (tree);
tree copy_tree_r (tree *, int *, void *); tree copy_tree_r (tree *, int *, void *);
void clone_body (tree, tree, void *); tree copy_generic_body (copy_body_data *id);
tree copy_decl_no_change (tree decl, copy_body_data *id);
void save_body (tree, tree *, tree *); void save_body (tree, tree *, tree *);
int estimate_move_cost (tree type); int estimate_move_cost (tree type);
int estimate_num_insns (tree expr, eni_weights *); int estimate_num_insns (tree expr, eni_weights *);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment