This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
HARD_REGNO_MODE_OK clarification.
- To: <gcc at gcc dot gnu dot org>
- Subject: HARD_REGNO_MODE_OK clarification.
- From: Michael Matz <matz at kde dot org>
- Date: Tue, 28 Aug 2001 22:05:33 +0200 (MET DST)
Hi,
Although the documentation for that macro is pretty clear:
"A C expression that is nonzero if it is permissible to store a value
of mode @var{mode} in hard register number @var{regno} (or in several
registers starting with that one)."
it contradicts itself, and also isn't implemented this way in some
machines:
* It contradicts itself:
"For a machine where all registers are equivalent, a suitable definition
is
#define HARD_REGNO_MODE_OK(REGNO, MODE) 1
"
Suppose we have N register, all equivalent. Say all are SImode wide.
According to the above statement I could define HARD_REGNO_MODE_OK to
1. Nonetheless register N-1 can _not_ hold a DImode, and
registers [N-3..N-1] can not hold TImode. Clearly HARD_REGNO_MODE_OK
can not simply be 1 in the light of multi hardreg modes.
* some machines don't implement it as documented:
take e.g. x86: HARD_REGNO_MODE_OK(6, DImode) returns 1. 6 is %ebp, and 7
is %esp, which is fixed, so there can't be a DImode value in hardreg 6.
Granted this is taken care of, because it wouldn't try allocating 6 to a
DImode, exactly because the next reg isn't free. What if %esp weren't
fixed? Then it would also return 1 for H_R_M_O(7,DImode), which reaches
into the floating point registers, so also there it isn't allowed.
So my, or our, question is: can we rely on the documented behaviour of
HARD_REGNO_MODE_OK(R,M), to detect if hardreg R is suitable for mode M,
given that the next HARD_REGNO_NREGS(R,M)-1 registers are free ? Do we
need to fix some ports, for this to happen?
Especially with wider modes M, and in case R lies near a border of
different register sets (the end of register set is easy, there the other
registers are free, because non-existant, but with in-between borders...)
Ciao,
Michael.