This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
CFG hooks
On Tue, Apr 15, 2003 at 06:06:23PM +0200, Jan Hubicka wrote:
> can you please push the cfghooks bits into mainline? Even when there
> will be just one hook vector for RTL. I would like to use it to cleanup
> cfglayout and get the interface sanier.
I'm bootstrapping the following patch for mainline, ok?
I will report the results soon.
* cfghooks.h, cfghooks.c: New files.
* Makefile.in (BASIC_BLOCK_H): Depends on cfghooks.h.
(OBJS): Add cfghooks.o.
(cfghooks.o): New rule.
* basic-block.h (split_edge): Rename to rtl_split_edge.
(verify_flow_info): Rename to rtl_verify_flow_info.
(cfghooks.h): Included here.
* cfgrtl.c (split_edge): Renamed rtl_split_edge.
(verify_flow_info): Renamed rtl_verify_flow_info.
* toplev.c (rest_of_compilation): Call rtl_register_cfg_hooks.
Index: gcc/Makefile.in
===================================================================
RCS file: /home/pop/cvsroot/gcc-cvs/gcc/gcc/Makefile.in,v
retrieving revision 1.1034
diff -u -3 -p -d -u -p -r1.1034 Makefile.in
--- gcc/Makefile.in 14 Apr 2003 22:25:10 -0000 1.1034
+++ gcc/Makefile.in 15 Apr 2003 18:55:46 -0000
@@ -635,7 +635,7 @@ PARAMS_H = params.h params.def
TREE_H = tree.h tree.def $(MACHMODE_H) tree-check.h version.h builtins.def \
location.h
BASIC_BLOCK_H = basic-block.h bitmap.h sbitmap.h varray.h $(PARTITION_H) \
- hard-reg-set.h
+ hard-reg-set.h cfghooks.h
DEMANGLE_H = $(srcdir)/../include/demangle.h
RECOG_H = recog.h
EXPR_H = expr.h
@@ -819,7 +819,7 @@ OBJS = alias.o bb-reorder.o bitmap.o bui
sibcall.o simplify-rtx.o sreal.o ssa.o ssa-ccp.o ssa-dce.o stmt.o \
stor-layout.o stringpool.o timevar.o toplev.o tracer.o tree.o tree-dump.o \
tree-inline.o unroll.o varasm.o varray.o version.o vmsdbgout.o xcoffout.o \
- alloc-pool.o et-forest.o cgraph.o cgraphunit.o \
+ alloc-pool.o et-forest.o cgraph.o cgraphunit.o cfghooks.o \
$(GGC) $(out_object_file) $(EXTRA_OBJS) $(host_hook_obj)
BACKEND = main.o libbackend.a
@@ -1637,6 +1637,8 @@ flow.o : flow.c $(CONFIG_H) $(SYSTEM_H)
cfg.o : cfg.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) flags.h insn-config.h \
$(BASIC_BLOCK_H) $(REGS_H) hard-reg-set.h output.h toplev.h $(RECOG_H) \
function.h except.h $(GGC_H) $(TM_P_H) alloc-pool.h
+cfghooks.o: cfghooks.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(TREE_H) \
+ $(BASIC_BLOCK_H) cfglayout.h
cfgrtl.o : cfgrtl.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) flags.h \
insn-config.h $(BASIC_BLOCK_H) $(REGS_H) hard-reg-set.h output.h toplev.h $(RECOG_H) \
function.h except.h $(GGC_H) $(TM_P_H) insn-config.h
Index: gcc/basic-block.h
===================================================================
RCS file: /home/pop/cvsroot/gcc-cvs/gcc/gcc/basic-block.h,v
retrieving revision 1.171
diff -u -3 -p -d -u -p -r1.171 basic-block.h
--- gcc/basic-block.h 10 Mar 2003 12:59:12 -0000 1.171
+++ gcc/basic-block.h 15 Apr 2003 18:40:41 -0000
@@ -335,7 +335,7 @@ extern void update_bb_for_insn PARAMS (
extern void free_basic_block_vars PARAMS ((int));
extern edge split_block PARAMS ((basic_block, rtx));
-extern basic_block split_edge PARAMS ((edge));
+extern basic_block rtl_split_edge PARAMS ((edge));
extern void insert_insn_on_edge PARAMS ((rtx, edge));
extern void commit_edge_insertions PARAMS ((void));
@@ -582,7 +582,7 @@ extern void free_aux_for_edges PARAMS (
/* This function is always defined so it can be called from the
debugger, and it is declared extern so we don't get warnings about
it being unused. */
-extern void verify_flow_info PARAMS ((void));
+extern void rtl_verify_flow_info PARAMS ((void));
typedef struct conflict_graph_def *conflict_graph;
@@ -645,4 +645,7 @@ extern void redirect_immediate_dominator
basic_block));
void iterate_fix_dominators PARAMS ((dominance_info, basic_block *, int));
extern void verify_dominators PARAMS ((dominance_info));
+
+#include "cfghooks.h"
+
#endif /* GCC_BASIC_BLOCK_H */
Index: gcc/cfghooks.c
===================================================================
RCS file: gcc/cfghooks.c
diff -N gcc/cfghooks.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gcc/cfghooks.c 15 Apr 2003 18:56:01 -0000
@@ -0,0 +1,61 @@
+/* Hooks for cfg representation specific functions.
+ Copyright (C) 2003 Free Software Foundation, Inc.
+ Contributed by Sebastian Pop <s dot pop at laposte dot net>
+
+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 2, 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 COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "tree.h"
+#include "rtl.h"
+#include "basic-block.h"
+
+
+/* Containers. */
+struct cfg_hooks tree_cfg_hooks = {
+ NULL,
+ NULL
+};
+
+struct cfg_hooks rtl_cfg_hooks = {
+ rtl_split_edge,
+ rtl_verify_flow_info
+};
+
+/* A pointer to one of the hooks containers. */
+struct cfg_hooks *cfg_hooks;
+bool cfg_at_rtl_level;
+
+/* Initialization of functions specific to the tree IR. */
+void
+tree_register_cfg_hooks ()
+{
+ cfg_at_rtl_level = false;
+ cfg_hooks = &tree_cfg_hooks;
+}
+
+/* Initialization of functions specific to the rtl IR. */
+void
+rtl_register_cfg_hooks ()
+{
+ cfg_at_rtl_level = true;
+ cfg_hooks = &rtl_cfg_hooks;
+}
+
Index: gcc/cfghooks.h
===================================================================
RCS file: gcc/cfghooks.h
diff -N gcc/cfghooks.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gcc/cfghooks.h 15 Apr 2003 18:29:52 -0000
@@ -0,0 +1,46 @@
+/* Hooks for cfg representation specific functions.
+ Copyright (C) 2003 Free Software Foundation, Inc.
+ Contributed by Sebastian Pop <s dot pop at laposte dot net>
+
+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 2, 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 COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#ifndef GCC_CFGHOOKS_H
+#define GCC_CFGHOOKS_H
+
+struct cfg_hooks
+{
+ basic_block (*cfgh_split_edge) PARAMS ((edge));
+ void (*cfgh_verify_flow_info) PARAMS ((void));
+};
+
+#define split_edge(e) cfg_hooks->cfgh_split_edge (e)
+#define verify_flow_info() cfg_hooks->cfgh_verify_flow_info ()
+
+/* Hooks containers. */
+extern struct cfg_hooks tree_cfg_hooks;
+extern struct cfg_hooks rtl_cfg_hooks;
+
+/* A pointer to one of the hooks containers. */
+extern struct cfg_hooks *cfg_hooks;
+extern bool cfg_at_rtl_level;
+
+/* Declarations. */
+extern void tree_register_cfg_hooks PARAMS ((void));
+extern void rtl_register_cfg_hooks PARAMS ((void));
+
+#endif /* GCC_CFGHOOKS_H */
Index: gcc/cfgrtl.c
===================================================================
RCS file: /home/pop/cvsroot/gcc-cvs/gcc/gcc/cfgrtl.c,v
retrieving revision 1.73
diff -u -3 -p -d -u -p -r1.73 cfgrtl.c
--- gcc/cfgrtl.c 14 Apr 2003 14:19:12 -0000 1.73
+++ gcc/cfgrtl.c 15 Apr 2003 18:52:25 -0000
@@ -1230,7 +1230,7 @@ back_edge_of_syntactic_loop_p (bb1, bb2)
block with multiple predecessors is not handled optimally. */
basic_block
-split_edge (edge_in)
+rtl_split_edge (edge_in)
edge edge_in;
{
basic_block bb;
@@ -1741,7 +1741,7 @@ update_br_prob_note (bb)
(reachability of basic blocks, life information, etc. etc.). */
void
-verify_flow_info ()
+rtl_verify_flow_info ()
{
const int max_uid = get_max_uid ();
const rtx rtx_first = get_insns ();
Index: gcc/toplev.c
===================================================================
RCS file: /home/pop/cvsroot/gcc-cvs/gcc/gcc/toplev.c,v
retrieving revision 1.741
diff -u -3 -p -d -u -p -r1.741 toplev.c
--- gcc/toplev.c 12 Apr 2003 02:16:45 -0000 1.741
+++ gcc/toplev.c 15 Apr 2003 18:52:27 -0000
@@ -2430,6 +2430,9 @@ rest_of_compilation (decl)
timevar_push (TV_REST_OF_COMPILATION);
+ /* Register rtl specific functions for cfg. */
+ rtl_register_cfg_hooks ();
+
/* Now that we're out of the frontend, we shouldn't have any more
CONCATs anywhere. */
generating_concat_p = 0;