Minor reload cleanup

Jeffrey A Law law@cygnus.com
Sat Oct 16 23:45:00 GMT 1999


I extracted this from Bernd's recent patch.  There's no reason not to go
ahead and get reload_mode & reload_nregs moved into struct reload.

	* reload.h (struct reload): Add new fields "mode" and "nregs".
	* reload1.c: Change all occurrences of reload_mode and reload_nregs
	to reference the "mode" and "nregs" field within struct reload.

Index: reload.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/reload.h,v
retrieving revision 1.18
diff -c -3 -p -r1.18 reload.h
*** reload.h	1999/09/12 14:54:55	1.18
--- reload.h	1999/10/17 06:43:40
*************** struct reload
*** 99,104 ****
--- 99,110 ----
    /* The mode this operand should have when reloaded, on output.  */
    enum machine_mode outmode;
  
+   /* The mode of the reload register.  */
+   enum mode;
+ 
+   /* the largest number of registers this reload will require.  */
+   int nregs;
+ 
    /* Positive amount to increment or decrement by if
       reload_in is a PRE_DEC, PRE_INC, POST_DEC, POST_INC.
       Ignored otherwise (don't assume it is zero).  */
Index: reload1.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/reload1.c,v
retrieving revision 1.170
diff -c -3 -p -r1.170 reload1.c
*** reload1.c	1999/10/13 06:48:26	1.170
--- reload1.c	1999/10/17 06:43:57
*************** forget_old_reloads_1 (x, ignored)
*** 4508,4519 ****
        reg_last_reload_reg[regno + nr] = 0;
  }
  
- /* For each reload, the mode of the reload register.  */
- static enum machine_mode reload_mode[MAX_RELOADS];
- 
- /* For each reload, the largest number of registers it will require.  */
- static int reload_nregs[MAX_RELOADS];
- 
  /* Comparison function for qsort to decide which of two reloads
     should be handled first.  *P1 and *P2 are the reload numbers.  */
  
--- 4508,4513 ----
*************** reload_reg_class_lower (r1p, r2p)
*** 4537,4543 ****
      return t;
  
    /* Aside from solitaires, consider all multi-reg groups first.  */
!   t = reload_nregs[r2] - reload_nregs[r1];
    if (t != 0)
      return t;
  
--- 4531,4537 ----
      return t;
  
    /* Aside from solitaires, consider all multi-reg groups first.  */
!   t = rld[r2].nregs - rld[r1].nregs;
    if (t != 0)
      return t;
  
*************** clear_reload_reg_in_use (regno, opnum, t
*** 4748,4754 ****
  	      int conflict_start = true_regnum (rld[i].reg_rtx);
  	      int conflict_end
  		= (conflict_start
! 		   + HARD_REGNO_NREGS (conflict_start, reload_mode[i]));
  
  	      /* If there is an overlap with the first to-be-freed register,
  		 adjust the interval start.  */
--- 4742,4748 ----
  	      int conflict_start = true_regnum (rld[i].reg_rtx);
  	      int conflict_end
  		= (conflict_start
! 		   + HARD_REGNO_NREGS (conflict_start, rld[i].mode));
  
  	      /* If there is an overlap with the first to-be-freed register,
  		 adjust the interval start.  */
*************** allocate_reload_reg (chain, r, last_relo
*** 5400,5406 ****
       Perhaps those classes should be avoided for reloading
       by use of more alternatives.  */
  
!   int force_group = reload_nregs[r] > 1 && ! last_reload;
  
    /* If we want a single register and haven't yet found one,
       take any reg in the right class and not in use.
--- 5394,5400 ----
       Perhaps those classes should be avoided for reloading
       by use of more alternatives.  */
  
!   int force_group = rld[r].nregs > 1 && ! last_reload;
  
    /* If we want a single register and haven't yet found one,
       take any reg in the right class and not in use.
*************** allocate_reload_reg (chain, r, last_relo
*** 5453,5459 ****
  						   rld[r].in,
  						   rld[r].out, r, 1)))
  	      && TEST_HARD_REG_BIT (reg_class_contents[class], regnum)
! 	      && HARD_REGNO_MODE_OK (regnum, reload_mode[r])
  	      /* Look first for regs to share, then for unshared.  But
  		 don't share regs used for inherited reloads; they are
  		 the ones we want to preserve.  */
--- 5447,5453 ----
  						   rld[r].in,
  						   rld[r].out, r, 1)))
  	      && TEST_HARD_REG_BIT (reg_class_contents[class], regnum)
