This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Add first_block and last_block to loops structure V2



Hi
This patch implements the searching of first and last basic block of loop
using new sbitmap functions first_set_bit and last_set_bit instead of
using new loop structure fields as sugested by Michael.

Fri Jan  7 19:48:04 CET 2000  Jan Hubicka  <jh@suse.cz>
	* sbitmap.c (sbitmap_first_set_bit, sbitmap_last_set_bit): New function.
	* sbitmap.h (sbitmap_first_set_bit, sbitmap_last_set_bit): Declare.
	* basic_block.h (FLOW_LOOP_FIRST_BLOCK): New macro.
	(FLOW_LOOP_LAST_BLOCK): Likewise.

*** sbitmap.c.old	Fri Jan  7 19:45:48 2000
--- sbitmap.c	Fri Jan  7 19:42:51 2000
*************** sbitmap_union_of_preds (dst, src, bb)
*** 497,502 ****
--- 497,540 ----
      }
  }
  
+ /* Return number of first bit set in the bitmap, -1 if none.  */
+ 
+ int
+ sbitmap_first_set_bit (bmap)
+      sbitmap bmap;
+ {
+   int n;
+   EXECUTE_IF_SET_IN_SBITMAP (bmap, 0, n, { return n; });
+   return -1;
+ }
+ 
+ /* Return number of last bit set in the bitmap, -1 if none.  */
+ 
+ int
+ sbitmap_last_set_bit (bmap)
+      sbitmap bmap;
+ {
+   int i;
+   SBITMAP_ELT_TYPE *ptr = bmap->elms;
+   for (i = bmap->size - 1; i >= 0; i--)
+     {
+       SBITMAP_ELT_TYPE word = ptr[i];
+       if (word)
+ 	{
+ 	  int index = (i + 1) * SBITMAP_ELT_BITS - 1;
+ 	  SBITMAP_ELT_TYPE mask = (SBITMAP_ELT_TYPE) 1 << (SBITMAP_ELT_BITS - 1);
+ 	  while (1)
+ 	    {
+ 	      if (word & mask)
+ 		return index;
+ 	      mask >>= 1;
+ 	      index--;
+ 	    }
+ 	}
+     }
+   return -1;
+ }
+ 
  void
  dump_sbitmap (file, bmap)
       FILE *file;
*** basic-block.h.noi	Thu Dec 30 04:57:00 1999
--- basic-block.h	Fri Jan  7 19:37:00 2000
*************** extern int flow_loops_find PROTO ((struc
*** 309,314 ****
--- 313,320 ----
  extern void flow_loops_free PROTO ((struct loops *));
  extern void flow_loops_dump PROTO ((const struct loops *, FILE *, int));
  
+ #define FLOW_LOOP_FIRST_BLOCK(loop) sbitmap_first_set_bit ((loop).nodes)
+ #define FLOW_LOOP_LAST_BLOCK(loop) sbitmap_last_set_bit ((loop).nodes)
  
  /* This structure maintains an edge list vector.  */
  struct edge_list 
*** sbitmap.h.old	Fri Jan  7 19:46:04 2000
--- sbitmap.h	Fri Jan  7 18:58:31 2000
*************** extern int sbitmap_a_and_b PROTO ((sbitm
*** 114,119 ****
--- 114,122 ----
  extern int sbitmap_a_or_b PROTO ((sbitmap, sbitmap, sbitmap));
  extern int sbitmap_a_subset_b_p PROTO ((sbitmap, sbitmap));
  
+ extern int sbitmap_first_set_bit PROTO ((sbitmap));
+ extern int sbitmap_last_set_bit PROTO ((sbitmap));
+ 
  struct int_list;
  extern void sbitmap_intersect_of_predsucc PROTO ((sbitmap, sbitmap *,
  						  int, struct int_list **));

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]