Commit f6cb56fa by Daniel Berlin Committed by Daniel Berlin

cfg.c: Include alloc-pool.h

2003-01-07  Daniel Berlin  <dberlin@dberlin.org>

	* cfg.c: Include alloc-pool.h
	(edge_pool): New pool.
	(bb_pool): New pool.
	(first_deleted_edge): Remove.
	(first_deleted_block): Remove.
	(init_flow): Alloc/free the pools.
	(free_edge): Use pools.
	(alloc_block): Ditto.
	(expunge_block): Ditto.
	(cached_make_edge): Ditto.

	* Makefile.in (cfg.o): Add alloc-pool.h dependency.

2003-01-07  Daniel Berlin  <dberlin@dberlin.org>

	* et-forest.c: Include alloc-pool.h.
	(struct et_forest): Add node_pool and occur_pool.
	(et_forest_create): Create the new pools.
	(et_forest_delete): Delete them.
	(et_forest_add_node): Allocate and free using pools.
	(et_forest_add_edge): Ditto.
	(et_forest_remove_node): Ditto.
	(et_forest_remove_edge): Ditto.

	* Makefile.in (et-forest.o): Add alloc-pool.h dependency.

From-SVN: r61001
parent 6ec62897
2003-01-07 Daniel Berlin <dberlin@dberlin.org>
* cfg.c: Include alloc-pool.h
(edge_pool): New pool.
(bb_pool): New pool.
(first_deleted_edge): Remove.
(first_deleted_block): Remove.
(init_flow): Alloc/free the pools.
(free_edge): Use pools.
(alloc_block): Ditto.
(expunge_block): Ditto.
(cached_make_edge): Ditto.
* Makefile.in (cfg.o): Add alloc-pool.h dependency.
2003-01-07 Daniel Berlin <dberlin@dberlin.org>
* et-forest.c: Include alloc-pool.h.
(struct et_forest): Add node_pool and occur_pool.
(et_forest_create): Create the new pools.
(et_forest_delete): Delete them.
(et_forest_add_node): Allocate and free using pools.
(et_forest_add_edge): Ditto.
(et_forest_remove_node): Ditto.
(et_forest_remove_edge): Ditto.
* Makefile.in (et-forest.o): Add alloc-pool.h dependency.
2003-01-07 Kazu Hirata <kazu@cs.umass.edu> 2003-01-07 Kazu Hirata <kazu@cs.umass.edu>
* config/h8300/h8300.c (output_logical_op): Simplify and * config/h8300/h8300.c (output_logical_op): Simplify and
......
...@@ -1547,7 +1547,7 @@ flow.o : flow.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(TREE_H) \ ...@@ -1547,7 +1547,7 @@ flow.o : flow.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(TREE_H) \
$(RECOG_H) function.h except.h $(EXPR_H) ssa.h $(GGC_H) $(TM_P_H) $(RECOG_H) function.h except.h $(EXPR_H) ssa.h $(GGC_H) $(TM_P_H)
cfg.o : cfg.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) flags.h insn-config.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) \ $(BASIC_BLOCK_H) $(REGS_H) hard-reg-set.h output.h toplev.h $(RECOG_H) \
function.h except.h $(GGC_H) $(TM_P_H) function.h except.h $(GGC_H) $(TM_P_H) alloc-pool.h
cfgrtl.o : cfgrtl.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) flags.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) \ 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 function.h except.h $(GGC_H) $(TM_P_H) insn-config.h
......
...@@ -57,12 +57,21 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -57,12 +57,21 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "toplev.h" #include "toplev.h"
#include "tm_p.h" #include "tm_p.h"
#include "obstack.h" #include "obstack.h"
#include "alloc-pool.h"
/* The obstack on which the flow graph components are allocated. */ /* The obstack on which the flow graph components are allocated. */
struct obstack flow_obstack; struct obstack flow_obstack;
static char *flow_firstobj; static char *flow_firstobj;
/* Basic block object pool. */
static alloc_pool bb_pool;
/* Edge object pool. */
static alloc_pool edge_pool;
/* Number of basic blocks in the current function. */ /* Number of basic blocks in the current function. */
int n_basic_blocks; int n_basic_blocks;
...@@ -75,11 +84,6 @@ int last_basic_block; ...@@ -75,11 +84,6 @@ int last_basic_block;
int n_edges; int n_edges;
/* First edge in the deleted edges chain. */
edge first_deleted_edge;
static basic_block first_deleted_block;
/* The basic block array. */ /* The basic block array. */
varray_type basic_block_info; varray_type basic_block_info;
...@@ -140,8 +144,6 @@ init_flow () ...@@ -140,8 +144,6 @@ init_flow ()
{ {
static int initialized; static int initialized;
first_deleted_edge = 0;
first_deleted_block = 0;
n_edges = 0; n_edges = 0;
if (!initialized) if (!initialized)
...@@ -152,9 +154,15 @@ init_flow () ...@@ -152,9 +154,15 @@ init_flow ()
} }
else else
{ {
free_alloc_pool (bb_pool);
free_alloc_pool (edge_pool);
obstack_free (&flow_obstack, flow_firstobj); obstack_free (&flow_obstack, flow_firstobj);
flow_firstobj = (char *) obstack_alloc (&flow_obstack, 0); flow_firstobj = (char *) obstack_alloc (&flow_obstack, 0);
} }
bb_pool = create_alloc_pool ("Basic block pool",
sizeof (struct basic_block_def), 100);
edge_pool = create_alloc_pool ("Edge pool",
sizeof (struct edge_def), 100);
} }
/* Helper function for remove_edge and clear_edges. Frees edge structure /* Helper function for remove_edge and clear_edges. Frees edge structure
...@@ -165,9 +173,7 @@ free_edge (e) ...@@ -165,9 +173,7 @@ free_edge (e)
edge e; edge e;
{ {
n_edges--; n_edges--;
memset (e, 0, sizeof *e); pool_free (edge_pool, e);
e->succ_next = first_deleted_edge;
first_deleted_edge = e;
} }
/* Free the memory associated with the edge structures. */ /* Free the memory associated with the edge structures. */
...@@ -216,18 +222,8 @@ basic_block ...@@ -216,18 +222,8 @@ basic_block
alloc_block () alloc_block ()
{ {
basic_block bb; basic_block bb;
bb = pool_alloc (bb_pool);
if (first_deleted_block) memset (bb, 0, sizeof (*bb));
{
bb = first_deleted_block;
first_deleted_block = (basic_block) bb->succ;
bb->succ = NULL;
}
else
{
bb = (basic_block) obstack_alloc (&flow_obstack, sizeof *bb);
memset (bb, 0, sizeof *bb);
}
return bb; return bb;
} }
...@@ -272,7 +268,6 @@ compact_blocks () ...@@ -272,7 +268,6 @@ compact_blocks ()
last_basic_block = n_basic_blocks; last_basic_block = n_basic_blocks;
} }
/* Remove block B from the basic block array. */ /* Remove block B from the basic block array. */
void void
...@@ -282,12 +277,7 @@ expunge_block (b) ...@@ -282,12 +277,7 @@ expunge_block (b)
unlink_block (b); unlink_block (b);
BASIC_BLOCK (b->index) = NULL; BASIC_BLOCK (b->index) = NULL;
n_basic_blocks--; n_basic_blocks--;
pool_free (bb_pool, b);
/* Invalidate data to make bughunting easier. */
memset (b, 0, sizeof *b);
b->index = -3;
b->succ = (edge) first_deleted_block;
first_deleted_block = (basic_block) b;
} }
/* Create an edge connecting SRC and DST with FLAGS optionally using /* Create an edge connecting SRC and DST with FLAGS optionally using
...@@ -329,17 +319,10 @@ cached_make_edge (edge_cache, src, dst, flags) ...@@ -329,17 +319,10 @@ cached_make_edge (edge_cache, src, dst, flags)
} }
break; break;
} }
if (first_deleted_edge)
{ e = pool_alloc (edge_pool);
e = first_deleted_edge; memset (e, 0, sizeof (*e));
first_deleted_edge = e->succ_next;
}
else
{
e = (edge) obstack_alloc (&flow_obstack, sizeof *e);
memset (e, 0, sizeof *e);
}
n_edges++; n_edges++;
e->succ_next = src->succ; e->succ_next = src->succ;
...@@ -504,7 +487,6 @@ dump_flow_info (file) ...@@ -504,7 +487,6 @@ dump_flow_info (file)
FILE *file; FILE *file;
{ {
int i; int i;
int max_regno = max_reg_num ();
basic_block bb; basic_block bb;
static const char * const reg_class_names[] = REG_CLASS_NAMES; static const char * const reg_class_names[] = REG_CLASS_NAMES;
......
...@@ -28,6 +28,7 @@ Boston, MA 02111-1307, USA. ...@@ -28,6 +28,7 @@ Boston, MA 02111-1307, USA.
#include "coretypes.h" #include "coretypes.h"
#include "tm.h" #include "tm.h"
#include "et-forest.h" #include "et-forest.h"
#include "alloc-pool.h"
struct et_forest_occurrence; struct et_forest_occurrence;
typedef struct et_forest_occurrence* et_forest_occurrence_t; typedef struct et_forest_occurrence* et_forest_occurrence_t;
...@@ -37,6 +38,8 @@ struct et_forest ...@@ -37,6 +38,8 @@ struct et_forest
{ {
/* Linked list of nodes is used to destroy the structure. */ /* Linked list of nodes is used to destroy the structure. */
int nnodes; int nnodes;
alloc_pool node_pool;
alloc_pool occur_pool;
}; };
/* Single occurrence of node in ET-forest. /* Single occurrence of node in ET-forest.
...@@ -73,7 +76,7 @@ struct et_forest_node ...@@ -73,7 +76,7 @@ struct et_forest_node
static et_forest_occurrence_t splay PARAMS ((et_forest_occurrence_t)); static et_forest_occurrence_t splay PARAMS ((et_forest_occurrence_t));
static void remove_all_occurrences PARAMS ((et_forest_node_t)); static void remove_all_occurrences PARAMS ((et_forest_t, et_forest_node_t));
static inline et_forest_occurrence_t find_leftmost_node static inline et_forest_occurrence_t find_leftmost_node
PARAMS ((et_forest_occurrence_t)); PARAMS ((et_forest_occurrence_t));
static inline et_forest_occurrence_t find_rightmost_node static inline et_forest_occurrence_t find_rightmost_node
...@@ -336,7 +339,8 @@ splay (node) ...@@ -336,7 +339,8 @@ splay (node)
/* Remove all occurences of the given node before destroying the node. */ /* Remove all occurences of the given node before destroying the node. */
static void static void
remove_all_occurrences (forest_node) remove_all_occurrences (forest, forest_node)
et_forest_t forest;
et_forest_node_t forest_node; et_forest_node_t forest_node;
{ {
et_forest_occurrence_t first = forest_node->first; et_forest_occurrence_t first = forest_node->first;
...@@ -381,7 +385,7 @@ remove_all_occurrences (forest_node) ...@@ -381,7 +385,7 @@ remove_all_occurrences (forest_node)
if (prev_node->node->last == next_node) if (prev_node->node->last == next_node)
prev_node->node->last = prev_node; prev_node->node->last = prev_node;
free (next_node); pool_free (forest->occur_pool, next_node);
} }
if (first != last) if (first != last)
...@@ -400,14 +404,14 @@ remove_all_occurrences (forest_node) ...@@ -400,14 +404,14 @@ remove_all_occurrences (forest_node)
node->right->parent = 0; node->right->parent = 0;
next_node = node->next; next_node = node->next;
free (node); pool_free (forest->occur_pool, node);
node = next_node; node = next_node;
} }
} }
free (first); pool_free (forest->occur_pool, first);
if (first != last) if (first != last)
free (last); pool_free (forest->occur_pool, last);
} }
/* Calculate ET value of the given node. */ /* Calculate ET value of the given node. */
...@@ -439,6 +443,8 @@ et_forest_create () ...@@ -439,6 +443,8 @@ et_forest_create ()
et_forest_t forest = xmalloc (sizeof (struct et_forest)); et_forest_t forest = xmalloc (sizeof (struct et_forest));
forest->nnodes = 0; forest->nnodes = 0;
forest->occur_pool = create_alloc_pool ("et_forest_occurrence pool", sizeof (struct et_forest_occurrence), 300);
forest->node_pool = create_alloc_pool ("et_forest_node pool", sizeof (struct et_forest_node), 300);
return forest; return forest;
} }
...@@ -451,7 +457,8 @@ et_forest_delete (forest) ...@@ -451,7 +457,8 @@ et_forest_delete (forest)
{ {
if (forest->nnodes) if (forest->nnodes)
abort (); abort ();
free_alloc_pool (forest->occur_pool);
free_alloc_pool (forest->node_pool);
free (forest); free (forest);
} }
...@@ -466,8 +473,8 @@ et_forest_add_node (forest, value) ...@@ -466,8 +473,8 @@ et_forest_add_node (forest, value)
et_forest_node_t node; et_forest_node_t node;
et_forest_occurrence_t occ; et_forest_occurrence_t occ;
node = xmalloc (sizeof (struct et_forest_node)); node = pool_alloc (forest->node_pool);
occ = xmalloc (sizeof (struct et_forest_occurrence)); occ = pool_alloc (forest->occur_pool);
node->first = node->last = occ; node->first = node->last = occ;
node->value = value; node->value = value;
...@@ -505,7 +512,7 @@ et_forest_add_edge (forest, parent_node, child_node) ...@@ -505,7 +512,7 @@ et_forest_add_edge (forest, parent_node, child_node)
if (child_occ->left) if (child_occ->left)
abort (); /* child must be root of its containing tree. */ abort (); /* child must be root of its containing tree. */
new_occ = xmalloc (sizeof (struct et_forest_occurrence)); new_occ = pool_alloc (forest->occur_pool);
new_occ->node = parent_node; new_occ->node = parent_node;
new_occ->left = child_occ; new_occ->left = child_occ;
...@@ -532,10 +539,10 @@ et_forest_remove_node (forest, node) ...@@ -532,10 +539,10 @@ et_forest_remove_node (forest, node)
et_forest_t forest; et_forest_t forest;
et_forest_node_t node; et_forest_node_t node;
{ {
remove_all_occurrences (node); remove_all_occurrences (forest, node);
forest->nnodes--; forest->nnodes--;
free (node); pool_free (forest->node_pool, node);
} }
/* Remove edge from the tree, return 1 if sucesfull, /* Remove edge from the tree, return 1 if sucesfull,
...@@ -575,7 +582,7 @@ et_forest_remove_edge (forest, parent_node, child_node) ...@@ -575,7 +582,7 @@ et_forest_remove_edge (forest, parent_node, child_node)
if (parent_post_occ == parent_node->last) if (parent_post_occ == parent_node->last)
parent_node->last = parent_pre_occ; parent_node->last = parent_pre_occ;
free (parent_post_occ); pool_free (forest->occur_pool, parent_post_occ);
return 1; return 1;
} }
......
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