This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Final basic-block.h flattening patch


Don't let it's size scare you, this is actually fairly trivial now. I split it into the more interesting patch and the big, boring, mechanical one. all-in-all, it touches 351 files :-P.

This patch completely flattens basic-block.h. I manually adjusted some of the remaining .h files and replicated the include list to any source and include files which included those... and so on until full closure was accompllshed. basic-block.h is not included from anything but source files now.

Very few actual tweaks... "enum profile_status_d" and "struct control_flow_graph" were moved from basic-block.h to cfg.h. They are used from very few places and there was a tiny bit of code in cfg.c which allocated the struct. This is also the logical place for it.

symbol_table::create_empty() was moved from cgraph.h to cgraph.c. It uses REG_BR_PROB_BASE which is defined in basic-block.h, and by moving it to the .c file, there is no dependency between basic-block.h and cgraph.h any more.

a few of the gen*.c needed to have the generated file's include list changed a little to still compile properly.

gccplugin.h now includes all the stuff basic-block.h use to. Its still not perfect as the testsuite showed. one of the tests included gcc-plugin.h almost last, so an existing #include "basic-block.h" earlier in the include list broke... Can't help everyone I guess. If gcc-plugin.h is included first, no problem. :-)

I also ran the include file reducer on all the new .h files this patch series introduced (they should be safe since there is no conditional macro stuff in them).. specifically on: predict.h, cfgrtl.h, cfg.h, cfganal.h, lcm.h, cfgbuild.h, cfgcleanup.h, dominance.h, and of course, basic-block.h itself. The only exception is that I didn't try to reduce any config/* files

I have bootstrapped on x86_64-unknown-linux-gnu, run the testsuite with no regressions, and run all the targets in contrib/config-list.mk to catch and #includes the might be required by #ifdef'd code. Hopefully I got them all :-) Im re-running on a fresh checkout over the weekend just to be sure.

Assuming no issues pop up, OK for trunk?

Andrew


	* basic-block.h: Remove all includes.
	(enum profile_status_d, struct control_flow_graph): Move to cfg.h
	* cfg.h (profile_status_d, struct control_flow_graph): Relocate here.
	* Makefile.in (GTFILES): Add cfg.h to list.
	* cgraph.h (symbol_table::create_empty): Move to cgraph.c.
	* cgraph.c (symbol_table::create_empty): Relocate from cgraph.h.
	* genconditions.c (write_header): Add predict.h and basic-block.h to
	lits of includes.
	* genemit.c (main): Ditto.
	* genpreds.c (write_insn_preds_c): Ditto.
	* genrecog.c (write_header): Ditto.
	* gengtype.c (open_base_files): Add predict.h, basic-block.h, and cfg.h
	to list of includes.
	* testsuite/gcc.dg/plugin/ggcplug.c: Shuffle includes to include
	gcc-plugin.h earlier.

Index: basic-block.h
===================================================================
--- basic-block.h	(revision 216559)
+++ basic-block.h	(working copy)
@@ -20,22 +20,6 @@
 #ifndef GCC_BASIC_BLOCK_H
 #define GCC_BASIC_BLOCK_H
 
