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] O(1) PHI argument look-up - Part 4/n


Hi,

Attached is a patch to part 4 of my O(1) PHI argument look-up patch.

In order to sync an edge vector and a PHI array, we need to catch
events like growing and shrinking of the edge vector.

This patch adds two targets hooks.  See the hunks from cfghooks.h for
their descriptions.  To make the patch readable, I didn't put the
applications of these hooks in this patch.

Tested on i686-pc-linux-gnu.  OK to apply?

Kazu Hirata

2004-11-21  Kazu Hirata  <kazu@cs.umass.edu>

	* cfg.c (unchecked_make_edge): Call execute_on_growing_pred
	after making an edge.
	(remove_edge): Call execute_on_shrinking_pred before removing
	an edge.
	(redirect_edge_succ): Call execute_on_growing_pred and
	execute_on_shrinking_pred.
	* cfghooks.c (execute_on_growing_pred): New.
	(execute_on_shrinking_pred): Likewise.
	* cfghooks.h (cfg_hooks): Add execute_on_growing_pred and
	execute_on_shrinking_pred.
	Add prototypes for execute_on_growing_pred and
	execute_on_shrinking_pred.
	* cfgrtl.c (rtl_cfg_hooks): Add NULL hooks to
	execute_on_growing_pred and execute_on_shrinking_pred.
	(cfg_layout_rtl_cfg_hook): Likewise.
	* tree-cfg.c (tree_cfg_hooks): Likewise.

Index: cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfg.c,v
retrieving revision 1.74
diff -u -d -p -r1.74 cfg.c
--- cfg.c	20 Nov 2004 05:02:28 -0000	1.74
+++ cfg.c	21 Nov 2004 06:19:58 -0000
@@ -278,6 +278,8 @@ unchecked_make_edge (basic_block src, ba
   e->flags = flags;
   e->dest_idx = EDGE_COUNT (dst->preds) - 1;
 
+  execute_on_growing_pred (e);
+
   return e;
 }
 
@@ -360,6 +362,8 @@ remove_edge (edge e)
   bool found = false;
   edge_iterator ei;
 
+  execute_on_shrinking_pred (e);
+
   src = e->src;
   dest = e->dest;
   dest_idx = e->dest_idx;
@@ -396,6 +400,8 @@ redirect_edge_succ (edge e, basic_block 
   basic_block dest = e->dest;
   unsigned int dest_idx = e->dest_idx;
 
+  execute_on_shrinking_pred (e);
+
   VEC_unordered_remove (edge, dest->preds, dest_idx);
 
   /* If we removed an edge in the middle of the edge vector, we need
@@ -407,6 +413,7 @@ redirect_edge_succ (edge e, basic_block 
   VEC_safe_push (edge, new_succ->preds, e);
   e->dest = new_succ;
   e->dest_idx = EDGE_COUNT (new_succ->preds) - 1;
+  execute_on_growing_pred (e);
 }
 
 /* Like previous but avoid possible duplicate edge.  */
Index: cfghooks.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfghooks.c,v
retrieving revision 1.19
diff -u -d -p -r1.19 cfghooks.c
--- cfghooks.c	20 Nov 2004 05:02:28 -0000	1.19
+++ cfghooks.c	21 Nov 2004 06:19:58 -0000
@@ -805,3 +805,23 @@ flow_call_edges_add (sbitmap blocks)
 
   return (cfg_hooks->flow_call_edges_add) (blocks);
 }
+
+/* This function is called immediately after edge E is added to the
+   edge vector E->dest->preds.  */
+
+void
+execute_on_growing_pred (edge e)
+{
+  if (cfg_hooks->execute_on_growing_pred)
+    cfg_hooks->execute_on_growing_pred (e);
+}
+
+/* This function is called immediately before edge E is removed from
+   the edge vector E->dest->preds.  */
+
+void
+execute_on_shrinking_pred (edge e)
+{
+  if (cfg_hooks->execute_on_shrinking_pred)
+    cfg_hooks->execute_on_shrinking_pred (e);
+}
Index: cfghooks.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfghooks.h,v
retrieving revision 1.11
diff -u -d -p -r1.11 cfghooks.h
--- cfghooks.h	13 May 2004 06:39:32 -0000	1.11
+++ cfghooks.h	21 Nov 2004 06:19:58 -0000
@@ -100,6 +100,14 @@ struct cfg_hooks
      The goal is to expose cases in which entering a basic block does not imply
      that all subsequent instructions must be executed.  */
   int (*flow_call_edges_add) (sbitmap);
+
+  /* This function is called immediately after edge E is added to the
+     edge vector E->dest->preds.  */
+  void (*execute_on_growing_pred) (edge);
+
+  /* This function is called immediately before edge E is removed from
+     the edge vector E->dest->preds.  */
+  void (*execute_on_shrinking_pred) (edge);
 };
 
 extern void verify_flow_info (void);
@@ -126,6 +134,8 @@ extern basic_block duplicate_block (basi
 extern bool block_ends_with_call_p (basic_block bb);
 extern bool block_ends_with_condjump_p (basic_block bb);
 extern int flow_call_edges_add (sbitmap);
+extern void execute_on_growing_pred (edge);
+extern void execute_on_shrinking_pred (edge);
 
 /* Hooks containers.  */
 extern struct cfg_hooks tree_cfg_hooks;
Index: cfgrtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgrtl.c,v
retrieving revision 1.146
diff -u -d -p -r1.146 cfgrtl.c
--- cfgrtl.c	17 Nov 2004 21:55:07 -0000	1.146
+++ cfgrtl.c	21 Nov 2004 06:19:58 -0000
@@ -3073,7 +3073,9 @@ struct cfg_hooks rtl_cfg_hooks = {
   rtl_tidy_fallthru_edge,
   rtl_block_ends_with_call_p,
   rtl_block_ends_with_condjump_p,
-  rtl_flow_call_edges_add
+  rtl_flow_call_edges_add,
+  NULL, /* execute_on_growing_pred */
+  NULL /* execute_on_shrinking_pred */
 };
 
 /* Implementation of CFG manipulation for cfg layout RTL, where
@@ -3109,6 +3111,8 @@ struct cfg_hooks cfg_layout_rtl_cfg_hook
   NULL,
   rtl_block_ends_with_call_p,
   rtl_block_ends_with_condjump_p,
-  rtl_flow_call_edges_add
+  rtl_flow_call_edges_add,
+  NULL, /* execute_on_growing_pred */
+  NULL /* execute_on_shrinking_pred */
 };
 
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.112
diff -u -d -p -r2.112 tree-cfg.c
--- tree-cfg.c	19 Nov 2004 22:14:35 -0000	2.112
+++ tree-cfg.c	21 Nov 2004 06:19:59 -0000
@@ -5369,7 +5369,9 @@ struct cfg_hooks tree_cfg_hooks = {
   NULL,				/* tidy_fallthru_edge  */
   tree_block_ends_with_call_p,	/* block_ends_with_call_p */
   tree_block_ends_with_condjump_p, /* block_ends_with_condjump_p */
-  tree_flow_call_edges_add      /* flow_call_edges_add */
+  tree_flow_call_edges_add,     /* flow_call_edges_add */
+  NULL,	/* execute_on_growing_pred */
+  NULL, /* execute_on_shrinking_pred */
 };
 
 


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