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
This commit is contained in:
Daniel Berlin 2003-01-07 17:05:16 +00:00 committed by Daniel Berlin
parent 6ec628973a
commit f6cb56fa00
4 changed files with 72 additions and 55 deletions

View File

@ -1,3 +1,31 @@
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>
* config/h8300/h8300.c (output_logical_op): Simplify and

View File

@ -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)
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)
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 \
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

View File

@ -57,12 +57,21 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "toplev.h"
#include "tm_p.h"
#include "obstack.h"
#include "alloc-pool.h"
/* The obstack on which the flow graph components are allocated. */
struct obstack flow_obstack;
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. */
int n_basic_blocks;
@ -75,11 +84,6 @@ int last_basic_block;
int n_edges;
/* First edge in the deleted edges chain. */
edge first_deleted_edge;
static basic_block first_deleted_block;
/* The basic block array. */
varray_type basic_block_info;
@ -140,8 +144,6 @@ init_flow ()
{
static int initialized;
first_deleted_edge = 0;
first_deleted_block = 0;
n_edges = 0;
if (!initialized)
@ -152,9 +154,15 @@ init_flow ()
}
else
{
free_alloc_pool (bb_pool);
free_alloc_pool (edge_pool);
obstack_free (&flow_obstack, flow_firstobj);
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
@ -165,9 +173,7 @@ free_edge (e)
edge e;
{
n_edges--;
memset (e, 0, sizeof *e);
e->succ_next = first_deleted_edge;
first_deleted_edge = e;
pool_free (edge_pool, e);
}
/* Free the memory associated with the edge structures. */
@ -216,18 +222,8 @@ basic_block
alloc_block ()
{
basic_block bb;
if (first_deleted_block)
{
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);
}
bb = pool_alloc (bb_pool);
memset (bb, 0, sizeof (*bb));
return bb;
}
@ -272,7 +268,6 @@ compact_blocks ()
last_basic_block = n_basic_blocks;
}
/* Remove block B from the basic block array. */
void
@ -282,12 +277,7 @@ expunge_block (b)
unlink_block (b);
BASIC_BLOCK (b->index) = NULL;
n_basic_blocks--;
/* 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;
pool_free (bb_pool, b);
}
/* Create an edge connecting SRC and DST with FLAGS optionally using
@ -329,17 +319,10 @@ cached_make_edge (edge_cache, src, dst, flags)
}
break;
}
if (first_deleted_edge)
{
e = first_deleted_edge;
first_deleted_edge = e->succ_next;
}
else
{
e = (edge) obstack_alloc (&flow_obstack, sizeof *e);
memset (e, 0, sizeof *e);
}
e = pool_alloc (edge_pool);
memset (e, 0, sizeof (*e));
n_edges++;
e->succ_next = src->succ;
@ -504,7 +487,6 @@ dump_flow_info (file)
FILE *file;
{
int i;
int max_regno = max_reg_num ();
basic_block bb;
static const char * const reg_class_names[] = REG_CLASS_NAMES;

View File

@ -28,6 +28,7 @@ Boston, MA 02111-1307, USA.
#include "coretypes.h"
#include "tm.h"
#include "et-forest.h"
#include "alloc-pool.h"
struct et_forest_occurrence;
typedef struct et_forest_occurrence* et_forest_occurrence_t;
@ -37,6 +38,8 @@ struct et_forest
{
/* Linked list of nodes is used to destroy the structure. */
int nnodes;
alloc_pool node_pool;
alloc_pool occur_pool;
};
/* Single occurrence of node in ET-forest.
@ -73,7 +76,7 @@ struct et_forest_node
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
PARAMS ((et_forest_occurrence_t));
static inline et_forest_occurrence_t find_rightmost_node
@ -336,7 +339,8 @@ splay (node)
/* Remove all occurences of the given node before destroying the node. */
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_occurrence_t first = forest_node->first;
@ -381,7 +385,7 @@ remove_all_occurrences (forest_node)
if (prev_node->node->last == next_node)
prev_node->node->last = prev_node;
free (next_node);
pool_free (forest->occur_pool, next_node);
}
if (first != last)
@ -400,14 +404,14 @@ remove_all_occurrences (forest_node)
node->right->parent = 0;
next_node = node->next;
free (node);
pool_free (forest->occur_pool, node);
node = next_node;
}
}
free (first);
pool_free (forest->occur_pool, first);
if (first != last)
free (last);
pool_free (forest->occur_pool, last);
}
/* Calculate ET value of the given node. */
@ -439,6 +443,8 @@ et_forest_create ()
et_forest_t forest = xmalloc (sizeof (struct et_forest));
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;
}
@ -451,7 +457,8 @@ et_forest_delete (forest)
{
if (forest->nnodes)
abort ();
free_alloc_pool (forest->occur_pool);
free_alloc_pool (forest->node_pool);
free (forest);
}
@ -466,8 +473,8 @@ et_forest_add_node (forest, value)
et_forest_node_t node;
et_forest_occurrence_t occ;
node = xmalloc (sizeof (struct et_forest_node));
occ = xmalloc (sizeof (struct et_forest_occurrence));
node = pool_alloc (forest->node_pool);
occ = pool_alloc (forest->occur_pool);
node->first = node->last = occ;
node->value = value;
@ -505,7 +512,7 @@ et_forest_add_edge (forest, parent_node, child_node)
if (child_occ->left)
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->left = child_occ;
@ -532,10 +539,10 @@ et_forest_remove_node (forest, node)
et_forest_t forest;
et_forest_node_t node;
{
remove_all_occurrences (node);
remove_all_occurrences (forest, node);
forest->nnodes--;
free (node);
pool_free (forest->node_pool, node);
}
/* Remove edge from the tree, return 1 if sucesfull,
@ -575,7 +582,7 @@ et_forest_remove_edge (forest, parent_node, child_node)
if (parent_post_occ == parent_node->last)
parent_node->last = parent_pre_occ;
free (parent_post_occ);
pool_free (forest->occur_pool, parent_post_occ);
return 1;
}