On Wed, Jul 19, 2006 at 02:12:09PM +0100, Saajan Singh Chana wrote:
> I have defined GO_IF_LEGITIMATE_ADDRESS() to only accept indexed
> addresses where the index is HImode,
I was trying to get you to copy and paste your definition og
GO_IF_LEGITIMATE_ADDRESS() into your message. :-)
> and then LEGITIMIZE_ADDRESS to replace SImode index registers
> with a subreg.
I don't think you can do that. (plus:SI (reg:SI <index>) (reg:SI <base)) is a
different address than (plus:SI (zero_extend:SI (subreg:HI (reg:SI <index>)
0)) (reg:SI <base>)) unless you can somehow prove that the index fits inside
16 bits. Here's an example where you can't:
int foo (int *base, unsigned long int index)
{
return (base[index]);
}
> This sometimes causes
> ICEs in emit_move_insn or copy_to_mode_reg because the mode of the index
> register is different to the mode of the PLUS or the MULT.
> I'll try using a zero_extend as you suggested.
Btw, I suppose you might see things like
(mem:XX (plus:SI (zero_extend:SI (subreg:HI (reg:SI <index>)) 0)
(reg:SI <base>)))
as well as
(mem:XX (plus:SI (zero_extend:SI (reg:HI <index>))
(reg:SI <base>)))
and I think GO_IF_LEGITIMATE_ADDRESS() should accept either form. You'd see
the former before the reload pass and the latter both after and before
reload.
(Does GCC ever use (truncate:HI (reg:SI ...)) instead of
(subreg:HI (reg:SI ...) 0 )? Just wondering.)
> What is the advantage of using PSImode? As far as I can see there is
> nothing which specifies how many bits are actually used, so it would
> seem to be treated the same as SImode. The target machine doesn't have
> special instructions for manipulating 24-bit pointers, all pointer moves
> and arithmetic are done with 32-bit instructions.
OK, use SImode.
--
Rask Ingemann Lambertsen