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]

new allocator: registers preferences



Sun Feb 25 22:14:13 2001  Denis Chertykov  <denisc@overta.ru>

	* ra.c (get_free_reg): Use preferred register order for selection.
	(colorize_one_web): Use call_used_reg_set as preference.
	(init_ra): arg,frame,stack pointers can use few hard regs.


Index: ra.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/Attic/ra.c,v
retrieving revision 1.1.2.5
diff -c -3 -p -r1.1.2.5 ra.c
*** ra.c	2001/02/24 03:33:57	1.1.2.5
--- ra.c	2001/02/25 19:20:42
*************** get_free_reg (free_colors, mode)
*** 2215,2221 ****
       enum machine_mode mode;
  {
    int c;
!   int last_resort = -1;
    for (c = 0; c < FIRST_PSEUDO_REGISTER; c++)
      if (TEST_HARD_REG_BIT (free_colors, c) && HARD_REGNO_MODE_OK (c, mode))
        {
--- 2215,2225 ----
       enum machine_mode mode;
  {
    int c;
!   int last_resort_reg = -1;
!   int pref_reg = -1;
!   int pref_reg_order = INT_MAX;
!   int last_resort_reg_order = INT_MAX;
!   
    for (c = 0; c < FIRST_PSEUDO_REGISTER; c++)
      if (TEST_HARD_REG_BIT (free_colors, c) && HARD_REGNO_MODE_OK (c, mode))
        {
*************** get_free_reg (free_colors, mode)
*** 2225,2238 ****
  	if (i == size)
  	  {
  	    if (size < 2 || (c & 1) == 0)
! 	      return c;
! 	    else if (last_resort < 0)
! 	      last_resort = c;
  	  }
  	else
  	  c += i;
        }
!   return last_resort;
  }
  
  /* Counts the number of non-overlapping bitblocks of length LEN
--- 2229,2251 ----
  	if (i == size)
  	  {
  	    if (size < 2 || (c & 1) == 0)
! 	      {
! 		if (inv_reg_alloc_order[c] < pref_reg_order)
! 		  {
! 		    pref_reg = c;
! 		    pref_reg_order = inv_reg_alloc_order[c];
! 		  }
! 	      }
! 	    else if (inv_reg_alloc_order[c] < last_resort_reg_order)
! 	      {
! 		last_resort_reg = c;
! 		last_resort_reg_order = inv_reg_alloc_order[c];
! 	      }
  	  }
  	else
  	  c += i;
        }
!   return pref_reg > 0 ? pref_reg : last_resort_reg;
  }
  
  /* Counts the number of non-overlapping bitblocks of length LEN
*************** colorize_one_web (web)
*** 2302,2320 ****
    while (1)
      {
        int long_blocks;
        if (web->use_my_regs)
  	COPY_HARD_REG_SET (colors, web->usable_regs);
        else
          COPY_HARD_REG_SET (colors,
  			   usable_regs[reg_preferred_class (web->regno)]);
        AND_COMPL_HARD_REG_SET (colors, conflict_colors);
!       c = get_free_reg (colors, PSEUDO_REGNO_MODE (web->regno));
        if (!web->use_my_regs && c < 0)
  	{
  	  IOR_HARD_REG_SET (colors, usable_regs
  			    [reg_alternate_class (web->regno)]);
  	  AND_COMPL_HARD_REG_SET (colors, conflict_colors);
! 	  c = get_free_reg (colors, PSEUDO_REGNO_MODE (web->regno));
  	}
        if (c < 0)
  	break;
--- 2315,2346 ----
    while (1)
      {
        int long_blocks;
+       HARD_REG_SET call_clobbered;
+ 	
        if (web->use_my_regs)
  	COPY_HARD_REG_SET (colors, web->usable_regs);
        else
          COPY_HARD_REG_SET (colors,
  			   usable_regs[reg_preferred_class (web->regno)]);
        AND_COMPL_HARD_REG_SET (colors, conflict_colors);
!       COPY_HARD_REG_SET (call_clobbered, colors);
!       AND_HARD_REG_SET (call_clobbered, call_used_reg_set);
! 
!       c = get_free_reg (call_clobbered, PSEUDO_REGNO_MODE (web->regno));
!       if (c < 0)
! 	c = get_free_reg (colors, PSEUDO_REGNO_MODE (web->regno));
!       
        if (!web->use_my_regs && c < 0)
  	{
  	  IOR_HARD_REG_SET (colors, usable_regs
  			    [reg_alternate_class (web->regno)]);
  	  AND_COMPL_HARD_REG_SET (colors, conflict_colors);
! 	  COPY_HARD_REG_SET (call_clobbered, colors);
! 	  AND_HARD_REG_SET (call_clobbered, call_used_reg_set);
! 	  
! 	  c = get_free_reg (call_clobbered, PSEUDO_REGNO_MODE (web->regno));
! 	  if (c < 0)
! 	    c = get_free_reg (colors, PSEUDO_REGNO_MODE (web->regno));
  	}
        if (c < 0)
  	break;
*************** init_ra (void)
*** 2722,2735 ****
    /* FIXME: Choose spill heuristic for platform if we have one */
    spill_heuristic = default_spill_heuristic;
  
!   CLEAR_HARD_REG_SET (never_use_colors);
!   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
!     if (fixed_regs[i]
! 	|| i == HARD_FRAME_POINTER_REGNUM
! 	|| i == STACK_POINTER_REGNUM
! 	|| i == FRAME_POINTER_REGNUM
! 	|| i == ARG_POINTER_REGNUM)
!       SET_HARD_REG_BIT (never_use_colors, i);
  	
    for (i = 0; i < N_REG_CLASSES; i++)
      {
--- 2748,2768 ----
    /* FIXME: Choose spill heuristic for platform if we have one */
    spill_heuristic = default_spill_heuristic;
  
!   COPY_HARD_REG_SET (never_use_colors, fixed_reg_set);
! 
! #if HARD_FRAME_POINTER_REGNUM != FRAME_POINTER_REGNUM
!   for (i = HARD_REGNO_NREGS (HARD_FRAME_POINTER_REGNUM, Pmode); i--;)
!     SET_HARD_REG_BIT (never_use_colors, HARD_FRAME_POINTER_REGNUM + i);
! #endif
! 
!   for (i = HARD_REGNO_NREGS (FRAME_POINTER_REGNUM, Pmode); i--;)
!     SET_HARD_REG_BIT (never_use_colors, FRAME_POINTER_REGNUM + i);
! 
!   for (i = HARD_REGNO_NREGS (STACK_POINTER_REGNUM, Pmode); i--;)
!     SET_HARD_REG_BIT (never_use_colors, STACK_POINTER_REGNUM + i);
! 
!   for (i = HARD_REGNO_NREGS (ARG_POINTER_REGNUM, Pmode); i--;)
!     SET_HARD_REG_BIT (never_use_colors, ARG_POINTER_REGNUM + i);
  	
    for (i = 0; i < N_REG_CLASSES; i++)
      {


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