Re: [PATCH] More code refactoring

2012-04-13 Thread Jan Hubicka
 
 Eventually I'll succeed in making tree-optimize.c empty.  At least
 the pass stuff I'm interested in get's better now.

Decompozing tree-optimize was on my wishlist, too.
 
 Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
 
 Richard.
 
 2012-04-12  Richard Guenther  rguent...@suse.de
 
   * Makefile.in (cgraphunit.o): Add $(EXCEPT_H) dependency.
   * cgraph.h (tree_rest_of_compilation): Remove.
   * cgraph.c (cgraph_add_new_function): Move ...
   * cgraphunit.c (cgraph_add_new_function): ... here.
   (tree_rest_of_compilation): Make static.
   (cgraph_expand_function): Do not set cgraph_function_flags_ready.

We could try keep in mind that cgraphunit.c is a historical mess and should
be also dismantled ;)
Majority of logic should go into symbol table (I have symtab.c for that),
cgraphbuild or pass management.

Honza


[PATCH] More code refactoring

2012-04-12 Thread Richard Guenther

Eventually I'll succeed in making tree-optimize.c empty.  At least
the pass stuff I'm interested in get's better now.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2012-04-12  Richard Guenther  rguent...@suse.de

* Makefile.in (cgraphunit.o): Add $(EXCEPT_H) dependency.
* cgraph.h (tree_rest_of_compilation): Remove.
* cgraph.c (cgraph_add_new_function): Move ...
* cgraphunit.c (cgraph_add_new_function): ... here.
(tree_rest_of_compilation): Make static.
(cgraph_expand_function): Do not set cgraph_function_flags_ready.
* tree-optimize.c (gate_all_optimizations, pass_all_optimizations,
gate_all_early_local_passes, execute_all_early_local_passes,
pass_early_local_passes, gate_all_early_optimizations,
pass_all_early_optimizations): Move ...
* passes.c (gate_all_optimizations, pass_all_optimizations,
gate_all_early_local_passes, execute_all_early_local_passes,
pass_early_local_passes, gate_all_early_optimizations,
pass_all_early_optimizations): ... here.
* tree-optimize.c (execute_free_datastructures): Remove.
* tree-flow.h (execute_free_datastructures): Remove.
* tree-optimize.c (execute_init_datastructures,
pass_init_datastructures): Move ...
* tree-ssa.c (execute_init_datastructures,
pass_init_datastructures): ... here.
* cfgexpand.c (gimple_expand_cfg): Inline-expand call to
execute_free_datastructures.

Index: gcc/Makefile.in
===
*** gcc/Makefile.in.orig2012-04-12 14:05:23.0 +0200
--- gcc/Makefile.in 2012-04-12 14:05:51.274596925 +0200
*** cgraphunit.o : cgraphunit.c $(CONFIG_H)
*** 2922,2928 
 $(FIBHEAP_H) output.h $(PARAMS_H) $(RTL_H) $(TIMEVAR_H) $(IPA_PROP_H) \
 gt-cgraphunit.h tree-iterator.h $(COVERAGE_H) $(TREE_DUMP_H) \
 tree-pretty-print.h gimple-pretty-print.h ipa-inline.h $(IPA_UTILS_H) \
!$(LTO_STREAMER_H) output.h $(REGSET_H)
  cgraphbuild.o : cgraphbuild.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
 $(TREE_H) langhooks.h $(CGRAPH_H) intl.h pointer-set.h $(GIMPLE_H) \
 $(TREE_FLOW_H) $(TREE_PASS_H) $(IPA_UTILS_H) $(EXCEPT_H) \
--- 2922,2928 
 $(FIBHEAP_H) output.h $(PARAMS_H) $(RTL_H) $(TIMEVAR_H) $(IPA_PROP_H) \
 gt-cgraphunit.h tree-iterator.h $(COVERAGE_H) $(TREE_DUMP_H) \
 tree-pretty-print.h gimple-pretty-print.h ipa-inline.h $(IPA_UTILS_H) \
!$(LTO_STREAMER_H) output.h $(REGSET_H) $(EXCEPT_H)
  cgraphbuild.o : cgraphbuild.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
 $(TREE_H) langhooks.h $(CGRAPH_H) intl.h pointer-set.h $(GIMPLE_H) \
 $(TREE_FLOW_H) $(TREE_PASS_H) $(IPA_UTILS_H) $(EXCEPT_H) \
Index: gcc/cgraph.c
===
*** gcc/cgraph.c.orig   2012-04-12 14:05:23.0 +0200
--- gcc/cgraph.c2012-04-12 14:05:51.276596925 +0200
*** cgraph_function_body_availability (struc
*** 2397,2485 
return avail;
  }
  
- /* Add the function FNDECL to the call graph.
-Unlike cgraph_finalize_function, this function is intended to be used
-by middle end and allows insertion of new function at arbitrary point
-of compilation.  The function can be either in high, low or SSA form
-GIMPLE.
- 
-The function is assumed to be reachable and have address taken (so no
-API breaking optimizations are performed on it).
- 
-Main work done by this function is to enqueue the function for later
-processing to avoid need the passes to be re-entrant.  */
- 
- void
- cgraph_add_new_function (tree fndecl, bool lowered)
- {
-   struct cgraph_node *node;
-   switch (cgraph_state)
- {
-   case CGRAPH_STATE_CONSTRUCTION:
-   /* Just enqueue function to be processed at nearest occurrence.  */
-   node = cgraph_create_node (fndecl);
-   node-next_needed = cgraph_new_nodes;
-   if (lowered)
- node-lowered = true;
-   cgraph_new_nodes = node;
- break;
- 
-   case CGRAPH_STATE_IPA:
-   case CGRAPH_STATE_IPA_SSA:
-   case CGRAPH_STATE_EXPANSION:
-   /* Bring the function into finalized state and enqueue for later
-  analyzing and compilation.  */
-   node = cgraph_get_create_node (fndecl);
-   node-local.local = false;
-   node-local.finalized = true;
-   node-reachable = node-needed = true;
-   if (!lowered  cgraph_state == CGRAPH_STATE_EXPANSION)
- {
-   push_cfun (DECL_STRUCT_FUNCTION (fndecl));
-   current_function_decl = fndecl;
-   gimple_register_cfg_hooks ();
-   bitmap_obstack_initialize (NULL);
-   execute_pass_list (all_lowering_passes);
-   execute_pass_list (pass_early_local_passes.pass.sub);
-   bitmap_obstack_release (NULL);
-   pop_cfun ();
-   current_function_decl =