-#include "predict.h"
-#include "vec.h"
-#include "hashtab.h"
-#include "hash-set.h"
-#include "machmode.h"
-#include "tm.h"
-#include "hard-reg-set.h"
-#include "input.h"
-#include "function.h"
-#include "cfgrtl.h"
-#include "cfg.h"
-#include "cfganal.h"
-#include "lcm.h"
-#include "cfgbuild.h"
-#include "cfgcleanup.h"
-#include "dominance.h"
 
 /* Use gcov_type to hold basic block counters.  Should be at least
    64bit.  Although a counter cannot be negative, we use a signed
@@ -220,57 +204,6 @@
 #define BB_COPY_PARTITION(dstbb, srcbb) \
   BB_SET_PARTITION (dstbb, BB_PARTITION (srcbb))
 
-/* What sort of profiling information we have.  */
-enum profile_status_d
-{
-  PROFILE_ABSENT,
-  PROFILE_GUESSED,
-  PROFILE_READ,
-  PROFILE_LAST	/* Last value, used by profile streaming.  */
-};
-
-/* A structure to group all the per-function control flow graph data.
-   The x_* prefixing is necessary because otherwise references to the
-   fields of this struct are interpreted as the defines for backward
-   source compatibility following the definition of this struct.  */
-struct GTY(()) control_flow_graph {
-  /* Block pointers for the exit and entry of a function.
-     These are always the head and tail of the basic block list.  */
-  basic_block x_entry_block_ptr;
-  basic_block x_exit_block_ptr;
-
-  /* Index by basic block number, get basic block struct info.  */
-  vec<basic_block, va_gc> *x_basic_block_info;
-
-  /* Number of basic blocks in this flow graph.  */
-  int x_n_basic_blocks;
-
-  /* Number of edges in this flow graph.  */
-  int x_n_edges;
-
-  /* The first free basic block number.  */
-  int x_last_basic_block;
-
-  /* UIDs for LABEL_DECLs.  */
-  int last_label_uid;
-
-  /* Mapping of labels to their associated blocks.  At present
-     only used for the gimple CFG.  */
-  vec<basic_block, va_gc> *x_label_to_block_map;
-
-  enum profile_status_d x_profile_status;
-
-  /* Whether the dominators and the postdominators are available.  */
-  enum dom_state x_dom_computed[2];
-
-  /* Number of basic blocks in the dominance tree.  */
-  unsigned x_n_bbs_in_dom_tree[2];
-
-  /* Maximal number of entities in the single jumptable.  Used to estimate
-     final flowgraph size.  */
-  int max_jumptable_ents;
-};
-
 /* Defines for accessing the fields of the CFG structure for function FN.  */
 #define ENTRY_BLOCK_PTR_FOR_FN(FN)	     ((FN)->cfg->x_entry_block_ptr)
 #define EXIT_BLOCK_PTR_FOR_FN(FN)	     ((FN)->cfg->x_exit_block_ptr)
Index: Makefile.in
===================================================================
--- Makefile.in	(revision 216558)
+++ Makefile.in	(working copy)
@@ -2256,7 +2256,7 @@
   $(srcdir)/libfuncs.h $(SYMTAB_H) \
   $(srcdir)/real.h $(srcdir)/function.h $(srcdir)/insn-addr.h $(srcdir)/hwint.h \
   $(srcdir)/fixed-value.h \
-  $(srcdir)/output.h $(srcdir)/cfgloop.h \
+  $(srcdir)/output.h $(srcdir)/cfgloop.h $(srcdir)/cfg.h \
   $(srcdir)/cselib.h $(srcdir)/basic-block.h  $(srcdir)/ipa-ref.h $(srcdir)/cgraph.h \
   $(srcdir)/reload.h $(srcdir)/caller-save.c $(srcdir)/symtab.c \
   $(srcdir)/alias.c $(srcdir)/bitmap.c $(srcdir)/cselib.c $(srcdir)/cgraph.c \
Index: cfg.h
===================================================================
--- cfg.h	(revision 216558)
+++ cfg.h	(working copy)
@@ -20,6 +20,58 @@
 #ifndef GCC_CFG_H
 #define GCC_CFG_H
 
