+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
$(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
#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;
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;
{
static int initialized;
- first_deleted_edge = 0;
- first_deleted_block = 0;
n_edges = 0;
if (!initialized)
}
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);
}
\f
/* Helper function for remove_edge and clear_edges. Frees edge structure
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. */
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;
}
last_basic_block = n_basic_blocks;
}
-
/* Remove block B from the basic block array. */
void
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);
}
\f
/* Create an edge connecting SRC and DST with FLAGS optionally using
}
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;
FILE *file;
{
int i;
- int max_regno = max_reg_num ();
basic_block bb;
static const char * const reg_class_names[] = REG_CLASS_NAMES;
#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;
{
/* 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.
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
/* 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;
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)
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. */
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;
}
{
if (forest->nnodes)
abort ();
-
+ free_alloc_pool (forest->occur_pool);
+ free_alloc_pool (forest->node_pool);
free (forest);
}
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;
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;
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,
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;
}