! 	      && HARD_REGNO_MODE_OK (regnum, rld[r].mode)
  	      /* Look first for regs to share, then for unshared.  But
  		 don't share regs used for inherited reloads; they are
  		 the ones we want to preserve.  */
*************** allocate_reload_reg (chain, r, last_relo
*** 5463,5474 ****
  		      && ! TEST_HARD_REG_BIT (reload_reg_used_for_inherit,
  					      regnum))))
  	    {
! 	      int nr = HARD_REGNO_NREGS (regnum, reload_mode[r]);
  	      /* Avoid the problem where spilling a GENERAL_OR_FP_REG
  		 (on 68000) got us two FP regs.  If NR is 1,
  		 we would reject both of them.  */
  	      if (force_group)
! 		nr = CLASS_MAX_NREGS (rld[r].class, reload_mode[r]);
  	      /* If we need only one reg, we have already won.  */
  	      if (nr == 1)
  		{
--- 5457,5468 ----
  		      && ! TEST_HARD_REG_BIT (reload_reg_used_for_inherit,
  					      regnum))))
  	    {
! 	      int nr = HARD_REGNO_NREGS (regnum, rld[r].mode);
  	      /* Avoid the problem where spilling a GENERAL_OR_FP_REG
  		 (on 68000) got us two FP regs.  If NR is 1,
  		 we would reject both of them.  */
  	      if (force_group)
! 		nr = CLASS_MAX_NREGS (rld[r].class, rld[r].mode);
  	      /* If we need only one reg, we have already won.  */
  	      if (nr == 1)
  		{
*************** allocate_reload_reg (chain, r, last_relo
*** 5517,5537 ****
  
    new = spill_reg_rtx[i];
  
!   if (new == 0 || GET_MODE (new) != reload_mode[r])
      spill_reg_rtx[i] = new
!       = gen_rtx_REG (reload_mode[r], spill_regs[i]);
  
    regno = true_regnum (new);
  
    /* Detect when the reload reg can't hold the reload mode.
       This used to be one `if', but Sequent compiler can't handle that.  */
!   if (HARD_REGNO_MODE_OK (regno, reload_mode[r]))
      {
        enum machine_mode test_mode = VOIDmode;
        if (rld[r].in)
  	test_mode = GET_MODE (rld[r].in);
        /* If rld[r].in has VOIDmode, it means we will load it
! 	 in whatever mode the reload reg has: to wit, reload_mode[r].
  	 We have already tested that for validity.  */
        /* Aside from that, we need to test that the expressions
  	 to reload from or into have modes which are valid for this
--- 5511,5531 ----
  
    new = spill_reg_rtx[i];
  
!   if (new == 0 || GET_MODE (new) != rld[r].mode)
      spill_reg_rtx[i] = new
!       = gen_rtx_REG (rld[r].mode, spill_regs[i]);
  
    regno = true_regnum (new);
  
    /* Detect when the reload reg can't hold the reload mode.
       This used to be one `if', but Sequent compiler can't handle that.  */
!   if (HARD_REGNO_MODE_OK (regno, rld[r].mode))
      {
        enum machine_mode test_mode = VOIDmode;
        if (rld[r].in)
  	test_mode = GET_MODE (rld[r].in);
        /* If rld[r].in has VOIDmode, it means we will load it
! 	 in whatever mode the reload reg has: to wit, rld[r].mode.
  	 We have already tested that for validity.  */
        /* Aside from that, we need to test that the expressions
  	 to reload from or into have modes which are valid for this
*************** allocate_reload_reg (chain, r, last_relo
*** 5547,5553 ****
  	    /* Mark as in use for this insn the reload regs we use
  	       for this.  */
  	    mark_reload_reg_in_use (spill_regs[i], rld[r].opnum,
! 				    rld[r].when_needed, reload_mode[r]);
  
  	    rld[r].reg_rtx = new;
  	    reload_spill_index[r] = spill_regs[i];
--- 5541,5547 ----
  	    /* Mark as in use for this insn the reload regs we use
  	       for this.  */
  	    mark_reload_reg_in_use (spill_regs[i], rld[r].opnum,
! 				    rld[r].when_needed, rld[r].mode);
  
  	    rld[r].reg_rtx = new;
  	    reload_spill_index[r] = spill_regs[i];
*************** choose_reload_regs (chain)
*** 5682,5697 ****
        reload_order[j] = j;
        reload_spill_index[j] = -1;
  
!       reload_mode[j] = ((rld[j].inmode == VOIDmode
! 			 || (GET_MODE_SIZE (rld[j].outmode)
! 			     > GET_MODE_SIZE (rld[j].inmode)))
! 			? rld[j].outmode : rld[j].inmode);
  
!       reload_nregs[j] = CLASS_MAX_NREGS (rld[j].class, reload_mode[j]);
  
!       if (reload_nregs[j] > 1)
  	{
! 	  max_group_size = MAX (reload_nregs[j], max_group_size);
  	  group_class = reg_class_superunion[(int)rld[j].class][(int)group_class];
  	}
  
--- 5676,5691 ----
        reload_order[j] = j;
        reload_spill_index[j] = -1;
  
!       rld[j].mode = ((rld[j].inmode == VOIDmode
! 		      || (GET_MODE_SIZE (rld[j].outmode)
! 			  > GET_MODE_SIZE (rld[j].inmode)))
! 		     ? rld[j].outmode : rld[j].inmode);
  
!       rld[j].nregs = CLASS_MAX_NREGS (rld[j].class, rld[j].mode);
  
!       if (rld[j].nregs > 1)
  	{
! 	  max_group_size = MAX (rld[j].nregs, max_group_size);
  	  group_class = reg_class_superunion[(int)rld[j].class][(int)group_class];
  	}
  
*************** choose_reload_regs (chain)
*** 5700,5706 ****
  	 don't use it in another way.  */
        if (rld[j].reg_rtx)
  	mark_reload_reg_in_use (REGNO (rld[j].reg_rtx), rld[j].opnum,
! 				rld[j].when_needed, reload_mode[j]);
      }
  
    if (n_reloads > 1)
--- 5694,5700 ----
  	 don't use it in another way.  */
        if (rld[j].reg_rtx)
  	mark_reload_reg_in_use (REGNO (rld[j].reg_rtx), rld[j].opnum,
! 				rld[j].when_needed, rld[j].mode);
      }
  
    if (n_reloads > 1)
*************** choose_reload_regs (chain)
*** 5882,5888 ****
  		       >= GET_MODE_SIZE (mode) + word * UNITS_PER_WORD)
  		      && reg_reloaded_contents[i] == regno
  		      && TEST_HARD_REG_BIT (reg_reloaded_valid, i)
! 		      && HARD_REGNO_MODE_OK (i, reload_mode[r])
  		      && (TEST_HARD_REG_BIT (reg_class_contents[(int) class], i)
  			  /* Even if we can't use this register as a reload
  			     register, we might use it for reload_override_in,
--- 5876,5882 ----
  		       >= GET_MODE_SIZE (mode) + word * UNITS_PER_WORD)
  		      && reg_reloaded_contents[i] == regno
  		      && TEST_HARD_REG_BIT (reg_reloaded_valid, i)
! 		      && HARD_REGNO_MODE_OK (i, rld[r].mode)
  		      && (TEST_HARD_REG_BIT (reg_class_contents[(int) class], i)
  			  /* Even if we can't use this register as a reload
  			     register, we might use it for reload_override_in,
*************** choose_reload_regs (chain)
*** 5901,5907 ****
  #endif
  			      ))
  
! 		      && (reload_nregs[r] == max_group_size
  			  || ! TEST_HARD_REG_BIT (reg_class_contents[(int) group_class],
  						  i))
  		      && reload_reg_free_for_value_p (i, rld[r].opnum,
--- 5895,5901 ----
  #endif
  			      ))
  
! 		      && (rld[r].nregs == max_group_size
  			  || ! TEST_HARD_REG_BIT (reg_class_contents[(int) group_class],
  						  i))
  		      && reload_reg_free_for_value_p (i, rld[r].opnum,
*************** choose_reload_regs (chain)
*** 5912,5918 ****
  		      /* If a group is needed, verify that all the subsequent
  			 registers still have their values intact.  */
  		      int nr
! 			= HARD_REGNO_NREGS (i, reload_mode[r]);
  		      int k;
  
  		      for (k = 1; k < nr; k++)
--- 5906,5912 ----
  		      /* If a group is needed, verify that all the subsequent
  			 registers still have their values intact.  */
  		      int nr
! 			= HARD_REGNO_NREGS (i, rld[r].mode);
  		      int k;
  
  		      for (k = 1; k < nr; k++)
*************** choose_reload_regs (chain)
*** 5953,5959 ****
  				  && rld[r].out)
  			      /* Don't really use the inherited spill reg
  				 if we need it wider than we've got it.  */
! 			      || (GET_MODE_SIZE (reload_mode[r])
  				  > GET_MODE_SIZE (mode))
  			      || ! TEST_HARD_REG_BIT (reg_class_contents[(int) rld[r].class],
  						      i)
--- 5947,5953 ----
  				  && rld[r].out)
  			      /* Don't really use the inherited spill reg
  				 if we need it wider than we've got it.  */
! 			      || (GET_MODE_SIZE (rld[r].mode)
  				  > GET_MODE_SIZE (mode))
  			      || ! TEST_HARD_REG_BIT (reg_class_contents[(int) rld[r].class],
  						      i)
*************** choose_reload_regs (chain)
*** 5978,5984 ****
  			      mark_reload_reg_in_use (i,
  						      rld[r].opnum,
  						      rld[r].when_needed,
! 						      reload_mode[r]);
  			      rld[r].reg_rtx = last_reg;
  			      reload_inherited[r] = 1;
  			      reload_inheritance_insn[r]
--- 5972,5978 ----
  			      mark_reload_reg_in_use (i,
  						      rld[r].opnum,
  						      rld[r].when_needed,
! 						      rld[r].mode);
  			      rld[r].reg_rtx = last_reg;
  			      reload_inherited[r] = 1;
  			      reload_inheritance_insn[r]
*************** choose_reload_regs (chain)
*** 6002,6008 ****
  		  || GET_CODE (rld[r].in) == PLUS
  		  || GET_CODE (rld[r].in) == REG
  		  || GET_CODE (rld[r].in) == MEM)
