From: Martin Liska Date: Mon, 1 Jun 2015 12:35:20 +0000 (+0200) Subject: Change use to type-based pool allocator in lra.c. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2f77a6072cccc1520dd609ac48cafda69a76832b;p=gcc.git Change use to type-based pool allocator in lra.c. * 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. From-SVN: r223945 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index be5ce2a69ce..10b6a107b6a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2015-06-01 Martin Liska + + * 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 * lra-lives.c (free_live_range): Use new type-based pool allocator. diff --git a/gcc/lra-int.h b/gcc/lra-int.h index 42e4a5445d5..25bd3cefd81 100644 --- a/gcc/lra-int.h +++ b/gcc/lra-int.h @@ -84,6 +84,22 @@ struct lra_copy 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 pool; + }; /* Common info about a register (pseudo or hard register). */ @@ -191,6 +207,21 @@ struct lra_insn_reg 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 pool; }; /* Static part (common info for insns with the same ICODE) of LRA diff --git a/gcc/lra.c b/gcc/lra.c index 7440668d69a..456f618203d 100644 --- a/gcc/lra.c +++ b/gcc/lra.c @@ -550,15 +550,7 @@ lra_update_dups (lra_insn_recog_data_t id, signed char *nops) 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::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 @@ -570,9 +562,7 @@ new_insn_reg (rtx_insn *insn, int regno, enum op_type type, 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) @@ -585,13 +575,6 @@ new_insn_reg (rtx_insn *insn, int regno, enum op_type type, 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) @@ -601,7 +584,7 @@ free_insn_regs (struct lra_insn_reg *ir) for (; ir != NULL; ir = next_ir) { next_ir = ir->next; - free_insn_reg (ir); + delete ir; } } @@ -609,7 +592,7 @@ free_insn_regs (struct lra_insn_reg *ir) static void finish_insn_regs (void) { - free_alloc_pool (insn_reg_pool); + lra_insn_reg::pool.release (); } @@ -737,7 +720,6 @@ init_insn_recog_data (void) { lra_insn_recog_data_len = 0; lra_insn_recog_data = NULL; - init_insn_regs (); } /* Expand, if necessary, LRA data about insns. */ @@ -791,6 +773,8 @@ finish_insn_recog_data (void) 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); } @@ -1310,7 +1294,7 @@ get_new_reg_value (void) } /* Pools for copies. */ -static alloc_pool copy_pool; +pool_allocator lra_copy::pool ("lra copies", 100); /* Vec referring to pseudo copies. */ static vec copy_vec; @@ -1350,8 +1334,6 @@ init_reg_info (void) 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); } @@ -1366,8 +1348,6 @@ finish_reg_info (void) 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. */ @@ -1394,7 +1374,7 @@ lra_free_copies (void) { cp = copy_vec.pop (); lra_reg_info[cp->regno1].copies = lra_reg_info[cp->regno2].copies = NULL; - pool_free (copy_pool, cp); + delete cp; } } @@ -1416,7 +1396,7 @@ lra_create_copy (int regno1, int regno2, int freq) 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; @@ -1585,7 +1565,7 @@ invalidate_insn_data_regno_info (lra_insn_recog_data_t data, rtx_insn *insn, { 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) {