This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] Fix MIPS jalr(.hb) register checking
"David Daney" wrote:
> Fu, Chao-Ying wrote:
> [...]
> > if (regno == lastregno)
> > {
> > - insn_error = _("source and destinationations must be different");
> > + insn_error = _("source and destination must be different");
> > continue;
> > }
>
> I question why we are doing this check in the first place.
>
> The ISA manual says not to place the destination in the same register as
> the source because if you trap in the delay slot you want to be able to
> re-try the instruction.
>
> If the programmer *knows* that there will not be a trap, then they could
> use the same register. I don't think the assembler should prevent this.
>
> David Daney
>
From MIPS32 architecture for programmers volume II: the MIPS32 instruction
set:
"Restrictions:
Register specifiers rs and rd must not be equal, because such an instruction
does not have the same effect when reexecuted.
The result of executing such an instruction is UNPREDICTABLE. This
restriction permits an exception handler
to resume execution by re-executing the branch when an exception occurs in
the branch delay slot."
The original patch was added as follows. Maybe Catherine can explain why
she added it. Thanks!
2008-01-02 Catherine Moore <clm@codesourcery.com>
* config/tc-mips.c (mips_ip): Check operands on jalr instruction.
Regards,
Chao-ying