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]

[PATCH] Make ssa_uses array useful



This patch makes ssa.c fill in the ssa_uses.

Instead of an INSN_LIST, which is what the person who wrote this
intended to originally use, we use a bitmap, setting the bits
corresponding to the INSN_UID's.

An INSN_LIST doesn't seem to make much sense, since we have functions
to run through all set bits, bitmap sizes aren't fixed ahead of time,
etc.  

I think I caught all the places we need to set the uses.

I also added code to dump the definitions and uses to the dump file.

It depends on the bitmap.[ch] patch that was approved a few weeks ago,
but that i haven't committed yet (Will do today at some point).

 2001-05-07  Daniel Berlin  <dan@cgsoftware.com>
 
 	* ssa.c (rename_insn_1): Mark the normal insns we use this register in,
 	in ssa_uses, when we do the renaming.
 	(rename_block): Do the same for the uses in phi nodes, here.
 	(rename_registers): ssa_uses is a VARRAY of bitmaps now, so
	initialize it as one, and allocate the memory for the bitmaps.
 	(convert_from_ssa): And free the the memory for the ssa_uses
 	varray bitmaps here.
 	(convert_to_ssa): Dump the SSA definitions and uses, to the dump file.
        
        * ssa.h: Update comment on what ssa_uses is.

Index: ssa.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/ssa.c,v
retrieving revision 1.26
diff -c -3 -p -w -B -b -r1.26 ssa.c
*** ssa.c	2001/04/13 16:34:41	1.26
--- ssa.c	2001/05/07 19:39:26
*************** rename_insn_1 (ptr, data)
*** 941,946 ****
--- 941,947 ----
  	      if (GET_MODE (x) != GET_MODE (new_reg))
  		abort ();
  	      *ptr = new_reg;
+ 	      bitmap_set_bit (VARRAY_BITMAP (ssa_uses, REGNO (new_reg)), INSN_UID (context->current_insn));
  	    }
  	  /* Else this is a use before a set.  Warn?  */
  	}
*************** rename_insn_1 (ptr, data)
*** 962,967 ****
--- 963,969 ----
  		rtx new_reg = ssa_rename_to_lookup (dest);
  		if (new_reg != NULL_RTX && new_reg != RENAME_NO_RTX)
  		    XCEXP (x, 0, CLOBBER) = new_reg;
+ 		bitmap_set_bit (VARRAY_BITMAP (ssa_uses, REGNO (new_reg)), INSN_UID (context->current_insn));
  	      }
  	    /* Stop traversing.  */
  	    return -1;
*************** rename_block (bb, idom)
*** 1084,1090 ****
  		abort();
  
  	      *phi_alternative (phi, bb) = reg;
! 	      /* ??? Mark for a new ssa_uses entry.  */
  	    }
  
  	  insn = NEXT_INSN (insn);
--- 1086,1092 ----
  		abort();
  
  	      *phi_alternative (phi, bb) = reg;
! 	      bitmap_set_bit (VARRAY_BITMAP (ssa_uses, REGNO (reg)), INSN_UID (insn));
  	    }
  
  	  insn = NEXT_INSN (insn);
*************** rename_registers (nregs, idom)
*** 1123,1130 ****
       int nregs;
       int *idom;
  {
    VARRAY_RTX_INIT (ssa_definition, nregs * 3, "ssa_definition");
!   VARRAY_RTX_INIT (ssa_uses, nregs * 3, "ssa_uses");
    ssa_rename_from_initialize ();
  
    ssa_rename_to_pseudo = (rtx *) alloca (nregs * sizeof(rtx));
--- 1125,1138 ----
       int nregs;
       int *idom;
  {
+   int i;
    VARRAY_RTX_INIT (ssa_definition, nregs * 3, "ssa_definition");
!   VARRAY_BITMAP_INIT (ssa_uses, nregs * 3, "ssa_uses");
!   for  (i = FIRST_PSEUDO_REGISTER; i < nregs * 3; i++)
!     {
!       VARRAY_BITMAP (ssa_uses, i) = BITMAP_XMALLOC();
!       bitmap_zero (VARRAY_BITMAP (ssa_uses, i));
!     }
    ssa_rename_from_initialize ();
  
    ssa_rename_to_pseudo = (rtx *) alloca (nregs * sizeof(rtx));
*************** convert_to_ssa ()
*** 1216,1221 ****
--- 1224,1253 ----
  
    rename_registers (nregs, idom);
  
+   if (rtl_dump_file)
+     {
+       unsigned int i;
+       fprintf (rtl_dump_file, "SSA definitions:\n");
+       for (i = FIRST_PSEUDO_REGISTER; i < VARRAY_SIZE (ssa_definition); i++)
+ 	{
+ 	  if (VARRAY_RTX (ssa_definition, i) != NULL_RTX)
+ 	    {
+ 	      fprintf (rtl_dump_file, "Register %d:", i);
+ 	      print_rtl_single (rtl_dump_file, VARRAY_RTX (ssa_definition, i));
+ 	      fprintf (rtl_dump_file, "\n");
+ 	    }
+ 	}
+       fprintf (rtl_dump_file, "SSA uses:\n");
+       for (i = FIRST_PSEUDO_REGISTER; i < VARRAY_SIZE (ssa_uses); i++)
+ 	{
+ 	  if (bitmap_first_set_bit (VARRAY_BITMAP (ssa_uses, i)) != -1)
+ 	    {
+ 	      fprintf (rtl_dump_file, "Register %d:", i);
+ 	      debug_bitmap_file (rtl_dump_file, VARRAY_BITMAP (ssa_uses, i));
+ 	      fprintf (rtl_dump_file, "\n");
+ 	    }
+ 	}
+     }
    /* All done!  Clean up and go home.  */
  
    sbitmap_vector_free (dfs);
*************** void
*** 2152,2157 ****
--- 2184,2190 ----
  convert_from_ssa()
  {
    int bb;
+   unsigned int i;
    partition reg_partition;
    rtx insns = get_insns ();
  
*************** convert_from_ssa()
*** 2222,2227 ****
--- 2255,2262 ----
  
    /* Deallocate the data structures.  */
    VARRAY_FREE (ssa_definition);
+   for (i = FIRST_PSEUDO_REGISTER; i < VARRAY_SIZE (ssa_uses); i++)
+     BITMAP_XFREE (VARRAY_BITMAP (ssa_uses, i));
    VARRAY_FREE (ssa_uses);
    ssa_rename_from_free ();
  }
Index: ssa.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/ssa.h,v
retrieving revision 1.1
diff -r1.1 ssa.h
42c42
< /* Element I is an INSN_LIST of instructions that use register I.  */
---
> /* Element I is an bitmap of insns that use register I.  */

-- 
"I've never seen electricity, so I don't pay for it.  I write
right on the bill, "I'm sorry, I haven't seen it all month."
"-Steven Wright


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