! 	      && (reload_nregs[r] == max_group_size
  		  || ! reg_classes_intersect_p (rld[r].class, group_class)))
  	    search_equiv = rld[r].in;
  	  /* If this is an output reload from a simple move insn, look
--- 5996,6002 ----
  		  || GET_CODE (rld[r].in) == PLUS
  		  || GET_CODE (rld[r].in) == REG
  		  || GET_CODE (rld[r].in) == MEM)
! 	      && (rld[r].nregs == max_group_size
  		  || ! reg_classes_intersect_p (rld[r].class, group_class)))
  	    search_equiv = rld[r].in;
  	  /* If this is an output reload from a simple move insn, look
*************** choose_reload_regs (chain)
*** 6021,6027 ****
  	    {
  	      register rtx equiv
  		= find_equiv_reg (search_equiv, insn, rld[r].class,
! 				  -1, NULL_PTR, 0, reload_mode[r]);
  	      int regno = 0;
  
  	      if (equiv != 0)
--- 6015,6021 ----
  	    {
  	      register rtx equiv
  		= find_equiv_reg (search_equiv, insn, rld[r].class,
! 				  -1, NULL_PTR, 0, rld[r].mode);
  	      int regno = 0;
  
  	      if (equiv != 0)
*************** choose_reload_regs (chain)
*** 6035,6041 ****
  			 address and not all machines support SUBREGs
  			 there.  */
  		      regno = REGNO (SUBREG_REG (equiv)) + SUBREG_WORD (equiv);