+/* What sort of profiling information we have.  */
+enum profile_status_d
+{
+  PROFILE_ABSENT,
+  PROFILE_GUESSED,
+  PROFILE_READ,
+  PROFILE_LAST	/* Last value, used by profile streaming.  */
+};
+
+/* A structure to group all the per-function control flow graph data.
+   The x_* prefixing is necessary because otherwise references to the
+   fields of this struct are interpreted as the defines for backward
+   source compatibility following the definition of this struct.  */
+struct GTY(()) control_flow_graph {
+  /* Block pointers for the exit and entry of a function.
+     These are always the head and tail of the basic block list.  */
+  basic_block x_entry_block_ptr;
+  basic_block x_exit_block_ptr;
+
+  /* Index by basic block number, get basic block struct info.  */
+  vec<basic_block, va_gc> *x_basic_block_info;
+
+  /* Number of basic blocks in this flow graph.  */
+  int x_n_basic_blocks;
+
+  /* Number of edges in this flow graph.  */
+  int x_n_edges;
+
+  /* The first free basic block number.  */
+  int x_last_basic_block;
+
+  /* UIDs for LABEL_DECLs.  */
+  int last_label_uid;
+
+  /* Mapping of labels to their associated blocks.  At present
+     only used for the gimple CFG.  */
+  vec<basic_block, va_gc> *x_label_to_block_map;
+
+  enum profile_status_d x_profile_status;
+
+  /* Whether the dominators and the postdominators are available.  */
+  enum dom_state x_dom_computed[2];
+
+  /* Number of basic blocks in the dominance tree.  */
+  unsigned x_n_bbs_in_dom_tree[2];
+
+  /* Maximal number of entities in the single jumptable.  Used to estimate
+     final flowgraph size.  */
+  int max_jumptable_ents;
+};
+
+
 extern void init_flow (struct function *);
 extern void clear_edges (void);
 extern basic_block alloc_block (void);
Index: cgraph.c
===================================================================
--- cgraph.c	(revision 216559)
+++ cgraph.c	(working copy)
@@ -39,6 +39,10 @@
 #include "flags.h"
 #include "debug.h"
 #include "target.h"
+#include "predict.h"
+#include "dominance.h"
+#include "cfg.h"
+#include "basic-block.h"
 #include "cgraph.h"
 #include "intl.h"
 #include "tree-ssa-alias.h"
@@ -239,6 +243,21 @@
   after->prev = before;
 }
 
+/* Allocate new callgraph node and insert it into basic data structures.  */
+
+cgraph_node *
+symbol_table::create_empty (void)
+{
+  cgraph_node *node = allocate_cgraph_symbol ();
+
+  node->type = SYMTAB_FUNCTION;
+  node->frequency = NODE_FREQUENCY_NORMAL;
+  node->count_materialization_scale = REG_BR_PROB_BASE;
+  cgraph_count++;
+
+  return node;
+}
+
 /* Register HOOK to be called with DATA on each removed edge.  */
 cgraph_edge_hook_list *
 symbol_table::add_edge_removal_hook (cgraph_edge_hook hook, void *data)
Index: cgraph.h
===================================================================
--- cgraph.h	(revision 216559)
+++ cgraph.h	(working copy)
@@ -25,7 +25,6 @@
 #include "is-a.h"
 #include "plugin-api.h"
 #include "vec.h"
-#include "basic-block.h"
 #include "hashtab.h"
 #include "hash-set.h"
 #include "machmode.h"
@@ -2278,21 +2277,6 @@
   node->previous = NULL;
 }
 
-/* Allocate new callgraph node and insert it into basic data structures.  */
-
-inline cgraph_node *
-symbol_table::create_empty (void)
-{
-  cgraph_node *node = allocate_cgraph_symbol ();
-
-  node->type = SYMTAB_FUNCTION;
-  node->frequency = NODE_FREQUENCY_NORMAL;
-  node->count_materialization_scale = REG_BR_PROB_BASE;
-  cgraph_count++;
-
-  return node;
-}
-
 /* Release a callgraph NODE with UID and put in to the list of free nodes.  */
 
 inline void
Index: genconditions.c
===================================================================
--- genconditions.c	(revision 216558)
+++ genconditions.c	(working copy)
@@ -88,6 +88,8 @@
 #include \"output.h\"\n\
 #include \"flags.h\"\n\
 #include \"hard-reg-set.h\"\n\
+#include \"predict.h\"\n\
+#include \"basic-block.h\"\n\
 #include \"resource.h\"\n\
 #include \"diagnostic-core.h\"\n\
 #include \"reload.h\"\n\
