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]

Re: [new-regalloc] Problem on x86 with initialization of ra_reg_info


Actually, I found that the problem that was holding me up was
that in make_worklist the code clears a bit at a time while traversing
the set. This doesn't work, as the traversing code assumes a constant
datastructure. It is also not necessary, as we can just clean the
set at once at the end, as we'll reset all bits anyway.

I added a patch for this at the end. This patch also includes a
static debug_msg routine that does the debug output if necessary.
I'd really like to use this instead of having all if-statements,
as they hurt readability of otherwise very readable code.

  -Geert

Index: new-regalloc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/new-regalloc.c,v
retrieving revision 1.1.2.11
diff -c -r1.1.2.11 new-regalloc.c
*** new-regalloc.c	2001/02/02 06:01:14	1.1.2.11
--- new-regalloc.c	2001/02/03 00:42:48
***************
*** 176,181 ****
--- 176,183 ----
  	}						\
    } while (0)
  
+ static void debug_msg PARAMS ((int, const char * , ...)) ATTRIBUTE_PRINTF_2;
+ 
  /* XXX:Extra regset routine, move into bitmap.c??? */
  static int regset_first_set_bit PARAMS((regset));
  
***************
*** 514,519 ****
--- 516,544 ----
  /* Whether to use biased coloring or not */
  static int biased_coloring = 0;
  
+ /* Print a message to the dump file, if debug_new_regalloc the
+    same or greater than the specified level. */
+ 
+ static void
+ debug_msg VPARAMS ((int level, const char *format, ...))
+ {
+ #ifndef ANSI_PROTOTYPES
+   int level;
+   const char *format;
+ #endif
+   va_list ap;
+   if (debug_new_regalloc >= level && rtl_dump_file != NULL)
+     {
+       VA_START (ap, format);
+ 
+ #ifndef ANSI_PROTOTYPES
+       format = va_arg (ap, const char *);
+ #endif
+ 
+       vfprintf (rtl_dump_file, format, ap);
+       va_end (ap);
+     }
+ }
  
  
  static int
***************
*** 687,726 ****
  
  /* Make the worklists from the inital set of candidates.  */
  static void
! make_worklist (set)
!      regset set;
  {
!   unsigned int entry;
! 
!   EXECUTE_IF_SET_IN_REG_SET (set, 0, entry,
!     {
!       unsigned int reg_num = entry;
  
!       /* Remove it from the initial set */
!       CLEAR_REGNO_REG_SET (set, entry);
  
        /* If it's of significant degree, place it on the spill_worklist.  */
        if (ra_reg_info[reg_num]->degree >= reg_freedom (reg_num))
  	{
! 	  if (rtl_dump_file != NULL && debug_new_regalloc > 1)
! 	    fprintf (rtl_dump_file, "Inserting %d onto spill_worklist\n", reg_num);
  	  SET_REGNO_REG_SET (spill_worklist, reg_num);
  	}
        /* If it's move related, put it on the freeze worklist.  */
        else if (move_related (reg_num))
  	{
! 	  if (rtl_dump_file != NULL && debug_new_regalloc > 1)
! 	    fprintf (rtl_dump_file, "Inserting %d onto freeze_worklist\n", reg_num);
  	  SET_REGNO_REG_SET (freeze_worklist, reg_num);
  	}
        /* Otherwise, put it on the simplify worklist.  */
        else
  	{
! 	  if (rtl_dump_file != NULL && debug_new_regalloc > 1)
! 	    fprintf (rtl_dump_file, "Inserting %d onto simplify_worklist\n", reg_num);
  	  SET_REGNO_REG_SET (simplify_worklist, reg_num);
  	}
      });
  }
  
  /* Returns 1 if the varray contains the register reg_num.  */
--- 712,748 ----
  
  /* Make the worklists from the inital set of candidates.  */
  static void
! make_worklist (initial)
!      regset initial;
  {
!   unsigned int reg_num;
  
!   /* Loop over all candidates in the initial set, starting with 0, 
!      setting reg_num to the register number and executing the block.  */
  
+   EXECUTE_IF_SET_IN_REG_SET (initial, 0, reg_num,
+     {
        /* If it's of significant degree, place it on the spill_worklist.  */
        if (ra_reg_info[reg_num]->degree >= reg_freedom (reg_num))
  	{
! 	  debug_msg (2, "Inserting %d onto spill_worklist\n", reg_num);
  	  SET_REGNO_REG_SET (spill_worklist, reg_num);
  	}
        /* If it's move related, put it on the freeze worklist.  */
        else if (move_related (reg_num))
  	{
! 	  debug_msg (2, "Inserting %d onto freeze_worklist\n", reg_num);
  	  SET_REGNO_REG_SET (freeze_worklist, reg_num);
  	}
        /* Otherwise, put it on the simplify worklist.  */
        else
  	{
! 	  debug_msg (2, "Inserting %d onto simplify_worklist\n", reg_num);
  	  SET_REGNO_REG_SET (simplify_worklist, reg_num);
  	}
      });
+ 
+   CLEAR_REG_SET (initial);
  }
  
  /* Returns 1 if the varray contains the register reg_num.  */




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