diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2004-11-22 12:23:59 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2004-11-22 12:23:59 +0000 |
commit | 7932a3db217873015c39424cdad931e0234be710 (patch) | |
tree | bb82fde51c2f61d86523137794f8e94bac6c2fb2 /gcc/bitmap.c | |
parent | e99f332f05fbe3e18d628a91cb363dc67047e19f (diff) | |
download | gcc-7932a3db217873015c39424cdad931e0234be710.zip gcc-7932a3db217873015c39424cdad931e0234be710.tar.gz gcc-7932a3db217873015c39424cdad931e0234be710.tar.bz2 |
bitmap.h (struct bitmap_obstack): New obstack type.
* bitmap.h (struct bitmap_obstack): New obstack type.
(struct bitmap_head_def): Replace using_obstack with obstack
pointer.
(bitmap_default_obstack): New.
(bitmap_initialize): Make inline, does not do allocation.
(bitmap_release_memory): Remove.
(bitmap_obstack_initialize, bitmap_obstack_release): Declare.
(bitmap_obstack_alloc, bitmap_malloc_alloc, bitmap_gc_alloc,
bitmap_obstack_free, bitmap_malloc_free): Declare.
(BITMAP_OBSTACK_ALLOC, BITMAP_GGC_ALLOC, BITMAP_XMALLOC): Adjust.
(BITMAP_FREE): Replace with ...
(BITMAP_OBSTACK_FREE): ... this.
(BITMAP_XFREE): Adjust.
(BITMAP_INIT_ONCE): Remove.
* bitmap.c (bitmap_obstack, bitmap_obstack_init, bitmap_free: Remove.
(bitmap_default_obstack): New.
(bitmap_elem_to_freelist): Adjust.
(bitmap_element_allocate): Adjust. Break initialization into ...
(bitmap_obstack_initialize): ... here.
(bitmap_release_memory): Replace with ...
(bitmap_obstack_release): ... this.
(bitmap_obstack_alloc, bitmap_malloc_alloc, bitmap_gc_alloc,
bitmap_obstack_free, bitmap_malloc_free): New.
(bitmap_ior_and_compl, bitmap_ior_and_compl_into): Use
bitmap_initialize.
(bitmap_initialize): Move to bitmap.h.
* gengtype.c (open_base_files): Add obstack.h to ifiles.
* Makefile.in (BASIC_BLOCK_H, REGS_H): Add obstack.h.
* basic-block.h (INIT_REG_SET): Allocate from reg_obstack.
(INITIALIZE_REG_SET): Remove.
(FREE_REG_SET): Use BITMAP_OBSTACK_FREE.
(INIT_ONCE_REG_SET, MAX_REGNO_REG_SET): Remove.
(flow_obstack): Do not declare.
(reg_obstack): Declare.
* regs.h: Include obstack.h.
* tree-optimize.c (tree_rest_of_compilation): Initialize and
release bitmap obstack here.
* bb-reorder.c: #include regs, not basic-block.
(fix_crossing_conditional_branches): Allocate regsets from
reg_obstack.
* bt-load.c: Do not inlude bitmap.h, sbitmap.h, basic-block.h or
obstack.h.
* caller-save.c: Include regs.h earlier.
* cfg.c: Do not include basic-block.h or obstack.h.
(reg_obstack): Define.
* cfganal.c: Include obstack.h
* cfgcleanyp.c: Do not include basic-block.h. Include regs.h
earlier.
* cfglayout.c: Do not include obstack.h.
(flow_obstack): Remove declaration.
(cfg_layout_duplicate_bb): Use reg_obstack.
* cfgloop.c, cfgloopanal.c, cfgloopmanip.c: Include obstack.h.
* cfgrtl.c (rtl_split_block): Use reg_obstack.
(force_nonfallthru_and_redirect, rtl_split_edge): Likewise.
(safe_insert_insn_on_edge): Use OBSTACK_ALLOC_REG_SET, adjust.
(cfg_layout_split_edge): Use reg_obstack.
* cse.c: Include regs.h earlier.
* ddg.c: Do not include basic-block.h.
* dominance.c: Inlude obstack.h.
* flow.c (update_life_info): Use OBSTACK_ALLOC_REG_SET, adjust.
(calculate_global_regs_live): Likewise.
(allocate_bb_life_data): Use reg_obstack.
(init_propagate_block_info): Use OBSTACK_ALLOC_REGSET.
* global.c: Do not include basic-block.h.
(build_insn_chain): Use OBSTACK_ALLOC_REG_SET, adjust.
* graph.c: Include obstack.h.
* haifa-sched.c: Do not include basic-block.h.
* ifcvt.c: Use OBSTACK_ALLOC_REG_SET, adjust.
* local-alloc.c: Do not include basic-block.h.
* loop-init.c, loop-invariant.c: Include obstack.h.
* loop-iv.c: Likewise.
(simplify_using_initial_values): Use OBSTACK_ALLOC_REG_SET,
adjust.
* loop-unroll.c, loop-unswitch.c: Inlude obstack.h.
* modulo-sched.c: Do not include basic-block.h.
* passes.c (rest_of_handle_final): Do not call
regset_release_memory.
* ra-debug.c: Include regs.h earlier. Do not include
basic-block.h.
* recog.c (peephole2_optimize): Use OBSTACK_ALLOC_REG_SET, adjust.
* regclass.c (init_reg_sets): Do not call INIT_ONCE_REG_SET.
(allocate_reg_info): Do not call MAX_REGNO_REG_SET.
(regset_release_memory): Remove.
* resource.c: Do not include basic-block.h.
* rtlanal.c: Do not include basic-block.h.
* sbitmap.c: Include obstack.h.
* sched-deps.c: Do not include basic-block.h.
(reg_pending_sets_head, reg_pending_clobbers_head,
reg_pending_uses_head): Remove.
(init_deps_global): Use OBSTACK_ALLOC_REG_SET.
* sched-ebb.c: Do not include basic-block.h.
* sched-rgn.c: Likewise.
* tree-if-conv.c (get_loop_body_in_if_conv_order): Use
BITMAP_XFREE.
* tree-outof-ssa.c (perform_edge_inserts): Use BITMAP_XFREE.
* tree-sra.c (decide_instantiations): Adjust bitmap
initialization.
* tree-ssa-dce.c: Include obstack.h.
* tree-ssa-pre.c (grand_bitmap_obstack): Make a bitmap_obstack.
(value_insert_into_set_bitmap): Remove useless bitmap_clear.
(bitmap_set_new): Likewise.
(init_pre): Initialize bitmap obstack.
(fini_pre): Release bitmap obstack.
* tree-ssanames.c (ssa_names_to_rewrite): Make static.
(marked_for_rewrite_p): ssa_names_to_rewrite is never NULL.
(mark_for_rewrite, unmark_for_rewrite): Likewise.
(marked_ssa_names): Likewise.
(init_ssanames): Use BITMAP_XMALLOC.
(fini_ssanames): Use BITMAP_XFREE.
* web.c: Include obstack.h
From-SVN: r91009
Diffstat (limited to 'gcc/bitmap.c')
-rw-r--r-- | gcc/bitmap.c | 246 |
1 files changed, 149 insertions, 97 deletions
diff --git a/gcc/bitmap.c b/gcc/bitmap.c index 6ab194f..68b8429 100644 --- a/gcc/bitmap.c +++ b/gcc/bitmap.c @@ -30,8 +30,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "bitmap.h" /* Obstack to allocate bitmap elements from. */ -static struct obstack bitmap_obstack; -static int bitmap_obstack_init = FALSE; #ifndef INLINE #ifndef __GNUC__ @@ -42,9 +40,10 @@ static int bitmap_obstack_init = FALSE; #endif /* Global data */ -bitmap_element bitmap_zero_bits; /* An element of all zero bits. */ -static bitmap_element *bitmap_free; /* Freelist of bitmap elements. */ -static GTY((deletable)) bitmap_element *bitmap_ggc_free; +bitmap_element bitmap_zero_bits; /* An element of all zero bits. */ +bitmap_obstack bitmap_default_obstack; /* The default bitmap obstack. */ +static GTY((deletable)) bitmap_element *bitmap_ggc_free; /* Freelist of + GC'd elements. */ static void bitmap_elem_to_freelist (bitmap, bitmap_element *); static void bitmap_element_free (bitmap, bitmap_element *); @@ -60,10 +59,12 @@ static bitmap_element *bitmap_find_bit (bitmap, unsigned int); static INLINE void bitmap_elem_to_freelist (bitmap head, bitmap_element *elt) { - if (head->using_obstack) + bitmap_obstack *bit_obstack = head->obstack; + + if (bit_obstack) { - elt->next = bitmap_free; - bitmap_free = elt; + elt->next = bit_obstack->elements; + bit_obstack->elements = elt; } else { @@ -107,43 +108,22 @@ static INLINE bitmap_element * bitmap_element_allocate (bitmap head) { bitmap_element *element; - - if (head->using_obstack) + bitmap_obstack *bit_obstack = head->obstack; + + if (bit_obstack) { - if (bitmap_free != 0) - { - element = bitmap_free; - bitmap_free = element->next; - } + element = bit_obstack->elements; + + if (element) + bit_obstack->elements = element->next; else - { - /* We can't use gcc_obstack_init to initialize the obstack since - print-rtl.c now calls bitmap functions, and bitmap is linked - into the gen* functions. */ - if (!bitmap_obstack_init) - { - bitmap_obstack_init = TRUE; - -#if !defined(__GNUC__) || (__GNUC__ < 2) -#define __alignof__(type) 0 -#endif - - obstack_specify_allocation (&bitmap_obstack, OBSTACK_CHUNK_SIZE, - __alignof__ (bitmap_element), - obstack_chunk_alloc, - obstack_chunk_free); - } - - element = XOBNEW (&bitmap_obstack, bitmap_element); - } + element = XOBNEW (&bit_obstack->obstack, bitmap_element); } else { - if (bitmap_ggc_free != NULL) - { - element = bitmap_ggc_free; - bitmap_ggc_free = element->next; - } + element = bitmap_ggc_free; + if (element) + bitmap_ggc_free = element->next; else element = GGC_NEW (bitmap_element); } @@ -153,19 +133,139 @@ bitmap_element_allocate (bitmap head) return element; } -/* Release any memory allocated by bitmaps. */ +/* Remove ELT and all following elements from bitmap HEAD. */ void -bitmap_release_memory (void) +bitmap_elt_clear_from (bitmap head, bitmap_element *elt) +{ + bitmap_element *next; + + while (elt) + { + next = elt->next; + bitmap_element_free (head, elt); + elt = next; + } +} + +/* Clear a bitmap by freeing the linked list. */ + +INLINE void +bitmap_clear (bitmap head) { - bitmap_free = 0; - if (bitmap_obstack_init) + bitmap_element *element, *next; + + for (element = head->first; element != 0; element = next) { - bitmap_obstack_init = FALSE; - obstack_free (&bitmap_obstack, NULL); + next = element->next; + bitmap_elem_to_freelist (head, element); } + + head->first = head->current = 0; +} + +/* Initialize a bitmap obstack. If BIT_OBSTACK is NULL, initialize + the default bitmap obstack. */ + +void +bitmap_obstack_initialize (bitmap_obstack *bit_obstack) +{ + if (!bit_obstack) + bit_obstack = &bitmap_default_obstack; + +#if !defined(__GNUC__) || (__GNUC__ < 2) +#define __alignof__(type) 0 +#endif + + bit_obstack->elements = NULL; + bit_obstack->heads = NULL; + obstack_specify_allocation (&bit_obstack->obstack, OBSTACK_CHUNK_SIZE, + __alignof__ (bitmap_element), + obstack_chunk_alloc, + obstack_chunk_free); } +/* Release the memory from a bitmap obstack. If BIT_OBSTACK is NULL, + release the default bitmap obstack. */ + +void +bitmap_obstack_release (bitmap_obstack *bit_obstack) +{ + if (!bit_obstack) + bit_obstack = &bitmap_default_obstack; + + bit_obstack->elements = NULL; + bit_obstack->heads = NULL; + obstack_free (&bit_obstack->obstack, NULL); +} + +/* Create a new bitmap on an obstack. If BIT_OBSTACK is NULL, create + it on the default bitmap obstack. */ + +bitmap +bitmap_obstack_alloc (bitmap_obstack *bit_obstack) +{ + bitmap map; + + if (!bit_obstack) + bit_obstack = &bitmap_default_obstack; + map = bit_obstack->heads; + if (map) + bit_obstack->heads = (void *)map->first; + else + map = XOBNEW (&bit_obstack->obstack, bitmap_head); + bitmap_initialize (map, bit_obstack); + + return map; +} + +/* Create a new GCd bitmap. */ + +bitmap +bitmap_gc_alloc (void) +{ + bitmap map; + + map = GGC_NEW (struct bitmap_head_def); + bitmap_initialize (map, NULL); + + return map; +} + +/* Create a new malloced bitmap. Elements will be allocated from the + default bitmap obstack. */ + +bitmap +bitmap_malloc_alloc (void) +{ + bitmap map; + + map = xmalloc (sizeof (bitmap_head)); + bitmap_initialize (map, &bitmap_default_obstack); + + return map; +} + +/* Release an obstack allocated bitmap. */ + +void +bitmap_obstack_free (bitmap map) +{ + bitmap_clear (map); + map->first = (void *)map->obstack->heads; + map->obstack->heads = map; +} + +/* Release a malloc allocated bitmap. */ + +void +bitmap_malloc_free (bitmap map) +{ + bitmap_clear (map); + free (map); +} + + /* Return nonzero if all bits in an element are zero. */ static INLINE int @@ -269,38 +369,6 @@ bitmap_elt_insert_after (bitmap head, bitmap_element *elt) } return node; } - -/* Remove ELT and all following elements from bitmap HEAD. */ - -void -bitmap_elt_clear_from (bitmap head, bitmap_element *elt) -{ - bitmap_element *next; - - while (elt) - { - next = elt->next; - bitmap_element_free (head, elt); - elt = next; - } -} - - -/* Clear a bitmap by freeing the linked list. */ - -INLINE void -bitmap_clear (bitmap head) -{ - bitmap_element *element, *next; - - for (element = head->first; element != 0; element = next) - { - next = element->next; - bitmap_elem_to_freelist (head, element); - } - - head->first = head->current = 0; -} /* Copy a bitmap to another bitmap. */ @@ -1065,9 +1133,8 @@ bitmap_ior_and_compl (bitmap dst, bitmap a, bitmap from1, bitmap from2) { bitmap_head tmp; bool changed; - - tmp.first = tmp.current = 0; - tmp.using_obstack = 0; + + bitmap_initialize (&tmp, &bitmap_default_obstack); bitmap_and_compl (&tmp, from1, from2); changed = bitmap_ior (dst, a, &tmp); bitmap_clear (&tmp); @@ -1083,8 +1150,7 @@ bitmap_ior_and_compl_into (bitmap a, bitmap from1, bitmap from2) bitmap_head tmp; bool changed; - tmp.first = tmp.current = 0; - tmp.using_obstack = 0; + bitmap_initialize (&tmp, &bitmap_default_obstack); bitmap_and_compl (&tmp, from1, from2); changed = bitmap_ior_into (a, &tmp); bitmap_clear (&tmp); @@ -1092,20 +1158,6 @@ bitmap_ior_and_compl_into (bitmap a, bitmap from1, bitmap from2) return changed; } -/* Initialize a bitmap header. */ - -bitmap -bitmap_initialize (bitmap head, int using_obstack) -{ - if (head == NULL && ! using_obstack) - head = GGC_NEW (struct bitmap_head_def); - - head->first = head->current = 0; - head->using_obstack = using_obstack; - - return head; -} - /* Debugging function to print out the contents of a bitmap. */ void |