! 		      equiv = gen_rtx_REG (reload_mode[r], regno);
  		    }
  		  else
  		    abort ();
--- 6029,6035 ----
  			 address and not all machines support SUBREGs
  			 there.  */
  		      regno = REGNO (SUBREG_REG (equiv)) + SUBREG_WORD (equiv);
! 		      equiv = gen_rtx_REG (rld[r].mode, regno);
  		    }
  		  else
  		    abort ();
*************** choose_reload_regs (chain)
*** 6053,6059 ****
  					      regno)))
  		equiv = 0;
  
! 	      if (equiv != 0 && ! HARD_REGNO_MODE_OK (regno, reload_mode[r]))
  		equiv = 0;
  
  	      /* We found a register that contains the value we need.
--- 6047,6053 ----
  					      regno)))
  		equiv = 0;
  
! 	      if (equiv != 0 && ! HARD_REGNO_MODE_OK (regno, rld[r].mode))
  		equiv = 0;
  
  	      /* We found a register that contains the value we need.
*************** choose_reload_regs (chain)
*** 6101,6107 ****
  		 to load it, and use it as our reload reg.  */
  	      if (equiv != 0 && regno != HARD_FRAME_POINTER_REGNUM)
  		{
! 		  int nr = HARD_REGNO_NREGS (regno, reload_mode[r]);
  		  int k;
  		  rld[r].reg_rtx = equiv;
  		  reload_inherited[r] = 1;
--- 6095,6101 ----
  		 to load it, and use it as our reload reg.  */
  	      if (equiv != 0 && regno != HARD_FRAME_POINTER_REGNUM)
  		{
! 		  int nr = HARD_REGNO_NREGS (regno, rld[r].mode);
  		  int k;
  		  rld[r].reg_rtx = equiv;
  		  reload_inherited[r] = 1;
*************** choose_reload_regs (chain)
*** 6121,6127 ****
  			{
  			  mark_reload_reg_in_use (regno, rld[r].opnum,
  						  rld[r].when_needed,
! 						  reload_mode[r]);
  			  SET_HARD_REG_BIT (reload_reg_used_for_inherit,
  					    regno + k);
  			}
--- 6115,6121 ----
  			{
  			  mark_reload_reg_in_use (regno, rld[r].opnum,
  						  rld[r].when_needed,
! 						  rld[r].mode);
  			  SET_HARD_REG_BIT (reload_reg_used_for_inherit,
  					    regno + k);
  			}
*************** choose_reload_regs (chain)
*** 6158,6164 ****
  	      if ((rld[s].class != rld[r].class
  		   && reg_classes_intersect_p (rld[r].class,
  					       rld[s].class))
! 		  || reload_nregs[s] < reload_nregs[r])
  		break;
  	    }
  
--- 6152,6158 ----
  	      if ((rld[s].class != rld[r].class
  		   && reg_classes_intersect_p (rld[r].class,
  					       rld[s].class))
! 		  || rld[s].nregs < rld[r].nregs)
  		break;
  	    }
  