Index: genemit.c
===================================================================
--- genemit.c	(revision 216558)
+++ genemit.c	(working copy)
@@ -815,6 +815,8 @@
   printf ("#include \"output.h\"\n");
   printf ("#include \"insn-config.h\"\n");
   printf ("#include \"recog.h\"\n");
+  printf ("#include \"predict.h\"\n");
+  printf ("#include \"basic-block.h\"\n");
   printf ("#include \"resource.h\"\n");
   printf ("#include \"reload.h\"\n");
   printf ("#include \"diagnostic-core.h\"\n");
Index: genpreds.c
===================================================================
--- genpreds.c	(revision 216558)
+++ genpreds.c	(working copy)
@@ -1434,6 +1434,8 @@
 #include \"output.h\"\n\
 #include \"flags.h\"\n\
 #include \"hard-reg-set.h\"\n\
+#include \"predict.h\"\n\
+#include \"basic-block.h\"\n\
 #include \"resource.h\"\n\
 #include \"diagnostic-core.h\"\n\
 #include \"reload.h\"\n\
Index: genrecog.c
===================================================================
--- genrecog.c	(revision 216558)
+++ genrecog.c	(working copy)
@@ -2317,6 +2317,8 @@
 #include \"output.h\"\n\
 #include \"flags.h\"\n\
 #include \"hard-reg-set.h\"\n\
+#include \"predict.h\"\n\
+#include \"basic-block.h\"\n\
 #include \"resource.h\"\n\
 #include \"diagnostic-core.h\"\n\
 #include \"reload.h\"\n\
Index: gengtype.c
===================================================================
--- gengtype.c	(revision 216558)
+++ gengtype.c	(working copy)
@@ -1829,11 +1829,11 @@
       "config.h", "system.h", "coretypes.h", "tm.h",
       "hashtab.h", "splay-tree.h", "obstack.h", "bitmap.h", "input.h",
       "tree.h", "rtl.h", "wide-int.h", "hashtab.h", "hash-set.h", "vec.h",
-      "machmode.h", "tm.h", "hard-reg-set.h", "input.h",
+      "machmode.h", "tm.h", "hard-reg-set.h", "input.h", "predict.h",
       "function.h", "insn-config.h", "expr.h",
       "hard-reg-set.h", "basic-block.h", "cselib.h", "insn-addr.h",
       "optabs.h", "libfuncs.h", "debug.h", "ggc.h", "cgraph.h",
-      "hash-table.h", "vec.h", "ggc.h", "basic-block.h",
+      "hash-table.h", "vec.h", "ggc.h", "dominance.h", "cfg.h", "basic-block.h",
       "tree-ssa-alias.h", "internal-fn.h", "gimple-fold.h", "tree-eh.h",
       "gimple-expr.h", "is-a.h",
       "gimple.h", "gimple-iterator.h", "gimple-ssa.h", "tree-cfg.h",
Index: testsuite/gcc.dg/plugin/ggcplug.c
===================================================================
--- testsuite/gcc.dg/plugin/ggcplug.c	(revision 216558)
+++ testsuite/gcc.dg/plugin/ggcplug.c	(working copy)
@@ -6,12 +6,11 @@
 #include "coretypes.h"
 #include "tm.h"
 #include "tree.h"
+#include "gcc-plugin.h"
 #include "toplev.h"
-#include "basic-block.h"
 #include "hash-table.h"
 #include "vec.h"
 #include "ggc.h"
-#include "basic-block.h"
 #include "tree-ssa-alias.h"
 #include "internal-fn.h"
 #include "gimple-fold.h"
@@ -22,7 +21,6 @@
 #include "tree.h"
 #include "tree-pass.h"
 #include "intl.h"
-#include "gcc-plugin.h"
 #include "plugin-version.h"
 #include "diagnostic.h"
 

Attachment: F2.patch.gz
Description: application/gzip


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]