aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2015-06-01 14:36:01 +0200
committerMartin Liska <marxin@gcc.gnu.org>2015-06-01 12:36:01 +0000
commit8b17d27f7661cc7376c6b12be514f1bc69191ff7 (patch)
tree35dccfcd3b05ecfa05fc52dd43102d9d99fe745d
parent2f77a6072cccc1520dd609ac48cafda69a76832b (diff)
downloadgcc-8b17d27f7661cc7376c6b12be514f1bc69191ff7.zip
gcc-8b17d27f7661cc7376c6b12be514f1bc69191ff7.tar.gz
gcc-8b17d27f7661cc7376c6b12be514f1bc69191ff7.tar.bz2
Change use to type-based pool allocator in ira-color.c.
* ira-color.c (init_update_cost_records):Use new type-based pool allocator. (get_update_cost_record) Likewise. (free_update_cost_record_list) Likewise. (finish_update_cost_records) Likewise. (initiate_cost_update) Likewise. From-SVN: r223946
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/ira-color.c34
2 files changed, 28 insertions, 14 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 10b6a10..d23503d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,13 @@
2015-06-01 Martin Liska <mliska@suse.cz>
+ * ira-color.c (init_update_cost_records):Use new type-based pool allocator.
+ (get_update_cost_record) Likewise.
+ (free_update_cost_record_list) Likewise.
+ (finish_update_cost_records) Likewise.
+ (initiate_cost_update) Likewise.
+
+2015-06-01 Martin Liska <mliska@suse.cz>
+
* lra.c (init_insn_regs): Use new type-based pool allocator.
(new_insn_reg) Likewise.
(free_insn_reg) Likewise.
diff --git a/gcc/ira-color.c b/gcc/ira-color.c
index 4750714..543440d 100644
--- a/gcc/ira-color.c
+++ b/gcc/ira-color.c
@@ -123,6 +123,21 @@ struct update_cost_record
int divisor;
/* Next record for given allocno. */
struct update_cost_record *next;
+
+ /* 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 ((update_cost_record *) ptr);
+ }
+
+ /* Memory allocation pool. */
+ static pool_allocator<update_cost_record> pool;
};
/* To decrease footprint of ira_allocno structure we store all data
@@ -1166,16 +1181,8 @@ setup_profitable_hard_regs (void)
allocnos. */
/* Pool for update cost records. */
-static alloc_pool update_cost_record_pool;
-
-/* Initiate update cost records. */
-static void
-init_update_cost_records (void)
-{
- update_cost_record_pool
- = create_alloc_pool ("update cost records",
- sizeof (struct update_cost_record), 100);
-}
+static pool_allocator<update_cost_record> update_cost_record_pool
+ ("update cost records", 100);
/* Return new update cost record with given params. */
static struct update_cost_record *
@@ -1184,7 +1191,7 @@ get_update_cost_record (int hard_regno, int divisor,
{
struct update_cost_record *record;
- record = (struct update_cost_record *) pool_alloc (update_cost_record_pool);
+ record = update_cost_record_pool.allocate ();
record->hard_regno = hard_regno;
record->divisor = divisor;
record->next = next;
@@ -1200,7 +1207,7 @@ free_update_cost_record_list (struct update_cost_record *list)
while (list != NULL)
{
next = list->next;
- pool_free (update_cost_record_pool, list);
+ update_cost_record_pool.remove (list);
list = next;
}
}
@@ -1209,7 +1216,7 @@ free_update_cost_record_list (struct update_cost_record *list)
static void
finish_update_cost_records (void)
{
- free_alloc_pool (update_cost_record_pool);
+ update_cost_record_pool.release ();
}
/* Array whose element value is TRUE if the corresponding hard
@@ -1264,7 +1271,6 @@ initiate_cost_update (void)
= (struct update_cost_queue_elem *) ira_allocate (size);
memset (update_cost_queue_elems, 0, size);
update_cost_check = 0;
- init_update_cost_records ();
}
/* Deallocate data used by function update_costs_from_copies. */