+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.
+ (free_insn_regs) Likewise.
+ (finish_insn_regs) Likewise.
+ (init_insn_recog_data) Likewise.
+ (init_reg_info) Likewise.
+ (finish_reg_info) Likewise.
+ (lra_free_copies) Likewise.
+ (lra_create_copy) Likewise.
+ (invalidate_insn_data_regno_info) Likewise.
+
2015-06-01 Martin Liska <mliska@suse.cz>
* lra-lives.c (free_live_range): Use new type-based pool allocator.
int regno1, regno2;
/* Next copy with correspondingly REGNO1 and REGNO2. */
lra_copy_t regno1_next, regno2_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 ((lra_copy *) ptr);
+ }
+
+ /* Memory allocation pool. */
+ static pool_allocator<lra_copy> pool;
+
};
/* Common info about a register (pseudo or hard register). */
int regno;
/* Next reg info of the same insn. */
struct lra_insn_reg *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 ((lra_insn_reg *) ptr);
+ }
+
+ /* Memory allocation pool. */
+ static pool_allocator<lra_insn_reg> pool;
};
/* Static part (common info for insns with the same ICODE) of LRA
insns. */
/* Pools for insn reg info. */
-static alloc_pool insn_reg_pool;
-
-/* Initiate pool for insn reg info. */
-static void
-init_insn_regs (void)
-{
- insn_reg_pool
- = create_alloc_pool ("insn regs", sizeof (struct lra_insn_reg), 100);
-}
+pool_allocator<lra_insn_reg> lra_insn_reg::pool ("insn regs", 100);
/* Create LRA insn related info about a reference to REGNO in INSN with
TYPE (in/out/inout), biggest reference mode MODE, flag that it is
machine_mode mode,
bool subreg_p, bool early_clobber, struct lra_insn_reg *next)
{
- struct lra_insn_reg *ir;
-
- ir = (struct lra_insn_reg *) pool_alloc (insn_reg_pool);
+ lra_insn_reg *ir = new lra_insn_reg ();
ir->type = type;
ir->biggest_mode = mode;
if (GET_MODE_SIZE (mode) > GET_MODE_SIZE (lra_reg_info[regno].biggest_mode)
return ir;
}
-/* Free insn reg info IR. */
-static void
-free_insn_reg (struct lra_insn_reg *ir)
-{
- pool_free (insn_reg_pool, ir);
-}
-
/* Free insn reg info list IR. */
static void
free_insn_regs (struct lra_insn_reg *ir)
for (; ir != NULL; ir = next_ir)
{
next_ir = ir->next;
- free_insn_reg (ir);
+ delete ir;
}
}
static void
finish_insn_regs (void)
{
- free_alloc_pool (insn_reg_pool);
+ lra_insn_reg::pool.release ();
}
\f
{
lra_insn_recog_data_len = 0;
lra_insn_recog_data = NULL;
- init_insn_regs ();
}
/* Expand, if necessary, LRA data about insns. */
if ((data = lra_insn_recog_data[i]) != NULL)
free_insn_recog_data (data);
finish_insn_regs ();
+ lra_copy::pool.release ();
+ lra_insn_reg::pool.release ();
free (lra_insn_recog_data);
}
}
/* Pools for copies. */
-static alloc_pool copy_pool;
+pool_allocator<lra_copy> lra_copy::pool ("lra copies", 100);
/* Vec referring to pseudo copies. */
static vec<lra_copy_t> copy_vec;
lra_reg_info = XNEWVEC (struct lra_reg, reg_info_size);
for (i = 0; i < reg_info_size; i++)
initialize_lra_reg_info_element (i);
- copy_pool
- = create_alloc_pool ("lra copies", sizeof (struct lra_copy), 100);
copy_vec.create (100);
}
bitmap_clear (&lra_reg_info[i].insn_bitmap);
free (lra_reg_info);
reg_info_size = 0;
- free_alloc_pool (copy_pool);
- copy_vec.release ();
}
/* Expand common reg info if it is necessary. */
{
cp = copy_vec.pop ();
lra_reg_info[cp->regno1].copies = lra_reg_info[cp->regno2].copies = NULL;
- pool_free (copy_pool, cp);
+ delete cp;
}
}
regno2 = regno1;
regno1 = temp;
}
- cp = (lra_copy_t) pool_alloc (copy_pool);
+ cp = new lra_copy ();
copy_vec.safe_push (cp);
cp->regno1_dest_p = regno1_dest_p;
cp->freq = freq;
{
i = ir->regno;
next_ir = ir->next;
- free_insn_reg (ir);
+ delete ir;
bitmap_clear_bit (&lra_reg_info[i].insn_bitmap, uid);
if (i >= FIRST_PSEUDO_REGISTER && ! debug_p)
{