diff options
author | meissner <meissner@138bc75d-0d04-0410-961f-82ee72b054a4> | 1997-09-04 15:12:20 +0000 |
---|---|---|
committer | meissner <meissner@138bc75d-0d04-0410-961f-82ee72b054a4> | 1997-09-04 15:12:20 +0000 |
commit | 23ec99a1993dd93385bd55a191fcefe643e9546a (patch) | |
tree | de700dc0cf119390613c23ee4b4497363513c8c2 | |
parent | c01db9d6a3df1551a2f994b2f2dad5e5842c55ff (diff) | |
download | gcc-23ec99a1993dd93385bd55a191fcefe643e9546a.tar.gz |
Add EXECUTE_IF_AND_IN_{BITMAP,REG_SET}, and bitmap_print
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@15071 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 17 | ||||
-rw-r--r-- | gcc/basic-block.h | 6 | ||||
-rw-r--r-- | gcc/bitmap.c | 74 | ||||
-rw-r--r-- | gcc/bitmap.h | 76 |
4 files changed, 163 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e77c1c6a30b..647f4f8d412 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,20 @@ +Thu Sep 4 11:04:21 1997 Michael Meissner <meissner@cygnus.com> + + * bitmap.h (EXECUTE_IF_AND_IN_BITMAP): New macro, to iterate over + two bitmaps ANDed together. + (bitmap_print): Declare. + + * bitmap.c (function_obstack): Don't declare any more. + (bitmap_obstack): Obstack for allocating links from. + (bitmap_obstack_init): New static to say whether to initialize + bitmap_obstack. + (bitmap_element_allocate): Use bitmap_obstack to allocate from. + (bitmap_release_memory): Free all memory allocated from + bitmap_obstack. + + * basic-block.h (EXECUTE_IF_AND_IN_REG_SET): New macro, invoke + EXECUTE_IF_AND_IN_BITMAP. + Wed Sep 3 10:39:42 1997 Jim Wilson <wilson@cygnus.com> * alias.c (true_dependence): Address with AND can alias scalars. diff --git a/gcc/basic-block.h b/gcc/basic-block.h index 4614b700380..c76d8507b7c 100644 --- a/gcc/basic-block.h +++ b/gcc/basic-block.h @@ -73,6 +73,12 @@ do { \ #define EXECUTE_IF_AND_COMPL_IN_REG_SET(REGSET1, REGSET2, MIN, REGNUM, CODE) \ EXECUTE_IF_AND_COMPL_IN_BITMAP (REGSET1, REGSET2, MIN, REGNUM, CODE) +/* Loop over all registers in REGSET1 and REGSET2, starting with MIN, setting + REGNUM to the register number and executing CODE for all registers that are + set in both regsets. */ +#define EXECUTE_IF_AND_IN_REG_SET(REGSET1, REGSET2, MIN, REGNUM, CODE) \ + EXECUTE_IF_AND_IN_BITMAP (REGSET1, REGSET2, MIN, REGNUM, CODE) + /* Allocate a register set with oballoc. */ #define OBSTACK_ALLOC_REG_SET(OBSTACK) BITMAP_OBSTACK_ALLOC (OBSTACK) diff --git a/gcc/bitmap.c b/gcc/bitmap.c index 0dec06ae82a..e2d61cd856f 100644 --- a/gcc/bitmap.c +++ b/gcc/bitmap.c @@ -26,12 +26,9 @@ Boston, MA 02111-1307, USA. */ #include "regs.h" #include "basic-block.h" -/* The contents of the current function definition are allocated - in this obstack, and all are freed at the end of the function. - For top-level functions, this is temporary_obstack. - Separate obstacks are made for nested functions. */ - -extern struct obstack *function_obstack; +/* Obstack to allocate bitmap elements from. */ +static struct obstack bitmap_obstack; +static int bitmap_obstack_init = FALSE; #ifndef INLINE @@ -95,8 +92,39 @@ bitmap_element_allocate (head) bitmap_free = element->next; } else - element = (bitmap_element *) obstack_alloc (function_obstack, - sizeof (bitmap_element)); + { + /* 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; + + /* Let particular systems override the size of a chunk. */ +#ifndef OBSTACK_CHUNK_SIZE +#define OBSTACK_CHUNK_SIZE 0 +#endif + /* Let them override the alloc and free routines too. */ +#ifndef OBSTACK_CHUNK_ALLOC +#define OBSTACK_CHUNK_ALLOC xmalloc +#endif +#ifndef OBSTACK_CHUNK_FREE +#define OBSTACK_CHUNK_FREE free +#endif + +#if !defined(__GNUC__) || (__GNUC__ < 2) +#define __alignof__(type) 0 +#endif + + obstack_specify_allocation (&bitmap_obstack, OBSTACK_CHUNK_SIZE, + __alignof__ (bitmap_element), + (void *(*) ()) OBSTACK_CHUNK_ALLOC, + (void (*) ()) OBSTACK_CHUNK_FREE); + } + + element = (bitmap_element *) obstack_alloc (&bitmap_obstack, + sizeof (bitmap_element)); + } #if BITMAP_ELEMENT_WORDS == 2 element->bits[0] = element->bits[1] = 0; @@ -573,11 +601,37 @@ debug_bitmap (head) bitmap_debug_file (stdout, head); } -/* Release any memory allocated by bitmaps. Since we allocate off of the - function_obstack, just zap the free list. */ +/* Function to print out the contents of a bitmap. Unlike bitmap_debug_file, + it does not print anything but the bits. */ + +void +bitmap_print (file, head, prefix, suffix) + FILE *file; + bitmap head; + char *prefix; + char *suffix; +{ + char *comma = ""; + int i; + + fputs (prefix, file); + EXECUTE_IF_SET_IN_BITMAP (head, 0, i, + { + fprintf (file, "%s%d", comma, i); + comma = ", "; + }); + fputs (suffix, file); +} + +/* Release any memory allocated by bitmaps. */ void bitmap_release_memory () { bitmap_free = 0; + if (bitmap_obstack_init) + { + bitmap_obstack_init = FALSE; + obstack_free (&bitmap_obstack, NULL_PTR); + } } diff --git a/gcc/bitmap.h b/gcc/bitmap.h index a01e398c287..343b24911c0 100644 --- a/gcc/bitmap.h +++ b/gcc/bitmap.h @@ -88,6 +88,9 @@ extern int bitmap_bit_p PROTO((bitmap, int)); extern void bitmap_debug PROTO((bitmap)); extern void bitmap_debug_file STDIO_PROTO((FILE *, bitmap)); +/* Print a bitmap */ +extern void bitmap_print STDIO_PROTO((FILE *, bitmap, char *, char *)); + /* Initialize a bitmap header. */ extern bitmap bitmap_initialize PROTO((bitmap)); @@ -237,3 +240,76 @@ do { \ word_num_ = 0; \ } \ } while (0) + +/* Loop over all bits in BITMAP1 and BITMAP2, starting with MIN, setting + BITNUM to the bit number and executing CODE for all bits that are set in + the both bitmaps. */ + +#define EXECUTE_IF_AND_IN_BITMAP(BITMAP1, BITMAP2, MIN, BITNUM, CODE) \ +do { \ + bitmap_element *ptr1_ = (BITMAP1)->first; \ + bitmap_element *ptr2_ = (BITMAP2)->first; \ + unsigned int indx_ = (MIN) / BITMAP_ELEMENT_ALL_BITS; \ + unsigned bit_num_ = (MIN) % ((unsigned) HOST_BITS_PER_WIDE_INT); \ + unsigned word_num_ = (((MIN) / ((unsigned) HOST_BITS_PER_WIDE_INT)) \ + % BITMAP_ELEMENT_WORDS); \ + \ + /* Find the block the minimum bit is in in the first bitmap. */ \ + while (ptr1_ != 0 && ptr1_->indx < indx_) \ + ptr1_ = ptr1_->next; \ + \ + if (ptr1_ != 0 && ptr1_->indx != indx_) \ + { \ + bit_num_ = 0; \ + word_num_ = 0; \ + } \ + \ + for (; ptr1_ != 0 ; ptr1_ = ptr1_->next) \ + { \ + /* Advance BITMAP2 to the equivalent link */ \ + while (ptr2_ != 0 && ptr2_->indx < ptr1_->indx) \ + ptr2_ = ptr2_->next; \ + \ + if (ptr2_ == 0) \ + { \ + /* If there are no more elements in BITMAP2, exit loop now.*/ \ + ptr1_ = (bitmap_element *)0; \ + break; \ + } \ + else if (ptr2_->indx > ptr1_->indx) \ + { \ + bit_num_ = word_num_ = 0; \ + continue; \ + } \ + \ + for (; word_num_ < BITMAP_ELEMENT_WORDS; word_num_++) \ + { \ + unsigned HOST_WIDE_INT word_ = (ptr1_->bits[word_num_] \ + & ptr2_->bits[word_num_]); \ + if (word_ != 0) \ + { \ + for (; bit_num_ < HOST_BITS_PER_WIDE_INT; bit_num_++) \ + { \ + unsigned HOST_WIDE_INT mask_ \ + = ((unsigned HOST_WIDE_INT)1) << bit_num_; \ + \ + if ((word_ & mask_) != 0) \ + { \ + word_ &= ~ mask_; \ + (BITNUM) = (ptr1_->indx * BITMAP_ELEMENT_ALL_BITS \ + + word_num_ * HOST_BITS_PER_WIDE_INT \ + + bit_num_); \ + \ + CODE; \ + if (word_ == 0) \ + break; \ + } \ + } \ + } \ + \ + bit_num_ = 0; \ + } \ + \ + word_num_ = 0; \ + } \ +} while (0) |