Hello,

I have a doubt here about define_expand and would be appreciated for
your any help. The internals say,
Usually these statements prepare temporary registers for use as
internal operands in the RTL template, but they can also generate RTL
insns directly by calling routines such as emit_insn, etc. Any such
insns precede the ones that come from the RTL template.

Well, here is the codes from mips_legitimize_move function in mips.c.
  if (!register_operand (dest, mode) && !register_operand (src, mode))
    {
      emit_move_insn (dest, force_reg (mode, src));
      return true;
    }
Here is from mips.md,
(define_expand "movsi"
  [(set (match_operand:SI 0 "nonimmediate_operand" "")
        (match_operand:SI 1 "" ""))]
  ""
{
  if (mips_legitimize_move (SImode, operands[0], operands[1]))
    DONE;
  ...
}

I think the function is to guarantee that there is at least one
register operand.
So if it's not, it will firstly load src into a register. But I think
it will be enough
for the function to just load src into a register. That is to say the
code should
be
if (!register_operand (dest, mode) && !register_operand (src, mode))
    {
      src=force_reg (mode, src);
      return true;
    }
I think since emit_move_insn (dest, force_reg (mode, src)) precedes
the rtl template
[(set (match_operand:SI 0 "nonimmediate_operand" "")
        (match_operand:SI 1 "" ""))]
Then they are overlapped. There will be two move insns.

Thanks.
Eric.

Reply via email to