Commit a78a26f1 by Martin Liska Committed by Martin Liska

Change use to type-based pool allocator in cselib.c.

	* cselib.c (new_elt_list):Use new type-based pool allocator.
	(new_elt_loc_list) Likewise.
	(unchain_one_elt_list) Likewise.
	(unchain_one_elt_loc_list) Likewise.
	(unchain_one_value) Likewise.
	(new_cselib_val) Likewise.
	(cselib_init) Likewise.
	(cselib_finish) Likewise.

From-SVN: r223952
parent 533ab6c4
2015-06-01 Martin Liska <mliska@suse.cz> 2015-06-01 Martin Liska <mliska@suse.cz>
* cselib.c (new_elt_list):Use new type-based pool allocator.
(new_elt_loc_list) Likewise.
(unchain_one_elt_list) Likewise.
(unchain_one_elt_loc_list) Likewise.
(unchain_one_value) Likewise.
(new_cselib_val) Likewise.
(cselib_init) Likewise.
(cselib_finish) Likewise.
2015-06-01 Martin Liska <mliska@suse.cz>
* config/sh/sh.c (add_constant):Use new type-based pool allocator. * config/sh/sh.c (add_constant):Use new type-based pool allocator.
(sh_reorg) Likewise. (sh_reorg) Likewise.
......
...@@ -53,6 +53,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -53,6 +53,7 @@ along with GCC; see the file COPYING3. If not see
#include "tm_p.h" #include "tm_p.h"
#include "regs.h" #include "regs.h"
#include "diagnostic-core.h" #include "diagnostic-core.h"
#include "alloc-pool.h"
#include "cselib.h" #include "cselib.h"
#include "hash-map.h" #include "hash-map.h"
#include "langhooks.h" #include "langhooks.h"
......
...@@ -50,6 +50,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -50,6 +50,7 @@ along with GCC; see the file COPYING3. If not see
#include "flags.h" #include "flags.h"
#include "recog.h" #include "recog.h"
#include "diagnostic-core.h" #include "diagnostic-core.h"
#include "alloc-pool.h"
#include "cselib.h" #include "cselib.h"
#include "params.h" #include "params.h"
#include "tm_p.h" #include "tm_p.h"
......
...@@ -63,6 +63,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -63,6 +63,7 @@ along with GCC; see the file COPYING3. If not see
#include "expr.h" #include "expr.h"
#include "except.h" #include "except.h"
#include "params.h" #include "params.h"
#include "alloc-pool.h"
#include "cselib.h" #include "cselib.h"
#include "intl.h" #include "intl.h"
#include "obstack.h" #include "obstack.h"
......
...@@ -46,6 +46,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -46,6 +46,7 @@ along with GCC; see the file COPYING3. If not see
#include "ggc.h" #include "ggc.h"
#include "hash-table.h" #include "hash-table.h"
#include "dumpfile.h" #include "dumpfile.h"
#include "alloc-pool.h"
#include "cselib.h" #include "cselib.h"
#include "predict.h" #include "predict.h"
#include "basic-block.h" #include "basic-block.h"
...@@ -56,9 +57,25 @@ along with GCC; see the file COPYING3. If not see ...@@ -56,9 +57,25 @@ along with GCC; see the file COPYING3. If not see
#include "bitmap.h" #include "bitmap.h"
/* A list of cselib_val structures. */ /* A list of cselib_val structures. */
struct elt_list { struct elt_list
{
struct elt_list *next; struct elt_list *next;
cselib_val *elt; cselib_val *elt;
/* Pool allocation new operator. */
inline void *operator new (size_t)
{
return pool.allocate ();
}
/* Delete operator utilizing pool allocation. */
inline void operator delete (void *ptr)
{
pool.remove ((elt_list *) ptr);
}
/* Memory allocation pool. */
static pool_allocator<elt_list> pool;
}; };
static bool cselib_record_memory; static bool cselib_record_memory;
...@@ -260,7 +277,13 @@ static unsigned int cfa_base_preserved_regno = INVALID_REGNUM; ...@@ -260,7 +277,13 @@ static unsigned int cfa_base_preserved_regno = INVALID_REGNUM;
May or may not contain the useless values - the list is compacted May or may not contain the useless values - the list is compacted
each time memory is invalidated. */ each time memory is invalidated. */
static cselib_val *first_containing_mem = &dummy_val; static cselib_val *first_containing_mem = &dummy_val;
static alloc_pool elt_loc_list_pool, elt_list_pool, cselib_val_pool, value_pool;
pool_allocator<elt_list> elt_list::pool ("elt_list", 10);
pool_allocator<elt_loc_list> elt_loc_list::pool ("elt_loc_list", 10);
pool_allocator<cselib_val> cselib_val::pool ("cselib_val_list", 10);
static pool_allocator<rtx_def> value_pool ("value", 100, RTX_CODE_SIZE (VALUE),
true);
/* If nonnull, cselib will call this function before freeing useless /* If nonnull, cselib will call this function before freeing useless
VALUEs. A VALUE is deemed useless if its "locs" field is null. */ VALUEs. A VALUE is deemed useless if its "locs" field is null. */
...@@ -288,8 +311,7 @@ void (*cselib_record_sets_hook) (rtx_insn *insn, struct cselib_set *sets, ...@@ -288,8 +311,7 @@ void (*cselib_record_sets_hook) (rtx_insn *insn, struct cselib_set *sets,
static inline struct elt_list * static inline struct elt_list *
new_elt_list (struct elt_list *next, cselib_val *elt) new_elt_list (struct elt_list *next, cselib_val *elt)
{ {
struct elt_list *el; elt_list *el = new elt_list ();
el = (struct elt_list *) pool_alloc (elt_list_pool);
el->next = next; el->next = next;
el->elt = elt; el->elt = elt;
return el; return el;
...@@ -373,14 +395,14 @@ new_elt_loc_list (cselib_val *val, rtx loc) ...@@ -373,14 +395,14 @@ new_elt_loc_list (cselib_val *val, rtx loc)
} }
/* Chain LOC back to VAL. */ /* Chain LOC back to VAL. */
el = (struct elt_loc_list *) pool_alloc (elt_loc_list_pool); el = new elt_loc_list;
el->loc = val->val_rtx; el->loc = val->val_rtx;
el->setting_insn = cselib_current_insn; el->setting_insn = cselib_current_insn;
el->next = NULL; el->next = NULL;
CSELIB_VAL_PTR (loc)->locs = el; CSELIB_VAL_PTR (loc)->locs = el;
} }
el = (struct elt_loc_list *) pool_alloc (elt_loc_list_pool); el = new elt_loc_list;
el->loc = loc; el->loc = loc;
el->setting_insn = cselib_current_insn; el->setting_insn = cselib_current_insn;
el->next = next; el->next = next;
...@@ -420,7 +442,7 @@ unchain_one_elt_list (struct elt_list **pl) ...@@ -420,7 +442,7 @@ unchain_one_elt_list (struct elt_list **pl)
struct elt_list *l = *pl; struct elt_list *l = *pl;
*pl = l->next; *pl = l->next;
pool_free (elt_list_pool, l); delete l;
} }
/* Likewise for elt_loc_lists. */ /* Likewise for elt_loc_lists. */
...@@ -431,7 +453,7 @@ unchain_one_elt_loc_list (struct elt_loc_list **pl) ...@@ -431,7 +453,7 @@ unchain_one_elt_loc_list (struct elt_loc_list **pl)
struct elt_loc_list *l = *pl; struct elt_loc_list *l = *pl;
*pl = l->next; *pl = l->next;
pool_free (elt_loc_list_pool, l); delete l;
} }
/* Likewise for cselib_vals. This also frees the addr_list associated with /* Likewise for cselib_vals. This also frees the addr_list associated with
...@@ -443,7 +465,7 @@ unchain_one_value (cselib_val *v) ...@@ -443,7 +465,7 @@ unchain_one_value (cselib_val *v)
while (v->addr_list) while (v->addr_list)
unchain_one_elt_list (&v->addr_list); unchain_one_elt_list (&v->addr_list);
pool_free (cselib_val_pool, v); delete v;
} }
/* Remove all entries from the hash table. Also used during /* Remove all entries from the hash table. Also used during
...@@ -1306,7 +1328,7 @@ cselib_hash_rtx (rtx x, int create, machine_mode memmode) ...@@ -1306,7 +1328,7 @@ cselib_hash_rtx (rtx x, int create, machine_mode memmode)
static inline cselib_val * static inline cselib_val *
new_cselib_val (unsigned int hash, machine_mode mode, rtx x) new_cselib_val (unsigned int hash, machine_mode mode, rtx x)
{ {
cselib_val *e = (cselib_val *) pool_alloc (cselib_val_pool); cselib_val *e = new cselib_val;
gcc_assert (hash); gcc_assert (hash);
gcc_assert (next_uid); gcc_assert (next_uid);
...@@ -1318,7 +1340,7 @@ new_cselib_val (unsigned int hash, machine_mode mode, rtx x) ...@@ -1318,7 +1340,7 @@ new_cselib_val (unsigned int hash, machine_mode mode, rtx x)
precisely when we can have VALUE RTXen (when cselib is active) precisely when we can have VALUE RTXen (when cselib is active)
so we don't need to put them in garbage collected memory. so we don't need to put them in garbage collected memory.
??? Why should a VALUE be an RTX in the first place? */ ??? Why should a VALUE be an RTX in the first place? */
e->val_rtx = (rtx) pool_alloc (value_pool); e->val_rtx = value_pool.allocate ();
memset (e->val_rtx, 0, RTX_HDR_SIZE); memset (e->val_rtx, 0, RTX_HDR_SIZE);
PUT_CODE (e->val_rtx, VALUE); PUT_CODE (e->val_rtx, VALUE);
PUT_MODE (e->val_rtx, mode); PUT_MODE (e->val_rtx, mode);
...@@ -2729,13 +2751,6 @@ cselib_process_insn (rtx_insn *insn) ...@@ -2729,13 +2751,6 @@ cselib_process_insn (rtx_insn *insn)
void void
cselib_init (int record_what) cselib_init (int record_what)
{ {
elt_list_pool = create_alloc_pool ("elt_list",
sizeof (struct elt_list), 10);
elt_loc_list_pool = create_alloc_pool ("elt_loc_list",
sizeof (struct elt_loc_list), 10);
cselib_val_pool = create_alloc_pool ("cselib_val_list",
sizeof (cselib_val), 10);
value_pool = create_alloc_pool ("value", RTX_CODE_SIZE (VALUE), 100);
cselib_record_memory = record_what & CSELIB_RECORD_MEMORY; cselib_record_memory = record_what & CSELIB_RECORD_MEMORY;
cselib_preserve_constants = record_what & CSELIB_PRESERVE_CONSTANTS; cselib_preserve_constants = record_what & CSELIB_PRESERVE_CONSTANTS;
cselib_any_perm_equivs = false; cselib_any_perm_equivs = false;
...@@ -2777,10 +2792,10 @@ cselib_finish (void) ...@@ -2777,10 +2792,10 @@ cselib_finish (void)
cselib_any_perm_equivs = false; cselib_any_perm_equivs = false;
cfa_base_preserved_val = NULL; cfa_base_preserved_val = NULL;
cfa_base_preserved_regno = INVALID_REGNUM; cfa_base_preserved_regno = INVALID_REGNUM;
free_alloc_pool (elt_list_pool); elt_list::pool.release ();
free_alloc_pool (elt_loc_list_pool); elt_loc_list::pool.release ();
free_alloc_pool (cselib_val_pool); cselib_val::pool.release ();
free_alloc_pool (value_pool); value_pool.release ();
cselib_clear_table (); cselib_clear_table ();
delete cselib_hash_table; delete cselib_hash_table;
cselib_hash_table = NULL; cselib_hash_table = NULL;
......
...@@ -21,7 +21,8 @@ along with GCC; see the file COPYING3. If not see ...@@ -21,7 +21,8 @@ along with GCC; see the file COPYING3. If not see
#define GCC_CSELIB_H #define GCC_CSELIB_H
/* Describe a value. */ /* Describe a value. */
struct cselib_val { struct cselib_val
{
/* The hash value. */ /* The hash value. */
unsigned int hash; unsigned int hash;
...@@ -40,6 +41,21 @@ struct cselib_val { ...@@ -40,6 +41,21 @@ struct cselib_val {
struct elt_list *addr_list; struct elt_list *addr_list;
struct cselib_val *next_containing_mem; struct cselib_val *next_containing_mem;
/* Pool allocation new operator. */
inline void *operator new (size_t)
{
return pool.allocate ();
}
/* Delete operator utilizing pool allocation. */
inline void operator delete (void *ptr)
{
pool.remove ((cselib_val *) ptr);
}
/* Memory allocation pool. */
static pool_allocator<cselib_val> pool;
}; };
/* A list of rtl expressions that hold the same value. */ /* A list of rtl expressions that hold the same value. */
...@@ -50,6 +66,21 @@ struct elt_loc_list { ...@@ -50,6 +66,21 @@ struct elt_loc_list {
rtx loc; rtx loc;
/* The insn that made the equivalence. */ /* The insn that made the equivalence. */
rtx_insn *setting_insn; rtx_insn *setting_insn;
/* Pool allocation new operator. */
inline void *operator new (size_t)
{
return pool.allocate ();
}
/* Delete operator utilizing pool allocation. */
inline void operator delete (void *ptr)
{
pool.remove ((elt_loc_list *) ptr);
}
/* Memory allocation pool. */
static pool_allocator<elt_loc_list> pool;
}; };
/* Describe a single set that is part of an insn. */ /* Describe a single set that is part of an insn. */
......
...@@ -180,6 +180,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -180,6 +180,7 @@ along with GCC; see the file COPYING3. If not see
#include "except.h" #include "except.h"
#include "ggc.h" #include "ggc.h"
#include "params.h" #include "params.h"
#include "alloc-pool.h"
#include "cselib.h" #include "cselib.h"
#include "intl.h" #include "intl.h"
#include "obstack.h" #include "obstack.h"
......
...@@ -63,6 +63,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -63,6 +63,7 @@ along with GCC; see the file COPYING3. If not see
#include "basic-block.h" #include "basic-block.h"
#include "reload.h" #include "reload.h"
#include "recog.h" #include "recog.h"
#include "alloc-pool.h"
#include "cselib.h" #include "cselib.h"
#include "diagnostic-core.h" #include "diagnostic-core.h"
#include "except.h" #include "except.h"
......
...@@ -52,6 +52,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -52,6 +52,7 @@ along with GCC; see the file COPYING3. If not see
#include "basic-block.h" #include "basic-block.h"
#include "diagnostic.h" #include "diagnostic.h"
#include "tree-pretty-print.h" #include "tree-pretty-print.h"
#include "alloc-pool.h"
#include "cselib.h" #include "cselib.h"
#include "dumpfile.h" /* for dump_flags */ #include "dumpfile.h" /* for dump_flags */
#include "dwarf2out.h" #include "dwarf2out.h"
......
...@@ -40,6 +40,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -40,6 +40,7 @@ along with GCC; see the file COPYING3. If not see
#include "insn-config.h" #include "insn-config.h"
#include "insn-attr.h" #include "insn-attr.h"
#include "params.h" #include "params.h"
#include "alloc-pool.h"
#include "cselib.h" #include "cselib.h"
#include "target.h" #include "target.h"
......
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