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]

Re: RFA: new reload macro: MODE_BASE_REG_CLASS


> Hi Guys,
> 
>   I would like to obtain permission to apply the following patch.  It
>   creates a new macro for use by reload.  This macro, called
>   MODE_BASE_REG_CLASS is a variant of the current BASE_REG_CLASS macro
>   except that it allows the selection of the base register class in a
>   mode dependent fashion.
> 
>   The patch was created by Bernd Schmidt some time ago, and I have
>   recently found that it is needed by the ARM port in order to fix
>   some code generation problems when it is running in THUMB mode.  In
>   particular for the Thumb, the stack pointer is a valid base register
>   for SI mode quantities but not QI or HI mode quantities.
> 
>   This patch fixes several unexpected failures in the gcc testsuite
>   when running in the Thumb mode.
> 
>   OK to apply ?

Some places in the patch pass VOIDmode as the argument:

> 
>   	      case 'p':
>   		/* All necessary reloads for an address_operand
>   		   were handled in find_reloads_address.  */
> ! 		this_alternative[i] = (int) MODE_BASE_REG_CLASS (VOIDmode);
>   		win = 1;
>   		break;
>   

But the documentation doesn't say what that means:

> + @findex MODE_BASE_REG_CLASS
> + @item MODE_BASE_REG_CLASS (@var{mode})
> + This is a variation of the @code{BASE_REG_CLASS} macro which allows
> + the selection of a base register in a mode depenedent manner.
> + 

That seems perverse.  If the class of registers is going to be dependent 
on the mode, then we really need to know the mode, or we can't do anything 
useful unless we have some common sub-class that satisfies all constraints.

> + /* For the Thumb the high registers cannot be used as base
> +    registers when addressing quanitities in QI or HI mode.  */
> + #define MODE_BASE_REG_CLASS(MODE)		\
> +     (TARGET_ARM ? BASE_REGS :			\
> +      (((MODE) != QImode && (MODE) != HImode)	\
> +      ? BASE_REGS : LO_REGS))
> + 

This implementation returns BASE_REGS for VOIDmode.  Given the above, I 
think it should return LO_REGS (the common sub-class).

R.


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