This is the mail archive of the gcc@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: HARD_REGNO_MODE_OK_FOR_CLASS Might Be Nice (tm)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, Jan 03, 2006 at 05:25:55PM +0000, Joern RENNECKE wrote:
> In http://gcc.gnu.org/ml/gcc/2005-12/msg00642.html, Bernd Jendrissek
> wrote:
> > Which leads me to the subject.  Would it be a win to have a macro
> > HARD_REGNO_MODE_OK_FOR_CLASS (REGNO, MODE, CLASS) which would be the
> > authoritative test for this loop in find_reg()?  On my port, and I
> > imagine on many others too, I think a default
> >
> > #ifndef HARD_REGNO_MODE_OK_FOR_CLASS
> > #define HARD_REGNO_MODE_OK_FOR_CLASS(REGNO, MODE, CLASS) \
> >   HARD_REGNO_MODE_OK ((REGNO), (MODE))
> > #endif
> >
> > would be okay.
> 
> It's not that simple.  For example, consider multi-word integer arithmetic.
> If you want to allocate a 32 bit integer register on your 16 bit x86,
> all the integer registers are suitable as parts of the allocation.
> However, if you start with the last integer register, the second part
> will end up in a hard register which is not an integer register.
> So to make this work, you's have to say that the last integer register is
> not suitable for SImode, SFmode or CHImode, the last three ones are not
> suitable for DImode, DFmode, CSImode or SCmode etc.

That's true, but it's also true of HARD_REGNO_MODE_OK already, isn't it?

Maybe it's just a misunderstanding on my part but my definition for
HARD_REGNO_MODE_OK already excludes the last (2^N)-1 registers from
allocation to a integer of size N units.

But... for other ports, it would be a problem.  It *also* couldn't be

#ifndef HARD_REGNO_MODE_OK_FOR_CLASS
#define HARD_REGNO_MODE_OK_FOR_CLASS(REGNO, MODE, CLASS) \
  (HARD_REGNO_MODE_OK ((REGNO), (MODE))
   && HARD_REGNO_MODE_OK ((REGNO) + GET_MODE_SIZE ((MODE)) - 1, (MODE)))
#endif

since it would ignore boundaries between disjoint register classes which
it may be illegal to cross.

Hmm, how about this?

#ifndef HARD_REGNO_MODE_OK_FOR_CLASS
#define HARD_REGNO_MODE_OK_FOR_CLASS(REGNO, MODE, CLASS) \
  (HARD_REGNO_MODE_OK ((REGNO), (MODE))
   && REG_IN_CLASS_P ((REGNO), (CLASS))
   && HARD_REGNO_MODE_OK ((REGNO) + GET_MODE_SIZE ((MODE)) - 1, (MODE))
   && REG_IN_CLASS_P ((REGNO) + GET_MODE_SIZE ((MODE)) - 1, (CLASS)))
#endif

(Leaving REG_IN_CLASS_P as an exercise to the reader.)  This does assume
though that register classes consist of exactly one contiguous series of
registers.

Bleh, I think I'll just bite the bullet and use up all my remaining
constraint characters for now.

Thanks for the replies.

- -- 
"If you lie to the compiler, it will get its revenge." - Henry Spencer
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Please fetch my new key 804177F8 from hkp://wwwkeys.eu.pgp.net/

iD8DBQFDv7THwyMv24BBd/gRAsLBAJ0X6LQuBoWJfNoD2+lLDAXYzvM7LwCbByid
FFjZg0GAtEq8vmwbG6/nY7I=
=kEtK
-----END PGP SIGNATURE-----


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