*************** choose_reload_regs (chain)
*** 6307,6313 ****
  
  	if (spill_reg_order[regno] >= 0)
  	  clear_reload_reg_in_use (regno, rld[j].opnum,
! 				   rld[j].when_needed, reload_mode[j]);
  	rld[j].reg_rtx = 0;
        }
  
--- 6301,6307 ----
  
  	if (spill_reg_order[regno] >= 0)
  	  clear_reload_reg_in_use (regno, rld[j].opnum,
! 				   rld[j].when_needed, rld[j].mode);
  	rld[j].reg_rtx = 0;
        }
  
*************** choose_reload_regs (chain)
*** 6328,6341 ****
  	  int nr = 1;
  
  	  if (nregno < FIRST_PSEUDO_REGISTER)
! 	    nr = HARD_REGNO_NREGS (nregno, reload_mode[r]);
  
  	  while (--nr >= 0)
  	    reg_has_output_reload[nregno + nr] = 1;
  
  	  if (i >= 0)
  	    {
! 	      nr = HARD_REGNO_NREGS (i, reload_mode[r]);
  	      while (--nr >= 0)
  		SET_HARD_REG_BIT (reg_is_output_reload, i + nr);
  	    }
--- 6322,6335 ----
  	  int nr = 1;
  
  	  if (nregno < FIRST_PSEUDO_REGISTER)
! 	    nr = HARD_REGNO_NREGS (nregno, rld[r].mode);
  
  	  while (--nr >= 0)
  	    reg_has_output_reload[nregno + nr] = 1;
  
  	  if (i >= 0)
  	    {
! 	      nr = HARD_REGNO_NREGS (i, rld[r].mode);
  	      while (--nr >= 0)
  		SET_HARD_REG_BIT (reg_is_output_reload, i + nr);
  	    }
*************** deallocate_reload_reg (r)
*** 6362,6368 ****
    rld[r].reg_rtx = 0;
    if (spill_reg_order[regno] >= 0)
      clear_reload_reg_in_use (regno, rld[r].opnum, rld[r].when_needed,
! 			     reload_mode[r]);
    reload_spill_index[r] = -1;
  }
  
--- 6356,6362 ----
    rld[r].reg_rtx = 0;
    if (spill_reg_order[regno] >= 0)
      clear_reload_reg_in_use (regno, rld[r].opnum, rld[r].when_needed,
! 			     rld[r].mode);
    reload_spill_index[r] = -1;
  }
  
*************** emit_reload_insns (chain)
*** 7640,7646 ****
  		  && REGNO (src_reg) < FIRST_PSEUDO_REGISTER)
  		{
  		  int src_regno = REGNO (src_reg);
! 		  int nr = HARD_REGNO_NREGS (src_regno, reload_mode[r]);
  		  /* The place where to find a death note varies with
  		     PRESERVE_DEATH_INFO_REGNO_P .  The condition is not
  		     necessarily checked exactly in the code that moves
--- 7634,7640 ----
  		  && REGNO (src_reg) < FIRST_PSEUDO_REGISTER)
  		{
  		  int src_regno = REGNO (src_reg);
! 		  int nr = HARD_REGNO_NREGS (src_regno, rld[r].mode);
  		  /* The place where to find a death note varies with
  		     PRESERVE_DEATH_INFO_REGNO_P .  The condition is not
  		     necessarily checked exactly in the code that moves





More information about the Gcc-patches mailing list