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]
Other format: [Raw text]

Possible patch for sh CLASS_MAX_NREGS


I haven't seen this cause a failure, it's just something
I noticed while looking into a register allocation bug.
The sh definition of CLASS_MAX_NREGS is:

  #define CLASS_MAX_NREGS(CLASS, MODE) \
     ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)

which isn't right for FP classes when TARGET_SHMEDIA.

The patch below has survived a sh64-elf regression test
{-m5-compact,-m5-32media,-m5-64media}{,-fpic,-fPIC}{,-ml}.
But like I say, I can't claim it fixes anything.
OK to install anyway?  Or is it better to leave things be?

Richard


	* config/sh/sh.h (CLASS_MAX_NREGS): If TARGET_SHMEDIA, and the given
	class contains a floating-point register, return the size of the
	mode in half words.

Index: config/sh/sh.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sh/sh.h,v
retrieving revision 1.173
diff -c -d -p -F^[(a-zA-Z0-9_^#] -r1.173 sh.h
*** config/sh/sh.h	4 Nov 2002 16:57:11 -0000	1.173
--- config/sh/sh.h	15 Nov 2002 16:35:55 -0000
*************** #define SECONDARY_INPUT_RELOAD_CLASS(CLA
*** 1363,1371 ****
  /* Return the maximum number of consecutive registers
     needed to represent mode MODE in a register of class CLASS.
  
!    On SH this is the size of MODE in words.  */
  #define CLASS_MAX_NREGS(CLASS, MODE) \
!      ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
  
  /* If defined, gives a class of registers that cannot be used as the
     operand of a SUBREG that changes the mode of the object illegally.  */
--- 1363,1375 ----
  /* Return the maximum number of consecutive registers
     needed to represent mode MODE in a register of class CLASS.
  
!    If TARGET_SHMEDIA, we need two FP registers per word.
!    Otherwise we will need at most one register per word.  */
  #define CLASS_MAX_NREGS(CLASS, MODE) \
!     (TARGET_SHMEDIA \
!      && TEST_HARD_REG_BIT (reg_class_contents[CLASS], FIRST_FP_REG) \
!      ? (GET_MODE_SIZE (MODE) + UNITS_PER_WORD/2 - 1) / (UNITS_PER_WORD/2) \
!      : (GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
  
  /* If defined, gives a class of registers that cannot be used as the
     operand of a SUBREG that changes the mode of the object illegally.  */


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