This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] MIPS: add mips32r2 patterns to generate ext andins insns.
On Thu, 2005-05-26 at 16:40 +0100, Richard Sandiford wrote:
> Nigel Stephens <nigel@mips.com> writes:
>
> > David Ung wrote:
> >
> >>+ bool
> >>+ mips_use_ins_ext_p (rtx op, rtx size, rtx position)
> >>+ {
> >>+ HOST_WIDE_INT len, pos;
> >> + + if (!ISA_HAS_EXT_INS
> >>+ || !register_operand (op, VOIDmode))
> >>+ return false;
> >> + + len = INTVAL (size);
> >>+ pos = INTVAL (position);
> >> + + if (len <= 0 || len >= BITS_PER_WORD || pos < 0
> >>+ || pos + len > BITS_PER_WORD)
> >>+ return false;
> >> +
> >>
> >
> > Looking at this go past, I wonder should that test be using
> > GET_MODE_BITSIZE (GET_MODE (op)) rather than BITS_PER_WORD?
>
> Good catch. Yes it should. And after that change, there should
> also be a check that GET_MODE_BITSIZE (GET_MODE (op)) <= BITS_PER_WORD.
>
> As it stands, I suppose this is just future-proofing. TARGET_64BIT is
> never true for mips32r2 anyway.
FYI, this is what its going to look like. re-running regressions.
David.
/* Return true if (zero_extract OP SIZE POSITION) can be used as the
source of an "ext" instruction or the destination of an "ins"
instruction. OP must be a register operand and the following
conditions must hold:
0 <= POSITION < GET_MODE_BITSIZE (GET_MODE (op))
0 < SIZE <= GET_MODE_BITSIZE (GET_MODE (op))
0 < POSITION + SIZE <= GET_MODE_BITSIZE (GET_MODE (op))
Also reject lengths equal to a word as they are better handled
by the move patterns. */
bool
mips_use_ins_ext_p (rtx op, rtx size, rtx position)
{
HOST_WIDE_INT len, pos;
if (!ISA_HAS_EXT_INS
|| !register_operand (op, VOIDmode)
|| GET_MODE_BITSIZE (GET_MODE (op)) > BITS_PER_WORD)
return false;
len = INTVAL (size);
pos = INTVAL (position);
if (len <= 0 || len >= GET_MODE_BITSIZE (GET_MODE (op))
|| pos < 0 || pos + len > GET_MODE_BITSIZE (GET_MODE (op)))
return false;
return true;
}